Exemple #1
0
 public function getCachedBoards()
 {
     if ($this->_cachedBoards == null) {
         $this->_cachedBoards = YiiForum::getAppParam('cachedBoards');
     }
     return $this->_cachedBoards;
 }
Exemple #2
0
 /**
  * Lists all Board models.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $boardId = YiiForum::getGetValue('boardid');
     $locals = [];
     $locals['currentBoard'] = $this->getBoard($boardId);
     $locals['boards'] = $this->buildSubBoards($boardId, null);
     return $this->render('index', $locals);
 }
Exemple #3
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)]);
 }
Exemple #4
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)]);
 }
 public function actionDo()
 {
     $sqlPath = \Yii::getAlias('@data') . TFileHelper::buildPath(['sql']);
     $upgradeInfo = $this->getUpgradeInfo();
     $lastSql = $upgradeInfo['lastSql'];
     $needUpgradeSqls = $upgradeInfo['needUpgradeSqls'];
     $message = '';
     if (empty($needUpgradeSqls)) {
         $message = '没有要升级的文件';
     } else {
         foreach ($needUpgradeSqls as $sql) {
             $sqlData = TFileHelper::readFile([$sqlPath, $sql]);
             YiiForum::execute($sqlData);
         }
         $lastSql = end($needUpgradeSqls);
         $lastSql = ltrim($lastSql, 'yiiforum_');
         $lastSql = rtrim($lastSql, '.sql');
         TFileHelper::writeFile([$sqlPath, 'upgrade.txt'], $lastSql);
         $message = '升级成功,当前sql为:yiiforum_' . $lastSql . '.sql';
     }
     return $this->render('do', ['message' => $message]);
 }
 /**
  * Deletes an existing AuthItem model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  *
  * @param string $id        	
  * @return mixed
  */
 public function actionDelete($id)
 {
     $categoryName = YiiForum::getGetValue('category');
     $item = new Permission();
     $item->name = $id;
     $this->auth->remove($item);
     AuthItem::createCachedPermissions();
     return $this->redirect(['index', 'category' => $categoryName]);
 }
 public function buildBoards($boardId = 0)
 {
     $html = '';
     $boards = Board::findAll(['parent_id' => $boardId], 'sort_num desc');
     foreach ($boards as $board) {
         $id = $board['id'];
         $subBoards = Board::findAll(['parent_id' => $id], 'sort_num desc');
         if (count($subBoards) == 0) {
             continue;
         }
         $parentBoard = $this->getCachedBoards()[$id];
         $totalRecords = count($subBoards);
         $columnsCount = intval($parentBoard['columns']);
         $html .= '<div class="tbox border">';
         $html .= '<div class="hd" style="border-bottom:none;"><h2><a href="' . YiiForum::getHomeUrl() . '?r=board/index&boardid=' . $id . '">' . $parentBoard['name'] . '</a></h2></div>';
         $html .= '<table class="table" style="margin-bottom:0px;">';
         if ($columnsCount > 1) {
             $html .= $this->getMoreColumn($subBoards, $totalRecords, $columnsCount);
         } else {
             $html .= $this->getOneColumn($subBoards, $totalRecords);
         }
         $html .= '</table>';
         $html .= '</div>';
     }
     return $html;
 }
Exemple #8
0
use yii\helpers\Html;
use base\YiiForum;
/**
 * @var yii\web\View $this
 * @var common\models\Board $model
 */
$this->title = 'Update Board: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Boards', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
$messageArray[1] = '<font color="red">父结点不能为当前结点的子结点</font>';
?>
<div class="board-update">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
$message = YiiForum::getGetValue('message', 0);
if ($message == 1) {
    echo $messageArray[$message] . '<br>';
}
?>
    <?php 
echo $this->render('_form', ['model' => $model, 'boardArrayTree' => $boardArrayTree]);
?>

