Exemplo n.º 1
0
    ?>
    <?php 
    $menu = [['url' => $this->updateURLWithSection(['manage', 'groups']), 'label' => 'Manage Groups'], ['url' => $this->updateURLWithSection(['manage', 'categories']), 'label' => 'Manage Categories'], ['url' => $this->updateURLWithSection(['manage', 'users']), 'label' => 'Manage Users'], ['url' => $this->updateURLWithSection(['manage', 'titles']), 'label' => 'Manage Titles']];
}
echo \app\components\htmltools\Page::get()->title(\mpf\web\helpers\Html::get()->link($this->updateURLWithSection(['home', 'index']), $this->forumTitle) . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " Members", $menu);
?>

<div class="forum-page <?php 
echo $this->forumPageTheme;
?>
">
    <?php 
$this->displayComponent('topuserpanel');
?>
    <?php 
if ((!\mpf\modules\forum\components\UserAccess::get()->isMember($this->sectionId) || \mpf\modules\forum\components\UserAccess::get()->isBanned($this->sectionId)) && !\mpf\modules\forum\components\UserAccess::get()->isSiteModerator() && !\mpf\modules\forum\components\UserAccess::get()->isSiteAdmin()) {
    ?>
        <?php 
    $this->displayComponent('accessdenied', ['location' => 'members']);
    ?>
        <?php 
    return;
    ?>
    <?php 
}
?>

    <?php 
\mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider($this->sectionId), 'columns' => ['user_id' => ['value' => '$row->getProfileLink()'], 'member_since' => ['class' => 'Date'], 'title_id' => ['value' => '$row->title_id?$row->title->title:"-"', 'filter' => \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\forum\models\ForumTitle::findAllByAttributes(['section_id' => $this->sectionId]), ['id' => 'title'])], 'group_id' => ['value' => '$row->group->full_name', 'filter' => \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\forum\models\ForumUserGroup::findAllBySection($this->sectionId), ['id' => 'full_name'])], 'muted' => ['class' => 'YesNo'], 'banned' => ['class' => 'YesNo']]])->display();
?>
</div>
Exemplo n.º 2
0
 public function actionEditTitle($id)
 {
     $model = ForumTitle::findByPk($id);
     if ($model->section_id != $this->sectionId) {
         Messages::get()->error("Access denied!");
         $this->goBack();
     }
     if (isset($_POST['ForumTitle'])) {
         $model->setAttributes($_POST['ForumTitle']);
         if ($model->save()) {
             if (false != ($icon = $this->uploadImage("titles", 'icon', $model->id))) {
                 if ($model->icon && $model->icon != "default.png" && $model->icon != $icon) {
                     @unlink($this->getUploadFolder() . 'titles' . DIRECTORY_SEPARATOR . $model->icon);
                 }
                 $model->icon = $icon;
                 if (!$model->save()) {
                     @unlink($this->getUploadFolder() . 'titles' . DIRECTORY_SEPARATOR . $model->icon);
                 }
             }
             Messages::get()->success("Title saved!");
             $this->goToAction('titles');
         }
     }
     $this->setPageLayout('title');
     $this->assign('model', $model);
 }
Exemplo n.º 3
0
 /**
  * Creates a new section + default user groups + a single user title. Use "Main" name if you only have one.
  * @param string $name
  * @param int $userId
  * @return int
  */
 public static function createNew($name = "Main", $userId)
 {
     $section = new self();
     $section->name = $name;
     $section->owner_user_id = $userId;
     if (!$section->save()) {
         return false;
     }
     if ("Main" == $name) {
         App::get()->debug("Main section detected. Setting ID to 0!");
         $section->id = 0;
         $section->save();
     }
     App::get()->debug("Section {$name}:  #{$section->id} created!");
     $group = new ForumUserGroup();
     $group->section_id = $section->id;
     $group->full_name = 'Visitors';
     $group->html_class = 'visitors';
     $group->admin = $group->moderator = $group->newthread = $group->threadreply = 0;
     $group->canread = 1;
     $group->save();
     App::get()->debug("Group {$group->full_name}:  #{$group->id} created!");
     $section->default_visitors_group_id = $group->id;
     $group->full_name = "Members";
     $group->html_class = "members";
     $group->newthread = $group->threadreply = 1;
     $group->saveAsNew();
     App::get()->debug("Group {$group->full_name}:  #{$group->id} created!");
     $section->default_members_group_id = $group->id;
     $section->save();
     App::get()->debug("Section updated with default group ids!");
     $group->full_name = "Moderators";
     $group->html_class = "moderators";
     $group->moderator = 1;
     $group->saveAsNew();
     App::get()->debug("Group {$group->full_name}:  #{$group->id} created!");
     $group->full_name = "Admins";
     $group->html_class = "admins";
     $group->admin = 1;
     $group->saveAsNew();
     App::get()->debug("Group {$group->full_name}:  #{$group->id} created!");
     $title = new ForumTitle();
     $title->section_id = $section->id;
     $title->title = "New Comer";
     $title->icon = "default.png";
     $title->description = $title->title;
     $title->save();
     App::get()->debug("Title {$title->title}:  #{$title->id} created!");
     $user = new ForumUser2Section();
     $user->user_id = $userId;
     $user->section_id = $section->id;
     $user->group_id = $group->id;
     $user->title_id = $title->id;
     $user->banned = $user->muted = 0;
     $user->signature = '';
     $user->save();
     App::get()->debug("User #{$userId} assigned to section as admin! (Group: #{$group->id})");
     return $section->id;
 }
Exemplo n.º 4
0
 /**
  * @param int $sectionId
  * @param bool $stringTitleOnly
  * @param bool $idOnly
  * @return ForumTitle|string
  */
 public function getUserTitle($sectionId, $stringTitleOnly = false, $idOnly = false)
 {
     if (WebApp::get()->user()->isGuest()) {
         return $idOnly ? 0 : ($stringTitleOnly ? '' : null);
     }
     if (!isset($this->user2Sections[$sectionId])) {
         return $idOnly ? 0 : ($stringTitleOnly ? '' : null);
     }
     if ($stringTitleOnly) {
         return $this->user2Sections[$sectionId]['title_string'];
     } elseif ($idOnly) {
         return $this->user2Sections[$sectionId]['title_id'];
     }
     if (!isset($this->forumTitles[$this->user2Sections[$sectionId]['title_id']])) {
         $this->forumTitles[$this->user2Sections[$sectionId]['title_id']] = ForumTitle::findByPk($this->user2Sections[$sectionId]['title_id']);
     }
     return $this->forumTitles[$this->user2Sections[$sectionId]['title_id']];
 }