mambax7 /
publisher
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||||||
| 2 | /* |
||||||
| 3 | You may not change or alter any portion of this comment or credits |
||||||
| 4 | of supporting developers from this source code or any supporting source code |
||||||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 6 | |||||||
| 7 | This program is distributed in the hope that it will be useful, |
||||||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 10 | */ |
||||||
| 11 | |||||||
| 12 | /** |
||||||
| 13 | * @copyright XOOPS Project (https://xoops.org) |
||||||
| 14 | * @license https://www.fsf.org/copyleft/gpl.html GNU public license |
||||||
| 15 | * @since 1.02 Beta 4 |
||||||
| 16 | * @author trabis <[email protected]> |
||||||
| 17 | * @author The SmartFactory <www.smartfactory.ca> |
||||||
| 18 | * @author Marius Scurtescu <[email protected]> |
||||||
| 19 | * @author ZySpec <[email protected]> |
||||||
| 20 | */ |
||||||
| 21 | |||||||
| 22 | use Xmf\Request; |
||||||
| 23 | use XoopsModules\Publisher\Category; |
||||||
| 24 | use XoopsModules\Publisher\Constants; |
||||||
| 25 | use XoopsModules\Publisher\Helper; |
||||||
| 26 | use XoopsModules\Publisher\Item; |
||||||
| 27 | use XoopsModules\Publisher\Utility; |
||||||
| 28 | |||||||
| 29 | /** @var Helper $helper */ |
||||||
| 30 | const DIRNAME = 'fmcontent'; |
||||||
| 31 | |||||||
| 32 | /** @var \XoopsPersistableObjectHandler $fmContentHandler */ |
||||||
| 33 | /** @var \XoopsPersistableObjectHandler $fmTopicHandler */ |
||||||
| 34 | require_once \dirname(__DIR__) . '/admin_header.php'; |
||||||
| 35 | $myts = \MyTextSanitizer::getInstance(); |
||||||
| 36 | |||||||
| 37 | $importFromModuleName = 'FmContent ' . Request::getString('fmcontent_version', '', 'POST'); |
||||||
| 38 | |||||||
| 39 | $scriptname = DIRNAME . '.php'; |
||||||
| 40 | |||||||
| 41 | $op = ('go' === Request::getString('op', '', 'POST')) ? 'go' : 'start'; |
||||||
| 42 | |||||||
| 43 | if ('start' === $op) { |
||||||
| 44 | xoops_load('XoopsFormLoader'); |
||||||
| 45 | |||||||
| 46 | Utility::cpHeader(); |
||||||
| 47 | //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); |
||||||
| 48 | Utility::openCollapsableBar('fmimport', 'fmimporticon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_INFO); |
||||||
| 49 | $moduleId = $helper->getModule() |
||||||
| 50 | ->getVar('mid'); |
||||||
| 51 | |||||||
| 52 | $fmTopicHandler = xoops_getModuleHandler('topic', 'fmcontent'); |
||||||
| 53 | $fmTopicCount = $fmTopicHandler->getCount(new \Criteria('topic_modid', $moduleId)); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 54 | |||||||
| 55 | if (empty($fmTopicCount)) { |
||||||
| 56 | echo "<span style='color: #567; margin: 3px 0 12px 0; font-size: small; display: block;'>" . _AM_PUBLISHER_IMPORT_NO_CATEGORY . '</span>'; |
||||||
| 57 | } else { |
||||||
| 58 | require_once $GLOBALS['xoops']->path('class/xoopstree.php'); |
||||||
| 59 | $fmContentHandler = xoops_getModuleHandler('page', 'fmcontent'); |
||||||
| 60 | $fmContentCount = $fmContentHandler->getCount(new \Criteria('content_modid', $moduleId)); |
||||||
| 61 | |||||||
| 62 | if (empty($fmContentCount)) { |
||||||
| 63 | echo "<span style='color: #567; margin: 3px 0 12px 0; font-size: small; display: block;'>" . sprintf(_AM_PUBLISHER_IMPORT_MODULE_FOUND_NO_ITEMS, $importFromModuleName, $fmContentCount) . '</span>'; |
||||||
| 64 | } else { |
||||||
| 65 | /* |
||||||
| 66 | echo "<span style='color: #567; margin: 3px 0 12px 0; font-size: small; display: block;'>" . sprintf(_AM_PUBLISHER_IMPORT_MODULE_FOUND, $importFromModuleName, $fmContentCount, $fmTopicCount) . "</span>"; |
||||||
| 67 | $form = new \XoopsThemeForm(_AM_PUBLISHER_IMPORT_SETTINGS, 'import_form', PUBLISHER_ADMIN_URL . "/import/$scriptname"); |
||||||
| 68 | */ |
||||||
| 69 | // Categories to be imported |
||||||
| 70 | $sql = 'SELECT cat.topic_id, cat.topic_pid, cat.topic_title, COUNT(art.content_id) FROM ' |
||||||
| 71 | . $GLOBALS['xoopsDB']->prefix('fmcontent_topic') |
||||||
| 72 | . ' AS cat INNER JOIN ' |
||||||
| 73 | . $GLOBALS['xoopsDB']->prefix('fmcontent_content') |
||||||
| 74 | . " AS art ON ((cat.topic_id=art.content_topic) AND (cat.topic_modid=art.content_modid)) WHERE cat.topic_modid={$moduleId} GROUP BY art.content_topic"; |
||||||
| 75 | |||||||
| 76 | $result = $GLOBALS['xoopsDB']->query($sql); |
||||||
| 77 | $catCboxOptions = []; |
||||||
| 78 | |||||||
| 79 | while ([$cid, $pid, $catTitle, $articleCount] = $GLOBALS['xoopsDB']->fetchRow($result)) { |
||||||
| 80 | $catTitle = $myts->displayTarea($catTitle); |
||||||
| 81 | $catCboxOptions[$cid] = "{$catTitle} ($articleCount)"; |
||||||
| 82 | } |
||||||
| 83 | // now get articles in the top level category (content_topic=0) |
||||||
| 84 | $criteria = new \CriteriaCompo(); |
||||||
| 85 | $criteria->add(new \Criteria('content_modid', $moduleId)); |
||||||
| 86 | $criteria->add(new \Criteria('content_topic', 0)); |
||||||
| 87 | $cnt_tla_contents = $fmContentHandler->getCount($criteria); |
||||||
| 88 | if ($cnt_tla_contents) { |
||||||
| 89 | $catCboxOptions[0] = _AM_PUBLISHER_IMPORT_FMCONTENT_NAME . " ({$cnt_tla_contents})"; |
||||||
| 90 | } |
||||||
| 91 | natcasesort($catCboxOptions); //put them in "alphabetical" order |
||||||
| 92 | |||||||
| 93 | echo "<span style='color: #567; margin: 3px 0 12px 0; font-size: small; display: block;'>" . sprintf(_AM_PUBLISHER_IMPORT_MODULE_FOUND, $importFromModuleName, $fmContentCount, count($catCboxOptions)) . '</span>'; |
||||||
| 94 | $form = new \XoopsThemeForm(_AM_PUBLISHER_IMPORT_SETTINGS, 'import_form', PUBLISHER_ADMIN_URL . "/import/$scriptname"); |
||||||
| 95 | |||||||
| 96 | $catLabel = new \XoopsFormLabel(_AM_PUBLISHER_IMPORT_CATEGORIES, implode('<br>', $catCboxOptions)); |
||||||
| 97 | $catLabel->setDescription(_AM_PUBLISHER_IMPORT_CATEGORIES_DSC); |
||||||
| 98 | $form->addElement($catLabel); |
||||||
| 99 | |||||||
| 100 | // Publisher parent category |
||||||
| 101 | xoops_load('tree'); |
||||||
| 102 | $categoryHandler = $helper->getHandler('Category'); |
||||||
| 103 | $catObjs = $categoryHandler->getAll(); |
||||||
| 104 | $myObjTree = new \XoopsObjectTree($catObjs, 'categoryid', 'parentid'); |
||||||
| 105 | $moduleDirName = \basename(\dirname(__DIR__)); |
||||||
| 106 | $module = \XoopsModule::getByDirname($moduleDirName); |
||||||
| 107 | $catSelBox = $myObjTree->makeSelectElement('parent_category', 'name', '-', 0, true, 0, '', '') |
||||||
| 108 | ->render(); |
||||||
| 109 | //$form->addElement($catSelBox); |
||||||
| 110 | |||||||
| 111 | $parent_cat_sel = new \XoopsFormLabel(_AM_PUBLISHER_IMPORT_PARENT_CATEGORY, $catSelBox); |
||||||
| 112 | $parent_cat_sel->setDescription(_AM_PUBLISHER_IMPORT_PARENT_CATEGORY_DSC); |
||||||
| 113 | $form->addElement($parent_cat_sel); |
||||||
| 114 | /* |
||||||
| 115 | $mytree = new \XoopsTree($GLOBALS['xoopsDB']->prefix("publisher_categories"), "categoryid", "parentid"); |
||||||
| 116 | ob_start(); |
||||||
| 117 | $mytree->makeMySelBox("name", "weight", $preset_id = 0, $none = 1, $sel_name = "parent_category"); |
||||||
| 118 | |||||||
| 119 | $parent_cat_sel = new \XoopsFormLabel(_AM_PUBLISHER_IMPORT_PARENT_CATEGORY, ob_get_contents()); |
||||||
| 120 | $parent_cat_sel->setDescription(_AM_PUBLISHER_IMPORT_PARENT_CATEGORY_DSC); |
||||||
| 121 | $form->addElement($parent_cat_sel); |
||||||
| 122 | ob_end_clean(); |
||||||
| 123 | */ |
||||||
| 124 | $form->addElement(new \XoopsFormHidden('op', 'go')); |
||||||
| 125 | $form->addElement(new \XoopsFormButton('', 'import', _AM_PUBLISHER_IMPORT, 'submit')); |
||||||
| 126 | |||||||
| 127 | $form->addElement(new \XoopsFormHidden('from_module_version', Request::getString('news_version', '', 'POST'))); |
||||||
| 128 | |||||||
| 129 | $form->display(); |
||||||
| 130 | } |
||||||
| 131 | } |
||||||
| 132 | |||||||
| 133 | Utility::closeCollapsableBar('fmimport', 'fmimporticon'); |
||||||
| 134 | xoops_cp_footer(); |
||||||
| 135 | } |
||||||
| 136 | |||||||
| 137 | if ('go' === $op) { |
||||||
| 138 | Utility::cpHeader(); |
||||||
| 139 | //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); |
||||||
| 140 | Utility::openCollapsableBar('fmimportgo', 'fmimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); |
||||||
| 141 | $moduleId = $helper->getModule() |
||||||
| 142 | ->getVar('mid'); |
||||||
| 143 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||||||
| 144 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
| 145 | |||||||
| 146 | $cnt_imported_cat = 0; |
||||||
| 147 | $cnt_imported_articles = 0; |
||||||
| 148 | |||||||
| 149 | $parentId = Request::getInt('parent_category', 0, 'POST'); |
||||||
| 150 | |||||||
| 151 | // get all FmContent Content items without a category (content_topic=0) |
||||||
| 152 | $fmContentHandler = xoops_getModuleHandler('page', 'fmcontent'); |
||||||
| 153 | |||||||
| 154 | $criteria = new \CriteriaCompo(); |
||||||
| 155 | $criteria->add(new \Criteria('content_modid', $moduleId)); |
||||||
| 156 | $criteria->add(new \Criteria('content_topic', 0)); |
||||||
| 157 | $fmContentObjs = $fmContentHandler->getAll($criteria); |
||||||
|
0 ignored issues
–
show
The method
getAll() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoUserHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 158 | |||||||
| 159 | if ($fmContentObjs && \is_array($fmContentObjs)) { |
||||||
| 160 | ++$cnt_imported_cat; //count category if there was content to import |
||||||
| 161 | |||||||
| 162 | // create Publsher category to hold FmContent Content items with no Topic (content_topic=0) |
||||||
| 163 | /** @var Category $categoryObj */ |
||||||
| 164 | $categoryObj = $helper->getHandler('Category') |
||||||
| 165 | ->create(); |
||||||
| 166 | $categoryObj->setVars([ |
||||||
| 167 | 'parentid' => $parentId, |
||||||
| 168 | 'name' => _AM_PUBLISHER_IMPORT_FMCONTENT_NAME, |
||||||
| 169 | 'description' => _AM_PUBLISHER_IMPORT_FMCONTENT_TLT, |
||||||
| 170 | 'image' => '', |
||||||
| 171 | 'total' => 0, |
||||||
| 172 | 'weight' => 1, |
||||||
| 173 | 'created' => time(), |
||||||
| 174 | 'moderator', |
||||||
| 175 | $GLOBALS['xoopsUser']->getVar('uid'), |
||||||
| 176 | ]); |
||||||
| 177 | $categoryObj->store(); |
||||||
| 178 | |||||||
| 179 | $fmTopicHandler = xoops_getModuleHandler('topic', 'fmcontent'); |
||||||
| 180 | |||||||
| 181 | // insert articles for this category |
||||||
| 182 | foreach ($fmContentObjs as $thisFmContentObj) { |
||||||
| 183 | $itemObj = $helper->getHandler('Item') |
||||||
| 184 | ->create(); |
||||||
| 185 | $itemObj->setVars([ |
||||||
| 186 | 'categoryid' => $categoryObj->categoryid(), |
||||||
| 187 | 'title' => $thisFmContentObj->getVar('content_title'), |
||||||
| 188 | 'uid' => $thisFmContentObj->getVar('content_uid'), |
||||||
| 189 | 'summary' => $thisFmContentObj->getVar('content_short'), |
||||||
| 190 | 'body' => $thisFmContentObj->getVar('content_text'), |
||||||
| 191 | 'datesub' => $thisFmContentObj->getVar('content_create'), |
||||||
| 192 | 'dohtml' => $thisFmContentObj->getVar('dohtml'), |
||||||
| 193 | 'dosmiley' => $thisFmContentObj->getVar('dosmiley'), |
||||||
| 194 | 'doxcode' => $thisFmContentObj->getVar('doxcode'), |
||||||
| 195 | 'doimage' => $thisFmContentObj->getVar('doimage'), |
||||||
| 196 | 'dobr' => $thisFmContentObj->getVar('dobr'), |
||||||
| 197 | 'weight' => $thisFmContentObj->getVar('content_order'), |
||||||
| 198 | 'status' => $thisFmContentObj->getVar('content_status') ? Constants::PUBLISHER_STATUS_PUBLISHED : Constants::PUBLISHER_STATUS_OFFLINE, |
||||||
| 199 | 'counter' => $thisFmContentObj->getVar('content_hits'), |
||||||
| 200 | 'rating' => 0, |
||||||
| 201 | 'votes' => 0, |
||||||
| 202 | 'comments' => $thisFmContentObj->getVar('content_comments'), |
||||||
| 203 | 'meta_keywords' => $thisFmContentObj->getVar('content_words'), |
||||||
| 204 | 'meta_description' => $thisFmContentObj->getVar('content_desc'), |
||||||
| 205 | ]); |
||||||
| 206 | $contentImg = $thisFmContentObj->getVar('content_img'); |
||||||
| 207 | if (!empty($contentImg)) { |
||||||
| 208 | $itemObj->setVars([ |
||||||
| 209 | 'images' => 1, |
||||||
| 210 | 'image' => $thisFmContentObj->getVar('content_img'), |
||||||
| 211 | ]); |
||||||
| 212 | } |
||||||
| 213 | |||||||
| 214 | if (!$itemObj->store()) { |
||||||
| 215 | echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $thisFmContentObj->getVar('title')) . "<br>\n"; |
||||||
| 216 | continue; |
||||||
| 217 | } |
||||||
| 218 | $newArticleArray[$thisFmContentObj->getVar('storyid')] = $itemObj->itemid(); |
||||||
| 219 | echo ' ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . "<br>\n"; |
||||||
| 220 | ++$cnt_imported_articles; |
||||||
| 221 | } |
||||||
| 222 | |||||||
| 223 | // Saving category permissions |
||||||
| 224 | $groupsIds = $grouppermHandler->getGroupIds('fmcontent_view', $thisFmContentObj->getVar('topic_id'), $moduleId); |
||||||
| 225 | Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read'); |
||||||
| 226 | $groupsIds = $grouppermHandler->getGroupIds('fmcontent_submit', $thisFmContentObj->getVar('topic_id'), $moduleId); |
||||||
| 227 | Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit'); |
||||||
| 228 | |||||||
| 229 | unset($fmContentObjs, $itemObj, $categoryObj, $thisFmContentObj); |
||||||
| 230 | echo "<br>\n"; |
||||||
| 231 | } |
||||||
| 232 | |||||||
| 233 | // Process all "normal" Topics (categories) from FmContent |
||||||
| 234 | $newCatArray = []; |
||||||
| 235 | $newArticleArray = []; |
||||||
| 236 | $oldToNew = []; |
||||||
| 237 | |||||||
| 238 | $fmTopicObjs = $fmTopicHandler->getAll(new \Criteria('topic_modid', $moduleId)); |
||||||
| 239 | |||||||
| 240 | // first create FmContent Topics as Publisher Categories |
||||||
| 241 | foreach ($fmTopicObjs as $thisFmTopicObj) { |
||||||
| 242 | $catIds = [ |
||||||
| 243 | 'oldid' => $thisFmTopicObj->getVar('topic_id'), |
||||||
| 244 | 'oldpid' => $thisFmTopicObj->getVar('topic_pid'), |
||||||
| 245 | ]; |
||||||
| 246 | |||||||
| 247 | $categoryObj = $helper->getHandler('Category') |
||||||
| 248 | ->create(); |
||||||
| 249 | |||||||
| 250 | $categoryObj->setVars([ |
||||||
| 251 | 'parentid' => $thisFmTopicObj->getVar('topic_pid'), |
||||||
| 252 | 'weight' => $thisFmTopicObj->getVar('topic_weight'), |
||||||
| 253 | 'name' => $thisFmTopicObj->getVar('topic_title'), |
||||||
| 254 | 'description' => $thisFmTopicObj->getVar('topic_desc'), |
||||||
| 255 | ]); |
||||||
| 256 | |||||||
| 257 | // Category image |
||||||
| 258 | if (!in_array($thisFmTopicObj->getVar('topic_img'), ['blank.gif', ''], true)) { |
||||||
| 259 | if (copy($GLOBALS['xoops']->path('www/uploads/fmcontent/img/' . $thisFmTopicObj->getVar('topic_img')), $GLOBALS['xoops']->path('www/uploads/publisher/images/category/' . $thisFmTopicObj->getVar('topic_img')))) { |
||||||
| 260 | $categoryObj->setVar('image', $thisFmTopicObj->getVar('topic_img')); |
||||||
| 261 | } |
||||||
| 262 | } |
||||||
| 263 | if (!$helper->getHandler('Category') |
||||||
| 264 | ->insert($categoryObj)) { |
||||||
| 265 | echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_ERROR, $thisFmTopicObj->getVar('topic_title')) . "<br>\n"; |
||||||
| 266 | continue; |
||||||
| 267 | } |
||||||
| 268 | |||||||
| 269 | $catIds['newid'] = $categoryObj->categoryid(); |
||||||
| 270 | ++$cnt_imported_cat; |
||||||
| 271 | |||||||
| 272 | echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . "<br>\n"; |
||||||
| 273 | |||||||
| 274 | // retrieve all articles (content) for this category |
||||||
| 275 | $criteria = new \CriteriaCompo(); |
||||||
| 276 | $criteria->add(new \Criteria('content_modid', $moduleId)); //only for this instance of fmcontent |
||||||
| 277 | $criteria->add(new \Criteria('content_topic', $thisFmTopicObj->getVar('topic_id'))); //for this category |
||||||
| 278 | $fmContentObjs = $fmContentHandler->getAll($criteria); |
||||||
| 279 | |||||||
| 280 | // insert articles for this category |
||||||
| 281 | /** @var Item $itemObj */ |
||||||
| 282 | foreach ($fmContentObjs as $thisFmContentObj) { |
||||||
| 283 | $itemObj = $helper->getHandler('Item') |
||||||
| 284 | ->create(); |
||||||
| 285 | $itemObj->setVars([ |
||||||
| 286 | 'categoryid' => $catIds['newid'], |
||||||
| 287 | 'title' => $thisFmContentObj->getVar('content_title'), |
||||||
| 288 | 'uid' => $thisFmContentObj->getVar('content_uid'), |
||||||
| 289 | 'summary' => $thisFmContentObj->getVar('content_short'), |
||||||
| 290 | 'body' => $thisFmContentObj->getVar('content_text'), |
||||||
| 291 | 'counter' => $thisFmContentObj->getVar('content_hits'), |
||||||
| 292 | 'datesub' => $thisFmContentObj->getVar('content_create'), |
||||||
| 293 | 'dohtml' => $thisFmContentObj->getVar('dohtml'), |
||||||
| 294 | 'dosmiley' => $thisFmContentObj->getVar('dosmiley'), |
||||||
| 295 | 'doxcode' => $thisFmContentObj->getVar('doxcode'), |
||||||
| 296 | 'doimage' => $thisFmContentObj->getVar('doimage'), |
||||||
| 297 | 'dobr' => $thisFmContentObj->getVar('dobr'), |
||||||
| 298 | 'weight' => $thisFmContentObj->getVar('content_order'), |
||||||
| 299 | 'status' => $thisFmContentObj->getVar('content_status') ? Constants::PUBLISHER_STATUS_PUBLISHED : Constants::PUBLISHER_STATUS_OFFLINE, |
||||||
| 300 | 'rating' => 0, |
||||||
| 301 | 'votes' => 0, |
||||||
| 302 | 'comments' => $thisFmContentObj->getVar('content_comments'), |
||||||
| 303 | 'meta_keywords' => $thisFmContentObj->getVar('content_words'), |
||||||
| 304 | 'meta_description' => $thisFmContentObj->getVar('content_desc'), |
||||||
| 305 | ]); |
||||||
| 306 | $contentImg = $thisFmContentObj->getVar('content_img'); |
||||||
| 307 | if (!empty($contentImg)) { |
||||||
| 308 | $itemObj->setVar('images', 1); |
||||||
| 309 | $itemObj->setVar('image', $thisFmContentObj->getVar('content_img')); |
||||||
| 310 | } |
||||||
| 311 | |||||||
| 312 | if (!$itemObj->store()) { |
||||||
| 313 | echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $thisFmContentObj->getVar('title')) . "<br>\n"; |
||||||
| 314 | continue; |
||||||
| 315 | } |
||||||
| 316 | $newArticleArray[$thisFmContentObj->getVar('storyid')] = $itemObj->itemid(); |
||||||
| 317 | echo ' ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . "<br>\n"; |
||||||
| 318 | ++$cnt_imported_articles; |
||||||
| 319 | } |
||||||
| 320 | |||||||
| 321 | // Saving category permissions |
||||||
| 322 | $groupsIds = $grouppermHandler->getGroupIds('fmcontent_view', $thisFmContentObj->getVar('topic_id'), $moduleId); |
||||||
| 323 | Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read'); |
||||||
| 324 | $groupsIds = $grouppermHandler->getGroupIds('fmcontent_submit', $thisFmContentObj->getVar('topic_id'), $moduleId); |
||||||
| 325 | Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit'); |
||||||
| 326 | |||||||
| 327 | $newCatArray[$catIds['oldid']] = $catIds; |
||||||
| 328 | unset($catIds, $thisFmContentObj); |
||||||
| 329 | echo "<br>\n"; |
||||||
| 330 | } |
||||||
| 331 | // unset($thisFmTopicObj); |
||||||
| 332 | |||||||
| 333 | // Looping through cat to change the parentid to the new parentid |
||||||
| 334 | foreach ($newCatArray as $oldid => $catIds) { |
||||||
| 335 | $criteria = new \CriteriaCompo(); |
||||||
| 336 | $criteria->add(new \Criteria('categoryid', $catIds['newid'])); |
||||||
| 337 | $oldpid = $catIds['oldpid']; |
||||||
| 338 | $newpid = (0 == $oldpid) ? $parentId : $newCatArray[$oldpid]['newid']; |
||||||
| 339 | $helper->getHandler('Category') |
||||||
| 340 | ->updateAll('parentid', $newpid, $criteria); |
||||||
| 341 | unset($criteria); |
||||||
| 342 | } |
||||||
| 343 | unset($oldid); |
||||||
| 344 | |||||||
| 345 | // Looping through the comments to link them to the new articles and module |
||||||
| 346 | echo _AM_PUBLISHER_IMPORT_COMMENTS . "<br>\n"; |
||||||
| 347 | |||||||
| 348 | $publisher_module_id = $helper->getModule() |
||||||
| 349 | ->mid(); |
||||||
| 350 | /** @var \XoopsCommentHandler $commentHandler */ |
||||||
| 351 | $commentHandler = xoops_getHandler('comment'); |
||||||
| 352 | $criteria = new \CriteriaCompo(); |
||||||
| 353 | $criteria->add(new \Criteria('com_modid', $moduleId)); |
||||||
| 354 | /** @var \XoopsComment $comment */ |
||||||
| 355 | $comments = $commentHandler->getObjects($criteria); |
||||||
| 356 | foreach ($comments as $comment) { |
||||||
| 357 | $comment->setVar('com_itemid', $newArticleArray[(int)$comment->getVar('com_itemid')]); |
||||||
| 358 | $comment->setVar('com_modid', $publisher_module_id); |
||||||
| 359 | $comment->setNew(); |
||||||
| 360 | if ($commentHandler->insert($comment)) { |
||||||
| 361 | echo ' ' . sprintf(_AM_PUBLISHER_IMPORTED_COMMENT, $comment->getVar('com_title')) . "<br>\n"; |
||||||
| 362 | } else { |
||||||
| 363 | echo ' ' . sprintf(_AM_PUBLISHER_IMPORTED_COMMENT_ERROR, $comment->getVar('com_title')) . "<br>\n"; |
||||||
| 364 | } |
||||||
| 365 | } |
||||||
| 366 | // unset($comment); |
||||||
| 367 | |||||||
| 368 | echo '<br><br>' |
||||||
| 369 | . _AM_PUBLISHER_IMPORT_DONE |
||||||
| 370 | . "<br>\n" |
||||||
| 371 | . sprintf(_AM_PUBLISHER_IMPORTED_CATEGORIES, $cnt_imported_cat) |
||||||
| 372 | . "<br>\n" |
||||||
| 373 | . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLES, $cnt_imported_articles) |
||||||
| 374 | . "<br>\n" |
||||||
| 375 | . "<br>\n<a href='" |
||||||
| 376 | . PUBLISHER_URL |
||||||
| 377 | . "/'>" |
||||||
| 378 | . _AM_PUBLISHER_IMPORT_GOTOMODULE |
||||||
| 379 | . "</a><br>\n"; |
||||||
| 380 | |||||||
| 381 | Utility::closeCollapsableBar('fmimportgo', 'fmimportgoicon'); |
||||||
| 382 | xoops_cp_footer(); |
||||||
| 383 | } |
||||||
| 384 |