mambax7 /
tdmcreate-1.91
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 namespace XoopsModules\Tdmcreate\Files\Admin; |
||||||
| 2 | |||||||
| 3 | use XoopsModules\Tdmcreate; |
||||||
| 4 | use XoopsModules\Tdmcreate\Files; |
||||||
| 5 | |||||||
| 6 | /* |
||||||
| 7 | You may not change or alter any portion of this comment or credits |
||||||
| 8 | of supporting developers from this source code or any supporting source code |
||||||
| 9 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 10 | |||||||
| 11 | This program is distributed in the hope that it will be useful, |
||||||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 14 | */ |
||||||
| 15 | /** |
||||||
| 16 | * tdmcreate module. |
||||||
| 17 | * |
||||||
| 18 | * @copyright XOOPS Project (https://xoops.org) |
||||||
| 19 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||||
| 20 | * |
||||||
| 21 | * @since 2.5.0 |
||||||
| 22 | * |
||||||
| 23 | * @author Txmod Xoops http://www.txmodxoops.org |
||||||
| 24 | * |
||||||
| 25 | * @version $Id: admin_menu.php 12258 2014-01-02 09:33:29Z timgno $ |
||||||
| 26 | */ |
||||||
| 27 | |||||||
| 28 | /** |
||||||
| 29 | * Class AdminMenu. |
||||||
| 30 | */ |
||||||
| 31 | class AdminMenu extends Files\CreateFile |
||||||
| 32 | { |
||||||
| 33 | /** |
||||||
| 34 | * @public function constructor |
||||||
| 35 | * @param null |
||||||
| 36 | */ |
||||||
| 37 | public function __construct() |
||||||
| 38 | { |
||||||
| 39 | parent::__construct(); |
||||||
| 40 | } |
||||||
| 41 | |||||||
| 42 | /** |
||||||
| 43 | * @static function getInstance |
||||||
| 44 | * @param null |
||||||
| 45 | * @return AdminMenu |
||||||
| 46 | */ |
||||||
| 47 | public static function getInstance() |
||||||
| 48 | { |
||||||
| 49 | static $instance = false; |
||||||
| 50 | if (!$instance) { |
||||||
| 51 | $instance = new self(); |
||||||
| 52 | } |
||||||
| 53 | |||||||
| 54 | return $instance; |
||||||
| 55 | } |
||||||
| 56 | |||||||
| 57 | /** |
||||||
| 58 | * @public function write |
||||||
| 59 | * @param string $module |
||||||
| 60 | * @param string $filename |
||||||
| 61 | */ |
||||||
| 62 | public function write($module, $filename) |
||||||
| 63 | { |
||||||
| 64 | $this->setModule($module); |
||||||
| 65 | $this->setFileName($filename); |
||||||
| 66 | } |
||||||
| 67 | |||||||
| 68 | /** |
||||||
| 69 | * @private function getAdminMenuArray |
||||||
| 70 | * @param $param |
||||||
| 71 | * @param $adminObject |
||||||
| 72 | * @param $ref |
||||||
| 73 | * |
||||||
| 74 | * @return string |
||||||
| 75 | */ |
||||||
| 76 | private function getAdminMenuArray($param = [], $adminObject = false, $ref = false) |
||||||
| 77 | { |
||||||
| 78 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||
| 79 | $ret = ''; |
||||||
| 80 | foreach ($param as $key => $value) { |
||||||
| 81 | if ($adminObject) { |
||||||
| 82 | $ret .= $xc->getXcEqualsOperator("\$adminmenu[\$i]['{$key}']", (string)$value); |
||||||
| 83 | } else { |
||||||
| 84 | if ($ref) { |
||||||
| 85 | $ret .= $xc->getXcEqualsOperator((string)$key, (string)$value, null, true); |
||||||
| 86 | } else { |
||||||
| 87 | $ret .= $xc->getXcEqualsOperator((string)$key, (string)$value); |
||||||
| 88 | } |
||||||
| 89 | } |
||||||
| 90 | } |
||||||
| 91 | |||||||
| 92 | return $ret; |
||||||
| 93 | } |
||||||
| 94 | |||||||
| 95 | /** |
||||||
| 96 | * @private function getAdminMenuHeader |
||||||
| 97 | * @param null |
||||||
| 98 | * @return string |
||||||
| 99 | */ |
||||||
| 100 | private function getAdminMenuHeader() |
||||||
| 101 | { |
||||||
| 102 | $dirname = ['$dirname' => 'basename(dirname(__DIR__))']; |
||||||
| 103 | $ret = $this->getAdminMenuArray($dirname); |
||||||
| 104 | $mod = [ |
||||||
| 105 | '$moduleHandler' => "xoops_getHandler('module')", |
||||||
| 106 | '$xoopsModule' => 'XoopsModule::getByDirname($dirname)', |
||||||
| 107 | '$moduleInfo' => "\$moduleHandler->get(\$xoopsModule->getVar('mid'))", |
||||||
| 108 | ]; |
||||||
| 109 | $ret .= $this->getAdminMenuArray($mod); |
||||||
| 110 | $sys = ['$sysPathIcon32' => "\$moduleInfo->getInfo('sysicons32')"]; |
||||||
| 111 | $ret .= $this->getAdminMenuArray($sys); |
||||||
| 112 | |||||||
| 113 | return $ret; |
||||||
| 114 | } |
||||||
| 115 | |||||||
| 116 | /** |
||||||
| 117 | * @private function getAdminMenuDashboard |
||||||
| 118 | * @param string $language |
||||||
| 119 | * @param int $menu |
||||||
| 120 | * |
||||||
| 121 | * @return string |
||||||
| 122 | */ |
||||||
| 123 | private function getAdminMenuDashboard($language, $menu) |
||||||
| 124 | { |
||||||
| 125 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||
| 126 | $param = ['title' => "{$language}{$menu}", 'link' => "'admin/index.php'", 'icon' => "\$sysPathIcon32.'/dashboard.png'"]; |
||||||
| 127 | $ret = $xc->getXcEqualsOperator('$i', '1'); |
||||||
| 128 | $ret .= $this->getAdminMenuArray($param, true); |
||||||
| 129 | $ret .= $this->getSimpleString('++$i;'); |
||||||
| 130 | |||||||
| 131 | return $ret; |
||||||
| 132 | } |
||||||
| 133 | |||||||
| 134 | /** |
||||||
| 135 | * @private function getAdminMenuImagesPath |
||||||
| 136 | * @param array $tables |
||||||
| 137 | * @param int $t |
||||||
| 138 | * |
||||||
| 139 | * @return string |
||||||
| 140 | */ |
||||||
| 141 | private function getAdminMenuImagesPath($tables, $t) |
||||||
|
0 ignored issues
–
show
|
|||||||
| 142 | { |
||||||
| 143 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||
| 144 | $ret = ''; |
||||||
| 145 | $fields = $this->getTableFields($tables[$t]->getVar('table_id')); |
||||||
|
0 ignored issues
–
show
The call to
XoopsModules\Tdmcreate\F...ields::getTableFields() has too few arguments starting with tId.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||||
| 146 | foreach (array_keys($fields) as $f) { |
||||||
| 147 | $fieldElement = $fields[$f]->getVar('field_element'); |
||||||
| 148 | switch ($fieldElement) { |
||||||
| 149 | case 13: |
||||||
| 150 | $ret = $xc->getXcEqualsOperator("\$adminmenu[\$i]['icon']", "'assets/icons/32/{$tables[$t]->getVar('table_image')}'"); |
||||||
| 151 | break; |
||||||
| 152 | default: |
||||||
| 153 | $ret = $xc->getXcEqualsOperator("\$adminmenu[\$i]['icon']", "\$sysPathIcon32.'/{$tables[$t]->getVar('table_image')}'"); |
||||||
| 154 | break; |
||||||
| 155 | } |
||||||
| 156 | } |
||||||
| 157 | |||||||
| 158 | return $ret; |
||||||
| 159 | } |
||||||
| 160 | |||||||
| 161 | /** |
||||||
| 162 | * @private function getAdminMenuList |
||||||
| 163 | * @param string $module |
||||||
| 164 | * @param string $language |
||||||
| 165 | * @param string $langAbout |
||||||
| 166 | * @param int $menu |
||||||
| 167 | * |
||||||
| 168 | * @return string |
||||||
| 169 | */ |
||||||
| 170 | private function getAdminMenuList($module, $language, $langAbout, $menu) |
||||||
| 171 | { |
||||||
| 172 | $ret = ''; |
||||||
| 173 | $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
||||||
| 174 | foreach (array_keys($tables) as $t) { |
||||||
| 175 | $tablePermissions[] = $tables[$t]->getVar('table_permissions'); |
||||||
| 176 | if (1 == $tables[$t]->getVar('table_admin')) { |
||||||
| 177 | ++$menu; |
||||||
| 178 | $param1 = ['title' => "{$language}{$menu}", 'link' => "'admin/{$tables[$t]->getVar('table_name')}.php'", 'icon' => "'assets/icons/32/{$tables[$t]->getVar('table_image')}'"]; |
||||||
| 179 | $ret .= $this->getAdminMenuArray($param1, true); |
||||||
| 180 | $ret .= $this->getSimpleString('++$i;'); |
||||||
| 181 | } |
||||||
| 182 | } |
||||||
| 183 | if (in_array(1, $tablePermissions)) { |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 184 | ++$menu; |
||||||
| 185 | $param2 = ['title' => "{$language}{$menu}", 'link' => "'admin/permissions.php'", 'icon' => "\$sysPathIcon32.'/permissions.png'"]; |
||||||
| 186 | $ret .= $this->getAdminMenuArray($param2, true); |
||||||
| 187 | $ret .= $this->getSimpleString('++$i;'); |
||||||
| 188 | } |
||||||
| 189 | unset($menu); |
||||||
| 190 | $param3 = ['title' => (string)$langAbout, 'link' => "'admin/about.php'", 'icon' => "\$sysPathIcon32.'/about.png'"]; |
||||||
| 191 | $ret .= $this->getAdminMenuArray($param3, true); |
||||||
| 192 | $ret .= $this->getSimpleString('unset($i);'); |
||||||
| 193 | |||||||
| 194 | return $ret; |
||||||
| 195 | } |
||||||
| 196 | |||||||
| 197 | /** |
||||||
| 198 | * @public function render |
||||||
| 199 | * @param null |
||||||
| 200 | * @return bool|string |
||||||
| 201 | */ |
||||||
| 202 | public function render() |
||||||
| 203 | { |
||||||
| 204 | $module = $this->getModule(); |
||||||
| 205 | $filename = $this->getFileName(); |
||||||
| 206 | $moduleDirname = $module->getVar('mod_dirname'); |
||||||
| 207 | $language = $this->getLanguage($moduleDirname, 'MI', 'ADMENU'); |
||||||
| 208 | $langAbout = $this->getLanguage($moduleDirname, 'MI', 'ABOUT'); |
||||||
| 209 | $menu = 1; |
||||||
| 210 | $content = $this->getHeaderFilesComments($module, $filename); |
||||||
| 211 | $content .= $this->getAdminMenuHeader(); |
||||||
| 212 | $content .= $this->getAdminMenuDashboard($language, $menu); |
||||||
| 213 | $content .= $this->getAdminMenuList($module, $language, $langAbout, $menu); |
||||||
| 214 | |||||||
| 215 | $this->create($moduleDirname, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
||||||
| 216 | |||||||
| 217 | return $this->renderFile(); |
||||||
| 218 | } |
||||||
| 219 | } |
||||||
| 220 |
This check looks for private methods that have been defined, but are not used inside the class.