Changeset 953 for trunk/Modules/News/NewsPage.php
- Timestamp:
- Aug 11, 2023, 11:17:28 AM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/News/NewsPage.php
r929 r953 11 11 } 12 12 13 function GetIntranetCondition(): string 14 { 15 if (IsInternetAddr()) return ' AND (`Intranet`=0)'; 16 else return ''; 17 } 18 13 19 function ShowView(): string 14 20 { … … 20 26 if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1; 21 27 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 22 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id);28 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`News`.`Id`='.$Id.')'.$this->GetIntranetCondition()); 23 29 if ($DbResult->num_rows > 0) 24 30 { … … 80 86 'Obsah:<br /><textarea name="content" rows="20" cols="40"></textarea><br />'. 81 87 'Odkaz:<br /><input type="text" size="54" name="link"><br />'. 88 'Viditelné jen z vnitřní sítě: <input type="checkbox" name="intranet"/><br />'. 82 89 'Přílohy (Max. velikost souboru 1 MB):<br /><input type="hidden" name="MAX_FILE_SIZE" value="1000000">'. 83 90 '<input name="enclosure1" size="38" type="file"><br />'. … … 116 123 } 117 124 $Enclosures = substr($Enclosures, 1); 125 if (array_key_exists('intranet', $_POST)) $Intranet = 1; 126 else $Intranet = 0; 118 127 119 128 $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'], 120 129 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr, 121 130 'Enclosure' => $Enclosures, 'Author' => $User->User['Name'], 122 'User' => $User->User['Id'], 'Link' => $_POST['link'] ));131 'User' => $User->User['Id'], 'Link' => $_POST['link'], 'Intranet' => $Intranet)); 123 132 $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />'; 124 133 $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>'; … … 154 163 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 155 164 { 156 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);165 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE (`Id`='.$_GET['id'].')'.$this->GetIntranetCondition()); 157 166 $Row = $DbResult->fetch_assoc(); 158 167 if (($User->User['Id'] == $Row['User'])) 159 168 { 169 if ($Row['Intranet'] == 1) $IntranetChecked = ' checked="1"'; 170 else $IntranetChecked = 0; 160 171 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); 161 172 $Output .= '<strong>Editace aktuality v kategorii '.$Category['Caption'].':</strong><br />'; … … 165 176 'Obsah:<br /><textarea name="content" rows="20" cols="40" style="width: 50%">'.$Row['Content'].'</textarea><br />'. 166 177 'Odkaz:<br /><input type="text" size="54" name="link" value="'.$Row['Link'].'"><br />'. 178 'Viditelné jen z vnitřní sítě: <input type="checkbox" name="intranet" '.$IntranetChecked.'/><br />'. 167 179 '<input type="hidden" name="category" value="'.$Category['Id'].'"><br />'. 168 180 '<input type="submit" value="Uložit">'. … … 182 194 { 183 195 $_POST['id'] = $_POST['id'] * 1; 184 $DbResult = $this->Database->select('News', '*', ' `Id`='.$_POST['id']);196 $DbResult = $this->Database->select('News', '*', '(`Id`='.$_POST['id'].')'.$this->GetIntranetCondition()); 185 197 if ($DbResult->num_rows > 0) 186 198 { … … 188 200 if ($User->User['Id'] == $Row['User']) 189 201 { 202 if (array_key_exists('intranet', $_POST)) $Intranet = 1; 203 else $Intranet = 0; 204 190 205 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], 191 'Content' => $_POST['content'], 'Link' => $_POST['link'] ));206 'Content' => $_POST['content'], 'Link' => $_POST['link'], 'Intranet' => $Intranet)); 192 207 $Output .= 'Aktualita uložena!<br />'; 193 208 $Output .= '<a href="?category='.$Category['Id'].'">Zpět na seznam aktualit</a>'; … … 205 220 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 206 221 { 207 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);222 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE (`Id`='.$_GET['id'].')'.$this->GetIntranetCondition()); 208 223 $Row = $DbResult->fetch_assoc(); 209 224 if ($User->User['Id'] == $Row['User']) … … 234 249 { 235 250 $PerPage = 20; 236 $DbResult = $this->Database->select('News', 'COUNT(*)', ' `Category`='.$Category['Id']);251 $DbResult = $this->Database->select('News', 'COUNT(*)', '(`Category`='.$Category['Id'].')'.$this->GetIntranetCondition()); 237 252 $RowTotal = $DbResult->fetch_array(); 238 253 $PageMax = $RowTotal[0]; … … 243 258 244 259 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 245 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage); 260 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`Category`='.$Category['Id'].')'.$this->GetIntranetCondition(). 261 ' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage); 246 262 while ($Row = $DbResult->fetch_assoc()) 247 263 {
Note:
See TracChangeset
for help on using the changeset viewer.