/** * Define the form for editing notes */ public function definition() { $mform =& $this->_form; $mform->addElement('header', 'general', get_string('note', 'notes')); $mform->addElement('textarea', 'content', get_string('content', 'notes'), array('rows' => 15, 'cols' => 40)); $mform->setType('content', PARAM_RAW); $mform->addRule('content', get_string('nocontent', 'notes'), 'required', null, 'client'); $mform->addElement('select', 'publishstate', get_string('publishstate', 'notes'), note_get_state_names()); $mform->setDefault('publishstate', NOTES_STATE_PUBLIC); $mform->setType('publishstate', PARAM_ALPHA); $mform->addHelpButton('publishstate', 'publishstate', 'notes'); $this->add_action_buttons(); $mform->addElement('hidden', 'courseid'); $mform->setType('courseid', PARAM_INT); $mform->addElement('hidden', 'userid'); $mform->setType('userid', PARAM_INT); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); }
} redirect("{$CFG->wwwroot}/user/index.php?id={$id}"); } /// Print headers $straddnote = get_string('groupaddnewnote', 'notes'); $navlinks = array(); $navlinks[] = array('name' => $straddnote, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header("{$course->shortname}: " . get_string('extendenrol'), $course->fullname, $navigation, "", "", true, " ", navmenu($course)); // this will contain all available the based On select options, but we'll disable some on them on a per user basis print_heading($straddnote); echo '<form method="post" action="groupaddnote.php" >'; echo '<div style="width:100%;text-align:center;">'; echo '<input type="hidden" name="id" value="' . $course->id . '" />'; echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />'; $state_names = note_get_state_names(); // the first time list hack if (empty($users)) { foreach ($_POST as $k => $v) { if (preg_match('/^user(\\d+)$/', $k, $m)) { $users[] = $m[1]; } } } $strpublishstate = get_string('publishstate', 'notes'); $userlist = array(); foreach ($users as $k => $v) { if (!($user = get_record('user', 'id', $v))) { continue; } echo '<input type="hidden" name="userid[' . $k . ']" value="' . $v . '" />';
/** * Converts a state value to its corespondent name * * @param string $state state value to convert * @return string corespondent state name */ function note_get_state_name($state) { // cache state names static $states; if (empty($states)) { $states = note_get_state_names(); } if (isset($states[$state])) { return $states[$state]; } else { return null; } }
/** * Converts a state value to its corespondent name * * @param string $state state value to convert * @return string corespondent state name */ function note_get_state_name($state) { // cache state names static $states; if (empty($states)) { $states = note_get_state_names(); } return @$states[$state]; }