</div>
Exemple #9
0
 /**
  * Deletes an existing AuthItem model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  *
  * @param string $id        	
  * @return mixed
  */
 public function actionDelete($id)
 {
     $groupName = YiiForum::getGetValue('group');
     $item = new Role();
     $item->name = $id;
     $this->auth->remove($item);
     AuthItem::createCachedRoles();
     return $this->redirect(['index', 'group' => $groupName]);
 }
    </div>

    <div class="tbox">
	    <table class="thread-list border">
	    	<tr>
	    		<th>主题</th>
	    		<th width="120px">作者</th>
	    		<th width="120px">回复/查看</th>
	    		<th width="120px">最后发表</th>
	    	</tr>
	    	<?php 
foreach ($rows as $row) {
    ?>
	    	<tr>
	    		<td><a href="<?php 
    echo YiiForum::getHomeUrl() . '?r=thread/view&id=' . $row['id'];
    ?>
"><?php 
    echo $row['title'];
    ?>
</a></td>
	    		<td class="author"><?php 
    echo $row['user_name'];
    ?>
<br/><?php 
    TTimeHelper::showTime($row['create_time']);
    ?>
</td>
	    		<td><?php 
    echo $row['posts'];
    ?>
Exemple #11
0
 */
$this->title = '脚本升级';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-index">

	<h1><?php 
echo $this->title;
?>
</h1>

   

    <div class="body-content">
    
       <?php 
if (empty($needUpgradeSqls)) {
    echo '不需要升级sql<br>';
    echo '<a href="' . YiiForum::getHomeUrl() . '">返回首页</a>';
} else {
    echo '上次升级到的sql为:' . $lastSql . '<br>';
    echo '需要升级以下sql文件:(升级之前强烈建议你备份数据库)<br>';
    foreach ($needUpgradeSqls as $sql) {
        echo '<font color="red">' . $sql . '</font><br>';
    }
    echo Html::a('升级', ['upgrade/do'], ['class' => 'btn btn-primary']);
}
?>
    </div>
</div>
 public function actionRole($id)
 {
     $auth = \Yii::$app->authManager;
     $existItems = $auth->getAssignments($id);
     $model = [];
     if (YiiForum::hasPostValue('submit')) {
         $allRoles = $this->getCachedRoles();
         $selectedRoles = YiiForum::getPostValue('selectedRoles');
         $this->updateAssignments($allRoles, $selectedRoles, $existItems, $id);
         return $this->redirect(['index']);
     } else {
         $allRoles = [];
         $groups = $this->getCachedRoleGroups();
         foreach ($groups as $group) {
             $allRoles[$group['description']] = $this->getCachedRolesByGroup($group['name']);
         }
         $locals = [];
         $locals['model'] = $model;
         $locals['allRoles'] = $allRoles;
         $locals['existRoles'] = $existItems;
         return $this->render('role', $locals);
     }
 }
Exemple #13
0
    </div>
   	<div class="tbox">
		<div class="floatl">
			<?php 
echo Html::a('发帖', ['new-thread', 'boardid' => $currentBoard['id']], ['class' => 'btn btn-success']);
?>
		</div>
		<div class="floatr">
			<?php 
echo LinkPager::widget(['pagination' => $pages]);
?>
		</div>
	</div>
   <div class="tbox">
       <?php 
$form = ActiveForm::begin(['id' => 'newPost', 'action' => YiiForum::getHomeUrl() . '?r=thread/new-post&threadid=' . $thread['id']]);
?>
	
			<input type="hidden" id="post-board_id" name="Post[board_id]" value="<?php 
echo $currentBoard['id'];
?>
"/>
	    	<input type="hidden" id="post-thread_id" name="Post[thread_id]" value="<?php 
echo $thread['id'];
?>
"/>
	    	<input type="hidden" id="post-thread_title" name="Post[thread_title]" value="<?php 
echo $thread['title'];
?>
"/>
	    	
Exemple #14
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]);
     }
 }