Skip to content

Commit

Permalink
XMF refactoring $moduleId
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Dec 27, 2020
1 parent bdbfa48 commit cba9d09
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 72 deletions.
15 changes: 7 additions & 8 deletions admin/import/ams.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
use Xmf\Request;
use XoopsModules\Publisher\{Category,
Constants,
Helper,
File,
Utility
};
/** @var Helper $helper */

const DIRNAME = 'ams';

Expand Down Expand Up @@ -169,10 +171,7 @@
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
// require_once dirname(dirname(__DIR__)) . '/include/common.php';
Utility::openCollapsableBar('amsimportgo', 'amsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname(DIRNAME);
$ams_module_id = $moduleObj->getVar('mid');
$moduleId = $helper->getModule()->getVar('mid');

/** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');
Expand Down Expand Up @@ -390,12 +389,12 @@
}

// Saving category permissions
$groupsIds = $grouppermHandler->getGroupIds('nw_view', $arrCat['topic_id'], $ams_module_id);
$groupsIds = $grouppermHandler->getGroupIds('nw_view', $arrCat['topic_id'], $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
$groupsIds = $grouppermHandler->getGroupIds('nw_submit', $arrCat['topic_id'], $ams_module_id);
$groupsIds = $grouppermHandler->getGroupIds('nw_submit', $arrCat['topic_id'], $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');

$groupsIds = $grouppermHandler->getGroupIds('nw_approve', $arrCat['topic_id'], $ams_module_id);
$groupsIds = $grouppermHandler->getGroupIds('nw_approve', $arrCat['topic_id'], $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_moderation');

$newCatArray[$newCat['oldid']] = $newCat;
Expand Down Expand Up @@ -426,7 +425,7 @@
/** @var \XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('com_modid', $ams_module_id));
$criteria->add(new \Criteria('com_modid', $moduleId));
$comments = $commentHandler->getObjects($criteria);
/** @var \XoopsComment $comment */
foreach ($comments as $comment) {
Expand Down
9 changes: 4 additions & 5 deletions admin/import/cjaycontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
Item,
Utility
};
/** @var Helper $helper */

const DIRNAME = 'cjaycontent';

require_once dirname(__DIR__) . '/admin_header.php';
Expand Down Expand Up @@ -93,10 +95,7 @@
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
// require_once dirname(dirname(__DIR__)) . '/include/common.php';
Utility::openCollapsableBar('cjaycontentimportgo', 'cjaycontentimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname(DIRNAME);
$cjaycontent_module_id = $moduleObj->getVar('mid');
$moduleId = $helper->getModule()->getVar('mid');
/** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');

Expand Down Expand Up @@ -167,7 +166,7 @@
/** @var \XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('com_modid', $cjaycontent_module_id));
$criteria->add(new \Criteria('com_modid', $moduleId));
/** @var \XoopsComment $comment */
$comments = $commentHandler->getObjects($criteria);
foreach ($comments as $comment) {
Expand Down
37 changes: 16 additions & 21 deletions admin/import/fmcontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
use Xmf\Request;
use XoopsModules\Publisher\{Category,
Constants,
Helper,
Item,
Utility
};
/** @var Helper $helper */

const DIRNAME = 'fmcontent';

Expand All @@ -48,20 +50,17 @@
Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
Utility::openCollapsableBar('fmimport', 'fmimporticon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_INFO);
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname('fmcontent');
$fm_module_id = $moduleObj->getVar('mid');
$moduleId = $helper->getModule()->getVar('mid');

$fmTopicHdlr = xoops_getModuleHandler('topic', 'fmcontent');
$fmTopicCount = $fmTopicHdlr->getCount(new \Criteria('topic_modid', $fm_module_id));
$fmTopicCount = $fmTopicHdlr->getCount(new \Criteria('topic_modid', $moduleId));

if (empty($fmTopicCount)) {
echo "<span style='color: #567; margin: 3px 0 12px 0; font-size: small; display: block;'>" . _AM_PUBLISHER_IMPORT_NO_CATEGORY . '</span>';
} else {
require_once $GLOBALS['xoops']->path('www/class/xoopstree.php');
$fmContentHdlr = xoops_getModuleHandler('page', 'fmcontent');
$fmContentCount = $fmContentHdlr->getCount(new \Criteria('content_modid', $fm_module_id));
$fmContentCount = $fmContentHdlr->getCount(new \Criteria('content_modid', $moduleId));

if (empty($fmContentCount)) {
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>';
Expand All @@ -75,7 +74,7 @@
. $GLOBALS['xoopsDB']->prefix('fmcontent_topic')
. ' AS cat INNER JOIN '
. $GLOBALS['xoopsDB']->prefix('fmcontent_content')
. " AS art ON ((cat.topic_id=art.content_topic) AND (cat.topic_modid=art.content_modid)) WHERE cat.topic_modid={$fm_module_id} GROUP BY art.content_topic";
. " 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";

$result = $GLOBALS['xoopsDB']->query($sql);
$catCboxOptions = [];
Expand All @@ -86,7 +85,7 @@
}
// now get articles in the top level category (content_topic=0)
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('content_modid', $fm_module_id));
$criteria->add(new \Criteria('content_modid', $moduleId));
$criteria->add(new \Criteria('content_topic', 0));
$cnt_tla_contents = $fmContentHdlr->getCount($criteria);
if ($cnt_tla_contents) {
Expand Down Expand Up @@ -141,11 +140,7 @@
Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
Utility::openCollapsableBar('fmimportgo', 'fmimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);

/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname(DIRNAME);
$fm_module_id = $moduleObj->getVar('mid');
$moduleId = $helper->getModule()->getVar('mid');
/** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');

Expand All @@ -158,7 +153,7 @@
$fmContentHdlr = xoops_getModuleHandler('page', 'fmcontent');

$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('content_modid', $fm_module_id));
$criteria->add(new \Criteria('content_modid', $moduleId));
$criteria->add(new \Criteria('content_topic', 0));
$fmContentObjs = $fmContentHdlr->getAll($criteria);

Expand Down Expand Up @@ -231,9 +226,9 @@
}

// Saving category permissions
$groupsIds = $grouppermHandler->getGroupIds('fmcontent_view', $thisFmContentObj->getVar('topic_id'), $fm_module_id);
$groupsIds = $grouppermHandler->getGroupIds('fmcontent_view', $thisFmContentObj->getVar('topic_id'), $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
$groupsIds = $grouppermHandler->getGroupIds('fmcontent_submit', $thisFmContentObj->getVar('topic_id'), $fm_module_id);
$groupsIds = $grouppermHandler->getGroupIds('fmcontent_submit', $thisFmContentObj->getVar('topic_id'), $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');

unset($fmContentObjs, $itemObj, $categoryObj, $thisFmContentObj);
Expand All @@ -245,7 +240,7 @@
$newArticleArray = [];
$oldToNew = [];

$fmTopicObjs = $fmTopicHdlr->getAll(new \Criteria('topic_modid', $fm_module_id));
$fmTopicObjs = $fmTopicHdlr->getAll(new \Criteria('topic_modid', $moduleId));

// first create FmContent Topics as Publisher Categories
foreach ($fmTopicObjs as $thisFmTopicObj) {
Expand Down Expand Up @@ -283,7 +278,7 @@

// retrieve all articles (content) for this category
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('content_modid', $fm_module_id)); //only for this instance of fmcontent
$criteria->add(new \Criteria('content_modid', $moduleId)); //only for this instance of fmcontent
$criteria->add(new \Criteria('content_topic', $thisFmTopicObj->getVar('topic_id'))); //for this category
$fmContentObjs = $fmContentHdlr->getAll($criteria);

Expand Down Expand Up @@ -330,9 +325,9 @@
}

// Saving category permissions
$groupsIds = $grouppermHandler->getGroupIds('fmcontent_view', $thisFmContentObj->getVar('topic_id'), $fm_module_id);
$groupsIds = $grouppermHandler->getGroupIds('fmcontent_view', $thisFmContentObj->getVar('topic_id'), $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
$groupsIds = $grouppermHandler->getGroupIds('fmcontent_submit', $thisFmContentObj->getVar('topic_id'), $fm_module_id);
$groupsIds = $grouppermHandler->getGroupIds('fmcontent_submit', $thisFmContentObj->getVar('topic_id'), $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');

$newCatArray[$catIds['oldid']] = $catIds;
Expand All @@ -359,7 +354,7 @@
/** @var \XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('com_modid', $fm_module_id));
$criteria->add(new \Criteria('com_modid', $moduleId));
/** @var \XoopsComment $comment */
$comments = $commentHandler->getObjects($criteria);
foreach ($comments as $comment) {
Expand Down
13 changes: 6 additions & 7 deletions admin/import/news.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
use Xmf\Request;
use XoopsModules\Publisher\{Category,
Constants,
Helper,
Item,
Utility
};
/** @var Helper $helper */

const DIRNAME = 'news';

Expand Down Expand Up @@ -105,10 +107,7 @@
Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
Utility::openCollapsableBar('newsimportgo', 'newsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname(DIRNAME);
$news_module_id = $moduleObj->getVar('mid');
$moduleId = $helper->getModule()->getVar('mid');
/** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');

Expand Down Expand Up @@ -233,9 +232,9 @@
}

// Saving category permissions
$groupsIds = $grouppermHandler->getGroupIds('news_view', $arrCat['topic_id'], $news_module_id);
$groupsIds = $grouppermHandler->getGroupIds('news_view', $arrCat['topic_id'], $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
$groupsIds = $grouppermHandler->getGroupIds('news_submit', $arrCat['topic_id'], $news_module_id);
$groupsIds = $grouppermHandler->getGroupIds('news_submit', $arrCat['topic_id'], $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');

$newCatArray[$newCat['oldid']] = $newCat;
Expand Down Expand Up @@ -265,7 +264,7 @@
/** @var \XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('com_modid', $news_module_id));
$criteria->add(new \Criteria('com_modid', $moduleId));
/** @var \XoopsComment $comment */
$comments = $commentHandler->getObjects($criteria);
foreach ($comments as $comment) {
Expand Down
13 changes: 6 additions & 7 deletions admin/import/smartsection.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Helper,
Utility
};
/** @var Helper $helper */

const CATEGORY = 'smartsection_categories';
const ITEMID = 'itemid';
Expand Down Expand Up @@ -108,10 +109,8 @@
Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
Utility::openCollapsableBar('newsimportgo', 'newsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname(DIRNAME);
$smartsection_module_id = $moduleObj->getVar('mid');
$moduleId = $helper->getModule()->getVar('mid');

/** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');

Expand Down Expand Up @@ -211,9 +210,9 @@
}

// Saving category permissions
$groupsIds = $grouppermHandler->getGroupIds('category_read', $arrCat['categoryid'], $smartsection_module_id);
$groupsIds = $grouppermHandler->getGroupIds('category_read', $arrCat['categoryid'], $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
$groupsIds = $grouppermHandler->getGroupIds('item_submit', $arrCat['categoryid'], $smartsection_module_id);
$groupsIds = $grouppermHandler->getGroupIds('item_submit', $arrCat['categoryid'], $moduleId);
Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');

$newCatArray[$newCat['oldid']] = $newCat;
Expand Down Expand Up @@ -243,7 +242,7 @@
/** @var \XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('com_modid', $smartsection_module_id));
$criteria->add(new \Criteria('com_modid', $moduleId));
/** @var \XoopsComment $comment */
$comments = $commentHandler->getObjects($criteria);
foreach ($comments as $comment) {
Expand Down
11 changes: 5 additions & 6 deletions admin/import/wfsection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
use XoopsModules\Publisher\{Constants,
Category,
File,
Helper,
Item,
Utility
};
/** @var Helper $helper */

const CATEGORY = 'wfs_category';
const ITEMID = 'itemid';
Expand Down Expand Up @@ -252,16 +254,13 @@

// Looping through the comments to link them to the new articles and module
echo _AM_PUBLISHER_IMPORT_COMMENTS . '<br>';
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname(DIRNAME);
$news_module_id = $moduleObj->getVar('mid');

$moduleId = $helper->getModule()->getVar('mid');

$publisher_module_id = $helper->getModule()->mid();
/** @var \XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('com_modid', $news_module_id));
$criteria->add(new \Criteria('com_modid', $moduleId));
/** @var \XoopsComment $comment */
$comments = $commentHandler->getObjects($criteria);
foreach ($comments as $comment) {
Expand Down
11 changes: 5 additions & 6 deletions admin/import/xfsection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
use XoopsModules\Publisher\{Constants,
Category,
File,
Helper,
Item,
Utility
};
/** @var Helper $helper */

const CATEGORY = 'xfs_category';
const ITEMID = 'articleid';
Expand Down Expand Up @@ -250,16 +252,13 @@

// Looping through the comments to link them to the new articles and module
echo _AM_PUBLISHER_IMPORT_COMMENTS . '<br>';
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname(DIRNAME);
$news_module_id = $moduleObj->getVar('mid');

$moduleId = $helper->getModule()->getVar('mid');

$publisher_module_id = $helper->getModule()->mid();
/** @var \XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('com_modid', $news_module_id));
$criteria->add(new \Criteria('com_modid', $moduleId));
/** @var \XoopsComment $comment */
$comments = $commentHandler->getObjects($criteria);
foreach ($comments as $comment) {
Expand Down
Loading

0 comments on commit cba9d09

Please sign in to comment.