public function run() { ForumGroup::create(array('title' => 'Group 1', 'author_id' => 1)); ForumCategory::create(array('title' => 'Group 2', 'group_id' => 1, 'author_id' => 1)); ForumCategory::create(array('title' => 'Group 3', 'group_id' => 1, 'author_id' => 1)); DB::table('users')->insert(['username' => 'admin', 'password' => Hash::make('admin'), 'isAdmin' => 1]); }
_admin/modules_forum_category/view/">Forum Category</a></li> </ul> </div> <? $forum = Forum::findForum($_REQUEST['id']); ?> <form id="store_page" action="" method="post" enctype="multipart/form-data"> <h3>ACM Forum</h3> <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span> <fieldset style="width:1065px;"> <legend>Forum Panel</legend> <ul> <li> <label for="title">Main Category</label> <select name="category_id"> <option value="0">no main category</option> <? $category= ForumCategory::displayAll(0); foreach($category as $categories) { if($forum->fldForumCategoryID == $categories->fldForumCategoryID) { $selected = "selected='selected'"; } else { $selected = ""; } ?> <option value="<?php echo $categories->fldForumCategoryID; ?> " <?php echo $selected; ?> ><?php echo $categories->fldForumCategoryTitle;
public function get_root_category() { $root = new ForumCategory(); $root->set_authorizations(ForumConfig::load()->get_authorizations()); return $root; }
public function run() { ForumGroup::create(array('title' => 'General Discussion', 'author_id' => 1)); ForumCategory::create(array('group_id' => 1, 'title' => 'Test Category 1', 'author_id' => 1)); ForumCategory::create(array('group_id' => 1, 'title' => 'Test Category 2', 'author_id' => 1)); }
/** * Exclude object from result * * @param ForumCategory $forumCategory Object to remove from the list of results * * @return ForumCategoryQuery The current query, for fluid interface */ public function prune($forumCategory = null) { if ($forumCategory) { $this->addUsingAlias(ForumCategoryPeer::CAT_ID, $forumCategory->getCatId(), Criteria::NOT_EQUAL); } return $this; }
/** * 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(); }); } }
public function deleteForumCategory() { $id = Input::get("delete_id"); ForumCategory::find($id)->delete(); Cache::flush(); return Redirect::to('/dashboard/storyteller/manage/forums/categories'); }
if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } else { $id = 0; } $count_record = ForumCategory::countForumCategory($id); if (!isset($_REQUEST['page'])) { $page = 1; } else { $page = $_GET[page]; } $pagination = new Pagination(); //for display $pg = $pagination->page_pagination(20, $count_record, $page, 20); //$result_prod = mysql_query($query_Recordset2.$pg[1]); $category = ForumCategory::findAll($pg[1], $id); ?> <? if($count_record == 0) { ?> <tr> <td colspan="3" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#F00; font-weight:bold">No Record Found</td> </tr> <? } else { foreach($category as $categories) { ?> <tr> <td> <?php echo $categories->fldForumCategoryID; ?> </td>
foreach($forum as $forums) { ?> <tr> <td> <?php echo $forums->fldForumID; ?> </td> <td><?php echo $forums->fldForumTitle; ?> </td> <td> <? $category = ForumCategory::findForumCategory($forums->fldForumCategoryID); echo $category->fldForumCategoryTitle; ?> </td> <td><?php echo $forums->fldForumClientName; ?> </td> <td align="center"> <a href="<?php echo $ROOT_URL; ?> _admin/modules_forum/edit/<?php echo $forums->fldForumID; ?>
private function create_forum_cats_table() { ForumCategory::create_categories_table(self::$forum_cats_table); }
/** * Set ForumCategory this forum belongs to by object * * @param ForumCategory $c */ public function setCategory(ForumCategory $c) { $this->category = $c; $this->categoryID = $c->getID(); }
public static function deleteCategory(ForumCategory $c) { global $db; $db->query("\n\t\t\t\tDELETE FROM " . TABLE_FORUM_CATEGORIES . "\n\t\t\t\tWHERE id = ?\n\t\t\t", array($c->getID())); }
<div class="row left"> @if($mode == "management") <h2>Forum Management</h2> <a href="/dashboard/storyteller/manage/forums/new"> <button class="button small right"> <i class="icon-plus"></i> New Forum </button> </a> <p> Note: Trashed forums are recoverable; they're flagged as hidden. </p> <?php $categories = ForumCategory::orderBy('display_order')->get(); $categories->add((object) ['name' => "Trashed", 'id' => 0]); $categories->add((object) ['name' => 'Unassociated', 'id' => 0]); ?> @foreach($categories as $category) <h4>{{$category->name}}</h4> <table class="responsive"> <thead> <th style="width: 90px">Actions</th> <th>Forum Name</th> <th>Sect Restriction</th> <th>Clan Restriction</th> <th>Background Restriction</th> <th>Read Permission</th> <th>Create Topic Permission</th> <th>Reply Permission</th>
/** * Add default records to database * * This function is called whenever the database is built, after the * database tables have all been created. */ public function requireDefaultRecords() { parent::requireDefaultRecords(); $code = "ACCESS_FORUM"; if (!($forumGroup = DataObject::get_one("Group", "\"Group\".\"Code\" = 'forum-members'"))) { $group = new Group(); $group->Code = 'forum-members'; $group->Title = "Forum Members"; $group->write(); Permission::grant($group->ID, $code); DB::alteration_message(_t('Forum.GROUPCREATED', 'Forum Members group created'), "created"); } else { if (DB::query("SELECT * FROM \"Permission\" WHERE \"GroupID\" = '{$forumGroup->ID}' AND \"Code\" LIKE '{$code}'")->numRecords() == 0) { Permission::grant($forumGroup->ID, $code); } } if (!($category = DataObject::get_one("ForumCategory"))) { $category = new ForumCategory(); $category->Title = _t('Forum.DEFAULTCATEGORY', 'General'); $category->write(); } if (!DataObject::get_one("ForumHolder")) { $forumholder = new ForumHolder(); $forumholder->Title = "Forums"; $forumholder->URLSegment = "forums"; $forumholder->Content = "<p>" . _t('Forum.WELCOMEFORUMHOLDER', 'Welcome to SilverStripe Forum Module! This is the default ForumHolder page. You can now add forums.') . "</p>"; $forumholder->Status = "Published"; $forumholder->write(); $forumholder->publish("Stage", "Live"); DB::alteration_message(_t('Forum.FORUMHOLDERCREATED', 'ForumHolder page created'), "created"); $forum = new Forum(); $forum->Title = _t('Forum.TITLE', 'General Discussion'); $forum->URLSegment = "general-discussion"; $forum->ParentID = $forumholder->ID; $forum->Content = "<p>" . _t('Forum.WELCOMEFORUM', 'Welcome to SilverStripe Forum Module! This is the default Forum page. You can now add topics.') . "</p>"; $forum->Status = "Published"; $forum->CategoryID = $category->ID; $forum->write(); $forum->publish("Stage", "Live"); DB::alteration_message(_t('Forum.FORUMCREATED', 'Forum page created'), "created"); } }
public function storeThread($id) { $category = ForumCategory::find($id); if ($category == null) { Redirect::route('forum-get-new-thread')->with('fail', "You posted to an invalid category."); } $validator = Validator::make(Input::all(), array('title' => 'required|min:3|max:255', 'body' => 'required|min:10|max:65000')); if ($validator->fails()) { return Redirect::route('forum-get-new-thread', $id)->withInput()->withErrors($validator)->with('fail', "Your input doesn't match the requirements"); } else { $thread = new ForumThread(); $thread->title = Input::get('title'); $thread->body = Input::get('body'); $thread->category_id = $id; $thread->group_id = $category->group_id; $thread->author_id = Auth::user()->id; if ($thread->save()) { return Redirect::route('forum-thread', $thread->id)->with('success', "Your thread has been saved."); } else { return Redirect::route('forum-get-new-thread', $id)->with('fail', "An error occured while saving your thread.")->withInput(); } } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param ForumCategory $value A ForumCategory object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(ForumCategory $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getCatId(); } // if key === null self::$instances[$key] = $obj; } }
<?php require 'base.php'; $categories = ForumCategory::getAllCategories(); Templates::assign('categories', $categories); PluginHelper::delegate('__onPageDisplay', array($page)); Templates::display('forums');
/** * Returns a FieldList with which to create the CMS editing form * * @return FieldList The fields to be displayed in the CMS. */ function getCMSFields() { Requirements::javascript("forum/javascript/ForumAccess.js"); Requirements::css("forum/css/Forum_CMS.css"); $fields = parent::getCMSFields(); $fields->addFieldToTab("Root.Access", new HeaderField(_t('Forum.ACCESSPOST', 'Who can post to the forum?'), 2)); $fields->addFieldToTab("Root.Access", $optionSetField = new OptionsetField("CanPostType", "", array("Inherit" => "Inherit", "Anyone" => _t('Forum.READANYONE', 'Anyone'), "LoggedInUsers" => _t('Forum.READLOGGEDIN', 'Logged-in users'), "OnlyTheseUsers" => _t('Forum.READLIST', 'Only these people (choose from list)'), "NoOne" => _t('Forum.READNOONE', 'Nobody. Make Forum Read Only')))); $optionSetField->addExtraClass('ForumCanPostTypeSelector'); $fields->addFieldsToTab("Root.Access", array(new TreeMultiselectField("PosterGroups", _t('Forum.GROUPS', "Groups")), new OptionsetField("CanAttachFiles", _t('Forum.ACCESSATTACH', 'Can users attach files?'), array("1" => _t('Forum.YES', 'Yes'), "0" => _t('Forum.NO', 'No'))))); //Dropdown of forum category selection. $categories = ForumCategory::get()->map(); $fields->addFieldsToTab("Root.Main", DropdownField::create('CategoryID', _t('Forum.FORUMCATEGORY', 'Forum Category'), $categories), 'Content'); //GridField Config - only need to attach or detach Moderators with existing Member accounts. $moderatorsConfig = GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldAddExistingAutocompleter('buttons-before-right'))->addComponent(new GridFieldToolbarHeader())->addComponent($sort = new GridFieldSortableHeader())->addComponent($columns = new GridFieldDataColumns())->addComponent(new GridFieldDeleteAction(true))->addComponent(new GridFieldPageCount('toolbar-header-right'))->addComponent($pagination = new GridFieldPaginator()); // Use GridField for Moderator management $moderators = GridField::create('Moderators', _t('MODERATORS', 'Moderators for this forum'), $this->Moderators(), $moderatorsConfig); $columns->setDisplayFields(array('Nickname' => 'Nickname', 'FirstName' => 'First name', 'Surname' => 'Surname', 'Email' => 'Email', 'LastVisited.Long' => 'Last Visit')); $sort->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); $fields->addFieldToTab('Root.Moderators', $moderators); return $fields; }