if ($forum->trackingtype == FORUM_TRACKING_OPTIONAL) {
- $trackedlink = '<a title="'.$strnotrackforum.'" href="settracking.php?id='.
- $forum->id.'">'.$stryes.'</a>';
+ $trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $stryes, 'post', '_self', true, $strnotrackforum);
}
else {
$trackedlink = $stryes;
}
} else {
$unreadlink = '-';
- $trackedlink = '<a title="'.$strtrackforum.'" href="settracking.php?id='.
- $forum->id.'">'.$strno.'</a>';
+ $trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $strno, 'post', '_self', true, $strtrackforum);
}
}
if ($can_subscribe) {
$row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
- 'cantsubscribe' => '-'), $cantaccessagroup);
+ 'cantsubscribe' => '-'), $cantaccessagroup, false);
}
//If this forum has RSS activated, calculate it
$unreadlink = '<span class="read"><a href="view.php?f='.$forum->id.'">'.$unread.'</a></span>';
}
if ($forum->trackingtype == FORUM_TRACKING_OPTIONAL) {
- $trackedlink = '<a title="'.$strnotrackforum.'" href="settracking.php?id='.
- $forum->id.'">'.$stryes.'</a>';
+ $trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $stryes, 'post', '_self', true, $strnotrackforum);
}
} else {
$unreadlink = '-';
- $trackedlink = '<a title="'.$strtrackforum.'" href="settracking.php?id='.$forum->id.'">'.$strno.'</a>';
+ $trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $strno, 'post', '_self', true, $strtrackforum);
}
}
if ($can_subscribe) {
$row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
- 'cantsubscribe' => '-'), $cantaccessagroup);
+ 'cantsubscribe' => '-'), $cantaccessagroup, false);
}
//If this forum has RSS activated, calculate it
* at the top of the function.
* @param
*/
-function forum_get_subscribe_link($forum, $context, $messages = array(), $cantaccessagroup = false) {
+function forum_get_subscribe_link($forum, $context, $messages = array(), $cantaccessagroup = false, $fakelink=true) {
global $CFG, $USER;
$defaultmessages = array(
'subscribed' => get_string('unsubscribe', 'forum'),
$linktitle = get_string('subscribestart', 'forum');
}
- $link = '<script type="text/javascript">';
- $link .= 'document.getElementById("subscriptionlink").innerHTML = "<a title=\"' . $linktitle . '\" href=\"' . $CFG->wwwroot .
- '/mod/forum/subscribe.php?id=' . $forum->id . '\">' . $linktext . '</a>";';
- $link .= '</script>';
- // use <noscript> to print button in case javascript is not enabled
- $link .= '<noscript>';
+ $link = '';
+ if ($fakelink) {
+ $link .= '<script type="text/javascript">';
+ $link .= '//<![CDATA['."\n";
+ $link .= 'document.getElementById("subscriptionlink").innerHTML = "<a title=\"' . $linktitle . '\" href=\"' . $CFG->wwwroot .
+ '/mod/forum/subscribe.php?id=' . $forum->id . '\">' . $linktext . '<\/a>";';
+ $link .= '//]]>';
+ $link .= '</script>';
+ // use <noscript> to print button in case javascript is not enabled
+ $link .= '<noscript>';
+ }
$link .= print_single_button($CFG->wwwroot . '/mod/forum/subscribe.php?id=' . $forum->id,
'', $linktext, 'post', '_self', true, $linktitle);
- $link .= '</noscript>';
+ if ($fakelink) {
+ $link .= '</noscript>';
+ }
return $link;
}
}
+
+/**
+ * Generate and return the track or no track link for a forum.
+ * @param object $forum the forum. Fields used are $forum->id and $forum->forcesubscribe.
+ */
+function forum_get_tracking_link($forum, $messages=array(), $fakelink=true) {
+ global $CFG, $USER;
+
+ static $strnotrackforum, $strtrackforum;
+
+ if (isset($messages['trackforum'])) {
+ $strtrackforum = $messages['trackforum'];
+ }
+ if (isset($messages['notrackforum'])) {
+ $strnotrackforum = $messages['notrackforum'];
+ }
+ if (empty($strtrackforum)) {
+ $strtrackforum = get_string('trackforum', 'forum');
+ }
+ if (empty($strnotrackforum)) {
+ $strnotrackforum = get_string('notrackforum', 'forum');
+ }
+
+ if (forum_tp_is_tracked($forum, $USER->id)) {
+ $linktitle = $strnotrackforum;
+ $linktext = $strtrackforum;
+ } else {
+ $linktitle = $strtrackforum;
+ $linktext = $strnotrackforum;
+ }
+
+ $link = '';
+ if ($fakelink) {
+ $link .= '<script type="text/javascript">';
+ $link .= '//<![CDATA['."\n";
+ $link .= 'document.getElementById("trackinglink").innerHTML = "<a title=\"' . $linktitle . '\" href=\"' . $CFG->wwwroot .
+ '/mod/forum/settracking.php?id=' . $forum->id . '\">' . $linktext . '<\/a>";'."\n";
+ $link .= '//]]>'."\n";
+ $link .= '</script>';
+ // use <noscript> to print button in case javascript is not enabled
+ $link .= '<noscript>';
+ }
+ $link .= print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id,
+ '', $linktext, 'post', '_self', true, $linktitle);
+ if ($fakelink) {
+ $link .= '</noscript>';
+ }
+
+ return $link;
+}
+
+
+
/**
*
*/
} else {
echo $streveryoneisnowsubscribed;
}
- echo '</span>';
+ echo '</span><br />';
} else if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
$strsubscriptionsoff = get_string('disallowsubscribe','forum');
echo '<span class="helplink">'.$streveryonecannowchoose.'</span>';
}
- echo '<br /><span class="helplink" id="subscriptionlink">', forum_get_subscribe_link($forum, $context,
- array('forcesubscribed' => '', 'cantsubscribe' => '')), '</span>';
+ echo '<div class="helplink" id="subscriptionlink">', forum_get_subscribe_link($forum, $context,
+ array('forcesubscribed' => '', 'cantsubscribe' => '')), '</div>';
}
- if (forum_tp_can_track_forums($forum) && ($forum->trackingtype == FORUM_TRACKING_OPTIONAL)) {
- if (forum_tp_is_tracked($forum, $USER->id)) {
- $trtitle = get_string('notrackforum', 'forum');
- $trackedlink = '<a title="'.get_string('notrackforum', 'forum').'" href="settracking.php?id='.
- $forum->id.'&returnpage=view.php">'.get_string('forumtracked', 'forum').'</a>';
- } else {
- $trtitle = get_string('trackforum', 'forum');
- $trackedlink = '<a title="'.get_string('trackforum', 'forum').'" href="settracking.php?id='.
- $forum->id.'&returnpage=view.php">'.get_string('forumtrackednot', 'forum').'</a>';
- }
- echo '<br />';
- echo "<span class=\"helplink\">$trackedlink</span>";
+ if (($forum->trackingtype == FORUM_TRACKING_OPTIONAL) && forum_tp_can_track_forums($forum)) {
+ echo '<div class="helplink" id="trackinglink">'. forum_get_tracking_link($forum). '</div';
}
}