public function __construct($config = array()) { // Initialize page. $page = new stdClass(); // Initialize page values. $page->icon = ''; $page->iconUrl = ''; $page->heading = ''; $page->description = ''; $this->page = $page; $this->my = FD::user(); // Initialize the breadcrumbs $this->breadcrumbs = array(); $view = $this->getName(); // Disallow access if user does not have sufficient permissions $rule = 'easysocial.access.' . $view; // For fields, it uses a different view if ($view == 'fields') { $rule = 'easysocial.access.profiles'; } if (!$this->authorise($rule)) { $this->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); } parent::__construct($config); }
public function __construct($config = array()) { // We want to allow child classes to easily access theme configurations on the view $this->themeConfig = FD::themes()->getConfig(); $this->my = FD::user(); parent::__construct($config); // Check if there is a method isFeatureEnabled exists. If it does, we should do a check all the time. if (method_exists($this, 'isFeatureEnabled')) { $this->isFeatureEnabled(); } }
public function __construct($config = array()) { // We want to allow child classes to easily access theme configurations on the view $this->themeConfig = FD::themes()->getConfig(); parent::__construct($config); // Check if there is a method isFeatureEnabled exists. If it does, we should do a check all the time. if (method_exists($this, 'isFeatureEnabled')) { $this->isFeatureEnabled(); } // // When the user doesn't have community access, ensure that they can only view selected views. if (!$this->my->hasCommunityAccess()) { // Get the current view $view = $this->getName(); $layout = $this->input->get('layout', '', 'cmd'); // If this is an ajax call, we need to allow some ajax calls to go through $allowedAjaxNamespaces = array('site/views/profile/showFormError'); if ($this->doc->getType() == 'ajax') { $namespace = $this->input->get('namespace', '', 'default'); // If this is an ajax call, and the namespace is valid, skip checking below if (in_array($namespace, $allowedAjaxNamespaces)) { return; } } // Define allowed views and layout $allowedViews = array('profile'); $allowedLayouts = array('edit'); // views that we should redirect the user to profile edit page. $redirectView = array('dashboard', 'profile'); // User should be allowed to logout from the site $isLogout = $this->input->get('controller', '', 'cmd') == 'account' && $this->input->get('task', '', 'cmd') == 'logout' || $this->input->get('view', '', 'cmd') == 'login' && $this->input->get('layout', '', 'cmd') == 'logout'; // user should be allowed to save their profile details on the site. $isProfileSaving = $this->input->get('controller', '', 'cmd') == 'profile' && $this->input->get('task', '', 'cmd') == 'save'; if (in_array($view, $redirectView) && !$layout && !$isLogout && !$isProfileSaving) { // we need to redirect the user to profile edit page. $this->redirect(FRoute::profile(array('layout' => 'edit'), false)); return; } // Ensure that the restricted user is not able to view other views if (!in_array($view, $allowedViews) && !$isLogout && !$isProfileSaving) { return JError::raiseError(500, JText::_('COM_EASYSOCIAL_NOT_ALLOWED_TO_VIEW_SECTION')); } // Ensure that the user is only viewing the allowed layouts if (!in_array($layout, $allowedLayouts) && !$isLogout && !$isProfileSaving) { return JError::raiseError(500, JText::_('COM_EASYSOCIAL_NOT_ALLOWED_TO_VIEW_SECTION')); } } }