mambax7 /
smartfaq
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | |||
| 3 | /** |
||
| 4 | * Module: SmartFAQ |
||
| 5 | * Author: The SmartFactory <www.smartfactory.ca> |
||
| 6 | * Licence: GNU |
||
| 7 | * @param $DB |
||
| 8 | * @param $gperm_modid |
||
| 9 | * @param null $gperm_name |
||
| 10 | * @param null $gperm_itemid |
||
| 11 | * @return bool |
||
| 12 | */ |
||
| 13 | |||
| 14 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 15 | |||
| 16 | function myDeleteByModule($DB, $gperm_modid, $gperm_name = null, $gperm_itemid = null) |
||
| 17 | { |
||
| 18 | $criteria = new CriteriaCompo(new Criteria('gperm_modid', (int)$gperm_modid)); |
||
| 19 | if (isset($gperm_name)) { |
||
| 20 | $criteria->add(new Criteria('gperm_name', $gperm_name)); |
||
| 21 | if (isset($gperm_itemid)) { |
||
| 22 | $criteria->add(new Criteria('gperm_itemid', (int)$gperm_itemid)); |
||
| 23 | } |
||
| 24 | } |
||
| 25 | $sql = 'DELETE FROM ' . $DB->prefix('group_permission') . ' ' . $criteria->renderWhere(); |
||
| 26 | if (!$result = $DB->query($sql)) { |
||
| 27 | return false; |
||
| 28 | } |
||
| 29 | |||
| 30 | return true; |
||
| 31 | } |
||
| 32 | |||
| 33 | // include_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; GIJ |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 34 | $modid = isset($HTTP_POST_VARS['modid']) ? (int)$HTTP_POST_VARS['modid'] : 1; |
||
| 35 | // we dont want system module permissions to be changed here ( 1 -> 0 GIJ) |
||
| 36 | if ($modid <= 0 || !is_object($xoopsUser) || !$xoopsUser->isAdmin($modid)) { |
||
| 37 | redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM); |
||
| 38 | } |
||
| 39 | $moduleHandler = xoops_getHandler('module'); |
||
| 40 | $module = $moduleHandler->get($modid); |
||
| 41 | if (!is_object($module) || !$module->getVar('isactive')) { |
||
| 42 | redirect_header(XOOPS_URL . '/admin.php', 1, _MODULENOEXIST); |
||
| 43 | } |
||
| 44 | $memberHandler = xoops_getHandler('member'); |
||
| 45 | $group_list =& $memberHandler->getGroupList(); |
||
| 46 | if (is_array($HTTP_POST_VARS['perms']) && !empty($HTTP_POST_VARS['perms'])) { |
||
| 47 | $gpermHandler = xoops_getHandler('groupperm'); |
||
| 48 | foreach ($HTTP_POST_VARS['perms'] as $perm_name => $perm_data) { |
||
| 49 | foreach ($perm_data['itemname'] as $item_id => $item_name) { |
||
| 50 | // checking code |
||
| 51 | // echo "<pre>" ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 52 | // var_dump( $HTTP_POST_VARS['perms'] ) ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 53 | // exit ; |
||
| 54 | if (false != myDeleteByModule($gpermHandler->db, $modid, $perm_name, $item_id)) { |
||
| 55 | if (empty($perm_data['groups'])) { |
||
| 56 | continue; |
||
| 57 | } |
||
| 58 | foreach ($perm_data['groups'] as $group_id => $item_ids) { |
||
| 59 | // foreach ($item_ids as $item_id => $selected) { |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
57% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 60 | $selected = isset($item_ids[$item_id]) ? $item_ids[$item_id] : 0; |
||
| 61 | if ($selected == 1) { |
||
| 62 | // make sure that all parent ids are selected as well |
||
| 63 | if ($perm_data['parents'][$item_id] != '') { |
||
| 64 | $parent_ids = explode(':', $perm_data['parents'][$item_id]); |
||
| 65 | foreach ($parent_ids as $pid) { |
||
| 66 | if ($pid != 0 && !in_array($pid, array_keys($item_ids))) { |
||
| 67 | // one of the parent items were not selected, so skip this item |
||
| 68 | $msg[] = sprintf(_MD_AM_PERMADDNG, '<b>' . $perm_name . '</b>', '<b>' . $perm_data['itemname'][$item_id] . '</b>', '<b>' . $group_list[$group_id] . '</b>') . ' (' . _MD_AM_PERMADDNGP . ')'; |
||
| 69 | continue 2; |
||
| 70 | } |
||
| 71 | } |
||
| 72 | } |
||
| 73 | $gperm = $gpermHandler->create(); |
||
| 74 | $gperm->setVar('gperm_groupid', $group_id); |
||
| 75 | $gperm->setVar('gperm_name', $perm_name); |
||
| 76 | $gperm->setVar('gperm_modid', $modid); |
||
| 77 | $gperm->setVar('gperm_itemid', $item_id); |
||
| 78 | if (!$gpermHandler->insert($gperm)) { |
||
| 79 | $msg[] = sprintf(_MD_AM_PERMADDNG, '<b>' . $perm_name . '</b>', '<b>' . $perm_data['itemname'][$item_id] . '</b>', '<b>' . $group_list[$group_id] . '</b>'); |
||
| 80 | } else { |
||
| 81 | $msg[] = sprintf(_MD_AM_PERMADDOK, '<b>' . $perm_name . '</b>', '<b>' . $perm_data['itemname'][$item_id] . '</b>', '<b>' . $group_list[$group_id] . '</b>'); |
||
| 82 | } |
||
| 83 | unset($gperm); |
||
| 84 | } |
||
| 85 | } |
||
| 86 | } else { |
||
| 87 | $msg[] = sprintf(_MD_AM_PERMRESETNG, $module->getVar('name')); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |
||
| 91 | } |
||
| 92 | /* |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
53% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 93 | $backlink = XOOPS_URL.'/admin.php'; |
||
| 94 | if ($module->getVar('hasadmin')) { |
||
| 95 | $adminindex = $module->getInfo('adminindex'); |
||
| 96 | if ($adminindex) { |
||
| 97 | $backlink = XOOPS_URL.'/modules/'.$module->getVar('dirname').'/'.$adminindex; |
||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 101 | $msg[] = '<br /><br /><a href="'.$backlink.'">'._BACK.'</a>'; |
||
| 102 | xoops_cp_header(); |
||
| 103 | xoops_result($msg); |
||
| 104 | xoops_cp_footer(); GIJ */ |
||
| 105 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.