Beispiel #1
0
    /**
     * delete category
     */
    public function delete()
    {
        if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_DELETE)) {
            return LogUtil::registerPermissionError();
        }

        $cid = (int)FormUtil::getPassedValue('cid', 0, 'GETPOST');
        $dr = (int)FormUtil::getPassedValue('dr', 0, 'GETPOST');
        $url = System::serverGetVar('HTTP_REFERER');

        if (!$dr) {
            return LogUtil::registerError($this->__('Error! The document root is invalid.'), null, $url);
        }

        if (!$cid) {
            return LogUtil::registerError($this->__('Error! The category ID is invalid.'), null, $url);
        }

        $obj = new Categories_DBObject_Category ();
        $data = $obj->get($cid);

        if (!$data) {
            $msg = $this->__f('Error! Cannot retrieve category with ID %s.', $cid);

            return LogUtil::registerError($msg, null, $url);
        }

        if ($data['is_locked']) {
            //! %1$s is the id, %2$s is the name
            return LogUtil::registerError($this->__f('Notice: The administrator has locked the category \'%2$s\' (ID \'%$1s\'). You cannot edit or delete it.', array($cid, $data['name'])), null, $url);
        }

        CategoryUtil::deleteCategoryByID($cid);
        $this->redirect($url);
    }
Beispiel #2
0
 public function delete($deleteSubcats = false, $newParentID = 0)
 {
     $data = $this->_objData;
     if (!$data) {
         return $data;
     }
     if ($deleteSubcats) {
         CategoryUtil::deleteCategoriesByPath($data['ipath']);
     } elseif ($newParentID) {
         CategoryUtil::moveSubCategoriesByPath($data['ipath'], $newParentID);
         CategoryUtil::deleteCategoryByID($data['id']);
     } else {
         exit(__('Can not delete category while preserving subcategories without specifying a new parent ID'));
     }
 }
Beispiel #3
0
 public function delete($deleteSubcats = false, $newParentID = 0)
 {
     $objArray = $this->_objData;
     if (!$objArray) {
         return $objArray;
     }
     foreach ($objArray as $k => $obj) {
         if ($deleteSubcats) {
             CategoryUtil::deleteCategoriesByPath($obj['ipath']);
         } elseif ($newParentID) {
             CategoryUtil::moveSubCategoriesByPath($obj['ipath'], $newParentID);
             CategoryUtil::deleteCategoryByID($obj['id']);
         } else {
             exit('Can not delete category while preserving subcategories without specifying a new parent ID');
         }
     }
 }