Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * Get all necessary data
  *
  * @return	void
  */
 private function getData()
 {
     // fetch the mailmotor settings
     $settings = BackendModel::getModuleSettings();
     // store mailmotor settings
     $this->settings = $settings['mailmotor'];
     // check if an account was linked already and/or client ID was set
     $this->accountLinked = BackendMailmotorCMHelper::checkAccount();
     $this->clientID = BackendMailmotorCMHelper::getClientID();
 }