当前位置: 首页>>代码示例>>PHP>>正文


PHP Forum::publish方法代码示例

本文整理汇总了PHP中Forum::publish方法的典型用法代码示例。如果您正苦于以下问题:PHP Forum::publish方法的具体用法?PHP Forum::publish怎么用?PHP Forum::publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Forum的用法示例。


在下文中一共展示了Forum::publish方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: requireDefaultRecords

 /**
  * 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");
     }
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:48,代码来源:Forum.php

示例2: requireDefaultRecords

 /**
  * 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 = Group::get()->filter('Code', 'forum-members')->first())) {
         $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 (!Permission::get()->filter(array('GroupID' => $forumGroup->ID, 'Code' => $code))->exists()) {
             Permission::grant($forumGroup->ID, $code);
         }
     }
     if (!($category = ForumCategory::get()->first())) {
         $category = new ForumCategory();
         $category->Title = _t('Forum.DEFAULTCATEGORY', 'General');
         $category->write();
     }
     if (!ForumHolder::get()->exists()) {
         $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");
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-forum,代码行数:48,代码来源:Forum.php


注:本文中的Forum::publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。