Exemple #1
0
 // Display form to edit a category
 case 'rqEdit':
     $category = new claroCategory();
     if ($category->load($id)) {
         $dialogBox->form($category->displayForm());
     } else {
         $dialogBox->error(get_lang('Category not found'));
     }
     break;
     // Edit a new category
 // Edit a new category
 case 'exEdit':
     $category = new claroCategory();
     $category->handleForm();
     if ($category->validate()) {
         $category->save();
         $dialogBox->success(get_lang('Category modified'));
     } else {
         if (claro_failure::get_last_failure() == 'category_duplicate_code') {
             $dialogBox->error(get_lang('This code already exists'));
         } elseif (claro_failure::get_last_failure() == 'category_self_linked') {
             $dialogBox->error(get_lang('Category can\'t be its own parent'));
         } elseif (claro_failure::get_last_failure() == 'category_child_linked') {
             $dialogBox->error(get_lang('Category can\'t be linked to one of its own children'));
         } elseif (claro_failure::get_last_failure() == 'category_missing_field') {
             $dialogBox->error(get_lang('Some fields are missing'));
         }
         $dialogBox->form($category->displayForm());
     }
     break;
     // Delete an existing category
Exemple #2
0
 /**
  * Exchange ranks between the current category and another one
  * and save the modification in database.
  *
  * @param int       identifier of the other category
  */
 public function exchangeRanks($id)
 {
     // Get the other category
     $swapCategory = new claroCategory();
     $swapCategory->load($id);
     // Exchange the ranks
     $tempRank = $this->rank;
     $this->rank = $swapCategory->rank;
     $swapCategory->rank = $tempRank;
     // Save the modifications
     $this->save();
     $swapCategory->save();
 }