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


PHP is_memcache_available函数代码示例

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


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

示例1: rowToElggStar

 /**
  * Create an Elgg* object from a given entity row.
  *
  * Handles loading all tables into the correct class.
  *
  * @param \stdClass $row The row of the entry in the entities table.
  *
  * @return \ElggEntity|false
  * @see get_entity_as_row()
  * @see add_subtype()
  * @see get_entity()
  * @access private
  *
  * @throws \ClassException|\InstallationException
  */
 function rowToElggStar($row)
 {
     if (!$row instanceof \stdClass) {
         return $row;
     }
     if (!isset($row->guid) || !isset($row->subtype)) {
         return $row;
     }
     $new_entity = false;
     // Create a memcache cache if we can
     static $newentity_cache;
     if (!$newentity_cache && is_memcache_available()) {
         $newentity_cache = new \ElggMemcache('new_entity_cache');
     }
     if ($newentity_cache) {
         $new_entity = $newentity_cache->load($row->guid);
     }
     if ($new_entity) {
         return $new_entity;
     }
     // load class for entity if one is registered
     $classname = get_subtype_class_from_id($row->subtype);
     if ($classname != "") {
         if (class_exists($classname)) {
             $new_entity = new $classname($row);
             if (!$new_entity instanceof \ElggEntity) {
                 $msg = $classname . " is not a " . '\\ElggEntity' . ".";
                 throw new \ClassException($msg);
             }
         } else {
             error_log("Class '" . $classname . "' was not found, missing plugin?");
         }
     }
     if (!$new_entity) {
         //@todo Make this into a function
         switch ($row->type) {
             case 'object':
                 $new_entity = new \ElggObject($row);
                 break;
             case 'user':
                 $new_entity = new \ElggUser($row);
                 break;
             case 'group':
                 $new_entity = new \ElggGroup($row);
                 break;
             case 'site':
                 $new_entity = new \ElggSite($row);
                 break;
             default:
                 $msg = "Entity type " . $row->type . " is not supported.";
                 throw new \InstallationException($msg);
         }
     }
     // Cache entity if we have a cache available
     if ($newentity_cache && $new_entity) {
         $newentity_cache->save($new_entity->guid, $new_entity);
     }
     return $new_entity;
 }
开发者ID:ibou77,项目名称:elgg,代码行数:74,代码来源:EntityTable.php

示例2: elasticsearch_entity_row_to_std

/**
 * Create a standard object from a given entity row.
 *
 * @param stdClass $row The row of the entry in the entities table.
 *
 * @return ElggEntity|false
 * @link http://docs.elgg.org/DataModel/Entities
 * @see get_entity_as_row()
 * @see add_subtype()
 * @see get_entity()
 * @access private
 *
 * @throws ClassException|InstallationException
 */
function elasticsearch_entity_row_to_std($row)
{
    if (!$row instanceof stdClass) {
        return $row;
    }
    if (!isset($row->guid) || !isset($row->subtype)) {
        return $row;
    }
    $new_entity = false;
    // Create a memcache cache if we can
    static $newentity_cache;
    if (!$newentity_cache && is_memcache_available()) {
        $newentity_cache = new ElggMemcache('new_entity_cache');
    }
    if ($newentity_cache) {
        $new_entity = $newentity_cache->load($row->guid);
    }
    if ($new_entity) {
        return $new_entity;
    }
    try {
        // load class for entity if one is registered
        $classname = get_subtype_class_from_id($row->subtype);
        if ($classname != "") {
            if (class_exists($classname)) {
                $new_entity = new $classname($row);
                if (!$new_entity instanceof ElggEntity) {
                    $msg = elgg_echo('ClassException:ClassnameNotClass', array($classname, 'ElggEntity'));
                    throw new ClassException($msg);
                }
            }
        }
        if (!$new_entity) {
            switch ($row->type) {
                case 'object':
                    $new_entity = new ElggObject($row);
                    break;
                case 'user':
                    $new_entity = new ElggUser($row);
                    break;
                case 'group':
                    $new_entity = new ElggGroup($row);
                    break;
                case 'site':
                    $new_entity = new ElggSite($row);
                    break;
                default:
                    $msg = elgg_echo('InstallationException:TypeNotSupported', array($row->type));
                    throw new InstallationException($msg);
            }
        }
    } catch (IncompleteEntityException $e) {
        return false;
    }
    return $new_entity;
}
开发者ID:pleio,项目名称:elasticsearch,代码行数:70,代码来源:functions.php

