return $file->getFilenameOnFilestore() . 'image/';\r
}\r
\r
+ \r
+ /**** these functions replace broken core functions ****/\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
+ \r
+ if ($subtype === false || $subtype === null || $subtype === 0)\r
+ return false;\r
+ \r
+ if ($order_by == "") $order_by = "time_created desc";\r
+ $order_by = sanitise_string($order_by);\r
+ $limit = (int)$limit;\r
+ $offset = (int)$offset;\r
+ $site_guid = (int) $site_guid;\r
+ $timelower = (int) $timelower;\r
+ $timeupper = (int) $timeupper;\r
+ if ($site_guid == 0)\r
+ $site_guid = $CONFIG->site_guid;\r
+ \r
+ $where = array();\r
+ \r
+ if (is_array($subtype)) {\r
+ $tempwhere = "";\r
+ if (sizeof($subtype))\r
+ foreach($subtype as $typekey => $subtypearray) {\r
+ foreach($subtypearray as $subtypeval) {\r
+ $typekey = sanitise_string($typekey);\r
+ if (!empty($subtypeval)) {\r
+ if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval))\r
+ return false;\r
+ } else {\r
+ // @todo: Setting subtype to 0 when $subtype = '' returns entities with\r
+ // no subtype. This is different to the non-array behavior\r
+ // but may be required in some cases.\r
+ $subtypeval = 0;\r
+ }\r
+ if (!empty($tempwhere)) $tempwhere .= " or ";\r
+ $tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})";\r
+ }\r
+ }\r
+ if (!empty($tempwhere)) $where[] = "({$tempwhere})";\r
+ \r
+ } else {\r
+ \r
+ $type = sanitise_string($type);\r
+ if ($subtype !== "" AND !$subtype = get_subtype_id($type, $subtype))\r
+ return false;\r
+ \r
+ if ($type != "")\r
+ $where[] = "type='$type'";\r
+ if ($subtype!=="")\r
+ $where[] = "subtype=$subtype";\r
+ }\r
+\r
+ if ($owner_guid != "") {\r
+ if (!is_array($owner_guid)) {\r
+ $owner_array = array($owner_guid);\r
+ $owner_guid = (int) $owner_guid;\r
+ $where[] = "owner_guid = '$owner_guid'";\r
+ } else if (sizeof($owner_guid) > 0) {\r
+ $owner_array = array_map('sanitise_int', $owner_guid);\r
+ // Cast every element to the owner_guid array to int\r
+ $owner_guid = array_map("sanitise_int", $owner_guid);\r
+ $owner_guid = implode(",",$owner_guid);\r
+ $where[] = "owner_guid in ({$owner_guid})";\r
+ }\r
+ }\r
+ if ($site_guid > 0)\r
+ $where[] = "site_guid = {$site_guid}";\r
+\r
+ if (!is_null($container_guid)) {\r
+ if (is_array($container_guid)) {\r
+ foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;\r
+ $where[] = "container_guid in (" . implode(",",$container_guid) . ")";\r
+ } else {\r
+ $container_guid = (int) $container_guid;\r
+ $where[] = "container_guid = {$container_guid}";\r
+ }\r
+ }\r
+ if ($timelower)\r
+ $where[] = "time_created >= {$timelower}";\r
+ if ($timeupper)\r
+ $where[] = "time_created <= {$timeupper}";\r
+ \r
+ if (!$count) {\r
+ $query = "SELECT * from {$CONFIG->dbprefix}entities where ";\r
+ } else {\r
+ $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where ";\r
+ }\r
+ foreach ($where as $w)\r
+ $query .= " $w and ";\r
+ $query .= get_access_sql_suffix(); // Add access controls\r
+ if (!$count) {\r
+ $query .= " order by $order_by";\r
+ if ($limit) $query .= " limit $offset, $limit"; // Add order and limit\r
+ $dt = get_data($query, "entity_row_to_elggstar");\r
+ return $dt;\r
+ } else {\r
+ $total = get_data_row($query);\r
+ return $total->total;\r
+ }\r
+ }\r
+\r
+ function tp_list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) {\r
+ \r
+ $offset = (int) get_input('offset');\r
+ $count = tp_get_entities($type, $subtype, $owner_guid, "", $limit, $offset, true);\r
+ $entities = tp_get_entities($type, $subtype, $owner_guid, "", $limit, $offset);\r
+\r
+ return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
+ \r
+ }\r
?>
\ No newline at end of file
+++ /dev/null
-<?php
- /**
- * List of someone else's most recent photos (we should be able to combine with yourmostrecent.php)
- *
- */
-
- include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php";
-
- if (is_null(page_owner_entity()->name) || page_owner_entity()->name == '') {
- $friendname = get_input('username');
- } else {
- $friendname = page_owner_entity()->name;
- };
-
- //there has to be a better way to do this
- if(!$friendname) {
- $page = get_input("page");
- list($pagename, $friendname) = split("/", $page);
- }
- $user = get_user_by_username($friendname);
-
- global $CONFIG;
- $prefix = $CONFIG->dbprefix;
- $max = 24;
- //grab the top views (metadata 'tp_views') for $max number of entities
- //ignores entity subtypes
-
- $sql = "SELECT ent.guid as entity_guid FROM " . $prefix . "entities ent
- INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id AND sub.subtype = 'image'
- WHERE ent.owner_guid = " . $user->guid . "
- ORDER BY ent.guid DESC
- LIMIT $max";
- $result = get_data($sql);
- $entities = array();
- foreach($result as $entity) {
- $entities[] = get_entity($entity->entity_guid);
- }
-
- $title = sprintf(elgg_echo("tidypics:friendmostrecent"), $friendname);
- $area2 = elgg_view_title($title);
- $area2 .= elgg_view_entity_list($entities, $max, 0, $max);
- $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
- page_draw($title, $body);
-
-?>
\ No newline at end of file
// Load Elgg engine
include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php";
+ // start with assumption this is for all site photos
+ $title = elgg_echo('tidypics:mostrecent');
+ $user_id = 0;
+
+ // is this all site or an individuals images
+ $username = get_input('username');
+ if ($username) {
+ $user = get_user_by_username($username);
+ if ($user) {
+ $user_id = $user->guid;
+
+ if ($user_id == get_loggedin_userid())
+ $title = elgg_echo('tidypics:yourmostrecent');
+ else
+ $title = sprintf(elgg_echo("tidypics:friendmostrecent"), $user->name);
+ }
+ }
+
// how many do we display
$max = 12;
// grab the html to display the images
- $images = list_entities("object", "image", 0, $max, false, false, true);
+ $images = tp_list_entities("object", "image", $user_id, $max, false, false, true);
+ $images .= '<div class="clearfloat"/>'; // hack until elgg fixes problem with css/list entities html
- $title = elgg_echo('tidypics:mostrecent');
// this view takes care of the title on the main column and the content wrapper
$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,));
+++ /dev/null
-<?php
- /**
- * List of user's most recently uploaded photos
- *
- */
-
- include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php";
-
- global $CONFIG;
- $viewer = get_loggedin_user();
- $prefix = $CONFIG->dbprefix;
- $max = 24;
- //grab the top views (metadata 'tp_views') for $max number of entities
- //ignores entity subtypes
-
- $sql = "SELECT ent.guid as entity_guid FROM " . $prefix . "entities ent
- INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id AND sub.subtype = 'image'
- WHERE ent.owner_guid = " . $viewer->guid . "
- ORDER BY ent.guid DESC
- LIMIT $max";
-
- $result = get_data($sql);
- $entities = array();
- foreach($result as $entity) {
- $entities[] = get_entity($entity->entity_guid);
- }
-
- $title = elgg_echo("tidypics:yourmostrecent");
- $area2 = elgg_view_title($title);
- $area2 .= elgg_view_entity_list($entities, $max, 0, $max);
- $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
- page_draw($title, $body);
-
-?>
\ No newline at end of file
}\r
\r
add_submenu_item( elgg_echo('tidypics:yourmostrecent'),\r
- $CONFIG->wwwroot . 'pg/photos/yourmostrecent',\r
+ $CONFIG->wwwroot . 'pg/photos/mostrecent/' . $_SESSION['user']->username,\r
'tidypics-a');\r
} else if (isloggedin()) {\r
// logged in not owner gets "your albums", "page owners albums", "page owner's friends albums", "page owner's most viewed", "page owner's most recent"\r
}\r
\r
add_submenu_item( elgg_echo('tidypics:yourmostrecent'),\r
- $CONFIG->wwwroot . 'pg/photos/yourmostrecent',\r
+ $CONFIG->wwwroot . 'pg/photos/mostrecent/' . $_SESSION['user']->username,\r
'tidypics-b');\r
\r
if($page_owner->name) { // check to make sure the owner set their display name\r
}\r
\r
add_submenu_item( sprintf(elgg_echo('tidypics:friendmostrecent'),$page_owner->name), \r
- $CONFIG->wwwroot . "pg/photos/friendmostrecent/". $page_owner->username, \r
+ $CONFIG->wwwroot . "pg/photos/mostrecent/". $page_owner->username, \r
'tidypics-a');\r
}\r
} else if ($page_owner->guid) {\r
break;\r
\r
case "mostrecent":\r
- if (isset($page[1])) set_input('guid',$page[1]);\r
+ if (isset($page[1])) set_input('username',$page[1]);\r
include($CONFIG->pluginspath . "tidypics/pages/lists/mostrecentimages.php");\r
break;\r
\r
include($CONFIG->pluginspath . "tidypics/pages/lists/yourmostviewed.php");\r
break;\r
\r
- case "yourmostrecent":\r
- if (isset($page[1])) set_input('guid',$page[1]);\r
- include($CONFIG->pluginspath . "tidypics/pages/lists/yourmostrecent.php");\r
- break;\r
- \r
case "friendmostviewed":\r
if (isset($page[1])) set_input('guid',$page[1]);\r
include($CONFIG->pluginspath . "tidypics/pages/lists/friendmostviewed.php");\r
break;\r
\r
- case "friendmostrecent":\r
- if (isset($page[1])) set_input('guid',$page[1]);\r
- include($CONFIG->pluginspath . "tidypics/pages/lists/friendmostrecent.php");\r
- break;\r
- \r
case "recentlyviewed":\r
if (isset($page[1])) set_input('guid',$page[1]);\r
include($CONFIG->pluginspath . "tidypics/pages/lists/recentlyviewed.php");\r
return $CONFIG->url . "pg/photos/album/" . $entity->getGUID() . "/" . $title;\r
}\r
\r
- function tp_mostrecentimages($max = 8, $pagination = true) {\r
- return list_entities("object", "image", 0, $max, false, false, $pagination); \r
- }\r
-\r
// Make sure tidypics_init is called on initialisation\r
register_elgg_event_handler('init','system','tidypics_init');\r
register_elgg_event_handler('pagesetup','system','tidypics_submenus');\r