aboutsummaryrefslogtreecommitdiff
path: root/views/default/object/image.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-06-17 01:27:43 +0000
committerCash Costello <cash.costello@gmail.com>2009-06-17 01:27:43 +0000
commit9eadf21d8a1782f4f77d99826c91d705cade404d (patch)
tree3d609c2a6e3833560aaaead5156011ca9f985dae /views/default/object/image.php
parent4928e46d6b93ccd1256117e08283341bdc224791 (diff)
downloadelgg-9eadf21d8a1782f4f77d99826c91d705cade404d.tar.gz
elgg-9eadf21d8a1782f4f77d99826c91d705cade404d.tar.bz2
added another setting - now view counter can be turned on and off
Diffstat (limited to 'views/default/object/image.php')
-rw-r--r--views/default/object/image.php62
1 files changed, 34 insertions, 28 deletions
diff --git a/views/default/object/image.php b/views/default/object/image.php
index 1ab2e921a..bd81e238e 100644
--- a/views/default/object/image.php
+++ b/views/default/object/image.php
@@ -101,33 +101,37 @@ if ($photo_tags) {
//
////////////////////////////////////////////////////////
- // Get view information
+ $view_count = get_plugin_setting('view_count', 'tidypics');
$viewer = get_loggedin_user();
-
- //who is viewing?
- if($viewer->guid) {
- $the_viewer = $viewer->guid;
- } else {
- $the_viewer = 0;
- }
+
+ if ($view_count != 'disabled') {
+ // Get view information
+
+ //who is viewing?
+ if($viewer->guid) {
+ $the_viewer = $viewer->guid;
+ } else {
+ $the_viewer = 0;
+ }
+
+ create_annotation($file_guid, "tp_view", "1", "integer", $the_viewer, ACCESS_PUBLIC);
+ $views_a = get_annotations($file_guid, "object", "image", "tp_view", "", 0, 9999);
+ $views = count($views_a);
- create_annotation($file_guid, "tp_view", "1", "integer", $the_viewer, 2);
- $views_a = get_annotations($file_guid, "object", "image", "tp_view", "", 0, 9999);
- $views = count($views_a);
-
- $my_views = 0;
- $owner_views = 0;
- $diff_viewers = array();
-// echo "<pre>"; var_dump($owner); echo "</pre>";
- foreach($views_a as $view) {
- if($view->owner_guid == $the_viewer && $the_viewer != 0) $my_views++;
- if($owner->guid == $view->owner_guid) $owner_views++;
- //count how many different people have viewed it
- if($owner->guid != $view->owner_guid) $diff_viewers[$view->owner_guid] = 1;
+ $my_views = 0;
+ $owner_views = 0;
+ $diff_viewers = array();
+ // echo "<pre>"; var_dump($owner); echo "</pre>";
+ foreach($views_a as $view) {
+ if($view->owner_guid == $the_viewer && $the_viewer != 0) $my_views++;
+ if($owner->guid == $view->owner_guid) $owner_views++;
+ //count how many different people have viewed it
+ if($owner->guid != $view->owner_guid) $diff_viewers[$view->owner_guid] = 1;
+ }
+ //remove the owner's views from the total count (prevents artificially inflated view counts)
+ $views = $views - $owner_views;
}
- //remove the owner's views from the total count (prevents artificially inflated view counts)
- $views = $views - $owner_views;
// Build back and next links
$back = '';
@@ -163,11 +167,13 @@ if ($photo_tags) {
<div id="tidypics_breadcrumbs">
<?php echo elgg_view('tidypics/breadcrumbs', array('album' => $album,) ); ?> <br />
- <?
- if($owner->guid == $the_viewer) {
- echo sprintf(elgg_echo("tidypics:viewsbyowner"), $views, count($diff_viewers));
- } else {
- echo sprintf(elgg_echo("tidypics:viewsbyothers"), $views, $my_views);
+ <?php
+ if ($view_count != 'disabled') {
+ if ($owner->guid == $the_viewer) {
+ echo sprintf(elgg_echo("tidypics:viewsbyowner"), $views, count($diff_viewers));
+ } else {
+ echo sprintf(elgg_echo("tidypics:viewsbyothers"), $views, $my_views);
+ }
}
?>
</div>