Example #1
0
 /**
  * Remove friends and friendscollections from the write access array
  *
  * @param string $hook        the name of the hook
  * @param string $type        the type of the hook
  * @param int    $returnvalue current return value
  * @param array  $params      supplied params
  *
  * @return array
  */
 public static function removeFriends($hook, $type, $returnvalue, $params)
 {
     if (empty($params) || !is_array($params)) {
         return;
     }
     $result = $returnvalue;
     // remove friends access
     unset($result[ACCESS_FRIENDS]);
     // unset access collections
     $user_guid = elgg_extract('user_id', $params);
     $site_guid = elgg_extract('site_id', $params);
     if ($user_guid && $site_guid) {
         $access_collections = get_user_access_collections($user_guid, $site_guid);
         if ($access_collections) {
             foreach ($access_collections as $acl) {
                 unset($result[$acl->id]);
             }
         }
     }
     return $result;
 }
/**
 * Removes a user from another user's friends list.
 *
 * @param int $user_guid The GUID of the friending user
 * @param int $friend_guid The GUID of the user on the friends list
 * @return true|false Depending on success
 */
function user_remove_friend($user_guid, $friend_guid)
{
    global $CONFIG;
    $user_guid = (int) $user_guid;
    $friend_guid = (int) $friend_guid;
    // perform cleanup for access lists.
    $collections = get_user_access_collections($user_guid);
    foreach ($collections as $collection) {
        remove_user_from_access_collection($friend_guid, $collection->id);
    }
    return remove_entity_relationship($user_guid, "friend", $friend_guid);
}
Example #3
0
 /**
  * Removes a user as a friend
  *
  * @param int $friend_guid The GUID of the user to remove
  *
  * @return bool
  * @todo change to accept \ElggUser
  */
 public function removeFriend($friend_guid)
 {
     if (!get_user($friend_guid)) {
         return false;
     }
     // @todo this should be done with a plugin hook handler on the delete relationship
     // perform cleanup for access lists.
     $collections = get_user_access_collections($this->guid);
     if ($collections) {
         foreach ($collections as $collection) {
             remove_user_from_access_collection($friend_guid, $collection->id);
         }
     }
     return remove_entity_relationship($this->guid, "friend", $friend_guid);
 }
Example #4
0
/**
 * Removes a user from another user's friends list.
 *
 * @param int $user_guid   The GUID of the friending user
 * @param int $friend_guid The GUID of the user on the friends list
 *
 * @return bool Depending on success
 * @deprecated 1.9 Use \ElggUser::removeFriend()
 */
function user_remove_friend($user_guid, $friend_guid)
{
    elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \\ElggUser::removeFriend()', 1.9);
    $user_guid = (int) $user_guid;
    $friend_guid = (int) $friend_guid;
    // perform cleanup for access lists.
    $collections = get_user_access_collections($user_guid);
    if ($collections) {
        foreach ($collections as $collection) {
            remove_user_from_access_collection($friend_guid, $collection->id);
        }
    }
    return remove_entity_relationship($user_guid, "friend", $friend_guid);
}
Example #5
0
<?php

/**
* Compose a message
*
* @package ElggMessages
*/
gatekeeper();
$message = get_entity(get_input('guid'));
if (!$message) {
    forward();
}
$page_owner = elgg_get_logged_in_user_entity();
elgg_set_page_owner_guid($page_owner->getGUID());
$title = elgg_echo('messages:forward');
elgg_push_breadcrumb($title);
$params = messages_prepare_form_vars((int) get_input('send_to'));
$params['friends'] = $page_owner->getFriends('', 50);
$params['collections'] = get_user_access_collections($page_owner->getGUID());
$params['message'] = $message;
$content = elgg_view_form('messages/forward', array(), $params);
$body = elgg_view_layout('content', array('content' => $content, 'title' => $title, 'filter' => ''));
echo elgg_view_page($title, $body);
Example #6
0
/**
 * Displays a user's access collections, using the core/friends/collections view
 *
 * @param int $owner_guid The GUID of the owning user
 *
 * @return string A formatted rendition of the collections
 * @todo Move to the friends/collection.php page.
 * @access private
 */
