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

PHP mod_forum\subscriptions类代码示例

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

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



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

示例1: setUp

 /**
  * Set up message and mail sinks, and set up other requirements for the
  * cron to be tested here.
  */
 public function setUp()
 {
     global $CFG;
     $this->helper = new stdClass();
     // Messaging is not compatible with transactions...
     $this->preventResetByRollback();
     // Catch all messages
     $this->helper->messagesink = $this->redirectMessages();
     $this->helper->mailsink = $this->redirectEmails();
     // Confirm that we have an empty message sink so far.
     $messages = $this->helper->messagesink->get_messages();
     $this->assertEquals(0, count($messages));
     $messages = $this->helper->mailsink->get_messages();
     $this->assertEquals(0, count($messages));
     // Tell Moodle that we've not sent any digest messages out recently.
     $CFG->digestmailtimelast = 0;
     // And set the digest sending time to a negative number - this has
     // the effect of making it 11pm the previous day.
     $CFG->digestmailtime = -1;
     // Forcibly reduce the maxeditingtime to a one second to ensure that
     // messages are sent out.
     $CFG->maxeditingtime = 1;
     // We must clear the subscription caches. This has to be done both before each test, and after in case of other
     // tests using these functions.
     \mod_forum\subscriptions::reset_forum_cache();
     \mod_forum\subscriptions::reset_discussion_cache();
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:maildigest_test.php


示例2: role_assigned

 /**
  * Observer for role_assigned event.
  *
  * @param \core\event\role_assigned $event
  * @return void
  */
 public static function role_assigned(\core\event\role_assigned $event)
 {
     global $CFG, $DB;
     $context = context::instance_by_id($event->contextid, MUST_EXIST);
     // If contextlevel is course then only subscribe user. Role assignment
     // at course level means user is enroled in course and can subscribe to forum.
     if ($context->contextlevel != CONTEXT_COURSE) {
         return;
     }
     // Forum lib required for the constant used below.
     require_once $CFG->dirroot . '/mod/forum/lib.php';
     $userid = $event->relateduserid;
     $sql = "SELECT f.id, f.course as course, cm.id AS cmid, f.forcesubscribe\n                  FROM {forum} f\n                  JOIN {course_modules} cm ON (cm.instance = f.id)\n                  JOIN {modules} m ON (m.id = cm.module)\n             LEFT JOIN {forum_subscriptions} fs ON (fs.forum = f.id AND fs.userid = :userid)\n                 WHERE f.course = :courseid\n                   AND f.forcesubscribe = :initial\n                   AND m.name = 'forum'\n                   AND fs.id IS NULL";
     $params = array('courseid' => $context->instanceid, 'userid' => $userid, 'initial' => FORUM_INITIALSUBSCRIBE);
     $forums = $DB->get_records_sql($sql, $params);
     foreach ($forums as $forum) {
         // If user doesn't have allowforcesubscribe capability then don't subscribe.
         $modcontext = context_module::instance($forum->cmid);
         if (has_capability('mod/forum:allowforcesubscribe', $modcontext, $userid)) {
             \mod_forum\subscriptions::subscribe_user($userid, $forum, $modcontext);
         }
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:29,代码来源:observer.php


示例3: format_string

$node->display = false;
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
开发者ID:mongo0se,项目名称:moodle,代码行数:31,代码来源:discuss.php


示例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;
开发者ID:aleph-n,项目名称:lms.aaenl,代码行数:31,代码来源:subscribe_ajax.php


示例5: test_is_subscribable_loggedin

 /**
  * @dataProvider is_subscribable_loggedin_provider
  */
 public function test_is_subscribable_loggedin($options, $expect)
 {
     $this->resetAfterTest(true);
     // Create a course, with a forum.
     $course = $this->getDataGenerator()->create_course();
     $options['course'] = $course->id;
     $forum = $this->getDataGenerator()->create_module('forum', $options);
     $user = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user->id, $course->id);
     $this->setUser($user);
     $this->assertEquals($expect, \mod_forum\subscriptions::is_subscribable($forum));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:subscriptions_test.php


示例6: test_forum_disallow_subscribe_on_create

 /**
  * Test subscription using disallow subscription on create.
  */
 public function test_forum_disallow_subscribe_on_create()
 {
     global $CFG;
     $this->resetAfterTest();
     $usercount = 5;
     $course = $this->getDataGenerator()->create_course();
     $users = array();
     for ($i = 0; $i < $usercount; $i++) {
         $user = $this->getDataGenerator()->create_user();
         $users[] = $user;
         $this->getDataGenerator()->enrol_user($user->id, $course->id);
     }
     $options = array('course' => $course->id, 'forcesubscribe' => FORUM_DISALLOWSUBSCRIBE);
     // Subscription prevented.
     $forum = $this->getDataGenerator()->create_module('forum', $options);
     $result = \mod_forum\subscriptions::fetch_subscribed_users($forum);
     // No subscriptions by default.
     $this->assertEquals(0, count($result));
     foreach ($users as $user) {
         $this->assertFalse(\mod_forum\subscriptions::is_subscribed($user->id, $forum));
     }
 }
开发者ID:rushi963,项目名称:moodle,代码行数:25,代码来源:lib_test.php


示例7: fetch_subscribed_users

 /**
  * Returns a list of user objects who are subscribed to this forum.
  *
  * @param stdClass $forum The forum record.
  * @param int $groupid The group id if restricting subscriptions to a group of users, or 0 for all.
  * @param context_module $context the forum context, to save re-fetching it where possible.
  * @param string $fields requested user fields (with "u." table prefix).
  * @param boolean $includediscussionsubscriptions Whether to take discussion subscriptions and unsubscriptions into consideration.
  * @return array list of users.
  */
 public static function fetch_subscribed_users($forum, $groupid = 0, $context = null, $fields = null, $includediscussionsubscriptions = false)
 {
     global $CFG, $DB;
     if (empty($fields)) {
         $allnames = get_all_user_name_fields(true, 'u');
         $fields = "u.id,\n                      u.username,\n                      {$allnames},\n                      u.maildisplay,\n                      u.mailformat,\n                      u.maildigest,\n                      u.imagealt,\n                      u.email,\n                      u.emailstop,\n                      u.city,\n                      u.country,\n                      u.lastaccess,\n                      u.lastlogin,\n                      u.picture,\n                      u.timezone,\n                      u.theme,\n                      u.lang,\n                      u.trackforums,\n                      u.mnethostid";
     }
     // Retrieve the forum context if it wasn't specified.
     $context = forum_get_context($forum->id, $context);
     if (self::is_forcesubscribed($forum)) {
         $results = \mod_forum\subscriptions::get_potential_subscribers($context, $groupid, $fields, "u.email ASC");
     } else {
         // Only active enrolled users or everybody on the frontpage.
         list($esql, $params) = get_enrolled_sql($context, '', $groupid, true);
         $params['forumid'] = $forum->id;
         if ($includediscussionsubscriptions) {
             $params['sforumid'] = $forum->id;
             $params['dsforumid'] = $forum->id;
             $params['unsubscribed'] = self::FORUM_DISCUSSION_UNSUBSCRIBED;
             $sql = "SELECT {$fields}\n                        FROM (\n                            SELECT userid FROM {forum_subscriptions} s\n                            WHERE\n                                s.forum = :sforumid\n                                UNION\n                            SELECT userid FROM {forum_discussion_subs} ds\n                            WHERE\n                                ds.forum = :dsforumid AND ds.preference <> :unsubscribed\n                        ) subscriptions\n                        JOIN {user} u ON u.id = subscriptions.userid\n                        JOIN ({$esql}) je ON je.id = u.id\n                        ORDER BY u.email ASC";
         } else {
             $sql = "SELECT {$fields}\n                        FROM {user} u\n                        JOIN ({$esql}) je ON je.id = u.id\n                        JOIN {forum_subscriptions} s ON s.userid = u.id\n                        WHERE\n                          s.forum = :forumid\n                        ORDER BY u.email ASC";
         }
         $results = $DB->get_records_sql($sql, $params);
     }
     // Guest user should never be subscribed to a forum.
     unset($results[$CFG->siteguest]);
     // Apply the activity module availability resetrictions.
     $cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course);
     $modinfo = get_fast_modinfo($forum->course);
     $info = new \core_availability\info_module($modinfo->get_cm($cm->id));
     $results = $info->filter_user_list($results);
     return $results;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:44,代码来源:subscriptions.php


示例8: test_forum_discussion_subscription_forum_unsubscribed_discussion_subscribed_after_post

 /**
  * Test that a user unsubscribed from a forum who has subscribed to a discussion, only receives posts made after
  * they subscribed to the discussion.
  */
 public function test_forum_discussion_subscription_forum_unsubscribed_discussion_subscribed_after_post()
 {
     $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);
     $expectedmessages = array();
     // 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);
     $this->helper_update_post_time($post, -90);
     $expectedmessages[] = array('id' => $post->id, 'subject' => $post->subject, 'count' => 0);
     // Then subscribe the user to the discussion.
     $this->assertTrue(\mod_forum\subscriptions::subscribe_user_to_discussion($author->id, $discussion));
     $this->helper_update_subscription_time($author, $discussion, -60);
     // Then post a reply to the first discussion.
     $reply = $this->helper_post_to_discussion($forum, $discussion, $author);
     $this->helper_update_post_time($reply, -30);
     $expectedmessages[] = array('id' => $reply->id, 'subject' => $reply->subject, 'count' => 1);
     $expectedcount = 1;
     // Run cron and check that the expected number of users received the notification.
     $messages = $this->helper_run_cron_check_counts($expectedmessages, $expectedcount);
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:29,代码来源:mail_test.php


示例9: definition

 /**
  * Form definition
  *
  * @return void
  */
 function definition()
 {
     global $CFG, $OUTPUT;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $coursecontext = $this->_customdata['coursecontext'];
     $modcontext = $this->_customdata['modcontext'];
     $forum = $this->_customdata['forum'];
     $post = $this->_customdata['post'];
     $subscribe = $this->_customdata['subscribe'];
     $edit = $this->_customdata['edit'];
     $thresholdwarning = $this->_customdata['thresholdwarning'];
     $mform->addElement('header', 'general', '');
     //fill in the data depending on page params later using set_data
     // If there is a warning message and we are not editing a post we need to handle the warning.
     if (!empty($thresholdwarning) && !$edit) {
         // Here we want to display a warning if they can still post but have reached the warning threshold.
         if ($thresholdwarning->canpost) {
             $message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional);
             $mform->addElement('html', $OUTPUT->notification($message));
         }
     }
     $mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="48"');
     $mform->setType('subject', PARAM_TEXT);
     $mform->addRule('subject', get_string('required'), 'required', null, 'client');
     $mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->addElement('editor', 'message', get_string('message', 'forum'), null, self::editor_options($modcontext, empty($post->id) ? null : $post->id));
     $mform->setType('message', PARAM_RAW);
     $mform->addRule('message', get_string('required'), 'required', null, 'client');
     $manageactivities = has_capability('moodle/course:manageactivities', $coursecontext);
     if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
         $mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum'));
         $mform->freeze('discussionsubscribe');
         $mform->setDefaults('discussionsubscribe', 0);
         $mform->addHelpButton('discussionsubscribe', 'forcesubscribed', 'forum');
     } else {
         if (\mod_forum\subscriptions::subscription_disabled($forum) && !$manageactivities) {
             $mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum'));
             $mform->freeze('discussionsubscribe');
             $mform->setDefaults('discussionsubscribe', 0);
             $mform->addHelpButton('discussionsubscribe', 'disallowsubscription', 'forum');
         } else {
             $mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum'));
             $mform->addHelpButton('discussionsubscribe', 'discussionsubscription', 'forum');
         }
     }
     if (!empty($forum->maxattachments) && $forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) {
         //  1 = No attachments at all
         $mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'), null, self::attachment_options($forum));
         $mform->addHelpButton('attachments', 'attachment', 'forum');
     }
     if (empty($post->id) && $manageactivities) {
         $mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forum'));
     }
     if (!empty($CFG->forum_enabletimedposts) && !$post->parent && has_capability('mod/forum:viewhiddentimedposts', $coursecontext)) {
         // hack alert
         $mform->addElement('header', 'displayperiod', get_string('displayperiod', 'forum'));
         $mform->addElement('date_time_selector', 'timestart', get_string('displaystart', 'forum'), array('optional' => true));
         $mform->addHelpButton('timestart', 'displaystart', 'forum');
         $mform->addElement('date_time_selector', 'timeend', get_string('displayend', 'forum'), array('optional' => true));
         $mform->addHelpButton('timeend', 'displayend', 'forum');
     } else {
         $mform->addElement('hidden', 'timestart');
         $mform->setType('timestart', PARAM_INT);
         $mform->addElement('hidden', 'timeend');
         $mform->setType('timeend', PARAM_INT);
         $mform->setConstants(array('timestart' => 0, 'timeend' => 0));
     }
     if ($groupmode = groups_get_activity_groupmode($cm, $course)) {
         $groupdata = groups_get_activity_allowed_groups($cm);
         $groupinfo = array();
         foreach ($groupdata as $groupid => $group) {
             // Check whether this user can post in this group.
             // We must make this check because all groups are returned for a visible grouped activity.
             if (forum_user_can_post_discussion($forum, $groupid, null, $cm, $modcontext)) {
                 // Build the data for the groupinfo select.
                 $groupinfo[$groupid] = $group->name;
             } else {
                 unset($groupdata[$groupid]);
             }
         }
         $groupcount = count($groupinfo);
         // Check whether a user can post to all of their own groups.
         // Posts to all of my groups are copied to each group that the user is a member of. Certain conditions must be met.
         // 1) It only makes sense to allow this when a user is in more than one group.
         // Note: This check must come before we consider adding accessallgroups, because that is not a real group.
         $canposttoowngroups = empty($post->edit) && $groupcount > 1;
         // 2) Important: You can *only* post to multiple groups for a top level post. Never any reply.
         $canposttoowngroups = $canposttoowngroups && empty($post->parent);
         // 3) You also need the canposttoowngroups capability.
         $canposttoowngroups = $canposttoowngroups && has_capability('mod/forum:canposttomygroups', $modcontext);
         if ($canposttoowngroups) {
             // This user is in multiple groups, and can post to all of their own groups.
             // Note: This is not the same as accessallgroups. This option will copy a post to all groups that a
//.........这里部分代码省略.........
开发者ID:alanaipe2015,项目名称:moodle,代码行数:101,代码来源:post_form.php


示例10: forum_get_potential_subscribers

/**
 * Get the list of potential subscribers to a forum.
 *
 * @param object $forumcontext the forum context.
 * @param integer $groupid the id of a group, or 0 for all groups.
 * @param string $fields the list of fields to return for each user. As for get_users_by_capability.
 * @param string $sort sort order. As for get_users_by_capability.
 * @return array list of users.
 * @deprecated since Moodle 2.8 use \mod_forum\subscriptions::get_potential_subscribers() instead
 */
function forum_get_potential_subscribers($forumcontext, $groupid, $fields, $sort = '')
{
    debugging("forum_get_potential_subscribers() has been deprecated, please use \\mod_forum\\subscriptions::get_potential_subscribers() instead.", DEBUG_DEVELOPER);
    \mod_forum\subscriptions::get_potential_subscribers($forumcontext, $groupid, $fields, $sort);
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:15,代码来源:deprecatedlib.php


示例11: get_string

    }
    $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));
    if ($edit != -1) {
        $USER->subscriptionsediting = $edit;
    }
} else {
    unset($USER->subscriptionsediting);
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('forum', 'forum') . ' ' . $strsubscribers);
if (empty($USER->subscriptionsediting)) {
    $subscribers = \mod_forum\subscriptions::fetch_subscribed_users($forum, $currentgroup, $context);
    echo $forumoutput->subscriber_overview($subscribers, $forum, $course);
} else {
    if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
        $subscriberselector->set_force_subscribed(true);
        echo $forumoutput->subscribed_users($subscriberselector);
    } else {
        echo $forumoutput->subscriber_selection_form($existingselector, $subscriberselector);
    }
}
echo $OUTPUT->footer();
开发者ID:abhilash1994,项目名称:moodle,代码行数:31,代码来源:subscribers.php


