MDL-20821 MDL-20889 reverting previous cleanup, we need to import new versions instead
[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
36$url = new moodle_url($CFG->wwwroot.'/user/portfoliologs.php', array('course'=>$course));
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
8bde1611 71$queued = $DB->get_records('portfolio_tempdata', array('userid' => $USER->id), '', 'id, expirytime');
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
PL
86 $queued = $e->get('queued');
87 $base = $CFG->wwwroot . '/portfolio/add.php?id=' . $q->id . '&logreturn=1&sesskey=' . sesskey();
88 $iconstr = '';
89
90 $cancel = new moodle_action_icon();
91 $cancel->link->url = new moodle_url($base . '&cancel=1');
92 $cancel->image->src = $OUTPUT->old_icon_url('t/stop');
93 $cancel->linktext = get_string('cancel');
94
95 $iconstr = $OUTPUT->action_icon($cancel);
96
97 if (!$e->get('queued') && $e->get('expirytime') > $now) {
98 $continue = new moodle_action_icon();
99 $continue->link->url = new moodle_url($base);
100 $continue->image->src = $OUTPUT->old_icon_url('t/go');
101 $continue->linktext = get_string('continue');
102 $iconstr .= '&nbsp;' . $OUTPUT->action_icon($continue);
103 }
8bde1611 104 $table->data[] = array(
105 $e->get('caller')->display_name(),
c95a6095 106 (($e->get('instance')) ? $e->get('instance')->get('name') : get_string('noinstanceyet', 'portfolio')),
8bde1611 107 $e->get('caller')->heading_summary(),
108 userdate($q->expirytime),
c95a6095 109 $iconstr,
8bde1611 110 );
111 unset($e); // this could potentially be quite big, so free it.
112 }
f24ca3ce 113 echo $OUTPUT->heading(get_string('queuesummary', 'portfolio'));
f2f085ee 114 echo $OUTPUT->table($table);
c95a6095 115 $somethingprinted = true;
8bde1611 116}
c95a6095 117// paging - get total count separately
8bde1611 118$logcount = $DB->count_records('portfolio_log', array('userid' => $USER->id));
119if ($logcount > 0) {
f2f085ee 120 $table = new html_table();
8bde1611 121 $table->head = array(
122 get_string('plugin', 'portfolio'),
123 get_string('displayarea', 'portfolio'),
124 get_string('transfertime', 'portfolio'),
125 );
126 $logs = $DB->get_records('portfolio_log', array('userid' => $USER->id), 'time DESC', '*', ($page * $perpage), $perpage);
127 foreach ($logs as $log) {
128 require_once($CFG->dirroot . $log->caller_file);
129 $class = $log->caller_class;
130 $pluginname = '';
131 try {
132 $plugin = portfolio_instance($log->portfolio);
133 $pluginname = $plugin->get('name');
134 } catch (portfolio_exception $e) { // may have been deleted
135 $pluginname = get_string('unknownplugin', 'portfolio');
136 }
137
138 $table->data[] = array(
139 $pluginname,
140 call_user_func(array($class, 'display_name')),
141 userdate($log->time),
142 );
143 }
f24ca3ce 144 echo $OUTPUT->heading(get_string('logsummary', 'portfolio'));
da9ac19f 145 $pagingbar = moodle_paging_bar::make($logcount, $page, $perpage, $CFG->wwwroot . '/user/portfoliologs.php?');
ecd035a4 146 echo $OUTPUT->paging_bar($pagingbar);
f2f085ee 147 echo $OUTPUT->table($table);
ecd035a4 148 echo $OUTPUT->paging_bar($pagingbar);
c95a6095 149 $somethingprinted = true;
8bde1611 150}
c95a6095
PL
151if (!$somethingprinted) {
152 echo $OUTPUT->heading($strportfolios);
153 echo get_string('nologs', 'portfolio');
154}
155echo $OUTPUT->box_end();
f24ca3ce 156echo $OUTPUT->footer();
8bde1611 157
aa6c1ced 158