/**
  * The singleton method
  *
  * @return EventManager
  */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new PermissionsOverrider_PermissionsOverriderManager();
     }
     return self::$instance;
 }
예제 #2
0
 function _getProjectTabs($toptab, &$project)
 {
     global $sys_default_domain;
     $pm = ProjectManager::instance();
     $tabs = array();
     $group_id = $project->getGroupId();
     $user = UserManager::instance()->getCurrentUser();
     if ($this->restrictedMemberIsNotProjectMember($user, $group_id)) {
         $allowed_services = array('summary');
         $this->getEventManager()->processEvent(Event::GET_SERVICES_ALLOWED_FOR_RESTRICTED, array('allowed_services' => &$allowed_services));
     }
     foreach ($project->getServicesData() as $short_name => $service_data) {
         if ((string) $short_name == "admin") {
             // for the admin service, we will check if the user is allowed to use the service
             // it means : 1) to be a super user, or
             //            2) to be project admin
             if (!user_is_super_user()) {
                 if (!user_isloggedin()) {
                     continue;
                     // we don't include the service in the $tabs
                 } else {
                     if (!user_ismember($group_id, 'A')) {
                         continue;
                         // we don't include the service in the $tabs
                     }
                 }
             }
         }
         $permissions_overrider = PermissionsOverrider_PermissionsOverriderManager::instance();
         if (!$this->isProjectSuperPublic($group_id) && $this->restrictedMemberIsNotProjectMember($user, $group_id) && !$permissions_overrider->doesOverriderAllowUserToAccessProject($user, $project)) {
             if (!in_array($short_name, $allowed_services)) {
                 continue;
             }
         }
         if (!$service_data['is_used']) {
             continue;
         }
         if (!$service_data['is_active']) {
             continue;
         }
         $hp = Codendi_HTMLPurifier::instance();
         // Get URL, and eval variables
         //$project->services[$short_name]->getUrl(); <- to use when service will be fully served by satellite
         if ($service_data['is_in_iframe']) {
             $link = '/service/?group_id=' . $group_id . '&amp;id=' . $service_data['service_id'];
         } else {
             $link = $hp->purify($service_data['link']);
         }
         if ($group_id == 100) {
             if (strstr($link, '$projectname')) {
                 // NOTE: if you change link variables here, change them also in src/common/project/RegisterProjectStep_Confirmation.class.php and src/www/project/admin/servicebar.php
                 // Don't check project name if not needed.
                 // When it is done here, the service bar will not appear updated on the current page
                 $link = str_replace('$projectname', $pm->getProject($group_id)->getUnixName(), $link);
             }
             $link = str_replace('$sys_default_domain', $GLOBALS['sys_default_domain'], $link);
             if ($GLOBALS['sys_force_ssl']) {
                 $sys_default_protocol = 'https';
             } else {
                 $sys_default_protocol = 'http';
             }
             $link = str_replace('$sys_default_protocol', $sys_default_protocol, $link);
             $link = str_replace('$group_id', $group_id, $link);
         }
         $enabled = is_numeric($toptab) && $toptab == $service_data['service_id'] || $short_name && $toptab == $short_name;
         if ($short_name == 'summary') {
             $label = '<span>';
             if (ForgeConfig::get('sys_display_project_privacy_in_service_bar')) {
                 // Add a default tab to explain project privacy
                 if ($project->isPublic()) {
                     $privacy = 'public';
                 } else {
                     $privacy = 'private';
                 }
                 $privacy_text = $GLOBALS['Language']->getText('project_privacy', 'tooltip_' . $this->getProjectPrivacy($project));
                 $label .= '<span class="project-title-container project_privacy_' . $privacy . '" data-content="' . $privacy_text . '" data-placement="bottom">[';
                 $label .= $GLOBALS['Language']->getText('project_privacy', $privacy);
                 $label .= ']</span>';
                 $label .= '&nbsp;';
             }
             $label .= $hp->purify(util_unconvert_htmlspecialchars($project->getPublicName()), CODENDI_PURIFIER_CONVERT_HTML) . '&nbsp;&raquo;</span>';
         } else {
             $label = '<span title="' . $hp->purify($service_data['description']) . '">';
             $label .= $hp->purify($service_data['label']) . '</span>';
         }
         $name = $hp->purify($service_data['label']);
         $icon = $this->getServiceIcon($short_name);
         if (isset($service_data['icon'])) {
             $icon = $service_data['icon'];
         }
         $tabs[] = array('link' => $link, 'icon' => $icon, 'name' => $name, 'label' => $label, 'enabled' => $enabled, 'description' => $hp->purify($service_data['description']), 'id' => $hp->purify('sidebar-' . $short_name));
     }
     return $tabs;
 }
예제 #3
0
 /**
  * @return PermissionsOverrider_PermissionsOverriderManager
  */
 protected function getPermissionsOverriderManager()
 {
     return PermissionsOverrider_PermissionsOverriderManager::instance();
 }
예제 #4
0
 public static function areAnonymousAllowed()
 {
     return self::get(ForgeAccess::CONFIG) === ForgeAccess::ANONYMOUS || PermissionsOverrider_PermissionsOverriderManager::instance()->doesOverriderForceUsageOfAnonymous();
 }