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


PHP forum::get_course_id方法代码示例

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


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

示例1: display_intro

 /**
  * Display intro section for forum.
  * @param forum $forum Forum
  * @return string Intro HTML or '' if none
  */
 public function display_intro($forum)
 {
     $text = $forum->get_intro();
     if (trim($text) === '') {
         return '';
     }
     $options = (object) array('trusttext' => true);
     return '<div class="forumng-intro">' . format_text($text, FORMAT_HTML, $options, $forum->get_course_id()) . '</div>';
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:14,代码来源:forum_type.php

示例2: copy

 /**
  * Copy the discussion and its  posts to another forum and/or group.
  * @param forum $targetforum Forum to copy the discussion to
  * @param int $groupid If 'All participants' has been selected from the
  *   Separate groups dropdown box, use default value 0
  */
 function copy($targetforum, $groupid)
 {
     global $SESSION, $CFG;
     $oldforum = $this->get_forum();
     $oldforumid = $oldforum->get_id();
     $oldcourseid = $oldforum->get_course_id();
     $targetforumid = $targetforum->get_id();
     $targetcourseid = $targetforum->get_course_id();
     //Clone the old discussion
     $discussionobj = clone $this->discussionfields;
     unset($discussionobj->id);
     //update the forumid and gruopid to the target forumid and selected groupid
     $discussionobj->forumid = $targetforumid;
     unset($discussionobj->groupid);
     if ($targetforum->get_group_mode() && $groupid) {
         $discussionobj->groupid = $groupid;
     }
     forum_utils::start_transaction();
     $newdiscussionid = forum_utils::insert_record('forumng_discussions', $discussionobj);
     $rs = forum_utils::get_recordset('forumng_posts', 'discussionid', $this->get_id());
     //$newids and $parentused are temp arrays used to
     //$newids is a array of new postids using the indices of its old postids
     //update the parentid of the post records copied over
     //$hasattachments is a temp array for record the posts which has attachments.
     $newids = array();
     $parentsused = array();
     $hasattachments = array();
     while ($postrec = rs_fetch_next_record($rs)) {
         $oldpostid = $postrec->id;
         unset($postrec->id);
         $postrec->discussionid = $newdiscussionid;
         $postrec->mailstate = forum::MAILSTATE_DIGESTED;
         $postrec->subject = addslashes($postrec->subject);
         $postrec->message = addslashes($postrec->message);
         $newpostid = forum_utils::insert_record('forumng_posts', $postrec);
         $newids[$oldpostid] = $newpostid;
         if ($postrec->parentpostid) {
             $parentsused[$postrec->parentpostid] = true;
         }
         if ($postrec->attachments == 1) {
             $hasattachments[$oldpostid] = $newpostid;
         }
     }
     rs_close($rs);
     //Update the postid and lastpostid in the discussion table no matter if they are null or not
     $newpostid = $newids[$discussionobj->postid];
     $newlastpostid = $newids[$discussionobj->lastpostid];
     forum_utils::execute_sql("UPDATE {$CFG->prefix}forumng_discussions SET " . "postid=" . $newpostid . ", lastpostid=" . $newlastpostid . " WHERE id=" . $newdiscussionid);
     foreach ($parentsused as $key => $value) {
         $newparentpostid = $newids[$key];
         //Update the parentpostids which have just been copied over
         forum_utils::execute_sql("UPDATE {$CFG->prefix}forumng_posts SET " . "parentpostid=" . $newparentpostid . " WHERE parentpostid=" . $key . "AND discussionid = " . $newdiscussionid);
     }
     //Copy attachments
     foreach ($hasattachments as $key => $value) {
         $oldfolder = forum_post::get_any_attachment_folder($oldcourseid, $oldforumid, $this->get_id(), $key);
         $newfolder = forum_post::get_any_attachment_folder($targetcourseid, $targetforumid, $newdiscussionid, $value);
         $handle = forum_utils::opendir($oldfolder);
         $created = false;
         while (false !== ($name = readdir($handle))) {
             //Get attachment file name one by one instead of using the get_attachment_names() to
             //avoid creating a post object
             if ($name != '.' && $name != '..') {
                 if (!is_dir("{$oldfolder}/{$name}")) {
                     // creating target folders and copying files
                     if (!$created) {
                         if (!check_dir_exists($newfolder, true, true)) {
                             throw new forum_exception("Failed to create attachment folder {$newfolder}");
                         }
                         $created = true;
                     }
                     forum_utils::copy("{$oldfolder}/{$name}", "{$newfolder}/{$name}");
                 }
             }
         }
         closedir($handle);
     }
     forum_utils::finish_transaction();
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:85,代码来源:forum_discussion.php


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