Example #1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionCheck()
 {
     $model = new RegisterForm();
     $this->registerformAjaxValidation($model);
     // collect user input data
     if (isset($_POST['RegisterForm'])) {
         $model = new User();
         $model->user_name = $_POST['RegisterForm']['username'];
         $model->register_time = time();
         $model->password = crypt($_POST['RegisterForm']['password']);
         $recvArray = array("subscribe_member_follow" => 1, "subscribe_ask_like" => 1, "subscribe_question_like" => 1, "subscribe_answer_like" => 1, "subscribe_comment_like" => 1, "subscribe_article_like" => 1, "subscribe_message_like" => 0);
         $model->recv_option = serialize($recvArray);
         $visitArray = array("visit_count" => 0, "refuse_count" => 0);
         $model->visit_count = serialize($visitArray);
         $privArray = array("visit_priv" => 0);
         $model->priv = serialize($privArray);
         if ($model->save()) {
             $score = Sys::model()->getvaluesByType("register_score");
             $wealthModel = new Wealth();
             if (Sys::model()->getvaluesByType("register_type") == "0") {
                 $content = "注册成功,奖励" . $score . "个财富值";
                 $data = array('content' => $content, 'create_time' => $model->register_time, 'create_user' => $model->id);
                 $wealthModel->insertWealth($data);
                 User::model()->updateByPk($model->id, array("wealth" => intval($score)));
             }
             Yii::app()->user->setFlash("success", "注册成功,<span id='time' style='font-weight:bold;'>3</span>秒后自动关闭");
             $this->redirect(Yii::app()->request->getUrlReferrer());
         }
     }
     //  $this->render('index', array('model' => $model));
 }
Example #2
0
<style>
    #toModal .control-label{width: 70px;}
    #groupModal .controls{margin-left: 80px;}
</style>
<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'topic-form', 'type' => 'horizontal', 'action' => $action, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
$score = Sys::model()->getvaluesByType("topic_score");
if (Sys::model()->getvaluesByType("topic_type") == "0") {
    $hint = "新建话题奖励你" . $score . "个财富值";
} else {
    $hint = "新建话题会花掉你" . $score . "个财富值";
}
echo $form->textFieldRow($topicModel, 'name', array("hint" => $hint));
echo $form->textAreaRow($topicModel, 'desc');
echo $form->dropDownListRow($topicModel, 'parent_id', Topic::model()->listTopics(0, '', '', '默认话题'), array('encode' => false));
echo $form->fileFieldRow($topicModel, 'logo', array('hint' => '上传图片格式为:gif、jpg、jpeg、png'));
$this->endwidget();
Example #3
0
if (!isset($_GET["action"])) {
    if (count($dataProvider->getdata()) == 0) {
        echo "<div class='alert alert-info'>暂无问题.</div>";
    } else {
        $this->widget('bootstrap.widgets.Tbtabs', array('type' => 'tabs', 'htmlOptions' => array('style' => 'margin-top:10px;', 'class' => 'vote-tabs'), 'tabs' => array(array('label' => '最新的', 'content' => $this->renderPartial('../_questiontabs', array("type" => "new", "dataProvider" => $dataProvider), true), 'active' => true), array('label' => '热门的', 'content' => $this->renderPartial('../_questiontabs', array("type" => "hot", "dataProvider" => $dataProvider), true), true), array('label' => '未回答', 'content' => $this->renderPartial('../_questiontabs', array("type" => "not", "dataProvider" => $dataProvider), true), true))));
    }
}
?>
    </div>
    <div class="news" style="padding-top:20px;">
        <div id="setting-tabs" class="tabs-above">
            <?php 
if (Yii::app()->user->isGuest) {
    ?>
                <div class="alert alert-info"><?php 
    echo Sys::model()->find()->site_desc;
    ?>
</div>
            <?php 
}
?>
            <fieldset style="margin-bottom:10px;">
                <legend style="margin-bottom: 10px;">热门话题</legend> 

                <?php 
$i = 0;
$hotTopicModel = Topic::getTopicOrder();
if (!empty($hotTopicModel)) {
    foreach ($hotTopicModel as $key => $value) {
        ?>
                        <div class="clearfix" style="padding:4px 0;"><a class="topic-label" style="margin-right:4px;" data-id="<?php 
Example #4
0
/* @var $form CActiveForm */
?>

<div class="form">

    <?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'article-form', 'enableAjaxValidation' => true, 'enableClientValidation' => true));
