private function check_authorizations()
 {
     if (!PollAuthorizationsService::check_authorizations()->read()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
 }
예제 #2
0
파일: poll.php 프로젝트: AroundPBT/PHPBoost
$archives = retrieve(GET, 'archives', false);
//On vérifie si on est sur les archives
$show_result = retrieve(GET, 'r', false);
//Affichage des résultats.
$now = new Date(Date::DATE_NOW, Timezone::USER_TIMEZONE);
//Récupération des éléments de configuration
$config_cookie_name = $poll_config->get_cookie_name();
$config_cookie_lenght = $poll_config->get_cookie_lenght_in_seconds();
$config_displayed_in_mini_module_list = $poll_config->get_displayed_in_mini_module_list();
if ($valid && !empty($poll['id']) && !$archives) {
    if (AppContext::get_current_user()->is_readonly()) {
        $controller = PHPBoostErrors::user_in_read_only();
        DispatchManager::redirect($controller);
    }
    //Autorisation de voter
    if (PollAuthorizationsService::check_authorizations()->write()) {
        //On note le passage du visiteur par un cookie.
        if (AppContext::get_request()->has_cookieparameter($config_cookie_name)) {
            $array_cookie = explode('/', AppContext::get_request()->get_cookie($config_cookie_name));
            if (in_array($poll['id'], $array_cookie)) {
                $check_cookie = true;
            } else {
                $check_cookie = false;
                $array_cookie[] = $poll['id'];
                //Ajout nouvelle valeur.
                $value_cookie = implode('/', $array_cookie);
                //On retransforme le tableau en chaîne.
                AppContext::get_response()->set_cookie(new HTTPCookie($config_cookie_name, $value_cookie, time() + $config_cookie_lenght));
            }
        } else {
            $check_cookie = false;
 public function is_displayed()
 {
     $polls = PollMiniMenuCache::load()->get_polls();
     return !empty($polls) && !Url::is_current_url('/poll/') && PollAuthorizationsService::check_authorizations()->read();
 }