luser; $this->template->mailing = $luser->get_mailing($id); $this->template->is_admin = $luser->admin; } public function renderDelete($id) { $luser = $this->luser; $this->template->mailing = $luser->get_mailing($id); $this->template->is_admin = $luser->admin; } protected function createComponentProofread($action) { $form = new Nette\Application\UI\Form; $form->addProtection("protection token expired"); $form->onSuccess[] = [$this, 'proofreadFormOK']; return $form; } public function proofreadFormOK(Nette\Application\UI\Form $form) { $luser = $this->luser; $mailing = $luser->get_mailing($this->id); $mailing->sendTestMail($luser); $this->redirect('default'); } protected function createComponentSubmit($action) { $form = new Nette\Application\UI\Form; $form->addProtection("protection token expired"); $form->onSuccess[] = [$this, 'submitFormOK']; return $form; } public function submitFormOK(Nette\Application\UI\Form $form) { $luser = $this->luser; $mailing = $luser->get_mailing($this->id); $mailing->submitForApproval($luser); $this->redirect('default'); } protected function createComponentSend($action) { $form = new Nette\Application\UI\Form; $form->addProtection("protection token expired"); $form->onSuccess[] = [$this, 'sendFormOK']; return $form; } public function sendFormOK(Nette\Application\UI\Form $form) { $luser = $this->luser; $mailing = $luser->get_mailing($this->id); $mailing->send($luser); $this->redirect('default'); } protected function createComponentDelete($action) { $form = new Nette\Application\UI\Form; $form->addProtection("protection token expired"); $form->addSubmit('delete', "Delete"); $form->onSuccess[] = [$this, 'deleteFormOK']; return $form; } public function deleteFormOK(Nette\Application\UI\Form $form) { $luser = $this->luser; $mailing = $luser->get_mailing($this->id); $mailing->delete(); $this->FlashMessage("Mailing deleted."); $this->redirect('Homepage:default', ['id' => false]); } public function renderBounces($id) { $luser = $this->luser; $this->template->mailing = $luser->get_mailing($id); $this->template->is_admin = $luser->admin; } public function actionResendauth($id) { $luser = $this->luser; $mailing = $luser->get_mailing($id); $mailing->requestAddresschange($luser, $mailing->getMtime()); $this->flashMessage("We have just resent the approval message. It should arrive within a few minutes and it will contain instructions on how to approve/reject the addresschange."); $this->redirect('default'); } public function actionApproveaddresschange($id) { $luser = $this->luser; $mailing = $luser->get_mailing($id); $token = $this->getParam("token"); $result = $mailing->addresschangeapproved($luser, $token); switch($result) { case "ok": $this->flashMessage("Address changed."); break; case "bad-token": $this->flashMessage("Incorrect token, address not changed."); break; case "no-approval-necessary": $this->flashMessage("No need to approve, the address is already allowed."); break; default: $this->flashMessage($result); } $this->redirect('default'); } public function actionRejectaddresschange($id) { $luser = $this->luser; $mailing = $luser->get_mailing($id); $token = $this->getParam("token"); $result = $mailing->addresschangerejected($luser, $token); switch($result) { case "ok": $this->flashMessage("Address rejected."); break; case "bad-token": $this->flashMessage("Incorrect token, address not changed."); break; case "no-approval-necessary": $this->flashMessage("No need to approve, the address is already allowed."); break; default: $this->flashMessage($result); } $this->redirect('default'); } protected function createComponentReset($action) { $form = new Nette\Application\UI\Form; $form->addHidden('attachment'); $form->addSubmit('reset', 'Reset'); $form->addProtection("protection token expired"); $form->onSuccess[] = [$this, 'resetFormOK']; return $form; } public function resetFormOK(Nette\Application\UI\Form $form) { $attachmentid = $form->values['attachment']; $luser = $this->luser; $mailing = $luser->get_mailing($this->id); $attachment = $mailing->get_attachment($attachmentid); if ($form['reset']->submittedBy) { if ($attachment) { $attachment->resetdownloadcounter(); } } $this->FlashMessage("Downloadcounter for the attachment has been reset"); $this->redirect('default'); } protected function createComponentAttachment($action) { $form = new Nette\Application\UI\Form; $form->addHidden('attachment'); $form->addSubmit('view', 'View'); $form->addSubmit('delete', 'Delete'); $form->addSubmit('attach', 'Attach'); $form->addSubmit('detach', 'Detach'); $form->addProtection("protection token expired"); $form->onSuccess[] = [$this, 'attachmentFormOK']; return $form; } public function attachmentFormOK(Nette\Application\UI\Form $form) { $attachmentid = $form->values['attachment']; $luser = $this->luser; $mailing = $luser->get_mailing($this->id); $attachment = $mailing->get_attachment($attachmentid); if ($form['delete']->submittedBy) { if ($attachment) $attachment->delete(); $this->FlashMessage("Attachment deleted"); $this->redirect('default'); } elseif ($form['attach']->submittedBy) { if ($attachment->size < $this->cfg->attachment_maxsize) { $attachment->attachattachment(); $this->FlashMessage("File is now attached to the message as attachment"); } else { $this->FlashMessage("File is too large to be attached to the message. Please use the downloadlink in your message."); } $this->redirect('default'); } elseif ($form['detach']->submittedBy) { $attachment->detachattachment(); $this->FlashMessage("File is now detached from the message and a downloadlink has been created"); $this->redirect('default'); } $this->FlashMessage("Iets met attachment gedaan"); $this->redirect('default'); } }