MDL-31902 general: Removing deprecated functions
[moodle.git] / user / portfoliologs.php
blob1690b1f63814cd49919b910375c88b29ae4ea114
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 navigation_node::override_active_url(new moodle_url('/user/portfoliologs.php', array('courseid'=>$courseid)));
53 if ($page !== 0) {
54 $url->param('page', $page);
56 if ($perpage !== 0) {
57 $url->param('perpage', $perpage);
60 $PAGE->set_url($url);
61 $PAGE->set_title("$course->fullname: $fullname: $strportfolios");
62 $PAGE->set_heading($course->fullname);
63 $PAGE->set_context(get_context_instance(CONTEXT_USER, $user->id));
64 $PAGE->set_pagelayout('standard');
66 echo $OUTPUT->header();
68 $showroles = 1;
69 $somethingprinted = false;
71 echo $OUTPUT->box_start();
73 $queued = $DB->get_records('portfolio_tempdata', array('userid' => $USER->id), 'expirytime DESC', 'id, expirytime');
74 if (count($queued) > 0) {
75 $table = new html_table();
76 $table->head = array(
77 get_string('displayarea', 'portfolio'),
78 get_string('plugin', 'portfolio'),
79 get_string('displayinfo', 'portfolio'),
80 get_string('displayexpiry', 'portfolio'),
81 '',
83 $table->data = array();
84 $now = time();
85 foreach ($queued as $q){
86 $e = portfolio_exporter::rewaken_object($q->id);
87 $e->verify_rewaken(true);
88 $queued = $e->get('queued');
89 $baseurl = new moodle_url('/portfolio/add.php', array('id'=>$q->id, 'logreturn'=>1, 'sesskey'=>sesskey()));
91 $iconstr = $OUTPUT->action_icon(new moodle_url($baseurl, array('cancel'=>1)), new pix_icon('t/stop', get_string('cancel')));
93 if (!$e->get('queued') && $e->get('expirytime') > $now) {
94 $iconstr .= '&nbsp;' . $OUTPUT->action_icon($baseurl, new pix_icon('t/go', get_string('continue')));
96 $table->data[] = array(
97 $e->get('caller')->display_name(),
98 (($e->get('instance')) ? $e->get('instance')->get('name') : get_string('noinstanceyet', 'portfolio')),
99 $e->get('caller')->heading_summary(),
100 userdate($q->expirytime),
101 $iconstr,
103 unset($e); // this could potentially be quite big, so free it.
105 echo $OUTPUT->heading(get_string('queuesummary', 'portfolio'));
106 echo html_writer::table($table);
107 $somethingprinted = true;
109 // paging - get total count separately
110 $logcount = $DB->count_records('portfolio_log', array('userid' => $USER->id));
111 if ($logcount > 0) {
112 $table = new html_table();
113 $table->head = array(
114 get_string('plugin', 'portfolio'),
115 get_string('displayarea', 'portfolio'),
116 get_string('transfertime', 'portfolio'),
118 $logs = $DB->get_records('portfolio_log', array('userid' => $USER->id), 'time DESC', '*', ($page * $perpage), $perpage);
119 foreach ($logs as $log) {
120 require_once($CFG->dirroot . $log->caller_file);
121 $class = $log->caller_class;
122 $pluginname = '';
123 try {
124 $plugin = portfolio_instance($log->portfolio);
125 $url = $plugin->resolve_static_continue_url($log->continueurl);
126 if ($url) {
127 $pluginname = '<a href="' . $url . '">' . $plugin->get('name') . '</a>';
128 } else {
129 $pluginname = $plugin->get('name');
131 } catch (portfolio_exception $e) { // may have been deleted
132 $pluginname = get_string('unknownplugin', 'portfolio');
135 $table->data[] = array(
136 $pluginname,
137 '<a href="' . $log->returnurl . '">' . call_user_func(array($class, 'display_name')) . '</a>',
138 userdate($log->time),
141 echo $OUTPUT->heading(get_string('logsummary', 'portfolio'));
142 $pagingbar = new paging_bar($logcount, $page, $perpage, $CFG->wwwroot . '/user/portfoliologs.php?');
143 echo $OUTPUT->render($pagingbar);
144 echo html_writer::table($table);
145 echo $OUTPUT->render($pagingbar);
146 $somethingprinted = true;
148 if (!$somethingprinted) {
149 echo $OUTPUT->heading($strportfolios);
150 echo get_string('nologs', 'portfolio');
152 echo $OUTPUT->box_end();
153 echo $OUTPUT->footer();