Example #1
0
 static function groupUserByLanguage($userList = array(), $userToExlude = 0, $notificationType = '')
 {
     $groupedUserList = array();
     $onlineUser = self::getCurrentOnlineUser();
     foreach ($userList as $index => $userId) {
         if (empty($userId)) {
             continue;
         }
         // exclude explicitly named user ids
         if (intval($userId) == intval($userToExlude)) {
             continue;
         }
         // If user is currently online, exclude him/her from receiving email notification
         if (in_array($userId, $onlineUser)) {
             continue;
         }
         $user = JXFactory::getUser($userId);
         // Filter user off if he does not have notification preference checked
         if (!empty($notificationType)) {
             $notification = new Notifications($user);
             if (!$notification->getEmailNotificationSetting($notificationType)) {
                 continue;
             }
         }
         $lang = $user->getParam('language', 'default');
         $groupedUserList[$lang][] = $user->email;
     }
     /*foreach($groupedUserList as $lang => $arrUsers)
     		{
     			$groupedUserList[$lang] = implode(',', $arrUsers);
     		}*/
     return $groupedUserList;
 }
Example #2
0
 /**
  *
  */
 public function notification()
 {
     if ($_POST) {
         $notification = new Notifications();
         $notification->setNotification($_POST);
         $user = JXFactory::getUser();
         $notificationSetting = $notification->getNotification();
         foreach ($notificationSetting as $group => $typeInfo) {
             foreach ($typeInfo as $type => $typeSetting) {
                 $globalNotification = $notification->getGlobalNotificationIndex($type);
                 $emailNotification = $notification->getEmailNotificationIndex($type);
                 $user->setParam($globalNotification, $notification->getGlobalNotificationSetting($type));
                 $user->setParam($emailNotification, $notification->getEmailNotificationSetting($type));
             }
         }
         $user->save();
         $mainframe = JFactory::getApplication();
         $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit&task=notification', false), JText::_('COM_PROFILE_ACTION_SAVE_NOTIFICATION_SUCCESS'));
         exit;
     }
     JRequest::setVar('view', 'notification');
     parent::display();
 }