當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。