/**
  * Delete category (statically)
  *
  * This function is used to delete an existing category.
  * This function is the same as EfrontDirection :: delete(),
  * except that it is called statically
  * <br/>Example:
  * <code>
  * try {
  *   EfrontDirection :: delete(32);					 //32 is the category id
  * } catch (Exception $e) {
  *   echo $e -> getMessage();
  * }
  * </code>
  *
  * @param mixed $category The category id or a category object
  * @return boolean True if everything is ok
  * @since 3.5.0
  * @access public
  * @static
  */
 public static function deleteDirection($category)
 {
     if (!$category instanceof EfrontDirection) {
         $category = new EfrontDirection($category);
     }
     return $category->delete();
 }
Beispiel #2
0
if (isset($currentUser->coreAccess['lessons']) && $currentUser->coreAccess['lessons'] == 'hidden') {
    eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
}
//Create shorthands for user access rights, to avoid long variable names
!isset($currentUser->coreAccess['lessons']) || $currentUser->coreAccess['lessons'] == 'change' ? $_change_ = 1 : ($_change_ = 0);
$smarty->assign("_change_", $_change_);
if (isset($_GET['delete_direction']) && eF_checkParameter($_GET['delete_direction'], 'id')) {
    if (!$_change_) {
        throw new Exception(_UNAUTHORIZEDACCESS);
    }
    try {
        $direction = new EfrontDirection($_GET['delete_direction']);
        if (sizeof($direction->getLessons(false, true)) > 0 || sizeof($direction->getCourses(false, true)) > 0) {
            throw new EfrontDirectionException(_YOUMUSTDELETEALLLESSONSANDSUBDIRECTIONSINTHISDIRECTIONBEFOREDELETINGIT . ': ' . $direction, EfrontDirectionException::NOT_EMPTY_CATEGORY);
        } else {
            $direction->delete();
        }
    } catch (Exception $e) {
        $message = _SOMEPROBLEMEMERGED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ')';
        header("HTTP/1.0 500 ");
        echo urlencode($e->getMessage()) . ' (' . $e->getCode() . ')';
    }
    exit;
} elseif (isset($_GET['deactivate_direction']) && eF_checkParameter($_GET['deactivate_direction'], 'id')) {
    if (!$_change_) {
        throw new Exception(_UNAUTHORIZEDACCESS);
    }
    try {
        $direction = new EfrontDirection($_GET['deactivate_direction']);
        if (sizeof($direction->getLessons(false, true)) > 0 || sizeof($direction->getCourses(false, true)) > 0) {
            throw new EfrontDirectionException(_YOUMUSTDELETEALLLESSONSANDSUBDIRECTIONSINTHISDIRECTIONBEFOREDELETINGIT . ': ' . $direction, EfrontDirectionException::NOT_EMPTY_CATEGORY);