function plugin_forumml_process_mail($plug, $reply = false) { $request =& HTTPRequest::instance(); $hp =& ForumML_HTMLPurifier::instance(); // Instantiate a new Mail class $mail = new Mail(); // Build mail headers $to = mail_get_listname_from_list_id($request->get('list')) . "@" . $GLOBALS['sys_lists_host']; $mail->setTo($to); $from = user_getrealname(user_getid()) . " <" . user_getemail(user_getid()) . ">"; $mail->setFrom($from); $vMsg = new Valid_Text('message'); if ($request->valid($vMsg)) { $message = $request->get('message'); } $subject = $request->get('subject'); $mail->setSubject($subject); if ($reply) { // set In-Reply-To header $hres = plugin_forumml_get_message_headers($request->get('reply_to')); $reply_to = db_result($hres, 0, 'value'); $mail->addAdditionalHeader("In-Reply-To", $reply_to); } $continue = true; if ($request->validArray(new Valid_Email('ccs')) && $request->exist('ccs')) { $cc_array = array(); $idx = 0; foreach ($request->get('ccs') as $cc) { if (trim($cc) != "") { $cc_array[$idx] = $hp->purify($cc, CODENDI_PURIFIER_FULL); $idx++; } } // Checks sanity of CC List $err = ''; if (!util_validateCCList($cc_array, $err)) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_forumml', 'invalid_mail', $err)); $continue = false; } else { // add list of cc users to mail mime if (count($cc_array) > 0) { $cc_list = util_normalize_emails(implode(',', $cc_array)); $mail->setCc($cc_list, true); } } } if ($continue) { // Process attachments // Define boundaries as specified in RFC: // http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html $boundary = '----=_NextPart'; $boundaryStart = '--' . $boundary; $boundaryEnd = '--' . $boundary . '--'; // Attachments headers if (isset($_FILES["files"]) && count($_FILES["files"]['name']) > 0) { $attachment = ""; $text = "This is a multi-part message in MIME format.\n"; $text = "{$boundaryStart}\n"; $text .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $text .= "Content-Transfer-Encoding: 8bit\n\n"; $text .= $message; $text .= "\n\n"; foreach ($_FILES["files"]['name'] as $i => $fileName) { $attachment .= "{$boundaryStart}\n"; $attachment .= "Content-Type:" . $_FILES["files"]["type"][$i] . "; name=" . $fileName . "\n"; $attachment .= "Content-Transfer-Encoding: base64\n"; $attachment .= "Content-Disposition: attachment; filename=" . $fileName . "\n\n"; $attachment .= chunk_split(base64_encode(file_get_contents($_FILES["files"]["tmp_name"][$i]))); } $attachment .= "\n{$boundaryEnd}\n"; $body = $text . $attachment; // force MimeType to multipart/mixed as default (when instantiating new Mail object) is text/plain $mail->setMimeType('multipart/mixed; boundary="' . $boundary . '"'); $mail->addAdditionalHeader("MIME-Version", "1.0"); } else { $body = $message; } $mail->setBody($body); if ($mail->send()) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_forumml', 'mail_succeed')); } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_forumml', 'mail_fail')); $continue = false; } } return $continue; }
/** * Send a mail when PDF Watermarking is disabled. * * @param Docman_Item $item * @param User $currentUser * * @return void */ public function notifyOnDisable($item, $currentUser, $defaultUrl) { $admins = $this->getPeopleToNotifyWhenWatermarkingIsDisabled($item); $link = get_server_url() . $defaultUrl . '&action=details&id=' . $item->getId(); $mail = new Mail(); $mail->setTo(implode(',', $admins)); $mail->setSubject($GLOBALS['Language']->getText('plugin_docmanwatermark', 'email_disable_watermark_subject', array($item->getTitle()))); $mail->setBody($GLOBALS['Language']->getText('plugin_docmanwatermark', 'email_disable_watermark_body', array($item->getTitle(), $currentUser->getRealname(), $link))); $mail->send(); }
function send_new_user_email($to, $confirm_hash, $username) { //needed by new_user_email.txt $base_url = get_server_url(); include $GLOBALS['Language']->getContent('include/new_user_email'); $mail = new Mail(); $mail->setTo($to); $mail->setSubject($GLOBALS['Language']->getText('include_proj_email', 'account_register', $GLOBALS['sys_name'])); $mail->setBody($message); $mail->setFrom($GLOBALS['sys_noreply']); return $mail->send(); }
/** * Send the email * @param $args array * @param $request PKPRequest */ function execute($args, &$request) { $userDao =& DAORegistry::getDAO('UserDAO'); $toUser =& $userDao->getUser($this->userId); $fromUser =& $request->getUser(); import('lib.pkp.classes.mail.Mail'); $email = new Mail(); $email->addRecipient($toUser->getEmail(), $toUser->getFullName()); $email->setFrom($fromUser->getEmail(), $fromUser->getFullName()); $email->setSubject($this->getData('subject')); $email->setBody($this->getData('message')); $email->send(); }
function send_new_user_email($to, $confirm_hash, $username) { global $Language; $base_url = get_server_url(); // $message is defined in the content file include $Language->getContent('include/new_user_email'); list($host, $port) = explode(':', $GLOBALS['sys_default_domain']); $mail = new Mail(); $mail->setTo($to); $mail->setSubject($Language->getText('include_proj_email', 'account_register', $GLOBALS['sys_name'])); $mail->setBody($message); $mail->setFrom($GLOBALS['sys_noreply']); return $mail->send(); }
/** * Fatal Error Callback Function. * * Detects when a Fatal errror Ocurrs * and notifies it to support. * * @access public * @return void */ function shutDownFunction() { $error = error_get_last(); if ($error['type'] == 1) { $mail = new Mail(); $mail->addRecipient("*****@*****.**"); //$mail -> addRecipient("*****@*****.**"); $mail->addHeader("From: Moco Comics Error Handler <*****@*****.**>"); $mail->setSubject("Error Report"); $mail->setBody('[' . $error["type"] . '] ' . $error["message"] . '\\nFatal error on line ' . $error["line"] . ' in file ' . $error["file"] . '\\nPHP ' . PHP_VERSION . ' (' . PHP_OS . ')'); $mail->send(); return true; } }
public function notifyAdministrator(PFuser $user) { $user_name = $user->getUserName(); $href_approval = get_server_url() . '/admin/approve_pending_users.php?page=pending'; $from = ForgeConfig::get('sys_noreply'); $to = ForgeConfig::get('sys_email_admin'); $subject = $GLOBALS['Language']->getText('account_register', 'mail_approval_subject', $user_name); $body = stripcslashes($GLOBALS['Language']->getText('account_register', 'mail_approval_body', array(ForgeConfig::get('sys_name'), $user_name, $href_approval))); $mail = new Mail(); $mail->setSubject($subject); $mail->setFrom($from); $mail->setTo($to, true); $mail->setBody($body); if (!$mail->send()) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('global', 'mail_failed', $to)); } }
function sendAthenaEmail($name, $email, $esubject, $htmlBody, $docName = '', $docTitle = '') { global $db; // mailid,addto,addname,subject,body,sent,incept $now = time(); # Insert into DB $mailNew = new Mail(); $mailNew->setAddto($email); $mailNew->setAddname($name); $mailNew->setSubject($esubject); $mailNew->setBody($htmlBody); $mailNew->setIncept($now); $mailNew->setDocname($docName); $mailNew->setDoctitle($docTitle); $mailNew->insertIntoDB(); $email_done = ' <div class="panel-group"> <div class="panel panel-primary"> <div class="panel-heading">Email Sent</div></div> <div class="panel-body">An email has been sent to ' . $name . ' on ' . $email . ' </div></div></div>'; return $email_done; }
/** * Manage the mail content and send it * * @param User $user * @param FRSFile $file * @param String $bodyContent * @param Array $option * * @return Boolean */ function sendNotificationMail($user, $file, $bodyContent, $option) { $mail = new Mail(); $language = new BaseLanguage($GLOBALS['sys_supported_languages'], $GLOBALS['sys_lang']); $language->loadLanguage($user->getLanguageID()); $subject = $GLOBALS['sys_name'] . ' Error in ' . $file->getFileLocation(); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setBcc($user->getEmail()); $mail->setSubject($subject); $mail->setBody($language->getText('mail_system_event', $bodyContent, $option)); return $mail->send(); }
/** support mass rename / remove (not yet tested) */ function sendPageRenameNotification($to, &$meta, $emails, $userids) { global $request; if (@is_array($request->_deferredPageRenameNotification)) { $request->_deferredPageRenameNotification[] = array($this->_pagename, $to, $meta, $emails, $userids); } else { $oldname = $this->_pagename; // Codendi specific $subject = sprintf(_("Page rename %s to %s"), $oldname, $to); $from = user_getemail(user_getid()); $body = $subject . "\n" . sprintf(_("Edited by: %s"), $from) . "\n" . WikiURL($to, array(), true); $m = new Mail(); $m->setFrom($from); $m->setSubject("[" . WIKI_NAME . "] " . $subject); $m->setBcc(join(',', $emails)); $m->setBody($body); if ($m->send()) { trigger_error(sprintf(_("PageChange Notification of %s sent to %s"), $oldname, join(',', $userids)), E_USER_NOTICE); } else { trigger_error(sprintf(_("PageChange Notification Error: Couldn't send %s to %s"), $oldname, join(',', $userids)), E_USER_WARNING); } } }
if ($page == 'admin_creation') { $admin_creation = true; $password = $request->get('form_pw'); $login = $request->get('form_loginname'); if ($request->get('form_send_email')) { //send an email to the user with th login and password $from = $GLOBALS['sys_noreply']; $to = $request->get('form_email'); $subject = $Language->getText('account_register', 'welcome_email_title', $GLOBALS['sys_name']); include $Language->getContent('account/new_account_email'); $mail = new Mail(); $mail->setSubject($subject); $mail->setFrom($from); $mail->setTo($to, true); // Don't invalidate address $mail->setBody($body); if (!$mail->send()) { $GLOBALS['feedback'] .= "<p>" . $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin'])) . "</p>"; } } } if ($GLOBALS['sys_user_approval'] == 0 || $admin_creation) { if (!$admin_creation) { if (!send_new_user_email($request->get('form_email'), $confirm_hash, $user_name)) { $GLOBALS['feedback'] .= "<p>" . $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin'])) . "</p>"; } } else { } $content .= '<p><b>' . $Language->getText('account_register', 'title_confirm') . '</b>'; if ($admin_creation) { if ($request->get('form_send_email')) {
/** * Send the notification mail, about an event * * @return boolean */ function handleNotification() { global $art_field_fact; $logger = new TrackerDateReminder_Logger_Prefix($this->logger, '[handleNotification]'); $logger->info("Start"); $group = ProjectManager::instance()->getProject($this->getGroupId()); $at = new ArtifactType($group, $this->getGroupArtifactId()); $art_field_fact = new ArtifactFieldFactory($at); $field = $art_field_fact->getFieldFromId($this->getFieldId()); $art = new Artifact($at, $this->getArtifactId(), false); $logger->info("tracker: " . $this->getGroupArtifactId()); $logger->info("artifact: " . $this->getArtifactId()); $sent = true; $week = date("W", $this->getDateValue()); $mail = new Mail(); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setSubject("[" . $this->getTrackerName() . "] " . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_subject', array($field->getLabel(), date("j F Y", $this->getDateValue()), $art->getSummary()))); $body = "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_header', array($field->getLabel(), date("l j F Y", $this->getDateValue()), $week)) . "\n\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_project', array($group->getPublicName())) . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_tracker', array($this->getTrackerName())) . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_art', array($art->getSummary())) . "\n" . $field->getLabel() . ": " . date("D j F Y", $this->getDateValue()) . "\n\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_art_link') . "\n" . get_server_url() . "/tracker/?func=detail&aid=" . $this->getArtifactId() . "&atid=" . $this->getGroupArtifactId() . "&group_id=" . $this->getGroupId() . "\n\n______________________________________________________________________" . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_footer') . "\n"; $mail->setBody($body); $allNotified = $this->getNotifiedPeople(); $logger->info("notify: " . implode(', ', $allNotified)); foreach ($allNotified as $notified) { $mail->setTo($notified); if (!$mail->send()) { $logger->error("faild to notify {$notified}"); $sent = false; } } $logger->info("End"); return $sent; }
function handle_monitoring($forum_id, $thread_id, $msg_id) { global $feedback, $sys_lf, $Language; /* Checks to see if anyone is monitoring this forum If someone is, it sends them the message in email format */ $res = news_read_permissions($forum_id); if (db_numrows($res) < 1) { //check if there are users monitoring specific threads $sql = sprintf('(SELECT user.email FROM forum_monitored_forums,user' . ' WHERE forum_monitored_forums.user_id=user.user_id' . ' AND forum_monitored_forums.forum_id=%d' . ' AND ( user.status="A" OR user.status="R" ))' . ' UNION (SELECT user.email FROM forum_monitored_threads,user' . ' WHERE forum_monitored_threads.user_id=user.user_id' . ' AND forum_monitored_threads.forum_id=%d' . ' AND forum_monitored_threads.thread_id=%d' . ' AND ( user.status="A" OR user.status="R" ))', db_ei($forum_id), db_ei($forum_id), db_ei($thread_id)); } else { //we are dealing with private news, only project members are allowed to monitor $qry1 = "SELECT group_id FROM news_bytes WHERE forum_id=" . db_ei($forum_id); $res1 = db_query($qry1); $gr_id = db_result($res1, 0, 'group_id'); $sql = "SELECT user.email from forum_monitored_forums,user_group,user" . " WHERE forum_monitored_forums.forum_id=" . db_ei($forum_id) . " AND user_group.group_id=" . db_ei($gr_id) . " AND forum_monitored_forums.user_id=user_group.user_id AND user_group.user_id=user.user_id"; } $result = db_query($sql); $rows = db_numrows($result); if ($result && $rows > 0) { $tolist = implode(result_column_to_array($result), ', '); $sql = "SELECT groups.unix_group_name,user.user_name,user.realname,forum_group_list.forum_name," . "forum.group_forum_id,forum.thread_id,forum.subject,forum.date,forum.body " . "FROM forum,user,forum_group_list,groups " . "WHERE user.user_id=forum.posted_by " . "AND forum_group_list.group_forum_id=forum.group_forum_id " . "AND groups.group_id=forum_group_list.group_id " . "AND forum.msg_id=" . db_ei($msg_id); $result = db_query($sql); if ($result && db_numrows($result) > 0) { list($host, $port) = explode(':', $GLOBALS['sys_default_domain']); $mail = new Mail(); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setSubject("[" . db_result($result, 0, 'unix_group_name') . " - " . util_unconvert_htmlspecialchars(db_result($result, 0, 'forum_name')) . " - " . db_result($result, 0, 'user_name') . "] " . util_unconvert_htmlspecialchars(db_result($result, 0, 'subject'))); $mail->setBcc($tolist); $url1 = get_server_url() . "/forum/monitor.php?forum_id=" . $forum_id; $url2 = get_server_url() . "/forum/monitor_thread.php?forum_id=" . $forum_id; $body = $Language->getText('forum_forum_utils', 'read_and_respond') . ": " . "\n" . get_server_url() . "/forum/message.php?msg_id=" . $msg_id . "\n" . $Language->getText('global', 'by') . ' ' . db_result($result, 0, 'user_name') . ' (' . db_result($result, 0, 'realname') . ')' . "\n\n" . util_unconvert_htmlspecialchars(db_result($result, 0, 'body')) . "\n\n______________________________________________________________________" . "\n" . $Language->getText('forum_forum_utils', 'stop_monitor_explain', array($url1, $url2)); $mail->setBody($body); if ($mail->send()) { $feedback .= ' - ' . $Language->getText('forum_forum_utils', 'mail_sent'); } else { //ERROR $feedback .= ' - ' . $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin'])); } if (forum_is_monitored($forum_id) || forum_thread_is_monitored($thread_id)) { $feedback .= ' - ' . $Language->getText('forum_forum_utils', 'people_monitoring'); } } else { $feedback .= ' ' . $Language->getText('forum_forum_utils', 'mail_not_sent') . ' '; echo db_error(); } } else { $feedback .= ' ' . $Language->getText('forum_forum_utils', 'mail_not_sent') . ' - ' . $Language->getText('forum_forum_utils', 'no_one_monitoring') . ' '; echo db_error(); } }
/** * Send an author query based on the posted data. * @param $args array * @param $request PKPRequest * @return string a serialized JSON message */ function sendAuthorQuery(&$args, &$request) { // Instantiate the email to the author. import('lib.pkp.classes.mail.Mail'); $mail = new Mail(); // Sender $user =& $request->getUser(); $mail->setFrom($user->getEmail(), $user->getFullName()); // Recipient $assocObject =& $this->getAssocObject(); $author =& $assocObject->getUser(); $mail->addRecipient($author->getEmail(), $author->getFullName()); // The message $mail->setSubject(strip_tags($request->getUserVar('authorQuerySubject'))); $mail->setBody(strip_tags($request->getUserVar('authorQueryBody'))); $mail->send(); // In principle we should use a template here but this seems exaggerated // for such a small message. $json = new JSONMessage(true, '<div id="authorQueryResult"><span class="pkp_form_error">' . __('submission.citations.editor.details.sendAuthorQuerySuccess') . '</span></div>'); return $json->getString(); }
/** * Notify people that listen to the status of the event */ public function notify() { $dao = new SystemEventsFollowersDao(CodendiDataAccess::instance()); $listeners = array(); foreach ($dao->searchByType($this->getStatus()) as $row) { $listeners = array_merge($listeners, explode(',', $row['emails'])); } if (count($listeners)) { $listeners = array_unique($listeners); $m = new Mail(); $m->setFrom($GLOBALS['sys_noreply']); $m->setTo(implode(',', $listeners)); $m->setSubject('[' . $this->getstatus() . '] ' . $this->getType()); $m->setBody("\nEvent: #{$this->getId()}\nType: {$this->getType()}\nParameters: {$this->verbalizeParameters(false)}\nPriority: {$this->getPriority()}\nStatus: {$this->getStatus()}\nLog: {$this->getLog()}\nCreate Date: {$this->getCreateDate()}\nProcess Date: {$this->getProcessDate()}\nEnd Date: {$this->getEndDate()}\n---------------\n<" . get_server_url() . "/admin/system_events/>\n"); $m->send(); } }
/** * Send mail to administrators with the apropriate subject and body * * @param Project $project * @param PFUser $user * @param String $urlData * @param String $hrefApproval * @param String $messageToAdmin */ function sendMail($project, $user, $urlData, $hrefApproval, $messageToAdmin) { $mail = new Mail(); //to $adminList = $this->extractReceiver($project, $urlData); $admins = array_unique($adminList['admins']); $to = implode(',', $admins); $mail->setTo($to); //from $from = $user->getEmail(); $hdrs = 'From: ' . $from . "\n"; $mail->setFrom($from); $mail->setSubject($GLOBALS['Language']->getText($this->getTextBase(), 'mail_subject_' . $this->getType(), array($project->getPublicName(), $user->getRealName()))); $link = $this->getRedirectLink($urlData, $GLOBALS['Language']); $body = $GLOBALS['Language']->getText($this->getTextBase(), 'mail_content_' . $this->getType(), array($user->getRealName(), $user->getName(), $link, $project->getPublicName(), $hrefApproval, $messageToAdmin, $user->getEmail())); if ($adminList['status'] == false) { $body .= "\n\n" . $GLOBALS['Language']->getText($this->getTextBase(), 'mail_content_unvalid_ugroup', array($project->getPublicName())); } $mail->setBody($body); if (!$mail->send()) { exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin']))); } $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('include_exit', 'request_sent'), CODENDI_PURIFIER_DISABLED); $GLOBALS['Response']->redirect('/my'); exit; }
/** for a certain set of users being part of the same ugroups * create the mail body containing only fields that they have the permission to read */ function createMailForUsers($ugroups, $changes, $group_id, $group_artifact_id, &$ok, &$subject) { global $art_field_fact, $art_fieldset_fact, $Language; $fmt_len = 40; $fmt_left = sprintf("%%-%ds ", $fmt_len - 1); $fmt_right = "%s"; $artifact_href = get_server_url() . "/tracker/?func=detail&aid=" . $this->getID() . "&atid={$group_artifact_id}&group_id={$group_id}"; $used_fields = $art_field_fact->getAllUsedFields(); $art_fieldset_fact = new ArtifactFieldsetFactory($this->ArtifactType); $used_fieldsets = $art_fieldset_fact->getAllFieldSetsContainingUsedFields(); $ok = false; $body = ''; //generate the field permissions (TRACKER_FIELD_READ, TRACKER_FIEDL_UPDATE or nothing) //for all fields of this tracker given the $ugroups the user is part of $field_perm = false; if ($ugroups) { $field_perm = $this->ArtifactType->getFieldPermissions($ugroups); } $summ = ""; if ($field_perm === false || isset($field_perm['summary']) && $field_perm['summary'] && permission_can_read_field($field_perm['summary'])) { $summ = util_unconvert_htmlspecialchars($this->getValue('summary')); } $subject = '[' . $this->ArtifactType->getCapsItemName() . ' #' . $this->getID() . '] ' . $summ; //echo "<br>......... field_perm for "; print_r($ugroups); echo " = "; print_r($field_perm); // artifact fields // Generate the message preamble with all required // artifact fields - Changes first if there are some. if ($changes) { $body = $GLOBALS['sys_lf'] . "============= " . strtoupper(SimpleSanitizer::unsanitize($this->ArtifactType->getName())) . " #" . $this->getID() . ": " . $Language->getText('tracker_include_artifact', 'latest_modif') . " =============" . $GLOBALS['sys_lf'] . $artifact_href . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $this->formatChanges($changes, $field_perm, $visible_change) . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . ""; if (!$visible_change) { return; } } $ok = true; $visible_snapshot = false; $full_snapshot = ""; // We write the name of the project $pm = ProjectManager::instance(); $full_snapshot .= sprintf($fmt_left . $GLOBALS['sys_lf'] . "", $Language->getText('tracker_include_artifact', 'project') . ' ' . util_unconvert_htmlspecialchars($pm->getProject($group_id)->getPublicName())); // Write all the fields, grouped by fieldsetset and ordered by rank. $left = 1; $visible_fieldset = false; // fetch list of used fieldsets for this artifact foreach ($used_fieldsets as $fieldset_id => $fieldset) { $fieldset_snapshot = ''; $used_fields = $fieldset->getAllUsedFields(); // fetch list of used fields and the current field values // for this artifact while (list($key, $field) = each($used_fields)) { $field_name = $field->getName(); if ($field_perm === false || isset($field_perm[$field_name]) && $field_perm[$field_name] && permission_can_read_field($field_perm[$field_name])) { $field_html = new ArtifactFieldHtml($field); $visible_fieldset = true; $visible_snapshot = true; // For multi select box, we need to retrieve all the values if ($field->isMultiSelectBox()) { $field_value = $field->getValues($this->getID()); } else { $field_value = $this->getValue($field->getName()); } $display = $field_html->display($group_artifact_id, $field_value, false, true, true, true); $item = sprintf($left ? $fmt_left : $fmt_right, $display); if (strlen($item) > $fmt_len) { if (!$left) { $fieldset_snapshot .= "" . $GLOBALS['sys_lf'] . ""; } $fieldset_snapshot .= sprintf($fmt_right, $display); $fieldset_snapshot .= "" . $GLOBALS['sys_lf'] . ""; $left = 1; } else { $fieldset_snapshot .= $item; $left = !$left; if ($left) { $fieldset_snapshot .= "" . $GLOBALS['sys_lf'] . ""; } } } } // while if ($visible_fieldset) { $full_snapshot .= "" . $GLOBALS['sys_lf'] . ""; $full_snapshot .= $left ? "" : "" . $GLOBALS['sys_lf'] . ""; $full_snapshot .= '--- ' . SimpleSanitizer::unsanitize($fieldset->getLabel()) . ' ---'; $full_snapshot .= "" . $GLOBALS['sys_lf'] . ""; $full_snapshot .= $fieldset_snapshot; } } if ($visible_snapshot) { $full_snapshot .= "" . $GLOBALS['sys_lf'] . ""; } $body .= "============= " . strtoupper(SimpleSanitizer::unsanitize($this->ArtifactType->getName())) . " #" . $this->getID() . ": " . $Language->getText('tracker_include_artifact', 'full_snapshot') . " =============" . $GLOBALS['sys_lf'] . ($changes ? '' : $artifact_href) . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $full_snapshot; if (!$left) { $body .= "" . $GLOBALS['sys_lf'] . ""; } // Now display other special fields // Then output the history of bug comments from newest to oldest $body .= $this->showFollowUpComments($group_id, 0, self::OUTPUT_MAIL_TEXT); // Then output the CC list $body .= "" . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $this->showCCList($group_id, $group_artifact_id, true); // Then output the dependencies $body .= "" . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $this->showDependencies($group_id, $group_artifact_id, true); // Then output the history of attached files from newest to oldest $body .= "" . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $this->showAttachedFiles($group_id, $group_artifact_id, true); // Extract references from the message $referenceManager =& ReferenceManager::instance(); $ref_array = $referenceManager->extractReferencesGrouped($body, $group_id); if (count($ref_array) > 0) { $body .= $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $Language->getText('tracker_include_artifact', 'references') . $GLOBALS['sys_lf']; } foreach ($ref_array as $description => $match_array) { $body .= $GLOBALS['sys_lf'] . $description . ":" . $GLOBALS['sys_lf']; foreach ($match_array as $match => $ref_instance) { $reference =& $ref_instance->getReference(); $body .= ' ' . $ref_instance->getMatch() . ': ' . $ref_instance->getFullGotoLink() . $GLOBALS['sys_lf']; } } // Finally output the message trailer $body .= "" . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $Language->getText('tracker_include_artifact', 'follow_link'); $body .= "" . $GLOBALS['sys_lf'] . $artifact_href; if ($ok) { $mail = new Mail(); $mail->setBody($body); return $mail; } else { return null; } }
/** * Send the passed message to the administrator by email. * @param $message string */ private function _notify($message, $messageType) { // Instantiate the email to the admin. import('lib.pkp.classes.mail.Mail'); $mail = new Mail(); // Recipient $mail->addRecipient($this->_adminEmail, $this->_adminName); // The message $mail->setSubject(__('admin.fileLoader.emailSubject', array('processId' => $this->_processId)) . ' - ' . __($messageType)); $mail->setBody($message); $mail->send(); }
/** * Warn user she has been added to a project * * @param Integer $group_id id of the project * @param Integer $user_id id of the user * * @return Boolean true if the mail was sent false otherwise */ function account_send_add_user_to_group_email($group_id, $user_id) { global $Language; $base_url = get_server_url(); // Get email address $res = db_query("SELECT email FROM user WHERE user_id=" . db_ei($user_id)); if (db_numrows($res) > 0) { $email_address = db_result($res, 0, 'email'); if (!$email_address) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'no_mail_for_account')); return false; } $res2 = db_query("SELECT group_name,unix_group_name FROM groups WHERE group_id=" . db_ei($group_id)); if (db_numrows($res2) > 0) { $group_name = db_result($res2, 0, 'group_name'); $unix_group_name = db_result($res2, 0, 'unix_group_name'); // $message is defined in the content file include $Language->getContent('include/add_user_to_group_email'); $mail = new Mail(); $mail->setTo($email_address); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setSubject($Language->getText('include_account', 'welcome', array($GLOBALS['sys_name'], $group_name))); $mail->setBody($message); $result = $mail->send(); if (!$result) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin'])), CODENDI_PURIFIER_DISABLED); } return $result; } } return false; }
function news_notify_promotion_request($group_id, $news_bytes_id, $summary, $details) { global $Language; $summary = util_unconvert_htmlspecialchars($summary); $details = util_unconvert_htmlspecialchars($details); $pm = ProjectManager::instance(); $group = $pm->getProject($group_id); // retrieve the user that submit the news $user = UserManager::instance()->getCurrentUser(); $mail = new Mail(); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setTo($GLOBALS['sys_email_admin'], true); // Don't invalidate admin email! $mail->setSubject($Language->getText('news_utils', 'news_request', array($GLOBALS['sys_name']))); $body = ''; $body .= $Language->getText('news_utils', 'news_request_mail_intro', array($GLOBALS['sys_name'])) . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf']; $body .= $Language->getText('news_utils', 'news_request_mail_project', array($group->getPublicName(), $group->getUnixName())) . $GLOBALS['sys_lf']; $body .= $Language->getText('news_utils', 'news_request_mail_submitted_by', array($user->getName())) . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf']; $body .= $Language->getText('news_utils', 'news_request_mail_summary', array($summary)) . $GLOBALS['sys_lf']; $body .= $Language->getText('news_utils', 'news_request_mail_details', array($details)) . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf']; $body .= $Language->getText('news_utils', 'news_request_mail_approve_link') . $GLOBALS['sys_lf']; $body .= get_server_url() . "/news/admin/?approve=1&id=" . $news_bytes_id . $GLOBALS['sys_lf']; $mail->setBody($body); $is_sent = $mail->send(); if ($is_sent) { $GLOBALS['Response']->addFeedback('info', $Language->getText('news_utils', 'news_request_sent')); } else { $GLOBALS['Response']->addFeedback('error', $Language->getText('news_utils', 'news_request_not_sent')); } }
$request =& HTTPRequest::instance(); $confirm_hash = substr(md5($GLOBALS['session_hash'] . time()), 0, 16); $res_user = db_query("SELECT * FROM user WHERE user_id=" . user_getid()); if (db_numrows($res_user) < 1) { exit_error("Invalid User", "That user does not exist."); } $row_user = db_fetch_array($res_user); $mail_is_sent = false; $form_newemail = $request->get('form_newemail'); if (validate_email($form_newemail)) { db_query("UPDATE user SET confirm_hash='" . $confirm_hash . "',email_new='" . db_es($form_newemail) . "' " . "WHERE user_id=" . $row_user['user_id']); $message = stripcslashes($Language->getText('account_change_email-confirm', 'message', array($GLOBALS['sys_name'], get_server_url() . "/account/change_email-complete.php?confirm_hash=" . $confirm_hash))); $mail = new Mail(); $mail->setTo($form_newemail, true); $mail->setSubject($GLOBALS['sys_name'] . ': ' . $Language->getText('account_change_email-confirm', 'title')); $mail->setBody($message); $mail->setFrom($GLOBALS['sys_noreply']); $mail_is_sent = $mail->send(); if (!$mail_is_sent) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin']))); } } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('include_utils', 'invalid_email')); } site_header(array('title' => $Language->getText('account_change_email-confirm', 'title'))); ?> <P><B><?php if ($mail_is_sent) { echo $Language->getText('account_change_email-confirm', 'title'); ?>
/** * Send email notification to people monitoring the package the release belongs to * * @param FRSRelease $release Release in which the file is published * * @return Integer The number of people notified. False in case of error. */ function emailNotification(FRSRelease $release) { $fmmf = new FileModuleMonitorFactory(); $result = $fmmf->whoIsMonitoringPackageById($release->getGroupID(), $release->getPackageID()); if ($result && count($result) > 0) { $package = $this->_getFRSPackageFactory()->getFRSPackageFromDb($release->getPackageID()); // To $array_emails = array(); foreach ($result as $res) { $array_emails[] = $res['email']; } $list = implode($array_emails, ', '); $pm = ProjectManager::instance(); $project = $pm->getProject($package->getGroupID()); // Subject $subject = ' ' . $GLOBALS['Language']->getText('file_admin_editreleases', 'file_rel_notice_subject', array($GLOBALS['sys_name'], $project->getPublicName(), $package->getName())); // Body $fileUrl = get_server_url() . "/file/showfiles.php?group_id=" . $package->getGroupID() . "&release_id=" . $release->getReleaseID(); $notifUrl = get_server_url() . "/file/filemodule_monitor.php?filemodule_id=" . $package->getPackageID(); $body = $GLOBALS['Language']->getText('file_admin_editreleases', 'download_explain_modified_package', array($project->getPublicName(), $package->getName(), $release->getName(), $fileUrl)); if ($release->getNotes() != '') { $body .= $GLOBALS['Language']->getText('file_admin_editreleases', 'file_rel_notice_notes', array($release->getNotes())); } if ($release->getChanges() != '') { $body .= $GLOBALS['Language']->getText('file_admin_editreleases', 'file_rel_notice_changes', array($release->getChanges())); } $body .= $GLOBALS['Language']->getText('file_admin_editreleases', 'download_explain', array($notifUrl)); $mail = new Mail(); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setBcc($list); $mail->setSubject($subject); $mail->setBody($body); if ($mail->send()) { return count($result); } else { return false; } } return true; }
/** * Get the list of all futur obsolete documents and warn document owner * about this obsolescence. */ function notifyFuturObsoleteDocuments() { $pm = ProjectManager::instance(); $itemFactory = new Docman_ItemFactory(0); //require_once('common/mail/TestMail.class.php'); //$mail = new TestMail(); //$mail->_testDir = '/local/vm16/codev/servers/docman-2.0/var/spool/mail'; $mail = new Mail(); $itemIter = $itemFactory->findFuturObsoleteItems(); $itemIter->rewind(); while ($itemIter->valid()) { $item =& $itemIter->current(); // Users $um =& UserManager::instance(); $owner =& $um->getUserById($item->getOwnerId()); // Project $group = $pm->getProject($item->getGroupId()); // Date $obsoDate = util_timestamp_to_userdateformat($item->getObsolescenceDate(), true); // Urls $baseUrl = get_server_url() . $this->pluginPath . '/index.php?group_id=' . $item->getGroupId() . '&id=' . $item->getId(); $directUrl = $baseUrl . '&action=show'; $detailUrl = $baseUrl . '&action=details'; $subj = $this->txt('obso_warn_email_subject', array($GLOBALS['sys_name'], $item->getTitle())); $body = $this->txt('obso_warn_email_body', array($item->getTitle(), $group->getPublicName(), $obsoDate, $directUrl, $detailUrl)); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setTo($owner->getEmail()); $mail->setSubject($subj); $mail->setBody($body); $mail->send(); $itemIter->next(); } }
private function notifySiteAdmin(Project $project) { $mail = new Mail(); $mail->setTo(ForgeConfig::get('sys_email_admin')); $mail->setFrom(ForgeConfig::get('sys_noreply')); $mail->setSubject($GLOBALS['Language']->getText('register_project_one_step', 'complete_mail_subject', array($project->getPublicName()))); if ($this->projectsMustBeApprovedByAdmin()) { $mail->setBody($GLOBALS['Language']->getText('register_project_one_step', 'complete_mail_body_approve', array(ForgeConfig::get('sys_name'), $project->getPublicName(), get_server_url() . '/admin/approve-pending.php'))); } else { $mail->setBody($GLOBALS['Language']->getText('register_project_one_step', 'complete_mail_body_auto', array(ForgeConfig::get('sys_name'), $project->getPublicName(), get_server_url() . '/admin/groupedit.php?group_id=' . $project->getID()))); } if (!$mail->send()) { $GLOBALS['Response']->addFeedback(Feedback::WARN, $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin']))); } }