From e295df447f46e397c855a692d5f87853d006ef8e Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Fri, 17 Aug 2007 11:18:58 +0000 Subject: [PATCH] MDL-10870 All files updated to new build_navigation() method. --- .../edit_field_save/edit_field_save.class.php | 11 +- .../edit_index_save/edit_index_save.class.php | 8 +- .../edit_key_save/edit_key_save.class.php | 9 +- .../edit_sentence_save.class.php | 8 +- .../edit_table_save/edit_table_save.class.php | 8 +- auth/cas/auth.php | 42 ++++---- auth/email/auth.php | 6 +- auth/ldap/auth.php | 36 ++++--- backup/backup.php | 24 +++-- backup/lib.php | 8 +- backup/log.php | 32 +++--- backup/restore.php | 36 ++++--- blog/edit.php | 15 +-- blog/edit_form.php | 4 +- blog/header.php | 102 +++++++++++++----- calendar/event.php | 35 +++--- calendar/event_select.html | 88 +++++++++------ calendar/export.php | 11 +- calendar/export_basic.html | 10 +- calendar/lib.php | 76 +++++++------ calendar/view.php | 18 ++-- course/category.php | 65 +++++------ course/delete.php | 32 +++--- 23 files changed, 417 insertions(+), 267 deletions(-) diff --git a/admin/xmldb/actions/edit_field_save/edit_field_save.class.php b/admin/xmldb/actions/edit_field_save/edit_field_save.class.php index 91f7196e41..35c967f6cf 100644 --- a/admin/xmldb/actions/edit_field_save/edit_field_save.class.php +++ b/admin/xmldb/actions/edit_field_save/edit_field_save.class.php @@ -283,12 +283,15 @@ class edit_field_save extends XMLDBAction { $tempfield->setDefault($default); /// Prepare the output $site = get_site(); - print_header("$site->shortname: XMLDB", - "$site->fullname", - "" . $this->str['administration'] . " -> XMLDB"); + $navlinks = array(); + $navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc'); + $navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$site->shortname: XMLDB", "$site->fullname", $navigation); notice ('

' .implode(', ', $errors) . '

' . $tempfield->readableInfo(), - 'index.php?action=edit_field&field=' .$field->getName() . '&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); + 'index.php?action=edit_field&field=' .$field->getName() . '&table=' . $table->getName() + . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); die; /// re-die :-P } diff --git a/admin/xmldb/actions/edit_index_save/edit_index_save.class.php b/admin/xmldb/actions/edit_index_save/edit_index_save.class.php index 8fd2e3b5dc..78bd325817 100644 --- a/admin/xmldb/actions/edit_index_save/edit_index_save.class.php +++ b/admin/xmldb/actions/edit_index_save/edit_index_save.class.php @@ -164,9 +164,11 @@ class edit_index_save extends XMLDBAction { $tempindex->setFields($fieldsarr); /// Prepare the output $site = get_site(); - print_header("$site->shortname: XMLDB", - "$site->fullname", - "" . $this->str['administration'] . " -> XMLDB"); + $navlinks = array(); + $navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc'); + $navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$site->shortname: XMLDB", "$site->fullname", $navigation); notice ('

' .implode(', ', $errors) . '

' . $tempindex->readableInfo(), 'index.php?action=edit_index&index=' .$index->getName() . '&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); diff --git a/admin/xmldb/actions/edit_key_save/edit_key_save.class.php b/admin/xmldb/actions/edit_key_save/edit_key_save.class.php index ec663af822..3fbc846e59 100644 --- a/admin/xmldb/actions/edit_key_save/edit_key_save.class.php +++ b/admin/xmldb/actions/edit_key_save/edit_key_save.class.php @@ -240,9 +240,12 @@ class edit_key_save extends XMLDBAction { } /// Prepare the output $site = get_site(); - print_header("$site->shortname: XMLDB", - "$site->fullname", - "" . $this->str['administration'] . " -> XMLDB"); + $navlinks = array(); + $navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc'); + $navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$site->shortname: XMLDB", "$site->fullname", $navigation); + notice ('

' .implode(', ', $errors) . '

