Ejemplo n.º 1
0
    $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 {
        $errors[] = array('message' => 'Category name cannot be blank.');
    }
    // get and validate image, if any
    if (@$_FILES['categoryimage']['tmp_name']) {
        $image = FileManager::MoveFile($_FILES['categoryimage']['tmp_name'], TYPEF_DIR . '/files/public/downloads/' . $_FILES['categoryimage']['name']);
        if ($image) {
            $image = basename($image);
        } else {
            $errors[] = array('message' => FileManager::Error());
        }
        $category->set('categoryimage', $image);
    }
    $image = $category->get('categoryimage');
    // get description, if any