MDL-10870 All files updated to new build_navigation() method.

This commit is contained in:
nicolasconnault
2007-08-17 11:18:58 +00:00
parent 88c8015ea0
commit e295df447f
23 changed files with 417 additions and 267 deletions
@@ -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",
"<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
$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 ('<p>' .implode(', ', $errors) . '</p>
<p>' . $tempfield->readableInfo(),
'index.php?action=edit_field&amp;field=' .$field->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
'index.php?action=edit_field&amp;field=' .$field->getName() . '&amp;table=' . $table->getName()
. '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
die; /// re-die :-P
}
@@ -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",
"<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
$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 ('<p>' .implode(', ', $errors) . '</p>
<p>' . $tempindex->readableInfo(),
'index.php?action=edit_index&amp;index=' .$index->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
@@ -240,9 +240,12 @@ class edit_key_save extends XMLDBAction {
}
/// Prepare the output
$site = get_site();
print_header("$site->shortname: XMLDB",
"$site->fullname",
"<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
$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 ('<p>' .implode(', ', $errors) . '</p>
<p>' . $tempkey->readableInfo(),
'index.php?action=edit_key&amp;key=' .$key->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
@@ -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",
"<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
$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 ('<p>' .implode(', ', $errors) . '</p>
<p>' . s($sentence),
'index.php?action=edit_sentence&amp;sentence=' .$sentenceparam . '&amp;statement=' . urlencode($statementparam) . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
@@ -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",
"<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
$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 ('<p>' .implode(', ', $errors) . '</p>
<p>' . $temptable->readableInfo(),
'index.php?action=edit_table&amp;table=' . $tableparam . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
+23 -19
View File
@@ -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;
}
}
?>
?>
+5 -1
View File
@@ -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;
+20 -16
View File
@@ -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');
+16 -8
View File
@@ -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,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> $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,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> ->
<a href=\"backup.php\">$strcoursebackup</a> -> $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,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
$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
+6 -2
View File
@@ -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, "&nbsp;", "&nbsp;");
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));
}
+19 -13
View File
@@ -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,
"<a href=\"../$CFG->admin/index.php\">$stradmin</a> -> ".
"<a href=\"../$CFG->admin/configure.php\">$strconfiguration</a> -> ".
"<a href=\"../$CFG->admin/backup.php?sesskey=$USER->sesskey\">$strbackup</a> -> ".
$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,
"<a href=\"../$CFG->admin/index.php\">$stradmin</a> -> ".
"<a href=\"../$CFG->admin/configure.php\">$strconfiguration</a> -> ".
"<a href=\"../$CFG->admin/backup.php?sesskey=$USER->sesskey\">$strbackup</a> -> ".
"<a href=\"log.php\">$strlogs</a> -> ".
$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("<center>".userdate($execution->laststarttime)."</center>", "center");
echo "</td>";
echo "</tr>";
$logs = get_records_sql("SELECT *
$logs = get_records_sql("SELECT *
FROM {$CFG->prefix}backup_log
WHERE courseid = '$courseid' AND
laststarttime = '$execution->laststarttime'
+21 -15
View File
@@ -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 [email protected]
backup_required_functions();
//Check backup_version
if ($file) {
$linkto = "restore.php?id=".$id."&amp;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,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> $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,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> $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,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> ->
$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,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
$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();
?>
+9 -6
View File
@@ -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,
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'">'.fullname($user).'</a> ->
<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$userid.'">'.$strblogs.'</a> -> '.$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) {
}
}
}
?>
?>
+3 -1
View File
@@ -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');
}
}
+76 -26
View File
@@ -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,
'<a href="index.php?filtertype=site">'. "$blogstring</a> -> $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,
'<a href="index.php?filtertype=course&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
$navlinks[] = array('name' => $blogstring,
'link' => "index.php?filtertype=course&amp;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,
'<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect.'">'.$thisgroup->name.'</a> ->
<a href="index.php?filtertype=group&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
$navlinks[] = array('name' => $thisgroup->name,
'link' => "$CFG->wwwroot/user/index.php?id=$course->id&amp;group=$filterselect",
'type' => 'misc');
$navlinks[] = array('name' => $blogstring,
'link' => "index.php?filtertype=group&amp;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,
'<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect.'">'.$thisgroup->name."</a> ->
$blogstring",'','',true,$PAGE->get_extra_header_string());
$navlinks[] = array('name' => $thisgroup->name,
'link' => "$CFG->wwwroot/user/index.php?id=$course->id&amp;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,
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'&amp;course='.$course->id.'">'.fullname($user).'</a> ->
<a href="index.php?courseid='.$course->id.'&amp;filtertype=user&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $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&amp;course=$course->id",
'type' => 'misc');
$navlinks[] = array('name' => $blogstring,
'link' => "index.php?courseid=$course->id&amp;filtertype=user&amp;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&amp;course=$course->id",
'type' => 'misc');
$navlinks[] = array('name' => $blogstring, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$course->shortname: $blogstring", $course->fullname,
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
@@ -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,
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
<a href="index.php?filtertype=user&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $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&amp;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,
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
'.$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());
}
+18 -17
View File
@@ -70,7 +70,12 @@
calendar_session_vars();
$now = usergetdate(time());
$nav = calendar_get_link_tag($strcalendar, CALENDAR_URL.'view.php?view=upcoming&amp;course='.$urlcourse.'&amp;', $now['mday'], $now['mon'], $now['year']);
$navlinks = array();
$calendar_navlink = array('name' => $strcalendar,
'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$urlcourse.'&amp;',
$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&amp;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&amp;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 = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$SESSION->cal_course_referer.'">'.$shortname.'</a> -> '.$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 '<div class="header">'.get_string('deleteevent', 'calendar').': '.$event->name.'</div>';
echo '<h2>'.get_string('confirmeventdelete', 'calendar').'</h2>';
@@ -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 '<td class="sidecalendar">';
echo '<div class="sideblock">';
echo '<div class="header">'.get_string('eventskey', 'calendar').'</div>';
@@ -541,7 +542,7 @@
echo calendar_filter_controls('event', 'action='.$action.'&amp;type='.$eventtype.'&amp;id='.$eventid);
echo '</div>';
echo '</div>';
echo '<div class="sideblock">';
echo '<div class="header">'.get_string('monthlyview', 'calendar').'</div>';
echo '<div class="minicalendarblock minicalendartop">';
@@ -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
+55 -33
View File
@@ -1,36 +1,58 @@
<form method="post" action="event.php">
<table class="formtable">
<tr>
<td>
<?php if(!empty($allowed->user)) { ?><div><input type='radio' name='type' value='user' id='type_user' checked='checked' /><label for='type_user'><?php print_string('typeuser', 'calendar') ?></label></div>
<?php } ?>
<?php if(!empty($allowed->groups)) { ?><div><input type='radio' name='type' value='group' id='type_group' /><label for='type_group'><?php echo get_string('typegroup', 'calendar').' '.get_string('groupfor'); ?></label>
<select name='groupid'>
<option value=''></option>
<table class="formtable">
<tr>
<td>
<?php if(!empty($allowed->user)) { ?>
<div>
<input type='radio' name='type' value='user' id='type_user' checked='checked' />
<label for='type_user'><?php print_string('typeuser', 'calendar') ?></label>
</div>
<?php } ?>
<?php if(!empty($allowed->groups) && is_array($allowed->groups)) { ?>
<div>
<input type='radio' name='type' value='group' id='type_group' />
<label for='type_group'><?php echo get_string('typegroup', 'calendar').' '.get_string('groupfor'); ?></label>
<select name='groupid'>
<option value=''></option>
<?php foreach($allowed->groups as $group) {?>
<option value='<?php echo $group->id; ?>' <?php if($group->id == $groupid) echo 'selected="selected"';?>><?php echo $group->name; ?></option>
<option value='<?php echo $group->id; ?>'
<?php if($group->id == $groupid) {
echo 'selected="selected"';
}
echo '>' . $group->name; ?></option>
<?php }?>
</select>
</div>
<?php } ?>
<?php if(!empty($allowed->courses)) { ?>
<div><input type='radio' name='type' value='course' id='type_course' /><input type="hidden" name="courseid" value="<?php echo($courseid) ?>" /><label for='type_course'><?php print_string('typecourse', 'calendar') ?></label></div>
<?php } ?>
<?php if(!empty($allowed->site)) { ?>
<div><input type='radio' name='type' value='site' id='type_site' /><label for='type_site'><?php print_string('typesite', 'calendar') ?></label></div>
<?php } ?>
</td>
</tr>
<tr>
<td style="text-align: center;">
<input type="submit" value=" <?php print_string('ok') ?> " />
<input type="button" onclick="document.location.href='view.php?view=upcoming';" value=" <?php print_string('cancel') ?> " />
</td>
</tr>
</table>
<p>
<input type="hidden" name="action" value="new" />
<input type="hidden" name="timestart" value="<?php echo $form->timestart; ?>" />
<input type="hidden" name="course" value="<?php p($urlcourse); ?>" />
</p>
</form>
</select>
</div>
<?php } ?>
<?php if(!empty($allowed->courses)) { ?>
<div>
<input type='radio' name='type' value='course' id='type_course' />
<input type="hidden" name="courseid" value="<?php echo($courseid) ?>" />
<label for='type_course'><?php print_string('typecourse', 'calendar') ?></label>
</div>
<?php } ?>
<?php if(!empty($allowed->site)) { ?>
<div>
<input type='radio' name='type' value='site' id='type_site' />
<label for='type_site'><?php print_string('typesite', 'calendar') ?></label>
</div>
<?php } ?>
</td>
</tr>
<tr>
<td style="text-align: center;">
<input type="submit" value=" <?php print_string('ok') ?> " />
<input type="button" onclick="document.location.href='view.php?view=upcoming';" value=" <?php print_string('cancel') ?> " />
</td>
</tr>
</table>
<p>
<input type="hidden" name="action" value="new" />
<input type="hidden" name="timestart" value="<?php echo $form->timestart; ?>" />
<input type="hidden" name="course" value="<?php p($urlcourse); ?>" />
</p>
</form>
+9 -2
View File
@@ -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&amp;course='.$course.'&amp;', $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&amp;course='.$course.'&amp;',
$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();
+5 -5
View File
@@ -1,12 +1,12 @@
<fieldset>
<legend><?php print_string('commontasks', 'calendar'); ?></legend>
<form method="get" action="export_execute.php">
<?php print_string('iwanttoexport', 'calendar'); ?>:
<div><?php print_string('iwanttoexport', 'calendar'); ?>:</div>
<div class="indent">
<input type="radio" name="preset_what" id="pw_all" value="all" checked="checked"/><label for="pw_all"><?php print_string('eventsall', 'calendar'); ?></label><br />
<input type="radio" name="preset_what" id="pw_course" value="courses" /><label for="pw_course"><?php print_string('eventsrelatedtocourses', 'calendar'); ?></label><br />
</div>
<?php print_string('for', 'calendar'); ?>:
<div><?php print_string('for', 'calendar'); ?>:</div>
<div class="indent">
<?php if($allowthisweek) { ?>
<input type="radio" name="preset_time" id="pt_wknow" value="weeknow" checked="checked"/><label for="pt_wknow"><?php print_string('weekthis', 'calendar'); ?></label><br />
@@ -34,7 +34,7 @@ function generate_url() {
} else {
preset_what = "all";
}
if (<?php echo (int) $allowthisweek; ?> && document.getElementById("pt_wknow").checked) {
preset_time = "weeknow";
} else if (<?php echo (int) $allownextweek; ?> && document.getElementById("pt_wknext").checked) {
@@ -46,11 +46,11 @@ function generate_url() {
} else {
preset_time = "recentupcoming";
}
url = "<?php echo $CFG->wwwroot; ?>/calendar/export_execute.php?preset_what=" + preset_what + "&amp;preset_time=" + preset_time + "&amp;username=<?php echo $usernameencoded; ?>&amp;authtoken=<?php echo $authtoken; ?>";
document.getElementById("url").innerText = url;
document.getElementById("url").innerHTML = url; //Need this as well, for Firefox
document.getElementById("urlbox").style.display = "block";
}
//]]>
+41 -35
View File
@@ -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 .= '<div><img class="icon" src="'.$popupicon.'" alt="'.$popupalt.'" /><a href="'.$dayhref.'#event_'.$event->id.'">'.format_string($event->name, true).'</a></div>';
}
//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".'<div class="calendar-controls">';
$content .= calendar_get_link_previous($prevname, 'view.php?view=day'.$courseid.'&amp;', $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 ? '' : "</tr>\n<tr>";
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);
}
?>
+11 -7
View File
@@ -67,9 +67,14 @@
$now = usergetdate(time());
$pagetitle = '';
$nav = calendar_get_link_tag(get_string('calendar', 'calendar'), CALENDAR_URL.'view.php?view=upcoming&amp;course='.$courseid.'&amp;', $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&amp;course='.$courseid.'&amp;',
$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 = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$SESSION->cal_course_referer.'">'.$shortname.'</a> -> '.$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();
+34 -31
View File
@@ -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",
"<a href=\"index.php\">$strcategories</a> -> $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",
"<a href=\"index.php\">$strcategories</a> -> $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 '<div class="rolelink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.
$context->id.'">'.get_string('assignroles','role').'</a></div>';
}
@@ -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 '<a title="'.$strsettings.'" href="'.$CFG->wwwroot.'/course/edit.php?id='.
$acourse->id.'">'.
'<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'.$stredit.'" /></a> '; }
// role assignment link
if (has_capability('moodle/role:assign', $coursecontext)) {
// role assignment link
if (has_capability('moodle/role:assign', $coursecontext)) {
echo'<a title="'.get_string('assignroles', 'role').'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$coursecontext->id.'"><img src="'.$CFG->pixpath.'/i/roles.gif" class="iconsmall" alt="'.get_string('assignroles', 'role').'" /></a>';
}
}
if (can_delete_course($acourse->id)) {
echo '<a title="'.$strdelete.'" href="delete.php?id='.$acourse->id.'">'.
'<img src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.$strdelete.'" /></a> ';
@@ -390,7 +393,7 @@
echo '<a title="'.$strbackup.'" href="../backup/backup.php?id='.$acourse->id.'">'.
'<img src="'.$CFG->pixpath.'/t/backup.gif" class="iconsmall" alt="'.$strbackup.'" /></a> ';
}
if (has_capability('moodle/site:restore', $coursecontext)) {
echo '<a title="'.$strrestore.'" href="../files/index.php?id='.$acourse->id.
'&amp;wdir=/backupdata">'.
@@ -415,11 +418,11 @@
}
$abletomovecourses = true;
}
echo '</td>';
echo '<td align="center">';
echo '<input type="checkbox" name="c'.$acourse->id.'" />';
echo '</td>';
echo '</td>';
} else {
echo '<td align="right">';
if (!empty($acourse->guest)) {
@@ -444,17 +447,17 @@
if ($abletomovecourses) {
echo '<tr><td colspan="3" align="right">';
echo '<br />';
echo '<br />';
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 '<input type="hidden" name="id" value="'.$category->id.'" />';
echo '</td></tr>';
@@ -464,7 +467,7 @@
echo '</div></form>';
echo '<br />';
}
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();
?>
+18 -14
View File
@@ -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,
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
"<a href=\"index.php\">$strcategories</a> -> ".
"<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
"$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<br /><br />" . format_string($course->fullname) .
" (" . format_string($course->shortname) . ")",
"delete.php?id=$course->id&amp;delete=".md5($course->timemodified)."&amp;sesskey=$USER->sesskey",
print_header("$site->shortname: $strdeletecheck", $site->fullname, $navigation);
notice_yesno("$strdeletecoursecheck<br /><br />" . format_string($course->fullname) .
" (" . format_string($course->shortname) . ")",
"delete.php?id=$course->id&amp;delete=".md5($course->timemodified)."&amp;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,
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
"<a href=\"index.php\">$strcategories</a> -> ".
"<a href=\"category.php?id=$course->category\">$category->name</a> -> ".
"$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);