From ff7a4572ab0e91a3e18390c0a0f9706b36ee394b Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 1 Sep 2009 01:26:02 +0000 Subject: moved tagging list to library and added group members --- lib/image.php | 95 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 19 deletions(-) (limited to 'lib/image.php') diff --git a/lib/image.php b/lib/image.php index f09377b64..f146aba1a 100644 --- a/lib/image.php +++ b/lib/image.php @@ -88,38 +88,54 @@ } /** + * Get the view information for this image * + * @param $viewer_guid the guid of the viewer (0 if not logged in) + * @return array with number of views, number of unique viewers, and number of views for this viewer */ public function getViews($viewer_guid) { - $views_a = get_annotations($this->getGUID(), "object", "image", "tp_view", "", 0, 9999); - $total_views = count($views_a); - - if ($this->owner_guid == $viewer_guid) + $views = get_annotations($this->getGUID(), "object", "image", "tp_view", "", 0, 9999); + if ($views) { - // get unique number of viewers - foreach ($views_a as $view) + $total_views = count($views); + + if ($this->owner_guid == $viewer_guid) { - $diff_viewers[$view->owner_guid] = 1; - } - $unique_viewers = count($diff_viewers); - } - else if ($viewer_guid) - { - // get the number of times this user has viewed the photo - $my_views = 0; - foreach ($views_a as $view) + // get unique number of viewers + foreach ($views as $view) + { + $diff_viewers[$view->owner_guid] = 1; + } + $unique_viewers = count($diff_viewers); + } + else if ($viewer_guid) { - if ($view->owner_guid == $viewer_guid) - $my_views++; + // get the number of times this user has viewed the photo + $my_views = 0; + foreach ($views as $view) + { + if ($view->owner_guid == $viewer_guid) + $my_views++; + } } + + $view_info = array("total" => $total_views, "unique" => $unique_viewers, "mine" => $my_views); + } + else + { + $view_info = array("total" => 0, "unique" => 0, "mine" => 0); } - - $view_info = array("total" => $total_views, "unique" => $unique_viewers, "mine" => $my_views); return $view_info; } + /** + * Add a tidypics view annotation to this image + * + * @param $viewer_guid + * @return none + */ public function addView($viewer_guid) { if ($viewer_guid != $this->owner_guid) @@ -127,4 +143,45 @@ } } + /** + * get a list of people that can be tagged in an image + * + * @param $viewer entity + * @return array of guid->name for tagging + */ + function tp_get_tag_list($viewer) + { + $friends = get_user_friends($viewer->getGUID(), '', 999, 0); + $friend_list = array(); + if ($friends) { + foreach($friends as $friend) { + $friend_list[$friend->guid] = $friend->name; + } + } + + // is this a group + $is_group = tp_is_group_page(); + if ($is_group) + { + $group_guid = page_owner(); + $viewer_guid = $viewer->guid; + $members = get_group_members($group_guid, 999); + if (is_array($members)) + { + foreach ($members as $member) + { + if ($viewer_guid != $member->guid) + $group_list[$member->guid] = $member->name; + } + + // combine group and friends list + $friend_list = array_merge($friend_list, $group_list); + $friend_list = array_unique($friend_list); + } + } + + sort($friend_list); + + return $friend_list; + } ?> \ No newline at end of file -- cgit v1.2.3