Exemplo n.º 1
0
 function getConfigValues()
 {
     $c = new Am_Config();
     $c->read();
     $ret = $this->_getConfigValues('', $c->getArray());
     // strip keys encoded for form
     foreach ($ret as $k => $v) {
         if (preg_match('/___/', $k)) {
             unset($ret[$k]);
         }
     }
     return $ret;
 }
Exemplo n.º 2
0
 public function saveConfig()
 {
     $c = new Am_Config();
     $c->read();
     $before = clone $c;
     foreach (array_merge($this->getDefaults(), $this->getValue()) as $k => $v) {
         if (preg_match('/(^|\\.)(save|_save_|p)$/', $k)) {
             continue;
         }
         if ($v === null) {
             continue;
         }
         $c->set($k, $v);
     }
     $this->beforeSaveConfig($before, $c);
     $c->save();
     $this->afterSaveConfig($before, $c);
     return true;
 }
 public function configSaveAction()
 {
     $type = $this->getRequest()->getFiltered('c');
     if ($type == 'default') {
         $type = 'ip';
     }
     $action = $this->getFiltered('a');
     Am_Config::saveValue('ban.' . $type . '_action', $action);
     //echo $this->getJson(array('result' => 'ok', 'ban.'.$type.'_action' =>  $action));
     $this->_redirect('admin-ban?c=' . $type);
 }
Exemplo n.º 4
0
 public function beforeSaveConfig(Am_Config $before, Am_Config $after)
 {
     $arr = $after->getArray();
     if (empty($arr['aff_comm'])) {
         return;
     }
     $this->rule = Am_Di::getInstance()->affCommissionRuleTable->findFirstByType(AffCommissionRule::TYPE_GLOBAL_1);
     if (empty($this->rule)) {
         $this->rule = Am_Di::getInstance()->affCommissionRuleTable->createRecord();
         $this->rule->type = AffCommissionRule::TYPE_GLOBAL_1;
         $this->rule->title = "Default Commmission";
     }
     foreach ($arr['aff_comm'] as $aa) {
         foreach ($aa as $k => $v) {
             $this->rule->set($k, $v);
         }
     }
     unset($arr['aff_comm']);
     $after->setArray($arr);
 }
Exemplo n.º 5
0
 public function deleteRecord($id, $record)
 {
     $record = $this->getRecord($id);
     $fields = Am_Di::getInstance()->config->get($this->config_key);
     foreach ($fields as $k => $v) {
         if ($v['name'] == $record->name) {
             unset($fields[$k]);
         }
     }
     Am_Config::saveValue($this->config_key, $fields);
     Am_Di::getInstance()->config->set('member_fields', $fields);
     if ($record->sql) {
         $this->dropSqlField($record->name);
     }
 }
 function indexAction()
 {
     $this->view->title = ___('Fix aMember Pro License Key');
     $this->view->msg = Am_License::getInstance()->check();
     $form = new Am_Form_Admin_FixLicense();
     $form->setDataSources(array($this->getRequest(), $form->getDsDefaults()));
     if ($form->isSubmitted() && $form->validate()) {
         $vars = $form->getValue();
         Am_Config::saveValue('license', $vars['license']);
         Am_Config::saveValue('root_url', $vars['root_url']);
         Am_Config::saveValue('root_surl', $vars['root_surl']);
         return $this->redirectLocation($this->getFullUrl());
     }
     $this->view->form = $form;
     $this->view->display('admin/fixlicense.phtml');
 }
Exemplo n.º 7
0
 /**
  * @todo ELIMINATE duplication source (Am_Form_Setup_Plugins)
  */
 function stepAutoEnable()
 {
     foreach ($this->getSession()->upgrades as $upgrade) {
         if (empty($upgrade->auto_enable)) {
             continue;
         }
         $type = $upgrade->type;
         if ($type == 'module') {
             $type = 'modules';
         }
         $pm = $this->getDi()->plugins[$type];
         if (!$pm) {
             continue;
         }
         $configKey = $type == 'modules' ? 'modules' : 'plugins.' . $type;
         $enabled = (array) $this->getDi()->config->get($configKey, array());
         if (!in_array($upgrade->id, $enabled)) {
             if ($pm->load($upgrade->id)) {
                 $class = $pm->getPluginClassName($upgrade->id);
                 try {
                     call_user_func(array($class, 'activate'), $upgrade->id, $type);
                 } catch (Exception $e) {
                     $this->getDi()->errorLogTable->logException($e);
                     trigger_error("Error during plugin [{$upgrade->id}] activation: " . get_class($e) . ": " . $e->getMessage(), E_USER_WARNING);
                     continue;
                 }
                 ///
                 $enabled[] = $upgrade->id;
                 $list = Am_Config::saveValue($configKey, $enabled);
                 if ($type == 'modules') {
                     // to run upgrade db with new module
                     $this->getDi()->config->set('modules', $enabled);
                 }
             }
         }
     }
     return true;
 }
 protected function removeRegion($regionId)
 {
     $regional_taxes = $this->getDi()->config->get('regional_taxes');
     unset($regional_taxes[$regionId]);
     Am_Config::saveValue('regional_taxes', $regional_taxes);
 }
 function fixLogoutRedirectSettings()
 {
     if (version_compare($this->db_version, '4.2.20') < 0) {
         if (!$this->getDi()->config->get('protect.php_include.redirect_logout') && $this->getDi()->config->get('protect.php_include.redirect')) {
             Am_Config::saveValue('protect.php_include.redirect_logout', 'url');
             $this->getDi()->config->read();
         }
     }
 }
