/** * Before _actionGet controller event. * * @param KEvent $event Event object * * @return string */ public function onBeforeControllerGet(KEvent $event) { $this->setActor(get_viewer()); parent::onBeforeControllerGet($event); $data = $event->data; $viewer = get_viewer(); $actor = $viewer; $layout = pick($this->getController()->layout, 'default'); $name = $this->getController()->getIdentifier()->name; if ($name == 'connection') { $name = $this->getController()->service; } $this->setTitle(JText::sprintf('COM-INVITES-ACTOR-HEADER-' . strtoupper($name) . 'S', $actor->name)); //create navigations $this->addNavigation('email', JText::_('COM-INVITES-LINK-EMAIL'), 'option=com_invites&view=email', $name == 'email'); if (ComConnectHelperApi::enabled('facebook')) { $this->addNavigation('facebook', JText::_('COM-INVITES-LINK-FACEBOOK'), 'option=com_invites&view=connections&service=facebook', $name == 'facebook'); } }
/** * Context. * * @param KCommandContext $context */ protected function _actionBrowse(KCommandContext $context) { $serviceType = pick($this->service, 'facebook'); if (!ComConnectHelperApi::enabled($serviceType)) { throw new LibBaseControllerExceptionBadRequest('Service is not enabled'); return; } $this->getService('repos://site/connect.session'); $service = $this->viewer->sessions->{$serviceType}; if (!empty($service)) { try { $this->_state->setList($service->getFriends()); } catch (Exception $e) { $session = $this->viewer->sessions->find(array('api' => 'facebook')); if (isset($session)) { $session->delete()->save(); } $service = null; } } else { $service = null; } $this->service = $service; }