MDL-23232 added support for enrol_plugin->all_enrol() which indicates plugin allows...
[moodle.git] / user / portfoliologs.php
CommitLineData
8bde1611 1<?php
2
ce221eb5 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.
14//
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/>.
17
18/**
19 * This file is part of the User section Moodle
20 *
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
24 */
25
8bde1611 26require_once(dirname(dirname(__FILE__)) . '/config.php');
27
28if (empty($CFG->enableportfolios)) {
29 print_error('disabled', 'portfolio');
30}
31
32require_once($CFG->libdir . '/portfoliolib.php');
33
34$course = optional_param('course', SITEID, PARAM_INT);
ce221eb5 35
a6855934 36$url = new moodle_url('/user/portfoliologs.php', array('course'=>$course));
ce221eb5 37
8bde1611 38if (! $course = $DB->get_record("course", array("id"=>$course))) {
39 print_error('invalidcourseid');
40}
41
42$user = $USER;
43$fullname = fullname($user);
44$strportfolios = get_string('portfolios', 'portfolio');
45
46require_login($course, false);
47
48$page = optional_param('page', 0, PARAM_INT);
49$perpage = optional_param('perpage', 10, PARAM_INT);
50
ce221eb5 51if ($page !== 0) {
52 $url->param('page', $page);
53}
54if ($perpage !== 0) {
55 $url->param('perpage', $perpage);
56}
57$PAGE->set_url($url);
58
caa8363f 59$PAGE->set_title("$course->fullname: $fullname: $strportfolios");
60$PAGE->set_heading($course->fullname);
8bde1611 61
caa8363f 62echo $OUTPUT->header();
8bde1611 63
55de6e07 64$currenttab = 'portfoliologs';
8bde1611 65$showroles = 1;
c95a6095 66$somethingprinted = false;
8bde1611 67include('tabs.php');
68
c95a6095
PL
69echo $OUTPUT->box_start();
70
59dd457e 71$queued = $DB->get_records('portfolio_tempdata', array('userid' => $USER->id), 'expirytime DESC', 'id, expirytime');
8bde1611 72if (count($queued) > 0) {
f2f085ee 73 $table = new html_table();
8bde1611 74 $table->head = array(
75 get_string('displayarea', 'portfolio'),
76 get_string('plugin', 'portfolio'),
77 get_string('displayinfo', 'portfolio'),
78 get_string('displayexpiry', 'portfolio'),
c95a6095 79 '',
8bde1611 80 );
81 $table->data = array();
c95a6095 82 $now = time();
8bde1611 83 foreach ($queued as $q){
84 $e = portfolio_exporter::rewaken_object($q->id);
85 $e->verify_rewaken(true);
c95a6095 86 $queued = $e->get('queued');
a6855934 87 $baseurl = new moodle_url('/portfolio/add.php', array('id'=>$q->id, 'logreturn'=>1, 'sesskey'=>sesskey()));
c95a6095 88
c63923bd 89 $iconstr = $OUTPUT->action_icon(new moodle_url($baseurl, array('cancel'=>1)), new pix_icon('t/stop', get_string('cancel')));
c95a6095
PL
90
91 if (!$e->get('queued') && $e->get('expirytime') > $now) {
c63923bd 92 $iconstr .= '&nbsp;' . $OUTPUT->action_icon($baseurl, new pix_icon('t/go', get_string('continue')));
c95a6095 93 }
8bde1611 94 $table->data[] = array(
95 $e->get('caller')->display_name(),
c95a6095 96 (($e->get('instance')) ? $e->get('instance')->get('name') : get_string('noinstanceyet', 'portfolio')),
8bde1611 97 $e->get('caller')->heading_summary(),
98 userdate($q->expirytime),
c95a6095 99 $iconstr,
8bde1611 100 );
101 unset($e); // this could potentially be quite big, so free it.
102 }
f24ca3ce 103 echo $OUTPUT->heading(get_string('queuesummary', 'portfolio'));
16be8974 104 echo html_writer::table($table);
c95a6095 105 $somethingprinted = true;
8bde1611 106}
c95a6095 107// paging - get total count separately
8bde1611 108$logcount = $DB->count_records('portfolio_log', array('userid' => $USER->id));
109if ($logcount > 0) {
f2f085ee 110 $table = new html_table();
8bde1611 111 $table->head = array(
112 get_string('plugin', 'portfolio'),
113 get_string('displayarea', 'portfolio'),
114 get_string('transfertime', 'portfolio'),
115 );
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);
5d0dbf13
PL
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');
128 }
8bde1611 129 } catch (portfolio_exception $e) { // may have been deleted
130 $pluginname = get_string('unknownplugin', 'portfolio');
131 }
132
133 $table->data[] = array(
134 $pluginname,
5d0dbf13 135 '<a href="' . $log->returnurl . '">' . call_user_func(array($class, 'display_name')) . '</a>',
8bde1611 136 userdate($log->time),
137 );
138 }
f24ca3ce 139 echo $OUTPUT->heading(get_string('logsummary', 'portfolio'));
929d7a83
PS
140 $pagingbar = new paging_bar($logcount, $page, $perpage, $CFG->wwwroot . '/user/portfoliologs.php?');
141 echo $OUTPUT->render($pagingbar);
16be8974 142 echo html_writer::table($table);
929d7a83 143 echo $OUTPUT->render($pagingbar);
c95a6095 144 $somethingprinted = true;
8bde1611 145}
c95a6095
PL
146if (!$somethingprinted) {
147 echo $OUTPUT->heading($strportfolios);
148 echo get_string('nologs', 'portfolio');
149}
150echo $OUTPUT->box_end();
f24ca3ce 151echo $OUTPUT->footer();
8bde1611 152
aa6c1ced 153