/**
  * Show and process config category form
  *
  * @param void
  * @return null
  */
 function update_category()
 {
     $category = ConfigCategories::findById(get_id());
     if (!$category instanceof ConfigCategory) {
         flash_error(lang('config category dnx'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     if ($category->isEmpty()) {
         flash_error(lang('config category is empty'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     $options = $category->getOptions(false);
     $categories = ConfigCategories::getAll(false);
     tpl_assign('category', $category);
     tpl_assign('options', $options);
     tpl_assign('config_categories', $categories);
     $submitted_values = array_var($_POST, 'options');
     if (is_array($submitted_values)) {
         foreach ($options as $option) {
             $new_value = array_var($submitted_values, $option->getName());
             if (is_null($new_value) || $new_value == $option->getValue()) {
                 continue;
             }
             $option->setValue($new_value);
             $option->save();
         }
         // foreach
         flash_success(lang('success update config category', $category->getDisplayName()));
         $this->redirectTo('administration', 'configuration');
     }
     // if
     $this->setSidebar(get_template_path('update_category_sidebar', 'config'));
 }
 /**
  * Show and process config category form
  *
  * @param void
  * @return null
  */
 function update_category()
 {
     // Access permissios
     if (!can_manage_configuration(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $category = ConfigCategories::findById(get_id());
     if (!$category instanceof ConfigCategory) {
         flash_error(lang('config category dnx'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     if ($category->isEmpty()) {
         flash_error(lang('config category is empty'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     $options = $category->getOptions(false);
     $categories = ConfigCategories::getAll(false);
     tpl_assign('category', $category);
     tpl_assign('options', $options);
     tpl_assign('config_categories', $categories);
     $submited_values = array_var($_POST, 'options');
     if (is_array($submited_values)) {
         foreach ($options as $option) {
             //update global cache if available
             if (GlobalCache::isAvailable() && GlobalCache::key_exists('config_option_' . $option->getName())) {
                 GlobalCache::delete('config_option_' . $option->getName());
             }
             if ($option->getName() == "working_days") {
                 $new_value = "";
                 foreach (array_var($submited_values, $option->getName()) as $value) {
                     $new_value .= $value . ",";
                 }
                 $new_value = substr($new_value, 0, -1);
             } else {
                 $new_value = array_var($submited_values, $option->getName());
                 if (is_null($new_value) || $new_value == $option->getValue()) {
                     continue;
                 }
             }
             $option->setValue($new_value);
             $option->save();
             evt_add("config option changed", array('name' => $option->getName(), 'value' => $new_value));
         }
         // foreach
         flash_success(lang('success update config category', $category->getDisplayName()));
         ajx_current("back");
     }
     // if
 }
 /**
  * Show and process config category form
  *
  * @param void
  * @return null
  */
 function update_category()
 {
     // Access permissios
     if (!can_manage_configuration(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $category = ConfigCategories::findById(get_id());
     if (!$category instanceof ConfigCategory) {
         flash_error(lang('config category dnx'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     if ($category->isEmpty()) {
         flash_error(lang('config category is empty'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     $options = $category->getOptions(false);
     $categories = ConfigCategories::getAll(false);
     tpl_assign('category', $category);
     tpl_assign('options', $options);
     tpl_assign('config_categories', $categories);
     $submited_values = array_var($_POST, 'options');
     if (is_array($submited_values)) {
         foreach ($options as $option) {
             $new_value = array_var($submited_values, $option->getName());
             if (is_null($new_value) || $new_value == $option->getValue()) {
                 continue;
             }
             $option->setValue($new_value);
             $option->save();
         }
         // foreach
         flash_success(lang('success update config category', $category->getDisplayName()));
         ajx_current("back");
     }
     // if
 }