Skip to content

Commit

Permalink
MDL-10870 All files updated to new build_navigation() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Aug 17, 2007
1 parent 88c8015 commit e295df4
Show file tree
Hide file tree
Showing 23 changed files with 417 additions and 267 deletions.
11 changes: 7 additions & 4 deletions admin/xmldb/actions/edit_field_save/edit_field_save.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,15 @@ function invoke() {
$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
}

Expand Down
8 changes: 5 additions & 3 deletions admin/xmldb/actions/edit_index_save/edit_index_save.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ function invoke() {
$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)));
Expand Down
9 changes: 6 additions & 3 deletions admin/xmldb/actions/edit_key_save/edit_key_save.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ function invoke() {
}
/// 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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ function invoke() {
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)));
Expand Down
8 changes: 5 additions & 3 deletions admin/xmldb/actions/edit_table_save/edit_table_save.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ function invoke() {
$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)));
Expand Down
42 changes: 23 additions & 19 deletions auth/cas/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function auth_plugin_cas() {
}
}
/**
* 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.
*
Expand Down Expand Up @@ -94,7 +94,7 @@ function loginpage_hook() {
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
Expand All @@ -105,25 +105,29 @@ function loginpage_hook() {
// 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();
Expand All @@ -134,7 +138,7 @@ function loginpage_hook() {
{phpCAS::forceAuthentication();}
}
/**
* logout from the cas
* logout from the cas
*
* This function is called from admin/auth.php
*
Expand All @@ -144,11 +148,11 @@ function prelogout_hook() {
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
*
Expand Down Expand Up @@ -209,19 +213,19 @@ function ldap_suppported_usertypes() {
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 = '';
Expand Down Expand Up @@ -1115,4 +1119,4 @@ function filter_addslashes($text) {
return $text;
}
}
?>
?>
6 changes: 5 additions & 1 deletion auth/email/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ function user_signup($user, $notify=true) {
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;
Expand Down
36 changes: 20 additions & 16 deletions auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,25 +286,25 @@ function user_create($userobject, $plainpass) {
// 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 . '"',
Expand Down Expand Up @@ -365,7 +365,11 @@ function user_signup($user, $notify=true) {
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;
Expand Down Expand Up @@ -1211,7 +1215,7 @@ function user_update_password($user, $newpassword) {
$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)));
}
Expand Down Expand Up @@ -1871,7 +1875,7 @@ function ldap_get_ad_pwdexpire($pwdlastset, $ldapconn, $user_dn){
define ('ROOTDSE', '');
// UF_DONT_EXPIRE_PASSWD value taken from MSDN directly
define ('UF_DONT_EXPIRE_PASSWD', 0x00010000);

global $CFG;

if (!function_exists('bcsub')) {
Expand All @@ -1889,22 +1893,22 @@ function ldap_get_ad_pwdexpire($pwdlastset, $ldapconn, $user_dn){
// 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)
if ($pwdlastset === '0') {
// password has expired
return -1;
}

// ----------------------------------------------------------------
// Password expiration time in Active Directory is the composition of
// two values:
Expand All @@ -1926,17 +1930,17 @@ function ldap_get_ad_pwdexpire($pwdlastset, $ldapconn, $user_dn){
// 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);
Expand Down Expand Up @@ -1970,14 +1974,14 @@ function ldap_get_ad_pwdexpire($pwdlastset, $ldapconn, $user_dn){
//
// 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
Expand All @@ -1990,7 +1994,7 @@ function ldap_get_ad_pwdexpire($pwdlastset, $ldapconn, $user_dn){
// 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');
Expand Down
24 changes: 16 additions & 8 deletions backup/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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
Expand Down
Loading

0 comments on commit e295df4

Please sign in to comment.