当前位置: 首页>>代码示例>>PHP>>正文


PHP Preference::save方法代码示例

本文整理汇总了PHP中Preference::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Preference::save方法的具体用法?PHP Preference::save怎么用?PHP Preference::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Preference的用法示例。


在下文中一共展示了Preference::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 function index()
 {
     if ($this->request->is_post()) {
         $preference = new Preference($_POST);
         $preference->save();
     }
     $preference_factory = new Preference();
     $preferences = $preference_factory->find_all();
     $this->preference = $preferences[0];
 }
开发者ID:emeraldion,项目名称:creso,代码行数:10,代码来源:preferences_controller.php

示例2: processForm

 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'Элемент создан успешно.' : 'Элемент изменен успешно.';
         $form->getObject()->setCompanyId($request->getParameter('element_company'));
         $form->getObject()->setPriceType($request->getParameter('element_price_type'));
         if ($form->getObject()->isNew()) {
             $form->getObject()->setDateCreated(time());
         }
         $form->getObject()->setDateUpdated(time());
         $form->getObject()->setCategoryId($request->getParameter('element_category_id'));
         $Element = $form->save();
         foreach ((array) $request->getParameter('element_file') as $key => $value) {
             if (isset($value['delete'])) {
                 $file_delete = ElementFilePeer::retrieveByPk($key);
                 $file_delete->delete();
             }
         }
         foreach ((array) $request->getFiles('element_file') as $key => $value) {
             list($type, $ext) = explode('/', $value['type']);
             if (isset($value['id']) and $value['id'] != 0) {
                 $file = ElementFilePeer::retrieveByPk($value['id']);
             } else {
                 $file = new ElementFile();
             }
             $file->setElementId($Element->getId());
             $file->setName(md5(time()) . '.' . $ext);
             $file->setFileType($type == 'image' ? 1 : 2);
             $file->save(null, $value);
         }
         foreach ((array) $request->getParameter('element_preference') as $key => $value) {
             if (isset($value['id']) and $value['id'] != 0) {
                 $preference = PreferencePeer::retrieveByPk($value['id']);
             } else {
                 $preference = new Preference();
             }
             $preference->setElementId($Element->getId());
             $preference->setCategoryPreferenceId($value['category_preference_id']);
             $preference->setValue(isset($value['value']) ? $value['value'] : 0);
             $preference->save();
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $Element)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' Можно добавить еще один.');
             $this->redirect('@element_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'element_edit', 'sf_subject' => $Element));
         }
     } else {
         $this->getUser()->setFlash('error', 'Эелемент не сохранен, так как некоторые поля заполненны не верно!', false);
     }
 }
开发者ID:Chipusy,项目名称:lkbroker,代码行数:54,代码来源:actions.class.php

示例3: processForm

 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         $Element = $form->save();
         foreach ((array) $request->getParameter('element_preference') as $key => $value) {
             if (isset($value['id']) and $value['id'] != 0) {
                 $preference = PreferencePeer::retrieveByPk($value['id']);
             } else {
                 $preference = new Preference();
             }
             $preference->setElementId($Element->getId());
             $preference->setCategoryPreferenceId($value['category_preference_id']);
             $preference->setValue(isset($value['value']) ? $value['value'] : 0);
             $preference->save();
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $Element)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@element_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'element_edit', 'sf_subject' => $Element));
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
开发者ID:Chipusy,项目名称:lkbroker,代码行数:29,代码来源:actions.class.php

示例4: actionPreferences

 public function actionPreferences()
 {
     $project = $_POST['project'];
     $userId = Yii::app()->user->id;
     $preference = Preference::model()->find("hideProject = '{$project}' AND userId = {$userId}");
     if ($preference) {
         $preference->delete();
         echo "deletion ok";
     } else {
         $model = new Preference();
         $model->hideProject = $_POST['project'];
         if ($model->save()) {
             echo "insertion ok";
         } else {
             throw new CHttpException(404, 'Error.');
         }
     }
 }
开发者ID:Romandre90,项目名称:vectortraveler,代码行数:18,代码来源:EquipmentController.php

示例5: actionPreferences

 public function actionPreferences()
 {
     $project = $_POST['project'];
     $hide = $_POST['hide'];
     $userId = Yii::app()->user->id;
     $preference = Preference::model()->find("hideProject = '{$project}' AND userId = {$userId}");
     if (!isset($hide)) {
         if ($preference) {
             $preference->delete();
             echo "deletion ok";
         } else {
             $model = new Preference();
             $model->hideProject = $_POST['project'];
             if ($model->save()) {
                 echo "insertion ok";
             } else {
                 throw new CHttpException(404, 'Error.');
             }
         }
     } else {
         if ($hide == 0) {
             if ($preference) {
                 $preference->delete();
                 echo "deletion ok";
             }
         } else {
             //throw new CHttpException(666, 'VEDIAMO COSA SCRIVE');
             if (!$preference) {
                 $model = new Preference();
                 $model->hideProject = $project;
                 if ($model->save()) {
                     echo "insertion ok";
                 } else {
                     throw new CHttpException(404, 'Error.');
                 }
             }
         }
     }
 }
开发者ID:Romandre90,项目名称:vectortraveler,代码行数:39,代码来源:TravelerController.php

示例6: actionPreference

 public function actionPreference()
 {
     $openidurl = Yii::app()->user->id;
     if ($openidurl == null) {
         throw new CHttpException(401, 'Not authorised');
     }
     $model = new Preference();
     $saved_model = Preference::model()->findByOpenId($openidurl);
     if ($saved_model != null) {
         $model =& $saved_model;
     }
     $categories = Category::model()->getAllCategories();
     //$model->email_newsletter=true;
     if (isset($_POST['Preference'])) {
         $model->attributes = $_POST['Preference'];
         $model->openidurl = $openidurl;
         $model->save();
         $this->render('preference', array('model' => $model));
     } else {
         $this->render('preference', array('model' => $model));
     }
 }
开发者ID:sljm12,项目名称:TestDrive,代码行数:22,代码来源:SiteController.php

示例7: executeSavePreferences

 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 : " . ($preference == 'none' ? __('do not display') : __('display'));
         $p = new Preference();
         $p->setUserId($this->getUser()->getId());
         $p->setName('box_user');
         $p->setValue($preference);
         $p->save();
     }
     if (($preference = $this->getUser()->getPreference('box_snippets')) != sfConfig::get('app_preference_box_snippets')) {
         $this->msg .= "\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;
     }
 }
开发者ID:hoydaa,项目名称:snippets.hoydaa.org,代码行数:72,代码来源:actions.class.php


注:本文中的Preference::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。