mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Fix events manager eroneous notification availability detection
This commit is contained in:
@@ -57,7 +57,7 @@ class eventsmanager_broker
|
||||
foreach ($this->pool_classes[$classname]->get_events() as $event)
|
||||
$this->bind($event, $classname);
|
||||
|
||||
if ($type === 'notify' && $this->pool_classes[$classname]->is_available())
|
||||
if ($type === 'notify' && $this->pool_classes[$classname])
|
||||
$this->notifications[] = $classname;
|
||||
}
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class eventsmanager_broker
|
||||
WHERE usr_id = :usr_id AND id = :notif_id';
|
||||
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':usr_id' => $usr_id, ':notif_id' => $notifications));
|
||||
$stmt->execute(array(':usr_id' => $usr_id, ':notif_id' => $notification));
|
||||
$stmt->closeCursor();
|
||||
|
||||
return;
|
||||
@@ -298,6 +298,9 @@ class eventsmanager_broker
|
||||
$personnal_notifications = array();
|
||||
|
||||
foreach ($this->notifications as $notification) {
|
||||
if (!$this->pool_classes[$notification]->is_available($usr_id)) {
|
||||
continue;
|
||||
}
|
||||
$group = $this->pool_classes[$notification]->get_group();
|
||||
$group = $group === null ? _('Notifications globales') : $group;
|
||||
|
||||
|
@@ -214,21 +214,22 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
$bool = false;
|
||||
|
||||
if ( ! $this->app['authentication']->isAuthenticated() || ! $this->app['registration.enabled']) {
|
||||
if (!$this->app['registration.enabled']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->app['authentication']->getUser()->ACL()->has_right('manageusers') === true) {
|
||||
$bool = true;
|
||||
try {
|
||||
$user = \User_Adapter::getInstance($usr_id, $this->app);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $bool;
|
||||
return $user->ACL()->has_right('manageusers');
|
||||
}
|
||||
}
|
||||
|
@@ -159,10 +159,11 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -157,10 +157,11 @@ class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -176,10 +176,11 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -185,20 +185,18 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
$bool = false;
|
||||
if ( !$this->app['authentication']->isAuthenticated()) {
|
||||
try {
|
||||
$user = \User_Adapter::getInstance($usr_id, $this->app);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->app['authentication']->getUser()->ACL()->has_right('order_master')) {
|
||||
$bool = true;
|
||||
}
|
||||
|
||||
return $bool;
|
||||
return $user->ACL()->has_right('order_master');
|
||||
}
|
||||
}
|
||||
|
@@ -196,10 +196,11 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -141,10 +141,11 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -162,10 +162,11 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -193,21 +193,22 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
$bool = false;
|
||||
|
||||
if ( !$this->app['authentication']->isAuthenticated() || ! $this->app['registration.enabled']) {
|
||||
if (!$this->app['registration.enabled']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->app['authentication']->getUser()->ACL()->has_right('manageusers')) {
|
||||
$bool = true;
|
||||
try {
|
||||
$user = \User_Adapter::getInstance($usr_id, $this->app);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $bool;
|
||||
return $user->ACL()->has_right('manageusers');
|
||||
}
|
||||
}
|
||||
|
@@ -180,15 +180,18 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
if (null !== $this->app['authentication']->getUser()) {
|
||||
return $this->app['authentication']->getUser()->ACL()->has_right('addrecord');
|
||||
try {
|
||||
$user = \User_Adapter::getInstance($usr_id, $this->app);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $user->ACL()->has_right('addrecord');
|
||||
}
|
||||
}
|
||||
|
@@ -190,10 +190,11 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -178,21 +178,18 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
$bool = false;
|
||||
|
||||
if ( ! $this->app['authentication']->isAuthenticated()) {
|
||||
try {
|
||||
$user = \User_Adapter::getInstance($usr_id, $this->app);
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->app['authentication']->getUser()->ACL()->has_right('push')) {
|
||||
$bool = true;
|
||||
}
|
||||
|
||||
return $bool;
|
||||
return $user->ACL()->has_right('push');
|
||||
}
|
||||
}
|
||||
|
@@ -187,10 +187,11 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usr_id The id of the user to check
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract
|
||||
|
||||
abstract public function datas($datas, $unread);
|
||||
|
||||
public function is_available()
|
||||
public function is_available($usr_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user