From 73ed4ae8513af1cc6e795b125cc1f319a965bfb4 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 12 Mar 2010 17:03:51 +0000 Subject: Merged Cash's bugfixes from the 1.7 branch (3288:5377). git-svn-id: http://code.elgg.org/elgg/trunk@5378 36083f99-b078-4883-b0ff-0f9b5a30f544 --- UPGRADE.txt | 30 ++++++---------------- admin/user.php | 2 +- engine/lib/elgglib.php | 2 +- index.php | 8 +++++- languages/en.php | 8 +++--- mod/diagnostics/start.php | 16 ++++++------ mod/file/friends.php | 1 + mod/file/index.php | 3 ++- mod/file/search.php | 5 ++-- mod/file/world.php | 2 +- mod/groups/all.php | 17 ++++++------ mod/groups/index.php | 2 +- mod/groups/membership.php | 3 ++- mod/groups/views/default/forms/forums/addpost.php | 4 +-- mod/groups/views/default/forms/forums/addtopic.php | 2 +- mod/groups/views/default/forms/groups/edit.php | 9 ++++--- mod/pages/actions/pages/edit.php | 12 +++++++++ mod/pages/index.php | 2 +- mod/pages/languages/en.php | 2 +- mod/pages/views/default/forms/pages/edit.php | 14 ++++++++++ mod/pages/views/default/pages/welcome.php | 2 +- mod/pages/world.php | 2 +- mod/reportedcontent/actions/add.php | 22 ++++++++-------- mod/reportedcontent/actions/archive.php | 8 +++--- mod/reportedcontent/actions/delete.php | 8 +++--- mod/search/search_hooks.php | 2 +- mod/thewire/everyone.php | 7 ++--- mod/uservalidationbyemail/start.php | 2 ++ 28 files changed, 113 insertions(+), 84 deletions(-) diff --git a/UPGRADE.txt b/UPGRADE.txt index b06519ac3..032d285e9 100644 --- a/UPGRADE.txt +++ b/UPGRADE.txt @@ -1,33 +1,19 @@ ELGG UPGRADE INSTRUCTIONS -1. Download the new version of Elgg from elgg.org or a mirror. +1. Backup your Elgg database and code -2. Overwrite your existing Elgg files. Any modifications should +2. Download the new version of Elgg from elgg.org. + +3. Overwrite your existing Elgg files. Any modifications should have been written within plugins, so that they are not lost on overwriting. If this is not the case, take care to maintain your modifications, although Elgg is not guaranteed to work correctly in this instance. -3. Visit http://your-elgg-site-URL/upgrade.php - -4. Copy htaccess_dist to .htaccess, replacing your existing version. - -5. If you haven't already done so, install your crontab (UNIX ONLY) - - Cron is a UNIX command which allows programs to be run at set - times of the day. - - If you want to take advantage of some of the maintenance - functions such as log rotation or garbage collection, you must - install a cron tab to trigger these events. - - We have provided an example crontab as /crontab.example. Edit this - with a text editor to provide the details of your site, rename it - to another filename (eg 'crontab.mine') and install it with the - following command: +4. Visit http://your-elgg-site-URL/upgrade.php - crontab crontab.mine - - Substitute your filename for 'crontab.mine'. +5. Copy htaccess_dist to .htaccess, replacing your existing version. + Any modifications to the original .htaccess should be moved to the + new .htaccess file. diff --git a/admin/user.php b/admin/user.php index 2eaeb3b87..c0d63d7e0 100644 --- a/admin/user.php +++ b/admin/user.php @@ -25,7 +25,7 @@ $title = elgg_view_title(elgg_echo('admin:user')); set_context('search'); -$result = "
".elgg_list_entities(array('type' => 'user', 'limit' => $limit, 'full_view' => FALSE))."
"; +$result = "
".elgg_list_entities(array('type' => 'user', 'limit' => $limit, 'offset' => $offset, 'full_view' => FALSE))."
"; set_context('admin'); diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index ac46df078..95292a2d7 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2374,7 +2374,7 @@ function elgg_normalise_plural_options_array($options, $singulars) { function full_url() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s; - $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); + $port = ($_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI']; } diff --git a/index.php b/index.php index c559df5b3..9f256c07e 100644 --- a/index.php +++ b/index.php @@ -30,8 +30,14 @@ if (!trigger_plugin_hook('index', 'system', null, FALSE)) { } */ + //Load the front page + $title = elgg_view_title(elgg_echo('content:latest')); + set_context('search'); + $offset = (int)get_input('offset', 0); + $content = elgg_list_registered_entities(array('limit' => 10, 'offset' => $offset, 'full_view' => FALSE, 'allowed_types' => array('object','group'))); + set_context('main'); global $autofeed; $autofeed = FALSE; - $content = elgg_view_layout('one_column_with_sidebar', $title, elgg_view('account/forms/login')); + $content .= elgg_view_layout('one_column_with_sidebar', $title, elgg_view('account/forms/login')); page_draw(null, $content); } diff --git a/languages/en.php b/languages/en.php index 7a00852ac..a84000039 100644 --- a/languages/en.php +++ b/languages/en.php @@ -1,6 +1,6 @@ "Not all elements were imported.", 'InvalidParameterException:UnrecognisedFileMode' => "Unrecognised file mode '%s'", - 'InvalidParameterException:MissingOwner' => "File %s (%d) is missing an owner!", + 'InvalidParameterException:MissingOwner' => "File %s (file guid:%d) (owner guid:%d) is missing an owner!", 'IOException:CouldNotMake' => "Could not make %s", 'IOException:MissingFileName' => "You must specify a name before opening a file.", 'ClassNotFoundException:NotFoundNotSavedWithFile' => "Filestore not found or class not saved with file!", @@ -757,9 +757,9 @@ Alternatively, you can enter your database settings below and we will try and do 'installation:viewpathcache:description' => "The view filepath cache decreases the loading times of plugins by caching the location of their views.", 'installation:viewpathcache:label' => "Use view filepath cache (recommended)", - 'upgrading' => 'Upgrading', + 'upgrading' => 'Upgrading...', 'upgrade:db' => 'Your database was upgraded.', - 'upgrade:core' => 'Your elgg installation was upgraded', + 'upgrade:core' => 'Your elgg installation was upgraded.', /** * Welcome diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php index c114c054e..12795ebc8 100644 --- a/mod/diagnostics/start.php +++ b/mod/diagnostics/start.php @@ -91,22 +91,22 @@ function diagnostics_plugins_hook($hook, $entity_type, $returnvalue, $params) */ function diagnostics_md5_dir($dir) { - //if (is_file(trim($dir, "/"))) { - $extensions_allowed = array('.php', '.gif', '.png', '.jpg'); + $extensions_allowed = array('.php', '.js', '.css'); $buffer = ""; - if (in_array(strrchr(trim($dir, "/"), '.'), $extensions_allowed)) - { - //$dir = trim($dir, "/"); - $buffer .= md5_file($dir). " " . trim($dir, "/") . "\n"; - } else if ($handle = opendir($dir)) { + if (in_array(strrchr(trim($dir, "/"), '.'), $extensions_allowed)) { + $dir = rtrim($dir, "/"); + $buffer .= md5_file($dir). " " . $dir . "\n"; + } else if (is_dir($dir)) { + $handle = opendir($dir); while ($file = readdir($handle)) { - if (($file != '.') && ($file != '..')) { $buffer .= diagnostics_md5_dir($dir . $file. "/", $buffer); } } + + closedir($handle); } return $buffer; diff --git a/mod/file/friends.php b/mod/file/friends.php index 0693991d9..71dd2b10a 100644 --- a/mod/file/friends.php +++ b/mod/file/friends.php @@ -21,6 +21,7 @@ $area2 = elgg_view_title($title); set_context('search'); + // offset is grabbed in list_user_friends_objects $content = list_user_friends_objects($owner->guid, 'file', 10, false); set_context('file'); $area1 = get_filetype_cloud($owner->guid, true); diff --git a/mod/file/index.php b/mod/file/index.php index e76583f0f..af3d4c471 100644 --- a/mod/file/index.php +++ b/mod/file/index.php @@ -28,7 +28,8 @@ // Get objects set_context('search'); - $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'container_guid' => page_owner(), 'limit' => 10, 'full_view' => FALSE)); + $offset = (int)get_input('offset', 0); + $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'container_guid' => page_owner(), 'limit' => 10, 'offset' => $offset, 'full_view' => FALSE)); set_context('file'); $get_filter = get_filetype_cloud(page_owner()); if ($get_filter) { diff --git a/mod/file/search.php b/mod/file/search.php index ed8846514..ea85e862d 100644 --- a/mod/file/search.php +++ b/mod/file/search.php @@ -70,13 +70,14 @@ // Set context set_context('search'); - + + $offset = (int)get_input('offset', 0); $limit = 10; if ($search_viewtype == "gallery") $limit = 12; if (!empty($tag)) { $area2 .= list_entities_from_metadata($md_type, $tag, 'object', 'file', $owner_guid, $limit); } else { - $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit)); + $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset)); } set_context("file"); diff --git a/mod/file/world.php b/mod/file/world.php index 8b5e2cb0c..9f2ae5ee4 100644 --- a/mod/file/world.php +++ b/mod/file/world.php @@ -30,7 +30,7 @@ if ($tag != "") $area2 .= list_entities_from_metadata('tags',$tag,'object','file',0,10,false); else - $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'limit' => 10, 'full_view' => FALSE)); + $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'limit' => 10, 'offset' => $offset, 'full_view' => FALSE)); set_context('file'); $body = elgg_view_layout('two_column_left_sidebar',$area1, $area2); diff --git a/mod/groups/all.php b/mod/groups/all.php index 1d9f36dc5..c4347c1e4 100644 --- a/mod/groups/all.php +++ b/mod/groups/all.php @@ -15,29 +15,30 @@ $offset = get_input("offset", 0); $tag = get_input("tag"); $filter = get_input("filter"); - if(!$filter) + if (!$filter) { + // active discussions is the default $filter = "active"; + } // Get objects $context = get_context(); set_context('search'); - if ($tag != "") - $objects = list_entities_from_metadata('tags',$tag,'group',"","", $limit, false); - else{ + if ($tag != "") { + // groups plugin saves tags as "interests" - see groups_fields_setup() in start.php + $objects = list_entities_from_metadata('interests',$tag,'group',"","", $limit, false); + } else { switch($filter){ case "newest": - $objects = elgg_list_entities(array('types' => 'group', 'owner_guid' => 0, 'limit' => $limit, 'full_view' => false)); + $objects = elgg_list_entities(array('types' => 'group', 'owner_guid' => 0, 'limit' => $limit, 'offset' => $offset, 'full_view' => false)); break; case "pop": $objects = list_entities_by_relationship_count('member', true, "", "", 0, $limit, false); break; case "active": - $objects = list_entities_from_annotations("object", "groupforumtopic", "group_topic_post", "", 40, 0, 0, false, true); - break; case 'default': - $objects = elgg_list_entities(array('types' => 'group', 'limit' => $limit, 'full_view' => FALSE)); + $objects = list_entities_from_annotations("object", "groupforumtopic", "group_topic_post", "", 40, 0, 0, false, true); break; } } diff --git a/mod/groups/index.php b/mod/groups/index.php index d23fe7360..501e6e288 100644 --- a/mod/groups/index.php +++ b/mod/groups/index.php @@ -20,7 +20,7 @@ $area1 = elgg_view('page_elements/content_header', array('context' => "everyone", 'type' => 'groups')); set_context('search'); - $objects = elgg_list_entities(array('types' => 'group', 'owner_guid' => page_owner(), 'limit' => $limit, 'full_view' => FALSE)); + $objects = elgg_list_entities(array('types' => 'group', 'owner_guid' => page_owner(), 'limit' => $limit, 'offset' => $offset, 'full_view' => FALSE)); set_context('groups'); $area1 .= $objects; diff --git a/mod/groups/membership.php b/mod/groups/membership.php index 4b5d6b89f..ac3ad7439 100644 --- a/mod/groups/membership.php +++ b/mod/groups/membership.php @@ -26,6 +26,7 @@ $area2 = elgg_view('page_elements/content_header', array('context' => "mine", 'type' => 'groups')); set_context('search'); + // offset is grabbed in the list_entities_from_relationship() function $objects = list_entities_from_relationship('member',page_owner(),false,'group','',0, $limit,false, false); set_context('groups'); @@ -34,4 +35,4 @@ // Finally draw the page page_draw($title, $body); -?> \ No newline at end of file +?> diff --git a/mod/groups/views/default/forms/forums/addpost.php b/mod/groups/views/default/forms/forums/addpost.php index 8aa316caa..3ad3de0ff 100644 --- a/mod/groups/views/default/forms/forums/addpost.php +++ b/mod/groups/views/default/forms/forums/addpost.php @@ -29,6 +29,6 @@ - + - \ No newline at end of file + diff --git a/mod/groups/views/default/forms/forums/addtopic.php b/mod/groups/views/default/forms/forums/addtopic.php index e3bc3e1c6..9dd70d7a8 100644 --- a/mod/groups/views/default/forms/forums/addtopic.php +++ b/mod/groups/views/default/forms/forums/addtopic.php @@ -99,7 +99,7 @@

