/**
  * @static
  * @param $type
  * @param array $value
  * @return array
  * @throws Exception
  */
 public static function findByListenerTypeAndValue($type, $value = null)
 {
     if ($type !== NotificationListener::LISTENER_TYPE_GLOBAL && empty($value)) {
         throw new Exception('Can not find non-global listener (' . $type . ') without a list or task id (' . $value . ')');
     }
     $return = array();
     $db = DBConnection::instance();
     if ($type === NotificationListener::LISTENER_TYPE_GLOBAL) {
         $result = $db->dq("SELECT * FROM {$db->prefix}notification_listeners WHERE type = 'global'");
     } else {
         $result = $db->dq("SELECT * FROM {$db->prefix}notification_listeners WHERE type = ? AND value = ?", array($type, $value));
     }
     while ($row = $result->fetch_assoc()) {
         $item = new NotificationListener();
         $item->setType($row['type']);
         $item->setUserid($row['user_id']);
         if ($type !== NotificationListener::LISTENER_TYPE_GLOBAL) {
             $item->setValue($row['value']);
         }
         $return[] = $item;
     }
     return $return;
 }