aboutsummaryrefslogtreecommitdiff
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
parent61d7f7243d7c06fd7ea9b282cda6efddf63a6a38 (diff)
downloadelgg-ff7a4572ab0e91a3e18390c0a0f9706b36ee394b.tar.gz
elgg-ff7a4572ab0e91a3e18390c0a0f9706b36ee394b.tar.bz2
moved tagging list to library and added group members
-rw-r--r--languages/en.php2
-rw-r--r--lib/image.php95
-rw-r--r--lib/tidypics.php21
-rw-r--r--views/default/tidypics/tagging.php15
4 files changed, 100 insertions, 33 deletions
diff --git a/languages/en.php b/languages/en.php
index c233e8090..83e600936 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -24,7 +24,7 @@
'album:group' => "Group albums",
'item:object:image' => "Photos",
'item:object:album' => "Albums",
- 'tidypics:enablephotos' => 'Enable Group Photo Albums',
+ 'tidypics:enablephotos' => 'Enable group photo albums',
'tidypics:editprops' => 'Edit Image Properties',
'tidypics:mostcommented' => 'Most commented images',
'tidypics:mostcommentedthismonth' => 'Most commented this month',
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
diff --git a/views/default/tidypics/tagging.php b/views/default/tidypics/tagging.php
index 5ba698d6d..ed33c4702 100644
--- a/views/default/tidypics/tagging.php
+++ b/views/default/tidypics/tagging.php
@@ -38,16 +38,7 @@
if ($viewer) {
- tp_get_tag_list($viewer);
-
- $friends = get_entities_from_relationship('friend', $viewer->getGUID(), false, 'user', '', 0, 'time_created desc', 1000);
-
- if ($friends) {
- foreach($friends as $friend) {
- $friend_array[$friend->name] = $friend->getGUID();
- }
- }
- ksort($friend_array);
+ $people_list = tp_get_tag_list($viewer);
$content = "<div id='tidypics_tagmenu_left'>";
$content .= "<input type='hidden' name='image_guid' value='{$image->guid}' />";
@@ -58,8 +49,8 @@
$content .= "<ul id='tidypics_phototag_list'>";
$content .= "<li><a href='javascript:void(0)' onclick='selectUser({$viewer->getGUID()},\"{$viewer->name}\")'> {$viewer->name} (" . elgg_echo('me') . ")</a></li>";
- if ($friends) {
- foreach($friend_array as $friend_name => $friend_guid) {
+ if ($people_list) {
+ foreach($people_list as $friend_guid => $friend_name) {
$content .= "<li><a href='javascript:void(0)' onclick='selectUser({$friend_guid}, \"{$friend_name}\")'>{$friend_name}</a></li>";
}
}