Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/report/stats/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 
00028 defined('MOODLE_INTERNAL') || die;
00029 
00037 function report_stats_extend_navigation_course($navigation, $course, $context) {
00038     global $CFG;
00039     if (!empty($CFG->enablestats)) {
00040         return;
00041     }
00042     if (has_capability('report/stats:view', $context)) {
00043         $url = new moodle_url('/report/stats/index.php', array('course'=>$course->id));
00044         $navigation->add(get_string('pluginname', 'report_stats'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
00045     }
00046 }
00047 
00055 function report_stats_extend_navigation_user($navigation, $user, $course) {
00056     global $CFG;
00057     if (!empty($CFG->enablestats)) {
00058         return;
00059     }
00060     if (report_stats_can_access_user_report($user, $course)) {
00061         $url = new moodle_url('/report/stats/user.php', array('id'=>$user->id, 'course'=>$course->id));
00062         $navigation->add(get_string('stats'), $url);
00063     }
00064 }
00065 
00075 function report_stats_can_access_user_report($user, $course) {
00076     global $USER;
00077 
00078     $coursecontext = context_course::instance($course->id);
00079     $personalcontext = context_user::instance($user->id);
00080 
00081     if (has_capability('report/stats:view', $coursecontext)) {
00082         return true;
00083     }
00084 
00085     if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
00086         if ($course->showreports and (is_viewing($coursecontext, $user) or is_enrolled($coursecontext, $user))) {
00087             return true;
00088         }
00089 
00090     } else if ($user->id == $USER->id) {
00091         if ($course->showreports and (is_viewing($coursecontext, $USER) or is_enrolled($coursecontext, $USER))) {
00092             return true;
00093         }
00094     }
00095 
00096     return false;
00097 }
00098 
00106 function report_stats_page_type_list($pagetype, $parentcontext, $currentcontext) {
00107     $array = array(
00108         '*'                  => get_string('page-x', 'pagetype'),
00109         'report-*'           => get_string('page-report-x', 'pagetype'),
00110         'report-stats-*'     => get_string('page-report-stats-x',  'report_stats'),
00111         'report-stats-index' => get_string('page-report-stats-index',  'report_stats'),
00112         'report-stats-user'  => get_string('page-report-stats-user',  'report_stats')
00113     );
00114     return $array;
00115 }
 All Data Structures Namespaces Files Functions Variables Enumerations