Changeset 761 for trunk/Modules/Forum/Forum.php
- Timestamp:
- Jan 24, 2014, 12:18:43 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Forum/Forum.php
r760 r761 47 47 else if(array_key_exists('a', $_GET)) $Action = $_GET['a']; 48 48 else $Action = ''; 49 if (array_key_exists('Edit', $_GET)) { 50 if (array_key_exists('text', $_POST)) 51 $Output .= $this->Edit(); 52 $Output .= $this->ShowEditForm(); 53 54 } else 49 55 if (array_key_exists('search', $_GET)) 50 56 $Output .= $this->ShowSearchForum(); … … 64 70 } 65 71 66 function Del() {72 function Edit() { 67 73 $Output = ''; 68 if (array_key_exists('Del', $_GET)) { 69 $this->System->Database->query('DELETE FROM `ForumThread` WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Del'].' '); 70 $Output .= ShowMessage('Vlákno smazáno!'); 71 } 74 75 $Text = $_POST['text']; 76 77 $DbResult = $this->System->Database->query('UPDATE `ForumText` SET `Text`="'.$_POST['text'].'" WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']); 78 79 $Output .= ShowMessage('Text upraven.'); 80 81 72 82 return ($Output); 73 83 } 74 84 85 function ShowEditForm() 86 { 87 $Output = ''; 88 if($this->System->User->Licence(LICENCE_USER)) 89 { 90 $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']); 91 if ( $DbResult->num_rows > 0) { 92 $DbRow = $DbResult->fetch_assoc(); 93 $Output .= '<form action="?Edit='.$_GET['Edit'].'" method="post">'. 94 '<fieldset><legend>Editovat zprávu</legend>'. 95 'Uživatel: '; 96 if($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 97 else $Output .= '<input type="text" name="user" /><br />'; 98 $Output .= 'Text zprávy: (Můžete využít <a href="http://www.bbcode.org/reference.php">BB kód</a>)<br/>'. 99 '<textarea onkeydown="ResizeTextArea(this)" rows="8" name="text" cols="80">'.$DbRow['Text'].'</textarea> <br/>'. 100 '<input type="hidden" name="a" value="add2"/>'. 101 '<input type="submit" value="Odeslat" /><br /></fieldset>'. 102 '</form>'; 103 } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL); 104 } else $Output .= ShowMessage('Editovat můžete pouze své zprávy', MESSAGE_CRITICAL); 105 return($Output); 106 } 107 75 108 function ShowSearchForum() 76 109 { … … 113 146 $DbResult = $this->System->Database->query('SELECT * FROM `ForumThread` WHERE 1 ORDER BY `ID` DESC '.$PageList['SQLLimit']); 114 147 while($Line = $DbResult->fetch_assoc()) 115 $Output .= '<div><a href="?Thread='.$Line['ID'].'">'.str_replace("\n", '',$Line['Text']).'</a> (<strong>'.$Line['UserName'].'</strong>) - '.HumanDate($Line['Date']).'</div>';148 $Output .= '<div><a href="?Thread='.$Line['ID'].'">'.str_replace("\n", '',$Line['Text']).'</a> <span style="float:right;"><strong>'.$Line['UserName'].'</strong> - ('.HumanDate($Line['Date']).')</span></div>'; 116 149 $Output .= '</div>'.$PageList['Output']; 117 150 return($Output); … … 145 178 $Output .= '<div class="shoutbox">'; 146 179 $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `Thread` = '.$_GET['Thread'].' '.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']); 147 while($Line = $DbResult->fetch_assoc()) 148 $Output .= '<div><strong>'.$Line['UserName'].'</strong> ('.HumanDate($Line['Date']).'): '.$parser->qparse($Line['Text']).'</div> '; 180 while($Line = $DbResult->fetch_assoc()) { 181 if ($this->System->User->Id == $Line['User']) 182 $edit = '<a href="?Edit='.$Line['ID'].'">editovat</a>'; 183 else $edit = ''; 184 $Output .= '<div><span style="float:right;">'.$edit.' ('.HumanDate($Line['Date']).')</span><strong>'.$Line['UserName'].'</strong>: '.str_replace("\n", '<br />',$parser->qparse($Line['Text'])).' </div> '; 185 } 149 186 $Output .= '</div>'.$PageList['Output']; 150 187 return($Output);
Note:
See TracChangeset
for help on using the changeset viewer.