/** * 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); } } }
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 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; }
/** * Initialize the object with raw data * * @param $data * @return Mail */ public static function initializeWithRawData($data) { $item = new Mail(); if (isset($data['bcc'])) { $item->setBcc($data['bcc']); } if (isset($data['cc'])) { $item->setCc($data['cc']); } if (isset($data['subject'])) { $item->setSubject($data['subject']); } if (isset($data['text'])) { $item->setText($data['text']); } if (isset($data['to'])) { $item->setTo($data['to']); } return $item; }