Public Member Functions | |
reload_collection () | |
insertElement ( $in_element, $in_before_index=-1, $dont_update=false) | |
insertElements ( $in_element_array, $in_before_index=-1) | |
deleteElements ( $in_first_index, $in_deletion_length) | |
deleteElement ( $in_index) | |
deleteThisElement ( $in_element) | |
appendElement ( $in_element) | |
appendElements ( $in_element_array) | |
deleteAllChildren () | |
indexOfThisElement ( $in_element) | |
whosYourDaddy ( $in_element) | |
areYouMyDaddy ( $in_element, $full_hierachy=true) | |
map ( $in_function) | |
recursiveMap ( $in_function, $in_hierarchy_level=0, $in_parent_object=NULL, $loop_stopper=Array()) | |
count ( $is_recursive=false) | |
children () | |
children_ids ( $in_raw=false) | |
set_children_ids ( $in_new_ids) | |
who_are_my_parents () | |
getHierarchy ( $loop_stopper=Array()) | |
Protected Member Functions | |
_scrub () | |
_set_up_container () | |
Protected Attributes | |
$_container | |
This contains instances of the records referenced by the IDs stored in the object. More... | |
This is a trait for the basic "collection" aggregator functionality.
Yes, I know that a lot of the code could do with some refactoring, and we should do that, but what we have here does work, and having pretty code is less important than having effective, tested, working code. We have a lot on our plate.
Definition at line 37 of file tco_collection.interface.php.
|
protected |
This is a "garbage collection" method. This checks each of the contained items, and removes the ID if the item does not actually exist (security is not taken into account, so it's an accurate check).
Definition at line 45 of file tco_collection.interface.php.
|
protected |
This method simply sets up the internal container from the object's tags. The tags already need to be loaded when this is called, so it should be called towards the end of the object's constructor.
Definition at line 73 of file tco_collection.interface.php.
Referenced by CO_User_Collection\load_from_db().
tCO_Collection::appendElement | ( | $in_element | ) |
This appends one record to the end of the collection. The element cannot be already in the collection at any level, as that could cause a loop. The logged-in user must have write access to the collection object (not the data object) in order to add the item. You can opt out of the automatic database update.
$in_element | The database record to add. |
Definition at line 383 of file tco_collection.interface.php.
tCO_Collection::appendElements | ( | $in_element_array | ) |
This appends multiple elements (passed as an array). The logged-in user must have write access to the collection object (not the data object) in order to add the items.
$in_element_array | An array of database element instances to be appended. |
Definition at line 396 of file tco_collection.interface.php.
tCO_Collection::areYouMyDaddy | ( | $in_element, | |
$full_hierachy = true |
|||
) |
This takes an element, and checks to see if it already exists in our hierarchy (anywhere).
$in_element | The element to check. This can be an array, in which case, each element is checked. |
$full_hierachy | If false, then only this level (not the full hierarchy) will be searched. Default is true. |
Definition at line 473 of file tco_collection.interface.php.
tCO_Collection::children | ( | ) |
This is an accessor for the child object array (instances). It should be noted that this may not be the same as the 'children' context variable, because the user may not be allowed to see all of the items.
Definition at line 591 of file tco_collection.interface.php.
Referenced by CO_User_Collection\delete_from_db().
tCO_Collection::children_ids | ( | $in_raw = false | ) |
This is an accessor that returns a list of IDs for the direct children of this instance. This is "security vetted," so only IDs of children visible to the logged-in user are returned.
$in_raw | This is only valid for "God Mode." If true, then the array is returned with no scrub, and no checks. |
Definition at line 606 of file tco_collection.interface.php.
tCO_Collection::count | ( | $is_recursive = false | ) |
This counts the direct children of this collection, and returns that count. If recursive, then it counts everything inside, including owners. Remember that this is "security-aware." The collection may have children that are not visible to the current login.
$is_recursive | If true, then this will also count all "child" collections. Default is false. |
Definition at line 564 of file tco_collection.interface.php.
Referenced by CO_User_Collection\is_god(), CO_User_Collection\set_tag(), and CO_User_Collection\set_tags().
tCO_Collection::deleteAllChildren | ( | ) |
This deletes all children of the container. However, the container may have children we can't see, so we don't delete those. We only delete the ones we know about (which could be all of them).
Definition at line 408 of file tco_collection.interface.php.
tCO_Collection::deleteElement | ( | $in_index | ) |
Deletes a single element, by its 0-based index (not recursive). It should be noted that this does not delete the element from the database, and it is not recursive.
$in_index | The 0-based index of the element we want to delete. |
Definition at line 348 of file tco_collection.interface.php.
tCO_Collection::deleteElements | ( | $in_first_index, | |
$in_deletion_length | |||
) |
Deletes multiple elements from the collection. It should be noted that this does not delete the elements from the database, and it is not recursive. This is an atomic operation. If any of the elements can't be removed, then non of the elements can be removed. The one exception is that the deletion length can extend past the boundaries of the collection. It will be truncated.
$in_first_index | The starting 0-based index of the first element to be removed from the collection. |
$in_deletion_length | The number of elements to remove (including the first one). If this is negative, then elements will be removed from the index, backwards (-1 is the same as 1). |
Definition at line 279 of file tco_collection.interface.php.
References CO_CHAMELEON_Lang_Common\$co_collection_error_code_user_not_authorized, CO_CHAMELEON_Lang\$co_collection_error_desc_user_not_authorized, and CO_CHAMELEON_Lang\$co_collection_error_name_user_not_authorized.
tCO_Collection::deleteThisElement | ( | $in_element | ) |
Deletes a single element, by its actual object reference (not recursive). It should be noted that this does not delete the element from the database, and it is not recursive.
$in_element | The element we want to delete. |
Definition at line 360 of file tco_collection.interface.php.
tCO_Collection::getHierarchy | ( | $loop_stopper = Array() | ) |
$loop_stopper | This is used to prevent "hierarchy loops." As we descend into recursion, we save the collection ID here. If the ID shows up in a "lower" collection, we don't add that collection. This shouldn't happen anyway, as were're not supposed to have been able to add embedded collections, but we can't be too careful. There can only be one... |
Definition at line 683 of file tco_collection.interface.php.
tCO_Collection::indexOfThisElement | ( | $in_element | ) |
$in_element | The element we're looking for. |
Definition at line 433 of file tco_collection.interface.php.
tCO_Collection::insertElement | ( | $in_element, | |
$in_before_index = -1 , |
|||
$dont_update = false |
|||
) |
This inserts one record to just before the indexed item (0-based index). If the index is -1, the length of the collection or larger, then the item will be appeneded. Collection elements cannot be already in the collection at any level, as that could cause a loop. We also don't allow duplicates of any instance in the same level of a collection. Only the first instance is retained. Subsequent copies are removed. The logged-in user must have write access to the collection object (not the data object) in order to add the item. You can opt out of the automatic database update.
$in_element | The database record to add. |
$in_before_index | The index of the element (in the current list) BEFORE which the insertion will be made. Default is -1 (append). |
$dont_update | true, if we are to skip the DB update (default is false). |
Definition at line 102 of file tco_collection.interface.php.
References CO_CHAMELEON_Lang_Common\$co_collection_error_code_user_not_authorized, CO_CHAMELEON_Lang\$co_collection_error_desc_user_not_authorized, and CO_CHAMELEON_Lang\$co_collection_error_name_user_not_authorized.
tCO_Collection::insertElements | ( | $in_element_array, | |
$in_before_index = -1 |
|||
) |
This inserts multiple records to just before the indexed item (0-based index). If the index is -1, the length of the collection or larger, then the items will be appeneded. Collection elements cannot be already in the collection at any level, as that could cause a loop. We also don't allow duplicates of any class in the same level of a collection. Only the first instance is retained. Subsequent copies are removed. The logged-in user must have write access to the collection object (not the data objects) in order to add the items. You can opt out of the automatic database update.
$in_element_array | An array of database element instances to be inserted. |
$in_before_index | The index of the element (in the current list) BEFORE which the insertion will be made. Default is -1 (append). |
Definition at line 182 of file tco_collection.interface.php.
References CO_CHAMELEON_Lang_Common\$co_collection_error_code_user_not_authorized, CO_CHAMELEON_Lang\$co_collection_error_desc_user_not_authorized, and CO_CHAMELEON_Lang\$co_collection_error_name_user_not_authorized.
tCO_Collection::map | ( | $in_function | ) |
This applies a given function to each of the elements in the child list. The function needs to have a signature of function mixed map_func(mixed $item);
$in_function | The function to be applied to each element. |
Definition at line 506 of file tco_collection.interface.php.
tCO_Collection::recursiveMap | ( | $in_function, | |
$in_hierarchy_level = 0 , |
|||
$in_parent_object = NULL , |
|||
$loop_stopper = Array() |
|||
) |
This applies a given function to each of the elements in the child list, and any embedded (recursive) ones. The function needs to have a signature of function mixed map_func(mixed $item, integer $hierarchy_level, mixed $parent_object);
$in_function | This is the function to be applied to all elements. |
$in_hierarchy_level | This is a 0-based integer that tells the callback how many "levels deep" the function is. |
$in_parent_object | This is the collection object that is the "parent" of the current array. |
$loop_stopper | This is used to prevent "hierarchy loops." As we descend into recursion, we save the collection ID here. If the ID shows up in a "lower" collection, we don't add that collection. This shouldn't happen anyway, as were're not supposed to have been able to add embedded collections, but we can't be too careful. There can only be one... |
Definition at line 527 of file tco_collection.interface.php.
tCO_Collection::reload_collection | ( | ) |
This method forces a reload of the collection data.
Definition at line 87 of file tco_collection.interface.php.
tCO_Collection::set_children_ids | ( | $in_new_ids | ) |
This is a "God Mode-only" method that is used to wholesale replace the entire children array.
$in_new_ids | This is an array of integers, with the IDs of new children. This entirely replaces the current array. |
Definition at line 640 of file tco_collection.interface.php.
tCO_Collection::who_are_my_parents | ( | ) |
Definition at line 658 of file tco_collection.interface.php.
tCO_Collection::whosYourDaddy | ( | $in_element | ) |
This takes an element, and returns its parent collection object (if available). This only checks the current collection and its "child" collection objects.
$in_element | The element to check. |
Definition at line 445 of file tco_collection.interface.php.
|
protected |
This contains instances of the records referenced by the IDs stored in the object.
Definition at line 38 of file tco_collection.interface.php.