MDL-25072 convert $CFG->disablecourseajax to $CFG->enablecourseajax
[moodle.git] / user / portfoliologs.php
blob3993261778355e28a74ec5e7fdc8d88564b81199
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * This file is part of the User section Moodle
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @package user
26 require_once(dirname(dirname(__FILE__)) . '/config.php');
28 if (empty($CFG->enableportfolios)) {
29 print_error('disabled', 'portfolio');
32 require_once($CFG->libdir . '/portfoliolib.php');
33 require_once($CFG->libdir . '/portfolio/exporter.php');
35 $courseid = optional_param('courseid', SITEID, PARAM_INT);
36 $page = optional_param('page', 0, PARAM_INT);
37 $perpage = optional_param('perpage', 10, PARAM_INT);
39 if (! $course = $DB->get_record("course", array("id"=>$courseid))) {
40 print_error('invalidcourseid');
43 require_login($course, false);
45 $user = $USER;
46 $fullname = fullname($user);
47 $strportfolios = get_string('portfolios', 'portfolio');
49 $url = new moodle_url('/user/portfoliologs.php', array('courseid'=>$courseid));
51 if ($page !== 0) {
52 $url->param('page', $page);
54 if ($perpage !== 0) {
55 $url->param('perpage', $perpage);
58 $PAGE->set_url($url);
59 $PAGE->set_title("$course->fullname: $fullname: $strportfolios");
60 $PAGE->set_heading($course->fullname);
61 $PAGE->set_context(get_context_instance(CONTEXT_USER, $user->id));
62 $PAGE->set_pagelayout('standard');
64 echo $OUTPUT->header();
66 $showroles = 1;
67 $somethingprinted = false;
69 echo $OUTPUT->box_start();
71 $queued = $DB->get_records('portfolio_tempdata', array('userid' => $USER->id), 'expirytime DESC', 'id, expirytime');
72 if (count($queued) > 0) {
73 $table = new html_table();
74 $table->head = array(
75 get_string('displayarea', 'portfolio'),
76 get_string('plugin', 'portfolio'),
77 get_string('displayinfo', 'portfolio'),
78 get_string('displayexpiry', 'portfolio'),
79 '',
81 $table->data = array();
82 $now = time();
83 foreach ($queued as $q){
84 $e = portfolio_exporter::rewaken_object($q->id);
85 $e->verify_rewaken(true);
86 $queued = $e->get('queued');
87 $baseurl = new moodle_url('/portfolio/add.php', array('id'=>$q->id, 'logreturn'=>1, 'sesskey'=>sesskey()));
89 $iconstr = $OUTPUT->action_icon(new moodle_url($baseurl, array('cancel'=>1)), new pix_icon('t/stop', get_string('cancel')));
91 if (!$e->get('queued') && $e->get('expirytime') > $now) {
92 $iconstr .= '&nbsp;' . $OUTPUT->action_icon($baseurl, new pix_icon('t/go', get_string('continue')));
94 $table->data[] = array(
95 $e->get('caller')->display_name(),
96 (($e->get('instance')) ? $e->get('instance')->get('name') : get_string('noinstanceyet', 'portfolio')),
97 $e->get('caller')->heading_summary(),
98 userdate($q->expirytime),
99 $iconstr,
101 unset($e); // this could potentially be quite big, so free it.
103 echo $OUTPUT->heading(get_string('queuesummary', 'portfolio'));
104 echo html_writer::table($table);
105 $somethingprinted = true;
107 // paging - get total count separately
108 $logcount = $DB->count_records('portfolio_log', array('userid' => $USER->id));
109 if ($logcount > 0) {
110 $table = new html_table();
111 $table->head = array(
112 get_string('plugin', 'portfolio'),
113 get_string('displayarea', 'portfolio'),
114 get_string('transfertime', 'portfolio'),
116 $logs = $DB->get_records('portfolio_log', array('userid' => $USER->id), 'time DESC', '*', ($page * $perpage), $perpage);
117 foreach ($logs as $log) {
118 require_once($CFG->dirroot . $log->caller_file);
119 $class = $log->caller_class;
120 $pluginname = '';
121 try {
122 $plugin = portfolio_instance($log->portfolio);
123 $url = $plugin->resolve_static_continue_url($log->continueurl);
124 if ($url) {
125 $pluginname = '<a href="' . $url . '">' . $plugin->get('name') . '</a>';
126 } else {
127 $pluginname = $plugin->get('name');
129 } catch (portfolio_exception $e) { // may have been deleted
130 $pluginname = get_string('unknownplugin', 'portfolio');
133 $table->data[] = array(
134 $pluginname,
135 '<a href="' . $log->returnurl . '">' . call_user_func(array($class, 'display_name')) . '</a>',
136 userdate($log->time),
139 echo $OUTPUT->heading(get_string('logsummary', 'portfolio'));
140 $pagingbar = new paging_bar($logcount, $page, $perpage, $CFG->wwwroot . '/user/portfoliologs.php?');
141 echo $OUTPUT->render($pagingbar);
142 echo html_writer::table($table);
143 echo $OUTPUT->render($pagingbar);
144 $somethingprinted = true;
146 if (!$somethingprinted) {
147 echo $OUTPUT->heading($strportfolios);
148 echo get_string('nologs', 'portfolio');
150 echo $OUTPUT->box_end();
151 echo $OUTPUT->footer();