| Total Complexity | 92 |
| Total Lines | 652 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Faq often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Faq, and based on these observations, apply Extract Interface, too.
| 1 | <?php namespace XoopsModules\Smartfaq; |
||
| 21 | class Faq extends \XoopsObject |
||
|
|
|||
| 22 | { |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var Smartfaq\Category |
||
| 26 | * @access private |
||
| 27 | */ |
||
| 28 | private $category = null; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var Answer |
||
| 32 | * @access private |
||
| 33 | */ |
||
| 34 | private $answer = null; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var array |
||
| 38 | * @access private |
||
| 39 | */ |
||
| 40 | private $_notifications = null; |
||
| 41 | // TODO : Create a seperated class for notifications |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var array |
||
| 45 | * @access private |
||
| 46 | */ |
||
| 47 | private $groups_read = null; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var object |
||
| 51 | * @access private |
||
| 52 | */ |
||
| 53 | // Is this still usefull?? |
||
| 54 | private $_smartModule = null; |
||
| 55 | private $_smartModuleConfig; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * constructor |
||
| 59 | * @param null $id |
||
| 60 | */ |
||
| 61 | public function __construct($id = null) |
||
| 62 | { |
||
| 63 | $this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 64 | $this->initVar('faqid', XOBJ_DTYPE_INT, -1, false); |
||
| 65 | $this->initVar('categoryid', XOBJ_DTYPE_INT, 0, false); |
||
| 66 | $this->initVar('question', XOBJ_DTYPE_TXTBOX, null, true, 100000); |
||
| 67 | $this->initVar('howdoi', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 68 | $this->initVar('diduno', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 69 | $this->initVar('uid', XOBJ_DTYPE_INT, 0, false); |
||
| 70 | $this->initVar('datesub', XOBJ_DTYPE_INT, null, false); |
||
| 71 | $this->initVar('status', XOBJ_DTYPE_INT, -1, false); |
||
| 72 | $this->initVar('counter', XOBJ_DTYPE_INT, 0, false); |
||
| 73 | $this->initVar('weight', XOBJ_DTYPE_INT, 0, false); |
||
| 74 | $this->initVar('html', XOBJ_DTYPE_INT, 1, false); |
||
| 75 | $this->initVar('smiley', XOBJ_DTYPE_INT, 1, false); |
||
| 76 | $this->initVar('image', XOBJ_DTYPE_INT, 1, false); |
||
| 77 | $this->initVar('linebreak', XOBJ_DTYPE_INT, 1, false); |
||
| 78 | $this->initVar('xcodes', XOBJ_DTYPE_INT, 1, false); |
||
| 79 | $this->initVar('cancomment', XOBJ_DTYPE_INT, 1, false); |
||
| 80 | $this->initVar('comments', XOBJ_DTYPE_INT, 0, false); |
||
| 81 | $this->initVar('notifypub', XOBJ_DTYPE_INT, 1, false); |
||
| 82 | $this->initVar('modulelink', XOBJ_DTYPE_TXTBOX, 'None', false, 50); |
||
| 83 | $this->initVar('contextpage', XOBJ_DTYPE_TXTBOX, null, false, 255); |
||
| 84 | $this->initVar('exacturl', XOBJ_DTYPE_INT, 0, false); |
||
| 85 | $this->initVar('partialview', XOBJ_DTYPE_INT, 0, false); |
||
| 86 | |||
| 87 | if (null !== $id) { |
||
| 88 | $faqHandler = new Smartfaq\FaqHandler($this->db); |
||
| 89 | $faq = $faqHandler->get($id); |
||
| 90 | foreach ($faq->vars as $k => $v) { |
||
| 91 | $this->assignVar($k, $v['value']); |
||
| 92 | } |
||
| 93 | $this->assignOtherProperties(); |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | public function assignOtherProperties() |
||
| 98 | { |
||
| 99 | $smartModule = Smartfaq\Utility::getModuleInfo(); |
||
| 100 | $module_id = $smartModule->getVar('mid'); |
||
| 101 | |||
| 102 | $gpermHandler = xoops_getHandler('groupperm'); |
||
| 103 | |||
| 104 | $this->category = new Smartfaq\Category($this->getVar('categoryid')); |
||
| 105 | $this->groups_read = $gpermHandler->getGroupIds('item_read', $this->faqid(), $module_id); |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @return bool |
||
| 110 | */ |
||
| 111 | public function checkPermission() |
||
| 112 | { |
||
| 113 | // require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php'; |
||
| 114 | |||
| 115 | $userIsAdmin = Smartfaq\Utility::userIsAdmin(); |
||
| 116 | if ($userIsAdmin) { |
||
| 117 | return true; |
||
| 118 | } |
||
| 119 | /** @var \XoopsModules\Smartfaq\PermissionHandler $smartPermHandler */ |
||
| 120 | $smartPermHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Permission'); |
||
| 121 | // $smartPermHandler = xoops_getModuleHandler('permission', 'smartfaq'); |
||
| 122 | |||
| 123 | $faqsGranted = $smartPermHandler->getPermissions('item'); |
||
| 124 | if (in_array($this->categoryid(), $faqsGranted)) { |
||
| 125 | $ret = true; |
||
| 126 | } |
||
| 127 | |||
| 128 | return $ret; |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @return array |
||
| 133 | */ |
||
| 134 | public function getGroups_read() |
||
| 135 | { |
||
| 136 | if (count($this->groups_read) < 1) { |
||
| 137 | $this->assignOtherProperties(); |
||
| 138 | } |
||
| 139 | |||
| 140 | return $this->groups_read; |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @param array $groups_read |
||
| 145 | */ |
||
| 146 | public function setGroups_read($groups_read = ['0']) |
||
| 147 | { |
||
| 148 | $this->groups_read = $groups_read; |
||
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @return mixed |
||
| 153 | */ |
||
| 154 | public function faqid() |
||
| 155 | { |
||
| 156 | return $this->getVar('faqid'); |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @return mixed |
||
| 161 | */ |
||
| 162 | public function categoryid() |
||
| 163 | { |
||
| 164 | return $this->getVar('categoryid'); |
||
| 165 | } |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @return Smartfaq\Category |
||
| 169 | */ |
||
| 170 | public function category() |
||
| 171 | { |
||
| 172 | return $this->category; |
||
| 173 | } |
||
| 174 | |||
| 175 | /** |
||
| 176 | * @param int $maxLength |
||
| 177 | * @param string $format |
||
| 178 | * @return mixed|string |
||
| 179 | */ |
||
| 180 | public function question($maxLength = 0, $format = 'S') |
||
| 181 | { |
||
| 182 | $ret = $this->getVar('question', $format); |
||
| 183 | if (('s' === $format) || ('S' === $format) || ('show' === $format)) { |
||
| 184 | $myts = \MyTextSanitizer::getInstance(); |
||
| 185 | $ret = $myts->displayTarea($ret); |
||
| 186 | } |
||
| 187 | if (0 != $maxLength) { |
||
| 188 | if (!XOOPS_USE_MULTIBYTES) { |
||
| 189 | if (strlen($ret) >= $maxLength) { |
||
| 190 | $ret = substr($ret, 0, $maxLength - 1) . '...'; |
||
| 191 | } |
||
| 192 | } |
||
| 193 | } |
||
| 194 | |||
| 195 | return $ret; |
||
| 196 | } |
||
| 197 | |||
| 198 | /** |
||
| 199 | * @param string $format |
||
| 200 | * @return mixed |
||
| 201 | */ |
||
| 202 | public function howdoi($format = 'S') |
||
| 203 | { |
||
| 204 | $ret = $this->getVar('howdoi', $format); |
||
| 205 | if (('s' === $format) || ('S' === $format) || ('show' === $format)) { |
||
| 206 | $myts = \MyTextSanitizer::getInstance(); |
||
| 207 | $ret = $myts->displayTarea($ret); |
||
| 208 | } |
||
| 209 | |||
| 210 | return $ret; |
||
| 211 | } |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @param string $format |
||
| 215 | * @return mixed |
||
| 216 | */ |
||
| 217 | public function diduno($format = 'S') |
||
| 218 | { |
||
| 219 | $ret = $this->getVar('diduno', $format); |
||
| 220 | if (('s' === $format) || ('S' === $format) || ('show' === $format)) { |
||
| 221 | $myts = \MyTextSanitizer::getInstance(); |
||
| 222 | $ret = $myts->displayTarea($ret); |
||
| 223 | } |
||
| 224 | |||
| 225 | return $ret; |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @return mixed |
||
| 230 | */ |
||
| 231 | public function uid() |
||
| 232 | { |
||
| 233 | return $this->getVar('uid'); |
||
| 234 | } |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @param string $dateFormat |
||
| 238 | * @param string $format |
||
| 239 | * @return string |
||
| 240 | */ |
||
| 241 | public function datesub($dateFormat = 'none', $format = 'S') |
||
| 242 | { |
||
| 243 | if ('none' === $dateFormat) { |
||
| 244 | $smartConfig = Smartfaq\Utility::getModuleConfig(); |
||
| 245 | $dateFormat = $smartConfig['dateformat']; |
||
| 246 | } |
||
| 247 | |||
| 248 | return formatTimestamp($this->getVar('datesub', $format), $dateFormat); |
||
| 249 | } |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @return mixed |
||
| 253 | */ |
||
| 254 | public function status() |
||
| 255 | { |
||
| 256 | return $this->getVar('status'); |
||
| 257 | } |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @return mixed |
||
| 261 | */ |
||
| 262 | public function counter() |
||
| 263 | { |
||
| 264 | return $this->getVar('counter'); |
||
| 265 | } |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @return mixed |
||
| 269 | */ |
||
| 270 | public function weight() |
||
| 271 | { |
||
| 272 | return $this->getVar('weight'); |
||
| 273 | } |
||
| 274 | |||
| 275 | /** |
||
| 276 | * @return mixed |
||
| 277 | */ |
||
| 278 | public function html() |
||
| 279 | { |
||
| 280 | return $this->getVar('html'); |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * @return mixed |
||
| 285 | */ |
||
| 286 | public function smiley() |
||
| 287 | { |
||
| 288 | return $this->getVar('smiley'); |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @return mixed |
||
| 293 | */ |
||
| 294 | public function xcodes() |
||
| 295 | { |
||
| 296 | return $this->getVar('xcodes'); |
||
| 297 | } |
||
| 298 | |||
| 299 | /** |
||
| 300 | * @return mixed |
||
| 301 | */ |
||
| 302 | public function cancomment() |
||
| 305 | } |
||
| 306 | |||
| 307 | /** |
||
| 308 | * @return mixed |
||
| 309 | */ |
||
| 310 | public function comments() |
||
| 311 | { |
||
| 312 | return $this->getVar('comments'); |
||
| 313 | } |
||
| 314 | |||
| 315 | /** |
||
| 316 | * @return mixed |
||
| 317 | */ |
||
| 318 | public function notifypub() |
||
| 319 | { |
||
| 320 | return $this->getVar('notifypub'); |
||
| 321 | } |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @param string $format |
||
| 325 | * @return mixed |
||
| 326 | */ |
||
| 327 | public function modulelink($format = 'S') |
||
| 328 | { |
||
| 329 | return $this->getVar('modulelink', $format); |
||
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @param string $format |
||
| 334 | * @return mixed |
||
| 335 | */ |
||
| 336 | public function contextpage($format = 'S') |
||
| 337 | { |
||
| 338 | return $this->getVar('contextpage', $format); |
||
| 339 | } |
||
| 340 | |||
| 341 | /** |
||
| 342 | * @return mixed |
||
| 343 | */ |
||
| 344 | public function exacturl() |
||
| 345 | { |
||
| 346 | return $this->getVar('exacturl'); |
||
| 347 | } |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @return mixed |
||
| 351 | */ |
||
| 352 | public function partialview() |
||
| 353 | { |
||
| 354 | return $this->getVar('partialview'); |
||
| 355 | } |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @param int $realName |
||
| 359 | * @return string |
||
| 360 | */ |
||
| 361 | public function posterName($realName = -1) |
||
| 362 | { |
||
| 363 | if (-1 == $realName) { |
||
| 364 | $smartConfig = Smartfaq\Utility::getModuleConfig(); |
||
| 365 | $realName = $smartConfig['userealname']; |
||
| 366 | } |
||
| 367 | |||
| 368 | return Smartfaq\Utility::getLinkedUnameFromId($this->uid(), $realName); |
||
| 369 | } |
||
| 370 | |||
| 371 | /** |
||
| 372 | * @return mixed|object|Smartfaq\Answer |
||
| 373 | */ |
||
| 374 | public function answer() |
||
| 375 | { |
||
| 376 | $answerHandler = new Smartfaq\AnswerHandler($this->db); |
||
| 377 | switch ($this->status()) { |
||
| 378 | case Constants::SF_STATUS_SUBMITTED: |
||
| 379 | $theAnswers = $answerHandler->getAllAnswers($this->faqid(), Constants::SF_AN_STATUS_APPROVED, 1, 0); |
||
| 380 | //echo "test"; |
||
| 381 | //exit; |
||
| 382 | $this->answer =& $theAnswers[0]; |
||
| 383 | break; |
||
| 384 | |||
| 385 | case Constants::SF_STATUS_ANSWERED: |
||
| 386 | $theAnswers = $answerHandler->getAllAnswers($this->faqid(), Constants::SF_AN_STATUS_PROPOSED, 1, 0); |
||
| 387 | //echo "test"; |
||
| 388 | //exit; |
||
| 389 | $this->answer =& $theAnswers[0]; |
||
| 390 | break; |
||
| 391 | |||
| 392 | case Constants::SF_STATUS_PUBLISHED: |
||
| 393 | case Constants::SF_STATUS_NEW_ANSWER: |
||
| 394 | case Constants::SF_STATUS_OFFLINE: |
||
| 395 | $this->answer = $answerHandler->getOfficialAnswer($this->faqid()); |
||
| 396 | break; |
||
| 397 | |||
| 398 | case Constants::SF_STATUS_ASKED: |
||
| 399 | $this->answer = $answerHandler->create(); |
||
| 400 | break; |
||
| 401 | case Constants::SF_STATUS_OPENED: |
||
| 402 | $this->answer = $answerHandler->create(); |
||
| 403 | break; |
||
| 404 | } |
||
| 405 | |||
| 406 | if ($this->answer) { |
||
| 407 | $this->answer->setVar('dohtml', $this->getVar('html')); |
||
| 408 | $this->answer->setVar('doxcode', $this->getVar('xcodes')); |
||
| 409 | $this->answer->setVar('dosmiley', $this->getVar('smiley')); |
||
| 410 | $this->answer->setVar('doimage', $this->getVar('image')); |
||
| 411 | $this->answer->setVar('dobr', $this->getVar('linebreak')); |
||
| 412 | } |
||
| 413 | |||
| 414 | return $this->answer; |
||
| 415 | } |
||
| 416 | |||
| 417 | /** |
||
| 418 | * @return array |
||
| 419 | */ |
||
| 420 | public function getAllAnswers() |
||
| 421 | { |
||
| 422 | $answerHandler = new Smartfaq\AnswerHandler($this->db); |
||
| 423 | |||
| 424 | return $answerHandler->getAllAnswers($this->faqid()); |
||
| 425 | } |
||
| 426 | |||
| 427 | /** |
||
| 428 | * @return bool |
||
| 429 | */ |
||
| 430 | public function updateCounter() |
||
| 431 | { |
||
| 432 | $faqHandler = new Smartfaq\FaqHandler($this->db); |
||
| 433 | |||
| 434 | return $faqHandler->updateCounter($this->faqid()); |
||
| 435 | } |
||
| 436 | |||
| 437 | /** |
||
| 438 | * @param bool $force |
||
| 439 | * @return bool |
||
| 440 | */ |
||
| 441 | public function store($force = true) |
||
| 446 | } |
||
| 447 | |||
| 448 | /** |
||
| 449 | * @return mixed |
||
| 450 | */ |
||
| 451 | public function getCategoryName() |
||
| 452 | { |
||
| 453 | if (!isset($this->category)) { |
||
| 454 | $this->category = new Smartfaq\Category($this->getVar('categoryid')); |
||
| 455 | } |
||
| 456 | |||
| 457 | return $this->category->name(); |
||
| 458 | } |
||
| 459 | |||
| 460 | /** |
||
| 461 | * @param array $notifications |
||
| 462 | */ |
||
| 463 | public function sendNotifications($notifications = []) |
||
| 464 | { |
||
| 465 | $smartModule = Smartfaq\Utility::getModuleInfo(); |
||
| 466 | |||
| 467 | $myts = \MyTextSanitizer::getInstance(); |
||
| 468 | $notificationHandler = xoops_getHandler('notification'); |
||
| 469 | //$categoryObj = $this->category(); |
||
| 470 | |||
| 471 | $tags = []; |
||
| 472 | $tags['MODULE_NAME'] = $myts->displayTarea($smartModule->getVar('name')); |
||
| 473 | $tags['FAQ_NAME'] = $this->question(); |
||
| 474 | $tags['CATEGORY_NAME'] = $this->getCategoryName(); |
||
| 475 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/category.php?categoryid=' . $this->categoryid(); |
||
| 476 | $tags['FAQ_QUESTION'] = $this->question(); |
||
| 477 | $answerObj = $this->answer(); |
||
| 478 | if (is_object($answerObj)) { |
||
| 479 | // TODO : Not sure about the 'formpreview' ... |
||
| 480 | $tags['FAQ_ANSWER'] = $answerObj->answer('formpreview'); |
||
| 481 | } |
||
| 482 | $tags['DATESUB'] = $this->datesub(); |
||
| 483 | |||
| 484 | foreach ($notifications as $notification) { |
||
| 485 | switch ($notification) { |
||
| 486 | case Constants::SF_NOT_FAQ_PUBLISHED: |
||
| 487 | $tags['FAQ_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/faq.php?faqid=' . $this->faqid(); |
||
| 488 | |||
| 489 | $notificationHandler->triggerEvent('global_faq', 0, 'published', $tags); |
||
| 490 | $notificationHandler->triggerEvent('category_faq', $this->categoryid(), 'published', $tags); |
||
| 491 | $notificationHandler->triggerEvent('faq', $this->faqid(), 'approved', $tags); |
||
| 492 | break; |
||
| 493 | |||
| 494 | case Constants::SF_NOT_FAQ_SUBMITTED: |
||
| 495 | $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/admin/faq.php?faqid=' . $this->faqid(); |
||
| 496 | $notificationHandler->triggerEvent('global_faq', 0, 'submitted', $tags); |
||
| 497 | $notificationHandler->triggerEvent('category_faq', $this->categoryid(), 'submitted', $tags); |
||
| 498 | break; |
||
| 499 | |||
| 500 | case Constants::SF_NOT_QUESTION_PUBLISHED: |
||
| 501 | $tags['FAQ_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/answer.php?faqid=' . $this->faqid(); |
||
| 502 | $notificationHandler->triggerEvent('global_question', 0, 'published', $tags); |
||
| 503 | $notificationHandler->triggerEvent('category_question', $this->categoryid(), 'published', $tags); |
||
| 504 | $notificationHandler->triggerEvent('question', $this->faqid(), 'approved', $tags); |
||
| 505 | break; |
||
| 506 | |||
| 507 | case Constants::SF_NOT_QUESTION_SUBMITTED: |
||
| 508 | $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/admin/question.php?op=mod&faqid=' . $this->faqid(); |
||
| 509 | $notificationHandler->triggerEvent('global_question', 0, 'submitted', $tags); |
||
| 510 | $notificationHandler->triggerEvent('category_question', $this->categoryid(), 'submitted', $tags); |
||
| 511 | break; |
||
| 512 | |||
| 513 | case Constants::SF_NOT_FAQ_REJECTED: |
||
| 514 | $notificationHandler->triggerEvent('faq', $this->faqid(), 'rejected', $tags); |
||
| 515 | break; |
||
| 516 | |||
| 517 | case Constants::SF_NOT_NEW_ANSWER_PROPOSED: |
||
| 518 | $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/admin/answer.php?op=mod&faqid=' . $this->faqid(); |
||
| 519 | $notificationHandler->triggerEvent('global_faq', 0, 'answer_proposed', $tags); |
||
| 520 | $notificationHandler->triggerEvent('category_faq', $this->categoryid(), 'answer_proposed', $tags); |
||
| 521 | break; |
||
| 522 | |||
| 523 | case Constants::SF_NOT_NEW_ANSWER_PUBLISHED: |
||
| 524 | $notificationHandler->triggerEvent('global_faq', 0, 'answer_published', $tags); |
||
| 525 | $notificationHandler->triggerEvent('category_faq', $this->categoryid(), 'answer_published', $tags); |
||
| 526 | break; |
||
| 527 | |||
| 528 | // TODO : I commented out this one because I'm not sure. The $this->faqid() should probably be the |
||
| 529 | // answerid not the faqid.... |
||
| 530 | /* |
||
| 531 | case Constants::SF_NOT_ANSWER_APPROVED: |
||
| 532 | $notificationHandler->triggerEvent('faq', $this->faqid(), 'answer_approved', $tags); |
||
| 533 | break; |
||
| 534 | */ |
||
| 535 | |||
| 536 | // TODO : I commented out this one because I'm not sure. The $this->faqid() should probably be the |
||
| 537 | // answerid not the faqid.... |
||
| 538 | /* |
||
| 539 | case Constants::SF_NOT_ANSWER_REJECTED: |
||
| 540 | $notificationHandler->triggerEvent('faq', $this->faqid(), 'answer_approved', $tags); |
||
| 541 | break; |
||
| 542 | */ |
||
| 543 | |||
| 544 | case -1: |
||
| 545 | default: |
||
| 546 | break; |
||
| 547 | } |
||
| 548 | } |
||
| 549 | } |
||
| 550 | |||
| 551 | public function setDefaultPermissions() |
||
| 552 | { |
||
| 553 | $memberHandler = xoops_getHandler('member'); |
||
| 554 | $groups = $memberHandler->getGroupList(); |
||
| 555 | |||
| 556 | $j = 0; |
||
| 557 | $group_ids = []; |
||
| 558 | foreach (array_keys($groups) as $i) { |
||
| 559 | $group_ids[$j] = $i; |
||
| 560 | ++$j; |
||
| 561 | } |
||
| 562 | $this->groups_read = $group_ids; |
||
| 563 | } |
||
| 564 | |||
| 565 | /** |
||
| 566 | * @param $group_ids |
||
| 567 | */ |
||
| 568 | public function setPermissions($group_ids) |
||
| 569 | { |
||
| 570 | if (!isset($group_ids)) { |
||
| 571 | $memberHandler = xoops_getHandler('member'); |
||
| 572 | $groups = $memberHandler->getGroupList(); |
||
| 573 | |||
| 574 | $j = 0; |
||
| 575 | $group_ids = []; |
||
| 576 | foreach (array_keys($groups) as $i) { |
||
| 577 | $group_ids[$j] = $i; |
||
| 578 | ++$j; |
||
| 579 | } |
||
| 580 | } |
||
| 581 | } |
||
| 582 | |||
| 583 | /** |
||
| 584 | * @return bool |
||
| 585 | */ |
||
| 586 | public function notLoaded() |
||
| 587 | { |
||
| 588 | return (-1 == $this->getVar('faqid')); |
||
| 589 | } |
||
| 590 | |||
| 591 | /** |
||
| 592 | * @param null $answerObj |
||
| 593 | * @param array $users |
||
| 594 | * @return string |
||
| 595 | */ |
||
| 596 | public function getWhoAndWhen($answerObj = null, $users = []) |
||
| 619 | } |
||
| 620 | |||
| 621 | /** |
||
| 622 | * @return string |
||
| 623 | */ |
||
| 624 | public function getComeFrom() |
||
| 625 | { |
||
| 626 | global $xoopsConfig; |
||
| 627 | $text = _MD_SF_QUESTIONCOMEFROM; |
||
| 628 | if ((Constants::SF_STATUS_PUBLISHED == $this->status()) || Constants::SF_STATUS_NEW_ANSWER == $this->status()) { |
||
| 629 | $text = _MD_SF_FAQCOMEFROM; |
||
| 630 | } |
||
| 631 | |||
| 632 | return $text . $xoopsConfig['sitename'] . ' : <a href=' . XOOPS_URL . '/modules/smartfaq/faq.php?faqid=' . $this->faqid() . '>' . XOOPS_URL . '/modules/smartfaq/faq.php?faqid=' . $this->faqid() . '</a>'; |
||
| 633 | } |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @param array $faq |
||
| 637 | * @param null $category |
||
| 638 | * @param bool $linkInQuestion |
||
| 639 | * @return array |
||
| 640 | */ |
||
| 641 | public function toArray($faq = [], $category = null, $linkInQuestion = true) |
||
| 673 | } |
||
| 674 | } |
||
| 675 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths