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


PHP check_entity_relationship函数代码示例

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


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

示例1: group_member_entity_menu_handler

function group_member_entity_menu_handler($hook, $type, $returnvalue, $params)
{
    $page_owner = elgg_get_page_owner_entity();
    $user = elgg_get_logged_in_user_entity();
    if (!$page_owner instanceof ElggGroup || empty($user) || $page_owner->owner_guid != $user->getGUID()) {
        return $returnvalue;
    }
    $result = $returnvalue;
    if (!empty($params) && is_array($params) && ($user = elgg_get_logged_in_user_entity())) {
        $entity = elgg_extract("entity", $params);
        if (elgg_instanceof($entity, "user") && $entity->getGUID() != $user->getGUID()) {
            if (!empty($result) && !is_array($result)) {
                $result = array($result);
            } elseif (empty($result)) {
                $result = array();
            }
            if (check_entity_relationship($page_owner->getGUID(), "manager", $entity->getGUID())) {
                // pending request
                $result[] = ElggMenuItem::factory(array("name" => "set_group_manager", "text" => elgg_echo("group:setmanager"), "href" => "groups/setmanager/" . $page_owner->getGUID() . "/" . $entity->getGUID(), "is_action" => true, "priority" => 503));
            } else {
                // add as friend
                $result[] = ElggMenuItem::factory(array("name" => "set_group_manager", "text" => elgg_echo("group:removemanager"), "href" => "groups/removemanager/" . $page_owner->getGUID() . "/" . $entity->getGUID(), "is_action" => true, "priority" => 503));
            }
        }
    }
    return $result;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:27,代码来源:start.php

示例2: friend_request_entity_menu_handler

function friend_request_entity_menu_handler($hook, $type, $returnvalue, $params)
{
    $result = $returnvalue;
    if (!empty($params) && is_array($params) && ($user = elgg_get_logged_in_user_entity())) {
        $entity = elgg_extract("entity", $params);
        if (elgg_instanceof($entity, "user") && $entity->getGUID() != $user->getGUID()) {
            if (!empty($result) && !is_array($result)) {
                $result = array($result);
            } elseif (empty($result)) {
                $result = array();
            }
            // are we friends
            if (!$entity->isFriendOf($user->getGUID())) {
                // no, check if pending request
                if (check_entity_relationship($user->getGUID(), "friendrequest", $entity->getGUID())) {
                    // pending request
                    $result[] = ElggMenuItem::factory(array("name" => "friend_request", "text" => elgg_echo("friend_request:friend:add:pending"), "href" => "friend_request/" . $user->username . "#friend_request_sent_listing", "priority" => 500));
                } else {
                    // add as friend
                    $result[] = ElggMenuItem::factory(array("name" => "add_friend", "text" => elgg_echo("friend:add"), "href" => "action/friends/add?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500));
                }
            } else {
                // is friend, se remove friend link
                $result[] = ElggMenuItem::factory(array("name" => "remove_friend", "text" => elgg_echo("friend:remove"), "href" => "action/friends/remove?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500));
            }
        }
    }
    return $result;
}
开发者ID:duanhv,项目名称:mdg-social,代码行数:29,代码来源:hooks.php

示例3: is_blocked

/**
 * Is $blocked_user blocked by $blocking_user?
 *
 * @param ElggUser $blocked_user
 * @param ElggUser $blocking_user
 * @return type bool
 */
function is_blocked(\ElggUser $blocked_user, \ElggUser $blocking_user)
{
    if (!$blocked_user instanceof \ElggUser || !$blocking_user instanceof \ElggUser) {
        return false;
    }
    return (bool) check_entity_relationship($blocking_user->getGUID(), 'blocked', $blocked_user->getGUID());
}
开发者ID:arckinteractive,项目名称:block_users,代码行数:14,代码来源:functions.php

示例4: hj_framework_set_ancestry

/**
 * Retrieve ancestry relationships / update if they have changed
 *
 * @param int $guid
 * @param mixed $subtypes
 * @return boolean|array
 */
function hj_framework_set_ancestry($guid)
{
    $entity = get_entity($guid);
    if (!$entity) {
        return false;
    }
    $ia = elgg_set_ignore_access(true);
    // Build an hierarchy from [0]highest to [X]lowest
    $ancestry = array();
    $ancestry_guids = array();
    $container = $entity->getContainerEntity();
    while (elgg_instanceof($container)) {
        array_unshift($ancestry, $container);
        array_unshift($ancestry_guids, $container->guid);
        $container = $container->getContainerEntity();
    }
    // Store as a hash so we don't unnecessarily update the hierarchy every time save() is calleed
    if (!isset($entity->hierarchy_hash) || $entity->hierarchy_hash != sha1(serialize($ancestry_guids))) {
        remove_entity_relationships($entity->guid, 'descendant', false);
        foreach ($ancestry as $ancestor) {
            if (elgg_instanceof($ancestor, 'object')) {
                update_entity_last_action($ancestor->guid, $entity->time_created);
            }
            if (!check_entity_relationship($entity->guid, 'descendant', $ancestor->guid)) {
                add_entity_relationship($entity->guid, 'descendant', $ancestor->guid);
            }
        }
        $entity->hierarchy_hash = sha1(serialize($ancestry_guids));
    }
    elgg_set_ignore_access($ia);
    return $ancestry;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:39,代码来源:hierarchies.php

示例5: isUserWaiting

 /**
  * Checks if a given user is waiting for this slot
  *
  * @param string $user_guid guid of the user
  *
  * @return ElggRelationship|false
  */
 public function isUserWaiting($user_guid = null)
 {
     if (empty($user_guid)) {
         $user_guid = elgg_get_logged_in_user_guid();
     }
     return check_entity_relationship($user_guid, EVENT_MANAGER_RELATION_SLOT_REGISTRATION_WAITINGLIST, $this->getGUID());
 }
开发者ID:pleio,项目名称:event_manager,代码行数:14,代码来源:EventSlot.php

示例6: au_staff_options

function au_staff_options($pageowner)
{
    $user = elgg_get_logged_in_user_entity();
    $group = elgg_get_page_owner_entity();
    if (elgg_instanceof($group, 'group')) {
        //check group attributes - ignore if au staff
        if ($group->staff_only_enable == 'yes') {
            elgg_extend_view('group/default', 'groups/sidebar/staff_only', 502);
            //do stuff if this is a staff-only group
            //system_message("AU staff-only group: only AU staff members can join this group");
            if (elgg_is_logged_in()) {
                $invited = check_entity_relationship($group->getGUID(), "invited", $user->getGUID());
                //allow invited users in
                if (is_au_staff_member($user) || elgg_is_admin_logged_in() || $group->canEdit() || $invited) {
                    //do other stuff - welcome here
                } else {
                    //remove buttons for non staff members who are not members of the group and not invited
                    if (!$group->isMember($user)) {
                        elgg_register_plugin_hook_handler('register', 'menu:title', 'au_landing_remove_group_join_button', 9999);
                        //remove the link we added in groups_ux to allow joining from discussion forum
                        elgg_unextend_view('discussion/replies', 'discussion/replies/join');
                    }
                }
            }
        } else {
            //this is a normal group
        }
    } else {
        //not a group, do nothing
    }
}
开发者ID:AU-Landing-Project,项目名称:au_landing,代码行数:31,代码来源:functions.php

示例7: theme_haarlem_intranet_profile_sync_site_membership

/**
 * Make sure the user from profile_sync is a member of the site
 *
 * @param string $event  the name of the event
 * @param string $type   the type of the event
 * @param mixed  $object supplied object
 *
 * @return void
 */
function theme_haarlem_intranet_profile_sync_site_membership($event, $type, $object)
{
    if (empty($object) || !is_array($object)) {
        return;
    }
    $user = elgg_extract('entity', $object);
    if (empty($user) || !elgg_instanceof($user, 'user')) {
        return;
    }
    $datasource = elgg_extract('datasource', $object);
    if (empty($datasource) || !elgg_instanceof($datasource, 'object', 'profile_sync_datasource')) {
        return;
    }
    if ($datasource->datasource_type !== 'csv') {
        return;
    }
    $csv_location = $datasource->csv_location;
    $csv_filename = basename($csv_location);
    $site = elgg_get_site_entity();
    $is_member = check_entity_relationship($user->getGUID(), 'member_of_site', $site->getGUID());
    if ($csv_filename === 'pleio_removed.csv') {
        if ($is_member) {
            $site->removeUser($user->getGUID());
        }
        return;
    }
    if (!$is_member) {
        // not a member, so add
        $site->addUser($user->getGUID());
    }
}
开发者ID:Twizanex,项目名称:theme_haarlem_intranet,代码行数:40,代码来源:events.php

示例8: plugins_is_dugg

/**
 * Has the current user has dugg the plugin project
 * @param $project
 * @return bool
 */
function plugins_is_dugg($project)
{
    if (check_entity_relationship(get_loggedin_userid(), "has_dugg", $project->guid)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:nohup,项目名称:community_plugins,代码行数:13,代码来源:plugin_functions.php

示例9: hj_inbox_user_hover_menu_setup

/**
 * Register user hover menu items
 */
function hj_inbox_user_hover_menu_setup($hook, $type, $return, $params)
{
    $recipient = elgg_extract('entity', $params);
    $sender = elgg_get_logged_in_user_entity();
    if (!$sender || !$recipient) {
        return $return;
    }
    if ($sender->guid == $recipient->guid) {
        return $return;
    }
    $message_types = elgg_get_config('inbox_message_types');
    $user_types = elgg_get_config('inbox_user_types');
    foreach ($message_types as $type => $options) {
        if ($type == HYPEINBOX_NOTIFICATION) {
            continue;
        }
        $valid = false;
        $policies = $options['policy'];
        if (!$policies) {
            $valid = true;
        } else {
            foreach ($policies as $policy) {
                $valid = false;
                $recipient_type = $policy['recipient'];
                $sender_type = $policy['sender'];
                $relationship = $policy['relationship'];
                $inverse_relationship = $policy['inverse_relationship'];
                $group_relationship = $policy['group_relationship'];
                $recipient_validator = $user_types[$recipient_type]['validator'];
                if ($recipient_type == 'all' || $recipient_validator && is_callable($recipient_validator) && call_user_func($recipient_validator, $recipient, $recipient_type)) {
                    $sender_validator = $user_types[$sender_type]['validator'];
                    if ($sender_type == 'all' || $sender_validator && is_callable($sender_validator) && call_user_func($sender_validator, $sender, $sender_type)) {
                        $valid = true;
                        if ($relationship && $relationship != 'all') {
                            if ($inverse_relationship) {
                                $valid = check_entity_relationship($recipient->guid, $relationship, $sender->guid);
                            } else {
                                $valid = check_entity_relationship($sender->guid, $relationship, $recipient->guid);
                            }
                        }
                        if ($valid && $group_relationship && $group_relationship != 'all') {
                            $dbprefix = elgg_get_config('dbprefix');
                            $valid = elgg_get_entities_from_relationship(array('types' => 'group', 'relationship' => 'member', 'relationship_guid' => $recipient->guid, 'count' => true, 'wheres' => array("EXISTS (SELECT * FROM {$dbprefix}entity_relationships WHERE guid_one = {$sender->guid} AND relationship = '{$group_relationship}' AND guid_two = r.guid_two)")));
                        }
                    }
                }
                if ($valid) {
                    break;
                }
            }
        }
        if ($valid) {
            $return[] = ElggMenuItem::factory(array('name' => "messages:{$type}", 'text' => elgg_echo("hj:inbox:send", array(strtolower(elgg_echo("item:object:message:{$type}:singular")))), 'href' => elgg_http_add_url_query_elements("messages/compose", array('message_type' => $type, 'send_to' => $recipient->guid)), 'section' => 'action'));
        }
    }
    return $return;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:60,代码来源:menus.php

示例10: testGroupSubscriptionRemovedWhenMemberRelationshipRemoved

 public function testGroupSubscriptionRemovedWhenMemberRelationshipRemoved()
 {
     $this->group->join($this->user1);
     $this->assertTrue($this->group->isMember($this->user1));
     elgg_add_subscription($this->user1->guid, 'test', $this->group->guid);
     $this->assertIsA(check_entity_relationship($this->user1->guid, 'notifytest', $this->group->guid), ElggRelationship::class);
     $this->group->leave($this->user1);
     $this->assertFalse($this->group->isMember($this->user1));
     $this->assertFalse(check_entity_relationship($this->user1->guid, 'notifytest', $this->user2->guid));
 }
开发者ID:elgg,项目名称:elgg,代码行数:10,代码来源:ElggNotificationsPluginUnitTest.php

示例11: post

 /**
  * {@inheritdoc}
  */
 public function post(ParameterBag $params)
 {
     $user = get_entity($params->guid);
     $site = elgg_get_site_entity();
     if (!$user || !$site || !check_entity_relationship($user->guid, 'member_of_site', $site->guid)) {
         throw new GraphException("User is not a member of this site", 403);
     }
     $token = hypeGraph()->tokens->create($user, $site);
     if (!$token) {
         throw new GraphException("Unable to generate a new user token", 500);
     }
     return array('token' => $token->token, 'expires' => date(DATE_ATOM, $token->expires), 'user' => $user, 'site_uid' => "se{$token->site_guid}");
 }
开发者ID:hypejunction,项目名称:hypegraph,代码行数:16,代码来源:AccessToken.php

示例12: groupMembership

 /**
  * Change the name/function of the group join button
  *
  * @param string          $hook         the name of the hook
  * @param string          $type         the type of the hook
  * @param \ElggMenuItem[] $return_value current return value
  * @param array           $params       supplied params
  *
  * @return void|\ElggMenuItem[]
  */
 public static function groupMembership($hook, $type, $return_value, $params)
 {
     if (!elgg_in_context('groups')) {
         return;
     }
     $page_owner = elgg_get_page_owner_entity();
     $user = elgg_get_logged_in_user_entity();
     if (!$page_owner instanceof \ElggGroup || !$user instanceof \ElggUser) {
         return;
     }
     if (empty($return_value) || !is_array($return_value)) {
         return;
     }
     foreach ($return_value as $menu_item) {
         // group join button?
         if ($menu_item->getName() !== 'groups:joinrequest') {
             continue;
         }
         if (check_entity_relationship($user->getGUID(), 'membership_request', $page_owner->getGUID())) {
             // user already requested to join this group
             $menu_item->setText(elgg_echo('group_tools:joinrequest:already'));
             $menu_item->setTooltip(elgg_echo('group_tools:joinrequest:already:tooltip'));
             $menu_item->setHref("action/groups/killrequest?user_guid={$user->getGUID()}&group_guid={$page_owner->getGUID()}");
             $menu_item->is_action = true;
         } elseif (check_entity_relationship($page_owner->getGUID(), 'invited', $user->getGUID())) {
             // the user was invited, so let him/her join
             $menu_item->setName('groups:join');
             $menu_item->setText(elgg_echo('groups:join'));
             $menu_item->setTooltip(elgg_echo('group_tools:join:already:tooltip'));
             $menu_item->setHref("action/groups/join?user_guid={$user->getGUID()}&group_guid={$page_owner->getGUID()}");
             $menu_item->is_action = true;
         } elseif (group_tools_check_domain_based_group($page_owner, $user)) {
             // user has a matching email domain
             $menu_item->setName('groups:join');
             $menu_item->setText(elgg_echo('groups:join'));
             $menu_item->setTooltip(elgg_echo('group_tools:join:domain_based:tooltip'));
             $menu_item->setHref("action/groups/join?user_guid={$user->getGUID()}&group_guid={$page_owner->getGUID()}");
             $menu_item->is_action = true;
         } elseif (group_tools_join_motivation_required($page_owner)) {
             // a join motivation is required
             elgg_load_js('lightbox');
             elgg_load_css('lightbox');
             $menu_item->setHref("ajax/view/group_tools/forms/motivation?guid={$page_owner->getGUID()}");
             $menu_item->addLinkClass('elgg-lightbox');
             $opts = 'data-colorbox-opts';
             $menu_item->{$opts} = json_encode(['width' => '500px']);
         }
         break;
     }
     return $return_value;
 }
开发者ID:coldtrick,项目名称:group_tools,代码行数:61,代码来源:TitleMenu.php

示例13: group_tools_multiple_admin_group_leave

function group_tools_multiple_admin_group_leave($event, $type, $params)
{
    if (!empty($params) && is_array($params)) {
        if (array_key_exists("group", $params) && array_key_exists("user", $params)) {
            $entity = $params["group"];
            $user = $params["user"];
            if ($entity instanceof ElggGroup && $user instanceof ElggUser) {
                if (check_entity_relationship($user->getGUID(), "group_admin", $entity->getGUID())) {
                    return remove_entity_relationship($user->getGUID(), "group_admin", $entity->getGUID());
                }
            }
        }
    }
}
开发者ID:socialweb,项目名称:PiGo,代码行数:14,代码来源:events.php

示例14: questions_leave_site_handler

/**
 * When an expert leaves the site, remove the expert role
 *
 * @param string $event the 'delete' event
 * @param string $type for the 'member_of_site' type
 * @param ElggRelationship $relationship the provided params
 *
 * @return void
 */
function questions_leave_site_handler($event, $type, $relationship)
{
    if (!empty($relationship) && $relationship instanceof ElggRelationship) {
        $user = get_user($relationship->guid_one);
        $site = elgg_get_site_entity($relationship->guid_two);
        if (!empty($user) && !empty($site)) {
            // is the user an expert in this site
            if (check_entity_relationship($user->getGUID(), QUESTIONS_EXPERT_ROLE, $site->getGUID())) {
                // remove the expert role
                remove_entity_relationship($user->getGUID(), QUESTIONS_EXPERT_ROLE, $site->getGUID());
            }
        }
    }
}
开发者ID:Pleio,项目名称:questions,代码行数:23,代码来源:events.php

示例15: execute

 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $relationship = check_entity_relationship($this->user->guid, 'tagged_in', $this->entity->guid);
     if ($relationship instanceof \ElggRelationship) {
         if ($relationship->delete()) {
             elgg_delete_river(array('subject_guids' => $this->user->guid, 'object_guids' => $this->entity->guid, 'action_types' => 'tagged'));
             /**
              * @todo: remove from access collection?
              */
             $this->result->addMessage(elgg_echo('wall:remove_tag:success'));
             return;
         }
     }
     $this->result->addError(elgg_echo('wall:remove_tag:error'));
 }
开发者ID:justangel,项目名称:hypeWall,代码行数:18,代码来源:RemoveTag.php


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