/** ----------------------------- /** Email form /** -----------------------------*/ function email_form() { global $IN, $DSP, $DB, $PREFS, $SESS, $LANG; /** ----------------------------- /** Default form values /** -----------------------------*/ $member_groups = array(); $mailing_lists = array(); $default = array('from_name' => '', 'from_email' => $SESS->userdata['email'], 'recipient' => '', 'cc' => '', 'bcc' => '', 'subject' => '', 'message' => '', 'plaintext_alt' => '', 'priority' => 3, 'mailtype' => $PREFS->ini('mail_format'), 'word_wrap' => $PREFS->ini('word_wrap')); /** ----------------------------- /** Are we emailing a member? /** -----------------------------*/ if ($IN->GBL('M', 'GET') == 'email_mbr' and $IN->GBL('mid', 'GET') and $DSP->allowed_group('can_admin_members')) { $query = $DB->query("SELECT email, screen_name FROM exp_members WHERE member_id = '" . $DB->escape_str($IN->GBL('mid', 'GET')) . "'"); if ($query->num_rows == 1) { $default['recipient'] = $query->row['email']; $default['message'] = $query->row['screen_name'] . ","; } } /** ----------------------------- /** Fetch form data /** -----------------------------*/ // If the user is viewing a cached email, we'll gather the data if ($id = $IN->GBL('id', 'GET')) { if (!$DSP->allowed_group('can_send_cached_email')) { return $DSP->no_access_message($LANG->line('not_allowed_to_email_mailinglist')); } // Fetch cached data $query = $DB->query("SELECT * FROM exp_email_cache WHERE cache_id = '" . $DB->escape_str($id) . "'"); if ($query->num_rows > 0) { foreach ($query->row as $key => $val) { if (isset($default[$key])) { $default[$key] = $val; } } } // Fetch member group IDs $query = $DB->query("SELECT group_id FROM exp_email_cache_mg WHERE cache_id = '" . $DB->escape_str($id) . "'"); if ($query->num_rows > 0) { foreach ($query->result as $row) { $member_groups[] = $row['group_id']; } } if ($this->mailinglist_exists == TRUE) { // Fetch mailing list IDs $query = $DB->query("SELECT list_id FROM exp_email_cache_ml WHERE cache_id = '" . $DB->escape_str($id) . "'"); if ($query->num_rows > 0) { foreach ($query->result as $row) { $mailing_lists[] = $row['list_id']; } } } } /** ----------------------------------- /** Turn default data into variables /** -----------------------------------*/ foreach ($default as $key => $val) { ${$key} = $val; } /** ----------------------------------- /** Create the email form /** -----------------------------------*/ $DSP->title = $LANG->line('communicate'); $DSP->crumb = $LANG->line('communicate'); if ($DSP->allowed_group('can_send_cached_email')) { $DSP->right_crumb($LANG->line('view_email_cache'), BASE . AMP . 'C=communicate' . AMP . 'M=view_cache'); } $r = $DSP->form_open(array('action' => 'C=communicate' . AMP . 'M=send_email')); $r .= $DSP->qdiv('tableHeading', $LANG->line('send_an_email')); $r .= $DSP->div('box'); $r .= $DSP->table('', '0', '0', '100%') . $DSP->tr() . $DSP->td('', '', '', '', 'top'); /** ----------------------------- /** Subject and message feilds /** -----------------------------*/ $r .= $DSP->div('itemWrapper') . $DSP->qdiv('itemTitle', $DSP->required() . NBS . $LANG->line('subject', 'subject')) . $DSP->qdiv('', $DSP->input_text('subject', $subject, '20', '75', 'input', '96%')) . $DSP->div_c(); if (!class_exists('Spellcheck')) { require PATH_CORE . 'core.spellcheck' . EXT; } $SPELL = new Spellcheck(); $r .= $SPELL->JavaScript(BASE . AMP . 'C=communicate' . AMP . 'M=spellcheck', TRUE); $r .= $DSP->div('itemWrapper') . $DSP->qdiv('itemTitle', $DSP->required() . NBS . $LANG->line('message', 'message')) . $DSP->qdiv('', $DSP->input_textarea('message', $message, 25, 'textarea', '96%')) . $DSP->div_c(); $iframe_url = BASE . AMP . 'C=communicate' . AMP . 'M=spellcheck_iframe'; $field_name = 'message'; $r .= $DSP->table('tableBorderNoBot', '0', '', '96%'); if ($SPELL->enabled === TRUE) { $r .= $DSP->tr() . $DSP->td('tableCellTwoBold', '100%', 2) . $DSP->div('itemWrapper') . $DSP->anchor('javascript:nullo();', $LANG->line('check_spelling'), 'onclick="eeSpell.getResults(\'' . $field_name . '\');return false;"') . '<span id="spellcheck_hidden_' . $field_name . '" style="visibility:hidden;">' . NBS . NBS . NBS . NBS . '|' . NBS . NBS . NBS . NBS . $DSP->anchor('javascript:nullo();', $LANG->line('save_spellcheck'), 'onclick="SP_saveSpellCheck();return false;"') . NBS . NBS . NBS . NBS . '|' . NBS . NBS . NBS . NBS . $DSP->anchor('javascript:nullo();', $LANG->line('revert_spellcheck'), 'onclick="SP_revertToOriginal();return false;"') . '</span>' . $DSP->div_c(); $r .= '<iframe src="' . $iframe_url . '" width="100%" style="display:none;" id="spellcheck_frame_' . $field_name . '" class="iframe" name="spellcheck_frame_' . $field_name . '"></iframe>' . '<div id="spellcheck_popup" class="wordSuggestion" style="position:absolute;visibility:hidden;"></div>'; $r .= $DSP->td_c() . $DSP->tr_c(); } /** ----------------------------- /** Mail formatting buttons /** -----------------------------*/ $extra_js = <<<EOTJS \t\t\t<script type="text/javascript"> \t\t\t\tfunction showhide_plaintext_field(val) \t\t\t\t{ \t\t\t\t\tif (val == 'html') \t\t\t\t\t{ \t\t\t\t\t\tdocument.getElementById('plaintext_field').style.display = 'block'; \t\t\t\t\t} \t\t\t\t\telse \t\t\t\t\t{ \t\t\t\t\t\tdocument.getElementById('plaintext_field').style.display = 'none'; \t\t\t\t\t} \t\t\t\t} \t\t\t</script> EOTJS; $r .= $extra_js . $DSP->tr() . $DSP->td('', '', 2); $r .= $DSP->table('', '0', '', '100%') . $DSP->tr() . $DSP->td('tableCellTwoBold', '40%') . $LANG->line('mail_format') . $DSP->td_c() . $DSP->td('tableCellTwoBold', '60%') . $DSP->input_select_header('mailtype', '', '', '', "onchange='showhide_plaintext_field(this.value);return false'") . $DSP->input_select_option('plain', $LANG->line('plain_text'), $mailtype == 'plain' ? 1 : '') . $DSP->input_select_option('html', $LANG->line('html'), $mailtype == 'html' ? 1 : '') . $DSP->input_select_footer() . $DSP->td_c() . $DSP->tr_c(); /** --------------------------------------- /** Alternative content field /** ---------------------------------------*/ $r .= $DSP->tr() . $DSP->td('', '', 2) . $DSP->div('tableCellTwoBold', '', 'plaintext_field', '', $mailtype == 'html' ? '' : "style='display:none;'") . $DSP->qdiv('tableCellTwoBold', $LANG->line('plaintext_alt', 'plaintext_alt')) . $DSP->qdiv('', $DSP->input_textarea('plaintext_alt', $plaintext_alt, 8, 'textarea', '96%')) . $DSP->td_c() . $DSP->tr_c() . $DSP->table_c(); /** --------------------------------------- /** Text Formatting /** ---------------------------------------*/ $r .= $DSP->tr() . $DSP->td('tableCellOneBold', '40%') . $LANG->line('text_formatting') . $DSP->td_c() . $DSP->td('tableCellOneBold', '60%') . $DSP->input_select_header('text_fmt') . $DSP->input_select_option('none', $LANG->line('none'), 1); // Fetch formatting plugins $list = $this->fetch_plugins(); foreach ($list as $val) { $name = ucwords(str_replace('_', ' ', $val)); if ($name == 'Br') { $name = $LANG->line('auto_br'); } elseif ($name == 'Xhtml') { $name = $LANG->line('xhtml'); } $r .= $DSP->input_select_option($val, $name); } $r .= $DSP->input_select_footer() . $DSP->td_c() . $DSP->tr_c(); $r .= $DSP->tr() . $DSP->td('tableCellTwoBold', '40%') . $LANG->line('word_wrap') . $DSP->td_c() . $DSP->td('tableCellTwoBold', '60%') . $DSP->input_select_header('wordwrap') . $DSP->input_select_option('y', $LANG->line('on'), $word_wrap == 'y' ? 1 : '') . $DSP->input_select_option('n', $LANG->line('off'), $word_wrap == 'n' ? 1 : '') . $DSP->input_select_footer() . $DSP->td_c() . $DSP->tr_c(); $r .= $DSP->tr() . $DSP->td('tableCellOneBold') . $LANG->line('priority') . $DSP->td_c() . $DSP->td('tableCellOneBold') . $DSP->input_select_header('priority') . $DSP->input_select_option('1', '1 (' . $LANG->line('highest') . ')', $priority == 1 ? 1 : '') . $DSP->input_select_option('2', '2 (' . $LANG->line('high') . ')', $priority == 2 ? 1 : '') . $DSP->input_select_option('3', '3 (' . $LANG->line('normal') . ')', $priority == 3 ? 1 : '') . $DSP->input_select_option('4', '4 (' . $LANG->line('low') . ')', $priority == 4 ? 1 : '') . $DSP->input_select_option('5', '5 (' . $LANG->line('lowest') . ')', $priority == 5 ? 1 : '') . $DSP->input_select_footer(); $r .= $DSP->td_c() . $DSP->tr_c() . $DSP->table_c(); /** ----------------------------- /** Submit button /** -----------------------------*/ if ($DSP->allowed_group('can_email_member_groups')) { $r .= $DSP->qdiv('itemWrapperTop', $DSP->input_checkbox('accept_admin_email', 'y', 1) . NBS . $LANG->line('honor_email_pref')); } $r .= $DSP->qdiv('itemWrapper', $DSP->required(1)); $r .= $DSP->qdiv('itemWrapper', $DSP->input_submit($LANG->line('send_it'))); /** ----------------------------- /** Right side of page /** -----------------------------*/ $r .= $DSP->td_c() . $DSP->td('', '300px', '', '', 'top'); /** ----------------------------- /** Sender/recipient fields /** -----------------------------*/ $r .= $DSP->div('itemWrapper') . $DSP->qdiv('itemTitle', $LANG->line('your_name', 'name')) . $DSP->qdiv('', $DSP->input_text('name', $from_name, '20', '50', 'input', '300px')) . $DSP->div_c(); $r .= $DSP->div('itemWrapper') . $DSP->qdiv('itemTitle', $DSP->required() . NBS . $LANG->line('your_email', 'from')) . $DSP->qdiv('', $DSP->input_text('from', $from_email, '20', '75', 'input', '300px')) . $DSP->div_c(); $r .= $DSP->div('itemWrapper') . $DSP->qdiv('itemWrapper', '<b>' . $LANG->line('recipient', 'recipient') . '</b>') . $DSP->qdiv('', $LANG->line('separate_emails_with_comma')) . $DSP->qdiv('', $DSP->input_text('recipient', $recipient, '20', '150', 'input', '300px')) . $DSP->div_c(); $r .= $DSP->div('itemWrapper') . $DSP->qdiv('itemTitle', $LANG->line('cc', 'cc')) . $DSP->qdiv('', $DSP->input_text('cc', $cc, '20', '150', 'input', '300px')) . $DSP->div_c(); $r .= $DSP->div('itemWrapper') . $DSP->qdiv('itemTitle', $LANG->line('bcc', 'bcc')) . $DSP->qdiv('', $DSP->input_text('bcc', $bcc, '20', '150', 'input', '300px') . BR) . $DSP->div_c(); if ($DSP->allowed_group('can_email_mailinglist') and $this->mailinglist_exists == TRUE) { $query = $DB->query("SELECT list_id, list_title FROM exp_mailing_lists ORDER BY list_title"); if ($query->num_rows > 0) { $r .= $DSP->table('tableBorder', '0', '', '300px') . $DSP->tr() . $DSP->td('tableHeading') . $DSP->qdiv('itemWrapper', $LANG->line('send_to_mailinglist')) . $DSP->td_c() . $DSP->tr_c(); $i = 0; foreach ($query->result as $row) { $style = $i++ % 2 ? 'tableCellOne' : 'tableCellTwo'; $r .= $DSP->tr() . $DSP->td($style, '50%') . $DSP->qdiv('defaultBold', $DSP->input_checkbox('list_' . $row['list_id'], $row['list_id'], in_array($row['list_id'], $mailing_lists) ? 1 : '') . $DSP->nbs(1) . $row['list_title']) . $DSP->td_c() . $DSP->tr_c(); } $r .= $DSP->table_c(); } } /** ----------------------------- /** Member group selection /** -----------------------------*/ if ($DSP->allowed_group('can_email_member_groups')) { $r .= $DSP->table('tableBorder', '0', '', '300px') . $DSP->tr() . $DSP->td('tableHeading') . $DSP->qdiv('itemWrapper', $LANG->line('recipient_group')) . $DSP->td_c() . $DSP->tr_c(); $i = 0; $query = $DB->query("SELECT group_id, group_title FROM exp_member_groups \n \t\t\t\t\t WHERE site_id = '" . $DB->escape_str($PREFS->ini('site_id')) . "'\n \t\t\t\t\t AND include_in_mailinglists = 'y' ORDER BY group_title"); foreach ($query->result as $row) { $style = $i++ % 2 ? 'tableCellOne' : 'tableCellTwo'; $r .= $DSP->tr() . $DSP->td($style, '50%') . $DSP->qdiv('defaultBold', $DSP->input_checkbox('group_' . $row['group_id'], $row['group_id'], in_array($row['group_id'], $member_groups) ? 1 : '') . $DSP->nbs(1) . $row['group_title']) . $DSP->td_c() . $DSP->tr_c(); } $r .= $DSP->table_c(); } /** ----------------------------- /** Table end /** -----------------------------*/ $r .= $DSP->td_c() . $DSP->tr_c() . $DSP->table_c(); $r .= $DSP->div_c(); $r .= $DSP->form_close(); $DSP->body = $r; }
/** -------------------------------- /** SpellCheck - JS /** --------------------------------*/ function spellcheck_js() { if (!class_exists('Spellcheck')) { require PATH_CORE . 'core.spellcheck' . EXT; } $SPELL = new Spellcheck(); $this->spellcheck_enabled = $SPELL->enabled; return $SPELL->JavaScript($this->_create_path('spellcheck'), TRUE); }