function elgg_view_access_collections($owner_guid)
{
    if ($collections = get_user_access_collections($owner_guid)) {
        $user = get_user($owner_guid);
        if ($user) {
            $entities = $user->getFriends(array('limit' => 0));
        } else {
            $entities = array();
        }
        foreach ($collections as $key => $collection) {
            $collections[$key]->members = get_members_of_access_collection($collection->id, true);
            $collections[$key]->entities = $entities;
        }
    }
    return elgg_view('core/friends/collections', array('collections' => $collections));
}
Example #7
0
        $tabs["users"] = array("text" => elgg_echo("group_tools:group:invite:users"), "href" => "#", "rel" => "users", "priority" => 300, "onclick" => "group_tools_group_invite_switch_tab(\"users\");");
        $form_data .= "<div id='group_tools_group_invite_users' class='mbm'>";
        $form_data .= "<div>" . elgg_echo("group_tools:group:invite:users:description") . "</div>";
        $form_data .= elgg_view("input/group_invite_autocomplete", array("name" => "user_guid", "id" => "group_tools_group_invite_autocomplete", "group_guid" => $group->getGUID(), "relationship" => "site"));
        if (elgg_is_admin_logged_in()) {
            $form_data .= elgg_view("input/checkbox", array("name" => "all_users", "value" => "yes"));
            $form_data .= elgg_echo("group_tools:group:invite:users:all");
        }
        $form_data .= "</div>";
    }
    if ($invite_circle == "yes") {
        $tabs["circle"] = array("text" => elgg_echo("friends:collections"), "href" => "#", "rel" => "users", "priority" => 400, "onclick" => "group_tools_group_invite_switch_tab(\"circle\");");
        $form_data .= "<div id='group_tools_group_invite_circle' class='mbm'>";
        $form_data .= "<p>" . elgg_echo("collections_circle_selection") . "</p>";
        $content = get_user_access_collections(elgg_get_logged_in_user_guid());
        $collection_id = get_user_access_collections(elgg_get_logged_in_user_guid());
        $form_data .= '<select class="form-control" id="user_guid[]" name="user_guid[]">
				 <option value="">---</option>';
        foreach ($content as $key => $collection) {
            $collections = get_members_of_access_collection($collection->id, true);
            $form_data .= "<option value=";
            $coll_members = array();
            foreach ($collections as $key => $value) {
                $name = get_user($value);
                $coll_members[] = $name->guid;
            }
            $form_data .= implode(',', $coll_members);
            if ($collection->id == $collection_id) {
                $form_data .= ' selected="selected"';
            }
            $form_data .= '> ';
Example #8
0
/**
 * Displays a user's access collections, using the friends/collections view
 *
 * @param int $owner_guid The GUID of the owning user
 * @return string A formatted rendition of the collections
 */
function elgg_view_access_collections($owner_guid)
{
    if ($collections = get_user_access_collections($owner_guid)) {
        foreach ($collections as $key => $collection) {
            $collections[$key]->members = get_members_of_access_collection($collection->id, true);
            $collections[$key]->entities = get_user_friends($owner_guid, "", 9999);
        }
    }
    return elgg_view('friends/collections', array('collections' => $collections));
}
if (get_plugin_setting('hidden_groups', 'groups') == 'yes') {
    ?>

	<p>
		<label>
			<?php 
    echo elgg_echo('groups:visibility');
    ?>
<br />
			<?php 
    $this_owner = $vars['entity']->owner_guid;
    if (!$this_owner) {
        $this_owner = get_loggedin_userid();
    }
    $access = array(ACCESS_FRIENDS => elgg_echo("access:friends:label"), 1 => elgg_echo("LOGGED_IN"), 2 => elgg_echo("PUBLIC"));
    $collections = get_user_access_collections($this_owner);
    if (is_array($collections)) {
        foreach ($collections as $c) {
            $access[$c->id] = $c->name;
        }
    }
    echo elgg_view('input/access', array('internalname' => 'vis', 'value' => $vars['entity']->access_id ? $vars['entity']->access_id : ACCESS_PUBLIC, 'options' => $access));
    ?>
		</label>
	</p>

<?php 
}
?>
	
    <?php 
Example #10
0
    if ($i > 0) {
        $fields .= "<td class='spacercolumn'>&nbsp;</td>";
    }
    $fields .= <<<END
\t\t\t<td class="{$method}togglefield">
\t\t\t<a border="0" id="{$method}collections-1" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}collections-1'); setCollection([{$members}],'{$method}',-1);">
\t\t\t<input type="checkbox" name="{$method}collections[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}collections-1');" value="-1" {$collectionschecked[$method]} /></a></td>
END;
    $i++;
}
echo $fields;
?>
		<td>&nbsp;</td>
	</tr>
