diff --git a/htdocs/admin/users/edit.php b/htdocs/admin/users/edit.php index 49d2c768b0f71e336f01636b79cb5a4565004907..62acfeb659add03635781c8e96248e26ab39d24a 100644 --- a/htdocs/admin/users/edit.php +++ b/htdocs/admin/users/edit.php @@ -42,63 +42,6 @@ if (!$USER->is_admin_for_user($user)) { redirect(get_config('wwwroot').'user/view.php?id='.$id); } -$suspended = $user->get('suspendedcusr'); -if (empty($suspended)) { - $suspendform = pieform(array( - 'name' => 'edituser_suspend', - 'plugintype' => 'core', - 'pluginname' => 'admin', - 'elements' => array( - 'id' => array( - 'type' => 'hidden', - 'value' => $id, - ), - 'reason' => array( - 'type' => 'textarea', - 'rows' => 5, - 'cols' => 60, - 'title' => get_string('reason'), - 'description' => get_string('suspendedreasondescription', 'admin'), - ), - 'submit' => array( - 'type' => 'submit', - 'value' => get_string('suspenduser','admin'), - ), - ) - )); -} else { - $suspendform = pieform(array( - 'name' => 'edituser_unsuspend', - 'plugintype' => 'core', - 'pluginname' => 'admin', - 'elements' => array( - 'id' => array( - 'type' => 'hidden', - 'value' => $id, - ), - 'submit' => array( - 'type' => 'submit', - 'value' => get_string('unsuspenduser','admin'), - ), - ) - )); - $suspender = display_name(get_record('usr', 'id', $suspended)); -} - -function edituser_suspend_submit(Pieform $form, $values) { - global $SESSION; - suspend_user($values['id'], $values['reason']); - $SESSION->add_ok_msg(get_string('usersuspended', 'admin')); - redirect('/admin/users/edit.php?id=' . $values['id']); -} - -function edituser_unsuspend_submit(Pieform $form, $values) { - global $SESSION; - unsuspend_user($values['id']); - $SESSION->add_ok_msg(get_string('userunsuspended', 'admin')); - redirect('/admin/users/edit.php?id=' . $values['id']); -} - // Site-wide account settings $currentdate = getdate(); @@ -123,14 +66,14 @@ if ($USER->get('admin')) { $elements['staff'] = array( 'type' => 'checkbox', 'title' => get_string('sitestaff','admin'), - //'description' => get_string('sitestaffdescription','admin'), 'defaultvalue' => $user->staff, + 'help' => true, ); $elements['admin'] = array( 'type' => 'checkbox', 'title' => get_string('siteadmin','admin'), - //'description' => get_string('siteadmindescription','admin'), 'defaultvalue' => $user->admin, + 'help' => true, ); } $elements['expiry'] = array( @@ -153,10 +96,18 @@ $authinstances = auth_get_auth_instances(); if (count($authinstances) > 1) { $options = array(); + // NOTE: This is a little broken at the moment. The "username in the remote + // system" setting is only actively used by the XMLRPC authentication + // plugin, and thus only makes sense when the user is authenticating in + // this manner. + // + // We hope to one day make it possible for users to get into accounts via + // multiple methods, at which time we can tie the username-in-remote-system + // setting to the XMLRPC plugin only, making the UI a bit more consistent $external = false; foreach ($authinstances as $authinstance) { if ($USER->can_edit_institution($authinstance->name)) { - $options[$authinstance->id] = $authinstance->displayname. ': '.$authinstance->instancename; + $options[$authinstance->id] = $authinstance->instancename . ' (' . $authinstance->displayname . ')'; if ($authinstance->authname != 'internal') { $external = true; } @@ -167,9 +118,10 @@ if (count($authinstances) > 1) { $elements['authinstance'] = array( 'type' => 'select', 'title' => get_string('authenticatedby', 'admin'), - //'description' => get_string('authenticatedbydescription', 'admin'), + 'description' => get_string('authenticatedbydescription', 'admin'), 'options' => $options, 'defaultvalue' => $user->authinstance, + 'help' => true, ); if ($external) { $un = get_field('auth_remote_user', 'remoteusername', 'authinstance', $user->authinstance, 'localusr', $user->id); @@ -258,8 +210,96 @@ function edituser_site_submit(Pieform $form, $values) { } -// Institution settings form +// Suspension/deletion controls +$suspended = $user->get('suspendedcusr'); +if (empty($suspended)) { + $suspendform = pieform(array( + 'name' => 'edituser_suspend', + 'plugintype' => 'core', + 'pluginname' => 'admin', + 'elements' => array( + 'id' => array( + 'type' => 'hidden', + 'value' => $id, + ), + 'reason' => array( + 'type' => 'textarea', + 'rows' => 5, + 'cols' => 60, + 'title' => get_string('reason'), + 'description' => get_string('suspendedreasondescription', 'admin'), + ), + 'submit' => array( + 'type' => 'submit', + 'value' => get_string('suspenduser','admin'), + ), + ) + )); +} +else { + $suspendformdef = array( + 'name' => 'edituser_unsuspend', + 'plugintype' => 'core', + 'pluginname' => 'admin', + 'renderer' => 'oneline', + 'elements' => array( + 'id' => array( + 'type' => 'hidden', + 'value' => $id, + ), + 'submit' => array( + 'type' => 'submit', + 'value' => get_string('unsuspenduser','admin'), + ), + ) + ); + + // Create two forms for unsuspension - one in the suspend message and the + // other where the 'suspend' button normally goes. This keeps the HTML IDs + // unique + $suspendform = pieform($suspendformdef); + $suspendformdef['name'] = 'edituser_suspend2'; + $suspendformdef['validatecallback'] = 'edituser_unsuspend_validate'; + $suspendformdef['successcallback'] = 'edituser_unsuspend_submit'; + $suspendform2 = pieform($suspendformdef); + + $suspender = display_name(get_record('usr', 'id', $suspended)); +} + +function edituser_suspend_submit(Pieform $form, $values) { + global $SESSION; + suspend_user($values['id'], $values['reason']); + $SESSION->add_ok_msg(get_string('usersuspended', 'admin')); + redirect('/admin/users/edit.php?id=' . $values['id']); +} + +function edituser_unsuspend_submit(Pieform $form, $values) { + global $SESSION; + unsuspend_user($values['id']); + $SESSION->add_ok_msg(get_string('userunsuspended', 'admin')); + redirect('/admin/users/edit.php?id=' . $values['id']); +} + +$deleteform = pieform(array( + 'name' => 'edituser_delete', + 'plugintype' => 'core', + 'pluginname' => 'admin', + 'renderer' => 'oneline', + 'elements' => array( + 'id' => array( + 'type' => 'hidden', + 'value' => $id, + ), + 'submit' => array( + 'type' => 'submit', + 'value' => get_string('deleteuser', 'admin'), + 'confirm' => get_string('confirmdeleteuser', 'admin'), + ), + ), +)); + +// Institution settings form $elements = array( 'id' => array( 'type' => 'hidden', @@ -302,13 +342,13 @@ foreach ($user->get('institutions') as $i) { 'type' => 'submit', 'value' => get_string('update'), ), + $i->institution.'_remove' => array( + 'type' => 'submit', + 'value' => get_string('removeuserfrominstitution', 'admin'), + 'confirm' => get_string('confirmremoveuserfrominstitution', 'admin'), + ), ), ); - $elements[$i->institution.'_remove'] = array( - 'type' => 'submit', - 'value' => get_string('remove'), - 'confirm' => get_string('confirmremoveuserfrominstitution', 'admin'), - ); } // Only site admins can add institutions; institutional admins must invite @@ -321,14 +361,18 @@ if ($USER->get('admin') } } if (!empty($options)) { + $elements['addinstitutionheader'] = array( + 'type' => 'markup', + 'value' => '

