예제 #1
0
파일: update.php 프로젝트: ssrsfs/blg
*/
// save some typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri() . 'categories/';
// if user clicked the cancel button...
if ('cancel' == @$_POST['cmd']) {
    // redirect to category admin page
    header("Location: {$typef_app_dir}");
    exit;
}
if (Download_Category::MODE_ADD == $mode) {
    // intantiate a new category
    $category = new Download_Category();
} else {
    // create category with the given id
    $categoryid = @$_REQUEST['categoryid'];
    $category = new Download_Category($categoryid);
    // download category must exist to proceed
    if (!$category->exists()) {
        Typeframe::Redirect('Invalid category specified.', $typef_app_dir, -1);
        return;
    }
}
// keep track of errors
$errors = array();
// process edit action
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    // get and validate name, if any
    $name = trim(@$_POST['categoryname']);
    if (strlen($name) > 0) {
        $category->set('categoryname', $name);
    } else {
예제 #2
0
 public static function CountDownloads($category)
 {
     // get category id
     $categoryid = $category->get('categoryid');
     // count files immediately parented to this category
     $downloads = Download_File::DAOFactory();
     Download::SetCategoryId($downloads, $categoryid);
     $count = $downloads->getTotal();
     // count children
     $subcats = Download_Category::DAOFactory();
     Download::SetParentId($subcats, $categoryid);
     foreach ($subcats->getAll() as $subcat) {
         $count += self::CountDownloads($subcat);
     }
     return $count;
 }
예제 #3
0
파일: delete.php 프로젝트: ssrsfs/blg
<?php

/*
	12 april 2011: created from admin/news/categories/delete.php
	22 april 2011: added typef_app_dir
*/
// save some typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// if not posting, bounce out of here
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    Typeframe::Redirect('Nothing to do.', $typef_app_dir);
    return;
}
// create category with the given id
$categoryid = @$_POST['categoryid'];
$category = new Download_Category($categoryid);
// download category must exist to proceed
if (!$category->exists()) {
    Typeframe::Redirect('Invalid category specified.', $typef_app_dir, -1);
    return;
}
// make sure the category is not in use
$categories = Download_Category::DAOFactory();
$categories->select()->where('parentid = ?', $categoryid);
$catCount = $categories->getTotal();
$files = Download_File::DAOFactory();
$files->select()->where('categoryid = ?', $categoryid);
$fileCount = $files->getTotal();
if ($catCount > 0 || $fileCount > 0) {
    $message = 'Unable to delete category. It is in use by';
    $categories = 1 == $catCount ? 'category' : 'categories';