diff options
Diffstat (limited to 'engine/classes')
-rw-r--r-- | engine/classes/ElggBatch.php | 10 | ||||
-rw-r--r-- | engine/classes/ElggCache.php | 37 | ||||
-rw-r--r-- | engine/classes/ElggEntity.php | 4 | ||||
-rw-r--r-- | engine/classes/ElggMenuItem.php | 295 | ||||
-rw-r--r-- | engine/classes/ElggPlugin.php | 23 | ||||
-rw-r--r-- | engine/classes/ElggPriorityList.php | 358 | ||||
-rw-r--r-- | engine/classes/ElggSite.php | 3 | ||||
-rw-r--r-- | engine/classes/ElggUser.php | 3 |
8 files changed, 574 insertions, 159 deletions
diff --git a/engine/classes/ElggBatch.php b/engine/classes/ElggBatch.php index 49aed800a..62128e34f 100644 --- a/engine/classes/ElggBatch.php +++ b/engine/classes/ElggBatch.php @@ -6,7 +6,7 @@ * This is usually used with elgg_get_entities() and friends, elgg_get_annotations() * and elgg_get_metadata(). * - * If pass a valid PHP callback, all results will be run through that callback. + * If you pass a valid PHP callback, all results will be run through that callback. * You can still foreach() through the result set after. Valid PHP callbacks * can be a string, an array, or a closure. * {@link http://php.net/manual/en/language.pseudo-types.php} @@ -14,10 +14,10 @@ * The callback function must accept 3 arguments: an entity, the getter used, and the options used. * * Results from the callback are stored in callbackResult. - * If the callback returns only booleans callbackResults will be the combined + * If the callback returns only booleans, callbackResults will be the combined * result of all calls. * - * If the callback returns anything else callbackresult will be an indexed array + * If the callback returns anything else, callbackresult will be an indexed array * of whatever the callback returns. If returning error handling information, * you should include enough information to determine which result you're referring * to. @@ -90,7 +90,7 @@ class ElggBatch private $offset = 0; /** - * Stop of this many results. + * Stop after this many results. * * @var unknown_type */ @@ -333,7 +333,7 @@ class ElggBatch $result = current($this->results); } else { - // the function above resets the indexes, so don't only inc if not + // the function above resets the indexes, so only inc if not // getting new set $this->resultIndex++; $result = next($this->results); diff --git a/engine/classes/ElggCache.php b/engine/classes/ElggCache.php index 2e697e0bb..5c2cafcb7 100644 --- a/engine/classes/ElggCache.php +++ b/engine/classes/ElggCache.php @@ -6,9 +6,7 @@ * @package Elgg.Core * @subpackage Cache */ -abstract class ElggCache implements - // Override for array access - ArrayAccess { +abstract class ElggCache implements ArrayAccess { /** * Variables for the cache object. * @@ -141,6 +139,9 @@ abstract class ElggCache implements /** * Load data from the cache using a given key. * + * @todo $offset is a horrible variable name because it creates confusion + * with the ArrayAccess methods + * * @param string $key Name * @param int $offset Offset * @param int $limit Limit @@ -186,12 +187,12 @@ abstract class ElggCache implements // ARRAY ACCESS INTERFACE ////////////////////////////////////////////////////////// /** - * Set offset + * Assigns a value for the specified key * * @see ArrayAccess::offsetSet() * - * @param mixed $key Name - * @param mixed $value Value + * @param mixed $key The key (offset) to assign the value to. + * @param mixed $value The value to set. * * @return void */ @@ -200,43 +201,43 @@ abstract class ElggCache implements } /** - * Get offset + * Get the value for specified key * * @see ArrayAccess::offsetGet() * - * @param mixed $key Name + * @param mixed $offset The key (offset) to retrieve. * - * @return void + * @return mixed */ function offsetGet($key) { return $this->load($key); } /** - * Unsets offset + * Unsets a key. * * @see ArrayAccess::offsetUnset() * - * @param mixed $key Name + * @param mixed $key The key (offset) to unset. * * @return void */ function offsetUnset($key) { - if (isset($this->key)) { - unset($this->key); + if (isset($this->$key)) { + unset($this->$key); } } /** - * Does offset exist + * Does key exist * * @see ArrayAccess::offsetExists() * - * @param mixed $offset Offset + * @param mixed $key A key (offset) to check for. * - * @return void + * @return bool */ - function offsetExists($offset) { - return isset($this->$offset); + function offsetExists($key) { + return isset($this->$key); } } diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index 8fc1e46cb..6edc99dd4 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -851,7 +851,7 @@ abstract class ElggEntity extends ElggData implements */ function countComments() { $params = array('entity' => $this); - $num = trigger_plugin_hook('comments:count', $this->getType(), $params); + $num = elgg_trigger_plugin_hook('comments:count', $this->getType(), $params); if (is_int($num)) { return $num; @@ -1628,7 +1628,7 @@ abstract class ElggEntity extends ElggData implements */ elgg_set_viewtype('default'); - $view = elgg_view_entity($this, true); + $view = elgg_view_entity($this, array('full_view' => true)); elgg_set_viewtype(); $tmp[] = new ODDMetaData($uuid . "volatile/renderedentity/", $uuid, diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 157ed9ceb..cfdc2f5fa 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -10,75 +10,62 @@ * @since 1.8.0 */ class ElggMenuItem { - /** - * @var string Identifier of the menu - */ - protected $name; /** - * @var string The menu display string + * @var array Non-rendered data about the menu item */ - protected $text; + protected $data = array( + // string Identifier of the menu + 'name' => '', - /** - * @var string The menu url - */ - protected $href = null; + // array Page contexts this menu item should appear on + 'contexts' => array('all'), - /** - * @var string The string to display if link is clicked - */ - protected $confirm = ''; + // string Menu section identifier + 'section' => 'default', - /** - * @var array Classes to apply to the anchor tag. - */ - protected $linkClass = array(); + // int Smaller priorities float to the top + 'priority' => 100, - /** - * @var array Classes to apply to the li tag. - */ - protected $itemClass = array(); + // bool Is this the currently selected menu item + 'selected' => false, - /** - * @var array Page context array - */ - protected $contexts = array('all'); + // string Identifier of this item's parent + 'parent_name' => '', - /** - * @var string Menu section identifier - */ - protected $section = 'default'; + // ElggMenuItem The parent object or null + 'parent' => null, - /** - * @var string Tooltip - */ - protected $title = ''; + // array Array of children objects or empty array + 'children' => array(), - /** - * @var int Menu priority - smaller prioritys float to the top - */ - protected $priority = 100; + // array Classes to apply to the li tag + 'itemClass' => array(), + + // array Classes to apply to the anchor tag + 'linkClass' => array(), + ); /** - * @var bool Is this the currently selected menu item + * @var string The menu display string */ - protected $selected = false; + protected $text; /** - * @var string Identifier of this item's parent + * @var string The menu url */ - protected $parent_name = ''; + protected $href = null; /** - * @var ElggMenuItem The parent object or null + * @var string Tooltip */ - protected $parent = null; + protected $title = ''; /** - * @var array Array of children objects or empty array + * @var string The string to display if link is clicked */ - protected $children = array(); + protected $confirm = ''; + /** * ElggMenuItem constructor @@ -88,13 +75,15 @@ class ElggMenuItem { * @param string $href URL of the menu item (false if not a link) */ public function __construct($name, $text, $href) { - $this->name = $name; + //$this->name = $name; $this->text = $text; if ($href) { $this->href = elgg_normalize_url($href); } else { $this->href = $href; } + + $this->data['name'] = $name; } /** @@ -122,6 +111,12 @@ class ElggMenuItem { $options['contexts'] = $options['context']; unset($options['context']); } + + // make sure contexts is set correctly + if (isset($options['contexts'])) { + $item->setContext($options['contexts']); + unset($options['contexts']); + } if (isset($options['link_class'])) { $item->setLinkClass($options['link_class']); @@ -132,17 +127,63 @@ class ElggMenuItem { $item->setItemClass($options['item_class']); unset($options['item_class']); } + + if (isset($options['data']) && is_array($options['data'])) { + $item->setData($options['data']); + unset($options['data']); + } foreach ($options as $key => $value) { - $item->$key = $value; + if (isset($item->data[$key])) { + $item->data[$key] = $value; + } else { + $item->$key = $value; + } } - // make sure contexts is set correctly - if (isset($options['contexts'])) { - $item->setContext($options['contexts']); + return $item; + } + + /** + * Set a data key/value pair or a set of key/value pairs + * + * This method allows storage of arbitrary data with this menu item. The + * data can be used for sorting, custom rendering, or any other use. + * + * @param mixed $key String key or an associative array of key/value pairs + * @param mixed $value The value if $key is a string + * @return void + */ + public function setData($key, $value = null) { + if (is_array($key)) { + $this->data += $key; + } else { + $this->data[$key] = $value; } + } - return $item; + /** + * Get stored data + * + * @param string $key The key for the requested key/value pair + * @return mixed + */ + public function getData($key) { + if (isset($this->data[$key])) { + return $this->data[$key]; + } else { + return null; + } + } + + /** + * Set the identifier of the menu item + * + * @param string Unique identifier + * @return void + */ + public function setName($name) { + $this->data['name'] = $name; } /** @@ -151,11 +192,21 @@ class ElggMenuItem { * @return string */ public function getName() { - return $this->name; + return $this->data['name']; + } + + /** + * Set the display text of the menu item + * + * @param string $text The display text + * @return void + */ + public function setText($text) { + $this->text = $text; } /** - * Get the display text of the menu + * Get the display text of the menu item * * @return string */ @@ -164,6 +215,16 @@ class ElggMenuItem { } /** + * Set the URL of the menu item + * + * @param string $href URL or false if not a link + * @return void + */ + public function setHref($href) { + $this->href = $href; + } + + /** * Get the URL of the menu item * * @return string @@ -176,14 +237,13 @@ class ElggMenuItem { * Set the contexts that this menu item is available for * * @param array $contexts An array of context strings - * * @return void */ public function setContext($contexts) { if (is_string($contexts)) { $contexts = array($contexts); } - $this->contexts = $contexts; + $this->data['contexts'] = $contexts; } /** @@ -192,27 +252,26 @@ class ElggMenuItem { * @return array */ public function getContext() { - return $this->contexts; + return $this->data['contexts']; } /** * Should this menu item be used given the current context * * @param string $context A context string (default is empty string for - * current context stack. - * + * current context stack). * @return bool */ public function inContext($context = '') { if ($context) { - return in_array($context, $this->contexts); + return in_array($context, $this->data['contexts']); } - if (in_array('all', $this->contexts)) { + if (in_array('all', $this->data['contexts'])) { return true; } - foreach ($this->contexts as $context) { + foreach ($this->data['contexts'] as $context) { if (elgg_in_context($context)) { return true; } @@ -224,11 +283,10 @@ class ElggMenuItem { * Set the selected flag * * @param bool $state Selected state (default is true) - * * @return void */ public function setSelected($state = true) { - $this->selected = $state; + $this->data['selected'] = $state; } /** @@ -237,14 +295,13 @@ class ElggMenuItem { * @return bool */ public function getSelected() { - return $this->selected; + return $this->data['selected']; } /** * Set the tool tip text * * @param string $text The text of the tool tip - * * @return void */ public function setTooltip($text) { @@ -264,7 +321,6 @@ class ElggMenuItem { * Set the confirm text shown when link is clicked * * @param string $text The text to show - * * @return void */ public function setConfirmText($text) { @@ -284,14 +340,13 @@ class ElggMenuItem { * Set the anchor class * * @param mixed $class An array of class names, or a single string class name. - * * @return void */ public function setLinkClass($class) { if (!is_array($class)) { - $this->linkClass[] = $class; + $this->data['linkClass'] = array($class); } else { - $this->linkClass = $class; + $this->data['linkClass'] = $class; } } @@ -301,21 +356,34 @@ class ElggMenuItem { * @return string */ public function getLinkClass() { - return implode(' ', $this->linkClass); + return implode(' ', $this->data['linkClass']); } /** - * Set the li classes + * Add a link class * * @param mixed $class An array of class names, or a single string class name. + * @return void + */ + public function addLinkClass($class) { + if (!is_array($class)) { + $this->data['linkClass'][] = $class; + } else { + $this->data['linkClass'] += $class; + } + } + + /** + * Set the li classes * + * @param mixed $class An array of class names, or a single string class name. * @return void */ public function setItemClass($class) { if (!is_array($class)) { - $this->itemClass[] = $class; + $this->data['itemClass'] = array($class); } else { - $this->itemClass = $class; + $this->data['itemClass'] = $class; } } @@ -325,11 +393,13 @@ class ElggMenuItem { * @return string */ public function getItemClass() { - //allow people to specify name with underscores and colons - $name = str_replace('_', '-', $this->getName()); + // allow people to specify name with underscores and colons + $name = strtolower($this->getName()); + $name = str_replace('_', '-', $name); $name = str_replace(':', '-', $name); + $name = str_replace(' ', '-', $name); - $class = implode(' ', $this->itemClass); + $class = implode(' ', $this->data['itemClass']); if ($class) { return "elgg-menu-item-$name $class"; } else { @@ -341,11 +411,10 @@ class ElggMenuItem { * Set the priority of the menu item * * @param int $priority The smaller numbers mean higher priority (1 before 100) - * * @return void */ public function setWeight($priority) { - $this->priority = $priority; + $this->data['priority'] = $priority; } /** @@ -354,18 +423,17 @@ class ElggMenuItem { * @return int */ public function getWeight() { - return $this->priority; + return $this->data['priority']; } /** * Set the section identifier * * @param string $section The identifier of the section - * * @return void */ public function setSection($section) { - $this->section = $section; + $this->data['section'] = $section; } /** @@ -374,18 +442,17 @@ class ElggMenuItem { * @return string */ public function getSection() { - return $this->section; + return $this->data['section']; } /** * Set the parent identifier * - * @param string $parent_name The identifier of the parent ElggMenuItem - * + * @param string $name The identifier of the parent ElggMenuItem * @return void */ - public function setParentName($parent_name) { - $this->parent_name = $parent_name; + public function setParentName($name) { + $this->data['parent_name'] = $name; } /** @@ -394,18 +461,17 @@ class ElggMenuItem { * @return string */ public function getParentName() { - return $this->parent_name; + return $this->data['parent_name']; } /** * Set the parent menu item * * @param ElggMenuItem $parent - * * @return void */ public function setParent($parent) { - $this->parent = $parent; + $this->data['parent'] = $parent; } /** @@ -414,29 +480,27 @@ class ElggMenuItem { * @return ElggMenuItem or null */ public function getParent() { - return $this->parent; + return $this->data['parent']; } /** * Add a child menu item * * @param ElggMenuItem $item - * * @return void */ public function addChild($item) { - $this->children[] = $item; + $this->data['children'][] = $item; } /** * Set the menu item's children * * @param array $children Array of ElggMenuItems - * * @return void */ public function setChildren($children) { - $this->children = $children; + $this->data['children'] = $children; } /** @@ -445,27 +509,25 @@ class ElggMenuItem { * @return array */ public function getChildren() { - return $this->children; + return $this->data['children']; } /** * Sort the children * - * @param string $sort_function - * + * @param string $sortFunction A function that is passed to usort() * @return void */ - public function sortChildren($sort_function) { - usort($this->children, $sort_function); + public function sortChildren($sortFunction) { + usort($this->data['children'], $sortFunction); } /** * Get the menu item content (usually a link) * * @params array $vars Options to pass to output/url if a link - * * @return string - * + * * @todo View code in a model. How do we feel about that? */ public function getContent(array $vars = array()) { @@ -474,26 +536,17 @@ class ElggMenuItem { return $this->text; } - $vars['text'] = $this->text; - - if ($this->href) { - $vars['href'] = $this->href; - } + $defaults = get_object_vars($this); + unset($defaults['data']); - if ($this->linkClass) { - $vars['class'] = $this->getLinkClass(); - } - - if ($this->rel) { - $vars['rel'] = $this->rel; - } - - if ($this->title) { - $vars['title'] = $this->title; - } - - if ($this->is_action) { - $vars['is_action'] = $this->is_action; + $vars += $defaults; + + if ($this->data['linkClass']) { + if (isset($vars['class'])) { + $vars['class'] += $this->getLinkClass(); + } else { + $vars['class'] = $this->getLinkClass(); + } } if ($this->confirm) { diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index 95a7362e2..d837431fc 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -315,9 +315,9 @@ class ElggPlugin extends ElggObject { return false; } // Hook to validate setting - $value = elgg_trigger_plugin_hook('plugin:setting', 'plugin', array( - 'plugin' => $this->pluginID, - 'plugin_object' => $this, + $value = elgg_trigger_plugin_hook('setting', 'plugin', array( + 'plugin_id' => $this->pluginID, + 'plugin' => $this, 'name' => $name, 'value' => $value ), $value); @@ -454,10 +454,11 @@ class ElggPlugin extends ElggObject { } // Hook to validate setting - // note this doesn't pass the namespaced name! - $value = elgg_trigger_plugin_hook('plugin:usersetting', 'user', array( + // note: this doesn't pass the namespaced name + $value = elgg_trigger_plugin_hook('usersetting', 'plugin', array( 'user' => $user, - 'plugin' => $this->getID(), + 'plugin' => $this, + 'plugin_id' => $this->getID(), 'name' => $name, 'value' => $value ), $value); @@ -700,6 +701,11 @@ class ElggPlugin extends ElggObject { // return false; // } + // include classes + if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) { + $this->registerClasses(); + } + // include start file if ($flags & ELGG_PLUGIN_INCLUDE_START) { $this->includeFile('start.php'); @@ -715,11 +721,6 @@ class ElggPlugin extends ElggObject { $this->registerLanguages(); } - // include classes - if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) { - $this->registerClasses(); - } - return true; } diff --git a/engine/classes/ElggPriorityList.php b/engine/classes/ElggPriorityList.php new file mode 100644 index 000000000..aa33831ff --- /dev/null +++ b/engine/classes/ElggPriorityList.php @@ -0,0 +1,358 @@ +<?php +/** + * Iterate over elements in a specific priority. + * + * $pl = new ElggPriorityList(); + * $pl->add('Element 0'); + * $pl->add('Element 10', 10); + * $pl->add('Element -10', -10); + * + * foreach ($pl as $priority => $element) { + * var_dump("$priority => $element"); + * } + * + * Yields: + * -10 => Element -10 + * 0 => Element 0 + * 10 => Element 10 + * + * Collisions on priority are handled by inserting the element at or as close to the + * requested priority as possible: + * + * $pl = new ElggPriorityList(); + * $pl->add('Element 5', 5); + * $pl->add('Colliding element 5', 5); + * $pl->add('Another colliding element 5', 5); + * + * foreach ($pl as $priority => $element) { + * var_dump("$priority => $element"); + * } + * + * Yields: + * 5 => 'Element 5', + * 6 => 'Colliding element 5', + * 7 => 'Another colliding element 5' + * + * You can do priority lookups by element: + * + * $pl = new ElggPriorityList(); + * $pl->add('Element 0'); + * $pl->add('Element -5', -5); + * $pl->add('Element 10', 10); + * $pl->add('Element -10', -10); + * + * $priority = $pl->getPriority('Element -5'); + * + * Or element lookups by priority. + * $element = $pl->getElement(-5); + * + * To remove elements, pass the element. + * $pl->remove('Element -10'); + * + * To check if an element exists: + * $pl->contains('Element -5'); + * + * To move an element: + * $pl->move('Element -5', -3); + * + * ElggPriorityList only tracks priority. No checking is done in ElggPriorityList for duplicates or + * updating. If you need to track this use objects and an external map: + * + * function elgg_register_something($id, $display_name, $location, $priority = 500) { + * // $id => $element. + * static $map = array(); + * static $list; + * + * if (!$list) { + * $list = new ElggPriorityList(); + * } + * + * // update if already registered. + * if (isset($map[$id])) { + * $element = $map[$id]; + * // move it first because we have to pass the original element. + * if (!$list->move($element, $priority)) { + * return false; + * } + * $element->display_name = $display_name; + * $element->location = $location; + * } else { + * $element = new stdClass(); + * $element->display_name = $display_name; + * $element->location = $location; + * if (!$list->add($element, $priority)) { + * return false; + * } + * $map[$id] = $element; + * } + * + * return true; + * } + * + * @package Elgg.Core + * @subpackage Helpers + */ +class ElggPriorityList + implements Iterator, Countable { + + /** + * The list of elements + * + * @var array + */ + private $elements = array(); + + /** + * Create a new priority list. + * + * @param array $elements An optional array of priorities => element + */ + public function __construct(array $elements = array()) { + if ($elements) { + foreach ($elements as $priority => $element) { + $this->add($element, $priority); + } + } + } + + /** + * Adds an element to the list. + * + * @warning This returns the priority at which the element was added, which can be 0. Use + * !== false to check for success. + * + * @param mixed $element The element to add to the list. + * @param mixed $priority Priority to add the element. In priority collisions, the original element + * maintains its priority and the new element is to the next available + * slot, taking into consideration all previously registered elements. + * Negative elements are accepted. + * @return int The priority of the added element. + */ + public function add($element, $priority = null, $exact = false) { + if ($priority !== null && !is_numeric($priority)) { + return false; + } else { + $priority = $this->getNextPriority($priority); + } + + $this->elements[$priority] = $element; + $this->sorted = false; + return $priority; + } + + /** + * Removes an element from the list. + * + * @warning The element must have the same attributes / values. If using $strict, it must have + * the same types. array(10) will fail in strict against array('10') (str vs int). + * + * @param type $element + * @return bool + */ + public function remove($element, $strict = false) { + $index = array_search($element, $this->elements, $strict); + if ($index !== false) { + unset($this->elements[$index]); + return true; + } else { + return false; + } + } + + /** + * Move an existing element to a new priority. + * + * @param mixed $current_priority + * @param int $new_priority + * + * @return int The new priority. + */ + public function move($element, $new_priority, $strict = false) { + $new_priority = (int) $new_priority; + + $current_priority = $this->getPriority($element, $strict); + if ($current_priority === false) { + return false; + } + + if ($current_priority == $new_priority) { + return true; + } + + // move the actual element so strict operations still work + $element = $this->getElement($current_priority); + unset($this->elements[$current_priority]); + return $this->add($element, $new_priority); + } + + /** + * Returns the elements + * + * @return array + */ + public function getElements() { + $this->sortIfUnsorted(); + return $this->elements; + } + + /** + * Sort the elements optionally by a callback function. + * + * If no user function is provided the elements are sorted by priority registered. + * + * The callback function should accept the array of elements as the first argument and should + * return a sorted array. + * + * This function can be called multiple times. + * + * @param type $callback + * @return bool + */ + public function sort($callback = null) { + if (!$callback) { + ksort($this->elements, SORT_NUMERIC); + } else { + $sorted = call_user_func($callback, $this->elements); + + if (!$sorted) { + return false; + } + + $this->elements = $sorted; + } + + $this->sorted = true; + return true; + } + + /** + * Sort the elements if they haven't been sorted yet. + * + * @return bool + */ + private function sortIfUnsorted() { + if (!$this->sorted) { + return $this->sort(); + } + } + + /** + * Returns the next priority available. + * + * @param int $near Make the priority as close to $near as possible. + * @return int + */ + public function getNextPriority($near = 0) { + $near = (int) $near; + + while (array_key_exists($near, $this->elements)) { + $near++; + } + + return $near; + } + + /** + * Returns the priority of an element if it exists in the list. + * + * @warning This can return 0 if the element's priority is 0. + * + * @param mixed $element The element to check for. + * @param bool $strict Use strict checking? + * @return mixed False if the element doesn't exists, the priority if it does. + */ + public function getPriority($element, $strict = false) { + return array_search($element, $this->elements, $strict); + } + + /** + * Returns the element at $priority. + * + * @param int $priority + * @return mixed The element or false on fail. + */ + public function getElement($priority) { + return (isset($this->elements[$priority])) ? $this->elements[$priority] : false; + } + + /** + * Returns if the list contains $element. + * + * @param mixed $element The element to check. + * @param bool $strict Use strict checking? + * @return bool + */ + public function contains($element, $strict = false) { + return $this->getPriority($element, $strict) !== false; + } + + + /********************** + * Interface methods * + **********************/ + + /** + * Iterator + */ + + /** + * PHP Iterator Interface + * + * @see Iterator::rewind() + * @return void + */ + public function rewind() { + $this->sortIfUnsorted(); + return rewind($this->elements); + } + + /** + * PHP Iterator Interface + * + * @see Iterator::current() + * @return mixed + */ + public function current() { + $this->sortIfUnsorted(); + return current($this->elements); + } + + /** + * PHP Iterator Interface + * + * @see Iterator::key() + * @return int + */ + public function key() { + $this->sortIfUnsorted(); + return key($this->elements); + } + + /** + * PHP Iterator Interface + * + * @see Iterator::next() + * @return mixed + */ + public function next() { + $this->sortIfUnsorted(); + return next($this->elements); + } + + /** + * PHP Iterator Interface + * + * @see Iterator::valid() + * @return bool + */ + public function valid() { + $this->sortIfUnsorted(); + $key = key($this->elements); + return ($key !== NULL && $key !== FALSE); + } + + // Countable + public function count() { + return count($this->elements); + } +}
\ No newline at end of file diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index e3b8b8f1a..40bfca060 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -410,8 +410,9 @@ class ElggSite extends ElggEntity { 'register', 'action/register', 'forgotpassword', - 'action/user/requestnewpassword', 'resetpassword', + 'action/user/requestnewpassword', + 'action/user/passwordreset', 'upgrade\.php', 'xml-rpc\.php', 'mt/mt-xmlrpc\.cgi', diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index 1af4cdc3a..75ac008f6 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -484,7 +484,8 @@ class ElggUser extends ElggEntity * @return array|false */ public function getCollections($subtype = "", $limit = 10, $offset = 0) { - return get_user_collections($this->getGUID(), $subtype, $limit, $offset); + elgg_deprecated_notice("ElggUser::getCollections() has been deprecated", 1.8); + return false; } /** |