- +

diff --git a/mod/groups/views/default/forms/groups/edit.php b/mod/groups/views/default/forms/groups/edit.php index 810c29bc9..3712add82 100644 --- a/mod/groups/views/default/forms/groups/edit.php +++ b/mod/groups/views/default/forms/groups/edit.php @@ -138,19 +138,22 @@ +
">
- + diff --git a/mod/pages/actions/pages/edit.php b/mod/pages/actions/pages/edit.php index 84aed61d6..a966232a8 100644 --- a/mod/pages/actions/pages/edit.php +++ b/mod/pages/actions/pages/edit.php @@ -52,6 +52,12 @@ // New instance, so set container_guid $container_guid = get_input('container_guid', $_SESSION['user']->getGUID()); $page->container_guid = $container_guid; + + // cache data in session in case data from form does not validate + $_SESSION['page_description'] = $input['description']; + $_SESSION['page_tags'] = get_input('tags'); + $_SESSION['page_read_access'] = (int)get_input('access_id'); + $_SESSION['page_write_access'] = (int)get_input('write_access_id'); } // Have we got it? Can we edit it? @@ -96,6 +102,12 @@ // Now save description as an annotation $page->annotate('page', $page->description, $page->access_id); + + // clear cache + unset($_SESSION['page_description']); + unset($_SESSION['page_tags']); + unset($_SESSION['page_read_access']); + unset($_SESSION['page_write_access']); system_message(elgg_echo("pages:saved")); diff --git a/mod/pages/index.php b/mod/pages/index.php index 0e4601cef..5b31c6347 100644 --- a/mod/pages/index.php +++ b/mod/pages/index.php @@ -41,7 +41,7 @@ set_context('search'); - $objects = elgg_list_entities(array('types' => 'object', 'subtypes' => 'page_top', 'container_guid' => page_owner(), 'limit' => $limit, 'full_view' => FALSE)); + $objects = elgg_list_entities(array('types' => 'object', 'subtypes' => 'page_top', 'container_guid' => page_owner(), 'limit' => $limit, 'offset' => $offset, 'full_view' => FALSE)); set_context($context); diff --git a/mod/pages/languages/en.php b/mod/pages/languages/en.php index d94ca8431..75d1bba9b 100644 --- a/mod/pages/languages/en.php +++ b/mod/pages/languages/en.php @@ -27,7 +27,7 @@ 'pages:history' => "Page history", 'pages:view' => "View page", 'pages:welcome' => "Edit welcome message", - 'pages:welcomemessage' => "Welcome to this Elgg pages plugin. This feature allows you to create pages on any topic and select who can view them and edit them.", + 'pages:welcomemessage' => "Welcome to the pages tool of %s. This tool allows you to create pages on any topic and select who can view them and edit them.", 'pages:welcomeerror' => "There was a problem saving your welcome message", 'pages:welcomeposted' => "Your welcome message has been posted", 'pages:navigation' => "Page navigation", diff --git a/mod/pages/views/default/forms/pages/edit.php b/mod/pages/views/default/forms/pages/edit.php index 2b57fe814..2ad454073 100644 --- a/mod/pages/views/default/forms/pages/edit.php +++ b/mod/pages/views/default/forms/pages/edit.php @@ -25,6 +25,20 @@ $vars['entity']->access_id = 0; $vars['entity']->write_access_id = 0; } + + // pull in sticky values from session + if (isset($_SESSION['page_description'])) { + $vars['entity']->description = $_SESSION['page_description']; + $vars['entity']->tags = $_SESSION['page_tags']; + $vars['entity']->access_id = $_SESSION['page_read_access']; + $vars['entity']->write_access_id = $_SESSION['page_write_access']; + + // clear them + unset($_SESSION['page_description']); + unset($_SESSION['page_tags']); + unset($_SESSION['page_read_access']); + unset($_SESSION['page_write_access']); + } } ?>
diff --git a/mod/pages/views/default/pages/welcome.php b/mod/pages/views/default/pages/welcome.php index deefdba30..e4a465fdd 100644 --- a/mod/pages/views/default/pages/welcome.php +++ b/mod/pages/views/default/pages/welcome.php @@ -22,7 +22,7 @@ ?> -

