MDL-21695 adding help and link strings
[moodle.git] / user / portfolio.php
blobdac069959f043ae880cef1ad172e75525effcc20
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/forms.php');
35 $config = optional_param('config', 0, PARAM_INT);
36 $hide = optional_param('hide', 0, PARAM_INT);
37 $course = optional_param('course', SITEID, PARAM_INT);
39 $url = new moodle_url('/user/portfolio.php', array('course'=>$course));
40 if ($hide !== 0) {
41 $url->param('hide', $hide);
43 if ($config !== 0) {
44 $url->param('config', $config);
46 $PAGE->set_url($url);
48 if (! $course = $DB->get_record("course", array("id"=>$course))) {
49 print_error('invalidcourseid');
52 $user = $USER;
53 $fullname = fullname($user);
54 $strportfolios = get_string('portfolios', 'portfolio');
55 $configstr = get_string('manageyourportfolios', 'portfolio');
56 $namestr = get_string('name');
57 $pluginstr = get_string('plugin', 'portfolio');
58 $baseurl = $CFG->wwwroot . '/user/portfolio.php';
60 $display = true; // set this to false in the conditions to stop processing
62 require_login($course, false);
64 echo $OUTPUT->header();
65 $currenttab = 'portfolioconf';
66 $showroles = 1;
67 include('tabs.php');
69 if (!empty($config)) {
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);
79 //this branch is where you process validated data.
80 $success = $instance->set_user_config($fromform, $USER->id);
81 //$success = $success && $instance->save();
82 if ($success) {
83 redirect($baseurl, get_string('instancesaved', 'portfolio'), 3);
84 } else {
85 print_error('instancenotsaved', 'portfolio', $baseurl);
87 exit;
88 } else {
89 echo $OUTPUT->heading(get_string('configplugin', 'portfolio'));
90 echo $OUTPUT->box_start();
91 $mform->display();
92 echo $OUTPUT->box_end();
93 $display = false;
96 } else if (!empty($hide)) {
97 $instance = portfolio_instance($hide);
98 $instance->set_user_config(array('visible' => !$instance->get_user_config('visible', $USER->id)), $USER->id);
101 if ($display) {
102 echo $OUTPUT->heading($configstr);
103 echo $OUTPUT->box_start();
105 if (!$instances = portfolio_instances(true, false)) {
106 print_error('noinstances', 'portfolio', $CFG->wwwroot . '/user/view.php');
109 $table = new html_table();
110 $table->head = array($namestr, $pluginstr, '');
111 $table->data = array();
113 foreach ($instances as $i) {
114 $visible = $i->get_user_config('visible', $USER->id);
115 $table->data[] = array($i->get('name'), $i->get('plugin'),
116 ($i->has_user_config()
117 ? '<a href="' . $baseurl . '?config=' . $i->get('id') . '"><img src="' . $OUTPUT->pix_url('t/edit') . '" alt="' . get_string('configure') . '" /></a>' : '') .
118 ' <a href="' . $baseurl . '?hide=' . $i->get('id') . '"><img src="' . $OUTPUT->pix_url('t/' . (($visible) ? 'hide' : 'show')) . '" alt="' . get_string($visible ? 'hide' : 'show') . '" /></a><br />'
122 echo html_writer::table($table);
123 echo $OUTPUT->box_end();
125 echo $OUTPUT->footer();