]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
moved tagging list to library and added group members
authorCash Costello <cash.costello@gmail.com>
Tue, 1 Sep 2009 01:26:02 +0000 (01:26 +0000)
committerCash Costello <cash.costello@gmail.com>
Tue, 1 Sep 2009 01:26:02 +0000 (01:26 +0000)
languages/en.php
lib/image.php
lib/tidypics.php
views/default/tidypics/tagging.php

index c233e8090d0de47191d49f385cd329eda274df88..83e6009367fe800b31670746060baabe36c4add1 100644 (file)
@@ -24,7 +24,7 @@
                        'album:group' => "Group albums",\r
                        'item:object:image' => "Photos",\r
                        'item:object:album' => "Albums",\r
-                       'tidypics:enablephotos' => 'Enable Group Photo Albums',\r
+                       'tidypics:enablephotos' => 'Enable group photo albums',\r
                        'tidypics:editprops' => 'Edit Image Properties',\r
                        'tidypics:mostcommented' => 'Most commented images',\r
                        'tidypics:mostcommentedthismonth' => 'Most commented this month',\r
index f09377b64719905efa60e8748a4c01d938b5d2ea..f146aba1a5990a71d65729673b7d9f657fa28f85 100644 (file)
                }
                
                /**
+                * 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)
                }
        }
        
+       /**
+        * 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
index e9b3ad46d1d43aa5315e363f90e62ec6cde62a8c..6bed421ed504da95ea59a4453be5b4f1c25e1405 100644 (file)
        }\r
        \r
        \r
-       /**** these functions replace broken core functions ****/\r
+       \r
+       /*********************************************************************\r
+        * the functions below replace broken core functions or add functions \r
+        * that should exist in the core\r
+        */\r
+        \r
+       /**\r
+        *\r
+        */\r
        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)\r
        {\r
                global $CONFIG;\r
                return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
                \r
        }\r
+       \r
+       function tp_is_group_page() {\r
+               \r
+               if ($group = page_owner_entity()) {\r
+                       if ($group instanceof ElggGroup)\r
+                               return true;\r
+               }\r
+               \r
+               return false;\r
+       }\r
+       \r
 ?>
\ No newline at end of file
index 5ba698d6d81235dbf87e3ea01217e27b8884d636..ed33c4702beb32990339eaac4f8b24eefa616989 100644 (file)
 \r
        if ($viewer) {\r
                \r
-               tp_get_tag_list($viewer);\r
-               \r
-               $friends = get_entities_from_relationship('friend', $viewer->getGUID(), false, 'user', '', 0, 'time_created desc', 1000);\r
-               \r
-               if ($friends) {\r
-                       foreach($friends as $friend) {\r
-                               $friend_array[$friend->name] = $friend->getGUID();\r
-                       }\r
-               }\r
-               ksort($friend_array);\r
+               $people_list = tp_get_tag_list($viewer);\r
 \r
                $content = "<div id='tidypics_tagmenu_left'>";\r
                $content .= "<input type='hidden' name='image_guid' value='{$image->guid}' />";\r
@@ -58,8 +49,8 @@
                $content .= "<ul id='tidypics_phototag_list'>";\r
                $content .= "<li><a href='javascript:void(0)' onclick='selectUser({$viewer->getGUID()},\"{$viewer->name}\")'> {$viewer->name} (" . elgg_echo('me') . ")</a></li>";\r
        \r
-               if ($friends) {\r
-                       foreach($friend_array as $friend_name => $friend_guid) {\r
+               if ($people_list) {\r
+                       foreach($people_list as $friend_guid => $friend_name) {\r
                                $content .= "<li><a href='javascript:void(0)' onclick='selectUser({$friend_guid}, \"{$friend_name}\")'>{$friend_name}</a></li>";\r
                        }\r
                }\r