?>

    <p class="note">带有<span class="required">*</span> 字段为必填项.</p>
    <?php 
echo $form->errorSummary($model);
?>
    <?php 
$score = Sys::model()->getvaluesByType("article_score");
if (Sys::model()->getvaluesByType("article_type") == "0") {
    $hint = "发表一篇文章会奖励" . $score . "个财富值";
} else {
    $hint = "发表一篇文章会花掉" . $score . "个财富值";
}
?>
    <?php 
echo $form->textFieldRow($model, 'subject', array('hint' => $hint, 'style' => 'width:710px'));
?>
    <?php 
echo $form->ckeditorRow($model, 'content', array('options' => array('toolbar' => 'Simple')));
?>
    <?php 
echo $form->select2Row($model, 'topic_ids', array('asDropDownList' => false, 'style' => 'width:710px;', 'options' => array('tags' => Topic::getTopicArray("name", 20), 'tokenSeparators' => array(',', ' '), 'maximumSelectionSize' => 5)));
?>
    <?php 
Example #5
0
                 'pageSize' => 5)
                 )
         );
         $this->widget('bootstrap.widgets.TbListView', array(
             'dataProvider' => $dataProvider,
             'itemView' => '../_commentlist',
             'template' => '{items}{pager}',
             'htmlOptions' => array('style' => 'padding-top:0px')
         ));
         ?>
     <?php } ?>
 </div>
 <div class="content-right">
     <div id="setting-tabs" class="tabs-above">
         <?php if (Yii::app()->user->isGuest) { ?>
             <div class="alert alert-info"><?php echo Sys::model()->find()->site_desc; ?></div>
         <?php } ?>
         <fieldset>
             <legend style="margin-bottom: 10px;">其他回答</legend> 
         </fieldset>
         <?php
         $criteria = new CDbCriteria;
         $criteria->order = "create_time desc";
         $criteria->addCondition("id!=" . $model->id);
         $criteria->addCondition("question_id=" . $model->question_id);
         $answerModel = Answer::model()->findAll($criteria);
         $count = array();
         if (!empty($answerModel)) {
             echo '<table><tbody>';
             foreach ($answerModel as $answer) {
                 $j++;
Example #6
0
?>
            </div>
        </div>
    </div>
</div>
<div class="settings-section clearfix">
    <div class="settings-section-title" style="width:10%;float: left;padding: 0 !important;">
        <h2>新建文章</h2>
    </div>
    <div class="settings-item clearfix" style="width:90%;float: left;">
        <div class="settings-item-content">
            <div style="width:50%;float: left;">
            <?php 
echo $form->textFieldRow($model, 'article_score');
?>
                </div>
                   <div style="width:50%;float: left;">
            <?php 
echo $form->radioButtonListInlineRow($model, 'article_type', Sys::model()->getType());
?>
            </div>
        </div>
    </div>
</div>
<div clasa="actions" style="text-align: left;padding-top: 10px;">
    <?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'info', 'label' => '保存'));
