Beispiel #1
0
 public function execute($config, $session, $filter, $matcher)
 {
     $mailtemplate = $this->getMailTemplate($session);
     if ($mailtemplate == null || $session->hasVariable("form")) {
         $templates = $session->getStorage()->getMailTemplateList($session->getAllowedGliederungIDs("mitglieder_show"));
         return array("sendmail" => "select", "templates" => $templates, "mailtemplate" => $mailtemplate);
     }
     // Remove Storage before (less driver-headaches and space-consumption)
     $mailtemplatecode = "";
     if ($mailtemplate != null) {
         $a = clone $mailtemplate;
         $a->setStorage(null);
         $mailtemplatecode = base64_encode(serialize($a));
     }
     switch ($session->getVariable("sendmail")) {
         default:
         case "preview":
             $mitgliedercount = $session->getStorage()->getMitgliederCount($filter);
             $mitglied = array_shift($session->getStorage()->getMitgliederList($filter, 1, rand(0, $mitgliedercount - 1)));
             $replacer = new MitgliedTextReplacer($mitglied);
             $mail = $mailtemplate->generateMail($mitglied->getLatestRevision()->getKontakt()->getEMail(), $replacer);
             return array("sendmail" => "preview", "mailtemplatecode" => $mailtemplatecode, "mail" => $mail);
         case "send":
             $process = new MitgliederFilterSendMailProcess($session->getStorage());
             $process->setTemplate($mailtemplate);
             return $this->executeProcess($session, $process, $filter, $matcher);
     }
 }
Beispiel #2
0
 public function execute($config, $session, $filter, $matcher)
 {
     $mailtemplateid = $this->mailtemplateid;
     if ($session->hasVariable("mailtemplateid")) {
         $mailtemplateid = $session->getVariable("mailtemplateid");
     }
     $mailtemplate = null;
     if ($mailtemplateid != null) {
         $mailtemplate = $session->getStorage()->getMailTemplate($mailtemplateid);
     }
     if (!$session->hasVariable("timestamp") || !$session->hasVariable("kommentar")) {
         return array("delete" => "options", "mailtemplate" => $mailtemplate, "mailtemplates" => $session->getStorage()->getMailTemplateList($this->getAllowedGliederungIDs($session)));
     } else {
         $timestamp = $session->getTimestampVariable("timestamp");
         $process = new MitgliederFilterConsecutiveProcess($session->getStorage());
         $p1 = new MitgliederFilterDeleteProcess($session->getStorage());
         $p1->setTimestamp($timestamp);
         $p1->setKommentar($session->getVariable("kommentar"));
         $process->addProcess($p1);
         if ($mailtemplate != null) {
             $p2 = new MitgliederFilterSendMailProcess($session->getStorage());
             $p2->setTemplate($mailtemplate);
             $process->addProcess($p2);
         }
         return $this->executeProcess($session, $process, $filter, $matcher);
     }
 }