From 5e7ea5369519949ea6dc7954a61f4d4eba29b0d0 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 3 Dec 2011 15:19:12 -0500 Subject: removed some old code --- mostvieweddashboard.php | 43 -------- start.php | 272 ++++++++++++++++++++++++------------------------ thumbnail.php | 80 -------------- 3 files changed, 136 insertions(+), 259 deletions(-) delete mode 100644 mostvieweddashboard.php delete mode 100644 thumbnail.php diff --git a/mostvieweddashboard.php b/mostvieweddashboard.php deleted file mode 100644 index e98e784da..000000000 --- a/mostvieweddashboard.php +++ /dev/null @@ -1,43 +0,0 @@ -dbprefix; -$max = 24; - -//this works but is wildly inefficient -//$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); - -$sql = "SELECT ent.guid, count( * ) AS views - FROM " . $prefix . "entities ent - INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id - AND sub.subtype = 'image' - INNER JOIN " . $prefix . "annotations ann1 ON ann1.entity_guid = ent.guid - INNER JOIN " . $prefix . "metastrings ms ON ms.id = ann1.name_id - AND ms.string = 'tp_view' - GROUP BY ent.guid - ORDER BY views DESC - LIMIT $max"; - -$result = get_data($sql); - -$entities = array(); -foreach($result as $entity) { - $entities[] = get_entity($entity->guid); -} - -tidypics_mostviewed_submenus(); - -$title = elgg_echo("tidypics:mostvieweddashboard"); -$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); diff --git a/start.php b/start.php index b24f3cb61..ce0af7312 100644 --- a/start.php +++ b/start.php @@ -104,142 +104,6 @@ function tidypics_init() { elgg_register_library('tidypics:resize', "$base_dir/resize.php"); } -/** - * Sets up sidebar menus for tidypics. Triggered on pagesetup. - */ -function tidypics_submenus() { - - global $CONFIG; - - $page_owner = page_owner_entity(); - - if ($page_owner instanceof ElggGroup) { - if (get_context() == "groups") { - if ($page_owner->photos_enable != "no") { - add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); - } - } - } - // context is only set to photos on individual pages, not on group pages - else if (get_context() == "photos") { - - $view_count = get_plugin_setting('view_count', 'tidypics'); - - // owner gets "your albumn", "your friends albums", "your most recent", "your most viewed" - if (get_loggedin_userid() && get_loggedin_userid() == $page_owner->guid) { - - add_submenu_item( elgg_echo('album:create'), - $CONFIG->wwwroot . "pg/photos/new/{$page_owner->username}/", - 'tidypics-a' ); - - add_submenu_item( elgg_echo("album:yours"), - $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", - 'tidypics-a' ); - - add_submenu_item( elgg_echo('album:yours:friends'), - $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", - 'tidypics-a'); - - add_submenu_item( elgg_echo('tidypics:yourmostrecent'), - $CONFIG->wwwroot . "pg/photos/mostrecent/{$page_owner->username}/", - 'tidypics-a'); - - if ($view_count != 'disabled') { - add_submenu_item( elgg_echo('tidypics:yourmostviewed'), - $CONFIG->wwwroot . "pg/photos/mostviewed/{$page_owner->username}/", - 'tidypics-a'); - } - - } else if (isloggedin()) { - - $user = get_loggedin_user(); - - // logged in not owner gets "page owners albums", "page owner's friends albums", "page owner's most viewed", "page owner's most recent" - // and then "your albums", "your most recent", "your most viewed" - add_submenu_item( elgg_echo("album:yours"), - $CONFIG->wwwroot . "pg/photos/owned/{$user->username}/", - 'tidypics-b' ); - - add_submenu_item( elgg_echo('tidypics:yourmostrecent'), - $CONFIG->wwwroot . "pg/photos/mostrecent/{$user->username}/", - 'tidypics-b'); - - if ($view_count != 'disabled') { - add_submenu_item( elgg_echo('tidypics:yourmostviewed'), - $CONFIG->wwwroot . "pg/photos/mostviewed/{$user->username}/", - 'tidypics-b'); - } - - if ($page_owner->name) { // check to make sure the owner set their display name - add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", - 'tidypics-a' ); - add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", - 'tidypics-a'); - - if ($view_count != 'disabled') { - add_submenu_item( sprintf(elgg_echo('tidypics:friendmostviewed'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/mostviewed/{$page_owner->username}/", - 'tidypics-a'); - } - - add_submenu_item( sprintf(elgg_echo('tidypics:friendmostrecent'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/mostrecent/{$page_owner->username}/", - 'tidypics-a'); - } - } else if ($page_owner->guid) { - // non logged in user gets "page owners albums", "page owner's friends albums" - add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", - 'tidypics-a' ); - add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", - 'tidypics-a'); - } - - // everyone gets world albums, most recent, most viewed, most recently viewed, recently commented - add_submenu_item( elgg_echo('album:all'), - $CONFIG->wwwroot . "pg/photos/world/", - 'tidypics-z'); - add_submenu_item( elgg_echo('tidypics:mostrecent'), - $CONFIG->wwwroot . 'pg/photos/mostrecent/', - 'tidypics-z'); - - if ($view_count != 'disabled') { - add_submenu_item( elgg_echo('tidypics:mostviewed'), - $CONFIG->wwwroot . 'pg/photos/mostviewed/', - 'tidypics-z'); - add_submenu_item( elgg_echo('tidypics:recentlyviewed'), - $CONFIG->wwwroot . 'pg/photos/recentlyviewed/', - 'tidypics-z'); - } - add_submenu_item( elgg_echo('tidypics:recentlycommented'), - $CONFIG->wwwroot . 'pg/photos/recentlycommented/', - 'tidypics-z'); - } - -} - -/** - * Sets up submenus for tidypics most viewed pages - */ -function tidypics_mostviewed_submenus() { - - global $CONFIG; - - add_submenu_item(elgg_echo('tidypics:mostvieweddashboard'), $CONFIG->url . "mod/tidypics/mostvieweddashboard.php"); - add_submenu_item(elgg_echo('tidypics:mostviewedthisyear'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagesthisyear.php"); - add_submenu_item(elgg_echo('tidypics:mostviewedthismonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagesthismonth.php"); - add_submenu_item(elgg_echo('tidypics:mostviewedlastmonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimageslastmonth.php"); - add_submenu_item(elgg_echo('tidypics:mostviewedtoday'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagestoday.php"); - add_submenu_item(elgg_echo('tidypics:mostcommented'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimages.php"); - add_submenu_item(elgg_echo('tidypics:mostcommentedthismonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimagesthismonth.php"); - add_submenu_item(elgg_echo('tidypics:mostcommentedtoday'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimagestoday.php"); - add_submenu_item(elgg_echo('tidypics:recentlycommented'), $CONFIG->wwwroot . 'pg/photos/recentlycommented/'); -} - /** * Tidypics page handler * @@ -583,3 +447,139 @@ function tidypics_ajax_session_handler($hook, $entity_type, $returnvalue, $param exit; } + +/** + * Sets up sidebar menus for tidypics. Triggered on pagesetup. + */ +function tidypics_submenus() { + + global $CONFIG; + + $page_owner = page_owner_entity(); + + if ($page_owner instanceof ElggGroup) { + if (get_context() == "groups") { + if ($page_owner->photos_enable != "no") { + add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); + } + } + } + // context is only set to photos on individual pages, not on group pages + else if (get_context() == "photos") { + + $view_count = get_plugin_setting('view_count', 'tidypics'); + + // owner gets "your albumn", "your friends albums", "your most recent", "your most viewed" + if (get_loggedin_userid() && get_loggedin_userid() == $page_owner->guid) { + + add_submenu_item( elgg_echo('album:create'), + $CONFIG->wwwroot . "pg/photos/new/{$page_owner->username}/", + 'tidypics-a' ); + + add_submenu_item( elgg_echo("album:yours"), + $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", + 'tidypics-a' ); + + add_submenu_item( elgg_echo('album:yours:friends'), + $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", + 'tidypics-a'); + + add_submenu_item( elgg_echo('tidypics:yourmostrecent'), + $CONFIG->wwwroot . "pg/photos/mostrecent/{$page_owner->username}/", + 'tidypics-a'); + + if ($view_count != 'disabled') { + add_submenu_item( elgg_echo('tidypics:yourmostviewed'), + $CONFIG->wwwroot . "pg/photos/mostviewed/{$page_owner->username}/", + 'tidypics-a'); + } + + } else if (isloggedin()) { + + $user = get_loggedin_user(); + + // logged in not owner gets "page owners albums", "page owner's friends albums", "page owner's most viewed", "page owner's most recent" + // and then "your albums", "your most recent", "your most viewed" + add_submenu_item( elgg_echo("album:yours"), + $CONFIG->wwwroot . "pg/photos/owned/{$user->username}/", + 'tidypics-b' ); + + add_submenu_item( elgg_echo('tidypics:yourmostrecent'), + $CONFIG->wwwroot . "pg/photos/mostrecent/{$user->username}/", + 'tidypics-b'); + + if ($view_count != 'disabled') { + add_submenu_item( elgg_echo('tidypics:yourmostviewed'), + $CONFIG->wwwroot . "pg/photos/mostviewed/{$user->username}/", + 'tidypics-b'); + } + + if ($page_owner->name) { // check to make sure the owner set their display name + add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", + 'tidypics-a' ); + add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", + 'tidypics-a'); + + if ($view_count != 'disabled') { + add_submenu_item( sprintf(elgg_echo('tidypics:friendmostviewed'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/mostviewed/{$page_owner->username}/", + 'tidypics-a'); + } + + add_submenu_item( sprintf(elgg_echo('tidypics:friendmostrecent'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/mostrecent/{$page_owner->username}/", + 'tidypics-a'); + } + } else if ($page_owner->guid) { + // non logged in user gets "page owners albums", "page owner's friends albums" + add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", + 'tidypics-a' ); + add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", + 'tidypics-a'); + } + + // everyone gets world albums, most recent, most viewed, most recently viewed, recently commented + add_submenu_item( elgg_echo('album:all'), + $CONFIG->wwwroot . "pg/photos/world/", + 'tidypics-z'); + add_submenu_item( elgg_echo('tidypics:mostrecent'), + $CONFIG->wwwroot . 'pg/photos/mostrecent/', + 'tidypics-z'); + + if ($view_count != 'disabled') { + add_submenu_item( elgg_echo('tidypics:mostviewed'), + $CONFIG->wwwroot . 'pg/photos/mostviewed/', + 'tidypics-z'); + add_submenu_item( elgg_echo('tidypics:recentlyviewed'), + $CONFIG->wwwroot . 'pg/photos/recentlyviewed/', + 'tidypics-z'); + } + add_submenu_item( elgg_echo('tidypics:recentlycommented'), + $CONFIG->wwwroot . 'pg/photos/recentlycommented/', + 'tidypics-z'); + } + +} + +/** + * Sets up submenus for tidypics most viewed pages + */ +function tidypics_mostviewed_submenus() { + + global $CONFIG; + + add_submenu_item(elgg_echo('tidypics:mostvieweddashboard'), $CONFIG->url . "mod/tidypics/mostvieweddashboard.php"); + add_submenu_item(elgg_echo('tidypics:mostviewedthisyear'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagesthisyear.php"); + add_submenu_item(elgg_echo('tidypics:mostviewedthismonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagesthismonth.php"); + add_submenu_item(elgg_echo('tidypics:mostviewedlastmonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimageslastmonth.php"); + add_submenu_item(elgg_echo('tidypics:mostviewedtoday'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagestoday.php"); + add_submenu_item(elgg_echo('tidypics:mostcommented'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimages.php"); + add_submenu_item(elgg_echo('tidypics:mostcommentedthismonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimagesthismonth.php"); + add_submenu_item(elgg_echo('tidypics:mostcommentedtoday'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimagestoday.php"); + add_submenu_item(elgg_echo('tidypics:recentlycommented'), $CONFIG->wwwroot . 'pg/photos/recentlycommented/'); +} diff --git a/thumbnail.php b/thumbnail.php deleted file mode 100644 index f9f9d1e5f..000000000 --- a/thumbnail.php +++ /dev/null @@ -1,80 +0,0 @@ -getSubtype() != "image") { - forward('mod/tidypics/graphics/' . $error_image); -} - -// Get filename -if ($size == "thumb") { - $thumbfile = $file->thumbnail; -} else if ($size == "small") { - $thumbfile = $file->smallthumb; -} else { - $thumbfile = $file->largethumb; -} - -if (!$thumbfile) { - forward('mod/tidypics/graphics/' . $error_image); -} - -// create Elgg File object -$readfile = new ElggFile(); -$readfile->owner_guid = $file->owner_guid; -$readfile->setFilename($thumbfile); -$contents = $readfile->grabFile(); - -// send error image if file could not be read -if (!$contents) { - forward('mod/tidypics/graphics/' . $error_image); -} - -// expires every 14 days -$expires = 14 * 60*60*24; - -// overwrite header caused by php session code so images can be cached -$mime = $file->getMimeType(); -header("Content-Type: $mime"); -header("Content-Length: " . strlen($contents)); -header("Cache-Control: public", true); -header("Pragma: public", true); -header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); - -// Return the thumbnail and exit -echo $contents; -exit; -- cgit v1.2.3