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


PHP elgg_get_annotations函数代码示例

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


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

示例1: theme_ffd_fivestar_get_top_users

function theme_ffd_fivestar_get_top_users($n_days = 21, $eps = 0.5)
{
    $options = array('annotation_name' => 'fivestar', 'where' => 'n_table.time_created > ' . (time() - 3600 * 24 * $n_days), 'order_by' => 'n_table.time_created desc', 'limit' => 250);
    $annotations = elgg_get_annotations($options);
    $top_users = array();
    foreach ($annotations as $annotation) {
        $user = $annotation->getEntity()->getOwnerGuid();
        if (!array_key_exists($user, $top_users)) {
            $top_users[$user] = array();
        }
        $top_users[$user][] = $annotation->value / 100;
    }
    $max_scores = 0;
    foreach ($top_users as $guid => $scores) {
        if (count($scores) > $max_scores) {
            $max_scores = count($scores);
        }
    }
    // calculate the average score
    $top_users = array_map(function ($scores) use($max_scores, $eps) {
        return $eps * (array_sum($scores) / count($scores)) * ((1 - $eps) * (count($scores) / $max_scores));
    }, $top_users);
    arsort($top_users);
    $top_users = array_slice($top_users, 0, 10, true);
    $users = array();
    foreach ($top_users as $guid => $score) {
        $users[] = get_entity($guid);
    }
    return $users;
}
开发者ID:pleio,项目名称:theme_ffd,代码行数:30,代码来源:functions.php

示例2: group_tools_check_group_email_invitation

/**
 * Check if a invitation code results in a group
 *
 * @param string $invite_code the invite code
 * @param int    $group_guid  (optional) the group to check
 *
 * @return false|ElggGroup
 */
function group_tools_check_group_email_invitation($invite_code, $group_guid = 0)
{
    if (empty($invite_code)) {
        return false;
    }
    $group_guid = sanitize_int($group_guid, false);
    // note not using elgg_get_entities_from_annotations
    // due to performance issues with LIKE wildcard search
    // prefetch metastring ids for use in lighter joins instead
    $name_id = elgg_get_metastring_id('email_invitation');
    $code_id = elgg_get_metastring_id($invite_code);
    $sanitized_invite_code = sanitize_string($invite_code);
    $options = ['limit' => 1, 'wheres' => ["n_table.name_id = {$name_id} AND (n_table.value_id = {$code_id} OR v.string LIKE '{$sanitized_invite_code}|%')"]];
    if (!empty($group_guid)) {
        $options['annotation_owner_guids'] = [$group_guid];
    }
    // find hidden groups
    $ia = elgg_set_ignore_access(true);
    $annotations = elgg_get_annotations($options);
    if (empty($annotations)) {
        // restore access
        elgg_set_ignore_access($ia);
        return false;
    }
    $group = $annotations[0]->getEntity();
    if ($group instanceof ElggGroup) {
        // restore access
        elgg_set_ignore_access($ia);
        return $group;
    }
    // restore access
    elgg_set_ignore_access($ia);
    return false;
}
开发者ID:coldtrick,项目名称:group_tools,代码行数:42,代码来源:functions.php

示例3: group_tools_check_group_email_invitation

/**
 * Check if a invitation code results in a group
 *
 * @param string $invite_code the invite code
 * @param int    $group_guid  (optional) the group to check
 *
 * @return boolean|ElggGroup a group for the invitation or false
 */
function group_tools_check_group_email_invitation($invite_code, $group_guid = 0)
{
    $result = false;
    if (!empty($invite_code)) {
        // note not using elgg_get_entities_from_annotations
        // due to performance issues with LIKE wildcard search
        // prefetch metastring ids for use in lighter joins instead
        $name_id = add_metastring('email_invitation');
        $code_id = add_metastring($invite_code);
        $sanitized_invite_code = sanitize_string($invite_code);
        $options = array('limit' => 1, 'wheres' => array("n_table.name_id = {$name_id} AND (n_table.value_id = {$code_id} OR v.string LIKE '{$sanitized_invite_code}|%')"));
        if (!empty($group_guid)) {
            $options["annotation_owner_guids"] = array($group_guid);
        }
        $annotations = elgg_get_annotations($options);
        if (!$annotations) {
            return $result;
        }
        // find hidden groups
        $ia = elgg_set_ignore_access(true);
        $group = $annotations[0]->getEntity();
        if ($group) {
            $result = $group;
        }
        // restore access
        elgg_set_ignore_access($ia);
    }
    return $result;
}
开发者ID:pleio,项目名称:group_tools,代码行数:37,代码来源:functions.php

示例4: tag_tools_get_user_following_tags

/**
 * Get all the tags a user is following
 *
 * @param int  $user_guid   the user to get the tags for (default: current user)
 * @param bool $reset_cache reset the internal cache
 *
 * @return bool|array
 */
