Changeset 867 for trunk/Modules/Notify/Notify.php
- Timestamp:
- Jan 13, 2020, 12:26:00 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Notify/Notify.php
r830 r867 15 15 $this->License = 'GNU/GPL'; 16 16 $this->Description = 'Send notification messages to selected users'; 17 $this->Dependencies = array('User' );17 $this->Dependencies = array('User', 'RSS'); 18 18 $this->Checks = array(); 19 19 } … … 39 39 )); 40 40 $this->System->RegisterCommandLine('notify', array($this, 'RunCheck')); 41 $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Notify log', 42 'Channel' => 'notifylog', 'Callback' => array('ModuleNotify', 'ShowLogRSS'), 43 'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS'))); 41 44 } 42 45 … … 59 62 $Output = ''; 60 63 $Content = ''; 64 $Title = ''; 61 65 62 66 // Get output from checks 63 67 $DbResult2 = $this->Database->query('SELECT `Id`, `Name`, `SysName` FROM `NotifyCategory`'); 64 while ($Category = $DbResult2->fetch_assoc())68 while ($Category = $DbResult2->fetch_assoc()) 65 69 { 66 if (array_key_exists($Category['SysName'], $this->Checks))70 if (array_key_exists($Category['SysName'], $this->Checks)) 67 71 { 68 $List = call_user_func($this->Checks[$Category['SysName']]['Callback']); 69 if($List != '') { 72 $Status = call_user_func($this->Checks[$Category['SysName']]['Callback']); 73 if ($Status['Report'] != '') 74 { 70 75 $Output .= 'Kategorie: '.$Category['Name'].":\n"; 71 76 $Content .= 'Kategorie: '.$Category['Name']."<br>\n"; 72 $Content .= $ List;77 $Content .= $Status['Report']; 73 78 } 79 if (strlen($Title) > 0) $Title .= ', '; 80 $Title .= $Status['ShortTitle'].':'.$Status['Count']; 74 81 } 75 82 } 83 84 $Time = time(); 76 85 77 86 // Send content to users … … 81 90 while($User = $DbResult->fetch_assoc()) 82 91 { 83 $Time = time();84 92 $Output .= 'User '.$User['Name'].'<br/>'; 85 93 86 94 $this->Database->update('NotifyUser', '`Id`='.$User['Id'], array('LastTime' => TimeToMysqlDateTime($Time))); 87 95 88 if(($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content !='')) { 96 if(($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content != '')) 97 { 89 98 $Mail = new Mail(); 90 99 $Mail->Subject = 'Notification'; … … 102 111 103 112 return($Output); 113 } 114 115 if ($Content != '') 116 { 117 $this->Database->insert('NotifyLog', array( 118 'Time' => TimeToMysqlDateTime($Time), 119 'Title' => $Title, 120 'Content' => $Content) 121 ); 104 122 } 105 123 } … … 147 165 $this->Database->query('DROP TABLE `NotifyCategory`'); 148 166 } 167 168 function ShowLogRSS() 169 { 170 $this->ClearPage = true; 171 $this->FormatHTML = false; 172 Header('Content-Type: text/xml'); 173 $Count = 100; 174 175 $Output = ''; 176 $Items = array(); 177 $sql = 'SELECT Title,Content, UNIX_TIMESTAMP(`Time`) AS `Time` FROM `NotifyLog`'. 178 ' ORDER BY `Time` DESC LIMIT '.$Count; 179 $DbResult = $this->System->Database->query($sql); 180 while($Line = $DbResult->fetch_assoc()) 181 { 182 $Items[] = array 183 ( 184 'Title' => $Line['Title'], 185 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/Notify.php'), 186 'Description' => $Line['Content'], 187 'Time' => $Line['Time'], 188 ); 189 } 190 191 $RSS = new RSS(); 192 $RSS->Title = $this->System->Config['Web']['Title'].' - Záznamy upozornění'; 193 $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/'; 194 $RSS->Description = 'Záznam upozornění '.$this->System->Config['Web']['Description']; 195 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 196 $RSS->Items = $Items; 197 return($RSS->Generate()); 198 } 149 199 }
Note:
See TracChangeset
for help on using the changeset viewer.