Skip to content

Commit

Permalink
MDL-10870 All files updated to new build_navigation() method. Most ar…
Browse files Browse the repository at this point in the history
…e untested, because they are not easily accessible within a moodle site.
  • Loading branch information
nicolasconnault committed Aug 17, 2007
1 parent 45b68ee commit 0be6f67
Show file tree
Hide file tree
Showing 59 changed files with 894 additions and 823 deletions.
6 changes: 3 additions & 3 deletions course/editsection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}

add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");

redirect("view.php?id=$course->id");
exit;
}
Expand Down Expand Up @@ -57,14 +57,14 @@
$strsummaryof = get_string('summaryof', '', " $sectionname $form->section");
}

print_header_simple($stredit, '', $stredit, 'theform.summary' );
print_header_simple($stredit, '', build_navigation(array(array('name' => $stredit, 'link' => null, 'type' => 'misc'))), 'theform.summary' );

print_heading($strsummaryof);
print_simple_box_start('center');
include('editsection.html');
print_simple_box_end();

if ($usehtmleditor) {
if ($usehtmleditor) {
use_html_editor("summary");
}
print_footer($course);
Expand Down
18 changes: 9 additions & 9 deletions course/enrol.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php // $Id$
// Depending on the current enrolment method, this page
// presents the user with whatever they need to know when
// Depending on the current enrolment method, this page
// presents the user with whatever they need to know when
// they try to enrol in a course.

require_once("../config.php");
Expand All @@ -15,7 +15,7 @@
if (!empty($CFG->loginhttps)) {
$wwwroot = str_replace('http:','https:', $wwwroot);
}
// do not use require_login here because we are usually comming from it
// do not use require_login here because we are usually comming from it
redirect($wwwroot.'/login/index.php');
}

Expand All @@ -32,14 +32,14 @@
print_error('loginasnoenrol', '', $CFG->wwwroot.'/course/view.php?id='.$USER->loginascontext->instanceid);
}

$enrol = enrolment_factory::factory($course->enrol); // do not use if (!$enrol... here, it can not work in PHP4 - see MDL-7529
$enrol = enrolment_factory::factory($course->enrol); // do not use if (!$enrol... here, it can not work in PHP4 - see MDL-7529

/// Refreshing all current role assignments for the current user

load_all_capabilities();

/// Double check just in case they are actually enrolled already and
/// thus got to this script by mistake. This might occur if enrolments
/// Double check just in case they are actually enrolled already and
/// thus got to this script by mistake. This might occur if enrolments
/// changed during this session or something

if (has_capability('moodle/course:view', $context) and !has_capability('moodle/legacy:guest', $context, NULL, false)) {
Expand All @@ -57,14 +57,14 @@
print_header_simple();
notice(get_string('coursenotaccessible'), "$CFG->wwwroot/index.php");
}

/// Users can't enroll to site course
if ($course->id == SITEID) {
print_header_simple();
notice(get_string('enrollfirst'), "$CFG->wwwroot/index.php");
}

/// Double check just in case they are enrolled to start in the future
/// Double check just in case they are enrolled to start in the future

if ($course->enrolperiod) { // Only active if the course has an enrolment period in effect
if ($roles = get_user_roles($context, $USER->id)) {
Expand All @@ -88,7 +88,7 @@
($course->enrollable == 2 && $course->enrolstartdate > 0 && $course->enrolstartdate > time()) ||
($course->enrollable == 2 && $course->enrolenddate > 0 && $course->enrolenddate <= time())
) {
print_header($course->shortname, $course->fullname, $course->shortname );
print_header($course->shortname, $course->fullname, build_navigation(array(array('name'=>$course->shortname,'link'=>'','type'=>'misc'))) );
notice(get_string('notenrollable'), "$CFG->wwwroot/index.php");
}

Expand Down
6 changes: 4 additions & 2 deletions course/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
}

$strimport = get_string('import');
$navlinks = array();
$navlinks[] = array('name' => $strimport, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);

