/**
  * Method to do additional instant update according config change
  *
  * @param	string	Name of changed config parameter
  * @param	mixed	Recent config parameter value
  * @return	void
  */
 protected function instantUpdate($name, $value)
 {
     $input = JFactory::getApplication()->input;
     if ($name == 'disable_all_messages') {
         // Get name of messages table
         $table = '#__jsn_' . substr(JRequest::getCmd('option'), 4) . '_messages';
         // Enable/disable all messages
         $db = JFactory::getDbo();
         $db->setQuery("UPDATE `{$table}` SET published = " . (1 - $value) . " WHERE 1");
         $db->query();
     } elseif ($name == 'languagemanager') {
         // Get variable
         $lang = $input->getVar('languagemanager', array(), 'default', 'array');
         // Install backend languages
         if (isset($lang['a'])) {
             JSNFactory::import('components.com_poweradmin.helpers.language');
             JSNLanguageHelper::installSupportedExtLangs($lang['a']);
             JSNUtilsLanguage::install($lang['a']);
         }
         // Install frontend languages
         if (isset($lang['s'])) {
             JSNUtilsLanguage::install($lang['s'], true);
         }
     } else {
         return parent::instantUpdate($name, $value);
     }
     return true;
 }
Beispiel #2
0
 /**
  * Additional instant update according to configuration change.
  *
  * @param   string  $name   Name of changed config parameter.
  * @param   mixed   $value  Recent config parameter value.
  *
  * @return  void
  */
 protected function instantUpdate($name, $value)
 {
     // Get input object
     $input = JFactory::getApplication()->input;
     // Update message publishing state
     if ($name == 'messagelist') {
         // Get variables
         $before = $input->getVar('messagelist', array(), 'default', 'array');
         $after = $input->getVar('messages', array(), 'default', 'array');
         // Update message configuration
         JSNUtilsMessage::saveConfig($before, $after);
     } elseif ($name == 'languagemanager') {
         // Get variable
         $lang = $input->getVar('languagemanager', array(), 'default', 'array');
         // Install backend languages
         if (isset($lang['a'])) {
             JSNUtilsLanguage::install($lang['a']);
         }
         // Install frontend languages
         if (isset($lang['s'])) {
             JSNUtilsLanguage::install($lang['s'], true);
         }
     } elseif ($name == 'permissions' and count($value = $input->getVar('permissions'))) {
         // Prepare permission value for saving
         foreach ($value as $action => $groups) {
             foreach ($groups as $group => $permission) {
                 if (!in_array($value[$action][$group], array('0', '1'))) {
                     unset($value[$action][$group]);
                 }
             }
         }
         // Initialize variables
         $component = $input->getCmd('option');
         $rules = new JAccessRules($value);
         $asset = JTable::getInstance('asset');
         if (!$asset->loadByName($component)) {
             $root = JTable::getInstance('asset');
             $root->loadByName('root.1');
             $asset->name = $component;
             $asset->title = $component;
             $asset->setLocation($root->id, 'last-child');
         }
         $asset->rules = (string) $rules;
         try {
             $asset->check();
             $asset->store();
         } catch (Exception $e) {
             throw $e;
         }
     }
 }