Exemplo n.º 1
0
function event_shutdown()
{
    State::$handle_updates = false;
    if (State::$users_leaving_probation) {
        set_time_limit(0);
    }
    $ia = elgg_set_ignore_access(true);
    $force_private = elgg_get_plugin_setting(QUARANTINE_PRIVATE, PLUGIN_ID);
    foreach (State::$entities_quarantined as $entity) {
        if ($entity->{ORIGINAL_ACCESS_ID} === null || $entity->access_id != ACCESS_PRIVATE) {
            $entity->{ORIGINAL_ACCESS_ID} = $entity->access_id;
        }
        if ($force_private) {
            $entity->access_id = ACCESS_PRIVATE;
        } elseif ($entity->access_id == ACCESS_PUBLIC) {
            $entity->access_id = ACCESS_LOGGED_IN;
        }
        $entity->save();
    }
    foreach (State::$users_leaving_probation as $user) {
        $options = ['owner_guid' => $user->guid, 'metadata_name' => QUARANTINED, 'metadata_value' => '1', 'limit' => 0];
        $batch = new \ElggBatch('elgg_get_entities_from_metadata', $options, null, 25, false);
        foreach ($batch as $object) {
            /* @var \ElggObject $object */
            approve_content($object);
        }
    }
    elgg_set_ignore_access($ia);
}
Exemplo n.º 2
0
function approve_content(\ElggObject $object)
{
    $object->deleteMetadata(QUARANTINED);
    $access_id = $object->{ORIGINAL_ACCESS_ID};
    // delete it so our update handler doesn't re-set it
    $object->deleteMetadata(ORIGINAL_ACCESS_ID);
    if ($access_id !== null) {
        $object->access_id = (int) $access_id;
        $handle = State::$handle_updates;
        State::$handle_updates = false;
        $object->save();
        State::$handle_updates = $handle;
    } else {
        $access_id = $object->access_id;
    }
    // just in case plugins look at river.access_id
    update_river_access_by_object($object->guid, $access_id);
}