예제 #1
0
 /**
  * Load the datagrid for subscriptions
  */
 private function loadSubscriptions()
 {
     // get results
     $results = BackendMailmotorModel::getAddressesByGroupID($this->groupId, false, self::PAGING_LIMIT);
     // there are some results
     if (!empty($results)) {
         // get the datagrid
         $dataGrid = new BackendDataGridArray($results);
         // no pagination
         $dataGrid->setPaging(false);
         // set column functions
         $dataGrid->setColumnFunction(array('BackendDataGridFunctions', 'getTimeAgo'), array('[created_on]'), 'created_on', true);
         // check if this action is allowed
         if (BackendAuthentication::isAllowedAction('edit_address', 'mailmotor')) {
             // set edit link
             $dataGrid->setColumnURL('email', BackendModel::createURLForAction('edit_address', 'mailmotor') . '&email=[email]');
         }
         // parse the datagrid
         $this->tpl->assign('dgMailmotorSubscriptions', $dataGrid->getContent());
     }
 }
예제 #2
0
 /**
  * Validate the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // shorten fields
         $txtName = $this->frm->getField('name');
         $txtFromName = $this->frm->getField('from_name');
         $txtFromEmail = $this->frm->getField('from_email');
         $txtReplyToEmail = $this->frm->getField('reply_to_email');
         $chkGroups = $this->frm->getField('groups');
         $rbtLanguages = $this->frm->getField('languages');
         // validate fields
         if ($txtName->isFilled(BL::err('NameIsRequired'))) {
             if (BackendMailmotorModel::existsMailingByName($txtName->getValue())) {
                 $txtName->addError(BL::err('MailingAlreadyExists'));
             }
         }
         $txtFromName->isFilled(BL::err('NameIsRequired'));
         $txtFromEmail->isFilled(BL::err('EmailIsRequired'));
         $txtReplyToEmail->isFilled(BL::err('EmailIsRequired'));
         // set form values
         $values = $this->frm->getValues();
         // check if at least one recipient group is chosen
         if (empty($values['groups'])) {
             $chkGroups->addError(BL::err('ChooseAtLeastOneGroup'));
         } else {
             // fetch the recipients for these groups
             $recipients = BackendMailmotorModel::getAddressesByGroupID($values['groups']);
             // if no recipients were found, throw an error
             if (empty($recipients)) {
                 $chkGroups->addError(BL::err('GroupsNoRecipients'));
             }
         }
         // check if at least one language is chosen
         if (empty($values['languages'])) {
             $rbtLanguages->isFilled(BL::err('FieldIsRequired'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // set values
             $item['name'] = $txtName->getValue();
             $item['from_name'] = $txtFromName->getValue();
             $item['from_email'] = $txtFromEmail->getValue();
             $item['reply_to_email'] = $txtReplyToEmail->getValue();
             $item['language'] = $rbtLanguages->getValue();
             $item['status'] = 'concept';
             $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
             $item['edited_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
             if (!empty($values['campaign'])) {
                 $item['campaign_id'] = $this->frm->getField('campaign')->getValue();
             }
             // insert the concept
             $item['id'] = BackendMailmotorModel::insertMailing($item);
             // update the groups for this mailing
             BackendMailmotorModel::updateGroupsForMailing($item['id'], $values['groups']);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_mailing_step1', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('edit') . '&id=' . $item['id'] . '&step=2');
         }
     }
 }