Example #1
0
 public function getHTML($userId = '')
 {
     static $html = false;
     if (!$html) {
         $my = CFactory::getUser();
         // @rule: Do not display toolbar for non logged in users.
         if (empty($my->id)) {
             CFactory::load('libraries', 'miniheader');
             $task = JRequest::getVar('task', '', 'GET');
             $groupId = JRequest::getVar('groupid', '', 'GET');
             if (!empty($groupId) && $task != 'viewgroup') {
                 CFactory::load('libraries', 'miniheader');
                 return CMiniHeader::showGroupMiniHeader($groupId);
             }
             return CMiniHeader::showMiniHeader($userId);
         }
         $format = JRequest::getVar('format', 'html', 'get');
         // @rule: For json formatted output, we do not want to display the output as well.
         if ($format == 'json') {
             return;
         }
         // Compatibility with other pages, we need to include necessary javascripts and css libraries.
         $this->attachHeaders();
         CFactory::load('libraries', 'window');
         CWindow::load();
         CFactory::load('libraries', 'miniheader');
         $config = CFactory::getConfig();
         $logoutLink = base64_encode(CRoute::_('index.php?option=com_community&view=' . $config->get('redirect_logout'), false));
         $tmpl = new CTemplate();
         $miniheader = CMiniHeader::showMiniHeader($userId);
         $groupMiniHeader = '';
         $task = JRequest::getVar('task', '');
         $groupId = JRequest::getVar('groupid', '');
         // Show miniheader
         if ($task != 'viewgroup') {
             $groupMiniHeader = CMiniHeader::showGroupMiniHeader($groupId);
         }
         $menus = $this->getItems();
         $this->addLegacyToolbars($menus);
         $model = CFactory::getModel('Toolbar');
         $newMessageCount = $this->getTotalNotifications('inbox');
         $newEventInviteCount = $this->getTotalNotifications('events');
         $newFriendInviteCount = $this->getTotalNotifications('friends');
         $newGroupInviteCount = $this->getTotalNotifications('groups');
         //add Event notification count with group notification count
         //$newEventInviteCount += $newGroupInviteCount;
         $totalNotifications = $newMessageCount + $newEventInviteCount + $newFriendInviteCount;
         $html = $tmpl->set('miniheader', $miniheader)->set('groupMiniHeader', $groupMiniHeader)->set('menus', $menus)->set('showToolbar', $config->get('show_toolbar'))->set('newMessageCount', $newMessageCount)->set('newFriendInviteCount', $newFriendInviteCount)->set('newEventInviteCount', $newEventInviteCount + $newGroupInviteCount)->set('logoutLink', $logoutLink)->set('active', $model->getActiveId(CToolbarLibrary::getActiveLink()))->set('notiAlert', $newMessageCount + $newEventInviteCount + $newFriendInviteCount)->fetch('toolbar.index');
     }
     return $html;
 }
Example #2
0
 public function getHTML($userId = '')
 {
     static $html = false;
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     if (!$html) {
         $my = CFactory::getUser();
         $view = $jinput->get('view', '');
         $task = $jinput->get('task', '');
         $groupId = $jinput->get('groupid', '', 'INT');
         // @rule: Do not display toolbar for non logged in users.
         if (empty($my->id)) {
             if (!empty($groupId) && ($task != 'viewgroup' && $view != 'events')) {
                 return CMiniHeader::showGroupMiniHeader($groupId);
             }
             return CMiniHeader::showMiniHeader($userId);
         }
         $format = $jinput->get->get('format', 'html', 'STRING');
         // @rule: For json formatted output, we do not want to display the output as well.
         if ($format == 'json') {
             return;
         }
         // Compatibility with other pages, we need to include necessary javascripts and css libraries.
         $this->attachHeaders();
         CWindow::load();
         $config = CFactory::getConfig();
         $logoutLink = base64_encode(CRoute::_('index.php?option=com_community&view=' . $config->get('redirect_logout'), false));
         $tmpl = new CTemplate();
         $miniheader = CMiniHeader::showMiniHeader($userId);
         $groupMiniHeader = '';
         $targetUserId = $jinput->get('userid', '', 'INT');
         // Show miniheader
         if ($task != 'viewgroup' && $view != 'events') {
             $groupMiniHeader = CMiniHeader::showGroupMiniHeader($groupId);
         } elseif ($task == 'myevents' && $targetUserId && $targetUserId != $my->id) {
             //show miniheader if this event list belongs to others
             $miniheader = CMiniHeader::showMiniHeader($targetUserId);
         }
         $menus = $this->getItems();
         $this->addLegacyToolbars($menus);
         $model = CFactory::getModel('Toolbar');
         $notifModel = CFactory::getModel('notification');
         $newMessageCount = $this->getTotalNotifications('inbox');
         $newEventInviteCount = $this->getTotalNotifications('events');
         $newFriendInviteCount = $this->getTotalNotifications('friends');
         $newGroupInviteCount = $this->getTotalNotifications('groups');
         $myParams = $my->getParams();
         $newNotificationCount = $notifModel->getNotificationCount($my->id, '0', $myParams->get('lastnotificationlist', ''));
         $menuParams = '';
         if (isset($menus[$model->getActiveId(CToolbarLibrary::getActiveLink())])) {
             $menuParams = new CParameter($menus[$model->getActiveId(CToolbarLibrary::getActiveLink())]->item->params);
         }
         //add Event notification count with group notification count
         //$newEventInviteCount += $newGroupInviteCount;
         $totalNotifications = $newMessageCount + $newEventInviteCount + $newFriendInviteCount;
         $html = $tmpl->set('miniheader', $miniheader)->set('groupMiniHeader', $groupMiniHeader)->set('menus', $menus)->set('showToolbar', $config->get('show_toolbar'))->set('newMessageCount', $newMessageCount)->set('newFriendInviteCount', $newFriendInviteCount)->set('newEventInviteCount', $newEventInviteCount + $newGroupInviteCount + $newNotificationCount)->set('logoutLink', $logoutLink)->set('active', $model->getActiveId(CToolbarLibrary::getActiveLink()))->set('notiAlert', $newMessageCount + $newEventInviteCount + $newFriendInviteCount + $newNotificationCount)->set('menuParams', $menuParams)->set('isMessageEnable', $config->get('enablepm'))->fetch('toolbar/base');
     }
     return $html;
 }