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


PHP remove_entity_relationship函数代码示例

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


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

示例1: group_tools_add_user

/**
 * Add a user to a group
 *
 * @param ElggGroup $group the group to add the user to
 * @param ElggUser  $user  the user to be added
 * @param string    $text  (optional) extra text for the notification
 *
 * @return boolean 	true if successfull
 */
function group_tools_add_user(ElggGroup $group, ElggUser $user, $text = "")
{
    $result = false;
    $loggedin_user = elgg_get_logged_in_user_entity();
    if (!empty($user) && $user instanceof ElggUser && !empty($group) && $group instanceof ElggGroup && !empty($loggedin_user)) {
        // make sure all goes well
        $ia = elgg_set_ignore_access(true);
        if ($group->join($user)) {
            // Remove any invite or join request flags
            remove_entity_relationship($group->getGUID(), "invited", $user->getGUID());
            remove_entity_relationship($user->getGUID(), "membership_request", $group->getGUID());
            // notify user
            $subject = elgg_echo("group_tools:groups:invite:add:subject", array($group->name));
            $msg = elgg_echo("group_tools:groups:invite:add:body", array($user->name, $loggedin_user->name, $group->name, $text, $group->getURL()));
            $params = array("group" => $group, "inviter" => $loggedin_user, "invitee" => $user);
            $msg = elgg_trigger_plugin_hook("invite_notification", "group_tools", $params, $msg);
            if (notify_user($user->getGUID(), $group->getOwnerGUID(), $subject, $msg, null, "email")) {
                $result = true;
            }
        }
        // restore access
        elgg_set_ignore_access($ia);
    }
    return $result;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:34,代码来源:functions.php

示例2: notifications_relationship_remove

/**
 * Update notifications when a relationship is deleted
 *
 * @param string $event
 * @param string $object_type
 * @param object $relationship
 */
function notifications_relationship_remove($event, $object_type, $relationship)
{
    global $NOTIFICATION_HANDLERS;
    $user_guid = $relationship->guid_one;
    $object_guid = $relationship->guid_two;
    // loop through all notification types
    foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
        remove_entity_relationship($user_guid, "notify{$method}", $object_guid);
    }
}
开发者ID:redvabel,项目名称:Vabelgg,代码行数:17,代码来源:start.php

示例3: testPreventRemoveRelationship

 public function testPreventRemoveRelationship()
 {
     $this->assertTrue(add_entity_relationship($this->entity1->guid, 'test_relationship', $this->entity2->guid));
     $r = check_entity_relationship($this->entity1->guid, 'test_relationship', $this->entity2->guid);
     $this->assertIsA($r, 'ElggRelationship');
     elgg_register_event_handler('delete', 'relationship', 'Elgg\\Values::getFalse');
     $this->assertFalse(remove_entity_relationship($this->entity1->guid, 'test_relationship', $this->entity2->guid));
     elgg_unregister_event_handler('delete', 'relationship', 'Elgg\\Values::getFalse');
     $r = check_entity_relationship($this->entity1->guid, 'test_relationship', $this->entity2->guid);
     $this->assertIsA($r, 'ElggRelationship');
 }
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:11,代码来源:ElggRelationshipTest.php

示例4: delete

 public function delete()
 {
     $result = false;
     $event = get_entity($this->event_guid);
     $result = remove_entity_relationship($this->event_guid, ZHAOHU_MANAGER_RELATION_ATTENDING, $this->user_guid);
     if (!$result) {
         elgg_log("ZHError ,coupon:delete, failed to remove_entity_relationship, coupon_id {$this->guid}", "ERROR");
         return false;
     }
     parent::delete();
     return true;
 }
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:12,代码来源:Coupon.php

示例5: removeMember

 /**
  * Remove user from chat
  *
  * - Delete the relationship
  * - Delete annotations from the messages
  * - Delete annotations from the chat
  *
  * @param $user
  */
 public function removeMember($user)
 {
     $success = remove_entity_relationship($user->getGUID(), 'member', $this->getGUID());
     $messages = elgg_get_entities_from_relationship(array('relationship' => 'unread', 'relationship_guid' => $user->getGUID(), 'inverse_relationship' => TRUE, 'container_guid' => $this->getGUID()));
     // Remove annotations from messages
     foreach ($messages as $message) {
         remove_entity_relationship($message->getGUID(), 'unread', $user->getGUID());
     }
     // Remove unread_messages annotation from chat
     $this->resetUnreadMessageCount($user);
     return $success;
 }
