Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/report/log/lib.php
Go to the documentation of this file.
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_log_extend_navigation_course($navigation, $course, $context) {
00036     if (has_capability('report/log:view', $context)) {
00037         $url = new moodle_url('/report/log/index.php', array('id'=>$course->id));
00038         $navigation->add(get_string('pluginname', 'report_log'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
00039     }
00040 }
00041 
00049 function report_log_extend_navigation_user($navigation, $user, $course) {
00050     list($all, $today) = report_log_can_access_user_report($user, $course);
00051 
00052     if ($today) {
00053         $url = new moodle_url('/report/log/user.php', array('id'=>$user->id, 'course'=>$course->id, 'mode'=>'today'));
00054         $navigation->add(get_string('todaylogs'), $url);
00055     }
00056     if ($all) {
00057         $url = new moodle_url('/report/log/user.php', array('id'=>$user->id, 'course'=>$course->id, 'mode'=>'all'));
00058         $navigation->add(get_string('alllogs'), $url);
00059     }
00060 }
00061 
00071 function report_log_can_access_user_report($user, $course) {
00072     global $USER;
00073 
00074     $coursecontext = context_course::instance($course->id);
00075     $personalcontext = context_user::instance($user->id);
00076 
00077     $today = false;
00078     $all = false;
00079 
00080     if (has_capability('report/log:view', $coursecontext)) {
00081         $today = true;
00082     }
00083     if (has_capability('report/log:viewtoday', $coursecontext)) {
00084         $all = true;;
00085     }
00086 
00087     if ($today and $all) {
00088         return array(true, true);
00089     }
00090 
00091     if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
00092         if ($course->showreports and (is_viewing($coursecontext, $user) or is_enrolled($coursecontext, $user))) {
00093             return array(true, true);
00094         }
00095 
00096     } else if ($user->id == $USER->id) {
00097         if ($course->showreports and (is_viewing($coursecontext, $USER) or is_enrolled($coursecontext, $USER))) {
00098             return array(true, true);
00099         }
00100     }
00101 
00102     return array($all, $today);
00103 }
00104 
00111 function report_log_extend_navigation_module($navigation, $cm) {
00112     if (has_capability('report/log:view', context_course::instance($cm->course))) {
00113         $url = new moodle_url('/report/log/index.php', array('chooselog'=>'1','id'=>$cm->course,'modid'=>$cm->id));
00114         $navigation->add(get_string('logs'), $url, navigation_node::TYPE_SETTING, null, 'logreport');
00115     }
00116 }
00117 
00125 function report_log_page_type_list($pagetype, $parentcontext, $currentcontext) {
00126     $array = array(
00127         '*'                => get_string('page-x', 'pagetype'),
00128         'report-*'         => get_string('page-report-x', 'pagetype'),
00129         'report-log-*'     => get_string('page-report-log-x',  'report_log'),
00130         'report-log-index' => get_string('page-report-log-index',  'report_log'),
00131         'report-log-user'  => get_string('page-report-log-user',  'report_log')
00132     );
00133     return $array;
00134 }
 All Data Structures Namespaces Files Functions Variables Enumerations