static function refreshCategoryParentId(&$categories)
 {
     global $database;
     foreach ($categories as $category) {
         if ($category->parent_id == 0 && $category->old_parent_id != 0) {
             foreach ($categories as $category2) {
                 if ($category2->old_id == $category->old_parent_id) {
                     $category->parent_id = $category2->id;
                     $row = new mainBooklibraryCategories($database);
                     // for 1.6
                     $row->load($category->id);
                     $row->parent_id = $category->parent_id;
                     if (!$row->check()) {
                         echo "error in import4 !";
                         exit;
                         exit;
                     }
                     if (!($mess = $row->store())) {
                         // echo "err-mess_".$mess."_";
                         echo "error in import5 !: " . $mess;
                         exit;
                     }
                     $row->updateOrder("section='com_booklibrary' AND parent_id='{$row->parent_id}'");
                     //for 1.6
                     break;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
function saveCategory()
{
    global $database;
    $row = new mainBooklibraryCategories($database);
    //for 1.6
    $post = JRequest::get('post', JREQUEST_ALLOWHTML);
    $params2 = new stdClass();
    $params2->alone_category = $post['alone_category'];
    $params2->view_book = $post['view_book'];
    $post['params2'] = serialize($params2);
    //if (!$row->bind($_POST)) {
    if (!$row->bind($post)) {
        echo "<script> alert('" . addslashes($row->getError()) . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->section = 'com_booklibrary';
    $row->parent_id = $_REQUEST['parent_id'];
    $row->language = $_REQUEST['language'];
    if (!$row->check()) {
        echo "<script> alert('" . addslashes($row->getError()) . "'); window.history.go(-1); </script>\n";
        exit;
    }
    //****set access level */
    $row->params = implode(',', mosGetParam($_POST, 'category_registrationlevel', ''));
    //****end set access level */
    if ($row->params == "") {
        $row->params = "-2";
    }
    if (!$row->store()) {
        echo "<script> alert('" . addslashes($row->getError()) . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder("section='com_booklibrary' AND parent_id='{$row->parent_id}'");
    mosRedirect('index.php?option=com_booklibrary&section=categories');
}