• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP forum_unsubscribe函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中forum_unsubscribe函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_unsubscribe函数的具体用法?PHP forum_unsubscribe怎么用?PHP forum_unsubscribe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: forum_is_subscribed

        $forum = $forums[$forumid];
        $modcontext = context_module::instance($cm->id);
        $cansub = false;
        if (has_capability('mod/forum:viewdiscussion', $modcontext)) {
            $cansub = true;
        }
        if ($cansub && $cm->visible == 0 && !has_capability('mod/forum:managesubscriptions', $modcontext)) {
            $cansub = false;
        }
        if (!forum_is_forcesubscribed($forum)) {
            $subscribed = forum_is_subscribed($USER->id, $forum);
            if ((has_capability('moodle/course:manageactivities', $coursecontext, $USER->id) || $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE) && $subscribe && !$subscribed && $cansub) {
                forum_subscribe($USER->id, $forumid, $modcontext);
            } else {
                if (!$subscribe && $subscribed) {
                    forum_unsubscribe($USER->id, $forumid, $modcontext);
                }
            }
        }
    }
    $returnto = forum_go_back_to("index.php?id={$course->id}");
    $shortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
    if ($subscribe) {
        redirect($returnto, get_string('nowallsubscribed', 'forum', $shortname), 1);
    } else {
        redirect($returnto, get_string('nowallunsubscribed', 'forum', $shortname), 1);
    }
}
/// First, let's process the general forums and build up a display
if ($generalforums) {
    foreach ($generalforums as $forum) {
开发者ID:gwsd2015,项目名称:LogiClass,代码行数:31,代码来源:index.php


示例2: forum_post_subscription

/**
 * Given a new post, subscribes or unsubscribes as appropriate.
 * Returns some text which describes what happened.
 *
 * @global objec
 * @param object $post
 * @param object $forum
 */
function forum_post_subscription($post, $forum) {

    global $USER;

    $action = '';
    $subscribed = forum_is_subscribed($USER->id, $forum);

    if ($forum->forcesubscribe == FORUM_FORCESUBSCRIBE) { // database ignored
        return "";

    } elseif (($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE)
        && !has_capability('moodle/course:manageactivities', context_course::instance($forum->course), $USER->id)) {
        if ($subscribed) {
            $action = 'unsubscribe'; // sanity check, following MDL-14558
        } else {
            return "";
        }

    } else { // go with the user's choice
        if (isset($post->subscribe)) {
            // no change
            if ((!empty($post->subscribe) && $subscribed)
                || (empty($post->subscribe) && !$subscribed)) {
                return "";

            } elseif (!empty($post->subscribe) && !$subscribed) {
                $action = 'subscribe';

            } elseif (empty($post->subscribe) && $subscribed) {
                $action = 'unsubscribe';
            }
        }
    }

    $info = new stdClass();
    $info->name  = fullname($USER);
    $info->forum = format_string($forum->name);

    switch ($action) {
        case 'subscribe':
            forum_subscribe($USER->id, $post->forum);
            return "<p>".get_string("nowsubscribed", "forum", $info)."</p>";
        case 'unsubscribe':
            forum_unsubscribe($USER->id, $post->forum);
            return "<p>".get_string("nownotsubscribed", "forum", $info)."</p>";
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:55,代码来源:lib.php


示例3: array_merge

                }
                break;
        }
    }
}
/// Do course wide subscribe/unsubscribe
if (!is_null($subscribe) && !isguest()) {
    $allforums = array_merge($generalforums, $learningforums);
    if ($allforums) {
        foreach ($allforums as $forum) {
            if (!forum_is_forcesubscribed($forum->id)) {
                $subscribed = forum_is_subscribed($USER->id, $forum->id);
                if ($subscribe && !$subscribed) {
                    forum_subscribe($USER->id, $forum->id);
                } elseif (!$subscribe && $subscribed) {
                    forum_unsubscribe($USER->id, $forum->id);
                }
            }
        }
    }
    $returnto = forum_go_back_to("index.php?id={$course->id}");
    if ($subscribe) {
        add_to_log($course->id, "forum", "subscribeall", "index.php?id={$course->id}", $course->id);
        redirect($returnto, get_string("nowallsubscribed", "forum", format_string($course->shortname)), 1);
    } else {
        add_to_log($course->id, "forum", "unsubscribeall", "index.php?id={$course->id}", $course->id);
        redirect($returnto, get_string("nowallunsubscribed", "forum", format_string($course->shortname)), 1);
    }
}
/// First, let's process the general forums and build up a display
if ($generalforums) {
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:index.php


示例4: forum_remove_user_subscriptions

/**
 * Remove subscriptions for a user in a context
 *
 * @global object
 * @global object
 * @uses CONTEXT_SYSTEM
 * @uses CONTEXT_COURSECAT
 * @uses CONTEXT_COURSE
 * @uses CONTEXT_MODULE
 * @param int $userid
 * @param object $context
 * @return bool
 */
function forum_remove_user_subscriptions($userid, $context) {

    global $CFG, $DB;

    if (empty($context->contextlevel)) {
        return false;
    }

    switch ($context->contextlevel) {

        case CONTEXT_SYSTEM:   // For the whole site
            // find all courses in which this user has a forum subscription
            if ($courses = $DB->get_records_sql("SELECT c.id
                                                  FROM {course} c,
                                                       {forum_subscriptions} fs,
                                                       {forum} f
                                                       WHERE c.id = f.course AND f.id = fs.forum AND fs.userid = ?
                                                       GROUP BY c.id", array($userid))) {

                foreach ($courses as $course) {
                    $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
                    forum_remove_user_subscriptions($userid, $subcontext);
                }
            }
            break;

        case CONTEXT_COURSECAT:   // For a whole category
             if ($courses = $DB->get_records('course', array('category' => $context->instanceid), '', 'id')) {
                 foreach ($courses as $course) {
                     $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
                     forum_remove_user_subscriptions($userid, $subcontext);
                 }
             }
             if ($categories = $DB->get_records('course_categories', array('parent' => $context->instanceid), '', 'id')) {
                 foreach ($categories as $category) {
                     $subcontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
                     forum_remove_user_subscriptions($userid, $subcontext);
                 }
             }
             break;

        case CONTEXT_COURSE:   // For a whole course
            if (!is_enrolled($context, $userid)) {
                 if ($course = $DB->get_record('course', array('id' => $context->instanceid), 'id')) {
                    // find all forums in which this user has a subscription, and its coursemodule id
                    if ($forums = $DB->get_records_sql("SELECT f.id, cm.id as coursemodule
                                                         FROM {forum} f,
                                                              {modules} m,
                                                              {course_modules} cm,
                                                              {forum_subscriptions} fs
                                                        WHERE fs.userid = ? AND f.course = ?
                                                              AND fs.forum = f.id AND cm.instance = f.id
                                                              AND cm.module = m.id AND m.name = 'forum'", array($userid, $context->instanceid))) {

                         foreach ($forums as $forum) {
                             if ($modcontext = get_context_instance(CONTEXT_MODULE, $forum->coursemodule)) {
                                 if (!has_capability('mod/forum:viewdiscussion', $modcontext, $userid)) {
                                     forum_unsubscribe($userid, $forum->id);
                                 }
                             }
                         }
                     }
                 }
            }
            break;

        case CONTEXT_MODULE:   // Just one forum
            if (!is_enrolled($context, $userid)) {
                 if ($cm = get_coursemodule_from_id('forum', $context->instanceid)) {
                     if ($forum = $DB->get_record('forum', array('id' => $cm->instance))) {
                         if (!has_capability('mod/forum:viewdiscussion', $context, $userid)) {
                             forum_unsubscribe($userid, $forum->id);
                         }
                     }
                 }
            }
            break;
    }

    return true;
}
开发者ID:nfreear,项目名称:moodle,代码行数:94,代码来源:lib.php


示例5: forum_forcesubscribe

if ($force and has_capability('mod/forum:managesubscriptions', $context)) {
    if (forum_is_forcesubscribed($forum)) {
        forum_forcesubscribe($forum->id, 0);
        redirect($returnto, get_string("everyonecannowchoose", "forum"), 1);
    } else {
        forum_forcesubscribe($forum->id, 1);
        redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
    }
}
if (forum_is_forcesubscribed($forum)) {
    redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
}
$info->name = fullname($user);
$info->forum = format_string($forum->name);
if (forum_is_subscribed($user->id, $forum->id)) {
    if (forum_unsubscribe($user->id, $forum->id)) {
        add_to_log($course->id, "forum", "unsubscribe", "view.php?f={$forum->id}", $forum->id, $cm->id);
        redirect($returnto, get_string("nownotsubscribed", "forum", $info), 1);
    } else {
        print_error('cannotunsubscribe', 'forum', $_SERVER["HTTP_REFERER"]);
    }
} else {
    // subscribe
    if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !has_capability('mod/forum:managesubscriptions', $context)) {
        print_error('disallowsubscribe', 'forum', $_SERVER["HTTP_REFERER"]);
    }
    if (!has_capability('mod/forum:viewdiscussion', $context)) {
        print_error('cannotsubscribe', 'forum', $_SERVER["HTTP_REFERER"]);
    }
    if (forum_subscribe($user->id, $forum->id)) {
        add_to_log($course->id, "forum", "subscribe", "view.php?f={$forum->id}", $forum->id, $cm->id);
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:subscribe.php


示例6: get_string

$strshowall = get_string("showall");
$strsubscribers = get_string("subscribers", "forum");
$strforums = get_string("forums", "forum");
$searchtext = optional_param('searchtext', '', PARAM_RAW);
if ($frm = data_submitted()) {
    /// A form was submitted so process the input
    if (!empty($frm->add) and !empty($frm->addselect)) {
        foreach ($frm->addselect as $addsubscriber) {
            if (!forum_subscribe($addsubscriber, $id)) {
                print_error('cannotaddsubscriber', 'forum', '', $addsubscriber);
            }
        }
    } else {
        if (!empty($frm->remove) and !empty($frm->removeselect)) {
            foreach ($frm->removeselect as $removesubscriber) {
                if (!forum_unsubscribe($removesubscriber, $id)) {
                    print_error('cannotremovesubscriber', 'forum', '', $removesubscriber);
                }
            }
        } else {
            if (!empty($frm->showall)) {
                $searchtext = '';
            }
        }
    }
}
/// Get all existing subscribers for this forum.
if (!($subscribers = forum_subscribed_users($course, $forum, $currentgroup, $context))) {
    $subscribers = array();
}
/// Get all the potential subscribers excluding users already subscribed
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:subscribers.php


示例7: test_forum_subscribe_toggle_as_other

 /**
  * Test that toggling the forum-level subscription for a different user does not affect their discussion-level
  * subscriptions.
  */
 public function test_forum_subscribe_toggle_as_other()
 {
     global $DB;
     $this->resetAfterTest(true);
     // Create a course, with a forum.
     $course = $this->getDataGenerator()->create_course();
     $options = array('course' => $course->id, 'forcesubscribe' => FORUM_CHOOSESUBSCRIBE);
     $forum = $this->getDataGenerator()->create_module('forum', $options);
     // Create a user enrolled in the course as a student.
     list($author) = $this->helper_create_users($course, 1);
     // Post a discussion to the forum.
     list($discussion, $post) = $this->helper_post_to_forum($forum, $author);
     // Check that the user is currently not subscribed to the forum.
     $this->assertFalse(\mod_forum\subscriptions::is_subscribed($author->id, $forum));
     // Check the deprecated function too.
     $this->assertFalse(forum_is_subscribed($author->id, $forum));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // Check that the user is unsubscribed from the discussion too.
     $this->assertFalse(\mod_forum\subscriptions::is_subscribed($author->id, $forum, $discussion->id));
     // Check that we have no records in either of the subscription tables.
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Subscribing to the forum should create a record in the subscriptions table, but not the forum discussion
     // subscriptions table.
     \mod_forum\subscriptions::subscribe_user($author->id, $forum);
     $this->assertEquals(1, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Unsubscribing should remove the record from the forum subscriptions table, and not modify the forum
     // discussion subscriptions table.
     \mod_forum\subscriptions::unsubscribe_user($author->id, $forum);
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // The same thing should happen calling the deprecated versions of
     // these functions.
     // Subscribing to the forum should create a record in the subscriptions table, but not the forum discussion
     // subscriptions table.
     forum_subscribe($author->id, $forum->id);
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     $this->assertEquals(1, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Unsubscribing should remove the record from the forum subscriptions table, and not modify the forum
     // discussion subscriptions table.
     forum_unsubscribe($author->id, $forum->id);
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Enroling the user in the discussion should add one record to the forum discussion table without modifying the
     // form subscriptions.
     \mod_forum\subscriptions::subscribe_user_to_discussion($author->id, $discussion);
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Unsubscribing should remove the record from the forum subscriptions table, and not modify the forum
     // discussion subscriptions table.
     \mod_forum\subscriptions::unsubscribe_user_from_discussion($author->id, $discussion);
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Re-subscribe to the discussion so that we can check the effect of forum-level subscriptions.
     \mod_forum\subscriptions::subscribe_user_to_discussion($author->id, $discussion);
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Subscribing to the forum should have no effect on the forum discussion subscriptions table if the user did
     // not request the change themself.
     \mod_forum\subscriptions::subscribe_user($author->id, $forum);
     $this->assertEquals(1, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Unsubscribing from the forum should have no effect on the forum discussion subscriptions table if the user
     // did not request the change themself.
     \mod_forum\subscriptions::unsubscribe_user($author->id, $forum);
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Subscribing to the forum should remove the per-discussion subscription preference if the user requested the
     // change themself.
     \mod_forum\subscriptions::subscribe_user($author->id, $forum, null, true);
     $this->assertEquals(1, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Now unsubscribe from the current discussion whilst being subscribed to the forum as a whole.
     \mod_forum\subscriptions::unsubscribe_user_from_discussion($author->id, $discussion);
     $this->assertEquals(1, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Unsubscribing from the forum should remove the per-discussion subscription preference if the user requested the
     // change themself.
     \mod_forum\subscriptions::unsubscribe_user($author->id, $forum, null, true);
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Subscribe to the discussion.
     \mod_forum\subscriptions::subscribe_user_to_discussion($author->id, $discussion);
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Subscribe to the forum without removing the discussion preferences.
     \mod_forum\subscriptions::subscribe_user($author->id, $forum);
     $this->assertEquals(1, $DB->count_records('forum_subscriptions', array('userid' => $author->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $author->id, 'discussion' => $discussion->id)));
     // Unsubscribing from the discussion should result in a change.
//.........这里部分代码省略.........
开发者ID:Jinelle,项目名称:moodle,代码行数:101,代码来源:subscriptions_test.php


示例8: forum_remove_user_subscriptions

/**
 * Remove subscriptions for a user in a context
 */
function forum_remove_user_subscriptions($userid, $context)
{
    global $CFG;
    if (empty($context->contextlevel)) {
        return false;
    }
    switch ($context->contextlevel) {
        case CONTEXT_SYSTEM:
            // For the whole site
            //if ($courses = get_my_courses($userid)) {
            // find all courses in which this user has a forum subscription
            if ($courses = get_records_sql("SELECT c.id\n                                              FROM {$CFG->prefix}course c,\n                                                   {$CFG->prefix}forum_subscriptions fs,\n                                                   {$CFG->prefix}forum f\n                                                   WHERE c.id = f.course AND f.id = fs.forum AND fs.userid = {$userid}\n                                                   GROUP BY c.id")) {
                foreach ($courses as $course) {
                    $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
                    forum_remove_user_subscriptions($userid, $subcontext);
                }
            }
            break;
        case CONTEXT_COURSECAT:
            // For a whole category
            if ($courses = get_records('course', 'category', $context->instanceid, '', 'id')) {
                foreach ($courses as $course) {
                    $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
                    forum_remove_user_subscriptions($userid, $subcontext);
                }
            }
            if ($categories = get_records('course_categories', 'parent', $context->instanceid, '', 'id')) {
                foreach ($categories as $category) {
                    $subcontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
                    forum_remove_user_subscriptions($userid, $subcontext);
                }
            }
            break;
        case CONTEXT_COURSE:
            // For a whole course
            if ($course = get_record('course', 'id', $context->instanceid, '', '', '', '', 'id')) {
                // find all forums in which this user has a subscription, and its coursemodule id
                if ($forums = get_records_sql("SELECT f.id, cm.id as coursemodule\n                                                 FROM {$CFG->prefix}forum f,\n                                                      {$CFG->prefix}modules m,\n                                                      {$CFG->prefix}course_modules cm,\n                                                      {$CFG->prefix}forum_subscriptions fs\n                                                WHERE fs.userid = {$userid} AND f.course = {$context->instanceid}\n                                                      AND fs.forum = f.id AND cm.instance = f.id\n                                                      AND cm.module = m.id AND m.name = 'forum'")) {
                    foreach ($forums as $forum) {
                        if ($modcontext = get_context_instance(CONTEXT_MODULE, $forum->coursemodule)) {
                            if (!has_capability('mod/forum:viewdiscussion', $modcontext, $userid)) {
                                forum_unsubscribe($userid, $forum->id);
                            }
                        }
                    }
                }
            }
            break;
        case CONTEXT_MODULE:
            // Just one forum
            if ($cm = get_coursemodule_from_id('forum', $context->instanceid)) {
                if ($forum = get_record('forum', 'id', $cm->instance)) {
                    if (!has_capability('mod/forum:viewdiscussion', $context, $userid)) {
                        forum_unsubscribe($userid, $forum->id);
                    }
                }
            }
            break;
    }
    return true;
}
开发者ID:r007,项目名称:PMoodle,代码行数:64,代码来源:lib.php


示例9: redirect

$PAGE->set_context(context_user::instance($USER->id));
$return = $CFG->wwwroot . '/';
if (isguestuser()) {
    redirect($return);
}
$strunsubscribeall = get_string('unsubscribeall', 'forum');
$PAGE->navbar->add(get_string('modulename', 'forum'));
$PAGE->navbar->add($strunsubscribeall);
$PAGE->set_title($strunsubscribeall);
$PAGE->set_heading($COURSE->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($strunsubscribeall);
if (data_submitted() and $confirm and confirm_sesskey()) {
    $forums = forum_get_optional_subscribed_forums();
    foreach ($forums as $forum) {
        forum_unsubscribe($USER->id, $forum->id, context_module::instance($forum->cm));
    }
    $DB->set_field('user', 'autosubscribe', 0, array('id' => $USER->id));
    echo $OUTPUT->box(get_string('unsubscribealldone', 'forum'));
    echo $OUTPUT->continue_button($return);
    echo $OUTPUT->footer();
    die;
} else {
    $a = count(forum_get_optional_subscribed_forums());
    if ($a) {
        $msg = get_string('unsubscribeallconfirm', 'forum', $a);
        echo $OUTPUT->confirm($msg, new moodle_url('unsubscribeall.php', array('confirm' => 1)), $return);
        echo $OUTPUT->footer();
        die;
    } else {
        echo $OUTPUT->box(get_string('unsubscribeallempty', 'forum'));
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:unsubscribeall.php


示例10: print_error

    /** It has to be one or the other, not both or neither */
    if (!($subscribe xor $unsubscribe)) {
        print_error('invalidaction');
    }
    if ($subscribe) {
        $users = $subscriberselector->get_selected_users();
        foreach ($users as $user) {
            if (!forum_subscribe($user->id, $id)) {
                print_error('cannotaddsubscriber', 'forum', '', $user->id);
            }
        }
    } else {
        if ($unsubscribe) {
            $users = $existingselector->get_selected_users();
            foreach ($users as $user) {
                if (!forum_unsubscribe($user->id, $id)) {
                    print_error('cannotremovesubscriber', 'forum', '', $user->id);
                }
            }
        }
    }
    $subscriberselector->invalidate_selected_users();
    $existingselector->invalidate_selected_users();
    $subscriberselector->set_existing_subscribers($existingselector->find_users(''));
}
$strsubscribers = get_string("subscribers", "forum");
$PAGE->navbar->add($strsubscribers);
$PAGE->set_title($strsubscribers);
$PAGE->set_heading($COURSE->fullname);
if (has_capability('mod/forum:managesubscriptions', $context)) {
    $PAGE->set_button(forum_update_subscriptions_button($course->id, $id));
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:subscribers.php


示例11: forum_remove_user_subscriptions

/**
 * Remove subscriptions for a user in a context
 */
function forum_remove_user_subscriptions($userid, $context)
{
    if (empty($context->contextlevel)) {
        return false;
    }
    switch ($context->contextlevel) {
        case CONTEXT_SYSTEM:
            // For the whole site
            if ($courses = get_records('course')) {
                foreach ($courses as $course) {
                    $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
                    forum_remove_user_subscriptions($userid, $subcontext);
                }
            }
            break;
        case CONTEXT_COURSECAT:
            // For a whole category
            if ($courses = get_records('course', 'category', $context->instanceid)) {
                foreach ($courses as $course) {
                    $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
                    forum_remove_user_subscriptions($userid, $subcontext);
                }
            }
            if ($categories = get_records('course_categories', 'parent', $context->instanceid)) {
                foreach ($categories as $category) {
                    $subcontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
                    forum_remove_user_subscriptions($userid, $subcontext);
                }
            }
            break;
        case CONTEXT_COURSE:
            // For a whole course
            if ($course = get_record('course', 'id', $context->instanceid)) {
                if ($forums = get_all_instances_in_course('forum', $course, $userid, true)) {
                    foreach ($forums as $forum) {
                        if ($modcontext = get_context_instance(CONTEXT_MODULE, $forum->coursemodule)) {
                            if (!has_capability('mod/forum:viewdiscussion', $modcontext, $userid)) {
                                forum_unsubscribe($userid, $forum->id);
                            }
                        }
                    }
                }
            }
            break;
        case CONTEXT_MODULE:
            // Just one forum
            if ($cm = get_coursemodule_from_id('forum', $context->instanceid)) {
                if ($forum = get_record('forum', 'id', $cm->instance)) {
                    if (!has_capability('mod/forum:viewdiscussion', $context, $userid)) {
                        forum_unsubscribe($userid, $forum->id);
                    }
                }
            }
            break;
    }
    return true;
}
开发者ID:njorth,项目名称:marginalia,代码行数:60,代码来源:lib.php



注:本文中的forum_unsubscribe函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP forum_update_grades函数代码示例发布时间:2022-05-15
下一篇:
PHP forum_trim函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap