public static function secureCookieTreeTwo::delete_node in Secure Cookie Data 7.2
Removes a certain node from the tree stored as cookie data.
Parameters
array $element: Specification of the element to delete.
object $data: The data tree as an object.
Return value
nothing Side effects only.
1 call to secureCookieTreeTwo::delete_node()
- secure_cookie_data_tree_two_delete in modules/
secure_cookie_data_tree_two.module - Delete the node of a tree.
File
- modules/
secure_cookie_data_tree_two.class.inc, line 92 - secure_cookie_data_tree_two.class.inc @author António P. P. Almeida <appa@perusio.net> @date Mon Dec 2 11:59:02 2013
Class
- secureCookieTreeTwo
- @file secure_cookie_data_tree_two.class.inc @author António P. P. Almeida <appa@perusio.net> @date Mon Dec 2 11:59:02 2013
Code
public static function delete_node($element, $data = NULL) {
// Get the cookie data if not given.
if (empty($data)) {
$cookie_data = self::get();
}
else {
$cookie_data = $data;
}
// Get the element description to know at which depth a tree branch should
// be pruned.
$keys = array_keys($element);
// Check to see if we are at the first or at the second level and proceed
// accordingly.
if (in_array('label_level1', $keys)) {
if (isset($cookie_data->data->{$element}[$element['label_level0']]->{$element}['label_level1'])) {
unset($cookie_data->data->{$element}[$element['label_level0']]->{$element}['label_level1']);
}
}
elseif (in_array('label_level0', $keys)) {
if (isset($cookie_data->data->{$element}[$element['label_level0']])) {
unset($cookie_data->data->{$element}[$element['label_level0']]);
}
}
elseif (count($keys) == 1 && $keys[0] == 'ALL' && $element['ALL']) {
if (isset($cookie_data)) {
self::delete();
}
}
else {
return FALSE;
}
// Set the cookie without the deleted node.
self::set_tree($cookie_data);
}