Completed
Push — master ( c004c3...65a58d )
by Michael
04:32
created
smartfaq/comment_edit.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_edit.php';
10
+include dirname(dirname(__DIR__)).'/mainfile.php';
11
+include_once XOOPS_ROOT_PATH.'/include/comment_edit.php';
Please login to merge, or discard this patch.
smartfaq/notification_update.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 XOOPS_ROOT_PATH . '/include/notification_update.php';
10
+include dirname(dirname(__DIR__)).'/mainfile.php';
11
+include XOOPS_ROOT_PATH.'/include/notification_update.php';
Please login to merge, or discard this patch.
smartfaq/category.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 * Licence: GNU
8 8
 */
9 9
 
10
-include_once __DIR__ . '/header.php';
10
+include_once __DIR__.'/header.php';
11 11
 
12 12
 $categoryid = isset($_GET['categoryid']) ? intval($_GET['categoryid']) : 0;
13 13
 
14 14
 // Creating the category handler object
15
-$category_handler =& sf_gethandler('category');
15
+$category_handler = & sf_gethandler('category');
16 16
 
17 17
 // Creating the category object for the selected category
18 18
 $categoryObj = new sfCategory($categoryid);
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 }
37 37
 $xoopsOption['template_main'] = 'smartfaq_category.tpl';
38 38
 
39
-include_once(XOOPS_ROOT_PATH . "/header.php");
40
-include_once __DIR__ . '/footer.php';
39
+include_once(XOOPS_ROOT_PATH."/header.php");
40
+include_once __DIR__.'/footer.php';
41 41
 
42 42
 // At which record shall we start
43 43
 $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
44 44
 
45 45
 // Creating the faq handler object
46
-$faq_handler =& sf_gethandler('faq');
46
+$faq_handler = & sf_gethandler('faq');
47 47
 
48 48
 // creating the FAQ objects that belong to the selected category