示例12: oc_forum_print_latest_discussions


//.........这里部分代码省略.........
    // Check if the forum is tracked.
    if ($cantrack = forum_tp_can_track_forums($forum)) {
        $forumtracked = forum_tp_is_tracked($forum);
    } else {
        $forumtracked = false;
    }
    if ($forumtracked) {
        $unreads = forum_get_discussions_unread($cm);
    } else {
        $unreads = array();
    }
    if ($displayformat == 'header') {
        echo '<table cellspacing="0" class="forumheaderlist">';
        echo '<thead>';
        echo '<tr>';
        echo '<th class="header topic" scope="col">' . get_string('discussion', 'forum') . '</th>';
        echo '<th class="header author" colspan="2" scope="col">' . get_string('startedby', 'forum') . '</th>';
        if ($groupmode > 0) {
            echo '<th class="header group" scope="col">' . get_string('group') . '</th>';
        }
        if (has_capability('mod/forum:viewdiscussion', $context)) {
            echo '<th class="header replies" scope="col">' . get_string('replies', 'forum') . '</th>';
            // If the forum can be tracked, display the unread column.
            if ($cantrack) {
                echo '<th class="header replies" scope="col">' . get_string('unread', 'forum');
                if ($forumtracked) {
                    echo '<a title="' . get_string('markallread', 'forum') . '" href="' . $CFG->wwwroot . '/mod/forum/markposts.php?f=' . $forum->id . '&amp;mark=read&amp;returnpage=view.php">' . '<img src="' . $OUTPUT->pix_url('t/markasread') . '" class="iconsmall" alt="' . get_string('markallread', 'forum') . '" /></a>';
                }
                echo '</th>';
            }
        }
        echo '<th class="header lastpost" scope="col">' . get_string('lastpost', 'forum') . '</th>';
        if (!is_guest($context, $USER) && isloggedin() && has_capability('mod/forum:viewdiscussion', $context)) {
            if (\mod_forum\subscriptions::is_subscribable($forum)) {
                echo '<th class="header discussionsubscription" scope="col">';
                echo forum_get_discussion_subscription_icon_preloaders();
                echo '</th>';
            }
        }
        echo '</tr>';
        echo '</thead>';
        echo '<tbody>';
    }
    foreach ($discussions as $discussion) {
        if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $context) && !forum_user_has_posted($forum->id, $discussion->discussion, $USER->id)) {
            $canviewparticipants = false;
        }
        if (!empty($replies[$discussion->discussion])) {
            $discussion->replies = $replies[$discussion->discussion]->replies;
            $discussion->lastpostid = $replies[$discussion->discussion]->lastpostid;
        } else {
            $discussion->replies = 0;
        }
        // SPECIAL CASE: The front page can display a news item post to non-logged in users.
        // All posts are read in this case.
        if (!$forumtracked) {
            $discussion->unread = '-';
        } else {
            if (empty($USER)) {
                $discussion->unread = 0;
            } else {
                if (empty($unreads[$discussion->discussion])) {
                    $discussion->unread = 0;
                } else {
                    $discussion->unread = $unreads[$discussion->discussion];
                }
开发者ID:oncampus,项目名称:mooin_block_oc_mooc_nav,代码行数:67,代码来源:forum_lib.php


示例13: get_string

$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 = \mod_forum\subscriptions::get_unsubscribable_forums();
    foreach ($forums as $forum) {
        \mod_forum\subscriptions::unsubscribe_user($USER->id, $forum, context_module::instance($forum->cm), true);
    }
    $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(\mod_forum\subscriptions::get_unsubscribable_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'));
        echo $OUTPUT->continue_button($return);
        echo $OUTPUT->footer();
        die;
    }
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:31,代码来源:unsubscribeall.php


示例14: test_optional_with_unsubscribed_discussion_in_subscribed_forum

 public function test_optional_with_unsubscribed_discussion_in_subscribed_forum()
 {
     $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 two users enrolled in the course as students.
     list($author, $recipient) = $this->helper_create_users($course, 2);
     // Post a discussion to the forum.
     list($discussion, $post) = $this->helper_post_to_forum($forum, $author);
     // Unsubscribe the 'recipient' user from the discussion.
     \mod_forum\subscriptions::subscribe_user($recipient->id, $forum);
     // Then unsubscribe them from the discussion.
     \mod_forum\subscriptions::unsubscribe_user_from_discussion($recipient->id, $discussion);
     // We don't expect any users to receive this post.
     $expected = 0;
     // Run cron and check that the expected number of users received the notification.
     $messages = $this->helper_run_cron_check_count($post, $expected);
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:20,代码来源:mail_test.php


示例15: test_forum_subscribe_toggle_as_other_repeat_subscriptions

 /**
  * Test that after toggling the forum subscription as another user,
  * the discussion subscription functionality works as expected.
  */
 public function test_forum_subscribe_toggle_as_other_repeat_subscriptions()
 {
     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($user) = $this->helper_create_users($course, 1);
     // Post a discussion to the forum.
     list($discussion, $post) = $this->helper_post_to_forum($forum, $user);
     // Confirm that the user is currently not subscribed to the forum.
     $this->assertFalse(\mod_forum\subscriptions::is_subscribed($user->id, $forum));
     // Confirm that the user is unsubscribed from the discussion too.
     $this->assertFalse(\mod_forum\subscriptions::is_subscribed($user->id, $forum, $discussion->id));
     // Confirm that we have no records in either of the subscription tables.
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $user->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $user->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($user->id, $forum);
     $this->assertEquals(1, $DB->count_records('forum_subscriptions', array('userid' => $user->id, 'forum' => $forum->id)));
     $this->assertEquals(0, $DB->count_records('forum_discussion_subs', array('userid' => $user->id, 'discussion' => $discussion->id)));
     // Now unsubscribe from the discussion. This should return true.
     $this->assertTrue(\mod_forum\subscriptions::unsubscribe_user_from_discussion($user->id, $discussion));
     // Attempting to unsubscribe again should return false because no change was made.
     $this->assertFalse(\mod_forum\subscriptions::unsubscribe_user_from_discussion($user->id, $discussion));
     // Subscribing to the discussion again should return truthfully as the subscription preference was removed.
     $this->assertTrue(\mod_forum\subscriptions::subscribe_user_to_discussion($user->id, $discussion));
     // Attempting to subscribe again should return false because no change was made.
     $this->assertFalse(\mod_forum\subscriptions::subscribe_user_to_discussion($user->id, $discussion));
     // Now unsubscribe from the discussion. This should return true once more.
     $this->assertTrue(\mod_forum\subscriptions::unsubscribe_user_from_discussion($user->id, $discussion));
     // And unsubscribing from the forum but not as a request from the user should maintain their preference.
     \mod_forum\subscriptions::unsubscribe_user($user->id, $forum);
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $user->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $user->id, 'discussion' => $discussion->id)));
     // Subscribing to the discussion should return truthfully because a change was made.
     $this->assertTrue(\mod_forum\subscriptions::subscribe_user_to_discussion($user->id, $discussion));
     $this->assertEquals(0, $DB->count_records('forum_subscriptions', array('userid' => $user->id, 'forum' => $forum->id)));
     $this->assertEquals(1, $DB->count_records('forum_discussion_subs', array('userid' => $user->id, 'discussion' => $discussion->id)));
 }
