/** * Get the notifications using options. * @param $notificationOptions Array * @param $contextId int * @param $userId int * @return Array */ function &_getNotificationsByOptions($notificationOptions, $contextId, $userId = null) { $notificationDao =& DAORegistry::getDAO('NotificationDAO'); $notificationsArray = array(); $notificationMgr = new NotificationManager(); $allUsersNotificationTypes = $notificationMgr->getAllUsersNotificationTypes(); foreach ($notificationOptions as $level => $levelOptions) { if ($levelOptions) { foreach ($levelOptions as $type => $typeOptions) { if ($typeOptions) { in_array($type, $allUsersNotificationTypes) ? $workingUserId = null : ($workingUserId = $userId); $notificationsResultFactory =& $notificationDao->getByAssoc($typeOptions['assocType'], $typeOptions['assocId'], $workingUserId, $type, $contextId); $notificationsArray =& $this->_addNotificationsToArray($notificationsResultFactory, $notificationsArray); } else { if ($userId) { $notificationsResultFactory =& $notificationDao->getByUserId($userId, $level, $type, $contextId); $notificationsArray =& $this->_addNotificationsToArray($notificationsResultFactory, $notificationsArray); } } } } else { if ($userId) { $notificationsResultFactory =& $notificationDao->getByUserId($userId, $level, null, $contextId); $notificationsArray =& $this->_addNotificationsToArray($notificationsResultFactory, $notificationsArray); } } $notificationsResultFactory = null; } return $notificationsArray; }