| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: mod.php,v 1.9.2.1 2008/04/23 08:11:32 dongsheng Exp $ 2 3 if (!defined('MOODLE_INTERNAL')) { 4 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page 5 } 6 7 require_once($CFG->dirroot.'/course/lib.php'); 8 require_once($CFG->dirroot.'/backup/restorelib.php'); 9 10 $syscontext = get_context_instance(CONTEXT_SYSTEM); 11 12 // if we're not a course creator , we can only import from our own courses. 13 if (has_capability('moodle/course:create', $syscontext)) { 14 $creator = true; 15 } 16 17 $strimport = get_string("importdata"); 18 19 $tcourseids = ''; 20 21 if ($teachers = get_user_capability_course('moodle/course:update')) { 22 foreach ($teachers as $teacher) { 23 if ($teacher->id != $course->id && $teacher->id != SITEID){ 24 $tcourseids .= $teacher->id.','; 25 } 26 } 27 } 28 29 $taught_courses = array(); 30 if (!empty($tcourseids)) { 31 $tcourseids = substr($tcourseids,0,-1); 32 $taught_courses = get_records_list('course', 'id', $tcourseids); 33 } 34 35 if (!empty($creator)) { 36 $cat_courses = get_courses($course->category); 37 } else { 38 $cat_courses = array(); 39 } 40 41 print_heading(get_string("importactivities")); 42 43 $options = array(); 44 foreach ($taught_courses as $tcourse) { 45 if ($tcourse->id != $course->id && $tcourse->id != SITEID){ 46 $options[$tcourse->id] = format_string($tcourse->fullname); 47 } 48 } 49 50 if (empty($options) && empty($creator)) { 51 notify(get_string('courseimportnotaught')); 52 return; // yay , this will pass control back to the file that included or required us. 53 } 54 55 // quick forms 56 include_once ('import_form.php'); 57 58 $mform_post = new course_import_activities_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text'=> get_string('coursestaught'))); 59 $mform_post ->display(); 60 61 unset($options); 62 $options = array(); 63 64 foreach ($cat_courses as $ccourse) { 65 if ($ccourse->id != $course->id && $ccourse->id != SITEID) { 66 $options[$ccourse->id] = format_string($ccourse->fullname); 67 } 68 } 69 $cat = get_record("course_categories","id",$course->category); 70 71 if (count($options) > 0) { 72 $mform_post = new course_import_activities_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text' => get_string('coursescategory'))); 73 $mform_post ->display(); 74 } 75 76 if (!empty($creator)) { 77 $mform_post = new course_import_activities_form_2($CFG->wwwroot.'/course/import/activities/index.php', array('courseid' => $course->id)); 78 $mform_post ->display(); 79 } 80 81 if (!empty($fromcoursesearch) && !empty($creator)) { 82 $totalcount = 0; 83 $courses = get_courses_search(explode(" ",$fromcoursesearch),"fullname ASC",$page,50,$totalcount); 84 if (is_array($courses) and count($courses) > 0) { 85 $table->data[] = array('<b>'.get_string('searchresults').'</b>','',''); 86 foreach ($courses as $scourse) { 87 if ($course->id != $scourse->id) { 88 $table->data[] = array('',format_string($scourse->fullname), 89 '<a href="'.$CFG->wwwroot.'/course/import/activities/index.php?id='.$course->id.'&fromcourse='.$scourse->id.'">'.get_string('usethiscourse').'</a>'); 90 } 91 } 92 } 93 else { 94 $table->data[] = array('',get_string('noresults'),''); 95 } 96 } 97 if (!empty($table)) { 98 print_table($table); 99 } 100 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |