[ Index ] |
PHP Cross Reference of Unnamed Project |
[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("../config.php"); 26 require_once($CFG->dirroot .'/notes/lib.php'); 27 28 $id = required_param('id', PARAM_INT); // Course id. 29 $users = optional_param_array('userid', array(), PARAM_INT); // Array of user id. 30 $content = optional_param('content', '', PARAM_RAW); // Note content. 31 $state = optional_param('state', '', PARAM_ALPHA); // Note publish state. 32 33 $url = new moodle_url('/user/groupaddnote.php', array('id' => $id)); 34 if ($content !== '') { 35 $url->param('content', $content); 36 } 37 if ($state !== '') { 38 $url->param('state', $state); 39 } 40 $PAGE->set_url($url); 41 42 if (! $course = $DB->get_record('course', array('id' => $id))) { 43 print_error('invalidcourseid'); 44 } 45 46 $context = context_course::instance($id); 47 require_login($course); 48 49 // To create notes the current user needs a capability. 50 require_capability('moodle/notes:manage', $context); 51 52 if (empty($CFG->enablenotes)) { 53 print_error('notesdisabled', 'notes'); 54 } 55 56 if (!empty($users) && !empty($content) && confirm_sesskey()) { 57 $note = new stdClass(); 58 $note->courseid = $id; 59 $note->format = FORMAT_PLAIN; 60 $note->content = $content; 61 $note->publishstate = $state; 62 foreach ($users as $k => $v) { 63 if (!$user = $DB->get_record('user', array('id' => $v))) { 64 continue; 65 } 66 $note->id = 0; 67 $note->userid = $v; 68 note_save($note); 69 } 70 71 redirect("$CFG->wwwroot/user/index.php?id=$id"); 72 } 73 74 $straddnote = get_string('groupaddnewnote', 'notes'); 75 76 $PAGE->navbar->add($straddnote); 77 $PAGE->set_title("$course->shortname: ".get_string('extendenrol')); 78 $PAGE->set_heading($course->fullname); 79 80 // Print headers. 81 echo $OUTPUT->header(); 82 83 // This will contain all available the based On select options, but we'll disable some on them on a per user basis. 84 85 echo $OUTPUT->heading($straddnote); 86 echo '<form method="post" action="groupaddnote.php" >'; 87 echo '<div style="width:100%;text-align:center;">'; 88 echo '<input type="hidden" name="id" value="'.$course->id.'" />'; 89 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; 90 $statenames = note_get_state_names(); 91 92 // The first time list hack. 93 if (empty($users) and $post = data_submitted()) { 94 foreach ($post as $k => $v) { 95 if (preg_match('/^user(\d+)$/', $k, $m)) { 96 $users[] = $m[1]; 97 } 98 } 99 } 100 101 $userlist = array(); 102 foreach ($users as $k => $v) { 103 if (!$user = $DB->get_record('user', array('id' => $v))) { 104 continue; 105 } 106 echo '<input type="hidden" name="userid['.$k.']" value="'.$v.'" />'; 107 $userlist[] = fullname($user, true); 108 } 109 echo '<p>'; 110 echo get_string('users'). ': ' . implode(', ', $userlist) . '.'; 111 echo '</p>'; 112 113 echo '<p>' . get_string('content', 'notes'); 114 echo '<br /><textarea name="content" rows="5" cols="50" spellcheck="true">' . strip_tags(@$content) . '</textarea></p>'; 115 116 echo '<p>'; 117 echo html_writer::label(get_string('publishstate', 'notes'), 'menustate'); 118 echo $OUTPUT->help_icon('publishstate', 'notes'); 119 echo html_writer::select($statenames, 'state', empty($state) ? NOTES_STATE_PUBLIC : $state, false); 120 echo '</p>'; 121 122 echo '<input type="submit" value="' . get_string('savechanges'). '" /></div></form>'; 123 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |