Esempio n. 1
0
 /**
  *
  */
 public function doSendCert()
 {
     $filter = $this->table->getFilterValues();
     $image = $this->setup->getPdfBgImageUrl()->toString();
     $now = \Tk\Date::create();
     $dateFrom = $filter['dateFrom']->floor()->toString(\Tk\Date::LONG_DATE);
     $dateTo = $filter['dateTo']->ceil()->toString(\Tk\Date::LONG_DATE);
     $tpl = $this->setup->pdfContent;
     $course = $this->term->getCourse();
     $list = $this->getList();
     $i = 0;
     foreach ($list as $obj) {
         //vd($obj);
         $dompdf = $this->makeCert($obj, $dateFrom, $dateTo, $image, $tpl);
         $message = \Tk\Config::getInstance()->createMailTplMessage(\Ext\Mail::getThemeMailTemplate());
         $message->setSubject($this->setup->emailSubject);
         $from = \Tk\Config::getInstance()->getSiteEmail();
         if ($course) {
             $from = $course->getEmail();
         }
         $message->setFrom($from);
         $message->set('content', $this->setup->emailContent);
         $message->set('termId', $this->term->getId());
         $message->set('date', $now->toString(\Tk\Date::LONG_DATE));
         $message->set('year', $now->toString('Y'));
         $message->set('dateFrom', $dateFrom);
         $message->set('dateTo', $dateTo);
         $message->set('courseId', $course->id);
         $message->set('name', $obj->name);
         $message->set('email', $obj->email);
         $message->set('companyId', $obj->id);
         $message->set('totalUnits', $obj->totalUnits);
         $message->set('totalPlaces', $obj->totalPlaces);
         $message->set('sig', \Tk\Config::getInstance()->get('mail.sig'));
         if ($course->emailSigniture) {
             $message->set('sig', $course->emailSigniture);
         }
         $message->addTo($obj->email);
         $message->addStringAttachment($dompdf->output(), 'Certificate_' . $now->toString('Y') . '.pdf');
         if (\Ext\Mail::send($message)) {
             $i++;
         }
     }
     \Mod\Notice::addSuccess($i . ' Certificates sent successfully.');
     $this->getUri()->delete('sendCert')->redirect();
 }
Esempio n. 2
0
 /**
  * execute
  *
  * @param \Form\Form $form
  */
 public function update($form)
 {
     $fac = $this->getConfig()->getPluginFactory();
     $plugin = $fac->getPlugin($this->getNamespace());
     $arr = \Tk\ArrayObject::createArray($form->getFormValuesArray());
     if ($form->hasErrors()) {
         return;
     }
     $plugin->getDataArray()->importFormArray($arr);
     $plugin->getDataArray()->saveToDb();
     \Mod\Notice::addSuccess('Settings Saved.');
 }
Esempio n. 3
0
 /**
  * __construct
  *
  * @param \Mod\Theme $theme
  */
 public function __construct(\Mod\Theme $theme = null)
 {
     parent::__construct($theme);
     $this->addChild(\Mod\Notice::getInstance(), self::VAR_PAGE_CONTENT_HEAD);
     $this->setPermission(\Tk\Auth\Auth::P_PUBLIC);
 }
Esempio n. 4
0
 /**
  * execute
  *
  * @param \Form\Form $form
  */
 public function update($form)
 {
     /* @var $object \coa\Db\CoaSetup */
     $object = $form->getObject();
     /* @var $file \Form\Field\File */
     $file = $form->getField('pdfBgImage');
     if ($object instanceof \Tk\Db\Model) {
         $form->loadObject($object);
         $form->addFieldErrors($object->getValidator()->getErrors());
     }
     if ($form->hasErrors()) {
         if (!\Mod\Notice::hasMessages()) {
             \Mod\Notice::addError('The form contains errors.');
         }
         return;
     }
     $object->save();
     if ($file && $file->hasFile()) {
         $path = $object->getBasePath();
         \Tk\Path::rmdir($this->getConfig()->getDataPath() . $path);
         $file->moveUploadedFile($this->getConfig()->getDataPath() . $path . '/' . $file->getFileName());
         $object->pdfBgImage = $path . '/' . $file->getFileName();
         $object->save();
     }
     \Mod\Notice::addSuccess('Form submission successful');
 }
Esempio n. 5
0
 /**
  * execute
  *
  * @param \Form\Form $form
  */
 public function update($form)
 {
     $config = \Tk\Config::getInstance();
     $data = $form->getObject();
     /* @var $field \Form\Field\Interface */
     foreach ($form->getFieldList() as $field) {
         if ($field->isRequired() && !$field->getValue() && $field->getName() != 'valid') {
             $field->addError('Please enter some valid data.');
         }
     }
     if ($form->hasErrors()) {
         return;
     }
     $message = '<table border="0" cellpadding="2" cellspacing="0" >';
     $message .= '<tr><th> Field </th><th> Value </th></tr>';
     $skip = array('__submitId', 'valid', 'send');
     /* @var $field \Form\Field\Interface */
     foreach ($form->getFieldList() as $field) {
         if (in_array($field->getName(), $skip)) {
             continue;
         }
         if ($field->getValue()) {
             $message .= '<tr><th class="label"> ' . $field->getLabel() . ': </th><td class="value"> ' . nl2br(htmlentities($field->getValue())) . ' </td></tr>';
         }
     }
     $message .= '</table>';
     $mail = new \Tk\Mail\Message();
     $mail->addTo($this->getConfig()->get('system.site.email'), $this->getConfig()->get('system.site.title'));
     $mail->setFrom($form->getFieldValue('email'), $form->getFieldValue('name'));
     $mail->setSubject('Contact Us Form Sent From ' . $this->getRequest()->getServer('HTTP_HOST'));
     $mail->setBody($mail->createHtmlTemplate($message));
     $mail->send();
     \Mod\Notice::addSuccess('Message Submited Successfully. Thank You!');
     $this->getUri()->redirect();
 }
Esempio n. 6
0
 /**
  * execute
  *
  * @param \Form\Form $form
  */
 public function update($form)
 {
     $object = new \LTI_Tool_Consumer($form->getFieldValue('key'), $this->getConfig()->getLtiDataConnector());
     // Load object
     $object->name = $form->getFieldValue('name');
     $object->secret = $form->getFieldValue('secret');
     $object->enabled = $form->getFieldValue('enabled');
     $object->protected = $form->getFieldValue('protected');
     $object->css_path = $form->getFieldValue('css_path');
     $object->updated = \Tk\Date::create()->getTimestamp();
     // validate object
     if (!$object->name) {
         $form->addFieldError('name', 'Please supply a valid consumer name');
     }
     if (!preg_match('/^[a-z0-9_-]{1,64}$/i', $object->getKey())) {
         $form->addFieldError('consumerKey', 'Invalid characters used in key field');
     }
     if (!preg_match('/^[a-z0-9]{1,64}$/i', $object->secret)) {
         $form->addFieldError('secret', 'Invalid characters used in secret field');
     }
     if ($form->hasErrors()) {
         if (!\Mod\Notice::hasMessages()) {
             \Mod\Notice::addError('The form contains errors.');
         }
         return;
     }
     if (!$this->getConfig()->getLtiDataConnector()->Tool_Consumer_save($object)) {
         if (!\Mod\Notice::hasMessages()) {
             \Mod\Notice::addError('Error saving consumer to DB.');
         }
         return;
     }
     //$this->getRedirectUrl()->set('key', $object->getKey())->redirect();
     $this->getRedirectUrl()->redirect();
 }
Esempio n. 7
0
 /**
  * (non-PHPdoc)
  * @see \Table\Action\Iface::execute()
  */
 public function execute($list)
 {
     $selected = $this->getRequest()->get($this->getObjectKey(\Table\Cell\Checkbox::CB_NAME));
     if (count($selected)) {
         $i = 0;
         foreach ($list as $obj) {
             if (in_array($obj->getKey(), $selected)) {
                 $this->getConfig()->getLtiDataConnector()->Tool_Consumer_delete($obj);
                 $i++;
             }
         }
         $p = '';
         if ($i > 1) {
             $p = '`s';
         }
         \Mod\Notice::addSuccess('Record' . $p . ' successfully deleted.');
     }
     $url = $this->getUri();
     $url->redirect();
 }
Esempio n. 8
0
 /**
  * execute
  *
  * @param Tk_Form $form
  */
 public function update($form)
 {
     if (!preg_match('/.{1,64}/', $form->getFieldValue('system-site-title'))) {
         $form->addFieldError('system-site-title', 'Please enter a title. (1-64 length)');
     }
     if (!preg_match(\Tk\Validator::REG_EMAIL, $form->getFieldValue('system-site-email'))) {
         $form->addFieldError('system-site-email', 'Please enter a valid email address');
     }
     if (!$form->getFieldValue('system-timezone')) {
         $form->addFieldError('system-timezone', 'Please enter a valid timezone');
     }
     if ($form->hasErrors()) {
         \Mod\Notice::addError('The form has errors. No data has been modified.');
         return;
     }
     $this->getConfig()->exportToDb(\Tk\ArrayObject::createArray($form->getValuesArray()));
     \Mod\Notice::addSuccess('The site settings have been saved.', 'Settings Saved');
 }