From db7b497114329dda5f560198884c5bc5fbb3c1a8 Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 3 Nov 2010 02:13:36 +0000 Subject: Fixes #2128 - replaces all uses of set_context() and get_context() in core and plugins git-svn-id: http://code.elgg.org/elgg/trunk@7215 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 2 +- engine/lib/api.php | 2 +- engine/lib/navigation.php | 4 ++-- engine/lib/users.php | 4 ++-- engine/lib/usersettings.php | 2 +- engine/lib/views.php | 2 +- engine/lib/widgets.php | 4 ++-- engine/tests/ui/submenu.php | 2 +- index.php | 9 +++++---- mod/bookmarks/start.php | 2 +- .../views/default/river/object/bookmarks/create.php | 2 +- mod/categories/listing.php | 5 ++--- .../views/default/defaultwidgets/editor.php | 8 ++++---- mod/diagnostics/index.php | 2 +- mod/diagnostics/start.php | 2 +- mod/ecml/start.php | 2 +- mod/file/friends.php | 5 +++-- mod/file/index.php | 5 +++-- mod/file/search.php | 5 ++--- mod/file/start.php | 2 +- mod/file/views/default/object/file.php | 2 +- mod/file/world.php | 4 ++-- mod/groups/all.php | 4 ++-- mod/groups/forum.php | 2 +- mod/groups/groupprofile.php | 2 +- mod/groups/index.php | 4 ++-- mod/groups/membership.php | 4 ++-- mod/groups/start.php | 4 ++-- mod/groups/views/default/object/groupforumtopic.php | 2 +- mod/invitefriends/index.php | 2 +- mod/invitefriends/start.php | 6 +++--- mod/members/index.php | 2 +- mod/messages/start.php | 2 +- mod/notifications/groups.php | 2 +- mod/notifications/index.php | 2 +- mod/notifications/start.php | 2 +- mod/pages/actions/pages/edit.php | 2 +- mod/pages/index.php | 8 ++------ mod/pages/start.php | 4 ++-- mod/pages/view.php | 2 +- mod/pages/world.php | 8 ++------ mod/profile/edit.php | 2 +- mod/profile/editicon.php | 2 +- mod/profile/start.php | 2 +- mod/riverdashboard/index.php | 2 +- mod/riverdashboard/views/default/river/item/wrapper.php | 2 +- mod/sitepages/index.php | 6 ++++-- mod/sitepages/start.php | 8 ++++---- mod/sitepages/views/default/sitepages/metatags.php | 2 +- mod/tagcloud/views/default/widgets/tagcloud/view.php | 11 +++++------ mod/thewire/start.php | 2 +- mod/uservalidationbyemail/start.php | 14 +++++--------- pages/dashboard/index.php | 2 +- pages/dashboard/latest.php | 4 ++-- pages/entities/index.php | 2 +- pages/entities/list.php | 4 ++-- views/default/admin/overview/online.php | 4 ++-- views/default/admin/users/online.php | 4 ++-- views/default/annotation/annotate.php | 2 +- views/default/canvas/layouts/widgets.php | 16 ++++++++-------- views/default/navigation/pagination.php | 2 +- views/default/navigation/site_nav.php | 2 +- views/default/output/tagcloud.php | 2 +- views/default/page_elements/content_header.php | 4 ++-- views/default/widgets/editwrapper.php | 2 +- 65 files changed, 117 insertions(+), 127 deletions(-) diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 595a3aa7c..b760adabe 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -168,7 +168,7 @@ function admin_settings_page_handler($page) { admin_gatekeeper(); elgg_admin_add_plugin_settings_sidemenu(); - set_context('admin'); + elgg_set_context('admin'); // default to overview if (!isset($page[0]) || empty($page[0])) { diff --git a/engine/lib/api.php b/engine/lib/api.php index a2b80625c..93de88d5b 100644 --- a/engine/lib/api.php +++ b/engine/lib/api.php @@ -1271,7 +1271,7 @@ function _php_api_exception_handler($exception) { function service_handler($handler, $request) { global $CONFIG; - set_context('api'); + elgg_set_context('api'); $request = explode('/', $request); diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index fcfc553fd..75c5958f4 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -43,7 +43,7 @@ function add_submenu_item($label, $link, $group = 'default', $onclick = false, $ // emulate that effect. // if context == 'main' (default) it probably means they always wanted // the menu item to show up everywhere. - $context = get_context(); + $context = elgg_get_context(); if ($context == 'main') { $context = 'all'; @@ -258,7 +258,7 @@ function elgg_get_submenu($context = NULL, $sort = FALSE) { global $CONFIG; if (!$context) { - $context = get_context(); + $context = elgg_get_context(); } if (!elgg_prepare_submenu($context, $sort)) { diff --git a/engine/lib/users.php b/engine/lib/users.php index e76702fb2..0075c9baa 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1397,8 +1397,8 @@ function users_pagesetup() { global $CONFIG; //add submenu options - if (get_context() == "friends" || get_context() == "friendsof") { - // || get_context() == "collections") { - disabled as we no longer use collections + if (elgg_get_context() == "friends" || elgg_get_context() == "friendsof") { + // || elgg_get_context() == "collections") { - disabled as we no longer use collections add_submenu_item(elgg_echo('friends'), $CONFIG->wwwroot . "pg/friends/" . elgg_get_page_owner()->username); diff --git a/engine/lib/usersettings.php b/engine/lib/usersettings.php index bec202b8a..396bb6de5 100644 --- a/engine/lib/usersettings.php +++ b/engine/lib/usersettings.php @@ -43,7 +43,7 @@ function usersettings_pagesetup() { global $CONFIG; // Menu options - if (get_context() == "settings") { + if (elgg_get_context() == "settings") { $user = get_loggedin_user(); add_submenu_item(elgg_echo('usersettings:user:opt:linktext'), $CONFIG->wwwroot . "pg/settings/user/{$user->username}/"); diff --git a/engine/lib/views.php b/engine/lib/views.php index 21056db0e..c70489117 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -843,7 +843,7 @@ $viewtypetoggle = true, $pagination = true) { $offset = sanitise_int(get_input('offset', 0)); } - $context = get_context(); + $context = elgg_get_context(); $html = elgg_view('entities/entity_list', array( 'entities' => $entities, diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index c849596d4..02ab3af69 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -38,7 +38,7 @@ function use_widgets($context) { function using_widgets() { global $CONFIG; - $context = get_context(); + $context = elgg_get_context(); if (isset($CONFIG->widgets->contexts) && is_array($CONFIG->widgets->contexts)) { if (in_array($context, $CONFIG->widgets->contexts)) { return true; @@ -299,7 +299,7 @@ function get_widget_types() { && !empty($CONFIG->widgets->handlers) && is_array($CONFIG->widgets->handlers)) { - $context = get_context(); + $context = elgg_get_context(); foreach ($CONFIG->widgets->handlers as $key => $handler) { if (!in_array('all', $handler->context) && diff --git a/engine/tests/ui/submenu.php b/engine/tests/ui/submenu.php index ac861254b..3069e7405 100644 --- a/engine/tests/ui/submenu.php +++ b/engine/tests/ui/submenu.php @@ -91,7 +91,7 @@ elgg_add_submenu_item(array('text' => 'Not Main C Test', 'href' => "$url?not_mai elgg_add_submenu_item(array('text' => 'All test', 'href' => "$url?all"), 'all'); -//set_context('not_main'); +//elgg_set_context('not_main'); $body = elgg_view_layout('one_column_with_sidebar', 'Look right.'); echo elgg_view_page('Submenu Test', $body); diff --git a/index.php b/index.php index 014721954..c036f0766 100644 --- a/index.php +++ b/index.php @@ -21,16 +21,16 @@ if (!trigger_plugin_hook('index', 'system', null, FALSE)) { being hard-coded here. if(is_plugin_enabled('riverdashboard')){ $title = elgg_view_title(elgg_echo('content:latest')); - set_context('search'); + elgg_set_context('search'); $content = elgg_list_registered_entities(array('limit' => 10, ' full_view' => FALSE, 'allowed_types' => array('object','group'))); - set_context('main'); + elgg_set_context('main'); } */ //Load the front page $title = elgg_view_title(elgg_echo('content:latest')); - set_context('search'); + elgg_set_context('search'); $offset = (int)get_input('offset', 0); if (is_plugin_enabled('riverdashboard')) { $activity = elgg_view_river_items(0, 0, '', '', '', '', 10, 0, 0, true, false); @@ -44,7 +44,8 @@ if (!trigger_plugin_hook('index', 'system', null, FALSE)) { $activity = elgg_list_registered_entities($options); } - set_context('main'); + elgg_set_context('main'); + global $autofeed; $autofeed = FALSE; diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php index 92ee7e421..ca367deb2 100644 --- a/mod/bookmarks/start.php +++ b/mod/bookmarks/start.php @@ -57,7 +57,7 @@ function bookmarks_pagesetup() { // Add group bookmark menu item if (isloggedin()) { - if ($page_owner instanceof ElggGroup && get_context() == 'groups') { + if ($page_owner instanceof ElggGroup && elgg_get_context() == 'groups') { if ($page_owner->bookmarks_enable != "no") { //add_submenu_item(sprintf(elgg_echo("bookmarks:group"),$page_owner->name), "pg/bookmarks/" . $page_owner->username . '/items'); } diff --git a/mod/bookmarks/views/default/river/object/bookmarks/create.php b/mod/bookmarks/views/default/river/object/bookmarks/create.php index dec4ab4d1..faffdec5d 100644 --- a/mod/bookmarks/views/default/river/object/bookmarks/create.php +++ b/mod/bookmarks/views/default/river/object/bookmarks/create.php @@ -10,7 +10,7 @@ $url = $object->getURL(); $url = "getURL()}\">{$performed_by->name}"; $string = sprintf(elgg_echo("bookmarks:river:created"),$url) . " "; $string .= "address . "\">" . $object->title . ""; -if(($is_group instanceof ElggGroup) && (get_context() != 'groups')){ +if (($is_group instanceof ElggGroup) && (elgg_get_context() != 'groups')){ $string .= " " . elgg_echo('bookmarks:ingroup') . " getURL()}\">" . $is_group->name . ""; } $string .= " " . elgg_view_friendly_time($object->time_created); diff --git a/mod/categories/listing.php b/mod/categories/listing.php index b2701b143..efbac8551 100644 --- a/mod/categories/listing.php +++ b/mod/categories/listing.php @@ -24,10 +24,9 @@ $params = array( 'full_view' => FALSE, 'metadata_case_sensitive' => FALSE, ); -$current_context = get_context(); -set_context('search'); +elgg_push_context('search'); $objects = elgg_list_entities_from_metadata($params); -set_context($current_context); +elgg_pop_context(); $title = sprintf(elgg_echo('categories:results'), $category); diff --git a/mod/defaultwidgets/views/default/defaultwidgets/editor.php b/mod/defaultwidgets/views/default/defaultwidgets/editor.php index 6400ed55d..e63e84a79 100644 --- a/mod/defaultwidgets/views/default/defaultwidgets/editor.php +++ b/mod/defaultwidgets/views/default/defaultwidgets/editor.php @@ -18,9 +18,9 @@ $area3widgets = false; // get available widget types - set_context ( $context ); + elgg_set_context($context); $widgettypes = get_widget_types(); - set_context ( 'admin' ); + elgg_set_context('admin'); // get the entities for the module $entities = elgg_get_entities(array('type' => 'object', 'subtype' => 'moddefaultwidgets', 'limit' => 9999)); @@ -103,7 +103,7 @@ $(document).ready(function () {