print_header($course->fullname.': '.$strimport, $course->fullname.': '.$strimport,
'<a href="view.php?id='.$course->id.'">'.$course->shortname.'</a> -> '.$strimport);
print_header($course->fullname.': '.$strimport, $course->fullname.': '.$strimport, $navigation);

$directories = get_list_of_plugins('course/import');

Expand Down
25 changes: 16 additions & 9 deletions course/import/activities/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once('../../../config.php');
require_once('../../lib.php');
require_once($CFG->dirroot.'/backup/restorelib.php');

$id = required_param('id', PARAM_INT); // course id to import TO
$fromcourse = optional_param('fromcourse', 0, PARAM_INT);
$fromcoursesearch = optional_param('fromcoursesearch', '', PARAM_RAW);
Expand All @@ -16,7 +16,7 @@
error("That's an invalid course id");
}

if (!$site = get_site()){
if (!$site = get_site()){
error("Couldn't get site course");
}

Expand Down Expand Up @@ -45,20 +45,27 @@
$restore->restoreto = 1;
$restore->course_id = $id;
$restore->importing = 1; // magic variable so we know that we're importing rather than just restoring.

$SESSION->restore = $restore;
redirect($CFG->wwwroot.'/backup/restore.php?file='.$filename.'&id='.$fromcourse.'&to='.$id);
}
else {
redirect($CFG->wwwroot.'/backup/backup.php?id='.$from->id.'&to='.$course->id);
}
}

print_header("$course->shortname: $strimportactivities", $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ".
"-> <a href=\"$CFG->wwwroot/course/import.php?id=$course->id\">".get_string('import')."</a> ".
"-> $strimportactivities");

$navlinks = array();
$navlinks[] = array('name' => $course->shortname,
'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
'type' => 'misc');
$navlinks[] = array('name' => get_string('import'),
'link' => "$CFG->wwwroot/course/import.php?id=$course->id",
'type' => 'misc');
$navlinks[] = array('name' => $strimportactivities, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);

print_header("$course->shortname: $strimportactivities", $course->fullname, $navigation);
require_once('mod.php');

print_footer();
?>
?>
60 changes: 33 additions & 27 deletions course/import/groups/index.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php // $Id: uploadgroups.php, 2005/10/31 19:09:31
<?php // $Id: uploadgroups.php, 2005/10/31 19:09:31

/// Bulk group creation registration script from a comma separated file

require_once('../../../config.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/group/lib.php');

$id = required_param('id', PARAM_INT); // Course id

if (! $course = get_record('course', 'id', $id) ) {
error("That's an invalid course id");
}

require_login($course->id);
$context = get_context_instance(CONTEXT_COURSE, $id);


if (!has_capability('moodle/course:managegroups', $context)) {
error("You do not have the required permissions to manage groups.");
}
Expand All @@ -27,7 +27,7 @@
$strimportgroups = get_string("importgroups");

