aboutsummaryrefslogtreecommitdiff
path: root/lib/image.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-09-01 01:26:02 +0000
committerCash Costello <cash.costello@gmail.com>2009-09-01 01:26:02 +0000
commitff7a4572ab0e91a3e18390c0a0f9706b36ee394b (patch)
treea2aed6adaca3de5f8814004f1a33bc1f638b0f0f /lib/image.php
parent61d7f7243d7c06fd7ea9b282cda6efddf63a6a38 (diff)
downloadelgg-ff7a4572ab0e91a3e18390c0a0f9706b36ee394b.tar.gz
elgg-ff7a4572ab0e91a3e18390c0a0f9706b36ee394b.tar.bz2
moved tagging list to library and added group members
Diffstat (limited to 'lib/image.php')
-rw-r--r--lib/image.php95
1 files changed, 76 insertions, 19 deletions
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