当前位置: 首页>>代码示例>>PHP>>正文


PHP elgg_get_entities函数代码示例

本文整理汇总了PHP中elgg_get_entities函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_entities函数的具体用法?PHP elgg_get_entities怎么用?PHP elgg_get_entities使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了elgg_get_entities函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_notifier_page_handler

function set_notifier_page_handler($page, $identifier)
{
    // select page based on first URL segment after /set_notifier/
    switch ($page[0]) {
        case 'set':
            gatekeeper();
            $num_users = 1;
            $limit = 100;
            $offset = 0;
            while ($num_users != 0) {
                $users = elgg_get_entities(array('types' => 'user', 'limit' => $limit, 'offset' => $offset));
                if ($users != 0) {
                    foreach ($users as $user) {
                        $prefix = "notification:method:notifier";
                        $user->{$prefix} = true;
                        $user->collections_notifications_preferences_notifier = '-1';
                        $user->save();
                    }
                }
                $num_users = count($users);
                $offset += $limit;
            }
            forward(REFERER);
            break;
        default:
            echo "request for {$identifier} {$page['0']}";
            break;
    }
    // return true to let Elgg know that a page was sent to browser
    return true;
}
开发者ID:rtugores,项目名称:set_notifier,代码行数:31,代码来源:start.php

示例2: hj_forum_get_forum_category_input_options

