Exemplo n.º 1
0
$db = new ossim_db();
$conn = $db->connect();
// Actions
$action = POST('action');
if (empty($action)) {
    $action = GET('action');
}
ossim_valid($action, 'addSubCategory', 'addCategory', 'deleteSubcategory', 'deleteCategory', 'expand', 'renameCategory', 'renameSubcategory', OSS_NULLABLE, 'illegal:' . _("Action"));
//
if ($action == 'addSubCategory') {
    $idCategory = POST('id');
    ossim_valid($idCategory, OSS_ALPHA, 'illegal:' . _("Category"));
    //
    $nameSubCategory = POST('nameSubCategory');
    ossim_valid($nameSubCategory, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Name Subcategory"));
    if (Subcategory::insert($conn, $idCategory, $nameSubCategory)) {
        // insert ok
        $msg = 'Ok! Add Subcategory';
    } else {
        // fail insert
        $msg = 'Error no add Subcategory';
    }
} elseif ($action == 'addCategory') {
    $nameCategory = POST('nameCategory');
    ossim_valid($nameCategory, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Name Subcategory"));
    if (Category::insert($conn, $nameCategory)) {
        // insert ok
        $msg = 'Ok! Add Category';
    } else {
        // fail insert
        $msg = 'Error no add Category';
Exemplo n.º 2
0
}
ossim_valid($action, 'add_subcategory', 'add_category', 'delete_subcategory', 'delete_category', 'expand', 'rename_category', 'rename_subcategory', OSS_NULLABLE, 'illegal:' . _("Action"));
if (ossim_error()) {
    $data['status'] = 'error';
    $data['data'] = _('Action not allowed');
} else {
    if ($action == 'add_subcategory') {
        $cat_id = POST('cat_id');
        $sc_name = POST('sc_name') != '' ? str_replace(' ', '_', POST('sc_name')) : POST('sc_name');
        ossim_valid($sc_name, OSS_SCORE, OSS_ALPHA, 'illegal:' . _('Subcategory Name'));
        ossim_valid($cat_id, OSS_DIGIT, 'illegal:' . _('Category'));
        $data['status'] = 'error';
        $data['data'] = _('Error! Subcategory not added');
        if (!ossim_error()) {
            if (!Subcategory::exist($conn, $cat_id, $sc_name)) {
                if (Subcategory::insert($conn, $cat_id, $sc_name)) {
                    $data['status'] = 'OK';
                    $data['data'] = _('Subcategory added successfully');
                }
            } else {
                $data['data'] = _('Error! This subcategory already exists');
            }
        } else {
            $data['data'] = ossim_get_error_clean();
        }
    } elseif ($action == 'add_category') {
        $c_name = POST('c_name') != '' ? str_replace(' ', '_', POST('c_name')) : POST('c_name');
        ossim_valid($c_name, OSS_SCORE, OSS_ALPHA, 'illegal:' . _('Category Name'));
        $data['status'] = 'error';
        $data['data'] = _('Error! Category not added');
        if (!ossim_error()) {
Exemplo n.º 3
0
            $category->cID = $_GET['ID'];
            $category->cName = $_POST['newCName'];
            $category->update();
            $responce = 'done';
        }
    } else {
        $responce = 'please enter a value';
    }
}
//------------------------------------------------------------- insert subcategory ------------------------------------
if (isset($_GET['subcategoryName']) && isset($_GET['catId'])) {
    if (!empty($_GET['subcategoryName']) && !empty($_GET['catId'])) {
        $subcategory = new Subcategory();
        $subcategory->scName = $_GET['subcategoryName'];
        $subcategory->cID = $_GET['catId'];
        $responce = $subcategory->insert();
        if ($responce == 0) {
            $responce = 'this subcategory name already exist in this category';
        } else {
            mkdir('../../images/products/' . $_GET['catId'] . '/' . $responce, 0777);
            chmod('../../images/products/' . $_GET['catId'] . '/' . $responce, 0777);
        }
    } else {
        $responce = 'please enter a value';
    }
}
//------------------------------------------------------ delete subcategory ----------------------------------------------
if (isset($_GET['scID'])) {
    if (!empty($_GET['scID'])) {
        $subcategory = new Subcategory($_GET['scID']);
        rm_fd('../../images/products/' . $subcategory->cID . '/' . $_GET['scID']);