aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/image.php95
-rw-r--r--lib/tidypics.php21
2 files changed, 96 insertions, 20 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
diff --git a/lib/tidypics.php b/lib/tidypics.php
index e9b3ad46d..6bed421ed 100644
--- a/lib/tidypics.php
+++ b/lib/tidypics.php
@@ -53,7 +53,15 @@
}
- /**** these functions replace broken core functions ****/
+
+ /*********************************************************************
+ * the functions below replace broken core functions or add functions
+ * that should exist in the core
+ */
+
+ /**
+ *
+ */
function tp_get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0, $timeupper = 0)
{
global $CONFIG;
@@ -164,4 +172,15 @@
return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
}
+
+ function tp_is_group_page() {
+
+ if ($group = page_owner_entity()) {
+ if ($group instanceof ElggGroup)
+ return true;
+ }
+
+ return false;
+ }
+
?> \ No newline at end of file