public function actionIndex($id, $level, $currentPage = 1) { $models = ['', 'ForumReply', 'ForumReplySecond', 'ForumReplyThird', 'ForumReplyForth', 'ForumReplyFifth', 'ForumReplySixth', 'ForumReplySeventh', 'ForumReplyEighth', 'ForumReplyNth', 'ForumReplyNth', 'ForumReplyNth', 'ForumReplyNth', 'ForumReplyNth', 'ForumReplyNth', 'ForumReplyNth', 'ForumReplyNth', 'ForumReplyNth', 'ForumReplyNth']; $model = "\\mpf\\modules\\forum\\models\\" . $models[$level]; /* @var $model \mpf\modules\forum\models\ForumReply */ $with = []; for ($i = 0; $i <= Config::value('FORUM_MAX_REPLY_LEVELS') - $level; $i++) { foreach (['author', 'editor', 'authorGroup', 'sectionAuthor', 'sectionAuthor.title', 'replies', 'myVote'] as $child) { $with[] = str_repeat('replies.', $i) . $child; } } $entry = $model::findByPk($id, ['with' => $with]); /* @var $entry \mpf\modules\forum\models\ForumReply */ $this->assign("reply", $entry); $this->assign("thread", $entry->thread); $this->assign("subcategory", $entry->thread->subcategory); $this->assign("currentPage", $currentPage); }
public static function notifyUser($type, $url, $vars, $user = null) { $originalType = $type; $type = Config::value('FORUM_NOTIFICATIONS_TYPES_PREFIX') . $type; if (!Type::findByName($type, true)) { $typeModel = new Type(); $typeModel->name = $type; $typeModel->description = "Automatically generated by the forum module! Can be edited to change the messages sent."; $typeModel->email = self::getDefaultEmailForType($originalType); $typeModel->sms = $typeModel->web = $typeModel->mobile = self::getDefaultMessageForType($originalType); $typeModel->save(); } return Notifications::add($type, $url, $vars, $user ?: WebApp::get()->user()->id); }
<?php /* @var $this \mpf\modules\forum\controllers\Home */ /* @var $categories \mpf\modules\forum\models\ForumCategory[] */ /* @var $threads \mpf\modules\forum\models\ForumThread[] */ $menu = []; if (\mpf\modules\forum\components\UserAccess::get()->isSectionAdmin($this->sectionId)) { ?> <?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']), \mpf\modules\forum\components\Translator::get()->translate($this->forumTitle)) . " " . \mpf\modules\forum\components\Config::value("FORUM_PAGE_TITLE_SEPARATOR") . " " . \mpf\modules\forum\components\Translator::get()->translate("Recent Threads"), $menu); ?> <div class="forum-page <?php echo $this->forumPageTheme; ?> "> <?php $this->displayComponent('searchbar'); ?> <?php $this->displayComponent('topuserpanel'); ?> <?php if (!\mpf\modules\forum\components\UserAccess::get()->canRead($this->sectionId)) { ?> <?php $this->displayComponent('accessdenied', ['location' => 'section']); ?> <?php
<?php /* @var $this \mpf\modules\forum\controllers\Manage */ /* @var $model \mpf\modules\forum\models\ForumSubcategory */ /* @var $category \mpf\modules\forum\models\ForumCategory */ 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') . " " . $category->name . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " Subcategories", [['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', ['category' => $category->id]]), 'label' => 'New Subcategory']]); \mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider($category->id), 'columns' => ['title', 'user_id' => ['value' => '$row->owner->name'], 'description', ['class' => 'Actions', 'buttons' => ['delete' => ['class' => 'Delete', 'iconSize' => 22, 'url' => $this->getUrlForDatatableAction('delete')], 'edit' => ['class' => 'Edit', 'iconSize' => 22, 'url' => $this->getUrlForDatatableAction('editSubcategory')]]]]])->display();
public function getUrlForDatatableAction($action, $params = [], $controller = null, $key = 'id', $column = 'id') { $controller = is_null($controller) ? "\\mpf\\WebApp::get()->request()->getController()" : "'{$controller}'"; if ($this->sectionId && 'get' == Config::value('FORUM_SECTION_ID_SOURCE')) { $params[Config::value('FORUM_SECTION_ID_KEY')] = $this->sectionId; } $prms = ["\"{$key}\" => \$row->{$column}"]; foreach ($params as $name => $value) { $prms[] = "\"{$name}\" => '{$value}'"; } $prms = implode(", ", $prms); return "\\mpf\\WebApp::get()->request()->createURL({$controller}, '{$action}', [{$prms}])"; }
<?php /* @var $model \mpf\modules\forum\models\ForumReply */ /* @var $this \mpf\modules\forum\controllers\Home */ ?> <?php echo \mpf\widgets\form\Form::get(['name' => isset($name) ? $name : 'reply', 'model' => $model, 'theme' => 'default-wide', 'action' => $model->isNewRecord() ? $this->updateURLWithSection(['thread', 'reply']) : null, 'hiddenInputs' => ['parent' => isset($parent) ? $parent : 0, 'level' => isset($level) ? $level : 1, 'thread_id' => $model->thread_id], 'fields' => [['name' => 'content', 'type' => \mpf\modules\forum\components\Config::value("FORUM_REPLY_INPUT_TYPE"), 'htmlOptions' => ['style' => 'min-height: ' . (isset($height) ? $height : '150px;')]]], 'links' => isset($cancel) ? 'main' === $cancel ? ['Cancel' => ['href' => '#', 'onclick' => 'return hideThreadReplyForm();']] : ['Cancel' => ['href' => '#', 'onclick' => 'return hideReplyForm(this.parentNode.parentNode);']] : []])->display();
<?php /* @var $this \mpf\modules\forum\controllers\Manage */ /* @var $model \mpf\modules\forum\models\ForumUserGroup */ 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') . " User Groups " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " " . ($model->isNewRecord() ? 'New Group' : 'Edit ' . $model->full_name), [['url' => ['manage', 'groups'], 'label' => 'Manage Groups'], ['url' => ['manage', 'categories'], 'label' => 'Manage Categories'], ['url' => $this->updateURLWithSection(['manage', 'users']), 'label' => 'Manage Users'], ['url' => $this->updateURLWithSection(['manage', 'titles']), 'label' => 'Manage Titles'], ['url' => ['manage', 'newGroup'], 'label' => 'New Group', 'htmlOptions' => $model->isNewRecord() ? ['class' => 'selected'] : []]]); echo \mpf\widgets\form\Form::get(['model' => $model, 'name' => 'save', 'theme' => 'default-wide', 'fields' => ['full_name', 'html_class', ['name' => 'admin', 'type' => 'radio', 'options' => ['No', 'Yes']], ['name' => 'moderator', 'type' => 'radio', 'options' => ['No', 'Yes']], ['name' => 'newthread', 'type' => 'radio', 'options' => ['No', 'Yes']], ['name' => 'threadreply', 'type' => 'radio', 'options' => ['No', 'Yes']], ['name' => 'canread', 'type' => 'radio', 'options' => ['No', 'Yes']]]])->display();
<?php /* @var $this \mpf\modules\forum\controllers\Manage */ /* @var $model \mpf\modules\forum\models\ForumTitle */ 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') . " Users", \mpf\modules\forum\components\UserAccess::get()->isSectionAdmin($this->sectionId) ? [['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', 'htmlOptions' => ['class' => 'selected']], ['url' => $this->updateURLWithSection(['manage', 'newTitle']), 'label' => 'New Title']] : [['url' => $this->updateURLWithSection(['manage', 'users']), 'label' => 'Manage Users'], ['url' => $this->updateURLWithSection(['manage', 'titles']), 'label' => 'Manage Titles', 'htmlOptions' => ['class' => 'selected']]]); \mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider($this->sectionId), 'columns' => ['id', 'title', ['class' => 'Actions', 'buttons' => ['delete' => ['class' => 'Delete', 'url' => $this->getUrlForDatatableAction('delete')], 'edit' => ['class' => 'Edit', 'url' => $this->getUrlForDatatableAction('editTitle')]]]]])->display();
/** * @return array */ public function getLink($module = null) { $s = $this->section_id; $r = ['thread', 'index', ['subcategory' => $this->subcategory->url_friendly_title, 'category' => $this->subcategory->category->url_friendly_name, 'id' => $this->id], $module]; if (!$s) { return $r; } if ('get' != Config::value('FORUM_SECTION_ID_SOURCE')) { return $r; } if (isset($r[2]) && is_array($r[2])) { $r[2][Config::value('FORUM_SECTION_ID_KEY')] = $s; } elseif (isset($r[2])) { $r[3] = $r[2]; $r[2] = [Config::value('FORUM_SECTION_ID_KEY') => $s]; } else { $r[2] = [Config::value('FORUM_SECTION_ID_KEY') => $s]; } return $r; }
<?php /* @var $this \mpf\modules\forum\controllers\Home */ /* @var $model \mpf\modules\forum\models\ForumUser2Section */ $menu = []; if (\mpf\modules\forum\components\UserAccess::get()->isSectionAdmin($this->sectionId)) { ?> <?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 }
/** * Moved user profile to config; * @param array $htmlOptions * @return string */ public function getEditorProfileLink($htmlOptions = []) { return Config::get()->getProfileLink($this->edit_user_id, $this->editor->name, $htmlOptions); }
<?php /* @var $this \mpf\modules\forum\components\Controller */ /* @var $model \mpf\modules\forum\models\ForumThread */ 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') . " " . \mpf\web\helpers\Html::get()->link($this->updateURLWithSection(['category', 'index', ['category' => $model->subcategory->category->url_friendly_name, 'id' => $model->subcategory->category_id]]), $model->subcategory->category->name) . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " " . \mpf\web\helpers\Html::get()->link($this->updateURLWithSection(['subcategory', 'index', ['category' => $model->subcategory->category->url_friendly_name, 'subcategory' => $model->subcategory->url_friendly_title, 'id' => $model->subcategory->category_id]]), $model->subcategory->title) . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " " . \mpf\web\helpers\Html::get()->link($this->updateURLWithSection(['thread', 'index', ['category' => $model->subcategory->category->url_friendly_name, 'subcategory' => $model->subcategory->url_friendly_title, 'id' => $model->id]]), $model->title) . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " " . \mpf\modules\forum\components\Translator::get()->translate("Edit post")); ?> <div class="forum-page <?php echo $this->forumPageTheme; ?> "> <?php $this->displayComponent('topuserpanel'); ?> <?php echo \mpf\widgets\form\Form::get(['model' => $model, 'name' => 'save', 'theme' => 'default-wide', 'fields' => ['title', ['name' => 'content', 'type' => \mpf\modules\forum\components\Config::value("FORUM_REPLY_INPUT_TYPE"), 'htmlOptions' => ['style' => 'min-height: 250px;']], ['name' => 'keywords', 'type' => 'seoKeywords']], 'buttons' => [['name' => 'preview', 'label' => 'Preview'], ['name' => 'sticky', 'label' => 'Save as Sticky', 'visible' => \mpf\modules\forum\components\UserAccess::get()->isCategoryModerator($model->subcategory->category_id, $this->sectionId)]]])->display(); ?> </div>
<?php if (!$reply->deleted && \mpf\modules\forum\components\Config::value('FORUM_MAX_REPLY_LEVELS') != $level && \mpf\modules\forum\components\UserAccess::get()->canReplyToThread($subcategory->category_id, $this->sectionId)) { ?> <div class="forum-thread-reply-actions"> <?php echo \mpf\web\helpers\Html::get()->link('#reply-for-' . $level . '-' . $subReply->id, \mpf\modules\forum\components\Translator::get()->translate('Reply'), ['class' => 'new-reply-button reply-to-existing-reply']); ?> </div> <?php } ?> <?php if ($subReply->sectionAuthor->getSignature()) { ?> <?php echo \mpf\modules\forum\components\Config::value('FORUM_THREAD_SIGNATURE_SEPARATOR'); ?> <?php echo $subReply->sectionAuthor->getSignature(); ?> <?php } ?> <?php $this->display("_replies", ['reply' => $subReply, 'level' => $level + 1]); ?> </td> </tr> <?php } ?>
/** * Moved user profile to config; * @param array $htmlOptions * @return string */ public function getLastActiveProfileLink($htmlOptions = []) { return Config::get()->getProfileLink($this->last_active_user_id, $this->lastActiveUser->name, $htmlOptions); }
?> <?php $this->display("_replies", ['reply' => $reply, 'level' => 2]); ?> </td> </tr> <tr class="forum-between-replies"> <td colspan="2"><span> </span></td> </tr> <?php } ?> </table> <?php $this->displayComponent("pagelist", ['elementsName' => \mpf\modules\forum\components\Translator::get()->translate('replies'), 'totalElements' => $thread->first_level_replies . ' ( ' . $thread->replies . ' )', 'visibleElements' => count($replies), 'totalPages' => (int) ($thread->first_level_replies / \mpf\modules\forum\components\Config::value('FORUM_REPLIES_PER_PAGE') + ($thread->first_level_replies % \mpf\modules\forum\components\Config::value('FORUM_REPLIES_PER_PAGE') ? 1 : 0)), 'currentPage' => $currentPage]); ?> </div> <script> $(document).ready(function () { $('.reply-to-existing-reply').each(function () { var className = $(this).attr('href').substring(11); $(this).click(function (e) { $('.forum-subreply-' + className).show(); var _self = $('.forum-subreply-' + className, this.parentNode.parentNode); setTimeout(function () { $('textarea', _self).focus(); }, 200); e.preventDefault();
<?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') . " Control Panel", $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 echo \mpf\widgets\form\Form::get(['name' => 'save', 'model' => $model, 'theme' => 'default-wide', 'formHtmlOptions' => ['enctype' => 'multipart/form-data'], 'fields' => \mpf\modules\forum\components\Config::value('FORUM_HANDLE_USER_ICON') ? [['name' => 'signature', 'type' => 'markdown', 'htmlOptions' => ['style' => 'min-height: 200px;']], ['name' => 'icon', 'type' => 'image', 'urlPrefix' => $model->getIconLocationURL()]] : [['name' => 'signature', 'type' => 'markdown', 'htmlOptions' => ['style' => 'min-height: 200px;']]]])->display(); ?> </div>
echo $thread->getLastActiveProfileLink(); ?> <span><?php echo \mpf\helpers\DateTimeHelper::get()->niceDate($thread->last_reply_date, false, false); ?> </span> <?php } else { ?> <span class="thread-no-replies-message"> <?php echo \mpf\modules\forum\components\Translator::get()->translate("no replies"); ?> </span> <?php } ?> </td> </tr> <?php } ?> <?php } ?> </table> <?php $this->displayComponent("pagelist", ['elementsName' => \mpf\modules\forum\components\Translator::get()->translate('threads'), 'totalElements' => $numberOfThreads, 'visibleElements' => count($threads), 'totalPages' => (int) ($numberOfThreads / \mpf\modules\forum\components\Config::value('FORUM_THREADS_PER_PAGE') + ($numberOfThreads % \mpf\modules\forum\components\Config::value('FORUM_THREADS_PER_PAGE') ? 1 : 0)), 'currentPage' => $currentPage]); ?> </div>
<?php /* @var $this \mpf\modules\forum\components\Controller */ /* @var $model \mpf\modules\forum\models\ForumThread */ 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') . " " . \mpf\web\helpers\Html::get()->link($this->updateURLWithSection(['category', 'index', ['category' => $model->subcategory->category->url_friendly_name, 'id' => $model->subcategory->category_id]]), $model->subcategory->category->name) . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " " . \mpf\web\helpers\Html::get()->link($this->updateURLWithSection(['subcategory', 'index', ['category' => $model->subcategory->category->url_friendly_name, 'subcategory' => $model->subcategory->url_friendly_title, 'id' => $model->subcategory->category_id]]), $model->subcategory->title) . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " " . \mpf\web\helpers\Html::get()->link($this->updateURLWithSection(['thread', 'index', ['category' => $model->subcategory->category->url_friendly_name, 'subcategory' => $model->subcategory->url_friendly_title, 'id' => $model->id]]), $model->title) . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " " . \mpf\modules\forum\components\Translator::get()->translate("Move post")); ?> <div class="forum-page <?php echo $this->forumPageTheme; ?> "> <?php $this->displayComponent('searchbar'); ?> <?php $this->displayComponent('topuserpanel'); ?> <?php echo \mpf\widgets\form\Form::get(['name' => 'move', 'model' => $model, 'theme' => 'default-wide', 'fields' => [['name' => 'subcategory_id', 'type' => 'select', 'options' => \mpf\modules\forum\models\ForumSubcategory::getAllForSelectTree($this->sectionId)]]])->display(); ?> </div>
public function changeIcon() { if (!isset($_FILES['icon']) || !$_FILES['icon']['tmp_name']) { return null; } if (!FileHelper::get()->isImage($_FILES['icon']['tmp_name'])) { return false; } if ($this->iconUploadHandle) { $function = $this->iconUploadHandle; return $function('icon'); } $name = $this->user_id . substr($_FILES['icon']['name'], -30); FileHelper::get()->upload('icon', $this->getIconLocationPath() . $name); $column = Config::value('USER_ICON_COLUMN_NAME'); $old = $this->user->{$column}; if ($old && 'default.png' != $old && $name != $old) { @unlink($old); } $this->user->{$column} = $name; $this->user->save(); }