' . $tempkey->readableInfo(), 'index.php?action=edit_key&key=' .$key->getName() . '&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); diff --git a/admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php b/admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php index 426b6d72bc..7c44ecd833 100644 --- a/admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php +++ b/admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php @@ -120,9 +120,11 @@ class edit_sentence_save extends XMLDBAction { if (!empty($errors)) { /// Prepare the output $site = get_site(); - print_header("$site->shortname: XMLDB", - "$site->fullname", - "" . $this->str['administration'] . " -> XMLDB"); + $navlinks = array(); + $navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc'); + $navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$site->shortname: XMLDB", "$site->fullname", $navigation); notice ('

' .implode(', ', $errors) . '

' . s($sentence), 'index.php?action=edit_sentence&sentence=' .$sentenceparam . '&statement=' . urlencode($statementparam) . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); diff --git a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php index e398b011c5..d2b1763af5 100644 --- a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php +++ b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php @@ -102,9 +102,11 @@ class edit_table_save extends XMLDBAction { $temptable = new XMLDBTable($name); /// Prepare the output $site = get_site(); - print_header("$site->shortname: XMLDB", - "$site->fullname", - "" . $this->str['administration'] . " -> XMLDB"); + $navlinks = array(); + $navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc'); + $navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$site->shortname: XMLDB", "$site->fullname", $navigation); notice ('

' .implode(', ', $errors) . '

' . $temptable->readableInfo(), 'index.php?action=edit_table&table=' . $tableparam . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath))); diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 5188d3f532..43faed08a9 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -48,7 +48,7 @@ class auth_plugin_cas extends auth_plugin_base { } } /** - * Authenticates user againt CAS + * Authenticates user againt CAS * Returns true if the username and password work and false if they are * wrong or don't exist. * @@ -94,7 +94,7 @@ class auth_plugin_cas extends auth_plugin_base { if (!empty($username)) { if (strstr($SESSION->wantsurl,'ticket') || strstr($SESSION->wantsurl,'NOCAS')) unset($SESSION->wantsurl); - return; + return; } // Test si cas activé et paramêtres non remplis @@ -105,25 +105,29 @@ class auth_plugin_cas extends auth_plugin_base { // Connection to CAS server $this->connectCAS(); - // Gestion de la connection CAS si accès direct d'un ent ou autre + // Gestion de la connection CAS si accès direct d'un ent ou autre if (phpCAS::checkAuthentication()) { $frm->username=phpCAS::getUser(); // if (phpCAS::getUser()=='esup9992') // $frm->username='erhar0062'; - $frm->password="passwdCas"; + $frm->password="passwdCas"; return; } - + if ($this->config->multiauth) { $authCAS = optional_param("authCAS"); - if ($authCAS=="NOCAS") + if ($authCAS=="NOCAS") return; - + // choice authentication form for multi-authentication // test pgtIou parameter for proxy mode (https connection // in background from CAS server to the php server) if ($authCAS!="CAS" && !isset($_GET["pgtIou"])) { - print_header("$site->fullname: $CASform", $site->fullname, $CASform); + $navlinks = array(); + $navlinks[] = array('name' => $CASform, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$site->fullname: $CASform", $site->fullname, $navigation); include($CFG->dirroot."/auth/cas/cas_form.html"); print_footer(); exit(); @@ -134,7 +138,7 @@ class auth_plugin_cas extends auth_plugin_base { {phpCAS::forceAuthentication();} } /** - * logout from the cas + * logout from the cas * * This function is called from admin/auth.php * @@ -144,11 +148,11 @@ class auth_plugin_cas extends auth_plugin_base { if ($this->config->logoutcas ) { $backurl = $CFG->wwwroot; $this->connectCAS(); - phpCAS::logout($backurl); + phpCAS::logout($backurl); } } /** - * Connect to the cas (clientcas connection or proxycas connection + * Connect to the cas (clientcas connection or proxycas connection * * This function is called from admin/auth.php * @@ -209,19 +213,19 @@ if ( !is_object($PHPCAS_CLIENT) ) { function process_config($config) { // set to defaults if undefined // CAS settings - if (!isset ($config->hostname)) + if (!isset ($config->hostname)) $config->hostname = ''; - if (!isset ($config->port)) + if (!isset ($config->port)) $config->port = ''; - if (!isset ($config->casversion)) + if (!isset ($config->casversion)) $config->casversion = ''; - if (!isset ($config->baseuri)) + if (!isset ($config->baseuri)) $config->baseuri = ''; - if (!isset ($config->language)) + if (!isset ($config->language)) $config->language = ''; - if (!isset ($config->proxycas)) + if (!isset ($config->proxycas)) $config->proxycas = ''; - if (!isset ($config->logoutcas)) + if (!isset ($config->logoutcas)) $config->logoutcas = ''; if (!isset ($config->multiauth)) $config->multiauth = ''; @@ -1115,4 +1119,4 @@ if (!empty($this->config->attrcreators)) { return $text; } } -?> \ No newline at end of file +?> diff --git a/auth/email/auth.php b/auth/email/auth.php index 20ad9232ef..2fc47c0672 100644 --- a/auth/email/auth.php +++ b/auth/email/auth.php @@ -86,7 +86,11 @@ class auth_plugin_email extends auth_plugin_base { if ($notify) { global $CFG; $emailconfirm = get_string('emailconfirm'); - print_header($emailconfirm, $emailconfirm, $emailconfirm); + $navlinks = array(); + $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header($emailconfirm, $emailconfirm, $navigation); notice(get_string('emailconfirmsent', '', $user->email), "$CFG->wwwroot/index.php"); } else { return true; diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 6170eabcf1..ea0c5c5b2c 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -286,25 +286,25 @@ class auth_plugin_ldap extends auth_plugin_base { // create the user object, then you set the password. If you try // to set the password while creating the user, the operation // fails. - + // Passwords in Active Directory must be encoded as Unicode // strings (UCS-2 Little Endian format) and surrounded with // double quotes. See http://support.microsoft.com/?kbid=269190 if (!function_exists('mb_convert_encoding')) { print_error ('auth_ldap_no_mbstring', 'auth'); } - + // First create the user account, and mark it as disabled. $newuser['objectClass'] = array('top','person','user','organizationalPerson'); $newuser['sAMAccountName'] = $extusername; - $newuser['userAccountControl'] = AUTH_AD_NORMAL_ACCOUNT | + $newuser['userAccountControl'] = AUTH_AD_NORMAL_ACCOUNT | AUTH_AD_ACCOUNTDISABLE; $userdn = 'cn=' . $this->ldap_addslashes($extusername) . ',' . $this->config->create_context; if (!ldap_add($ldapconnection, $userdn, $newuser)) { print_error ('auth_ldap_ad_create_req', 'auth'); } - + // Now set the password unset($newuser); $newuser['unicodePwd'] = mb_convert_encoding('"' . $extpassword . '"', @@ -365,7 +365,11 @@ class auth_plugin_ldap extends auth_plugin_base { if ($notify) { global $CFG; $emailconfirm = get_string('emailconfirm'); - print_header($emailconfirm, $emailconfirm, $emailconfirm); + $navlinks = array(); + $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header($emailconfirm, $emailconfirm, $navigation); notice(get_string('emailconfirmsent', '', $user->email), "$CFG->wwwroot/index.php"); } else { return true; @@ -1211,7 +1215,7 @@ class auth_plugin_ldap extends auth_plugin_base { $extpassword = mb_convert_encoding('"'.$extpassword.'"', "UCS-2LE", $this->config->ldapencoding); $result = ldap_modify($ldapconnection, $user_dn, array('unicodePwd' => $extpassword)); if (!$result) { - error_log('LDAP Error in user_update_password(). Error code: ' + error_log('LDAP Error in user_update_password(). Error code: ' . ldap_errno($ldapconnection) . '; Error string : ' . ldap_err2str(ldap_errno($ldapconnection))); } @@ -1871,7 +1875,7 @@ class auth_plugin_ldap extends auth_plugin_base { define ('ROOTDSE', ''); // UF_DONT_EXPIRE_PASSWD value taken from MSDN directly define ('UF_DONT_EXPIRE_PASSWD', 0x00010000); - + global $CFG; if (!function_exists('bcsub')) { @@ -1889,14 +1893,14 @@ class auth_plugin_ldap extends auth_plugin_base { // expired or not. return 0; } - + $info = $this->ldap_get_entries($ldapconn, $sr); $useraccountcontrol = $info[0]['userAccountControl'][0]; if ($useraccountcontrol & UF_DONT_EXPIRE_PASSWD) { // password doesn't expire. return 0; } - + // If pwdLastSet is zero, the user must change his/her password now // (unless UF_DONT_EXPIRE_PASSWD flag is set, but we already // tested this above) @@ -1904,7 +1908,7 @@ class auth_plugin_ldap extends auth_plugin_base { // password has expired return -1; } - + // ---------------------------------------------------------------- // Password expiration time in Active Directory is the composition of // two values: @@ -1926,17 +1930,17 @@ class auth_plugin_ldap extends auth_plugin_base { // So we need to convert the values to Unix timestamps (see // details below). // ---------------------------------------------------------------- - + $sr = ldap_read($ldapconn, ROOTDSE, 'objectclass=*', array('defaultNamingContext')); if (!$sr) { error_log("ldap: error querying rootDSE for Active Directory"); return 0; } - + $info = $this->ldap_get_entries($ldapconn, $sr); $domaindn = $info[0]['defaultNamingContext'][0]; - + $sr = ldap_read ($ldapconn, $domaindn, 'objectclass=*', array('maxPwdAge')); $info = $this->ldap_get_entries($ldapconn, $sr); @@ -1970,14 +1974,14 @@ class auth_plugin_ldap extends auth_plugin_base { // // As a last remark, if the low 32 bits of maxPwdAge are equal to 0, // the maximum password age in the domain is set to 0, which means - // passwords do not expire (see + // passwords do not expire (see // http://msdn2.microsoft.com/en-us/library/ms974598.aspx) // // As the quantities involved are too big for PHP integers, we // need to use BCMath functions to work with arbitrary precision // numbers. // ---------------------------------------------------------------- - + // If the low order 32 bits are 0, then passwords do not expire in // the domain. Just do '$maxpwdage mod 2^32' and check the result @@ -1990,7 +1994,7 @@ class auth_plugin_ldap extends auth_plugin_base { // time, in MS time units. Remember maxPwdAge is stored as a // _negative_ quantity, so we need to substract it in fact. $pwdexpire = bcsub ($pwdlastset, $maxpwdage); - + // Scale the result to convert it to Unix time units and return // that value. return bcsub( bcdiv($pwdexpire, '10000000'), '11644473600'); diff --git a/backup/backup.php b/backup/backup.php index 766682f8c7..9e3c5f11d3 100644 --- a/backup/backup.php +++ b/backup/backup.php @@ -71,9 +71,13 @@ //If no course has been selected, show a list of available courses + $navlinks = array(); if (!$id) { - print_header("$site->shortname: $strcoursebackup", $site->fullname, - "wwwroot/$CFG->admin/index.php\">$stradministration -> $strcoursebackup"); + $navlinks[] = array('name' => $stradministration, 'link' => "$CFG->wwwroot/$CFG->admin/index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strcoursebackup, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$site->shortname: $strcoursebackup", $site->fullname, $navigation); if ($courses = get_courses('all','c.shortname','c.id,c.shortname,c.fullname')) { print_heading(get_string("choosecourse")); @@ -97,13 +101,17 @@ //Print header if (has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - print_header("$site->shortname: $strcoursebackup", $site->fullname, - "wwwroot/$CFG->admin/index.php\">$stradministration -> - $strcoursebackup -> $course->fullname ($course->shortname)"); + $navlinks[] = array('name' => $stradministration, 'link' => "$CFG->wwwroot/$CFG->admin/index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strcoursebackup, 'link' => 'backup.php', 'type' => 'misc'); + $navlinks[] = array('name' => "$course->fullname ($course->shortname)", 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$site->shortname: $strcoursebackup", $site->fullname, $navigation); } else { - print_header("$course->shortname: $strcoursebackup", $course->fullname, - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> - $strcoursebackup"); + $navlinks[] = array('name' => $course->fullname, 'link' => "$CFG->wwwroot/course/view.php?id=$course->id", 'type' => 'misc'); + $navlinks[] = array('name' => $strcoursebackup, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$course->shortname: $strcoursebackup", $course->fullname, $navigation); } //Print form diff --git a/backup/lib.php b/backup/lib.php index 31aa4b9244..709375196b 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -332,7 +332,11 @@ if (empty($CFG->backup_version)) { // Backup has never been installed. $strdatabaseupgrades = get_string("databaseupgrades"); - print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, "", + $navlinks = array(); + $navlinks[] = array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header($strdatabaseupgrades, $strdatabaseupgrades, $navigation, "", upgrade_get_javascript(), false, " ", " "); upgrade_log_start(); @@ -541,7 +545,7 @@ function backup_todb ($data) { // MDL-10770 if ($data === '$@NULL@$') { - return null; + return null; } else { return restore_decode_absolute_links(addslashes($data)); } diff --git a/backup/log.php b/backup/log.php index 456f1f2ddb..d85b36a8b8 100644 --- a/backup/log.php +++ b/backup/log.php @@ -36,11 +36,14 @@ //Decide when to show last execution logs or detailed logs //Lastlog view if (!$courseid) { - print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname, - "admin/index.php\">$stradmin -> ". - "admin/configure.php\">$strconfiguration -> ". - "admin/backup.php?sesskey=$USER->sesskey\">$strbackup -> ". - $strlogs); + $navlinks = array(); + $navlinks[] = array('name' => $stradmin, 'link' => "../$CFG->admin/index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strconfiguration, 'link' => "../$CFG->admin/configure.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strbackup, 'link' => "../$CFG->admin/backup.php?sesskey=$USER->sesskey", 'type' => 'misc'); + $navlinks[] = array('name' => $strlogs, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname, $navigation); print_heading($backuploglaststatus); print_simple_box_start('center'); @@ -84,12 +87,15 @@ print_simple_box_end(); //Detailed View !! } else { - print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname, - "admin/index.php\">$stradmin -> ". - "admin/configure.php\">$strconfiguration -> ". - "admin/backup.php?sesskey=$USER->sesskey\">$strbackup -> ". - "$strlogs -> ". - $strbackupdetails); + $navlinks = array(); + $navlinks[] = array('name' => $stradmin, 'link' => "../$CFG->admin/index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strconfiguration, 'link' => "../$CFG->admin/configure.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strbackup, 'link' => "../$CFG->admin/backup.php?sesskey=$USER->sesskey", 'type' => 'misc'); + $navlinks[] = array('name' => $strlogs, 'link' => 'log.php', 'type' => 'misc'); + $navlinks[] = array('name' => $strbackupdetails, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname, $navigation); print_heading($backuplogdetailed); @@ -97,7 +103,7 @@ print_heading("$strcourse: $coursename"); print_simple_box_start('center'); - + //First, me get all the distinct backups for that course in backup_log $executions = get_records_sql("SELECT DISTINCT laststarttime,laststarttime FROM {$CFG->prefix}backup_log @@ -115,7 +121,7 @@ print_simple_box("

".userdate($execution->laststarttime)."
", "center"); echo ""; echo ""; - $logs = get_records_sql("SELECT * + $logs = get_records_sql("SELECT * FROM {$CFG->prefix}backup_log WHERE courseid = '$courseid' AND laststarttime = '$execution->laststarttime' diff --git a/backup/restore.php b/backup/restore.php index df9b64cfd3..e6cdeda5a3 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -23,7 +23,7 @@ $method = optional_param( 'method' ); $backup_unique_code = optional_param('backup_unique_code',0,PARAM_INT); - //Check login + //Check login require_login(); /// With method=manual, we come from the FileManager so we delete all the backup/restore/import session structures @@ -72,7 +72,7 @@ //Check necessary functions exists. Thanks to gregb@crowncollege.edu backup_required_functions(); - + //Check backup_version if ($file) { $linkto = "restore.php?id=".$id."&file=".$file; @@ -90,9 +90,13 @@ $stradministration = get_string("administration"); //If no file has been selected from the FileManager, inform and end + $navlinks = array(); + $navlinks[] = array('name' => $stradministration, 'link' => "$CFG->wwwroot/$CFG->admin/index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strcourserestore, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + if (!$file) { - print_header("$site->shortname: $strcourserestore", $site->fullname, - "wwwroot/$CFG->admin/index.php\">$stradministration -> $strcourserestore"); + print_header("$site->shortname: $strcourserestore", $site->fullname, $navigation); print_heading(get_string("nofilesselected")); print_continue("$CFG->wwwroot/$CFG->admin/index.php"); print_footer(); @@ -101,8 +105,7 @@ //If cancel has been selected, inform and end if ($cancel) { - print_header("$site->shortname: $strcourserestore", $site->fullname, - "wwwroot/$CFG->admin/index.php\">$stradministration -> $strcourserestore"); + print_header("$site->shortname: $strcourserestore", $site->fullname, $navigation); print_heading(get_string("restorecancelled")); print_continue("$CFG->wwwroot/$CFG->admin/index.php"); print_footer(); @@ -118,18 +121,21 @@ //Print header if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - print_header("$site->shortname: $strcourserestore", $site->fullname, - "wwwroot/$CFG->admin/index.php\">$stradministration -> - $strcourserestore -> ".basename($file)); + $navlinks[] = array('name' => basename($file), 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$site->shortname: $strcourserestore", $site->fullname, $navigation); } else { - print_header("$course->shortname: $strcourserestore", $course->fullname, - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> - $strcourserestore"); + $navlinks = array(); + $navlinks[] = array('name' => $course->shortname, 'link' => "$CFG->wwwroot/course/view.php?id=$course->id", 'type' => 'misc'); + $navlinks[] = array('name' => $strcourserestore, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$course->shortname: $strcourserestore", $course->fullname, $navigation); } //Print form print_heading("$strcourserestore".((empty($to) ? ': '.basename($file) : ''))); print_simple_box_start('center'); - + //Adjust some php variables to the execution of this script @ini_set("max_execution_time","3000"); raise_memory_limit("192M"); @@ -150,7 +156,7 @@ include_once("restore_check.html"); //To avoid multiple restore executions... $SESSION->cancontinue = true; - } else if ($launch == "execute") { + } else if ($launch == "execute") { //Prevent multiple restore executions... if (empty($SESSION->cancontinue)) { error("Multiple restore execution not allowed!"); @@ -161,7 +167,7 @@ } print_simple_box_end(); - //Print footer + //Print footer print_footer(); ?> diff --git a/blog/edit.php b/blog/edit.php index 5743b66bc5..51a45295cb 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -148,10 +148,13 @@ switch ($action) { if (!$user = get_record('user', 'id', $userid)) { error('Incorrect user id'); } +$navlinks = array(); +$navlinks[] = array('name' => fullname($user), 'link' => "$CFG->wwwroot/user/view.php?id=$userid", 'type' => 'misc'); +$navlinks[] = array('name' => $strblogs, 'link' => "$CFG->wwwroot/blog/index.php?userid=$userid", 'type' => 'misc'); +$navlinks[] = array('name' => $strformheading, 'link' => null, 'type' => 'misc'); +$navigation = build_navigation($navlinks); -print_header("$SITE->shortname: $strblogs", $SITE->fullname, - ''.fullname($user).' -> - '.$strblogs.' -> '.$strformheading,'','',true); +print_header("$SITE->shortname: $strblogs", $SITE->fullname, $navigation,'','',true); $blogeditform->set_data($post); $blogeditform->display(); @@ -244,9 +247,9 @@ function do_delete($post) { $status = delete_records('post', 'id', $post->id); $status = delete_records('blog_tag_instance', 'entryid', $post->id) and $status; - + blog_delete_old_attachments($post); - + add_to_log(SITEID, 'blog', 'delete', 'index.php?userid='. $post->userid, 'deleted blog entry with entry id# '. $post->id); if (!$status) { @@ -361,4 +364,4 @@ function add_tags_info($postid) { } } } -?> \ No newline at end of file +?> diff --git a/blog/edit_form.php b/blog/edit_form.php index 45b71a2078..b98a46a341 100644 --- a/blog/edit_form.php +++ b/blog/edit_form.php @@ -66,7 +66,7 @@ class blog_edit_form extends moodleform { $mform->setAdvanced('otagsgrp'); } - $mform->addElement('textarea', 'ptags', get_string('ptags', 'blog'), array('wrap'=>'soft')); + $mform->addElement('textarea', 'ptags', get_string('ptags', 'blog'), array('cols'=>'40', 'rows'=>'5')); $mform->setType('ptagsadd', PARAM_NOTAGS); $this->add_action_buttons(); @@ -96,6 +96,8 @@ class blog_edit_form extends moodleform { $otagsselect->removeOptions(); if ($otags = get_records_sql_menu('SELECT id, text from '.$CFG->prefix.'tags WHERE type=\'official\' ORDER by text ASC')){ $otagsselect->loadArray($otags); + } else { + $mform->removeElement('otags'); } } diff --git a/blog/header.php b/blog/header.php index d891f961de..c12f8ed4c4 100755 --- a/blog/header.php +++ b/blog/header.php @@ -35,7 +35,7 @@ define('BLOCK_L_MIN_WIDTH', $lmin); define('BLOCK_L_MAX_WIDTH', $lmax); define('BLOCK_R_MIN_WIDTH', $rmin); define('BLOCK_R_MAX_WIDTH', $rmax); - + //_____________ new page class code ________ $pagetype = PAGE_BLOG_VIEW; $pageclass = 'page_blog'; @@ -111,27 +111,36 @@ if (!$course = get_record('course', 'id', $courseid)) { error('Wrong course id'); } +$navlinks = array(); /// This is very messy atm. switch ($filtertype) { case 'site': if ($tagid || !empty($tag)) { - print_header("$SITE->shortname: $blogstring", $SITE->fullname, - ''. "$blogstring -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => $blogstring, 'link' => "index.php?filtertype=site", 'type' => 'misc'); + $navlinks[] = array('name' => "$tagstring: $taginstance->text", 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$SITE->shortname: $blogstring", $SITE->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } else { - print_header("$SITE->shortname: $blogstring", $SITE->fullname, - $blogstring,'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => $blogstring, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$SITE->shortname: $blogstring", $SITE->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } break; case 'course': if ($tagid || !empty($tag)) { - print_header("$course->shortname: $blogstring", $course->fullname, - ''. "$blogstring -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => $blogstring, + 'link' => "index.php?filtertype=course&filterselect=$filterselect", + 'type' => 'misc'); + $navlinks[] = array('name' => "$tagstring: $taginstance->text", 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } else { - print_header("$course->shortname: $blogstring", $course->fullname, - $blogstring,'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => $blogstring, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } break; @@ -139,13 +148,22 @@ if (!$course = get_record('course', 'id', $courseid)) { if ($thisgroup = groups_get_group($filterselect, false)) { //TODO: if ($tagid || !empty($tag)) { - print_header("$course->shortname: $blogstring", $course->fullname, - ''.$thisgroup->name.' -> - '. "$blogstring -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => $thisgroup->name, + 'link' => "$CFG->wwwroot/user/index.php?id=$course->id&group=$filterselect", + 'type' => 'misc'); + $navlinks[] = array('name' => $blogstring, + 'link' => "index.php?filtertype=group&filterselect=$filterselect", + 'type' => 'misc'); + $navlinks[] = array('name' => "$tagstring: $taginstance->text", 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } else { - print_header("$course->shortname: $blogstring", $course->fullname, - ''.$thisgroup->name." -> - $blogstring",'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => $thisgroup->name, + 'link' => "$CFG->wwwroot/user/index.php?id=$course->id&group=$filterselect", + 'type' => 'misc'); + $navlinks[] = array('name' => $blogstring, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } } else { print_error('Unable to find group'); @@ -161,13 +179,35 @@ if (!$course = get_record('course', 'id', $courseid)) { if ($course->id != SITEID) { if ($tagid || !empty($tag)) { - print_header("$course->shortname: $blogstring", $course->fullname, - ''.$course->shortname.' -> - '.$participants.' -> - '.fullname($user).' -> - '. "$blogstring -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => $course->shortname, + 'link' => "$CFG->wwwroot/course/view.php?id=$course->id", + 'type' => 'misc'); + $navlinks[] = array('name' => $participants, + 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", + 'type' => 'misc'); + $navlinks[] = array('name' => fullname($user), + 'link' => "$CFG->wwwroot/user/view.php?id=$filterselect&course=$course->id", + 'type' => 'misc'); + $navlinks[] = array('name' => $blogstring, + 'link' => "index.php?courseid=$course->id&filtertype=user&filterselect=$filterselect", + 'type' => 'misc'); + $navlinks[] = array('name' => "$tagstring: $taginstance->text", 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } else { + $navlinks[] = array('name' => $course->shortname, + 'link' => "$CFG->wwwroot/course/view.php?id=$course->id", + 'type' => 'misc'); + $navlinks[] = array('name' => $participants, + 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", + 'type' => 'misc'); + $navlinks[] = array('name' => fullname($user), + 'link' => "$CFG->wwwroot/user/view.php?id=$filterselect&course=$course->id", + 'type' => 'misc'); + $navlinks[] = array('name' => $blogstring, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); print_header("$course->shortname: $blogstring", $course->fullname, ''.$course->shortname.' -> '.$participants.' -> @@ -180,14 +220,24 @@ if (!$course = get_record('course', 'id', $courseid)) { //in top view if ($tagid || !empty($tag)) { - print_header("$SITE->shortname: $blogstring", $SITE->fullname, - ''.fullname($user).' -> - '. "$blogstring -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => fullname($user), + 'link' => "$CFG->wwwroot/user/view.php?id=$filterselect", + 'type' => 'misc'); + $navlinks[] = array('name' => $blogstring, + 'link' => "index.php?filtertype=user&filterselect=$filterselect", + 'type' => 'misc'); + $navlinks[] = array('name' => "$tagstring: $taginstance->text", 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$SITE->shortname: $blogstring", $SITE->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } else { - print_header("$SITE->shortname: $blogstring", $SITE->fullname, - ''.fullname($user).' -> - '.$blogstring,'','',true,$PAGE->get_extra_header_string()); + $navlinks[] = array('name' => fullname($user), + 'link' => "$CFG->wwwroot/user/view.php?id=$filterselect", + 'type' => 'misc'); + $navlinks[] = array('name' => $blogstring, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header("$SITE->shortname: $blogstring", $SITE->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } diff --git a/calendar/event.php b/calendar/event.php index a00e7ceb9f..bf995650cb 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -70,7 +70,12 @@ calendar_session_vars(); $now = usergetdate(time()); - $nav = calendar_get_link_tag($strcalendar, CALENDAR_URL.'view.php?view=upcoming&course='.$urlcourse.'&', $now['mday'], $now['mon'], $now['year']); + $navlinks = array(); + $calendar_navlink = array('name' => $strcalendar, + 'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&course='.$urlcourse.'&', + $now['mday'], $now['mon'], $now['year']), + 'type' => 'misc'); + $day = intval($now['mday']); $mon = intval($now['mon']); $yr = intval($now['year']); @@ -158,7 +163,7 @@ 'timestart = '.$timestartoffset.','. 'timeduration = '.$form->timeduration.','. 'timemodified = '.time().' WHERE repeatid = '.$event->repeatid); - + /// Log the event update. $form->name = stripslashes($form->name); //To avoid double-slashes add_to_log($form->courseid, 'calendar', 'edit all', 'event.php?action=edit&id='.$form->id, $form->name); @@ -168,7 +173,7 @@ // Update this $form->timemodified = time(); update_record('event', $form); - + /// Log the event update. $form->name = stripslashes($form->name); //To avoid double-slashes add_to_log($form->courseid, 'calendar', 'edit', 'event.php?action=edit&id='.$form->id, $form->name); @@ -255,13 +260,6 @@ break; } - // Let's see if we are supposed to provide a referring course link - // but NOT for the "main page" course - if($SESSION->cal_course_referer != SITEID && - ($shortname = get_field('course', 'shortname', 'id', $SESSION->cal_course_referer)) !== false) { - // If we know about the referring course, show a return link - $nav = ''.$shortname.' -> '.$nav; - } if (!empty($SESSION->cal_course_referer)) { // TODO: This is part of the Great $course Hack in Moodle. Replace it at some point. @@ -271,7 +269,10 @@ } require_login($course, false); - print_header($site->shortname.': '.$strcalendar.': '.$title, $strcalendar, $nav.' -> '.$title, + $navlinks[] = $calendar_navlink; + $navlinks[] = array('name' => $title, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + print_header($site->shortname.': '.$strcalendar.': '.$title, $strcalendar, $navigation, 'eventform.name', '', true, '', user_login_string($site)); echo calendar_overlib_html(); @@ -313,7 +314,7 @@ else { $repeatcount = 0; } - + // Display confirmation form echo '
'.get_string('deleteevent', 'calendar').': '.$event->name.'
'; echo '

'.get_string('confirmeventdelete', 'calendar').'

'; @@ -533,7 +534,7 @@ calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses); list($prevmon, $prevyr) = calendar_sub_month($mon, $yr); list($nextmon, $nextyr) = calendar_add_month($mon, $yr); - + echo ''; echo '
'; echo '
'.get_string('eventskey', 'calendar').'
'; @@ -541,7 +542,7 @@ echo calendar_filter_controls('event', 'action='.$action.'&type='.$eventtype.'&id='.$eventid); echo '
'; echo ''; - + echo '
'; echo '
'.get_string('monthlyview', 'calendar').'
'; echo '
'; @@ -604,7 +605,7 @@ function calendar_add_event_allowed($event) { // can not be using guest account if (empty($USER->id) or $USER->username == 'guest') { - return false; + return false; } $sitecontext = get_context_instance(CONTEXT_SYSTEM); @@ -620,8 +621,8 @@ function calendar_add_event_allowed($event) { case 'group': if (! groups_group_exists($event->groupid)) { //TODO:check. return false; - } - // this is ok because if you have this capability at course level, you should be able + } + // this is ok because if you have this capability at course level, you should be able // to edit group calendar too // there is no need to check membership, because if you have this capability // you will have a role in this group context diff --git a/calendar/event_select.html b/calendar/event_select.html index 09049b1273..7fd1b565c2 100644 --- a/calendar/event_select.html +++ b/calendar/event_select.html @@ -1,36 +1,58 @@
- - - + + + + +
- user)) { ?>
- - groups)) { ?>
- + + - - - - -
+ +user)) { ?> +
+ + +
+ + +groups) && is_array($allowed->groups)) { ?> +
+ + + -
- - courses)) { ?> -
- - site)) { ?> -
- -
- - -
-

- - - -

- \ No newline at end of file + +
+ + +courses)) { ?> +
+ + + +
+ + +site)) { ?> +
+ + +
+ +
+ + +
+

+ + + +

+ diff --git a/calendar/export.php b/calendar/export.php index c267eb6a01..0edbaf3e10 100644 --- a/calendar/export.php +++ b/calendar/export.php @@ -21,8 +21,15 @@ if(!$site = get_site()) { calendar_session_vars(); $pagetitle = get_string('export', 'calendar'); +$navlinks = array(); $now = usergetdate(time()); -$nav = calendar_get_link_tag(get_string('calendar', 'calendar'), CALENDAR_URL.'view.php?view=upcoming&course='.$course.'&', $now['mday'], $now['mon'], $now['year']).' -> '.$pagetitle; + +$navlinks[] = array('name' => get_string('calendar', 'calendar'), + 'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&course='.$course.'&', + $now['mday'], $now['mon'], $now['year']), + 'type' => 'misc'); +$navlinks[] = array('name' => $pagetitle, 'link' => null, 'type' => 'misc'); +$navigation = build_navigation($navlinks); if(!checkdate($mon, $day, $yr)) { $day = intval($now['mday']); @@ -46,7 +53,7 @@ $strcalendar = get_string('calendar', 'calendar'); $prefsbutton = calendar_preferences_button(); // Print title and header -print_header("$site->shortname: $strcalendar: $pagetitle", $strcalendar, $nav, +print_header("$site->shortname: $strcalendar: $pagetitle", $strcalendar, $navigation, '', '', true, $prefsbutton, user_login_string($site)); echo calendar_overlib_html(); diff --git a/calendar/export_basic.html b/calendar/export_basic.html index c0778dac5a..30bffecb77 100644 --- a/calendar/export_basic.html +++ b/calendar/export_basic.html @@ -1,12 +1,12 @@
-: +
:


-: +
:

@@ -34,7 +34,7 @@ function generate_url() { } else { preset_what = "all"; } - + if ( && document.getElementById("pt_wknow").checked) { preset_time = "weeknow"; } else if ( && document.getElementById("pt_wknext").checked) { @@ -46,11 +46,11 @@ function generate_url() { } else { preset_time = "recentupcoming"; } - + url = "wwwroot; ?>/calendar/export_execute.php?preset_what=" + preset_what + "&preset_time=" + preset_time + "&username=&authtoken="; document.getElementById("url").innerText = url; document.getElementById("url").innerHTML = url; //Need this as well, for Firefox - + document.getElementById("urlbox").style.display = "block"; } //]]> diff --git a/calendar/lib.php b/calendar/lib.php index 6a839cf458..ba43c76c9e 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -49,7 +49,7 @@ define('CALENDAR_DEFAULT_WEEKEND', 65); // Fetch the correct values from admin settings/lang pack // If no such settings found, use the above defaults $firstday = isset($CFG->calendar_startwday) ? $CFG->calendar_startwday : get_string('firstdayofweek'); -if(!is_numeric($firstday)) { +if(!is_numeric($firstday)) { define ('CALENDAR_STARTING_WEEKDAY', CALENDAR_DEFAULT_STARTING_WEEKDAY); } else { @@ -254,13 +254,13 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y } $popupcontent .= ''; } - + //Accessibility: functionality moved to calendar_get_popup. if($display->thismonth && $day == $d) { $popup = calendar_get_popup(true, $events[$eventid]->timestart, $popupcontent); } else { $popup = calendar_get_popup(false, $events[$eventid]->timestart, $popupcontent); - } + } // Class and cell content if(isset($typesbyday[$day]['startglobal'])) { @@ -314,7 +314,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y if($display->thismonth && $day == $d) { $class .= ' today'; $today = get_string('today', 'calendar').' '.userdate(time(), get_string('strftimedayshort')); - + if(! isset($eventsbyday[$day])) { $class .= ' eventnone'; $popup = calendar_get_popup(true, false); @@ -348,7 +348,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y * @param $is_today bool, false except when called on the current day. * @param $event_timestart mixed, $events[$eventid]->timestart, OR false if there are no events. * @param $popupcontent string. - * @return $popup string, contains onmousover and onmouseout events. + * @return $popup string, contains onmousover and onmouseout events. */ function calendar_get_popup($is_today, $event_timestart, $popupcontent='') { $popupcaption = ''; @@ -363,7 +363,7 @@ function calendar_get_popup($is_today, $event_timestart, $popupcontent='') { $popupcaption .= get_string('eventsfor', 'calendar', userdate($event_timestart, get_string('strftimedayshort'))); } $popupcontent = str_replace("'", "\'", htmlspecialchars($popupcontent)); - $popupcaption = str_replace("'", "\'", htmlspecialchars($popupcaption)); + $popupcaption = str_replace("'", "\'", htmlspecialchars($popupcaption)); $popup = 'onmouseover="return overlib(\''.$popupcontent.'\', CAPTION, \''.$popupcaption.'\');" onmouseout="return nd();"'; return $popup; } @@ -434,9 +434,9 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve function calendar_add_event_metadata($event) { global $CFG; - //Support multilang in event->name + //Support multilang in event->name $event->name = format_string($event->name,true); - + if(!empty($event->modulename)) { // Activity event // The module name is set. I will assume that it has to be displayed, and // also that it is an automatically-generated event. And of course that the @@ -473,7 +473,7 @@ function calendar_add_event_metadata($event) { $event->cssclass = 'event_user'; } return $event; -} +} function calendar_print_event($event) { global $CFG, $USER; @@ -659,7 +659,7 @@ function calendar_top_controls($type, $data) { $time = make_timestamp($data['y'], $data['m'], $data['d']); } $date = usergetdate($time); - + $data['m'] = $date['mon']; $data['y'] = $date['year']; @@ -713,7 +713,7 @@ function calendar_top_controls($type, $data) { $nextname = calendar_wday_name($CALENDARDAYS[$nextdate['wday']]); $content .= "\n".'
'; $content .= calendar_get_link_previous($prevname, 'view.php?view=day'.$courseid.'&', $prevdate['mday'], $prevdate['mon'], $prevdate['year']); - + // Get the format string $text = get_string('strftimedaydate'); /* @@ -738,7 +738,7 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL, $courses $groupevents = true; $getvars = ''; - + $id = optional_param( 'id',0,PARAM_INT ); switch($type) { @@ -852,10 +852,10 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL, $courses } if ($n) { - + $content .= $tr; $tr = $tr ? '' : "\n"; - + if ($n < 2) { $strcourse = get_string('course', 'calendar'); } else { @@ -935,6 +935,9 @@ function calendar_time_representation($time) { return userdate($time, empty($timeformat) ? $langtimeformat : $timeformat); } +/** + * TODO document + */ function calendar_get_link_href($linkbase, $d, $m, $y) { if(empty($linkbase)) return ''; $paramstr = ''; @@ -945,6 +948,9 @@ function calendar_get_link_href($linkbase, $d, $m, $y) { return $linkbase.$paramstr; } +/** + * TODO document + */ function calendar_get_link_tag($text, $linkbase, $d, $m, $y) { $href = calendar_get_link_href($linkbase, $d, $m, $y); if(empty($href)) return $text; @@ -1245,7 +1251,7 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU else { $courses = false; } - //BUG 6130 clean $courses array as SESSION has bad entries. + //BUG 6130 clean $courses array as SESSION has bad entries. // [pj] TODO: See if this has to do with my new change in get_default_courses and can be taken out if (is_array($courses)) { foreach ($courses as $index => $value) { @@ -1313,17 +1319,17 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU } } } - + if (!empty($groupids)) { - $sql = "SELECT id + $sql = "SELECT id FROM {$CFG->prefix}groups WHERE courseid IN (".implode(',', $groupids).')'; - + if ($grouprecords= get_records_sql($sql)) { $grouparray = array_merge($grouparray, array_keys($grouprecords)); } } - + if(empty($grouparray)) { $group = false; } @@ -1331,7 +1337,7 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU $group = $grouparray; } } - + } else { $group = false; @@ -1339,40 +1345,40 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU } function calendar_edit_event_allowed($event) { - + global $USER; // can not be using guest account if ($USER->username == "guest") { - return false; + return false; } - + $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); // if user has manageentries at site level, return true if (has_capability('moodle/calendar:manageentries', $sitecontext)) { return true; } - + // if groupid is set, it's definitely a group event if ($event->groupid) { //TODO:check. if (! groups_group_exists($event->groupid)) { return false; - } - - // this is ok because if you have this capability at course level, you should be able + } + + // this is ok because if you have this capability at course level, you should be able // to edit group calendar too // there is no need to check membership, because if you have this capability // you will have a role in this group context - return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_GROUP, $event->groupid)); + return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_GROUP, $event->groupid)); } else if ($event->courseid) { // if groupid is not set, but course is set, // it's definiely a course event - return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid)); - } else if ($event->userid && $event->userid == $USER->id) { + return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid)); + } else if ($event->userid && $event->userid == $USER->id) { // if course is not set, but userid id set, it's a user event return (has_capability('moodle/calendar:manageownentries', $sitecontext)); - } + } return false; } @@ -1394,7 +1400,7 @@ function calendar_get_default_courses($ignoreref = false) { return $courses; } } - + if (isset($CFG->adminseesall)) { $courses = get_my_courses($USER->id, null, null, $CFG->adminseesall); } @@ -1499,7 +1505,7 @@ function calendar_format_event_time($event, $now, $morehref, $usecommonwords = t } function calendar_print_month_selector($name, $selected) { - + $months = array(); for ($i=1; $i<=12; $i++) { @@ -1537,7 +1543,7 @@ function calendar_set_filters_status($packed_bitfield) { $SESSION->cal_show_global = ($packed_bitfield & 1); $SESSION->cal_show_course = ($packed_bitfield & 2); - $SESSION->cal_show_groups = ($packed_bitfield & 4); + $SESSION->cal_show_groups = ($packed_bitfield & 4); $SESSION->cal_show_user = ($packed_bitfield & 8); return true; @@ -1569,6 +1575,6 @@ function calendar_get_allowed_types(&$allowed) { */ function calendar_user_can_add_event() { calendar_get_allowed_types($allowed); - return (bool)($allowed->user || $allowed->groups || $allowed->courses || $allowed->site); + return (bool)($allowed->user || $allowed->groups || $allowed->courses || $allowed->site); } ?> diff --git a/calendar/view.php b/calendar/view.php index 1341b07b3b..ce8fcfba74 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -67,9 +67,14 @@ $now = usergetdate(time()); $pagetitle = ''; - $nav = calendar_get_link_tag(get_string('calendar', 'calendar'), CALENDAR_URL.'view.php?view=upcoming&course='.$courseid.'&', $now['mday'], $now['mon'], $now['year']); + $strcalendar = get_string('calendar', 'calendar'); + $navlinks = array(); + $navlinks[] = array('name' => $strcalendar, + 'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&course='.$courseid.'&', + $now['mday'], $now['mon'], $now['year']), + 'type' => 'misc'); + - if(!checkdate($mon, $day, $yr)) { $day = intval($now['mday']); $mon = intval($now['mon']); @@ -79,11 +84,11 @@ switch($view) { case 'day': - $nav .= ' -> '.userdate($time, get_string('strftimedate')); + $navlinks[] = array('name' => userdate($time, get_string('strftimedate')), 'link' => null, 'type' => 'misc'); $pagetitle = get_string('dayview', 'calendar'); break; case 'month': - $nav .= ' -> '.userdate($time, get_string('strftimemonthyear')); + $navlinks[] = array('name' => userdate($time, get_string('strftimemonthyear')), 'link' => null, 'type' => 'misc'); $pagetitle = get_string('detailedmonthview', 'calendar'); break; case 'upcoming': @@ -121,9 +126,7 @@ // but NOT for the "main page" course if ($SESSION->cal_course_referer != SITEID && ($shortname = get_field('course', 'shortname', 'id', $SESSION->cal_course_referer)) !== false) { - // If we know about the referring course, show a return link and ALSO require login! require_login(); - $nav = ''.$shortname.' -> '.$nav; if (empty($course)) { $course = get_record('course', 'id', $SESSION->cal_course_referer); // Useful to have around } @@ -133,7 +136,8 @@ $prefsbutton = calendar_preferences_button(); // Print title and header - print_header("$site->shortname: $strcalendar: $pagetitle", $strcalendar, $nav, + $navigation = build_navigation($navlinks); + print_header("$site->shortname: $strcalendar: $pagetitle", $strcalendar, $navigation, '', '', true, $prefsbutton, user_login_string($site)); echo calendar_overlib_html(); diff --git a/course/category.php b/course/category.php index cb7b53064f..2fc9e66cb7 100644 --- a/course/category.php +++ b/course/category.php @@ -23,9 +23,9 @@ if (!$site = get_site()) { error("Site isn't defined!"); } - + $context = get_context_instance(CONTEXT_COURSECAT, $id); - + if ($CFG->forcelogin) { require_login(); } @@ -115,6 +115,11 @@ $strcategory = get_string("category"); $strcourses = get_string("courses"); + $navlinks = array(); + $navlinks[] = array('name' => $strcategories, 'link' => 'index.php', 'type' => 'misc'); + $navlinks[] = array('name' => $category->name, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + if ($creatorediting) { if ($adminediting) { // modify this to treat this as an admin page @@ -123,12 +128,10 @@ admin_externalpage_setup('coursemgmt'); admin_externalpage_print_header(); } else { - print_header("$site->shortname: $category->name", "$site->fullname: $strcourses", - "$strcategories -> $category->name", "", "", true, $navbaritem); + print_header("$site->shortname: $category->name", "$site->fullname: $strcourses", $navigation, "", "", true, $navbaritem); } } else { - print_header("$site->shortname: $category->name", "$site->fullname: $strcourses", - "$strcategories -> $category->name", "", "", true, $navbaritem); + print_header("$site->shortname: $category->name", "$site->fullname: $strcourses", $navigation, "", "", true, $navbaritem); } /// Print button to turn editing off @@ -138,7 +141,7 @@ /// Print link to roles - if (has_capability('moodle/role:assign', $context)) { + if (has_capability('moodle/role:assign', $context)) { echo ''; } @@ -170,19 +173,19 @@ // user must have category update in both cats to perform this require_capability('moodle/category:update', $context); - require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto)); - + require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto)); + if (! $destcategory = get_record("course_categories", "id", $data->moveto)) { error("Error finding the category"); } - - $courses = array(); + + $courses = array(); foreach ( $data as $key => $value ) { if (preg_match('/^c\d+$/', $key)) { array_push($courses, substr($key, 1)); } - } + } move_courses($courses, $data->moveto); } @@ -272,9 +275,9 @@ } /// print option to add a subcategory - if (has_capability('moodle/category:create', $context)) { + if (has_capability('moodle/category:create', $context)) { $cat->id = $id; - $mform->set_data($cat); + $mform->set_data($cat); $mform->display(); } @@ -346,9 +349,9 @@ } foreach ($courses as $acourse) { - + $coursecontext = get_context_instance(CONTEXT_COURSE, $acourse->id); - + $count++; $up = ($count > 1 || !$atfirstpage); $down = ($count < $numcourses || !$atlastpage); @@ -362,12 +365,12 @@ echo ''. ''.$stredit.' '; } - - // role assignment link - if (has_capability('moodle/role:assign', $coursecontext)) { + + // role assignment link + if (has_capability('moodle/role:assign', $coursecontext)) { echo''.get_string('assignroles', 'role').''; - } - + } + if (can_delete_course($acourse->id)) { echo ''. ''.$strdelete.' '; @@ -390,7 +393,7 @@ echo ''. ''.$strbackup.' '; } - + if (has_capability('moodle/site:restore', $coursecontext)) { echo ''. @@ -415,11 +418,11 @@ } $abletomovecourses = true; } - + echo ''; echo ''; echo ''; - echo ''; + echo ''; } else { echo ''; if (!empty($acourse->guest)) { @@ -444,17 +447,17 @@ if ($abletomovecourses) { echo ''; - echo '
'; + echo '
'; unset($displaylist[$category->id]); // loop and unset categories the user can't move into - + foreach ($displaylist as $did=>$dlist) { if (!has_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $did))) { - unset($displaylist[$did]); + unset($displaylist[$did]); } } - + choose_from_menu ($displaylist, "moveto", "", get_string("moveselectedcoursesto"), "javascript: submitFormById('movecourses')"); echo ''; echo ''; @@ -464,7 +467,7 @@ echo '
'; echo '
'; } - + if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $numcourses > 1) { /// Print button to re-sort courses by name unset($options); $options['id'] = $category->id; @@ -505,9 +508,9 @@ } } - + print_course_search(); - + print_footer(); ?> diff --git a/course/delete.php b/course/delete.php index 418047f231..02ed485bca 100644 --- a/course/delete.php +++ b/course/delete.php @@ -25,21 +25,23 @@ } $category = get_record("course_categories", "id", $course->category); + $navlinks = array(); if (! $delete) { $strdeletecheck = get_string("deletecheck", "", $course->shortname); $strdeletecoursecheck = get_string("deletecoursecheck"); - - print_header("$site->shortname: $strdeletecheck", $site->fullname, - "
admin/index.php\">$stradministration -> ". - "$strcategories -> ". - "category\">$category->name -> ". - "$strdeletecheck"); + $navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strcategories, 'link' => "index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $category->name, 'link' => "category.php?id=$course->category", 'type' => 'misc'); + $navlinks[] = array('name' => $strdeletecheck, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); - notice_yesno("$strdeletecoursecheck

" . format_string($course->fullname) . - " (" . format_string($course->shortname) . ")", - "delete.php?id=$course->id&delete=".md5($course->timemodified)."&sesskey=$USER->sesskey", + print_header("$site->shortname: $strdeletecheck", $site->fullname, $navigation); + + notice_yesno("$strdeletecoursecheck

" . format_string($course->fullname) . + " (" . format_string($course->shortname) . ")", + "delete.php?id=$course->id&delete=".md5($course->timemodified)."&sesskey=$USER->sesskey", "category.php?id=$course->category"); print_footer($course); @@ -60,11 +62,13 @@ $strdeletingcourse = get_string("deletingcourse", "", format_string($course->shortname)); - print_header("$site->shortname: $strdeletingcourse", $site->fullname, - "admin/index.php\">$stradministration -> ". - "$strcategories -> ". - "category\">$category->name -> ". - "$strdeletingcourse"); + $navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strcategories, 'link' => "index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $category->name, 'link' => "category.php?id=$course->category", 'type' => 'misc'); + $navlinks[] = array('name' => $strdeletingcourse, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + + print_header("$site->shortname: $strdeletingcourse", $site->fullname, $navigation); print_heading($strdeletingcourse); -- 2.39.5