コード例 #1
0
 /**
  * Displays a discussion (main part of discussion page) with given options.
  * @param mod_forumng_discussion $discussion
  * @param object $options
  * @return string HTML content of discussion
  */
 public function render_discussion($discussion, $options)
 {
     // Get main bit of discussion
     $content = $discussion->get_root_post()->display_with_children($options);
     // Get lock post, if any
     $lockpost = $discussion->get_lock_post();
     if ($lockpost) {
         $content = '<div class="forumng-lockmessage">' . $lockpost->display(true, array(mod_forumng_post::OPTION_NO_COMMANDS => true)) . '</div>' . $content;
     }
     return $content;
 }
コード例 #2
0
 /**
  * Displays a discussion (main part of discussion page) with given options.
  * @param mod_forumng_discussion $discussion
  * @param object $options
  * @return string HTML content of discussion
  */
 public function render_discussion($discussion, $options)
 {
     if ($discussion->is_auto_locked()) {
         $options[mod_forumng_post::OPTION_INCLUDE_LOCK] = true;
     }
     // Get main bit of discussion.
     $content = $discussion->get_root_post()->display_with_children($options);
     if ($discussion->is_auto_locked()) {
         $content = $this->render_lock_message() . $content;
     } else {
         // Get lock post, if any.
         $lockpost = $discussion->get_lock_post();
         if ($lockpost) {
             $content = '<div class="forumng-lockmessage">' . $lockpost->display(true, array(mod_forumng_post::OPTION_NO_COMMANDS => true)) . '</div>' . $content;
         }
     }
     return $content;
 }
コード例 #3
0
 /**
  * Merges the contents of this discussion into another discussion.
  * @param mod_forumng_discussion $targetdiscussion Target discussion
  * @param int $userid User ID (0 = current)
  * @param bool $log True to log this action
  */
 public function merge_into($targetdiscussion, $userid = 0, $log = true)
 {
     global $DB;
     $transaction = $DB->start_delegated_transaction();
     // Delete search data for the source discussion
     $this->ismakingsearchchange = true;
     $root = $this->get_root_post();
     $root->search_update();
     $root->search_update_children();
     $this->ismakingsearchchange = false;
     // Update parent post id of root post
     $record = new stdClass();
     $record->id = $this->discussionfields->postid;
     $record->parentpostid = $targetdiscussion->discussionfields->postid;
     $DB->update_record('forumng_posts', $record);
     // Move all posts into new discussion
     $DB->execute("UPDATE {forumng_posts} SET discussionid = ? WHERE discussionid = ?", array($targetdiscussion->get_id(), $this->get_id()));
     // Delete this discussion
     $DB->delete_records('forumng_discussions', array('id' => $this->discussionfields->id));
     // Attachments are OK because they are still in the same context, postid
     // etc (note this would NOT be the case if we allowed merging between
     // forums).
     if ($this->get_forum()->get_id() != $targetdiscussion->get_forum()->get_id()) {
         throw new coding_exception('Cannot merge into different forum');
     }
     // Merging the discussion into another might cause completion changes
     // (if there was a requirement for discussions and this is no longer
     // a discussion in its own right).
     $this->update_completion(false);
     // Update the search data for the target discussion after the merge
     $newroot = $targetdiscussion->get_root_post();
     $newroot->search_update();
     $newroot->search_update_children();
     if ($log) {
         $this->log('merge discussion', 'd' . $this->get_id() . ' into d' . $targetdiscussion->get_id());
     }
     $transaction->allow_commit();
     $this->uncache();
     $targetdiscussion->uncache();
 }