g '1' from 'submit_edit_cat_1' */
$this->_mActionedCategoryId = (int)substr($key, $last_underscore + 1);
break;
}
$this->mLinkToDepartmentsAdmin = Link::ToDepartmentsAdmin();
$this->mLinkToDepartmentCategoriesAdmin =
Link::ToDepartmentCategoriesAdmin($this->mDepartmentId);
}
public function init()
{
// If adding a new category ...
if ($this->_mAction == 'add_cat')
{
$category_name = $_POST['category_name'];
$category_description = $_POST['category_description'];
if ($category_name == null)
$this->mErrorMessage = 'Category name is empty';
if ($this->mErrorMessage == null)
{
Catalog::AddCategory($this->mDepartmentId, $category_name,
$category_description);
header('Location: ' .
htmlspecialchars_decode(
$this->mLinkToDepartmentCategoriesAdmin));
}
}
// If editing an existing category ...
if ($this->_mAction == 'edit_cat')
{
$this->mEditItem = $this->_mActionedCategoryId;
}
// If updating a category ...
if ($this->_mAction == 'update_cat')
{
$category_name = $_POST['name'];
$category_description = $_POST['description'];
CHAPTER 10 ?– CATALOG ADMINISTRATION: DEPARTMENTS AND CATEGORIES 299
if ($category_name == null)
$this->mErrorMessage = 'Category name is empty';
if ($this->mErrorMessage == null)
{
Catalog::UpdateCategory($this->_mActionedCategoryId, $category_name,
$category_description);
header('Location: ' .
htmlspecialchars_decode(
$this->mLinkToDepartmentCategoriesAdmin));
}
}
// If deleting a category .
Pages:
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419