Commit 08749b8b authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Changes to Group Category admin area:


- Move group config options back to site options
- Remove search plugin option & search fieldset
- Move group category management to a group categories page (still to be placed in menu)
- Don't display 'item saved' every time a category is added or edited
Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 8f06c8b2
...@@ -36,10 +36,10 @@ json_headers(); ...@@ -36,10 +36,10 @@ json_headers();
$itemid = param_integer('itemid'); $itemid = param_integer('itemid');
//first update all records that use this group id //first update all records that use this group id
$groups = get_records_assoc('group', 'groupcategory', $itemid); $groups = get_records_assoc('group', 'category', $itemid);
if (!empty($groups)) { if (!empty($groups)) {
foreach ($groups as $group) { foreach ($groups as $group) {
$group->groupcategory = 0; $group->groupcategory = null;
update_record('group', $group); update_record('group', $group);
} }
} }
......
...@@ -31,8 +31,6 @@ define('JSON', 1); ...@@ -31,8 +31,6 @@ define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php'); require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$public = (int) param_boolean('public');
$result = array(); $result = array();
$groupcategories = get_records_array('group_category','','','displayorder'); $groupcategories = get_records_array('group_category','','','displayorder');
......
...@@ -35,6 +35,11 @@ define('SECTION_PAGE', 'groups'); ...@@ -35,6 +35,11 @@ define('SECTION_PAGE', 'groups');
require(dirname(dirname(dirname(__FILE__))) . '/init.php'); require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('groups', 'admin')); define('TITLE', get_string('groups', 'admin'));
if (!get_config('allowgroupcategories')) {
$SESSION->add_error_msg(get_string('groupcategoriesnotenabled', 'admin'));
redirect(get_config('wwwroot') . 'admin');
}
$strings = array('edit','delete','update','cancel','add','name','unknownerror'); $strings = array('edit','delete','update','cancel','add','name','unknownerror');
$adminstrings = array('confirmdeletecategory', 'deletefailed'); $adminstrings = array('confirmdeletecategory', 'deletefailed');
foreach ($strings as $string) { foreach ($strings as $string) {
...@@ -43,65 +48,7 @@ foreach ($strings as $string) { ...@@ -43,65 +48,7 @@ foreach ($strings as $string) {
foreach ($adminstrings as $string) { foreach ($adminstrings as $string) {
$getstring[$string] = json_encode(get_string($string, 'admin')); $getstring[$string] = json_encode(get_string($string, 'admin'));
} }
//set up initial pieform
$groupoptionform = array(
'name' => 'groupoptions',
'renderer' => 'table',
'plugintype' => 'core',
'pluginname' => 'admin',
'elements' => array(
'creategroups' => array(
'type' => 'select',
'title' => get_string('whocancreategroups', 'admin'),
'description' => get_string('whocancreategroupsdescription', 'admin'),
'defaultvalue' => get_config('creategroups'),
'options' => array(
'admins' => get_string('adminsonly', 'admin'),
'staff' => get_string('adminsandstaffonly', 'admin'),
'all' => get_string('Everyone', 'admin'),
),
),
'createpublicgroups' => array(
'type' => 'select',
'title' => get_string('whocancreatepublicgroups', 'admin'),
'description' => get_string('whocancreatepublicgroupsdescription', 'admin'),
'defaultvalue' => get_config('createpublicgroups'),
'options' => array(
'admins' => get_string('adminsonly', 'admin'),
'all' => get_string('Everyone', 'admin'),
),
'help' => true,
),
'allowgroupcategories' => array(
'type' => 'select',
'title' => get_string('allowgroupcategories', 'admin'),
'description' => get_string('allowgroupcategoriesdescription', 'admin'),
'defaultvalue' => get_config('allowgroupcategories'),
'options' => array(true => get_string('yes'), false => get_string('no')),
'help' => true,
),
)
);
$groupoptionform['elements']['submit'] = array(
'type' => 'submit',
'value' => get_string('updatesiteoptions', 'admin')
);
$groupoptionform = pieform($groupoptionform);
function groupoptions_submit(Pieform $form, $values) {
global $SESSION;
$fields = array('creategroups', 'createpublicgroups', 'allowgroupcategories');
foreach ($fields as $field) {
if (!set_config($field, $values[$field])) {
siteoptions_fail($form, $field);
}
}
$SESSION->add_ok_msg(get_string('groupoptionsset', 'group'));
redirect(get_config('wwwroot') . 'admin/site/groups.php');
}
if (get_config('allowgroupcategories')) {
$thead = array(json_encode(get_string('name', 'admin')), '""'); $thead = array(json_encode(get_string('name', 'admin')), '""');
$ijs = "var thead = TR(null,map(partial(TH,null),[" . implode($thead,",") . "]));\n"; $ijs = "var thead = TR(null,map(partial(TH,null),[" . implode($thead,",") . "]));\n";
...@@ -133,7 +80,7 @@ function formatrow (item) { ...@@ -133,7 +80,7 @@ function formatrow (item) {
partial(TD,null), partial(TD,null),
[ [
item.name, item.name,
[del,edit,contextualHelpIcon(null, null, 'core', 'admin', null, 'adminmenuedit')] [del,edit]
] ]
); );
return TR({'id':'menuitem_'+item.id},cells); return TR({'id':'menuitem_'+item.id},cells);
...@@ -156,11 +103,6 @@ function editform(item) { ...@@ -156,11 +103,6 @@ function editform(item) {
connect(save, 'onclick', function () { saveitem(item.id); }); connect(save, 'onclick', function () { saveitem(item.id); });
var rowtype = 'add'; var rowtype = 'add';
if (!item) {
// This is the 'add' form rather than the edit form
// Set defaults.
item = {'type':'externallist'};
}
if (!item.name) { if (!item.name) {
item.name = ''; item.name = '';
// The save button says 'add', and there's no cancel button. // The save button says 'add', and there's no cancel button.
...@@ -191,8 +133,8 @@ function closeopenedits() { ...@@ -191,8 +133,8 @@ function closeopenedits() {
if (hasElementClass(rows[i],'edit')) { if (hasElementClass(rows[i],'edit')) {
removeElement(rows[i]); removeElement(rows[i]);
} }
else if (hasElementClass(rows[i],'invisible')) { else if (hasElementClass(rows[i],'hidden')) {
removeElementClass(rows[i],'invisible'); removeElementClass(rows[i],'hidden');
} }
} }
} }
...@@ -201,7 +143,7 @@ function closeopenedits() { ...@@ -201,7 +143,7 @@ function closeopenedits() {
function edititem(item) { function edititem(item) {
closeopenedits(); closeopenedits();
var menuitem = $('menuitem_'+item.id); var menuitem = $('menuitem_'+item.id);
addElementClass(menuitem,'invisible'); addElementClass(menuitem,'hidden');
var newrow = editform(item); var newrow = editform(item);
insertSiblingNodesBefore(menuitem, newrow); insertSiblingNodesBefore(menuitem, newrow);
} }
...@@ -233,16 +175,10 @@ addLoadEvent(function () { ...@@ -233,16 +175,10 @@ addLoadEvent(function () {
getitems(); getitems();
}); });
EOJS; EOJS;
}
$style = '<style type="text/css">.invisible{display:none;}</style>';
$smarty = smarty(array('groupoptions'), array($style));
$smarty->assign('PAGEHEADING', hsc(get_string('groups', 'admin')));
$smarty->assign('groupoptionform', $groupoptionform);
if (get_config('allowgroupcategories')) {
$smarty->assign('grouptitle', get_string('groupsdescription', 'admin'));
$smarty->assign('INLINEJAVASCRIPT', $ijs);
}
$smarty->display('admin/site/groups.tpl'); $smarty = smarty(array('groupoptions'));
$smarty->assign('PAGEHEADING', hsc(get_string('groupcategories', 'admin')));
$smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->display('admin/site/groupcategories.tpl');
?> ?>
\ No newline at end of file
...@@ -154,7 +154,7 @@ $siteoptionform = array( ...@@ -154,7 +154,7 @@ $siteoptionform = array(
), ),
), ),
), ),
'searchsettings' => array( /* 'searchsettings' => array(
'type' => 'fieldset', 'type' => 'fieldset',
'collapsible' => true, 'collapsible' => true,
'collapsed' => true, 'collapsed' => true,
...@@ -170,12 +170,43 @@ $siteoptionform = array( ...@@ -170,12 +170,43 @@ $siteoptionform = array(
'help' => true, 'help' => true,
'disabled' => in_array('searchplugin', $OVERRIDDEN), 'disabled' => in_array('searchplugin', $OVERRIDDEN),
), ),
'showselfsearchsideblock' => array( ),
'type' => 'checkbox', ),*/
'title' => get_string('showselfsearchsideblock', 'admin'), 'groupsettings' => array(
'description' => get_string('showselfsearchsideblockdescription', 'admin'), 'type' => 'fieldset',
'defaultvalue' => get_config('showselfsearchsideblock'), 'collapsible' => true,
'disabled' => in_array('showselfsearchsideblock', $OVERRIDDEN), 'collapsed' => true,
'legend' => get_string('groupsettingslegend', 'admin'),
'elements' => array(
'creategroups' => array(
'type' => 'select',
'title' => get_string('whocancreategroups', 'admin'),
'description' => get_string('whocancreategroupsdescription', 'admin'),
'defaultvalue' => get_config('creategroups'),
'options' => array(
'admins' => get_string('adminsonly', 'admin'),
'staff' => get_string('adminsandstaffonly', 'admin'),
'all' => get_string('Everyone', 'admin'),
),
),
'createpublicgroups' => array(
'type' => 'select',
'title' => get_string('whocancreatepublicgroups', 'admin'),
'description' => get_string('whocancreatepublicgroupsdescription', 'admin'),
'defaultvalue' => get_config('createpublicgroups'),
'options' => array(
'admins' => get_string('adminsonly', 'admin'),
'all' => get_string('Everyone', 'admin'),
),
'help' => true,
),
'allowgroupcategories' => array(
'type' => 'select',
'title' => get_string('allowgroupcategories', 'admin'),
'description' => get_string('allowgroupcategoriesdescription', 'admin'),
'defaultvalue' => get_config('allowgroupcategories'),
'options' => array(true => get_string('yes'), false => get_string('no')),
'help' => true,
), ),
), ),
), ),
...@@ -326,6 +357,13 @@ $siteoptionform = array( ...@@ -326,6 +357,13 @@ $siteoptionform = array(
'help' => true, 'help' => true,
'disabled' => in_array('allowpublicprofiles', $OVERRIDDEN), 'disabled' => in_array('allowpublicprofiles', $OVERRIDDEN),
), ),
'showselfsearchsideblock' => array(
'type' => 'checkbox',
'title' => get_string('showselfsearchsideblock', 'admin'),
'description' => get_string('showselfsearchsideblockdescription', 'admin'),
'defaultvalue' => get_config('showselfsearchsideblock'),
'disabled' => in_array('showselfsearchsideblock', $OVERRIDDEN),
),
'showtagssideblock' => array( 'showtagssideblock' => array(
'type' => 'checkbox', 'type' => 'checkbox',
'title' => get_string('showtagssideblock', 'admin'), 'title' => get_string('showtagssideblock', 'admin'),
...@@ -386,12 +424,13 @@ function siteoptions_submit(Pieform $form, $values) { ...@@ -386,12 +424,13 @@ function siteoptions_submit(Pieform $form, $values) {
$fields = array( $fields = array(
'sitename','lang','theme', 'pathtoclam', 'sitename','lang','theme', 'pathtoclam',
'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn', 'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'allowpublicviews', 'allowpublicprofiles', 'searchplugin', 'allowpublicviews', 'allowpublicprofiles',
'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend', 'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend',
'showselfsearchsideblock', 'showtagssideblock', 'showselfsearchsideblock', 'showtagssideblock',
'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes', 'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes',
'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments', 'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments',
'homepageinfo', 'showonlineuserssideblock', 'registerterms', 'homepageinfo', 'showonlineuserssideblock', 'registerterms',
'creategroups', 'createpublicgroups', 'allowgroupcategories',
); );
$oldlanguage = get_config('lang'); $oldlanguage = get_config('lang');
$oldtheme = get_config('theme'); $oldtheme = get_config('theme');
......
...@@ -65,6 +65,6 @@ else { ...@@ -65,6 +65,6 @@ else {
} }
} }
json_reply(false,get_string('menuitemsaved','admin')); json_reply(false, null);
?> ?>
...@@ -116,6 +116,8 @@ $string['htmlfiltersdescription'] = 'Enable new filters for HTML Purifier'; ...@@ -116,6 +116,8 @@ $string['htmlfiltersdescription'] = 'Enable new filters for HTML Purifier';
$string['newfiltersdescription'] = 'If you have downloaded a new set of HTML filters, you can install them by unzipping the file into the folder %s and then clicking the button below'; $string['newfiltersdescription'] = 'If you have downloaded a new set of HTML filters, you can install them by unzipping the file into the folder %s and then clicking the button below';
$string['filtersinstalled'] = 'Filters installed.'; $string['filtersinstalled'] = 'Filters installed.';
$string['nofiltersinstalled'] = 'No html filters installed.'; $string['nofiltersinstalled'] = 'No html filters installed.';
$string['groupcategories'] ='Group Categories';
$string['allowgroupcategories'] ='Allow Group Categories'; $string['allowgroupcategories'] ='Allow Group Categories';
$string['allowgroupcategoriesdescription'] ='If set to yes, admins will be able to create categories for users to assign their groups'; $string['allowgroupcategoriesdescription'] ='If set to yes, admins will be able to create categories for users to assign their groups';
$string['groupoptionsset'] = 'Group options have been updated.'; $string['groupoptionsset'] = 'Group options have been updated.';
...@@ -666,6 +668,7 @@ $string['Advanced'] = 'Advanced'; ...@@ -666,6 +668,7 @@ $string['Advanced'] = 'Advanced';
//admin option fieldset legends //admin option fieldset legends
$string['sitesettingslegend'] = 'Site Settings'; $string['sitesettingslegend'] = 'Site Settings';
$string['usersettingslegend'] = 'User Settings'; $string['usersettingslegend'] = 'User Settings';
$string['groupsettingslegend'] = 'Group Settings';
$string['searchsettingslegend'] = 'Search Settings'; $string['searchsettingslegend'] = 'Search Settings';
$string['institutionsettingslegend'] = 'Institution Settings'; $string['institutionsettingslegend'] = 'Institution Settings';
$string['accountsettingslegend'] = 'Account Settings'; $string['accountsettingslegend'] = 'Account Settings';
......
...@@ -1645,12 +1645,6 @@ function admin_nav() { ...@@ -1645,12 +1645,6 @@ function admin_nav() {
'title' => get_string('editsitepages', 'admin'), 'title' => get_string('editsitepages', 'admin'),
'weight' => 20 'weight' => 20
), ),
array(
'path' => 'configsite/groups',
'url' => 'admin/site/groups.php',
'title' => get_string('groups', 'admin'),
'weight' => 25,
),
array( array(
'path' => 'configsite/sitemenu', 'path' => 'configsite/sitemenu',
'url' => 'admin/site/menu.php', 'url' => 'admin/site/menu.php',
......
{auto_escape off} {auto_escape off}
{include file="header.tpl"} {include file="header.tpl"}
{$groupoptionform}
<p>{$grouptitle}</p>
<div id="editmenus"> <div id="editmenus">
<div id="menuitemlist"></div> <div id="menuitemlist"></div>
</div> </div>
......
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