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(''); }
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); } }