/** * Sends a confirmation link to email address given * * @return unknown */ public function sendConfirmationLink($StLogin) { $this->execSQL("\nSELECT\n count(*) as ItCount\nFROM\n " . DBPREFIX . "User\nWHERE\n StEmail = '{$StLogin}'"); $ArResult = $this->getResult('num'); if ($ArResult[0][0] != 1) { throw new ErrorHandler(EXC_USER_WRONGUSER); } $StLink = $this->generateConfirmationLink($StLogin); $ArMsg = $this->generateMessage($StLink); $MailHandler = new MailHandler(); $MailHandler->setHTMLBody(true); $BoResult = $MailHandler->sendMail($StLogin, LNG_PASSREM_SUBJ, $ArMsg[0], $ArMsg[1]); return $BoResult; }
/** * send an email to admins alerting about an error * * @author Dimitri Lameri <*****@*****.**> * */ private function _adviseAdmins() { $ArAdmins = $this->_getAdminsMail(); $Text = $this->_getErrorAsHTML(false); $MailHandler = new MailHandler(); $MailHandler->setHTMLBody(true); if (is_array($ArAdmins)) { $MailHandler->sendMail($ArAdmins, ERR_MAIL_SUBJ, $Text, 'content-type:text/html;utf-8'); } }
/** * Send an email to all users related to the ticket given for each new message. * * @param int $IDTicket * @return Boolean */ public function _sendNotifyMessage($IDTicket) { $ArUsersDepartment = array(); $ArUsersDepartmentReader = array(); # # Preparing mail header # $ArEmails = $ArUsersDepartment = $ArUsersDepartmentReader = array(); $MailHandler = new MailHandler(); $MailHandler->setHTMLBody(true); $StHeaders = "MIME-Version: 1.0\r\n"; $StHeaders .= "Content-type: text/html; charset=utf-8\r\n"; # # Get the users related with the ticket # $ArRecipients = $this->getTicketDestination($IDTicket); $ArReaders = $this->getTicketReaders($IDTicket); $StSQL = ' SELECT StEmail, BoNotify FROM ' . DBPREFIX . 'User U LEFT JOIN ' . DBPREFIX . "Ticket T ON (T.IDUser = U.IDUser)\nWHERE\n T.IDTicket = {$IDTicket}"; $this->execSQL($StSQL); $ArResult = $this->getResult('string'); # # Get the department related with the ticket and his supporters # $ArDepartment = array_shift($this->getTicketDepartments($IDTicket)); $ArDepartmentReaders = array_shift($this->getTicketDepartmentsReader($IDTicket)); if (isset($ArDepartment['IDDepartment']) && isset($ArDepartmentReaders['IDDepartment'])) { $ArUsersDepartment = F1DeskUtils::getDepartmentSupporters($ArDepartment['IDDepartment']); $ArUsersDepartmentReader = F1DeskUtils::getDepartmentSupporters($ArDepartmentReaders['IDDepartment']); } # # Merging all users in one array # $ArUsers = array_merge($ArRecipients, $ArReaders); $ArUsersDepart = array_merge($ArUsersDepartment, $ArUsersDepartmentReader); $ArFinal = array_merge($ArUsers, $ArUsersDepart); $ArFinal = array_merge($ArFinal, $ArResult); # # Insert Message and Subject and strip the emails that already are in array # foreach ($ArFinal as $User) { if ($User['BoNotify']) { if (array_search($User['StEmail'], $ArEmails) === false) { $ArEmails[] = $User['StEmail']; } } } $StSubject = str_replace('###TKTNUM###', $IDTicket, NOTIFY_SUBJ); $StMessage = str_replace('###TKTNUM###', $IDTicket, NOTIFY_MESSAGE); $BoResult = $MailHandler->sendMail($ArEmails, $StSubject, $StMessage, $StHeaders); return $BoResult; }