3 // This file is part of Moodle - http://moodle.org/
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.
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/>.
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
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);
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)));
54 $url->param('page', $page);
57 $url->param('perpage', $perpage);
61 $PAGE->set_title("$course->fullname: $fullname: $strportfolios");
62 $PAGE->set_heading($course->fullname
);
63 $PAGE->set_context(context_user
::instance($user->id
));
64 $PAGE->set_pagelayout('report');
66 echo $OUTPUT->header();
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();
77 get_string('displayarea', 'portfolio'),
78 get_string('plugin', 'portfolio'),
79 get_string('displayinfo', 'portfolio'),
80 get_string('displayexpiry', 'portfolio'),
83 $table->data
= array();
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 .= $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
),
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
));
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 if (!empty($log->caller_file
)) {
121 portfolio_include_callback_file($log->caller_file
);
122 } else if (!empty($log->caller_component
)) {
123 portfolio_include_callback_file($log->caller_component
);
124 } else { // Errrmahgerrrd - this should never happen. Skipping.
127 $class = $log->caller_class
;
130 $plugin = portfolio_instance($log->portfolio
);
131 $url = $plugin->resolve_static_continue_url($log->continueurl
);
133 $pluginname = '<a href="' . $url . '">' . $plugin->get('name') . '</a>';
135 $pluginname = $plugin->get('name');
137 } catch (portfolio_exception
$e) { // may have been deleted
138 $pluginname = get_string('unknownplugin', 'portfolio');
141 $table->data
[] = array(
143 '<a href="' . $log->returnurl
. '">' . call_user_func(array($class, 'display_name')) . '</a>',
144 userdate($log->time
),
147 echo $OUTPUT->heading(get_string('logsummary', 'portfolio'));
148 $pagingbar = new paging_bar($logcount, $page, $perpage, $CFG->wwwroot
. '/user/portfoliologs.php?');
149 echo $OUTPUT->render($pagingbar);
150 echo html_writer
::table($table);
151 echo $OUTPUT->render($pagingbar);
152 $somethingprinted = true;
154 if (!$somethingprinted) {
155 echo $OUTPUT->heading($strportfolios);
156 echo get_string('nologs', 'portfolio');
158 echo $OUTPUT->box_end();
159 echo $OUTPUT->footer();