' . get_string('addusertoinstitution', 'admin') . '

', + ); $elements['addinstitution'] = array( 'type' => 'select', - 'title' => get_string('addinstitution', 'admin'), + 'title' => get_string('institution'), 'options' => $options, ); $elements['add'] = array( 'type' => 'submit', - 'value' => get_string('addinstitution','admin'), + 'value' => get_string('addusertoinstitution', 'admin'), ); } } @@ -427,6 +471,10 @@ if ($suspended) { $smarty->assign('suspendedby', get_string('suspendedby', 'admin', $suspender)); } $smarty->assign('suspendform', $suspendform); +if (isset($suspendform2)) { + $smarty->assign('suspendform2', $suspendform2); +} +$smarty->assign('deleteform', $deleteform); $smarty->assign('siteform', $siteform); $smarty->assign('institutions', count($allinstitutions) > 1); $smarty->assign('institutionform', $institutionform); diff --git a/htdocs/lang/en.utf8/admin.php b/htdocs/lang/en.utf8/admin.php index 744c41b02283fb810b27889bfefd15bb7e6cc944..1b13ea03649c133e1af562fd820099e8316ced4d 100644 --- a/htdocs/lang/en.utf8/admin.php +++ b/htdocs/lang/en.utf8/admin.php @@ -296,10 +296,8 @@ $string['resetpassworddescription'] = 'If you enter text here, it will replace t $string['forcepasswordchange'] = 'Force password change on next login'; $string['forcepasswordchangedescription'] = 'The user will be directed to a change password page the next time they login.'; $string['sitestaff'] = 'Site Staff'; -$string['sitestaffdescription'] = 'If checked, the user can create controlled Communities, receive and release submitted views and access key user profile information.'; $string['siteadmins'] = 'Site Admins'; -$string['siteadmin'] = 'Site administrator'; -$string['siteadmindescription'] = 'Site administrators can to do anything and go anywhere on the site'; +$string['siteadmin'] = 'Site Administrator'; $string['accountexpiry'] = 'Account expires'; $string['accountexpirydescription'] = 'Date on which the user\'s login is automatically disabled.'; $string['suspended'] = 'Suspended'; @@ -308,8 +306,12 @@ $string['suspendedreasondescription'] = 'The text that will be displayed to the $string['unsuspenduser'] = 'Unsuspend User'; $string['thisuserissuspended'] = 'This user has been suspended'; $string['suspendedby'] = 'This user has been suspended by %s'; +$string['deleteuser'] = 'Delete User'; +$string['confirmdeleteuser'] = 'Are you sure you want to delete this user?'; $string['filequota'] = 'File quota (MB)'; $string['filequotadescription'] = 'Total storage available in the user\'s files area.'; +$string['addusertoinstitution'] = 'Add User to Institution'; +$string['removeuserfrominstitution'] = 'Remove user from this institution'; $string['confirmremoveuserfrominstitution'] = 'Are you sure you want to remove the user from this institution?'; // Add User @@ -349,9 +351,9 @@ $string['registrationalloweddescription2'] = 'Whether users can register for you $string['defaultmembershipperiod'] = 'Default membership period'; $string['defaultmembershipperioddescription'] = 'How long new members remain associated with the institution'; $string['authenticatedby'] = 'Authentication Method'; -$string['authenticatedbydescription'] = ''; +$string['authenticatedbydescription'] = 'How this user authenticates to Mahara'; $string['remoteusername'] = 'Username for external authentication'; -$string['remoteusernamedescription'] = 'If this user is authenticated by an external method and you would like to associate them with a different identity on a remote database, enter their remote username here.'; +$string['remoteusernamedescription'] = 'The username that this user has in the remote system'; $string['institutionsettings'] = 'Institution Settings'; $string['changeinstitution'] = 'Change Institution'; $string['institutionstaff'] = 'Institution Staff'; diff --git a/htdocs/lang/en.utf8/mahara.php b/htdocs/lang/en.utf8/mahara.php index 2924abad26f6968666b26a4531e9615893af390f..dcf78fe41673c58c53d4c5b644fef86ed774b765 100644 --- a/htdocs/lang/en.utf8/mahara.php +++ b/htdocs/lang/en.utf8/mahara.php @@ -519,9 +519,10 @@ $string['virusrepeatsubject'] = 'Warning: %s is a repeat virus uploader.'; $string['virusrepeatmessage'] = 'The user %s has uploaded multiple files which have been scanned by a virus checker and found to be infected.'; $string['youraccounthasbeensuspended'] = 'Your account has been suspended'; -$string['youraccounthasbeensuspendedtext'] = 'Your account has been suspended'; // @todo: more info? +$string['youraccounthasbeensuspendedtext2'] = 'Your account at %s has been suspended by %s.'; // @todo: more info? +$string['youraccounthasbeensuspendedreasontext'] = "Your account at %s has been suspended by %s. Reason:\n\n%s"; $string['youraccounthasbeenunsuspended'] = 'Your account has been unsuspended'; -$string['youraccounthasbeenunsuspendedtext'] = 'Your account has been unsuspended'; // @todo: more info? +$string['youraccounthasbeenunsuspendedtext2'] = 'Your account at %s has been unsuspended. You may once again log in and use the site.'; // can't provide a login link because we don't know how they log in - it might be by xmlrpc // size of stuff $string['sizemb'] = 'MB'; diff --git a/htdocs/lib/db/upgrade.php b/htdocs/lib/db/upgrade.php index 4bda08f92c838ab28d4c4c8f5c5f0081271ed3a7..97ba26ffbc3ebdd969089bdf060394277bf7263e 100644 --- a/htdocs/lib/db/upgrade.php +++ b/htdocs/lib/db/upgrade.php @@ -1474,6 +1474,11 @@ function xmldb_core_upgrade($oldversion=0) { ensure_record_exists('event_type', $event, $event); } + if ($oldversion < 2008110400) { + // Correct capitalisation of internal authinstance for 'no institution', only if it hasn't changed previously + execute_sql("UPDATE {auth_instance} SET instancename = 'Internal' WHERE institution = 'mahara' AND authname = 'internal' AND instancename = 'internal'"); + } + return $status; } diff --git a/htdocs/lib/upgrade.php b/htdocs/lib/upgrade.php index d806898225d06434281dacb7979d3da213ce7394..898d684fc8e2b2d8b21277dd33fbf70cf6e7e2f9 100644 --- a/htdocs/lib/upgrade.php +++ b/htdocs/lib/upgrade.php @@ -560,7 +560,7 @@ function core_install_lastcoredata_defaults() { insert_record('institution', $institution); $auth_instance = new StdClass; - $auth_instance->instancename = 'internal'; + $auth_instance->instancename = 'Internal'; $auth_instance->priority='1'; $auth_instance->institution = 'mahara'; $auth_instance->authname = 'internal'; diff --git a/htdocs/lib/user.php b/htdocs/lib/user.php index ef99a0fbadfadb96ff81f8a72322fa03a4b04aaa..4003287239ca1c1abe3a87a06f9b395b9bd330f7 100644 --- a/htdocs/lib/user.php +++ b/htdocs/lib/user.php @@ -640,7 +640,14 @@ function suspend_user($suspendeduserid, $reason, $suspendinguserid=null) { $message = new StdClass; $message->users = array($suspendeduserid); $message->subject = get_string_from_language($lang, 'youraccounthasbeensuspended'); - $message->message = get_string_from_language($lang, 'youraccounthasbeensuspendedtext'); + if ($reason == '') { + $message->message = get_string_from_language($lang, 'youraccounthasbeensuspendedtext2', 'mahara', + get_config('sitename'), display_name($suspendinguserid, $suspendeduserid)); + } + else { + $message->message = get_string_from_language($lang, 'youraccounthasbeensuspendedreasontext', 'mahara', + get_config('sitename'), display_name($suspendinguserid, $suspendeduserid), $reason); + } require_once('activity.php'); activity_occurred('maharamessage', $message); @@ -664,7 +671,7 @@ function unsuspend_user($userid) { $message = new StdClass; $message->users = array($userid); $message->subject = get_string_from_language($lang, 'youraccounthasbeenunsuspended'); - $message->message = get_string_from_language($lang, 'youraccounthasbeenunsuspendedtext'); + $message->message = get_string_from_language($lang, 'youraccounthasbeenunsuspendedtext2', 'mahara', get_config('sitename')); require_once('activity.php'); activity_occurred('maharamessage', $message); diff --git a/htdocs/theme/default/static/style/style.css b/htdocs/theme/default/static/style/style.css index 78dee0d69005114e028d9a350e8323b90898a74e..c39f0c5d2130d189fb5dac4970fa4d2b1ee1c695 100644 --- a/htdocs/theme/default/static/style/style.css +++ b/htdocs/theme/default/static/style/style.css @@ -2707,6 +2707,32 @@ table#initials .initial-letters { padding: 0; } +/* MANAGE USERS > EDIT USER */ +#edituser hr { + height: 1px; + border: 1px solid #aaa; + border-width: 1px 0 0 0; +} +#edituser .message h4 { + margin: 0; +} +#edituser .message div#suspendreason { + text-align: left; + width: 50%; + margin: 0 auto; +} +#edituser table#suspenddelete { + width: 90%; + margin: 0 auto; +} +#edituser table#suspenddelete td#delete { + width: 50%; + text-align: center; +} +#edituser table#suspenddelete h4 { + margin-top: 0; +} + /* MANAGE USERS > SUSPENDED USERS */ #suspendedlist { diff --git a/htdocs/theme/default/templates/admin/users/edit.tpl b/htdocs/theme/default/templates/admin/users/edit.tpl index 028f753011a1c43a8546875c7ff1db60992907ef..4f1c0bdad7cc93cae037efbb8c5c0c4b1eb0b546 100644 --- a/htdocs/theme/default/templates/admin/users/edit.tpl +++ b/htdocs/theme/default/templates/admin/users/edit.tpl @@ -1,25 +1,51 @@ {include file="header.tpl"} {include file="columnfullstart.tpl"} -
+
+

