Ejemplo n.º 1
0
 $categoryObj->setVar('name', $arrCat['title']);
 $categoryObj->setVar('description', $arrCat['description']);
 // Category image
 if ($arrCat['imgurl'] !== 'blank.gif' && $arrCat['imgurl']) {
     if (copy($GLOBALS['xoops']->path('modules/wfsection/images/category/' . $arrCat['imgurl']), PUBLISHER_UPLOAD_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
 publisherSaveCategoryPermissions($categoryObj->getGroupsRead(), $categoryObj->categoryid(), 'category_read');
 publisherSaveCategoryPermissions($categoryObj->getGroupsSubmit(), $categoryObj->categoryid(), 'item_submit');
 ++$cnt_imported_cat;
 echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . '<br\\>';
 $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfs_article') . ' WHERE categoryid=' . $arrCat['id'] . ' ORDER BY weight';
 $resultArticles = $GLOBALS['xoopsDB']->query($sql);
 while (($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles)) !== false) {
     // 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('dohtml', !$arrArticle['nohtml']);
Ejemplo n.º 2
0
                         if ($fileObj->store($allowed_mimetypes, true, false)) {
                             echo '&nbsp;&nbsp;&nbsp;&nbsp;' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filename']) . '<br />';
                         }
                     }
                 }
             }
             $newArticleArray[$arrArticle['itemid']] = $itemObj->itemid();
             echo '&nbsp;&nbsp;' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '<br />';
             ++$cnt_imported_articles;
         }
     }
     // Saving category permissions
     $groupsIds = $gpermHandler->getGroupIds('category_read', $arrCat['categoryid'], $smartsection_module_id);
     publisherSaveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
     $groupsIds = $gpermHandler->getGroupIds('item_submit', $arrCat['categoryid'], $smartsection_module_id);
     publisherSaveCategoryPermissions($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);
Ejemplo n.º 3
0
                     }
                 }
             }
             //------------------------
             $newArticleArray[$arrArticle['storyid']] = $itemObj->itemid();
             echo '&nbsp;&nbsp;' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '<br />';
             ++$cnt_imported_articles;
         }
     }
     // Saving category permissions
     $groupsIds = $gpermHandler->getGroupIds('nw_view', $arrCat['topic_id'], $ams_module_id);
     publisherSaveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
     $groupsIds = $gpermHandler->getGroupIds('nw_submit', $arrCat['topic_id'], $ams_module_id);
     publisherSaveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');
     $groupsIds = $gpermHandler->getGroupIds('nw_approve', $arrCat['topic_id'], $ams_module_id);
     publisherSaveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_moderation');
     $newCatArray[$newCat['oldid']] = $newCat;
     unset($newCat);
     echo '<br/>';
 }
 // Looping through category 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);