]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2428 just a few more CONFIG uses left to be replaced
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 3 Feb 2011 12:07:28 +0000 (12:07 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 3 Feb 2011 12:07:28 +0000 (12:07 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8000 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/configuration.php
mod/categories/start.php
mod/defaultwidgets/start.php
mod/diagnostics/start.php
mod/groups/start.php
mod/pages/start.php
mod/profile/start.php
mod/search/start.php
mod/twitterservice/languages/en.php
mod/twitterservice/twitterservice_lib.php
mod/twitterservice/views/default/usersettings/twitterservice/edit.php

index 4bbed775c7edea391fc8f1844c31e4f91bbe6504..3459c52a3195df15ac1860e822717f8197dbf793 100644 (file)
@@ -61,6 +61,17 @@ function elgg_get_data_path() {
        return $CONFIG->dataroot;
 }
 
+/**
+ * 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
  *
index e69e482b81760799c64654719c2eefaecb7584f4..a904f19ae14cf6aa6017afb8203a4b7bf84411a3 100644 (file)
  *
  */
 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;
index 4e6766dd4720f56932da5b41bd5af7049748ea58..acc8951d38f451f753595e1351f0c0fa9df59adc 100644 (file)
@@ -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');
index b161e47c4f060f78d97e5532298cb61c37e0a945..27893f4eddcccebf55a3ada43950232cd5e71b92 100644 (file)
@@ -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;
index 0b2926a18fd19a7d9a907da37f8058e1907e35b6..cb062bd46755334b4abca410c12e9e7261355f6b 100644 (file)
@@ -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');
index afa6651e340207723e819961b43f4aa818b95c4c..678449dc1b5bc8bfa3bb49f349ab4f3bff718f9d 100644 (file)
@@ -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');
 
index 06c5dfdc2d56c10fdec902de5e9fdaac207c3e59..2c4a5c84c073d27fec8834ee4c0c655277389857 100644 (file)
@@ -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;
        }
 
index 41e67dcdf38a65620482a756eb64074bd1a29964..ac61963d4b991ac070f6e76d4a9803ab707249d0 100644 (file)
@@ -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);
index 39bb47741324049a158a248c076d1f975ae88809..06c90f3b7d7a7f35bf63470eb7365a5954da9caf 100644 (file)
@@ -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
index 0251a9208e89919073f3b90ec45c09a2981715b2..c8b31c526ec28b3283a1de69f091f1ac952e1da9 100644 (file)
@@ -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();
                        
index eb5a5096989ad5890fe88ce82d003299a9a55ff4..d3083d48f2ce444a838e9c86a03a8558cfc99a81 100644 (file)
@@ -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>';
 }