Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/report/completion/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_completion_extend_navigation_course($navigation, $course, $context) {
00036     global $CFG;
00037 
00038     require_once($CFG->libdir.'/completionlib.php');
00039 
00040     if (has_capability('report/completion:view', $context)) {
00041         $completion = new completion_info($course);
00042         if ($completion->is_enabled() && $completion->has_criteria()) {
00043             $url = new moodle_url('/report/completion/index.php', array('course'=>$course->id));
00044             $navigation->add(get_string('pluginname','report_completion'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
00045         }
00046     }
00047 }
00048 
00056 function report_completion_extend_navigation_user($navigation, $user, $course) {
00057 
00058     return; //TODO: this plugin was not linked from navigation in 2.0, let's keep it that way for now --skodak
00059 
00060     if (report_completion_can_access_user_report($user, $course)) {
00061         $url = new moodle_url('/report/completion/user.php', array('id'=>$user->id, 'course'=>$course->id));
00062         $navigation->add(get_string('coursecompletion'), $url);
00063     }
00064 }
00065 
00075 function report_completion_can_access_user_report($user, $course) {
00076     global $USER, $CFG;
00077 
00078     if (empty($CFG->enablecompletion)) {
00079         return false;
00080     }
00081 
00082     if ($course->id != SITEID and !$course->enablecompletion) {
00083         return;
00084     }
00085 
00086     $coursecontext = context_course::instance($course->id);
00087     $personalcontext = context_user::instance($user->id);
00088 
00089     if (has_capability('report/completion:view', $coursecontext)) {
00090         return true;
00091     }
00092 
00093     if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
00094         if ($course->showreports and (is_viewing($coursecontext, $user) or is_enrolled($coursecontext, $user))) {
00095             return true;
00096         }
00097 
00098     } else if ($user->id == $USER->id) {
00099         if ($course->showreports and (is_viewing($coursecontext, $USER) or is_enrolled($coursecontext, $USER))) {
00100             return true;
00101         }
00102     }
00103 
00104     return false;
00105 }
00106 
00114 function report_completion_page_type_list($pagetype, $parentcontext, $currentcontext) {
00115     $array = array(
00116         '*'                       => get_string('page-x', 'pagetype'),
00117         'report-*'                => get_string('page-report-x', 'pagetype'),
00118         'report-completion-*'     => get_string('page-report-completion-x',  'report_completion'),
00119         'report-completion-index' => get_string('page-report-completion-index',  'report_completion'),
00120         'report-completion-user'  => get_string('page-report-completion-user',  'report_completion')
00121     );
00122     return $array;
00123 }
 All Data Structures Namespaces Files Functions Variables Enumerations