/**
  * 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();
     foreach ($notificationOptions as $level => $levelOptions) {
         if ($levelOptions) {
             foreach ($levelOptions as $type => $typeOptions) {
                 if ($typeOptions) {
                     $notificationMgr->isVisibleToAllUsers($type, $typeOptions['assocType'], $typeOptions['assocId']) ? $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;
 }