开发者ID:juho-jaakkola,项目名称:elgg-chat,代码行数:21,代码来源:ElggChat.php

示例6: update_entity_categories

/**
 * Update entity categories
 *
 * @param string $event		Equals 'create' or 'update'
 * @param string $type		Equals 'object', 'user' or 'group'
 * @param ElggEntity $entity
 * @return boolean
 */
function update_entity_categories($event, $type, $entity)
{
    if (!elgg_instanceof($entity)) {
        return true;
    }
    $entity_guid = $entity->getGUID();
    // No need to run this handler on multiple update events for this entity
    global $TAXONOMY_CATCH;
    if (isset($TAXONOMY_CATCH[$entity_guid])) {
        return true;
    }
    $TAXONOMY_CATCH[$entity_guid] = true;
    // Restrict the scope of the handler to entity types/subtypes specified in the plugin settings
    $type = $entity->getType();
    $subtype = $entity->getSubtype();
    if (!$subtype) {
        $subtype = 'default';
    }
    $taxonomy_type_subtype_pairs = elgg_get_config('taxonomy_type_subtype_pairs');
    if (!in_array("{$type}:{$subtype}", $taxonomy_type_subtype_pairs)) {
        return true;
    }
    $input_categories = get_input('categories', false);
    //set_input('categories', false); // prevent this handler from running multiple times in case of nested actions
    // Category form input was not present
    if (!$input_categories) {
        return true;
    }
    // User did not specify any categories
    if ($input_categories && !is_array($input_categories)) {
        $input_categories = array();
    }
    $future_categories = array();
    foreach ($input_categories as $guid) {
        $category = get_entity($guid);
        $universal_categories[] = $category->title;
        $hierarchy = get_hierarchy($category->guid, true, true);
        $future_categories = array_merge($future_categories, $hierarchy);
    }
    // Storing categories metadata for compatibility with categories plugin
    $entity->universal_categories = $universal_categories;
    $current_categories = get_entity_categories($entity_guid, array(), true);
    $to_remove = array_diff($current_categories, $future_categories);
    $to_add = array_diff($future_categories, $current_categories);
    foreach ($to_remove as $guid) {
        remove_entity_relationship($entity_guid, HYPECATEGORIES_RELATIONSHIP, $guid);
    }
    foreach ($to_add as $guid) {
        add_entity_relationship($entity_guid, HYPECATEGORIES_RELATIONSHIP, $guid);
    }
    return true;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:60,代码来源:events.php

示例7: testCanInsert

 public function testCanInsert()
 {
     $time = time();
     $id1 = insert_data("\n\t\t\tINSERT INTO {$this->prefix}entity_relationships\n\t\t\t       (guid_one, relationship, guid_two, time_created)\n\t\t\tVALUES ({$this->user->guid}, 'test_self1', {$this->user->guid}, {$time})\n\t\t\tON DUPLICATE KEY UPDATE time_created = {$time}\n\t\t");
     $id2 = insert_data("\n\t\t\tINSERT INTO {$this->prefix}entity_relationships\n\t\t\t       (guid_one, relationship, guid_two, time_created)\n\t\t\tVALUES (:guid1,   :rel,         :guid2,   :time)\n\t\t\tON DUPLICATE KEY UPDATE time_created = :time\n\t\t", [':guid1' => $this->user->guid, ':guid2' => $this->user->guid, ':rel' => 'test_self2', ':time' => $time]);
     $rows = get_data("\n\t\t\tSELECT *\n\t\t\tFROM {$this->prefix}entity_relationships\n\t\t\tWHERE guid_one = ?\n\t\t\t  AND guid_two = ?\n\t\t\t  AND time_created = ?\n\t\t\tORDER BY id ASC\n\t\t", null, [$this->user->guid, $this->user->guid, $time]);
     $this->assertIsA($id1, 'int');
     $this->assertIsA($id2, 'int');
     $this->assertEqual($rows[0]->id, $id1);
     $this->assertEqual($rows[1]->id, $id2);
     remove_entity_relationship($this->user->guid, 'test_self1', $this->user->guid);
     remove_entity_relationship($this->user->guid, 'test_self2', $this->user->guid);
 }
开发者ID:elgg,项目名称:elgg,代码行数:13,代码来源:ElggDataFunctionsTest.php

示例8: groupLeave

 /**
  * Cleanup group admin status on group leave
  *
  * @param string $event  the name of the event
  * @param string $type   the type of the event
  * @param array  $params supplied params
  *
  * @return void|bool
  */
 public static function groupLeave($event, $type, $params)
 {
     $user = elgg_extract('user', $params);
     $group = elgg_extract('group', $params);
     if (!$user instanceof \ElggUser || !$group instanceof \ElggGroup) {
         return;
     }
     // is the user a group admin
     if (!check_entity_relationship($user->getGUID(), 'group_admin', $group->getGUID())) {
         return;
     }
     return remove_entity_relationship($user->getGUID(), 'group_admin', $group->getGUID());
 }
开发者ID:coldtrick,项目名称:group_tools,代码行数:22,代码来源:GroupAdmins.php

示例9: 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

示例10: 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

示例11: delete

 /**
  * {@inheritdoc}
  */
 public function delete(ParameterBag $params)
 {
     $user = get_entity($params->guid);
     $friend = $params->friend_uid ? $this->graph->get($params->friend_uid) : elgg_get_logged_in_user_entity();
     if (!$user instanceof ElggUser || !$friend instanceof ElggUser) {
         throw new GraphException("User or friend not found", HttpResponse::HTTP_NOT_FOUND);
     }
     if (!$user->canEdit()) {
         throw new GraphException("You are not allowed to modify this user's friends list", HttpResponse::HTTP_FORBIDDEN);
     }
     if (!remove_entity_relationship($user->guid, "friend", $friend->guid)) {
         throw new GraphException("Unable to remove friendship");
     }
     return array('nodes' => array('friend' => check_entity_relationship($user->guid, 'friend', $friend->guid), 'friend_of' => check_entity_relationship($friend->guid, 'friend', $user->guid)));
 }
开发者ID:hypejunction,项目名称:hypegraph,代码行数:18,代码来源:UserFriends.php

示例12: group_tools_add_user

function group_tools_add_user(ElggGroup $group, ElggUser $user, $text = "")
{
    $result = false;
    if (!empty($user) && $user instanceof ElggUser && !empty($group) && $group instanceof ElggGroup && ($loggedin_user = elgg_get_logged_in_user_entity())) {
        if ($group->join($user)) {
            // Remove any invite or join request flags
            remove_entity_relationship($group->getGUID(), "invited", $user->getGUID());
            remove_entity_relationship($user->getGUID(), "membership_request", $group->getGUID());
            // notify user
            $subject = elgg_echo("group_tools:groups:invite:add:subject", array($group->name));
            $msg = elgg_echo("group_tools:groups:invite:add:body", array($user->name, $loggedin_user->name, $group->name, $text, $group->getURL()));
            if (notify_user($user->getGUID(), $group->getOwnerGUID(), $subject, $msg)) {
                $result = true;
            }
        }
    }
    return $result;
}
开发者ID:remy40,项目名称:gvrs,代码行数:18,代码来源:functions.php

示例13: content_subscriptions_subscribe

/**
 * Subscribe a user to the updates of an entity
 *
 * @param int $entity_guid the content entity to subscribe to
 * @param int $user_guid   the user to subscribe (defaults to current user)
 *
 * @return bool
 */
function content_subscriptions_subscribe($entity_guid, $user_guid = 0)
{
    $entity_guid = sanitise_int($entity_guid, false);
    $user_guid = sanitise_int($user_guid, false);
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    // remove autosubscription block
    remove_entity_relationship($user_guid, CONTENT_SUBSCRIPTIONS_BLOCK, $entity_guid);
    $notification_services = _elgg_services()->notifications->getMethods();
    if (empty($notification_services)) {
        return false;
    }
    foreach ($notification_services as $service) {
        elgg_add_subscription($user_guid, $service, $entity_guid);
    }
    return true;
}
开发者ID:coldtrick,项目名称:content_subscriptions,代码行数:26,代码来源:functions.php

示例14: setStatus

 /**
  * Sets the plugin to active or inactive for $site_guid.
  *
  * @param bool  $active    Set to active or inactive
  * @param mixed $site_guid Int for specific site, null for current site.
  *
  * @return bool
  */
 private function setStatus($active, $site_guid = null)
 {
     if (!$this->guid) {
         return false;
     }
     if ($site_guid) {
         $site = get_entity($site_guid);
         if (!$site instanceof \ElggSite) {
             return false;
         }
     } else {
         $site = _elgg_services()->configTable->get('site');
     }
     if ($active) {
         $result = add_entity_relationship($this->guid, 'active_plugin', $site->guid);
     } else {
         $result = remove_entity_relationship($this->guid, 'active_plugin', $site->guid);
     }
     _elgg_invalidate_plugins_provides_cache();
     return $result;
 }
开发者ID:bhargavgarlapati,项目名称:Elgg,代码行数:29,代码来源:ElggPlugin.php

示例15: group_tools_transfer_group_ownership

/**
 * Helper function to transfer the ownership of a group to a new user
 *
 * @param ElggGroup $group     the group to transfer
 * @param ElggUser  $new_owner the new owner
 *
 * @return boolean
 */
function group_tools_transfer_group_ownership(ElggGroup $group, ElggUser $new_owner)
{
    $result = false;
    if (empty($group) || !elgg_instanceof($group, "group") || !$group->canEdit()) {
        return $result;
    }
    if (empty($new_owner) || !elgg_instanceof($new_owner, "user")) {
        return $result;
    }
    $loggedin_user = elgg_get_logged_in_user_entity();
    // register plugin hook to make sure transfer can complete
    elgg_register_plugin_hook_handler("permissions_check", "group", "group_tools_admin_transfer_permissions_hook");
    $old_owner = $group->getOwnerEntity();
    // transfer ownership
    $group->owner_guid = $new_owner->getGUID();
    $group->container_guid = $new_owner->getGUID();
    // make sure user is added to the group
    $group->join($new_owner);
    if ($group->save()) {
        // remove existing group administrator role for new owner
        remove_entity_relationship($new_owner->getGUID(), "group_admin", $group->getGUID());
        // check for group icon
        if (!empty($group->icontime)) {
            $prefix = "groups/" . $group->getGUID();
            $sizes = array("", "tiny", "small", "medium", "large");
            $ofh = new ElggFile();
            $ofh->owner_guid = $old_owner->getGUID();
            $nfh = new ElggFile();
            $nfh->owner_guid = $group->getOwnerGUID();
            foreach ($sizes as $size) {
                // set correct file to handle
                $ofh->setFilename($prefix . $size . ".jpg");
                $nfh->setFilename($prefix . $size . ".jpg");
                // open files
                $ofh->open("read");
                $nfh->open("write");
                // copy file
                $nfh->write($ofh->grabFile());
                // close file
                $ofh->close();
                $nfh->close();
                // cleanup old file
                $ofh->delete();
            }
            $group->icontime = time();
        }
        // move metadata of the group to the new owner
        $options = array("guid" => $group->getGUID(), "limit" => false);
        $metadata = elgg_get_metadata($options);
        if (!empty($metadata)) {
            foreach ($metadata as $md) {
                if ($md->owner_guid == $old_owner->getGUID()) {
                    $md->owner_guid = $new_owner->getGUID();
                    $md->save();
                }
            }
        }
        // notify new owner
        if ($new_owner->getGUID() != $loggedin_user->getGUID()) {
            $subject = elgg_echo("group_tools:notify:transfer:subject", array($group->name));
            $message = elgg_echo("group_tools:notify:transfer:message", array($new_owner->name, $loggedin_user->name, $group->name, $group->getURL()));
            notify_user($new_owner->getGUID(), $group->getGUID(), $subject, $message);
        }
        $result = true;
    }
    // unregister plugin hook to make sure transfer can complete
    elgg_unregister_plugin_hook_handler("permissions_check", "group", "group_tools_admin_transfer_permissions_hook");
    return $result;
}
开发者ID:pleio,项目名称:group_tools,代码行数:77,代码来源:functions.php


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