XoopsModules25x /
xhelp
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 | /* |
||||
| 4 | * You may not change or alter any portion of this comment or credits |
||||
| 5 | * of supporting developers from this source code or any supporting source code |
||||
| 6 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 7 | * |
||||
| 8 | * This program is distributed in the hope that it will be useful, |
||||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 11 | */ |
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
| 15 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||
| 16 | * @author Brian Wahoff <[email protected]> |
||||
| 17 | * @author Eric Juden <[email protected]> |
||||
| 18 | * @author XOOPS Development Team |
||||
| 19 | */ |
||||
| 20 | |||||
| 21 | use Xmf\Request; |
||||
| 22 | use XoopsModules\Xhelp; |
||||
| 23 | |||||
| 24 | if (!defined('XHELP_CONSTANTS_INCLUDED')) { |
||||
| 25 | require_once XOOPS_ROOT_PATH . '/modules/xhelp/include/constants.php'; |
||||
| 26 | } |
||||
| 27 | |||||
| 28 | $helper = Xhelp\Helper::getInstance(); |
||||
| 29 | //require_once XHELP_BASE_PATH . '/functions.php'; |
||||
| 30 | // require_once XHELP_CLASS_PATH . '/session.php'; |
||||
| 31 | $helper->loadLanguage('main'); |
||||
| 32 | |||||
| 33 | /** |
||||
| 34 | * @param array $options |
||||
| 35 | * @return array|false |
||||
| 36 | */ |
||||
| 37 | function b_xhelp_open_show(array $options) |
||||
| 38 | { |
||||
| 39 | global $xoopsUser; |
||||
| 40 | if (!class_exists(Xhelp\Helper::class)) { |
||||
| 41 | return false; |
||||
| 42 | } |
||||
| 43 | $helper = Xhelp\Helper::getInstance(); |
||||
| 44 | |||||
| 45 | $max_char_in_title = $options[0]; |
||||
| 46 | $block = []; |
||||
| 47 | |||||
| 48 | if ($xoopsUser) { |
||||
| 49 | $uid = $xoopsUser->getVar('uid'); // Get uid |
||||
| 50 | /** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */ |
||||
| 51 | $ticketHandler = $helper->getHandler('Ticket'); // Get ticket handler |
||||
| 52 | /** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
||||
| 53 | $staffHandler = $helper->getHandler('Staff'); |
||||
| 54 | $isStaff = $staffHandler->isStaff($xoopsUser->getVar('uid')); |
||||
| 55 | if ($isStaff) { |
||||
| 56 | $criteria = new \CriteriaCompo(new \Criteria('ownership', $uid)); |
||||
| 57 | $criteria->add(new \Criteria('status', '2', '<')); |
||||
| 58 | $criteria->setOrder('DESC'); |
||||
| 59 | $criteria->setSort('priority, posted'); |
||||
| 60 | $criteria->setLimit(5); |
||||
| 61 | $tickets = $ticketHandler->getObjects($criteria); |
||||
| 62 | |||||
| 63 | foreach ($tickets as $ticket) { |
||||
| 64 | $overdue = false; |
||||
| 65 | if ($ticket->isOverdue()) { |
||||
| 66 | $overdue = true; |
||||
| 67 | } |
||||
| 68 | $block['ticket'][] = [ |
||||
| 69 | 'id' => $ticket->getVar('id'), |
||||
| 70 | 'uid' => $ticket->getVar('uid'), |
||||
| 71 | 'subject' => $ticket->getVar('subject'), |
||||
| 72 | 'truncSubject' => xoops_substr($ticket->getVar('subject'), 0, $max_char_in_title), |
||||
| 73 | 'description' => $ticket->getVar('description'), |
||||
| 74 | //'department'=>$department->getVar('department'), |
||||
| 75 | 'priority' => $ticket->getVar('priority'), |
||||
| 76 | 'status' => $ticket->getVar('status'), |
||||
| 77 | 'posted' => $ticket->posted(), |
||||
| 78 | //'ownership'=>$owner->getVar('uname'), |
||||
| 79 | 'closedBy' => $ticket->getVar('closedBy'), |
||||
| 80 | 'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), |
||||
| 81 | //'uname'=>$user->getVar('uname'), |
||||
| 82 | 'userinfo' => XOOPS_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), |
||||
| 83 | //'ownerinfo'=>XOOPS_URL . '/userinfo.php?uid=' . $ticket->getVar('ownership'), |
||||
| 84 | 'url' => XOOPS_URL . '/modules/xhelp/ticket.php?id=' . $ticket->getVar('id'), |
||||
| 85 | 'overdue' => $overdue, |
||||
| 86 | ]; |
||||
| 87 | } |
||||
| 88 | |||||
| 89 | $block['isStaff'] = true; |
||||
| 90 | $block['viewAll'] = XOOPS_URL . '/modules/xhelp/index.php?op=staffViewAll'; |
||||
| 91 | $block['viewAllText'] = _MB_XHELP_TEXT_VIEW_ALL_OPEN; |
||||
| 92 | $block['priorityText'] = _MB_XHELP_TEXT_PRIORITY; |
||||
| 93 | $block['noTickets'] = _MB_XHELP_TEXT_NO_TICKETS; |
||||
| 94 | } else { |
||||
| 95 | $criteria = new \CriteriaCompo(new \Criteria('uid', $uid)); |
||||
| 96 | $criteria->add(new \Criteria('status', '2', '<')); |
||||
| 97 | $criteria->setOrder('DESC'); |
||||
| 98 | $criteria->setSort('priority, posted'); |
||||
| 99 | $criteria->setLimit(5); |
||||
| 100 | $tickets = $ticketHandler->getObjects($criteria); |
||||
| 101 | /** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
||||
| 102 | $departmentHandler = $helper->getHandler('Department'); |
||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||
| 103 | |||||
| 104 | foreach ($tickets as $ticket) { |
||||
| 105 | //$department = $departmentHandler->get($ticket->getVar('department')); |
||||
| 106 | $block['ticket'][] = [ |
||||
| 107 | 'id' => $ticket->getVar('id'), |
||||
| 108 | 'uid' => $ticket->getVar('uid'), |
||||
| 109 | 'subject' => $ticket->getVar('subject'), |
||||
| 110 | 'truncSubject' => xoops_substr($ticket->getVar('subject'), 0, $max_char_in_title), |
||||
| 111 | 'description' => $ticket->getVar('description'), |
||||
| 112 | //'department'=>($department->getVar('department'), |
||||
| 113 | 'priority' => $ticket->getVar('priority'), |
||||
| 114 | 'status' => $ticket->getVar('status'), |
||||
| 115 | 'posted' => $ticket->posted(), |
||||
| 116 | //'ownership'=>$owner->getVar('uname'), |
||||
| 117 | 'closedBy' => $ticket->getVar('closedBy'), |
||||
| 118 | 'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), |
||||
| 119 | //'uname'=>$user->getVar('uname'), |
||||
| 120 | 'userinfo' => XOOPS_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), |
||||
| 121 | //'ownerinfo'=>XOOPS_URL . '/userinfo.php?uid=' . $ticket->getVar('ownership'), |
||||
| 122 | 'url' => XOOPS_URL . '/modules/xhelp/ticket.php?id=' . $ticket->getVar('id'), |
||||
| 123 | ]; |
||||
| 124 | } |
||||
| 125 | } |
||||
| 126 | $block['numTickets'] = count($tickets); |
||||
| 127 | $block['noTickets'] = _MB_XHELP_TEXT_NO_TICKETS; |
||||
| 128 | unset($tickets); |
||||
| 129 | $block['picPath'] = XOOPS_URL . '/modules/xhelp/assets/images/'; |
||||
| 130 | } |
||||
| 131 | return $block; |
||||
| 132 | } |
||||
| 133 | |||||
| 134 | /** |
||||
| 135 | * @param array $options |
||||
| 136 | * @return array|bool |
||||
| 137 | */ |
||||
| 138 | function b_xhelp_performance_show(array $options) |
||||
|
0 ignored issues
–
show
The parameter
$options is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 139 | { |
||||
| 140 | global $xoopsUser, $xoopsDB; |
||||
| 141 | if (!class_exists(Xhelp\Helper::class)) { |
||||
| 142 | return false; |
||||
| 143 | } |
||||
| 144 | $helper = Xhelp\Helper::getInstance(); |
||||
| 145 | $dirname = $helper->getDirname(); |
||||
|
0 ignored issues
–
show
|
|||||
| 146 | $block = []; |
||||
| 147 | |||||
| 148 | if (!$xoopsUser) { |
||||
| 149 | return false; |
||||
| 150 | } |
||||
| 151 | |||||
| 152 | //Determine if the GD library is installed |
||||
| 153 | $block['use_img'] = function_exists('imagecreatefrompng'); |
||||
| 154 | |||||
| 155 | $xoopsModule = Xhelp\Utility::getModule(); |
||||
| 156 | |||||
| 157 | if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { |
||||
| 158 | $sql = sprintf( |
||||
| 159 | 'SELECT COUNT(*) AS TicketCount, d.department, d.id FROM `%s` t INNER JOIN %s d ON t.department = d.id INNER JOIN %s s ON t.status = s.id WHERE s.state = 1 GROUP BY d.department, d.id ORDER BY d.department', |
||||
| 160 | $xoopsDB->prefix('xhelp_tickets'), |
||||
| 161 | $xoopsDB->prefix('xhelp_departments'), |
||||
| 162 | $xoopsDB->prefix('xhelp_status') |
||||
| 163 | ); |
||||
| 164 | } else { |
||||
| 165 | $sql = sprintf( |
||||
| 166 | 'SELECT COUNT(*) AS TicketCount, d.department, d.id FROM `%s` t INNER JOIN %s j ON t.department = j.department INNER JOIN %s d ON t.department = d.id INNER JOIN %s s ON t.status = s.id WHERE s.state = 1 AND j.uid = %u GROUP BY d.department, d.id', |
||||
| 167 | $xoopsDB->prefix('xhelp_tickets'), |
||||
| 168 | $xoopsDB->prefix('xhelp_jstaffdept'), |
||||
| 169 | $xoopsDB->prefix('xhelp_departments'), |
||||
| 170 | $xoopsDB->prefix('xhelp_status'), |
||||
| 171 | $xoopsUser->getVar('uid') |
||||
| 172 | ); |
||||
| 173 | } |
||||
| 174 | |||||
| 175 | $ret = $xoopsDB->query($sql); |
||||
| 176 | |||||
| 177 | $depts = []; |
||||
| 178 | $max_open = 0; |
||||
| 179 | while (false !== ($myrow = $xoopsDB->fetchArray($ret))) { |
||||
| 180 | $max_open = max($max_open, $myrow['TicketCount']); |
||||
| 181 | $url = Xhelp\Utility::createURI(XHELP_BASE_URL . '/index.php', ['op' => 'staffViewAll', 'dept' => $myrow['id'], 'state' => 1]); |
||||
| 182 | $depts[] = [ |
||||
| 183 | 'id' => $myrow['id'], |
||||
| 184 | 'tickets' => $myrow['TicketCount'], |
||||
| 185 | 'name' => $myrow['department'], |
||||
| 186 | 'url' => $url, |
||||
| 187 | ]; |
||||
| 188 | } |
||||
| 189 | |||||
| 190 | if (0 == count($depts)) { |
||||
| 191 | return false; |
||||
| 192 | } |
||||
| 193 | |||||
| 194 | if ($block['use_img']) { |
||||
| 195 | //Retrieve the image path for each department |
||||
| 196 | foreach ($depts as $i => $iValue) { |
||||
| 197 | $depts[$i]['img'] = getDeptImg($iValue['id'], (int)$iValue['tickets'], (int)$max_open, $i); |
||||
| 198 | } |
||||
| 199 | } |
||||
| 200 | |||||
| 201 | $block['departments'] = $depts; |
||||
| 202 | |||||
| 203 | return $block; |
||||
| 204 | } |
||||
| 205 | |||||
| 206 | /** |
||||
| 207 | * @param int|string $dept |
||||
| 208 | * @param int $tickets |
||||
| 209 | * @param int $max |
||||
| 210 | * @param int $counter |
||||
| 211 | * @return string |
||||
| 212 | */ |
||||
| 213 | function getDeptImg($dept, int $tickets, int $max, int $counter = 0): string |
||||
| 214 | { |
||||
| 215 | $dept = (int)$dept; |
||||
| 216 | $tickets = $tickets; |
||||
| 217 | $max = $max; |
||||
| 218 | $counter = $counter; |
||||
| 219 | |||||
| 220 | $width = 60; //Width of resulting image |
||||
| 221 | |||||
| 222 | $cachedir_local = XHELP_CACHE_PATH . '/'; |
||||
| 223 | $cachedir_www = XHELP_CACHE_URL . '/'; |
||||
| 224 | $imgdir = XHELP_IMAGE_PATH . '/'; |
||||
| 225 | $filename = "xhelp_perf_$dept.png"; |
||||
| 226 | |||||
| 227 | $colors = ['green', 'orange', 'red', 'blue']; |
||||
| 228 | |||||
| 229 | if (!is_file($cachedir_local . $filename)) { |
||||
| 230 | //Generate Progress Image |
||||
| 231 | $cur_color = $colors[$counter % count($colors)]; |
||||
| 232 | $bg = @imagecreatefrompng($imgdir . 'dept-bg.png'); |
||||
| 233 | $fill = @imagecreatefrompng($imgdir . "dept-$cur_color.png"); |
||||
| 234 | $bg_cap = @imagecreatefrompng($imgdir . 'dept-bg-cap.png'); |
||||
| 235 | $fill_cap = @imagecreatefrompng($imgdir . 'dept-fill-cap.png'); |
||||
| 236 | $fill_width = round((($width - imagesx($bg_cap)) * $tickets) / $max) - imagesx($fill_cap); |
||||
|
0 ignored issues
–
show
It seems like
$bg_cap can also be of type false; however, parameter $image of imagesx() does only seem to accept GdImage|resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 237 | |||||
| 238 | $image = imagecreatetruecolor($width, imagesy($bg)); |
||||
|
0 ignored issues
–
show
It seems like
$bg can also be of type false; however, parameter $image of imagesy() does only seem to accept GdImage|resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 239 | imagecopy($image, $bg, 0, 0, 0, 0, imagesx($bg), $width - imagesx($bg_cap)); |
||||
|
0 ignored issues
–
show
It seems like
$bg can also be of type false; however, parameter $src_im of imagecopy() does only seem to accept GdImage|resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 240 | imagecopy($image, $bg_cap, $width - imagesx($bg_cap), 0, 0, 0, imagesx($bg_cap), imagesy($bg_cap)); |
||||
| 241 | imagecopy($image, $fill, 0, 0, 0, 0, (int)$fill_width, imagesy($fill)); |
||||
| 242 | imagecopy($image, $fill_cap, (int)$fill_width, 0, 0, 0, imagesx($fill_cap), imagesy($fill_cap)); |
||||
| 243 | |||||
| 244 | imagepng($image, $cachedir_local . $filename); |
||||
| 245 | } |
||||
| 246 | |||||
| 247 | return ($cachedir_www . $filename); |
||||
| 248 | } |
||||
| 249 | |||||
| 250 | /** |
||||
| 251 | * @param array $options |
||||
| 252 | * @return array|bool |
||||
| 253 | */ |
||||
| 254 | function b_xhelp_recent_show(array $options) |
||||
|
0 ignored issues
–
show
The parameter
$options is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 255 | { |
||||
| 256 | if (!isset($_COOKIE['xhelp_recent_tickets'])) { |
||||
| 257 | return false; |
||||
| 258 | } |
||||
| 259 | if (!class_exists(Xhelp\Helper::class)) { |
||||
| 260 | return false; |
||||
| 261 | } |
||||
| 262 | $helper = Xhelp\Helper::getInstance(); |
||||
| 263 | |||||
| 264 | $tmp = $_COOKIE['xhelp_recent_tickets']; |
||||
| 265 | |||||
| 266 | $block = []; |
||||
| 267 | |||||
| 268 | if ('' != $tmp) { |
||||
| 269 | $tmp2 = explode(',', $tmp); |
||||
| 270 | |||||
| 271 | $criteria = new \Criteria('id', '(' . $tmp . ')', 'IN', 't'); |
||||
| 272 | /** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */ |
||||
| 273 | $ticketHandler = $helper->getHandler('Ticket'); |
||||
| 274 | $tickets = $ticketHandler->getObjects($criteria, true); |
||||
| 275 | |||||
| 276 | foreach ($tmp2 as $ele) { |
||||
| 277 | if (isset($tickets[(int)$ele])) { |
||||
| 278 | $ticket = $tickets[(int)$ele]; |
||||
| 279 | |||||
| 280 | $overdue = false; |
||||
| 281 | if ($ticket->isOverdue()) { |
||||
| 282 | $overdue = true; |
||||
| 283 | } |
||||
| 284 | |||||
| 285 | $block['tickets'][] = [ |
||||
| 286 | 'id' => $ticket->getVar('id'), |
||||
| 287 | 'trim_subject' => xoops_substr($ticket->getVar('subject'), 0, 25), |
||||
| 288 | 'subject' => $ticket->getVar('subject'), |
||||
| 289 | 'url' => XOOPS_URL . '/modules/xhelp/ticket.php?id=' . $ticket->getVar('id'), |
||||
| 290 | 'overdue' => $overdue, |
||||
| 291 | ]; |
||||
| 292 | } |
||||
| 293 | } |
||||
| 294 | $block['ticketcount'] = count($tickets); |
||||
| 295 | |||||
| 296 | return $block; |
||||
| 297 | } |
||||
| 298 | |||||
| 299 | return false; |
||||
| 300 | } |
||||
| 301 | |||||
| 302 | /** |
||||
| 303 | * @return bool|array |
||||
| 304 | */ |
||||
| 305 | function b_xhelp_actions_show() |
||||
| 306 | { |
||||
| 307 | // $session = new Xhelp\Session(); |
||||
| 308 | $session = Xhelp\Session::getInstance(); |
||||
|
0 ignored issues
–
show
|
|||||
| 309 | global $ticketInfo, $xoopsUser, $xoopsModule, $ticketInfo, $staff, $xoopsConfig; |
||||
| 310 | if (!class_exists(Xhelp\Helper::class)) { |
||||
| 311 | return false; |
||||
| 312 | } |
||||
| 313 | $helper = Xhelp\Helper::getInstance(); |
||||
| 314 | |||||
| 315 | /** @var \XoopsModuleHandler $moduleHandler */ |
||||
| 316 | $moduleHandler = xoops_getHandler('module'); |
||||
|
0 ignored issues
–
show
|
|||||
| 317 | /** @var \XoopsConfigHandler $configHandler */ |
||||
| 318 | $configHandler = xoops_getHandler('config'); |
||||
|
0 ignored issues
–
show
|
|||||
| 319 | /** @var \XoopsMemberHandler $memberHandler */ |
||||
| 320 | $memberHandler = xoops_getHandler('member'); |
||||
|
0 ignored issues
–
show
|
|||||
| 321 | $ticketHandler = $helper->getHandler('Ticket'); |
||||
| 322 | /** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
||||
| 323 | $membershipHandler = $helper->getHandler('Membership'); |
||||
|
0 ignored issues
–
show
|
|||||
| 324 | /** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
||||
| 325 | $staffHandler = $helper->getHandler('Staff'); |
||||
| 326 | /** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
||||
| 327 | $departmentHandler = $helper->getHandler('Department'); |
||||
| 328 | |||||
| 329 | //Don't show block for anonymous users or for non-staff members |
||||
| 330 | if (!$xoopsUser) { |
||||
| 331 | return false; |
||||
| 332 | } |
||||
| 333 | |||||
| 334 | //Don't show block if outside the xhelp module' |
||||
| 335 | if (null === $xoopsModule || 'xhelp' !== $xoopsModule->getVar('dirname')) { |
||||
| 336 | return false; |
||||
| 337 | } |
||||
| 338 | |||||
| 339 | $block = []; |
||||
| 340 | |||||
| 341 | $myPage = $_SERVER['SCRIPT_NAME']; |
||||
| 342 | $currentPage = mb_substr(mb_strrchr($myPage, '/'), 1); |
||||
| 343 | if (('ticket.php' !== $currentPage) || (2 != $helper->getConfig('xhelp_staffTicketActions'))) { |
||||
| 344 | return false; |
||||
| 345 | } |
||||
| 346 | |||||
| 347 | if (Request::hasVar('id', 'GET')) { |
||||
| 348 | $block['ticketid'] = Request::getInt('id', 0, 'GET'); |
||||
| 349 | } else { |
||||
| 350 | return false; |
||||
| 351 | } |
||||
| 352 | |||||
| 353 | //Use Global $ticketInfo object (if exists) |
||||
| 354 | if (null === $ticketInfo) { |
||||
| 355 | $ticketInfo = $ticketHandler->get($block['ticketid']); |
||||
| 356 | } |
||||
| 357 | |||||
| 358 | if (2 == $helper->getConfig('xhelp_staffTicketActions')) { |
||||
| 359 | $aOwnership = []; |
||||
| 360 | $aOwnership[] = [ |
||||
| 361 | 'uid' => 0, |
||||
| 362 | 'uname' => _XHELP_NO_OWNER, |
||||
| 363 | ]; |
||||
| 364 | if (null !== $staff) { |
||||
| 365 | foreach ($staff as $stf) { |
||||
| 366 | //** BTW - Need to have a way to get all XoopsUser objects for the staff in 1 shot |
||||
| 367 | //$own = $memberHandler->getUser($stf->getVar('uid')); // Create user object |
||||
| 368 | $aOwnership[] = [ |
||||
| 369 | 'uid' => $stf->getVar('uid'), |
||||
| 370 | 'uname' => '', |
||||
| 371 | ]; |
||||
| 372 | $all_users[$stf->getVar('uid')] = ''; |
||||
| 373 | } |
||||
| 374 | } else { |
||||
| 375 | return false; |
||||
| 376 | } |
||||
| 377 | |||||
| 378 | /** @var \XoopsMySQLDatabase $xoopsDB */ |
||||
| 379 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||
| 380 | $users = []; |
||||
| 381 | |||||
| 382 | //@Todo - why is this query here instead of using a function or the XoopsMemberHandler? |
||||
| 383 | $sql = sprintf('SELECT uid, uname, name FROM `%s` WHERE uid IN (%s)', $xoopsDB->prefix('users'), implode(',', array_keys($all_users))); |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 384 | $ret = $xoopsDB->query($sql); |
||||
| 385 | $displayName = $helper->getConfig('xhelp_displayName'); |
||||
| 386 | while (false !== ($member = $xoopsDB->fetchArray($ret))) { |
||||
|
0 ignored issues
–
show
It seems like
$ret can also be of type boolean; however, parameter $result of XoopsMySQLDatabase::fetchArray() does only seem to accept mysqli_result, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 387 | if ((2 == $displayName) && ('' != $member['name'])) { |
||||
| 388 | $users[$member['uid']] = $member['name']; |
||||
| 389 | } else { |
||||
| 390 | $users[$member['uid']] = $member['uname']; |
||||
| 391 | } |
||||
| 392 | } |
||||
| 393 | |||||
| 394 | foreach ($aOwnership as $i => $iValue) { |
||||
| 395 | if (isset($users[$iValue['uid']])) { |
||||
| 396 | $aOwnership[$i]['uname'] = $users[$iValue['uid']]; |
||||
| 397 | } |
||||
| 398 | } |
||||
| 399 | $block['ownership'] = $aOwnership; |
||||
| 400 | } |
||||
| 401 | |||||
| 402 | $block['imagePath'] = XHELP_IMAGE_URL . '/'; |
||||
| 403 | $block['xhelp_priorities'] = [1, 2, 3, 4, 5]; |
||||
| 404 | $block['xhelp_priorities_desc'] = [ |
||||
| 405 | 5 => _XHELP_PRIORITY5, |
||||
| 406 | 4 => _XHELP_PRIORITY4, |
||||
| 407 | 3 => _XHELP_PRIORITY3, |
||||
| 408 | 2 => _XHELP_PRIORITY2, |
||||
| 409 | 1 => _XHELP_PRIORITY1, |
||||
| 410 | ]; |
||||
| 411 | $block['ticket_priority'] = $ticketInfo->getVar('priority'); |
||||
| 412 | $block['ticket_status'] = $ticketInfo->getVar('status'); |
||||
| 413 | $block['xhelp_status0'] = _XHELP_STATUS0; |
||||
| 414 | $block['xhelp_status1'] = _XHELP_STATUS1; |
||||
| 415 | $block['xhelp_status2'] = _XHELP_STATUS2; |
||||
| 416 | $block['ticket_ownership'] = $ticketInfo->getVar('ownership'); |
||||
| 417 | |||||
| 418 | $block['xhelp_has_changeOwner'] = false; |
||||
| 419 | if ($ticketInfo->getVar('uid') == $xoopsUser->getVar('uid')) { |
||||
| 420 | $block['xhelp_has_addResponse'] = true; |
||||
| 421 | } else { |
||||
| 422 | $block['xhelp_has_addResponse'] = false; |
||||
| 423 | } |
||||
| 424 | $block['xhelp_has_editTicket'] = false; |
||||
| 425 | $block['xhelp_has_deleteTicket'] = false; |
||||
| 426 | $block['xhelp_has_changePriority'] = false; |
||||
| 427 | $block['xhelp_has_changeStatus'] = false; |
||||
| 428 | $block['xhelp_has_editResponse'] = false; |
||||
| 429 | $block['xhelp_has_mergeTicket'] = false; |
||||
| 430 | $rowspan = 2; |
||||
| 431 | $checkRights = [ |
||||
| 432 | XHELP_SEC_TICKET_OWNERSHIP => ['xhelp_has_changeOwner', false], |
||||
| 433 | XHELP_SEC_RESPONSE_ADD => ['xhelp_has_addResponse', false], |
||||
| 434 | XHELP_SEC_TICKET_EDIT => ['xhelp_has_editTicket', true], |
||||
| 435 | XHELP_SEC_TICKET_DELETE => ['xhelp_has_deleteTicket', true], |
||||
| 436 | XHELP_SEC_TICKET_MERGE => ['xhelp_has_mergeTicket', true], |
||||
| 437 | XHELP_SEC_TICKET_PRIORITY => ['xhelp_has_changePriority', false], |
||||
| 438 | XHELP_SEC_TICKET_STATUS => ['xhelp_has_changeStatus', false], |
||||
| 439 | XHELP_SEC_RESPONSE_EDIT => ['xhelp_has_editResponse', false], |
||||
| 440 | XHELP_SEC_FILE_DELETE => ['xhelp_has_deleteFile', false], |
||||
| 441 | XHELP_SEC_FAQ_ADD => ['xhelp_has_addFaq', false], |
||||
| 442 | XHELP_SEC_TICKET_TAKE_OWNERSHIP => ['xhelp_has_takeOwnership', false], |
||||
| 443 | ]; |
||||
| 444 | |||||
| 445 | $staff = $staffHandler->getByUid($xoopsUser->getVar('uid')); |
||||
| 446 | // See if this user is accepted for this ticket |
||||
| 447 | /** @var \XoopsModules\Xhelp\TicketEmailsHandler $ticketEmailsHandler */ |
||||
| 448 | $ticketEmailsHandler = $helper->getHandler('TicketEmails'); |
||||
| 449 | $criteria = new \CriteriaCompo(new \Criteria('ticketid', $ticketInfo->getVar('id'))); |
||||
| 450 | $criteria->add(new \Criteria('uid', $xoopsUser->getVar('uid'))); |
||||
| 451 | $ticketEmails = $ticketEmailsHandler->getObjects($criteria); |
||||
| 452 | |||||
| 453 | //Retrieve all departments |
||||
| 454 | $criteria = new \Criteria('', ''); |
||||
| 455 | $criteria->setSort('department'); |
||||
| 456 | $alldepts = $departmentHandler->getObjects($criteria); |
||||
| 457 | $aDept = []; |
||||
| 458 | foreach ($alldepts as $dept) { |
||||
| 459 | $aDept[$dept->getVar('id')] = $dept->getVar('department'); |
||||
| 460 | } |
||||
| 461 | unset($alldepts); |
||||
| 462 | $block['departments'] = $aDept; |
||||
| 463 | $block['departmentid'] = $ticketInfo->getVar('department'); |
||||
| 464 | |||||
| 465 | foreach ($checkRights as $right => $desc) { |
||||
| 466 | if ((XHELP_SEC_RESPONSE_ADD == $right) && count($ticketEmails) > 0) { |
||||
| 467 | $block[$desc[0]] = true; |
||||
| 468 | continue; |
||||
| 469 | } |
||||
| 470 | if ((XHELP_SEC_TICKET_STATUS == $right) && count($ticketEmails) > 0) { |
||||
| 471 | $block[$desc[0]] = true; |
||||
| 472 | continue; |
||||
| 473 | } |
||||
| 474 | $hasRights = $staff->checkRoleRights($right, $ticketInfo->getVar('department')); |
||||
| 475 | if ($hasRights) { |
||||
| 476 | $block[$desc[0]] = true; |
||||
| 477 | if ($desc[1]) { |
||||
| 478 | ++$rowspan; |
||||
| 479 | } |
||||
| 480 | } |
||||
| 481 | } |
||||
| 482 | |||||
| 483 | $block['xhelp_actions_rowspan'] = $rowspan; |
||||
| 484 | |||||
| 485 | /** @var \XoopsModules\Xhelp\StatusHandler $statusHandler */ |
||||
| 486 | $statusHandler = $helper->getHandler('Status'); |
||||
| 487 | $criteria = new \Criteria('', ''); |
||||
| 488 | $criteria->setSort('description'); |
||||
| 489 | $criteria->setOrder('ASC'); |
||||
| 490 | $statuses = $statusHandler->getObjects($criteria); |
||||
| 491 | $aStatuses = []; |
||||
| 492 | foreach ($statuses as $status) { |
||||
| 493 | $aStatuses[$status->getVar('id')] = [ |
||||
| 494 | 'id' => $status->getVar('id'), |
||||
| 495 | 'desc' => $status->getVar('description'), |
||||
| 496 | 'state' => $status->getVar('state'), |
||||
| 497 | ]; |
||||
| 498 | } |
||||
| 499 | |||||
| 500 | $block['statuses'] = $aStatuses; |
||||
| 501 | |||||
| 502 | return $block; |
||||
| 503 | } |
||||
| 504 | |||||
| 505 | /** |
||||
| 506 | * @param array $options |
||||
| 507 | * @return string |
||||
| 508 | */ |
||||
| 509 | function b_xhelp_actions_edit(array $options): string |
||||
| 510 | { |
||||
| 511 | $form = '<table>'; |
||||
| 512 | $form .= '<tr>'; |
||||
| 513 | $form .= '<td>' . _MB_XHELP_TRUNCATE_TITLE . '</td>'; |
||||
| 514 | $form .= '<td>' . "<input type='text' name='options[]' value='" . $options[0] . "'></td>"; |
||||
| 515 | $form .= '</tr>'; |
||||
| 516 | $form .= '</table>'; |
||||
| 517 | |||||
| 518 | return $form; |
||||
| 519 | } |
||||
| 520 | |||||
| 521 | /** |
||||
| 522 | * @param array $options |
||||
| 523 | * @return array|false |
||||
| 524 | */ |
||||
| 525 | function b_xhelp_mainactions_show(array $options) |
||||
| 526 | { |
||||
| 527 | global $xoopsUser, $xhelp_isStaff; |
||||
| 528 | if (!class_exists(Xhelp\Helper::class)) { |
||||
| 529 | return false; |
||||
| 530 | } |
||||
| 531 | $helper = Xhelp\Helper::getInstance(); |
||||
| 532 | // @todo - use the constant here if possible instead of the raw string |
||||
| 533 | $dirname = $helper->getDirname(); |
||||
|
0 ignored issues
–
show
|
|||||
| 534 | $block['linkPath'] = XHELP_BASE_URL . '/'; |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 535 | $block['imagePath'] = XHELP_IMAGE_URL . '/'; |
||||
| 536 | $block['menustyle'] = $options[0]; |
||||
| 537 | $block['showicon'] = !$block['menustyle'] && $options[1]; |
||||
| 538 | $block['startitem'] = !$block['menustyle'] ? '<li>' : ''; |
||||
| 539 | $block['enditem'] = !$block['menustyle'] ? '</li>' : ''; |
||||
| 540 | $block['startblock'] = !$block['menustyle'] ? '<ul>' : '<table cellspacing="0"><tr><td id="usermenu">'; |
||||
| 541 | $block['endblock'] = !$block['menustyle'] ? '</ul>' : '</td></tr></table>'; |
||||
| 542 | $block['savedSearches'] = false; |
||||
| 543 | $block['items'][0] = [ |
||||
| 544 | 'link' => 'anon_addTicket.php', |
||||
| 545 | 'image' => 'addTicket.png', |
||||
| 546 | 'text' => _XHELP_MENU_LOG_TICKET, |
||||
| 547 | ]; |
||||
| 548 | |||||
| 549 | if ($xoopsUser) { |
||||
| 550 | $block['items'][0] = ['link' => 'index.php', 'image' => 'main.png', 'text' => _XHELP_MENU_MAIN]; |
||||
| 551 | $block['items'][1] = [ |
||||
| 552 | 'link' => 'addTicket.php', |
||||
| 553 | 'image' => 'addTicket.png', |
||||
| 554 | 'text' => _XHELP_MENU_LOG_TICKET, |
||||
| 555 | ]; |
||||
| 556 | $block['items'][2] = [ |
||||
| 557 | 'link' => 'index.php?viewAllTickets=1&op=userViewAll', |
||||
| 558 | 'image' => 'ticket.png', |
||||
| 559 | 'text' => _XHELP_MENU_ALL_TICKETS, |
||||
| 560 | ]; |
||||
| 561 | /** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
||||
| 562 | $staffHandler = $helper->getHandler('Staff'); |
||||
| 563 | $staff = $staffHandler->getByUid($xoopsUser->getVar('uid')); |
||||
| 564 | if ($staff) { |
||||
| 565 | $block['whoami'] = 'staff'; |
||||
| 566 | $block['items'][3] = ['link' => 'search.php', 'image' => 'search2.png', 'text' => _XHELP_MENU_SEARCH]; |
||||
| 567 | $block['items'][4] = [ |
||||
| 568 | 'link' => 'profile.php', |
||||
| 569 | 'image' => 'profile.png', |
||||
| 570 | 'text' => _XHELP_MENU_MY_PROFILE, |
||||
| 571 | ]; |
||||
| 572 | $block['items'][2] = [ |
||||
| 573 | 'link' => 'index.php?viewAllTickets=1&op=staffViewAll', |
||||
| 574 | 'image' => 'ticket.png', |
||||
| 575 | 'text' => _XHELP_MENU_ALL_TICKETS, |
||||
| 576 | ]; |
||||
| 577 | /** @var \XoopsModules\Xhelp\SavedSearchHandler $savedSearchHandler */ |
||||
| 578 | $savedSearchHandler = $helper->getHandler('SavedSearch'); |
||||
| 579 | $savedSearches = $savedSearchHandler->getByUid($xoopsUser->getVar('uid')); |
||||
| 580 | $aSavedSearches = []; |
||||
| 581 | foreach ($savedSearches as $sSearch) { |
||||
| 582 | $aSavedSearches[$sSearch->getVar('id')] = [ |
||||
| 583 | 'id' => $sSearch->getVar('id'), |
||||
| 584 | 'name' => $sSearch->getVar('name'), |
||||
| 585 | 'search' => $sSearch->getVar('search'), |
||||
| 586 | 'pagenav_vars' => $sSearch->getVar('pagenav_vars'), |
||||
| 587 | ]; |
||||
| 588 | } |
||||
| 589 | $block['savedSearches'] = (count($aSavedSearches) < 1) ? false : $aSavedSearches; |
||||
| 590 | } |
||||
| 591 | } |
||||
| 592 | |||||
| 593 | return $block; |
||||
| 594 | } |
||||
| 595 | |||||
| 596 | /** |
||||
| 597 | * @param array $options |
||||
| 598 | * @return string |
||||
| 599 | */ |
||||
| 600 | function b_xhelp_mainactions_edit(array $options): string |
||||
| 601 | { |
||||
| 602 | $form = "<table border='0'>"; |
||||
| 603 | |||||
| 604 | // Menu style |
||||
| 605 | $form .= '<tr><td>' . _MB_XHELP_TEXT_MENUSTYLE . '</td><td>'; |
||||
| 606 | $form .= "<input type='radio' name='options[0]' value='0'" . ((0 == $options[0]) ? ' checked' : '') . '>' . _MB_XHELP_OPTION_MENUSTYLE1 . ''; |
||||
| 607 | $form .= "<input type='radio' name='options[0]' value='1'" . ((1 == $options[0]) ? ' checked' : '') . '>' . _MB_XHELP_OPTION_MENUSTYLE2 . '</td></tr>'; |
||||
| 608 | |||||
| 609 | // Auto select last items |
||||
| 610 | $form .= '<tr><td>' . _MB_XHELP_TEXT_SHOWICON . '</td><td>'; |
||||
| 611 | $form .= "<input type='radio' name='options[1]' value='0'" . ((0 == $options[1]) ? ' checked' : '') . '>' . _NO . ''; |
||||
| 612 | $form .= "<input type='radio' name='options[1]' value='1'" . ((1 == $options[1]) ? ' checked' : '') . '>' . _YES . '</td></tr>'; |
||||
| 613 | |||||
| 614 | $form .= '</table>'; |
||||
| 615 | |||||
| 616 | return $form; |
||||
| 617 | } |
||||
| 618 |