public function execute($filterChain) { $context = $this->getContext(); $session_user = $context->getUser(); // we are looking at a potential request for switching main filter: if ($session_user->hasAttribute('filters_switch')) { $cookie_value = $context->getRequest()->getCookie(sfConfig::get('app_personalization_cookie_switch_name')); if ($cookie_value) { $cookie_value = $cookie_value == 'true' ? true : false; if ($session_user->getAttribute('filters_switch') == $cookie_value) { // if cookie has been set, and both values match, remove attribute in user session. $session_user->getAttributeHolder()->remove('filters_switch'); //c2cTools::log("{FiltersSwitchFilter} we're now removing attribute in user session because cookie has been set and cookie value=attribute value"); } else { // set cookie to attribute value. $attr_value = $session_user->getAttribute('filters_switch'); c2cPersonalization::setFilterSwitch($attr_value, $session_user->isConnected() ? $session_user->getId() : null); //c2cTools::log("{FiltersSwitchFilter} we're now setting cookie value to $attr_value because cookie value != attribute value and attribute is stronger than cookie"); } } else { // there's not yet a cookie, but it has been requested to write it. $new_status = (int) $session_user->getAttribute('filters_switch'); //c2cTools::log("{FiltersSwitchFilter} No cookie, but attribute present => we're now asking to set main filter switch to $new_status"); c2cPersonalization::setFilterSwitch($new_status, $session_user->isConnected() ? $session_user->getId() : null); } } $filterChain->execute(); }
/** * Retrieve the singleton instance of this class. * * @return c2cPersonalization A c2cPersonalization implementation instance. */ public static function getInstance() { if (!isset(self::$instance)) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; }
public function executePortalredirect() { $module = $this->getRequestParameter('wtype'); $params = $this->getRequestParameter('params'); $query_string = $this->getRequestParameter('q'); if ($query_string) { list($module, $module_params) = explode('/', $module, 2); if (!empty($module_params)) { $params = $module_params; } if ($module && in_array($module, sfConfig::get('app_modules_list'))) { $model = c2cTools::module2model($module); } else { $model = 'Document'; $module = 'documents'; } $perso = c2cPersonalization::getInstance(); if ($perso->isMainFilterSwitchOn()) { $langs = $perso->getLanguagesFilter(); $ranges = $perso->getPlacesFilter(); $activities = $perso->getActivitiesFilter(); } else { $langs = $ranges = $activities = array(); } sfLoader::loadHelpers(array('Pagination')); $url_params = array(); unpackUrlParameters($params, $url_params); $result_module = $module; $field = 'name'; switch ($module) { case 'documents': $order = 'orderby=module&order=desc'; break; case 'portals': $field = 'wnam'; $order = 'orderby=wnam&order=asc'; break; case 'summits': $result_module = 'routes'; $field = 'snam'; $order = 'orderby=rnam&order=asc'; break; case 'sites': $field = 'tnam'; $order = 'orderby=tnam&order=asc'; break; case 'routes': $field = 'srnam'; $order = 'orderby=rnam&order=asc'; break; case 'parkings': $result_module = 'routes'; $field = 'pnam'; $order = 'orderby=rnam&order=asc'; break; case 'huts': $result_module = 'routes'; $field = 'hnam'; $order = 'orderby=rnam&order=asc'; break; case 'products': $field = 'fnam'; $order = 'orderby=fnam&order=asc'; break; case 'outings': $field = 'onam'; $order = 'orderby=date&order=desc'; break; case 'areas': $result_module = 'routes'; $field = 'anam'; $order = 'orderby=rnam&order=asc'; break; case 'maps': $field = 'mnam'; $order = 'orderby=mnam&order=asc'; break; case 'books': $result_module = 'routes'; $field = 'rbnam'; $order = 'orderby=rnam&order=asc'; break; case 'articles': $field = 'cnam'; $order = 'orderby=cnam&order=asc'; break; case 'images': $field = 'inam'; $order = ''; break; case 'users': $field = 'utfnam'; // utfnam = unam + ufnam $order = 'orderby=unam&order=asc'; break; default: $order = ''; break; } $query_string = trim(str_replace(array(' ', ' ', '.'), array(' ', ' ', '%2E'), $query_string)); $url_params[] = "{$field}={$query_string}"; $url_params[] = $order; $route = '/' . $result_module . '/list?' . implode('&', $url_params); c2cTools::log("redirecting to {$route}"); $this->redirect($route); } else { $this->forward404('need a string'); } }
protected static function filterOnRegions($q, $areas = null, $alias = 'g2') { if (is_null($areas)) { $areas = c2cPersonalization::getInstance()->getPlacesFilter(); } if (!empty($areas)) { $q->leftJoin('m.associations l')->leftJoin('l.MainGeoassociations ' . $alias)->addWhere(self::getAreasQueryString($areas, $alias), $areas); c2cTools::log('filtering on regions'); } }
<?php use_helper('MyForm', 'Language', 'Javascript', 'Ajax', 'Link'); echo customization_nav('customize'); ?> <div id="fake_div"> <div id="customize"> <?php echo c2c_form_remote_tag('users/savefilters'); $perso = c2cPersonalization::getInstance(); ?> <div id="home_left_content"> <?php echo tips_tag('if you select nothing / deselect all, no filter is applied'); ?> <fieldset> <legend><?php echo __('languages_to_display'); ?> </legend> <?php echo checkbox_nokey_list('language_filter', $sf_user->getCulturesForDocuments(), $perso->getLanguagesFilter(), false, false); ?> </fieldset> <fieldset> <legend><?php echo __('activities_to_display'); ?>
/** * Executes view action. */ public function executeView() { parent::executeView(); $mobile_version = c2cTools::mobileVersion(); if (!$this->document->isArchive() && $this->document['redirects_to'] == NULL) { sfLoader::loadHelpers(array('Pagination')); $user = $this->getUser(); $prefered_cultures = $user->getCulturesForDocuments(); $document = $this->document; $id = $this->document->get('id'); $topo_filter = $this->document->get('topo_filter'); $url_params = array(); $main_params = unpackUrlParameters($topo_filter, $main_url_params); // map filter $has_map = $this->document->get('has_map'); $has_map = !$mobile_version && !empty($has_map); $this->has_map = $has_map; if ($has_map) { $map_filter_temp = $this->document->get('map_filter'); $map_filter_temp = str_replace(' ', '', $map_filter_temp); $map_filter_temp = explode('|', $map_filter_temp); $map_filter = array(); foreach ($map_filter_temp as $filter) { $filter = explode(':', $filter); if (isset($filter[1])) { $map_filter[$filter[0]] = $filter[1]; } } if (empty($map_filter['objects'])) { $map_filter['objects'] = null; } if (!empty($map_filter['lon']) || !empty($map_filter['lat']) || !empty($map_filter['zoom'])) { if (empty($map_filter['lon'])) { $lon = $this->document->get('lon'); if (is_null($lon)) { $lon = 7; } } else { $lon = $map_filter['lon']; } if (empty($map_filter['lat'])) { $lat = $this->document->get('lat'); if (is_null($lat)) { $lat = 45.5; } } else { $lat = $map_filter['lat']; } if (empty($map_filter['zoom'])) { $zoom = 6; } else { $zoom = $map_filter['zoom']; } $map_filter['center'] = array($lon, $lat, $zoom); } else { $map_filter['center'] = null; } if (empty($map_filter['height'])) { $map_filter['height'] = null; } $this->map_filter = $map_filter; $this->has_geom = false; } // user filters: $perso = c2cPersonalization::getInstance(); $langs = $ranges = $activities = array(); if ($perso->isMainFilterSwitchOn()) { $langs = $perso->getLanguagesFilter(); $names = array_keys($main_params); if (!array_intersect($names, array('areas', 'summits', 'sites', 'huts', 'parkings', 'routes', 'books'))) { $ranges = $perso->getPlacesFilter(); } if (!in_array('act', $names)) { $activities = $perso->getActivitiesFilter(); } } // latest outings $nb_outings = $this->document->get('nb_outings'); $has_outings = !empty($nb_outings); $this->has_outings = $has_outings; if ($has_outings) { $outing_url_params = array(); $outing_params = $this->document->get('outing_filter'); $outing_params = unpackUrlParameters($outing_params, $outing_url_params); $outing_langs = $langs; $outing_ranges = $ranges; $outing_activities = $activities; if (isset($outing_params['perso'])) { $perso_params = explode('-', $outing_params['perso']); if (array_intersect(array('areas', 'act', 'cult', 'no'), $perso_params)) { if (!in_array('cult', $perso_params)) { $outing_langs = array(); } if (!in_array('areas', $perso_params)) { $outing_ranges = array(); } if (!in_array('act', $perso_params)) { $outing_activities = array(); } } } $latest_outings = Outing::listLatest($nb_outings, $outing_langs, $outing_ranges, $outing_activities, $outing_params); // choose best language for outings and regions names $latest_outings = Language::getTheBest($latest_outings, 'Outing'); $this->latest_outings = Language::getTheBestForAssociatedAreas($latest_outings); $this->outing_url_params = $outing_url_params; } // latest articles $nb_articles = $this->document->get('nb_articles'); $has_articles = !empty($nb_articles); $this->has_articles = $has_articles; if ($has_articles) { $article_url_params = array(); $article_params = $this->document->get('article_filter'); $article_params = unpackUrlParameters($article_params, $article_url_params); $this->latest_articles = Article::listLatest($nb_articles, $langs, $activities, $article_params); $this->article_url_params = $article_url_params; } // latest images if ($mobile_version) { $nb_images = sfConfig::get('app_recent_documents_images_mobile_limit'); } else { $nb_images = $this->document->get('nb_images'); } $has_images = !empty($nb_images); $this->has_images = $has_images; if ($has_images) { $image_url_params = array(); $image_params = $this->document->get('image_filter'); $image_params = unpackUrlParameters($image_params, $image_url_params); $latest_images = Image::listLatest($nb_images, $langs, $ranges, $activities, $image_params); $this->latest_images = Language::getTheBest($latest_images, 'Image'); $this->image_url_params = $image_url_params; } // latest videos $nb_videos = $this->document->get('nb_videos'); $has_videos = !$mobile_version && !empty($nb_videos); if ($has_videos) { $video_url_params = array(); $video_params = $this->document->get('video_filter'); $video_params = explode('|', $video_params, 3); if (count($video_params) == 3) { $video_item = array('url' => trim($video_params[0]), 'thumbnail' => trim($video_params[1]), 'title' => trim($video_params[2])); $latest_videos = array($video_item); $this->latest_videos = $latest_videos; } else { $has_videos = false; } } $this->has_videos = $has_videos; // forum 'mountain news' latest active threads $nb_news = $this->document->get('nb_news'); $has_news = !empty($nb_news); $this->has_news = $has_news; $news_filter_ids = array(); if ($has_news) { $news_filter_temp = $this->document->get('news_filter'); $news_filter_temp = explode('|', $news_filter_temp); $news_filter = array(); foreach ($news_filter_temp as $filter) { $filter = explode(':', $filter); if (isset($filter[1])) { $news_filter[$filter[0]] = explode(',', $filter[1]); } } $news_filter_ids = PunbbTopics::getForumIds('app_forum_mountain_news', $langs, $activities, $news_filter); $this->latest_mountain_news = PunbbTopics::listLatestById($nb_news, $news_filter_ids); $this->news_filter_ids = implode('-', $news_filter_ids); } // forum latest active threads $nb_topics = $this->document->get('nb_topics'); $has_topics = !empty($nb_topics); $this->has_topics = $has_topics; if ($has_topics) { $forum_filter_temp = $this->document->get('forum_filter'); $forum_filter_temp = explode('|', $forum_filter_temp); $forum_filter = array(); foreach ($forum_filter_temp as $filter) { $filter = explode(':', $filter); if (isset($filter[1])) { $forum_filter[$filter[0]] = explode(',', $filter[1]); } } $forum_filter_ids = PunbbTopics::getForumIds('app_forum_public_ids', $langs, $activities, $forum_filter); $this->latest_threads = PunbbTopics::listLatestById($nb_topics, $forum_filter_ids); $this->forum_filter_ids = implode('-', array_merge($news_filter_ids, $forum_filter_ids)); } $cda_config = sfConfig::get('app_portals_cda'); if ($id == $cda_config['id']) { $description = $this->document->get('description'); $has_description = !empty($description); $this->has_description = $has_description; $this->setTemplate('changerdapproche'); } sfLoader::loadHelpers(array('sfBBCode', 'SmartFormat')); $abstract = strip_tags(parse_links(parse_bbcode_abstract($this->document->get('abstract')))); $this->getResponse()->addMeta('description', $abstract); } }
public function signIn($login_name, $password, $remember = false, $password_is_hashed = false) { c2cTools::log('in signin function from myUser class'); $return = false; // we need to retrieve the stored hash for the correspondings user to: // - the salt is stored there, needed for verifiying the password // - allows us to check whether it is still an old hash, without salt $upd = UserPrivateData::retrieveByLoginName($login_name); if (!$upd) { return false; } else { $userid = $upd->id; $hash_tmp = $upd->password_tmp; $hash = $upd->password; } if ($password_is_hashed) { $user = $password === $hash ? sfDoctrine::getTable('User')->find($userid) : false; } else { $user = self::check_password($password, $hash) ? sfDoctrine::getTable('User')->find($userid) : false; } // maybe the user requested a new password, check if password_tmp is ok if (!$user && !$password_is_hashed) { // This block is not used when password is hashed. Indeed password is hashed only // when performing an automatic signIn ("remember me"). // In that case, no temp password is used. c2cTools::log('base login failed, start trying with password_temp'); // user not found, try with tmp password $user = self::check_password($password, $hash_tmp) ? sfDoctrine::getTable('User')->find($userid) : false; if ($user) { c2cTools::log('user found, make temp password the new password'); // user used his tmp password $user_private_data = $user->get('private_data'); // set password to tmp password $user_private_data->set('password', $password); // delete tmp password $user_private_data->set('password_tmp', null); $user->save(); } } if ($user) { c2cTools::log('user found, continue to test if active'); if ($user->isActive()) { c2cTools::log('user is active'); $user_id = $user->get('id'); // if we went there with the old hash algorithm (simple hash, no salt), // then update the db with so that we use the new algorithm next time if (!$password_is_hashed && password_needs_rehash($hash, PASSWORD_DEFAULT)) { c2cTools::log('upgrading user to new hash algorithm'); $conn = sfDoctrine::Connection(); try { $user_private_data = UserPrivateData::find($user_id); $user_private_data->setPassword($password); $user_private_data->save(); $conn->commit(); } catch (Exception $e) { $conn->rollback(); c2cTools::log('could not upgrade user to new hash algorithm'); } $hash = $user_private_data->getPassword(); } $user_culture = $user->get('private_data')->getPreferedCulture(); // when user signs-in it confirms his signup if ($user->isConfirmationPending()) { c2cTools::log('remove user from pending group'); $user->removeFromGroup('pending'); } // login punbb if ($password_is_hashed) { Punbb::signIn($user_id, $password); } else { Punbb::signIn($user_id, $hash); } c2cTools::log('logged in punbb'); // remember? if ($remember) { c2cTools::log('remember me requested / or renew'); $context = sfContext::getInstance(); $remember_cookie = sfConfig::get('app_remember_key_cookie_name', 'c2corg_remember'); $key = RememberKey::generateRandomKey(); // if remember_cookie was set in the request, it means that we are renewing it $remember_key = $context->getRequest()->getCookie($remember_cookie); if ($remember_key) { RememberKey::renewKey($remember_key, $key); } else { $rk = new RememberKey(); $rk->set('remember_key', $key); $rk->set('user', $user); $rk->set('ip_address', isset($_SERVER['HTTP_X_ORIGIN_IP']) ? $_SERVER['HTTP_X_ORIGIN_IP'] : $_SERVER['REMOTE_ADDR']); // TODO remove obsolete field $rk->save(); } // TODO : move remove old keys in a batch // remove old keys RememberKey::deleteOldKeys(); // make key as a cookie $expiration_age = sfConfig::get('app_remember_key_expiration_age', 30 * 24 * 3600); $context->getResponse()->setCookie($remember_cookie, $key, time() + $expiration_age, '/', '', false, true); } else { // user is authenticated but has not checked "remember me" option // let's add a cookie to indicate his/her session should not be reset while his/her browser is open sfContext::getInstance()->getResponse()->setCookie('temp_remember', 1); } c2cTools::log('add some information in user session'); // give credentials $this->addCredentials($user->getAllPermissionNames()); // login session symfony $this->setAttribute('username', $user->get('private_data')->get('topo_name')); $this->setAttribute('id', $user_id); // set the prefered language for user session // and the list of languages ordered by preference $this->saveLanguageListInSession($user->get('private_data')->getDocumentCulture()); // set logged $this->setAuthenticated(true); $return = true; // change language session if needed if ($this->getCulture() != $user_culture) { $this->setCulture($user_culture); } // be sure to update punbb language cookie Punbb::setLanguage($user_culture); // Restore pref cookies c2cPersonalization::restorePrefCookies($user_id); } } return $return; }
function link_to_associated_images($label, $join = '', $orderby = array()) { $params = array(); $rename_params['users'] = 'ousers'; $perso = array(); if (!empty($join)) { $perso_param = c2cPersonalization::getDefaultFiltersUrlParam($join, array('ifon')); if (!empty($perso_param)) { $perso['perso'] = $perso_param; } $rename_params['act'] = c2cTools::Module2Letter($join) . 'act'; $rename_params['id'] = $join; $join = substr($join, 0, -1); $params['join'] = $join; } $params = array_merge($params, $orderby); $uri = '/images/list'; $uri .= _addUrlParameters($uri, array('orderby', 'orderby2', 'orderby3', 'order', 'order2', 'order3', 'page'), $params, $rename_params, $perso); return link_to($label, $uri, array('rel' => 'nofollow')); }
public function executeSavePref() { if (!$this->hasRequestParameter('name') || !$this->hasRequestParameter('value') || !$this->getUser()->isConnected()) { return $this->ajax_feedback(''); } $pref_name = $this->getRequestParameter('name'); $pref_value = $this->getRequestParameter('value'); // if not forum categories, it is a section // check if section exists if ($pref_name != sfConfig::get('app_personalization_cookie_forum_categories_name')) { $valid_prefs = sfConfig::get('app_personalization_cookie_fold_positions'); if (!in_array(substr($pref_name, 0, -12), $valid_prefs)) { return $this->ajax_feedback(''); } } c2cPersonalization::saveFilter($pref_name, $pref_value, $this->getUser()->getId(), false); // cannot save cookie in ajax, done via js return $this->renderText(''); }
function activities_selector($onclick = false, $use_personalization = false, $filtered_activities = array(), $unavailable_activities = array(), $merged_activities = array(), $multiple = true, $show_picto = true, $activity_config = '') { $out = array(); $col = 0; $col_item = 0; if (empty($activity_config)) { $activity_config = 'app_activities_form'; } $activities = sfConfig::get($activity_config); $multiple_activities = array(); if (is_array($multiple)) { if (count($multiple)) { $multiple_activities = $multiple; } $multiple = false; } if (!$multiple) { foreach ($merged_activities as $key => $value) { $activities[$key] = $value; } } foreach ($unavailable_activities as $key => $value) { if (array_key_exists($key, $activities) && (empty($value) || !$multiple)) { $activity = $activities[$key]; unset($activities[$key]); } if (!empty($value) && !$multiple) { $activities[$key] = $activity; } } if ($multiple) { foreach ($merged_activities as $key => $value) { $activities[$key] = $value; } } else { foreach ($multiple_activities as $key) { $activity = $activities[$key]; unset($activities[$key]); $activities[$key] = $activity; } } $item_max = count($activities) - count($multiple_activities) - 1; $col_item_max = ceil(($item_max + 1) / 2) - 1; if (!count($filtered_activities) && $use_personalization) { $perso = c2cPersonalization::getInstance(); if ($perso->isMainFilterSwitchOn()) { $filtered_activities = $perso->getActivitiesFilter(); } } foreach ($activities as $activity_id => $activity) { if (array_key_exists($activity_id, $unavailable_activities)) { $tag = explode('/', $unavailable_activities[$activity_id]); if (count($tag) == 2) { $param = $tag[0]; $value = $tag[1]; $ckeckbox = true; } else { continue; } } else { $param = 'act'; $value = $activity_id; if (in_array($activity_id, $multiple_activities)) { $ckeckbox = true; } else { $ckeckbox = $multiple; } } if ($col_item == 0) { $col_class = $col % 2 ? 'col' : 'col_left'; $out[] = '<div class="' . $col_class . '">'; } $checked = in_array($activity_id, $filtered_activities) ? true : false; $activity_id_list = explode('-', $activity_id); $label_text = ''; if ($show_picto) { foreach ($activity_id_list as $id) { $label_text .= '<span class="picto activity_' . $id . '"></span>'; } } $label_text .= __($activity); if ($ckeckbox) { $input_tag = checkbox_tag($param . '[]', $value, $checked); } else { $input_tag = my_radiobutton_tag($param . '[]', $value, $checked); } $out[] = $input_tag . ' ' . label_for($param . '_' . $value, $label_text); if ($col_item == $col_item_max || $col * $col_item_max + $col_item == $item_max) { $out[] = '</div>'; $col += 1; $col_item = 0; } else { $out[] = '<br />'; $col_item += 1; } } if ($col_item > 0) { $out[] = '</div>'; } return '<div id="actform">' . implode("\n", $out) . '</div>'; }
public static function retrieveConditions($days) { $pager = new sfDoctrinePager('Outing', 10); $q = $pager->getQuery(); $q->select('m.date, m.activities, m.conditions_status, m.up_snow_elevation, m.down_snow_elevation, ' . 'm.access_elevation, mi.name, mi.search_name, mi.conditions, mi.conditions_levels, mi.weather, mi.culture' . 'g0.type, g0.linked_id, ai.name, m.max_elevation')->from('Outing m')->leftJoin('m.OutingI18n mi')->where("m.redirects_to IS NULL AND age(date) < interval '{$days} days'")->orderBy('m.date DESC, m.id DESC'); self::joinOnRegions($q); // applying user filters if (c2cPersonalization::getInstance()->isMainFilterSwitchOn()) { self::filterOnLanguages($q); self::filterOnActivities($q); self::filterOnRegions($q); } return $pager; }
public function getPrevNextId($model, $current_id, $direction = 'next') { $where = 'm.id ' . ($direction == 'next' ? '<' : '>') . ' ?'; $orderBy = 'm.id ' . ($direction == 'next' ? 'DESC' : 'ASC'); $q = Doctrine_Query::create()->select('m.id')->from("{$model} m")->where($where, array($current_id))->addWhere('m.redirects_to IS NULL'); if (c2cPersonalization::getInstance()->isMainFilterSwitchOn()) { $this->addPrevNextIdFilters($q, $model); } $res = $q->orderBy($orderBy)->limit(1)->execute()->getFirst(); return !empty($res) ? $res->getId() : NULL; }
public function executeBeforeExecution() { $context = $this->getContext(); $module = $context->getModuleName(); $action = $context->getActionName(); $request_parameters = $context->getRequest()->getParameterHolder()->getAll(); unset($request_parameters['module']); unset($request_parameters['action']); $count_request_parameters = count($request_parameters); // register our cache configuration $this->cacheManager->registerConfiguration($module); // this previous line removes the dynamic cache configuration we could have been adding in previous filter ! // so that conditionalCacheFilter defined in documentation : // http://www.symfony-project.com/book/1_0/12-Caching#Configuring%20the%20Cache%20Dynamically // does not work ! if ($action == 'home' || $module == 'portals' && $action == 'view') { $module_cache = 'outings'; } else { $module_cache = $module; } $perso = c2cPersonalization::getInstance(); list($langs_enable, $areas_enable, $activities_enable) = c2cPersonalization::getDefaultFilters($module_cache); $are_filters_active = $perso->areFiltersActive(); $is_main_filter_switch_on = $perso->isMainFilterSwitchOn(); $count_activities_filter = count($perso->getActivitiesFilter()); $count_places_filter = count($perso->getPlacesFilter()); $are_default_filters = $perso->areDefaultFilters(); $are_simple_activities_langs_filters = $perso->areSimpleActivitiesFilters(true); $are_simple_activities_filters = $perso->areSimpleActivitiesFilters(false); // portals and home cache // Following condition means that filter is deactivated, or filters are empty, // or there is only one culture in the prefs, which the same as the interface culture // Other cases should not happen often, we don't cache them switch ($action) { case 'home': case 'view': if (!$are_filters_active || !$is_main_filter_switch_on || $are_default_filters || $are_simple_activities_langs_filters) { $this->cacheManager->addCache('documents', 'home', array('lifeTime' => 300, 'vary' => array())); $this->cacheManager->addCache('portals', 'changerdapproche', array('lifeTime' => 600, 'vary' => array())); $this->cacheManager->addCache('portals', 'view', array('lifeTime' => 600, 'vary' => array())); } break; case 'list': if (!isset($request_parameters['page'])) { $request_parameters['page'] = 1; $count_request_parameters++; } if ($request_parameters['page'] <= 2 && ($count_request_parameters == 1 || $module == 'outings' && $count_request_parameters == 3 && isset($request_parameters['orderby']) && $request_parameters['orderby'] == 'date' && isset($request_parameters['order']) && $request_parameters['order'] == 'desc') && (!$are_filters_active || !$is_main_filter_switch_on || $perso->areCacheableFilters($module))) { $this->cacheManager->addCache($module, 'list', array('lifeTime' => 350000, 'vary' => array())); } break; case 'filter': if (!$count_request_parameters && !$count_places_filter && (!$are_filters_active || !$is_main_filter_switch_on || $are_simple_activities_filters)) { if (in_array($module, array('outings', 'images'))) { $lifetime = 86400; } else { $lifetime = 600000; } $this->cacheManager->addCache($module, 'filter', array('lifeTime' => $lifetime, 'vary' => array())); } break; case 'cdasearch': if (!$count_request_parameters || !$count_places_filter) { $this->cacheManager->addCache($module, 'cdasearch', array('lifeTime' => 350000, 'vary' => array())); } break; default: break; } if (!$is_main_filter_switch_on || !$count_activities_filter) { $this->cacheManager->addCache('common', '_menu', array('lifeTime' => 350000, 'vary' => array())); } // get current uri adapted for cache $uri = self::getCurrentCacheUri(); // page cache $this->cache[$uri] = array('page' => false, 'action' => false); $cacheable = $this->cacheManager->isCacheable($uri); if ($cacheable) { if ($this->cacheManager->withLayout($uri)) { $inCache = $this->getPageCache($uri); $this->cache[$uri]['page'] = !$inCache; if ($inCache) { // page is in cache, so no need to run execution filter return false; } } else { $inCache = $this->getActionCache($uri); $this->cache[$uri]['action'] = !$inCache; } } return true; }
public function executeCustomize() { $referer = $this->getRequest()->getReferer(); $alist = sfConfig::get('app_activities_list'); array_shift($alist); // to remove 0 if ($this->hasRequestParameter('activity')) { $activity = $this->getRequestParameter('activity', 0) - 1; // comprised between 0 and 7 /* 1: skitouring 2: snow_ice_mixed 3: mountain_climbing 4: rock_climbing 5: ice_climbing 6: hiking 7: snowshoeing 8: paragliding */ } else { if ($this->hasRequestParameter('activity_name')) { $name = $this->getRequestParameter('activity_name'); foreach ($alist as $a => $a_name) { if ($a_name == $name) { $activity = $a; } } } else { $activity = -1; } } $user = $this->getUser(); if ($user->isConnected()) { $user_id = $user->getId(); } else { $user_id = null; } if (array_key_exists($activity, $alist)) { if (c2cPersonalization::getInstance()->getActivitiesFilter() == array($activity + 1) && $this->hasRequestParameter('activity')) { // we disactivate the previously set quick filter on this activity c2cPersonalization::saveFilter(sfConfig::get('app_personalization_cookie_activities_name'), array(), $user_id); return $this->setNoticeAndRedirect("c2c is no more customized with activies", $referer); } else { // we build a simple activity filter with one activity: c2cPersonalization::saveFilter(sfConfig::get('app_personalization_cookie_activities_name'), array($activity + 1), $user_id); // we need to activate main filter switch: $user->setFiltersSwitch(true); $activity_name = $alist[$activity]; return $this->setNoticeAndRedirect("c2c customized for {$activity_name} !", $referer); } } else { return $this->setNoticeAndRedirect('could not understand your request', $referer); } }
public function executeGetmultipleselect() { $mobile_version = c2cTools::mobileVersion(); $separate_prefs = $this->hasRequestParameter('sep_prefs') ? $this->getRequestParameter('sep_prefs') : 'true'; $separate_prefs = $separate_prefs == 'false' ? false : true; $area_type = $this->getRequestParameter('area_type'); if (!$mobile_version) { $default_width = 'auto'; $default_height = '350px'; } else { $default_width = '216px'; $default_height = '3.8em'; } $height = $this->hasRequestParameter('height') ? $this->getRequestParameter('height') . 'px' : $default_height; $width = $this->hasRequestParameter('width') ? $this->getRequestParameter('width') . 'px' : $default_width; $select_id = $this->hasRequestParameter('select_id') ? $this->getRequestParameter('select_id') : 'places'; $select_name = $this->hasRequestParameter('select_id') ? $this->getRequestParameter('select_name') : 'areas'; $areas = $this->getAreas($area_type, $separate_prefs); sfLoader::loadHelpers(array('Tag', 'Form')); return $this->renderText(select_tag($select_name, options_for_select($areas, $separate_prefs ? null : c2cPersonalization::getInstance()->getPlacesFilter()), array('id' => $select_id, 'multiple' => true, 'style' => 'width:' . $width . '; height:' . $height . ';')) . input_hidden_tag($select_id . '_type', $area_type)); }