{$user->firstname} {$user->lastname} ({$user->username})

{if !empty($loginas)}
{$loginas}
{/if} - {if !$suspended} -

{str tag="suspenduser" section="admin"}

- {else} + + {if $suspended} +

{$suspendedby|escape}

{if $user->suspendedreason} -
{str tag="suspendedreason" section="admin"}:
-
{$user->suspendedreason}
+
+
{str tag="suspendedreason" section="admin"}:
+ {$user->suspendedreason|format_whitespace} +
{/if} +
{$suspendform2}
+
{/if} - {$suspendform} +

{str tag="siteaccountsettings" section="admin"}

+

Here you can view and set details for this user account. Below, you can also suspend or delete this account, or change settings for this user in the institutions they are in.

{$siteform} + +
+

Suspend/Delete User

+

Here you may suspend or entirely delete a user account. Suspended users are unable to log in until their account is unsuspended. Please note that while a suspension can be undone, deletion cannot be undone.

+ + + + + +
+

Suspend User

+ {$suspendform} +
+

Delete User

+

Please note that this operation cannot be undone.

+ {$deleteform} +
+ {if ($institutions)} -

{str tag="institutionsettings" section="admin"}

+
+

{str tag="institutionsettings" section="admin"}

+

Here you can change settings regarding this user's membership with institutions in the system.

{$institutionform} {/if}