/** * Get the forums. Actually its a bit more complex than that * we need to group by the Forum Categories. * * @return ArrayList */ function Forums() { $categoryText = isset($_REQUEST['Category']) ? Convert::raw2xml($_REQUEST['Category']) : null; $holder = $this; if ($this->getShowInCategories()) { return ForumCategory::get()->filter('ForumHolderID', $this->ID)->filterByCallback(function ($category) use($categoryText, $holder) { // Don't include if we've specified a Category, and it doesn't match this one if ($categoryText !== null && $category->Title != $categoryText) { return false; } // Get a list of forums that live under this holder & category $category->CategoryForums = Forum::get()->filter(array('CategoryID' => $category->ID, 'ParentID' => $holder->ID, 'ShowInMenus' => 1))->filterByCallback(function ($forum) { return $forum->canView(); }); return $category->CategoryForums->exists(); }); } else { return Forum::get()->filter(array('ParentID' => $this->ID, 'ShowInMenus' => 1))->filterByCallback(function ($forum) { return $forum->canView(); }); } }
/** * Forum Admin Features form. * Handles the dropdown to select the new forum category and the checkbox for stickyness * * @return Form */ function AdminFormFeatures() { if (!$this->canModerate()) { return; } $id = isset($this->urlParams['ID']) ? $this->urlParams['ID'] : false; $fields = new FieldList(new CheckboxField('IsSticky', _t('Forum.ISSTICKYTHREAD', 'Is this a Sticky Thread?')), new CheckboxField('IsGlobalSticky', _t('Forum.ISGLOBALSTICKY', 'Is this a Global Sticky (shown on all forums)')), new CheckboxField('IsReadOnly', _t('Forum.ISREADONLYTHREAD', 'Is this a Read only Thread?')), new HiddenField("ID", "Thread")); if (($forums = Forum::get()) && $forums->exists()) { $fields->push(new DropdownField("ForumID", _t('Forum.CHANGETHREADFORUM', "Change Thread Forum"), $forums->map('ID', 'Title', 'Select New Category:')), '', null, 'Select New Location:'); } $actions = new FieldList(new FormAction('doAdminFormFeatures', _t('Forum.SAVE', 'Save'))); $form = new Form($this, 'AdminFormFeatures', $fields, $actions); // need this id wrapper since the form method is called on save as // well and needs to return a valid form object if ($id) { $thread = ForumThread::get()->byID($id); $form->loadDataFrom($thread); } return $form; }