Changeset 893 for trunk/Modules/Forum/Forum.php
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Forum/Forum.php
r891 r893 68 68 function Show(): string 69 69 { 70 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 70 71 $Output = ''; 71 72 $this->Title = T('Forum'); … … 84 85 $Output .= '<h3>'.T('Forum - Thread').'</h3>'; 85 86 if ($Action == 'add2') $Output .= $this->AddFinish(); 86 if ($ this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddForm();87 if ($User->Licence(LICENCE_USER)) $Output .= $this->ShowAddForm(); 87 88 $Output .= $this->ShowList(); 88 89 } else { 89 90 $Output .= '<h3>'.T('Forum - List of Thread').'</h3>'; 90 91 if ($Action == 'add2') $Output .= $this->AddFinish('ForumThread'); 91 if ($ this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddFormThread();92 if ($User->Licence(LICENCE_USER)) $Output .= $this->ShowAddFormThread(); 92 93 $Output .= $this->ShowListThread(); 93 94 } … … 97 98 function Edit() 98 99 { 99 $Output = ''; 100 $this->System->Database->query('UPDATE `ForumText` SET `Text`="'.$_POST['text'].'" WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']); 100 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 101 $Output = ''; 102 $this->System->Database->query('UPDATE `ForumText` SET `Text`="'.$_POST['text'].'" WHERE `User` = '.$User->Id.' AND `ID` = '.$_GET['Edit']); 101 103 $Output .= ShowMessage(T('Text edited.')); 102 104 return $Output; … … 105 107 function ShowEditForm() 106 108 { 107 $Output = ''; 108 if ($this->System->User->Licence(LICENCE_USER)) 109 { 110 $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']); 109 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 110 $Output = ''; 111 if ($User->Licence(LICENCE_USER)) 112 { 113 $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `User` = '.$User->Id.' AND `ID` = '.$_GET['Edit']); 111 114 if ( $DbResult->num_rows > 0) { 112 115 $DbRow = $DbResult->fetch_assoc(); … … 114 117 '<fieldset><legend>'.T('Edit message').'</legend>'. 115 118 T('User').': '; 116 if ($ this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';119 if ($User->Licence(LICENCE_USER)) $Output .= '<b>'.$User->Name.'</b><br />'; 117 120 else $Output .= '<input type="text" name="user" /><br />'; 118 121 $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'. … … 173 176 function ShowList() 174 177 { 178 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 175 179 $Output = ''; 176 180 … … 200 204 while ($Line = $DbResult->fetch_assoc()) 201 205 { 202 if ($ this->System->User->Id == $Line['User'])206 if ($User->Id == $Line['User']) 203 207 { 204 208 $edit = '<a href="?Edit='.$Line['ID'].'">'.T('edit').'</a>'; … … 215 219 function ShowAddForm() 216 220 { 217 $Output = ''; 218 if ($this->System->User->Licence(LICENCE_USER)) 221 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 222 $Output = ''; 223 if ($User->Licence(LICENCE_USER)) 219 224 { 220 225 $Output .= '<form action="?Thread='.$_GET['Thread'].'" method="post">'. 221 226 '<fieldset><legend>'.T('New Forum Message').'</legend>'. 222 227 T('User').': '; 223 if ($ this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';228 if ($User->Licence(LICENCE_USER)) $Output .= '<b>'.$User->Name.'</b><br />'; 224 229 else $Output .= '<input type="text" name="user" /><br />'; 225 230 $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'. … … 234 239 function ShowAddFormThread() 235 240 { 236 $Output = ''; 237 if ($this->System->User->Licence(LICENCE_USER)) 241 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 242 $Output = ''; 243 if ($User->Licence(LICENCE_USER)) 238 244 { 239 245 $Output .= '<form action="?" method="post">'. 240 246 '<fieldset><legend>'.T('New thread').'</legend>'.T('User').': '; 241 if ($ this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';247 if ($User->Licence(LICENCE_USER)) $Output .= '<b>'.$User->Name.'</b><br />'; 242 248 else $Output .= '<input type="text" name="user" /><br />'; 243 249 $Output .= T('Name of thread').': <br />'. … … 252 258 function AddFinish($Table = 'ForumText') 253 259 { 254 $Output = ''; 255 if ($this->System->User->Licence(LICENCE_USER)) 260 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 261 $Output = ''; 262 if ($User->Licence(LICENCE_USER)) 256 263 { 257 264 if (array_key_exists('text', $_POST)) … … 265 272 if ($Table == 'ForumText') $Thread = 'AND `Thread` = '.$_GET['Thread']; 266 273 $DbResult = $this->System->Database->query('SELECT `Text` FROM `'.$Table.'` WHERE 1 '.$Thread.' AND (`User` = "'. 267 $ this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1');274 $User->Id.'") ORDER BY `Date` DESC LIMIT 1'); 268 275 if ($DbResult->num_rows > 0) 269 276 { … … 280 287 { 281 288 $this->System->Database->query('INSERT INTO `'.$Table.'` ( `User`, `UserName` , `Text` , `Date` , `IP` , `Thread` ) '. 282 ' VALUES ('.$ this->System->User->Id.', "'.$this->System->User->Name.289 ' VALUES ('.$User->Id.', "'.$User->Name. 283 290 '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'","'.$_GET['Thread'].'")'); 284 291 } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 285 292 } else 286 293 $this->System->Database->query('INSERT INTO `'.$Table.'` ( `User`, `UserName` , `Text` , `Date` , `IP`) '. 287 ' VALUES ('.$ this->System->User->Id.', "'.$this->System->User->Name.294 ' VALUES ('.$User->Id.', "'.$User->Name. 288 295 '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'")'); 289 296 $Output .= ShowMessage(T('Added.')); … … 311 318 ( 312 319 'Title' => htmlspecialchars($DbRow['ThreadText']).' - '.$DbRow['UserName'].': ', 313 'Link' => 'http ://'.$this->System->Config['Web']['Host'].$this->System->Link('/forum/?Thread='.$DbRow['Thread']),320 'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/forum/?Thread='.$DbRow['Thread']), 314 321 'Description' => ShowBBcodes(htmlspecialchars($DbRow['Text'])), 315 322 'Time' => $DbRow['UnixDate'], … … 318 325 $Output = GenerateRSS(array 319 326 ( 320 'Title' => $this->System->Config['Web']['Title'].' - '.T('Forum'),321 'Link' => 'http ://'.$this->System->Config['Web']['Host'].$this->System->Link('/forum/'),322 'Description' => $this->System->Config['Web']['Description'],323 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],327 'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('Forum'), 328 'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/forum/'), 329 'Description' => Core::Cast($this->System)->Config['Web']['Description'], 330 'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'], 324 331 'Items' => $Items, 325 332 ));
Note:
See TracChangeset
for help on using the changeset viewer.