Example #1
0
 /**
  * @method POST
  */
 function update($categoryUniqId)
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         parse_str($this->request->data, $request);
         // parse request
         $name = $request['name'];
         $lastModifiedBy = $authUser->UserId;
         Category::Edit($categoryUniqId, $name, $lastModifiedBy);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Example #2
0
     include View::Get('game.html', $st_subdir);
     break;
 case 'category':
     $name = Filter::input('name');
     $priority = Filter::input('lvl', 'post', 'int');
     $desc = Filter::input('desc');
     if (!$id and $name) {
         $new_category = new Category();
         if ($new_category->Create($name, $priority, $desc)) {
             $info .= lng('CAT_COMPLITE');
         } else {
             $info .= lng('CAT_EXIST');
         }
     } elseif ($id and $name and Filter::input('edit', 'post', 'bool')) {
         $category = new Category($id);
         if ($category->Edit($name, $priority, $desc)) {
             $info .= lng('CAT_UPDATED');
         } else {
             $info .= lng('CAT_EXIST');
         }
     } elseif ($id and Filter::input('delete', 'post', 'bool')) {
         $category = new Category($id);
         if ($category->Delete()) {
             $info .= lng('CAT_DELETED');
         } else {
             $info .= lng('CAT_NOT_EXIST');
         }
         $id = false;
     }
     $cat_list = CategoryManager::GetList($id);
     include View::Get('category_header.html', $st_subdir . 'category/');
Example #3
0
 function Edit()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
     }
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $categoryID = Kit::GetParam('categoryid', _POST, _INT);
     $category = Kit::GetParam('category', _POST, _STRING);
     // Edit the category
     $resObject = new Category($db);
     if (!$resObject->Edit($categoryID, $category)) {
         trigger_error($resObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse('Category edited');
     $response->Respond();
 }