Commit 43e25911 authored by Carson Tam's avatar Carson Tam Committed by Francois Marier
Browse files

Implemented custom links for footer menu (bug #809694)



Allow administrators to provide their own links for the following
links in the footer:

terms.php
privacy.php
about.php
contact.php
Signed-off-by: default avatarCarson Tam <carson.tam@ucsf.edu>
Change-Id: I90d2eba97bede9eca55799b1af21ae11cb4444e9
parent 9a2cfb06
......@@ -279,12 +279,22 @@ foreach ($menulist as &$menu) {
$all = footer_menu(true);
$active = get_config('footerlinks');
$active = $active ? unserialize($active) : array_keys($all);
$activeurls = get_config('footercustomlinks');
$activeurls = $activeurls ? unserialize($activeurls) : null;
$footerelements = array();
foreach ($all as $k => $v) {
$footerelements[$k] = array(
'type' => 'checkbox',
'title' => $v['title'],
'defaultvalue' => in_array($k, $active),
'onclick' => "getElement('footerlinks_{$k}_link').disabled = !this.checked;",
);
$footerelements[$k . '_link'] = array(
'type' => 'text',
'size' => 60,
'description' => get_string('footercustomlink', 'admin', $v['url']),
'defaultvalue' => isset($activeurls[$k]) ? $activeurls[$k] : '',
'disabled' => !in_array($k, $active),
);
}
$footerelements['submit'] = array(
......@@ -297,17 +307,29 @@ $footerform = pieform(array(
));
function footerlinks_submit(Pieform $form, $values) {
global $active, $all, $SESSION;
global $active, $activeurls, $all, $SESSION;
$new = array();
$newurls = array();
foreach (array_keys($all) as $k) {
if (!empty($values[$k])) {
$new[] = $k;
}
if (!empty($values[$k.'_link']) &&
($values[$k.'_link'] != $all[$k]['url'])) {
$newurls[$k] = $values[$k.'_link'];
}
}
if ($new != $active) {
set_config('footerlinks', serialize($new));
$SESSION->add_ok_msg(get_string('footerupdated', 'admin'));
}
if ($newurls != $activeurls) {
set_config('footercustomlinks', serialize($newurls));
if ($new == $active) {
// record message in session only if we haven't done so yet.
$SESSION->add_ok_msg(get_string('footerupdated', 'admin'));
}
}
redirect(get_config('wwwroot') . 'admin/site/menu.php');
}
......
......@@ -358,6 +358,7 @@ $string['type'] = 'Type';
$string['footermenu'] = 'Footer Menu';
$string['footermenudescription'] = 'Enable or disable the links in the footer.';
$string['footerupdated'] = 'Footer updated';
$string['footercustomlink'] = 'You can override the default page, <em>%s</em>, by entering a URL here or leave it empty to use the default value.';
// 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.';
......
......@@ -2245,21 +2245,23 @@ function right_nav() {
function footer_menu($all=false) {
$wwwroot = get_config('wwwroot');
$menu = array(
'termsandconditions' => array(
'url' => 'terms.php',
'url' => $wwwroot . 'terms.php',
'title' => get_string('termsandconditions'),
),
'privacystatement' => array(
'url' => 'privacy.php',
'url' => $wwwroot . 'privacy.php',
'title' => get_string('privacystatement'),
),
'about' => array(
'url' => 'about.php',
'url' => $wwwroot . 'about.php',
'title' => get_string('about'),
),
'contactus' => array(
'url' => 'contact.php',
'url' => $wwwroot . 'contact.php',
'title' => get_string('contactus'),
),
);
......@@ -2274,6 +2276,14 @@ function footer_menu($all=false) {
}
}
}
if ($customlinks = get_config('footercustomlinks')) {
$customlinks = unserialize($customlinks);
foreach ($customlinks as $k => $v) {
if (!empty($menu[$k])) {
$menu[$k]['url'] = $v;
}
}
}
return $menu;
}
......
......@@ -24,7 +24,7 @@
displaying them on your site to spread the word! -->
<div id="footernav">
{foreach from=$FOOTERMENU item=item name=footermenu}
{if !$.foreach.footermenu.first}| {/if}<a href="{$WWWROOT}{$item.url}">{$item.title}</a>
{if !$.foreach.footermenu.first}| {/if}<a href="{$item.url}">{$item.title}</a>
{/foreach}
</div>
<!-- there is a div id="performance-info" wrapping this -->{mahara_performance_info}
......
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