예제 #1
0
 public function actionTrip($id)
 {
     /** @var $trip Trip */
     $trip = Trip::model()->findByPk($id);
     /** @var $user User */
     $user = User::model()->findByPk($trip->owner_id);
     $this->breadcrumbs = array(_('Користувачі') => $this->createUrl('users'), $user->getFirstName() . ' - подорожі' => $this->createUrl('trips', array('userId' => $user->id)), 'Перегляд подорожі');
     $this->render('trip', array('trip' => $trip, 'user' => $user));
 }
예제 #2
0
 public function load($id)
 {
     $trip = Trip::model()->findByPk($id);
     if ($trip) {
         $this->_isNew = FALSE;
         $this->_initial = $trip;
         $this->setAttributes($trip->getAttributes());
     } else {
         throw new CHttpException('404');
     }
 }
예제 #3
0
 protected function _updateRelatedModels()
 {
     if ($this->_initialAttributes['first_name'] != $this->first_name) {
         Trip::model()->updateAll(array('owner_name' => $this->first_name), 'owner_id = :userId', array(':userId' => $this->id));
     }
     if ($this->_initialAttributes['birthday'] != $this->birthday) {
         Trip::model()->updateAll(array('owner_age' => $this->getAge()), 'owner_id = :userId', array(':userId' => $this->id));
     }
 }
예제 #4
0
 /**
  * 切换日游媒体状态
  * @return bool
  */
 public function ActionAjaxChangeTripMediaValid()
 {
     $trip_id = $_POST['trip_media_id'];
     // 获取要修改的日游媒体ID
     $valid = $_POST['valid'];
     // 获取该日游媒体当前的状态 [0:禁用 / 1:启用]
     $valid = $valid == 0 ? 1 : 0;
     $trip_media_model = TripMedia::model();
     $trip_media_info = $trip_media_model->findByPk($trip_id);
     // 查询更改的日游媒体信息
     // 执行更新
     if ($trip_media_info->updateByPk($trip_id, array('Valid' => $valid)) > 0) {
         // 获取所有日游
         $trip = IconvEncode::ObjArrChangeArray(Trip::model()->findAll(), 'TripName');
         // 添加操作日志 [S]
         $log = Yii::app()->user->name . '于 ' . date('Y-m-d H:i:s', time()) . ' ' . ($valid == 0 ? '禁用了' : '启用了') . ' 【' . $trip[$trip_media_info['TripId']] . '】 的媒体文件';
         OperationLogManage::AddOperationLog($log);
         // 添加日志
         // 添加操作日志 [E]
         echo true;
     } else {
         echo false;
     }
 }
예제 #5
0
 /**
  * 切换线路状态
  * @return bool
  */
 public function ActionAjaxChangeTripValid()
 {
     $id = $_POST['id'];
     // 获取要修改的线路ID
     $valid = $_POST['valid'];
     // 获取该线路当前的状态 [0:禁用 / 1:启用]
     $valid = $valid == 0 ? 1 : 0;
     $trip_model = Trip::model();
     $trip_info = $trip_model->findByPk($id);
     // 查询更改的线路信息
     // 执行更新
     if ($trip_info->updateByPk($id, array('Valid' => $valid)) > 0) {
         // 添加操作日志 [S]
         $log = Yii::app()->user->name . '于 ' . date('Y-m-d H:i:s', time()) . ' ' . ($valid == 0 ? '禁用了' : '启用了') . ' 【' . $trip_info['TripName'] . '】 线路';
         OperationLogManage::AddOperationLog($log);
         // 添加日志
         // 添加操作日志 [E]
         echo true;
     } else {
         echo false;
     }
 }
예제 #6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Trip::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionTrip($id)
 {
     /** @var $user User */
     /** @var $mode Trip */
     if (!($model = Trip::model()->findByPk($id))) {
         throw new CHttpException(404);
     }
     $user = User::model()->findByPk($model->owner_id);
     $this->breadcrumbs = array('Головна' => $this->createUrl('site/index'), 'Туристичні знайомства' => $this->createUrl('index'), $user->getFirstName() => $this->createUrl('view', array('id' => $user->id)), 'Поїздка');
     $model->increaseViews();
     $messageForm = new MessageForm();
     $messageForm->setReceiverId($user->id);
     $this->render('trip', array('model' => $model, 'user' => $user, 'countOfPhotos' => Photos::getCountOfPhotos($user->id), 'messageForm' => $messageForm, 'sendMessageHandlerUrl' => $this->createUrl('SendMessageHandler')));
 }