/**
 * Get entities with the specified access collection id.
 *
 * @deprecated 1.7. Use elgg_get_entities_from_access_id()
 *
 * @param int    $collection_id  ID of collection
 * @param string $entity_type    Type of entities
 * @param string $entity_subtype Subtype of entities
 * @param int    $owner_guid     Guid of owner
 * @param int    $limit          Limit of number of entities to return
 * @param int    $offset         Skip this many entities
 * @param string $order_by       Column to order by
 * @param int    $site_guid      The site guid
 * @param bool   $count          Return a count or entities
 *
 * @return array
 */
function get_entities_from_access_id($collection_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false)
{
    // log deprecated warning
    elgg_deprecated_notice('get_entities_from_access_id() was deprecated by elgg_get_entities()', 1.7);
    if (!$collection_id) {
        return FALSE;
    }
    // build the options using given parameters
    $options = array();
    $options['limit'] = $limit;
    $options['offset'] = $offset;
    $options['count'] = $count;
    if ($entity_type) {
        $options['type'] = sanitise_string($entity_type);
    }
    if ($entity_subtype) {
        $options['subtype'] = $entity_subtype;
    }
    if ($site_guid) {
        $options['site_guid'] = $site_guid;
    }
    if ($order_by) {
        $options['order_by'] = sanitise_string("e.time_created, {$order_by}");
    }
    if ($owner_guid) {
        if (is_array($owner_guid)) {
            $options['owner_guids'] = $owner_guid;
        } else {
            $options['owner_guid'] = $owner_guid;
        }
    }
    if ($site_guid) {
        $options['site_guid'] = $site_guid;
    }
    $options['access_id'] = $collection_id;
    return elgg_get_entities_from_access_id($options);
}
Esempio n. 2
0
function aga_get_group_acl_count($group, $inout)
{
    $options = array('access_id' => $group->group_acl, 'type' => 'object');
    if ($inout == 'in') {
        $options['container_guids'] = array($group->guid);
    }
    $result = elgg_get_entities_from_access_id($options);
    return $result;
}
Esempio n. 3
0
<?php

/**
 * release time constrained files
 * run through crontab
 *
 */
login($admin);
$admin = get_user(33);
elgg_set_ignore_access(true);
date_default_timezone_set('America/Toronto');
$db_prefix = elgg_get_config("dbprefix");
$joins = array("JOIN {$db_prefix}objects_entity ge ON e.guid = ge.guid", "JOIN {$db_prefix}metadata md on e.guid = md.entity_guid", "JOIN {$db_prefix}metastrings msv ON md.name_id = msv.id");
$wheres = array("msv.string = 'isTimeReleased'");
//get all time released files
$content = elgg_get_entities_from_access_id(array('type' => 'object', 'subtype' => 'file', 'access_id' => 0, 'limit' => 5000, 'joins' => $joins, 'wheres' => $wheres));
foreach ($content as $file) {
    $releaseFlag = false;
    if ($file->releaseDate < date("Y-m-d")) {
        $releaseFlag = true;
    }
    if ($file->releaseDate == date("Y-m-d")) {
        if ($file->releaseTime <= date('H:i', time())) {
            $releaseFlag = true;
        }
    }
    if ($releaseFlag === true) {
        $fileObj = new ElggFile($file->guid);
        $fileObj->access_id = $fileObj->releasedAccessId;
        if ($fileObj->save()) {
            elgg_delete_metadata(array('guid' => $file->guid, 'metadata_name' => 'isTimeReleased'));