function tag_tools_get_user_following_tags($user_guid = 0, $reset_cache = false)
{
    static $cache;
    if (!isset($cache)) {
        $cache = [];
    }
    $user_guid = sanitise_int($user_guid, false);
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if (empty($user_guid)) {
        return false;
    }
    if (!isset($cache[$user_guid]) || $reset_cache) {
        $cache[$user_guid] = [];
        $ia = elgg_set_ignore_access(true);
        $annotations = elgg_get_annotations(['guid' => $user_guid, 'annotation_name' => 'follow_tag', 'limit' => false]);
        elgg_set_ignore_access($ia);
        if (!empty($annotations)) {
            foreach ($annotations as $annotation) {
                $cache[$user_guid][] = $annotation->value;
            }
        }
    }
    return $cache[$user_guid];
}
开发者ID:coldtrick,项目名称:tag_tools,代码行数:34,代码来源:functions.php

示例5: tag_tools_get_user_following_tags

/**
 * Get all the tags a user is following
 *
 * @param int  $user_guid   the user to get the tags for (default: current user)
 * @param bool $reset_cache reset the internal cache
 *
 * @return bool|array
 */
function tag_tools_get_user_following_tags($user_guid = 0, $reset_cache = false)
{
    static $cache;
    if (!isset($cache)) {
        $cache = array();
    }
    $user_guid = sanitise_int($user_guid, false);
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if (empty($user_guid)) {
        return false;
    }
    if (!isset($cache[$user_guid]) || $reset_cache) {
        $cache[$user_guid] = array();
        $options = array("guid" => $user_guid, "annotation_name" => "follow_tag", "limit" => false);
        $ia = elgg_set_ignore_access(true);
        $annotations = elgg_get_annotations($options);
        elgg_set_ignore_access($ia);
        if (!empty($annotations)) {
            foreach ($annotations as $annotation) {
                $cache[$user_guid][] = $annotation->value;
            }
        }
    }
    return $cache[$user_guid];
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:35,代码来源:functions.php

示例6: isCheckedIn

 /**
  * Check if the user is checked in at the place
  *
  * @param integer $user_guid GUID of the user to check
  * @return integer Count of checkins within checkin duration limit
  */
 public function isCheckedIn($user_guid = 0)
 {
     if (!$user_guid) {
         $user_guid = elgg_get_logged_in_user_guid();
     }
     return elgg_get_annotations(array('guids' => $this->guid, 'annotation_owner_guids' => sanitize_int($user_guid), 'annotation_names' => 'checkin', 'annotation_created_time_lower' => time() - $this->getCheckinDuration(), 'count' => true));
 }
开发者ID:hypejunction,项目名称:hypeplaces,代码行数:13,代码来源:Place.php

示例7: rijkshuisstijl_get_votes

function rijkshuisstijl_get_votes(ElggObject $entity)
{
    $result = elgg_get_annotations(array('guid' => $entity->guid, 'annotation_name' => 'vote', 'annotation_calculation' => 'sum', 'limit' => false));
    if ($result) {
        return (int) $result;
    }
    return 0;
}
开发者ID:pleio,项目名称:rijkshuisstijl,代码行数:8,代码来源:functions.php

示例8: tu_spam_report_is_marked

/**
 * has the user already marked the entity as spam?
 */
function tu_spam_report_is_marked($object, $user)
{
    if (!elgg_instanceof($object) || !elgg_instanceof($user, 'user')) {
        return false;
    }
    $annotations = elgg_get_annotations(array('guid' => $object->guid, 'annotation_owner_guid' => $user->guid, 'annotation_names' => 'tu_spam_report'));
    return $annotations ? true : false;
}
开发者ID:ewinslow,项目名称:trusted_user_spam_report,代码行数:11,代码来源:start.php

示例9: delete

 /**
  * {@inheritdoc}
  */
 public function delete(ParameterBag $params)
 {
     $likes = elgg_get_annotations(array('guid' => (int) $params->guid, 'annotation_owner_guid' => elgg_get_logged_in_user_guid(), 'annotation_name' => 'likes'));
     $like = !empty($likes) ? $likes[0] : false;
     if ($like && $like->canEdit()) {
         return $like->delete();
     }
     throw new GraphException(elgg_echo("likes:notdeleted"));
 }
开发者ID:hypejunction,项目名称:hypegraph,代码行数:12,代码来源:ObjectLikes.php

示例10: hasVoted

 /**
  * Check whether the user has voted in this poll
  *
  * @param ElggUser $user
  * @return boolean
  */
 public function hasVoted($user)
 {
     $votes = elgg_get_annotations(array('guid' => $this->guid, 'type' => "object", 'subtype' => "poll", 'annotation_name' => "vote", 'annotation_owner_guid' => $user->guid, 'limit' => 1));
     if ($votes) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:lorea,项目名称:Hydra-dev,代码行数:15,代码来源:Poll.php

示例11: group_tools_join_group_event

/**
 * When a user joins a group
 *
 * @param string $event  join
 * @param string $type   group
 * @param array  $params array with the user and the user
 *
 * @return void
 */
function group_tools_join_group_event($event, $type, $params)
{
    global $NOTIFICATION_HANDLERS;
    static $auto_notification;
    // only load plugin setting once
    if (!isset($auto_notification)) {
        $auto_notification = array();
        if (isset($NOTIFICATION_HANDLERS) && is_array($NOTIFICATION_HANDLERS)) {
            if (elgg_get_plugin_setting("auto_notification", "group_tools") == "yes") {
                // Backwards compatibility
                $auto_notification = array("email", "site");
            }
            foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
                if (elgg_get_plugin_setting("auto_notification_" . $method, "group_tools") == "1") {
                    $auto_notification[] = $method;
                }
            }
        }
    }
    if (!empty($params) && is_array($params)) {
        $group = elgg_extract("group", $params);
        $user = elgg_extract("user", $params);
        if ($user instanceof ElggUser && $group instanceof ElggGroup) {
            // check for the auto notification settings
            if (!empty($NOTIFICATION_HANDLERS) && is_array($NOTIFICATION_HANDLERS)) {
                foreach ($NOTIFICATION_HANDLERS as $method => $dummy) {
                    if (in_array($method, $auto_notification)) {
                        add_entity_relationship($user->getGUID(), "notify" . $method, $group->getGUID());
                    }
                }
            }
            // cleanup invites
            remove_entity_relationship($group->getGUID(), "invited", $user->getGUID());
            // and requests
            remove_entity_relationship($user->getGUID(), "membership_request", $group->getGUID());
            // cleanup email invitations
            $options = array("annotation_name" => "email_invitation", "annotation_value" => group_tools_generate_email_invite_code($group->getGUID(), $user->email), "limit" => false);
            if (elgg_is_logged_in()) {
                elgg_delete_annotations($options);
            } elseif ($annotations = elgg_get_annotations($options)) {
                group_tools_delete_annotations($annotations);
            }
            // welcome message
            $welcome_message = $group->getPrivateSetting("group_tools:welcome_message");
            $check_message = trim(strip_tags($welcome_message));
            if (!empty($check_message)) {
                // replace the place holders
                $welcome_message = str_ireplace("[name]", $user->name, $welcome_message);
                $welcome_message = str_ireplace("[group_name]", $group->name, $welcome_message);
                $welcome_message = str_ireplace("[group_url]", $group->getURL(), $welcome_message);
                // notify the user
                notify_user($user->getGUID(), $group->getGUID(), elgg_echo("group_tools:welcome_message:subject", array($group->name)), $welcome_message);
            }
        }
    }
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:65,代码来源:events.php

示例12: polls_check_for_previous_vote

function polls_check_for_previous_vote($poll, $user_guid)
{
    $options = array('guid' => $poll->guid, 'type' => "object", 'subtype' => "poll", 'annotation_name' => "vote", 'annotation_owner_guid' => $user_guid, 'limit' => 1);
    $votes = elgg_get_annotations($options);
    if ($votes) {
        return true;
    } else {
        return false;
    }
}
开发者ID:napilap,项目名称:polls,代码行数:10,代码来源:model.php

示例13: gvpolls_remove_previous_vote

function gvpolls_remove_previous_vote($poll, $user_guid)
{
    $options = array('guid' => $poll->guid, 'type' => "object", 'subtype' => "poll", 'annotation_name' => "vote", 'annotation_owner_guid' => $user_guid, 'limit' => 1);
    $votes = elgg_get_annotations($options);
    if ($votes) {
        foreach ($votes as $vote) {
            $vote->delete();
        }
    }
}
开发者ID:remy40,项目名称:gvrs,代码行数:10,代码来源:model.php

示例14: testElggGetAnnotationsCount

 public function testElggGetAnnotationsCount()
 {
     $this->object->title = 'Annotation Unit Test';
     $this->object->save();
     $guid = $this->object->getGUID();
     create_annotation($guid, 'tested', 'tested1', 'text', 0, ACCESS_PUBLIC);
     create_annotation($guid, 'tested', 'tested2', 'text', 0, ACCESS_PUBLIC);
     $count = (int) elgg_get_annotations(array('annotation_names' => array('tested'), 'guid' => $guid, 'count' => true));
     $this->assertIdentical($count, 2);
     $this->object->delete();
 }
开发者ID:redvabel,项目名称:Vabelgg,代码行数:11,代码来源:annotations.php

示例15: getAnswerFromUser

 /**
  * Returns the answer given by a user
  *
  * @param string $user_guid guid of the entity
  *
  * @return boolean|ElggAnnotation
  */
 public function getAnswerFromUser($user_guid = null)
 {
     if (empty($user_guid)) {
         $user_guid = elgg_get_logged_in_user_guid();
     }
     $params = ['guid' => $this->getGUID(), 'annotation_name' => 'answer_to_event_registration', 'annotation_owner_guid' => $user_guid, 'limit' => 1];
     $annotations = elgg_get_annotations($params);
     if (empty($annotations)) {
         return false;
     }
     return $annotations[0];
 }
开发者ID:coldtrick,项目名称:event_manager,代码行数:19,代码来源:EventRegistrationQuestion.php


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