/** * Web service to get file list by all users * * @param string $context eg. all, friends, mine, groups * @param int $limit (optional) default 10 * @param int $offset (optional) default 0 * @param int $group_guid (optional) the guid of a group, $context must be set to 'group' * @param string $username (optional) the username of the user default loggedin user * * @return array $file Array of files uploaded */ function file_get_files($context, $limit = 10, $offset = 0, $group_guid, $username) { if (!$username) { $user = get_loggedin_user(); } else { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } } if ($context == "all") { $params = array('types' => 'object', 'subtypes' => 'file', 'limit' => $limit, 'full_view' => FALSE); } if ($context == "mine" || $context == "user") { $params = array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $user->guid, 'limit' => $limit, 'full_view' => FALSE); } if ($context == "group") { $params = array('types' => 'object', 'subtypes' => 'file', 'container_guid' => $group_guid, 'limit' => $limit, 'full_view' => FALSE); } $latest_file = elgg_get_entities($params); if ($context == "friends") { $latest_file = get_user_friends_objects($user->guid, 'file', $limit, $offset); } if ($latest_file) { foreach ($latest_file as $single) { $file['guid'] = $single->guid; $file['title'] = $single->title; $owner = get_entity($single->owner_guid); $file['owner']['guid'] = $owner->guid; $file['owner']['name'] = $owner->name; $file['owner']['avatar_url'] = get_entity_icon_url($owner, 'small'); $file['container_guid'] = $single->container_guid; $file['access_id'] = $single->access_id; $file['time_created'] = (int) $single->time_created; $file['time_updated'] = (int) $single->time_updated; $file['last_action'] = (int) $single->last_action; $file['MIMEType'] = $single->mimetype; $file['file_icon'] = get_entity_icon_url($single, 'small'); $return[] = $file; } } else { $msg = elgg_echo('file:none'); throw new InvalidParameterException($msg); } return $return; }
/** * Web service for read latest wire post by friends * * @param string $username username * @param string $limit number of results to display * @param string $offset offset of list * * @return bool */ function wire_get_friends_posts($username, $limit = 10, $offset = 0) { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } $posts = get_user_friends_objects($user->guid, 'thewire', $limit, $offset); if ($posts) { foreach ($posts as $single) { $wire[$single->guid]['time_created'] = $single->time_created; $wire[$single->guid]['description'] = $single->description; } } else { $wire['error']['message'] = elgg_echo('thewire:noposts'); } return $wire; }
/** * Web service to get file list by friends * * @param string $username username * @param string $limit (optional) default 10 * @param string $offset (optional) default 0 * * @return array $file Array of files uploaded */ function file_get_files_by_friend($username, $limit = 10, $offset = 0) { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } $latest_file = get_user_friends_objects($user->guid, 'file', $limit, $offset); if ($latest_file) { foreach ($latest_file as $single) { $file[$single->guid]['title'] = $single->title; $file[$single->guid]['owner_guid'] = $single->owner_guid; $file[$single->guid]['container_guid'] = $single->container_guid; $file[$single->guid]['access_id'] = $single->access_id; $file[$single->guid]['time_created'] = $single->time_created; $file[$single->guid]['time_updated'] = $single->time_updated; $file[$single->guid]['last_action'] = $single->last_action; } } else { $file['error']['message'] = elgg_echo('file:none'); } return $file; }
/** * Web service for read latest wire post of user * * @param string $context all/mine/friends * @param string $username username of author * * @return bool */ function wire_get_posts($context, $limit = 10, $offset = 0, $username) { if (!$username) { $user = get_loggedin_user(); } else { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } } if ($context == "all") { $params = array('types' => 'object', 'subtypes' => 'thewire', 'limit' => $limit, 'full_view' => FALSE); } if ($context == "mine" || $context == "user") { $params = array('types' => 'object', 'subtypes' => 'thewire', 'owner_guid' => $user->guid, 'limit' => $limit, 'full_view' => FALSE); } $latest_wire = elgg_get_entities($params); if ($context == "friends") { $latest_wire = get_user_friends_objects($user->guid, 'thewire', $limit, $offset); } if ($latest_wire) { foreach ($latest_wire as $single) { $wire['guid'] = $single->guid; $owner = get_entity($single->owner_guid); $wire['owner']['guid'] = $owner->guid; $wire['owner']['name'] = $owner->name; $wire['owner']['avatar_url'] = get_entity_icon_url($owner, 'small'); $wire['time_created'] = (int) $single->time_created; $wire['description'] = $single->description; $return[] = $wire; } } else { $msg = elgg_echo('thewire:noposts'); throw new InvalidParameterException($msg); } return $return; }
/** * Get an array of ElggObjects owned by this user's friends. * * @param string $subtype The subtype of the objects, if any * @param int $limit Number of results to return * @param int $offset Any indexing offset */ public function getFriendsObjects($subtype = "", $limit = 10, $offset = 0) { return get_user_friends_objects($this->getGUID(), $subtype, $limit, $offset); }
/** * Answers widget content view */ $content_type = $vars['entity']->content_type; // Get the current page's owner $page_owner = elgg_get_page_owner_entity(); if ($page_owner === false || is_null($page_owner)) { $page_owner = $_SESSION['user']; set_page_owner($page_owner->getGUID()); } $num = $vars['entity']->num_display; if ($content_type == 'mine') { $objects = $page_owner->getObjects('question', $num); $count = $page_owner->countObjects('question'); } else { if ($content_type == 'friends') { $objects = get_user_friends_objects($page_owner->getGUID(), 'question', $num); $count = count_user_friends_objects($page_owner->getGUID(), 'question'); } else { // site $options = array('type' => 'object', 'subtype' => 'question', 'limit' => $num); $objects = elgg_get_entities($options); $options['count'] = true; $count = elgg_get_entities($options); } } if (is_array($objects) && sizeof($objects) > 0) { foreach ($objects as $object) { echo elgg_view_entity($object); } }
/** * Displays a list of a user's friends' objects of a particular subtype, with navigation. * * @see elgg_view_entity_list * * @param int $user_guid The GUID of the user * @param string $subtype The object subtype * @param int $limit The number of entities to display on a page * @param bool $full_view Whether or not to display the full view (default: true) * @param bool $listtypetoggle Whether or not to allow you to flip to gallery mode (default: true) * @param bool $pagination Whether to display pagination (default: true) * @param int $timelower The earliest time the entity can have been created. Default: all * @param int $timeupper The latest time the entity can have been created. Default: all * * @return string */ function list_user_friends_objects($user_guid, $subtype = "", $limit = 10, $full_view = true, $listtypetoggle = true, $pagination = true, $timelower = 0, $timeupper = 0) { $offset = (int) get_input('offset'); $limit = (int) $limit; $count = (int) count_user_friends_objects($user_guid, $subtype, $timelower, $timeupper); $entities = get_user_friends_objects($user_guid, $subtype, $limit, $offset, $timelower, $timeupper); return elgg_view_entity_list($entities, array('count' => $count, 'offset' => $offset, 'limit' => $limit, 'full_view' => $full_view, 'list_type_toggle' => $listtypetoggle, 'pagination' => $pagination)); }
/** * Web service for read latest blog post by friends * * @param string $username username * @param string $limit number of results to display * @param string $offset offset of list * * @return string $time_created Time at which blog post was made * @return string $title Title of blog post * @return string $content Text of blog post * @return string $excerpt Excerpt * @return string $tags Tags of blog post * @return string $owner_guid GUID of owner * @return string $access_id Access level of blog post (0,-2,1,2) * @return string $status (Published/Draft) * @return string $comments_on On/Off */ function blog_get_friends_posts($username, $limit = 10, $offset = 0) { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } $posts = get_user_friends_objects($user->guid, 'blog', $limit, $offset); if ($posts) { foreach ($posts as $single) { $blog[$single->guid]['time_created'] = $single->time_created; $blog[$single->guid]['title'] = htmlspecialchars($single->title); $blog[$single->guid]['content'] = $single->description; $blog[$single->guid]['excerpt'] = $single->excerpt; $blog[$single->guid]['tags'] = $single->tags; $blog[$single->guid]['owner_guid'] = $single->owner_guid; $blog[$single->guid]['access_id'] = $single->access_id; $blog[$single->guid]['status'] = $single->status; $blog[$single->guid]['comments_on'] = $single->comments_on; } } else { $blog['error']['message'] = elgg_echo("blog:message:noposts"); } return $blog; }