开发者ID:Jinelle,项目名称:moodle,代码行数:47,代码来源:subscriptions_test.php


示例16: definition

 /**
  * Form definition
  *
  * @return void
  */
 function definition()
 {
     global $CFG, $OUTPUT;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $coursecontext = $this->_customdata['coursecontext'];
     $modcontext = $this->_customdata['modcontext'];
     $forum = $this->_customdata['forum'];
     $post = $this->_customdata['post'];
     $subscribe = $this->_customdata['subscribe'];
     $edit = $this->_customdata['edit'];
     $thresholdwarning = $this->_customdata['thresholdwarning'];
     $mform->addElement('header', 'general', '');
     //fill in the data depending on page params later using set_data
     // If there is a warning message and we are not editing a post we need to handle the warning.
     if (!empty($thresholdwarning) && !$edit) {
         // Here we want to display a warning if they can still post but have reached the warning threshold.
         if ($thresholdwarning->canpost) {
             $message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional);
             $mform->addElement('html', $OUTPUT->notification($message));
         }
     }
     $mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="48"');
     $mform->setType('subject', PARAM_TEXT);
     $mform->addRule('subject', get_string('required'), 'required', null, 'client');
     $mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->addElement('editor', 'message', get_string('message', 'forum'), null, self::editor_options($modcontext, empty($post->id) ? null : $post->id));
     $mform->setType('message', PARAM_RAW);
     $mform->addRule('message', get_string('required'), 'required', null, 'client');
     $manageactivities = has_capability('moodle/course:manageactivities', $coursecontext);
     if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
         $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('everyoneissubscribed', 'forum'));
         $mform->addElement('hidden', 'subscribe');
         $mform->setType('subscribe', PARAM_INT);
         $mform->addHelpButton('subscribemessage', 'forcesubscribed', 'forum');
     } else {
         if (\mod_forum\subscriptions::subscription_disabled($forum) && !$manageactivities) {
             $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum'));
             $mform->addElement('hidden', 'discussionsubscribe');
             $mform->setType('discussionsubscribe', PARAM_INT);
             $mform->addHelpButton('subscribemessage', 'disallowsubscription', 'forum');
         } else {
             $options = array();
             $options[0] = get_string('discussionsubscribestop', 'forum');
             $options[1] = get_string('discussionsubscribestart', 'forum');
             $mform->addElement('select', 'discussionsubscribe', get_string('discussionsubscription', 'forum'), $options);
             $mform->addHelpButton('discussionsubscribe', 'discussionsubscription', 'forum');
         }
     }
     if (!empty($forum->maxattachments) && $forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) {
         //  1 = No attachments at all
         $mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'), null, self::attachment_options($forum));
         $mform->addHelpButton('attachments', 'attachment', 'forum');
     }
     if (empty($post->id) && $manageactivities) {
         $mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forum'));
     }
     if (!empty($CFG->forum_enabletimedposts) && !$post->parent && has_capability('mod/forum:viewhiddentimedposts', $coursecontext)) {
         // hack alert
         $mform->addElement('header', 'displayperiod', get_string('displayperiod', 'forum'));
         $mform->addElement('date_selector', 'timestart', get_string('displaystart', 'forum'), array('optional' => true));
         $mform->addHelpButton('timestart', 'displaystart', 'forum');
         $mform->addElement('date_selector', 'timeend', get_string('displayend', 'forum'), array('optional' => true));
         $mform->addHelpButton('timeend', 'displayend', 'forum');
     } else {
         $mform->addElement('hidden', 'timestart');
         $mform->setType('timestart', PARAM_INT);
         $mform->addElement('hidden', 'timeend');
         $mform->setType('timeend', PARAM_INT);
         $mform->setConstants(array('timestart' => 0, 'timeend' => 0));
     }
     if ($groupmode = groups_get_activity_groupmode($cm, $course)) {
         // hack alert
         $groupdata = groups_get_activity_allowed_groups($cm);
         $groupcount = count($groupdata);
         $groupinfo = array();
         $modulecontext = context_module::instance($cm->id);
         // Check whether the user has access to all groups in this forum from the accessallgroups cap.
         if ($groupmode == VISIBLEGROUPS || has_capability('moodle/site:accessallgroups', $modulecontext)) {
             // Only allow posting to all groups if the user has access to all groups.
             $groupinfo = array('0' => get_string('allparticipants'));
             $groupcount++;
         }
         $contextcheck = has_capability('mod/forum:movediscussions', $modulecontext) && empty($post->parent) && $groupcount > 1;
         if ($contextcheck) {
             foreach ($groupdata as $grouptemp) {
                 $groupinfo[$grouptemp->id] = $grouptemp->name;
             }
             $mform->addElement('select', 'groupinfo', get_string('group'), $groupinfo);
             $mform->setDefault('groupinfo', $post->groupid);
             $mform->setType('groupinfo', PARAM_INT);
         } else {
             if (empty($post->groupid)) {
                 $groupname = get_string('allparticipants');
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:post_form.php


示例17: test_forum_subscription_page_context_valid

 /**
  * Test that the correct context is used in the events when subscribing
  * users.
  */
 public function test_forum_subscription_page_context_valid()
 {
     global $CFG, $PAGE;
     require_once $CFG->dirroot . '/mod/forum/lib.php';
     // Setup test data.
     $course = $this->getDataGenerator()->create_course();
     $user = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user->id, $course->id);
     $options = array('course' => $course->id, 'forcesubscribe' => FORUM_CHOOSESUBSCRIBE);
     $forum = $this->getDataGenerator()->create_module('forum', $options);
     $quiz = $this->getDataGenerator()->create_module('quiz', $options);
     // Add a discussion.
     $record = array();
     $record['course'] = $course->id;
     $record['forum'] = $forum->id;
     $record['userid'] = $user->id;
     $discussion = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
     // Add a post.
     $record = array();
     $record['discussion'] = $discussion->id;
     

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Model\Project类代码示例发布时间:2022-05-23
下一篇:
PHP Mockery\MockInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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