49 49
 if ($xoopsModuleConfig['orderbydate'] == 1) {
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
     $subcat_keys = array_keys($subcatsObj);
85 85
     foreach ($subcat_keys as $i) {
86 86
         $subcat_id = $subcatsObj[$i]->getVar('categoryid');
87
-        if (isset($totalQnas[$subcat_id]) && $totalQnas[$subcat_id] > 0 ) {
87
+        if (isset($totalQnas[$subcat_id]) && $totalQnas[$subcat_id] > 0) {
88 88
             if (isset($last_qnaObj[$subcat_id])) {
89 89
                 $subcatsObj[$i]->setVar('last_faqid', $last_qnaObj[$subcat_id]->getVar('faqid'));
90
-                $subcatsObj[$i]->setVar('last_question_link', "<a href='faq.php?faqid=" . $last_qnaObj[$subcat_id]->getVar('faqid') . "'>" . $last_qnaObj[$subcat_id]->question($lastfaqsize) . "</a>");
90
+                $subcatsObj[$i]->setVar('last_question_link', "<a href='faq.php?faqid=".$last_qnaObj[$subcat_id]->getVar('faqid')."'>".$last_qnaObj[$subcat_id]->question($lastfaqsize)."</a>");
91 91
             }
92 92
         }
93 93
         $subcatsObj[$i]->setVar('faqcount', $totalQnas[$subcat_id]);
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
     $xoopsTpl->assign('subcats', $subcats);
99 99
 }
100 100
 $thiscategory_faqcount = isset($totalQnas[$categoryid]) ? $totalQnas[$categoryid] : 0;
101
-$category['total'] = $thiscategory_faqcount + $total_faqs;
101
+$category['total'] = $thiscategory_faqcount+$total_faqs;
102 102
 
103
-if (count($faqsObj)>0) {
103
+if (count($faqsObj) > 0) {
104 104
     $userids = array();
105 105
     foreach ($faqsObj as $key => $thisfaq) {
106 106
         $faqids[] = $thisfaq->getVar('faqid');
107 107
         $userids[$thisfaq->uid()] = 1;
108 108
     }
109
-    $answer_handler =& sf_gethandler('answer');
109
+    $answer_handler = & sf_gethandler('answer');
110 110
     $allanswers = $answer_handler->getLastPublishedByFaq($faqids);
111 111
 
112 112
     foreach ($allanswers as $key => $thisanswer) {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         $faq = $faqsObj[$i]->toArray(null, $categoryObj);
121 121
 
122 122
         // Creating the answer object
123
-        $answerObj =& $allanswers[$faqsObj[$i]->faqid()];
123
+        $answerObj = & $allanswers[$faqsObj[$i]->faqid()];
124 124
 
125 125
         $answerObj->setVar('dohtml', $faqsObj[$i]->getVar('html'));
126 126
         $answerObj->setVar('doxcode', $faqsObj[$i]->getVar('xcodes'));
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
 
141 141
     if (isset($last_qnaObj) && $last_qnaObj) {
142 142
         $category['last_faqid'] = $last_qnaObj[$categoryObj->getVar('categoryid')]->getVar('faqid');
143
-        $category['last_question_link'] = "<a href='faq.php?faqid=" . $last_qnaObj[$categoryObj->getVar('categoryid')]->getVar('faqid') . "'>" . $last_qnaObj[$categoryObj->getVar('categoryid')]->question($lastfaqsize) . "</a>";
143
+        $category['last_question_link'] = "<a href='faq.php?faqid=".$last_qnaObj[$categoryObj->getVar('categoryid')]->getVar('faqid')."'>".$last_qnaObj[$categoryObj->getVar('categoryid')]->question($lastfaqsize)."</a>";
144 144
     }
145 145
 }
146 146
 
147 147
 $xoopsTpl->assign('whereInSection', $myts->displayTarea($xoopsModule->getVar('name')));
148 148
 $xoopsTpl->assign('displaylastfaqs', true);
149 149
 $xoopsTpl->assign('display_categoryname', true);
150
-$xoopsTpl->assign('displayFull', $xoopsModuleConfig['displaytype']=='full');
150
+$xoopsTpl->assign('displayFull', $xoopsModuleConfig['displaytype'] == 'full');
151 151
 
152 152
 // Language constants
153 153
 $xoopsTpl->assign('lang_index_faqs', _MD_SF_SMARTFAQS);
@@ -165,26 +165,26 @@  discard block
 block discarded – undo
165 165
 $xoopsTpl->assign('lang_comments', _MD_SF_COMMENTS);
166 166
 
167 167
 // The Navigation Bar
168
-include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
169
-$pagenav = new XoopsPageNav($thiscategory_faqcount, $xoopsModuleConfig['indexperpage'], $start, 'start', 'categoryid=' . $categoryObj->getVar('categoryid'));
168
+include_once XOOPS_ROOT_PATH.'/class/pagenav.php';
169
+$pagenav = new XoopsPageNav($thiscategory_faqcount, $xoopsModuleConfig['indexperpage'], $start, 'start', 'categoryid='.$categoryObj->getVar('categoryid'));
170 170
 if ($xoopsModuleConfig['useimagenavpage'] == 1) {
171
-    $xoopsTpl->assign('navbar', '<div style="text-align:right;">' . $pagenav->renderImageNav() . '</div>');
171
+    $xoopsTpl->assign('navbar', '<div style="text-align:right;">'.$pagenav->renderImageNav().'</div>');
172 172
 } else {
173
-    $xoopsTpl->assign('navbar', '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>');
173
+    $xoopsTpl->assign('navbar', '<div style="text-align:right;">'.$pagenav->renderNav().'</div>');
174 174
 }
175 175
 
176 176
 $xoopsTpl->assign('category', $category);
177 177
 
178 178
 // Page Title Hack by marcan
179 179
 $module_name = $myts->htmlSpecialChars($xoopsModule->getVar('name'));
180
-$xoopsTpl->assign('xoops_pagetitle', $module_name . ' - ' . $category['name']);
180
+$xoopsTpl->assign('xoops_pagetitle', $module_name.' - '.$category['name']);
181 181
 // End Page Title Hack by marcan
182 182
 
183 183
 //code to include smartie
184
-if (file_exists(XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php')) {
185
-    include_once XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php';
186
-        $xoopsTpl->assign('smarttie',1);
184
+if (file_exists(XOOPS_ROOT_PATH.'/modules/smarttie/smarttie_links.php')) {
185
+    include_once XOOPS_ROOT_PATH.'/modules/smarttie/smarttie_links.php';
186
+        $xoopsTpl->assign('smarttie', 1);
187 187
 }
188 188
 //end code for smarttie
189 189
 
190
-include_once(XOOPS_ROOT_PATH . "/footer.php");
190
+include_once(XOOPS_ROOT_PATH."/footer.php");
Please login to merge, or discard this patch.
smartfaq/xoops_version.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 //about
27 27
 $modversion["module_status"]       = "RC3";
28 28
 $modversion['release_date']        = "2015/02/18";
29
-$modversion['release_file']        = XOOPS_URL . "/modules/" . $modversion['dirname'] . "/docs/changelog.txt";
29
+$modversion['release_file']        = XOOPS_URL."/modules/".$modversion['dirname']."/docs/changelog.txt";
30 30
 $modversion["module_website_url"] = "www.xoops.org";
31 31
 $modversion["module_website_name"] = "XOOPS";
32 32
 $modversion['min_php']             = '5.5';
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
         $isAdmin = ($xoopsUser->isAdmin($xoopsModule->getVar('mid')));
123 123
     }
124 124
 
125
-    if ($smartModule =& $xoopsModule) {
126
-        $smartConfig =& $xoopsModuleConfig;
125
+    if ($smartModule = & $xoopsModule) {
126
+        $smartConfig = & $xoopsModuleConfig;
127 127
         // Add the Submit new faq button
128 128
         if ($isAdmin || (isset($smartConfig['allowsubmit']) && $smartConfig['allowsubmit'] == 1 && (is_object($xoopsUser) || (isset($smartConfig['anonpost']) && $smartConfig['anonpost'] == 1)))) {
129 129
             $modversion['sub'][1]['name'] = _MI_SF_SUB_SMNAME1;
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
             $modversion['sub'][2]['url'] = "request.php?op=add";
136 136
         }
137 137
 
138
-        include_once XOOPS_ROOT_PATH . "/modules/smartfaq/include/functions.php";
138
+        include_once XOOPS_ROOT_PATH."/modules/smartfaq/include/functions.php";
139 139
 
140 140
         // Creating the FAQ handler object
141
-        $faq_handler =& sf_gethandler('faq');
141
+        $faq_handler = & sf_gethandler('faq');
142 142
 
143
-        if ($faq_handler->getFaqsCount(-1,  _SF_STATUS_OPENED) > 0) {
143
+        if ($faq_handler->getFaqsCount(-1, _SF_STATUS_OPENED) > 0) {
144 144
             $modversion['sub'][3]['name'] = _MI_SF_SUB_SMNAME3;
145 145
             $modversion['sub'][3]['url'] = "open_index.php";
146 146
         }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 // Config Settings (only for modules that need config settings generated automatically)
229 229
 
230
-$i=1;
230
+$i = 1;
231 231
 $modversion['config'][$i]['name'] = 'allowsubmit';
232 232
 $modversion['config'][$i]['title'] = '_MI_SF_ALLOWSUBMIT';
233 233
 $modversion['config'][$i]['description'] = '_MI_SF_ALLOWSUBMITDSC';
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 $modversion['config'][$i]['description'] = '_MI_SF_HELP_PATH_SELECT_DSC';
467 467
 $modversion['config'][$i]['formtype'] = 'select';
468 468
 $modversion['config'][$i]['valuetype'] = 'text';
469
-$modversion['config'][$i]['options'] = array( _MI_SF_HELP_INSIDE => 'inside', _MI_SF_HELP_CUSTOM => 'custom');
469
+$modversion['config'][$i]['options'] = array(_MI_SF_HELP_INSIDE => 'inside', _MI_SF_HELP_CUSTOM => 'custom');
470 470
 $modversion['config'][$i]['default'] = 'docs.xoops.org';
471 471
 ++$i;
472 472
 $modversion['config'][$i]['name'] = 'helppath_custom';
Please login to merge, or discard this patch.
smartfaq/class/answer.php 1 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.
smartfaq/class/faq.php 1 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 1 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/category.php 1 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/uploader.php 1 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.