예제 #1
0
 public function executeSavePreferences()
 {
     sfLoader::loadHelpers('I18N');
     $criteria = new Criteria();
     $criteria->add(PreferencePeer::USER_ID, $this->getUser()->getId());
     $preferences = PreferencePeer::doSelect($criteria);
     foreach ($preferences as $preference) {
         $preference->delete();
     }
     $this->msg = __('Preferences saved.');
     if (($preference = $this->getUser()->getPreference('box_user')) != sfConfig::get('app_preference_box_user')) {
         $this->msg .= "\napp_preference_box_user : "******"\napp_preference_box_snippets : " . ($preference == 'none' ? __('do not display') : __('display'));
         $p = new Preference();
         $p->setUserId($this->getUser()->getId());
         $p->setName('box_snippets');
         $p->setValue($preference);
         $p->save();
     }
     if (($preference = $this->getUser()->getPreference('box_language_cloud')) != sfConfig::get('app_preference_box_language_cloud')) {
         $this->msg .= "\napp_preference_box_language_cloud : " . ($preference == 'none' ? __('do not display') : __('display'));
         $p = new Preference();
         $p->setUserId($this->getUser()->getId());
         $p->setName('box_language_cloud');
         $p->setValue($preference);
         $p->save();
     }
     if (($preference = $this->getUser()->getPreference('box_tag_cloud')) != sfConfig::get('app_preference_box_tag_cloud')) {
         $this->msg .= "\napp_preference_box_tag_cloud : " . ($preference == 'none' ? __('do not display') : __('display'));
         $p = new Preference();
         $p->setUserId($this->getUser()->getId());
         $p->setName('box_tag_cloud');
         $p->setValue($preference);
         $p->save();
     }
     if (($preference = $this->getUser()->getPreference('box_snippets_size')) != sfConfig::get('app_preference_box_snippets_size')) {
         $this->msg .= "\napp_preference_box_snippets_size : " . $preference;
         $p = new Preference();
         $p->setUserId($this->getUser()->getId());
         $p->setName('box_snippets_size');
         $p->setValue($preference);
         $p->save();
     }
     if (($preference = $this->getUser()->getPreference('search_size')) != sfConfig::get('app_preference_search_size')) {
         $this->msg .= "\napp_preference_search_size : " . $preference;
         $p = new Preference();
         $p->setUserId($this->getUser()->getId());
         $p->setName('box_search_size');
         $p->setValue($preference);
         $p->save();
     }
     if (($preference = $this->getUser()->getPreference('box_order')) != sfConfig::get('app_preference_box_order')) {
         $order_str = "";
         foreach ($preference as $order_no) {
             $order_str .= "{$order_no}, ";
         }
         $order_str = substr($order_str, 0, strlen($order_str) - 2);
         $p = new Preference();
         $p->setUserId($this->getUser()->getId());
         $p->setName('box_order');
         $p->setValue($order_str);
         $p->save();
         $this->msg .= "\napp_preference_box_order : " . $order_str;
     }
 }