コード例 #1
0
ファイル: add_group.php プロジェクト: naujasdizainas/forkcms
 /**
  * Validate the form
  */
 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');
         $rbtDefaultForLanguage = $this->frm->getField('default');
         // validate fields
         if ($txtName->isFilled(BL::err('NameIsRequired'))) {
             // check if the group exists by name
             if (BackendMailmotorModel::existsGroupByName($txtName->getValue())) {
                 $txtName->addError(BL::err('GroupAlreadyExists'));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['name'] = $txtName->getValue();
             $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
             $item['language'] = $rbtDefaultForLanguage->getValue() === '0' ? null : $rbtDefaultForLanguage->getValue();
             $item['is_default'] = $rbtDefaultForLanguage->getChecked() ? 'Y' : 'N';
             // insert the item
             $item['id'] = BackendMailmotorCMHelper::insertGroup($item);
             // check if all default groups were set
             BackendMailmotorModel::checkDefaultGroups();
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('groups') . '&report=added&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']);
         }
     }
 }
コード例 #2
0
ファイル: config.php プロジェクト: netconstructor/forkcms
 /**
  * Checks if any groups are made yet. Depending on the client that is linked to Fork, it will creates default groups if none were found in CampaignMonitor.
  * If they were, the user is presented with an overview to import all groups and their subscribers in Fork.
  *
  * @return	void
  */
 private function checkForGroups()
 {
     // groups are already set
     if (BackendModel::getModuleSetting('mailmotor', 'cm_groups_set')) {
         return false;
     }
     // no CM data found
     if (!BackendMailmotorCMHelper::checkAccount()) {
         return false;
     }
     // check if there are external groups present in CampaignMonitor
     if ($this->checkForExternalGroups()) {
         // external groups were found, so redirect to the import_groups action
         SpoonHTTP::redirect(BackendModel::createURLForAction('import_groups', 'mailmotor'));
     }
     // fetch the default groups, language abbreviation is the array key
     $groups = BackendMailmotorModel::getDefaultGroups();
     // loop languages
     foreach (BL::getActiveLanguages() as $language) {
         // this language does not have a default group set
         if (!isset($groups[$language])) {
             // set group record
             $group['name'] = 'Website (' . strtoupper($language) . ')';
             $group['language'] = $language;
             $group['is_default'] = 'Y';
             $group['created_on'] = date('Y-m-d H:i:s');
             try {
                 // insert the group in CampaignMonitor
                 BackendMailmotorCMHelper::insertGroup($group);
             } catch (CampaignMonitorException $e) {
                 // ignore
             }
         }
     }
     // we have groups set, and default groups chosen
     BackendModel::setModuleSetting('mailmotor', 'cm_groups_set', true);
     BackendModel::setModuleSetting('mailmotor', 'cm_groups_defaults_set', true);
 }
コード例 #3
0
 /**
  * Validate the form
  */
 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
         $txtGroup = $this->frm->getField('group');
         // validate fields
         if ($txtGroup->isFilled(BL::err('NameIsRequired'))) {
             if (BackendMailmotorModel::existsGroupByName($txtGroup->getValue())) {
                 $txtGroup->addError(BL::err('GroupAlreadyExists'));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['name'] = $txtGroup->getValue();
             $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
             // update the item
             $item['id'] = BackendMailmotorCMHelper::insertGroup($item);
             // loop the adresses
             foreach ($this->statistics['clicked_links_by'][$this->linkURL] as $clicker) {
                 // subscribe the user to the created group
                 BackendMailmotorCMHelper::subscribe($clicker['email'], $item['id']);
             }
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('statistics_link') . '&url=' . $this->linkURL . '&mailing_id=' . $this->mailing['id'] . '&report=group-added&var=' . urlencode($item['name']) . '&highlight=id-' . $this->mailing['id']);
         }
     }
 }