We have moved to Github. Please open tickets there.

Opened 17 months ago

Last modified 12 months ago

#4202 new Defect

Make user function site_guid independant

Reported by: fabcol Owned by:
Priority: normal Milestone: Long Term Discussion
Component: Core Version: 1.8.1
Severity: major Keywords: user, multisite
Cc: brett@… Difficulty:

Description (last modified by ewinslow)

As the users membership to a site is based on "member_of_site" relationship since 1.7, some functions in userlib must be adapted to suit with multisite usage, most of them with adding a 'site_guids' => ELGG_ENTITIES_ANY_VALUE,

Here is the list of function that should be corrected in userlib including my own corrections :

function get_user_sites($user_guid, $limit = 10, $offset = 0) {

$user_guid = (int)$user_guid;
$limit = (int)$limit;
$offset = (int)$offset;

return elgg_get_entities_from_relationship(array(

'site_guids' => ELGG_ENTITIES_ANY_VALUE,

'relationship' => 'member_of_site',
'relationship_guid' => $user_guid,
'inverse_relationship' => FALSE,
'types' => 'site',
'limit' => $limit,
'offset' => $offset)

);

}

function get_user_friends($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,
$offset = 0) {

return elgg_get_entities_from_relationship(array(

'site_guids' => ELGG_ENTITIES_ANY_VALUE,

'relationship' => 'friend',
'relationship_guid' => $user_guid,
'types' => 'user',
'subtypes' => $subtype,
'limit' => $limit,
'offset' => $offset

));

}

function get_user_friends_of($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,
$offset = 0) {

return elgg_get_entities_from_relationship(array(

'site_guids' => ELGG_ENTITIES_ANY_VALUE,

'relationship' => 'friend',
'relationship_guid' => $user_guid,
'inverse_relationship' => TRUE,
'types' => 'user',
'subtypes' => $subtype,
'limit' => $limit,
'offset' => $offset

));

}

function find_active_users($seconds = 600, $limit = 10, $offset = 0, $count = false) {

$seconds = (int)$seconds;
$limit = (int)$limit;
$offset = (int)$offset;
$params = array('seconds' => $seconds, 'limit' => $limit, 'offset' => $offset, 'count' => $count);
$data = elgg_trigger_plugin_hook('find_active_users', 'system', $params, NULL);
if (!$data) {

global $CONFIG;

$time = time() - $seconds;

$data = elgg_get_entities(array(

'type' => 'user',
'site_guids' => ELGG_ENTITIES_ANY_VALUE,
'limit' => $limit,
'offset' => $offset,
'count' => $count,
'joins' => array("join {$dbprefix}entity_relationships r on e.guid=r.guid_one" ,"join {$dbprefix}users_entity u on e.guid = u.guid"),
'wheres' => array("r.relationship = 'member_of_site'","r.guid_two = {$site_guid}","u.last_action >= {$time}"),
'order_by' => "u.last_action desc",

));

}

return $data;

}

Change History (3)

comment:1 Changed 17 months ago by fabcol

  • Version changed from 1.8.1b1 to 1.8.1

comment:2 Changed 17 months ago by cash

The first one is clear cut to me so I'll make another ticket for it (#4260). The other three are questionable. I would think that some multi-sites installs would want each site to be separate even if users are able to cross sites. That means providing an option for those functions.

comment:3 Changed 12 months ago by ewinslow

  • Description modified (diff)
  • Milestone changed from Needs Review to Long Term Discussion
Note: See TracTickets for help on using tickets.