Exemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Tucao();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Tucao'])) {
         $model->attributes = $_POST['Tucao'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->tucao_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemplo n.º 2
0
 public function actionTucao($cate_id = -1, $self = false)
 {
     // 全部吐槽分类
     // 自己来吐槽
     if ($self == true) {
         $_GET['cateI_id'] = $cate_id;
         $model = new Tucao();
         if (isset($_POST['Tucao'])) {
             $model->attributes = $_POST['Tucao'];
             $model->save() or die('发布失败');
             $this->redirect(array('index/tucao'));
         }
         $this->render('createTucao', array('model' => $model));
     } else {
         if ($cate_id == -1) {
             $criteria = new CDbCriteria();
             $criteria->addCondition('class_id=' . Yii::app()->user->class_id);
             $model = TucaoCategory::model()->findAll($criteria);
             $this->render('tucaoCategory', array('model' => $model));
         } else {
             $_GET['cate_id'] = $cate_id;
             $_GET['cate_name'] = TucaoCategory::model()->findByPk($cate_id)->tucao_cate_name;
             $criteria = new CDbCriteria();
             $criteria->addCondition('tucao_cate_id=' . $cate_id);
             $criteria->limit = 10;
             $model = Tucao::model()->findAll($criteria);
             $this->render('tucaos', array('model' => $model));
         }
     }
 }