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


PHP forum::get_id方法代码示例

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


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

示例1: digest_add_post_for_user

 /**
  * Updates the in-memory digest records to add a new post to the given
  * user's digests.
  * @param object $user User object (must include special ->emailtype, etc)
  * @param array $userdigests Array of user id => digest information object
  * @param forum_post $post Post object
  * @param forum_post $inreplyto Parent post
  * @param forum_discussion $discussion Discus
  * @param forum $forum
  * @param object $cm
  * @param object $course
  * @param object $context
  */
 private static function digest_add_post_for_user(&$user, &$userdigests, &$post, &$inreplyto, &$discussion, &$forum, &$cm, &$course, &$context)
 {
     global $CFG;
     // Set up digest for user if required
     if (!array_key_exists($user->id, $userdigests)) {
         $userdigests[$user->id] = new StdClass();
         $userdigests[$user->id]->discussionid = -1;
         // So we do header next
         $userdigests[$user->id]->user = $user;
         $userdigests[$user->id]->forumid = -1;
         // Get header text
         $headerdata = new object();
         $headerdata->sitename = format_string($course->fullname, true);
         $headerdata->userprefs = $CFG->wwwroot . '/user/edit.php?id=' . $user->id . '&course=' . $course->id;
         $userdigests[$user->id]->text = get_string('digestmailheader', 'forumng', $headerdata) . "\n\n";
         // Get header HTML
         $html = "<head>";
         foreach ($CFG->stylesheets as $stylesheet) {
             $html .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n";
         }
         $html .= "</head>\n<body id='forumng-email'>\n";
         $headerdata->userprefs = '<a target="_blank" href="' . $headerdata->userprefs . '">' . get_string('digestmailprefs', 'forumng') . '</a>';
         $html .= '<div class="forumng-emailheader"><p>' . get_string('digestmailheader', 'forumng', $headerdata) . '</p></div><hr size="1" noshade="noshade" />';
         $userdigests[$user->id]->html = $html;
         // Get email subject
         $userdigests[$user->id]->subject = get_string('digestmailsubject', 'forumng', format_string($course->shortname, true));
     }
     // New forum?
     if ($userdigests[$user->id]->forumid != $forum->get_id()) {
         $userdigests[$user->id]->forumid = $forum->get_id();
     }
     // Is this a new discussion?
     if ($userdigests[$user->id]->discussionid != $discussion->get_id()) {
         $strforums = get_string('forums', 'forumng');
         // Per-discussion header (text mode)
         $text = "\n \n";
         $text .= '=====================================================================';
         $text .= "\n \n";
         $text .= "{$course->shortname} -> {$strforums} -> " . format_string($forum->get_name(), true);
         if ($discussion->get_subject(false) !== $forum->get_name()) {
             $text .= " -> " . format_string($discussion->get_subject(false), true);
         }
         $text .= "\n";
         // HTML mode
         $html = '<hr size="1" noshade="noshade" />';
         $html .= "<div class='forumng-breadcrumbs'>" . "<a target='_blank' href='{$CFG->wwwroot}/course/view.php?id={$course->id}'>{$course->shortname}</a> -> " . "<a target='_blank' href='{$CFG->wwwroot}/mod/forumng/index.php?id={$course->id}'>{$strforums}</a> -> " . "<a target='_blank' href='{$CFG->wwwroot}/mod/forumng/view.php?" . $forum->get_link_params(forum::PARAM_HTML) . "'>" . format_string($forum->get_name(), true) . "</a>";
         if ($discussion->get_subject(false) !== $forum->get_name()) {
             $html .= " -> <a target='_blank' href='{$CFG->wwwroot}/mod/forumng/discuss.php?" . $discussion->get_link_params(forum::PARAM_HTML) . "'>" . format_string($discussion->get_subject(false), true) . "</a>";
         }
         $html .= '</div>';
         $userdigests[$user->id]->text .= $text;
         $userdigests[$user->id]->html .= $html;
         $userdigests[$user->id]->discussionid = $discussion->get_id();
     }
     // Get both plaintext and html versions (and subject).
     // The html version will be blank if set to
     // plain text mode.
     $post->build_email($inreplyto, $subject, $text, $html, $user->emailtype & 1, $user->emailtype & 2, $user->emailtype & 4, $user->lang, $user->timezone, true);
     $userdigests[$user->id]->text .= $text;
     $userdigests[$user->id]->html .= $html;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:74,代码来源:forum_cron.php

示例2: print_view_page

 /**
  * Displays the view page (usually showing a list of discussions).
  * @param forum $forum Forum
  * @param int $groupid Group ID
  */
 public function print_view_page($forum, $groupid)
 {
     global $SESSION;
     $forumid = $forum->get_id();
     $baseurl = 'view.php?' . $forum->get_link_params(forum::PARAM_PLAIN);
     if (isset($SESSION->forumng_discussionlist[$forumid]) && property_exists($SESSION->forumng_discussionlist[$forumid], 'groupid') && $SESSION->forumng_discussionlist[$forumid]->groupid != $groupid) {
         unset($SESSION->forumng_discussionlist[$forumid]->page);
         unset($SESSION->forumng_discussionlist[$forumid]->groupid);
     }
     //Remember the sort order and page number in session variables
     //Unset the page session variable when the sort links are clicked
     // or groupid has been changed (using the group dropdown box)
     $sortorder = optional_param('sort', '', PARAM_ALPHA);
     if (!$sortorder) {
         if (isset($SESSION->forumng_discussionlist[$forumid]->sort)) {
             $sortorder = $SESSION->forumng_discussionlist[$forumid]->sort;
         } else {
             $sortorder = 'd';
         }
     } else {
         if (optional_param('sortlink', '', PARAM_ALPHA)) {
             $SESSION->forumng_discussionlist[$forumid]->sort = $sortorder;
             unset($SESSION->forumng_discussionlist[$forumid]->page);
         }
     }
     $page = optional_param('page', 0, PARAM_INT);
     if (!$page) {
         if (isset($SESSION->forumng_discussionlist[$forumid]->page)) {
             $page = $SESSION->forumng_discussionlist[$forumid]->page;
         } else {
             $page = 1;
         }
     } else {
         $SESSION->forumng_discussionlist[$forumid]->page = $page;
         $SESSION->forumng_discussionlist[$forumid]->groupid = $groupid;
     }
     $baseurl .= '&page=' . $page;
     $sortchar = substr($sortorder, 0, 1);
     if (strlen($sortorder) == 2) {
         $sortreverse = substr($sortorder, 1, 1) == 'r' ? true : false;
     } else {
         $sortreverse = false;
     }
     $baseurl .= '&sort=' . $sortchar;
     $baseurl .= $sortreverse ? 'r' : '';
     $sort = forum::get_sort_code($sortchar);
     $list = $forum->get_discussion_list($groupid, $forum->can_view_hidden(), $forum->can_manage_discussions(), $page, $sort, $sortreverse);
     $sticky = $list->get_sticky_discussions();
     $normal = $list->get_normal_discussions();
     // Remove discussions from list if the forumtype thinks we can't see
     // them
     foreach ($sticky as $key => $value) {
         if (!$this->can_view_discussion($value)) {
             unset($sticky[$key]);
         }
     }
     foreach ($normal as $key => $value) {
         if (!$this->can_view_discussion($value)) {
             unset($normal[$key]);
         }
     }
     // Intro
     print $forum->display_intro();
     // Draft posts
     $drafts = $forum->get_drafts();
     if (count($drafts) > 0) {
         print $forum->display_draft_list_start();
         foreach ($drafts as $draft) {
             print $draft->display_draft_list_item($forum, $draft == end($drafts));
         }
         print $forum->display_draft_list_end();
     }
     //print info about the start and end dtates of the forum from the form setting;
     $stringend = has_capability('mod/forumng:ignorepostlimits', $forum->get_context()) ? 'capable' : '';
     $startdate = $forum->get_postingfrom();
     $enddate = $forum->get_postinguntil();
     // Before start date
     if (time() < $startdate) {
         $message = get_string('beforestartdate' . $stringend, 'forumng', forum_utils::display_date($startdate));
         print "<div class='forumng-show-dates'>{$message}</div>";
     } else {
         if (time() < $enddate) {
             $message = get_string('beforeenddate' . $stringend, 'forumng', forum_utils::display_date($enddate));
             print "<div class='forumng-show-dates'>{$message}</div>";
         }
     }
     // After end date
     if ($enddate && time() >= $enddate) {
         $message = get_string('afterenddate' . $stringend, 'forumng', forum_utils::display_date($enddate));
         print "<div class='forumng-show-dates'>{$message}</div>";
     }
     // Post button - temporarily disabled when in all-groups mode
     print $groupid == NULL ? '' : $forum->display_post_button($groupid);
     print $list->display_paging_bar($baseurl);
     if (count($sticky) + count($normal) > 0) {
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:general_forum_type.php

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