示例3: _elgg_invalidate_memcache_for_entity

/**
 * Invalidate an entity in memcache
 *
 * @param int $entity_guid The GUID of the entity to invalidate
 *
 * @return void
 * @access private
 */
function _elgg_invalidate_memcache_for_entity($entity_guid)
{
    static $newentity_cache;
    if (!$newentity_cache && is_memcache_available()) {
        $newentity_cache = new \ElggMemcache('new_entity_cache');
    }
    if ($newentity_cache) {
        $newentity_cache->delete($entity_guid);
    }
}
开发者ID:ibou77,项目名称:elgg,代码行数:18,代码来源:memcache.php

示例4: getInstance

 /**
  * Returns a singleton
  * @return self
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance)) {
         $conf = self::getHttpClientConfig();
         $client = new \GuzzleHttp\Client($conf);
         $parser = new \hypeJunction\Parser($client);
         $cache = $routes_cache = is_memcache_available() ? new Memcache() : new FileCache();
         self::$_instance = new self($parser, $cache);
     }
     return self::$_instance;
 }
开发者ID:hypejunction,项目名称:hypescraper,代码行数:15,代码来源:ScraperService.php

示例5: izap_update_metadata

/**
*function to update the metadata
*same as the update_metadata, only made metadata editable
*/
function izap_update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id)
{
    $id = (int) $id;
    if (!($md = elgg_get_metadata_from_id($id))) {
        return false;
    }
    // If memcached then we invalidate the cache for this entry
    static $metabyname_memcache;
    if (!$metabyname_memcache && is_memcache_available()) {
        $metabyname_memcache = new ElggMemcache('metabyname_memcache');
    }
    if ($metabyname_memcache) {
        $metabyname_memcache->delete("{$md->entity_guid}:{$md->name_id}");
    }
    $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
    $owner_guid = (int) $owner_guid;
    if ($owner_guid == 0) {
        $owner_guid = elgg_get_logged_in_user_guid();
    }
    $access_id = (int) $access_id;
    // Support boolean types (as integers)
    if (is_bool($value)) {
        if ($value) {
            $value = 1;
        } else {
            $value = 0;
        }
    }
    // Add the metastring
    $value = elgg_get_metastring_id($value);
    if (!$value) {
        return false;
    }
    $name = elgg_get_metastring_id($name);
    if (!$name) {
        return false;
    }
    // If ok then add it
    $db_prefix = elgg_get_config('dbprefix');
    $result = update_data("UPDATE {$db_prefix}metadata set value_id='{$value}', value_type='{$value_type}', access_id={$access_id}, owner_guid={$owner_guid} where id={$id} and name_id='{$name}'");
    if ($result !== false) {
        $obj = elgg_get_metadata_from_id($id);
        if (elgg_trigger_event('update', 'metadata', $obj)) {
            return true;
        } else {
            elgg_delete_metadata(array('metadata_id' => $id));
        }
    }
    return $result;
}
开发者ID:Daltonmedia,项目名称:izap_profile_visitors,代码行数:54,代码来源:izap_profile_visitors_lib.php

