Changeset 880 for trunk/Modules/News
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- Location:
- trunk/Modules/News
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/News/News.php
r862 r880 35 35 $DbResult = $this->Database->query('SELECT `News`.`Time`, `User`.`Name`, `News`.`Text`,`News`.`Title`, `News`.`Id` '. 36 36 ' FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT '.$Count); 37 while ($DbRow = $DbResult->fetch_assoc())37 while ($DbRow = $DbResult->fetch_assoc()) 38 38 { 39 39 $Output .= '<h4><a href="'.$this->System->Link('/news/?a=item&i='.$DbRow['Id']).'">'.$DbRow['Title'].'</a> ('.HumanDate($DbRow['Time']).')</h4>'. … … 41 41 } 42 42 $Output .= '</div></div>'; 43 return ($Output);43 return $Output; 44 44 } 45 45 … … 48 48 $this->RSSChannels[$Channel['Channel']] = $Channel; 49 49 50 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];50 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; 51 51 else { 52 52 array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']); … … 57 57 { 58 58 $Output = ''; 59 foreach ($this->RSSChannels as $Channel)59 foreach ($this->RSSChannels as $Channel) 60 60 { 61 if ($this->System->User->Licence($Channel['Permission']))61 if ($this->System->User->Licence($Channel['Permission'])) 62 62 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 63 63 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; 64 64 } 65 return ($Output);65 return $Output; 66 66 } 67 67 } … … 72 72 { 73 73 $this->Title = T('News'); 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 if ($Action == 'add2') $Output = $this->SaveNew();78 else if ($Action == 'add') $Output = $this->ShowAddForm();79 else if ($Action == 'item') $Output = $this->ShowItem();77 if ($Action == 'add2') $Output = $this->SaveNew(); 78 else if ($Action == 'add') $Output = $this->ShowAddForm(); 79 else if ($Action == 'item') $Output = $this->ShowItem(); 80 80 else $Output = $this->ShowList(); 81 return ($Output);81 return $Output; 82 82 } 83 83 … … 89 89 90 90 $Output = '<h3>'.T('News').'</h3>'; 91 if ($this->System->User->Licence(LICENCE_ADMIN))91 if ($this->System->User->Licence(LICENCE_ADMIN)) 92 92 $Output .= ' <a href="?a=add">'.T('Add').'</a>'; 93 93 $Output .= $PageList['Output']; … … 95 95 $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, `News`.`Id`, '. 96 96 '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` ORDER BY `News`.`Time` DESC '.$PageList['SQLLimit']); 97 while ($Line = $DbResult->fetch_assoc())97 while ($Line = $DbResult->fetch_assoc()) 98 98 { 99 99 $Output .= '<h4><a href="?a=item&i='.$Line['Id'].'">'.$Line['Title'].'</a> ('.HumanDate($Line['Time']).')</h4><div>'.$Line['Text'].' ('.$Line['User'].')</div>'; 100 100 } 101 101 $Output .= '</div>'.$PageList['Output']; 102 return ($Output);102 return $Output; 103 103 } 104 104 105 105 function ShowItem() 106 106 { 107 if (array_key_exists('i', $_GET))107 if (array_key_exists('i', $_GET)) 108 108 { 109 109 $Output = '<h3>'.T('News').'</h3>'; 110 110 $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, `News`.`Id`, '. 111 111 '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id` = '.($_GET['i'] * 1)); 112 if ($DbResult->num_rows == 1)112 if ($DbResult->num_rows == 1) 113 113 { 114 114 $Line = $DbResult->fetch_assoc(); … … 117 117 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 118 118 $Output .= '<br/><a href="'.$this->System->Link('/news/').'">'.T('All news').'</a>'; 119 return ($Output);119 return $Output; 120 120 } 121 121 122 122 function ShowAddForm() 123 123 { 124 if ($this->System->User->Licence(LICENCE_ADMIN))124 if ($this->System->User->Licence(LICENCE_ADMIN)) 125 125 { 126 126 $Output = '<form action="?" method="POST">'. … … 134 134 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 135 135 $Output .= $this->ShowList(); 136 return ($Output);136 return $Output; 137 137 } 138 138 139 139 function SaveNew() 140 140 { 141 if ($this->System->User->Licence(LICENCE_ADMIN))141 if ($this->System->User->Licence(LICENCE_ADMIN)) 142 142 { 143 if (array_key_exists('text', $_POST) and array_key_exists('title', $_POST))143 if (array_key_exists('text', $_POST) and array_key_exists('title', $_POST)) 144 144 { 145 145 $querty = 'INSERT INTO `News` (`Title`, `Time` ,`User` ,`Text`) VALUES ( "'.$_POST['title'].'", NOW( ) , '. … … 151 151 } else $Output = ShowMessage(T('Data not specified'), MESSAGE_CRITICAL); 152 152 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 153 return ($Output);153 return $Output; 154 154 } 155 155 … … 160 160 '`News`.`Title`, `News`.`Time`, `User`.`Name`, `News`.`Text`, `News`.`Id` '. 161 161 'FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10'); 162 while ($DbRow = $DbResult->fetch_assoc())162 while ($DbRow = $DbResult->fetch_assoc()) 163 163 { 164 164 $Items[] = array … … 178 178 'Items' => $Items, 179 179 )); 180 return ($Output);180 return $Output; 181 181 } 182 182 } -
trunk/Modules/News/RSS.php
r876 r880 15 15 " <pubDate>".date('r')."</pubDate>\n". 16 16 " <ttl>20</ttl>\n"; 17 foreach ($Data['Items'] as $Item)17 foreach ($Data['Items'] as $Item) 18 18 { 19 19 $Result .= " <item>\n". … … 26 26 $Result .= " </channel>\n". 27 27 "</rss>"; 28 return ($Result);28 return $Result; 29 29 } 30 30 … … 35 35 $this->RawPage = true; 36 36 37 if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];37 if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel']; 38 38 else $ChannelName = ''; 39 if (array_key_exists('token', $_GET)) $Token = $_GET['token'];39 if (array_key_exists('token', $_GET)) $Token = $_GET['token']; 40 40 else $Token = ''; 41 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['News']->RSSChannels))41 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['News']->RSSChannels)) 42 42 { 43 43 $Channel = $this->System->ModuleManager->Modules['News']->RSSChannels[$ChannelName]; 44 if ($this->System->User->Licence($Channel['Permission']) or44 if ($this->System->User->Licence($Channel['Permission']) or 45 45 $this->System->User->CheckToken($Channel['Permission'], $Token)) 46 46 { 47 if (is_string($Channel['Callback'][0]))47 if (is_string($Channel['Callback'][0])) 48 48 { 49 49 $Class = new $Channel['Callback'][0]($this->System); … … 53 53 } else $Output = T('Access denied'); 54 54 } else $Output = 'Nezadán žádný kanál'; 55 return ($Output);55 return $Output; 56 56 } 57 57 }
Note:
See TracChangeset
for help on using the changeset viewer.