Пример #1
0
            redirect($returnto, get_string("everyoneisnowsubscribed", "twf"), 1);
            break;
        case FORUM_INITIALSUBSCRIBE:
            // 2
            if ($twf->forcesubscribe != FORUM_INITIALSUBSCRIBE) {
                $users = \mod_twf\subscriptions::get_potential_subscribers($context, 0, 'u.id, u.email', '');
                foreach ($users as $user) {
                    \mod_twf\subscriptions::subscribe_user($user->id, $twf, $context);
                }
            }
            \mod_twf\subscriptions::set_subscription_mode($twf->id, FORUM_INITIALSUBSCRIBE);
            redirect($returnto, get_string("everyoneisnowsubscribed", "twf"), 1);
            break;
        case FORUM_DISALLOWSUBSCRIBE:
            // 3
            \mod_twf\subscriptions::set_subscription_mode($twf->id, FORUM_DISALLOWSUBSCRIBE);
            redirect($returnto, get_string("noonecansubscribenow", "twf"), 1);
            break;
        default:
            print_error(get_string('invalidforcesubscribe', 'twf'));
    }
}
if (\mod_twf\subscriptions::is_forcesubscribed($twf)) {
    redirect($returnto, get_string("everyoneisnowsubscribed", "twf"), 1);
}
$info = new stdClass();
$info->name = fullname($user);
$info->twf = format_string($twf->name);
if ($issubscribed) {
    if (is_null($sesskey)) {
        // We came here via link in email.
Пример #2
0
 public function test_subscription_modes()
 {
     global $DB;
     $this->resetAfterTest(true);
     // Create a course, with a twf.
     $course = $this->getDataGenerator()->create_course();
     $options = array('course' => $course->id);
     $twf = $this->getDataGenerator()->create_module('twf', $options);
     \mod_twf\subscriptions::set_subscription_mode($twf->id, FORUM_FORCESUBSCRIBE);
     $twf = $DB->get_record('twf', array('id' => $twf->id));
     $this->assertEquals(FORUM_FORCESUBSCRIBE, \mod_twf\subscriptions::get_subscription_mode($twf));
     $this->assertTrue(\mod_twf\subscriptions::is_forcesubscribed($twf));
     $this->assertFalse(\mod_twf\subscriptions::is_subscribable($twf));
     $this->assertFalse(\mod_twf\subscriptions::subscription_disabled($twf));
     \mod_twf\subscriptions::set_subscription_mode($twf->id, FORUM_DISALLOWSUBSCRIBE);
     $twf = $DB->get_record('twf', array('id' => $twf->id));
     $this->assertEquals(FORUM_DISALLOWSUBSCRIBE, \mod_twf\subscriptions::get_subscription_mode($twf));
     $this->assertTrue(\mod_twf\subscriptions::subscription_disabled($twf));
     $this->assertFalse(\mod_twf\subscriptions::is_subscribable($twf));
     $this->assertFalse(\mod_twf\subscriptions::is_forcesubscribed($twf));
     \mod_twf\subscriptions::set_subscription_mode($twf->id, FORUM_INITIALSUBSCRIBE);
     $twf = $DB->get_record('twf', array('id' => $twf->id));
     $this->assertEquals(FORUM_INITIALSUBSCRIBE, \mod_twf\subscriptions::get_subscription_mode($twf));
     $this->assertTrue(\mod_twf\subscriptions::is_subscribable($twf));
     $this->assertFalse(\mod_twf\subscriptions::subscription_disabled($twf));
     $this->assertFalse(\mod_twf\subscriptions::is_forcesubscribed($twf));
     \mod_twf\subscriptions::set_subscription_mode($twf->id, FORUM_CHOOSESUBSCRIBE);
     $twf = $DB->get_record('twf', array('id' => $twf->id));
     $this->assertEquals(FORUM_CHOOSESUBSCRIBE, \mod_twf\subscriptions::get_subscription_mode($twf));
     $this->assertTrue(\mod_twf\subscriptions::is_subscribable($twf));
     $this->assertFalse(\mod_twf\subscriptions::subscription_disabled($twf));
     $this->assertFalse(\mod_twf\subscriptions::is_forcesubscribed($twf));
 }
Пример #3
0
/**
 * Set the subscription mode for a twf.
 *
 * @param int $twfid
 * @param mixed $value
 * @return bool
 * @deprecated since Moodle 2.8 use \mod_twf\subscriptions::set_subscription_mode() instead
 */
function twf_forcesubscribe($twfid, $value = 1)
{
    debugging("twf_forcesubscribe() has been deprecated, please use \\mod_twf\\subscriptions::set_subscription_mode() instead.", DEBUG_DEVELOPER);
    return \mod_twf\subscriptions::set_subscription_mode($twfid, $value);
}