luser; $this->template->setFile("/srv/www/massmail/app/templates/Attachments/default.latte"); $this->template->mailing = $luser->get_mailing($id); $this->template->cfg = $this->cfg; $this->template->render(); # __tostring(); #print "HERE, NOW TERMINATE WITHOUT FURTHER DATA\n"; $this->terminate(); } public function renderInfo($id) { # Force disable debugging \Nette\Diagnostics\Debugger::$productionMode = TRUE; $luser = $this->luser; $this->template->mailing = $luser->get_mailing($id); $this->template->cfg = $this->cfg; } protected function createComponentAttachmentForm() { $mailing = $this->luser->get_mailing($this->id); $form = new Nette\Application\UI\Form; $form->addUpload('attachments', "Attachments", true); $form->addSubmit('add', "Save and continue"); $form->addProtection("protection token expired"); $form->onSuccess[] = [$this, 'AttachmentFormOK']; return $form; } public function AttachmentFormOK(Nette\Application\UI\Form $form, $values = '') { $values = $form->values; if($form['add']->submittedBy) { $mailing = $this->luser->get_mailing($this->id); if (count($values['attachments'])>0) { $results = $mailing->addAttachments($values['attachments']); foreach($results as $result) { $this->FlashMessage($result); } } } $this->redirect(':User:Attachments:info'); } protected function createComponentAttachmenthandler($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, 'attachmenthandlerFormOK']; return $form; } public function attachmenthandlerFormOK(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('info'); } elseif ($form['attach']->submittedBy) { if ($attachment->size < $this->cfg->attachment_maxsize) { $attachment->attachattachment(); $this->FlashMessage("File is now attached to the message as attachment. Remember to update your document if you have previously used a link to this document."); } else { $this->FlashMessage("File is too large to be attached to the message. Please use the downloadlink in your message."); } $this->redirect('info'); } elseif ($form['detach']->submittedBy) { $attachment->detachattachment(); $this->FlashMessage("File is now detached from the message and a downloadlink has been created"); $this->redirect('info'); } $this->redirect('info'); } }