+

sitename); ?>

'object', 'subtypes' => 'page_top', 'limit' => $limit, 'full_view' => FALSE)); + $objects = elgg_list_entities(array('types' => 'object', 'subtypes' => 'page_top', 'limit' => $limit, 'offset' => $offset, 'full_view' => FALSE)); set_context($context); diff --git a/mod/reportedcontent/actions/add.php b/mod/reportedcontent/actions/add.php index 76cefa4c8..80f67eab4 100644 --- a/mod/reportedcontent/actions/add.php +++ b/mod/reportedcontent/actions/add.php @@ -17,21 +17,21 @@ if ($title && $address) { - $entity = new ElggObject; - $entity->subtype = "reported_content"; - $entity->owner_guid = $_SESSION['user']->getGUID(); - $entity->title = $title; - $entity->address = $address; - $entity->description = $description; - $entity->access_id = $access; + $report = new ElggObject; + $report->subtype = "reported_content"; + $report->owner_guid = $_SESSION['user']->getGUID(); + $report->title = $title; + $report->address = $address; + $report->description = $description; + $report->access_id = $access; - if ($entity->save()) { - if (!trigger_plugin_hook('reportedcontent:add', $reported->type, array('entity'=>$reported), true)) { - $entity->delete(); + if ($report->save()) { + if (!trigger_plugin_hook('reportedcontent:add', 'system', array('report'=>$report), true)) { + $report->delete(); register_error(elgg_echo('reportedcontent:failed')); } else { system_message(elgg_echo('reportedcontent:success')); - $entity->state = "active"; + $report->state = "active"; } forward($address); } else { diff --git a/mod/reportedcontent/actions/archive.php b/mod/reportedcontent/actions/archive.php index a550abc2a..ca4ad2c41 100644 --- a/mod/reportedcontent/actions/archive.php +++ b/mod/reportedcontent/actions/archive.php @@ -17,15 +17,15 @@ $guid = (int) get_input('item'); // Make sure we actually have permission to edit - $reported = get_entity($guid); - if ($reported->getSubtype() == "reported_content" && $reported->canEdit()) { + $report = get_entity($guid); + if ($report->getSubtype() == "reported_content" && $report->canEdit()) { // change the state - if (!trigger_plugin_hook('reportedcontent:archive', $reported->type, array('entity'=>$reported), true)) { + if (!trigger_plugin_hook('reportedcontent:archive', 'system', array('report'=>$report), true)) { system_message(elgg_echo("reportedcontent:notarchived")); forward("pg/reportedcontent/"); } - $reported->state = "archived"; + $report->state = "archived"; // Success message system_message(elgg_echo("reportedcontent:archived")); diff --git a/mod/reportedcontent/actions/delete.php b/mod/reportedcontent/actions/delete.php index cff42b025..b2e9c7acd 100644 --- a/mod/reportedcontent/actions/delete.php +++ b/mod/reportedcontent/actions/delete.php @@ -17,15 +17,15 @@ $guid = (int) get_input('item'); // Make sure we actually have permission to edit - $reported = get_entity($guid); - if ($reported->getSubtype() == "reported_content" && $reported->canEdit()) { + $report = get_entity($guid); + if ($report->getSubtype() == "reported_content" && $report->canEdit()) { // Delete it! - if (!trigger_plugin_hook('reportedcontent:delete', $reported->type, array('entity'=>$reported), true)) { + if (!trigger_plugin_hook('reportedcontent:delete', '$system', array('report'=>$report), true)) { register_error(elgg_echo("reportedcontent:notdeleted")); forward("pg/reportedcontent/"); } - $rowsaffected = $reported->delete(); + $rowsaffected = $report->delete(); if ($rowsaffected > 0) { // Success message system_message(elgg_echo("reportedcontent:deleted")); diff --git a/mod/search/search_hooks.php b/mod/search/search_hooks.php index cc70f43ea..0b606ac66 100644 --- a/mod/search/search_hooks.php +++ b/mod/search/search_hooks.php @@ -232,7 +232,7 @@ function search_tags_hook($hook, $type, $value, $params) { // @todo make one long tag string and run this through the highlight // function. This might be confusing as it could chop off // the tag labels. - if (in_array($query, $tags)) { + if (in_array(strtolower($query), array_map('strtolower', $tags))) { if (is_array($tags)) { $tag_name_str = elgg_echo("tag_names:$tag_name"); $matched_tags_strs[] = "$tag_name_str: " . implode(', ', $tags); diff --git a/mod/thewire/everyone.php b/mod/thewire/everyone.php index 1f0913ab3..b49c1d9fc 100644 --- a/mod/thewire/everyone.php +++ b/mod/thewire/everyone.php @@ -17,11 +17,12 @@ //add form $area2 .= elgg_view("thewire/forms/add"); - $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'thewire')); + $offset = (int)get_input('offset', 0); + $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'thewire', 'offset' => $offset)); - $body = elgg_view_layout("one_column_with_sidebar", $area2); + $body = elgg_view_layout("two_column_left_sidebar", '', $area2); // Display page page_draw(elgg_echo('thewire:everyone'),$body); -?> \ No newline at end of file +?> diff --git a/mod/uservalidationbyemail/start.php b/mod/uservalidationbyemail/start.php index 7010fa4b8..fcfcb899d 100644 --- a/mod/uservalidationbyemail/start.php +++ b/mod/uservalidationbyemail/start.php @@ -26,6 +26,8 @@ function uservalidationbyemail_init() { * @return unknown_type */ function uservalidationbyemail_page_handler($page) { + global $CONFIG; + if (isset($page[0]) && $page[0] == 'confirm') { $code = sanitise_string(get_input('c', FALSE)); $user_guid = get_input('u', FALSE); -- cgit v1.2.3