PostGenericAction($frontend, $args, $dummy_run); } function run($hook, &$post) { $tpl =& $this->_frontend->tpl; $action =& $this->_action; if ($post['skip_form'] || !in_array($this->_action, $this->_actions)) { // we can't display the form as something else is happening // (eg the "send post to a friend" form) $tpl->setVar('PLUGIN_POSTSEND', ' '); return; } $messages =& $this->_frontend->messages; $options =& $this->_frontend->options; $this->_bootstrap($post, $messages['comment_form_message']); // too lazy to add $this->_ to every variable $message =& $this->_message; $message_class =& $this->_message_class; $user_data =& $this->_user_data; $labels =& $this->_labels; // check user submitted data $empty_fields = array(); foreach (array('name', 'email', 'text', 'recipients') as $key) { if (empty($user_data["ud_$key"])) $empty_fields[] = $key; } if (count($empty_fields) == 0) { // no errors, let's send message $mh =& $this->_frontend->getMailHelper(); $shortname = $mh->htent2qp($options['shortname']); $shortname_hdr = $mh->encoded2hdr($options['shortname']); $header_dashes = ''; for ($i=0; $isetVar(array( 'notify_header_dashes' => $header_dashes, 'notify_post_title' => $mh->htent2qp($post['post_title']), 'notify_post_name' => $mh->htent2qp($post['post_name']), 'notify_post_permalink' => $mh->htent2qp($post['post_permalink']), 'notify_post_date' => $mh->htent2qp($post['post_date']), 'notify_post_time' => $mh->htent2qp($post['post_time']), 'notify_sender_name' => $mh->htent2qp($user_data['ud_name']), 'notify_sender_email' => $mh->htent2qp($user_data['ud_email']), 'notify_sender_message' => $mh->htent2qp(wordwrap(strip_tags($user_data['ud_text']), 75, "\r\n")) )); $headers = array( 'Content-Type: text/plain; charset="' . $options['charset'] . '"', 'MIME-Version: 1.0', 'Content-Transfer-Encoding: quoted-printable', 'From: "['. $shortname_hdr . '] ' . $mh->encoded2hdr($user_data['ud_name'], $options['charset']) . '" <' . $user_data['ud_email'] . '>'); $tpl->setFile('plugin_postsend', 'plugins/post_send.txt'); $mh->send_mail( $user_data["ud_recipients"], "[$shortname_hdr] " . $mh->encoded2hdr($messages['post_mail_subject']), $tpl->parse('PLUGIN_POSTSEND', 'plugin_postsend'), implode("\r\n", $headers)); // redirect user so that he does not insert the comment twice $this->_frontend->redirectToPost($post['post_permalink'], $messages['mail_sent'], $this->_remember); } else { if ($action == 'send_post') { // we have errors, let's set warnings and hide comment stuff foreach ($empty_fields as $empty_field) $user_data["ud_label_$empty_field"] = "warning"; $message_class = 'comment_form_warning'; } // we are displaying this form for the first time $message = $messages['comment_required_fields']; // . implode(", ", $empty_fields); $post['skip_form'] = $post['skip_comments'] = true; $tpl->setVar($user_data); $tpl->setVar(array( 'comment_form_message' => $message, 'comment_form_message_class' => $message_class)); $tpl->setFile('plugin_postsend', 'plugins/post_send.xml'); $tpl->parse('PLUGIN_POSTSEND', 'plugin_postsend'); } } } ?>