Commit 3f6fb17d authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

- Implemented "deleting" of institutions

  - i18n for institutions
parent 2d967e15
......@@ -33,12 +33,52 @@ $smarty = smarty();
$institution = param_variable('i', '');
$add = param_boolean('add');
$edit = param_boolean('edit');
$delete = param_boolean('delete');
if ($institution || $add) {
if ($delete) {
function delete_cancel_submit() {
redirect(get_config('wwwroot') . 'admin/institutions.php');
}
function delete_submit($values) {
global $SESSION;
db_begin();
delete_records('institution_locked_profile_field', 'name', $values['i']);
delete_records('institution', 'name', $values['i']);
db_commit();
$SESSION->add_ok_msg(get_string('institutiondeletedsuccessfully', 'admin'));
redirect(get_config('wwwroot') . 'admin/institutions.php');
}
$form = array(
'name' => 'delete',
'elements' => array(
'i' => array(
'type' => 'hidden',
'value' => $institution
),
'delete' => array(
'type' => 'hidden',
'value' => 1
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('yes'), get_string('no'))
)
)
);
$smarty->assign('delete_form', pieform($form));
$smarty->display('admin/institutions.tpl');
exit;
}
if (!$add) {
$data = get_record('institution', 'name', $institution);
$lockedprofilefields = (array)get_column('institution_locked_profile_field', 'profilefield', 'name', $institution);
$lockedprofilefields = (array) get_column('institution_locked_profile_field', 'profilefield', 'name', $institution);
}
else {
$data = new StdClass;
......@@ -52,76 +92,74 @@ if ($institution || $add) {
}
safe_require('artefact', 'internal');
$elements = array();
if ($add) {
$elements['name'] = array(
$elements = array(
'name' => array(
'type' => 'text',
'title' => get_string('institutionname'),
'title' => get_string('institutionname', 'admin'),
'rules' => array(
'required' => true,
'maxlength' => 255,
'regex' => '/^[a-z]+$/'
)
);
$elements['add'] = array(
),
'ignore' => !$add
),
'add' => array(
'type' => 'hidden',
'value' => true
);
}
else {
$elements['i'] = array(
'value' => true,
'ignore' => !$add
),
'i' => array(
'type' => 'hidden',
'value' => $institution
);
}
$elements['displayname'] = array(
'value' => $institution,
'ignore' => $add
),
'displayname' => array(
'type' => 'text',
'title' => get_string('institutiondisplayname'),
'title' => get_string('institutiondisplayname', 'admin'),
'defaultvalue' => $data->displayname,
'rules' => array(
'required' => true,
'maxlength' => 255
)
);
$elements['authplugin'] = array(
),
'authplugin' => array(
'type' => 'select',
'title' => get_string('authplugin'),
'title' => get_string('authplugin', 'admin'),
'options' => get_records_menu('auth_installed', '', '', 'name', 'name, name')
);
$elements['registerallowed'] = array(
),
'registerallowed' => array(
'type' => 'checkbox',
'title' => get_string('registrationallowed'),
'description' => get_string('registrationalloweddescription'),
'title' => get_string('registrationallowed', 'admin'),
'description' => get_string('registrationalloweddescription', 'admin'),
'checked' => $data->registerallowed
);
$elements['defaultaccountlifetime'] = array(
),
'defaultaccountlifetime' => array(
'type' => 'expiry',
'title' => get_string('defaultaccountlifetime'),
'description' => get_string('defaultaccountlifetimedescription'),
'title' => get_string('defaultaccountlifetime', 'admin'),
'description' => get_string('defaultaccountlifetimedescription', 'admin'),
'defaultvalue' => $data->defaultaccountlifetime
);
$elements['defaultaccountinactiveexpire'] = array(
),
'defaultaccountinactiveexpire' => array(
'type' => 'expiry',
'title' => get_string('defaultaccountinactiveexpire'),
'description' => get_string('defaultaccountinactiveexpiredescription'),
'title' => get_string('defaultaccountinactiveexpire', 'admin'),
'description' => get_string('defaultaccountinactiveexpiredescription', 'admin'),
'defaultvalue' => $data->defaultaccountinactiveexpire
);
$elements['defaultaccountinactivewarn'] = array(
),
'defaultaccountinactivewarn' => array(
'type' => 'expiry',
'title' => get_string('defaultaccountinactivewarn'),
'description' => get_string('defaultaccountinactivewarndescription'),
'title' => get_string('defaultaccountinactivewarn', 'admin'),
'description' => get_string('defaultaccountinactivewarndescription', 'admin'),
'defaultvalue' => $data->defaultaccountinactivewarn
);
$elements['lockedfields'] = array(
),
'lockedfields' => array(
'value' => '<tr><th colspan="2">Locked fields</th></tr>'
)
);
foreach (ArtefactTypeProfile::get_all_fields() as $field => $type) {
$elements[$field] = array(
'type' => 'checkbox',
'title' => get_string($field),
'title' => get_string($field, 'artefact.internal'),
'checked' => in_array($field, $lockedprofilefields)
);
}
......@@ -138,7 +176,7 @@ if ($institution || $add) {
}
else {
// Get a list of institutions
$institutions = get_records_sql_array('SELECT i.name, i.displayname, i.authplugin, i.registerallowed, COUNT(u.*)
$institutions = get_records_sql_array('SELECT i.name, i.displayname, i.authplugin, i.registerallowed, COUNT(u.*) AS hasmembers
FROM institution i
LEFT OUTER JOIN usr u ON (u.institution = i.name)
GROUP BY 1, 2, 3, 4
......@@ -185,7 +223,8 @@ function institution_submit($values) {
}
db_commit();
$SESSION->add_ok_msg(get_string('institutionupdatedsuccessfully'));
$message = ($add) ? 'institutionaddedsuccessfully' : 'institutionupdatedsuccessfully';
$SESSION->add_ok_msg(get_string($message, 'admin'));
redirect(get_config('wwwroot') . 'admin/institutions.php');
}
......
......@@ -147,7 +147,21 @@ $string['adminnotifications'] = 'Admin Notifications';
// Suspended Users
$string['suspendedusers'] = 'Suspended Users';
// Authentication
$string['authconfigoptionssaved'] = 'Auth configuration has been saved';
// Institutions
$string['addinstitution'] = 'Add Institution';
$string['authplugin'] = 'Authentication plugin';
$string['defaultaccountinactiveexpire'] = 'Default account expiry time';
$string['defaultaccountinactiveexpiredescription'] = 'How long a user account will remain active without the user logging in';
$string['defaultaccountinactivewarn'] = 'Default account expire warning time';
$string['defaultaccountinactivewarndescription'] = 'The time before user accounts are to expire at which a warning message will be sent to them';
$string['defaultaccountlifetime'] = 'Default account lifetime';
$string['defaultaccountlifetimedescription'] = 'How long accounts will last for by default';
$string['institutionaddedsuccessfully'] = 'Institution added successfully';
$string['institutiondeletedsuccessfully'] = 'Institution deleted successfully';
$string['institutionname'] = 'Institution name';
$string['institutiondisplayname'] = 'Institution display name';
$string['institutionupdatedsuccessfully'] = 'Institution updated successfully';
$string['registrationallowed'] = 'Registration allowed?';
$string['registrationalloweddescription'] = 'Whether users can register for the system with this institution';
?>
......@@ -2,19 +2,24 @@
<h2>AdminInstitutions</h2>
{if $delete_form}
<h3>{str tag="deleteinstitution" section="admin"}</h3>
<p>{str tag="deleteinstitutionconfirm" section="admin"}</p>
{$delete_form}
{else}
{if $institution_form}
{if $add}
<h3>Add Institution</h3>
<h3>{str tag="addinstitution" section="admin"}</h3>
{/if}
{$institution_form}
{else}
<p>Here is a list of all installed institutions.</p>
<table>
<tr>
<th>Institution</th>
<th>Authentication Method</th>
<th>Registration Allowed?</th>
<th>{str tag="institution"}</th>
<th>{str tag="authplugin" section="admin"}</th>
<th>{str tag="registrationallowed" section="admin"}</th>
<th></th>
</tr>
{foreach from=$institutions item=institution}
......@@ -25,8 +30,8 @@
<td>
<form action="" method="post">
<input type="hidden" name="i" value="{$institution->name}">
<input type="submit" name="edit" value="Edit">
{if $institution->candelete}<input type="submit" name="delete" value="Delete">{/if}
<input type="submit" name="edit" value="{str tag="edit"}">
{if !$institution->hasmembers && $institution->name != 'mahara'}<input type="submit" name="delete" value="{str tag="delete"}">{/if}
</form>
</td>
</tr>
......@@ -34,11 +39,12 @@
<tr>
<td colspan="4">
<form action="" method="post">
<input type="submit" name="add" value="Add Institution">
<input type="submit" name="add" value="{str tag="addinstitution" section="admin"}">
</form>
</td>
</tr>
</table>
{/if}
{/if}
{include file="footer.tpl"}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment