本文整理汇总了PHP中remove_entity_relationships函数的典型用法代码示例。如果您正苦于以下问题:PHP remove_entity_relationships函数的具体用法?PHP remove_entity_relationships怎么用?PHP remove_entity_relationships使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_entity_relationships函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: file_tools_object_handler
function file_tools_object_handler($event, $type, $object)
{
if (!empty($object) && elgg_instanceof($object, "object", "file")) {
$folder_guid = (int) get_input("folder_guid", 0);
if (!empty($folder_guid)) {
if ($folder = get_entity($folder_guid)) {
if (!elgg_instanceof($folder, "object", FILE_TOOLS_SUBTYPE)) {
unset($folder_guid);
}
} else {
unset($folder_guid);
}
}
// remove old relationships
remove_entity_relationships($object->getGUID(), FILE_TOOLS_RELATIONSHIP, true);
if (!empty($folder_guid)) {
add_entity_relationship($folder_guid, FILE_TOOLS_RELATIONSHIP, $object->getGUID());
//update parent folders last_action attribute
update_entity_last_action($folder_guid);
$parent_guid = get_entity($folder_guid)->parent_guid;
if ($parent_guid) {
update_parent_folder_last_action($parent_guid);
}
}
}
}
示例2: 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;
}
示例3: roles_set_role
/**
* Assigns a role to a particular user
*
* @param ElggRole $role The role to be assigned
* @param ElggUser $user The user the role needs to be assigned to
* @return mixed True if the role change was successful, false if could not update user role, and null if there was no change in user role
*/
function roles_set_role($role, $user = null)
{
if (!elgg_instanceof($role, 'object', 'role')) {
return false;
// Couldn't set new role
}
$user = $user ? $user : elgg_get_logged_in_user_entity();
if (!elgg_instanceof($user, 'user')) {
return false;
// Couldn't set new role
}
$current_role = roles_get_role($user);
if ($role != $current_role) {
remove_entity_relationships($user->guid, 'has_role');
if ($role->name != DEFAULT_ROLE && $role->name != ADMIN_ROLE) {
if (!add_entity_relationship($user->guid, 'has_role', $role->guid)) {
return false;
// Couldn't set new role
}
}
return true;
// Role has been changed
}
return null;
// There was no change necessary, old and new role are the same
}
示例4: unmarkCorrect
/**
* Unmark answer as correct
*
* @return bool
*/
public function unmarkCorrect()
{
if ($this->getQuestion()->getStatus() == 'closed') {
$this->getQuestion()->setStatus('open');
}
return remove_entity_relationships($this->getQuestion()->guid, "correctAnswer");
}
示例5: entity_admins_manage_admins
function entity_admins_manage_admins($event, $object_type, $object)
{
if (get_input('entity-admins-support') && $object instanceof ElggEntity) {
remove_entity_relationships($object->guid, 'entity_admin_for', true);
// currently the userpicker name is hardcoded to "members"
$members = get_input('members');
if ($members) {
foreach ($members as $guid) {
add_entity_relationship($guid, 'entity_admin_for', $object->guid);
}
}
}
return true;
}
示例6: migrateTreeStructure
/**
* Migrate old tree structure to new structure
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $entity supplied entity
*
* @return void
*/
public static function migrateTreeStructure($event, $type, $entity)
{
// this process could take a while
set_time_limit(0);
// set entity options
$options = ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'metadata_name' => 'parent_guid', 'site_guids' => false, 'limit' => false];
// set default metadata options
$metadata_options = ['metadata_name' => 'parent_guid', 'site_guids' => false, 'limit' => false];
// make sure we can get all entities
$ia = elgg_set_ignore_access(true);
// create a batch for processing
$batch = new \ElggBatch('elgg_get_entities_from_metadata', $options);
$batch->setIncrementOffset(false);
foreach ($batch as $entity) {
$metadata_options['guid'] = $entity->getGUID();
$parent_guid = (int) $entity->parent_guid;
if (empty($parent_guid)) {
// workaround for multi-site
elgg_delete_metadata($metadata_options);
continue;
}
$parent = get_entity($parent_guid);
if (empty($parent)) {
// workaround for multi-site
elgg_delete_metadata($metadata_options);
continue;
}
// set correct container
$entity->container_guid = $parent->getGUID();
$entity->save();
// find the root page for the tree
$root = self::findOldRootPage($entity);
if (empty($root)) {
// workaround for multi-site
elgg_delete_metadata($metadata_options);
continue;
}
// add relationship to the correct tree
remove_entity_relationships($entity->getGUID(), 'subpage_of');
$entity->addRelationship($root->getGUID(), 'subpage_of');
// workaround for multi-site
elgg_delete_metadata($metadata_options);
}
// restore access
elgg_set_ignore_access($ia);
}
示例7: bookmark_tools_object_handler
function bookmark_tools_object_handler($event, $type, $object)
{
if (!empty($object) && elgg_instanceof($object, "object", "bookmarks")) {
$folder_guid = (int) get_input("bmfolder_guid", 0);
if (!empty($folder_guid)) {
if ($folder = get_entity($folder_guid)) {
if (!elgg_instanceof($folder, "object", BOOKMARK_TOOLS_SUBTYPE)) {
unset($folder_guid);
}
} else {
unset($folder_guid);
}
}
// remove old relationships
remove_entity_relationships($object->getGUID(), BOOKMARK_TOOLS_RELATIONSHIP, true);
if (!empty($folder_guid)) {
add_entity_relationship($folder_guid, BOOKMARK_TOOLS_RELATIONSHIP, $object->getGUID());
}
}
}
示例8: setFolderGUID
/**
* Set the folder for the file
*
* @param \ElggFile $entity the file to edit
*
* @return void
*/
protected static function setFolderGUID(\ElggFile $entity)
{
$folder_guid = get_input('folder_guid', false);
if ($folder_guid === false) {
// folder_input was not present in form/action
// maybe someone else did something with a file
return;
}
$folder_guid = (int) $folder_guid;
if (!empty($folder_guid)) {
$folder = get_entity($folder_guid);
if (!elgg_instanceof($folder, 'object', FILE_TOOLS_SUBTYPE)) {
unset($folder_guid);
}
}
// remove old relationships
remove_entity_relationships($entity->getGUID(), FILE_TOOLS_RELATIONSHIP, true);
if (!empty($folder_guid)) {
add_entity_relationship($folder_guid, FILE_TOOLS_RELATIONSHIP, $entity->getGUID());
}
}
示例9: unsetUserRole
/**
* {@inheritdoc}
*/
public function unsetUserRole(\ElggUser $user)
{
return (bool) remove_entity_relationships($user->guid, 'has_role');
}
示例10: afterCleanup
/**
* Cleanup some stuff
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param null $return_value current return value
* @param array $params supplied params
*
* @return void
*/
public static function afterCleanup($hook, $type, $return_value, $params)
{
if (!self::validateNotificationEvent($params)) {
// not the correct notification event
return;
}
/* @var $event \Elgg\Notifications\Event */
$event = elgg_extract('event', $params);
/* @var $relationship \ElggRelationship */
$relationship = $event->getObject();
$entity = get_entity($relationship->guid_two);
// cleanup the relationship
remove_entity_relationships($entity->getGUID(), 'tag_tools:notification', true);
// save the newly sent tags
$sending_tags = tag_tools_get_unsent_tags($entity);
if (empty($sending_tags)) {
return;
}
tag_tools_add_sent_tags($entity, $sending_tags);
}
示例11: update_user_friends_notifications_settings
update_user_friends_notifications_settings($user->guid, get_input('friends_batch_method'));
// actualizo las relaciones de notificacion entre un usuario y todos sus amigos
$friends_method = get_input('friends_batch_method');
if ($friends_method != 'nocambiar') {
$friends = get_user_friends($user->guid);
foreach ($friends as $friend) {
switch (get_input('friends_batch_method')) {
case 'email':
add_entity_relationship($user->guid, 'notifyemail', $friend->guid);
remove_entity_relationships($user->guid, 'notifysite', false, 'user');
break;
case 'site':
add_entity_relationship($user->guid, 'notifysite', $friend->guid);
remove_entity_relationships($user->guid, 'notifyemail', false, 'user');
break;
case 'todos':
add_entity_relationship($user->guid, 'notifyemail', $friend->guid);
add_entity_relationship($user->guid, 'notifysite', $friend->guid);
break;
case 'ninguno':
remove_entity_relationships($user->guid, 'notifyemail', false, 'user');
remove_entity_relationships($user->guid, 'notifysite', false, 'user');
default:
// metodo (nocambiar)
break;
}
}
}
}
system_message(elgg_echo("notifications_tools:done"));
forward("admin/batch_update&personal_batch_method=" . get_input('personal_batch_method') . "&friends_batch_method=" . get_input('friends_batch_method'));
示例12: gatekeeper
* Elgg notifications
*
* @package ElggNotifications
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider Ltd
* @copyright Curverider Ltd 2008-2009
* @link http://elgg.com/
*/
// Restrict to logged in users
gatekeeper();
global $SESSION;
global $NOTIFICATION_HANDLERS;
foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
$subscriptions[$method] = get_input($method . 'subscriptions');
$personal[$method] = get_input($method . 'personal');
$collections[$method] = get_input($method . 'collections');
$metaname = 'collections_notifications_preferences_' . $method;
$_SESSION['user']->{$metaname} = $collections[$method];
set_user_notification_setting($_SESSION['user']->guid, $method, $personal[$method] == '1' ? true : false);
remove_entity_relationships($SESSION['user']->guid, 'notify' . $method, false, 'user');
}
// Add new ones
foreach ($subscriptions as $key => $subscription) {
if (is_array($subscription) && !empty($subscription)) {
foreach ($subscription as $subscriptionperson) {
add_entity_relationship($_SESSION['user']->guid, 'notify' . $key, $subscriptionperson);
}
}
}
system_message(elgg_echo('notifications:subscriptions:success'));
forward($_SERVER['HTTP_REFERER']);
示例13: static_check_children_tree
/**
* Make sure all the children are in the correct tree
*
* @param ElggObject $entity the entity to check the children from
* @param int $tree_guid the correct tree guid (will default to the given entity)
*
* @return bool
*/
function static_check_children_tree(ElggObject $entity, $tree_guid = 0)
{
if (!elgg_instanceof($entity, 'object', 'static')) {
return false;
}
$tree_guid = sanitise_int($tree_guid, false);
if (empty($tree_guid)) {
$tree_guid = $entity->getGUID();
}
// ignore access for this part
$ia = elgg_set_ignore_access(true);
$batch = new ElggBatch('elgg_get_entities', ['type' => 'object', 'subtype' => StaticPage::SUBTYPE, 'owner_guid' => $entity->getOwnerGUID(), 'container_guid' => $entity->getGUID(), 'limit' => false]);
foreach ($batch as $static) {
// remove old tree
remove_entity_relationships($static->getGUID(), 'subpage_of');
// add new tree
add_entity_relationship($static->getGUID(), 'subpage_of', $tree_guid);
// check children
static_check_children_tree($static, $tree_guid);
}
// restore access
elgg_set_ignore_access($ia);
return true;
}
示例14: add_entity_relationship
add_entity_relationship(elgg_get_logged_in_user_guid(), 'is_doing', $entity_guid);
break;
case 'assign_and_activate':
add_entity_relationship(elgg_get_logged_in_user_guid(), 'subscribes', $entity_guid);
add_entity_relationship(elgg_get_logged_in_user_guid(), 'is_doing', $entity_guid);
break;
case 'deactivate':
remove_entity_relationship(elgg_get_logged_in_user_guid(), 'is_doing', $entity_guid);
break;
case 'leave':
remove_entity_relationship(elgg_get_logged_in_user_guid(), 'is_doing', $entity_guid);
remove_entity_relationship(elgg_get_logged_in_user_guid(), 'subscribes', $entity_guid);
break;
case 'reopen':
remove_entity_relationships($entity_guid, 'is_doing', true);
remove_entity_relationships($entity_guid, 'subscribes', true);
break;
}
if (in_array($state_action, array('activate', 'assign_and_activate'))) {
if ($active_task = tasks_get_user_active_task($user->guid)) {
$active_task->status = 'assigned';
create_annotation($active_task->guid, 'task_state_changed', 'assigned', "", $user->guid, $active_task->access_id);
}
}
$new_state = tasks_get_state_from_action($state_action);
if ($state_action == 'leave') {
$have_participants_yet = elgg_get_entities_from_relationship(array('relationship' => 'subscribes', 'relationship_guid' => $entity->guid, 'inverse_relationship' => true, 'count' => true));
if ($have_participants_yet) {
$new_state = $entity->status;
}
}
示例15: get_input
$file_guid = (int) get_input("file_guid", 0);
$folder_guid = (int) get_input("folder_guid", 0);
if (!empty($file_guid)) {
if ($file = get_entity($file_guid)) {
$container_entity = $file->getContainerEntity();
if ($file->canEdit() || elgg_instanceof($container_entity, "group") && $container_entity->isMember()) {
if (elgg_instanceof($file, "object", "file")) {
// check if a given guid is a folder
if (!empty($folder_guid)) {
if (!($folder = get_entity($folder_guid)) || !elgg_instanceof($folder, "object", FILE_TOOLS_SUBTYPE)) {
unset($folder_guid);
}
}
// remove old relationships
remove_entity_relationships($file->getGUID(), FILE_TOOLS_RELATIONSHIP, true);
if (!empty($folder_guid)) {
add_entity_relationship($folder_guid, FILE_TOOLS_RELATIONSHIP, $file_guid);
}
system_message(elgg_echo("file_tools:action:move:success:file"));
} elseif (elgg_instanceof($file, "object", FILE_TOOLS_SUBTYPE)) {
$file->parent_guid = $folder_guid;
system_message(elgg_echo("file_tools:action:move:success:folder"));
}
} else {
register_error(elgg_echo("InvalidParameterException:NoEntityFound"));
}
} else {
register_error(elgg_echo("InvalidParameterException:NoEntityFound"));
}
} else {