Example #1
0
 $categoryObj->setVar('name', $arrCat['title']);
 $categoryObj->setVar('description', $arrCat['description']);
 // Category image
 if ($arrCat['imgurl'] != 'blank.gif' && $arrCat['imgurl']) {
     if (copy(XOOPS_ROOT_PATH . "/modules/xfsection/images/category/" . $arrCat['imgurl'], PUBLISHER_UPLOADS_PATH . "/images/category/" . $arrCat['imgurl'])) {
         $categoryObj->setVar('image', $arrCat['imgurl']);
     }
 }
 if (!$categoryObj->store(false)) {
     echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_ERROR, $arrCat['title']) . "<br/>";
     continue;
 }
 $newCat['newid'] = $categoryObj->categoryid();
 // Saving category permissions
 publisher_saveCategoryPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid(), 'category_read');
 publisher_saveCategoryPermissions($categoryObj->getGroups_submit(), $categoryObj->categoryid(), 'item_submit');
 $cnt_imported_cat++;
 echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . "<br\\>";
 $sql = "SELECT * FROM " . $xoopsDB->prefix("xfs_article") . " WHERE categoryid=" . $arrCat['id'] . " ORDER BY weight";
 $resultArticles = $xoopsDB->query($sql);
 while ($arrArticle = $xoopsDB->fetchArray($resultArticles)) {
     // insert article
     $itemObj = $publisher->getHandler('item')->create();
     $itemObj->setVar('categoryid', $categoryObj->categoryid());
     $itemObj->setVar('title', $arrArticle['title']);
     $itemObj->setVar('uid', $arrArticle['uid']);
     $itemObj->setVar('summary', $arrArticle['summary']);
     $itemObj->setVar('body', $arrArticle['maintext']);
     $itemObj->setVar('counter', $arrArticle['counter']);
     $itemObj->setVar('datesub', $arrArticle['created']);
     $itemObj->setVar('weight', $arrArticle['weight']);
Example #2
0
             echo "&nbsp;&nbsp;&nbsp;&nbsp;"  . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . "<br />";
             }
             }
             }
             }
             */
             $newArticleArray[$arrArticle['storyid']] = $itemObj->itemid();
             echo "&nbsp;&nbsp;" . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->title()) . "<br />";
             $cnt_imported_articles++;
         }
     }
     // Saving category permissions
     $groupsIds = $gperm_handler->getGroupIds('news_view', $arrCat['topic_id'], $news_module_id);
     publisher_saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
     $groupsIds = $gperm_handler->getGroupIds('news_submit', $arrCat['topic_id'], $news_module_id);
     publisher_saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');
     $newCatArray[$newCat['oldid']] = $newCat;
     unset($newCat);
     echo "<br/>";
 }
 // Looping through cat to change the parentid to the new parentid
 foreach ($newCatArray as $oldid => $newCat) {
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('categoryid', $newCat['newid']));
     $oldpid = $newCat['oldpid'];
     if ($oldpid == 0) {
         $newpid = $parentId;
     } else {
         $newpid = $newCatArray[$oldpid]['newid'];
     }
     $publisher->getHandler('category')->updateAll('parentid', $newpid, $criteria);
Example #3
0
     for ($i = 0; $i < $sizeof; $i++) {
         if ($_POST['scname'][$i] != '') {
             $categoryObj = $publisher->getHandler('category')->create();
             $categoryObj->setVar('name', $_POST['scname'][$i]);
             $categoryObj->setVar('parentid', $parentCat);
             $categoryObj->setGroups_read($grpread);
             $categoryObj->setGroups_submit($grpsubmit);
             $categoryObj->setGroups_moderation($grpmoderation);
             if (!$categoryObj->store()) {
                 redirect_header("javascript:history.go(-1)", 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . publisher_formatErrors($categoryObj->getErrors()));
                 exit;
             }
             // TODO : put this function in the category class
             publisher_saveCategoryPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid(), 'category_read');
             publisher_saveCategoryPermissions($categoryObj->getGroups_submit(), $categoryObj->categoryid(), 'item_submit');
             publisher_saveCategoryPermissions($categoryObj->getGroups_moderation(), $categoryObj->categoryid(), 'category_moderation');
         }
     }
     //end of fx2024 code
     redirect_header($redirect_to, 2, $redirect_msg);
     exit;
     break;
     //Added by fx2024
 //Added by fx2024
 case "addsubcats":
     $categoryid = 0;
     $nb_subcats = intval($_POST['nb_subcats']) + $_POST['nb_sub_yet'];
     $categoryObj = $publisher->getHandler('category')->create();
     $categoryObj->setVar('name', $_POST['name']);
     $categoryObj->setVar('description', $_POST['description']);
     $categoryObj->setVar('weight', $_POST['weight']);