Completed
Push — master ( c004c3...65a58d )
by Michael
04:32
created
smartfaq/admin/mygrouppermform.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -85,6 +85,10 @@  discard block
 block discarded – undo
85 85
 
86 86
     /**
87 87
      * Constructor
88
+     * @param string $title
89
+     * @param integer $modid
90
+     * @param string $permname
91
+     * @param string $permdesc
88 92
      */
89 93
     function MyXoopsGroupPermForm($title, $modid, $permname, $permdesc)
90 94
     {
@@ -117,6 +121,8 @@  discard block
 block discarded – undo
117 121
      * Add appendix
118 122
      *
119 123
      * @access public
124
+     * @param string $permName
125
+     * @param string $itemName
120 126
      */
121 127
     function addAppendix($permName,$itemId,$itemName)
122 128
     {
@@ -249,6 +255,7 @@  discard block
 block discarded – undo
249 255
 
250 256
     /**
251 257
      * Constructor
258
+     * @param string $name
252 259
      */
253 260
     function MyXoopsGroupFormCheckBox($caption, $name, $groupId, $values = null)
254 261
     {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * Appendix
82 82
      * @var array ('permname'=>,'itemid'=>,'itemname'=>,'selected'=>)
83 83
      */
84
-    var $_appendix = array() ;
84
+    var $_appendix = array();
85 85
 
86 86
     /**
87 87
      * Constructor
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     function MyXoopsGroupPermForm($title, $modid, $permname, $permdesc)
90 90
     {
91 91
 //		$this->XoopsForm($title, 'groupperm_form', XOOPS_URL.'/modules/system/admin/groupperm.php', 'post'); GIJ
92
-        $this->XoopsForm($title, 'groupperm_form', '' , 'post');
92
+        $this->XoopsForm($title, 'groupperm_form', '', 'post');
93 93
         $this->_modid = intval($modid);
94 94
         $this->_permName = $permname;
95 95
         $this->_permDesc = $permdesc;
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
      *
119 119
      * @access public
120 120
      */
121
-    function addAppendix($permName,$itemId,$itemName)
121
+    function addAppendix($permName, $itemId, $itemName)
122 122
     {
123
-        $this->_appendix[] = array('permname'=>$permName,'itemid'=>$itemId,'itemname'=>$itemName,'selected'=>false);
123
+        $this->_appendix[] = array('permname'=>$permName, 'itemid'=>$itemId, 'itemname'=>$itemName, 'selected'=>false);
124 124
     }
125 125
 
126 126
     /**
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
             $this->_itemTree[$item_id]['allchild'] = array();
160 160
             $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']);
161 161
         }
162
-        $gperm_handler =& xoops_gethandler('groupperm');
163
-        $member_handler =& xoops_gethandler('member');
164
-        $glist =& $member_handler->getGroupList();
162
+        $gperm_handler = & xoops_gethandler('groupperm');
163
+        $member_handler = & xoops_gethandler('member');
164
+        $glist = & $member_handler->getGroupList();
165 165
         foreach (array_keys($glist) as $i) {
166 166
             // get selected item id(s) for each group
167 167
             $selected = $gperm_handler->getItemIds($this->_permName, $i, $this->_modid);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             $ele->setOptionTree($this->_itemTree);
170 170
 
171 171
             foreach ($this->_appendix as $key => $append) {
172
-                $this->_appendix[$key]['selected'] = $gperm_handler->checkRight($append['permname'], $append['itemid'], $i, $this->_modid ) ;
172
+                $this->_appendix[$key]['selected'] = $gperm_handler->checkRight($append['permname'], $append['itemid'], $i, $this->_modid);
173 173
             }
174 174
             $ele->setAppendix($this->_appendix);
175 175
             $this->addElement($ele);
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
         // GIJ start
180 180
         $jstray = new XoopsFormElementTray('   ');
181 181
         $jsuncheckbutton = new XoopsFormButton('', 'none', _NONE, 'button');
182
-        $jsuncheckbutton->setExtra( "onclick=\"with(document.groupperm_form){for (i=0;i<length;i++) {if (elements[i].type=='checkbox') {elements[i].checked=false;}}}\"" ) ;
182
+        $jsuncheckbutton->setExtra("onclick=\"with(document.groupperm_form){for (i=0;i<length;i++) {if (elements[i].type=='checkbox') {elements[i].checked=false;}}}\"");
183 183
         $jscheckbutton = new XoopsFormButton('', 'all', _ALL, 'button');
184
-        $jscheckbutton->setExtra( "onclick=\"with(document.groupperm_form){for (i=0;i<length;i++) {if (elements[i].type=='checkbox' && (elements[i].name.indexOf('module_admin')<0 || elements[i].name.indexOf('[groups][1]')>=0)) {elements[i].checked=true;}}}\"" ) ;
185
-        $jstray->addElement( $jsuncheckbutton ) ;
186
-        $jstray->addElement( $jscheckbutton ) ;
184
+        $jscheckbutton->setExtra("onclick=\"with(document.groupperm_form){for (i=0;i<length;i++) {if (elements[i].type=='checkbox' && (elements[i].name.indexOf('module_admin')<0 || elements[i].name.indexOf('[groups][1]')>=0)) {elements[i].checked=true;}}}\"");
185
+        $jstray->addElement($jsuncheckbutton);
186
+        $jstray->addElement($jscheckbutton);
187 187
         $this->addElement($jstray);
188 188
         // GIJ end
189 189
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
         $ret = '<h4>'.$this->getTitle().'</h4>'.$this->_permDesc.'<br />';
196 196
         $ret .= "<form name='".$this->getName()."' id='".$this->getName()."' action='".$this->getAction()."' method='".$this->getMethod()."'".$this->getExtra().">\n<table width='100%' class='outer' cellspacing='1'>\n";
197
-        $elements =& $this->getElements();
197
+        $elements = & $this->getElements();
198 198
         foreach (array_keys($elements) as $i) {
199 199
             if (!is_object($elements[$i])) {
200 200
                 $ret .= $elements[$i];
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      * Appendix
246 246
      * @var array ('permname'=>,'itemid'=>,'itemname'=>,'selected'=>)
247 247
      */
248
-    var $_appendix = array() ;
248
+    var $_appendix = array();
249 249
 
250 250
     /**
251 251
      * Constructor
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      */
286 286
     function setOptionTree(&$optionTree)
287 287
     {
288
-        $this->_optionTree =& $optionTree;
288
+        $this->_optionTree = & $optionTree;
289 289
     }
290 290
 
291 291
     /**
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
      */
296 296
     function setAppendix($appendix)
297 297
     {
298
-        $this->_appendix = $appendix ;
298
+        $this->_appendix = $appendix;
299 299
     }
300 300
 
301 301
     /**
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
      */
307 307
     function render()
308 308
     {
309
-        $ret = '' ;
309
+        $ret = '';
310 310
 
311
-        if ( sizeof( $this->_appendix ) > 0 ) {
311
+        if (sizeof($this->_appendix) > 0) {
312 312
             $ret .= '<table class="outer"><tr>';
313 313
             $cols = 1;
314 314
             foreach ($this->_appendix as $append) {
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
                     $ret .= '</tr><tr>';
317 317
                     $cols = 1;
318 318
                 }
319
-                $checked = $append['selected']? 'checked="checked"' : '' ;
320
-                $name = 'perms['.$append['permname'].']' ;
321
-                $itemid = $append['itemid'] ;
322
-                $itemid = $append['itemid'] ;
323
-                $ret .= "<td class=\"odd\"><input type=\"checkbox\" name=\"{$name}[groups][$this->_groupId][$itemid]\" id=\"{$name}[groups][$this->_groupId][$itemid]\" value=\"1\" $checked />{$append['itemname']}<input type=\"hidden\" name=\"{$name}[parents][$itemid]\" value=\"\" /><input type=\"hidden\" name=\"{$name}[itemname][$itemid]\" value=\"{$append['itemname']}\" /><br /></td>" ;
319
+                $checked = $append['selected'] ? 'checked="checked"' : '';
320
+                $name = 'perms['.$append['permname'].']';
321
+                $itemid = $append['itemid'];
322
+                $itemid = $append['itemid'];
323
+                $ret .= "<td class=\"odd\"><input type=\"checkbox\" name=\"{$name}[groups][$this->_groupId][$itemid]\" id=\"{$name}[groups][$this->_groupId][$itemid]\" value=\"1\" $checked />{$append['itemname']}<input type=\"hidden\" name=\"{$name}[parents][$itemid]\" value=\"\" /><input type=\"hidden\" name=\"{$name}[itemname][$itemid]\" value=\"{$append['itemname']}\" /><br /></td>";
324 324
                 ++$cols;
325 325
             }
326 326
             $ret .= '</tr></table>';
@@ -372,11 +372,11 @@  discard block
 block discarded – undo
372 372
             $tree .= "var ele = xoopsGetElementById('".$child_ele."'); if (this.checked != true) {ele.checked = false;}";
373 373
         }
374 374
         $tree .= '" value="1"';
375
-        if ( isset( $this->_value ) && in_array($option['id'], $this->_value)) {
375
+        if (isset($this->_value) && in_array($option['id'], $this->_value)) {
376 376
             $tree .= ' checked="checked"';
377 377
         }
378 378
         $tree .= " />".$option['name']."<input type=\"hidden\" name=\"".$this->getName()."[parents][".$option['id']."]\" value=\"".implode(':', $parentIds)."\" /><input type=\"hidden\" name=\"".$this->getName()."[itemname][".$option['id']."]\" value=\"".htmlspecialchars($option['name'])."\" /><br />\n";
379
-        if ( isset( $option['children'] ) ) foreach ($option['children'] as $child) {
379
+        if (isset($option['children'])) foreach ($option['children'] as $child) {
380 380
             array_push($parentIds, $option['id']);
381 381
             $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix.'&nbsp;-', $parentIds);
382 382
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -376,8 +376,10 @@
 block discarded – undo
376 376
             $tree .= ' checked="checked"';
377 377
         }
378 378
         $tree .= " />".$option['name']."<input type=\"hidden\" name=\"".$this->getName()."[parents][".$option['id']."]\" value=\"".implode(':', $parentIds)."\" /><input type=\"hidden\" name=\"".$this->getName()."[itemname][".$option['id']."]\" value=\"".htmlspecialchars($option['name'])."\" /><br />\n";
379
-        if ( isset( $option['children'] ) ) foreach ($option['children'] as $child) {
379
+        if ( isset( $option['children'] ) ) {
380
+            foreach ($option['children'] as $child) {
380 381
             array_push($parentIds, $option['id']);
382
+        }
381 383
             $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix.'&nbsp;-', $parentIds);
382 384
         }
383 385
     }
Please login to merge, or discard this patch.
smartfaq/class/answer.php 4 patches
Doc Comments   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,6 +24,7 @@  discard block
 block discarded – undo
24 24
     var $attachment_array = array();
25 25
     /**
26 26
     * constructor
27
+    * @param integer $id
27 28
     */
28 29
     function __construct ($id = null)
29 30
     {
@@ -297,7 +298,7 @@  discard block
 block discarded – undo
297 298
     * create a new answer
298 299
     *
299 300
     * @param bool $isNew flag the new objects as "new"?
300
-    * @return object sfAnswer
301
+    * @return sfAnswer sfAnswer
301 302
     */
302 303
     function &create($isNew = true)
303 304
     {
@@ -338,7 +339,7 @@  discard block
 block discarded – undo
338 339
     /**
339 340
     * insert a new answer in the database
340 341
     *
341
-    * @param object $answer reference to the {@link sfAnswer} object
342
+    * @param sfAnswer $answerObj reference to the {@link sfAnswer} object
342 343
     * @param bool $force
343 344
     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
344 345
     */
@@ -414,8 +415,6 @@  discard block
 block discarded – undo
414 415
     /**
415 416
     * delete an answer from the database
416 417
     *
417
-    * @param object $answer reference to the answer to delete
418
-    * @param bool $force
419 418
     * @return bool FALSE if failed.
420 419
     */
421 420
     function deleteFaqAnswers(&$faqObj)
@@ -476,7 +475,6 @@  discard block
 block discarded – undo
476 475
     /**
477 476
     * retrieve 1 official answer (for now SmartFAQ only allow 1 official answer...)
478 477
     *
479
-    * @param object $criteria {@link CriteriaElement} conditions to be met
480 478
     * @param int $faqid
481 479
     * @return mixed reference to the {@link sfAnswer} object, FALSE if failed
482 480
     */
@@ -495,7 +493,6 @@  discard block
 block discarded – undo
495 493
     /**
496 494
     * retrieve all answers
497 495
     *
498
-    * @param object $criteria {@link CriteriaElement} conditions to be met
499 496
     * @param int $faqid
500 497
     * @return array array of {@link sfAnswer} objects
501 498
     */
Please login to merge, or discard this patch.
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 {
24 24
     var $attachment_array = array();
25 25
     /**
26
-    * constructor
27
-    */
26
+     * constructor
27
+     */
28 28
     function __construct ($id = null)
29 29
     {
30 30
         $this->db =& XoopsDatabaseFactory::getDatabaseConnection();
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 }
185 185
                 $post_attachment .= '<br />';
186 186
             }
187
-       }
187
+        }
188 188
 
189 189
         return $post_attachment;
190 190
     }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
     function notLoaded()
242 242
     {
243
-       return ($this->getVar('answerid')== -1);
243
+        return ($this->getVar('answerid')== -1);
244 244
     }
245 245
 
246 246
     function sendNotifications($notifications=array())
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 {
295 295
 
296 296
     /**
297
-    * create a new answer
298
-    *
299
-    * @param bool $isNew flag the new objects as "new"?
300
-    * @return object sfAnswer
301
-    */
297
+     * create a new answer
298
+     *
299
+     * @param bool $isNew flag the new objects as "new"?
300
+     * @return object sfAnswer
301
+     */
302 302
     function &create($isNew = true)
303 303
     {
304 304
         $answer = new sfAnswer();
@@ -310,11 +310,11 @@  discard block
 block discarded – undo
310 310
     }
311 311
 
312 312
     /**
313
-    * retrieve an answer
314
-    *
315
-    * @param int $id answerid of the answer
316
-    * @return mixed reference to the {@link sfAnswer} object, FALSE if failed
317
-    */
313
+     * retrieve an answer
314
+     *
315
+     * @param int $id answerid of the answer
316
+     * @return mixed reference to the {@link sfAnswer} object, FALSE if failed
317
+     */
318 318
     function &get($id)
319 319
     {
320 320
         if (intval($id) > 0) {
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
     }
337 337
 
338 338
     /**
339
-    * insert a new answer in the database
340
-    *
341
-    * @param object $answer reference to the {@link sfAnswer} object
342
-    * @param bool $force
343
-    * @return bool FALSE if failed, TRUE if already present and unchanged or successful
344
-    */
339
+     * insert a new answer in the database
340
+     *
341
+     * @param object $answer reference to the {@link sfAnswer} object
342
+     * @param bool $force
343
+     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
344
+     */
345 345
     function insert(&$answerObj, $force = false)
346 346
     {
347 347
         if (strtolower(get_class($answerObj)) != 'sfanswer') {
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
     }
385 385
 
386 386
     /**
387
-    * delete an answer from the database
388
-    *
389
-    * @param object $answer reference to the answer to delete
390
-    * @param bool $force
391
-    * @return bool FALSE if failed.
392
-    */
387
+     * delete an answer from the database
388
+     *
389
+     * @param object $answer reference to the answer to delete
390
+     * @param bool $force
391
+     * @return bool FALSE if failed.
392
+     */
393 393
     function delete(&$answer, $force = false)
394 394
     {
395 395
         if (strtolower(get_class($answer)) != 'sfanswer') {
@@ -412,12 +412,12 @@  discard block
 block discarded – undo
412 412
     }
413 413
 
414 414
     /**
415
-    * delete an answer from the database
416
-    *
417
-    * @param object $answer reference to the answer to delete
418
-    * @param bool $force
419
-    * @return bool FALSE if failed.
420
-    */
415
+     * delete an answer from the database
416
+     *
417
+     * @param object $answer reference to the answer to delete
418
+     * @param bool $force
419
+     * @return bool FALSE if failed.
420
+     */
421 421
     function deleteFaqAnswers(&$faqObj)
422 422
     {
423 423
         if (strtolower(get_class($faqObj)) != 'sffaq') {
@@ -435,12 +435,12 @@  discard block
 block discarded – undo
435 435
     }
436 436
 
437 437
     /**
438
-    * retrieve answers from the database
439
-    *
440
-    * @param object $criteria {@link CriteriaElement} conditions to be met
441
-    * @param bool $id_as_key use the answerid as key for the array?
442
-    * @return array array of {@link sfAnswer} objects
443
-    */
438
+     * retrieve answers from the database
439
+     *
440
+     * @param object $criteria {@link CriteriaElement} conditions to be met
441
+     * @param bool $id_as_key use the answerid as key for the array?
442
+     * @return array array of {@link sfAnswer} objects
443
+     */
444 444
     function &getObjects($criteria = null, $id_as_key = false)
445 445
     {
446 446
         $ret = array();
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
     }
475 475
 
476 476
     /**
477
-    * retrieve 1 official answer (for now SmartFAQ only allow 1 official answer...)
478
-    *
479
-    * @param object $criteria {@link CriteriaElement} conditions to be met
480
-    * @param int $faqid
481
-    * @return mixed reference to the {@link sfAnswer} object, FALSE if failed
482
-    */
477
+     * retrieve 1 official answer (for now SmartFAQ only allow 1 official answer...)
478
+     *
479
+     * @param object $criteria {@link CriteriaElement} conditions to be met
480
+     * @param int $faqid
481
+     * @return mixed reference to the {@link sfAnswer} object, FALSE if failed
482
+     */
483 483
     function &getOfficialAnswer($faqid=0)
484 484
     {
485 485
         $theaAnswers =& $this->getAllAnswers($faqid, _SF_AN_STATUS_APPROVED, 1, 0);
@@ -493,12 +493,12 @@  discard block
 block discarded – undo
493 493
     }
494 494
 
495 495
     /**
496
-    * retrieve all answers
497
-    *
498
-    * @param object $criteria {@link CriteriaElement} conditions to be met
499
-    * @param int $faqid
500
-    * @return array array of {@link sfAnswer} objects
501
-    */
496
+     * retrieve all answers
497
+     *
498
+     * @param object $criteria {@link CriteriaElement} conditions to be met
499
+     * @param int $faqid
500
+     * @return array array of {@link sfAnswer} objects
501
+     */
502 502
     function &getAllAnswers($faqid=0, $status = -1, $limit = 0, $start = 0, $sort = 'datesub', $order = 'DESC')
503 503
     {
504 504
         $hasStatusCriteria = false;
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
     }
532 532
 
533 533
     /**
534
-    * count answers matching a condition
535
-    *
536
-    * @param object $criteria {@link CriteriaElement} to match
537
-    * @return int count of answers
538
-    */
534
+     * count answers matching a condition
535
+     *
536
+     * @param object $criteria {@link CriteriaElement} to match
537
+     * @return int count of answers
538
+     */
539 539
     function getCount($criteria = null)
540 540
     {
541 541
         $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('smartfaq_answers');
@@ -552,11 +552,11 @@  discard block
 block discarded – undo
552 552
     }
553 553
 
554 554
     /**
555
-    * count answers matching a condition and group by faq ID
556
-    *
557
-    * @param object $criteria {@link CriteriaElement} to match
558
-    * @return array
559
-    */
555
+     * count answers matching a condition and group by faq ID
556
+     *
557
+     * @param object $criteria {@link CriteriaElement} to match
558
+     * @return array
559
+     */
560 560
     function getCountByFAQ($criteria = null)
561 561
     {
562 562
         $sql = 'SELECT faqid, COUNT(*) FROM '.$this->db->prefix('smartfaq_answers');
@@ -580,11 +580,11 @@  discard block
 block discarded – undo
580 580
     }
581 581
 
582 582
     /**
583
-    * delete answers matching a set of conditions
584
-    *
585
-    * @param object $criteria {@link CriteriaElement}
586
-    * @return bool FALSE if deletion failed
587
-    */
583
+     * delete answers matching a set of conditions
584
+     *
585
+     * @param object $criteria {@link CriteriaElement}
586
+     * @return bool FALSE if deletion failed
587
+     */
588 588
     function deleteAll($criteria = null)
589 589
     {
590 590
         $sql = 'DELETE FROM '.$this->db->prefix('smartfaq_answers');
@@ -599,14 +599,14 @@  discard block
 block discarded – undo
599 599
     }
600 600
 
601 601
     /**
602
-    * Change a value for answers with a certain criteria
603
-    *
604
-    * @param   string  $fieldname  Name of the field
605
-    * @param   string  $fieldvalue Value to write
606
-    * @param   object  $criteria   {@link CriteriaElement}
607
-    *
608
-    * @return  bool
609
-    **/
602
+     * Change a value for answers with a certain criteria
603
+     *
604
+     * @param   string  $fieldname  Name of the field
605
+     * @param   string  $fieldvalue Value to write
606
+     * @param   object  $criteria   {@link CriteriaElement}
607
+     *
608
+     * @return  bool
609
+     **/
610 610
     function updateAll($fieldname, $fieldvalue, $criteria = null)
611 611
     {
612 612
         $set_clause = is_numeric($fieldvalue)? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
     /**
26 26
     * constructor
27 27
     */
28
-    function __construct ($id = null)
28
+    function __construct($id = null)
29 29
     {
30
-        $this->db =& XoopsDatabaseFactory::getDatabaseConnection();
30
+        $this->db = & XoopsDatabaseFactory::getDatabaseConnection();
31 31
         $this->initVar("answerid", XOBJ_DTYPE_INT, null, false);
32 32
         $this->initVar("status", XOBJ_DTYPE_INT, -1, false);
33 33
         $this->initVar("faqid", XOBJ_DTYPE_INT, null, false);
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                 $this->assignVars($id);
51 51
             } else {
52 52
                 $answer_handler = new sfAnswerHandler($this->db);
53
-                $answer =& $answer_handler->get($id);
53
+                $answer = & $answer_handler->get($id);
54 54
                 foreach ($answer->vars as $k => $v) {
55 55
                     $this->assignVar($k, $v['value']);
56 56
                 }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     function incrementDownload($attach_key)
74 74
     {
75 75
         if (!$attach_key) return false;
76
-        $this->attachment_array[strval($attach_key)]['num_download'] ++;
76
+        $this->attachment_array[strval($attach_key)]['num_download']++;
77 77
 
78 78
         return $this->attachment_array[strval($attach_key)]['num_download'];
79 79
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $attachment_save = base64_encode(serialize($this->attachment_array));
85 85
         else $attachment_save = '';
86 86
         $this->setVar('attachment', $attachment_save);
87
-        $sql = "UPDATE " . $GLOBALS["xoopsDB"]->prefix("smartfaq_answers") . " SET attachment=" . $GLOBALS["xoopsDB"]->quoteString($attachment_save) . " WHERE post_id = " . $this->getVar('answerid');
87
+        $sql = "UPDATE ".$GLOBALS["xoopsDB"]->prefix("smartfaq_answers")." SET attachment=".$GLOBALS["xoopsDB"]->quoteString($attachment_save)." WHERE post_id = ".$this->getVar('answerid');
88 88
         if (!$result = $GLOBALS["xoopsDB"]->queryF($sql)) {
89 89
             //xoops_error($GLOBALS["xoopsDB"]->error());
90 90
             return false;
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 
107 107
         foreach ($attach_old as $key => $attach) {
108 108
             if (in_array($key, $attach_array)) {
109
-                @unlink(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/' . $attach['name_saved']);
110
-                @unlink(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/thumbs/' . $attach['name_saved']); // delete thumbnails
109
+                @unlink(XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig['dir_attachments'].'/'.$attach['name_saved']);
110
+                @unlink(XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig['dir_attachments'].'/thumbs/'.$attach['name_saved']); // delete thumbnails
111 111
                 continue;
112 112
             }
113 113
             $this->attachment_array[$key] = $attach;
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 
123 123
     function setAttachment($name_saved = '', $name_display = '', $mimetype = '', $num_download = 0)
124 124
     {
125
-        static $counter=0;
125
+        static $counter = 0;
126 126
         $this->attachment_array = $this->getAttachment();
127 127
         if ($name_saved) {
128 128
             $key = strval(time()+$counter++);
129 129
             $this->attachment_array[$key] = array('name_saved' => $name_saved,
130
-                'name_display' => isset($name_display)?$name_display:$name_saved,
130
+                'name_display' => isset($name_display) ? $name_display : $name_saved,
131 131
                 'mimetype' => $mimetype,
132
-                'num_download' => isset($num_download)?intval($num_download):0
132
+                'num_download' => isset($num_download) ? intval($num_download) : 0
133 133
                 );
134 134
         }
135 135
         if (is_array($this->attachment_array)) {
@@ -154,30 +154,30 @@  discard block
 block discarded – undo
154 154
         if (is_array($attachments) && count($attachments) > 0) {
155 155
             $icon_handler = sf_getIconHandler();
156 156
             $mime_path = $icon_handler->getPath("mime");
157
-            include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar("dirname", "n") . '/include/functions.image.php';
157
+            include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar("dirname", "n").'/include/functions.image.php';
158 158
             $image_extensions = array("jpg", "jpeg", "gif", "png", "bmp"); // need improve !!!
159
-            $post_attachment .= '<br /><strong>' . _MD_ATTACHMENT . '</strong>:';
159
+            $post_attachment .= '<br /><strong>'._MD_ATTACHMENT.'</strong>:';
160 160
             $post_attachment .= '<br /><hr size="1" noshade="noshade" /><br />';
161 161
             foreach ($attachments as $key => $att) {
162 162
                 $file_extension = ltrim(strrchr($att['name_saved'], '.'), '.');
163 163
                 $filetype = $file_extension;
164
-                if (file_exists(XOOPS_ROOT_PATH . '/' . $mime_path . '/' . $filetype . '.gif')) {
165
-                    $icon_filetype = XOOPS_URL . '/' . $mime_path . '/' . $filetype . '.gif';
164
+                if (file_exists(XOOPS_ROOT_PATH.'/'.$mime_path.'/'.$filetype.'.gif')) {
165
+                    $icon_filetype = XOOPS_URL.'/'.$mime_path.'/'.$filetype.'.gif';
166 166
                 } else {
167
-                    $icon_filetype = XOOPS_URL . '/' . $mime_path . '/unknown.gif';
167
+                    $icon_filetype = XOOPS_URL.'/'.$mime_path.'/unknown.gif';
168 168
                 }
169
-                $file_size = @filesize(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/' . $att['name_saved']);
170
-                $file_size = number_format ($file_size / 1024, 2)." KB";
169
+                $file_size = @filesize(XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig['dir_attachments'].'/'.$att['name_saved']);
170
+                $file_size = number_format($file_size / 1024, 2)." KB";
171 171
                 if (in_array(strtolower($file_extension), $image_extensions) && $xoopsModuleConfig['media_allowed']) {
172
-                        $post_attachment .= '<br /><img src="' . $icon_filetype . '" alt="' . $filetype . '" /><strong>&nbsp; ' . $att['name_display'] . '</strong> <small>('.$file_size.')</small>';
173
-                        $post_attachment .= '<br />' . sf_attachmentImage($att['name_saved']);
172
+                        $post_attachment .= '<br /><img src="'.$icon_filetype.'" alt="'.$filetype.'" /><strong>&nbsp; '.$att['name_display'].'</strong> <small>('.$file_size.')</small>';
173
+                        $post_attachment .= '<br />'.sf_attachmentImage($att['name_saved']);
174 174
                         $isDisplayed = true;
175 175
                 } else {
176 176
                     global $xoopsUser;
177 177
                     if (empty($xoopsModuleConfig['show_userattach'])) {
178
-                        $post_attachment .= '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar("dirname", "n") . '/dl_attachment.php?attachid=' . $key . '&amp;post_id=' . $this->getVar('post_id') . '"> <img src="' . $icon_filetype . '" alt="' . $filetype . '" /> ' . $att['name_display'] . '</a> ' . _MD_FILESIZE . ': '. $file_size . '; '._MD_HITS.': ' . $att['num_download'];
179
-                    } elseif (($xoopsUser && $xoopsUser->uid() > 0 && $xoopsUser->isactive()) ) {
180
-                        $post_attachment .= '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar("dirname", "n") . '/dl_attachment.php?attachid=' . $key . '&amp;post_id=' . $this->getVar('post_id') . '"> <img src="' . $icon_filetype . '" alt="' . $filetype . '" /> ' . $att['name_display'] . '</a> ' . _MD_FILESIZE . ': '. $file_size . '; '._MD_HITS.': ' . $att['num_download'];
178
+                        $post_attachment .= '<a href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar("dirname", "n").'/dl_attachment.php?attachid='.$key.'&amp;post_id='.$this->getVar('post_id').'"> <img src="'.$icon_filetype.'" alt="'.$filetype.'" /> '.$att['name_display'].'</a> '._MD_FILESIZE.': '.$file_size.'; '._MD_HITS.': '.$att['num_download'];
179
+                    } elseif (($xoopsUser && $xoopsUser->uid() > 0 && $xoopsUser->isactive())) {
180
+                        $post_attachment .= '<a href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar("dirname", "n").'/dl_attachment.php?attachid='.$key.'&amp;post_id='.$this->getVar('post_id').'"> <img src="'.$icon_filetype.'" alt="'.$filetype.'" /> '.$att['name_display'].'</a> '._MD_FILESIZE.': '.$file_size.'; '._MD_HITS.': '.$att['num_download'];
181 181
                     } else {
182 182
                         $post_attachment .= _MD_NEWBB_SEENOTGUEST;
183 183
                     }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         return $this->getVar("faqid");
214 214
     }
215 215
 
216
-    function answer($format="S")
216
+    function answer($format = "S")
217 217
     {
218 218
         return $this->getVar("answer", $format);
219 219
     }
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
         return $this->getVar("uid");
224 224
     }
225 225
 
226
-    function datesub($dateFormat='none', $format="S")
226
+    function datesub($dateFormat = 'none', $format = "S")
227 227
     {
228 228
         if ($dateFormat == 'none') {
229
-            $smartModuleConfig =& sf_getModuleConfig();
229
+            $smartModuleConfig = & sf_getModuleConfig();
230 230
             $dateFormat = $smartModuleConfig['dateformat'];
231 231
         }
232 232
 
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
 
241 241
     function notLoaded()
242 242
     {
243
-       return ($this->getVar('answerid')== -1);
243
+       return ($this->getVar('answerid') == -1);
244 244
     }
245 245
 
246
-    function sendNotifications($notifications=array())
246
+    function sendNotifications($notifications = array())
247 247
     {
248
-        $smartModule =& sf_getModuleInfo();
248
+        $smartModule = & sf_getModuleInfo();
249 249
 
250
-        $myts =& MyTextSanitizer::getInstance();
250
+        $myts = & MyTextSanitizer::getInstance();
251 251
         $notification_handler = &xoops_gethandler('notification');
252 252
 
253 253
         $faqObj = new sfFaq($this->faqid());
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
         $tags = array();
256 256
         $tags['MODULE_NAME'] = $myts->displayTarea($smartModule->getVar('name'));
257 257
         $tags['FAQ_NAME'] = $faqObj->question();
258
-        $tags['FAQ_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/faq.php?faqid=' . $faqObj->faqid();
258
+        $tags['FAQ_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/faq.php?faqid='.$faqObj->faqid();
259 259
         $tags['CATEGORY_NAME'] = $faqObj->getCategoryName();
260
-        $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/category.php?categoryid=' . $faqObj->categoryid();
260
+        $tags['CATEGORY_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/category.php?categoryid='.$faqObj->categoryid();
261 261
         $tags['FAQ_QUESTION'] = $faqObj->question();
262 262
 
263 263
         // TODO : Not sure about the 'formpreview' ...
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         if (strtolower(get_class($faqObj)) != 'sffaq') {
424 424
             return false;
425 425
         }
426
-        $answers =& $this->getAllAnswers($faqObj->faqid());
426
+        $answers = & $this->getAllAnswers($faqObj->faqid());
427 427
         $result = true;
428 428
         foreach ($answers as $answer) {
429 429
             if (!$this->delete($answer)) {
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
             $answer = new sfAnswer();
464 464
             $answer->assignVars($myrow);
465 465
             if (!$id_as_key) {
466
-                $ret[] =& $answer;
466
+                $ret[] = & $answer;
467 467
             } else {
468
-                $ret[$myrow['answerid']] =& $answer;
468
+                $ret[$myrow['answerid']] = & $answer;
469 469
             }
470 470
             unset($answer);
471 471
         }
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
     * @param int $faqid
481 481
     * @return mixed reference to the {@link sfAnswer} object, FALSE if failed
482 482
     */
483
-    function &getOfficialAnswer($faqid=0)
483
+    function &getOfficialAnswer($faqid = 0)
484 484
     {
485
-        $theaAnswers =& $this->getAllAnswers($faqid, _SF_AN_STATUS_APPROVED, 1, 0);
485
+        $theaAnswers = & $this->getAllAnswers($faqid, _SF_AN_STATUS_APPROVED, 1, 0);
486 486
         if (count($theaAnswers) == 1) {
487 487
             $ret = $theaAnswers[0];
488 488
         } else {
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
     * @param int $faqid
500 500
     * @return array array of {@link sfAnswer} objects
501 501
     */
502
-    function &getAllAnswers($faqid=0, $status = -1, $limit = 0, $start = 0, $sort = 'datesub', $order = 'DESC')
502
+    function &getAllAnswers($faqid = 0, $status = -1, $limit = 0, $start = 0, $sort = 'datesub', $order = 'DESC')
503 503
     {
504 504
         $hasStatusCriteria = false;
505 505
         $criteriaStatus = new CriteriaCompo();
506
-        if ( is_array($status)) {
506
+        if (is_array($status)) {
507 507
             $hasStatusCriteria = true;
508 508
             foreach ($status as $v) {
509 509
                 $criteriaStatus->add(new Criteria('status', $v), 'OR');
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
     **/
610 610
     function updateAll($fieldname, $fieldvalue, $criteria = null)
611 611
     {
612
-        $set_clause = is_numeric($fieldvalue)? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
612
+        $set_clause = is_numeric($fieldvalue) ? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
613 613
         $sql = 'UPDATE '.$this->db->prefix('smartfaq_answers').' SET '.$set_clause;
614 614
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
615 615
             $sql .= ' '.$criteria->renderWhere();
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
     {
627 627
         $ret = array();
628 628
         $sql = "SELECT faqid, answer, uid, datesub FROM ".$this->db->prefix("smartfaq_answers")."
629
-               WHERE faqid IN (".implode(',', $faqids).") AND status = ". _SF_AN_STATUS_APPROVED." GROUP BY faqid";
629
+               WHERE faqid IN (".implode(',', $faqids).") AND status = "._SF_AN_STATUS_APPROVED." GROUP BY faqid";
630 630
         $result = $this->db->query($sql);
631 631
         if (!$result) {
632 632
             return $ret;
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
         while ($row = $this->db->fetchArray($result)) {
635 635
             $answer = new sfAnswer();
636 636
             $answer->assignVars($row);
637
-            $ret[$row['faqid']] =& $answer;
637
+            $ret[$row['faqid']] = & $answer;
638 638
             unset($answer);
639 639
         }
640 640
 
Please login to merge, or discard this patch.
Braces   +31 added lines, -13 removed lines patch added patch discarded remove patch
@@ -62,17 +62,24 @@  discard block
 block discarded – undo
62 62
     // attachment functions    TODO: there should be a file/attachment management class
63 63
     function getAttachment()
64 64
     {
65
-        if (count($this->attachment_array)) return $this->attachment_array;
65
+        if (count($this->attachment_array)) {
66
+            return $this->attachment_array;
67
+        }
66 68
         $attachment = $this->getVar('attachment');
67
-        if (empty($attachment)) $this->attachment_array = null;
68
-        else $this->attachment_array = @unserialize(base64_decode($attachment));
69
+        if (empty($attachment)) {
70
+            $this->attachment_array = null;
71
+        } else {
72
+            $this->attachment_array = @unserialize(base64_decode($attachment));
73
+        }
69 74
 
70 75
         return $this->attachment_array;
71 76
     }
72 77
 
73 78
     function incrementDownload($attach_key)
74 79
     {
75
-        if (!$attach_key) return false;
80
+        if (!$attach_key) {
81
+            return false;
82
+        }
76 83
         $this->attachment_array[strval($attach_key)]['num_download'] ++;
77 84
 
78 85
         return $this->attachment_array[strval($attach_key)]['num_download'];
@@ -80,9 +87,11 @@  discard block
 block discarded – undo
80 87
 
81 88
     function saveAttachment()
82 89
     {
83
-        if (is_array($this->attachment_array) && count($this->attachment_array) > 0)
84
-            $attachment_save = base64_encode(serialize($this->attachment_array));
85
-        else $attachment_save = '';
90
+        if (is_array($this->attachment_array) && count($this->attachment_array) > 0) {
91
+                    $attachment_save = base64_encode(serialize($this->attachment_array));
92
+        } else {
93
+            $attachment_save = '';
94
+        }
86 95
         $this->setVar('attachment', $attachment_save);
87 96
         $sql = "UPDATE " . $GLOBALS["xoopsDB"]->prefix("smartfaq_answers") . " SET attachment=" . $GLOBALS["xoopsDB"]->quoteString($attachment_save) . " WHERE post_id = " . $this->getVar('answerid');
88 97
         if (!$result = $GLOBALS["xoopsDB"]->queryF($sql)) {
@@ -98,11 +107,18 @@  discard block
 block discarded – undo
98 107
         global $xoopsModuleConfig;
99 108
 
100 109
         $attach_old = $this->getAttachment();
101
-        if (!is_array($attach_old) || count($attach_old) < 1) return true;
110
+        if (!is_array($attach_old) || count($attach_old) < 1) {
111
+            return true;
112
+        }
102 113
         $this->attachment_array = array();
103 114
 
104
-        if ($attach_array === null) $attach_array = array_keys($attach_old); // to delete all!
105
-        if (!is_array($attach_array)) $attach_array = array($attach_array);
115
+        if ($attach_array === null) {
116
+            $attach_array = array_keys($attach_old);
117
+        }
118
+        // to delete all!
119
+        if (!is_array($attach_array)) {
120
+            $attach_array = array($attach_array);
121
+        }
106 122
 
107 123
         foreach ($attach_old as $key => $attach) {
108 124
             if (in_array($key, $attach_array)) {
@@ -112,9 +128,11 @@  discard block
 block discarded – undo
112 128
             }
113 129
             $this->attachment_array[$key] = $attach;
114 130
         }
115
-        if (is_array($this->attachment_array) && count($this->attachment_array) > 0)
116
-            $attachment_save = base64_encode(serialize($this->attachment_array));
117
-        else $attachment_save = '';
131
+        if (is_array($this->attachment_array) && count($this->attachment_array) > 0) {
132
+                    $attachment_save = base64_encode(serialize($this->attachment_array));
133
+        } else {
134
+            $attachment_save = '';
135
+        }
118 136
         $this->setVar('attachment', $attachment_save);
119 137
 
120 138
         return true;
Please login to merge, or discard this patch.
smartfaq/class/category.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     * create a new category
229 229
     *
230 230
     * @param bool $isNew flag the new objects as "new"?
231
-    * @return object sfCategory
231
+    * @return sfCategory sfCategory
232 232
     */
233 233
     function &create($isNew = true)
234 234
     {
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     /**
271 271
     * insert a new category in the database
272 272
     *
273
-    * @param object $category reference to the {@link sfCategory} object
273
+    * @param sfCategory $category reference to the {@link sfCategory} object
274 274
     * @param bool $force
275 275
     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
276 276
     */
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
     var $_groups_admin = null;
25 25
 
26 26
     /**
27
-    * constructor
28
-    */
27
+     * constructor
28
+     */
29 29
     function __construct($id = null)
30 30
     {
31 31
         $this->db =& XoopsDatabaseFactory::getDatabaseConnection();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     function notLoaded()
61 61
     {
62
-       return ($this->getVar('categoryid')== -1);
62
+        return ($this->getVar('categoryid')== -1);
63 63
     }
64 64
 
65 65
     function assignOtherProperties()
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
     function setGroups_read($groups_read = array('0'))
162 162
     {
163
-      $this->_groups_read = $groups_read;
163
+        $this->_groups_read = $groups_read;
164 164
     }
165 165
 
166 166
     function store($sendNotifications = true, $force = true )
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 class sfCategoryHandler extends XoopsObjectHandler
226 226
 {
227 227
     /**
228
-    * create a new category
229
-    *
230
-    * @param bool $isNew flag the new objects as "new"?
231
-    * @return object sfCategory
232
-    */
228
+     * create a new category
229
+     *
230
+     * @param bool $isNew flag the new objects as "new"?
231
+     * @return object sfCategory
232
+     */
233 233
     function &create($isNew = true)
234 234
     {
235 235
         $category = new sfCategory();
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
     }
242 242
 
243 243
     /**
244
-    * retrieve a category
245
-    *
246
-    * @param int $id categoryid of the category
247
-    * @return mixed reference to the {@link sfCategory} object, FALSE if failed
248
-    */
244
+     * retrieve a category
245
+     *
246
+     * @param int $id categoryid of the category
247
+     * @return mixed reference to the {@link sfCategory} object, FALSE if failed
248
+     */
249 249
     function &get($id)
250 250
     {
251 251
         $false = false;
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
     }
269 269
 
270 270
     /**
271
-    * insert a new category in the database
272
-    *
273
-    * @param object $category reference to the {@link sfCategory} object
274
-    * @param bool $force
275
-    * @return bool FALSE if failed, TRUE if already present and unchanged or successful
276
-    */
271
+     * insert a new category in the database
272
+     *
273
+     * @param object $category reference to the {@link sfCategory} object
274
+     * @param bool $force
275
+     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
276
+     */
277 277
     function insert(&$category, $force = false)
278 278
     {
279 279
         if (strtolower(get_class($category)) != 'sfcategory') {
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
     }
314 314
 
315 315
     /**
316
-    * delete a category from the database
317
-    *
318
-    * @param object $category reference to the category to delete
319
-    * @param bool $force
320
-    * @return bool FALSE if failed.
321
-    */
316
+     * delete a category from the database
317
+     *
318
+     * @param object $category reference to the category to delete
319
+     * @param bool $force
320
+     * @return bool FALSE if failed.
321
+     */
322 322
     function delete(&$category, $force = false)
323 323
     {
324 324
 
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
     }
361 361
 
362 362
     /**
363
-    * retrieve categories from the database
364
-    *
365
-    * @param object $criteria {@link CriteriaElement} conditions to be met
366
-    * @param bool $id_as_key use the categoryid as key for the array?
367
-    * @return array array of {@link XoopsFaq} objects
368
-    */
363
+     * retrieve categories from the database
364
+     *
365
+     * @param object $criteria {@link CriteriaElement} conditions to be met
366
+     * @param bool $id_as_key use the categoryid as key for the array?
367
+     * @return array array of {@link XoopsFaq} objects
368
+     */
369 369
     function &getObjects($criteria = null, $id_as_key = false)
370 370
     {
371 371
         $ret = array();
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
     }
477 477
 
478 478
     /**
479
-    * count Categories matching a condition
480
-    *
481
-    * @param object $criteria {@link CriteriaElement} to match
482
-    * @return int count of categories
483
-    */
479
+     * count Categories matching a condition
480
+     *
481
+     * @param object $criteria {@link CriteriaElement} to match
482
+     * @return int count of categories
483
+     */
484 484
     function getCount($criteria = null)
485 485
     {
486 486
         $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('smartfaq_categories');
@@ -569,11 +569,11 @@  discard block
 block discarded – undo
569 569
     }
570 570
 
571 571
     /**
572
-    * delete categories matching a set of conditions
573
-    *
574
-    * @param object $criteria {@link CriteriaElement}
575
-    * @return bool FALSE if deletion failed
576
-    */
572
+     * delete categories matching a set of conditions
573
+     *
574
+     * @param object $criteria {@link CriteriaElement}
575
+     * @return bool FALSE if deletion failed
576
+     */
577 577
     function deleteAll($criteria = null)
578 578
     {
579 579
         $sql = 'DELETE FROM '.$this->db->prefix('smartfaq_categories');
@@ -590,14 +590,14 @@  discard block
 block discarded – undo
590 590
     }
591 591
 
592 592
     /**
593
-    * Change a value for categories with a certain criteria
594
-    *
595
-    * @param   string  $fieldname  Name of the field
596
-    * @param   string  $fieldvalue Value to write
597
-    * @param   object  $criteria   {@link CriteriaElement}
598
-    *
599
-    * @return  bool
600
-    **/
593
+     * Change a value for categories with a certain criteria
594
+     *
595
+     * @param   string  $fieldname  Name of the field
596
+     * @param   string  $fieldvalue Value to write
597
+     * @param   object  $criteria   {@link CriteriaElement}
598
+     *
599
+     * @return  bool
600
+     **/
601 601
     function updateAll($fieldname, $fieldvalue, $criteria = null)
602 602
     {
603 603
         $set_clause = is_numeric($fieldvalue)? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     */
29 29
     function __construct($id = null)
30 30
     {
31
-        $this->db =& XoopsDatabaseFactory::getDatabaseConnection();
31
+        $this->db = & XoopsDatabaseFactory::getDatabaseConnection();
32 32
         $this->initVar("categoryid", XOBJ_DTYPE_INT, null, false);
33 33
         $this->initVar("parentid", XOBJ_DTYPE_INT, null, false);
34 34
         $this->initVar("name", XOBJ_DTYPE_TXTBOX, null, true, 100);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                 $this->assignVars($id);
49 49
             } else {
50 50
                 $category_handler = new sfCategoryHandler($this->db);
51
-                $category =& $category_handler->get($id);
51
+                $category = & $category_handler->get($id);
52 52
                 foreach ($category->vars as $k => $v) {
53 53
                     $this->assignVar($k, $v['value']);
54 54
                 }
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 
60 60
     function notLoaded()
61 61
     {
62
-       return ($this->getVar('categoryid')== -1);
62
+       return ($this->getVar('categoryid') == -1);
63 63
     }
64 64
 
65 65
     function assignOtherProperties()
66 66
     {
67 67
         global $xoopsUser;
68
-        $smartModule =& sf_getModuleInfo();
68
+        $smartModule = & sf_getModuleInfo();
69 69
         $module_id = $smartModule->getVar('mid');
70 70
 
71 71
         $gperm_handler = &xoops_gethandler('groupperm');
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
             return true;
83 83
         }
84 84
 
85
-        $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
85
+        $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
86 86
 
87 87
         $categoriesGranted = $smartPermHandler->getPermissions('category');
88
-        if ( in_array($this->categoryid(), $categoriesGranted) ) {
88
+        if (in_array($this->categoryid(), $categoriesGranted)) {
89 89
             $ret = true;
90 90
         }
91 91
 
@@ -102,18 +102,18 @@  discard block
 block discarded – undo
102 102
         return $this->getVar("parentid");
103 103
     }
104 104
 
105
-    function name($format="S")
105
+    function name($format = "S")
106 106
     {
107 107
         $ret = $this->getVar("name", $format);
108
-        if (($format=='s') || ($format=='S') || ($format=='show')) {
109
-            $myts =& MyTextSanitizer::getInstance();
108
+        if (($format == 's') || ($format == 'S') || ($format == 'show')) {
109
+            $myts = & MyTextSanitizer::getInstance();
110 110
             $ret = $myts->displayTarea($ret);
111 111
         }
112 112
 
113 113
         return $ret;
114 114
     }
115 115
 
116
-    function description($format="S")
116
+    function description($format = "S")
117 117
     {
118 118
         return $this->getVar("description", $format);
119 119
     }
@@ -131,19 +131,19 @@  discard block
 block discarded – undo
131 131
             $filename = "category.php";
132 132
         }
133 133
         if ($withAllLink) {
134
-            $ret = "<a href='" . XOOPS_URL . "/modules/smartfaq/".$filename."?categoryid=" . $this->categoryid() . "'>" . $this->name() . "</a>";
134
+            $ret = "<a href='".XOOPS_URL."/modules/smartfaq/".$filename."?categoryid=".$this->categoryid()."'>".$this->name()."</a>";
135 135
         } else {
136 136
             $ret = $this->name();
137 137
         }
138 138
         $parentid = $this->parentid();
139
-        $category_handler =& sf_gethandler('category');
139
+        $category_handler = & sf_gethandler('category');
140 140
         if ($parentid != 0) {
141
-            $parentObj =& $category_handler->get($parentid);
141
+            $parentObj = & $category_handler->get($parentid);
142 142
             if ($parentObj->notLoaded()) {
143 143
                 exit;
144 144
             }
145 145
             $parentid = $parentObj->parentid();
146
-            $ret = $parentObj->getCategoryPath(true, $open) . " > " .$ret;
146
+            $ret = $parentObj->getCategoryPath(true, $open)." > ".$ret;
147 147
         }
148 148
 
149 149
         return $ret;
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
       $this->_groups_read = $groups_read;
164 164
     }
165 165
 
166
-    function store($sendNotifications = true, $force = true )
166
+    function store($sendNotifications = true, $force = true)
167 167
     {
168 168
         $category_handler = new sfCategoryHandler($this->db);
169 169
 
170 170
         $ret = $category_handler->insert($this, $force);
171
-        if ( $sendNotifications && $ret && ($this->isNew()) ) {
171
+        if ($sendNotifications && $ret && ($this->isNew())) {
172 172
             $this->sendNotifications();
173 173
         }
174 174
         $this->unsetNew();
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
 
179 179
     function sendNotifications()
180 180
     {
181
-        $smartModule =& sf_getModuleInfo();
181
+        $smartModule = & sf_getModuleInfo();
182 182
 
183
-        $myts =& MyTextSanitizer::getInstance();
183
+        $myts = & MyTextSanitizer::getInstance();
184 184
         $notification_handler = &xoops_gethandler('notification');
185 185
 
186 186
         $tags = array();
187 187
         $tags['MODULE_NAME'] = $myts->htmlSpecialChars($smartModule->getVar('name'));
188 188
         $tags['CATEGORY_NAME'] = $this->name();
189
-        $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $smartModule->getVar('dirname') . '/category.php?categoryid=' . $this->categoryid();
189
+        $tags['CATEGORY_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/category.php?categoryid='.$this->categoryid();
190 190
 
191 191
         $notification_handler = &xoops_gethandler('notification');
192 192
         $notification_handler->triggerEvent('global_faq', 0, 'category_created', $tags);
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
         $category['categoryid'] = $this->categoryid();
198 198
         $category['name'] = $this->name();
199 199
         if ($open != false) {
200
-            $category['categorylink'] = "<a href='" . XOOPS_URL . "/modules/smartfaq/open_category.php?categoryid=" . $this->categoryid() . "'>" . $this->name() . "</a>";
200
+            $category['categorylink'] = "<a href='".XOOPS_URL."/modules/smartfaq/open_category.php?categoryid=".$this->categoryid()."'>".$this->name()."</a>";
201 201
         } else {
202
-            $category['categorylink'] = "<a href='" . XOOPS_URL . "/modules/smartfaq/category.php?categoryid=" . $this->categoryid() . "'>" . $this->name() . "</a>";
202
+            $category['categorylink'] = "<a href='".XOOPS_URL."/modules/smartfaq/category.php?categoryid=".$this->categoryid()."'>".$this->name()."</a>";
203 203
         }
204 204
         $category['total'] = $this->getVar('faqcount');
205 205
         $category['description'] = $this->description();
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         }
292 292
 
293 293
         if ($category->isNew()) {
294
-            $sql = sprintf("INSERT INTO %s (categoryid, parentid, name, description, total, weight, created) VALUES (NULL, %u, %s, %s, %u, %u, %u)", $this->db->prefix('smartfaq_categories'),  $parentid, $this->db->quoteString($name), $this->db->quoteString($description), $total, $weight, time());
294
+            $sql = sprintf("INSERT INTO %s (categoryid, parentid, name, description, total, weight, created) VALUES (NULL, %u, %s, %s, %u, %u, %u)", $this->db->prefix('smartfaq_categories'), $parentid, $this->db->quoteString($name), $this->db->quoteString($description), $total, $weight, time());
295 295
         } else {
296 296
             $sql = sprintf("UPDATE %s SET parentid = %u, name = %s, description = %s, total = %s, weight = %u, created = %u WHERE categoryid = %u", $this->db->prefix('smartfaq_categories'), $parentid, $this->db->quoteString($name), $this->db->quoteString($description), $total, $weight, $created, $categoryid);
297 297
         }
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
         }
334 334
 
335 335
         // Deleteing the sub categories
336
-        $subcats =& $this->getCategories(0, 0, $category->categoryid());
336
+        $subcats = & $this->getCategories(0, 0, $category->categoryid());
337 337
         foreach ($subcats as $subcat) {
338 338
             $this->delete($subcat);
339 339
         }
340 340
 
341 341
         $sql = sprintf("DELETE FROM %s WHERE categoryid = %u", $this->db->prefix("smartfaq_categories"), $category->getVar('categoryid'));
342 342
 
343
-        $smartModule =& sf_getModuleInfo();
343
+        $smartModule = & sf_getModuleInfo();
344 344
         $module_id = $smartModule->getVar('mid');
345 345
 
346 346
         if (false != $force) {
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             $result = $this->db->query($sql);
350 350
         }
351 351
 
352
-        xoops_groupperm_deletebymoditem ($module_id, "category_read", $category->categoryid());
352
+        xoops_groupperm_deletebymoditem($module_id, "category_read", $category->categoryid());
353 353
         //xoops_groupperm_deletebymoditem ($module_id, "category_admin", $categoryObj->categoryid());
354 354
 
355 355
         if (!$result) {
@@ -389,9 +389,9 @@  discard block
 block discarded – undo
389 389
             $category = new sfCategory();
390 390
             $category->assignVars($myrow);
391 391
             if (!$id_as_key) {
392
-                $ret[] =& $category;
392
+                $ret[] = & $category;
393 393
             } else {
394
-                $ret[$myrow['categoryid']] =& $category;
394
+                $ret[$myrow['categoryid']] = & $category;
395 395
             }
396 396
             unset($category);
397 397
         }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         return $ret;
400 400
     }
401 401
 
402
-    function &getCategories($limit=0, $start=0, $parentid=0, $sort='weight', $order='ASC', $id_as_key = true)
402
+    function &getCategories($limit = 0, $start = 0, $parentid = 0, $sort = 'weight', $order = 'ASC', $id_as_key = true)
403 403
     {
404 404
         include_once XOOPS_ROOT_PATH.'/modules/smartfaq/include/functions.php';
405 405
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
             $criteria->add(new Criteria('parentid', $parentid));
413 413
         }
414 414
         if (!sf_userIsAdmin()) {
415
-            $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
415
+            $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
416 416
 
417 417
             $categoriesGranted = $smartPermHandler->getPermissions('category');
418 418
             $criteria->add(new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN'));
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
         return $ret;
425 425
     }
426 426
 
427
-    function &getCategoriesWithOpenQuestion($limit=0, $start=0, $parentid=0, $sort='weight', $order='ASC')
427
+    function &getCategoriesWithOpenQuestion($limit = 0, $start = 0, $parentid = 0, $sort = 'weight', $order = 'ASC')
428 428
     {
429 429
         include_once XOOPS_ROOT_PATH.'/modules/smartfaq/include/functions.php';
430 430
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
             $criteria->add(new Criteria('c.parentid', $parentid));
438 438
         }
439 439
         if (!sf_userIsAdmin()) {
440
-            $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
440
+            $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
441 441
 
442 442
             $categoriesGranted = $smartPermHandler->getPermissions('category');
443 443
             $criteria->add(new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN'));
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 
450 450
         $ret = array();
451 451
         $limit = $start = 0;
452
-        $sql = 'SELECT DISTINCT c.categoryid, c.parentid, c.name, c.description, c.total, c.weight, c.created FROM '.$this->db->prefix('smartfaq_categories') . ' AS c INNER JOIN '.$this->db->prefix('smartfaq_faq') . ' AS f ON c.categoryid = f.categoryid';
452
+        $sql = 'SELECT DISTINCT c.categoryid, c.parentid, c.name, c.description, c.total, c.weight, c.created FROM '.$this->db->prefix('smartfaq_categories').' AS c INNER JOIN '.$this->db->prefix('smartfaq_faq').' AS f ON c.categoryid = f.categoryid';
453 453
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
454 454
             $sql .= ' '.$criteria->renderWhere();
455 455
             if ($criteria->getSort() != '') {
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         while ($myrow = $this->db->fetchArray($result)) {
468 468
             $category = new sfCategory();
469 469
             $category->assignVars($myrow);
470
-            $ret[] =& $category;
470
+            $ret[] = & $category;
471 471
             unset($category);
472 472
         }
473 473
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
         return $count;
497 497
     }
498 498
 
499
-    function getCategoriesCount($parentid=0)
499
+    function getCategoriesCount($parentid = 0)
500 500
     {
501 501
 
502 502
         if ($parentid == -1) {
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
         if (isset($parentid) && ($parentid != -1)) {
507 507
             $criteria->add(new criteria('parentid', $parentid));
508 508
             if (!sf_userIsAdmin()) {
509
-                $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
509
+                $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
510 510
 
511 511
                 $categoriesGranted = $smartPermHandler->getPermissions('category');
512 512
                 $criteria->add(new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN'));
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
         return $this->getCount($criteria);
517 517
     }
518 518
 
519
-    function getCategoriesWithOpenQuestionsCount($parentid=0)
519
+    function getCategoriesWithOpenQuestionsCount($parentid = 0)
520 520
     {
521 521
 
522 522
         if ($parentid == -1) {
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         if (isset($parentid) && ($parentid != -1)) {
527 527
             $criteria->add(new criteria('parentid', $parentid));
528 528
             if (!sf_userIsAdmin()) {
529
-                $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
529
+                $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
530 530
 
531 531
                 $categoriesGranted = $smartPermHandler->getPermissions('category');
532 532
                 $criteria->add(new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN'));
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 
536 536
         $criteria->add(new Criteria('f.status', _SF_STATUS_OPENED));
537 537
 
538
-        $sql = 'SELECT COUNT(c.categoryid) FROM '.$this->db->prefix('smartfaq_categories') . ' AS c INNER JOIN '.$this->db->prefix('smartfaq_faq') . ' AS f ON c.categoryid = f.categoryid';
538
+        $sql = 'SELECT COUNT(c.categoryid) FROM '.$this->db->prefix('smartfaq_categories').' AS c INNER JOIN '.$this->db->prefix('smartfaq_faq').' AS f ON c.categoryid = f.categoryid';
539 539
 
540 540
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
541 541
             $sql .= ' '.$criteria->renderWhere();
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
         $criteria = new CriteriaCompo('parentid', "(".implode(',', array_keys($categories)).")", 'IN');
556 556
         $ret = array();
557 557
         if (!sf_userIsAdmin()) {
558
-            $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
558
+            $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
559 559
 
560 560
             $categoriesGranted = $smartPermHandler->getPermissions('category');
561 561
             $criteria->add(new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN'));
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
     **/
601 601
     function updateAll($fieldname, $fieldvalue, $criteria = null)
602 602
     {
603
-        $set_clause = is_numeric($fieldvalue)? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
603
+        $set_clause = is_numeric($fieldvalue) ? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
604 604
         $sql = 'UPDATE '.$this->db->prefix('smartfaq_categories').' SET '.$set_clause;
605 605
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
606 606
             $sql .= ' '.$criteria->renderWhere();
@@ -614,16 +614,16 @@  discard block
 block discarded – undo
614 614
 
615 615
     function publishedFaqsCount($cat_id = 0)
616 616
     {
617
-        return $this->faqsCount($cat_id, $status=array(_SF_STATUS_PUBLISHED, _SF_STATUS_NEW_ANSWER));
617
+        return $this->faqsCount($cat_id, $status = array(_SF_STATUS_PUBLISHED, _SF_STATUS_NEW_ANSWER));
618 618
     }
619 619
 
620
-    function faqsCount($cat_id = 0, $status='')
620
+    function faqsCount($cat_id = 0, $status = '')
621 621
     {
622 622
 
623 623
         Global $xoopsUser;
624 624
         include_once XOOPS_ROOT_PATH.'/modules/smartfaq/include/functions.php';
625 625
 
626
-        $faq_handler =& sf_gethandler('faq');
626
+        $faq_handler = & sf_gethandler('faq');
627 627
 
628 628
         return $faq_handler->getCountsByCat($cat_id, $status);
629 629
     }
Please login to merge, or discard this patch.
smartfaq/class/faq.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -207,6 +207,9 @@  discard block
 block discarded – undo
207 207
         return $ret;
208 208
     }
209 209
 
210
+    /**
211
+     * @return integer
212
+     */
210 213
     function uid()
211 214
     {
212 215
         return $this->getVar("uid");
@@ -619,7 +622,7 @@  discard block
 block discarded – undo
619 622
     /**
620 623
     * insert a new faq in the database
621 624
     *
622
-    * @param object $faq reference to the {@link sfFaq} object
625
+    * @param sfFaq $faq reference to the {@link sfFaq} object
623 626
     * @param bool $force
624 627
     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
625 628
     */
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
     var $_smartModule= null;
71 71
     var $_smartModuleConfig;
72 72
     /**
73
-    * constructor
74
-    */
73
+     * constructor
74
+     */
75 75
     function __construct($id= null)
76 76
     {
77 77
         $this->db= & XoopsDatabaseFactory::getDatabaseConnection();
@@ -591,11 +591,11 @@  discard block
 block discarded – undo
591 591
     }
592 592
 
593 593
     /**
594
-    * retrieve an FAQ
595
-    *
596
-    * @param int $id faqid of the user
597
-    * @return mixed reference to the {@link sfFaq} object, FALSE if failed
598
-    */
594
+     * retrieve an FAQ
595
+     *
596
+     * @param int $id faqid of the user
597
+     * @return mixed reference to the {@link sfFaq} object, FALSE if failed
598
+     */
599 599
     function & get($id)
600 600
     {
601 601
         if (intval($id) > 0) {
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
     }
618 618
 
619 619
     /**
620
-    * insert a new faq in the database
621
-    *
622
-    * @param object $faq reference to the {@link sfFaq} object
623
-    * @param bool $force
624
-    * @return bool FALSE if failed, TRUE if already present and unchanged or successful
625
-    */
620
+     * insert a new faq in the database
621
+     *
622
+     * @param object $faq reference to the {@link sfFaq} object
623
+     * @param bool $force
624
+     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
625
+     */
626 626
     function insert(& $faq, $force= false)
627 627
     {
628 628
 
@@ -668,12 +668,12 @@  discard block
 block discarded – undo
668 668
     }
669 669
 
670 670
     /**
671
-    * delete an FAQ from the database
672
-    *
673
-    * @param object $faq reference to the FAQ to delete
674
-    * @param bool $force
675
-    * @return bool FALSE if failed.
676
-    */
671
+     * delete an FAQ from the database
672
+     *
673
+     * @param object $faq reference to the FAQ to delete
674
+     * @param bool $force
675
+     * @return bool FALSE if failed.
676
+     */
677 677
     function delete(& $faq, $force= false)
678 678
     {
679 679
         $smartModule= & sf_getModuleInfo();
@@ -707,12 +707,12 @@  discard block
 block discarded – undo
707 707
     }
708 708
 
709 709
     /**
710
-    * retrieve FAQs from the database
711
-    *
712
-    * @param object $criteria {@link CriteriaElement} conditions to be met
713
-    * @param bool $id_as_key use the faqid as key for the array?
714
-    * @return array array of {@link sfFaq} objects
715
-    */
710
+     * retrieve FAQs from the database
711
+     *
712
+     * @param object $criteria {@link CriteriaElement} conditions to be met
713
+     * @param bool $id_as_key use the faqid as key for the array?
714
+     * @return array array of {@link sfFaq} objects
715
+     */
716 716
     function & getObjects($criteria= null, $id_as_key= false, $notNullFields= '')
717 717
     {
718 718
         $ret= array();
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
     }
852 852
 
853 853
     /**
854
-    * count FAQs matching a condition
855
-    *
856
-    * @param object $criteria {@link CriteriaElement} to match
857
-    * @return int count of FAQs
858
-    */
854
+     * count FAQs matching a condition
855
+     *
856
+     * @param object $criteria {@link CriteriaElement} to match
857
+     * @return int count of FAQs
858
+     */
859 859
     function getCount($criteria= null, $notNullFields= '')
860 860
     {
861 861
         $sql= 'SELECT COUNT(*) FROM '.$this->db->prefix('smartfaq_faq');
@@ -1224,11 +1224,11 @@  discard block
 block discarded – undo
1224 1224
     }
1225 1225
 
1226 1226
     /**
1227
-    * delete FAQs matching a set of conditions
1228
-    *
1229
-    * @param object $criteria {@link CriteriaElement}
1230
-    * @return bool FALSE if deletion failed
1231
-    */
1227
+     * delete FAQs matching a set of conditions
1228
+     *
1229
+     * @param object $criteria {@link CriteriaElement}
1230
+     * @return bool FALSE if deletion failed
1231
+     */
1232 1232
     function deleteAll($criteria= null)
1233 1233
     {
1234 1234
         $sql= 'DELETE FROM '.$this->db->prefix('smartfaq_faq');
@@ -1244,14 +1244,14 @@  discard block
 block discarded – undo
1244 1244
     }
1245 1245
 
1246 1246
     /**
1247
-    * Change a value for FAQ with a certain criteria
1248
-    *
1249
-    * @param   string  $fieldname  Name of the field
1250
-    * @param   string  $fieldvalue Value to write
1251
-    * @param   object  $criteria   {@link CriteriaElement}
1252
-    *
1253
-    * @return  bool
1254
-    **/
1247
+     * Change a value for FAQ with a certain criteria
1248
+     *
1249
+     * @param   string  $fieldname  Name of the field
1250
+     * @param   string  $fieldvalue Value to write
1251
+     * @param   object  $criteria   {@link CriteriaElement}
1252
+     *
1253
+     * @return  bool
1254
+     **/
1255 1255
     function updateAll($fieldname, $fieldvalue, $criteria= null)
1256 1256
     {
1257 1257
         $set_clause= is_numeric($fieldvalue) ? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
Please login to merge, or discard this patch.
Spacing   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -41,40 +41,40 @@  discard block
 block discarded – undo
41 41
      * @var sfCategory
42 42
      * @access private
43 43
      */
44
-    var $_category= null;
44
+    var $_category = null;
45 45
 
46 46
     /**
47 47
      * @var sfAnswer
48 48
      * @access private
49 49
      */
50
-    var $_answer= null;
50
+    var $_answer = null;
51 51
 
52 52
     /**
53 53
      * @var array
54 54
      * @access private
55 55
      */
56
-    var $_notifications= null;
56
+    var $_notifications = null;
57 57
     // TODO : Create a seperated class for notifications
58 58
 
59 59
     /**
60 60
      * @var array
61 61
      * @access private
62 62
      */
63
-    var $_groups_read= null;
63
+    var $_groups_read = null;
64 64
 
65 65
     /**
66 66
      * @var object
67 67
      * @access private
68 68
      */
69 69
     // Is this still usefull??
70
-    var $_smartModule= null;
70
+    var $_smartModule = null;
71 71
     var $_smartModuleConfig;
72 72
     /**
73 73
     * constructor
74 74
     */
75
-    function __construct($id= null)
75
+    function __construct($id = null)
76 76
     {
77
-        $this->db= & XoopsDatabaseFactory::getDatabaseConnection();
77
+        $this->db = & XoopsDatabaseFactory::getDatabaseConnection();
78 78
         $this->initVar("faqid", XOBJ_DTYPE_INT, -1, false);
79 79
         $this->initVar("categoryid", XOBJ_DTYPE_INT, 0, false);
80 80
         $this->initVar("question", XOBJ_DTYPE_TXTBOX, null, true, 100000);
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
         $this->initVar("partialview", XOBJ_DTYPE_INT, 0, false);
100 100
 
101 101
         if (isset($id)) {
102
-            $faq_handler= new sfFaqHandler($this->db);
103
-            $faq= & $faq_handler->get($id);
102
+            $faq_handler = new sfFaqHandler($this->db);
103
+            $faq = & $faq_handler->get($id);
104 104
             foreach ($faq->vars as $k => $v) {
105 105
                 $this->assignVar($k, $v['value']);
106 106
             }
@@ -110,29 +110,29 @@  discard block
 block discarded – undo
110 110
 
111 111
     function assignOtherProperties()
112 112
     {
113
-        $smartModule= & sf_getModuleInfo();
114
-        $module_id= $smartModule->getVar('mid');
113
+        $smartModule = & sf_getModuleInfo();
114
+        $module_id = $smartModule->getVar('mid');
115 115
 
116
-        $gperm_handler= & xoops_gethandler('groupperm');
116
+        $gperm_handler = & xoops_gethandler('groupperm');
117 117
 
118
-        $this->_category= new sfCategory($this->getVar('categoryid'));
119
-        $this->_groups_read= $gperm_handler->getGroupIds('item_read', $this->faqid(), $module_id);
118
+        $this->_category = new sfCategory($this->getVar('categoryid'));
119
+        $this->_groups_read = $gperm_handler->getGroupIds('item_read', $this->faqid(), $module_id);
120 120
     }
121 121
 
122 122
     function checkPermission()
123 123
     {
124 124
         include_once XOOPS_ROOT_PATH.'/modules/smartfaq/include/functions.php';
125 125
 
126
-        $userIsAdmin= sf_userIsAdmin();
126
+        $userIsAdmin = sf_userIsAdmin();
127 127
         if ($userIsAdmin) {
128 128
             return true;
129 129
         }
130 130
 
131
-        $smartPermHandler= & xoops_getmodulehandler('permission', 'smartfaq');
131
+        $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
132 132
 
133
-        $faqsGranted= $smartPermHandler->getPermissions('item');
133
+        $faqsGranted = $smartPermHandler->getPermissions('item');
134 134
         if (in_array($this->categoryid(), $faqsGranted)) {
135
-            $ret= true;
135
+            $ret = true;
136 136
         }
137 137
 
138 138
         return $ret;
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
         return $this->_groups_read;
148 148
     }
149 149
 
150
-    function setGroups_read($groups_read= array('0'))
150
+    function setGroups_read($groups_read = array('0'))
151 151
     {
152
-        $this->_groups_read= $groups_read;
152
+        $this->_groups_read = $groups_read;
153 153
     }
154 154
 
155 155
     function faqid()
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
         return $this->_category;
168 168
     }
169 169
 
170
-    function question($maxLength= 0, $format= "S")
170
+    function question($maxLength = 0, $format = "S")
171 171
     {
172
-        $ret= $this->getVar("question", $format);
173
-        if (($format == 's') ||($format == 'S') ||($format == 'show')) {
174
-            $myts= & MyTextSanitizer :: getInstance();
175
-            $ret= $myts->displayTarea($ret);
172
+        $ret = $this->getVar("question", $format);
173
+        if (($format == 's') || ($format == 'S') || ($format == 'show')) {
174
+            $myts = & MyTextSanitizer :: getInstance();
175
+            $ret = $myts->displayTarea($ret);
176 176
         }
177 177
         if ($maxLength != 0) {
178 178
             if (!XOOPS_USE_MULTIBYTES) {
179 179
                 if (strlen($ret) >= $maxLength) {
180
-                    $ret= substr($ret, 0,($maxLength -1))."...";
180
+                    $ret = substr($ret, 0, ($maxLength-1))."...";
181 181
                 }
182 182
             }
183 183
         }
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
         return $ret;
186 186
     }
187 187
 
188
-    function howdoi($format= "S")
188
+    function howdoi($format = "S")
189 189
     {
190
-        $ret= $this->getVar("howdoi", $format);
191
-        if (($format == 's') ||($format == 'S') ||($format == 'show')) {
192
-            $myts= & MyTextSanitizer :: getInstance();
193
-            $ret= $myts->displayTarea($ret);
190
+        $ret = $this->getVar("howdoi", $format);
191
+        if (($format == 's') || ($format == 'S') || ($format == 'show')) {
192
+            $myts = & MyTextSanitizer :: getInstance();
193
+            $ret = $myts->displayTarea($ret);
194 194
         }
195 195
 
196 196
         return $ret;
197 197
     }
198 198
 
199
-    function diduno($format= "S")
199
+    function diduno($format = "S")
200 200
     {
201
-        $ret= $this->getVar("diduno", $format);
202
-        if (($format == 's') ||($format == 'S') ||($format == 'show')) {
203
-            $myts= & MyTextSanitizer :: getInstance();
204
-            $ret= $myts->displayTarea($ret);
201
+        $ret = $this->getVar("diduno", $format);
202
+        if (($format == 's') || ($format == 'S') || ($format == 'show')) {
203
+            $myts = & MyTextSanitizer :: getInstance();
204
+            $ret = $myts->displayTarea($ret);
205 205
         }
206 206
 
207 207
         return $ret;
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
         return $this->getVar("uid");
213 213
     }
214 214
 
215
-    function datesub($dateFormat= 'none', $format= "S")
215
+    function datesub($dateFormat = 'none', $format = "S")
216 216
     {
217 217
         if ($dateFormat == 'none') {
218
-            $smartConfig= & sf_getModuleConfig();
219
-            $dateFormat= $smartConfig['dateformat'];
218
+            $smartConfig = & sf_getModuleConfig();
219
+            $dateFormat = $smartConfig['dateformat'];
220 220
         }
221 221
 
222 222
         return formatTimestamp($this->getVar('datesub', $format), $dateFormat);
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
         return $this->getVar("notifypub");
268 268
     }
269 269
 
270
-    function modulelink($format= "S")
270
+    function modulelink($format = "S")
271 271
     {
272 272
         return $this->getVar("modulelink", $format);
273 273
     }
274 274
 
275
-    function contextpage($format= "S")
275
+    function contextpage($format = "S")
276 276
     {
277 277
         return $this->getVar("contextpage", $format);
278 278
     }
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
         return $this->getVar("partialview");
288 288
     }
289 289
 
290
-    function posterName($realName= -1)
290
+    function posterName($realName = -1)
291 291
     {
292 292
         if ($realName == -1) {
293
-            $smartConfig= & sf_getModuleConfig();
294
-            $realName= $smartConfig['userealname'];
293
+            $smartConfig = & sf_getModuleConfig();
294
+            $realName = $smartConfig['userealname'];
295 295
         }
296 296
 
297 297
         return sf_getLinkedUnameFromId($this->uid(), $realName);
@@ -299,33 +299,33 @@  discard block
 block discarded – undo
299 299
 
300 300
     function answer()
301 301
     {
302
-        $answer_handler= new sfAnswerHandler($this->db);
302
+        $answer_handler = new sfAnswerHandler($this->db);
303 303
         switch ($this->status()) {
304 304
             case _SF_STATUS_SUBMITTED :
305
-                $theAnswers= & $answer_handler->getAllAnswers($this->faqid(), _SF_AN_STATUS_APPROVED, 1, 0);
305
+                $theAnswers = & $answer_handler->getAllAnswers($this->faqid(), _SF_AN_STATUS_APPROVED, 1, 0);
306 306
                 //echo "test";
307 307
                 //exit;
308
-                $this->_answer= & $theAnswers[0];
308
+                $this->_answer = & $theAnswers[0];
309 309
                 break;
310 310
 
311 311
             case _SF_STATUS_ANSWERED :
312
-                $theAnswers= & $answer_handler->getAllAnswers($this->faqid(), _SF_AN_STATUS_PROPOSED, 1, 0);
312
+                $theAnswers = & $answer_handler->getAllAnswers($this->faqid(), _SF_AN_STATUS_PROPOSED, 1, 0);
313 313
                 //echo "test";
314 314
                 //exit;
315
-                $this->_answer= & $theAnswers[0];
315
+                $this->_answer = & $theAnswers[0];
316 316
                 break;
317 317
 
318 318
             case _SF_STATUS_PUBLISHED :
319 319
             case _SF_STATUS_NEW_ANSWER :
320 320
             case _SF_STATUS_OFFLINE :
321
-                $this->_answer= & $answer_handler->getOfficialAnswer($this->faqid());
321
+                $this->_answer = & $answer_handler->getOfficialAnswer($this->faqid());
322 322
                 break;
323 323
 
324 324
             case _SF_STATUS_ASKED :
325
-                $this->_answer= & $answer_handler->create();
325
+                $this->_answer = & $answer_handler->create();
326 326
 
327 327
             case _SF_STATUS_OPENED :
328
-                $this->_answer= & $answer_handler->create();
328
+                $this->_answer = & $answer_handler->create();
329 329
                 break;
330 330
         }
331 331
 
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
 
343 343
     function getAllAnswers()
344 344
     {
345
-        $answer_handler= new sfAnswerHandler($this->db);
345
+        $answer_handler = new sfAnswerHandler($this->db);
346 346
 
347 347
         return $answer_handler->getAllAnswers($this->faqid());
348 348
     }
349 349
 
350 350
     function updateCounter()
351 351
     {
352
-        $faq_handler= new sfFaqHandler($this->db);
352
+        $faq_handler = new sfFaqHandler($this->db);
353 353
 
354 354
         return $faq_handler->updateCounter($this->faqid());
355 355
     }
356 356
 
357
-    function store($force= true)
357
+    function store($force = true)
358 358
     {
359
-        $faq_handler= new sfFaqHandler($this->db);
359
+        $faq_handler = new sfFaqHandler($this->db);
360 360
 
361 361
         return $faq_handler->insert($this, $force);
362 362
     }
@@ -364,37 +364,37 @@  discard block
 block discarded – undo
364 364
     function getCategoryName()
365 365
     {
366 366
         if (!isset($this->_category)) {
367
-            $this->_category= new sfCategory($this->getVar('categoryid'));
367
+            $this->_category = new sfCategory($this->getVar('categoryid'));
368 368
         }
369 369
 
370 370
         return $this->_category->name();
371 371
     }
372 372
 
373
-    function sendNotifications($notifications= array())
373
+    function sendNotifications($notifications = array())
374 374
     {
375
-        $smartModule= & sf_getModuleInfo();
375
+        $smartModule = & sf_getModuleInfo();
376 376
 
377
-        $myts= & MyTextSanitizer :: getInstance();
378
-        $notification_handler= & xoops_gethandler('notification');
377
+        $myts = & MyTextSanitizer :: getInstance();
378
+        $notification_handler = & xoops_gethandler('notification');
379 379
         //$categoryObj = $this->category();
380 380
 
381
-        $tags= array();
382
-        $tags['MODULE_NAME']= $myts->displayTarea($smartModule->getVar('name'));
383
-        $tags['FAQ_NAME']= $this->question();
384
-        $tags['CATEGORY_NAME']= $this->getCategoryName();
385
-        $tags['CATEGORY_URL']= XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/category.php?categoryid='.$this->categoryid();
386
-        $tags['FAQ_QUESTION']= $this->question();
387
-        $answerObj= & $this->answer();
381
+        $tags = array();
382
+        $tags['MODULE_NAME'] = $myts->displayTarea($smartModule->getVar('name'));
383
+        $tags['FAQ_NAME'] = $this->question();
384
+        $tags['CATEGORY_NAME'] = $this->getCategoryName();
385
+        $tags['CATEGORY_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/category.php?categoryid='.$this->categoryid();
386
+        $tags['FAQ_QUESTION'] = $this->question();
387
+        $answerObj = & $this->answer();
388 388
         if (is_object($answerObj)) {
389 389
             // TODO : Not sure about the 'formpreview' ...
390
-            $tags['FAQ_ANSWER']= $answerObj->answer('formpreview');
390
+            $tags['FAQ_ANSWER'] = $answerObj->answer('formpreview');
391 391
         }
392
-        $tags['DATESUB']= $this->datesub();
392
+        $tags['DATESUB'] = $this->datesub();
393 393
 
394 394
         foreach ($notifications as $notification) {
395 395
             switch ($notification) {
396 396
                 case _SF_NOT_FAQ_PUBLISHED :
397
-                    $tags['FAQ_URL']= XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/faq.php?faqid='.$this->faqid();
397
+                    $tags['FAQ_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/faq.php?faqid='.$this->faqid();
398 398
 
399 399
                     $notification_handler->triggerEvent('global_faq', 0, 'published', $tags);
400 400
                     $notification_handler->triggerEvent('category_faq', $this->categoryid(), 'published', $tags);
@@ -402,20 +402,20 @@  discard block
 block discarded – undo
402 402
                     break;
403 403
 
404 404
                 case _SF_NOT_FAQ_SUBMITTED :
405
-                    $tags['WAITINGFILES_URL']= XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/admin/faq.php?faqid='.$this->faqid();
405
+                    $tags['WAITINGFILES_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/admin/faq.php?faqid='.$this->faqid();
406 406
                     $notification_handler->triggerEvent('global_faq', 0, 'submitted', $tags);
407 407
                     $notification_handler->triggerEvent('category_faq', $this->categoryid(), 'submitted', $tags);
408 408
                     break;
409 409
 
410 410
                 case _SF_NOT_QUESTION_PUBLISHED :
411
-                    $tags['FAQ_URL']= XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/answer.php?faqid='.$this->faqid();
411
+                    $tags['FAQ_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/answer.php?faqid='.$this->faqid();
412 412
                     $notification_handler->triggerEvent('global_question', 0, 'published', $tags);
413 413
                     $notification_handler->triggerEvent('category_question', $this->categoryid(), 'published', $tags);
414 414
                     $notification_handler->triggerEvent('question', $this->faqid(), 'approved', $tags);
415 415
                     break;
416 416
 
417 417
                 case _SF_NOT_QUESTION_SUBMITTED :
418
-                    $tags['WAITINGFILES_URL']= XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/admin/question.php?op=mod&faqid='.$this->faqid();
418
+                    $tags['WAITINGFILES_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/admin/question.php?op=mod&faqid='.$this->faqid();
419 419
                     $notification_handler->triggerEvent('global_question', 0, 'submitted', $tags);
420 420
                     $notification_handler->triggerEvent('category_question', $this->categoryid(), 'submitted', $tags);
421 421
                     break;
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
                     break;
426 426
 
427 427
                 case _SF_NOT_NEW_ANSWER_PROPOSED :
428
-                    $tags['WAITINGFILES_URL']= XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/admin/answer.php?op=mod&faqid='.$this->faqid();
428
+                    $tags['WAITINGFILES_URL'] = XOOPS_URL.'/modules/'.$smartModule->getVar('dirname').'/admin/answer.php?op=mod&faqid='.$this->faqid();
429 429
                     $notification_handler->triggerEvent('global_faq', 0, 'answer_proposed', $tags);
430 430
                     $notification_handler->triggerEvent('category_faq', $this->categoryid(), 'answer_proposed', $tags);
431 431
                     break;
@@ -461,28 +461,28 @@  discard block
 block discarded – undo
461 461
     function setDefaultPermissions()
462 462
     {
463 463
 
464
-        $member_handler= & xoops_gethandler('member');
465
-        $groups= & $member_handler->getGroupList();
464
+        $member_handler = & xoops_gethandler('member');
465
+        $groups = & $member_handler->getGroupList();
466 466
 
467
-        $j= 0;
468
-        $group_ids= array();
467
+        $j = 0;
468
+        $group_ids = array();
469 469
         foreach (array_keys($groups) as $i) {
470
-            $group_ids[$j]= $i;
470
+            $group_ids[$j] = $i;
471 471
             ++$j;
472 472
         }
473
-        $this->_groups_read= $group_ids;
473
+        $this->_groups_read = $group_ids;
474 474
     }
475 475
 
476 476
     function setPermissions($group_ids)
477 477
     {
478 478
         if (!isset($group_ids)) {
479
-            $member_handler= & xoops_gethandler('member');
480
-            $groups= & $member_handler->getGroupList();
479
+            $member_handler = & xoops_gethandler('member');
480
+            $groups = & $member_handler->getGroupList();
481 481
 
482
-            $j= 0;
483
-            $group_ids= array();
482
+            $j = 0;
483
+            $group_ids = array();
484 484
             foreach (array_keys($groups) as $i) {
485
-                $group_ids[$j]= $i;
485
+                $group_ids[$j] = $i;
486 486
                 ++$j;
487 487
             }
488 488
         }
@@ -494,27 +494,27 @@  discard block
 block discarded – undo
494 494
         return($this->getVar('faqid') == -1);
495 495
     }
496 496
 
497
-    function getWhoAndWhen($answerObj= null, $users= array())
497
+    function getWhoAndWhen($answerObj = null, $users = array())
498 498
     {
499
-        $smartModuleConfig= sf_getModuleConfig();
499
+        $smartModuleConfig = sf_getModuleConfig();
500 500
 
501
-        $requester= sf_getLinkedUnameFromId($this->uid(), $smartModuleConfig['userealname'], $users);
502
-        $requestdate= $this->datesub();
501
+        $requester = sf_getLinkedUnameFromId($this->uid(), $smartModuleConfig['userealname'], $users);
502
+        $requestdate = $this->datesub();
503 503
 
504 504
         if (($this->status() == _SF_STATUS_PUBLISHED) || $this->status() == _SF_STATUS_NEW_ANSWER) {
505 505
             if ($answerObj == null) {
506
-                $answerObj= & $this->answer();
506
+                $answerObj = & $this->answer();
507 507
             }
508
-            $submitdate= $answerObj->datesub();
508
+            $submitdate = $answerObj->datesub();
509 509
             if ($this->uid() == $answerObj->uid()) {
510
-                $result= sprintf(_MD_SF_REQUESTEDANDANSWERED, $requester, $submitdate);
510
+                $result = sprintf(_MD_SF_REQUESTEDANDANSWERED, $requester, $submitdate);
511 511
             } else {
512
-                $submitter= sf_getLinkedUnameFromId($answerObj->uid(), $smartModuleConfig['userealname'], $users);
513
-                $result= sprintf(_MD_SF_REQUESTEDBYANDANSWEREDBY, $requester, $submitter, $submitdate);
512
+                $submitter = sf_getLinkedUnameFromId($answerObj->uid(), $smartModuleConfig['userealname'], $users);
513
+                $result = sprintf(_MD_SF_REQUESTEDBYANDANSWEREDBY, $requester, $submitter, $submitdate);
514 514
             }
515 515
 
516 516
         } else {
517
-            $result= sprintf(_MD_SF_REQUESTEDBY, $requester, $requestdate);
517
+            $result = sprintf(_MD_SF_REQUESTEDBY, $requester, $requestdate);
518 518
         }
519 519
 
520 520
         return $result;
@@ -524,44 +524,44 @@  discard block
 block discarded – undo
524 524
     {
525 525
         global $xoopsConfig;
526 526
         if (($this->status() == _SF_STATUS_PUBLISHED) || $this->status() == _SF_STATUS_NEW_ANSWER) {
527
-            $text= _MD_SF_FAQCOMEFROM;
527
+            $text = _MD_SF_FAQCOMEFROM;
528 528
         } else {
529
-            $text= _MD_SF_QUESTIONCOMEFROM;
529
+            $text = _MD_SF_QUESTIONCOMEFROM;
530 530
         }
531 531
 
532 532
         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>";
533 533
     }
534 534
 
535
-    function toArray($faq= array(), $category= null, $linkInQuestion= true)
535
+    function toArray($faq = array(), $category = null, $linkInQuestion = true)
536 536
     {
537 537
 
538 538
         global $xoopsModuleConfig;
539
-        $lastfaqsize= intval($xoopsModuleConfig['lastfaqsize']);
539
+        $lastfaqsize = intval($xoopsModuleConfig['lastfaqsize']);
540 540
 
541
-        $faq['id']= $this->faqid();
542
-        $faq['categoryid']= $this->categoryid();
543
-        $faq['question']= $this->question();
544
-        $page=($this->status() == _SF_STATUS_OPENED) ? 'answer.php' : 'faq.php';
541
+        $faq['id'] = $this->faqid();
542
+        $faq['categoryid'] = $this->categoryid();
543
+        $faq['question'] = $this->question();
544
+        $page = ($this->status() == _SF_STATUS_OPENED) ? 'answer.php' : 'faq.php';
545 545
 
546
-        $faq['questionlink']= "<a href='$page?faqid=".$this->faqid()."'>".$this->question($lastfaqsize)."</a>";
546
+        $faq['questionlink'] = "<a href='$page?faqid=".$this->faqid()."'>".$this->question($lastfaqsize)."</a>";
547 547
         if ($linkInQuestion) {
548
-            $faq['fullquestionlink']= "<a href='$page?faqid=".$this->faqid()."'>".$this->question()."</a>";
548
+            $faq['fullquestionlink'] = "<a href='$page?faqid=".$this->faqid()."'>".$this->question()."</a>";
549 549
         } else {
550
-            $faq['fullquestionlink']= $this->question();
550
+            $faq['fullquestionlink'] = $this->question();
551 551
         }
552
-        $faq['faqid']= $this->faqid();
553
-        $faq['counter']= $this->counter();
554
-        $faq['cancomment']= $this->cancomment();
555
-        $faq['comments']= $this->comments();
556
-        $faq['datesub']= $this->datesub();
552
+        $faq['faqid'] = $this->faqid();
553
+        $faq['counter'] = $this->counter();
554
+        $faq['cancomment'] = $this->cancomment();
555
+        $faq['comments'] = $this->comments();
556
+        $faq['datesub'] = $this->datesub();
557 557
         if (isset($category)) {
558 558
             if (is_object($category) && strtolower(get_class($category)) == 'sfcategory') {
559
-                $categoryObj= $category;
559
+                $categoryObj = $category;
560 560
             } elseif (is_array($category)) {
561
-                $categoryObj= $category[$this->categoryid()];
561
+                $categoryObj = $category[$this->categoryid()];
562 562
             }
563
-            $faq['categoryname']= $categoryObj->getVar('name');
564
-            $faq['categorylink']= "<a href='".XOOPS_URL."/modules/smartfaq/category.php?categoryid=".$this->categoryid()."'>".$categoryObj->getVar('name')."</a>";
563
+            $faq['categoryname'] = $categoryObj->getVar('name');
564
+            $faq['categorylink'] = "<a href='".XOOPS_URL."/modules/smartfaq/category.php?categoryid=".$this->categoryid()."'>".$categoryObj->getVar('name')."</a>";
565 565
         }
566 566
 
567 567
         return $faq;
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
 
580 580
 class sfFaqHandler extends XoopsObjectHandler
581 581
 {
582
-    function & create($isNew= true)
582
+    function & create($isNew = true)
583 583
     {
584
-        $faq= new sfFaq();
584
+        $faq = new sfFaq();
585 585
         if ($isNew) {
586 586
             $faq->setDefaultPermissions();
587 587
             $faq->setNew();
@@ -599,14 +599,14 @@  discard block
 block discarded – undo
599 599
     function & get($id)
600 600
     {
601 601
         if (intval($id) > 0) {
602
-            $sql= 'SELECT * FROM '.$this->db->prefix('smartfaq_faq').' WHERE faqid='.$id;
603
-            if (!$result= $this->db->query($sql)) {
602
+            $sql = 'SELECT * FROM '.$this->db->prefix('smartfaq_faq').' WHERE faqid='.$id;
603
+            if (!$result = $this->db->query($sql)) {
604 604
                 return false;
605 605
             }
606 606
 
607
-            $numrows= $this->db->getRowsNum($result);
607
+            $numrows = $this->db->getRowsNum($result);
608 608
             if ($numrows == 1) {
609
-                $faq= new sfFaq();
609
+                $faq = new sfFaq();
610 610
                 $faq->assignVars($this->db->fetchArray($result));
611 611
 
612 612
                 return $faq;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
     * @param bool $force
624 624
     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
625 625
     */
626
-    function insert(& $faq, $force= false)
626
+    function insert(& $faq, $force = false)
627 627
     {
628 628
 
629 629
         if (strtolower(get_class($faq)) != 'sffaq') {
@@ -639,19 +639,19 @@  discard block
 block discarded – undo
639 639
         }
640 640
 
641 641
         foreach ($faq->cleanVars as $k => $v) {
642
-            ${ $k }= $v;
642
+            ${ $k } = $v;
643 643
         }
644 644
 
645 645
         if ($faq->isNew()) {
646
-            $sql= sprintf("INSERT INTO %s (faqid, categoryid, question, howdoi, diduno, uid, datesub, `status`, counter, weight, html, smiley, xcodes, cancomment, comments, notifypub, modulelink, contextpage, exacturl, partialview) VALUES (NULL, %u, %s, %s, %s, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %s, %s, %u, %u)", $this->db->prefix('smartfaq_faq'), $categoryid, $this->db->quoteString($question), $this->db->quoteString($howdoi), $this->db->quoteString($diduno), $uid, time(), $status, $counter, $weight, $html, $smiley, $xcodes, $cancomment, $comments, $notifypub, $this->db->quoteString($modulelink), $this->db->quoteString($contextpage), $exacturl, $partialview);
646
+            $sql = sprintf("INSERT INTO %s (faqid, categoryid, question, howdoi, diduno, uid, datesub, `status`, counter, weight, html, smiley, xcodes, cancomment, comments, notifypub, modulelink, contextpage, exacturl, partialview) VALUES (NULL, %u, %s, %s, %s, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %s, %s, %u, %u)", $this->db->prefix('smartfaq_faq'), $categoryid, $this->db->quoteString($question), $this->db->quoteString($howdoi), $this->db->quoteString($diduno), $uid, time(), $status, $counter, $weight, $html, $smiley, $xcodes, $cancomment, $comments, $notifypub, $this->db->quoteString($modulelink), $this->db->quoteString($contextpage), $exacturl, $partialview);
647 647
 
648 648
         } else {
649
-            $sql= sprintf("UPDATE %s SET categoryid = %u, question = %s, howdoi = %s, diduno = %s, uid = %u, datesub = %u, `status` = %u, counter = %u, weight = %u, html = %u, smiley = %u, xcodes = %u, cancomment = %u, comments = %u, notifypub = %u, modulelink = %s, contextpage = %s, exacturl = %u, partialview = %u  WHERE faqid = %u", $this->db->prefix('smartfaq_faq'), $categoryid, $this->db->quoteString($question), $this->db->quoteString($howdoi), $this->db->quoteString($diduno), $uid, $datesub, $status, $counter, $weight, $html, $smiley, $xcodes, $cancomment, $comments, $notifypub, $this->db->quoteString($modulelink), $this->db->quoteString($contextpage), $exacturl, $partialview, $faqid);
649
+            $sql = sprintf("UPDATE %s SET categoryid = %u, question = %s, howdoi = %s, diduno = %s, uid = %u, datesub = %u, `status` = %u, counter = %u, weight = %u, html = %u, smiley = %u, xcodes = %u, cancomment = %u, comments = %u, notifypub = %u, modulelink = %s, contextpage = %s, exacturl = %u, partialview = %u  WHERE faqid = %u", $this->db->prefix('smartfaq_faq'), $categoryid, $this->db->quoteString($question), $this->db->quoteString($howdoi), $this->db->quoteString($diduno), $uid, $datesub, $status, $counter, $weight, $html, $smiley, $xcodes, $cancomment, $comments, $notifypub, $this->db->quoteString($modulelink), $this->db->quoteString($contextpage), $exacturl, $partialview, $faqid);
650 650
         }
651 651
         if (false != $force) {
652
-            $result= $this->db->queryF($sql);
652
+            $result = $this->db->queryF($sql);
653 653
         } else {
654
-            $result= $this->db->query($sql);
654
+            $result = $this->db->query($sql);
655 655
         }
656 656
 
657 657
         if (!$result) {
@@ -674,28 +674,28 @@  discard block
 block discarded – undo
674 674
     * @param bool $force
675 675
     * @return bool FALSE if failed.
676 676
     */
677
-    function delete(& $faq, $force= false)
677
+    function delete(& $faq, $force = false)
678 678
     {
679
-        $smartModule= & sf_getModuleInfo();
680
-        $module_id= $smartModule->getVar('mid');
679
+        $smartModule = & sf_getModuleInfo();
680
+        $module_id = $smartModule->getVar('mid');
681 681
 
682 682
         if (strtolower(get_class($faq)) != 'sffaq') {
683 683
             return false;
684 684
         }
685 685
 
686 686
         // Deleting the answers
687
-        $answer_handler= new sfAnswerHandler($this->db);
687
+        $answer_handler = new sfAnswerHandler($this->db);
688 688
         if (!$answer_handler->deleteFaqAnswers($faq)) {
689 689
             // error msg...
690 690
             echo "error while deleteing an answer";
691 691
         }
692 692
 
693
-        $sql= sprintf("DELETE FROM %s WHERE faqid = %u", $this->db->prefix("smartfaq_faq"), $faq->getVar('faqid'));
693
+        $sql = sprintf("DELETE FROM %s WHERE faqid = %u", $this->db->prefix("smartfaq_faq"), $faq->getVar('faqid'));
694 694
 
695 695
         if (false != $force) {
696
-            $result= $this->db->queryF($sql);
696
+            $result = $this->db->queryF($sql);
697 697
         } else {
698
-            $result= $this->db->query($sql);
698
+            $result = $this->db->query($sql);
699 699
         }
700 700
         if (!$result) {
701 701
             return false;
@@ -713,14 +713,14 @@  discard block
 block discarded – undo
713 713
     * @param bool $id_as_key use the faqid as key for the array?
714 714
     * @return array array of {@link sfFaq} objects
715 715
     */
716
-    function & getObjects($criteria= null, $id_as_key= false, $notNullFields= '')
716
+    function & getObjects($criteria = null, $id_as_key = false, $notNullFields = '')
717 717
     {
718
-        $ret= array();
719
-        $limit= $start= 0;
720
-        $sql= 'SELECT * FROM '.$this->db->prefix('smartfaq_faq');
718
+        $ret = array();
719
+        $limit = $start = 0;
720
+        $sql = 'SELECT * FROM '.$this->db->prefix('smartfaq_faq');
721 721
 
722 722
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
723
-            $whereClause= $criteria->renderWhere();
723
+            $whereClause = $criteria->renderWhere();
724 724
 
725 725
             if ($whereClause != 'WHERE ()') {
726 726
                 $sql .= ' '.$criteria->renderWhere();
@@ -733,14 +733,14 @@  discard block
 block discarded – undo
733 733
             if ($criteria->getSort() != '') {
734 734
                 $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
735 735
             }
736
-            $limit= $criteria->getLimit();
737
-            $start= $criteria->getStart();
736
+            $limit = $criteria->getLimit();
737
+            $start = $criteria->getStart();
738 738
         } elseif (!empty($notNullFields)) {
739 739
             $sql .= $sql .= " WHERE ".$this->NotNullFieldClause($notNullFields);
740 740
         }
741 741
 
742 742
         //echo "<br />" . $sql . "<br />";
743
-        $result= $this->db->query($sql, $limit, $start);
743
+        $result = $this->db->query($sql, $limit, $start);
744 744
         if (!$result) {
745 745
             return false;
746 746
         }
@@ -749,14 +749,14 @@  discard block
 block discarded – undo
749 749
             return false;
750 750
         }
751 751
 
752
-        while ($myrow= $this->db->fetchArray($result)) {
753
-            $faq= new sfFaq();
752
+        while ($myrow = $this->db->fetchArray($result)) {
753
+            $faq = new sfFaq();
754 754
             $faq->assignVars($myrow);
755 755
 
756 756
             if (!$id_as_key) {
757
-                $ret[]= & $faq;
757
+                $ret[] = & $faq;
758 758
             } else {
759
-                $ret[$myrow['faqid']]= & $faq;
759
+                $ret[$myrow['faqid']] = & $faq;
760 760
             }
761 761
             unset($faq);
762 762
         }
@@ -764,11 +764,11 @@  discard block
 block discarded – undo
764 764
         return $ret;
765 765
     }
766 766
 
767
-    function & getObjectsAdminSide($criteria= null, $id_as_key= false, $notNullFields= '')
767
+    function & getObjectsAdminSide($criteria = null, $id_as_key = false, $notNullFields = '')
768 768
     {
769
-        $ret= array();
770
-        $limit= $start= 0;
771
-        $sql= "SELECT
769
+        $ret = array();
770
+        $limit = $start = 0;
771
+        $sql = "SELECT
772 772
                             faq.faqid AS faqid,
773 773
                             faq.categoryid AS categoryid,
774 774
                             faq.question AS question,
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
                 FROM ".$this->db->prefix('smartfaq_faq')." AS faq INNER JOIN ".$this->db->prefix('smartfaq_categories')." AS category ON faq.categoryid = category.categoryid ";
794 794
 
795 795
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
796
-            $whereClause= $criteria->renderWhere();
796
+            $whereClause = $criteria->renderWhere();
797 797
 
798 798
             if ($whereClause != 'WHERE ()') {
799 799
                 $sql .= ' '.$criteria->renderWhere();
@@ -806,14 +806,14 @@  discard block
 block discarded – undo
806 806
             if ($criteria->getSort() != '') {
807 807
                 $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
808 808
             }
809
-            $limit= $criteria->getLimit();
810
-            $start= $criteria->getStart();
809
+            $limit = $criteria->getLimit();
810
+            $start = $criteria->getStart();
811 811
         } elseif (!empty($notNullFields)) {
812 812
             $sql .= $sql .= " WHERE ".$this->NotNullFieldClause($notNullFields);
813 813
         }
814 814
 
815 815
         //echo "<br />" . $sql . "<br />";
816
-        $result= $this->db->query($sql, $limit, $start);
816
+        $result = $this->db->query($sql, $limit, $start);
817 817
         if (!$result) {
818 818
             return false;
819 819
         }
@@ -822,14 +822,14 @@  discard block
 block discarded – undo
822 822
             return false;
823 823
         }
824 824
 
825
-        while ($myrow= $this->db->fetchArray($result)) {
826
-            $faq= new sfFaq();
825
+        while ($myrow = $this->db->fetchArray($result)) {
826
+            $faq = new sfFaq();
827 827
             $faq->assignVars($myrow);
828 828
 
829 829
             if (!$id_as_key) {
830
-                $ret[]= & $faq;
830
+                $ret[] = & $faq;
831 831
             } else {
832
-                $ret[$myrow['faqid']]= & $faq;
832
+                $ret[$myrow['faqid']] = & $faq;
833 833
             }
834 834
             unset($faq);
835 835
         }
@@ -856,11 +856,11 @@  discard block
 block discarded – undo
856 856
     * @param object $criteria {@link CriteriaElement} to match
857 857
     * @return int count of FAQs
858 858
     */
859
-    function getCount($criteria= null, $notNullFields= '')
859
+    function getCount($criteria = null, $notNullFields = '')
860 860
     {
861
-        $sql= 'SELECT COUNT(*) FROM '.$this->db->prefix('smartfaq_faq');
861
+        $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('smartfaq_faq');
862 862
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
863
-            $whereClause= $criteria->renderWhere();
863
+            $whereClause = $criteria->renderWhere();
864 864
             if ($whereClause != 'WHERE ()') {
865 865
                 $sql .= ' '.$criteria->renderWhere();
866 866
                 if (!empty($notNullFields)) {
@@ -874,16 +874,16 @@  discard block
 block discarded – undo
874 874
         }
875 875
 
876 876
         //echo "<br />" . $sql . "<br />";
877
-        $result= $this->db->query($sql);
877
+        $result = $this->db->query($sql);
878 878
         if (!$result) {
879 879
             return 0;
880 880
         }
881
-        list($count)= $this->db->fetchRow($result);
881
+        list($count) = $this->db->fetchRow($result);
882 882
 
883 883
         return $count;
884 884
     }
885 885
 
886
-    function getFaqsCount($categoryid= -1, $status= '', $notNullFields= '')
886
+    function getFaqsCount($categoryid = -1, $status = '', $notNullFields = '')
887 887
     {
888 888
 
889 889
         global $xoopsUser;
@@ -892,16 +892,16 @@  discard block
 block discarded – undo
892 892
         //return $this->getCount();
893 893
         //}
894 894
 
895
-        $userIsAdmin= sf_userIsAdmin();
895
+        $userIsAdmin = sf_userIsAdmin();
896 896
         // Categories for which user has access
897 897
         if (!$userIsAdmin) {
898
-            $smartPermHandler= & xoops_getmodulehandler('permission', 'smartfaq');
898
+            $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
899 899
 
900
-            $categoriesGranted= $smartPermHandler->getPermissions('category');
901
-            $grantedCategories= new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN');
900
+            $categoriesGranted = $smartPermHandler->getPermissions('category');
901
+            $grantedCategories = new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN');
902 902
 
903
-            $faqsGranted= $smartPermHandler->getPermissions('item');
904
-            $grantedFaq= new CriteriaCompo();
903
+            $faqsGranted = $smartPermHandler->getPermissions('item');
904
+            $grantedFaq = new CriteriaCompo();
905 905
             $grantedFaq->add(new Criteria('faqid', "(".implode(',', $faqsGranted).")", 'IN'), 'OR');
906 906
             // If user is anonymous, check if the FAQ allow partialview
907 907
             if (!is_object($xoopsUser)) {
@@ -909,31 +909,31 @@  discard block
 block discarded – undo
909 909
             }
910 910
         }
911 911
 
912
-        if (isset($categoryid) &&($categoryid != -1)) {
913
-            $criteriaCategory= new criteria('categoryid', $categoryid);
912
+        if (isset($categoryid) && ($categoryid != -1)) {
913
+            $criteriaCategory = new criteria('categoryid', $categoryid);
914 914
         }
915 915
 
916
-        $criteriaStatus= new CriteriaCompo();
917
-        if (!empty($status) &&(is_array($status))) {
916
+        $criteriaStatus = new CriteriaCompo();
917
+        if (!empty($status) && (is_array($status))) {
918 918
             foreach ($status as $v) {
919 919
                 $criteriaStatus->add(new Criteria('status', $v), 'OR');
920 920
             }
921
-        } elseif (!empty($status) &&($status != -1)) {
921
+        } elseif (!empty($status) && ($status != -1)) {
922 922
             $criteriaStatus->add(new Criteria('status', $status), 'OR');
923 923
         }
924 924
 
925
-        $criteriaPermissions= new CriteriaCompo();
925
+        $criteriaPermissions = new CriteriaCompo();
926 926
         if (!$userIsAdmin) {
927 927
             $criteriaPermissions->add($grantedCategories, 'AND');
928 928
             $criteriaPermissions->add($grantedFaq, 'AND');
929 929
         }
930 930
 
931
-        $criteria= new CriteriaCompo();
931
+        $criteria = new CriteriaCompo();
932 932
         if (!empty($criteriaCategory)) {
933 933
             $criteria->add($criteriaCategory);
934 934
         }
935 935
 
936
-        if (!empty($criteriaPermissions) &&(!$userIsAdmin)) {
936
+        if (!empty($criteriaPermissions) && (!$userIsAdmin)) {
937 937
             $criteria->add($criteriaPermissions);
938 938
         }
939 939
 
@@ -946,25 +946,25 @@  discard block
 block discarded – undo
946 946
 
947 947
     function getFaqsCountByStatus()
948 948
     {
949
-        $sql= 'SELECT status, COUNT(*) FROM '.$this->db->prefix('smartfaq_faq').' GROUP BY status';
950
-        $result= $this->db->query($sql);
949
+        $sql = 'SELECT status, COUNT(*) FROM '.$this->db->prefix('smartfaq_faq').' GROUP BY status';
950
+        $result = $this->db->query($sql);
951 951
         if (!$result) {
952 952
             return array();
953 953
         }
954
-        $ret= array();
955
-        while (list($status, $count)= $this->db->fetchRow($result)) {
956
-            $ret[$status]= $count;
954
+        $ret = array();
955
+        while (list($status, $count) = $this->db->fetchRow($result)) {
956
+            $ret[$status] = $count;
957 957
         }
958 958
 
959 959
         return $ret;
960 960
     }
961 961
 
962
-    function getAllPublished($limit= 0, $start= 0, $categoryid= -1, $sort= 'datesub', $order= 'DESC', $asobject= true)
962
+    function getAllPublished($limit = 0, $start = 0, $categoryid = -1, $sort = 'datesub', $order = 'DESC', $asobject = true)
963 963
     {
964 964
         return $this->getFaqs($limit, $start, array(_SF_STATUS_PUBLISHED, _SF_STATUS_NEW_ANSWER), $categoryid, $sort, $order, null, $asobject, null);
965 965
     }
966 966
 
967
-    function getFaqs($limit= 0, $start= 0, $status= '', $categoryid= -1, $sort= 'datesub', $order= 'DESC', $notNullFields= '', $asobject= true, $otherCriteria= null)
967
+    function getFaqs($limit = 0, $start = 0, $status = '', $categoryid = -1, $sort = 'datesub', $order = 'DESC', $notNullFields = '', $asobject = true, $otherCriteria = null)
968 968
     {
969 969
         global $xoopsUser;
970 970
         include_once XOOPS_ROOT_PATH.'/modules/smartfaq/include/functions.php';
@@ -972,17 +972,17 @@  discard block
 block discarded – undo
972 972
         //if ( ($categoryid == -1) && (empty($status) || ($status == -1)) && ($limit == 0) && ($start ==0) ) {
973 973
         //	return $this->getObjects();
974 974
         //}
975
-        $ret= array();
976
-        $userIsAdmin= sf_userIsAdmin();
975
+        $ret = array();
976
+        $userIsAdmin = sf_userIsAdmin();
977 977
         // Categories for which user has access
978 978
         if (!$userIsAdmin) {
979
-            $smartPermHandler= & xoops_getmodulehandler('permission', 'smartfaq');
979
+            $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
980 980
 
981
-            $categoriesGranted= $smartPermHandler->getPermissions('category');
982
-            $grantedCategories= new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN');
981
+            $categoriesGranted = $smartPermHandler->getPermissions('category');
982
+            $grantedCategories = new Criteria('categoryid', "(".implode(',', $categoriesGranted).")", 'IN');
983 983
 
984
-            $faqsGranted= $smartPermHandler->getPermissions('item');
985
-            $grantedFaq= new CriteriaCompo();
984
+            $faqsGranted = $smartPermHandler->getPermissions('item');
985
+            $grantedFaq = new CriteriaCompo();
986 986
             $grantedFaq->add(new Criteria('faqid', "(".implode(',', $faqsGranted).")", 'IN'), 'OR');
987 987
             // If user is anonymous, check if the FAQ allow partialview
988 988
             if (!is_object($xoopsUser)) {
@@ -991,36 +991,36 @@  discard block
 block discarded – undo
991 991
 
992 992
         }
993 993
 
994
-        if (isset($categoryid) &&($categoryid != -1)) {
994
+        if (isset($categoryid) && ($categoryid != -1)) {
995 995
             if (is_array($categoryid)) {
996
-                $criteriaCategory= new Criteria('categoryid', "(".implode(',', $categoryid).")", 'IN');
996
+                $criteriaCategory = new Criteria('categoryid', "(".implode(',', $categoryid).")", 'IN');
997 997
             } else {
998
-                $criteriaCategory= new Criteria('categoryid', intval($categoryid));
998
+                $criteriaCategory = new Criteria('categoryid', intval($categoryid));
999 999
             }
1000 1000
         }
1001 1001
 
1002
-        if (!empty($status) &&(is_array($status))) {
1003
-            $criteriaStatus= new CriteriaCompo();
1002
+        if (!empty($status) && (is_array($status))) {
1003
+            $criteriaStatus = new CriteriaCompo();
1004 1004
             foreach ($status as $v) {
1005 1005
                 $criteriaStatus->add(new Criteria('status', $v), 'OR');
1006 1006
             }
1007
-        } elseif (!empty($status) &&($status != -1)) {
1008
-            $criteriaStatus= new CriteriaCompo();
1007
+        } elseif (!empty($status) && ($status != -1)) {
1008
+            $criteriaStatus = new CriteriaCompo();
1009 1009
             $criteriaStatus->add(new Criteria('status', $status), 'OR');
1010 1010
         }
1011 1011
 
1012
-        $criteriaPermissions= new CriteriaCompo();
1012
+        $criteriaPermissions = new CriteriaCompo();
1013 1013
         if (!$userIsAdmin) {
1014 1014
             $criteriaPermissions->add($grantedCategories, 'AND');
1015 1015
             $criteriaPermissions->add($grantedFaq, 'AND');
1016 1016
         }
1017 1017
 
1018
-        $criteria= new CriteriaCompo();
1018
+        $criteria = new CriteriaCompo();
1019 1019
         if (!empty($criteriaCategory)) {
1020 1020
             $criteria->add($criteriaCategory);
1021 1021
         }
1022 1022
 
1023
-        if (!empty($criteriaPermissions) &&(!$userIsAdmin)) {
1023
+        if (!empty($criteriaPermissions) && (!$userIsAdmin)) {
1024 1024
             $criteria->add($criteriaPermissions);
1025 1025
         }
1026 1026
 
@@ -1036,34 +1036,34 @@  discard block
 block discarded – undo
1036 1036
         $criteria->setStart($start);
1037 1037
         $criteria->setSort($sort);
1038 1038
         $criteria->setOrder($order);
1039
-        $ret= & $this->getObjects($criteria, false, $notNullFields);
1039
+        $ret = & $this->getObjects($criteria, false, $notNullFields);
1040 1040
 
1041 1041
         return $ret;
1042 1042
     }
1043 1043
 
1044
-    function getFaqsAdminSide($limit= 0, $start= 0, $status= '', $categoryid= -1, $sort= 'datesub', $order= 'DESC', $asobject= true, $otherCriteria= null)
1044
+    function getFaqsAdminSide($limit = 0, $start = 0, $status = '', $categoryid = -1, $sort = 'datesub', $order = 'DESC', $asobject = true, $otherCriteria = null)
1045 1045
     {
1046 1046
         include_once XOOPS_ROOT_PATH.'/modules/smartfaq/include/functions.php';
1047 1047
 
1048
-        $smartModule= & sf_getModuleInfo();
1048
+        $smartModule = & sf_getModuleInfo();
1049 1049
 
1050
-        $ret= array();
1050
+        $ret = array();
1051 1051
 
1052
-        if (isset($categoryid) &&($categoryid != -1)) {
1053
-            $criteriaCategory= new criteria('faq.categoryid', $categoryid);
1052
+        if (isset($categoryid) && ($categoryid != -1)) {
1053
+            $criteriaCategory = new criteria('faq.categoryid', $categoryid);
1054 1054
         }
1055 1055
 
1056
-        if (!empty($status) &&(is_array($status))) {
1057
-            $criteriaStatus= new CriteriaCompo();
1056
+        if (!empty($status) && (is_array($status))) {
1057
+            $criteriaStatus = new CriteriaCompo();
1058 1058
             foreach ($status as $v) {
1059 1059
                 $criteriaStatus->add(new Criteria('faq.status', $v), 'OR');
1060 1060
             }
1061
-        } elseif (!empty($status) &&($status != -1)) {
1062
-            $criteriaStatus= new CriteriaCompo();
1061
+        } elseif (!empty($status) && ($status != -1)) {
1062
+            $criteriaStatus = new CriteriaCompo();
1063 1063
             $criteriaStatus->add(new Criteria('faq.status', $status), 'OR');
1064 1064
         }
1065 1065
 
1066
-        $criteria= new CriteriaCompo();
1066
+        $criteria = new CriteriaCompo();
1067 1067
         if (!empty($criteriaCategory)) {
1068 1068
             $criteria->add($criteriaCategory);
1069 1069
         }
@@ -1080,27 +1080,27 @@  discard block
 block discarded – undo
1080 1080
         $criteria->setStart($start);
1081 1081
         $criteria->setSort($sort);
1082 1082
         $criteria->setOrder($order);
1083
-        $ret= & $this->getObjectsAdminSide($criteria, false);
1083
+        $ret = & $this->getObjectsAdminSide($criteria, false);
1084 1084
 
1085 1085
         return $ret;
1086 1086
     }
1087 1087
 
1088
-    function getRandomFaq($field= '', $status= '', $category= -1)
1088
+    function getRandomFaq($field = '', $status = '', $category = -1)
1089 1089
     {
1090
-        $ret= false;
1090
+        $ret = false;
1091 1091
 
1092
-        $notNullFields= $field;
1092
+        $notNullFields = $field;
1093 1093
 
1094 1094
         // Getting the number of published FAQ
1095
-        $totalFaqs= $this->getFaqsCount(-1, $status, $notNullFields);
1095
+        $totalFaqs = $this->getFaqsCount(-1, $status, $notNullFields);
1096 1096
 
1097 1097
         if ($totalFaqs > 0) {
1098
-            $totalFaqs= $totalFaqs -1;
1098
+            $totalFaqs = $totalFaqs-1;
1099 1099
             mt_srand((double) microtime() * 1000000);
1100
-            $entrynumber= mt_rand(0, $totalFaqs);
1101
-            $faq= & $this->getFaqs(1, $entrynumber, $status, -1, 'datesub', 'DESC', $notNullFields);
1100
+            $entrynumber = mt_rand(0, $totalFaqs);
1101
+            $faq = & $this->getFaqs(1, $entrynumber, $status, -1, 'datesub', 'DESC', $notNullFields);
1102 1102
             if ($faq) {
1103
-                $ret= & $faq[0];
1103
+                $ret = & $faq[0];
1104 1104
             }
1105 1105
         }
1106 1106
 
@@ -1108,92 +1108,92 @@  discard block
 block discarded – undo
1108 1108
 
1109 1109
     }
1110 1110
 
1111
-    function getContextualFaqs($limit= 0)
1111
+    function getContextualFaqs($limit = 0)
1112 1112
     {
1113
-        $ret= false;
1113
+        $ret = false;
1114 1114
 
1115
-        $otherCriteria= new CriteriaCompo();
1115
+        $otherCriteria = new CriteriaCompo();
1116 1116
         $otherCriteria->add(new Criteria('modulelink', 'None', '<>'));
1117 1117
 
1118
-        $faqsObj= & $this->getFaqs(0, 0, Array(_SF_STATUS_PUBLISHED, _SF_STATUS_NEW_ANSWER), -1, 'datesub', 'DESC', '', true, $otherCriteria);
1118
+        $faqsObj = & $this->getFaqs(0, 0, Array(_SF_STATUS_PUBLISHED, _SF_STATUS_NEW_ANSWER), -1, 'datesub', 'DESC', '', true, $otherCriteria);
1119 1119
 
1120
-        $totalfaqs= count($faqsObj);
1121
-        $randomFaqs= array();
1120
+        $totalfaqs = count($faqsObj);
1121
+        $randomFaqs = array();
1122 1122
         if ($faqsObj) {
1123
-            for ($i= 0; $i < $totalfaqs; ++$i) {
1124
-                $display= false;
1123
+            for ($i = 0; $i < $totalfaqs; ++$i) {
1124
+                $display = false;
1125 1125
 
1126
-                $http=((strpos(XOOPS_URL, "https://")) === false) ?("http://") :("https://");
1127
-                $phpself= $_SERVER['PHP_SELF'];
1128
-                $httphost= $_SERVER['HTTP_HOST'];
1129
-                $querystring= $_SERVER['QUERY_STRING'];
1126
+                $http = ((strpos(XOOPS_URL, "https://")) === false) ? ("http://") : ("https://");
1127
+                $phpself = $_SERVER['PHP_SELF'];
1128
+                $httphost = $_SERVER['HTTP_HOST'];
1129
+                $querystring = $_SERVER['QUERY_STRING'];
1130 1130
                 if ($querystring != '') {
1131
-                    $querystring= '?'.$querystring;
1131
+                    $querystring = '?'.$querystring;
1132 1132
                 }
1133
-                $currenturl= $http.$httphost.$phpself.$querystring;
1134
-                $fullcontexturl= XOOPS_URL."/".$faqsObj[$i]->contextpage();
1133
+                $currenturl = $http.$httphost.$phpself.$querystring;
1134
+                $fullcontexturl = XOOPS_URL."/".$faqsObj[$i]->contextpage();
1135 1135
                 switch ($faqsObj[$i]->modulelink()) {
1136 1136
                     case '' :
1137
-                        $display= false;
1137
+                        $display = false;
1138 1138
                         break;
1139 1139
                     case 'None' :
1140
-                        $display= false;
1140
+                        $display = false;
1141 1141
                         break;
1142 1142
                     case 'All' :
1143
-                        $display= true;
1143
+                        $display = true;
1144 1144
                         break;
1145 1145
                     case 'url' :
1146 1146
                         if ($faqsObj[$i]->exacturl()) {
1147
-                            $display=($currenturl == $fullcontexturl);
1147
+                            $display = ($currenturl == $fullcontexturl);
1148 1148
                         } else {
1149
-                            $display=(strpos($currenturl, $fullcontexturl) === false) ?(false) :(true);
1149
+                            $display = (strpos($currenturl, $fullcontexturl) === false) ? (false) : (true);
1150 1150
                         }
1151 1151
                         break;
1152 1152
                     default :
1153 1153
                         if (strpos($currenturl, XOOPS_URL."/modules/") === false) {
1154
-                            $display= false;
1154
+                            $display = false;
1155 1155
                         } else {
1156 1156
                             if (strpos($currenturl, $faqsObj[$i]->modulelink()) === false) {
1157
-                                $display= false;
1157
+                                $display = false;
1158 1158
                             } else {
1159
-                                $display= true;
1159
+                                $display = true;
1160 1160
                             }
1161 1161
                         }
1162 1162
                         break;
1163 1163
                 }
1164 1164
                 if ($display) {
1165
-                    $randomFaqs[]= & $faqsObj[$i];
1165
+                    $randomFaqs[] = & $faqsObj[$i];
1166 1166
                 }
1167 1167
             }
1168 1168
         }
1169 1169
 
1170 1170
         if (count($randomFaqs) > $limit) {
1171 1171
             srand((float) microtime() * 10000000);
1172
-            $rand_keys= array_rand($randomFaqs, $limit);
1173
-            for ($j= 0; $j < count($rand_keys); ++$j) {
1174
-                $ret[]= & $randomFaqs[$rand_keys[$j]];
1172
+            $rand_keys = array_rand($randomFaqs, $limit);
1173
+            for ($j = 0; $j < count($rand_keys); ++$j) {
1174
+                $ret[] = & $randomFaqs[$rand_keys[$j]];
1175 1175
             }
1176 1176
         } else {
1177
-            $ret= & $randomFaqs;
1177
+            $ret = & $randomFaqs;
1178 1178
         }
1179 1179
 
1180 1180
         return $ret;
1181 1181
     }
1182 1182
 
1183
-    function getLastPublishedByCat($status= array(_SF_STATUS_PUBLISHED, _SF_STATUS_NEW_ANSWER))
1183
+    function getLastPublishedByCat($status = array(_SF_STATUS_PUBLISHED, _SF_STATUS_NEW_ANSWER))
1184 1184
     {
1185
-        $ret= array();
1186
-        $faqclause= "";
1185
+        $ret = array();
1186
+        $faqclause = "";
1187 1187
         if (!sf_userIsAdmin()) {
1188
-            $smartPermHandler= & xoops_getmodulehandler('permission', 'smartfaq');
1189
-            $items= $smartPermHandler->getPermissions('item');
1190
-            $faqclause= " AND faqid IN (".implode(',', $items).")";
1188
+            $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
1189
+            $items = $smartPermHandler->getPermissions('item');
1190
+            $faqclause = " AND faqid IN (".implode(',', $items).")";
1191 1191
         }
1192 1192
 
1193
-        $sql= "CREATE TEMPORARY TABLE tmp (categoryid INT(8) UNSIGNED NOT NULL,datesub int(11) DEFAULT '0' NOT NULL);";
1194
-        $sql2= " LOCK TABLES ".$this->db->prefix('smartfaq_faq')." READ;";
1195
-        $sql3= " INSERT INTO tmp SELECT categoryid, MAX(datesub) FROM ".$this->db->prefix('smartfaq_faq')." WHERE status IN (".implode(',', $status).") $faqclause GROUP BY categoryid;";
1196
-        $sql4= " SELECT ".$this->db->prefix('smartfaq_faq').".categoryid, faqid, question, uid, ".$this->db->prefix('smartfaq_faq').".datesub FROM ".$this->db->prefix('smartfaq_faq').", tmp
1193
+        $sql = "CREATE TEMPORARY TABLE tmp (categoryid INT(8) UNSIGNED NOT NULL,datesub int(11) DEFAULT '0' NOT NULL);";
1194
+        $sql2 = " LOCK TABLES ".$this->db->prefix('smartfaq_faq')." READ;";
1195
+        $sql3 = " INSERT INTO tmp SELECT categoryid, MAX(datesub) FROM ".$this->db->prefix('smartfaq_faq')." WHERE status IN (".implode(',', $status).") $faqclause GROUP BY categoryid;";
1196
+        $sql4 = " SELECT ".$this->db->prefix('smartfaq_faq').".categoryid, faqid, question, uid, ".$this->db->prefix('smartfaq_faq').".datesub FROM ".$this->db->prefix('smartfaq_faq').", tmp
1197 1197
                               WHERE ".$this->db->prefix('smartfaq_faq').".categoryid=tmp.categoryid AND ".$this->db->prefix('smartfaq_faq').".datesub=tmp.datesub;";
1198 1198
         /*
1199 1199
         //Old implementation
@@ -1204,8 +1204,8 @@  discard block
 block discarded – undo
1204 1204
         $this->db->queryF($sql);
1205 1205
         $this->db->queryF($sql2);
1206 1206
         $this->db->queryF($sql3);
1207
-        $result= $this->db->query($sql4);
1208
-        $error= $this->db->error();
1207
+        $result = $this->db->query($sql4);
1208
+        $error = $this->db->error();
1209 1209
         $this->db->queryF("UNLOCK TABLES;");
1210 1210
         $this->db->queryF("DROP TABLE tmp;");
1211 1211
         if (!$result) {
@@ -1213,10 +1213,10 @@  discard block
 block discarded – undo
1213 1213
 
1214 1214
             return $ret;
1215 1215
         }
1216
-        while ($row= $this->db->fetchArray($result)) {
1217
-            $faq= new sfFaq();
1216
+        while ($row = $this->db->fetchArray($result)) {
1217
+            $faq = new sfFaq();
1218 1218
             $faq->assignVars($row);
1219
-            $ret[$row['categoryid']]= & $faq;
1219
+            $ret[$row['categoryid']] = & $faq;
1220 1220
             unset($faq);
1221 1221
         }
1222 1222
 
@@ -1229,9 +1229,9 @@  discard block
 block discarded – undo
1229 1229
     * @param object $criteria {@link CriteriaElement}
1230 1230
     * @return bool FALSE if deletion failed
1231 1231
     */
1232
-    function deleteAll($criteria= null)
1232
+    function deleteAll($criteria = null)
1233 1233
     {
1234
-        $sql= 'DELETE FROM '.$this->db->prefix('smartfaq_faq');
1234
+        $sql = 'DELETE FROM '.$this->db->prefix('smartfaq_faq');
1235 1235
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
1236 1236
             $sql .= ' '.$criteria->renderWhere();
1237 1237
         }
@@ -1252,10 +1252,10 @@  discard block
 block discarded – undo
1252 1252
     *
1253 1253
     * @return  bool
1254 1254
     **/
1255
-    function updateAll($fieldname, $fieldvalue, $criteria= null)
1255
+    function updateAll($fieldname, $fieldvalue, $criteria = null)
1256 1256
     {
1257
-        $set_clause= is_numeric($fieldvalue) ? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
1258
-        $sql= 'UPDATE '.$this->db->prefix('smartfaq_faq').' SET '.$set_clause;
1257
+        $set_clause = is_numeric($fieldvalue) ? $fieldname.' = '.$fieldvalue : $fieldname.' = '.$this->db->quoteString($fieldvalue);
1258
+        $sql = 'UPDATE '.$this->db->prefix('smartfaq_faq').' SET '.$set_clause;
1259 1259
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
1260 1260
             $sql .= ' '.$criteria->renderWhere();
1261 1261
         }
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 
1269 1269
     function updateCounter($faqid)
1270 1270
     {
1271
-        $sql= "UPDATE ".$this->db->prefix("smartfaq_faq")." SET counter=counter+1 WHERE faqid = ".$faqid;
1271
+        $sql = "UPDATE ".$this->db->prefix("smartfaq_faq")." SET counter=counter+1 WHERE faqid = ".$faqid;
1272 1272
         if ($this->db->queryF($sql)) {
1273 1273
             return true;
1274 1274
         } else {
@@ -1276,13 +1276,13 @@  discard block
 block discarded – undo
1276 1276
         }
1277 1277
     }
1278 1278
 
1279
-    function NotNullFieldClause($notNullFields= '', $withAnd= false)
1279
+    function NotNullFieldClause($notNullFields = '', $withAnd = false)
1280 1280
     {
1281
-        $ret= '';
1281
+        $ret = '';
1282 1282
         if ($withAnd) {
1283 1283
             $ret .= " AND ";
1284 1284
         }
1285
-        if (!empty($notNullFields) &&(is_array($notNullFields))) {
1285
+        if (!empty($notNullFields) && (is_array($notNullFields))) {
1286 1286
             foreach ($notNullFields as $v) {
1287 1287
                 $ret .= " ($v IS NOT NULL AND $v <> ' ' )";
1288 1288
             }
@@ -1293,24 +1293,24 @@  discard block
 block discarded – undo
1293 1293
         return $ret;
1294 1294
     }
1295 1295
 
1296
-    function getFaqsFromSearch($queryarray= array(), $andor= 'AND', $limit= 0, $offset= 0, $userid= 0)
1296
+    function getFaqsFromSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
1297 1297
     {
1298 1298
         global $xoopsUser;
1299 1299
 
1300
-        $ret= array();
1300
+        $ret = array();
1301 1301
 
1302
-        $userIsAdmin= sf_userIsAdmin();
1302
+        $userIsAdmin = sf_userIsAdmin();
1303 1303
 
1304 1304
         if ($userid != 0) {
1305
-            $criteriaUser= new CriteriaCompo();
1305
+            $criteriaUser = new CriteriaCompo();
1306 1306
             $criteriaUser->add(new Criteria('faq.uid', $userid), 'OR');
1307 1307
             $criteriaUser->add(new Criteria('answer.uid', $userid), 'OR');
1308 1308
         }
1309 1309
 
1310 1310
         if ($queryarray) {
1311
-            $criteriaKeywords= new CriteriaCompo();
1312
-            for ($i= 0; $i < count($queryarray); ++$i) {
1313
-                $criteriaKeyword= new CriteriaCompo();
1311
+            $criteriaKeywords = new CriteriaCompo();
1312
+            for ($i = 0; $i < count($queryarray); ++$i) {
1313
+                $criteriaKeyword = new CriteriaCompo();
1314 1314
                 $criteriaKeyword->add(new Criteria('faq.question', '%'.$queryarray[$i].'%', 'LIKE'), 'OR');
1315 1315
                 $criteriaKeyword->add(new Criteria('answer.answer', '%'.$queryarray[$i].'%', 'LIKE'), 'OR');
1316 1316
                 $criteriaKeywords->add($criteriaKeyword, $andor);
@@ -1320,18 +1320,18 @@  discard block
 block discarded – undo
1320 1320
 
1321 1321
         // Categories for which user has access
1322 1322
         if (!$userIsAdmin) {
1323
-            $smartPermHandler= & xoops_getmodulehandler('permission', 'smartfaq');
1323
+            $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
1324 1324
 
1325
-            $categoriesGranted= $smartPermHandler->getPermissions('category');
1326
-            $faqsGranted= $smartPermHandler->getPermissions('item');
1325
+            $categoriesGranted = $smartPermHandler->getPermissions('category');
1326
+            $faqsGranted = $smartPermHandler->getPermissions('item');
1327 1327
             if (!$categoriesGranted) {
1328 1328
                 return $ret;
1329 1329
             }
1330 1330
             if (!$faqsGranted) {
1331 1331
                 return $ret;
1332 1332
             }
1333
-            $grantedCategories= new Criteria('faq.categoryid', "(".implode(',', $categoriesGranted).")", 'IN');
1334
-            $grantedFaq= new CriteriaCompo();
1333
+            $grantedCategories = new Criteria('faq.categoryid', "(".implode(',', $categoriesGranted).")", 'IN');
1334
+            $grantedFaq = new CriteriaCompo();
1335 1335
             $grantedFaq->add(new Criteria('faq.faqid', "(".implode(',', $faqsGranted).")", 'IN'), 'OR');
1336 1336
             // If user is anonymous, check if the FAQ allow partialview
1337 1337
             if (!is_object($xoopsUser)) {
@@ -1339,20 +1339,20 @@  discard block
 block discarded – undo
1339 1339
             }
1340 1340
         }
1341 1341
 
1342
-        $criteriaPermissions= new CriteriaCompo();
1342
+        $criteriaPermissions = new CriteriaCompo();
1343 1343
         if (!$userIsAdmin) {
1344 1344
             $criteriaPermissions->add($grantedCategories, 'AND');
1345 1345
             $criteriaPermissions->add($grantedFaq, 'AND');
1346 1346
         }
1347 1347
 
1348
-        $criteriaAnswersStatus= new CriteriaCompo();
1348
+        $criteriaAnswersStatus = new CriteriaCompo();
1349 1349
         $criteriaAnswersStatus->add(new Criteria('answer.status', _SF_AN_STATUS_APPROVED));
1350 1350
 
1351
-        $criteriaFasStatus= new CriteriaCompo();
1351
+        $criteriaFasStatus = new CriteriaCompo();
1352 1352
         $criteriaFasStatus->add(new Criteria('faq.status', _SF_STATUS_OPENED), 'OR');
1353 1353
         $criteriaFasStatus->add(new Criteria('faq.status', _SF_STATUS_PUBLISHED), 'OR');
1354 1354
 
1355
-        $criteria= new CriteriaCompo();
1355
+        $criteria = new CriteriaCompo();
1356 1356
         if (!empty($criteriaUser)) {
1357 1357
             $criteria->add($criteriaUser, 'AND');
1358 1358
         }
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
             $criteria->add($criteriaKeywords, 'AND');
1362 1362
         }
1363 1363
 
1364
-        if (!empty($criteriaPermissions) &&(!$userIsAdmin)) {
1364
+        if (!empty($criteriaPermissions) && (!$userIsAdmin)) {
1365 1365
             $criteria->add($criteriaPermissions);
1366 1366
         }
1367 1367
 
@@ -1378,24 +1378,24 @@  discard block
 block discarded – undo
1378 1378
         $criteria->setSort('faq.datesub');
1379 1379
         $criteria->setOrder('DESC');
1380 1380
 
1381
-        $sql= 'SELECT faq.faqid, faq.question, faq.datesub, faq.uid FROM '.$this->db->prefix('smartfaq_faq').' as faq INNER JOIN '.$this->db->prefix('smartfaq_answers').' as answer ON faq.faqid = answer.faqid';
1381
+        $sql = 'SELECT faq.faqid, faq.question, faq.datesub, faq.uid FROM '.$this->db->prefix('smartfaq_faq').' as faq INNER JOIN '.$this->db->prefix('smartfaq_answers').' as answer ON faq.faqid = answer.faqid';
1382 1382
 
1383 1383
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
1384
-            $whereClause= $criteria->renderWhere();
1384
+            $whereClause = $criteria->renderWhere();
1385 1385
 
1386 1386
             if ($whereClause != 'WHERE ()') {
1387 1387
                 $sql .= ' '.$criteria->renderWhere();
1388 1388
                 if ($criteria->getSort() != '') {
1389 1389
                     $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
1390 1390
                 }
1391
-                $limit= $criteria->getLimit();
1392
-                $start= $criteria->getStart();
1391
+                $limit = $criteria->getLimit();
1392
+                $start = $criteria->getStart();
1393 1393
             }
1394 1394
         }
1395 1395
 
1396 1396
         //echo "<br />" . $sql . "<br />";
1397 1397
 
1398
-        $result= $this->db->query($sql, $limit, $start);
1398
+        $result = $this->db->query($sql, $limit, $start);
1399 1399
         if (!$result) {
1400 1400
             trigger_error("Query did not work in smartfaq", E_USER_WARNING);
1401 1401
 
@@ -1406,29 +1406,29 @@  discard block
 block discarded – undo
1406 1406
             return $ret;
1407 1407
         }
1408 1408
 
1409
-        while ($myrow= $this->db->fetchArray($result)) {
1410
-            $faq= new sfFaq();
1409
+        while ($myrow = $this->db->fetchArray($result)) {
1410
+            $faq = new sfFaq();
1411 1411
             $faq->assignVars($myrow);
1412
-            $ret[]= & $faq;
1412
+            $ret[] = & $faq;
1413 1413
             unset($faq);
1414 1414
         }
1415 1415
 
1416 1416
         return $ret;
1417 1417
     }
1418 1418
 
1419
-    function getCountsByCat($cat_id= 0, $status)
1419
+    function getCountsByCat($cat_id = 0, $status)
1420 1420
     {
1421 1421
         global $xoopsUser;
1422
-        $ret= array();
1423
-        $sql= 'SELECT categoryid, COUNT(*) AS count FROM '.$this->db->prefix('smartfaq_faq');
1422
+        $ret = array();
1423
+        $sql = 'SELECT categoryid, COUNT(*) AS count FROM '.$this->db->prefix('smartfaq_faq');
1424 1424
         if (intval($cat_id) > 0) {
1425 1425
             $sql .= ' WHERE categoryid = '.intval($cat_id);
1426 1426
             $sql .= ' AND status IN ('.implode(',', $status).')';
1427 1427
         } else {
1428 1428
             $sql .= ' WHERE status IN ('.implode(',', $status).')';
1429 1429
             if (!sf_userIsAdmin()) {
1430
-                $smartPermHandler= & xoops_getmodulehandler('permission', 'smartfaq');
1431
-                $items= $smartPermHandler->getPermissions('item');
1430
+                $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
1431
+                $items = $smartPermHandler->getPermissions('item');
1432 1432
                 if (is_object($xoopsUser)) {
1433 1433
                     $sql .= ' AND faqid IN ('.implode(',', $items).')';
1434 1434
                 } else {
@@ -1440,12 +1440,12 @@  discard block
 block discarded – undo
1440 1440
 
1441 1441
         //echo "<br />" . $sql . "<br />";
1442 1442
 
1443
-        $result= $this->db->query($sql);
1443
+        $result = $this->db->query($sql);
1444 1444
         if (!$result) {
1445 1445
             return $ret;
1446 1446
         }
1447
-        while ($row= $this->db->fetchArray($result)) {
1448
-            $ret[$row['categoryid']]= intval($row['count']);
1447
+        while ($row = $this->db->fetchArray($result)) {
1448
+            $ret[$row['categoryid']] = intval($row['count']);
1449 1449
         }
1450 1450
 
1451 1451
         return $ret;
Please login to merge, or discard this patch.
smartfaq/class/smartdbupdater.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,6 +164,9 @@  discard block
 block discarded – undo
164 164
         return $fields;
165 165
     }
166 166
 
167
+    /**
168
+     * @param string $field
169
+     */
167 170
     function fieldExists($field)
168 171
     {
169 172
         $existingFields = $this->getExistingFieldsArray();
@@ -620,7 +623,7 @@  discard block
 block discarded – undo
620 623
    /**
621 624
     * Use to update a table
622 625
     *
623
-    * @param object $table {@link SmartDbTable} that will be updated
626
+    * @param SmartDbTable $table {@link SmartDbTable} that will be updated
624 627
     *
625 628
     * @see SmartDbTable
626 629
     *
Please login to merge, or discard this patch.
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     var $_flagForDrop = false;
103 103
 
104 104
     /**
105
- * @var array $_updatedFields containing fields which values will be updated
105
+     * @var array $_updatedFields containing fields which values will be updated
106 106
      */
107 107
     var $_updatedFields;
108 108
 
@@ -111,24 +111,24 @@  discard block
 block discarded – undo
111 111
      */    //felix
112 112
     var $_updatedWhere;
113 113
 
114
-   /**
115
-    * Constructor
116
-    *
117
-    * @param string $name name of the table
118
-    *
119
-    */
114
+    /**
115
+     * Constructor
116
+     *
117
+     * @param string $name name of the table
118
+     *
119
+     */
120 120
     function __construct($name)
121 121
     {
122 122
         $this->_name = $name;
123 123
         $this->_data = array();
124 124
     }
125 125
 
126
-   /**
127
-    * Return the table name, prefixed with site table prefix
128
-    *
129
-    * @return string table name
130
-    *
131
-    */
126
+    /**
127
+     * Return the table name, prefixed with site table prefix
128
+     *
129
+     * @return string table name
130
+     *
131
+     */
132 132
     function name()
133 133
     {
134 134
         global $xoopsDB;
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         return $xoopsDB->prefix($this->_name);
137 137
     }
138 138
 
139
-   /**
140
-    * Checks if the table already exists in the database
141
-    *
142
-    * @return bool TRUE if it exists, FALSE if not
143
-    *
144
-    */
139
+    /**
140
+     * Checks if the table already exists in the database
141
+     *
142
+     * @return bool TRUE if it exists, FALSE if not
143
+     *
144
+     */
145 145
     function exists()
146 146
     {
147 147
         return smart_TableExists($this->_name);
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
         global $xoopsDB;
153 153
         $result = $xoopsDB->query("SHOW COLUMNS FROM ".$this->name());
154 154
         while ($existing_field = $xoopsDB->fetchArray($result)) {
155
-             $fields[$existing_field['Field']] = $existing_field['Type'];
156
-             if ($existing_field['Null'] != "YES") {
157
-                 $fields[$existing_field['Field']] .= " NOT NULL";
158
-             }
159
-             if ($existing_field['Extra']) {
160
-                 $fields[$existing_field['Field']] .= " ".$existing_field['Extra'];
161
-             }
155
+                $fields[$existing_field['Field']] = $existing_field['Type'];
156
+                if ($existing_field['Null'] != "YES") {
157
+                    $fields[$existing_field['Field']] .= " NOT NULL";
158
+                }
159
+                if ($existing_field['Extra']) {
160
+                    $fields[$existing_field['Field']] .= " ".$existing_field['Extra'];
161
+                }
162 162
         }
163 163
 
164 164
         return $fields;
@@ -171,56 +171,56 @@  discard block
 block discarded – undo
171 171
         return isset($existingFields[$field]);
172 172
     }
173 173
 
174
-   /**
175
-    * Set the table structure
176
-    *
177
-    * @param  string $structure table structure
178
-    *
179
-    */
174
+    /**
175
+     * Set the table structure
176
+     *
177
+     * @param  string $structure table structure
178
+     *
179
+     */
180 180
     function setStructure($structure)
181 181
     {
182 182
         $this->_structure = $structure;
183 183
     }
184 184
 
185 185
     /**
186
-    * Return the table structure
187
-    *
188
-    * @return string table structure
189
-    *
190
-    */
186
+     * Return the table structure
187
+     *
188
+     * @return string table structure
189
+     *
190
+     */
191 191
     function getStructure()
192 192
     {
193 193
         return sprintf($this->_structure, $this->name());
194 194
     }
195 195
 
196
-   /**
197
-    * Add values of a record to be added
198
-    *
199
-    * @param string $data values of a record
200
-    *
201
-    */
196
+    /**
197
+     * Add values of a record to be added
198
+     *
199
+     * @param string $data values of a record
200
+     *
201
+     */
202 202
     function setData($data)
203 203
     {
204 204
         $this->_data[] = $data;
205 205
     }
206 206
 
207
-   /**
208
-    * Get the data array
209
-    *
210
-    * @return array containing the records values to be added
211
-    *
212
-    */
207
+    /**
208
+     * Get the data array
209
+     *
210
+     * @return array containing the records values to be added
211
+     *
212
+     */
213 213
     function getData()
214 214
     {
215 215
         return $this->_data;
216 216
     }
217 217
 
218
-   /**
219
-    * Use to insert data in a table
220
-    *
221
-    * @return bool true if success, false if an error occured
222
-    *
223
-    */
218
+    /**
219
+     * Use to insert data in a table
220
+     *
221
+     * @return bool true if success, false if an error occured
222
+     *
223
+     */
224 224
     function addData()
225 225
     {
226 226
         global $xoopsDB;
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
 
240 240
     }
241 241
 
242
-   /**
243
-    * Add a field to be added
244
-    *
245
-    * @param string $name name of the field
246
-    * @param string $properties properties of the field
247
-    *
248
-    */
242
+    /**
243
+     * Add a field to be added
244
+     *
245
+     * @param string $name name of the field
246
+     * @param string $properties properties of the field
247
+     *
248
+     */
249 249
     function addAlteredField($name, $properties, $showerror=true)
250 250
     {
251 251
         $field['name'] = $name;
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
     }
256 256
 
257 257
     /**
258
-    * Invert values 0 to 1 and 1 to 0
259
-    *
260
-    * @param string $name name of the field
261
-    * @param string $old old propertie
262
-    * @param string $new new propertie
263
-    *
264
-    */    //felix
258
+     * Invert values 0 to 1 and 1 to 0
259
+     *
260
+     * @param string $name name of the field
261
+     * @param string $old old propertie
262
+     * @param string $new new propertie
263
+     *
264
+     */    //felix
265 265
     function addUpdatedWhere($name, $newValue, $oldValue)
266 266
     {
267 267
         $field['name'] = $name;
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
         $this->_updatedWhere[] = $field;
271 271
     }
272 272
 
273
-   /**
274
-    * Add new field of a record to be added
275
-    *
276
-    * @param string $name name of the field
277
-    * @param string $properties properties of the field
278
-    *
279
-    */
273
+    /**
274
+     * Add new field of a record to be added
275
+     *
276
+     * @param string $name name of the field
277
+     * @param string $properties properties of the field
278
+     *
279
+     */
280 280
     function addNewField($name, $properties)
281 281
     {
282 282
         $field['name'] = $name;
@@ -284,24 +284,24 @@  discard block
 block discarded – undo
284 284
         $this->_newFields[] = $field;
285 285
     }
286 286
 
287
-   /**
288
-    * Get fields that need to be altered
289
-    *
290
-    * @return array fields that need to be altered
291
-    *
292
-    */
287
+    /**
288
+     * Get fields that need to be altered
289
+     *
290
+     * @return array fields that need to be altered
291
+     *
292
+     */
293 293
     function getAlteredFields()
294 294
     {
295 295
         return $this->_alteredFields;
296 296
     }
297 297
 
298
-   /**
299
-    * Add field for which the value will be updated
300
-    *
301
-    * @param string $name name of the field
302
-    * @param string $value value to be set
303
-    *
304
-    */
298
+    /**
299
+     * Add field for which the value will be updated
300
+     *
301
+     * @param string $name name of the field
302
+     * @param string $value value to be set
303
+     *
304
+     */
305 305
     function addUpdatedField($name, $value)
306 306
     {
307 307
         $field['name'] = $name;
@@ -309,76 +309,76 @@  discard block
 block discarded – undo
309 309
         $this->_updatedFields[] = $field;
310 310
     }
311 311
 
312
-   /**
313
-    * Get new fields to be added
314
-    *
315
-    * @return array fields to be added
316
-    *
317
-    */
312
+    /**
313
+     * Get new fields to be added
314
+     *
315
+     * @return array fields to be added
316
+     *
317
+     */
318 318
     function getNewFields()
319 319
     {
320 320
         return $this->_newFields;
321 321
     }
322 322
 
323
-   /**
324
-    * Get fields which values need to be updated
325
-    *
326
-    * @return array fields which values need to be updated
327
-    *
328
-    */
323
+    /**
324
+     * Get fields which values need to be updated
325
+     *
326
+     * @return array fields which values need to be updated
327
+     *
328
+     */
329 329
     function getUpdatedFields()
330 330
     {
331 331
         return $this->_updatedFields;
332 332
     }
333 333
 
334
-     /**
335
-    * Get fields which values need to be updated
336
-    *
337
-    * @return array fields which values need to be updated
338
-    *
339
-    */    //felix
334
+        /**
335
+         * Get fields which values need to be updated
336
+         *
337
+         * @return array fields which values need to be updated
338
+         *
339
+         */    //felix
340 340
     function getUpdatedWhere()
341 341
     {
342 342
         return $this->_updatedWhere;
343 343
     }
344 344
 
345
-   /**
346
-    * Add values of a record to be added
347
-    *
348
-    * @param string $name name of the field
349
-    *
350
-    */
345
+    /**
346
+     * Add values of a record to be added
347
+     *
348
+     * @param string $name name of the field
349
+     *
350
+     */
351 351
     function addDropedField($name)
352 352
     {
353 353
         $this->_dropedFields[] = $name;
354 354
     }
355 355
 
356
-   /**
357
-    * Get fields that need to be droped
358
-    *
359
-    * @return array fields that need to be droped
360
-    *
361
-    */
356
+    /**
357
+     * Get fields that need to be droped
358
+     *
359
+     * @return array fields that need to be droped
360
+     *
361
+     */
362 362
     function getDropedFields()
363 363
     {
364 364
         return $this->_dropedFields;
365 365
     }
366 366
 
367
-   /**
368
-    * Set the flag to drop the table
369
-    *
370
-    */
367
+    /**
368
+     * Set the flag to drop the table
369
+     *
370
+     */
371 371
     function setFlagForDrop()
372 372
     {
373 373
         $this->_flagForDrop = true;
374 374
     }
375 375
 
376
-   /**
377
-    * Use to create a table
378
-    *
379
-    * @return bool true if success, false if an error occured
380
-    *
381
-    */
376
+    /**
377
+     * Use to create a table
378
+     *
379
+     * @return bool true if success, false if an error occured
380
+     *
381
+     */
382 382
     function createTable()
383 383
     {
384 384
         global $xoopsDB;
@@ -395,12 +395,12 @@  discard block
 block discarded – undo
395 395
         return $ret;
396 396
     }
397 397
 
398
-   /**
399
-    * Use to drop a table
400
-    *
401
-    * @return bool true if success, false if an error occured
402
-    *
403
-    */
398
+    /**
399
+     * Use to drop a table
400
+     *
401
+     * @return bool true if success, false if an error occured
402
+     *
403
+     */
404 404
     function dropTable()
405 405
     {
406 406
         global $xoopsDB;
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
         }
419 419
     }
420 420
 
421
-   /**
422
-    * Use to alter a table
423
-    *
424
-    * @return bool true if success, false if an error occured
425
-    *
426
-    */
421
+    /**
422
+     * Use to alter a table
423
+     *
424
+     * @return bool true if success, false if an error occured
425
+     *
426
+     */
427 427
     function alterTable()
428 428
     {
429 429
         global $xoopsDB;
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
         return $ret;
447 447
     }
448 448
 
449
-   /**
450
-    * Use to add new fileds in the table
451
-    *
452
-    * @return bool true if success, false if an error occured
453
-    *
454
-    */
449
+    /**
450
+     * Use to add new fileds in the table
451
+     *
452
+     * @return bool true if success, false if an error occured
453
+     *
454
+     */
455 455
     function addNewFields()
456 456
     {
457 457
         global $xoopsDB;
@@ -471,12 +471,12 @@  discard block
 block discarded – undo
471 471
         return $ret;
472 472
     }
473 473
 
474
-   /**
475
-    * Use to update fields values
476
-    *
477
-    * @return bool true if success, false if an error occured
478
-    *
479
-    */
474
+    /**
475
+     * Use to update fields values
476
+     *
477
+     * @return bool true if success, false if an error occured
478
+     *
479
+     */
480 480
     function updateFieldsValues()
481 481
     {
482 482
         global $xoopsDB;
@@ -491,16 +491,16 @@  discard block
 block discarded – undo
491 491
             } else {
492 492
                 echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_UPDATE_TABLE, $this->name()) . "<br />";
493 493
             }
494
-         }
494
+            }
495 495
 
496
-         return $ret;
496
+            return $ret;
497 497
     }
498
-       /**
499
-    * Use to update fields values
500
-    *
501
-    * @return bool true if success, false if an error occured
502
-    *
503
-    */        //felix
498
+        /**
499
+         * Use to update fields values
500
+         *
501
+         * @return bool true if success, false if an error occured
502
+         *
503
+         */        //felix
504 504
     function updateWhereValues()
505 505
     {
506 506
         global $xoopsDB;
@@ -516,16 +516,16 @@  discard block
 block discarded – undo
516 516
             } else {
517 517
                 echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_UPDATE_TABLE, $this->name()) . "<br />";
518 518
             }
519
-         }
519
+            }
520 520
 
521
-         return $ret;
521
+            return $ret;
522 522
     }
523
-   /**
524
-    * Use to drop fields
525
-    *
526
-    * @return bool true if success, false if an error occured
527
-    *
528
-    */
523
+    /**
524
+     * Use to drop fields
525
+     *
526
+     * @return bool true if success, false if an error occured
527
+     *
528
+     */
529 529
     function dropFields()
530 530
     {
531 531
         global $xoopsDB;
@@ -564,16 +564,16 @@  discard block
 block discarded – undo
564 564
 
565 565
     }
566 566
 
567
-   /**
568
-    * Use to execute a general query
569
-    *
570
-    * @param string $query query that will be executed
571
-    * @param string $goodmsg message displayed on success
572
-    * @param string $badmsg message displayed on error
573
-    *
574
-    * @return bool true if success, false if an error occured
575
-    *
576
-    */
567
+    /**
568
+     * Use to execute a general query
569
+     *
570
+     * @param string $query query that will be executed
571
+     * @param string $goodmsg message displayed on success
572
+     * @param string $badmsg message displayed on error
573
+     *
574
+     * @return bool true if success, false if an error occured
575
+     *
576
+     */
577 577
     function runQuery($query, $goodmsg, $badmsg)
578 578
     {
579 579
         global $xoopsDB;
@@ -589,14 +589,14 @@  discard block
 block discarded – undo
589 589
         }
590 590
     }
591 591
 
592
-   /**
593
-    * Use to rename a table
594
-    *
595
-    * @param string $from name of the table to rename
596
-    * @param string $to new name of the renamed table
597
-    *
598
-    * @return bool true if success, false if an error occured
599
-    */
592
+    /**
593
+     * Use to rename a table
594
+     *
595
+     * @param string $from name of the table to rename
596
+     * @param string $to new name of the renamed table
597
+     *
598
+     * @return bool true if success, false if an error occured
599
+     */
600 600
     function renameTable($from, $to)
601 601
     {
602 602
         global $xoopsDB;
@@ -617,15 +617,15 @@  discard block
 block discarded – undo
617 617
         }
618 618
     }
619 619
 
620
-   /**
621
-    * Use to update a table
622
-    *
623
-    * @param object $table {@link SmartDbTable} that will be updated
624
-    *
625
-    * @see SmartDbTable
626
-    *
627
-    * @return bool true if success, false if an error occured
628
-    */
620
+    /**
621
+     * Use to update a table
622
+     *
623
+     * @param object $table {@link SmartDbTable} that will be updated
624
+     *
625
+     * @see SmartDbTable
626
+     *
627
+     * @return bool true if success, false if an error occured
628
+     */
629 629
     function updateTable($table)
630 630
     {
631 631
         global $xoopsDB;
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@  discard block
 block discarded – undo
15 15
 
16 16
     $bRetVal = false;
17 17
     //Verifies that a MySQL table exists
18
-    $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection();
18
+    $xoopsDB = & XoopsDatabaseFactory::getDatabaseConnection();
19 19
     $realname = $xoopsDB->prefix($table);
20 20
     $sql = "SHOW TABLES FROM ".XOOPS_DB_NAME;
21 21
     $ret = $xoopsDB->queryF($sql);
22
-    while (list($m_table)=$xoopsDB->fetchRow($ret)) {
22
+    while (list($m_table) = $xoopsDB->fetchRow($ret)) {
23 23
 
24
-        if ($m_table ==  $realname) {
24
+        if ($m_table == $realname) {
25 25
             $bRetVal = true;
26 26
             break;
27 27
         }
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
  * Include the language constants for the SmartObjectDBUpdater
57 57
  */
58 58
 global $xoopsConfig;
59
-$common_file = XOOPS_ROOT_PATH . "/modules/smartfaq/language/" . $xoopsConfig['language'] . "/smartdbupdater.php";
59
+$common_file = XOOPS_ROOT_PATH."/modules/smartfaq/language/".$xoopsConfig['language']."/smartdbupdater.php";
60 60
 if (!file_exists($common_file)) {
61 61
 
62
-    $common_file = XOOPS_ROOT_PATH . "/modules/smartfaq/language/english/smartdbupdater.php";
62
+    $common_file = XOOPS_ROOT_PATH."/modules/smartfaq/language/english/smartdbupdater.php";
63 63
 }
64 64
 
65 65
 include($common_file);
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
         global $xoopsDB;
227 227
 
228 228
         foreach ($this->getData() as $data) {
229
-                $query = sprintf('INSERT INTO %s VALUES (%s)',$this->name(), $data);
229
+                $query = sprintf('INSERT INTO %s VALUES (%s)', $this->name(), $data);
230 230
             $ret = $xoopsDB->query($query);
231
-            if (! $ret) {
232
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_ADD_DATA_ERR, $this->name()) . "<br />";
231
+            if (!$ret) {
232
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_ADD_DATA_ERR, $this->name())."<br />";
233 233
             } else {
234
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_ADD_DATA, $this->name()) . "<br />";
234
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_ADD_DATA, $this->name())."<br />";
235 235
             }
236 236
         }
237 237
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     * @param string $properties properties of the field
247 247
     *
248 248
     */
249
-    function addAlteredField($name, $properties, $showerror=true)
249
+    function addAlteredField($name, $properties, $showerror = true)
250 250
     {
251 251
         $field['name'] = $name;
252 252
         $field['properties'] = $properties;
@@ -386,10 +386,10 @@  discard block
 block discarded – undo
386 386
         $query = $this->getStructure();
387 387
 
388 388
         $ret = $xoopsDB->query($query);
389
-        if (! $ret) {
390
-            echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_CREATE_TABLE_ERR, $this->name()) . "<br />";
389
+        if (!$ret) {
390
+            echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_CREATE_TABLE_ERR, $this->name())."<br />";
391 391
         } else {
392
-            echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_CREATE_TABLE, $this->name()) . "<br />";
392
+            echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_CREATE_TABLE, $this->name())."<br />";
393 393
         }
394 394
 
395 395
         return $ret;
@@ -407,12 +407,12 @@  discard block
 block discarded – undo
407 407
 
408 408
         $query = sprintf("DROP TABLE %s", $this->name());
409 409
         $ret = $xoopsDB->query($query);
410
-        if (! $ret) {
411
-            echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_DROP_TABLE_ERR,  $this->name()) . "<br />";
410
+        if (!$ret) {
411
+            echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_DROP_TABLE_ERR, $this->name())."<br />";
412 412
 
413 413
             return false;
414 414
         } else {
415
-            echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_DROP_TABLE,  $this->name()) . "<br />";
415
+            echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_DROP_TABLE, $this->name())."<br />";
416 416
 
417 417
             return true;
418 418
         }
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
             //echo $query;
436 436
             $ret = $ret && $xoopsDB->query($query);
437 437
             if ($alteredField['showerror']) {
438
-                if (! $ret) {
439
-                    echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_CHGFIELD_ERR, $alteredField['name'], $this->name()) . "<br />";
438
+                if (!$ret) {
439
+                    echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_CHGFIELD_ERR, $alteredField['name'], $this->name())."<br />";
440 440
                 } else {
441
-                    echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_CHGFIELD,$alteredField['name'], $this->name()) . "<br />";
441
+                    echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_CHGFIELD, $alteredField['name'], $this->name())."<br />";
442 442
                 }
443 443
             }
444 444
         }
@@ -461,10 +461,10 @@  discard block
 block discarded – undo
461 461
             $query = sprintf("ALTER TABLE `%s` ADD `%s` %s", $this->name(), $newField['name'], $newField['properties']);
462 462
             //echo $query;
463 463
             $ret = $ret && $xoopsDB->query($query);
464
-            if (! $ret) {
465
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_NEWFIELD_ERR, $newField['name'], $this->name()) . "<br />";
464
+            if (!$ret) {
465
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_NEWFIELD_ERR, $newField['name'], $this->name())."<br />";
466 466
             } else {
467
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_NEWFIELD,$newField['name'], $this->name()) . "<br />";
467
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_NEWFIELD, $newField['name'], $this->name())."<br />";
468 468
             }
469 469
         }
470 470
 
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
         foreach ($this->getUpdatedFields() as $updatedField) {
487 487
             $query = sprintf("UPDATE %s SET %s = %s", $this->name(), $updatedField['name'], $updatedField['value']);
488 488
             $ret = $ret && $xoopsDB->query($query);
489
-            if (! $ret) {
490
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_UPDATE_TABLE_ERR, $this->name()) . "<br />";
489
+            if (!$ret) {
490
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_UPDATE_TABLE_ERR, $this->name())."<br />";
491 491
             } else {
492
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_UPDATE_TABLE, $this->name()) . "<br />";
492
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_UPDATE_TABLE, $this->name())."<br />";
493 493
             }
494 494
          }
495 495
 
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
             $query = sprintf("UPDATE %s SET %s = %s WHERE %s  %s", $this->name(), $updatedWhere['name'], $updatedWhere['value'], $updatedWhere['name'], $updatedWhere['where']);
512 512
             //echo $query."<br>";
513 513
             $ret = $ret && $xoopsDB->query($query);
514
-            if (! $ret) {
515
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_UPDATE_TABLE_ERR, $this->name()) . "<br />";
514
+            if (!$ret) {
515
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_UPDATE_TABLE_ERR, $this->name())."<br />";
516 516
             } else {
517
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_UPDATE_TABLE, $this->name()) . "<br />";
517
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_UPDATE_TABLE, $this->name())."<br />";
518 518
             }
519 519
          }
520 520
 
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
             $query = sprintf("ALTER TABLE %s DROP %s", $this->name(), $dropedField);
537 537
 
538 538
             $ret = $ret && $xoopsDB->query($query);
539
-            if (! $ret) {
540
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_DROPFIELD_ERR, $dropedField, $this->name()) . "<br />";
539
+            if (!$ret) {
540
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_DROPFIELD_ERR, $dropedField, $this->name())."<br />";
541 541
             } else {
542
-                echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_DROPFIELD, $dropedField, $this->name()) . "<br />";
542
+                echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_DROPFIELD, $dropedField, $this->name())."<br />";
543 543
             }
544 544
         }
545 545
 
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
     {
579 579
         global $xoopsDB;
580 580
         $ret = $xoopsDB->query($query);
581
-        if (! $ret) {
581
+        if (!$ret) {
582 582
             echo "&nbsp;&nbsp;$badmsg<br />";
583 583
 
584 584
             return false;
@@ -606,12 +606,12 @@  discard block
 block discarded – undo
606 606
 
607 607
         $query = sprintf("ALTER TABLE %s RENAME %s", $from, $to);
608 608
         $ret = $xoopsDB->query($query);
609
-        if (! $ret) {
610
-            echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_RENAME_TABLE_ERR, $from) . "<br />";
609
+        if (!$ret) {
610
+            echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_RENAME_TABLE_ERR, $from)."<br />";
611 611
 
612 612
             return false;
613 613
         } else {
614
-            echo "&nbsp;&nbsp;" . sprintf(_SDU_MSG_RENAME_TABLE, $from, $to) . "<br />";
614
+            echo "&nbsp;&nbsp;".sprintf(_SDU_MSG_RENAME_TABLE, $from, $to)."<br />";
615 615
 
616 616
             return true;
617 617
         }
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 
640 640
         // If table is flag for drop, drop it
641 641
         if ($table->_flagForDrop) {
642
-            $ret = $table->dropTable()  && $ret;
642
+            $ret = $table->dropTable() && $ret;
643 643
         }
644 644
 
645 645
         // If table has data, insert it
Please login to merge, or discard this patch.
smartfaq/class/uploader.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      * Constructor
24 24
      *
25 25
      * @param string $uploadDir
26
-     * @param array  $allowedMimeTypes
26
+     * @param integer  $allowedMimeTypes
27 27
      * @param int    $maxFileSize
28 28
      * @param int    $maxWidth
29 29
      * @param int    $maxHeight
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * CBB, XOOPS forum module
4
- *
5
- * @copyright	The XOOPS Project http://xoops.sf.net
6
- * @license		http://www.fsf.org/copyleft/gpl.html GNU public license
7
- * @author		Taiwen Jiang (phppp or D.J.) <[email protected]>
8
- * @since		4.00
9
- * @version		$Id $
10
- * @package		module::newbb
11
- */
3
+     * CBB, XOOPS forum module
4
+     *
5
+     * @copyright	The XOOPS Project http://xoops.sf.net
6
+     * @license		http://www.fsf.org/copyleft/gpl.html GNU public license
7
+     * @author		Taiwen Jiang (phppp or D.J.) <[email protected]>
8
+     * @since		4.00
9
+     * @version		$Id $
10
+     * @package		module::newbb
11
+     */
12 12
 
13 13
 // defined("XOOPS_ROOT_PATH") || exit("XOOPS root path not defined");
14 14
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 // defined("XOOPS_ROOT_PATH") || exit("XOOPS root path not defined");
14 14
 
15
-include_once XOOPS_ROOT_PATH . "/class/uploader.php";
15
+include_once XOOPS_ROOT_PATH."/class/uploader.php";
16 16
 
17 17
 class sf_uploader extends XoopsMediaUploader
18 18
 {
Please login to merge, or discard this patch.
smartfaq/include/functions.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -581,6 +581,9 @@
 block discarded – undo
581 581
     echo "<h3 style=\"color: #2F5376; margin: 6px 0 0 0; \"><a href='#' onClick=\"toggle('" . $tablename . "'); toggleIcon('" . $iconname . "');\">";
582 582
 }
583 583
 
584
+/**
585
+ * @param string $name
586
+ */
584 587
 function sf_gethandler($name, $optional = false )
585 588
 {
586 589
     static $handlers;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -287,8 +287,7 @@  discard block
 block discarded – undo
287 287
 * @param array $groups : group with granted permission
288 288
 * @param integer $itemID : faqid on which we are setting permissions
289 289
 * @return boolean : TRUE if the no errors occured
290
-
291
-*/
290
+ */
292 291
 function sf_saveItemPermissions($groups, $itemID)
293 292
 {
294 293
     $result = true;
@@ -536,7 +535,7 @@  discard block
 block discarded – undo
536 535
 function sf_collapsableBar($tablename = '', $iconname = '')
537 536
 {
538 537
 
539
-   ?>
538
+    ?>
540 539
     <script type="text/javascript"><!--
541 540
     function goto_URL(object)
542 541
     {
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     if (!isset($smartModule)) {
19 19
         global $xoopsModule;
20 20
         if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == 'smartfaq') {
21
-            $smartModule =& $xoopsModule;
21
+            $smartModule = & $xoopsModule;
22 22
         } else {
23 23
             $hModule = &xoops_gethandler('module');
24 24
             $smartModule = $hModule->getByDirname('smartfaq');
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
         global $xoopsModule;
36 36
         if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == 'smartfaq') {
37 37
             global $xoopsModuleConfig;
38
-            $smartConfig =& $xoopsModuleConfig;
38
+            $smartConfig = & $xoopsModuleConfig;
39 39
         } else {
40
-            $smartModule =& sf_getModuleInfo();
40
+            $smartModule = & sf_getModuleInfo();
41 41
             $hModConfig = &xoops_gethandler('config');
42 42
             $smartConfig = $hModConfig->getConfigsByCat(0, $smartModule->getVar('mid'));
43 43
         }
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 
49 49
 function sf_getHelpPath()
50 50
 {
51
-    $smartConfig =& sf_getModuleConfig();
51
+    $smartConfig = & sf_getModuleConfig();
52 52
     switch ($smartConfig['helppath_select']) {
53 53
         case 'docs.xoops.org' :
54 54
             return 'http://docs.xoops.org/help/sfaqh/index.htm';
55 55
         break;
56 56
 
57 57
         case 'inside' :
58
-            return XOOPS_URL . "/modules/smartfaq/doc/";
58
+            return XOOPS_URL."/modules/smartfaq/doc/";
59 59
         break;
60 60
 
61 61
         case 'custom' :
@@ -64,31 +64,31 @@  discard block
 block discarded – undo
64 64
     }
65 65
 }
66 66
 
67
-function sf_formatErrors($errors=array())
67
+function sf_formatErrors($errors = array())
68 68
 {
69 69
     $ret = '';
70 70
     foreach ($errors as $key=>$value) {
71
-        $ret .= "<br /> - " . $value;
71
+        $ret .= "<br /> - ".$value;
72 72
     }
73 73
 
74 74
     return $ret;
75 75
 }
76 76
 
77
-function sf_addCategoryOption($categoryObj, $selectedid=0, $level = 0, $ret='')
77
+function sf_addCategoryOption($categoryObj, $selectedid = 0, $level = 0, $ret = '')
78 78
 {
79 79
     // Creating the category handler object
80
-    $category_handler =& sf_gethandler('category');
80
+    $category_handler = & sf_gethandler('category');
81 81
 
82 82
     $spaces = '';
83 83
     for ($j = 0; $j < $level; ++$j) {
84 84
         $spaces .= '--';
85 85
     }
86 86
 
87
-    $ret .= "<option value='" . $categoryObj->categoryid() . "'";
87
+    $ret .= "<option value='".$categoryObj->categoryid()."'";
88 88
     if ($selectedid == $categoryObj->categoryid()) {
89 89
         $ret .= " selected='selected'";
90 90
     }
91
-    $ret .= ">" . $spaces . $categoryObj->name() . "</option>\n";
91
+    $ret .= ">".$spaces.$categoryObj->name()."</option>\n";
92 92
 
93 93
     $subCategoriesObj = $category_handler->getCategories(0, 0, $categoryObj->categoryid());
94 94
     if (count($subCategoriesObj) > 0) {
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
     return $ret;
102 102
 }
103 103
 
104
-function sf_createCategorySelect($selectedid=0, $parentcategory=0, $allCatOption=true)
104
+function sf_createCategorySelect($selectedid = 0, $parentcategory = 0, $allCatOption = true)
105 105
 {
106
-    $ret = "" . _MB_SF_SELECTCAT . "&nbsp;<select name='options[]'>";
106
+    $ret = ""._MB_SF_SELECTCAT."&nbsp;<select name='options[]'>";
107 107
     if ($allCatOption) {
108 108
         $ret .= "<option value='0'";
109
-        $ret .= ">" . _MB_SF_ALLCAT . "</option>\n";
109
+        $ret .= ">"._MB_SF_ALLCAT."</option>\n";
110 110
     }
111 111
 
112 112
     // Creating the category handler object
113
-    $category_handler =& sf_gethandler('category');
113
+    $category_handler = & sf_gethandler('category');
114 114
 
115 115
     // Creating category objects
116 116
     $categoriesObj = $category_handler->getCategories(0, 0, $parentcategory);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     return $ret;
126 126
 }
127 127
 
128
-function sf_getStatusArray ()
128
+function sf_getStatusArray()
129 129
 {
130 130
     $result = array("1" => _AM_SF_STATUS1,
131 131
     "2" => _AM_SF_STATUS2,
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
     return $result;
140 140
 }
141 141
 
142
-function sf_moderator ()
142
+function sf_moderator()
143 143
 {
144 144
     global $xoopsUser;
145 145
 
146 146
     if (!$xoopsUser) {
147 147
         $result = false;
148 148
     } else {
149
-        $smartPermHandler =& xoops_getmodulehandler('permission', 'smartfaq');
149
+        $smartPermHandler = & xoops_getmodulehandler('permission', 'smartfaq');
150 150
 
151 151
         $categories = $smartPermHandler->getPermissions('moderation');
152 152
         if (count($categories) == 0) {
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
     return $result;
160 160
 }
161 161
 
162
-function sf_modFooter ()
162
+function sf_modFooter()
163 163
 {
164
-    $smartModule =& sf_getModuleInfo();
164
+    $smartModule = & sf_getModuleInfo();
165 165
 
166
-    $modfootertxt = "Module " . $smartModule->getInfo('name') . " - Version " . $smartModule->getInfo('version') . "";
166
+    $modfootertxt = "Module ".$smartModule->getInfo('name')." - Version ".$smartModule->getInfo('version')."";
167 167
 
168
-    $modfooter = "<a href='" . $smartModule->getInfo('support_site_url') . "' target='_blank'><img src='" . XOOPS_URL . "/modules/smartfaq/assets/images/sfcssbutton.gif' title='" . $modfootertxt . "' alt='" . $modfootertxt . "'/></a>";
168
+    $modfooter = "<a href='".$smartModule->getInfo('support_site_url')."' target='_blank'><img src='".XOOPS_URL."/modules/smartfaq/assets/images/sfcssbutton.gif' title='".$modfootertxt."' alt='".$modfootertxt."'/></a>";
169 169
 
170 170
     return $modfooter;
171 171
 }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
     $result = false;
185 185
 
186
-    $smartModule =& sf_getModuleInfo();
186
+    $smartModule = & sf_getModuleInfo();
187 187
     $module_id = $smartModule->getVar('mid');
188 188
 
189 189
     if (!empty($xoopsUser)) {
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
     } else {
217 217
         $result = -1;
218 218
 
219
-        $groups = ($xoopsUser)? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
219
+        $groups = ($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
220 220
 
221 221
         $gperm_handler = &xoops_gethandler('groupperm');
222
-        $smartModule =& sf_getModuleInfo();
222
+        $smartModule = & sf_getModuleInfo();
223 223
         $module_id = $smartModule->getVar('mid');
224 224
 
225 225
         // Do we have access to the parent category
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
     Global $xoopsDB;
256 256
 
257 257
     $result = true;
258
-    $smartModule =& sf_getModuleInfo();
258
+    $smartModule = & sf_getModuleInfo();
259 259
     $module_id = $smartModule->getVar('mid');
260 260
 
261 261
     $gperm_handler = &xoops_gethandler('groupperm');
262 262
 
263
-    $sql = "SELECT faqid FROM " . $xoopsDB->prefix("smartfaq_faq") . " WHERE categoryid = '$categoryid' ";
263
+    $sql = "SELECT faqid FROM ".$xoopsDB->prefix("smartfaq_faq")." WHERE categoryid = '$categoryid' ";
264 264
     $result = $xoopsDB->query($sql);
265 265
 
266 266
     if (count($result) > 0) {
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 function sf_saveItemPermissions($groups, $itemID)
293 293
 {
294 294
     $result = true;
295
-    $smartModule =& sf_getModuleInfo();
295
+    $smartModule = & sf_getModuleInfo();
296 296
     $module_id = $smartModule->getVar('mid');
297 297
 
298 298
     $gperm_handler = &xoops_gethandler('groupperm');
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 function sf_saveCategory_Permissions($groups, $categoryid, $perm_name)
323 323
 {
324 324
     $result = true;
325
-    $smartModule =& sf_getModuleInfo();
325
+    $smartModule = & sf_getModuleInfo();
326 326
     $module_id = $smartModule->getVar('mid');
327 327
 
328 328
     $gperm_handler = &xoops_gethandler('groupperm');
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 function sf_saveModerators($moderators, $categoryid)
352 352
 {
353 353
     $result = true;
354
-    $smartModule =& sf_getModuleInfo();
354
+    $smartModule = & sf_getModuleInfo();
355 355
     $module_id = $smartModule->getVar('mid');
356 356
 
357 357
     $gperm_handler = &xoops_gethandler('groupperm');
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     $ret = array();
373 373
     global $xoopsDB;
374 374
 
375
-    $result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("smartfaq_faq") . " WHERE faqid = '$faqid'");
375
+    $result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("smartfaq_faq")." WHERE faqid = '$faqid'");
376 376
     $ret = $xoopsDB->fetcharray($result);
377 377
 
378 378
     return $ret;
@@ -386,30 +386,30 @@  discard block
 block discarded – undo
386 386
 */
387 387
 
388 388
 // TODO : Move this to the sfFaq class
389
-function sf_getAdminLinks($faqid = 0, $open=false)
389
+function sf_getAdminLinks($faqid = 0, $open = false)
390 390
 {
391 391
     global $xoopsUser, $xoopsModule, $xoopsModuleConfig, $xoopsConfig;
392 392
     $adminLinks = '';
393
-    $modulePath = XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/";
394
-    $page = $open? 'question.php' : 'faq.php';
393
+    $modulePath = XOOPS_URL."/modules/".$xoopsModule->dirname()."/";
394
+    $page = $open ? 'question.php' : 'faq.php';
395 395
     if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
396 396
         // Edit button
397
-        $adminLinks .= "<a href='" . $modulePath . "admin/$page?op=mod&amp;faqid=" . $faqid . "'><img src='" . $modulePath . "assets/images/links/edit.gif'" . " title='" . _MD_SF_EDIT . "' alt='" . _MD_SF_EDIT . "'/></a>";
397
+        $adminLinks .= "<a href='".$modulePath."admin/$page?op=mod&amp;faqid=".$faqid."'><img src='".$modulePath."assets/images/links/edit.gif'"." title='"._MD_SF_EDIT."' alt='"._MD_SF_EDIT."'/></a>";
398 398
         $adminLinks .= " ";
399 399
         // Delete button
400
-        $adminLinks .= "<a href='" . $modulePath . "admin/$page?op=del&amp;faqid=" . $faqid . "'><img src='" . $modulePath . "assets/images/links/delete.gif'" . " title='" . _MD_SF_DELETE . "' alt='" . _MD_SF_DELETE . "'/></a>";
400
+        $adminLinks .= "<a href='".$modulePath."admin/$page?op=del&amp;faqid=".$faqid."'><img src='".$modulePath."assets/images/links/delete.gif'"." title='"._MD_SF_DELETE."' alt='"._MD_SF_DELETE."'/></a>";
401 401
         $adminLinks .= " ";
402 402
     }
403 403
     // Print button
404
-    $adminLinks .= "<a href='" . $modulePath . "print.php?faqid=" . $faqid . "'><img src='" . $modulePath . "assets/images/links/print.gif' title='" . _MD_SF_PRINT . "' alt='" . _MD_SF_PRINT . "'/></a>";
404
+    $adminLinks .= "<a href='".$modulePath."print.php?faqid=".$faqid."'><img src='".$modulePath."assets/images/links/print.gif' title='"._MD_SF_PRINT."' alt='"._MD_SF_PRINT."'/></a>";
405 405
     $adminLinks .= " ";
406 406
     // Email button
407
-    $maillink = 'mailto:?subject=' . sprintf(_MD_SF_INTARTICLE, $xoopsConfig['sitename']) . '&amp;body=' . sprintf(_MD_SF_INTARTFOUND, $xoopsConfig['sitename']) . ':  ' . $modulePath . 'faq.php?faqid=' . $faqid;
408
-    $adminLinks .= "<a href=\"" . $maillink . "\"><img src='" . $modulePath . "assets/images/links/friend.gif' title='" . _MD_SF_MAIL . "' alt='" . _MD_SF_MAIL . "'/></a>";
407
+    $maillink = 'mailto:?subject='.sprintf(_MD_SF_INTARTICLE, $xoopsConfig['sitename']).'&amp;body='.sprintf(_MD_SF_INTARTFOUND, $xoopsConfig['sitename']).':  '.$modulePath.'faq.php?faqid='.$faqid;
408
+    $adminLinks .= "<a href=\"".$maillink."\"><img src='".$modulePath."assets/images/links/friend.gif' title='"._MD_SF_MAIL."' alt='"._MD_SF_MAIL."'/></a>";
409 409
     $adminLinks .= " ";
410 410
     // Submit New Answer button
411 411
     if (($xoopsModuleConfig['allownewanswer']) && (is_object($xoopsUser) || $xoopsModuleConfig['anonpost'])) {
412
-        $adminLinks .= "<a href='" . $modulePath . "answer.php?faqid=" . $faqid . "'><img src='" . $modulePath . "assets/images/links/newanswer.gif' title='" . _MD_SF_SUBMITANSWER . "' alt='" . _MD_SF_SUBMITANSWER . "'/></a>";
412
+        $adminLinks .= "<a href='".$modulePath."answer.php?faqid=".$faqid."'><img src='".$modulePath."assets/images/links/newanswer.gif' title='"._MD_SF_SUBMITANSWER."' alt='"._MD_SF_SUBMITANSWER."'/></a>";
413 413
         $adminLinks .= " ";
414 414
     }
415 415
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             if (!isset($users[$userid])) {
440 440
                 return $GLOBALS['xoopsConfig']['anonymous'];
441 441
             }
442
-            $user =& $users[$userid];
442
+            $user = & $users[$userid];
443 443
         }
444 444
 
445 445
         if (is_object($user)) {
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
                 $fullname = $user->getVar('name');
454 454
             }
455 455
             if (!empty($fullname)) {
456
-                $linkeduser = "$fullname [<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $userid . "'>" . $ts->htmlSpecialChars($username) . "</a>]";
456
+                $linkeduser = "$fullname [<a href='".XOOPS_URL."/userinfo.php?uid=".$userid."'>".$ts->htmlSpecialChars($username)."</a>]";
457 457
             } else {
458
-                $linkeduser = "<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . "</a>";
458
+                $linkeduser = "<a href='".XOOPS_URL."/userinfo.php?uid=".$userid."'>".ucwords($ts->htmlSpecialChars($username))."</a>";
459 459
             }
460 460
 
461 461
             return $linkeduser;
@@ -479,18 +479,18 @@  discard block
 block discarded – undo
479 479
     return $xurl;
480 480
 }
481 481
 
482
-function sf_adminMenu ($currentoption = 0, $breadcrumb = '')
482
+function sf_adminMenu($currentoption = 0, $breadcrumb = '')
483 483
 {
484 484
 
485 485
     /* Nice buttons styles */
486 486
     echo "
487 487
         <style type='text/css'>
488 488
         #buttontop { float:left; width:100%; background: #e7e7e7; font-size:93%; line-height:normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0; }
489
-        #buttonbar { float:left; width:100%; background: #e7e7e7 url('" . XOOPS_URL . "/modules/smartfaq/assets/images/bg.gif') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 12px; }
489
+        #buttonbar { float:left; width:100%; background: #e7e7e7 url('" . XOOPS_URL."/modules/smartfaq/assets/images/bg.gif') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 12px; }
490 490
         #buttonbar ul { margin:0; margin-top: 15px; padding:10px 10px 0; list-style:none; }
491 491
         #buttonbar li { display:inline; margin:0; padding:0; }
492
-        #buttonbar a { float:left; background:url('" . XOOPS_URL . "/modules/smartfaq/assets/images/left_both.gif') no-repeat left top; margin:0; padding:0 0 0 9px; border-bottom:1px solid #000; text-decoration:none; }
493
-        #buttonbar a span { float:left; display:block; background:url('" . XOOPS_URL . "/modules/smartfaq/assets/images/right_both.gif') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }
492
+        #buttonbar a { float:left; background:url('" . XOOPS_URL."/modules/smartfaq/assets/images/left_both.gif') no-repeat left top; margin:0; padding:0 0 0 9px; border-bottom:1px solid #000; text-decoration:none; }
493
+        #buttonbar a span { float:left; display:block; background:url('" . XOOPS_URL."/modules/smartfaq/assets/images/right_both.gif') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }
494 494
         /* Commented Backslash Hack hides rule from IE5-Mac \*/
495 495
         #buttonbar a span {float:none;}
496 496
         /* End IE5-Mac hack */
@@ -509,27 +509,27 @@  discard block
 block discarded – undo
509 509
     $tblColors = Array();
510 510
     $tblColors[0] = $tblColors[1] = $tblColors[2] = $tblColors[3] = $tblColors[4] = $tblColors[5] = $tblColors[6] = $tblColors[7] = $tblColors[8] = '';
511 511
     $tblColors[$currentoption] = 'current';
512
-    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
513
-        include_once XOOPS_ROOT_PATH . '/modules/smartfaq/language/' . $xoopsConfig['language'] . '/modinfo.php';
512
+    if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php')) {
513
+        include_once XOOPS_ROOT_PATH.'/modules/smartfaq/language/'.$xoopsConfig['language'].'/modinfo.php';
514 514
     } else {
515
-        include_once XOOPS_ROOT_PATH . '/modules/smartfaq/english/modinfo.php';
515
+        include_once XOOPS_ROOT_PATH.'/modules/smartfaq/english/modinfo.php';
516 516
     }
517 517
 
518 518
     echo "<div id='buttontop'>";
519 519
     echo "<table style=\"width: 100%; padding: 0; \" cellspacing=\"0\"><tr>";
520 520
     //echo "<td style=\"width: 45%; font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;\"><a class=\"nobutton\" href=\"../../system/admin.php?fct=preferences&amp;op=showmod&amp;mod=" . $xoopsModule->getVar('mid') . "\">" . _AM_SF_OPTS . "</a> | <a href=\"import.php\">" . _AM_SF_IMPORT . "</a> | <a href=\"../index.php\">" . _AM_SF_GOMOD . "</a> | <a href=\"../help/index.html\" target=\"_blank\">" . _AM_SF_HELP . "</a> | <a href=\"about.php\">" . _AM_SF_ABOUT . "</a></td>";
521
-    echo "<td style='font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;'><a class='nobutton' href='" . XOOPS_URL . "/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=" . $xoopsModule->getVar('mid') . "'>" . _AM_SF_OPTS . "</a> | <a href='" . XOOPS_URL . "/modules/smartfaq/admin/import.php'>" . _AM_SF_IMPORT . "</a> | <a href='" . XOOPS_URL . "/modules/smartfaq/index.php'>" . _AM_SF_GOMOD . "</a> | <a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin&op=update&module=" . $xoopsModule->getVar('dirname') . "'>" . _AM_SF_UPDATE . "</a> | <a href='" . sf_getHelpPath() . "' target='_blank'>" . _AM_SF_HELP . "</a> | <a href='" . XOOPS_URL . "/modules/smartfaq/admin/about.php'>" . _AM_SF_ABOUT . "</a></td>";
522
-    echo "<td style='font-size: 10px; text-align: right; color: #2F5376; padding: 0 6px; line-height: 18px;'><b>" . $myts->displayTarea($xoopsModule->name()) . " " . _AM_SF_MODADMIN . "</b> " . $breadcrumb . "</td>";
521
+    echo "<td style='font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;'><a class='nobutton' href='".XOOPS_URL."/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=".$xoopsModule->getVar('mid')."'>"._AM_SF_OPTS."</a> | <a href='".XOOPS_URL."/modules/smartfaq/admin/import.php'>"._AM_SF_IMPORT."</a> | <a href='".XOOPS_URL."/modules/smartfaq/index.php'>"._AM_SF_GOMOD."</a> | <a href='".XOOPS_URL."/modules/system/admin.php?fct=modulesadmin&op=update&module=".$xoopsModule->getVar('dirname')."'>"._AM_SF_UPDATE."</a> | <a href='".sf_getHelpPath()."' target='_blank'>"._AM_SF_HELP."</a> | <a href='".XOOPS_URL."/modules/smartfaq/admin/about.php'>"._AM_SF_ABOUT."</a></td>";
522
+    echo "<td style='font-size: 10px; text-align: right; color: #2F5376; padding: 0 6px; line-height: 18px;'><b>".$myts->displayTarea($xoopsModule->name())." "._AM_SF_MODADMIN."</b> ".$breadcrumb."</td>";
523 523
     echo "</tr></table>";
524 524
     echo "</div>";
525 525
 
526 526
     echo "<div id='buttonbar'>";
527 527
     echo "<ul>";
528
-    echo "<li id='" . $tblColors[0] . "'><a href=\"" . XOOPS_URL . "/modules/smartfaq/admin/index.php\"><span>" . _AM_SF_INDEX . "</span></a></li>";
529
-    echo "<li id='" . $tblColors[1] . "'><a href=\"" . XOOPS_URL . "/modules/smartfaq/admin/category.php\"><span>" . _AM_SF_CATEGORIES . "</span></a></li>";
530
-    echo "<li id='" . $tblColors[2] . "'><a href=\"" . XOOPS_URL . "/modules/smartfaq/admin/faq.php\"><span>" . _AM_SF_SMARTFAQS . "</span></a></li>";
531
-    echo "<li id='" . $tblColors[3] . "'><a href=\"" . XOOPS_URL . "/modules/smartfaq/admin/question.php\"><span>" . _AM_SF_OPEN_QUESTIONS . "</span></a></li>";
532
-    echo "<li id='" . $tblColors[4] . "'><a href=\"" . XOOPS_URL . "/modules/smartfaq/admin/permissions.php\"><span>" . _AM_SF_PERMISSIONS . "</span></a></li>";
528
+    echo "<li id='".$tblColors[0]."'><a href=\"".XOOPS_URL."/modules/smartfaq/admin/index.php\"><span>"._AM_SF_INDEX."</span></a></li>";
529
+    echo "<li id='".$tblColors[1]."'><a href=\"".XOOPS_URL."/modules/smartfaq/admin/category.php\"><span>"._AM_SF_CATEGORIES."</span></a></li>";
530
+    echo "<li id='".$tblColors[2]."'><a href=\"".XOOPS_URL."/modules/smartfaq/admin/faq.php\"><span>"._AM_SF_SMARTFAQS."</span></a></li>";
531
+    echo "<li id='".$tblColors[3]."'><a href=\"".XOOPS_URL."/modules/smartfaq/admin/question.php\"><span>"._AM_SF_OPEN_QUESTIONS."</span></a></li>";
532
+    echo "<li id='".$tblColors[4]."'><a href=\"".XOOPS_URL."/modules/smartfaq/admin/permissions.php\"><span>"._AM_SF_PERMISSIONS."</span></a></li>";
533 533
     echo "</ul></div>";
534 534
 }
535 535
 
@@ -578,15 +578,15 @@  discard block
 block discarded – undo
578 578
     //-->
579 579
     </script>
580 580
     <?php
581
-    echo "<h3 style=\"color: #2F5376; margin: 6px 0 0 0; \"><a href='#' onClick=\"toggle('" . $tablename . "'); toggleIcon('" . $iconname . "');\">";
581
+    echo "<h3 style=\"color: #2F5376; margin: 6px 0 0 0; \"><a href='#' onClick=\"toggle('".$tablename."'); toggleIcon('".$iconname."');\">";
582 582
 }
583 583
 
584
-function sf_gethandler($name, $optional = false )
584
+function sf_gethandler($name, $optional = false)
585 585
 {
586 586
     static $handlers;
587 587
     $name = strtolower(trim($name));
588 588
     if (!isset($handlers[$name])) {
589
-        if ( file_exists( $hnd_file = XOOPS_ROOT_PATH.'/modules/smartfaq/class/'.$name.'.php' ) ) {
589
+        if (file_exists($hnd_file = XOOPS_ROOT_PATH.'/modules/smartfaq/class/'.$name.'.php')) {
590 590
             require_once $hnd_file;
591 591
         }
592 592
         $class = 'sf'.ucfirst($name).'Handler';
@@ -594,10 +594,10 @@  discard block
 block discarded – undo
594 594
             $handlers[$name] = new $class($GLOBALS['xoopsDB']);
595 595
         }
596 596
     }
597
-    if (!isset($handlers[$name]) && !$optional ) {
597
+    if (!isset($handlers[$name]) && !$optional) {
598 598
         trigger_error('Class <b>'.$class.'</b> does not exist<br />Handler Name: '.$name, E_USER_ERROR);
599 599
     }
600 600
     $false = false;
601 601
 
602
-    return isset($handlers[$name])? $handlers[$name] : $false;
602
+    return isset($handlers[$name]) ? $handlers[$name] : $false;
603 603
 }
Please login to merge, or discard this patch.
smartfaq/include/functions.render.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,6 @@
 block discarded – undo
68 68
 /**
69 69
  * Display forrum button
70 70
  *
71
- * @param	string	$image		image/button name, without extension
72 71
  * @param	string	$alt		alt message
73 72
  * @param	boolean	$asImage	true for image mode; false for text mode
74 73
  * @param	string	$extra		extra attribute for the button
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     if ($br != 0) {
54 54
         $text = $myts->nl2Br($text);
55 55
     }
56
-    $text = $myts->codeConv($text, $xcode, $image);    // Ryuji_edit(2003-11-18)
56
+    $text = $myts->codeConv($text, $xcode, $image); // Ryuji_edit(2003-11-18)
57 57
 
58 58
     return $text;
59 59
 }
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
     // START hacked by irmtfan
101 101
     // to show text links instead of buttons - func_num_args()==2 => only when $image, $alt is set and optional $display not set
102 102
     global $xoopsModuleConfig;
103
-    if (func_num_args()== 2) {
103
+    if (func_num_args() == 2) {
104 104
         // overall setting
105
-        if ( !empty($xoopsModuleConfig['display_text_links']) ) {
106
-            $display=false;
105
+        if (!empty($xoopsModuleConfig['display_text_links'])) {
106
+            $display = false;
107 107
         }
108 108
         // if set for each link => overwrite $display
109 109
         if (isset($xoopsModuleConfig['display_text_each_link'][$image])) {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     }
131 131
 
132 132
     $icon_handler = NewbbIconHandler::instance();
133
-    $icon_handler->template =& $xoTheme->template;
133
+    $icon_handler->template = & $xoTheme->template;
134 134
     $icon_handler->init($xoopsConfig["language"]);
135 135
 
136 136
     return $icon_handler;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,9 @@
 block discarded – undo
123 123
     global $xoTheme, $xoopsConfig;
124 124
     static $icon_handler;
125 125
 
126
-    if (isset($icon_handler)) return $icon_handler;
126
+    if (isset($icon_handler)) {
127
+        return $icon_handler;
128
+    }
127 129
 
128 130
     if (!class_exists("NewbbIconHandler")) {
129 131
         require_once dirname(__DIR__)."/class/icon.php";
Please login to merge, or discard this patch.
smartfaq/comment_delete.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
 * Licence: GNU
8 8
 */
9 9
 
10
-include dirname(dirname(__DIR__)) . '/mainfile.php';
11
-include_once XOOPS_ROOT_PATH . '/include/comment_delete.php';
10
+include dirname(dirname(__DIR__)).'/mainfile.php';
11
+include_once XOOPS_ROOT_PATH.'/include/comment_delete.php';
Please login to merge, or discard this patch.