示例6: __set

 /**
  * Updates setting cache when parent data is set
  *
  * @param string $name  setting/metadata being updated
  * @param mixed  $value new value
  *
  * @return void
  */
 public function __set($name, $value)
 {
     if (is_array($value)) {
         if (empty($value)) {
             $value = null;
         } else {
             $value = json_encode($value);
         }
     }
     parent::__set($name, $value);
     $this->settings_cache[$name] = $value;
     // If memcache is available then delete this entry from the cache
     static $newentity_cache;
     if (!$newentity_cache && is_memcache_available()) {
         $newentity_cache = new ElggMemcache('new_entity_cache');
     }
     if ($newentity_cache) {
         $newentity_cache->delete($this->getGUID());
     }
 }
开发者ID:pleio,项目名称:widget_manager,代码行数:28,代码来源:WidgetManagerWidget.php

示例7: login

/**
 * Logs in a specified ElggUser. For standard registration, use in conjunction
 * with elgg_authenticate.
 *
 * @see elgg_authenticate
 *
 * @param ElggUser $user       A valid Elgg user object
 * @param boolean  $persistent Should this be a persistent login?
 *
 * @return true or throws exception
 * @throws LoginException
 */
function login(ElggUser $user, $persistent = false)
{
    // User is banned, return false.
    if ($user->isBanned()) {
        throw new LoginException(elgg_echo('LoginException:BannedUser'));
    }
    $_SESSION['user'] = $user;
    $_SESSION['guid'] = $user->getGUID();
    $_SESSION['id'] = $_SESSION['guid'];
    $_SESSION['username'] = $user->username;
    $_SESSION['name'] = $user->name;
    // if remember me checked, set cookie with token and store token on user
    if ($persistent) {
        $code = md5($user->name . $user->username . time() . rand());
        $_SESSION['code'] = $code;
        $user->code = md5($code);
        setcookie("elggperm", $code, time() + 86400 * 30, "/");
    }
    if (!$user->save() || !elgg_trigger_event('login', 'user', $user)) {
        unset($_SESSION['username']);
        unset($_SESSION['name']);
        unset($_SESSION['code']);
        unset($_SESSION['guid']);
        unset($_SESSION['id']);
        unset($_SESSION['user']);
        setcookie("elggperm", "", time() - 86400 * 30, "/");
        throw new LoginException(elgg_echo('LoginException:Unknown'));
    }
    // Users privilege has been elevated, so change the session id (prevents session fixation)
    session_regenerate_id();
    // Update statistics
    set_last_login($_SESSION['guid']);
    reset_login_failure_count($user->guid);
    // Reset any previous failed login attempts
    // if memcache is enabled, invalidate the user in memcache @see https://github.com/Elgg/Elgg/issues/3143
    if (is_memcache_available()) {
        // this needs to happen with a shutdown function because of the timing with set_last_login()
        register_shutdown_function("_elgg_invalidate_memcache_for_entity", $_SESSION['guid']);
    }
    return true;
}
开发者ID:socialweb,项目名称:PiGo,代码行数:53,代码来源:sessions.php

示例8: delete_entity

/**
 * Delete an entity.
 *
 * Removes an entity and its metadata, annotations, relationships, river entries,
 * and private data.
 *
 * Optionally can remove entities contained and owned by $guid.
 *
 * @tip Use ElggEntity::delete() instead.
 *
 * @warning If deleting recursively, this bypasses ownership of items contained by
 * the entity.  That means that if the container_guid = $guid, the item will be deleted
 * regardless of who owns it.
 *
 * @param int  $guid      The guid of the entity to delete
 * @param bool $recursive If true (default) then all entities which are
 *                        owned or contained by $guid will also be deleted.
 *
 * @return bool
 * @access private
 */
