Changeset 880 for trunk/Modules/Forum
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Forum/Forum.php
r854 r880 21 21 'Permission' => LICENCE_ANONYMOUS)); 22 22 23 if (array_key_exists('Search', $this->System->ModuleManager->Modules))23 if (array_key_exists('Search', $this->System->ModuleManager->Modules)) 24 24 $this->System->ModuleManager->Modules['Search']->RegisterSearch('forum', 25 25 T('Forum'), array('UserName', 'Text'), '`ForumText`', $this->System->Link('/forum/?search=')); 26 if (array_key_exists('Search', $this->System->ModuleManager->Modules))26 if (array_key_exists('Search', $this->System->ModuleManager->Modules)) 27 27 $this->System->ModuleManager->Modules['Search']->RegisterSearch('forumthread', 28 28 T('Name of thread forum'), array('UserName', 'Text'), '`ForumThread`', … … 53 53 $DbResult = $this->Database->query($Query); 54 54 $Output .= '<table class="MiniTable"><tr><th>'.T('Date').'</th><th>'.T('User').'</th><th>'.T('Post').'</th></tr>'; 55 while ($DbRow = $DbResult->fetch_assoc())55 while ($DbRow = $DbResult->fetch_assoc()) 56 56 { 57 57 $Output .= '<tr>'. … … 62 62 } 63 63 $Output .= '</table></div>'; 64 return ($Output);64 return $Output; 65 65 } 66 66 } … … 72 72 $Output = ''; 73 73 $this->Title = T('Forum'); 74 if (array_key_exists('a', $_POST)) $Action = $_POST['a'];75 else if (array_key_exists('a', $_GET)) $Action = $_GET['a'];74 if (array_key_exists('a', $_POST)) $Action = $_POST['a']; 75 else if (array_key_exists('a', $_GET)) $Action = $_GET['a']; 76 76 else $Action = ''; 77 77 if (array_key_exists('Edit', $_GET)) { … … 86 86 if (array_key_exists('Thread', $_GET)) { 87 87 $Output .= '<h3>'.T('Forum - Thread').'</h3>'; 88 if ($Action == 'add2') $Output .= $this->AddFinish();89 if ($this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddForm();88 if ($Action == 'add2') $Output .= $this->AddFinish(); 89 if ($this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddForm(); 90 90 $Output .= $this->ShowList(); 91 91 } else { 92 92 $Output .= '<h3>'.T('Forum - List of Thread').'</h3>'; 93 if ($Action == 'add2') $Output .= $this->AddFinish('ForumThread');94 if ($this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddFormThread();93 if ($Action == 'add2') $Output .= $this->AddFinish('ForumThread'); 94 if ($this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddFormThread(); 95 95 $Output .= $this->ShowListThread(); 96 96 } 97 return ($Output);97 return $Output; 98 98 } 99 99 … … 104 104 $DbResult = $this->System->Database->query('UPDATE `ForumText` SET `Text`="'.$_POST['text'].'" WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']); 105 105 $Output .= ShowMessage(T('Text edited.')); 106 return ($Output);106 return $Output; 107 107 } 108 108 … … 110 110 { 111 111 $Output = ''; 112 if ($this->System->User->Licence(LICENCE_USER))112 if ($this->System->User->Licence(LICENCE_USER)) 113 113 { 114 114 $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']); … … 118 118 '<fieldset><legend>'.T('Edit message').'</legend>'. 119 119 T('User').': '; 120 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';120 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 121 121 else $Output .= '<input type="text" name="user" /><br />'; 122 122 $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'. … … 127 127 } else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL); 128 128 } else $Output .= ShowMessage(T('You can edit only your own message.'), MESSAGE_CRITICAL); 129 return ($Output);129 return $Output; 130 130 } 131 131 … … 150 150 $DbResult = $this->System->Database->query('SELECT `ForumText`.`Text`, `ForumText`.`Date`, `ForumText`.`UserName`,'. 151 151 '`ForumThread`.`Text` as `ThreadName`,`ForumText`.`Thread` FROM `ForumText` '.$join.' WHERE '.$where.' ORDER BY `ForumText`.`Date` DESC '.$PageList['SQLLimit']); 152 while ($Line = $DbResult->fetch_assoc())152 while ($Line = $DbResult->fetch_assoc()) 153 153 $Output .= '<div><a href="'.$this->System->Link('/forum/?Thread='.$Line['Thread']).'">'. 154 154 htmlspecialchars($Line['ThreadName']).'</a><br /><strong>'.$Line['UserName']. 155 155 '</strong> ('.HumanDate($Line['Date']).'): '.$parser->qparse(htmlspecialchars($Line['Text'])).'</div> '; 156 156 $Output .= '</div>'.$PageList['Output']; 157 return ($Output);157 return $Output; 158 158 } 159 159 … … 169 169 $Output .= '<div class="shoutbox">'; 170 170 $DbResult = $this->System->Database->query('SELECT * FROM `ForumThread` WHERE 1 ORDER BY `ID` DESC '.$PageList['SQLLimit']); 171 while ($Line = $DbResult->fetch_assoc())171 while ($Line = $DbResult->fetch_assoc()) 172 172 $Output .= '<div><span style="float:right;"><strong>'.$Line['UserName']. 173 173 '</strong> - ('.HumanDate($Line['Date']).')</span> <a href="?Thread='.$Line['ID'].'">'. 174 174 str_replace("\n", '', htmlspecialchars($Line['Text'])).'</a></div>'; 175 175 $Output .= '</div>'.$PageList['Output']; 176 return ($Output);176 return $Output; 177 177 } 178 178 … … 183 183 $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email'))); 184 184 185 if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];186 else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';187 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';188 if ($_SESSION['search'] != '')185 if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search']; 186 else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 187 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 188 if ($_SESSION['search'] != '') 189 189 { 190 190 $SearchQuery = ' AND (`Text` LIKE "%'.$_SESSION['search'].'%")'; … … 193 193 194 194 $DbResult = $this->System->Database->query('SELECT * FROM `ForumThread` WHERE ID='.($_GET['Thread']*1).' LIMIT 1'); 195 if ($DbResult->num_rows > 0)195 if ($DbResult->num_rows > 0) 196 196 { 197 197 $Thread = $DbResult->fetch_assoc(); … … 206 206 $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `Thread` = '. 207 207 ($_GET['Thread']*1).' '.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']); 208 while ($Line = $DbResult->fetch_assoc()) {208 while ($Line = $DbResult->fetch_assoc()) { 209 209 if ($this->System->User->Id == $Line['User']) 210 210 $edit = '<a href="?Edit='.$Line['ID'].'">'.T('edit').'</a>'; … … 216 216 $Output .= '</div>'.$PageList['Output']; 217 217 } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 218 return ($Output);218 return $Output; 219 219 } 220 220 … … 222 222 { 223 223 $Output = ''; 224 if ($this->System->User->Licence(LICENCE_USER))224 if ($this->System->User->Licence(LICENCE_USER)) 225 225 { 226 226 $Output .= '<form action="?Thread='.$_GET['Thread'].'" method="post">'. 227 227 '<fieldset><legend>'.T('New Forum Message').'</legend>'. 228 228 T('User').': '; 229 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';229 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 230 230 else $Output .= '<input type="text" name="user" /><br />'; 231 231 $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'. … … 235 235 '</form>'; 236 236 } else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL); 237 return ($Output);237 return $Output; 238 238 } 239 239 … … 241 241 { 242 242 $Output = ''; 243 if ($this->System->User->Licence(LICENCE_USER))243 if ($this->System->User->Licence(LICENCE_USER)) 244 244 { 245 245 $Output .= '<form action="?" method="post">'. 246 246 '<fieldset><legend>'.T('New thread').'</legend>'. 247 247 T('User').': '; 248 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';248 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 249 249 else $Output .= '<input type="text" name="user" /><br />'; 250 250 $Output .= T('Name of thread').': <br />'. … … 254 254 '</form>'; 255 255 } else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL); 256 return ($Output);256 return $Output; 257 257 } 258 258 … … 260 260 { 261 261 $Output = ''; 262 if ($this->System->User->Licence(LICENCE_USER))263 { 264 if (array_key_exists('text', $_POST))262 if ($this->System->User->Licence(LICENCE_USER)) 263 { 264 if (array_key_exists('text', $_POST)) 265 265 { 266 266 $Text = $_POST['text']; 267 if (trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING);267 if (trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING); 268 268 else 269 269 { … … 273 273 $DbResult = $this->System->Database->query('SELECT `Text` FROM `'.$Table.'` WHERE 1 '.$Thread.' AND (`User` = "'. 274 274 $this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1'); 275 if ($DbResult->num_rows > 0)275 if ($DbResult->num_rows > 0) 276 276 { 277 277 $DbRow = $DbResult->fetch_assoc(); 278 278 } else $DbRow['Text'] = ''; 279 279 280 if ($DbRow['Text'] == $Text) $Output .= ShowMessage(T('You can\' add same message twice.'), MESSAGE_WARNING);280 if ($DbRow['Text'] == $Text) $Output .= ShowMessage(T('You can\' add same message twice.'), MESSAGE_WARNING); 281 281 else 282 282 { … … 284 284 285 285 $DbResult = $this->System->Database->query('SELECT * FROM `ForumThread` WHERE ID='.($_GET['Thread']*1).' LIMIT 1'); 286 if ($DbResult->num_rows > 0)286 if ($DbResult->num_rows > 0) 287 287 { 288 288 $this->System->Database->query('INSERT INTO `'.$Table.'` ( `User`, `UserName` , `Text` , `Date` , `IP` , `Thread` ) '. … … 300 300 $Output .= '<br/>'; 301 301 } else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL); 302 return ($Output);302 return $Output; 303 303 } 304 304 … … 313 313 '`User`, `UserName`, `Text`, ( SELECT `Text` FROM `ForumThread` '. 314 314 'WHERE `ID` = `ForumText`.`Thread`) AS `ThreadText` FROM `ForumText` ORDER BY `ID` DESC LIMIT 20'); 315 while ($DbRow = $DbResult->fetch_assoc())315 while ($DbRow = $DbResult->fetch_assoc()) 316 316 { 317 317 $Title = mb_substr($DbRow['Text'], 0, $TitleLength); 318 if (mb_strlen($Title) == $TitleLength) $Title .= '...';318 if (mb_strlen($Title) == $TitleLength) $Title .= '...'; 319 319 $Items[] = array 320 320 ( … … 333 333 'Items' => $Items, 334 334 )); 335 return ($Output);335 return $Output; 336 336 } 337 337 }
Note:
See TracChangeset
for help on using the changeset viewer.