@@ -118,7 +118,7 @@ $(document).ready(function () {

-
> +
> 0) { diff --git a/mod/diagnostics/index.php b/mod/diagnostics/index.php index ca0f9b9f4..9bc58b56a 100644 --- a/mod/diagnostics/index.php +++ b/mod/diagnostics/index.php @@ -8,7 +8,7 @@ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); admin_gatekeeper(); -set_context('admin'); +elgg_set_context('admin'); // system diagnostics $body = elgg_view_title(elgg_echo('diagnostics')); diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php index 45403e3b5..52bd8a1d8 100644 --- a/mod/diagnostics/start.php +++ b/mod/diagnostics/start.php @@ -26,7 +26,7 @@ function diagnostics_init() */ function diagnostics_pagesetup() { - if (get_context() == 'admin' && isadminloggedin()) { + if (elgg_get_context() == 'admin' && isadminloggedin()) { global $CONFIG; add_submenu_item(elgg_echo('diagnostics'), 'pg/diagnostics/'); } diff --git a/mod/ecml/start.php b/mod/ecml/start.php index 2c6cc073b..14031aac4 100644 --- a/mod/ecml/start.php +++ b/mod/ecml/start.php @@ -181,7 +181,7 @@ function ecml_generate_page_handler($page) { */ function ecml_admin_page_handler($page) { admin_gatekeeper(); - set_context('admin'); + elgg_set_context('admin'); $content = elgg_view('ecml/admin/ecml_admin'); $body = elgg_view_layout('one_column_with_sidebar', $content); echo elgg_view_page(elgg_echo('ecml:admin'), $body); diff --git a/mod/file/friends.php b/mod/file/friends.php index 038d7efa2..f76c4e692 100644 --- a/mod/file/friends.php +++ b/mod/file/friends.php @@ -15,10 +15,11 @@ $title = sprintf(elgg_echo("file:friends"),$owner->name); $area1 = elgg_view('page_elements/content_header', array('context' => "friends", 'type' => 'file')); - set_context('search'); + elgg_push_context('search'); // offset is grabbed in list_user_friends_objects $content = list_user_friends_objects($owner->guid, 'file', 10, false); - set_context('file'); + elgg_pop_context(); + $area1 .= get_filetype_cloud($owner->guid, true); // handle case where friends don't have any files diff --git a/mod/file/index.php b/mod/file/index.php index 7fb246367..2a82ee1e4 100644 --- a/mod/file/index.php +++ b/mod/file/index.php @@ -23,10 +23,11 @@ } // Get objects - set_context('search'); + elgg_push_context('search'); $offset = (int)get_input('offset', 0); $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'container_guid' => elgg_get_page_owner_guid(), 'limit' => 10, 'offset' => $offset, 'full_view' => FALSE)); - set_context('file'); + elgg_pop_context(); + $get_filter = get_filetype_cloud(elgg_get_page_owner_guid()); if ($get_filter) { $area1 .= $get_filter; diff --git a/mod/file/search.php b/mod/file/search.php index 6568eae79..e92cf0362 100644 --- a/mod/file/search.php +++ b/mod/file/search.php @@ -69,8 +69,7 @@ $area1 = get_filetype_cloud(); } - // Set context - set_context('search'); + elgg_push_context('search'); $offset = (int)get_input('offset', 0); $limit = 10; @@ -89,7 +88,7 @@ $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset)); } - set_context("file"); + elgg_pop_context(); $content = "
".$area1.$area2."
"; diff --git a/mod/file/start.php b/mod/file/start.php index 544024d49..3d66dcc21 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -77,7 +77,7 @@ $page_owner = elgg_get_page_owner(); // Group submenu option - if ($page_owner instanceof ElggGroup && get_context() == "groups") { + if ($page_owner instanceof ElggGroup && elgg_get_context() == "groups") { if($page_owner->file_enable != "no"){ add_submenu_item(sprintf(elgg_echo("file:group"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username); } diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php index 2511f5af6..5858a1f1e 100644 --- a/mod/file/views/default/object/file.php +++ b/mod/file/views/default/object/file.php @@ -22,7 +22,7 @@ $title = elgg_echo('untitled'); } - if (get_context() == "search") { // Start search listing version + if (elgg_get_context() == "search") { // Start search listing version if (get_input('search_viewtype') == "gallery") { echo "