Beispiel #1
0
 public function actionDelete($id)
 {
     //$this->loadModel($id)->delete();
     $model = Msg::model()->findByPk($id);
     if ($model->delete()) {
         //添加成功时候的提示信息设置
         /**
          *setFlash getFlash hasFlash 几个方法
          */
         Yii::app()->user->setFlash('shanchu', '删除成功!');
     }
     $this->redirect('./index.php?r=backend/msg/index');
 }
Beispiel #2
0
 public function actionList($uid)
 {
     $userid = Yii::app()->user->id;
     $model = new Msg();
     if (isset($_POST['Msg'])) {
         $model->uid = $userid;
         $model->time = time();
         $model->state = 1;
         $model->content = $_POST['Msg']['content'];
         $model->touid = $uid;
         if ($model->save(false)) {
             Yii::app()->user->setFlash('fasong', '私信回复成功 ^_^ ');
         }
         $this->refresh();
     }
     $sql = "select * from {{msg}} where (uid={$uid} and touid={$userid}) or (uid={$userid} and touid={$uid}) order by time asc";
     //输出不同条件按时间排序
     $msglist = Msg::model()->findAllBySql($sql);
     //var_dump($msglist);
     $data = array('model' => $model, 'msglist' => $msglist);
     $this->render('list', $data);
 }
Beispiel #3
0
" target="_blank"><?php 
    echo $_x->senduser->nickname;
    ?>
</a>:<?php 
    echo $_x->content;
    ?>
</p>
                                <p class="font-gray" style="margin-top:5px;">
                                    <span class="fr"><a href="<?php 
    echo Yii::app()->createUrl('msg/list', array('uid' => $_x->uid));
    ?>
">共有
                                    <?php 
    $yonghu = Yii::app()->user->id;
    $duihua = "select * from {{msg}} where (uid={$_x->uid} and touid={$yonghu}) or (uid={$yonghu} and touid={$_x->uid})";
    echo count(Msg::model()->findAllBySql($duihua));
    ?>
对话</a> | <a href="<?php 
    echo Yii::app()->createUrl('msg/list', array('uid' => $_x->uid));
    ?>
">回复</a></span>
                                <?php 
    date_default_timezone_set('PRC');
    //设置默认时区
    echo date('y年m月d日 H:i', $_x->time);
    ?>
                                </p>
                            </li>
                        <?php 
}
?>