Commit edd88967 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow admins to enable/disable footer links


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 22195310
......@@ -33,7 +33,8 @@ define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'sitemenu');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('linksandresourcesmenu', 'admin'));
require_once('pieforms/pieform.php');
define('TITLE', get_string('menus', 'admin'));
$strings = array('edit','delete','update','cancel','add','name','unknownerror');
$adminstrings = array('confirmdeletemenuitem', 'deletefailed','deletingmenuitem','savingmenuitem',
......@@ -273,11 +274,50 @@ foreach ($menulist as &$menu) {
'name' => get_string($menu,'admin'));
}
// Edit form for footer links
$all = footer_menu(true);
$active = get_config('footerlinks');
$active = $active ? unserialize($active) : array_keys($all);
$footerelements = array();
foreach ($all as $k => $v) {
$footerelements[$k] = array(
'type' => 'checkbox',
'title' => $v['title'],
'defaultvalue' => in_array($k, $active),
);
}
$footerelements['submit'] = array(
'type' => 'submit',
'value' => get_string('savechanges', 'admin')
);
$footerform = pieform(array(
'name' => 'footerlinks',
'elements' => $footerelements,
));
function footerlinks_submit(Pieform $form, $values) {
global $active, $all, $SESSION;
$new = array();
foreach (array_keys($all) as $k) {
if (!empty($values[$k])) {
$new[] = $k;
}
}
if ($new != $active) {
set_config('footerlinks', serialize($new));
$SESSION->add_ok_msg(get_string('footerupdated', 'admin'));
}
redirect(get_config('wwwroot') . 'admin/site/menu.php');
}
$smarty = smarty();
$smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->assign('MENUS', $menulist);
$smarty->assign('descriptionstrargs', array('<a href="' . get_config('wwwroot') . 'artefact/file/sitefiles.php">', '</a>'));
$smarty->assign('PAGEHEADING', hsc(get_string('linksandresourcesmenu', 'admin')));
$smarty->assign('footerform', $footerform);
$smarty->display('admin/site/menu.tpl');
?>
......@@ -75,8 +75,8 @@ $string['siteoptions'] = 'Site options';
$string['siteoptionsdescription'] = 'Configure basic site options such as the name, language and theme';
$string['editsitepages'] = 'Edit site pages';
$string['editsitepagesdescription'] = 'Edit the content of various pages around the site';
$string['linksandresourcesmenu'] = 'Links and Resources Menu';
$string['linksandresourcesmenudescription'] = 'Manage the links and files within the Links and Resources Menu';
$string['menus'] = 'Menus';
$string['menusdescription'] = 'Manage the links and files within the Links and Resources and Footer Menus';
$string['sitefiles'] = 'Site Files';
$string['sitefilesdescription'] = 'Upload and administer files that can be put in the Links and Resources Menu and in Site Views';
$string['siteviews'] = 'Site Views';
......@@ -285,8 +285,9 @@ $string['confirmdeletemenuitem'] = 'Do you really want to delete this item?';
$string['deletingmenuitem'] = 'Deleting item';
$string['deletefailed'] = 'Failed deleting item';
$string['externallink'] = 'External link';
$string['editmenus'] = 'Edit links and resources';
$string['editlinksandresources'] = 'Edit links and resources';
$string['linkedto'] = 'Linked to';
$string['linksandresourcesmenu'] = 'Links and Resources Menu';
$string['linksandresourcesmenupagedescription'] = 'The Links and Resources Menu appears to all users on most pages. You can add links to other websites and to files uploaded to the %sAdmin Files%s section.';
$string['loadingmenuitems'] = 'Loading items';
$string['loadmenuitemsfailed'] = 'Failed to load items';
......@@ -300,6 +301,9 @@ $string['nositefiles'] = 'No site files available';
$string['public'] = 'public';
$string['savingmenuitem'] = 'Saving item';
$string['type'] = 'Type';
$string['footermenu'] = 'Footer Menu';
$string['footermenudescription'] = 'Enable or disable the links in the footer.';
$string['footerupdated'] = 'Footer updated';
// Admin Files
$string['adminfilespagedescription'] = 'Here you can upload files that can be included in the %sLinks and Resources Menu%s. Files in the home directory will be able to be added to the logged in menu, while files in the public directory will be able to be added to the public menu.';
......
......@@ -685,6 +685,7 @@ function core_install_firstcoredata_defaults() {
set_config('anonymouscomments', 1);
set_config('homepageinfo', 1);
set_config('showonlineuserssideblock', 1);
set_config('footerlinks', serialize(array('privacystatement', 'about', 'contactus')));
// install the applications
$app = new StdClass;
......
......@@ -1648,7 +1648,7 @@ function admin_nav() {
array(
'path' => 'configsite/sitemenu',
'url' => 'admin/site/menu.php',
'title' => get_string('linksandresourcesmenu', 'admin'),
'title' => get_string('menus', 'admin'),
'weight' => 30,
),
array(
......@@ -2030,7 +2030,7 @@ function right_nav() {
}
function footer_menu() {
function footer_menu($all=false) {
$menu = array(
'termsandconditions' => array(
'url' => 'terms.php',
......@@ -2049,9 +2049,15 @@ function footer_menu() {
'title' => get_string('contactus'),
),
);
if ($disabled = get_config('hidefooterlinks')) {
foreach (split(',', $disabled) as $k) {
unset($menu[$k]);
if ($all) {
return $menu;
}
if ($enabled = get_config('footerlinks')) {
$enabled = unserialize($enabled);
foreach ($menu as $k => $v) {
if (!in_array($k, $enabled)) {
unset($menu[$k]);
}
}
}
return $menu;
......
......@@ -64,7 +64,7 @@
<ul>
<li><strong><a href="{$WWWROOT}admin/site/options.php">{str tag=siteoptions section=admin}</a></strong> - {str tag=siteoptionsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/pages.php">{str tag=editsitepages section=admin}</a></strong> - {str tag=editsitepagesdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/menu.php">{str tag=linksandresourcesmenu section=admin}</a></strong> - {str tag=linksandresourcesmenudescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/menu.php">{str tag=menus section=admin}</a></strong> - {str tag=menusdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/networking.php">{str tag=networking section=admin}</a></strong> - {str tag=networkingdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}admin/site/views.php">{str tag=siteviews section=admin}</a></strong> - {str tag=siteviewsdescription section=admin}</li>
<li><strong><a href="{$WWWROOT}artefact/file/sitefiles.php">{str tag=sitefiles section=admin}</a></strong> - {str tag=sitefilesdescription section=admin}</li>
......
......@@ -17,5 +17,9 @@
</div>
<h1>{str tag=footermenu section=admin}</h1>
<p>{str tag=footermenudescription section=admin}</p>
{$footerform}
{include file="footer.tpl"}
{/auto_escape}
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