Exemplo n.º 10
0
 /**
  * Return (generate if necessary) a constant, random site ID
  * @return string
  */
 function getSiteKey()
 {
     static $key;
     if ($key) {
         return $key;
     }
     $config = $this->di->config;
     if ($key = $config->get('random-site-key')) {
         return $key;
     }
     $key = sha1(mt_rand() . @$_SERVER['REMOTE_ADDR'] . microtime(true));
     Am_Config::saveValue('random-site-key', $key);
     $config->set('random-site-key', $key);
     return $key;
 }
Exemplo n.º 11
0
 public function beforeSaveConfig(Am_Config $before, Am_Config $after)
 {
     // Do the same for plugins;
     foreach (Am_Di::getInstance()->plugins as $type => $pm) {
         /* @var $pm Am_Plugins */
         $configKey = $type == 'modules' ? 'modules' : 'plugins.' . $type;
         $b = (array) $before->get($configKey);
         $a = (array) $after->get($configKey);
         $enabled = array_filter(array_diff($a, $b), 'strlen');
         $disabled = array_filter(array_diff($b, $a), 'strlen');
         foreach ($disabled as $plugin) {
             if ($pm->load($plugin)) {
                 try {
                     $pm->get($plugin)->deactivate();
                 } catch (Exception $e) {
                     Am_Di::getInstance()->errorLogTable->logException($e);
                     trigger_error("Error during plugin [{$plugin}] deactivation: " . get_class($e) . ": " . $e->getMessage(), E_USER_WARNING);
                 }
             }
             // Now clean config for plugin;
             $after->set($pm->getConfigKey($plugin), array());
         }
         foreach ($enabled as $plugin) {
             if ($type == 'payment' && !empty($this->plugins_cc[$plugin]) && !Am_Di::getInstance()->modules->isEnabled('cc')) {
                 // we got a cc plugin enabled but cc module is not yet enabled!
                 $modules_cc = $after->get('modules', array());
                 $modules_cc[] = 'cc';
                 $modules_cc = array_unique($modules_cc);
                 $after->set('modules', $modules_cc);
                 continue;
             }
             if ($pm->load($plugin)) {
                 $class = $pm->getPluginClassName($plugin);
                 try {
                     call_user_func(array($class, 'activate'), $plugin, $type);
                 } catch (Exception $e) {
                     Am_Di::getInstance()->errorLogTable->logException($e);
                     trigger_error("Error during plugin [{$plugin}] activattion: " . get_class($e) . ": " . $e->getMessage(), E_USER_WARNING);
                 }
             }
         }
     }
     Am_Di::getInstance()->config->set('modules', $modules = $after->get('modules', array()));
     Am_Di::getInstance()->app->dbSync(true, $modules);
     $after->save();
 }
Exemplo n.º 12
0
 function disableQuickstartAction()
 {
     Am_Config::saveValue('quickstart-disable', true);
     $this->getDi()->config->set('quickstart-disable', true);
     return $this->indexAction();
 }
Exemplo n.º 13
0
 public function beforeSaveConfig(Am_Config $before, Am_Config $after)
 {
     // Do the same for plugins;
     foreach (array('modules', 'payment', 'misc', 'protect') as $type) {
         $configKey = $type == 'modules' ? 'modules' : 'plugins.' . $type;
         $b = (array) $before->get($configKey);
         $a = (array) $after->get($configKey);
         $enabled = array_filter(array_diff($a, $b), 'strlen');
         $disabled = array_filter(array_diff($b, $a), 'strlen');
         $pm = Am_Di::getInstance()->plugins[$type];
         foreach ($disabled as $plugin) {
             if ($pm->load($plugin)) {
                 try {
                     $pm->get($plugin)->deactivate();
                 } catch (Exception $e) {
                     Am_Di::getInstance()->errorLogTable->logException($e);
                     trigger_error("Error during plugin [{$plugin}] deactivation: " . get_class($e) . ": " . $e->getMessage(), E_USER_WARNING);
                 }
             }
             // Now clean config for plugin;
             $after->set($pm->getConfigKey($plugin), array());
         }
         foreach ($enabled as $plugin) {
             if ($pm->load($plugin)) {
                 $class = $pm->getPluginClassName($plugin);
                 try {
                     call_user_func(array($class, 'activate'), $plugin, $type);
                 } catch (Exception $e) {
                     Am_Di::getInstance()->errorLogTable->logException($e);
                     trigger_error("Error during plugin [{$plugin}] activattion: " . get_class($e) . ": " . $e->getMessage(), E_USER_WARNING);
                 }
             }
         }
     }
     Am_Di::getInstance()->config->set('modules', $modules = $after->get('modules', array()));
     Am_Di::getInstance()->app->dbSync(true, $modules);
     $after->save();
 }