Example #1
0
    <input type="submit" name="changedefaultvisitorsgroup" value="Update"/>
    <?php 
echo \mpf\web\helpers\Form::get()->closeForm();
?>
</div>
<div class="forum-default-group-line">
    <span>Default Members Group:</span>
    <a href="#"><?php 
echo \mpf\modules\forum\models\ForumSection::findByPk($this->sectionId)->defaultMembersGroup->full_name;
?>
</a>
    <?php 
echo \mpf\web\helpers\Form::get()->openForm(['method' => 'post', 'style' => 'display:none;']);
?>
    <?php 
echo \mpf\web\helpers\Form::get()->select('group', \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\forum\models\ForumUserGroup::findAllByAttributes(['section_id' => $this->sectionId]), ['id' => 'full_name']));
?>
    <input type="submit" name="changedefaultmembersgroup" value="Update"/>
    <?php 
echo \mpf\web\helpers\Form::get()->closeForm();
?>
</div>


<?php 
\mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider($this->sectionId), 'columns' => ['full_name', 'html_class', 'admin' => ['class' => 'YesNo'], 'moderator' => ['class' => 'YesNo'], 'newthread' => ['class' => 'YesNo'], 'threadreply' => ['class' => 'YesNo'], 'canread' => ['class' => 'YesNo'], ['class' => 'Actions', 'buttons' => ['delete' => ['class' => 'Delete', 'iconSize' => 22, 'url' => $this->getUrlForDatatableAction('delete')], 'edit' => ['class' => 'Edit', 'iconSize' => 22, 'url' => $this->getUrlForDatatableAction('editGroup')]]]]])->display();
?>
<script>
    $(document).ready(function () {
        $('.forum-default-group-line a').click(function () {
            $(this).hide();
Example #2
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>
Example #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;
 }
Example #4
0
 public function actionDelete()
 {
     if (isset($_POST['ForumUserGroup'])) {
         $models = ForumUserGroup::findAllByPk($_POST['ForumUserGroup']);
         foreach ($models as $model) {
             $model->delete();
         }
         Messages::get()->success("Deleted!");
         $this->goBack();
     }
     if (isset($_POST['ForumCategory'])) {
         $models = ForumCategory::findAllByPk($_POST['ForumCategory']);
         foreach ($models as $model) {
             $model->delete();
         }
         Messages::get()->success("Deleted!");
         $this->goBack();
     }
     if (isset($_POST['ForumSubcategory'])) {
         $models = ForumSubcategory::findAllByPk($_POST['ForumSubcategory']);
         foreach ($models as $model) {
             $model->delete();
         }
         Messages::get()->success("Deleted!");
         $this->goBack();
     }
 }
Example #5
0
 /**
  * @param int $sectionId
  * @param int $categoryId
  * @return bool
  */
 public function canRead($sectionId, $categoryId = null)
 {
     if ($this->isSiteAdmin() || $this->isSiteModerator()) {
         return true;
     }
     if ($this->isBanned($sectionId)) {
         return false;
         // can't read if it's banned
     }
     if (isset($this->user2Sections[$sectionId])) {
         $groupId = $this->user2Sections[$sectionId]['group_id'];
         if (is_null($categoryId)) {
             return (bool) $this->user2Sections[$sectionId]['groupRights']['canread'];
         }
     } else {
         if (!isset($this->sections[$sectionId])) {
             $this->sections[$sectionId] = ForumSection::findByPk($sectionId);
         }
         if (!isset($this->sections[$sectionId])) {
             return false;
             // section doesn't exists
         }
         $groupId = $this->sections[$sectionId]->default_visitors_group_id;
     }
     if (is_null($categoryId)) {
         return (bool) ForumUserGroup::findByPk($groupId)->canread;
     }
     $categoryRights = ForumUserGroup::getDb()->table('forum_groups2categories')->where("group_id = :id AND category_id = :cat")->setParams([':id' => $groupId, ':cat' => $categoryId])->first();
     if (!$categoryRights) {
         return (bool) ForumUserGroup::findByPk($groupId)->canread;
     }
     return (bool) $categoryRights['canread'];
 }
 public function updateGroupRights()
 {
     $allGroups = ForumUserGroup::findAllBySection($this->section_id);
     foreach ($this->groupRights as $groupId => $details) {
         $this->getDb()->table('forum_groups2categories')->insert(['group_id' => $groupId, 'category_id' => $this->id, 'admin' => (int) in_array('admin', $details), 'moderator' => (int) in_array('moderator', $details), 'newthread' => (int) in_array('newthread', $details), 'threadreply' => (int) in_array('threadreply', $details), 'canread' => (int) in_array('canread', $details)], ['admin' => (int) in_array('admin', $details), 'moderator' => (int) in_array('moderator', $details), 'newthread' => (int) in_array('newthread', $details), 'threadreply' => (int) in_array('threadreply', $details), 'canread' => (int) in_array('canread', $details)]);
     }
     foreach ($allGroups as $grp) {
         if (!isset($this->groupRights[$grp->id])) {
             $this->getDb()->table('forum_groups2categories')->insert(['group_id' => $grp->id, 'category_id' => $this->id, 'admin' => 0, 'moderator' => 0, 'newthread' => 0, 'threadreply' => 0, 'canread' => 0], ['admin' => 0, 'moderator' => 0, 'newthread' => 0, 'threadreply' => 0, 'canread' => 0]);
         }
     }
 }