Passed
Push — master ( 81ba93...c6c854 )
by Michael
03:30
created

Faq::status()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace XoopsModules\Smartfaq;
4
5
/**
6
 * Module: SmartFAQ
7
 * Author: The SmartFactory <www.smartfactory.ca>
8
 * Licence: GNU
9
 */
10
11
use XoopsModules\Smartfaq;
12
13
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
14
15
//require_once XOOPS_ROOT_PATH . '/modules/smartfaq/class/category.php';
16
17
/**
18
 * Class Faq
19
 */
20
class Faq extends \XoopsObject
21
{
22
    public $db;
23
    /**
24
     * @var Smartfaq\Category
25
     * @access private
26
     */
27
    private $category = null;
28
29
    /**
30
     * @var Answer
31
     * @access private
32
     */
33
    private $answer = null;
34
35
    /**
36
     * @var array
37
     * @access private
38
     */
39
    private $_notifications = null;
0 ignored issues
show
introduced by
The private property $_notifications is not used, and could be removed.
Loading history...
40
    // TODO : Create a seperated class for notifications
41
42
    /**
43
     * @var array
44
     * @access private
45
     */
46
    private $groups_read = null;
47
48
    /**
49
     * @var object
50
     * @access private
51
     */
52
    // Is this still usefull??
53
    private $_smartModule = null;
0 ignored issues
show
introduced by
The private property $_smartModule is not used, and could be removed.
Loading history...
54
    private $_smartModuleConfig;
0 ignored issues
show
introduced by
The private property $_smartModuleConfig is not used, and could be removed.
Loading history...
55
56
    /**
57
     * constructor
58
     * @param null $id
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $id is correct as it would always require null to be passed?
Loading history...
59
     */
60
    public function __construct($id = null)
61
    {
62
        $this->db = \XoopsDatabaseFactory::getDatabaseConnection();
63
        $this->initVar('faqid', XOBJ_DTYPE_INT, -1, false);
64
        $this->initVar('categoryid', XOBJ_DTYPE_INT, 0, false);
65
        $this->initVar('question', XOBJ_DTYPE_TXTBOX, null, true, 100000);
66
        $this->initVar('howdoi', XOBJ_DTYPE_TXTBOX, null, false, 255);
67
        $this->initVar('diduno', XOBJ_DTYPE_TXTBOX, null, false, 255);
68
        $this->initVar('uid', XOBJ_DTYPE_INT, 0, false);
69
        $this->initVar('datesub', XOBJ_DTYPE_INT, null, false);
70
        $this->initVar('status', XOBJ_DTYPE_INT, -1, false);
71
        $this->initVar('counter', XOBJ_DTYPE_INT, 0, false);
72
        $this->initVar('weight', XOBJ_DTYPE_INT, 0, false);
73
        $this->initVar('html', XOBJ_DTYPE_INT, 1, false);
74
        $this->initVar('smiley', XOBJ_DTYPE_INT, 1, false);
75
        $this->initVar('image', XOBJ_DTYPE_INT, 1, false);
76
        $this->initVar('linebreak', XOBJ_DTYPE_INT, 1, false);
77
        $this->initVar('xcodes', XOBJ_DTYPE_INT, 1, false);
78
        $this->initVar('cancomment', XOBJ_DTYPE_INT, 1, false);
79
        $this->initVar('comments', XOBJ_DTYPE_INT, 0, false);
80
        $this->initVar('notifypub', XOBJ_DTYPE_INT, 1, false);
81
        $this->initVar('modulelink', XOBJ_DTYPE_TXTBOX, 'None', false, 50);
82
        $this->initVar('contextpage', XOBJ_DTYPE_TXTBOX, null, false, 255);
83
        $this->initVar('exacturl', XOBJ_DTYPE_INT, 0, false);
84
        $this->initVar('partialview', XOBJ_DTYPE_INT, 0, false);
85
86
        if (null !== $id) {
0 ignored issues
show
introduced by
The condition null !== $id is always false.
Loading history...
87
            $faqHandler = new Smartfaq\FaqHandler($this->db);
88
            $faq        = $faqHandler->get($id);
89
            foreach ($faq->vars as $k => $v) {
90
                $this->assignVar($k, $v['value']);
91
            }
92
            $this->assignOtherProperties();
93
        }
94
    }
95
96
    public function assignOtherProperties()
97
    {
98
        $smartModule = Smartfaq\Utility::getModuleInfo();
99
        $module_id   = $smartModule->getVar('mid');
100
101
        $grouppermHandler = xoops_getHandler('groupperm');
102
103
        $this->category    = new Smartfaq\Category($this->getVar('categoryid'));
104
        $this->groups_read = $grouppermHandler->getGroupIds('item_read', $this->faqid(), $module_id);
0 ignored issues
show
Bug introduced by
The method getGroupIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

104
        /** @scrutinizer ignore-call */ 
105
        $this->groups_read = $grouppermHandler->getGroupIds('item_read', $this->faqid(), $module_id);
Loading history...
105
    }
106
107
    /**
108
     * @return bool
109
     */
110
    public function checkPermission()
111
    {
112
        //        require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php';
113
114
        $userIsAdmin = Smartfaq\Utility::userIsAdmin();
115
        if ($userIsAdmin) {
116
            return true;
117
        }
118
        /** @var Smartfaq\PermissionHandler $smartPermHandler */
119
        $smartPermHandler = Smartfaq\Helper::getInstance()->getHandler('Permission');
120
        //        $smartPermHandler = xoops_getModuleHandler('permission', 'smartfaq');
121
122
        $faqsGranted = $smartPermHandler->getPermissions('item');
123
        if (in_array($this->categoryid(), $faqsGranted)) {
124
            $ret = true;
125
        }
126
127
        return $ret;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ret does not seem to be defined for all execution paths leading up to this point.
Loading history...
128
    }
129
130
    /**
131
     * @return array
132
     */
133
    public function getGroups_read()
134
    {
135
        if (count($this->groups_read) < 1) {
136
            $this->assignOtherProperties();
137
        }
138
139
        return $this->groups_read;
140
    }
141
142
    /**
143
     * @param array $groups_read
144
     */
145
    public function setGroups_read($groups_read = ['0'])
146
    {
147
        $this->groups_read = $groups_read;
148
    }
149
150
    /**
151
     * @return mixed
152
     */
153
    public function faqid()
154
    {
155
        return $this->getVar('faqid');
156
    }
157
158
    /**
159
     * @return mixed
160
     */
161
    public function categoryid()
162
    {
163
        return $this->getVar('categoryid');
164
    }
165
166
    /**
167
     * @return Smartfaq\Category
168
     */
169
    public function category()
170
    {
171
        return $this->category;
172
    }
173
174
    /**
175
     * @param  int    $maxLength
176
     * @param  string $format
177
     * @return mixed|string
178
     */
179
    public function question($maxLength = 0, $format = 'S')
180
    {
181
        $ret = $this->getVar('question', $format);
182
        if (('s' === $format) || ('S' === $format) || ('show' === $format)) {
183
            $myts = \MyTextSanitizer::getInstance();
184
            $ret  = $myts->displayTarea($ret);
185
        }
186
        if (0 != $maxLength) {
187
            if (!XOOPS_USE_MULTIBYTES) {
188
                if (mb_strlen($ret) >= $maxLength) {
189
                    $ret = mb_substr($ret, 0, $maxLength - 1) . '...';
190
                }
191
            }
192
        }
193
194
        return $ret;
195
    }
196
197
    /**
198
     * @param  string $format
199
     * @return mixed
200
     */
201
    public function howdoi($format = 'S')
202
    {
203
        $ret = $this->getVar('howdoi', $format);
204
        if (('s' === $format) || ('S' === $format) || ('show' === $format)) {
205
            $myts = \MyTextSanitizer::getInstance();
206
            $ret  = $myts->displayTarea($ret);
207
        }
208
209
        return $ret;
210
    }
211
212
    /**
213
     * @param  string $format
214
     * @return mixed
215
     */
216
    public function diduno($format = 'S')
217
    {
218
        $ret = $this->getVar('diduno', $format);
219
        if (('s' === $format) || ('S' === $format) || ('show' === $format)) {
220
            $myts = \MyTextSanitizer::getInstance();
221
            $ret  = $myts->displayTarea($ret);
222
        }
223
224
        return $ret;
225
    }
226
227
    /**
228
     * @return mixed
229
     */
230
    public function uid()
231
    {
232
        return $this->getVar('uid');
233
    }
234
235
    /**
236
     * @param  string $dateFormat
237
     * @param  string $format
238
     * @return string
239
     */
240
    public function datesub($dateFormat = 'none', $format = 'S')
241
    {
242
        if ('none' === $dateFormat) {
243
            $smartConfig = Smartfaq\Utility::getModuleConfig();
244
            $dateFormat  = $smartConfig['dateformat'];
245
        }
246
247
        return formatTimestamp($this->getVar('datesub', $format), $dateFormat);
248
    }
249
250
    /**
251
     * @return mixed
252
     */
253
    public function status()
254
    {
255
        return $this->getVar('status');
256
    }
257
258
    /**
259
     * @return mixed
260
     */
261
    public function counter()
262
    {
263
        return $this->getVar('counter');
264
    }
265
266
    /**
267
     * @return mixed
268
     */
269
    public function weight()
270
    {
271
        return $this->getVar('weight');
272
    }
273
274
    /**
275
     * @return mixed
276
     */
277
    public function html()
278
    {
279
        return $this->getVar('html');
280
    }
281
282
    /**
283
     * @return mixed
284
     */
285
    public function smiley()
286
    {
287
        return $this->getVar('smiley');
288
    }
289
290
    /**
291
     * @return mixed
292
     */
293
    public function xcodes()
294
    {
295
        return $this->getVar('xcodes');
296
    }
297
298
    /**
299
     * @return mixed
300
     */
301
    public function cancomment()
302
    {
303
        return $this->getVar('cancomment');
304
    }
305
306
    /**
307
     * @return mixed
308
     */
309
    public function comments()
310
    {
311
        return $this->getVar('comments');
312
    }
313
314
    /**
315
     * @return mixed
316
     */
317
    public function notifypub()
318
    {
319
        return $this->getVar('notifypub');
320
    }
321
322
    /**
323
     * @param  string $format
324
     * @return mixed
325
     */
326
    public function modulelink($format = 'S')
327
    {
328
        return $this->getVar('modulelink', $format);
329
    }
330
331
    /**
332
     * @param  string $format
333
     * @return mixed
334
     */
335
    public function contextpage($format = 'S')
336
    {
337
        return $this->getVar('contextpage', $format);
338
    }
339
340
    /**
341
     * @return mixed
342
     */
343
    public function exacturl()
344
    {
345
        return $this->getVar('exacturl');
346
    }
347
348
    /**
349
     * @return mixed
350
     */
351
    public function partialview()
352
    {
353
        return $this->getVar('partialview');
354
    }
355
356
    /**
357
     * @param  int $realName
358
     * @return string
359
     */
360
    public function posterName($realName = -1)
361
    {
362
        if (-1 == $realName) {
363
            $smartConfig = Smartfaq\Utility::getModuleConfig();
364
            $realName    = $smartConfig['userealname'];
365
        }
366
367
        return Smartfaq\Utility::getLinkedUnameFromId($this->uid(), $realName);
368
    }
369
370
    /**
371
     * @return mixed|object|Smartfaq\Answer
372
     */
373
    public function answer()
374
    {
375
        $answerHandler = new Smartfaq\AnswerHandler($this->db);
376
        switch ($this->status()) {
377
            case Constants::SF_STATUS_SUBMITTED:
378
                $theAnswers = $answerHandler->getAllAnswers($this->faqid(), Constants::SF_AN_STATUS_APPROVED, 1, 0);
379
                //echo "test";
380
                //exit;
381
                $this->answer = &$theAnswers[0];
382
                break;
383
            case Constants::SF_STATUS_ANSWERED:
384
                $theAnswers = $answerHandler->getAllAnswers($this->faqid(), Constants::SF_AN_STATUS_PROPOSED, 1, 0);
385
                //echo "test";
386
                //exit;
387
                $this->answer = &$theAnswers[0];
388
                break;
389
            case Constants::SF_STATUS_PUBLISHED:
390
            case Constants::SF_STATUS_NEW_ANSWER:
391
            case Constants::SF_STATUS_OFFLINE:
392
                $this->answer = $answerHandler->getOfficialAnswer($this->faqid());
393
                break;
394
            case Constants::SF_STATUS_ASKED:
395
                $this->answer = $answerHandler->create();
396
                break;
397
            case Constants::SF_STATUS_OPENED:
398
                $this->answer = $answerHandler->create();
399
                break;
400
        }
401
402
        if ($this->answer) {
403
            $this->answer->setVar('dohtml', $this->getVar('html'));
404
            $this->answer->setVar('doxcode', $this->getVar('xcodes'));
405
            $this->answer->setVar('dosmiley', $this->getVar('smiley'));
406
            $this->answer->setVar('doimage', $this->getVar('image'));
407
            $this->answer->setVar('dobr', $this->getVar('linebreak'));
408
        }
409
410
        return $this->answer;
411
    }
412
413
    /**
414
     * @return array
415
     */
416
    public function getAllAnswers()
417
    {
418
        $answerHandler = new Smartfaq\AnswerHandler($this->db);
419
420
        return $answerHandler->getAllAnswers($this->faqid());
421
    }
422
423
    /**
424
     * @return bool
425
     */
426
    public function updateCounter()
427
    {
428
        $faqHandler = new Smartfaq\FaqHandler($this->db);
429
430
        return $faqHandler->updateCounter($this->faqid());
431
    }
432
433
    /**
434
     * @param  bool $force
435
     * @return bool
436
     */
437
    public function store($force = true)
438
    {
439
        $faqHandler = new Smartfaq\FaqHandler($this->db);
440
441
        return $faqHandler->insert($this, $force);
442
    }
443
444
    /**
445
     * @return mixed
446
     */
447
    public function getCategoryName()
448
    {
449
        if (!isset($this->category)) {
450
            $this->category = new Smartfaq\Category($this->getVar('categoryid'));
451
        }
452
453
        return $this->category->name();
454
    }
455
456
    /**
457
     * @param array $notifications
458
     */
459
    public function sendNotifications($notifications = [])
460
    {
461
        $smartModule = Smartfaq\Utility::getModuleInfo();
462
463
        $myts = \MyTextSanitizer::getInstance();
464
        /** @var \XoopsNotificationHandler $notificationHandler */
465
        $notificationHandler = xoops_getHandler('notification');
466
        //$categoryObj = $this->category();
467
468
        $tags                  = [];
469
        $tags['MODULE_NAME']   = $myts->displayTarea($smartModule->getVar('name'));
470
        $tags['FAQ_NAME']      = $this->question();
471
        $tags['CATEGORY_NAME'] = $this->getCategoryName();
472
        $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/category.php?categoryid=' . $this->categoryid();
473
        $tags['FAQ_QUESTION']  = $this->question();
474
        $answerObj             = $this->answer();
475
        if (is_object($answerObj)) {
476
            // TODO : Not sure about the 'formpreview' ...
477
            $tags['FAQ_ANSWER'] = $answerObj->answer('formpreview');
478
        }
479
        $tags['DATESUB'] = $this->datesub();
480
481
        foreach ($notifications as $notification) {
482
            switch ($notification) {
483
                case Constants::SF_NOT_FAQ_PUBLISHED:
484
                    $tags['FAQ_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/faq.php?faqid=' . $this->faqid();
485
486
                    $notificationHandler->triggerEvent('global_faq', 0, 'published', $tags);
487
                    $notificationHandler->triggerEvent('category_faq', $this->categoryid(), 'published', $tags);
488
                    $notificationHandler->triggerEvent('faq', $this->faqid(), 'approved', $tags);
489
                    break;
490
                case Constants::SF_NOT_FAQ_SUBMITTED:
491
                    $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/admin/faq.php?faqid=' . $this->faqid();
492
                    $notificationHandler->triggerEvent('global_faq', 0, 'submitted', $tags);
493
                    $notificationHandler->triggerEvent('category_faq', $this->categoryid(), 'submitted', $tags);
494
                    break;
495
                case Constants::SF_NOT_QUESTION_PUBLISHED:
496
                    $tags['FAQ_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/answer.php?faqid=' . $this->faqid();
497
                    $notificationHandler->triggerEvent('global_question', 0, 'published', $tags);
498
                    $notificationHandler->triggerEvent('category_question', $this->categoryid(), 'published', $tags);
499
                    $notificationHandler->triggerEvent('question', $this->faqid(), 'approved', $tags);
500
                    break;
501
                case Constants::SF_NOT_QUESTION_SUBMITTED:
502
                    $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/admin/question.php?op=mod&faqid=' . $this->faqid();
503
                    $notificationHandler->triggerEvent('global_question', 0, 'submitted', $tags);
504
                    $notificationHandler->triggerEvent('category_question', $this->categoryid(), 'submitted', $tags);
505
                    break;
506
                case Constants::SF_NOT_FAQ_REJECTED:
507
                    $notificationHandler->triggerEvent('faq', $this->faqid(), 'rejected', $tags);
508
                    break;
509
                case Constants::SF_NOT_NEW_ANSWER_PROPOSED:
510
                    $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/admin/answer.php?op=mod&faqid=' . $this->faqid();
511
                    $notificationHandler->triggerEvent('global_faq', 0, 'answer_proposed', $tags);
512
                    $notificationHandler->triggerEvent('category_faq', $this->categoryid(), 'answer_proposed', $tags);
513
                    break;
514
                case Constants::SF_NOT_NEW_ANSWER_PUBLISHED:
515
                    $notificationHandler->triggerEvent('global_faq', 0, 'answer_published', $tags);
516
                    $notificationHandler->triggerEvent('category_faq', $this->categoryid(), 'answer_published', $tags);
517
                    break;
518
                // TODO : I commented out this one because I'm not sure. The $this->faqid() should probably be the
519
                // answerid not the faqid....
520
                /*
521
                case Constants::SF_NOT_ANSWER_APPROVED:
522
                $notificationHandler->triggerEvent('faq', $this->faqid(), 'answer_approved', $tags);
523
                break;
524
                */
525
526
                // TODO : I commented out this one because I'm not sure. The $this->faqid() should probably be the
527
                // answerid not the faqid....
528
                /*
529
                case Constants::SF_NOT_ANSWER_REJECTED:
530
                $notificationHandler->triggerEvent('faq', $this->faqid(), 'answer_approved', $tags);
531
                break;
532
                */
533
534
                case -1:
535
                default:
536
                    break;
537
            }
538
        }
539
    }
540
541
    public function setDefaultPermissions()
542
    {
543
        $memberHandler = xoops_getHandler('member');
544
        $groups        = $memberHandler->getGroupList();
0 ignored issues
show
Bug introduced by
The method getGroupList() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

544
        /** @scrutinizer ignore-call */ 
545
        $groups        = $memberHandler->getGroupList();
Loading history...
545
546
        $j         = 0;
547
        $group_ids = [];
548
        foreach (array_keys($groups) as $i) {
549
            $group_ids[$j] = $i;
550
            ++$j;
551
        }
552
        $this->groups_read = $group_ids;
553
    }
554
555
    /**
556
     * @param $group_ids
557
     */
558
    public function setPermissions($group_ids)
559
    {
560
        if (!isset($group_ids)) {
561
            $memberHandler = xoops_getHandler('member');
562
            $groups        = $memberHandler->getGroupList();
563
564
            $j         = 0;
565
            $group_ids = [];
566
            foreach (array_keys($groups) as $i) {
567
                $group_ids[$j] = $i;
568
                ++$j;
569
            }
570
        }
571
    }
572
573
    /**
574
     * @return bool
575
     */
576
    public function notLoaded()
577
    {
578
        return (-1 == $this->getVar('faqid'));
579
    }
580
581
    /**
582
     * @param  null  $answerObj
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $answerObj is correct as it would always require null to be passed?
Loading history...
583
     * @param  array $users
584
     * @return string
585
     */
586
    public function getWhoAndWhen($answerObj = null, $users = [])
587
    {
588
        /** @var Smartfaq\Helper $helper */
589
        $helper = Smartfaq\Helper::getInstance();
590
        $smartModuleConfig = $helper->getConfig();
591
592
        $requester   = Smartfaq\Utility::getLinkedUnameFromId($this->uid(), $smartModuleConfig['userealname'], $users);
593
        $requestdate = $this->datesub();
594
595
        if ((Constants::SF_STATUS_PUBLISHED == $this->status()) || Constants::SF_STATUS_NEW_ANSWER == $this->status()) {
596
            if (null === $answerObj) {
0 ignored issues
show
introduced by
The condition null === $answerObj is always true.
Loading history...
597
                $answerObj = $this->answer();
598
            }
599
            $submitdate = $answerObj->datesub();
600
            if ($this->uid() == $answerObj->uid()) {
601
                $result = sprintf(_MD_SF_REQUESTEDANDANSWERED, $requester, $submitdate);
602
            } else {
603
                $submitter = Smartfaq\Utility::getLinkedUnameFromId($answerObj->uid(), $smartModuleConfig['userealname'], $users);
604
                $result    = sprintf(_MD_SF_REQUESTEDBYANDANSWEREDBY, $requester, $submitter, $submitdate);
605
            }
606
        } else {
607
            $result = sprintf(_MD_SF_REQUESTEDBY, $requester, $requestdate);
608
        }
609
610
        return $result;
611
    }
612
613
    /**
614
     * @return string
615
     */
616
    public function getComeFrom()
617
    {
618
        global $xoopsConfig;
619
        $text = _MD_SF_QUESTIONCOMEFROM;
620
        if ((Constants::SF_STATUS_PUBLISHED == $this->status()) || Constants::SF_STATUS_NEW_ANSWER == $this->status()) {
621
            $text = _MD_SF_FAQCOMEFROM;
622
        }
623
624
        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>';
625
    }
626
627
    /**
628
     * @param  array $faq
629
     * @param  null  $category
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $category is correct as it would always require null to be passed?
Loading history...
630
     * @param  bool  $linkInQuestion
631
     * @return array
632
     */
633
    public function toArray($faq = [], $category = null, $linkInQuestion = true)
634
    {
635
        /** @var Smartfaq\Helper $helper */
636
        $helper = Smartfaq\Helper::getInstance();
637
638
        $lastfaqsize = (int)$helper->getConfig('lastfaqsize');
639
640
        $faq['id']         = $this->faqid();
641
        $faq['categoryid'] = $this->categoryid();
642
        $faq['question']   = $this->question();
643
        $page              = (Constants::SF_STATUS_OPENED == $this->status()) ? 'answer.php' : 'faq.php';
644
645
        $faq['questionlink'] = "<a href='$page?faqid=" . $this->faqid() . "'>" . $this->question($lastfaqsize) . '</a>';
646
        if ($linkInQuestion) {
647
            $faq['fullquestionlink'] = "<a href='$page?faqid=" . $this->faqid() . "'>" . $this->question() . '</a>';
648
        } else {
649
            $faq['fullquestionlink'] = $this->question();
650
        }
651
        $faq['faqid']      = $this->faqid();
652
        $faq['counter']    = $this->counter();
653
        $faq['cancomment'] = $this->cancomment();
654
        $faq['comments']   = $this->comments();
655
        $faq['datesub']    = $this->datesub();
656
        if (null !== $category) {
0 ignored issues
show
introduced by
The condition null !== $category is always false.
Loading history...
657
            if (is_object($category) && 'xoopsmodules\smartfaq\category' === mb_strtolower(get_class($category))) {
658
                $categoryObj = $category;
659
            } elseif (is_array($category)) {
660
                $categoryObj = $category[$this->categoryid()];
661
            }
662
            $faq['categoryname'] = $categoryObj->getVar('name');
663
            $faq['categorylink'] = "<a href='" . XOOPS_URL . '/modules/smartfaq/category.php?categoryid=' . $this->categoryid() . "'>" . $categoryObj->getVar('name') . '</a>';
664
        }
665
666
        return $faq;
667
    }
668
}
669