on-demand release 4.0dev+
[moodle.git] / mod / forum / index.php
CommitLineData
cd4e6b17 1<?php
f93f848a 2
8f685009
SH
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
01030f1b 19 * @package mod_forum
8f685009
SH
20 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22 */
23
1fcf0ca8 24require_once(__DIR__ . '/../../config.php');
cd4e6b17 25require_once($CFG->dirroot . '/course/lib.php');
26require_once($CFG->dirroot . '/mod/forum/lib.php');
27require_once($CFG->libdir . '/rsslib.php');
f93f848a 28
cd4e6b17 29$id = optional_param('id', 0, PARAM_INT); // Course id
30$subscribe = optional_param('subscribe', null, PARAM_INT); // Subscribe/Unsubscribe all forums
f93f848a 31
8381ac52 32$url = new moodle_url('/mod/forum/index.php', array('id' => $id));
cd4e6b17 33if ($subscribe !== null) {
c56ed7bb 34 require_sesskey();
cd4e6b17 35 $url->param('subscribe', $subscribe);
36}
37$PAGE->set_url($url);
92833547 38$PAGE->set_secondary_active_tab('coursehome');
cd4e6b17 39
40if ($id) {
8381ac52 41 if (!$course = $DB->get_record('course', array('id' => $id))) {
cd4e6b17 42 print_error('invalidcourseid');
43 }
44} else {
2a250a0b 45 $course = get_site();
cd4e6b17 46}
f93f848a 47
cd4e6b17 48require_course_login($course);
191b267b 49$PAGE->set_pagelayout('incourse');
bf0f06b1 50$coursecontext = context_course::instance($course->id);
583b57b4 51
cd4e6b17 52unset($SESSION->fromdiscussion);
f93f848a 53
22881392
DP
54$params = array(
55 'context' => context_course::instance($course->id)
56);
57$event = \mod_forum\event\course_module_instance_list_viewed::create($params);
1e242b41 58$event->add_record_snapshot('course', $course);
22881392 59$event->trigger();
2f3f505f 60
cd4e6b17 61$strforums = get_string('forums', 'forum');
62$strforum = get_string('forum', 'forum');
63$strdescription = get_string('description');
64$strdiscussions = get_string('discussions', 'forum');
65$strsubscribed = get_string('subscribed', 'forum');
66$strunreadposts = get_string('unreadposts', 'forum');
67$strtracking = get_string('tracking', 'forum');
68$strmarkallread = get_string('markallread', 'forum');
69$strtrackforum = get_string('trackforum', 'forum');
70$strnotrackforum = get_string('notrackforum', 'forum');
71$strsubscribe = get_string('subscribe', 'forum');
72$strunsubscribe = get_string('unsubscribe', 'forum');
73$stryes = get_string('yes');
74$strno = get_string('no');
75$strrss = get_string('rss');
8e08c731 76$stremaildigest = get_string('emaildigest');
97485d07 77
cd4e6b17 78$searchform = forum_search_form($course);
f93f848a 79
c42c2355 80// Start of the table for General Forums.
cd4e6b17 81$generaltable = new html_table();
82$generaltable->head = array ($strforum, $strdescription, $strdiscussions);
83$generaltable->align = array ('left', 'left', 'center');
f37da850 84
cd4e6b17 85if ($usetracking = forum_tp_can_track_forums()) {
86 $untracked = forum_tp_get_untracked_forums($USER->id, $course->id);
c2468824 87
cd4e6b17 88 $generaltable->head[] = $strunreadposts;
89 $generaltable->align[] = 'center';
38994d6f 90
cd4e6b17 91 $generaltable->head[] = $strtracking;
92 $generaltable->align[] = 'center';
93}
f93f848a 94
59075a43
AN
95// Fill the subscription cache for this course and user combination.
96\mod_forum\subscriptions::fill_subscription_cache_for_course($course->id, $USER->id);
cd4e6b17 97
7487c856 98$usesections = course_format_uses_sections($course->format);
7487c856
SH
99
100$table = new html_table();
f93f848a 101
cd4e6b17 102// Parse and organise all the forums. Most forums are course modules but
103// some special ones are not. These get placed in the general forums
104// category with the forums in section 0.
105
8e08c731
AN
106$forums = $DB->get_records_sql("
107 SELECT f.*,
108 d.maildigest
109 FROM {forum} f
110 LEFT JOIN {forum_digests} d ON d.forum = f.id AND d.userid = ?
111 WHERE f.course = ?
112 ", array($USER->id, $course->id));
cd4e6b17 113
114$generalforums = array();
115$learningforums = array();
f20edd52 116$modinfo = get_fast_modinfo($course);
8381ac52 117$showsubscriptioncolumns = false;
cd4e6b17 118
8381ac52 119foreach ($modinfo->get_instances_of('forum') as $forumid => $cm) {
cd4e6b17 120 if (!$cm->uservisible or !isset($forums[$forumid])) {
121 continue;
33f48f03 122 }
123
cd4e6b17 124 $forum = $forums[$forumid];
fa5a5b52 125
0d4d49d1 126 if (!$context = context_module::instance($cm->id, IGNORE_MISSING)) {
8381ac52
AN
127 // Shouldn't happen.
128 continue;
cd4e6b17 129 }
130
131 if (!has_capability('mod/forum:viewdiscussion', $context)) {
8381ac52 132 // User can't view this one - skip it.
cd4e6b17 133 continue;
134 }
ecc8403e 135
8381ac52
AN
136 // Determine whether subscription options should be displayed.
137 $forum->cansubscribe = mod_forum\subscriptions::is_subscribable($forum);
138 $forum->cansubscribe = $forum->cansubscribe || has_capability('mod/forum:managesubscriptions', $context);
139 $forum->issubscribed = mod_forum\subscriptions::is_subscribed($USER->id, $forum, null, $cm);
140
141 $showsubscriptioncolumns = $showsubscriptioncolumns || $forum->issubscribed || $forum->cansubscribe;
142
143 // Fill two type array - order in modinfo is the same as in course.
cd4e6b17 144 if ($forum->type == 'news' or $forum->type == 'social') {
145 $generalforums[$forum->id] = $forum;
dd97c328 146
cd4e6b17 147 } else if ($course->id == SITEID or empty($cm->sectionnum)) {
148 $generalforums[$forum->id] = $forum;
ecc8403e 149
cd4e6b17 150 } else {
151 $learningforums[$forum->id] = $forum;
2f3f505f 152 }
cd4e6b17 153}
2f3f505f 154
8381ac52
AN
155if ($showsubscriptioncolumns) {
156 // The user can subscribe to at least one forum.
157 $generaltable->head[] = $strsubscribed;
158 $generaltable->align[] = 'center';
159
160 $generaltable->head[] = $stremaildigest . ' ' . $OUTPUT->help_icon('emaildigesttype', 'mod_forum');
161 $generaltable->align[] = 'center';
162
8381ac52
AN
163}
164
165if ($show_rss = (($showsubscriptioncolumns || $course->id == SITEID) &&
166 isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) &&
167 $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds)) {
168 $generaltable->head[] = $strrss;
169 $generaltable->align[] = 'center';
170}
171
172
b688c449
EL
173// Do course wide subscribe/unsubscribe if requested
174if (!is_null($subscribe)) {
8381ac52 175 if (isguestuser() or !$showsubscriptioncolumns) {
d954b54f
AN
176 // There should not be any links leading to this place, just redirect.
177 redirect(
178 new moodle_url('/mod/forum/index.php', array('id' => $id)),
179 get_string('subscribeenrolledonly', 'forum'),
180 null,
181 \core\output\notification::NOTIFY_ERROR
182 );
b688c449
EL
183 }
184 // Can proceed now, the user is not guest and is enrolled
8381ac52 185 foreach ($modinfo->get_instances_of('forum') as $forumid => $cm) {
2f3f505f 186 $forum = $forums[$forumid];
bf0f06b1 187 $modcontext = context_module::instance($cm->id);
cd4e6b17 188 $cansub = false;
dd97c328 189
cd4e6b17 190 if (has_capability('mod/forum:viewdiscussion', $modcontext)) {
191 $cansub = true;
2f3f505f 192 }
cd4e6b17 193 if ($cansub && $cm->visible == 0 &&
194 !has_capability('mod/forum:managesubscriptions', $modcontext))
195 {
196 $cansub = false;
2f3f505f 197 }
59075a43 198 if (!\mod_forum\subscriptions::is_forcesubscribed($forum)) {
4238983e 199 $subscribed = \mod_forum\subscriptions::is_subscribed($USER->id, $forum, null, $cm);
59075a43
AN
200 $canmanageactivities = has_capability('moodle/course:manageactivities', $coursecontext, $USER->id);
201 if (($canmanageactivities || \mod_forum\subscriptions::is_subscribable($forum)) && $subscribe && !$subscribed && $cansub) {
e3bbfb52 202 \mod_forum\subscriptions::subscribe_user($USER->id, $forum, $modcontext, true);
cd4e6b17 203 } else if (!$subscribe && $subscribed) {
e3bbfb52 204 \mod_forum\subscriptions::unsubscribe_user($USER->id, $forum, $modcontext, true);
cd4e6b17 205 }
206 }
207 }
3d8d8a8c 208 $returnto = forum_go_back_to(new moodle_url('/mod/forum/index.php', array('id' => $course->id)));
bf0f06b1 209 $shortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
cd4e6b17 210 if ($subscribe) {
d954b54f
AN
211 redirect(
212 $returnto,
213 get_string('nowallsubscribed', 'forum', $shortname),
214 null,
215 \core\output\notification::NOTIFY_SUCCESS
216 );
cd4e6b17 217 } else {
d954b54f
AN
218 redirect(
219 $returnto,
220 get_string('nowallunsubscribed', 'forum', $shortname),
221 null,
222 \core\output\notification::NOTIFY_SUCCESS
223 );
cd4e6b17 224 }
225}
dd97c328 226
cd4e6b17 227if ($generalforums) {
8381ac52 228 // Process general forums.
cd4e6b17 229 foreach ($generalforums as $forum) {
230 $cm = $modinfo->instances['forum'][$forum->id];
bf0f06b1 231 $context = context_module::instance($cm->id);
cd4e6b17 232
233 $count = forum_count_discussions($forum, $cm, $course);
234
235 if ($usetracking) {
236 if ($forum->trackingtype == FORUM_TRACKING_OFF) {
237 $unreadlink = '-';
238 $trackedlink = '-';
239
240 } else {
241 if (isset($untracked[$forum->id])) {
242 $unreadlink = '-';
243 } else if ($unread = forum_tp_count_forum_unread_posts($cm, $course)) {
428db95d 244 $unreadlink = '<span class="unread"><a href="view.php?f='.$forum->id.'#unread">'.$unread.'</a>';
663640f5 245 $icon = $OUTPUT->pix_icon('t/markasread', $strmarkallread);
cd4e6b17 246 $unreadlink .= '<a title="'.$strmarkallread.'" href="markposts.php?f='.
663640f5 247 $forum->id.'&amp;mark=read&amp;sesskey=' . sesskey() . '">' . $icon . '</a></span>';
cd4e6b17 248 } else {
249 $unreadlink = '<span class="read">0</span>';
250 }
2f3f505f 251
bd8f5d45 252 if (($forum->trackingtype == FORUM_TRACKING_FORCED) && ($CFG->forum_allowforcedreadtracking)) {
cd4e6b17 253 $trackedlink = $stryes;
20e6782f
EM
254 } else if ($forum->trackingtype === FORUM_TRACKING_OFF || ($USER->trackforums == 0)) {
255 $trackedlink = '-';
cd4e6b17 256 } else {
7a311adb
AN
257 $aurl = new moodle_url('/mod/forum/settracking.php', array(
258 'id' => $forum->id,
259 'sesskey' => sesskey(),
260 ));
cd4e6b17 261 if (!isset($untracked[$forum->id])) {
8381ac52 262 $trackedlink = $OUTPUT->single_button($aurl, $stryes, 'post', array('title' => $strnotrackforum));
cd4e6b17 263 } else {
8381ac52 264 $trackedlink = $OUTPUT->single_button($aurl, $strno, 'post', array('title' => $strtrackforum));
cd4e6b17 265 }
266 }
267 }
268 }
269
270 $forum->intro = shorten_text(format_module_intro('forum', $forum, $cm->id), $CFG->forum_shortpost);
0e35ba6f 271 $forumname = format_string($forum->name, true);
cd4e6b17 272
273 if ($cm->visible) {
274 $style = '';
2f3f505f 275 } else {
cd4e6b17 276 $style = 'class="dimmed"';
37b15514 277 }
cd4e6b17 278 $forumlink = "<a href=\"view.php?f=$forum->id\" $style>".format_string($forum->name,true)."</a>";
279 $discussionlink = "<a href=\"view.php?f=$forum->id\" $style>".$count."</a>";
702dc57b 280
cd4e6b17 281 $row = array ($forumlink, $forum->intro, $discussionlink);
282 if ($usetracking) {
283 $row[] = $unreadlink;
284 $row[] = $trackedlink; // Tracking.
285 }
3b8b9b6a 286
8381ac52 287 if ($showsubscriptioncolumns) {
f71df007
AN
288 $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
289 'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
290 'cantsubscribe' => '-'), false, false, true);
291 $row[] = forum_index_get_forum_subscription_selector($forum);
cd4e6b17 292 }
293
8381ac52 294 // If this forum has RSS activated, calculate it.
cd4e6b17 295 if ($show_rss) {
296 if ($forum->rsstype and $forum->rssarticles) {
9e86f2e7 297 //Calculate the tooltip text
cd4e6b17 298 if ($forum->rsstype == 1) {
9e86f2e7 299 $tooltiptext = get_string('rsssubscriberssdiscussions', 'forum');
cd4e6b17 300 } else {
9e86f2e7 301 $tooltiptext = get_string('rsssubscriberssposts', 'forum');
03877b04 302 }
dbf4433d
RW
303
304 if (!isloggedin() && $course->id == SITEID) {
305 $userid = guest_user()->id;
306 } else {
307 $userid = $USER->id;
308 }
cd4e6b17 309 //Get html code for RSS link
dbf4433d 310 $row[] = rss_get_link($context->id, $userid, 'mod_forum', $forum->id, $tooltiptext);
cd4e6b17 311 } else {
312 $row[] = '&nbsp;';
03877b04 313 }
314 }
cd4e6b17 315
316 $generaltable->data[] = $row;
317 }
318}
319
320
321// Start of the table for Learning Forums
322$learningtable = new html_table();
323$learningtable->head = array ($strforum, $strdescription, $strdiscussions);
324$learningtable->align = array ('left', 'left', 'center');
325
326if ($usetracking) {
327 $learningtable->head[] = $strunreadposts;
328 $learningtable->align[] = 'center';
329
330 $learningtable->head[] = $strtracking;
331 $learningtable->align[] = 'center';
332}
333
8381ac52 334if ($showsubscriptioncolumns) {
cd4e6b17 335 $learningtable->head[] = $strsubscribed;
336 $learningtable->align[] = 'center';
8e08c731
AN
337
338 $learningtable->head[] = $stremaildigest . ' ' . $OUTPUT->help_icon('emaildigesttype', 'mod_forum');
339 $learningtable->align[] = 'center';
cd4e6b17 340}
341
8381ac52 342if ($show_rss = (($showsubscriptioncolumns || $course->id == SITEID) &&
cd4e6b17 343 isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) &&
344 $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds)) {
345 $learningtable->head[] = $strrss;
346 $learningtable->align[] = 'center';
347}
348
8381ac52 349// Now let's process the learning forums.
cd4e6b17 350if ($course->id != SITEID) { // Only real courses have learning forums
4202a917 351 // 'format_.'$course->format only applicable when not SITEID (format_site is not a format)
b489d37d 352 $strsectionname = get_string('sectionname', 'format_'.$course->format);
cd4e6b17 353 // Add extra field for section number, at the front
7487c856 354 array_unshift($learningtable->head, $strsectionname);
cd4e6b17 355 array_unshift($learningtable->align, 'center');
03877b04 356
ecc8403e 357
cd4e6b17 358 if ($learningforums) {
359 $currentsection = '';
360 foreach ($learningforums as $forum) {
2f3f505f 361 $cm = $modinfo->instances['forum'][$forum->id];
bf0f06b1 362 $context = context_module::instance($cm->id);
dd97c328 363
90f4745c 364 $count = forum_count_discussions($forum, $cm, $course);
8f0cd6ef 365
eaf50aef 366 if ($usetracking) {
a90e92a5 367 if ($forum->trackingtype == FORUM_TRACKING_OFF) {
368 $unreadlink = '-';
369 $trackedlink = '-';
90f4745c 370
371 } else {
372 if (isset($untracked[$forum->id])) {
cd4e6b17 373 $unreadlink = '-';
90f4745c 374 } else if ($unread = forum_tp_count_forum_unread_posts($cm, $course)) {
428db95d 375 $unreadlink = '<span class="unread"><a href="view.php?f='.$forum->id.'#unread">'.$unread.'</a>';
663640f5 376 $icon = $OUTPUT->pix_icon('t/markasread', $strmarkallread);
c39748f4 377 $unreadlink .= '<a title="'.$strmarkallread.'" href="markposts.php?f='.
663640f5 378 $forum->id.'&amp;mark=read&sesskey=' . sesskey() . '">' . $icon . '</a></span>';
38994d6f 379 } else {
90f4745c 380 $unreadlink = '<span class="read">0</span>';
38994d6f 381 }
630bd96b 382
bd8f5d45 383 if (($forum->trackingtype == FORUM_TRACKING_FORCED) && ($CFG->forum_allowforcedreadtracking)) {
90f4745c 384 $trackedlink = $stryes;
20e6782f
EM
385 } else if ($forum->trackingtype === FORUM_TRACKING_OFF || ($USER->trackforums == 0)) {
386 $trackedlink = '-';
a90e92a5 387 } else {
8381ac52 388 $aurl = new moodle_url('/mod/forum/settracking.php', array('id' => $forum->id));
90f4745c 389 if (!isset($untracked[$forum->id])) {
8381ac52 390 $trackedlink = $OUTPUT->single_button($aurl, $stryes, 'post', array('title' => $strnotrackforum));
90f4745c 391 } else {
8381ac52 392 $trackedlink = $OUTPUT->single_button($aurl, $strno, 'post', array('title' => $strtrackforum));
90f4745c 393 }
630bd96b 394 }
f37da850 395 }
396 }
397
4ba2221a 398 $forum->intro = shorten_text(format_module_intro('forum', $forum, $cm->id), $CFG->forum_shortpost);
cd4e6b17 399
400 if ($cm->sectionnum != $currentsection) {
71a56e08 401 $printsection = get_section_name($course, $cm->sectionnum);
cd4e6b17 402 if ($currentsection) {
403 $learningtable->data[] = 'hr';
404 }
405 $currentsection = $cm->sectionnum;
406 } else {
407 $printsection = '';
408 }
409
0e35ba6f 410 $forumname = format_string($forum->name,true);
ecc8403e 411
90f4745c 412 if ($cm->visible) {
413 $style = '';
ecc8403e 414 } else {
90f4745c 415 $style = 'class="dimmed"';
ecc8403e 416 }
90f4745c 417 $forumlink = "<a href=\"view.php?f=$forum->id\" $style>".format_string($forum->name,true)."</a>";
418 $discussionlink = "<a href=\"view.php?f=$forum->id\" $style>".$count."</a>";
ecc8403e 419
cd4e6b17 420 $row = array ($printsection, $forumlink, $forum->intro, $discussionlink);
49b53f26 421 if ($usetracking) {
422 $row[] = $unreadlink;
423 $row[] = $trackedlink; // Tracking.
f4646b44 424 }
425
8381ac52 426 if ($showsubscriptioncolumns) {
f71df007
AN
427 $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
428 'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
429 'cantsubscribe' => '-'), false, false, true);
430 $row[] = forum_index_get_forum_subscription_selector($forum);
49b53f26 431 }
432
433 //If this forum has RSS activated, calculate it
90f4745c 434 if ($show_rss) {
435 if ($forum->rsstype and $forum->rssarticles) {
436 //Calculate the tolltip text
437 if ($forum->rsstype == 1) {
9e86f2e7 438 $tooltiptext = get_string('rsssubscriberssdiscussions', 'forum');
90f4745c 439 } else {
9e86f2e7 440 $tooltiptext = get_string('rsssubscriberssposts', 'forum');
90f4745c 441 }
442 //Get html code for RSS link
aa60291e 443 $row[] = rss_get_link($context->id, $USER->id, 'mod_forum', $forum->id, $tooltiptext);
49b53f26 444 } else {
90f4745c 445 $row[] = '&nbsp;';
f4646b44 446 }
ecc8403e 447 }
49b53f26 448
cd4e6b17 449 $learningtable->data[] = $row;
ecc8403e 450 }
8f0cd6ef 451 }
cd4e6b17 452}
453
8381ac52 454// Output the page.
cd4e6b17 455$PAGE->navbar->add($strforums);
456$PAGE->set_title("$course->shortname: $strforums");
457$PAGE->set_heading($course->fullname);
cd4e6b17 458echo $OUTPUT->header();
459
92833547
SH
460echo html_writer::start_div('input-group mr-5');
461echo $searchform;
462echo html_writer::end_div();
463
8381ac52
AN
464if (!isguestuser() && isloggedin() && $showsubscriptioncolumns) {
465 // Show the subscribe all options only to non-guest, enrolled users.
cd4e6b17 466 echo $OUTPUT->box_start('subscription');
8381ac52
AN
467
468 $subscriptionlink = new moodle_url('/mod/forum/index.php', [
469 'id' => $course->id,
470 'sesskey' => sesskey(),
471 ]);
472
473 // Subscribe all.
474 $subscriptionlink->param('subscribe', 1);
475 echo html_writer::tag('div', html_writer::link($subscriptionlink, get_string('allsubscribe', 'forum')), [
476 'class' => 'helplink',
477 ]);
478
479 // Unsubscribe all.
480 $subscriptionlink->param('subscribe', 0);
481 echo html_writer::tag('div', html_writer::link($subscriptionlink, get_string('allunsubscribe', 'forum')), [
482 'class' => 'helplink',
483 ]);
484
cd4e6b17 485 echo $OUTPUT->box_end();
486 echo $OUTPUT->box('&nbsp;', 'clearer');
487}
488
489if ($generalforums) {
66e2b9f8 490 echo $OUTPUT->heading(get_string('generalforums', 'forum'), 2);
16be8974 491 echo html_writer::table($generaltable);
cd4e6b17 492}
493
494if ($learningforums) {
66e2b9f8 495 echo $OUTPUT->heading(get_string('learningforums', 'forum'), 2);
16be8974 496 echo html_writer::table($learningtable);
cd4e6b17 497}
498
499echo $OUTPUT->footer();
f71df007
AN
500
501/**
502 * Get the content of the forum subscription options for this forum.
503 *
504 * @param stdClass $forum The forum to return options for
505 * @return string
506 */
507function forum_index_get_forum_subscription_selector($forum) {
c42c2355 508 global $OUTPUT, $PAGE;
f71df007
AN
509
510 if ($forum->cansubscribe || $forum->issubscribed) {
c42c2355
AN
511 if ($forum->maildigest === null) {
512 $forum->maildigest = -1;
513 }
514
515 $renderer = $PAGE->get_renderer('mod_forum');
516 return $OUTPUT->render($renderer->render_digest_options($forum, $forum->maildigest));
f71df007
AN
517 } else {
518 // This user can subscribe to some forums. Add the empty fields.
519 return '';
520 }
521};