function hj_forum_get_forum_category_input_options($entity = null, $container = null)
{
    if ((elgg_instanceof($container, 'site') || elgg_instanceof($container, 'group')) && !HYPEFORUM_CATEGORIES_TOP) {
        return false;
    }
    if (elgg_instanceof($container, 'object', 'hjforum') && !HYPEFORUM_CATEGORIES) {
        return false;
    }
    if (!$entity && !$container) {
        return false;
    }
    if (elgg_instanceof($container, 'object', 'hjforum') && !$container->enable_subcategories) {
        return false;
    }
    $dbprefix = elgg_get_config('dbprefix');
    $categories = elgg_get_entities(array('types' => 'object', 'subtypes' => 'hjforumcategory', 'limit' => 0, 'container_guids' => $container->guid, 'joins' => array("JOIN {$dbprefix}objects_entity oe ON oe.guid = e.guid"), 'order_by' => 'oe.title ASC'));
    if ($categories) {
        foreach ($categories as $category) {
            $options_values[$category->guid] = $category->title;
        }
        if ($entity) {
            $categories = $entity->getCategories('hjforumcategory');
            $value = $categories[0]->guid;
        }
        $options = array('input_type' => 'dropdown', 'options_values' => $options_values, 'value' => $value);
    } else {
        if ($container->canWriteToContainer(0, 'object', 'hjforumcategory')) {
            $options = array('input_type' => 'text', 'override_view' => 'output/url', 'text' => elgg_echo('hj:forum:create:category'), 'href' => "forum/create/category/{$container->guid}");
        } else {
            return false;
        }
    }
    return $options;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:34,代码来源:forms.php

示例3: subscribers

 /**
  * Get notification preferences of users who have answered the poll
  *
  * The poll contents have changed so we must notify the people
  * who had answered before the changes took place.
  *
  * @param string $hook          'get'
  * @param string $type          'subscriptions'
  * @param array  $subscriptions Array containing subscriptions in the form
  *                              <user guid> => array('email', 'site', etc.)
  * @param array  $params        Hook parameters
  * @return array
  */
 public static function subscribers($hook,   $type, $subscriptions, $params)
 {
     $poll = $params['event']->getObject();
     if (!$poll instanceof \ElggSchedulingPoll) {
         return $subscriptions;
     }
     $subscriptions = array();
     $voters = array_keys($poll->getVotesByUser());
     if (empty($voters)) {
         // There's no one to notify
         return $subscriptions;
     }
     // Get all available notification methods
     $methods = _elgg_services()->notifications->getMethods();
     // Get all users who have voted
     $users = elgg_get_entities(array('type' => 'user', 'guids' => $voters, 'limit' => 0));
     // Personal notification settings are saved into a metadata
     // called notification:method:{$method}. Go through the users
     // and check which methods have been enabled for each user.
     foreach ($users as $user) {
         foreach ($methods as $method) {
             $meta_name = "notification:method:{$method}";
             if ((bool) $user->{$meta_name}) {
                 $subscriptions[$user->guid][] = $method;
             }
         }
     }
     return $subscriptions;
 }
开发者ID:lorea,项目名称:Hydra-dev,代码行数:42,代码来源:Notification.php

示例4: upgrade_20141125

function upgrade_20141125()
{
    $version = (int) elgg_get_plugin_setting('version', PLUGIN_ID);
    if ($version == 2011111502) {
        // this didn't happen correctly in the last upgrade
        // due to some legacy setting
        elgg_set_plugin_setting('version', 20141121, PLUGIN_ID);
        $version = 20141121;
    }
    if ($version >= UPGRADE_VERSION) {
        return true;
    }
    $options = array('type' => 'object', 'subtype' => 'plugin_project', 'limit' => false);
    $batch = new ElggBatch('elgg_get_entities', $options);
    foreach ($batch as $plugin) {
        // get most recent release
        $releases = elgg_get_entities(array('type' => 'object', 'subtype' => 'plugin_release', 'container_guid' => $plugin->guid, 'limit' => 1, 'callback' => false));
        if ($releases[0]->time_created) {
            update_entity_last_action($plugin->guid, $releases[0]->time_created);
        } else {
            update_entity_last_action($plugin->guid, $plugin->time_created);
        }
    }
    elgg_set_plugin_setting('version', 20141125, PLUGIN_ID);
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:25,代码来源:upgrades.php

示例5: batch_find_images

function batch_find_images()
{
    $log = elgg_get_config('mfp_log');
    $logtime = elgg_get_config('mfp_logtime');
    // only search
    $options = array('type' => 'object', 'subtype' => 'image', 'limit' => 0);
    $images = new ElggBatch('elgg_get_entities', $options);
    $count = 0;
    $bad_images = 0;
    $total = elgg_get_entities(array_merge($options, array('count' => true)));
    file_put_contents($log, "Starting scan of {$total} images" . "\n", FILE_APPEND);
    foreach ($images as $image) {
        $count++;
        // don't use ->exists() because of #5207.
        if (!is_file($image->getFilenameOnFilestore())) {
            $bad_images++;
            $image->mfp_delete_check = $logtime;
        }
        if ($count == 1 || !($count % 25)) {
            $time = date('Y-m-d g:ia');
            $message = "Checked {$count} of {$total} images as of {$time}";
            file_put_contents($log, $message . "\n", FILE_APPEND);
        }
    }
    $message = '<div class="done"><a href="#" id="elgg-tidypics-broken-images-delete" data-time="' . $logtime . '">Delete ' . $bad_images . ' broken images</a></div>';
    file_put_contents($log, $message . "\n", FILE_APPEND);
}
开发者ID:arckinteractive,项目名称:tidypics_cleanup,代码行数:27,代码来源:broken_images.php

示例6: current_dokuwiki_entity

function current_dokuwiki_entity($create = true)
{
    $page_owner = elgg_get_page_owner_guid();
    $user = elgg_get_logged_in_user_entity();
    //error_log($page_owner->guid);
    //error_log($user->guid);
    if (!$page_owner) {
        $page_owner = 0;
    }
    $entities = elgg_get_entities(array('types' => 'object', 'subtypes' => 'dokuwiki', 'limit' => 1, 'owner_guid' => $page_owner));
    if ($entities) {
        $doku = $entities[0];
        return $doku;
    } elseif ($user && $create) {
        elgg_set_ignore_access(true);
        $newdoku = new ElggObject();
        $newdoku->access_id = ACCESS_PUBLIC;
        $newdoku->owner_guid = $page_owner;
        $newdoku->subtype = 'dokuwiki';
        $newdoku->container_guid = $page_owner;
        $newdoku->save();
        $acl = array();
        $acl[] = "# acl.auth.php";
        $acl[] = '# <?php exit()?\\>';
        $acl[] = "*               @ALL        0";
        $acl[] = "*               @user        1";
        $acl[] = "*               @member        8";
        $acl[] = "*               @admin        16";
        $acl[] = "*               @root        255";
        $newdoku->wiki_acl = implode("\n", $acl) . "\n";
        elgg_set_ignore_access(false);
        return $newdoku;
    }
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:34,代码来源:dokuwiki.php

示例7: show_members_json

 function show_members_json($context, $limit = 30, $offset = 0, $username)
 {
     if (!$username) {
         $user = elgg_get_logged_in_user_entity();
     } else {
         $user = get_user_by_username($username);
         if (!$user) {
             throw new InvalidParameterException('registration:usernamenotvalid');
         }
     }
     if ($context == "newest") {
         $params = array('types' => 'user', 'limit' => $limit, 'full_view' => FALSE);
         $latest_member = elgg_get_entities($params);
         //return $return;
     }
     if ($context == "online") {
         $latest_member = get_online_users();
     }
     if ($context == "popular") {
         $params = array('types' => 'user', 'relationship' => 'friend', 'inverse_relationship' => false);
         $latest_member = elgg_list_entities_from_relationship_count($params);
     }
     if ($latest_member) {
         foreach ($latest_member as $single) {
             $member['guid'] = $single->guid;
             $member['name'] = $single->name;
             //$member['avatar_url'] = get_entity_icon_url($single,'small');
             $return[] = $member;
         }
     }
     //return $return;
     return json_encode($return, true);
 }
开发者ID:elahegol,项目名称:APIPlugin,代码行数:33,代码来源:member.php

示例8: migrateEntitiesToJSON

 /**
  * Migrates old (pre MenuBuilder 2.0) menu entities to json
  *
  * @return void
  */
 public static function migrateEntitiesToJSON()
 {
     $ia = elgg_set_ignore_access(true);
     $menu = new \ColdTrick\MenuBuilder\Menu('site');
     $menu->save();
     $options = ['type' => 'object', 'subtype' => 'menu_builder_menu_item', 'limit' => false];
     $entities = elgg_get_entities($options);
     if (empty($entities)) {
         elgg_set_ignore_access($ia);
         return;
     }
     foreach ($entities as $menu_item) {
         $parent_name = null;
         $parent_guid = $menu_item->parent_guid;
         if ($parent_guid) {
             $parent = get_entity($parent_guid);
             if ($parent) {
                 $parent_name = "menu_name_{$parent_guid}";
             }
         }
         $menu->addMenuItem(['name' => "menu_name_{$menu_item->guid}", 'text' => $menu_item->title, 'href' => $menu_item->url, 'target' => $menu_item->target, 'is_action' => $menu_item->is_action, 'access_id' => $menu_item->access_id, 'priority' => $menu_item->order, 'parent_name' => $parent_name]);
     }
     // delete entities need to do it afterwards as parents are not always available otherwise
     foreach ($entities as $menu_item) {
         $menu_item->delete();
     }
     elgg_set_ignore_access($ia);
 }
开发者ID:coldtrick,项目名称:menu_builder,代码行数:33,代码来源:Upgrade.php

示例9: bookmark_tools_get_folders

function bookmark_tools_get_folders($container_guid = 0)
{
    $result = false;
    if (empty($container_guid)) {
        $container_guid = elgg_get_page_owner_guid();
    }
    if (!empty($container_guid)) {
        $options = array("type" => "object", "subtype" => BOOKMARK_TOOLS_SUBTYPE, "container_guid" => $container_guid, "limit" => false);
        if ($folders = elgg_get_entities($options)) {
            $parents = array();
            foreach ($folders as $folder) {
                $parent_guid = (int) $folder->parent_guid;
                if (!empty($parent_guid)) {
                    if ($temp = get_entity($parent_guid)) {
                        if ($temp->getSubtype() != BOOKMARK_TOOLS_SUBTYPE) {
                            $parent_guid = 0;
                        }
                    } else {
                        $parent_guid = 0;
                    }
                } else {
                    $parent_guid = 0;
                }
                if (!array_key_exists($parent_guid, $parents)) {
                    $parents[$parent_guid] = array();
                }
                $parents[$parent_guid][] = $folder;
            }
            $result = bookmark_tools_sort_folders($parents, 0);
        }
    }
    return $result;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:33,代码来源:functions.php

示例10: file_tools_get_folders

/**
 * Get the folders in a container
 *
 * @param int $container_guid the container to check
 *
 * @return bool|ElggObject[]
 */
function file_tools_get_folders($container_guid = 0)
{
    $container_guid = (int) $container_guid;
    if (empty($container_guid)) {
        $container_guid = elgg_get_page_owner_guid();
    }
    if (empty($container_guid)) {
        return false;
    }
    $folders = elgg_get_entities(['type' => 'object', 'subtype' => FILE_TOOLS_SUBTYPE, 'container_guid' => $container_guid, 'limit' => false]);
    if (empty($folders)) {
        return false;
    }
    $parents = array();
    /* @var $folder ElggObject */
    foreach ($folders as $folder) {
        $parent_guid = (int) $folder->parent_guid;
        if (!empty($parent_guid)) {
            $temp = get_entity($parent_guid);
            if (!elgg_instanceof($temp, 'object', FILE_TOOLS_SUBTYPE)) {
                $parent_guid = 0;
            }
        }
        if (!array_key_exists($parent_guid, $parents)) {
            $parents[$parent_guid] = [];
        }
        $parents[$parent_guid][] = $folder;
    }
    return file_tools_sort_folders($parents, 0);
}
开发者ID:coldtrick,项目名称:file_tools,代码行数:37,代码来源:functions.php

示例11: ckeditor_extended_get_inline_object

/**
 * Returns the object based on the id
 *
 * @param string  $id     id of the object to find
 * @param boolean $create should the object be created if id is missing
 *
 * @return /ElggObject|false
 */
function ckeditor_extended_get_inline_object($id, $create = false)
{
    static $cached = [];
    if (empty($id)) {
        return false;
    }
    $prefix = elgg_extract(0, explode('_', $id));
    if (!array_key_exists($prefix, $cached)) {
        $cached[$prefix] = [];
        // preload entities
        $entities = elgg_get_entities(['type' => 'object', 'subtype' => 'ckeditor_inline', 'limit' => false, 'joins' => 'JOIN ' . elgg_get_config('dbprefix') . "objects_entity oe ON oe.guid = e.guid", 'wheres' => "oe.title LIKE '{$prefix}%'"]);
        foreach ($entities as $entity) {
            $cached[$prefix][$entity->title] = $entity;
        }
    }
    if (array_key_exists($id, $cached[$prefix])) {
        return $cached[$prefix][$id];
    }
    if (!$create) {
        return false;
    }
    $object = new \ElggObject();
    $object->subtype = 'ckeditor_inline';
    $object->title = $id;
    $object->owner_guid = elgg_get_site_entity()->guid;
    $object->container_guid = elgg_get_site_entity()->guid;
    $object->access_id = ACCESS_PUBLIC;
    $cached[$prefix][$id] = $object;
    return $object;
}
开发者ID:coldtrick,项目名称:ckeditor_extended,代码行数:38,代码来源:functions.php

示例12: search_by_proximity_hook

function search_by_proximity_hook($hook, $type, $return, $params)
{
    $query = $params['query'];
    $coords = elgg_geocode_location($query);
    if (!$coords) {
        return $return;
    }
    $registered_entities = elgg_get_config('registered_entities');
    $options = array('types' => array('object', 'user', 'group'), 'subtypes' => array_merge($registered_entities['object'], $registered_entities['user'], $registered_entities['group']), 'limit' => get_input('limit', 20), 'offset' => get_input('proximity_offset', 0), 'offset_key' => 'proximity_offset', 'count' => true);
    $options = add_order_by_proximity_clauses($options, $coords['lat'], $coords['long']);
    $options = add_distance_constraint_clauses($options, $coords['lat'], $coords['long'], SEARCH_RADIUS);
    $count = elgg_get_entities($options);
    if ($count) {
        $options['count'] = false;
        $entities = elgg_get_entities($options);
    }
    if ($entities) {
        foreach ($entities as $entity) {
            $name = search_get_highlighted_relevant_substrings(isset($entity->name) ? $entity->name : $entity->title, $query);
            $entity->setVolatileData('search_matched_title', $name);
            $location = search_get_highlighted_relevant_substrings($entity->getLocation(), $query);
            $entity->setVolatileData('search_matched_location', $location);
            $distance = get_distance($entity->getLatitude(), $entity->getLongitude(), $coords['lat'], $coords['long']);
            // distance in metres
            $distance = round($distance / 1000, 2);
            // distance in km
            $distance_str = elgg_echo('geo:search:proximity', array($query, $distance));
            $entity->setVolatileData('search_proximity', $distance_str);
        }
    }
    return array('entities' => $entities, 'count' => $count);
}
开发者ID:hypejunction,项目名称:hypegeo,代码行数:32,代码来源:hooks.php

示例13: pages_register_navigation_tree

/**
 * Register the navigation menu
 * 
 * @param ElggEntity $container Container entity for the pages
 */
function pages_register_navigation_tree($container)
{
    if (!$container) {
        return;
    }
    $top_pages = elgg_get_entities(array('type' => 'object', 'subtype' => 'page_top', 'container_guid' => $container->getGUID(), 'limit' => 0));
    if (!$top_pages) {
        return;
    }
    foreach ($top_pages as $page) {
        elgg_register_menu_item('pages_nav', array('name' => $page->getGUID(), 'text' => $page->title, 'href' => $page->getURL()));
        $stack = array();
        array_push($stack, $page);
        while (count($stack) > 0) {
            $parent = array_pop($stack);
            $children = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'page', 'metadata_name' => 'parent_guid', 'metadata_value' => $parent->getGUID(), 'limit' => 0));
            if ($children) {
                foreach ($children as $child) {
                    elgg_register_menu_item('pages_nav', array('name' => $child->getGUID(), 'text' => $child->title, 'href' => $child->getURL(), 'parent_name' => $parent->getGUID()));
                    array_push($stack, $child);
                }
            }
        }
    }
}
开发者ID:nogsus,项目名称:Elgg,代码行数:30,代码来源:pages.php

示例14: get_suggestions

/**
 *
 * Returns array of people containing entity, mutuals (friends), groups (shared) and priority
 * @param Int $guid
 * @param Int $friends_limit
 * @param Int $groups_limit
 * @return Array
 */
function get_suggestions($guid, $friends_of_friends_limit = 10, $groups_members_limit = 10)
{
    $dbprefix = elgg_get_config('dbprefix');
    $guid = sanitize_int($guid);
    $suggestions = array();
    if ($friends_of_friends_limit) {
        // get some friends of friends
        $options = array('selects' => array('COUNT(fof.guid_two) as priority'), 'type' => 'user', 'joins' => array("JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid", "JOIN {$dbprefix}entity_relationships fr ON fr.guid_one = {$guid} AND fr.relationship = 'friend'", "JOIN {$dbprefix}entity_relationships fof ON fof.guid_one = fr.guid_two AND fof.relationship = 'friend'"), "wheres" => array("ue.banned = 'no'", "e.guid NOT IN (SELECT f.guid_two FROM {$dbprefix}entity_relationships f WHERE f.guid_one = {$guid} AND f.relationship = 'friend')", "fof.guid_two = e.guid", "e.guid != {$guid}"), 'group_by' => 'e.guid', 'order_by' => 'priority desc, ue.last_action desc', 'limit' => abs((int) $friends_of_friends_limit));
        $fof = elgg_get_entities($options);
        foreach ($fof as $f) {
            $priority = (int) $f->getVolatileData('select:priority');
            $suggestions[$f->guid] = array('entity' => $f, 'mutuals' => $priority, 'groups' => 0, 'priority' => $priority);
        }
    }
    if ($groups_members_limit) {
        // get some mutual group members
        $options = array('selects' => array('COUNT(mog.guid_two) as priority'), 'type' => 'user', 'joins' => array("JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid", "JOIN {$dbprefix}entity_relationships g ON g.guid_one = {$guid} AND g.relationship = 'member'", "JOIN {$dbprefix}groups_entity ge ON ge.guid = g.guid_two", "JOIN {$dbprefix}entity_relationships mog ON mog.guid_two = g.guid_two AND mog.relationship = 'member'"), "wheres" => array("ue.banned = 'no'", "e.guid NOT IN (SELECT f.guid_two FROM {$dbprefix}entity_relationships f WHERE f.guid_one = {$guid} AND f.relationship = 'friend')", "mog.guid_one = e.guid", "e.guid != {$guid}"), 'group_by' => 'e.guid', 'order_by' => 'priority desc, ue.last_action desc', 'limit' => 3);
        // get members of groups
        $mog = elgg_get_entities($options);
        foreach ($mog as $m) {
            if (!isset($suggestions[$m->guid])) {
                $priority = (int) $m->getVolatileData('select:priority');
                $suggestions[$m->guid] = array('entity' => $m, 'mutuals' => 0, 'groups' => $priority, 'priority' => $priority);
            } else {
                $priority = (int) $m->getVolatileData('select:priority');
                $suggestions[$m->guid]['groups'] = $priority;
                $suggestions[$m->guid]['priority'] += $priority;
            }
        }
    }
    // sort by priority
    usort($suggestions, __NAMESPACE__ . '\\suggested_friends_sorter');
    return $suggestions;
}
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:42,代码来源:functions.php

示例15: elggchat_session_cleanup

function elggchat_session_cleanup($hook, $entity_type, $returnvalue, $params)
{
    $resulttext = elgg_echo("elggchat:crondone");
    $access = elgg_set_ignore_access(true);
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    $session_count = elgg_get_entities(array('type' => "object", 'subtype' => ELGGCHAT_SESSION_SUBTYPE, 'count' => true));
    if ($session_count < 1) {
        // no sessions to clean up
        access_show_hidden_entities($access_status);
        elgg_set_ignore_access($access);
        return $returnvalue . $resulttext;
    }
    $sessions = elgg_get_entities(array('type' => "object", 'subtype' => ELGGCHAT_SESSION_SUBTYPE, 'limit' => $session_count));
    foreach ($sessions as $session) {
        $member_count = $session->countEntitiesFromRelationship(ELGGCHAT_MEMBER);
        if ($member_count > 0) {
            $max_age = (int) elgg_get_plugin_setting("maxSessionAge", "elggchat");
            $age = time() - $session->time_updated;
            if ($age > $max_age) {
                $session->delete();
            }
        } else {
            $session->delete();
        }
    }
    access_show_hidden_entities($access_status);
    elgg_set_ignore_access($access);
    return $returnvalue . $resulttext;
}
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:30,代码来源:start.php


注:本文中的elgg_get_entities函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。