$csv_encode = '/\&\#44/';
if (isset($CFG->CSV_DELIMITER)) {
if (isset($CFG->CSV_DELIMITER)) {
$csv_delimiter = '\\' . $CFG->CSV_DELIMITER;
$csv_delimiter2 = $CFG->CSV_DELIMITER;

Expand All @@ -40,11 +40,17 @@
}

/// Print the header

print_header("$course->shortname: $strimportgroups", $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ".
"-> <a href=\"$CFG->wwwroot/course/import.php?id=$course->id\">".get_string('import')."</a> ".
"-> $strimportgroups");
$navlinks = array();
$navlinks[] = array('name' => $course->shortname,
'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
'type' => 'misc');
$navlinks[] = array('name' => get_string('import'),
'link' => "$CFG->wwwroot/course/import.php?id=$course->id",
'type' => 'misc');
$navlinks[] = array('name' => $strimportgroups, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);

print_header("$course->shortname: $strimportgroups", $course->fullname, $navigation);

/// If a file has been uploaded, then process it

Expand All @@ -65,21 +71,21 @@
// make arrays of valid fields for error checking
$required = array("groupname" => 1, );
$optionalDefaults = array("lang" => 1, );
$optional = array("coursename" => 1,
$optional = array("coursename" => 1,
"idnumber" =>1,
"description" => 1,
"enrolmentkey" => 1,
"theme" => 1,
"picture" => 1,
"picture" => 1,
"hidepicture" => 1, );

// --- get header (field names) ---
$header = split($csv_delimiter, fgets($fp,1024));
// check for valid field names
foreach ($header as $i => $h) {
$h = trim($h); $header[$i] = $h; // remove whitespace
if ( !(isset($required[$h]) or
isset($optionalDefaults[$h]) or
if ( !(isset($required[$h]) or
isset($optionalDefaults[$h]) or
isset($optional[$h])) ) {
error(get_string('invalidfieldname', 'error', $h), 'index.php?id='.$id.'&amp;sesskey='.$USER->sesskey);
}
Expand All @@ -96,7 +102,7 @@
$linenum = 2; // since header is line 1

while (!feof ($fp)) {

$newgroup = new object();//to make Martin happy
foreach ($optionalDefaults as $key => $value) {
$newgroup->$key = current_language(); //defaults to current language
Expand All @@ -117,7 +123,7 @@
if (isset($required[$name]) and !$value) {
error(get_string('missingfield', 'error', $name). " ".
get_string('erroronline', 'error', $linenum) .". ".
get_string('processingstops', 'error'),
get_string('processingstops', 'error'),
'uploaduser.php?sesskey='.$USER->sesskey);
}
else if ($name == "groupname") {
Expand All @@ -129,31 +135,31 @@
}
}
///Find the courseid of the course with the given shortname

//if idnumber is set, we use that.
//unset invalid courseid
if (isset($newgroup->idnumber)){
if (!$mycourse = get_record('course', 'idnumber',$newgroup->idnumber)){
notify(get_string('unknowncourseidnumber', 'error', $newgroup->idnumber));
unset($newgroup->courseid);//unset so 0 doesnt' get written to database
}
$newgroup->courseid = $mycourse->id;
$newgroup->courseid = $mycourse->id;
}
//else use course short name to look up
//unset invalid coursename (if no id)

else if (isset($newgroup->coursename)){
if (!$mycourse = get_record('course', 'shortname',$newgroup->coursename)){
notify(get_string('unknowncourse', 'error', $newgroup->coursename));
unset($newgroup->courseid);//unset so 0 doesnt' get written to database
}
$newgroup->courseid = $mycourse->id;
$newgroup->courseid = $mycourse->id;
}
//else juse use current id
else{
$newgroup->courseid = $id;
}

//if courseid is set
if (isset($newgroup->courseid)){

Expand All @@ -162,22 +168,22 @@
$linenum++;
$groupname = $newgroup->name;
$newgrpcoursecontext = get_context_instance(CONTEXT_COURSE, $newgroup->courseid);

///Users cannot upload groups in courses they cannot update.
if (!has_capability('moodle/course:managegroups', $newgrpcoursecontext)){
notify(get_string('nopermissionforcreation','group',$groupname));

} else {
if ( $groupid = groups_get_group_by_name($newgroup->courseid, $groupname) || !($newgroup->id = groups_create_group($newgroup)) ) {

//Record not added - probably because group is already registered
//In this case, output groupname from previous registration
if ($groupid) {
notify("$groupname :".get_string('groupexistforcourse', 'error', $groupname));
} else {
notify(get_string('groupnotaddederror', 'error', $groupname));
}
}
}
}
else {
notify(get_string('groupaddedsuccesfully', 'group', $groupname));
}
Expand Down
3 changes: 1 addition & 2 deletions course/importstudents.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@

print_header("$course->shortname: $strassigncourses",
$site->fullname,
"<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $strassigncourses",
"searchtext");
build_navigation(array(array('name' => $strassigncourses, 'link' => null, 'type' => 'misc'))), "searchtext");


/// Print a help notice about the need to use this page
Expand Down
Loading

0 comments on commit 0be6f67

Please sign in to comment.