[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * @package mod_forum 19 * @copyright 2014 Andrew Robert Nicols <[email protected]> 20 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 21 */ 22 23 defined('MOODLE_INTERNAL') || die(); 24 25 // Deprecated a very long time ago. 26 27 /** 28 * How many posts by other users are unrated by a given user in the given discussion? 29 * 30 * @param int $discussionid 31 * @param int $userid 32 * @return mixed 33 * @deprecated since Moodle 1.1 - please do not use this function any more. 34 */ 35 function forum_count_unrated_posts($discussionid, $userid) { 36 global $CFG, $DB; 37 debugging('forum_count_unrated_posts() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 38 39 $sql = "SELECT COUNT(*) as num 40 FROM {forum_posts} 41 WHERE parent > 0 42 AND discussion = :discussionid 43 AND userid <> :userid"; 44 $params = array('discussionid' => $discussionid, 'userid' => $userid); 45 $posts = $DB->get_record_sql($sql, $params); 46 if ($posts) { 47 $sql = "SELECT count(*) as num 48 FROM {forum_posts} p, 49 {rating} r 50 WHERE p.discussion = :discussionid AND 51 p.id = r.itemid AND 52 r.userid = userid AND 53 r.component = 'mod_forum' AND 54 r.ratingarea = 'post'"; 55 $rated = $DB->get_record_sql($sql, $params); 56 if ($rated) { 57 if ($posts->num > $rated->num) { 58 return $posts->num - $rated->num; 59 } else { 60 return 0; // Just in case there was a counting error 61 } 62 } else { 63 return $posts->num; 64 } 65 } else { 66 return 0; 67 } 68 } 69 70 71 // Since Moodle 1.5. 72 73 /** 74 * Returns the count of records for the provided user and discussion. 75 * 76 * @global object 77 * @global object 78 * @param int $userid 79 * @param int $discussionid 80 * @return bool 81 * @deprecated since Moodle 1.5 - please do not use this function any more. 82 */ 83 function forum_tp_count_discussion_read_records($userid, $discussionid) { 84 debugging('forum_tp_count_discussion_read_records() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 85 86 global $CFG, $DB; 87 88 $cutoffdate = isset($CFG->forum_oldpostdays) ? (time() - ($CFG->forum_oldpostdays*24*60*60)) : 0; 89 90 $sql = 'SELECT COUNT(DISTINCT p.id) '. 91 'FROM {forum_discussions} d '. 92 'LEFT JOIN {forum_read} r ON d.id = r.discussionid AND r.userid = ? '. 93 'LEFT JOIN {forum_posts} p ON p.discussion = d.id '. 94 'AND (p.modified < ? OR p.id = r.postid) '. 95 'WHERE d.id = ? '; 96 97 return ($DB->count_records_sql($sql, array($userid, $cutoffdate, $discussionid))); 98 } 99 100 /** 101 * Get all discussions started by a particular user in a course (or group) 102 * 103 * @global object 104 * @global object 105 * @param int $courseid 106 * @param int $userid 107 * @param int $groupid 108 * @return array 109 * @deprecated since Moodle 1.5 - please do not use this function any more. 110 */ 111 function forum_get_user_discussions($courseid, $userid, $groupid=0) { 112 debugging('forum_get_user_discussions() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 113 114 global $CFG, $DB; 115 $params = array($courseid, $userid); 116 if ($groupid) { 117 $groupselect = " AND d.groupid = ? "; 118 $params[] = $groupid; 119 } else { 120 $groupselect = ""; 121 } 122 123 $allnames = get_all_user_name_fields(true, 'u'); 124 return $DB->get_records_sql("SELECT p.*, d.groupid, $allnames, u.email, u.picture, u.imagealt, 125 f.type as forumtype, f.name as forumname, f.id as forumid 126 FROM {forum_discussions} d, 127 {forum_posts} p, 128 {user} u, 129 {forum} f 130 WHERE d.course = ? 131 AND p.discussion = d.id 132 AND p.parent = 0 133 AND p.userid = u.id 134 AND u.id = ? 135 AND d.forum = f.id $groupselect 136 ORDER BY p.created DESC", $params); 137 } 138 139 140 // Since Moodle 1.6. 141 142 /** 143 * Returns the count of posts for the provided forum and [optionally] group. 144 * @global object 145 * @global object 146 * @param int $forumid 147 * @param int|bool $groupid 148 * @return int 149 * @deprecated since Moodle 1.6 - please do not use this function any more. 150 */ 151 function forum_tp_count_forum_posts($forumid, $groupid=false) { 152 debugging('forum_tp_count_forum_posts() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 153 154 global $CFG, $DB; 155 $params = array($forumid); 156 $sql = 'SELECT COUNT(*) '. 157 'FROM {forum_posts} fp,{forum_discussions} fd '. 158 'WHERE fd.forum = ? AND fp.discussion = fd.id'; 159 if ($groupid !== false) { 160 $sql .= ' AND (fd.groupid = ? OR fd.groupid = -1)'; 161 $params[] = $groupid; 162 } 163 $count = $DB->count_records_sql($sql, $params); 164 165 166 return $count; 167 } 168 169 /** 170 * Returns the count of records for the provided user and forum and [optionally] group. 171 * @global object 172 * @global object 173 * @param int $userid 174 * @param int $forumid 175 * @param int|bool $groupid 176 * @return int 177 * @deprecated since Moodle 1.6 - please do not use this function any more. 178 */ 179 function forum_tp_count_forum_read_records($userid, $forumid, $groupid=false) { 180 debugging('forum_tp_count_forum_read_records() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 181 182 global $CFG, $DB; 183 184 $cutoffdate = time() - ($CFG->forum_oldpostdays*24*60*60); 185 186 $groupsel = ''; 187 $params = array($userid, $forumid, $cutoffdate); 188 if ($groupid !== false) { 189 $groupsel = "AND (d.groupid = ? OR d.groupid = -1)"; 190 $params[] = $groupid; 191 } 192 193 $sql = "SELECT COUNT(p.id) 194 FROM {forum_posts} p 195 JOIN {forum_discussions} d ON d.id = p.discussion 196 LEFT JOIN {forum_read} r ON (r.postid = p.id AND r.userid= ?) 197 WHERE d.forum = ? 198 AND (p.modified < $cutoffdate OR (p.modified >= ? AND r.id IS NOT NULL)) 199 $groupsel"; 200 201 return $DB->get_field_sql($sql, $params); 202 } 203 204 205 // Since Moodle 1.7. 206 207 /** 208 * Returns array of forum open modes. 209 * 210 * @return array 211 * @deprecated since Moodle 1.7 - please do not use this function any more. 212 */ 213 function forum_get_open_modes() { 214 debugging('forum_get_open_modes() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 215 return array(); 216 } 217 218 219 // Since Moodle 1.9. 220 221 /** 222 * Gets posts with all info ready for forum_print_post 223 * We pass forumid in because we always know it so no need to make a 224 * complicated join to find it out. 225 * 226 * @global object 227 * @global object 228 * @param int $parent 229 * @param int $forumid 230 * @return array 231 * @deprecated since Moodle 1.9 MDL-13303 - please do not use this function any more. 232 */ 233 function forum_get_child_posts($parent, $forumid) { 234 debugging('forum_get_child_posts() is deprecated.', DEBUG_DEVELOPER); 235 236 global $CFG, $DB; 237 238 $allnames = get_all_user_name_fields(true, 'u'); 239 return $DB->get_records_sql("SELECT p.*, $forumid AS forum, $allnames, u.email, u.picture, u.imagealt 240 FROM {forum_posts} p 241 LEFT JOIN {user} u ON p.userid = u.id 242 WHERE p.parent = ? 243 ORDER BY p.created ASC", array($parent)); 244 } 245 246 /** 247 * Gets posts with all info ready for forum_print_post 248 * We pass forumid in because we always know it so no need to make a 249 * complicated join to find it out. 250 * 251 * @global object 252 * @global object 253 * @return mixed array of posts or false 254 * @deprecated since Moodle 1.9 MDL-13303 - please do not use this function any more. 255 */ 256 function forum_get_discussion_posts($discussion, $sort, $forumid) { 257 debugging('forum_get_discussion_posts() is deprecated.', DEBUG_DEVELOPER); 258 259 global $CFG, $DB; 260 261 $allnames = get_all_user_name_fields(true, 'u'); 262 return $DB->get_records_sql("SELECT p.*, $forumid AS forum, $allnames, u.email, u.picture, u.imagealt 263 FROM {forum_posts} p 264 LEFT JOIN {user} u ON p.userid = u.id 265 WHERE p.discussion = ? 266 AND p.parent > 0 $sort", array($discussion)); 267 } 268 269 270 // Since Moodle 2.0. 271 272 /** 273 * Returns a list of ratings for a particular post - sorted. 274 * 275 * @param stdClass $context 276 * @param int $postid 277 * @param string $sort 278 * @return array Array of ratings or false 279 * @deprecated since Moodle 2.0 MDL-21657 - please do not use this function any more. 280 */ 281 function forum_get_ratings($context, $postid, $sort = "u.firstname ASC") { 282 debugging('forum_get_ratings() is deprecated.', DEBUG_DEVELOPER); 283 $options = new stdClass; 284 $options->context = $context; 285 $options->component = 'mod_forum'; 286 $options->ratingarea = 'post'; 287 $options->itemid = $postid; 288 $options->sort = "ORDER BY $sort"; 289 290 $rm = new rating_manager(); 291 return $rm->get_all_ratings_for_item($options); 292 } 293 294 /** 295 * Generate and return the track or no track link for a forum. 296 * 297 * @global object 298 * @global object 299 * @global object 300 * @param object $forum the forum. Fields used are $forum->id and $forum->forcesubscribe. 301 * @param array $messages 302 * @param bool $fakelink 303 * @return string 304 * @deprecated since Moodle 2.0 MDL-14632 - please do not use this function any more. 305 */ 306 function forum_get_tracking_link($forum, $messages=array(), $fakelink=true) { 307 debugging('forum_get_tracking_link() is deprecated.', DEBUG_DEVELOPER); 308 309 global $CFG, $USER, $PAGE, $OUTPUT; 310 311 static $strnotrackforum, $strtrackforum; 312 313 if (isset($messages['trackforum'])) { 314 $strtrackforum = $messages['trackforum']; 315 } 316 if (isset($messages['notrackforum'])) { 317 $strnotrackforum = $messages['notrackforum']; 318 } 319 if (empty($strtrackforum)) { 320 $strtrackforum = get_string('trackforum', 'forum'); 321 } 322 if (empty($strnotrackforum)) { 323 $strnotrackforum = get_string('notrackforum', 'forum'); 324 } 325 326 if (forum_tp_is_tracked($forum)) { 327 $linktitle = $strnotrackforum; 328 $linktext = $strnotrackforum; 329 } else { 330 $linktitle = $strtrackforum; 331 $linktext = $strtrackforum; 332 } 333 334 $link = ''; 335 if ($fakelink) { 336 $PAGE->requires->js('/mod/forum/forum.js'); 337 $PAGE->requires->js_function_call('forum_produce_tracking_link', Array($forum->id, $linktext, $linktitle)); 338 // use <noscript> to print button in case javascript is not enabled 339 $link .= '<noscript>'; 340 } 341 $url = new moodle_url('/mod/forum/settracking.php', array( 342 'id' => $forum->id, 343 'sesskey' => sesskey(), 344 )); 345 $link .= $OUTPUT->single_button($url, $linktext, 'get', array('title'=>$linktitle)); 346 347 if ($fakelink) { 348 $link .= '</noscript>'; 349 } 350 351 return $link; 352 } 353 354 /** 355 * Returns the count of records for the provided user and discussion. 356 * 357 * @global object 358 * @global object 359 * @param int $userid 360 * @param int $discussionid 361 * @return int 362 * @deprecated since Moodle 2.0 MDL-14113 - please do not use this function any more. 363 */ 364 function forum_tp_count_discussion_unread_posts($userid, $discussionid) { 365 debugging('forum_tp_count_discussion_unread_posts() is deprecated.', DEBUG_DEVELOPER); 366 global $CFG, $DB; 367 368 $cutoffdate = isset($CFG->forum_oldpostdays) ? (time() - ($CFG->forum_oldpostdays*24*60*60)) : 0; 369 370 $sql = 'SELECT COUNT(p.id) '. 371 'FROM {forum_posts} p '. 372 'LEFT JOIN {forum_read} r ON r.postid = p.id AND r.userid = ? '. 373 'WHERE p.discussion = ? '. 374 'AND p.modified >= ? AND r.id is NULL'; 375 376 return $DB->count_records_sql($sql, array($userid, $discussionid, $cutoffdate)); 377 } 378 379 /** 380 * Converts a forum to use the Roles System 381 * 382 * @deprecated since Moodle 2.0 MDL-23479 - please do not use this function any more. 383 */ 384 function forum_convert_to_roles() { 385 debugging('forum_convert_to_roles() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 386 } 387 388 /** 389 * Returns all records in the 'forum_read' table matching the passed keys, indexed 390 * by userid. 391 * 392 * @global object 393 * @param int $userid 394 * @param int $postid 395 * @param int $discussionid 396 * @param int $forumid 397 * @return array 398 * @deprecated since Moodle 2.0 MDL-14113 - please do not use this function any more. 399 */ 400 function forum_tp_get_read_records($userid=-1, $postid=-1, $discussionid=-1, $forumid=-1) { 401 debugging('forum_tp_get_read_records() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 402 403 global $DB; 404 $select = ''; 405 $params = array(); 406 407 if ($userid > -1) { 408 if ($select != '') $select .= ' AND '; 409 $select .= 'userid = ?'; 410 $params[] = $userid; 411 } 412 if ($postid > -1) { 413 if ($select != '') $select .= ' AND '; 414 $select .= 'postid = ?'; 415 $params[] = $postid; 416 } 417 if ($discussionid > -1) { 418 if ($select != '') $select .= ' AND '; 419 $select .= 'discussionid = ?'; 420 $params[] = $discussionid; 421 } 422 if ($forumid > -1) { 423 if ($select != '') $select .= ' AND '; 424 $select .= 'forumid = ?'; 425 $params[] = $forumid; 426 } 427 428 return $DB->get_records_select('forum_read', $select, $params); 429 } 430 431 /** 432 * Returns all read records for the provided user and discussion, indexed by postid. 433 * 434 * @global object 435 * @param inti $userid 436 * @param int $discussionid 437 * @deprecated since Moodle 2.0 MDL-14113 - please do not use this function any more. 438 */ 439 function forum_tp_get_discussion_read_records($userid, $discussionid) { 440 debugging('forum_tp_get_discussion_read_records() is deprecated and will not be replaced.', DEBUG_DEVELOPER); 441 442 global $DB; 443 $select = 'userid = ? AND discussionid = ?'; 444 $fields = 'postid, firstread, lastread'; 445 return $DB->get_records_select('forum_read', $select, array($userid, $discussionid), '', $fields); 446 } 447 448 // Deprecated in 2.3. 449 450 /** 451 * This function gets run whenever user is enrolled into course 452 * 453 * @deprecated since Moodle 2.3 MDL-33166 - please do not use this function any more. 454 * @param stdClass $cp 455 * @return void 456 */ 457 function forum_user_enrolled($cp) { 458 debugging('forum_user_enrolled() is deprecated. Please use forum_user_role_assigned instead.', DEBUG_DEVELOPER); 459 global $DB; 460 461 // NOTE: this has to be as fast as possible - we do not want to slow down enrolments! 462 // Originally there used to be 'mod/forum:initialsubscriptions' which was 463 // introduced because we did not have enrolment information in earlier versions... 464 465 $sql = "SELECT f.id 466 FROM {forum} f 467 LEFT JOIN {forum_subscriptions} fs ON (fs.forum = f.id AND fs.userid = :userid) 468 WHERE f.course = :courseid AND f.forcesubscribe = :initial AND fs.id IS NULL"; 469 $params = array('courseid'=>$cp->courseid, 'userid'=>$cp->userid, 'initial'=>FORUM_INITIALSUBSCRIBE); 470 471 $forums = $DB->get_records_sql($sql, $params); 472 foreach ($forums as $forum) { 473 \mod_forum\subscriptions::subscribe_user($cp->userid, $forum); 474 } 475 } 476 477 478 // Deprecated in 2.4. 479 480 /** 481 * Checks to see if a user can view a particular post. 482 * 483 * @deprecated since Moodle 2.4 use forum_user_can_see_post() instead 484 * 485 * @param object $post 486 * @param object $course 487 * @param object $cm 488 * @param object $forum 489 * @param object $discussion 490 * @param object $user 491 * @return boolean 492 */ 493 function forum_user_can_view_post($post, $course, $cm, $forum, $discussion, $user=null){ 494 debugging('forum_user_can_view_post() is deprecated. Please use forum_user_can_see_post() instead.', DEBUG_DEVELOPER); 495 return forum_user_can_see_post($forum, $discussion, $post, $user, $cm); 496 } 497 498 499 // Deprecated in 2.6. 500 501 /** 502 * FORUM_TRACKING_ON - deprecated alias for FORUM_TRACKING_FORCED. 503 * @deprecated since 2.6 504 */ 505 define('FORUM_TRACKING_ON', 2); 506 507 /** 508 * @deprecated since Moodle 2.6 509 * @see shorten_text() 510 */ 511 function forum_shorten_post($message) { 512 throw new coding_exception('forum_shorten_post() can not be used any more. Please use shorten_text($message, $CFG->forum_shortpost) instead.'); 513 } 514 515 // Deprecated in 2.8. 516 517 /** 518 * @global object 519 * @param int $userid 520 * @param object $forum 521 * @return bool 522 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::is_subscribed() instead 523 */ 524 function forum_is_subscribed($userid, $forum) { 525 global $DB; 526 debugging("forum_is_subscribed() has been deprecated, please use \\mod_forum\\subscriptions::is_subscribed() instead.", 527 DEBUG_DEVELOPER); 528 529 // Note: The new function does not take an integer form of forum. 530 if (is_numeric($forum)) { 531 $forum = $DB->get_record('forum', array('id' => $forum)); 532 } 533 534 return mod_forum\subscriptions::is_subscribed($userid, $forum); 535 } 536 537 /** 538 * Adds user to the subscriber list 539 * 540 * @param int $userid 541 * @param int $forumid 542 * @param context_module|null $context Module context, may be omitted if not known or if called for the current module set in page. 543 * @param boolean $userrequest Whether the user requested this change themselves. This has an effect on whether 544 * discussion subscriptions are removed too. 545 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::subscribe_user() instead 546 */ 547 function forum_subscribe($userid, $forumid, $context = null, $userrequest = false) { 548 global $DB; 549 debugging("forum_subscribe() has been deprecated, please use \\mod_forum\\subscriptions::subscribe_user() instead.", 550 DEBUG_DEVELOPER); 551 552 // Note: The new function does not take an integer form of forum. 553 $forum = $DB->get_record('forum', array('id' => $forumid)); 554 \mod_forum\subscriptions::subscribe_user($userid, $forum, $context, $userrequest); 555 } 556 557 /** 558 * Removes user from the subscriber list 559 * 560 * @param int $userid 561 * @param int $forumid 562 * @param context_module|null $context Module context, may be omitted if not known or if called for the current module set in page. 563 * @param boolean $userrequest Whether the user requested this change themselves. This has an effect on whether 564 * discussion subscriptions are removed too. 565 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::unsubscribe_user() instead 566 */ 567 function forum_unsubscribe($userid, $forumid, $context = null, $userrequest = false) { 568 global $DB; 569 debugging("forum_unsubscribe() has been deprecated, please use \\mod_forum\\subscriptions::unsubscribe_user() instead.", 570 DEBUG_DEVELOPER); 571 572 // Note: The new function does not take an integer form of forum. 573 $forum = $DB->get_record('forum', array('id' => $forumid)); 574 \mod_forum\subscriptions::unsubscribe_user($userid, $forum, $context, $userrequest); 575 } 576 577 /** 578 * Returns list of user objects that are subscribed to this forum. 579 * 580 * @param stdClass $course the course 581 * @param stdClass $forum the forum 582 * @param int $groupid group id, or 0 for all. 583 * @param context_module $context the forum context, to save re-fetching it where possible. 584 * @param string $fields requested user fields (with "u." table prefix) 585 * @param boolean $considerdiscussions Whether to take discussion subscriptions and unsubscriptions into consideration. 586 * @return array list of users. 587 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::fetch_subscribed_users() instead 588 */ 589 function forum_subscribed_users($course, $forum, $groupid = 0, $context = null, $fields = null) { 590 debugging("forum_subscribed_users() has been deprecated, please use \\mod_forum\\subscriptions::fetch_subscribed_users() instead.", 591 DEBUG_DEVELOPER); 592 593 \mod_forum\subscriptions::fetch_subscribed_users($forum, $groupid, $context, $fields); 594 } 595 596 /** 597 * Determine whether the forum is force subscribed. 598 * 599 * @param object $forum 600 * @return bool 601 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::is_forcesubscribed() instead 602 */ 603 function forum_is_forcesubscribed($forum) { 604 debugging("forum_is_forcesubscribed() has been deprecated, please use \\mod_forum\\subscriptions::is_forcesubscribed() instead.", 605 DEBUG_DEVELOPER); 606 607 global $DB; 608 if (!isset($forum->forcesubscribe)) { 609 $forum = $DB->get_field('forum', 'forcesubscribe', array('id' => $forum)); 610 } 611 612 return \mod_forum\subscriptions::is_forcesubscribed($forum); 613 } 614 615 /** 616 * Set the subscription mode for a forum. 617 * 618 * @param int $forumid 619 * @param mixed $value 620 * @return bool 621 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::set_subscription_mode() instead 622 */ 623 function forum_forcesubscribe($forumid, $value = 1) { 624 debugging("forum_forcesubscribe() has been deprecated, please use \\mod_forum\\subscriptions::set_subscription_mode() instead.", 625 DEBUG_DEVELOPER); 626 627 return \mod_forum\subscriptions::set_subscription_mode($forumid, $value); 628 } 629 630 /** 631 * Get the current subscription mode for the forum. 632 * 633 * @param int|stdClass $forumid 634 * @param mixed $value 635 * @return bool 636 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::get_subscription_mode() instead 637 */ 638 function forum_get_forcesubscribed($forum) { 639 debugging("forum_get_forcesubscribed() has been deprecated, please use \\mod_forum\\subscriptions::get_subscription_mode() instead.", 640 DEBUG_DEVELOPER); 641 642 global $DB; 643 if (!isset($forum->forcesubscribe)) { 644 $forum = $DB->get_field('forum', 'forcesubscribe', array('id' => $forum)); 645 } 646 647 return \mod_forum\subscriptions::get_subscription_mode($forumid, $value); 648 } 649 650 /** 651 * Get a list of forums in the specified course in which a user can change 652 * their subscription preferences. 653 * 654 * @param stdClass $course The course from which to find subscribable forums. 655 * @return array 656 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::is_subscribed in combination wtih 657 * \mod_forum\subscriptions::fill_subscription_cache_for_course instead. 658 */ 659 function forum_get_subscribed_forums($course) { 660 debugging("forum_get_subscribed_forums() has been deprecated, please see " . 661 "\\mod_forum\\subscriptions::is_subscribed::() " . 662 " and \\mod_forum\\subscriptions::fill_subscription_cache_for_course instead.", 663 DEBUG_DEVELOPER); 664 665 global $USER, $CFG, $DB; 666 $sql = "SELECT f.id 667 FROM {forum} f 668 LEFT JOIN {forum_subscriptions} fs ON (fs.forum = f.id AND fs.userid = ?) 669 WHERE f.course = ? 670 AND f.forcesubscribe <> ".FORUM_DISALLOWSUBSCRIBE." 671 AND (f.forcesubscribe = ".FORUM_FORCESUBSCRIBE." OR fs.id IS NOT NULL)"; 672 if ($subscribed = $DB->get_records_sql($sql, array($USER->id, $course->id))) { 673 foreach ($subscribed as $s) { 674 $subscribed[$s->id] = $s->id; 675 } 676 return $subscribed; 677 } else { 678 return array(); 679 } 680 } 681 682 /** 683 * Returns an array of forums that the current user is subscribed to and is allowed to unsubscribe from 684 * 685 * @return array An array of unsubscribable forums 686 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::get_unsubscribable_forums() instead 687 */ 688 function forum_get_optional_subscribed_forums() { 689 debugging("forum_get_optional_subscribed_forums() has been deprecated, please use \\mod_forum\\subscriptions::get_unsubscribable_forums() instead.", 690 DEBUG_DEVELOPER); 691 692 return \mod_forum\subscriptions::get_unsubscribable_forums(); 693 } 694 695 /** 696 * Get the list of potential subscribers to a forum. 697 * 698 * @param object $forumcontext the forum context. 699 * @param integer $groupid the id of a group, or 0 for all groups. 700 * @param string $fields the list of fields to return for each user. As for get_users_by_capability. 701 * @param string $sort sort order. As for get_users_by_capability. 702 * @return array list of users. 703 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::get_potential_subscribers() instead 704 */ 705 function forum_get_potential_subscribers($forumcontext, $groupid, $fields, $sort = '') { 706 debugging("forum_get_potential_subscribers() has been deprecated, please use \\mod_forum\\subscriptions::get_potential_subscribers() instead.", 707 DEBUG_DEVELOPER); 708 709 \mod_forum\subscriptions::get_potential_subscribers($forumcontext, $groupid, $fields, $sort); 710 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |