Esempio n. 1
0
 public static function updateLastData($threadId)
 {
     $attributes = [];
     $attributes['posts'] = new Expression("[[posts]]+:bp0", [":bp0" => 1]);
     $attributes['last_user_id'] = YiiForum::getIdentity()->id;
     $attributes['last_user_name'] = YiiForum::getIdentity()->username;
     $attributes['last_modify_time'] = TTimeHelper::getCurrentTime();
     Thread::updateAll($attributes, ['id' => intval($threadId)]);
 }
Esempio n. 2
0
 public static function updateLastData($boardId, $threadId, $threadTitle, $isThread = True)
 {
     $attributes = [];
     $attributes['modify_time'] = TTimeHelper::getCurrentTime();
     if ($isThread) {
         $attributes['threads'] = new Expression("[[threads]]+:bp0", [":bp0" => 1]);
     } else {
         $attributes['posts'] = new Expression("[[posts]]+:bp0", [":bp0" => 1]);
     }
     $attributes['user_id'] = YiiForum::getIdentity()->id;
     $attributes['user_name'] = YiiForum::getIdentity()->username;
     $attributes['thread_id'] = $threadId;
     $attributes['thread_title'] = $threadTitle;
     YiiForum::info($attributes);
     Board::updateAll($attributes, ['id' => intval($boardId)]);
 }
Esempio n. 3
0
<br/><?php 
    TTimeHelper::showTime($row['create_time']);
    ?>
</td>
	    		<td><?php 
    echo $row['posts'];
    ?>
/<?php 
    echo $row['views'];
    ?>
</td>
	    		<td class="last-author"><?php 
    echo $row['last_user_name'];
    ?>
<br/><?php 
    echo TTimeHelper::showTime($row['last_modify_time'], 'Y-m-d H:i');
    ?>
</td>
	    	</tr>
	    	<?php 
}
?>
	    </table>
    </div>
    
    <div class="tbox">
	    <div class="floatl">
	    	<?php 
echo Html::a('发帖', ['new-thread', 'boardid' => $currentBoard['id']], ['class' => 'btn btn-success']);
?>
	    </div>
Esempio n. 4
0
 public function actionEditPost($id)
 {
     if (!YiiForum::checkAuth('post_edit')) {
         return $this->noPermission();
     }
     YiiForum::checkIsGuest();
     $boardId = YiiForum::getGetValue('boardid');
     $model = Post::findOne(['id' => $id]);
     $data = YiiForum::getPostValue('Post');
     if ($data == null) {
         $thread = Thread::findOne(['id' => $model['thread_id']]);
         $locals = [];
         $locals['thread'] = $thread;
         $locals['currentBoard'] = $this->getBoard($boardId);
         $locals['model'] = $model;
         return $this->render('edit-post', $locals);
     } else {
         $model->load(Yii::$app->request->post());
         $model->modify_time = TTimeHelper::getCurrentTime();
         $model->save();
         return $this->redirect(['view', 'id' => $model->thread_id]);
     }
 }