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;
                 }
             }
         }
     }
 }
Exemple #2
0
 static function categoryParentList($id, $action, $is_new, $options = array())
 {
     global $database;
     $list = CAT_Utils::categoryArray();
     $cat = new mainBooklibraryCategories($database);
     //for 1.6
     $cat->load($id);
     $this_treename = '';
     $childs_ids = array();
     foreach ($list as $item) {
         if ($item->id == $cat->id || array_key_exists($item->parent_id, $childs_ids)) {
             $childs_ids[$item->id] = $item->id;
         }
     }
     foreach ($list as $item) {
         if ($this_treename) {
             if ($item->id != $cat->id && strpos($item->treename, $this_treename) === false && array_key_exists($item->id, $childs_ids) === false) {
                 $options[] = mosHTML::makeOption($item->id, $item->treename);
             }
         } else {
             if ($item->id != $cat->id) {
                 $options[] = mosHTML::makeOption($item->id, $item->treename);
             } else {
                 $this_treename = "{$item->treename}/";
             }
         }
     }
     $parent = null;
     $parent = mosHTML::selectList($options, 'parent_id', 'class="inputbox" size="1"', 'value', 'text', $cat->parent_id);
     return $parent;
 }