Ejemplo n.º 1
0
 public function actionIndex()
 {
     $_criteria = new CDbCriteria();
     $_criteria->condition = ' find_in_set(category_id, :category_id)';
     if (isset($_GET['id'])) {
         // sepcial node
         if (is_numeric($_GET['id'])) {
             $node = Category::model()->findByPk($_GET['id']);
         } else {
             $node = Category::model()->findByAttributes(array('ident_label' => $_GET['id']));
         }
         if ($node === null) {
             throw new CHttpException(404, 'The requested Node does not exist.');
         }
         $this->_pageTitle = $node->name . API::lchart();
         $articles = $node->forumarticles;
         $_criteria->params[':category_id'] = $node->id;
     } else {
         //site index
         $model = Category::model()->findByAttributes(array('ident_label' => 'forum_node'));
         $criteria = new CDbCriteria();
         $criteria->condition = ' find_in_set(category_id, :category_id)';
         $criteria->order = 'reply_time desc';
         $criteria->limit = '20';
         $leafs = Category::model()->findAll(array('select' => 'id, name', 'condition' => ' rgt <= :rgt AND lft >= :lft ', 'params' => array(':rgt' => $model->rgt, ':lft' => $model->lft)));
         $all_leafs = '';
         foreach ($leafs as $_leaf) {
             $all_leafs .= $_leaf->id . ',';
         }
         $criteria->params[':category_id'] = $all_leafs;
         $articles = Article::model()->findAll($criteria);
         $_criteria->params[':category_id'] = $all_leafs;
     }
     $latest_articles = Article::model()->latest()->findAll($_criteria);
     $this->render('index', array('latest_articles' => $latest_articles, 'articles' => $articles, 'node' => $node));
 }
Ejemplo n.º 2
0
 public function actionIndex()
 {
     $u =& $this->iuser;
     $this->_pageTitle = '主题回复提醒' . API::lchart();
     $this->render('index', array('notices' => $u->notices));
 }
Ejemplo n.º 3
0
 public function actionCreate()
 {
     $model = new Article('forum');
     //	  $model->content = "<p></p>";
     $model->category_id = $_GET['f'];
     if (isset($_POST['Article']) && !Yii::app()->user->isGuest) {
         $model->attributes = $_POST['Article'];
         $model->reply_time = $model->update_time = $model->create_time = date("Y-m-d H:i:s");
         $model->user_id = Yii::app()->user->id;
         if ($model->save()) {
             $this->redirect(array('t/index', 'id' => $model->id));
             exit;
         }
     }
     $node = Category::model()->findByPk($_GET['f']);
     if ($node === null) {
         throw new CHttpException(404, 'The requested Node does not exist.');
     }
     if ($model->content == '') {
         //		  $model->content = "<p></p>";
     }
     $this->_pageTitle = '新主题' . API::lchart() . $node->name . API::lchart();
     $this->render('create', array('model' => $model, 'node' => $node));
 }
Ejemplo n.º 4
0
 public function actionReset()
 {
     $token = trim($_GET['token']);
     $model = new ResetPasswordForm();
     if (isset($_POST['ResetPasswordForm'])) {
         $model->attributes = $_POST['ResetPasswordForm'];
         if ($model->validate() && $model->reset()) {
             $str = '密码重置成功,请试着登录下!';
             Yii::app()->user->setFlash('success', $str);
             $this->redirect(array('s/signin'));
         }
     } else {
         $record = User::model()->findByAttributes(array('token' => $token));
         $model->token = $record->token;
         if ($record == null) {
             throw new CHttpException(404, 'The requested Reset Password does not exist.');
             exit;
         }
     }
     $this->_pageTitle = '重新设置密码' . API::lchart();
     $this->render('reset', array('record' => $record, 'model' => $model));
 }
Ejemplo n.º 5
0
 public function actionSetting()
 {
     $m = new SettingForm();
     $user =& $this->iuser;
     $m->id = $user->id;
     $m->sign = $user->sign;
     if (isset($_POST['SettingForm'])) {
         $m->attributes = $_POST['SettingForm'];
         $m->avatar = CUploadedFile::getInstance($m, 'avatar');
         // $user->avatar->saveAs('/home/paranoid/projects/infuzhou/123.jpg');
         // $user->save(false);
         if ($m->validate() && $m->setting()) {
             $str = '会员资料已保存,';
             if (strlen($m->password) > 0) {
                 $str .= "密码已更新!";
             } else {
                 $str .= "密码未更新!";
             }
             Yii::app()->user->setFlash('success', $str);
         }
         $user = User::model()->findByPk(Yii::app()->user->id);
     }
     $m->password = $m->rpassword = '';
     $this->_pageTitle = '会员资料设置' . API::lchart();
     $this->render('setting', array('m' => $m, 'user' => $user));
 }