Changeset 880 for trunk/Modules/ShoutBox
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/ShoutBox/ShoutBox.php
r857 r880 20 20 'Title' => T('Shoutbox'), 'Channel' => 'shoutbox', 'Callback' => array('PageShoutBox', 'ShowRSS'), 21 21 'Permission' => LICENCE_ANONYMOUS)); 22 if (array_key_exists('Search', $this->System->ModuleManager->Modules))22 if (array_key_exists('Search', $this->System->ModuleManager->Modules)) 23 23 $this->System->ModuleManager->Modules['Search']->RegisterSearch('shoutbox', 24 24 T('Shoutbox'), array('UserName', 'Text'), '`ShoutBox`', $this->System->Link('/shoutbox/?search=')); … … 29 29 $Output = '<strong><a href="'.$this->System->Link('/shoutbox/').'">'.T('Shoutbox').':</a></strong>'; 30 30 31 if ($this->System->User->Licence(LICENCE_USER))31 if ($this->System->User->Licence(LICENCE_USER)) 32 32 $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>'; 33 33 $Output .= '<div class="box"><div class="shoutbox"><table>'; 34 34 $DbResult = $this->Database->query('SELECT * FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 30'); 35 while ($Line = $DbResult->fetch_assoc())35 while ($Line = $DbResult->fetch_assoc()) 36 36 $Output .= '<tr><td><strong>'.$Line['UserName'].'</strong>: '.MakeActiveLinks($Line['Text']).'</td></tr>'; 37 37 $Output .= '</table></div></div>'; 38 return ($Output);38 return $Output; 39 39 } 40 40 } … … 45 45 { 46 46 $this->Title = T('Shoutbox'); 47 if (array_key_exists('a', $_POST)) $Action = $_POST['a'];48 else if (array_key_exists('a', $_GET)) $Action = $_GET['a'];47 if (array_key_exists('a', $_POST)) $Action = $_POST['a']; 48 else if (array_key_exists('a', $_GET)) $Action = $_GET['a']; 49 49 else $Action = ''; 50 if ($Action == 'add2') $Output = $this->AddFinish();51 if ($Action == 'add') $Output = $this->ShowAddForm();50 if ($Action == 'add2') $Output = $this->AddFinish(); 51 if ($Action == 'add') $Output = $this->ShowAddForm(); 52 52 else $Output = $this->ShowList(); 53 return ($Output);53 return $Output; 54 54 } 55 55 … … 57 57 { 58 58 $Output = ''; 59 if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];60 else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';61 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';62 if ($_SESSION['search'] != '')59 if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search']; 60 else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 61 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 62 if ($_SESSION['search'] != '') 63 63 { 64 64 $SearchQuery = ' AND (`Text` LIKE "%'.$_SESSION['search'].'%")'; … … 71 71 72 72 $Output .= '<h3>'.T('Shoutbox').'</h3>'; 73 if ($this->System->User->Licence(LICENCE_USER))73 if ($this->System->User->Licence(LICENCE_USER)) 74 74 $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>'; 75 75 $Output .= $PageList['Output']; 76 76 $Output .= '<div class="shoutbox">'; 77 77 $DbResult = $this->System->Database->query('SELECT * FROM `ShoutBox` WHERE 1'.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']); 78 while ($Line = $DbResult->fetch_assoc())78 while ($Line = $DbResult->fetch_assoc()) 79 79 $Output .= '<div><strong>'.$Line['UserName'].'</strong>: '.MakeActiveLinks($Line['Text']).'</div>'; 80 80 $Output .= '</div>'.$PageList['Output']; 81 return ($Output);81 return $Output; 82 82 } 83 83 … … 85 85 { 86 86 $Output = ''; 87 if ($this->System->User->Licence(LICENCE_USER))87 if ($this->System->User->Licence(LICENCE_USER)) 88 88 { 89 89 $Output .= '<form action="?" method="post">'. 90 90 '<fieldset><legend>'.T('New message').'</legend>'. 91 91 'Uživatel: '; 92 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';92 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 93 93 else $Output .= '<input type="text" name="user" /><br />'; 94 94 $Output .= 'Text zprávy: <br/>'. … … 99 99 } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL); 100 100 $Output .= $this->ShowList(); 101 return ($Output);101 return $Output; 102 102 } 103 103 … … 105 105 { 106 106 $Output = ''; 107 if ($this->System->User->Licence(LICENCE_USER))107 if ($this->System->User->Licence(LICENCE_USER)) 108 108 { 109 if (array_key_exists('text', $_POST))109 if (array_key_exists('text', $_POST)) 110 110 { 111 111 $Text = $_POST['text']; 112 if (trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING);112 if (trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING); 113 113 else 114 114 { … … 116 116 $DbResult = $this->System->Database->query('SELECT `Text` FROM `ShoutBox` WHERE (`User` = "'. 117 117 $this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1'); 118 if ($DbResult->num_rows > 0)118 if ($DbResult->num_rows > 0) 119 119 { 120 120 $DbRow = $DbResult->fetch_assoc(); 121 121 } else $DbRow['Text'] = ''; 122 122 123 if ($DbRow['Text'] == $Text) $Output .= ShowMessage('Nelze vložit stejnou zprávu vícekrát za sebou.', MESSAGE_WARNING);123 if ($DbRow['Text'] == $Text) $Output .= ShowMessage('Nelze vložit stejnou zprávu vícekrát za sebou.', MESSAGE_WARNING); 124 124 else 125 125 { … … 134 134 } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL); 135 135 $Output .= $this->ShowList(); 136 return ($Output);136 return $Output; 137 137 } 138 138 … … 143 143 mb_internal_encoding('utf-8'); 144 144 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `UnixDate`, `User`, `UserName`, `Text` FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 20'); 145 while ($DbRow = $DbResult->fetch_assoc())145 while ($DbRow = $DbResult->fetch_assoc()) 146 146 { 147 147 $Title = mb_substr($DbRow['Text'], 0, $TitleLength); 148 if (mb_strlen($Title) == $TitleLength) $Title .= '...';148 if (mb_strlen($Title) == $TitleLength) $Title .= '...'; 149 149 $Items[] = array 150 150 ( … … 163 163 'Items' => $Items, 164 164 )); 165 return ($Output);165 return $Output; 166 166 } 167 167 }
Note:
See TracChangeset
for help on using the changeset viewer.