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
*
*
*/
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');
*/
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;
*
*/
-global $CONFIG;
-
/**
* Default widgets initialisation
*
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');
// 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
// 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');
/**
* Initialise the diagnostics tool
- *
*/
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();
/**
* 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)));
/**
* 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;
}
/**
* 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;
/**
* 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;
*/
function groups_init() {
- global $CONFIG;
-
elgg_register_library('elgg:groups', elgg_get_plugin_path() . 'groups/lib/groups.php');
// register group entities for search
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');
*
*/
function groups_submenus() {
- global $CONFIG;
// Get the page owner entity
$page_owner = elgg_get_page_owner_entity();
*/
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]);
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");
}
/**
* @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'];
}
function activity_profile_menu($hook, $entity_type, $return_value, $params) {
- global $CONFIG;
if ($params['owner'] instanceof ElggGroup) {
$return_value[] = array(
$descr = $entity->description;
$title = $entity->title;
- global $CONFIG;
$url = $entity->getURL();
$msg = get_input('topicmessage');
*
*/
function pages_init() {
- global $CONFIG;
// register a library of helper functions
elgg_register_library('elgg:pages', elgg_get_plugin_path() . 'pages/lib/pages.php');
// 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');
* @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];
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;
}
* @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.
* @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);
'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
// @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();
$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>';
}