aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-03 12:07:28 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-03 12:07:28 +0000
commit755947e111d89d6babcd0f070d91c2245e22a809 (patch)
tree284e62a3f1cfca8f9d23e88680544cde4f5aea79
parent949a233076ec18f86e60f90a7a8837cb422664af (diff)
downloadelgg-755947e111d89d6babcd0f070d91c2245e22a809.tar.gz
elgg-755947e111d89d6babcd0f070d91c2245e22a809.tar.bz2
Refs #2428 just a few more CONFIG uses left to be replaced
git-svn-id: http://code.elgg.org/elgg/trunk@8000 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/configuration.php11
-rw-r--r--mod/categories/start.php8
-rw-r--r--mod/defaultwidgets/start.php17
-rw-r--r--mod/diagnostics/start.php53
-rw-r--r--mod/groups/start.php32
-rw-r--r--mod/pages/start.php5
-rw-r--r--mod/profile/start.php4
-rw-r--r--mod/search/start.php3
-rw-r--r--mod/twitterservice/languages/en.php8
-rw-r--r--mod/twitterservice/twitterservice_lib.php3
-rw-r--r--mod/twitterservice/views/default/usersettings/twitterservice/edit.php7
11 files changed, 68 insertions, 83 deletions
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php
index 4bbed775c..3459c52a3 100644
--- a/engine/lib/configuration.php
+++ b/engine/lib/configuration.php
@@ -62,6 +62,17 @@ function elgg_get_data_path() {
}
/**
+ * Get the root directory for this installation
+ *
+ * @return string
+ * @since 1.8.0
+ */
+function elgg_get_root_dir() {
+ global $CONFIG;
+ return $CONFIG->path;
+}
+
+/**
* Get an Elgg configuration value
*
* @param string $name Name of the configuration value
diff --git a/mod/categories/start.php b/mod/categories/start.php
index e69e482b8..a904f19ae 100644
--- a/mod/categories/start.php
+++ b/mod/categories/start.php
@@ -11,11 +11,11 @@
*
*/
function categories_init() {
- global $CONFIG;
elgg_extend_view('css/screen', 'categories/css');
- elgg_register_action('settings/categories/save', $CONFIG->pluginspath . 'categories/actions/save.php', 'admin');
+ $action_base = elgg_get_plugin_path() . 'categories/actions';
+ elgg_register_action('settings/categories/save', "$action_base/save.php", 'admin');
register_page_handler('categories', 'categories_page_handler');
@@ -59,8 +59,8 @@ function categories_save($event, $object_type, $object) {
*/
function categories_on_enable() {
if (!$site->categories) {
- global $CONFIG;
- $message = elgg_echo('categories:on_enable_reminder', array("{$CONFIG->url}pg/admin/plugin_settings/categories"));
+ $url = elgg_normalize_url('pg/admin/plugin_settings/categories');
+ $message = elgg_echo('categories:on_enable_reminder', array($url));
elgg_add_admin_notice('categories_admin_notice_no_categories', $message);
}
return TRUE;
diff --git a/mod/defaultwidgets/start.php b/mod/defaultwidgets/start.php
index 4e6766dd4..acc8951d3 100644
--- a/mod/defaultwidgets/start.php
+++ b/mod/defaultwidgets/start.php
@@ -11,8 +11,6 @@
*
*/
-global $CONFIG;
-
/**
* Default widgets initialisation
*
@@ -31,6 +29,13 @@ function defaultwidgets_init() {
elgg_register_event_handler('validate', 'user', 'defaultwidgets_reset_access');
}
+ $action_dir = elgg_get_plugin_path() . 'defaultwidgets/actions';
+ elgg_register_action("defaultwidgets/update", "$action_dir/update.php", 'admin');
+
+ elgg_register_plugin_hook_handler('permissions_check', 'user', 'defaultwidgets_can_edit');
+ elgg_register_plugin_hook_handler('permissions_check', 'object', 'defaultwidgets_can_edit');
+ elgg_register_plugin_hook_handler('container_permissions_check', 'user', 'defaultwidgets_can_edit_container');
+
// @todo These submenu pages should be DRYed up
//elgg_add_admin_menu_item('default_profile_widgets', elgg_echo('defaultwidgets:menu:profile'), 'appearance');
//elgg_add_admin_menu_item('default_dashboard_widgets', elgg_echo('defaultwidgets:menu:dashboard'), 'appearance');
@@ -92,7 +97,7 @@ function defaultwidgets_newusers($event, $object_type, $object) {
// this is an admin-created user
// no permissions problems, so set proper access now
// use system default access (not the admin's default access!, because that could be a personal access level)
- $widget_access = $CONFIG->default_access;
+ $widget_access = elgg_get_config('default_access');
} else {
// this is a regular registration
// set widget access to public for now and reset it properly during the validate event
@@ -199,9 +204,3 @@ function defaultwidgets_reset_access($event, $object_type, $object) {
// Make sure the status initialisation function is called on initialisation
elgg_register_event_handler('init', 'system', 'defaultwidgets_init');
-
-elgg_register_plugin_hook_handler('permissions_check', 'user', 'defaultwidgets_can_edit');
-elgg_register_plugin_hook_handler('permissions_check', 'object', 'defaultwidgets_can_edit');
-elgg_register_plugin_hook_handler('container_permissions_check', 'user', 'defaultwidgets_can_edit_container');
-
-elgg_register_action("defaultwidgets/update", $CONFIG->pluginspath . "defaultwidgets/actions/update.php", 'admin');
diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php
index b161e47c4..27893f4ed 100644
--- a/mod/diagnostics/start.php
+++ b/mod/diagnostics/start.php
@@ -9,7 +9,6 @@ elgg_register_event_handler('init', 'system', 'diagnostics_init');
/**
* Initialise the diagnostics tool
- *
*/
function diagnostics_init() {
@@ -27,13 +26,9 @@ function diagnostics_init() {
/**
* Generate a basic report.
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @return string
*/
function diagnostics_basic_hook($hook, $entity_type, $returnvalue, $params) {
- global $CONFIG;
// Get version information
$version = get_version();
@@ -47,10 +42,7 @@ function diagnostics_basic_hook($hook, $entity_type, $returnvalue, $params) {
/**
* Get some information about the plugins installed on the system.
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @return tring
*/
function diagnostics_plugins_hook($hook, $entity_type, $returnvalue, $params) {
$returnvalue .= elgg_echo('diagnostics:report:plugins', array(print_r(get_installed_plugins(), true)));
@@ -89,15 +81,12 @@ function diagnostics_md5_dir($dir) {
/**
* Get some information about the files installed on a system.
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @return string
*/
function diagnostics_sigs_hook($hook, $entity_type, $returnvalue, $params) {
- global $CONFIG;
- $returnvalue .= elgg_echo('diagnostics:report:md5', array(diagnostics_md5_dir($CONFIG->path)));
+ $base_dir = elgg_get_root_dir();
+ $returnvalue .= elgg_echo('diagnostics:report:md5', array(diagnostics_md5_dir($base_dir)));
return $returnvalue;
}
@@ -105,31 +94,27 @@ function diagnostics_sigs_hook($hook, $entity_type, $returnvalue, $params) {
/**
* Get some information about the php install
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @return string
*/
function diagnostics_phpinfo_hook($hook, $entity_type, $returnvalue, $params) {
- global $CONFIG;
ob_start();
phpinfo();
$phpinfo = array('phpinfo' => array());
- if(preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER))
+ if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) {
- foreach($matches as $match)
- {
- if(strlen($match[1]))
- $phpinfo[$match[1]] = array();
- else if(isset($match[3]))
- $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
- else
- $phpinfo[end(array_keys($phpinfo))][] = $match[2];
+ foreach ($matches as $match) {
+ if (strlen($match[1])) {
+ $phpinfo[$match[1]] = array();
+ } else if(isset($match[3])) {
+ $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
+ } else {
+ $phpinfo[end(array_keys($phpinfo))][] = $match[2];
+ }
+ }
}
-
$returnvalue .= elgg_echo('diagnostics:report:php', array(print_r($phpinfo, true)));
return $returnvalue;
@@ -138,11 +123,7 @@ function diagnostics_phpinfo_hook($hook, $entity_type, $returnvalue, $params) {
/**
* Get global variables.
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- * @return unknown
+ * @return string
*/
function diagnostics_globals_hook($hook, $entity_type, $returnvalue, $params) {
global $CONFIG;
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 0b2926a18..cb062bd46 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -15,8 +15,6 @@ elgg_register_event_handler('init', 'system', 'groups_fields_setup', 10000);
*/
function groups_init() {
- global $CONFIG;
-
elgg_register_library('elgg:groups', elgg_get_plugin_path() . 'groups/lib/groups.php');
// register group entities for search
@@ -36,16 +34,17 @@ function groups_init() {
register_page_handler('groupicon', 'groups_icon_handler');
// Register some actions
- elgg_register_action("groups/edit", $CONFIG->pluginspath . "groups/actions/edit.php");
- elgg_register_action("groups/delete", $CONFIG->pluginspath . "groups/actions/delete.php");
- elgg_register_action("groups/join", $CONFIG->pluginspath . "groups/actions/join.php");
- elgg_register_action("groups/leave", $CONFIG->pluginspath . "groups/actions/leave.php");
- elgg_register_action("groups/joinrequest", $CONFIG->pluginspath . "groups/actions/joinrequest.php");
- elgg_register_action("groups/killrequest", $CONFIG->pluginspath . "groups/actions/groupskillrequest.php");
- elgg_register_action("groups/killinvitation", $CONFIG->pluginspath . "groups/actions/groupskillinvitation.php");
- elgg_register_action("groups/addtogroup", $CONFIG->pluginspath . "groups/actions/addtogroup.php");
- elgg_register_action("groups/invite", $CONFIG->pluginspath . "groups/actions/invite.php");
- elgg_register_action("groups/featured", $CONFIG->pluginspath . "groups/actions/featured.php", 'admin');
+ $action_base = elgg_get_plugin_path() . 'groups/actions';
+ elgg_register_action("groups/edit", "$action_base/edit.php");
+ elgg_register_action("groups/delete", "$action_base/delete.php");
+ elgg_register_action("groups/join", "$action_base/join.php");
+ elgg_register_action("groups/leave", "$action_base/leave.php");
+ elgg_register_action("groups/joinrequest", "$action_base/joinrequest.php");
+ elgg_register_action("groups/killrequest", "$action_base/groupskillrequest.php");
+ elgg_register_action("groups/killinvitation", "$action_base/groupskillinvitation.php");
+ elgg_register_action("groups/addtogroup", "$action_base/addtogroup.php");
+ elgg_register_action("groups/invite", "$action_base/invite.php");
+ elgg_register_action("groups/featured", "$action_base/featured.php", 'admin');
// Add a page owner handler
//elgg_register_plugin_hook_handler('page_owner', 'system', 'groups_page_owner_handler');
@@ -130,7 +129,6 @@ function groups_fields_setup() {
*
*/
function groups_submenus() {
- global $CONFIG;
// Get the page owner entity
$page_owner = elgg_get_page_owner_entity();
@@ -239,8 +237,6 @@ function groups_page_handler($page) {
*/
function groups_icon_handler($page) {
- global $CONFIG;
-
// The username should be the file we're getting
if (isset($page[0])) {
set_input('group_guid', $page[0]);
@@ -249,7 +245,8 @@ function groups_icon_handler($page) {
set_input('size', $page[1]);
}
// Include the standard profile index
- include($CONFIG->pluginspath . "groups/icon.php");
+ $plugin_dir = elgg_get_plugin_path();
+ include("$plugin_dir/groups/icon.php");
}
/**
@@ -404,7 +401,6 @@ function groups_user_leave_event_listener($event, $object_type, $object) {
* @return unknown
*/
function groups_groupicon_hook($hook, $entity_type, $returnvalue, $params) {
- global $CONFIG;
if ((!$returnvalue) && ($hook == 'entity:icon:url') && ($params['entity'] instanceof ElggGroup)) {
$entity = $params['entity'];
@@ -465,7 +461,6 @@ function group_access_options($group) {
}
function activity_profile_menu($hook, $entity_type, $return_value, $params) {
- global $CONFIG;
if ($params['owner'] instanceof ElggGroup) {
$return_value[] = array(
@@ -668,7 +663,6 @@ function groupforumtopic_notify_message($hook, $entity_type, $returnvalue, $para
$descr = $entity->description;
$title = $entity->title;
- global $CONFIG;
$url = $entity->getURL();
$msg = get_input('topicmessage');
diff --git a/mod/pages/start.php b/mod/pages/start.php
index afa6651e3..678449dc1 100644
--- a/mod/pages/start.php
+++ b/mod/pages/start.php
@@ -12,7 +12,6 @@ elgg_register_event_handler('init', 'system', 'pages_init');
*
*/
function pages_init() {
- global $CONFIG;
// register a library of helper functions
elgg_register_library('elgg:pages', elgg_get_plugin_path() . 'pages/lib/pages.php');
@@ -55,13 +54,13 @@ function pages_init() {
// Language short codes must be of the form "pages:key"
// where key is the array key below
- $CONFIG->pages = array(
+ elgg_set_config('pages', array(
'title' => 'text',
'description' => 'longtext',
'tags' => 'tags',
'access_id' => 'access',
'write_access_id' => 'access',
- );
+ ));
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'pages_owner_block_menu');
diff --git a/mod/profile/start.php b/mod/profile/start.php
index 06c5dfdc2..2c4a5c84c 100644
--- a/mod/profile/start.php
+++ b/mod/profile/start.php
@@ -42,7 +42,6 @@ function profile_init() {
* @param array $page Array of page elements, forwarded by the page handling mechanism
*/
function profile_page_handler($page) {
- global $CONFIG;
if (isset($page[0])) {
$username = $page[0];
@@ -63,7 +62,8 @@ function profile_page_handler($page) {
if ($action == 'edit') {
// use the core profile edit page
- require $CONFIG->path . 'pages/profile/edit.php';
+ $base_dir = elgg_get_root_dir();
+ require "{$base_dir}pages/profile/edit.php";
return;
}
diff --git a/mod/search/start.php b/mod/search/start.php
index 41e67dcdf..ac61963d4 100644
--- a/mod/search/start.php
+++ b/mod/search/start.php
@@ -61,7 +61,6 @@ function search_init() {
* @param array $page Page elements from pain page handler
*/
function search_page_handler($page) {
- global $CONFIG;
// if there is no q set, we're being called from a legacy installation
// it expects a search by tags.
@@ -86,7 +85,7 @@ function search_page_handler($page) {
* @return string
*/
function search_get_highlighted_relevant_substrings($haystack, $query, $min_match_context = 30, $max_length = 300) {
- global $CONFIG;
+
$haystack = strip_tags($haystack);
$haystack_length = elgg_strlen($haystack);
$haystack_lc = elgg_strtolower($haystack);
diff --git a/mod/twitterservice/languages/en.php b/mod/twitterservice/languages/en.php
index 39bb47741..06c90f3b7 100644
--- a/mod/twitterservice/languages/en.php
+++ b/mod/twitterservice/languages/en.php
@@ -13,19 +13,19 @@ $english = array(
'twitterservice:settings:instructions' => 'You must obtain a consumer key and secret from <a href="https://twitter.com/oauth_clients" target="_blank">Twitter</a>. Most of the fields are self explanatory, the one piece of data you will need is the callback url which takes the form http://[yoursite]/action/twitterlogin/return - [yoursite] is the url of your Elgg network.',
- 'twitterservice:usersettings:description' => "Link your {$CONFIG->site->name} account with Twitter.",
- 'twitterservice:usersettings:request' => "You must first <a href=\"%s\">authorize</a> {$CONFIG->site->name} to access your Twitter account.",
+ 'twitterservice:usersettings:description' => "Link your %s account with Twitter.",
+ 'twitterservice:usersettings:request' => "You must first <a href=\"%s\">authorize</a> %s to access your Twitter account.",
'twitterservice:authorize:error' => 'Unable to authorize Twitter.',
'twitterservice:authorize:success' => 'Twitter access has been authorized.',
- 'twitterservice:usersettings:authorized' => "You have authorized {$CONFIG->site->name} to access your Twitter account: @%s.",
+ 'twitterservice:usersettings:authorized' => "You have authorized %s to access your Twitter account: @%s.",
'twitterservice:usersettings:revoke' => 'Click <a href="%s">here</a> to revoke access.',
'twitterservice:revoke:success' => 'Twitter access has been revoked.',
'twitterservice:login' => 'Allow users to sign in with Twitter?',
'twitterservice:login:success' => 'You have been logged in.',
'twitterservice:login:error' => 'Unable to login with Twitter.',
- 'twitterservice:login:email' => "You must enter a valid email address for your new {$CONFIG->site->name} account.",
+ 'twitterservice:login:email' => "You must enter a valid email address for your new %s account.",
);
add_translation('en', $english); \ No newline at end of file
diff --git a/mod/twitterservice/twitterservice_lib.php b/mod/twitterservice/twitterservice_lib.php
index 0251a9208..c8b31c526 100644
--- a/mod/twitterservice/twitterservice_lib.php
+++ b/mod/twitterservice/twitterservice_lib.php
@@ -112,7 +112,8 @@ function twitterservice_login() {
// @hack Remove temporary email and forward to user settings page
// @todo Consider using a view to force valid email
- system_message(elgg_echo('twitterservice:login:email'));
+ $site_name = elgg_get_site_entity()->name;
+ system_message(elgg_echo('twitterservice:login:email', array($site_name)));
$user->email = '';
$user->save();
diff --git a/mod/twitterservice/views/default/usersettings/twitterservice/edit.php b/mod/twitterservice/views/default/usersettings/twitterservice/edit.php
index eb5a50969..d3083d48f 100644
--- a/mod/twitterservice/views/default/usersettings/twitterservice/edit.php
+++ b/mod/twitterservice/views/default/usersettings/twitterservice/edit.php
@@ -8,14 +8,15 @@ $twitter_name = get_plugin_usersetting('twitter_name', $user_id, 'twitterservice
$access_key = get_plugin_usersetting('access_key', $user_id, 'twitterservice');
$access_secret = get_plugin_usersetting('access_secret', $user_id, 'twitterservice');
-echo '<p>' . elgg_echo('twitterservice:usersettings:description') . '</p>';
+$site_name = elgg_get_site_entity()->name;
+echo '<p>' . elgg_echo('twitterservice:usersettings:description', array($site_name)) . '</p>';
if (!$access_key || !$access_secret) {
// send user off to validate account
$request_link = twitterservice_get_authorize_url();
- echo '<p>' . sprintf(elgg_echo('twitterservice:usersettings:request'), $request_link) . '</p>';
+ echo '<p>' . elgg_echo('twitterservice:usersettings:request', array($request_link, $site_name)) . '</p>';
} else {
$url = elgg_get_site_url() . "pg/twitterservice/revoke";
- echo '<p class="twitter_anywhere">' . sprintf(elgg_echo('twitterservice:usersettings:authorized'), $twitter_name) . '</p>';
+ echo '<p class="twitter_anywhere">' . elgg_echo('twitterservice:usersettings:authorized', array($site_name, $twitter_name)) . '</p>';
echo '<p>' . sprintf(elgg_echo('twitterservice:usersettings:revoke'), $url) . '</p>';
}