Exemple #1
0
/**
 * Recursivly change the access of subfolders (and files)
 *
 * @param ElggObject $folder       the folder to change the access for
 * @param bool       $change_files include files in this folder (default: false)
 *
 * @return void
 */
function file_tools_change_children_access($folder, $change_files = false)
{
    if (!empty($folder) && $folder instanceof ElggObject) {
        if ($folder->getSubtype() == FILE_TOOLS_SUBTYPE) {
            // get children folders
            $options = array("type" => "object", "subtype" => FILE_TOOLS_SUBTYPE, "container_guid" => $folder->getContainerGUID(), "limit" => false, "metadata_name" => "parent_guid", "metadata_value" => $folder->getGUID());
            if ($children = elgg_get_entities_from_metadata($options)) {
                foreach ($children as $child) {
                    $child->access_id = $folder->access_id;
                    $child->save();
                    file_tools_change_children_access($child, $change_files);
                }
            }
            if ($change_files) {
                // change access on files in this folder
                file_tools_change_files_access($folder);
            }
        }
    }
}
Exemple #2
0
    $folder->order = $order;
    if (!$folder->save()) {
        unset($folder);
    }
}
if (empty($folder)) {
    register_error(elgg_echo('file_tools:action:edit:error:folder'));
    forward(REFERER);
}
// check for the correct parent_guid
if (!empty($parent_guid) && $parent_guid === $folder->getGUID()) {
    register_error(elgg_echo('file_tools:action:edit:error:parent_guid'));
    forward(REFERER);
}
$folder->title = $title;
$folder->description = $description;
$folder->access_id = $access_id;
if (!empty($change_children_access)) {
    $folder->save();
    file_tools_change_children_access($folder, !empty($change_files_access));
} elseif (!empty($change_files_access)) {
    $folder->save();
    file_tools_change_files_access($folder);
}
$folder->parent_guid = $parent_guid;
if ($folder->save()) {
    system_message(elgg_echo('file_tools:action:edit:success'));
    forward($folder->getURL());
}
register_error(elgg_echo('file_tools:action:edit:error:save'));
forward(REFERER);
Exemple #3
0
/**
 * Recursivly change the access of subfolders (and files)
 *
 * @param ElggObject $folder       the folder to change the access for
 * @param bool       $change_files include files in this folder (default: false)
 *
 * @return void
 */
function file_tools_change_children_access($folder, $change_files = false)
{
    if (!elgg_instanceof($folder, 'object', FILE_TOOLS_SUBTYPE)) {
        return;
    }
    // get children folders
    $children = new ElggBatch('elgg_get_entities_from_metadata', ['type' => 'object', 'subtype' => FILE_TOOLS_SUBTYPE, 'container_guid' => $folder->getContainerGUID(), 'limit' => false, 'metadata_name_value_pairs' => ['parent_guid' => $folder->getGUID()]]);
    /* @var $child ElggObject */
    foreach ($children as $child) {
        $child->access_id = $folder->access_id;
        $child->save();
        file_tools_change_children_access($child, $change_files);
    }
    if ($change_files) {
        // change access on files in this folder
        file_tools_change_files_access($folder);
    }
}