private function get_module_map($auth_mode)
 {
     $lang = LangLoader::get('common', 'bugtracker');
     $config = BugtrackerConfig::load();
     $current_user = AppContext::get_current_user();
     $link = new SitemapLink($lang['module_title'], BugtrackerUrlBuilder::home(), Sitemap::FREQ_DEFAULT, Sitemap::PRIORITY_MAX);
     $module_map = new ModuleMap($link, 'bugtracker');
     if ($auth_mode == Sitemap::AUTH_PUBLIC) {
         $this_auth = Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $config->get_authorizations(), BugtrackerAuthorizationsService::READ_AUTHORIZATIONS);
     } else {
         if ($auth_mode == Sitemap::AUTH_USER) {
             if ($current_user->get_level() == User::ADMIN_LEVEL) {
                 $this_auth = true;
             } else {
                 $this_auth = Authorizations::check_auth(RANK_TYPE, $current_user->get_level(), $config->get_authorizations(), BugtrackerAuthorizationsService::READ_AUTHORIZATIONS);
             }
         }
     }
     if ($this_auth) {
         $module_map->add(new SitemapLink($lang['titles.unsolved'], BugtrackerUrlBuilder::unsolved()));
         $module_map->add(new SitemapLink($lang['titles.solved'], BugtrackerUrlBuilder::solved()));
         if ($config->is_roadmap_enabled() && $config->get_versions()) {
             $module_map->add(new SitemapLink($lang['titles.roadmap'], BugtrackerUrlBuilder::roadmap()));
         }
         $module_map->add(new SitemapLink($lang['titles.stats'], BugtrackerUrlBuilder::stats()));
     }
     return $module_map;
 }
 public function check_authorizations(Category $category)
 {
     $nbr_bits = count($this->authorizations_bits);
     if ($nbr_bits == 0) {
         return true;
     } else {
         $authorized_bits = array();
         foreach ($this->authorizations_bits as $bit) {
             if ($this->allow_only_member_level_authorizations && Authorizations::check_auth(RANK_TYPE, User::MEMBER_LEVEL, $category->get_authorizations(), $bit) || $category->check_auth($bit)) {
                 $authorized_bits[] = $bit;
             }
         }
         $nbr_authorized_bits = count($authorized_bits);
         if ($this->check_all_bits) {
             return $nbr_authorized_bits == $nbr_bits;
         } else {
             return $nbr_authorized_bits >= 1;
         }
     }
 }
 private function create_module_map_sections($categories, $id_cat, $auth_mode)
 {
     $category = $this->categories_manager->get_categories_cache()->get_category($id_cat);
     $this_category = new SitemapLink($category->get_name(), $this->get_category_url($category));
     $section = new SitemapSection($this_category);
     $i = 0;
     foreach ($categories as $id => $category) {
         if ($auth_mode == Sitemap::AUTH_PUBLIC) {
             $this_auth = Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $category->get_authorizations(), Category::READ_AUTHORIZATIONS);
         } else {
             $this_auth = AppContext::get_current_user()->check_auth($category->get_authorizations(), Category::READ_AUTHORIZATIONS);
         }
         if ($this_auth && $id != Category::ROOT_CATEGORY && $category->get_id_parent() == $id_cat) {
             $section->add($this->create_module_map_sections($categories, $id, $auth_mode));
             $i++;
         }
     }
     if ($i == 0) {
         $section = $this_category;
     }
     return $section;
 }
 private function check_authorizations()
 {
     if (AppContext::get_current_user()->is_guest()) {
         if ($this->config->are_descriptions_displayed_to_guests() && (!Authorizations::check_auth(RANK_TYPE, User::MEMBER_LEVEL, $this->get_category()->get_authorizations(), Category::READ_AUTHORIZATIONS) || $this->config->get_category_display_type() == DownloadConfig::DISPLAY_ALL_CONTENT) || !$this->config->are_descriptions_displayed_to_guests() && !DownloadAuthorizationsService::check_authorizations($this->get_category()->get_id())->read()) {
             $error_controller = PHPBoostErrors::user_not_authorized();
             DispatchManager::redirect($error_controller);
         }
     } else {
         if (!DownloadAuthorizationsService::check_authorizations($this->get_category()->get_id())->read()) {
             $error_controller = PHPBoostErrors::user_not_authorized();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 /**
  * @desc Computes the number of contributions available for each profile.
  * It will count the contributions for the administrator, the moderators, the members, for each group and for each member who can have some special authorizations.
  * @return int[] A map containing the values for each profile:
  * <ul>
  * 	<li>r2 => for the administrator</li>
  * 	<li>r1 => for the moderators</li>
  * 	<li>r0 => for the members</li>
  * 	<li>gi => for the group whose id is i</li>
  * 	<li>mi => for the member whose id is i</li>
  * </ul>
  */
 public static function compute_number_contrib_for_each_profile()
 {
     $array_result = array('r2' => 0, 'r1' => 0, 'r0' => 0);
     $result = self::$db_querier->select("SELECT auth FROM " . DB_TABLE_EVENTS . "\n\t\tWHERE current_status = :current_status AND contribution_type = :contribution_type", array('current_status' => Event::EVENT_STATUS_UNREAD, 'contribution_type' => self::CONTRIBUTION_TYPE));
     while ($row = $result->fetch()) {
         if (!($this_auth = @unserialize($row['auth']))) {
             $this_auth = array();
         }
         //We can count only for ranks. For groups and users we can't generalize because there can be intersection problems. Yet, we know the maximum number of contributions they can see, and we can be sure if they have at least 1.
         //Administrators can see everything
         $array_result['r2']++;
         //For moderators ?
         if (Authorizations::check_auth(RANK_TYPE, User::MODERATOR_LEVEL, $this_auth, Contribution::CONTRIBUTION_AUTH_BIT)) {
             $array_result['r1']++;
         }
         //For members ?
         if (Authorizations::check_auth(RANK_TYPE, User::MEMBER_LEVEL, $this_auth, Contribution::CONTRIBUTION_AUTH_BIT)) {
             $array_result['r0']++;
         }
         foreach ($this_auth as $profile => $auth_profile) {
             //Groups
             if (is_numeric($profile)) {
                 //If this member has not already an entry and he can see that contribution
                 if (empty($array_result[$profile]) && Authorizations::check_auth(GROUP_TYPE, (int) $profile, $this_auth, Contribution::CONTRIBUTION_AUTH_BIT)) {
                     $array_result['g' . $profile] = 1;
                 }
             } elseif (substr($profile, 0, 1) == 'm') {
                 //If this member has not already an entry and he can see that contribution
                 if (empty($array_result[$profile]) && Authorizations::check_auth(USER_TYPE, (int) substr($profile, 1), $this_auth, Contribution::CONTRIBUTION_AUTH_BIT)) {
                     $array_result[$profile] = 1;
                 }
             }
         }
     }
     $result->dispose();
     return $array_result;
 }
 function _check_cats_auth($id_cat, &$list)
 {
     global $DOWNLOAD_CATS, $CONFIG_DOWNLOAD;
     if ($id_cat == 0) {
         if (Authorizations::check_auth(RANK_TYPE, GUEST_LEVEL, $CONFIG_DOWNLOAD['global_auth'], DOWNLOAD_READ_CAT_AUTH_BIT)) {
             $list[] = 0;
         } else {
             return;
         }
     } else {
         if (!empty($DOWNLOAD_CATS[$id_cat])) {
             $auth = !empty($DOWNLOAD_CATS[$id_cat]['auth']) ? $DOWNLOAD_CATS[$id_cat]['auth'] : $CONFIG_DOWNLOAD['global_auth'];
             if (Authorizations::check_auth(RANK_TYPE, GUEST_LEVEL, $auth, DOWNLOAD_READ_CAT_AUTH_BIT)) {
                 $list[] = $id_cat;
             }
         } else {
             return;
         }
     }
     $keys = array_keys($DOWNLOAD_CATS);
     $num_cats = count($DOWNLOAD_CATS);
     $properties = array();
     for ($j = 0; $j < $num_cats; $j++) {
         $id = $keys[$j];
         $properties = $DOWNLOAD_CATS[$id];
         if ($properties['id_parent'] == $id_cat) {
             $this_auth = is_array($properties['auth']) ? Authorizations::check_auth(RANK_TYPE, GUEST_LEVEL, $properties['auth'], DOWNLOAD_READ_CAT_AUTH_BIT) : Authorizations::check_auth(RANK_TYPE, GUEST_LEVEL, $CONFIG_DOWNLOAD['global_auth'], DOWNLOAD_READ_CAT_AUTH_BIT);
             if ($this_auth) {
                 $list[] = $id;
                 $this->_check_cats_auth($id, $list);
             }
         }
     }
 }
Esempio n. 7
0
                PollMiniMenuCache::invalidate();
            }
            //Tout s'est bien déroulé, on redirige vers la page des resultats.
            AppContext::get_response()->redirect(PATH_TO_ROOT . '/poll/poll' . url('.php?id=' . $poll['id'], '-' . $poll['id'] . '.php'));
        } else {
            //Vote blanc
            AppContext::get_response()->redirect(PATH_TO_ROOT . '/poll/poll' . url('.php?id=' . $poll['id'], '-' . $poll['id'] . '.php'));
        }
    } else {
        AppContext::get_response()->redirect(PATH_TO_ROOT . '/poll/poll' . url('.php?id=' . $poll['id'] . '&error=e_unauth_poll', '-' . $poll['id'] . '.php?error=e_unauth_poll', '&') . '#message_helper');
    }
} elseif (!empty($poll['id']) && !$archives) {
    $tpl = new FileTemplate('poll/poll.tpl');
    //Résultats
    $check_bdd = false;
    if (Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $poll_config->get_authorizations(), PollAuthorizationsService::WRITE_AUTHORIZATIONS)) {
        //Injection de l'adresse ip du visiteur dans la bdd.
        $ip = PersistenceContext::get_querier()->count(PREFIX . "poll_ip", 'WHERE ip = :ip AND idpoll = :id', array('ip' => AppContext::get_request()->get_ip_address(), 'id' => $poll['id']));
        if (!empty($ip)) {
            $check_bdd = true;
        }
    } else {
        //Injection de l'adresse ip du visiteur dans la bdd.
        $nbr_votes = PersistenceContext::get_querier()->count(PREFIX . "poll_ip", 'WHERE user_id = :user_id AND idpoll = :id', array('user_id' => AppContext::get_current_user()->get_id(), 'id' => $poll['id']));
        if (!empty($nbr_votes)) {
            $check_bdd = true;
        }
    }
    //Gestion des erreurs
    $get_error = retrieve(GET, 'error', '');
    switch ($get_error) {
 private function create_module_map_sections($id_cat, $auth_mode)
 {
     global $LANG;
     $pages_config = PagesConfig::load();
     $categories_cache = PagesCategoriesCache::load();
     $categories = $categories_cache->get_categories();
     //Configuration des authorisations
     $config_authorizations = $pages_config->get_authorizations();
     $this_category = new SitemapLink($categories[$id_cat]['title'], new Url('/pages/' . url('pages.php?title=' . Url::encode_rewrite($categories[$id_cat]['title']), Url::encode_rewrite($categories[$id_cat]['title']))));
     $category = new SitemapSection($this_category);
     $i = 0;
     $keys = array_keys($categories);
     $num_cats = $categories_cache->get_number_categories();
     $properties = array();
     for ($j = 0; $j < $num_cats; $j++) {
         $id = $keys[$j];
         $properties = $categories[$id];
         if ($auth_mode == Sitemap::AUTH_PUBLIC) {
             $this_auth = is_array($properties['auth']) ? Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $properties['auth'], READ_PAGE) : Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $config_authorizations, READ_PAGE);
         } elseif ($auth_mode == Sitemap::AUTH_USER) {
             if (AppContext::get_current_user()->get_level() == User::ADMIN_LEVEL) {
                 $this_auth = true;
             } else {
                 $this_auth = is_array($properties['auth']) ? Authorizations::check_auth(RANK_TYPE, AppContext::get_current_user()->get_level(), $properties['auth'], READ_PAGE) : Authorizations::check_auth(RANK_TYPE, AppContext::get_current_user()->get_level(), $config_authorizations, READ_PAGE);
             }
         }
         if ($this_auth && $id != 0 && $properties['id_parent'] == $id_cat) {
             $category->add($this->create_module_map_sections($id, $auth_mode));
             $i++;
         }
     }
     if ($i == 0) {
         $category = $this_category;
     }
     return $category;
 }
 function _create_module_map_sections($id_cat, $auth_mode)
 {
     global $FAQ_CATS, $FAQ_LANG, $LANG, $User, $FAQ_CONFIG;
     $this_category = new SiteMapLink($FAQ_CATS[$id_cat]['name'], new Url('/faq/' . url('faq.php?id=' . $id_cat, 'faq-' . $id_cat . '+' . url_encode_rewrite($FAQ_CATS[$id_cat]['name']) . '.php')));
     $category = new SiteMapSection($this_category);
     $i = 0;
     $keys = array_keys($FAQ_CATS);
     $num_cats = count($FAQ_CATS);
     $properties = array();
     for ($j = 0; $j < $num_cats; $j++) {
         $id = $keys[$j];
         $properties = $FAQ_CATS[$id];
         if ($auth_mode == SITE_MAP_AUTH_GUEST) {
             $this_auth = is_array($properties['auth']) ? Authorizations::check_auth(RANK_TYPE, GUEST_LEVEL, $properties['auth'], AUTH_READ) : Authorizations::check_auth(RANK_TYPE, GUEST_LEVEL, $FAQ_CONFIG['global_auth'], AUTH_READ);
         } else {
             $this_auth = is_array($properties['auth']) ? $User->check_auth($properties['auth'], AUTH_READ) : $User->check_auth($FAQ_CONFIG['global_auth'], AUTH_READ);
         }
         if ($this_auth && $id != 0 && $properties['visible'] && $properties['id_parent'] == $id_cat) {
             $category->add($this->_create_module_map_sections($id, $auth_mode));
             $i++;
         }
     }
     if ($i == 0) {
         $category = $this_category;
     }
     return $category;
 }
 static function compute_number_contrib_for_each_profile()
 {
     global $Sql;
     $array_result = array('r2' => 0, 'r1' => 0, 'r0' => 0);
     $result = $Sql->query_while("SELECT auth FROM " . DB_TABLE_EVENTS . " WHERE current_status = '" . EVENT_STATUS_UNREAD . "' AND contribution_type = '" . CONTRIBUTION_TYPE . "'", __LINE__, __FILE__);
     while ($row = $Sql->fetch_assoc($result)) {
         if (!($this_auth = @unserialize($row['auth']))) {
             $this_auth = array();
         }
         $array_result['r2']++;
         if (Authorizations::check_auth(RANK_TYPE, MODERATOR_LEVEL, $this_auth, CONTRIBUTION_AUTH_BIT)) {
             $array_result['r1']++;
         }
         if (Authorizations::check_auth(RANK_TYPE, MEMBER_LEVEL, $this_auth, CONTRIBUTION_AUTH_BIT)) {
             $array_result['r0']++;
         }
         foreach ($this_auth as $profile => $auth_profile) {
             if (is_numeric($profile)) {
                 if (empty($array_result[$profile]) && Authorizations::check_auth(GROUP_TYPE, (int) $profile, $this_auth, CONTRIBUTION_AUTH_BIT)) {
                     $array_result['g' . $profile] = 1;
                 }
             } elseif (substr($profile, 0, 1) == 'm') {
                 if (empty($array_result[$profile]) && Authorizations::check_auth(USER_TYPE, (int) substr($profile, 1), $this_auth, CONTRIBUTION_AUTH_BIT)) {
                     $array_result[$profile] = 1;
                 }
             }
         }
     }
     return $array_result;
 }