Пример #1
0
 /**
  * Toggles the active state of a ShopCategory
  *
  * The ShopCategory ID may be present in $_REQUEST['toggle_category_id'].
  * If it's not, returns NULL immediately.
  * Otherwise, will add a message indicating success or failure,
  * and redirect back to the category overview.
  * @global  array       $_ARRAYLANG
  * @return  boolean                     Null on noop
  */
 function toggle_category()
 {
     global $_ARRAYLANG;
     if (empty($_REQUEST['toggle_category_id'])) {
         return NULL;
     }
     $category_id = intval($_REQUEST['toggle_category_id']);
     $result = ShopCategories::toggleStatusById($category_id);
     if (is_null($result)) {
         // NOOP
         return;
     }
     if ($result) {
         \Message::ok($_ARRAYLANG['TXT_SHOP_CATEGORY_UPDATED_SUCCESSFULLY']);
     } else {
         \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_CATEGORY_ERROR_UPDATING'], $category_id));
     }
     \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=categories');
 }