?>
</div>
<?php 
$this->endWidget();
Example #7
0
 /**
  * 更新user表 
  */
 public function afterDelete()
 {
     parent::afterDelete();
     $createUser = Yii::app()->user->id;
     $time = strtotime(date("Y-m-d", time()));
     $count = self::model()->count("create_user = "******" and update_time > " . $time);
     if ($count == 0 && $this->update_time > $time && $this->publish == 1) {
         $userModal = User::model()->findByPk($createUser);
         $score = Sys::model()->getvaluesByType("artice_score");
         $wealthModel = new Wealth();
         if (Sys::model()->getvaluesByType("artice_type") == "0") {
             $userModal->wealth = $userModal->wealth - intval($score);
             $content = "删除文章成功,花费" . $score . "个财富值";
             $data = array('content' => $content, 'create_time' => time());
             $wealthModel->insertWealth($data);
         }
         $userModal->save();
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("pk_id=" . $this->id);
     $criteria->addCondition("model='article'");
     $commentModel = Comment::model()->findAll($criteria);
     foreach ($commentModel as $value) {
         Comment::model()->findByPk($value->id)->delete();
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("pk_id=" . $this->id);
     $criteria->addCondition("model='article'");
     Vote::model()->deleteAll($criteria);
     $notificationCriteria = new CDbCriteria();
     $notificationCriteria->addCondition("pk_id=" . $this->id);
     $notificationCriteria->addCondition("notification_type='createarticle'");
     $notifyModel = NotificationContent::model()->find($notificationCriteria);
     if ($notifyModel != null) {
         NotificationContent::model()->findByPk($notifyModel->id)->delete();
     }
 }
Example #8
0
<?php

$modelSys = Sys::model()->find();
?>
<div class="footer"><?php 
//echo Yii::getVersion()
?>
    <div class="email" style="float: left">管理员邮箱:<a href="mailto:<?php 
echo $modelSys->mail;
?>
" class="red"><?php 
echo $modelSys->mail;
?>
</a></div>
    <div class="copyright"  style="float: right">版权所有&copy; :<a href="<?php 
echo $this->createUrl("about");
?>
" class="red"><?php 
echo $modelSys->copyright;
?>
</a></div>
</div><!-- footer -->
<?php 
$this->renderPartial('../_topicmodal', array("topicModel" => new Topic(), 'action' => $this->createUrl("/default/createtopic")));
$this->renderPartial('../_questionmodal', array("questionModel" => new Question(), 'action' => $this->createUrl("/default/createquestion")));
$this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'loginModal', 'options' => array("backdrop" => 'static'), 'fade' => false));
?>
<div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h4 class="modal-title" id="myModalLabel">登陆</h4> 
</div>
Example #9
0
<style>
    #toModal .control-label{width: 70px;}
    #groupModal .controls{margin-left: 80px;}
</style>
<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'question-form', 'action' => $action));
$score = Sys::model()->getvaluesByType("question_score");
if (Sys::model()->getvaluesByType("question_type") == "0") {
    $hint = "新建问题奖励你" . $score . "个财富值";
} else {
    $hint = "新建问题会花掉你" . $score . "个财富值";
}
echo $form->textFieldRow($questionModel, 'title', array("hint" => $hint));
echo $form->textAreaRow($questionModel, 'content');
echo $form->select2Row($questionModel, 'topic_ids', array('asDropDownList' => false, 'style' => 'width:530px;', 'options' => array('tags' => Topic::getTopicArray("name", 20), 'tokenSeparators' => array(',', ' '), 'maximumSelectionSize' => 5)));
$this->endwidget();
Example #10
0
 /**
  * 更新user表 
  */
 public function inserNotify($id)
 {
     $model = Question::model()->findByPk($id);
     $createUser = $model->create_user;
     $userModal = User::model()->findByPk($createUser);
     $score = Sys::model()->getvaluesByType("question_score");
     $type = Sys::model()->getvaluesByType("question_type");
     $time = strtotime(date("Y-m-d", time()));
     $count = Question::model()->count("create_user=:create_user and create_time>:create_time", array(":create_user" => $this->create_user, ":create_time" => $time));
     if ($count == 1) {
         $wealthModel = new Wealth();
         if ($type == "0") {
             $userModal->wealth = $userModal->wealth + intval($score);
             $content = "提问成功,奖励" . $score . "个财富值";
             $data = array('content' => $content, 'create_time' => $model->create_time);
             $wealthModel->insertWealth($data);
         }
     }
     if ($type == "1") {
         $userModal->wealth = $userModal->wealth - intval($score);
         $content = "提问成功,花费" . $score . "个财富值";
         $data = array('content' => $content, 'create_time' => $model->create_time);
         $wealthModel->insertWealth($data);
     }
     $userModal->save();
     $notificationData = array("pk_id" => $model->id, "content" => "提出了一个问题", "send_time" => $model->create_time, "notification_type" => "createquestion");
     NotificationContent::insertNotificationContent($notificationData, true);
 }
Example #11
0
<ul class="status-list"> 
    <li><span>问题总数:<?php 
echo Question::model()->count();
?>
</span><span>文章总数:<?php 
echo Article::model()->count("publish=1");
?>
</span></li>
    <li><span>评论总数:<?php 
echo Comment::model()->count("parent_id=0") + SysComment::model()->count();
?>
</span><span>会员总数:<?php 
echo User::model()->count();
?>
</span></li>
    <li><span>回答总数:<?php 
echo Answer::model()->count();
?>
</span><span>访问总数:<?php 
echo Sys::model()->find()->view_count;
?>
</span></li>
</ul>