|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00026 require_once(dirname(dirname(__FILE__)) . '/config.php'); 00027 00028 if (empty($CFG->enableportfolios)) { 00029 print_error('disabled', 'portfolio'); 00030 } 00031 00032 require_once($CFG->libdir . '/portfoliolib.php'); 00033 require_once($CFG->libdir . '/portfolio/exporter.php'); 00034 00035 $courseid = optional_param('courseid', SITEID, PARAM_INT); 00036 $page = optional_param('page', 0, PARAM_INT); 00037 $perpage = optional_param('perpage', 10, PARAM_INT); 00038 00039 if (! $course = $DB->get_record("course", array("id"=>$courseid))) { 00040 print_error('invalidcourseid'); 00041 } 00042 00043 require_login($course, false); 00044 00045 $user = $USER; 00046 $fullname = fullname($user); 00047 $strportfolios = get_string('portfolios', 'portfolio'); 00048 00049 $url = new moodle_url('/user/portfoliologs.php', array('courseid'=>$courseid)); 00050 00051 navigation_node::override_active_url(new moodle_url('/user/portfoliologs.php', array('courseid'=>$courseid))); 00052 00053 if ($page !== 0) { 00054 $url->param('page', $page); 00055 } 00056 if ($perpage !== 0) { 00057 $url->param('perpage', $perpage); 00058 } 00059 00060 $PAGE->set_url($url); 00061 $PAGE->set_title("$course->fullname: $fullname: $strportfolios"); 00062 $PAGE->set_heading($course->fullname); 00063 $PAGE->set_context(get_context_instance(CONTEXT_USER, $user->id)); 00064 $PAGE->set_pagelayout('standard'); 00065 00066 echo $OUTPUT->header(); 00067 00068 $showroles = 1; 00069 $somethingprinted = false; 00070 00071 echo $OUTPUT->box_start(); 00072 00073 $queued = $DB->get_records('portfolio_tempdata', array('userid' => $USER->id), 'expirytime DESC', 'id, expirytime'); 00074 if (count($queued) > 0) { 00075 $table = new html_table(); 00076 $table->head = array( 00077 get_string('displayarea', 'portfolio'), 00078 get_string('plugin', 'portfolio'), 00079 get_string('displayinfo', 'portfolio'), 00080 get_string('displayexpiry', 'portfolio'), 00081 '', 00082 ); 00083 $table->data = array(); 00084 $now = time(); 00085 foreach ($queued as $q){ 00086 $e = portfolio_exporter::rewaken_object($q->id); 00087 $e->verify_rewaken(true); 00088 $queued = $e->get('queued'); 00089 $baseurl = new moodle_url('/portfolio/add.php', array('id'=>$q->id, 'logreturn'=>1, 'sesskey'=>sesskey())); 00090 00091 $iconstr = $OUTPUT->action_icon(new moodle_url($baseurl, array('cancel'=>1)), new pix_icon('t/stop', get_string('cancel'))); 00092 00093 if (!$e->get('queued') && $e->get('expirytime') > $now) { 00094 $iconstr .= ' ' . $OUTPUT->action_icon($baseurl, new pix_icon('t/go', get_string('continue'))); 00095 } 00096 $table->data[] = array( 00097 $e->get('caller')->display_name(), 00098 (($e->get('instance')) ? $e->get('instance')->get('name') : get_string('noinstanceyet', 'portfolio')), 00099 $e->get('caller')->heading_summary(), 00100 userdate($q->expirytime), 00101 $iconstr, 00102 ); 00103 unset($e); // this could potentially be quite big, so free it. 00104 } 00105 echo $OUTPUT->heading(get_string('queuesummary', 'portfolio')); 00106 echo html_writer::table($table); 00107 $somethingprinted = true; 00108 } 00109 // paging - get total count separately 00110 $logcount = $DB->count_records('portfolio_log', array('userid' => $USER->id)); 00111 if ($logcount > 0) { 00112 $table = new html_table(); 00113 $table->head = array( 00114 get_string('plugin', 'portfolio'), 00115 get_string('displayarea', 'portfolio'), 00116 get_string('transfertime', 'portfolio'), 00117 ); 00118 $logs = $DB->get_records('portfolio_log', array('userid' => $USER->id), 'time DESC', '*', ($page * $perpage), $perpage); 00119 foreach ($logs as $log) { 00120 require_once($CFG->dirroot . $log->caller_file); 00121 $class = $log->caller_class; 00122 $pluginname = ''; 00123 try { 00124 $plugin = portfolio_instance($log->portfolio); 00125 $url = $plugin->resolve_static_continue_url($log->continueurl); 00126 if ($url) { 00127 $pluginname = '<a href="' . $url . '">' . $plugin->get('name') . '</a>'; 00128 } else { 00129 $pluginname = $plugin->get('name'); 00130 } 00131 } catch (portfolio_exception $e) { // may have been deleted 00132 $pluginname = get_string('unknownplugin', 'portfolio'); 00133 } 00134 00135 $table->data[] = array( 00136 $pluginname, 00137 '<a href="' . $log->returnurl . '">' . call_user_func(array($class, 'display_name')) . '</a>', 00138 userdate($log->time), 00139 ); 00140 } 00141 echo $OUTPUT->heading(get_string('logsummary', 'portfolio')); 00142 $pagingbar = new paging_bar($logcount, $page, $perpage, $CFG->wwwroot . '/user/portfoliologs.php?'); 00143 echo $OUTPUT->render($pagingbar); 00144 echo html_writer::table($table); 00145 echo $OUTPUT->render($pagingbar); 00146 $somethingprinted = true; 00147 } 00148 if (!$somethingprinted) { 00149 echo $OUTPUT->heading($strportfolios); 00150 echo get_string('nologs', 'portfolio'); 00151 } 00152 echo $OUTPUT->box_end(); 00153 echo $OUTPUT->footer(); 00154 00155