public function __construct($member) { $this->member = $member; if ($member) { $this->hasSuggestionRight = $this->checkSuggestionRight(); $this->disableTinyMCE = $member->getPreference("PreferenceDisableTinyMCE", $default = "No"); if ($member->Status != 'ChoiceInactive') { $this->viewOnly = false; } } $this->purifier = MOD_htmlpure::getSuggestionsHtmlPurifier(); }
private function informSuggestionTeam($suggestion) { // get all team members $query = "\r\n SELECT\r\n username\r\n FROM\r\n members, rights, rightsvolunteers\r\n WHERE\r\n members.Status = 'Active'\r\n AND members.id = rightsvolunteers.IdMember\r\n AND rights.`Name` = 'Suggestions'\r\n AND rightsvolunteers.IdRight = rights.id\r\n AND rightsvolunteers.Level > 0\r\n ORDER BY\r\n username\r\n "; $res = $this->dao->query($query); if (!$res) { return false; } $receivers = array(); while ($row = $res->fetch(PDB::FETCH_OBJ)) { $member = $this->createEntity('Member')->findByUsername($row->username); $email = MOD_crypt::AdminReadCrypted($member->Email); $receivers[$email] = "BW " . $row->username; } //Create the Transport $transport = Swift_SmtpTransport::newInstance('localhost', 25); //Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); $purifier = MOD_htmlpure::getSuggestionsHtmlPurifier(); $plain = 'Please check the suggestion and take the necessary <a href="' . PVars::getObj('env')->baseuri . 'suggestions/' . $suggestion->id . '/approve">action</a>.'; $html = $purifier->purify($suggestion->description) . '<br/>' . $plain; try { $creator = $this->createEntity('Member')->findById($suggestion->createdby); $message = Swift_Message::newInstance(); $message->setSubject("New suggestion added by " . $creator->Username . ": " . $suggestion->summary); $message->setFrom("*****@*****.**"); $message->setBcc($receivers); $message->addPart($html, 'text/html', 'utf-8'); $message->addPart($plain, 'text/plain', 'utf-8'); $message->setBody($plain); } catch (Exception $e) { $this->logWrite("In suggestions model creating mail message threw exception.", "suggestions"); return false; } //Now check if Swift actually sends it try { $sendResult = $mailer->send($message); } catch (Exception $e) { $this->logWrite("Exception when executing Swift_Mailer::send()", "suggestions"); $sendResult = false; } if ($sendResult) { return true; } else { $this->logWrite("In suggestions model swift::send: Failed to send mail.", "suggestions"); return false; } }
public function __construct($model = false) { parent::__construct(); $this->purifier = MOD_htmlpure::getSuggestionsHtmlPurifier(); }