public function get_content() { global $CFG, $COURSE, $OUTPUT; if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; $context = context_course::instance($COURSE->id); $config = clampmail::load_config($COURSE->id); $permission = has_capability('block/clampmail:cansend', $context); $icon_class = array('class' => 'icon'); if ($permission) { $cparam = array('courseid' => $COURSE->id); $send_email_str = clampmail::_s('composenew'); $send_email = html_writer::link(new moodle_url('/blocks/clampmail/email.php', $cparam), $send_email_str); $this->content->items[] = $send_email; $this->content->icons[] = $OUTPUT->pix_icon('i/email', $send_email_str, 'moodle', $icon_class); $signature_str = clampmail::_s('signature'); $signature = html_writer::link(new moodle_url('/blocks/clampmail/signature.php', $cparam), $signature_str); $this->content->items[] = $signature; $this->content->icons[] = $OUTPUT->pix_icon('i/edit', $signature_str, 'moodle', $icon_class); $draft_params = $cparam + array('type' => 'drafts'); $drafts_email_str = clampmail::_s('drafts'); $drafts = html_writer::link(new moodle_url('/blocks/clampmail/emaillog.php', $draft_params), $drafts_email_str); $this->content->items[] = $drafts; $this->content->icons[] = $OUTPUT->pix_icon('i/settings', $drafts_email_str, 'moodle', $icon_class); $history_str = clampmail::_s('history'); $history = html_writer::link(new moodle_url('/blocks/clampmail/emaillog.php', $cparam), $history_str); $this->content->items[] = $history; $this->content->icons[] = $OUTPUT->pix_icon('i/settings', $history_str, 'moodle', $icon_class); } if (has_capability('block/clampmail:allowalternate', $context)) { $alt_str = clampmail::_s('alternate'); $alt = html_writer::link(new moodle_url('/blocks/clampmail/alternate.php', $cparam), $alt_str); $this->content->items[] = $alt; $this->content->icons[] = $OUTPUT->pix_icon('i/edit', $alt_str, 'moodle', $icon_class); } if (has_capability('block/clampmail:canconfig', $context)) { $config_str = clampmail::_s('config'); $config = html_writer::link(new moodle_url('/blocks/clampmail/config.php', $cparam), $config_str); $this->content->items[] = $config; $this->content->icons[] = $OUTPUT->pix_icon('i/settings', $config_str, 'moodle', $icon_class); } return $this->content; }
public function definition() { $mform =& $this->_form; $reset_link = html_writer::link(new moodle_url('/blocks/clampmail/config.php', array('courseid' => $this->_customdata['courseid'], 'reset' => 1)), clampmail::_s('reset')); $mform->addElement('static', 'reset', '', $reset_link); $student_select = array(0 => get_string('no'), 1 => get_string('yes')); $roles =& $mform->addElement('select', 'roleselection', clampmail::_s('select_roles'), $this->_customdata['roles']); $roles->setMultiple(true); $options = array(0 => get_string('none'), 'idnumber' => get_string('idnumber'), 'shortname' => get_string('shortname')); $mform->addElement('select', 'prepend_class', clampmail::_s('prepend_class'), $options); $mform->addElement('select', 'receipt', clampmail::_s('receipt'), $student_select); $mform->addElement('submit', 'save', get_string('savechanges')); $mform->addElement('hidden', 'courseid', $this->_customdata['courseid']); $mform->setType('courseid', PARAM_INT); $mform->addRule('roleselection', null, 'required'); }
public function definition() { global $USER; $mform =& $this->_form; $mform->addElement('hidden', 'courseid', ''); $mform->setType('courseid', PARAM_INT); $mform->addElement('hidden', 'id', ''); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'userid', $USER->id); $mform->setType('userid', PARAM_INT); $mform->addElement('text', 'title', clampmail::_s('title')); $mform->setType('title', PARAM_TEXT); $mform->addRule('title', get_string('maximumchars', '', 125), 'maxlength', 125, 'client'); $mform->addElement('editor', 'signature_editor', clampmail::_s('sig'), null, $this->_customdata['signature_options']); $mform->setType('signature_editor', PARAM_RAW); $mform->addElement('checkbox', 'default_flag', clampmail::_s('default_flag')); $buttons = array($mform->createElement('submit', 'save', get_string('savechanges')), $mform->createElement('submit', 'delete', get_string('delete')), $mform->createElement('cancel')); $mform->addGroup($buttons, 'buttons', clampmail::_s('actions'), array(' '), false); $mform->addRule('title', null, 'required', null, 'client'); }
} case "delete": $html = clampmail::delete_dialog($courseid, $type, $typeid); break; default: $html = clampmail::list_entries($courseid, $type, $page, $perpage, $userid, $count, $can_delete); } if ($canimpersonate and $USER->id != $userid) { $user = $DB->get_record('user', array('id' => $userid)); $header .= ' for ' . fullname($user); } echo $OUTPUT->header(); echo $OUTPUT->heading($header); if ($canimpersonate) { $sql = "SELECT DISTINCT(l.userid), u.firstname, u.lastname, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename\n FROM {block_clampmail_{$type}} l,\n {user} u\n WHERE u.id = l.userid AND courseid = ? ORDER BY u.lastname"; $users = $DB->get_records_sql($sql, array($courseid)); $user_options = array_map(function ($user) { return fullname($user); }, $users); $url = new moodle_url('emaillog.php', array('courseid' => $courseid, 'type' => $type)); $default_option = array('' => clampmail::_s('select_users')); echo $OUTPUT->single_select($url, 'userid', $user_options, $userid, $default_option); } if (empty($count)) { echo $OUTPUT->notification(clampmail::_s('no_' . $type)); echo $OUTPUT->continue_button('/blocks/clampmail/email.php?courseid=' . $courseid); echo $OUTPUT->footer(); exit; } echo $html; echo $OUTPUT->footer();
if (!empty($type) and empty($typeid)) { $string = new stdclass(); $string->tpe = $type; $string->id = $typeid; print_error('no_typeid', 'block_clampmail', '', $string); } $config = clampmail::load_config($courseid); $context = context_course::instance($courseid); if (!has_capability('block/clampmail:cansend', $context)) { print_error('no_permission', 'block_clampmail'); } $sigs = $DB->get_records('block_clampmail_signatures', array('userid' => $USER->id), 'default_flag DESC'); $alt_params = array('courseid' => $course->id, 'valid' => 1); $alternates = $DB->get_records_menu('block_clampmail_alternate', $alt_params, '', 'id, address'); $blockname = clampmail::_s('pluginname'); $header = clampmail::_s('email'); $PAGE->set_context($context); $PAGE->set_course($course); $PAGE->navbar->add($blockname); $PAGE->navbar->add($header); $PAGE->set_title($blockname . ': ' . $header); $PAGE->set_heading($blockname . ': ' . $header); $PAGE->set_url('/course/view.php', array('courseid' => $courseid)); $PAGE->set_pagetype($blockname); $PAGE->set_pagelayout('standard'); $PAGE->requires->js('/blocks/clampmail/js/jquery.js'); $PAGE->requires->js('/blocks/clampmail/js/selection.js'); // Build role arrays. $course_roles = get_roles_used_in_context($context); $filter_roles = $DB->get_records_select('role', sprintf('id IN (%s)', $config['roleselection'])); $roles = clampmail::filter_roles($course_roles, $filter_roles);
* @copyright 2012 Louisiana State University (original Quickmail block) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once '../../config.php'; require_once 'lib.php'; require_once 'config_form.php'; require_login(); $courseid = required_param('courseid', PARAM_INT); $reset = optional_param('reset', 0, PARAM_INT); if (!($course = $DB->get_record('course', array('id' => $courseid)))) { print_error('no_course', 'block_clampmail', '', $courseid); } $context = context_course::instance($courseid); require_capability('block/clampmail:canconfig', $context); $blockname = clampmail::_s('pluginname'); $header = clampmail::_s('config'); $PAGE->set_context($context); $PAGE->set_course($course); $PAGE->set_url('/blocks/clampmail/config.php', array('courseid' => $courseid)); $PAGE->set_title($blockname . ': ' . $header); $PAGE->set_heading($blockname . ': ' . $header); $PAGE->navbar->add($header); $PAGE->set_pagetype($blockname); $PAGE->set_pagelayout('standard'); $changed = false; if ($reset) { $changed = true; clampmail::default_config($courseid); } $roles = $DB->get_records_menu('role', null, 'sortorder ASC', 'id, shortname'); $form = new config_form(null, array('courseid' => $courseid, 'roles' => $roles));
*/ require_once '../../config.php'; require_once 'lib.php'; require_once 'alt_lib.php'; require_once 'alt_form.php'; $courseid = required_param('courseid', PARAM_INT); $action = optional_param('action', 'view', PARAM_TEXT); $id = optional_param('id', null, PARAM_INT); $flash = optional_param('flash', 0, PARAM_INT); $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); $context = context_course::instance($courseid); // Permission. require_login($course); require_capability('block/clampmail:allowalternate', $context); $blockname = clampmail::_s('pluginname'); $heading = clampmail::_s('alternate'); $title = "{$blockname}: {$heading}"; $url = new moodle_url('/blocks/clampmail/alternate.php', array('courseid' => $courseid)); $PAGE->set_url($url); $PAGE->set_context($context); $PAGE->set_course($course); $PAGE->navbar->add($blockname); $PAGE->navbar->add($heading); $PAGE->set_title($title); $PAGE->set_heading($title); if (!method_exists('clampmail_alternate', $action)) { // Always fallback on view. $action = 'view'; } $body = clampmail_alternate::$action($course, $id); echo $OUTPUT->header();
public static function view($course) { global $OUTPUT; $alternates = self::get($course); $new_url = self::base_url($course->id, array('action' => self::INTERACT)); if (empty($alternates)) { $html = $OUTPUT->notification(clampmail::_s('no_alternates', $course)); $html .= $OUTPUT->continue_button($new_url); return $html; } $table = new html_table(); $table->head = array(get_string('email'), clampmail::_s('valid'), get_string('action')); $approval = array(clampmail::_s('waiting'), clampmail::_s('approved')); $icons = array(self::INTERACT => $OUTPUT->pix_icon('i/edit', get_string('edit')), self::DELETE => $OUTPUT->pix_icon('t/delete', get_string('delete'))); foreach ($alternates as $email) { $edit_url = self::base_url($course->id, array('action' => self::INTERACT, 'id' => $email->id)); $edit = html_writer::link($edit_url, $icons[self::INTERACT]); $delete_url = self::base_url($course->id, array('action' => self::DELETE, 'id' => $email->id)); $delete = html_writer::link($delete_url, $icons[self::DELETE]); $row = array($email->address, $approval[$email->valid], implode(' | ', array($edit, $delete))); $table->data[] = new html_table_row($row); } $new_link = html_writer::link($new_url, clampmail::_s('alternate_new')); $html = html_writer::tag('div', $new_link, array('class' => 'new_link')); $html .= $OUTPUT->box_start(); $html .= html_writer::table($table); $html .= $OUTPUT->box_end(); return $html; }
// Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package block_clampmail * @copyright 2013 Collaborative Liberal Arts Moodle Project * @copyright 2012 Louisiana State University (original Quickmail block) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; if ($ADMIN->fulltree) { require_once $CFG->dirroot . '/blocks/clampmail/lib.php'; $select = array(0 => get_string('no'), 1 => get_string('yes')); $roles = $DB->get_records('role', null, 'sortorder ASC'); $default_sns = array('editingteacher', 'teacher', 'student'); $defaults = array_filter($roles, function ($role) use($default_sns) { return in_array($role->shortname, $default_sns); }); $only_names = function ($role) { return $role->shortname; }; $select_roles = clampmail::_s('select_roles'); $settings->add(new admin_setting_configmultiselect('block_clampmail_roleselection', $select_roles, $select_roles, array_keys($defaults), array_map($only_names, $roles))); $settings->add(new admin_setting_configselect('block_clampmail_receipt', clampmail::_s('receipt'), clampmail::_s('receipt_help'), 0, $select)); $options = array(0 => get_string('none'), 'idnumber' => get_string('idnumber'), 'shortname' => get_string('shortname')); $settings->add(new admin_setting_configselect('block_clampmail_prepend_class', clampmail::_s('prepend_class'), clampmail::_s('prepend_class_desc'), 0, $options)); }
public function definition() { global $CFG, $USER, $COURSE, $OUTPUT; $mform =& $this->_form; $mform->addElement('hidden', 'mailto', ''); $mform->setType('mailto', PARAM_RAW); $mform->addElement('hidden', 'userid', $USER->id); $mform->setType('userid', PARAM_INT); $mform->addElement('hidden', 'courseid', $COURSE->id); $mform->setType('courseid', PARAM_INT); $mform->addElement('hidden', 'type', ''); $mform->setType('type', PARAM_ALPHA); $mform->addElement('hidden', 'typeid', 0); $mform->setType('typeid', PARAM_INT); $role_options = array('none' => clampmail::_s('no_filter')); foreach ($this->_customdata['roles'] as $role) { $role_options[$role->shortname] = $role->name; } $group_options = empty($this->_customdata['groups']) ? array() : array('all' => clampmail::_s('all_sections')); foreach ($this->_customdata['groups'] as $group) { $group_options[$group->id] = $group->name; } $group_options[0] = clampmail::_s('no_section'); $user_options = array(); foreach ($this->_customdata['users'] as $user) { $user_options[$this->option_value($user)] = $this->option_display($user); } $links = array(); $gen_url = function ($type) use($COURSE) { $email_param = array('courseid' => $COURSE->id, 'type' => $type); return new moodle_url('emaillog.php', $email_param); }; $draft_link = html_writer::link($gen_url('drafts'), clampmail::_s('drafts')); $links[] =& $mform->createElement('static', 'draft_link', '', $draft_link); $context = context_course::instance($COURSE->id); $config = clampmail::load_config($COURSE->id); $can_send = (has_capability('block/clampmail:cansend', $context) or !empty($config['allowstudents'])); if ($can_send) { $history_link = html_writer::link($gen_url('log'), clampmail::_s('history')); $links[] =& $mform->createElement('static', 'history_link', '', $history_link); } $mform->addGroup($links, 'links', ' ', array(' | '), false); $req_img = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('req'), 'class' => 'req')); $table = new html_table(); $table->attributes['class'] = 'emailtable'; $selected_required_label = new html_table_cell(); $selected_required_label->text = html_writer::tag('strong', clampmail::_s('selected') . $req_img, array('class' => 'required')); $role_filter_label = new html_table_cell(); $role_filter_label->colspan = "2"; $role_filter_label->text = html_writer::tag('div', clampmail::_s('role_filter'), array('class' => 'object_labels')); $select_filter = new html_table_cell(); $select_filter->text = html_writer::tag('select', array_reduce($this->_customdata['selected'], array($this, 'reduce_users'), ''), array('id' => 'mail_users', 'multiple' => 'multiple', 'size' => 30)); $embed = function ($text, $id) { return html_writer::tag('p', html_writer::empty_tag('input', array('value' => $text, 'type' => 'button', 'id' => $id))); }; $embed_quick = function ($text) use($embed) { return $embed(clampmail::_s($text), $text); }; $center_buttons = new html_table_cell(); $center_buttons->text = $embed($OUTPUT->larrow() . ' ' . clampmail::_s('add_button'), 'add_button') . $embed(clampmail::_s('remove_button') . ' ' . $OUTPUT->rarrow(), 'remove_button') . $embed_quick('add_all') . $embed_quick('remove_all'); $filters = new html_table_cell(); $filters->text = html_writer::tag('div', html_writer::select($role_options, '', 'none', null, array('id' => 'roles'))) . html_writer::tag('div', clampmail::_s('potential_sections'), array('class' => 'object_labels')) . html_writer::tag('div', html_writer::select($group_options, '', 'all', null, array('id' => 'groups', 'multiple' => 'multiple', 'size' => 5))) . html_writer::tag('div', clampmail::_s('potential_users'), array('class' => 'object_labels')) . html_writer::tag('div', html_writer::select($user_options, '', '', null, array('id' => 'from_users', 'multiple' => 'multiple', 'size' => 20))); $table->data[] = new html_table_row(array($selected_required_label, $role_filter_label)); $table->data[] = new html_table_row(array($select_filter, $center_buttons, $filters)); if (has_capability('block/clampmail:allowalternate', $context)) { $alternates = $this->_customdata['alternates']; } else { $alternates = array(); } if (empty($alternates)) { $mform->addElement('static', 'from', clampmail::_s('from'), $USER->email); $mform->setType('from', PARAM_EMAIL); } else { $options = array(0 => $USER->email) + $alternates; $mform->addElement('select', 'alternateid', clampmail::_s('from'), $options); $mform->setType('alternateid', PARAM_INT); } $mform->addElement('static', 'selectors', '', html_writer::table($table)); $mform->setType('selectors', PARAM_RAW); $mform->addElement('filemanager', 'attachments', clampmail::_s('attachment')); $mform->setType('attachments', PARAM_FILE); $mform->addElement('text', 'subject', clampmail::_s('subject')); $mform->setType('subject', PARAM_TEXT); $mform->addRule('subject', null, 'required'); $mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addElement('editor', 'message_editor', clampmail::_s('message'), null, $this->_customdata['editor_options']); $options = $this->_customdata['sigs'] + array(-1 => 'No ' . clampmail::_s('sig')); $mform->addElement('select', 'sigid', clampmail::_s('signature'), $options); $radio = array($mform->createElement('radio', 'receipt', '', get_string('yes'), 1), $mform->createElement('radio', 'receipt', '', get_string('no'), 0)); $mform->addGroup($radio, 'receipt_action', clampmail::_s('receipt'), array(' '), false); $mform->addHelpButton('receipt_action', 'receipt', 'block_clampmail'); $mform->setDefault('receipt', !empty($config['receipt'])); $buttons = array(); $buttons[] =& $mform->createElement('submit', 'send', clampmail::_s('send_email')); $buttons[] =& $mform->createElement('submit', 'draft', clampmail::_s('save_draft')); $buttons[] =& $mform->createElement('cancel'); $mform->addGroup($buttons, 'buttons', clampmail::_s('actions'), array(' '), false); }
} if (empty($data->id)) { $data->id = null; $data->id = $DB->insert_record('block_clampmail_signatures', $data); } // Persist relative links. $data = file_postupdate_standard_editor($data, 'signature', $options, $context, 'block_clampmail', 'signature', $data->id); $DB->update_record('block_clampmail_signatures', $data); $url = new moodle_url('signature.php', array('id' => $data->id, 'courseid' => $course->id, 'flash' => 1)); redirect($url); } } } echo $OUTPUT->header(); echo $OUTPUT->heading($header); $first = array(0 => 'New ' . clampmail::_s('sig')); $only_names = function ($sig) { return $sig->default_flag ? $sig->title . ' (Default)' : $sig->title; }; $sig_options = $first + array_map($only_names, $dbsigs); $form->set_data($sig); if ($flash) { echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess'); } if (!empty($delete)) { $msg = get_string('are_you_sure', 'block_clampmail', $sig); $confirm_url = new moodle_url('/blocks/clampmail/signature.php', array('id' => $sig->id, 'courseid' => $courseid, 'confirm' => 1)); $cancel_url = new moodle_url('/blocks/clampmail/signature.php', array('id' => $sig->id, 'courseid' => $courseid)); echo $OUTPUT->confirm($msg, $confirm_url, $cancel_url); } else { echo $OUTPUT->single_select('signature.php?courseid=' . $courseid, 'id', $sig_options, $sigid);