Commit cd08104c authored by Robert Lyon's avatar Robert Lyon

Drop-down navigation overridden at institutional level (Bug #1194672)

Create the ability for Institutions to override the site default for
displaying drop-down navigation instead of tabs for main menu.

Can now: Set drop-down navigation option on Administer institutions
screen /admin/users/institutions.php

Users who are in more than one institution will have drop-down setting
of the institution whose theme they are using as their theme.

If $cfg->sitethemeprefs = true, where a user can pick any theme then
for those themes associated with an institution they will use the
institution's setting otherwise they will use the site's setting for
drop-down navigation.

Can not do: Have user make their own choice for whether they see drop
down or not for any particular theme

Change-Id: I580953c62b35cbc8169d47781c8bf88cc94d9fe8
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent e0bf4ff4
......@@ -248,6 +248,7 @@ if ($institution || $add) {
$data->allowinstitutionpublicviews = get_config('allowpublicviews') ? 1 : 0;
$data->licensemandatory = 0;
$data->licensedefault = '';
$data->dropdownmenu = get_config('dropdownmenu') ? 1 : 0;
$lockedprofilefields = array();
$authtypes = auth_get_available_auth_types();
......@@ -387,6 +388,13 @@ if ($institution || $add) {
'options' => $themeoptions,
'help' => true,
);
$elements['dropdownmenu'] = array(
'type' => 'checkbox',
'title' => get_string('dropdownmenu', 'admin'),
'description' => get_string('dropdownmenudescriptioninstitution','admin'),
'defaultvalue' => $data->dropdownmenu,
'help' => true,
);
$elements['customthemefs'] = array(
'type' => 'fieldset',
'class' => 'customtheme' . ($elements['theme']['defaultvalue'] != 'custom' ? ' js-hidden' : ''),
......@@ -639,6 +647,7 @@ function institution_submit(Pieform $form, $values) {
$newinstitution->registerconfirm = ($values['registerconfirm']) ? 1 : 0;
}
$newinstitution->theme = (empty($values['theme']) || $values['theme'] == 'sitedefault') ? null : $values['theme'];
$newinstitution->dropdownmenu = ($values['dropdownmenu']) ? 1 : 0;
if ($newinstitution->theme == 'custom') {
if (!empty($oldinstitution->style)) {
......
......@@ -305,6 +305,7 @@ $string['antispam'] = 'Anti-spam';
$string['antispamdescription'] = 'The type of anti-spam measures used on publicly visible forms';
$string['dropdownmenu'] = 'Drop-down navigation';
$string['dropdownmenudescription'] = 'If checked, the main Mahara navigation will use a drop-down format for the sub-navigation.';
$string['dropdownmenudescriptioninstitution'] = 'If checked, the main navigation for the chosen institution theme will use a drop-down format.';
$string['defaultaccountinactiveexpire'] = 'Default account inactivity time';
$string['defaultaccountinactiveexpiredescription'] = 'How long a user account will remain active without the user logging in';
$string['defaultaccountinactivewarn'] = 'Warning time for inactivity / expiry';
......
<h3>Drop-down navigation</h3>
<p>The drop-down menu navigation chosen here only influences the theme
for <strong>this institution</strong>. If users can choose their own
theme on the site, the settings on these will determine if users see a
drop-down menu or tabs.</p>
<p>Site-wide themes take on the <strong>site settings</strong>, and if
a user can choose <strong>another institution theme</strong>, the settings there decide whether the
navigation happens via a drop-down menu or tabs.</p>
\ No newline at end of file
......@@ -79,6 +79,7 @@
<FIELD NAME="style" TYPE="int" LENGTH="10" NOTNULL="false"/>
<FIELD NAME="licensemandatory" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0"/>
<FIELD NAME="licensedefault" TYPE="char" LENGTH="255" NOTNULL="false"/>
<FIELD NAME="dropdownmenu" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="name" />
......
......@@ -3206,5 +3206,12 @@ function xmldb_core_upgrade($oldversion=0) {
create_table($table);
}
if ($oldversion < 2013062600) {
$table = new XMLDBTable('institution');
$field = new XMLDBField('dropdownmenu');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
}
return $status;
}
......@@ -1541,7 +1541,7 @@ function load_user_institutions($userid) {
throw new InvalidArgumentException("couldn't load institutions, no user id specified");
}
if ($institutions = get_records_sql_assoc('
SELECT u.institution,'.db_format_tsfield('ctime').','.db_format_tsfield('u.expiry', 'membership_expiry').',u.studentid,u.staff,u.admin,i.displayname,i.theme,i.registerallowed, i.showonlineusers,i.allowinstitutionpublicviews, i.logo, i.style, i.licensemandatory, i.licensedefault
SELECT u.institution,'.db_format_tsfield('ctime').','.db_format_tsfield('u.expiry', 'membership_expiry').',u.studentid,u.staff,u.admin,i.displayname,i.theme,i.registerallowed, i.showonlineusers,i.allowinstitutionpublicviews, i.logo, i.style, i.licensemandatory, i.licensedefault, i.dropdownmenu
FROM {usr_institution} u INNER JOIN {institution} i ON u.institution = i.name
WHERE u.usr = ? ORDER BY i.priority DESC', array($userid))) {
return $institutions;
......
......@@ -30,7 +30,9 @@ defined('INTERNAL') || die();
$config = new StdClass;
// See https://wiki.mahara.org/index.php/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2013050700;
$config->version = 2013062600;
$config->release = '1.8.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -410,8 +410,29 @@ EOF;
$smarty->assign('THEMELIST', json_encode(array_merge((array)json_decode($smarty->get_template_vars('THEMELIST')), $theme_list)));
}
// disable drop-downs if a handheld device detected
$dropdownmenu = $SESSION->get('handheld_device') ? false : get_config('dropdownmenu');
$dropdownmenu = get_config('dropdownmenu');
// disable drop-downs if overridden at institution level
$sitethemeprefs = get_config('sitethemeprefs');
$institutions = $USER->institutions;
if (!empty($institutions)) {
foreach ($institutions as $i) {
if (!empty($sitethemeprefs)) {
if (!empty($USER->accountprefs['theme']) && $USER->accountprefs['theme'] == $THEME->basename . '/' . $i->institution) {
$dropdownmenu = $i->dropdownmenu;
}
}
else {
if ((!empty($USER->accountprefs['theme']) && $USER->accountprefs['theme'] == $THEME->basename . '/' . $i->institution)
|| (empty($USER->accountprefs) && $i->theme == $THEME->basename && $USER->institutiontheme->institutionname == $i->institution)) {
$dropdownmenu = $i->dropdownmenu;
}
}
}
}
// and/or disable drop-downs if a handheld device detected
$dropdownmenu = $SESSION->get('handheld_device') ? false : $dropdownmenu;
if ($dropdownmenu) {
$smarty->assign('DROPDOWNMENU', $dropdownmenu);
}
......
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