1 |
13462
|
thanos.pap
|
<?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 |
14031
|
thanos.pap
|
$db -> setQuery('SELECT `time`, `title`, `message`, `link` FROM `#__openaire_alerts` WHERE `username` = ' . $db -> quote($user -> username) . ' ORDER BY `time` DESC;');
|
16 |
13462
|
thanos.pap
|
$alerts = $db -> loadAssocList();
|
17 |
|
|
if ($alerts === NULL)
|
18 |
14031
|
thanos.pap
|
$log -> addEntry(array('level' => 'error', 'comment' => ('Error retrieving alerts for user ' . $user -> username . ': ' . $db -> getErrorMsg() . ' (' . $db -> getErrorNum() . ')')));
|
19 |
13462
|
thanos.pap
|
else
|
20 |
14031
|
thanos.pap
|
$log -> addEntry(array('level' => 'info', 'comment' => ('Retrieved ' . count($alerts) . ' alerts for user ' . $user -> username)));
|
21 |
13462
|
thanos.pap
|
return $alerts;
|
22 |
|
|
}
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
?>
|