{"action":"created","issue":{"url":"https://api.github.com/repos/Elgg/Elgg/issues/4202","repository_url":"https://api.github.com/repos/Elgg/Elgg","labels_url":"https://api.github.com/repos/Elgg/Elgg/issues/4202/labels{/name}","comments_url":"https://api.github.com/repos/Elgg/Elgg/issues/4202/comments","events_url":"https://api.github.com/repos/Elgg/Elgg/issues/4202/events","html_url":"https://github.com/Elgg/Elgg/issues/4202","id":11076159,"number":4202,"title":"Make user function site_guid independant (Trac #4202)","user":{"login":"elgg-gitbot","id":3541971,"avatar_url":"https://avatars.githubusercontent.com/u/3541971?v=3","gravatar_id":"","url":"https://api.github.com/users/elgg-gitbot","html_url":"https://github.com/elgg-gitbot","followers_url":"https://api.github.com/users/elgg-gitbot/followers","following_url":"https://api.github.com/users/elgg-gitbot/following{/other_user}","gists_url":"https://api.github.com/users/elgg-gitbot/gists{/gist_id}","starred_url":"https://api.github.com/users/elgg-gitbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elgg-gitbot/subscriptions","organizations_url":"https://api.github.com/users/elgg-gitbot/orgs","repos_url":"https://api.github.com/users/elgg-gitbot/repos","events_url":"https://api.github.com/users/elgg-gitbot/events{/privacy}","received_events_url":"https://api.github.com/users/elgg-gitbot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Elgg/Elgg/labels/discussion","name":"discussion","color":"eb6420"},{"url":"https://api.github.com/repos/Elgg/Elgg/labels/engine","name":"engine","color":"444444"},{"url":"https://api.github.com/repos/Elgg/Elgg/labels/multisite","name":"multisite","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2013-02-16T19:32:16Z","updated_at":"2016-04-07T09:09:41Z","closed_at":"2016-04-07T09:09:41Z","body":"_Original ticket http://trac.elgg.org/ticket/4202 on 41950967-12-05 by trac user fabcol, assigned to unknown._\r\n\r\nElgg version: 1.8.1\r\n\r\nAs 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,\r\n\r\n\r\nHere is the list of function that should be corrected in userlib including my own corrections :\r\n\r\n```php\r\nfunction get_user_sites($user_guid, $limit = 10, $offset = 0) {\r\n\t$user_guid = (int)$user_guid;\r\n\t$limit = (int)$limit;\r\n\t$offset = (int)$offset;\r\n\r\n\treturn elgg_get_entities_from_relationship(array(\r\n\t  'site_guids' => ELGG_ENTITIES_ANY_VALUE,\r\n\t\t'relationship' => 'member_of_site',\r\n\t\t'relationship_guid' => $user_guid,\r\n\t\t'inverse_relationship' => FALSE,\r\n\t\t'types' => 'site',\r\n\t\t'limit' => $limit,\r\n\t\t'offset' => $offset)\r\n\t);\r\n}\r\n```\r\n```php\r\nfunction get_user_friends($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,\r\n$offset = 0) {\r\n\r\n\treturn elgg_get_entities_from_relationship(array(\r\n\t  'site_guids' => ELGG_ENTITIES_ANY_VALUE,\r\n\t\t'relationship' => 'friend',\r\n\t\t'relationship_guid' => $user_guid,\r\n\t\t'types' => 'user',\r\n\t\t'subtypes' => $subtype,\r\n\t\t'limit' => $limit,\r\n\t\t'offset' => $offset\r\n\t));\r\n}\r\n```\r\n```php\r\nfunction get_user_friends_of($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,\r\n$offset = 0) {\r\n\r\n\treturn elgg_get_entities_from_relationship(array(\r\n\t  'site_guids' => ELGG_ENTITIES_ANY_VALUE,\r\n\t\t'relationship' => 'friend',\r\n\t\t'relationship_guid' => $user_guid,\r\n\t\t'inverse_relationship' => TRUE,\r\n\t\t'types' => 'user',\r\n\t\t'subtypes' => $subtype,\r\n\t\t'limit' => $limit,\r\n\t\t'offset' => $offset\r\n\t));\r\n}\r\n```\r\n```php\r\nfunction find_active_users($seconds = 600, $limit = 10, $offset = 0, $count = false) {\r\n\t$seconds = (int)$seconds;\r\n\t$limit = (int)$limit;\r\n\t$offset = (int)$offset;\r\n\t$params = array('seconds' => $seconds, 'limit' => $limit, 'offset' => $offset, 'count' => $count);\r\n\t$data = elgg_trigger_plugin_hook('find_active_users', 'system', $params, NULL);\r\n\tif (!$data) {\r\n\t\tglobal $CONFIG;\r\n\r\n\t\t$time = time() - $seconds;\r\n\r\n\t\t$data = elgg_get_entities(array(\r\n\t\t\t'type' => 'user', \r\n\t\t\t'site_guids' => ELGG_ENTITIES_ANY_VALUE,\r\n\t\t\t'limit' => $limit,\r\n\t\t\t'offset' => $offset,\r\n\t\t\t'count' => $count,\r\n\t\t\t'joins' => array(\"join {$dbprefix}entity_relationships r on e.guid=r.guid_one\" ,\"join {$dbprefix}users_entity u on e.guid = u.guid\"),\r\n\t\t\t'wheres' => array(\"r.relationship = 'member_of_site'\",\"r.guid_two = {$site_guid}\",\"u.last_action >= {$time}\"),\r\n\t\t\t'order_by' => \"u.last_action desc\",\r\n\t\t));\r\n\t}\r\n\r\n\treturn $data;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/Elgg/Elgg/issues/comments/206774664","html_url":"https://github.com/Elgg/Elgg/issues/4202#issuecomment-206774664","issue_url":"https://api.github.com/repos/Elgg/Elgg/issues/4202","id":206774664,"user":{"login":"jdalsem","id":861833,"avatar_url":"https://avatars.githubusercontent.com/u/861833?v=3","gravatar_id":"","url":"https://api.github.com/users/jdalsem","html_url":"https://github.com/jdalsem","followers_url":"https://api.github.com/users/jdalsem/followers","following_url":"https://api.github.com/users/jdalsem/following{/other_user}","gists_url":"https://api.github.com/users/jdalsem/gists{/gist_id}","starred_url":"https://api.github.com/users/jdalsem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdalsem/subscriptions","organizations_url":"https://api.github.com/users/jdalsem/orgs","repos_url":"https://api.github.com/users/jdalsem/repos","events_url":"https://api.github.com/users/jdalsem/events{/privacy}","received_events_url":"https://api.github.com/users/jdalsem/received_events","type":"User","site_admin":false},"created_at":"2016-04-07T09:09:41Z","updated_at":"2016-04-07T09:09:41Z","body":"Current Elgg implementation of multisite is not providing cross site features, so listings should limit the data to the current site "}}