|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00026 defined('MOODLE_INTERNAL') || die; 00027 00035 function report_outline_extend_navigation_course($navigation, $course, $context) { 00036 if (has_capability('report/outline:view', $context)) { 00037 $url = new moodle_url('/report/outline/index.php', array('id'=>$course->id)); 00038 $navigation->add(get_string('pluginname', 'report_outline'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); 00039 } 00040 } 00041 00049 function report_outline_extend_navigation_user($navigation, $user, $course) { 00050 if (report_outline_can_access_user_report($user, $course)) { 00051 $url = new moodle_url('/report/outline/user.php', array('id'=>$user->id, 'course'=>$course->id, 'mode'=>'outline')); 00052 $navigation->add(get_string('outlinereport'), $url); 00053 $url = new moodle_url('/report/outline/user.php', array('id'=>$user->id, 'course'=>$course->id, 'mode'=>'complete')); 00054 $navigation->add(get_string('completereport'), $url); 00055 } 00056 } 00057 00067 function report_outline_can_access_user_report($user, $course) { 00068 global $USER; 00069 00070 $coursecontext = context_course::instance($course->id); 00071 $personalcontext = context_user::instance($user->id); 00072 00073 if (has_capability('report/outline:view', $coursecontext)) { 00074 return true; 00075 } 00076 00077 if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) { 00078 if ($course->showreports and (is_viewing($coursecontext, $user) or is_enrolled($coursecontext, $user))) { 00079 return true; 00080 } 00081 00082 } else if ($user->id == $USER->id) { 00083 if ($course->showreports and (is_viewing($coursecontext, $USER) or is_enrolled($coursecontext, $USER))) { 00084 return true; 00085 } 00086 } 00087 00088 return false; 00089 } 00090 00098 function report_outline_page_type_list($pagetype, $parentcontext, $currentcontext) { 00099 $array = array( 00100 '*' => get_string('page-x', 'pagetype'), 00101 'report-*' => get_string('page-report-x', 'pagetype'), 00102 'report-outline-*' => get_string('page-report-outline-x', 'report_outline'), 00103 'report-outline-index' => get_string('page-report-outline-index', 'report_outline'), 00104 'report-outline-user' => get_string('page-report-outline-user', 'report_outline') 00105 ); 00106 return $array; 00107 }