<?php 
if ($collections = get_user_access_collections($user->guid)) {
    foreach ($collections as $collection) {
        $members = get_members_of_access_collection($collection->id, true);
        $memberno = 0;
        if ($members) {
            $memberno = sizeof($members);
            $members = implode(',', $members);
        } else {
            $members = '';
        }
        ?>
	<tr>
		<td class="namefield">
			<p>
				<?php 
        echo $collection->name;
Example #11
0
 /**
  * Update access_id of the entity
  *
  * @return void
  */
 public function updateAccessID()
 {
     $access_id = (int) $this->object->access_id;
     // ignore access restrictions
     $ia = elgg_set_ignore_access(true);
     $old_container_guid = (int) $this->original_attributes['container_guid'];
     $old_container = get_entity($old_container_guid);
     $new_container = $this->object->getContainerEntity();
     // check the old container to check access_id
     if ($old_container instanceof \ElggGroup) {
         // from a group
         if ($access_id === (int) $old_container->group_acl) {
             // with group access
             if ($new_container instanceof \ElggGroup) {
                 // to a new group
                 // change access to the new group
                 $this->object->access_id = (int) $new_container->group_acl;
             } else {
                 // new container is a user, so make the entity private
                 $this->object->access_id = ACCESS_PRIVATE;
             }
         }
     } else {
         // from a user
         $acls = [];
         $user_access_collections = get_user_access_collections($old_container_guid);
         if (!empty($user_access_collections)) {
             foreach ($user_access_collections as $acl) {
                 $acls[] = (int) $acl->id;
             }
         }
         if (in_array($access_id, $acls)) {
             // access was a private access collection
             if ($new_container instanceof \ElggGroup) {
                 // moved to a group
                 // change access to the group
                 $this->object->access_id = (int) $new_container->group_acl;
             } else {
                 // moved to different user
                 // change access to private
                 $this->object->access_id = ACCESS_PRIVATE;
             }
         }
     }
     // restore access restrictions
     elgg_set_ignore_access($ia);
 }
Example #12
0
    if ($i > 0) {
        $fields .= "<td class=\"spacercolumn\">&nbsp;</td>";
    }
    $fields .= <<<END
\t\t\t    <td class="{$method}togglefield">
\t\t\t    <a border="0" id="{$method}collections-1" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}collections-1'); setCollection([{$members}],'{$method}',-1);">
\t\t\t    <input type="checkbox" name="{$method}collections[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}collections-1');" value="-1" {$collectionschecked[$method]} /></a></td>
END;
    $i++;
}
echo $fields;
?>
	<td>&nbsp;</td>
  </tr>
<?php 
if ($collections = get_user_access_collections($vars['user']->guid)) {
    foreach ($collections as $collection) {
        $members = get_members_of_access_collection($collection->id, true);
        $memberno = sizeof($members);
        $members = implode(',', $members);
        ?>
  <tr>
    <td class="namefield">
    	<p>
    		<?php 
        echo $collection->name;
        ?>
 (<?php 
        echo $memberno;
        ?>
)