function delete_entity($guid, $recursive = true)
{
    global $CONFIG, $ENTITY_CACHE;
    $guid = (int) $guid;
    if ($entity = get_entity($guid)) {
        if (elgg_trigger_event('delete', $entity->type, $entity)) {
            if ($entity->canEdit()) {
                // delete cache
                if (isset($ENTITY_CACHE[$guid])) {
                    _elgg_invalidate_cache_for_entity($guid);
                }
                // If memcache is available then delete this entry from the cache
                static $newentity_cache;
                if (!$newentity_cache && is_memcache_available()) {
                    $newentity_cache = new ElggMemcache('new_entity_cache');
                }
                if ($newentity_cache) {
                    $newentity_cache->delete($guid);
                }
                // Delete contained owned and otherwise releated objects (depth first)
                if ($recursive) {
                    // Temporary token overriding access controls
                    // @todo Do this better.
                    static $__RECURSIVE_DELETE_TOKEN;
                    // Make it slightly harder to guess
                    $__RECURSIVE_DELETE_TOKEN = md5(elgg_get_logged_in_user_guid());
                    $entity_disable_override = access_get_show_hidden_status();
                    access_show_hidden_entities(true);
                    $ia = elgg_set_ignore_access(true);
                    // @todo there was logic in the original code that ignored
                    // entities with owner or container guids of themselves.
                    // this should probably be prevented in ElggEntity instead of checked for here
                    $options = array("limit" => 0, "order_by" => false, "site_guids" => false);
                    foreach (array("site_guid", "container_guid", "owner_guid") as $column) {
                        $options['wheres'] = array("(({$column} = {$guid}) AND guid != {$guid})");
                        $batch = new ElggBatch('elgg_get_entities', $options);
                        $batch->setIncrementOffset(false);
                        foreach ($batch as $e) {
                            $e->delete(true);
                        }
                    }
                    access_show_hidden_entities($entity_disable_override);
                    $__RECURSIVE_DELETE_TOKEN = null;
                    elgg_set_ignore_access($ia);
                }
                // Now delete the entity itself
                $entity->deleteMetadata();
                $entity->deleteOwnedMetadata();
                $entity->deleteAnnotations();
                $entity->deleteOwnedAnnotations();
                $entity->deleteRelationships();
                elgg_delete_river(array('subject_guid' => $guid));
                elgg_delete_river(array('object_guid' => $guid));
                remove_all_private_settings($guid);
                $res = delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}");
                if ($res) {
                    $sub_table = "";
                    // Where appropriate delete the sub table
                    switch ($entity->type) {
                        case 'object':
                            $sub_table = $CONFIG->dbprefix . 'objects_entity';
                            break;
                        case 'user':
                            $sub_table = $CONFIG->dbprefix . 'users_entity';
                            break;
                        case 'group':
                            $sub_table = $CONFIG->dbprefix . 'groups_entity';
                            break;
                        case 'site':
                            $sub_table = $CONFIG->dbprefix . 'sites_entity';
                            break;
                    }
                    if ($sub_table) {
                        delete_data("DELETE from {$sub_table} where guid={$guid}");
                    }
                }
                return (bool) $res;
            }
        }
//.........这里部分代码省略.........
开发者ID:pleio,项目名称:subsite_manager,代码行数:101,代码来源:entities.php

示例9: get_entity

$to = get_entity($to);
if (!$from instanceof ElggGroup || !$from->canEdit()) {
    register_error(elgg_echo("subsite_manager:admin:move_group:permission_denied"));
    forward(REFERER);
}
if (!$to instanceof ElggGroup || !$to->canEdit()) {
    register_error(elgg_echo("subsite_manager:admin:move_group:permission_denied"));
    forward(REFERER);
}
if ($from == $to) {
    register_error(elgg_echo("subsite_manager:admin:move_group:from_to_same"));
    forward(REFERER);
}
$submit = get_input("submit");
if (!$submit) {
    forward("/admin/administer_utilities/move_group?preview=true&from={$from->guid}&to={$to->guid}");
}
$dbprefix = elgg_get_config("dbprefix");
$from_acl = $from->group_acl;
$to_acl = $to->group_acl;
$invalidate_entities = get_data("SELECT guid FROM {$dbprefix}entities WHERE container_guid = {$from->guid}");
update_data("UPDATE {$dbprefix}entities SET container_guid = {$to->guid} WHERE container_guid = {$from->guid}");
update_data("UPDATE {$dbprefix}entities SET access_id = {$to_acl} WHERE access_id = {$from_acl}");
update_data("UPDATE {$dbprefix}metadata SET access_id = {$to_acl} WHERE access_id = {$from_acl}");
update_data("UPDATE {$dbprefix}annotations SET access_id = {$to_acl} WHERE access_id = {$from_acl}");
if (is_memcache_available()) {
    foreach ($invalidate_entities as $entity) {
        _elgg_invalidate_memcache_for_entity($entity->guid);
    }
}
system_message(elgg_echo("subsite_manager:admin:move_group:success"));
开发者ID:pleio,项目名称:subsite_manager,代码行数:31,代码来源:move_group.php

示例10: datalist_set

/**
 * Sets the value for a system-wide piece of data (overwriting a previous value if it exists)
 *
 * @param string $name The name of the datalist
 * @param string $value The new value
 * @return true
 */
function datalist_set($name, $value)
{
    global $CONFIG, $DATALIST_CACHE;
    $name = sanitise_string($name);
    $value = sanitise_string($value);
    // If memcache is available then invalidate the cached copy
    static $datalist_memcache;
    if (!$datalist_memcache && is_memcache_available()) {
        $datalist_memcache = new ElggMemcache('datalist_memcache');
    }
    if ($datalist_memcache) {
        $datalist_memcache->delete($name);
    }
    //delete_data("delete from {$CONFIG->dbprefix}datalists where name = '{$name}'");
    insert_data("INSERT into {$CONFIG->dbprefix}datalists set name = '{$name}', value = '{$value}' ON DUPLICATE KEY UPDATE value='{$value}'");
    $DATALIST_CACHE[$name] = $value;
    return true;
}
开发者ID:eokyere,项目名称:elgg,代码行数:25,代码来源:elgglib.php

示例11: get_metastring_id

/**
 * Return the meta string id for a given tag, or false.
 *
 * @param string $string         The value to store
 * @param bool   $case_sensitive Do we want to make the query case sensitive?
 *                               If not there may be more than one result
 *
 * @return int|array|false meta   string id, array of ids or false if none found
 * @deprecated 1.9 Use elgg_get_metastring_id()
 */
function get_metastring_id($string, $case_sensitive = TRUE)
{
    elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_metastring_id()', 1.9);
    global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
    $string = sanitise_string($string);
    // caching doesn't work for case insensitive searches
    if ($case_sensitive) {
        $result = array_search($string, $METASTRINGS_CACHE, true);
        if ($result !== false) {
            return $result;
        }
        // See if we have previously looked for this and found nothing
        if (in_array($string, $METASTRINGS_DEADNAME_CACHE, true)) {
            return false;
        }
        // Experimental memcache
        $msfc = null;
        static $metastrings_memcache;
        if (!$metastrings_memcache && is_memcache_available()) {
            $metastrings_memcache = new \ElggMemcache('metastrings_memcache');
        }
        if ($metastrings_memcache) {
            $msfc = $metastrings_memcache->load($string);
        }
        if ($msfc) {
            return $msfc;
        }
    }
    // Case sensitive
    if ($case_sensitive) {
        $query = "SELECT * from {$CONFIG->dbprefix}metastrings where string= BINARY '{$string}' limit 1";
    } else {
        $query = "SELECT * from {$CONFIG->dbprefix}metastrings where string = '{$string}'";
    }
    $row = FALSE;
    $metaStrings = get_data($query);
    if (is_array($metaStrings)) {
        if (sizeof($metaStrings) > 1) {
            $ids = array();
            foreach ($metaStrings as $metaString) {
                $ids[] = $metaString->id;
            }
            return $ids;
        } else {
            if (isset($metaStrings[0])) {
                $row = $metaStrings[0];
            }
        }
    }
    if ($row) {
        $METASTRINGS_CACHE[$row->id] = $row->string;
        // Cache it
        // Attempt to memcache it if memcache is available
        if ($metastrings_memcache) {
            $metastrings_memcache->save($row->string, $row->id);
        }
        return $row->id;
    } else {
        $METASTRINGS_DEADNAME_CACHE[$string] = $string;
    }
    return false;
}
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:72,代码来源:deprecated-1.9.php

示例12: delete

 /**
  * Deletes the entity.
  *
  * Removes the entity and its metadata, annotations, relationships,
  * river entries, and private data.
  *
  * Optionally can remove entities contained and owned by this entity.
  *
  * @warning If deleting recursively, this bypasses ownership of items contained by
  * the entity.  That means that if the container_guid = $this->guid, the item will
  * be deleted regardless of who owns it.
  *
  * @param bool $recursive If true (default) then all entities which are
  *                        owned or contained by $this will also be deleted.
  *
  * @return bool
  */
 public function delete($recursive = true)
 {
     global $CONFIG;
     $guid = $this->guid;
     if (!$guid) {
         return false;
     }
     // first check if we can delete this entity
     // NOTE: in Elgg <= 1.10.3 this was after the delete event,
     // which could potentially remove some content if the user didn't have access
     if (!$this->canDelete()) {
         return false;
     }
     // now trigger an event to let others know this entity is about to be deleted
     // so they can prevent it or take their own actions
     if (!_elgg_services()->events->trigger('delete', $this->type, $this)) {
         return false;
     }
     _elgg_invalidate_cache_for_entity($guid);
     // If memcache is available then delete this entry from the cache
     static $newentity_cache;
     if (!$newentity_cache && is_memcache_available()) {
         $newentity_cache = new \ElggMemcache('new_entity_cache');
     }
     if ($newentity_cache) {
         $newentity_cache->delete($guid);
     }
     // Delete contained owned and otherwise releated objects (depth first)
     if ($recursive) {
         // Temporarily overriding access controls
         $entity_disable_override = access_get_show_hidden_status();
         access_show_hidden_entities(true);
         $ia = elgg_set_ignore_access(true);
         // @todo there was logic in the original code that ignored
         // entities with owner or container guids of themselves.
         // this should probably be prevented in \ElggEntity instead of checked for here
         $options = array('wheres' => array("((container_guid = {$guid} OR owner_guid = {$guid} OR site_guid = {$guid})" . " AND guid != {$guid})"), 'limit' => 0);
         $batch = new \ElggBatch('elgg_get_entities', $options);
         $batch->setIncrementOffset(false);
         foreach ($batch as $e) {
             $e->delete(true);
         }
         access_show_hidden_entities($entity_disable_override);
         elgg_set_ignore_access($ia);
     }
     $entity_disable_override = access_get_show_hidden_status();
     access_show_hidden_entities(true);
     $ia = elgg_set_ignore_access(true);
     // Now delete the entity itself
     $this->deleteMetadata();
     $this->deleteOwnedMetadata();
     $this->deleteAnnotations();
     $this->deleteOwnedAnnotations();
     $this->deleteRelationships();
     $this->deleteAccessCollectionMemberships();
     $this->deleteOwnedAccessCollections();
     access_show_hidden_entities($entity_disable_override);
     elgg_set_ignore_access($ia);
     elgg_delete_river(array('subject_guid' => $guid));
     elgg_delete_river(array('object_guid' => $guid));
     elgg_delete_river(array('target_guid' => $guid));
     remove_all_private_settings($guid);
     $res = $this->getDatabase()->deleteData("DELETE FROM {$CONFIG->dbprefix}entities WHERE guid = {$guid}");
     if ($res) {
         $sub_table = "";
         // Where appropriate delete the sub table
         switch ($this->type) {
             case 'object':
                 $sub_table = $CONFIG->dbprefix . 'objects_entity';
                 break;
             case 'user':
                 $sub_table = $CONFIG->dbprefix . 'users_entity';
                 break;
             case 'group':
                 $sub_table = $CONFIG->dbprefix . 'groups_entity';
                 break;
             case 'site':
                 $sub_table = $CONFIG->dbprefix . 'sites_entity';
                 break;
         }
         if ($sub_table) {
             $this->getDatabase()->deleteData("DELETE FROM {$sub_table} WHERE guid = {$guid}");
         }
//.........这里部分代码省略.........
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:101,代码来源:ElggEntity.php

示例13: subsite_manager_get_plugin_order

function subsite_manager_get_plugin_order()
{
    if (is_memcache_available()) {
        $memcache = new ElggMemcache('subsite_manager');
    }
    if (isset($memcache)) {
        if ($plugin_order = $memcache->load('plugin_order')) {
            return $plugin_order;
        }
    }
    $db_prefix = get_config('dbprefix');
    $priority = elgg_namespace_plugin_private_setting('internal', 'priority');
    $options = array('type' => 'object', 'subtype' => 'plugin', 'limit' => ELGG_ENTITIES_NO_VALUE, 'selects' => array('plugin_oe.*'), 'joins' => array("JOIN {$db_prefix}private_settings ps on ps.entity_guid = e.guid", "JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"), 'wheres' => array("ps.name = '{$priority}'"), 'order_by' => "CAST(ps.value as unsigned), e.guid", 'site_guids' => array(1));
    $plugins = elgg_get_entities_from_relationship($options);
    $plugin_order = array();
    foreach ($plugins as $i => $plugin) {
        $plugin_order[$plugin->title] = $i;
    }
    if (isset($memcache)) {
        $memcache->save('plugin_order', $plugin_order);
    }
    return $plugin_order;
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:23,代码来源:functions.php

示例14: remove_user_admin

/**
 * Removes user $guid's admin flag.
 *
 * @param int $user_guid User GUID
 *
 * @return bool
 */
function remove_user_admin($user_guid)
{
    global $CONFIG;
    $user = get_entity((int) $user_guid);
    if ($user && $user instanceof ElggUser && $user->canEdit()) {
        if (elgg_trigger_event('remove_admin', 'user', $user)) {
            // invalidate memcache for this user
            static $newentity_cache;
            if (!$newentity_cache && is_memcache_available()) {
                $newentity_cache = new ElggMemcache('new_entity_cache');
            }
            if ($newentity_cache) {
                $newentity_cache->delete($user_guid);
            }
            $r = update_data("UPDATE {$CONFIG->dbprefix}users_entity set admin='no' where guid={$user_guid}");
            invalidate_cache_for_entity($user_guid);
            return $r;
        }
        return FALSE;
    }
    return FALSE;
}
开发者ID:riggo,项目名称:Elgg,代码行数:29,代码来源:users.php

示例15: get_entity

/**
 * Loads and returns an entity object from a guid.
 *
 * @param int $guid The GUID of the entity
 *
 * @return ElggEntity The correct Elgg or custom object based upon entity type and subtype
 * @link http://docs.elgg.org/DataModel/Entities
 */
function get_entity($guid)
{
    static $newentity_cache;
    $new_entity = false;
    if (!is_numeric($guid)) {
        return FALSE;
    }
    if (!$newentity_cache && is_memcache_available()) {
        $newentity_cache = new ElggMemcache('new_entity_cache');
    }
    if ($newentity_cache) {
        $new_entity = $newentity_cache->load($guid);
    }
    if ($new_entity) {
        return $new_entity;
    }
    return entity_row_to_elggstar(get_entity_as_row($guid));
}
开发者ID:rasul,项目名称:Elgg,代码行数:26,代码来源:entities.php


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