Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mambax7/newbb5
Browse files Browse the repository at this point in the history
# Conflicts:
#	admin/admin_permissions.php
  • Loading branch information
mambax7 committed Sep 15, 2017
2 parents d075267 + aa59d0e commit 171f6b4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
50 changes: 25 additions & 25 deletions admin/admin_permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function render()
if ('' !== $elements[$i]->getDescription()) {
$ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>';
}
$ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n";
$ret .= "</td>\n<td class='even' style='text-align:center;'>\n" . $elements[$i]->render() . "\n</td></tr>\n";
} else {
$hidden .= $elements[$i]->render();
}
Expand Down Expand Up @@ -205,16 +205,16 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
//$action = isset($_REQUEST['action']) ? strtolower($_REQUEST['action']) : "";
$action = strtolower(Request::getCmd('action', ''));
$module_id = $xoopsModule->getVar('mid');
///** @var \NewbbPermissionHandler $permHandler */
//$permHandler = xoops_getModuleHandler('permission', 'newbb');
$perms = $permHandler->getValidForumPerms();
/** @var \NewbbPermissionHandler $newbbpermHandler */
$newbbpermHandler = xoops_getModuleHandler('permission', 'newbb');
$perms = $newbbpermHandler->getValidForumPerms();

switch ($action) {
case 'template':
xoops_cp_header();
$adminObject->displayNavigation(basename(__FILE__));
echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>';
$opform = new XoopsSimpleForm(_AM_NEWBB_PERM_ACTION, 'actionform', 'admin_permissions.php', 'get');
$opform = new XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP_TEMPLAT, 'actionform', 'admin_permissions.php', 'get');
$op_select = new XoopsFormSelect('', 'action');
$op_select->setExtra('onchange="document.forms.actionform.submit()"');
$op_select->addOptionArray([
Expand All @@ -229,7 +229,7 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
$memberHandler = xoops_getHandler('member');
$glist = $memberHandler->getGroupList();
$elements = [];
$perm_template = $permHandler->getTemplate();
$perm_template = $newbbpermHandler->getTemplate();
foreach (array_keys($glist) as $i) {
$selected = !empty($perm_template[$i]) ? array_keys($perm_template[$i]) : [];
$ret_ele = '<tr align="left" valign="top"><td class="head">' . $glist[$i] . '</td>';
Expand Down Expand Up @@ -260,17 +260,17 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
$ret = '<h4>' . _AM_NEWBB_PERM_TEMPLATE . '</h4>' . _AM_NEWBB_PERM_TEMPLATE_DESC . '<br><br><br>';
$ret .= "<form name='template' id='template' method='post'>\n<table width='100%' class='outer' cellspacing='1'>\n";
$ret .= implode("\n", $elements);
$ret .= '<tr align="left" valign="top"><td class="head"></td><td class="even">';
$ret .= '<tr align="left" valign="top"><td class="head"></td><td class="even" style="text-align:center;">';
$ret .= $tray->render();
$ret .= '</td></tr>';
$ret .= '</table></form>';
echo $ret;
include_once __DIR__ . '/admin_footer.php';
break;

case 'template_save':
// $res = $permHandler->setTemplate($_POST['perms'], $groupid = 0);
$res = $permHandler->setTemplate(Request::getArray('perms', '', 'POST'), $groupid = 0);
// $res = $newbbpermHandler->setTemplate($_POST['perms'], $groupid = 0);
$res = $newbbpermHandler->setTemplate(Request::getArray('perms', '', 'POST'), $groupid = 0);
if ($res) {
redirect_header('admin_permissions.php', 2, _AM_NEWBB_PERM_TEMPLATE_CREATED);
} else {
Expand All @@ -280,14 +280,14 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
// exit();

case 'apply':
$perm_template = $permHandler->getTemplate();
$perm_template = $newbbpermHandler->getTemplate();
if (null === $perm_template) {
redirect_header('admin_permissions.php?action=template', 2, _AM_NEWBB_PERM_TEMPLATE);
}
xoops_cp_header();
$adminObject->displayNavigation(basename(__FILE__));
echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>';
$opform = new XoopsSimpleForm(_AM_NEWBB_PERM_ACTION, 'actionform', 'admin_permissions.php', 'get');
$opform = new XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP_APPLY, 'actionform', 'admin_permissions.php', 'get');
$op_select = new XoopsFormSelect('', 'action');
$op_select->setExtra('onchange="document.forms.actionform.submit()"');
$op_select->addOptionArray([
Expand All @@ -298,14 +298,14 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
$opform->addElement($op_select);
$opform->display();

// /** @var \NewbbCategoryHandler $categoryHandler */
// $categoryHandler = xoops_getModuleHandler('category', 'newbb');
/** @var \NewbbCategoryHandler $categoryHandler */
$categoryHandler = xoops_getModuleHandler('category', 'newbb');
$criteriaCategory = new CriteriaCompo(new criteria('1', 1));
$criteriaCategory->setSort('cat_order');
$categories = $categoryHandler->getList($criteriaCategory);

// /** @var \NewbbForumHandler $forumHandler */
// $forumHandler = xoops_getModuleHandler('forum', 'newbb');
/** @var \NewbbForumHandler $forumHandler */
$forumHandler = xoops_getModuleHandler('forum', 'newbb');
$forums = $forumHandler->getTree(array_keys($categories), 0, 'all');
foreach (array_keys($forums) as $c) {
$fm_options[-1 * $c - 1000] = ' ';
Expand Down Expand Up @@ -337,7 +337,7 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
if ($forum < 1) {
continue;
}
$permHandler->applyTemplate($forum, $module_id);
$newbbpermHandler->applyTemplate($forum, $module_id);
}
$cacheHelper = NewbbUtility::cleanCache();
//$cacheHelper->delete('permission');
Expand All @@ -347,7 +347,7 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
default:
xoops_cp_header();

// $categoryHandler = xoops_getModuleHandler('category', 'newbb');
$categoryHandler = xoops_getModuleHandler('category', 'newbb');
$criteriaCategory = new CriteriaCompo(new criteria('1', 1));
$criteriaCategory->setSort('cat_order');
$categories = $categoryHandler->getList($criteriaCategory);
Expand All @@ -356,7 +356,7 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
redirect_header('admin_cat_manager.php', 2, _AM_NEWBB_CREATENEWCATEGORY);
}

// $forumHandler = xoops_getModuleHandler('forum', 'newbb');
$forumHandler = xoops_getModuleHandler('forum', 'newbb');
$forums = $forumHandler->getTree(array_keys($categories), 0, 'all');

if (0 === count($forums)) {
Expand All @@ -365,7 +365,7 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])

$adminObject->displayNavigation(basename(__FILE__));
echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>';
$opform = new XoopsSimpleForm(_AM_NEWBB_PERM_ACTION, 'actionform', 'admin_permissions.php', 'get');
$opform = new XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP, 'actionform', 'admin_permissions.php', 'get');
$op_select = new XoopsFormSelect('', 'action');
$op_select->setExtra('onchange="document.forms.actionform.submit()"');
$op_select->addOptionArray([
Expand Down Expand Up @@ -416,7 +416,7 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])

$form = new NewbbXoopsGroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/admin_permissions.php', $fm_options[$op]['anonymous']);

// $categoryHandler = xoops_getModuleHandler('category', 'newbb');
$categoryHandler = xoops_getModuleHandler('category', 'newbb');
$criteriaCategory = new CriteriaCompo(new criteria('1', 1));
$criteriaCategory->setSort('cat_order');
$categories = $categoryHandler->getList($criteriaCategory);
Expand All @@ -426,7 +426,7 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
}
unset($categories);
} else {
// $forumHandler = xoops_getModuleHandler('forum', 'newbb');
$forumHandler = xoops_getModuleHandler('forum', 'newbb');
$forums = $forumHandler->getTree(array_keys($categories), 0, 'all');
if (count($forums) > 0) {
foreach (array_keys($forums) as $c) {
Expand All @@ -443,9 +443,9 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
$form->display();

// Since we can not control the permission update, a trick is used here
// /** @var \NewbbPermissionHandler $permHandler */
// $permHandler = xoops_getModuleHandler('permission', 'newbb');
$permHandler->createPermData();
/** @var \NewbbPermissionHandler $permissionHandler */
$permissionHandler = xoops_getModuleHandler('permission', 'newbb');
$permissionHandler->createPermData();
$cacheHelper = NewbbUtility::cleanCache();
//$cacheHelper->delete('permission');
include_once __DIR__ . '/admin_footer.php';
Expand Down
3 changes: 3 additions & 0 deletions language/english/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
define('_AM_NEWBB_PERM_TEMPLATEAPP', 'Apply default permission');
define('_AM_NEWBB_PERM_TEMPLATE_APPLIED', 'Default permissions have been applied to forums');
define('_AM_NEWBB_PERM_ACTION', 'Permission management tools');
define('_AM_NEWBB_PERM_ACTION_HELP', 'Allows you to set the access rights for each function and group');
define('_AM_NEWBB_PERM_ACTION_HELP_TEMPLAT', 'Allows you to create an access rights template for automatic installation when creating a forum.');
define('_AM_NEWBB_PERM_ACTION_HELP_APPLY', 'Allows you to apply a permission template to already created forums.');
define('_AM_NEWBB_PERM_SETBYGROUP', 'Set permissions directly by group');
// admin_forum_prune.php
define('_AM_NEWBB_PRUNE_RESULTS_TITLE', 'Prune Results');
Expand Down

0 comments on commit 171f6b4

Please sign in to comment.