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 = get_context_instance(CONTEXT_COURSE, $COURSE->id);
     $config = quickmail::load_config($COURSE->id);
     $permission = has_capability('block/quickmail:cansend', $context);
     $can_send = ($permission or !empty($config['allowstudents']));
     $icon_class = array('class' => 'icon');
     if ($can_send) {
         $cparam = array('courseid' => $COURSE->id);
         $send_email_str = quickmail::_s('composenew');
         $send_email = html_writer::link(new moodle_url('/blocks/quickmail/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 = quickmail::_s('signature');
         $signature = html_writer::link(new moodle_url('/blocks/quickmail/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 = quickmail::_s('drafts');
         $drafts = html_writer::link(new moodle_url('/blocks/quickmail/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 = quickmail::_s('history');
         $history = html_writer::link(new moodle_url('/blocks/quickmail/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/quickmail:allowalternate', $context)) {
         $alt_str = quickmail::_s('alternate');
         $alt = html_writer::link(new moodle_url('/blocks/quickmail/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/quickmail:canconfig', $context)) {
         $config_str = quickmail::_s('config');
         $config = html_writer::link(new moodle_url('/blocks/quickmail/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()
 {
     global $USER;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'courseid', '');
     $mform->addElement('hidden', 'id', '');
     $mform->addElement('hidden', 'userid', $USER->id);
     $mform->addElement('text', 'title', quickmail::_s('title'));
     $mform->addElement('editor', 'signature_editor', quickmail::_s('sig'), null, $this->_customdata['signature_options']);
     $mform->setType('signature_editor', PARAM_RAW);
     $mform->addElement('checkbox', 'default_flag', quickmail::_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', quickmail::_s('actions'), array(' '), false);
     $mform->addRule('title', null, 'required', null, 'client');
 }
 public function definition()
 {
     $mform =& $this->_form;
     $reset_link = html_writer::link(new moodle_url('/blocks/quickmail/config.php', array('courseid' => $this->_customdata['courseid'], 'reset' => 1)), quickmail::_s('reset'));
     $mform->addElement('static', 'reset', '', $reset_link);
     $student_select = array(0 => get_string('no'), 1 => get_string('yes'));
     $mform->addElement('select', 'allowstudents', quickmail::_s('allowstudents'), $student_select);
     $roles =& $mform->addElement('select', 'roleselection', quickmail::_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', quickmail::_s('prepend_class'), $options);
     $mform->addElement('select', 'receipt', quickmail::_s('receipt'), $student_select);
     $mform->addElement('submit', 'save', get_string('savechanges'));
     $mform->addElement('hidden', 'courseid', $this->_customdata['courseid']);
     $mform->addRule('roleselection', null, 'required');
 }
 public function definition()
 {
     $mform =& $this->_form;
     $reset_link = html_writer::link(new moodle_url('/blocks/quickmail/config_qm.php', array('courseid' => $this->_customdata['courseid'], 'reset' => 1)), quickmail::_s('reset'));
     $mform->addElement('static', 'reset', '', $reset_link);
     $student_select = array(0 => get_string('no'), 1 => get_string('yes'));
     $allowstudents = get_config('moodle', 'block_quickmail_allowstudents');
     if ($allowstudents != -1) {
         // If we disallow "Allow students to use Quickmail" at the site
         // level, then disallow the config to be set at the course level.
         $mform->addElement('select', 'allowstudents', quickmail::_s('allowstudents'), $student_select);
     }
     $roles =& $mform->addElement('select', 'roleselection', quickmail::_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', quickmail::_s('prepend_class'), $options);
     $mform->addElement('select', 'receipt', quickmail::_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');
 }
Beispiel #5
0
 static function list_entries($courseid, $type, $page, $perpage, $userid, $count, $can_delete)
 {
     global $CFG, $DB, $OUTPUT;
     $dbtable = 'block_quickmail_' . $type;
     $table = new html_table();
     $params = array('courseid' => $courseid, 'userid' => $userid);
     $logs = $DB->get_records($dbtable, $params, 'time DESC', '*', $page * $perpage, $perpage);
     if ($courseid == '1') {
         $table->head = array(get_string('date'), quickmail::_s('subject'), get_string('action'), quickmail::_s('status'), quickmail::_s('failed_to_send_to'), quickmail::_s('send_again'));
     } else {
         $table->head = array(get_string('date'), quickmail::_s('subject'), quickmail::_s('attachment'), get_string('action'), quickmail::_s('status'), quickmail::_s('failed_to_send_to'), quickmail::_s('send_again'));
     }
     $table->data = array();
     foreach ($logs as $log) {
         $array_of_failed_user_ids = array();
         $date = quickmail::format_time($log->time);
         $subject = $log->subject;
         $attachments = $log->attachment;
         if (!empty($log->failuserids)) {
             // DWE -> keep track of user ids that failed.
             $array_of_failed_user_ids = explode(",", $log->failuserids);
         }
         $params = array('courseid' => $log->courseid, 'type' => $type, 'typeid' => $log->id);
         $actions = array();
         if ($courseid == '1') {
             $open_link = html_writer::link(new moodle_url('/blocks/quickmail/admin_email.php', $params), $OUTPUT->pix_icon('i/search', 'Open Email'));
         } else {
             $open_link = html_writer::link(new moodle_url('/blocks/quickmail/email.php', $params), $OUTPUT->pix_icon('i/search', 'Open Email'));
         }
         $actions[] = $open_link;
         if ($can_delete) {
             $delete_params = $params + array('userid' => $userid, 'action' => 'delete');
             $delete_link = html_writer::link(new moodle_url('/blocks/quickmail/emaillog.php', $delete_params), $OUTPUT->pix_icon("i/invalid", "Delete Email"));
             $actions[] = $delete_link;
         }
         $action_links = implode(' ', $actions);
         $statusSENTorNot = quickmail::_s($type . "success");
         if (!empty($array_of_failed_user_ids)) {
             $statusSENTorNot = quickmail::_s('message_failure');
             $params += array('fmid' => 1);
             $text = quickmail::_s('send_again');
             if ($courseid == '1') {
                 $sendagain = html_writer::link(new moodle_url("/blocks/quickmail/admin_email.php", $params), $text);
             } else {
                 $sendagain = html_writer::link(new moodle_url("/blocks/quickmail/email.php", $params), $text);
             }
             $listFailIDs = count($array_of_failed_user_ids);
             $failCount = $listFailIDs === 1 ? $listFailIDs . " " . quickmail::_s("user") : $listFailIDs . " " . quickmail::_s("users");
         } else {
             $listFailIDs = $array_of_failed_user_ids;
             $sendagain = "";
             $failCount = "";
         }
         if ($courseid == 1) {
             $table->data[] = array($date, $subject, $action_links, $statusSENTorNot, $failCount, $sendagain);
         } else {
             $table->data[] = array($date, $subject, $attachments, $action_links, $statusSENTorNot, $failCount, $sendagain);
         }
     }
     $paging = $OUTPUT->paging_bar($count, $page, $perpage, '/blocks/quickmail/emaillog.php?type=' . $type . '&courseid=' . $courseid . '&userid=' . $userid);
     $html = $paging;
     $html .= html_writer::table($table);
     $html .= $paging;
     return $html;
 }
Beispiel #6
0
    // http://docs.moodle.org/dev/Additional_name_fields
    $header .= ' for ' . fullname($user);
}
echo $OUTPUT->header();
echo $OUTPUT->heading($header);
if ($canimpersonate) {
    $get_name_string = 'u.firstname, u.lastname';
    if ($CFG->version >= 2013111800) {
        $get_name_string = get_all_user_name_fields(true, 'u');
    }
    $sql = "SELECT DISTINCT(l.userid)," . $get_name_string . "\n                FROM {block_quickmail_{$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('' => quickmail::_s('select_users'));
    echo $OUTPUT->single_select($url, 'userid', $user_options, $userid, $default_option);
}
if (empty($count)) {
    echo $OUTPUT->notification(quickmail::_s('no_' . $type));
    if ($COURSE->id == 1) {
        echo $OUTPUT->continue_button('/blocks/quickmail/admin_email.php?courseid=' . $courseid);
    } else {
        echo $OUTPUT->continue_button('/blocks/quickmail/email.php?courseid=' . $courseid);
    }
    echo $OUTPUT->footer();
    exit;
}
echo $html;
echo $OUTPUT->footer();
 public function definition()
 {
     global $CFG, $USER, $COURSE, $OUTPUT;
     $mform =& $this->_form;
     $mform->addElement('hidden', 'mailto', '');
     $mform->addElement('hidden', 'userid', $USER->id);
     $mform->addElement('hidden', 'courseid', $COURSE->id);
     $mform->addElement('hidden', 'type', '');
     $mform->addElement('hidden', 'typeid', 0);
     $role_options = array('none' => quickmail::_s('no_filter'));
     foreach ($this->_customdata['roles'] as $role) {
         $role_options[$role->shortname] = $role->name;
     }
     $group_options = empty($this->_customdata['groups']) ? array() : array('all' => quickmail::_s('all_sections'));
     foreach ($this->_customdata['groups'] as $group) {
         $group_options[$group->id] = $group->name;
     }
     $group_options[0] = quickmail::_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'), quickmail::_s('drafts'));
     $links[] =& $mform->createElement('static', 'draft_link', '', $draft_link);
     $context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
     $config = quickmail::load_config($COURSE->id);
     $can_send = (has_capability('block/quickmail:cansend', $context) or !empty($config['allowstudents']));
     if ($can_send) {
         $history_link = html_writer::link($gen_url('log'), quickmail::_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', quickmail::_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', quickmail::_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(quickmail::_s($text), $text);
     };
     $center_buttons = new html_table_cell();
     $center_buttons->text = $embed($OUTPUT->larrow() . ' ' . quickmail::_s('add_button'), 'add_button') . $embed(quickmail::_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', quickmail::_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', quickmail::_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/quickmail:allowalternate', $context)) {
         $alternates = $this->_customdata['alternates'];
     } else {
         $alternates = array();
     }
     if (empty($alternates)) {
         $mform->addElement('static', 'from', quickmail::_s('from'), $USER->email);
     } else {
         $options = array(0 => $USER->email) + $alternates;
         $mform->addElement('select', 'alternateid', quickmail::_s('from'), $options);
     }
     $mform->addElement('static', 'selectors', '', html_writer::table($table));
     $mform->addElement('filemanager', 'attachments', quickmail::_s('attachment'));
     $mform->addElement('text', 'subject', quickmail::_s('subject'));
     $mform->setType('subject', PARAM_TEXT);
     $mform->addRule('subject', null, 'required');
     $mform->addElement('editor', 'message_editor', quickmail::_s('message'), null, $this->_customdata['editor_options']);
     $options = $this->_customdata['sigs'] + array(-1 => 'No ' . quickmail::_s('sig'));
     $mform->addElement('select', 'sigid', quickmail::_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', quickmail::_s('receipt'), array(' '), false);
     $mform->addHelpButton('receipt_action', 'receipt', 'block_quickmail');
     $mform->setDefault('receipt', !empty($config['receipt']));
     $buttons = array();
     $buttons[] =& $mform->createElement('submit', 'send', quickmail::_s('send_email'));
     $buttons[] =& $mform->createElement('submit', 'draft', quickmail::_s('save_draft'));
     $buttons[] =& $mform->createElement('cancel');
     $mform->addGroup($buttons, 'buttons', quickmail::_s('actions'), array(' '), false);
 }
Beispiel #8
0
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/quickmail:allowalternate', $context);
$blockname = quickmail::_s('pluginname');
$heading = quickmail::_s('alternate');
$title = "{$blockname}: {$heading}";
$url = new moodle_url('/blocks/quickmail/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('quickmail_alternate', $action)) {
    // Always fallback on view
    $action = 'view';
}
$body = quickmail_alternate::$action($course, $id);
echo $OUTPUT->header();
Beispiel #9
0
 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(quickmail::_s('no_alternates', $course));
         $html .= $OUTPUT->continue_button($new_url);
         return $html;
     }
     $table = new html_table();
     $table->head = array(get_string('email'), quickmail::_s('valid'), get_string('action'));
     $approval = array(quickmail::_s('waiting'), quickmail::_s('approved'));
     $icons = array(self::INTERACT => $OUTPUT->pix_icon('i/edit', get_string('edit')), self::DELETE => $OUTPUT->pix_icon('i/invalid', 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, quickmail::_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;
 }
Beispiel #10
0
 function list_entries($courseid, $type, $page, $perpage, $userid, $count, $can_delete)
 {
     global $CFG, $DB, $OUTPUT;
     $dbtable = 'block_quickmail_' . $type;
     $table = new html_table();
     $params = array('courseid' => $courseid, 'userid' => $userid);
     $logs = $DB->get_records($dbtable, $params, 'time DESC', '*', $page * $perpage, $perpage * ($page + 1));
     $table->head = array(get_string('date'), quickmail::_s('subject'), quickmail::_s('attachment'), get_string('action'));
     $table->data = array();
     foreach ($logs as $log) {
         $date = quickmail::format_time($log->time);
         $subject = $log->subject;
         $attachments = $log->attachment;
         $params = array('courseid' => $log->courseid, 'type' => $type, 'typeid' => $log->id);
         $actions = array();
         $open_link = html_writer::link(new moodle_url('/blocks/quickmail/email.php', $params), $OUTPUT->pix_icon('i/search', 'Open Email'));
         $actions[] = $open_link;
         if ($can_delete) {
             $delete_params = $params + array('userid' => $userid, 'action' => 'delete');
             $delete_link = html_writer::link(new moodle_url('/blocks/quickmail/emaillog.php', $delete_params), $OUTPUT->pix_icon("i/cross_red_big", "Delete Email"));
             $actions[] = $delete_link;
         }
         $action_links = implode(' ', $actions);
         $table->data[] = array($date, $subject, $attachments, $action_links);
     }
     $paging = $OUTPUT->paging_bar($count, $page, $perpage, '/blocks/quickmail/emaillog.php?type=' . $type . '&courseid=' . $courseid);
     $html = $paging;
     $html .= html_writer::table($table);
     $html .= $paging;
     return $html;
 }
Beispiel #11
0
            }
            if (empty($data->id)) {
                $data->id = null;
                $data->id = $DB->insert_record('block_quickmail_signatures', $data);
            }
            // Persist relative links
            $data = file_postupdate_standard_editor($data, 'signature', $options, $context, 'block_quickmail', 'signature', $data->id);
            $DB->update_record('block_quickmail_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 ' . quickmail::_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_quickmail', $sig);
    $confirm_url = new moodle_url('/blocks/quickmail/signature.php', array('id' => $sig->id, 'courseid' => $courseid, 'confirm' => 1));
    $cancel_url = new moodle_url('/blocks/quickmail/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);
Beispiel #12
0
<?php

// Written at Louisiana State University
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    require_once $CFG->dirroot . '/blocks/quickmail/lib.php';
    $select = array(0 => get_string('no'), 1 => get_string('yes'));
    $allow = quickmail::_s('allowstudents');
    $settings->add(new admin_setting_configselect('block_quickmail_allowstudents', $allow, $allow, 0, $select));
    $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->name;
    };
    $select_roles = quickmail::_s('select_roles');
    $settings->add(new admin_setting_configmultiselect('block_quickmail_roleselection', $select_roles, $select_roles, array_keys($defaults), array_map($only_names, $roles)));
    $settings->add(new admin_setting_configselect('block_quickmail_receipt', quickmail::_s('receipt'), quickmail::_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_quickmail_prepend_class', quickmail::_s('prepend_class'), quickmail::_s('prepend_class_desc'), 0, $options));
}
Beispiel #13
0
     $sig = $sigs[$data->sigid];
     $signaturetext = file_rewrite_pluginfile_urls($sig->signature, 'pluginfile.php', $context->id, 'block_quickmail', 'signature', $sig->id, $editor_options);
 }
 // Prepare html content of message /////////////////////////////////
 //$data->message = file_rewrite_pluginfile_urls($data->message, 'pluginfile.php', $context->id, 'block_quickmail', $table, $data->id, $editor_options);
 if (empty($signaturetext)) {
     $data->messageWithSigAndAttach = $data->message;
 } else {
     if ($data->format == 0 || $data->format == 2) {
         $data->messageWithSigAndAttach = $data->message . "\n\n" . $signaturetext;
     } else {
         $data->messageWithSigAndAttach = $data->message . "<br /> <br /> <p></p>" . $signaturetext;
     }
 }
 // Append links to attachments, if any /////////////////////////////
 $data->messageWithSigAndAttach .= quickmail::process_attachments($context, $data, $table, $data->id);
 // Prepare html content of message
 $data->message = file_rewrite_pluginfile_urls($data->message, 'pluginfile.php', $context->id, 'block_quickmail', $table, $data->id, $editor_options);
 // Same user, alternate email //////////////////////////////////////
 if (!empty($data->alternateid)) {
     $user = clone $USER;
     $user->email = $alternates[$data->alternateid];
 } else {
     $user = $USER;
 }
 $data->failuserids = array();
 // DWE -> Begin hopefully new way of dealing with messagetext and messagehtml
 // TEXT
 // This is where we'll need to factor in the preferences of the receiver.
 $messagetext = format_text_email($data->messageWithSigAndAttach, $data->format);
 // HTML
Beispiel #14
0
$PAGE->set_url('/blocks/quickmail/config.php', array('courseid' => $courseid));
$PAGE->set_title($blockname . ': ' . $header);
$PAGE->set_heading($blockname . ': ' . $header);
$PAGE->navbar->add($header);
$PAGE->set_pagetype($blockname);
$changed = false;
if ($reset) {
    $changed = true;
    quickmail::default_config($courseid);
}
$roles = $DB->get_records_menu('role', null, 'sortorder ASC', 'id, name');
$form = new config_form(null, array('courseid' => $courseid, 'roles' => $roles));
if ($data = $form->get_data()) {
    $config = get_object_vars($data);
    unset($config['save'], $config['courseid']);
    $config['roleselection'] = implode(',', $config['roleselection']);
    quickmail::save_config($courseid, $config);
    $changed = true;
}
$config = quickmail::load_config($courseid);
$config['roleselection'] = explode(',', $config['roleselection']);
$form->set_data($config);
echo $OUTPUT->header();
echo $OUTPUT->heading($header);
echo $OUTPUT->box_start();
if ($changed) {
    echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
}
$form->display();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
         $data->id = $DB->insert_record('block_quickmail_log', $data);
         // Send the messages and save the failed users if there are any
         $data->failuserids = implode(',', $message->send());
         $message->sendAdminReceipt();
         // Finished processing
         // Empty errors mean that you can go back home
         if (empty($message->warnings)) {
             unset($SESSION->user_filtering);
             if (is_siteadmin($USER->id)) {
                 redirect(new moodle_url('/blocks/quickmail/emaillog.php', array('courseid' => $COURSE->id)));
             } else {
                 redirect(new moodle_url('/my', NULL));
             }
         } else {
             // update DB to reflect fail status.
             $data->status = quickmail::_s('failed_to_send_to') + count($message->warnings) + quickmail::_s('users');
             $DB->update_record('block_quickmail_log', $data);
         }
     }
 }
 // get data for form
 if (!empty($type)) {
     $data = $log_message;
     $log_message->messageformat = $USER->mailformat;
     $log_message = file_prepare_standard_editor($log_message, 'message', $editor_options, $context, 'block_quickmail', $type, $log_message->id);
 } else {
     $log_message = new stdClass();
 }
 // begin output.
 echo $OUTPUT->header();
 echo $OUTPUT->heading($header);
Beispiel #16
0
     $subject = $data->subject;
 }
 // An instance id is needed before storing the file repository
 file_save_draft_area_files($data->attachments, $context->id, 'block_quickmail', 'attachment_' . $table, $data->id, $editor_options);
 // Send emails
 if (isset($data->send)) {
     if ($type == 'drafts') {
         quickmail::draft_cleanup($typeid);
     }
     if (!empty($sigs) and $data->sigid > -1) {
         $sig = $sigs[$data->sigid];
         $signaturetext = file_rewrite_pluginfile_urls($sig->signature, 'pluginfile.php', $context->id, 'block_quickmail', 'signature', $sig->id, $editor_options);
         $data->message .= $signaturetext;
     }
     // Append links to attachments, if any
     $data->message .= quickmail::process_attachments($context, $data, $table, $data->id);
     // Prepare html content of message
     $data->message = file_rewrite_pluginfile_urls($data->message, 'pluginfile.php', $context->id, 'block_quickmail', $table, $data->id, $editor_options);
     // Same user, alternate email
     if (!empty($data->alternateid)) {
         $user = clone $USER;
         $user->email = $alternates[$data->alternateid];
     } else {
         $user = $USER;
     }
     foreach (explode(',', $data->mailto) as $userid) {
         $success = email_to_user($everyone[$userid], $user, $subject, strip_tags($data->message), $data->message);
         if (!$success) {
             $warnings[] = get_string("no_email", 'block_quickmail', $everyone[$userid]);
         }
     }
Beispiel #17
0
 public function sendAdminReceipt()
 {
     $this->html = $this->buildAdminReceipt();
     $this->text = $this->buildAdminReceipt();
     $this->subject = quickmail::_s("admin_email_send_receipt");
     $this->send($this->admins);
 }
Beispiel #18
0
 $data = file_postupdate_standard_editor($data, 'message', $editor_options, $context, 'block_quickmail', $table, $data->id);
 $DB->update_record('block_quickmail_' . $table, $data);
 $prepender = $config['prepend_class'];
 if (!empty($prepender) and !empty($course->{$prepender})) {
     $subject = "[{$course->{$prepender}}] {$data->subject}";
 } else {
     $subject = $data->subject;
 }
 // An instance id is needed before storing the file repository
 file_save_draft_area_files($data->attachments, $context->id, 'block_quickmail', 'attachment_' . $table, $data->id);
 // Send emails
 if (isset($data->send)) {
     if ($type == 'drafts') {
         quickmail::draft_cleanup($typeid);
     }
     list($zipname, $zip, $actual_zip) = quickmail::process_attachments($context, $data, $table, $data->id);
     if (!empty($sigs) and $data->sigid > -1) {
         $sig = $sigs[$data->sigid];
         $signaturetext = file_rewrite_pluginfile_urls($sig->signature, 'pluginfile.php', $context->id, 'block_quickmail', 'signature', $sig->id, $editor_options);
         $data->message .= $signaturetext;
     }
     // Prepare html content of message
     $data->message = file_rewrite_pluginfile_urls($data->message, 'pluginfile.php', $context->id, 'block_quickmail', $table, $data->id, $editor_options);
     // Same user, alternate email
     if (!empty($data->alternateid)) {
         $user = clone $USER;
         $user->email = $alternates[$data->alternateid];
     } else {
         $user = $USER;
     }
     foreach (explode(',', $data->mailto) as $userid) {
Beispiel #19
0
<?php

// Written at Louisiana State University
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    require_once $CFG->dirroot . '/blocks/quickmail/lib.php';
    $select = array(-1 => get_string('never'), 0 => get_string('no'), 1 => get_string('yes'));
    $allow = quickmail::_s('allowstudents');
    $allowdesc = quickmail::_s('allowstudentsdesc');
    $settings->add(new admin_setting_configselect('block_quickmail_allowstudents', $allow, $allowdesc, 0, $select));
    $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 = quickmail::_s('select_roles');
    $settings->add(new admin_setting_configmultiselect('block_quickmail_roleselection', $select_roles, $select_roles, array_keys($defaults), array_map($only_names, $roles)));
    $settings->add(new admin_setting_configselect('block_quickmail_receipt', quickmail::_s('receipt'), quickmail::_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_quickmail_prepend_class', quickmail::_s('prepend_class'), quickmail::_s('prepend_class_desc'), 0, $options));
    $groupoptions = array('strictferpa' => get_string('strictferpa', 'block_quickmail'), 'courseferpa' => get_string('courseferpa', 'block_quickmail'), 'noferpa' => get_string('noferpa', 'block_quickmail'));
    $settings->add(new admin_setting_configselect('block_quickmail_ferpa', quickmail::_s('ferpa'), quickmail::_s('ferpa_desc'), 'strictferpa', $groupoptions));
    $settings->add(new admin_setting_configcheckbox('block_quickmail_downloads', quickmail::_s('downloads'), quickmail::_s('downloads_desc'), 1));
    $settings->add(new admin_setting_configcheckbox('block_quickmail_addionalemail', quickmail::_s('addionalemail'), quickmail::_s('addionalemail_desc'), 0));
}