diff options
author | Cash Costello <cash.costello@gmail.com> | 2009-08-26 11:29:21 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2009-08-26 11:29:21 +0000 |
commit | f0bb034d7b84190a0984e99a9dca56c9a7f0344d (patch) | |
tree | 72cdc6c7394e8e568857212b023b28a7a34da65f /lib | |
parent | 181b82b27317722f0701eda072943b9d2e7b6cb1 (diff) | |
download | elgg-f0bb034d7b84190a0984e99a9dca56c9a7f0344d.tar.gz elgg-f0bb034d7b84190a0984e99a9dca56c9a7f0344d.tar.bz2 |
started moving views code into image library
Diffstat (limited to 'lib')
-rw-r--r-- | lib/image.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/image.php b/lib/image.php index 7986335ed..f09377b64 100644 --- a/lib/image.php +++ b/lib/image.php @@ -19,6 +19,11 @@ parent::__construct($guid); } + /** + * Has the photo been tagged with "in this photo" tags + * + * @return true/false + */ public function isPhotoTagged() { $num_tags = count_annotations($this->getGUID(), 'object', 'image', 'phototag'); @@ -28,6 +33,11 @@ return false; } + /** + * Get an array of photo tag information + * + * @return array of json representations of the tags and the tag link text + */ public function getPhotoTags() { global $CONFIG; @@ -76,6 +86,45 @@ $ret_data = array('json' => $photo_tags_json, 'links' => $photo_tag_links); return $ret_data; } + + /** + * + */ + 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) + { + // get unique number of viewers + foreach ($views_a as $view) + { + $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) + { + if ($view->owner_guid == $viewer_guid) + $my_views++; + } + } + + $view_info = array("total" => $total_views, "unique" => $unique_viewers, "mine" => $my_views); + + return $view_info; + } + + public function addView($viewer_guid) + { + if ($viewer_guid != $this->owner_guid) + create_annotation($this->getGUID(), "tp_view", "1", "integer", $viewer_guid, ACCESS_PUBLIC); + } } ?>
\ No newline at end of file |