[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * This file is part of the User section Moodle 19 * 20 * @copyright 1999 Martin Dougiamas http://dougiamas.com 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 * @package core_user 23 */ 24 25 require_once(dirname(dirname(__FILE__)) . '/config.php'); 26 27 if (empty($CFG->enableportfolios)) { 28 print_error('disabled', 'portfolio'); 29 } 30 31 require_once($CFG->libdir . '/portfoliolib.php'); 32 require_once($CFG->libdir . '/portfolio/forms.php'); 33 34 $config = optional_param('config', 0, PARAM_INT); 35 $hide = optional_param('hide', 0, PARAM_INT); 36 $courseid = optional_param('courseid', SITEID, PARAM_INT); 37 38 $url = new moodle_url('/user/portfolio.php', array('courseid' => $courseid)); 39 40 if ($config !== 0) { 41 $url->param('config', $config); 42 } 43 if (! $course = $DB->get_record("course", array("id" => $courseid))) { 44 print_error('invalidcourseid'); 45 } 46 47 $user = $USER; 48 $fullname = fullname($user); 49 $strportfolios = get_string('portfolios', 'portfolio'); 50 $configstr = get_string('manageyourportfolios', 'portfolio'); 51 $namestr = get_string('name'); 52 $pluginstr = get_string('plugin', 'portfolio'); 53 $baseurl = $CFG->wwwroot . '/user/portfolio.php'; 54 55 $display = true; // Set this to false in the conditions to stop processing. 56 57 require_login($course, false); 58 59 $PAGE->set_url($url); 60 $PAGE->set_context(context_user::instance($user->id)); 61 $PAGE->set_title("$course->fullname: $fullname: $strportfolios"); 62 $PAGE->set_heading($course->fullname); 63 $PAGE->set_pagelayout('admin'); 64 65 echo $OUTPUT->header(); 66 $showroles = 1; 67 68 if (!empty($config)) { 69 navigation_node::override_active_url(new moodle_url('/user/portfolio.php', array('courseid' => $courseid))); 70 $instance = portfolio_instance($config); 71 $mform = new portfolio_user_form('', array('instance' => $instance, 'userid' => $user->id)); 72 if ($mform->is_cancelled()) { 73 redirect($baseurl); 74 exit; 75 } else if ($fromform = $mform->get_data()) { 76 if (!confirm_sesskey()) { 77 print_error('confirmsesskeybad', '', $baseurl); 78 } 79 // This branch is where you process validated data. 80 $instance->set_user_config($fromform, $USER->id); 81 core_plugin_manager::reset_caches(); 82 redirect($baseurl, get_string('instancesaved', 'portfolio'), 3); 83 84 exit; 85 } else { 86 echo $OUTPUT->heading(get_string('configplugin', 'portfolio')); 87 echo $OUTPUT->box_start(); 88 $mform->display(); 89 echo $OUTPUT->box_end(); 90 $display = false; 91 } 92 93 } else if (!empty($hide)) { 94 $instance = portfolio_instance($hide); 95 $instance->set_user_config(array('visible' => !$instance->get_user_config('visible', $USER->id)), $USER->id); 96 core_plugin_manager::reset_caches(); 97 } 98 99 if ($display) { 100 echo $OUTPUT->heading($configstr); 101 echo $OUTPUT->box_start(); 102 103 if (!$instances = portfolio_instances(true, false)) { 104 print_error('noinstances', 'portfolio', $CFG->wwwroot . '/user/view.php'); 105 } 106 107 $table = new html_table(); 108 $table->head = array($namestr, $pluginstr, ''); 109 $table->data = array(); 110 111 foreach ($instances as $i) { 112 $visible = $i->get_user_config('visible', $USER->id); 113 $table->data[] = array($i->get('name'), $i->get('plugin'), 114 ($i->has_user_config() 115 ? '<a href="' . $baseurl . '?config=' . $i->get('id') . '"><img src="' . $OUTPUT->pix_url('t/edit') . '" alt="' . get_string('configure') . '" /></a>' : '') . 116 ' <a href="' . $baseurl . '?hide=' . $i->get('id') . '"><img src="' . $OUTPUT->pix_url('t/' . (($visible) ? 'hide' : 'show')) . '" alt="' . get_string($visible ? 'hide' : 'show') . '" /></a><br />' 117 ); 118 } 119 120 echo html_writer::table($table); 121 echo $OUTPUT->box_end(); 122 } 123 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |