<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();
/** * @param ForumUser2Section[] $sections * @param $limit * @param $offset * @param null $sectionId * @return array|static[] */ protected static function _findRecent($sections, $limit, $offset, $sectionId = null) { $guest = false; $sectionsIds = []; if (1 === count($sections) && is_null($sections[0])) { if (is_null($sectionId)) { return []; } $sectionsIds = [$sectionId]; $guest = true; } elseif (count($sections)) { $sectionsIds = ArrayHelper::get()->transform($sections, 'section_id'); } $userId = WebApp::get()->user()->isConnected() ? WebApp::get()->user()->id : 0; $reload = !WebApp::get()->cache()->exists('User:'******':visibleSubcategories'); $ids = []; if (!$reload) { $info = WebApp::get()->cache()->value('User:'******':visibleSubcategories'); if ($info['time'] < time() - 720) { //force refresh once every 30m $reload = true; } else { $ids = $info['categories']; } } if ($reload) { $condition = new ModelCondition(['model' => ForumSubcategory::className()]); $condition->with = ['category']; if ($guest) { $groups = [ForumSection::findByPk($sectionId)->default_visitors_group_id]; } else { $groups = ArrayHelper::get()->transform($sections, 'group_id'); } if ($groups) { $groups = implode(', ', $groups); $condition->join = "LEFT JOIN forum_groups2categories ON (forum_groups2categories.category_id = category.id AND forum_groups2categories.group_id IN ({$groups}))"; $condition->addCondition("forum_groups2categories.canread IS NULL OR forum_groups2categories.canread = 1"); $condition->addInCondition('category.section_id', $sectionsIds); $categories = ForumSubcategory::findAll($condition); } else { $categories = []; } $ids = []; foreach ($categories as $cat) { if (!isset($ids[$cat->category->section_id])) { $ids[$cat->category->section_id] = []; } $ids[$cat->category->section_id][] = $cat->id; } WebApp::get()->cache()->set('User:'******':visibleSubcategories', ['time' => time(), 'categories' => $ids]); } $finalIDs = []; if ($guest) { $finalIDs = $ids[$sectionId]; } else { foreach ($sections as $s) { if (isset($ids[$s->section_id])) { foreach ($ids[$s->section_id] as $id) { $finalIDs[] = $id; } } } } if (!$finalIDs) { return []; } $condition = new ModelCondition(['model' => __CLASS__]); $condition->with = ['category', 'subcategory', 'lastActiveUser', 'owner']; $condition->addInCondition('subcategory_id', $finalIDs); $condition->compareColumn('deleted', 0); $condition->order = "GREATEST(IFNULL(t.edit_time, t.create_time), IFNULL(t.last_reply_date, t.create_time)) DESC"; $condition->limit = $limit; $condition->offset = $offset; return self::findAll($condition); }
?> <?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>
<?php /* @var $this \mpf\modules\forum\controllers\Manage */ /* @var $model \mpf\modules\forum\models\ForumSubcategory */ 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') . " New subcategory", [['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'], ['url' => $this->updateURLWithSection(['manage', 'newCategory']), 'label' => 'New Category'], ['url' => $this->updateURLWithSection(['manage', 'newSubcategory']), 'label' => 'New Subcategory', 'htmlOptions' => $model->isNewRecord() ? ['class' => 'selected'] : []]]); echo \mpf\widgets\form\Form::get(['name' => 'save', 'model' => $model, 'theme' => 'default-wide', 'formHtmlOptions' => ['enctype' => 'multipart/form-data'], 'fields' => ['title', 'url_friendly_title', 'description', ['name' => 'category_id', 'type' => 'select', 'options' => \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\forum\models\ForumCategory::findAllBySection($this->sectionId), ['id' => 'name'])], ['name' => 'icon', 'type' => 'image', 'urlPrefix' => $this->getUploadUrl() . 'subcategories/']]])->display();
/** * @param User $user * @param string $source * @param boolean $rememberMe * @return boolean */ protected function checkUserLogin(User $user, $source, $rememberMe) { if ($user->status == User::STATUS_NEW) { if (is_null($user->lastconfirmationmail_date) || $user->lastconfirmationmail_date < date('Y-m-d H:i:s', strtotime('-5 minutes'))) { // if confirmation email was older than 5 minutes then allow it to resend it User::$allowConfirmationEmailResend = true; if (isset($_POST['resend'])) { $user->resendConfirmationEmail(); } } if (!isset($_POST['resend'])) { Messages::get()->error('Email address was not yet confirmed! Check your emails and access received link to activate the account!'); } return false; } if ($user->status == User::STATUS_BLOCKED) { Messages::get()->error('This account has been banned! Please contact an admin if you think this is a mistake!'); return false; } if ($user->status == User::STATUS_DELETED) { Messages::get()->error('This account has been recently deleted! If you want to recover it please contact an admin. An account is permanently removed ' . User::DELETE_ACCOUNT_AFTER_X_DAYS . ' days after it was deleted!'); return false; } $this->connected = true; $this->setState('id', $user->id); $this->setState('name', $user->name); $this->setState('email', $user->email); $this->setState('icon', $user->icon ?: 'default.png'); $this->setState('status', $user->status); $this->setState('title', $user->title ? $user->title->title : '- no title -'); if ($user->joinuser_id) { $all = User::findAllByAttributes(['joinuser_id' => $user->joinuser_id]); $this->setState('mergedIDs', ArrayHelper::get()->transform($all, 'id')); } $this->setRights($groups = $user->getGroupsList()); $this->debug("Saved groups: " . implode(", ", $groups)); $user->last_login = date('Y-m-d H:i:s'); $user->last_login_source = $source; $user->save(); if ($rememberMe) { Cookie::get()->set(App::get()->shortName . $this->cookieKey, $user->email, $this->cookieTimeout); } if (!trim($user->name)) { // fill last details if they were not already saved $this->debug('need auto register'); WebApp::get()->request()->setController('user'); WebApp::get()->request()->setAction('registerauto'); } return true; }
<?php require_once dirname(dirname(__DIR__)) . '/layout/header.php'; echo \mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider(), 'columns' => ['url', 'author_id' => ['filter' => \mpf\helpers\ArrayHelper::get()->transform(\app\models\User::findAll(), ['id' => 'name']), 'value' => function (\mpf\modules\blog\models\BlogPost $model) { return $model->author->name; }], 'category_id' => ['filter' => \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\blog\models\BlogCategory::findAll(), ['id' => 'name']), 'value' => function (\mpf\modules\blog\models\BlogPost $model) { return $model->category->name; }], 'time_written' => ['class' => 'Date'], 'time_published' => ['class' => 'Date'], 'status' => ['filter' => \mpf\modules\blog\models\BlogPost::getStatuses(), 'value' => function (\mpf\modules\blog\models\BlogPost $model) { $all = \mpf\modules\blog\models\BlogPost::getStatuses(); return $all[$model->status]; }], ['class' => 'Actions', 'buttons' => ['delete' => ['class' => 'Delete'], 'edit' => ['class' => 'Edit'], 'publish' => ['post' => ['{{modelKey}}' => '$row->id'], 'confirmation' => \app\components\htmltools\Translator::get()->t("Are you sure that you want to publish the article?"), 'title' => '"Publish Article"', 'url' => "\\mpf\\WebApp::get()->request()->createURL('articles', 'publish')", 'icon' => '%MPF_ASSETS%images/oxygen/%SIZE%/actions/view-task.png', 'visible' => "\$row->status != " . \mpf\modules\blog\models\BlogPost::STATUS_PUBLISHED]], 'headerHtmlOptions' => ['style' => 'width:60px;']]]])->display(); require_once dirname(dirname(__DIR__)) . '/layout/footer.php';
/** * @return string[] */ public static function getFormFields() { $f = ['url', ['name' => 'allow_comments', 'type' => 'checkbox'], ['name' => 'category_id', 'type' => 'select', 'options' => ArrayHelper::get()->transform(BlogCategory::findAll(), ['id' => 'name'])], ['name' => 'image_icon', 'type' => 'image', 'urlPrefix' => BlogConfig::get()->articleImageURL], ['name' => 'image_cover', 'type' => 'image', 'urlPrefix' => BlogConfig::get()->articleImageURL], ['name' => 'keywords', 'type' => 'seoKeywords'], ['name' => 'visibility', 'type' => 'select', 'options' => BlogConfig::get()->visibilityOptions], ['name' => 'anonimous', 'type' => 'checkbox']]; foreach (BlogConfig::get()->languages as $lang) { $f[] = 'title[' . $lang . ']'; $f[] = ['name' => 'content[' . $lang . ']', 'type' => 'markdown']; } return $f; }
public function actionUsers() { foreach (['muted', 'banned', 'group_id', 'title_id'] as $field) { if (isset($_POST[$field])) { ForumUser2Section::update($_POST['id'], [$field => $_POST[$field]]); Messages::get()->success("User saved!"); $this->goBack(); } } $model = ForumUser2Section::model(); $model->section_id = $this->sectionId; if (isset($_GET['ForumUser2Section'])) { $model->setAttributes($_GET['ForumUser2Section']); } $this->assign('model', $model); $this->assign('groups', ArrayHelper::get()->transform(ForumUserGroup::findAllBySection($this->sectionId), ['id' => 'full_name'])); $this->assign('titles', ArrayHelper::get()->transform(ForumTitle::findAll(), ['id' => 'title'])); }
/** * Returns list of user_groups.name to be used by ActiveUser (or any other class that needs it. * @return array */ public function getGroupsList() { return ArrayHelper::get()->transform($this->groups, 'name'); }
<?php $actions = array('index' => 'View All', 'create' => 'New User'); $menu = array(); foreach ($actions as $action => $label) { $menu[] = array('url' => array('users', $action), 'label' => $label, 'htmlOptions' => $action == $this->getActiveAction() ? array('class' => 'selected') : array()); } echo \app\components\htmltools\Page::title('Users - Edit', $menu); echo \mpf\widgets\form\Form::get(array('name' => 'save', 'model' => $model, 'theme' => 'default-wide', 'fields' => array('name', 'email', array('name' => 'title_id', 'type' => 'select', 'options' => \mpf\helpers\ArrayHelper::get()->transform(\app\models\UserTitle::findAll(), array('id' => 'title'))), array('name' => 'status', 'type' => 'radio', 'options' => array(\app\models\User::STATUS_ACTIVE => 'Active', \app\models\User::STATUS_BLOCKED => 'Blocked')), array('name' => 'groupIDs', 'type' => 'checkbox', 'options' => \mpf\helpers\ArrayHelper::get()->transform(\app\models\UserGroup::findAll(), array('id' => 'label'))))))->display();
<?php require_once dirname(dirname(__DIR__)) . '/layout/header.php'; echo \mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider(), 'columns' => ['name', 'added_by' => ['filter' => \mpf\helpers\ArrayHelper::get()->transform(\app\models\User::findAll(), ['id' => 'name']), 'value' => function (\mpf\modules\blog\models\BlogCategory $model) { return $model->user->name; }], 'added_time' => ['class' => 'Date'], ['class' => 'Actions', 'buttons' => ['delete' => ['class' => 'Delete'], 'edit' => ['class' => 'Edit']], 'headerHtmlOptions' => ['style' => 'width:60px;'], 'topButtons' => ['add' => ['class' => 'Add']]]]])->display(); require_once dirname(dirname(__DIR__)) . '/layout/footer.php'; ?>
/** * @param int $sectionId * @param bool $forPublic * @return static[] */ public static function findAllBySection($sectionId, $forPublic = false) { if (!$forPublic) { return self::findAllByAttributes(['section_id' => $sectionId], ['order' => '`order` ASC']); } if (!UserAccess::get()->canRead($sectionId)) { return []; } $condition = new ModelCondition(['model' => __CLASS__]); $condition->join = "LEFT JOIN forum_groups2categories ON (category_id = id AND group_id = :group)"; $condition->addCondition("canread IS NULL OR canread = 1"); $condition->setParam(":group", UserAccess::get()->getUserGroup($sectionId, true)); $condition->order = "`order` ASC"; $condition->with = ['subcategories', 'subcategories.lastActiveThread', 'subcategories.lastActiveUser']; $condition->compareColumn("section_id", $sectionId); $categories = self::findAll($condition); if (WebApp::get()->user()->isConnected()) { $subcategories = self::getDb()->table('forum_userhiddensubcategories')->where("user_id = :user")->setParam(":user", WebApp::get()->user()->id)->get(); $subcategories = ArrayHelper::get()->transform($subcategories, "subcategory_id"); foreach ($categories as $category) { if ($category->subcategories) { foreach ($category->subcategories as $subcategory) { if (in_array($subcategory->id, $subcategories)) { $subcategory->hidden = true; } } } } } return $categories; }