/** * Get all active languages in a format usable by SpoonForm's addRadioButton * * @return array */ public static function getCheckboxValues() { $languages = BL::getActiveLanguages(); $results = array(); // stop here if no languages are present if (empty($languages)) { return array(); } // addRadioButton requires an array with keys 'value' and 'label' foreach ($languages as $abbreviation) { $results[] = array('value' => $abbreviation, 'label' => BL::lbl(strtoupper($abbreviation))); } return $results; }
/** * 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); }
/** * Get all active languages in a format acceptable for SpoonForm::addRadioButton() and SpoonForm::addMultiCheckbox() * * @return array */ public static function getLanguagesForCheckboxes() { // get the active languages $languages = BL::getActiveLanguages(); // no languages found if (empty($languages)) { return array(); } // init results $results = array(); // loop the languages foreach ($languages as $abbreviation) { // build new value $results[] = array('value' => $abbreviation, 'label' => BL::lbl(strtoupper($abbreviation))); } return $results; }
/** * Install a module. * * @param string $module The name of the module to be installed. * @param array $information Warnings from the upload of the module. */ public static function installModule($module, array $warnings = array()) { // we need the installer require_once BACKEND_CORE_PATH . '/installer/installer.php'; require_once BACKEND_MODULES_PATH . '/' . $module . '/installer/installer.php'; // installer class name $class = SpoonFilter::toCamelCase($module) . 'Installer'; // possible variables available for the module installers $variables = array(); // run installer $installer = new $class(BackendModel::getDB(true), BL::getActiveLanguages(), array_keys(BL::getInterfaceLanguages()), false, $variables); // execute installation $installer->install(); // add the warnings foreach ($warnings as $warning) { $installer->addWarning($warning); } // save the warnings in session for later use if ($installer->getWarnings()) { $warnings = SpoonSession::exists('installer_warnings') ? SpoonSession::get('installer_warnings') : array(); $warnings = array_merge($warnings, array('module' => $module, 'warnings' => $installer->getWarnings())); SpoonSession::set('installer_warnings', $warnings); } // clear the cache so locale (and so much more) gets rebuilt self::clearCache(); }