Project

General

Profile

1
<?php
2

    
3
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
4

    
5
jimport('joomla.error.log');
6

    
7
class ModMyAlertsHelper
8
{
9
	public function getAlerts() {
10
		$user =& JFactory :: getUser();
11
		if ($user -> guest)
12
			return array();
13
		$db =& JFactory :: getDBO();
14
		$log = JLog :: getInstance();
15
		$db -> setQuery('SELECT `time`, `title`, `message`, `link` FROM `#__openaire_alerts` WHERE `username` = ' . $db -> quote($user -> username) . ' ORDER BY `time` DESC;');
16
		$alerts = $db -> loadAssocList();
17
		if ($alerts === NULL)
18
			$log -> addEntry(array('level' => 'error', 'comment' => ('Error retrieving alerts for user ' . $user -> username . ': ' . $db -> getErrorMsg() . ' (' . $db -> getErrorNum() . ')')));
19
		else
20
			$log -> addEntry(array('level' => 'info', 'comment' => ('Retrieved ' . count($alerts) . ' alerts for user ' . $user -> username)));
21
		return $alerts;
22
	}
23
}
24

    
25
?>
26

    
(1-1/4)