本文整理匯總了PHP中mod_forum\subscriptions::set_subscription_mode方法的典型用法代碼示例。如果您正苦於以下問題:PHP subscriptions::set_subscription_mode方法的具體用法?PHP subscriptions::set_subscription_mode怎麽用?PHP subscriptions::set_subscription_mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mod_forum\subscriptions
的用法示例。
在下文中一共展示了subscriptions::set_subscription_mode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_subscription_modes
public function test_subscription_modes()
{
global $DB;
$this->resetAfterTest(true);
// Create a course, with a forum.
$course = $this->getDataGenerator()->create_course();
$options = array('course' => $course->id);
$forum = $this->getDataGenerator()->create_module('forum', $options);
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_FORCESUBSCRIBE);
$forum = $DB->get_record('forum', array('id' => $forum->id));
$this->assertEquals(FORUM_FORCESUBSCRIBE, \mod_forum\subscriptions::get_subscription_mode($forum));
$this->assertTrue(\mod_forum\subscriptions::is_forcesubscribed($forum));
$this->assertFalse(\mod_forum\subscriptions::is_subscribable($forum));
$this->assertFalse(\mod_forum\subscriptions::subscription_disabled($forum));
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_DISALLOWSUBSCRIBE);
$forum = $DB->get_record('forum', array('id' => $forum->id));
$this->assertEquals(FORUM_DISALLOWSUBSCRIBE, \mod_forum\subscriptions::get_subscription_mode($forum));
$this->assertTrue(\mod_forum\subscriptions::subscription_disabled($forum));
$this->assertFalse(\mod_forum\subscriptions::is_subscribable($forum));
$this->assertFalse(\mod_forum\subscriptions::is_forcesubscribed($forum));
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_INITIALSUBSCRIBE);
$forum = $DB->get_record('forum', array('id' => $forum->id));
$this->assertEquals(FORUM_INITIALSUBSCRIBE, \mod_forum\subscriptions::get_subscription_mode($forum));
$this->assertTrue(\mod_forum\subscriptions::is_subscribable($forum));
$this->assertFalse(\mod_forum\subscriptions::subscription_disabled($forum));
$this->assertFalse(\mod_forum\subscriptions::is_forcesubscribed($forum));
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_CHOOSESUBSCRIBE);
$forum = $DB->get_record('forum', array('id' => $forum->id));
$this->assertEquals(FORUM_CHOOSESUBSCRIBE, \mod_forum\subscriptions::get_subscription_mode($forum));
$this->assertTrue(\mod_forum\subscriptions::is_subscribable($forum));
$this->assertFalse(\mod_forum\subscriptions::subscription_disabled($forum));
$this->assertFalse(\mod_forum\subscriptions::is_forcesubscribed($forum));
}
示例2: redirect
redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
break;
case FORUM_INITIALSUBSCRIBE:
// 2
if ($forum->forcesubscribe != FORUM_INITIALSUBSCRIBE) {
$users = \mod_forum\subscriptions::get_potential_subscribers($context, 0, 'u.id, u.email', '');
foreach ($users as $user) {
\mod_forum\subscriptions::subscribe_user($user->id, $forum, $context);
}
}
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_INITIALSUBSCRIBE);
redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
break;
case FORUM_DISALLOWSUBSCRIBE:
// 3
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_DISALLOWSUBSCRIBE);
redirect($returnto, get_string("noonecansubscribenow", "forum"), 1);
break;
default:
print_error(get_string('invalidforcesubscribe', 'forum'));
}
}
if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
}
$info = new stdClass();
$info->name = fullname($user);
$info->forum = format_string($forum->name);
if ($issubscribed) {
if (is_null($sesskey)) {
// we came here via link in email
示例3: forum_forcesubscribe
/**
* Set the subscription mode for a forum.
*
* @param int $forumid
* @param mixed $value
* @return bool
* @deprecated since Moodle 2.8 use \mod_forum\subscriptions::set_subscription_mode() instead
*/
function forum_forcesubscribe($forumid, $value = 1)
{
debugging("forum_forcesubscribe() has been deprecated, please use \\mod_forum\\subscriptions::set_subscription_mode() instead.", DEBUG_DEVELOPER);
return \mod_forum\subscriptions::set_subscription_mode($forumid, $value);
}
示例4: test_subscription_modes
public function test_subscription_modes()
{
global $DB;
$this->resetAfterTest(true);
// Create a course, with a forum.
$course = $this->getDataGenerator()->create_course();
$options = array('course' => $course->id);
$forum = $this->getDataGenerator()->create_module('forum', $options);
// Create a user enrolled in the course as a student.
list($user) = $this->helper_create_users($course, 1);
// Must be logged in as the current user.
$this->setUser($user);
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_FORCESUBSCRIBE);
$forum = $DB->get_record('forum', array('id' => $forum->id));
$this->assertEquals(FORUM_FORCESUBSCRIBE, \mod_forum\subscriptions::get_subscription_mode($forum));
$this->assertTrue(\mod_forum\subscriptions::is_forcesubscribed($forum));
$this->assertFalse(\mod_forum\subscriptions::is_subscribable($forum));
$this->assertFalse(\mod_forum\subscriptions::subscription_disabled($forum));
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_DISALLOWSUBSCRIBE);
$forum = $DB->get_record('forum', array('id' => $forum->id));
$this->assertEquals(FORUM_DISALLOWSUBSCRIBE, \mod_forum\subscriptions::get_subscription_mode($forum));
$this->assertTrue(\mod_forum\subscriptions::subscription_disabled($forum));
$this->assertFalse(\mod_forum\subscriptions::is_subscribable($forum));
$this->assertFalse(\mod_forum\subscriptions::is_forcesubscribed($forum));
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_INITIALSUBSCRIBE);
$forum = $DB->get_record('forum', array('id' => $forum->id));
$this->assertEquals(FORUM_INITIALSUBSCRIBE, \mod_forum\subscriptions::get_subscription_mode($forum));
$this->assertTrue(\mod_forum\subscriptions::is_subscribable($forum));
$this->assertFalse(\mod_forum\subscriptions::subscription_disabled($forum));
$this->assertFalse(\mod_forum\subscriptions::is_forcesubscribed($forum));
\mod_forum\subscriptions::set_subscription_mode($forum->id, FORUM_CHOOSESUBSCRIBE);
$forum = $DB->get_record('forum', array('id' => $forum->id));
$this->assertEquals(FORUM_CHOOSESUBSCRIBE, \mod_forum\subscriptions::get_subscription_mode($forum));
$this->assertTrue(\mod_forum\subscriptions::is_subscribable($forum));
$this->assertFalse(\mod_forum\subscriptions::subscription_disabled($forum));
$this->assertFalse(\mod_forum\subscriptions::is_forcesubscribed($forum));
}