本文整理汇总了PHP中forum_get_discussion_subscription_icon函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_get_discussion_subscription_icon函数的具体用法?PHP forum_get_discussion_subscription_icon怎么用?PHP forum_get_discussion_subscription_icon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_get_discussion_subscription_icon函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_print_discussion_header
//.........这里部分代码省略.........
echo '<td class="' . $topicclass . '">';
if (FORUM_DISCUSSION_PINNED == $post->pinned) {
echo $OUTPUT->pix_icon('i/pinned', get_string('discussionpinned', 'forum'), 'mod_forum');
}
$canalwaysseetimedpost = $USER->id == $post->userid || $canviewhiddentimedposts;
if ($timeddiscussion && $canalwaysseetimedpost) {
echo $PAGE->get_renderer('mod_forum')->timed_discussion_tooltip($post, empty($timedoutsidewindow));
}
echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">' . $post->subject . '</a>';
echo "</td>\n";
// Picture
$postuser = new stdClass();
$postuserfields = explode(',', user_picture::fields());
$postuser = username_load_fields_from_object($postuser, $post, null, $postuserfields);
$postuser->id = $post->userid;
echo '<td class="picture">';
echo $OUTPUT->user_picture($postuser, array('courseid' => $forum->course));
echo "</td>\n";
// User name
$fullname = fullname($postuser, has_capability('moodle/site:viewfullnames', $modcontext));
echo '<td class="author">';
echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $forum->course . '">' . $fullname . '</a>';
echo "</td>\n";
// Group picture
if ($group !== -1) {
// Groups are active - group is a group data object or NULL
echo '<td class="picture group">';
if (!empty($group->picture) and empty($group->hidepicture)) {
if ($canviewparticipants && $COURSE->groupmode) {
$picturelink = true;
} else {
$picturelink = false;
}
print_group_picture($group, $forum->course, false, false, $picturelink);
} else {
if (isset($group->id)) {
if ($canviewparticipants && $COURSE->groupmode) {
echo '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $forum->course . '&group=' . $group->id . '">' . $group->name . '</a>';
} else {
echo $group->name;
}
}
}
echo "</td>\n";
}
if (has_capability('mod/forum:viewdiscussion', $modcontext)) {
// Show the column with replies
echo '<td class="replies">';
echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">';
echo $post->replies . '</a>';
echo "</td>\n";
if ($cantrack) {
echo '<td class="replies">';
if ($forumtracked) {
if ($post->unread > 0) {
echo '<span class="unread">';
echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#unread">';
echo $post->unread;
echo '</a>';
echo '<a title="' . $strmarkalldread . '" href="' . $CFG->wwwroot . '/mod/forum/markposts.php?f=' . $forum->id . '&d=' . $post->discussion . '&mark=read&returnpage=view.php&sesskey=' . sesskey() . '">' . '<img src="' . $OUTPUT->pix_url('t/markasread') . '" class="iconsmall" alt="' . $strmarkalldread . '" /></a>';
echo '</span>';
} else {
echo '<span class="read">';
echo $post->unread;
echo '</span>';
}
} else {
echo '<span class="read">';
echo '-';
echo '</span>';
}
echo "</td>\n";
}
}
echo '<td class="lastpost">';
$usedate = empty($post->timemodified) ? $post->modified : $post->timemodified;
// Just in case
$parenturl = '';
$usermodified = new stdClass();
$usermodified->id = $post->usermodified;
$usermodified = username_load_fields_from_object($usermodified, $post, 'um');
// In QA forums we check that the user can view participants.
if ($forum->type !== 'qanda' || $canviewparticipants) {
echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->usermodified . '&course=' . $forum->course . '">' . fullname($usermodified) . '</a><br />';
$parenturl = empty($post->lastpostid) ? '' : '&parent=' . $post->lastpostid;
}
echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $parenturl . '">' . userdate($usedate, $datestring) . '</a>';
echo "</td>\n";
// is_guest should be used here as this also checks whether the user is a guest in the current course.
// Guests and visitors cannot subscribe - only enrolled users.
if (!is_guest($modcontext, $USER) && isloggedin() && has_capability('mod/forum:viewdiscussion', $modcontext)) {
// Discussion subscription.
if (\mod_forum\subscriptions::is_subscribable($forum)) {
echo '<td class="discussionsubscription">';
echo forum_get_discussion_subscription_icon($forum, $post->discussion);
echo '</td>';
}
}
echo "</tr>\n\n";
}
示例2: forum_print_discussion_header
//.........这里部分代码省略.........
print_error('invalidcoursemodule');
}
$modcontext = context_module::instance($cm->id);
}
if (!isset($rowcount)) {
$rowcount = 0;
$strmarkalldread = get_string('markalldread', 'forum');
} else {
$rowcount = ($rowcount + 1) % 2;
}
$post->subject = format_string($post->subject, true);
echo "\n\n";
echo '<tr class="discussion r' . $rowcount . '">';
// Topic
echo '<td class="topic starter">';
echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">' . $post->subject . '</a>';
echo "</td>\n";
// Picture
$postuser = new stdClass();
$postuserfields = explode(',', user_picture::fields());
$postuser = username_load_fields_from_object($postuser, $post, null, $postuserfields);
$postuser->id = $post->userid;
echo '<td class="picture">';
echo $OUTPUT->user_picture($postuser, array('courseid' => $forum->course));
echo "</td>\n";
// User name
$fullname = fullname($postuser, has_capability('moodle/site:viewfullnames', $modcontext));
echo '<td class="author">';
echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $forum->course . '">' . $fullname . '</a>';
echo "</td>\n";
// Group picture
if ($group !== -1) {
// Groups are active - group is a group data object or NULL
echo '<td class="picture group">';
if (!empty($group->picture) and empty($group->hidepicture)) {
print_group_picture($group, $forum->course, false, false, true);
} else {
if (isset($group->id)) {
if ($canviewparticipants) {
echo '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $forum->course . '&group=' . $group->id . '">' . $group->name . '</a>';
} else {
echo $group->name;
}
}
}
echo "</td>\n";
}
if (has_capability('mod/forum:viewdiscussion', $modcontext)) {
// Show the column with replies
echo '<td class="replies">';
echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">';
echo $post->replies . '</a>';
echo "</td>\n";
if ($cantrack) {
echo '<td class="replies">';
if ($forumtracked) {
if ($post->unread > 0) {
echo '<span class="unread">';
echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#unread">';
echo $post->unread;
echo '</a>';
echo '<a title="' . $strmarkalldread . '" href="' . $CFG->wwwroot . '/mod/forum/markposts.php?f=' . $forum->id . '&d=' . $post->discussion . '&mark=read&returnpage=view.php">' . '<img src="' . $OUTPUT->pix_url('t/markasread') . '" class="iconsmall" alt="' . $strmarkalldread . '" /></a>';
echo '</span>';
} else {
echo '<span class="read">';
echo $post->unread;
echo '</span>';
}
} else {
echo '<span class="read">';
echo '-';
echo '</span>';
}
echo "</td>\n";
}
}
echo '<td class="lastpost">';
$usedate = empty($post->timemodified) ? $post->modified : $post->timemodified;
// Just in case
$parenturl = '';
$usermodified = new stdClass();
$usermodified->id = $post->usermodified;
$usermodified = username_load_fields_from_object($usermodified, $post, 'um');
// Show link to last poster and their post if user can see them.
if ($canviewparticipants) {
echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->usermodified . '&course=' . $forum->course . '">' . fullname($usermodified) . '</a><br />';
$parenturl = empty($post->lastpostid) ? '' : '&parent=' . $post->lastpostid;
}
echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $parenturl . '">' . userdate($usedate, $datestring) . '</a>';
echo "</td>\n";
if (has_capability('mod/forum:viewdiscussion', $modcontext)) {
// Discussion subscription.
if (\mod_forum\subscriptions::is_subscribable($forum)) {
echo '<td class="discussionsubscription">';
echo forum_get_discussion_subscription_icon($forum, $post->discussion);
echo '</td>';
}
}
echo "</tr>\n\n";
}
示例3: format_string
if ($node && $post->id != $discussion->firstpost) {
$node->add(format_string($post->subject), $PAGE->url);
}
$PAGE->set_title("{$course->shortname}: " . format_string($discussion->name));
$PAGE->set_heading($course->fullname);
$PAGE->set_button($searchform);
$renderer = $PAGE->get_renderer('mod_forum');
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($forum->name), 2);
echo $OUTPUT->heading(format_string($discussion->name), 3, 'discussionname');
// is_guest should be used here as this also checks whether the user is a guest in the current course.
// Guests and visitors cannot subscribe - only enrolled users.
if (!is_guest($modcontext, $USER) && isloggedin() && has_capability('mod/forum:viewdiscussion', $modcontext)) {
// Discussion subscription.
if (\mod_forum\subscriptions::is_subscribable($forum)) {
echo html_writer::div(forum_get_discussion_subscription_icon($forum, $post->discussion, null, true), 'discussionsubscription');
echo forum_get_discussion_subscription_icon_preloaders();
}
}
/// Check to see if groups are being used in this forum
/// If so, make sure the current person is allowed to see this discussion
/// Also, if we know they should be able to reply, then explicitly set $canreply for performance reasons
$canreply = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
if (!$canreply and $forum->type !== 'news') {
if (isguestuser() or !isloggedin()) {
$canreply = true;
}
if (!is_enrolled($modcontext) and !is_viewing($modcontext)) {
// allow guests and not-logged-in to see the link - they are prompted to log in after clicking the link
// normal users with temporary guest access see this link too, they are asked to enrol instead
$canreply = enrol_selfenrol_available($course->id);
示例4: optional_param
$includetext = optional_param('includetext', false, PARAM_BOOL);
$forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST);
$discussion = $DB->get_record('forum_discussions', array('id' => $discussionid, 'forum' => $forumid), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
$context = context_module::instance($cm->id);
require_sesskey();
require_login($course, false, $cm);
require_capability('mod/forum:viewdiscussion', $context);
$return = new stdClass();
if (is_guest($context, $USER)) {
// is_guest should be used here as this also checks whether the user is a guest in the current course.
// Guests and visitors cannot subscribe - only enrolled users.
throw new moodle_exception('noguestsubscribe', 'mod_forum');
}
if (!\mod_forum\subscriptions::is_subscribable($forum)) {
// Nothing to do. We won't actually output any content here though.
echo json_encode($return);
die;
}
if (\mod_forum\subscriptions::is_subscribed($USER->id, $forum, $discussion->id, $cm)) {
// The user is subscribed, unsubscribe them.
\mod_forum\subscriptions::unsubscribe_user_from_discussion($USER->id, $discussion, $context);
} else {
// The user is unsubscribed, subscribe them.
\mod_forum\subscriptions::subscribe_user_to_discussion($USER->id, $discussion, $context);
}
// Now return the updated subscription icon.
$return->icon = forum_get_discussion_subscription_icon($forum, $discussion->id, null, $includetext);
echo json_encode($return);
die;
示例5: format_string
$node->add(format_string($post->subject), $PAGE->url);
}
$PAGE->set_title("$course->shortname: ".format_string($discussion->name));
$PAGE->set_heading($course->fullname);
$PAGE->set_button($searchform);
$renderer = $PAGE->get_renderer('mod_forum');
echo $OUTPUT->header();
$headingvalue = format_string($forum->name);
if ((!isguestuser() && isloggedin()) && has_capability('mod/forum:viewdiscussion', $modcontext)) {
// Discussion subscription.
if (\mod_forum\subscriptions::is_subscribable($forum)) {
$headingvalue .= ' ';
$headingvalue .= html_writer::tag('span', forum_get_discussion_subscription_icon($forum, $post->discussion), array(
'class' => 'discussionsubscription',
));
}
}
echo $OUTPUT->heading($headingvalue, 2);
/// Check to see if groups are being used in this forum
/// If so, make sure the current person is allowed to see this discussion
/// Also, if we know they should be able to reply, then explicitly set $canreply for performance reasons
$canreply = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
if (!$canreply and $forum->type !== 'news') {
if (isguestuser() or !isloggedin()) {
$canreply = true;
示例6: forum_get_discussion_subscription_icon
$PAGE->set_heading($course->fullname);
$PAGE->set_button($searchform);
$renderer = $PAGE->get_renderer('mod_forum');
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($forum->name), 2);
echo $OUTPUT->heading(format_string($discussion->name), 3, 'discussionname');
// is_guest should be used here as this also checks whether the user is a guest in the current course.
// Guests and visitors cannot subscribe - only enrolled users.
if ((!is_guest($modcontext, $USER) && isloggedin()) && has_capability('mod/forum:viewdiscussion', $modcontext)) {
// Discussion subscription.
if (\mod_forum\subscriptions::is_subscribable($forum)) {
echo html_writer::div(
forum_get_discussion_subscription_icon($forum, $post->discussion, null, true),
'discussionsubscription'
);
echo forum_get_discussion_subscription_icon_preloaders();
}
}
/// Check to see if groups are being used in this forum
/// If so, make sure the current person is allowed to see this discussion
/// Also, if we know they should be able to reply, then explicitly set $canreply for performance reasons
$canreply = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
if (!$canreply and $forum->type !== 'news') {
if (isguestuser() or !isloggedin()) {
$canreply = true;
示例7: define
define('AJAX_SCRIPT', true);
require_once dirname(dirname(__DIR__)) . '/config.php';
require_once $CFG->dirroot . '/mod/forum/lib.php';
$forumid = required_param('forumid', PARAM_INT);
// The forum to subscribe or unsubscribe.
$discussionid = optional_param('discussionid', null, PARAM_INT);
// The discussionid to subscribe.
$sesskey = optional_param('sesskey', null, PARAM_RAW);
$forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST);
$discussion = $DB->get_record('forum_discussions', array('id' => $discussionid), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
$context = context_module::instance($cm->id);
require_login($course, false, $cm);
$return = new stdClass();
if (!\mod_forum\subscriptions::is_subscribable($forum)) {
// Nothing to do. We won't actually output any content here though.
echo json_encode($return);
die;
}
if (\mod_forum\subscriptions::is_subscribed($USER->id, $forum, $discussion->id, $cm)) {
// The user is subscribed, unsubscribe them.
\mod_forum\subscriptions::unsubscribe_user_from_discussion($USER->id, $discussion, $context);
} else {
// The user is unsubscribed, subscribe them.
\mod_forum\subscriptions::subscribe_user_to_discussion($USER->id, $discussion, $context);
}
// Now return the updated subscription icon.
$return->icon = forum_get_discussion_subscription_icon($forum, $discussion->id);
echo json_encode($return);
die;