aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/admin/site/update_basic.php6
-rw-r--r--engine/lib/access.php20
-rw-r--r--engine/lib/users.php5
-rw-r--r--languages/en.php11
-rw-r--r--views/default/settings/system.php2
5 files changed, 40 insertions, 4 deletions
diff --git a/actions/admin/site/update_basic.php b/actions/admin/site/update_basic.php
index 564a3aa1c..a106a22f0 100644
--- a/actions/admin/site/update_basic.php
+++ b/actions/admin/site/update_basic.php
@@ -44,6 +44,12 @@
set_config('default_access', get_input('default_access'), $site->getGUID());
+ if (get_input('allow_user_default_access')) {
+ set_config('allow_user_default_access', 1, $site->getGUID());
+ } else {
+ set_config('allow_user_default_access', 0, $site->getGUID());
+ }
+
set_config('view', get_input('view'), $site->getGUID());
$debug = get_input('debug');
diff --git a/engine/lib/access.php b/engine/lib/access.php
index eb00d7543..2f9feae43 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -116,13 +116,27 @@
*
* @return int default access id (see ACCESS defines in elgglib.php)
*/
- function get_default_access()
+ function get_default_access($user=null)
{
global $CONFIG;
- // future: if user has a default access set, override site default access
+ if (!$CONFIG->allow_user_default_access) {
+ return $CONFIG->default_access;
+ }
+
+ if (!$user) {
+ if (isloggedin()) {
+ $user = $_SESSION['user'];
+ } else {
+ return $CONFIG->default_access;
+ }
+ }
- return $CONFIG->default_access;
+ if (false !== ($default_access = $user->getPrivateSetting('elgg_default_access'))) {
+ return $default_access;
+ } else {
+ return $CONFIG->default_access;
+ }
}
/**
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 82ba38dde..f7c12bbc9 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1472,6 +1472,10 @@
// Add language settings
extend_elgg_settings_page('user/settings/language', 'usersettings/user', 1);
+
+ // Add default access settings
+ extend_elgg_settings_page('user/settings/default_access', 'usersettings/user', 1);
+
//register_action("user/language");
// Register the user type
@@ -1520,6 +1524,7 @@
@include($CONFIG->path . "actions/user/password.php");
@include($CONFIG->path . "actions/email/save.php");
@include($CONFIG->path . "actions/user/language.php");
+ @include($CONFIG->path . "actions/user/default_access.php");
}
diff --git a/languages/en.php b/languages/en.php
index 2a7be9a81..05b27c802 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -774,6 +774,9 @@ Alternatively, you can enter your database settings below and we will try and do
'installation:disableapi' => "The RESTful API is a flexible and extensible interface that enables applications to use certain Elgg features remotely.",
'installation:disableapi:label' => "Enable the RESTful API",
+
+ 'installation:allow_user_default_access:description' => "If checked, individual users will be allowed to set their own default access level that can over-ride the system default access level.",
+ 'installation:allow_user_default_access:label' => "Allow user default access",
'installation:simplecache:description' => "The simple cache increases performance by caching static content including some CSS and JavaScript files. Normally you will want this on.",
'installation:simplecache:label' => "Use simple cache",
@@ -825,6 +828,14 @@ If you requested this click on the link below, otherwise ignore this email.
%s
",
+ /**
+ * user default access
+ */
+
+ 'default_access:settings' => "Your default access level",
+ 'default_access:label' => "Default access",
+ 'user:default_access:success' => "Your new default access level was saved.",
+ 'user:default_access:failure' => "Your new default access level could not be saved.",
/**
* XML-RPC
diff --git a/views/default/settings/system.php b/views/default/settings/system.php
index 572304e14..420cc225b 100644
--- a/views/default/settings/system.php
+++ b/views/default/settings/system.php
@@ -37,7 +37,7 @@
$form_body .= "<p class=\"admin_debug\">" . elgg_echo('admin:site:access:warning') . "<br />";
$form_body .= elgg_echo('installation:sitepermissions') . elgg_view('input/access', array('internalname' => 'default_access','value' => $vars['config']->default_access)) . "</p>";
-
+ $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:allow_user_default_access:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:allow_user_default_access:label')), 'internalname' => 'allow_user_default_access', 'value' => ($vars['config']->allow_user_default_access ? elgg_echo('installation:allow_user_default_access:label') : "") )) . "</p>";
$form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:simplecache:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:simplecache:label')), 'internalname' => 'simplecache_enabled', 'value' => ($vars['config']->simplecache_enabled ? elgg_echo('installation:simplecache:label') : "") )) . "</p>";
$form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:debug:label')), 'internalname' => 'debug', 'value' => ($vars['config']->debug ? elgg_echo('installation:debug:label') : "") )) . "</p>";