public function getNotifications($id = null, $userId = null, $userRole = null) {
		$fields = [
			$this->alias . '.id',
			$this->alias . '.user_id',
			$this->alias . '.user_role',
			$this->alias . '.tag',
			$this->alias . '.title',
			$this->alias . '.body',
			$this->alias . '.data',
		];
		$conditions = [
			'AND' => [
				$this->alias . '.expires >=' => date('Y-m-d H:i:s'),
				'OR' => [
					[
						'AND' => [
							$this->alias . '.user_id' => '',
							$this->alias . '.user_role' => '',
						]
					]
				]
			]
		];
		if (!empty($id)) {
			$conditions['AND'][][$this->alias . '.id >'] = (int)$id;
		}
		if (!empty($userId)) {
			$conditions['AND']['OR'][][$this->alias . '.user_id'] = (int)$userId;
		}
		if (!empty($userRole)) {
			$conditions['AND']['OR'][]['AND'] = [
				$this->alias . '.user_role & ' . (int)$userRole . ' > 0',
				$this->alias . '.user_id' => '',
			];
		}

		$order = [$this->alias . '.id' => 'asc'];

		return $this->find('all', compact('fields', 'conditions', 'order'));
	}
public function getNotifications($id = null, $userId = null, $userRole = null) {
		$fields = [
			$this->alias . '.id',
			$this->alias . '.user_id',
			$this->alias . '.user_role',
			$this->alias . '.tag',
			$this->alias . '.title',
			$this->alias . '.body',
			$this->alias . '.data',
		];
		$conditions = [
			'AND' => [
				$this->alias . '.expires >=' => date('Y-m-d H:i:s'),
				'OR' => [
					[
						'AND' => [
							$this->alias . '.user_id' => '',
							$this->alias . '.user_role' => '',
						]
					]
				]
			]
		];
		if (!empty($id)) {
			$conditions['AND'][][$this->alias . '.id >'] = (int)$id;
		}
		if (!empty($userId)) {
			$conditions['AND']['OR'][][$this->alias . '.user_id'] = (int)$userId;
		}
		if (!empty($userRole)) {
			$conditions['AND']['OR'][]['AND'] = [
				$this->alias . '.user_role & ' . (int)$userRole . ' > 0',
				$this->alias . '.user_id' => '',
			];
		}

		$order = [$this->alias . '.id' => 'asc'];

		return $this->find('all', compact('fields', 'conditions', 'order'));
	}
public function getNotifications ( $ id = null , $ userId = null , $ userRole = null ) { $ fields = [ $ this -> alias . '.id' , $ this -> alias . '.user_id' , $ this -> alias . '.user_role' , $ this -> alias . '.tag' , $ this -> alias . '.title' , $ this -> alias . '.body' , $ this -> alias . '.data' , ] ; $ conditions = [ 'AND' => [ $ this -> alias . '.expires >=' => date ( 'Y-m-d H:i:s' ) , 'OR' => [ [ 'AND' => [ $ this -> alias . '.user_id' => '' , $ this -> alias . '.user_role' => '' , ] ] ] ] ] ; if ( ! empty ( $ id ) ) { $ conditions [ 'AND' ] [ ] [ $ this -> alias . '.id >' ] = ( int ) $ id ; } if ( ! empty ( $ userId ) ) { $ conditions [ 'AND' ] [ 'OR' ] [ ] [ $ this -> alias . '.user_id' ] = ( int ) $ userId ; } if ( ! empty ( $ userRole ) ) { $ conditions [ 'AND' ] [ 'OR' ] [ ] [ 'AND' ] = [ $ this -> alias . '.user_role & ' . ( int ) $ userRole . ' > 0' , $ this -> alias . '.user_id' => '' , ] ; } $ order = [ $ this -> alias . '.id' => 'asc' ] ; return $ this -> find ( 'all' , compact ( 'fields' , 'conditions' , 'order' ) ) ; }
Return array of notifications

@param int $id The ID of last processed notify.
@param int $userId The ID of user to personal notify.
@param int $userRole Bit mask of user roles to
notify users with a certain role.
@return bool Success.
Return array of notifications