From 76978dd5620b5664e68a3a4068d5bd07771fe7ea Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Tue, 17 Apr 2012 00:13:46 -0400 Subject: Fixes #4432: Do not escape ORDER BY/GROUP BY clauses in elgg_get_entities --- engine/lib/entities.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 4875b2c2f..7fe913888 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -915,11 +915,11 @@ function elgg_get_entities(array $options = array()) { } if (!$options['count']) { - if ($options['group_by'] = sanitise_string($options['group_by'])) { + if ($options['group_by']) { $query .= " GROUP BY {$options['group_by']}"; } - if ($options['order_by'] = sanitise_string($options['order_by'])) { + if ($options['order_by']) { $query .= " ORDER BY {$options['order_by']}"; } -- cgit v1.2.3 From 7e59ef7adec3b716aabc9c61c485ceb17e5d1f68 Mon Sep 17 00:00:00 2001 From: Jerome Bakker Date: Wed, 18 Apr 2012 15:06:00 +0200 Subject: fixes #3405 Memcache: fault in contructor can cause site to go into English language --- engine/classes/ElggMemcache.php | 6 +++--- languages/en.php | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggMemcache.php b/engine/classes/ElggMemcache.php index f27b017d0..d9539b9cb 100644 --- a/engine/classes/ElggMemcache.php +++ b/engine/classes/ElggMemcache.php @@ -40,7 +40,7 @@ class ElggMemcache extends ElggSharedMemoryCache { // Do we have memcache? if (!class_exists('Memcache')) { - throw new ConfigurationException(elgg_echo('memcache:notinstalled')); + throw new ConfigurationException('PHP memcache module not installed, you must install php5-memcache'); } // Create memcache object @@ -48,7 +48,7 @@ class ElggMemcache extends ElggSharedMemoryCache { // Now add servers if (!$CONFIG->memcache_servers) { - throw new ConfigurationException(elgg_echo('memcache:noservers')); + throw new ConfigurationException('No memcache servers defined, please populate the $CONFIG->memcache_servers variable'); } if (is_callable(array($this->memcache, 'addServer'))) { @@ -85,7 +85,7 @@ class ElggMemcache extends ElggSharedMemoryCache { // Get version $this->version = $this->memcache->getVersion(); if (version_compare($this->version, ElggMemcache::$MINSERVERVERSION, '<')) { - $msg = elgg_echo('memcache:versiontoolow', + $msg = vsprintf('Memcache needs at least version %s to run, you are running %s', array(ElggMemcache::$MINSERVERVERSION, $this->version )); diff --git a/languages/en.php b/languages/en.php index 14df3db34..7ff484a8f 100644 --- a/languages/en.php +++ b/languages/en.php @@ -229,11 +229,6 @@ $english = array( 'LoginException:AccountLocked' => 'Your account has been locked for too many log in failures.', 'LoginException:ChangePasswordFailure' => 'Failed current password check.', - 'memcache:notinstalled' => 'PHP memcache module not installed, you must install php5-memcache', - 'memcache:noservers' => 'No memcache servers defined, please populate the $CONFIG->memcache_servers variable', - 'memcache:versiontoolow' => 'Memcache needs at least version %s to run, you are running %s', - 'memcache:noaddserver' => 'Multiple server support disabled, you may need to upgrade your PECL memcache library', - 'deprecatedfunction' => 'Warning: This code uses the deprecated function \'%s\' and is not compatible with this version of Elgg', 'pageownerunavailable' => 'Warning: The page owner %d is not accessible!', -- cgit v1.2.3 From 690f226100a2f690bd77d05a82668c9cfee7b863 Mon Sep 17 00:00:00 2001 From: cash Date: Tue, 19 Jun 2012 20:23:49 -0400 Subject: Fixes #4382 catches lost connection to database - from Paweł MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine/lib/database.php | 4 ++++ languages/en.php | 1 + 2 files changed, 5 insertions(+) (limited to 'engine') diff --git a/engine/lib/database.php b/engine/lib/database.php index cc2b99f6a..7d90b30b8 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -253,6 +253,10 @@ function execute_query($query, $dblink) { throw new DatabaseException(elgg_echo('DatabaseException:InvalidQuery')); } + if (!is_resource($dblink)) { + throw new DatabaseException(elgg_echo('DatabaseException:InvalidDBLink')); + } + $dbcalls++; $result = mysql_query($query, $dblink); diff --git a/languages/en.php b/languages/en.php index e9c333041..93096df38 100644 --- a/languages/en.php +++ b/languages/en.php @@ -56,6 +56,7 @@ $english = array( 'DatabaseException:DBSetupIssues' => "There were a number of issues: ", 'DatabaseException:ScriptNotFound' => "Elgg couldn't find the requested database script at %s.", 'DatabaseException:InvalidQuery' => "Invalid query", + 'DatabaseException:InvalidDBLink' => "Connection to database was lost.", 'IOException:FailedToLoadGUID' => "Failed to load new %s from GUID:%d", 'InvalidParameterException:NonElggObject' => "Passing a non-ElggObject to an ElggObject constructor!", -- cgit v1.2.3 From c4262b93dd12de7d8b04533b261c39e4ce8ccf8c Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 21 Jun 2012 20:00:52 -0400 Subject: Fixes #4165 livesearch now returns people based on last names --- engine/lib/input.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engine') diff --git a/engine/lib/input.php b/engine/lib/input.php index dda8211b6..6d1646e1a 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -283,7 +283,7 @@ function input_livesearch_page_handler($page) { WHERE e.guid = ue.guid AND e.enabled = 'yes' AND ue.banned = 'no' - AND (ue.name LIKE '$q%' OR ue.username LIKE '$q%') + AND (ue.name LIKE '$q%' OR ue.name LIKE '% $q%' OR ue.username LIKE '$q%') LIMIT $limit "; @@ -333,7 +333,7 @@ function input_livesearch_page_handler($page) { WHERE e.guid = ge.guid AND e.enabled = 'yes' $owner_where - AND (ge.name LIKE '$q%' OR ge.description LIKE '%$q%') + AND (ge.name LIKE '$q%' OR ge.name LIKE '% $q%' OR ge.description LIKE '% $q%') LIMIT $limit "; if ($entities = get_data($query)) { @@ -379,7 +379,7 @@ function input_livesearch_page_handler($page) { AND e.guid = ue.guid AND e.enabled = 'yes' AND ue.banned = 'no' - AND (ue.name LIKE '$q%' OR ue.username LIKE '$q%') + AND (ue.name LIKE '$q%' OR ue.name LIKE '% $q%' OR ue.username LIKE '$q%') LIMIT $limit "; -- cgit v1.2.3 From ffd992ae30c58acd60ccd1f536a5000982fc4745 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 23 Jun 2012 09:07:47 -0400 Subject: Fixes #4619 downgraded type violations to warnings --- engine/lib/elgglib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 62cb2d5bb..65666954c 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1060,7 +1060,6 @@ function _elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) { switch ($errno) { case E_USER_ERROR: - case E_RECOVERABLE_ERROR: // (e.g. type hint violation) error_log("PHP ERROR: $error"); register_error("ERROR: $error"); @@ -1070,6 +1069,7 @@ function _elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) { case E_WARNING : case E_USER_WARNING : + case E_RECOVERABLE_ERROR: // (e.g. type hint violation) error_log("PHP WARNING: $error"); break; -- cgit v1.2.3 From 8fd511bcd35646c64658f63cfd35f4b0fb3541a8 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 23 Jun 2012 09:16:22 -0400 Subject: Fixes #4168 returning default value from elgg_extract if non-array passed - not removing type hint since we downgraded it from an error to a warning --- engine/lib/elgglib.php | 6 +++++- engine/lib/views.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 65666954c..9aad2a5bd 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1578,7 +1578,11 @@ function elgg_http_url_is_identical($url1, $url2, $ignore_params = array('offset * @return void * @since 1.8.0 */ -function elgg_extract($key, array $array, $default = NULL, $strict = true) { +function elgg_extract($key, array $array, $default = null, $strict = true) { + if (!is_array($array)) { + return $default; + } + if ($strict) { return (isset($array[$key])) ? $array[$key] : $default; } else { diff --git a/engine/lib/views.php b/engine/lib/views.php index c98ad4e78..25acbf2b2 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1224,12 +1224,12 @@ function elgg_view_image_block($image, $body, $vars = array()) { * @param string $type The type of module (main, info, popup, aside, etc.) * @param string $title A title to put in the header * @param string $body Content of the module - * @param string $vars Additional parameters for the module + * @param array $vars Additional parameters for the module * * @return string * @since 1.8.0 */ -function elgg_view_module($type, $title, $body, $vars = array()) { +function elgg_view_module($type, $title, $body, array $vars = array()) { $vars['class'] = elgg_extract('class', $vars, '') . " elgg-module-$type"; $vars['title'] = $title; -- cgit v1.2.3 From 5e16ef8e61e7674ac8caa6ee770e106983d261da Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 23 Jun 2012 10:16:15 -0400 Subject: Fixes #4428 functions deprecated for current version logged at WARNING. They become visual for everyone when the site's trace level is set to WARNING or lower --- engine/lib/elgglib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 9aad2a5bd..0c42c1c08 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1265,7 +1265,7 @@ function elgg_deprecated_notice($msg, $dep_version, $backtrace_level = 1) { $msg .= implode("
-> ", $stack); - elgg_dump($msg, elgg_is_admin_logged_in(), 'WARNING'); + elgg_log($msg, 'WARNING'); return true; } -- cgit v1.2.3 From 4fff20a33467a7318956412d4dabfcab1ce6daba Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Mon, 25 Jun 2012 01:25:46 -0400 Subject: Fixes #2276: Better friendly titles, portable ElggTranslit class, better units --- engine/classes/ElggTranslit.php | 238 ++++++++++++++++++++++++++++++++++ engine/lib/output.php | 18 +-- engine/tests/api/metadata.php | 10 ++ engine/tests/regression/trac_bugs.php | 21 ++- 4 files changed, 269 insertions(+), 18 deletions(-) create mode 100644 engine/classes/ElggTranslit.php (limited to 'engine') diff --git a/engine/classes/ElggTranslit.php b/engine/classes/ElggTranslit.php new file mode 100644 index 000000000..704c17f6a --- /dev/null +++ b/engine/classes/ElggTranslit.php @@ -0,0 +1,238 @@ +. + * + * @author Konsta Vesterinen + * @author Jonathan H. Wage + * + * @author Steve Clay + * @package Elgg.Core + */ +class ElggTranslit { + + /** + * Create a version of a string for embedding in a URL + * @param string $string a UTF-8 string + * @param string $separator + * @return string + */ + static public function urlize($string, $separator = '-') { + // Iñtërnâtiônàlizætiøn, AND 日本語! + + // Internationalization, AND 日本語! + $string = self::transliterateAscii($string); + + // more translation + $string = strtr($string, array( + // Euro/GBP + "\xE2\x82\xAC" /* € */ => 'E', "\xC2\xA3" /* £ */ => 'GBP', + )); + + // remove all ASCII except 0-9a-zA-Z, hyphen, underscore, and whitespace + // note: "x" modifier did not work with this pattern. + $string = preg_replace('~[' + . '\x00-\x08' # control chars + . '\x0b\x0c' # vert tab, form feed + . '\x0e-\x1f' # control chars + . '\x21-\x2c' # ! ... , + . '\x2e\x2f' # . slash + . '\x3a-\x40' # : ... @ + . '\x5b-\x5e' # [ ... ^ + . '\x60' # ` + . '\x7b-\x7f' # { ... DEL + . ']~', '', $string); + $string = strtr($string, '', ''); + + // internationalization, and 日本語! + // note: not using elgg_strtolower to keep this class portable + $string = is_callable('mb_strtolower') + ? mb_strtolower($string, 'UTF-8') + : strtolower($string); + + // split by ASCII chars not in 0-9a-zA-Z + // note: we cannot use [^0-9a-zA-Z] because that matches multibyte chars. + // note: "x" modifier did not work with this pattern. + $pattern = '~[' + . '\x00-\x2f' # controls ... slash + . '\x3a-\x40' # : ... @ + . '\x5b-\x60' # [ ... ` + . '\x7b-\x7f' # { ... DEL + . ']+~x'; + + // ['internationalization', 'and', '日本語'] + $words = preg_split($pattern, $string, -1, PREG_SPLIT_NO_EMPTY); + + // ['internationalization', 'and', '%E6%97%A5%E6%9C%AC%E8%AA%9E'] + $words = array_map('urlencode', $words); + + // internationalization-and-%E6%97%A5%E6%9C%AC%E8%AA%9E + return implode($separator, $words); + } + + /** + * Transliterate Western multibyte chars to ASCII + * @param string $utf8 a UTF-8 string + * @return string + */ + static public function transliterateAscii($utf8) { + static $map = null; + if (!preg_match('/[\x80-\xff]/', $utf8)) { + return $utf8; + } + if (null === $map) { + $map = self::getAsciiTranslitMap(); + } + return strtr($utf8, $map); + } + + /** + * Get array of UTF-8 (NFC) character replacements. + * + * @return array + */ + static public function getAsciiTranslitMap() { + return array( + // Decompositions for Latin-1 Supplement + "\xC2\xAA" /* ª */ => 'a', "\xC2\xBA" /* º */ => 'o', "\xC3\x80" /* À */ => 'A', + "\xC3\x81" /* Á */ => 'A', "\xC3\x82" /*  */ => 'A', "\xC3\x83" /* à */ => 'A', + "\xC3\x84" /* Ä */ => 'A', "\xC3\x85" /* Å */ => 'A', "\xC3\x86" /* Æ */ => 'AE', + "\xC3\x87" /* Ç */ => 'C', "\xC3\x88" /* È */ => 'E', "\xC3\x89" /* É */ => 'E', + "\xC3\x8A" /* Ê */ => 'E', "\xC3\x8B" /* Ë */ => 'E', "\xC3\x8C" /* Ì */ => 'I', + "\xC3\x8D" /* Í */ => 'I', "\xC3\x8E" /* Î */ => 'I', "\xC3\x8F" /* Ï */ => 'I', + "\xC3\x90" /* Ð */ => 'D', "\xC3\x91" /* Ñ */ => 'N', "\xC3\x92" /* Ò */ => 'O', + "\xC3\x93" /* Ó */ => 'O', "\xC3\x94" /* Ô */ => 'O', "\xC3\x95" /* Õ */ => 'O', + "\xC3\x96" /* Ö */ => 'O', "\xC3\x99" /* Ù */ => 'U', "\xC3\x9A" /* Ú */ => 'U', + "\xC3\x9B" /* Û */ => 'U', "\xC3\x9C" /* Ü */ => 'U', "\xC3\x9D" /* Ý */ => 'Y', + "\xC3\x9E" /* Þ */ => 'TH', "\xC3\x9F" /* ß */ => 'ss', "\xC3\xA0" /* à */ => 'a', + "\xC3\xA1" /* á */ => 'a', "\xC3\xA2" /* â */ => 'a', "\xC3\xA3" /* ã */ => 'a', + "\xC3\xA4" /* ä */ => 'a', "\xC3\xA5" /* å */ => 'a', "\xC3\xA6" /* æ */ => 'ae', + "\xC3\xA7" /* ç */ => 'c', "\xC3\xA8" /* è */ => 'e', "\xC3\xA9" /* é */ => 'e', + "\xC3\xAA" /* ê */ => 'e', "\xC3\xAB" /* ë */ => 'e', "\xC3\xAC" /* ì */ => 'i', + "\xC3\xAD" /* í */ => 'i', "\xC3\xAE" /* î */ => 'i', "\xC3\xAF" /* ï */ => 'i', + "\xC3\xB0" /* ð */ => 'd', "\xC3\xB1" /* ñ */ => 'n', "\xC3\xB2" /* ò */ => 'o', + "\xC3\xB3" /* ó */ => 'o', "\xC3\xB4" /* ô */ => 'o', "\xC3\xB5" /* õ */ => 'o', + "\xC3\xB6" /* ö */ => 'o', "\xC3\xB8" /* ø */ => 'o', "\xC3\xB9" /* ù */ => 'u', + "\xC3\xBA" /* ú */ => 'u', "\xC3\xBB" /* û */ => 'u', "\xC3\xBC" /* ü */ => 'u', + "\xC3\xBD" /* ý */ => 'y', "\xC3\xBE" /* þ */ => 'th', "\xC3\xBF" /* ÿ */ => 'y', + "\xC3\x98" /* Ø */ => 'O', + // Decompositions for Latin Extended-A + "\xC4\x80" /* Ā */ => 'A', "\xC4\x81" /* ā */ => 'a', "\xC4\x82" /* Ă */ => 'A', + "\xC4\x83" /* ă */ => 'a', "\xC4\x84" /* Ą */ => 'A', "\xC4\x85" /* ą */ => 'a', + "\xC4\x86" /* Ć */ => 'C', "\xC4\x87" /* ć */ => 'c', "\xC4\x88" /* Ĉ */ => 'C', + "\xC4\x89" /* ĉ */ => 'c', "\xC4\x8A" /* Ċ */ => 'C', "\xC4\x8B" /* ċ */ => 'c', + "\xC4\x8C" /* Č */ => 'C', "\xC4\x8D" /* č */ => 'c', "\xC4\x8E" /* Ď */ => 'D', + "\xC4\x8F" /* ď */ => 'd', "\xC4\x90" /* Đ */ => 'D', "\xC4\x91" /* đ */ => 'd', + "\xC4\x92" /* Ē */ => 'E', "\xC4\x93" /* ē */ => 'e', "\xC4\x94" /* Ĕ */ => 'E', + "\xC4\x95" /* ĕ */ => 'e', "\xC4\x96" /* Ė */ => 'E', "\xC4\x97" /* ė */ => 'e', + "\xC4\x98" /* Ę */ => 'E', "\xC4\x99" /* ę */ => 'e', "\xC4\x9A" /* Ě */ => 'E', + "\xC4\x9B" /* ě */ => 'e', "\xC4\x9C" /* Ĝ */ => 'G', "\xC4\x9D" /* ĝ */ => 'g', + "\xC4\x9E" /* Ğ */ => 'G', "\xC4\x9F" /* ğ */ => 'g', "\xC4\xA0" /* Ġ */ => 'G', + "\xC4\xA1" /* ġ */ => 'g', "\xC4\xA2" /* Ģ */ => 'G', "\xC4\xA3" /* ģ */ => 'g', + "\xC4\xA4" /* Ĥ */ => 'H', "\xC4\xA5" /* ĥ */ => 'h', "\xC4\xA6" /* Ħ */ => 'H', + "\xC4\xA7" /* ħ */ => 'h', "\xC4\xA8" /* Ĩ */ => 'I', "\xC4\xA9" /* ĩ */ => 'i', + "\xC4\xAA" /* Ī */ => 'I', "\xC4\xAB" /* ī */ => 'i', "\xC4\xAC" /* Ĭ */ => 'I', + "\xC4\xAD" /* ĭ */ => 'i', "\xC4\xAE" /* Į */ => 'I', "\xC4\xAF" /* į */ => 'i', + "\xC4\xB0" /* İ */ => 'I', "\xC4\xB1" /* ı */ => 'i', "\xC4\xB2" /* IJ */ => 'IJ', + "\xC4\xB3" /* ij */ => 'ij', "\xC4\xB4" /* Ĵ */ => 'J', "\xC4\xB5" /* ĵ */ => 'j', + "\xC4\xB6" /* Ķ */ => 'K', "\xC4\xB7" /* ķ */ => 'k', "\xC4\xB8" /* ĸ */ => 'k', + "\xC4\xB9" /* Ĺ */ => 'L', "\xC4\xBA" /* ĺ */ => 'l', "\xC4\xBB" /* Ļ */ => 'L', + "\xC4\xBC" /* ļ */ => 'l', "\xC4\xBD" /* Ľ */ => 'L', "\xC4\xBE" /* ľ */ => 'l', + "\xC4\xBF" /* Ŀ */ => 'L', "\xC5\x80" /* ŀ */ => 'l', "\xC5\x81" /* Ł */ => 'L', + "\xC5\x82" /* ł */ => 'l', "\xC5\x83" /* Ń */ => 'N', "\xC5\x84" /* ń */ => 'n', + "\xC5\x85" /* Ņ */ => 'N', "\xC5\x86" /* ņ */ => 'n', "\xC5\x87" /* Ň */ => 'N', + "\xC5\x88" /* ň */ => 'n', "\xC5\x89" /* ʼn */ => 'N', "\xC5\x8A" /* Ŋ */ => 'n', + "\xC5\x8B" /* ŋ */ => 'N', "\xC5\x8C" /* Ō */ => 'O', "\xC5\x8D" /* ō */ => 'o', + "\xC5\x8E" /* Ŏ */ => 'O', "\xC5\x8F" /* ŏ */ => 'o', "\xC5\x90" /* Ő */ => 'O', + "\xC5\x91" /* ő */ => 'o', "\xC5\x92" /* Œ */ => 'OE', "\xC5\x93" /* œ */ => 'oe', + "\xC5\x94" /* Ŕ */ => 'R', "\xC5\x95" /* ŕ */ => 'r', "\xC5\x96" /* Ŗ */ => 'R', + "\xC5\x97" /* ŗ */ => 'r', "\xC5\x98" /* Ř */ => 'R', "\xC5\x99" /* ř */ => 'r', + "\xC5\x9A" /* Ś */ => 'S', "\xC5\x9B" /* ś */ => 's', "\xC5\x9C" /* Ŝ */ => 'S', + "\xC5\x9D" /* ŝ */ => 's', "\xC5\x9E" /* Ş */ => 'S', "\xC5\x9F" /* ş */ => 's', + "\xC5\xA0" /* Š */ => 'S', "\xC5\xA1" /* š */ => 's', "\xC5\xA2" /* Ţ */ => 'T', + "\xC5\xA3" /* ţ */ => 't', "\xC5\xA4" /* Ť */ => 'T', "\xC5\xA5" /* ť */ => 't', + "\xC5\xA6" /* Ŧ */ => 'T', "\xC5\xA7" /* ŧ */ => 't', "\xC5\xA8" /* Ũ */ => 'U', + "\xC5\xA9" /* ũ */ => 'u', "\xC5\xAA" /* Ū */ => 'U', "\xC5\xAB" /* ū */ => 'u', + "\xC5\xAC" /* Ŭ */ => 'U', "\xC5\xAD" /* ŭ */ => 'u', "\xC5\xAE" /* Ů */ => 'U', + "\xC5\xAF" /* ů */ => 'u', "\xC5\xB0" /* Ű */ => 'U', "\xC5\xB1" /* ű */ => 'u', + "\xC5\xB2" /* Ų */ => 'U', "\xC5\xB3" /* ų */ => 'u', "\xC5\xB4" /* Ŵ */ => 'W', + "\xC5\xB5" /* ŵ */ => 'w', "\xC5\xB6" /* Ŷ */ => 'Y', "\xC5\xB7" /* ŷ */ => 'y', + "\xC5\xB8" /* Ÿ */ => 'Y', "\xC5\xB9" /* Ź */ => 'Z', "\xC5\xBA" /* ź */ => 'z', + "\xC5\xBB" /* Ż */ => 'Z', "\xC5\xBC" /* ż */ => 'z', "\xC5\xBD" /* Ž */ => 'Z', + "\xC5\xBE" /* ž */ => 'z', "\xC5\xBF" /* ſ */ => 's', + // Decompositions for Latin Extended-B + "\xC8\x98" /* Ș */ => 'S', "\xC8\x99" /* ș */ => 's', + "\xC8\x9A" /* Ț */ => 'T', "\xC8\x9B" /* ț */ => 't', + // unmarked + "\xC6\xA0" /* Ơ */ => 'O', "\xC6\xA1" /* ơ */ => 'o', + "\xC6\xAF" /* Ư */ => 'U', "\xC6\xB0" /* ư */ => 'u', + // grave accent + "\xE1\xBA\xA6" /* Ầ */ => 'A', "\xE1\xBA\xA7" /* ầ */ => 'a', + "\xE1\xBA\xB0" /* Ằ */ => 'A', "\xE1\xBA\xB1" /* ằ */ => 'a', + "\xE1\xBB\x80" /* Ề */ => 'E', "\xE1\xBB\x81" /* ề */ => 'e', + "\xE1\xBB\x92" /* Ồ */ => 'O', "\xE1\xBB\x93" /* ồ */ => 'o', + "\xE1\xBB\x9C" /* Ờ */ => 'O', "\xE1\xBB\x9D" /* ờ */ => 'o', + "\xE1\xBB\xAA" /* Ừ */ => 'U', "\xE1\xBB\xAB" /* ừ */ => 'u', + "\xE1\xBB\xB2" /* Ỳ */ => 'Y', "\xE1\xBB\xB3" /* ỳ */ => 'y', + // hook + "\xE1\xBA\xA2" /* Ả */ => 'A', "\xE1\xBA\xA3" /* ả */ => 'a', + "\xE1\xBA\xA8" /* Ẩ */ => 'A', "\xE1\xBA\xA9" /* ẩ */ => 'a', + "\xE1\xBA\xB2" /* Ẳ */ => 'A', "\xE1\xBA\xB3" /* ẳ */ => 'a', + "\xE1\xBA\xBA" /* Ẻ */ => 'E', "\xE1\xBA\xBB" /* ẻ */ => 'e', + "\xE1\xBB\x82" /* Ể */ => 'E', "\xE1\xBB\x83" /* ể */ => 'e', + "\xE1\xBB\x88" /* Ỉ */ => 'I', "\xE1\xBB\x89" /* ỉ */ => 'i', + "\xE1\xBB\x8E" /* Ỏ */ => 'O', "\xE1\xBB\x8F" /* ỏ */ => 'o', + "\xE1\xBB\x94" /* Ổ */ => 'O', "\xE1\xBB\x95" /* ổ */ => 'o', + "\xE1\xBB\x9E" /* Ở */ => 'O', "\xE1\xBB\x9F" /* ở */ => 'o', + "\xE1\xBB\xA6" /* Ủ */ => 'U', "\xE1\xBB\xA7" /* ủ */ => 'u', + "\xE1\xBB\xAC" /* Ử */ => 'U', "\xE1\xBB\xAD" /* ử */ => 'u', + "\xE1\xBB\xB6" /* Ỷ */ => 'Y', "\xE1\xBB\xB7" /* ỷ */ => 'y', + // tilde + "\xE1\xBA\xAA" /* Ẫ */ => 'A', "\xE1\xBA\xAB" /* ẫ */ => 'a', + "\xE1\xBA\xB4" /* Ẵ */ => 'A', "\xE1\xBA\xB5" /* ẵ */ => 'a', + "\xE1\xBA\xBC" /* Ẽ */ => 'E', "\xE1\xBA\xBD" /* ẽ */ => 'e', + "\xE1\xBB\x84" /* Ễ */ => 'E', "\xE1\xBB\x85" /* ễ */ => 'e', + "\xE1\xBB\x96" /* Ỗ */ => 'O', "\xE1\xBB\x97" /* ỗ */ => 'o', + "\xE1\xBB\xA0" /* Ỡ */ => 'O', "\xE1\xBB\xA1" /* ỡ */ => 'o', + "\xE1\xBB\xAE" /* Ữ */ => 'U', "\xE1\xBB\xAF" /* ữ */ => 'u', + "\xE1\xBB\xB8" /* Ỹ */ => 'Y', "\xE1\xBB\xB9" /* ỹ */ => 'y', + // acute accent + "\xE1\xBA\xA4" /* Ấ */ => 'A', "\xE1\xBA\xA5" /* ấ */ => 'a', + "\xE1\xBA\xAE" /* Ắ */ => 'A', "\xE1\xBA\xAF" /* ắ */ => 'a', + "\xE1\xBA\xBE" /* Ế */ => 'E', "\xE1\xBA\xBF" /* ế */ => 'e', + "\xE1\xBB\x90" /* Ố */ => 'O', "\xE1\xBB\x91" /* ố */ => 'o', + "\xE1\xBB\x9A" /* Ớ */ => 'O', "\xE1\xBB\x9B" /* ớ */ => 'o', + "\xE1\xBB\xA8" /* Ứ */ => 'U', "\xE1\xBB\xA9" /* ứ */ => 'u', + // dot below + "\xE1\xBA\xA0" /* Ạ */ => 'A', "\xE1\xBA\xA1" /* ạ */ => 'a', + "\xE1\xBA\xAC" /* Ậ */ => 'A', "\xE1\xBA\xAD" /* ậ */ => 'a', + "\xE1\xBA\xB6" /* Ặ */ => 'A', "\xE1\xBA\xB7" /* ặ */ => 'a', + "\xE1\xBA\xB8" /* Ẹ */ => 'E', "\xE1\xBA\xB9" /* ẹ */ => 'e', + "\xE1\xBB\x86" /* Ệ */ => 'E', "\xE1\xBB\x87" /* ệ */ => 'e', + "\xE1\xBB\x8A" /* Ị */ => 'I', "\xE1\xBB\x8B" /* ị */ => 'i', + "\xE1\xBB\x8C" /* Ọ */ => 'O', "\xE1\xBB\x8D" /* ọ */ => 'o', + "\xE1\xBB\x98" /* Ộ */ => 'O', "\xE1\xBB\x99" /* ộ */ => 'o', + "\xE1\xBB\xA2" /* Ợ */ => 'O', "\xE1\xBB\xA3" /* ợ */ => 'o', + "\xE1\xBB\xA4" /* Ụ */ => 'U', "\xE1\xBB\xA5" /* ụ */ => 'u', + "\xE1\xBB\xB0" /* Ự */ => 'U', "\xE1\xBB\xB1" /* ự */ => 'u', + "\xE1\xBB\xB4" /* Ỵ */ => 'Y', "\xE1\xBB\xB5" /* ỵ */ => 'y', + ); + } +} diff --git a/engine/lib/output.php b/engine/lib/output.php index b1245a924..7bfc4be6e 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -310,19 +310,11 @@ function elgg_get_friendly_title($title) { return $result; } - // @todo not using this because of locale concerns - //$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title); - - // @todo this uses a utf8 character class. can use if - // we want to support utf8 in the url. - //$title = preg_replace('/[^\p{L}\- ]/u', '', $title); - - // use A-Za-z0-9_ instead of \w because \w is locale sensitive - $title = preg_replace("/[^A-Za-z0-9_\- ]/", "", $title); - $title = str_replace(" ", "-", $title); - $title = str_replace("--", "-", $title); - $title = trim($title); - $title = elgg_strtolower($title); + // handle some special cases + $title = str_replace('&', 'and', $title); + + $title = ElggTranslit::urlize($title); + return $title; } diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php index 244036f80..c63b0cbec 100644 --- a/engine/tests/api/metadata.php +++ b/engine/tests/api/metadata.php @@ -28,6 +28,8 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest { public function testGetMetastringById() { foreach (array('metaUnitTest', 'metaunittest', 'METAUNITTEST') as $string) { + // in case previous tests failed to cleanup after themselves + $this->delete_metastrings($string); $this->create_metastring($string); } @@ -194,11 +196,19 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest { $u2->delete(); } + protected function delete_metastrings($string) { + global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; + $METASTRINGS_CACHE = $METASTRINGS_DEADNAME_CACHE = array(); + + $string = sanitise_string($string); + mysql_query("DELETE FROM {$CONFIG->dbprefix}metastrings WHERE string = BINARY '$string'"); + } protected function create_metastring($string) { global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; $METASTRINGS_CACHE = $METASTRINGS_DEADNAME_CACHE = array(); + $string = sanitise_string($string); mysql_query("INSERT INTO {$CONFIG->dbprefix}metastrings (string) VALUES ('$string')"); $this->metastrings[$string] = mysql_insert_id(); } diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php index 26a45ab6a..e81bd6936 100644 --- a/engine/tests/regression/trac_bugs.php +++ b/engine/tests/regression/trac_bugs.php @@ -202,14 +202,25 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest { /** * http://trac.elgg.org/ticket/3210 - Don't remove -s in friendly titles - * @todo: http://trac.elgg.org/ticket/2276 - improve char encoding + * http://trac.elgg.org/ticket/2276 - improve char encoding */ public function test_friendly_title() { $cases = array( - 'Simple Test' => 'simple-test', - 'Test top-level page' => 'test-top-level-page', -// 'éclair' => 'éclair', -// 'English, Español, and 日本語' => 'english-español-and-日本語' + // hyphen, underscore and ASCII whitespace replaced by separator, + // other non-alphanumeric ASCII removed + "a-a_a a\na\ra\ta\va!a\"a#a\$a%a&a'a(a)a*a+a,a.a/a:a;aa?a@a[a\\a]a^a`a{a|a}a~a" + => "a-a-a-a-a-a-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + + // separators trimmed + "-_ hello _-" => "hello", + + // accents removed, lower case, other multibyte chars are URL encoded + "I\xC3\xB1t\xC3\xABrn\xC3\xA2ti\xC3\xB4n\xC3\xA0liz\xC3\xA6ti\xC3\xB8n, AND \xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" + // Iñtërnâtiônàlizætiøn, AND 日本語 + => 'internationalizaetion-and-%E6%97%A5%E6%9C%AC%E8%AA%9E', + + // some HTML entity replacements + "Me & You" => 'me-and-you', ); foreach ($cases as $case => $expected) { -- cgit v1.2.3 From 8a5ddacfa2598b8d984c2cdc6142d41936f38c48 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Tue, 26 Jun 2012 11:28:58 -0400 Subject: Added NFC conversion where available --- engine/classes/ElggTranslit.php | 22 ++++++++++++++++++++++ engine/tests/regression/trac_bugs.php | 6 ++++++ 2 files changed, 28 insertions(+) (limited to 'engine') diff --git a/engine/classes/ElggTranslit.php b/engine/classes/ElggTranslit.php index 704c17f6a..809302276 100644 --- a/engine/classes/ElggTranslit.php +++ b/engine/classes/ElggTranslit.php @@ -37,6 +37,13 @@ class ElggTranslit { static public function urlize($string, $separator = '-') { // Iñtërnâtiônàlizætiøn, AND 日本語! + // try to force combined chars because the translit map and others expect it + if (self::hasNormalizerSupport()) { + $nfc = normalizer_normalize($string); + if (is_string($nfc)) { + $string = $nfc; + } + } // Internationalization, AND 日本語! $string = self::transliterateAscii($string); @@ -235,4 +242,19 @@ class ElggTranslit { "\xE1\xBB\xB4" /* Ỵ */ => 'Y', "\xE1\xBB\xB5" /* ỵ */ => 'y', ); } + + /** + * Tests that "normalizer_normalize" exists and works + * @return bool + */ + static public function hasNormalizerSupport() { + static $ret = null; + if (null === $ret) { + $form_c = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) + $form_d = "A\xCC\x8A"; // A followed by 'COMBINING RING ABOVE' (U+030A) + $ret = (function_exists('normalizer_normalize') + && $form_c === normalizer_normalize($form_d)); + } + return $ret; + } } diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php index e81bd6936..691433a41 100644 --- a/engine/tests/regression/trac_bugs.php +++ b/engine/tests/regression/trac_bugs.php @@ -223,6 +223,12 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest { "Me & You" => 'me-and-you', ); + // where available, string is converted to NFC before transliteration + if (ElggTranslit::hasNormalizerSupport()) { + $form_d = "A\xCC\x8A"; // A followed by 'COMBINING RING ABOVE' (U+030A) + $cases[$form_d] = "a"; + } + foreach ($cases as $case => $expected) { $friendly_title = elgg_get_friendly_title($case); $this->assertIdentical($expected, $friendly_title); -- cgit v1.2.3 From 0cb5a8c719b676f57d3436b1c02d56fa3cfdc9be Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 28 Jun 2012 19:00:13 -0400 Subject: Fixes #4642 group discussion replies work now --- engine/lib/notification.php | 16 +++--- mod/groups/languages/en.php | 10 ++++ mod/groups/start.php | 129 +++++++++++++++++++++++++++++++++----------- 3 files changed, 117 insertions(+), 38 deletions(-) (limited to 'engine') diff --git a/engine/lib/notification.php b/engine/lib/notification.php index 5a2f5f8ac..18faff27f 100644 --- a/engine/lib/notification.php +++ b/engine/lib/notification.php @@ -480,8 +480,8 @@ function object_notifications($event, $object_type, $object) { } if (isset($CONFIG->register_objects[$object_type][$object_subtype])) { - $descr = $CONFIG->register_objects[$object_type][$object_subtype]; - $string = $descr . ": " . $object->getURL(); + $subject = $CONFIG->register_objects[$object_type][$object_subtype]; + $string = $subject . ": " . $object->getURL(); // Get users interested in content from this person and notify them // (Person defined by container_guid so we can also subscribe to groups if we want) @@ -500,16 +500,16 @@ function object_notifications($event, $object_type, $object) { if ($user instanceof ElggUser && !$user->isBanned()) { if (($user->guid != $SESSION['user']->guid) && has_access_to_entity($object, $user) && $object->access_id != ACCESS_PRIVATE) { - $methodstring = elgg_trigger_plugin_hook('notify:entity:message', $object->getType(), array( + $body = elgg_trigger_plugin_hook('notify:entity:message', $object->getType(), array( 'entity' => $object, 'to_entity' => $user, 'method' => $method), $string); - if (empty($methodstring) && $methodstring !== false) { - $methodstring = $string; + if (empty($body) && $body !== false) { + $body = $string; } - if ($methodstring !== false) { - notify_user($user->guid, $object->container_guid, $descr, $methodstring, - NULL, array($method)); + if ($body !== false) { + notify_user($user->guid, $object->container_guid, $subject, $body, + null, array($method)); } } } diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php index e51e51a14..88aeccb54 100644 --- a/mod/groups/languages/en.php +++ b/mod/groups/languages/en.php @@ -64,12 +64,22 @@ $english = array( 'groups:search_in_group' => "Search in this group", 'groups:acl' => "Group: %s", + 'discussion:notification:topic:subject' => 'New group discussion post', 'groups:notification' => '%s added a new discussion topic to %s: %s %s +View and reply to the discussion: +%s +', + + 'discussion:notification:reply:body' => +'%s replied to the discussion topic %s in the group %s: + +%s + View and reply to the discussion: %s ', diff --git a/mod/groups/start.php b/mod/groups/start.php index c8198371b..8eb0d4036 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -93,7 +93,6 @@ function groups_init() { elgg_register_event_handler('join', 'group', 'groups_user_join_event_listener'); elgg_register_event_handler('leave', 'group', 'groups_user_leave_event_listener'); elgg_register_event_handler('pagesetup', 'system', 'groups_setup_sidebar_menus'); - elgg_register_event_handler('annotate', 'all', 'group_object_notifications'); elgg_register_plugin_hook_handler('access:collections:add_user', 'collection', 'groups_access_collection_override'); @@ -741,8 +740,10 @@ function discussion_init() { elgg_extend_view('groups/tool_latest', 'discussion/group_module'); // notifications - register_notification_object('object', 'groupforumtopic', elgg_echo('groupforumtopic:new')); + register_notification_object('object', 'groupforumtopic', elgg_echo('discussion:notification:topic:subject')); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'groupforumtopic_notify_message'); + elgg_register_event_handler('create', 'annotation', 'discussion_reply_notifications'); + elgg_register_plugin_hook_handler('notify:annotation:message', 'group_topic_post', 'discussion_create_reply_notification'); } /** @@ -863,36 +864,16 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) { } /** - * Event handler for group forum posts + * Create discussion notification body * - */ -function group_object_notifications($event, $object_type, $object) { - - static $flag; - if (!isset($flag)) { - $flag = 0; - } - - if (is_callable('object_notifications')) - if ($object instanceof ElggObject) { - if ($object->getSubtype() == 'groupforumtopic') { - if ($flag == 0) { - $flag = 1; - object_notifications($event, $object_type, $object); - } - } - } -} - -/** - * Returns a more meaningful message + * @todo namespace method with 'discussion' * - * @param unknown_type $hook - * @param unknown_type $entity_type - * @param unknown_type $returnvalue - * @param unknown_type $params + * @param string $hook + * @param string $type + * @param string $message + * @param array $params */ -function groupforumtopic_notify_message($hook, $entity_type, $returnvalue, $params) { +function groupforumtopic_notify_message($hook, $type, $message, $params) { $entity = $params['entity']; $to_entity = $params['to_entity']; $method = $params['method']; @@ -912,10 +893,98 @@ function groupforumtopic_notify_message($hook, $entity_type, $returnvalue, $para $entity->getURL() )); } - + return null; } +/** + * Create discussion reply notification body + * + * @param string $hook + * @param string $type + * @param string $message + * @param array $params + */ +function discussion_create_reply_notification($hook, $type, $message, $params) { + $reply = $params['annotation']; + $method = $params['method']; + $topic = $reply->getEntity(); + $poster = $reply->getOwnerEntity(); + $group = $topic->getContainerEntity(); + + return elgg_echo('discussion:notification:reply:body', array( + $poster->name, + $topic->title, + $group->name, + $reply->value, + $topic->getURL(), + )); +} + +/** + * Catch reply to discussion topic and generate notifications + * + * @todo this will be replaced in Elgg 1.9 and is a clone of object_notifications() + * + * @param string $event + * @param string $type + * @param ElggAnnotation $annotation + * @return void + */ +function discussion_reply_notifications($event, $type, $annotation) { + global $CONFIG, $NOTIFICATION_HANDLERS; + + // Have we registered notifications for this type of entity? + $object_type = 'object'; + $object_subtype = 'groupforumtopic'; + + $topic = $annotation->getEntity(); + if (!$topic) { + return; + } + + $poster = $annotation->getOwnerEntity(); + if (!$poster) { + return; + } + + if (isset($CONFIG->register_objects[$object_type][$object_subtype])) { + $subject = $CONFIG->register_objects[$object_type][$object_subtype]; + $string = $subject . ": " . $topic->getURL(); + + // Get users interested in content from this person and notify them + // (Person defined by container_guid so we can also subscribe to groups if we want) + foreach ($NOTIFICATION_HANDLERS as $method => $foo) { + $interested_users = elgg_get_entities_from_relationship(array( + 'relationship' => 'notify' . $method, + 'relationship_guid' => $topic->getContainerGUID(), + 'inverse_relationship' => true, + 'types' => 'user', + 'limit' => 0, + )); + + if ($interested_users && is_array($interested_users)) { + foreach ($interested_users as $user) { + if ($user instanceof ElggUser && !$user->isBanned()) { + if (($user->guid != $poster->guid) && has_access_to_entity($topic, $user) && $topic->access_id != ACCESS_PRIVATE) { + $body = elgg_trigger_plugin_hook('notify:annotation:message', $annotation->getSubtype(), array( + 'annotation' => $annotation, + 'to_entity' => $user, + 'method' => $method), $string); + if (empty($body) && $body !== false) { + $body = $string; + } + if ($body !== false) { + notify_user($user->guid, $topic->getContainerGUID(), $subject, $body, null, array($method)); + } + } + } + } + } + } + } +} + /** * A simple function to see who can edit a group discussion post * @param the comment $entity -- cgit v1.2.3 From b05caab768f9e1c4cbef4af87670dc87ef4d529f Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Thu, 28 Jun 2012 21:52:30 -0400 Subject: Fixes #4634: Restores pre 1.7 group profile pics after update --- engine/classes/ElggGroup.php | 2 -- mod/groups/icon.php | 6 ++++++ mod/groups/start.php | 13 +++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php index f7f67bf41..121186196 100644 --- a/engine/classes/ElggGroup.php +++ b/engine/classes/ElggGroup.php @@ -16,8 +16,6 @@ class ElggGroup extends ElggEntity * Sets the type to group. * * @return void - * - * @deprecated 1.8 Use initializeAttributes */ protected function initializeAttributes() { parent::initializeAttributes(); diff --git a/mod/groups/icon.php b/mod/groups/icon.php index f86f84fa5..1bd240ea6 100644 --- a/mod/groups/icon.php +++ b/mod/groups/icon.php @@ -8,7 +8,13 @@ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); $group_guid = get_input('group_guid'); + +/* @var ElggGroup $group */ $group = get_entity($group_guid); +if (!($group instanceof ElggGroup)) { + header("HTTP/1.1 404 Not Found"); + exit; +} // If is the same ETag, content didn't changed. $etag = $group->icontime . $group_guid; diff --git a/mod/groups/start.php b/mod/groups/start.php index c8198371b..d6c2a47d2 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -284,12 +284,21 @@ function groups_url($entity) { * @return string Relative URL */ function groups_icon_url_override($hook, $type, $returnvalue, $params) { + /* @var ElggGroup $group */ $group = $params['entity']; $size = $params['size']; - if (isset($group->icontime)) { + $icontime = $group->icontime; + // handle missing metadata (pre 1.7 installations) + if (null === $icontime) { + $file = new ElggFile(); + $file->owner_guid = $group->owner_guid; + $file->setFilename("groups/" . $group->guid . "large.jpg"); + $icontime = $file->exists() ? time() : 0; + create_metadata($group->guid, 'icontime', $icontime, 'integer', $group->owner_guid, ACCESS_PUBLIC); + } + if ($icontime) { // return thumbnail - $icontime = $group->icontime; return "groupicon/$group->guid/$size/$icontime.jpg"; } -- cgit v1.2.3 From bcd5b0e59e4ea7191475e30397578859315cf2bb Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 1 Jul 2012 22:28:56 -0400 Subject: Fixes #3955 removes public access from walled gardens - maintains groups functionality --- engine/classes/ElggSite.php | 26 ++++++++++++++++++-------- engine/lib/elgglib.php | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index e793ab9c6..401939005 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -381,14 +381,24 @@ class ElggSite extends ElggEntity { public function checkWalledGarden() { global $CONFIG; - if ($CONFIG->walled_garden && !elgg_is_logged_in()) { - // hook into the index system call at the highest priority - elgg_register_plugin_hook_handler('index', 'system', 'elgg_walled_garden_index', 1); - - if (!$this->isPublicPage()) { - $_SESSION['last_forward_from'] = current_page_url(); - register_error(elgg_echo('loggedinrequired')); - forward(); + if ($CONFIG->walled_garden) { + if ($CONFIG->default_access == ACCESS_PUBLIC) { + $CONFIG->default_access = ACCESS_LOGGED_IN; + } + elgg_register_plugin_hook_handler( + 'access:collections:write', + 'user', + '_elgg_walled_garden_remove_public_access'); + + if (!elgg_is_logged_in()) { + // hook into the index system call at the highest priority + elgg_register_plugin_hook_handler('index', 'system', 'elgg_walled_garden_index', 1); + + if (!$this->isPublicPage()) { + $_SESSION['last_forward_from'] = current_page_url(); + register_error(elgg_echo('loggedinrequired')); + forward(); + } } } } diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 0c42c1c08..3026a78e3 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2097,6 +2097,22 @@ function elgg_walled_garden() { } } +/** + * Remove public access for walled gardens + * + * @param string $hook + * @param string $type + * @param array $accesses + * @return array + * @access private + */ +function _elgg_walled_garden_remove_public_access($hook, $type, $accesses) { + if (isset($accesses[ACCESS_PUBLIC])) { + unset($accesses[ACCESS_PUBLIC]); + } + return $accesses; +} + /** * Boots the engine * -- cgit v1.2.3 From 34576a1f81d50a44064567469eb1406a028c92a7 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Wed, 4 Jul 2012 14:41:46 -0400 Subject: stop double encoding the ban reason --- engine/lib/users.php | 1 - 1 file changed, 1 deletion(-) (limited to 'engine') diff --git a/engine/lib/users.php b/engine/lib/users.php index 241b524f9..527eff3cd 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -136,7 +136,6 @@ function ban_user($user_guid, $reason = "") { global $CONFIG; $user_guid = (int)$user_guid; - $reason = sanitise_string($reason); $user = get_entity($user_guid); -- cgit v1.2.3 From 2755f1cd44de70d32833d95aae9a761c80666687 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 5 Jul 2012 20:18:11 -0400 Subject: Refs #2276 made the new class private --- engine/classes/ElggTranslit.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engine') diff --git a/engine/classes/ElggTranslit.php b/engine/classes/ElggTranslit.php index 809302276..676c59fc8 100644 --- a/engine/classes/ElggTranslit.php +++ b/engine/classes/ElggTranslit.php @@ -25,6 +25,8 @@ * * @author Steve Clay * @package Elgg.Core + * + * @access private Plugin authors should not use this directly */ class ElggTranslit { -- cgit v1.2.3 From 511f23d66219a7a92f12f61f5cc725a6861808fd Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 5 Jul 2012 20:22:27 -0400 Subject: added different comment so I don't break this test again --- engine/tests/api/metadata.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engine') diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php index c63b0cbec..9933263d1 100644 --- a/engine/tests/api/metadata.php +++ b/engine/tests/api/metadata.php @@ -28,7 +28,8 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest { public function testGetMetastringById() { foreach (array('metaUnitTest', 'metaunittest', 'METAUNITTEST') as $string) { - // in case previous tests failed to cleanup after themselves + // since there is no guarantee that metastrings are garbage collected + // between unit test runs, we delete before testing $this->delete_metastrings($string); $this->create_metastring($string); } -- cgit v1.2.3 From 9d69bf365d7ac19ae87c060f9b39d1ca21dd8854 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 5 Jul 2012 21:30:51 -0400 Subject: fixed typo in comment --- engine/lib/views.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine') diff --git a/engine/lib/views.php b/engine/lib/views.php index 25acbf2b2..b00334062 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -303,7 +303,7 @@ function elgg_set_view_location($view, $location, $viewtype = '') { /** * Returns whether the specified view exists * - * @note If $recurse is strue, also checks if a view exists only as an extension. + * @note If $recurse is true, also checks if a view exists only as an extension. * * @param string $view The view name * @param string $viewtype If set, forces the viewtype -- cgit v1.2.3 From b2f46500941a2093734e7672a4de79aabd95b9fc Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 5 Jul 2012 21:40:50 -0400 Subject: Fixes #4438 using request language to clear up confusion --- engine/lib/pagehandler.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engine') diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php index 46c7d059e..ba7518a77 100644 --- a/engine/lib/pagehandler.php +++ b/engine/lib/pagehandler.php @@ -31,18 +31,18 @@ function page_handler($handler, $page) { } // return false to stop processing the request (because you handled it) - // return a new $params array if you want to route the request differently - $params = array( + // return a new $request array if you want to route the request differently + $request = array( 'handler' => $handler, 'segments' => $page, ); - $params = elgg_trigger_plugin_hook('route', $handler, NULL, $params); - if ($params === false) { + $request = elgg_trigger_plugin_hook('route', $handler, null, $request); + if ($request === false) { return true; } - $handler = $params['handler']; - $page = $params['segments']; + $handler = $request['handler']; + $page = $request['segments']; $result = false; if (isset($CONFIG->pagehandler) && !empty($handler) && isset($CONFIG->pagehandler[$handler])) { -- cgit v1.2.3 From e9df0780e7499f983ccb9d346d202343aa1b2c18 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 6 Jul 2012 18:22:32 -0400 Subject: Fixes #3046 adds documentation for requesting entities that do not have metadata or relationships --- engine/lib/metadata.php | 13 ++++++++++++- engine/lib/relationships.php | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'engine') diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 0ff3a43dc..77fa30e41 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -361,13 +361,24 @@ function elgg_enable_metadata(array $options) { * options available to elgg_get_entities(). Supports * the singular option shortcut. * - * NB: Using metadata_names and metadata_values results in a + * @note Using metadata_names and metadata_values results in a * "names IN (...) AND values IN (...)" clause. This is subtly * differently than default multiple metadata_name_value_pairs, which use * "(name = value) AND (name = value)" clauses. * * When in doubt, use name_value_pairs. * + * To ask for entities that do not have a metadata value, use a custom + * where clause like this: + * + * $options['wheres'][] = "NOT EXISTS ( + * SELECT 1 FROM {$dbprefix}metadata md + * WHERE md.entity_guid = e.guid + * AND md.name_id = $name_metastring_id + * AND md.value_id = $value_metastring_id)"; + * + * Note the metadata name and value has been denormalized in the above example. + * * @see elgg_get_entities * * @param array $options Array in format: diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index f50c4a485..09d541e22 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -239,6 +239,15 @@ function get_entity_relationships($guid, $inverse_relationship = FALSE) { * Also accepts all options available to elgg_get_entities() and * elgg_get_entities_from_metadata(). * + * To ask for entities that do not have a particulat relationship to an entity, + * use a custom where clause like the following: + * + * $options['wheres'][] = "NOT EXISTS ( + * SELECT 1 FROM {$db_prefix}entity_relationships + * WHERE guid_one = e.guid + * AND relationship = '$relationship' + * )"; + * * @see elgg_get_entities * @see elgg_get_entities_from_metadata * -- cgit v1.2.3 From 2329cb233a8766ac1a6bc5d5b4d699f2ab773ea4 Mon Sep 17 00:00:00 2001 From: Sem Date: Sat, 7 Jul 2012 03:03:04 +0200 Subject: Fixes #4631. Admins are now able to delete river items. --- actions/river/delete.php | 21 +++++++++++++++++++++ engine/lib/navigation.php | 12 ++++++++++++ engine/lib/river.php | 4 +++- languages/en.php | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 actions/river/delete.php (limited to 'engine') diff --git a/actions/river/delete.php b/actions/river/delete.php new file mode 100644 index 000000000..0d8297932 --- /dev/null +++ b/actions/river/delete.php @@ -0,0 +1,21 @@ + $id))) { + system_message(elgg_echo('river:delete:success')); + } else { + register_error(elgg_echo('river:delete:fail')); + } +} else { + register_error(elgg_echo('river:delete:fail')); +} + +forward(REFERER); diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index 4ff009bfb..61d283f4b 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -335,6 +335,18 @@ function elgg_river_menu_setup($hook, $type, $return, $params) { $return[] = ElggMenuItem::factory($options); } } + + if ($object->canEdit() && elgg_is_admin_logged_in()) { + $options = array( + 'name' => 'delete', + 'href' => "action/river/delete?id=$item->id", + 'text' => elgg_view_icon('delete'), + 'title' => elgg_echo('delete'), + 'is_action' => true, + 'priority' => 200, + ); + $return[] = ElggMenuItem::factory($options); + } } return $return; diff --git a/engine/lib/river.php b/engine/lib/river.php index 711832f70..b717a7756 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -643,9 +643,11 @@ function elgg_river_init() { elgg_register_page_handler('activity', 'elgg_river_page_handler'); $item = new ElggMenuItem('activity', elgg_echo('activity'), 'activity'); elgg_register_menu_item('site', $item); - + elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description')); + elgg_register_action('river/delete', '', 'admin'); + elgg_register_plugin_hook_handler('unit_test', 'system', 'elgg_river_test'); } diff --git a/languages/en.php b/languages/en.php index 7cd091115..7b4bc9771 100644 --- a/languages/en.php +++ b/languages/en.php @@ -437,6 +437,8 @@ $english = array( 'river:ingroup' => 'in the group %s', 'river:none' => 'No activity', 'river:update' => 'Update for %s', + 'river:delete:success' => 'River item has been deleted', + 'river:delete:fail' => 'River item could not be deleted', 'river:widget:title' => "Activity", 'river:widget:description' => "Display latest activity", -- cgit v1.2.3 From 5d9a8f414432e575b185c30b8e9764ab18f13ccd Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Mon, 9 Jul 2012 19:38:24 -0400 Subject: Refs #4631 $object->canEdit() check not necessary and added a confirm popup on delete to prevent accidental deletes --- engine/lib/navigation.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'engine') diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index 61d283f4b..10b11acfe 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -336,15 +336,16 @@ function elgg_river_menu_setup($hook, $type, $return, $params) { } } - if ($object->canEdit() && elgg_is_admin_logged_in()) { + if (elgg_is_admin_logged_in()) { $options = array( - 'name' => 'delete', - 'href' => "action/river/delete?id=$item->id", - 'text' => elgg_view_icon('delete'), - 'title' => elgg_echo('delete'), - 'is_action' => true, - 'priority' => 200, - ); + 'name' => 'delete', + 'href' => "action/river/delete?id=$item->id", + 'text' => elgg_view_icon('delete'), + 'title' => elgg_echo('delete'), + 'confirm' => elgg_echo('deleteconfirm'), + 'is_action' => true, + 'priority' => 200, + ); $return[] = ElggMenuItem::factory($options); } } -- cgit v1.2.3 From 017b609861984718b73ba909d1b2266d4b144b06 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Mon, 9 Jul 2012 21:41:36 -0400 Subject: Fixes #4685 display proper error on invalid requirement --- engine/classes/ElggPluginManifest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index 7e79c15c8..6b3932b32 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -456,7 +456,7 @@ class ElggPluginManifest { * Normalizes a dependency array using the defined structs. * Can be used with either requires or suggests. * - * @param array $dep An dependency array. + * @param array $dep A dependency array. * @return array The normalized deps array. */ private function normalizeDep($dep) { @@ -500,8 +500,10 @@ class ElggPluginManifest { break; } } - break; + default: + // unrecognized so we just return the raw dependency + return $dep; } $normalized_dep = $this->buildStruct($struct, $dep); -- cgit v1.2.3