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

PHP forum_is_subscribed函数代码示例

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

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



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

示例1: foreach

     $frontpagelayout = $CFG->frontpage;
 }
 foreach (explode(',', $frontpagelayout) as $v) {
     switch ($v) {
         /// Display the main part of the front page.
         case FRONTPAGENEWS:
             if ($SITE->newsitems) {
                 // Print forums only when needed
                 require_once $CFG->dirroot . '/mod/forum/lib.php';
                 if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) {
                     error('Could not find or create a main news forum for the site');
                 }
                 if (!empty($USER->id)) {
                     $SESSION->fromdiscussion = $CFG->wwwroot;
                     $subtext = '';
                     if (forum_is_subscribed($USER->id, $newsforum)) {
                         if (!forum_is_forcesubscribed($newsforum)) {
                             $subtext = get_string('unsubscribe', 'forum');
                         }
                     } else {
                         $subtext = get_string('subscribe', 'forum');
                     }
                     print_heading_block($newsforum->name);
                     echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>';
                 } else {
                     print_heading_block($newsforum->name);
                 }
                 forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
             }
             break;
         case FRONTPAGECOURSELIST:
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:31,代码来源:index.php


示例2: redirect

     // there should not be any links leading to this place, just redirect
     redirect(new moodle_url('/mod/forum/index.php', array('id' => $id)), get_string('subscribeenrolledonly', 'forum'));
 }
 // Can proceed now, the user is not guest and is enrolled
 foreach ($modinfo->get_instances_of('forum') as $forumid => $cm) {
     $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);
开发者ID:gwsd2015,项目名称:LogiClass,代码行数:31,代码来源:index.php


示例3: forum_extend_settings_navigation

/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $forumnode The node to add module settings to
 */
function forum_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $forumnode) {
    global $USER, $PAGE, $CFG, $DB, $OUTPUT;

    $forumobject = $DB->get_record("forum", array("id" => $PAGE->cm->instance));
    if (empty($PAGE->cm->context)) {
        $PAGE->cm->context = context_module::instance($PAGE->cm->instance);
    }

    // for some actions you need to be enrolled, beiing admin is not enough sometimes here
    $enrolled = is_enrolled($PAGE->cm->context, $USER, '', false);
    $activeenrolled = is_enrolled($PAGE->cm->context, $USER, '', true);

    $canmanage  = has_capability('mod/forum:managesubscriptions', $PAGE->cm->context);
    $subscriptionmode = forum_get_forcesubscribed($forumobject);
    $cansubscribe = ($activeenrolled && $subscriptionmode != FORUM_FORCESUBSCRIBE && ($subscriptionmode != FORUM_DISALLOWSUBSCRIBE || $canmanage));

    if ($canmanage) {
        $mode = $forumnode->add(get_string('subscriptionmode', 'forum'), null, navigation_node::TYPE_CONTAINER);

        $allowchoice = $mode->add(get_string('subscriptionoptional', 'forum'), new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>FORUM_CHOOSESUBSCRIBE, 'sesskey'=>sesskey())), navigation_node::TYPE_SETTING);
        $forceforever = $mode->add(get_string("subscriptionforced", "forum"), new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>FORUM_FORCESUBSCRIBE, 'sesskey'=>sesskey())), navigation_node::TYPE_SETTING);
        $forceinitially = $mode->add(get_string("subscriptionauto", "forum"), new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>FORUM_INITIALSUBSCRIBE, 'sesskey'=>sesskey())), navigation_node::TYPE_SETTING);
        $disallowchoice = $mode->add(get_string('subscriptiondisabled', 'forum'), new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>FORUM_DISALLOWSUBSCRIBE, 'sesskey'=>sesskey())), navigation_node::TYPE_SETTING);

        switch ($subscriptionmode) {
            case FORUM_CHOOSESUBSCRIBE : // 0
                $allowchoice->action = null;
                $allowchoice->add_class('activesetting');
                break;
            case FORUM_FORCESUBSCRIBE : // 1
                $forceforever->action = null;
                $forceforever->add_class('activesetting');
                break;
            case FORUM_INITIALSUBSCRIBE : // 2
                $forceinitially->action = null;
                $forceinitially->add_class('activesetting');
                break;
            case FORUM_DISALLOWSUBSCRIBE : // 3
                $disallowchoice->action = null;
                $disallowchoice->add_class('activesetting');
                break;
        }

    } else if ($activeenrolled) {

        switch ($subscriptionmode) {
            case FORUM_CHOOSESUBSCRIBE : // 0
                $notenode = $forumnode->add(get_string('subscriptionoptional', 'forum'));
                break;
            case FORUM_FORCESUBSCRIBE : // 1
                $notenode = $forumnode->add(get_string('subscriptionforced', 'forum'));
                break;
            case FORUM_INITIALSUBSCRIBE : // 2
                $notenode = $forumnode->add(get_string('subscriptionauto', 'forum'));
                break;
            case FORUM_DISALLOWSUBSCRIBE : // 3
                $notenode = $forumnode->add(get_string('subscriptiondisabled', 'forum'));
                break;
        }
    }

    if ($cansubscribe) {
        if (forum_is_subscribed($USER->id, $forumobject)) {
            $linktext = get_string('unsubscribe', 'forum');
        } else {
            $linktext = get_string('subscribe', 'forum');
        }
        $url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'sesskey'=>sesskey()));
        $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
    }

    if (has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)){
        $url = new moodle_url('/mod/forum/subscribers.php', array('id'=>$forumobject->id));
        $forumnode->add(get_string('showsubscribers', 'forum'), $url, navigation_node::TYPE_SETTING);
    }

    if ($enrolled && forum_tp_can_track_forums($forumobject)) { // keep tracking info for users with suspended enrolments
        if ($forumobject->trackingtype != FORUM_TRACKING_OPTIONAL) {
            //tracking forced on or off in forum settings so dont provide a link here to change it
            //could add unclickable text like for forced subscription but not sure this justifies adding another menu item
        } else {
            if (forum_tp_is_tracked($forumobject)) {
                $linktext = get_string('notrackforum', 'forum');
            } else {
                $linktext = get_string('trackforum', 'forum');
            }
            $url = new moodle_url('/mod/forum/settracking.php', array('id'=>$forumobject->id));
            $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
        }
    }

    if (!isloggedin() && $PAGE->course->id == SITEID) {
        $userid = guest_user()->id;
    } else {
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:lib.php


示例4: forum_print_posts_threaded

            forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum, $modcontext);
        }
    }
    $heading = get_string("yourreply", "forum");
} else {
    $forum->intro = trim($forum->intro);
    if (!empty($forum->intro)) {
        print_box(format_text($forum->intro), 'generalbox', 'intro');
    }
    if ($forum->type == 'qanda') {
        $heading = get_string('yournewquestion', 'forum');
    } else {
        $heading = get_string('yournewtopic', 'forum');
    }
}
if ($USER->id != $post->userid) {
    // Not the original author, so add a message to the end
    $data->date = userdate($post->modified);
    if ($post->format == FORMAT_HTML) {
        $data->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $USER->id . '&course=' . $post->course . '">' . fullname($USER) . '</a>';
        $post->message .= '<p>(<span class="edited">' . get_string('editedby', 'forum', $data) . '</span>)</p>';
    } else {
        $data->name = fullname($USER);
        $post->message .= "\n\n(" . get_string('editedby', 'forum', $data) . ')';
    }
}
//load data into form
$subscribe = isset($post->forum) && forum_is_subscribed($USER->id, $post->forum) || !empty($USER->autosubscribe);
$mform_post->set_data(array('general' => $heading, 'subject' => $post->subject, 'message' => $post->message, 'subscribe' => $subscribe ? 1 : 0, 'mailnow' => !empty($post->mailnow), 'userid' => $post->userid, 'parent' => $post->parent, 'discussion' => $post->discussion, 'course' => $course->id) + $page_params + (isset($post->format) ? array('format' => $post->format) : array()) + (isset($dicussion->timestart) ? array('timestart' => $discussion->timestart) : array()) + (isset($discussion->timeend) ? array('timeend' => $discussion->timeend) : array()) + (isset($post->groupid) ? array('groupid' => $post->groupid) : array()) + (isset($discussion->id) ? array('discussion' => $discussion->id) : array()));
$mform_post->display();
print_footer($course);
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:post.php


示例5: get_string

        $post->message .= '<p>(<span class="edited">' . get_string('editedby', 'forum', $data) . '</span>)</p>';
    } else {
        $data->name = fullname($USER);
        $post->message .= "\n\n(" . get_string('editedby', 'forum', $data) . ')';
    }
}
if (!empty($parent)) {
    $heading = get_string("yourreply", "forum");
} else {
    if ($forum->type == 'qanda') {
        $heading = get_string('yournewquestion', 'forum');
    } else {
        $heading = get_string('yournewtopic', 'forum');
    }
}
if (forum_is_subscribed($USER->id, $forum->id)) {
    $subscribe = true;
} else {
    if (forum_user_has_posted($forum->id, 0, $USER->id)) {
        $subscribe = false;
    } else {
        // user not posted yet - use subscription default specified in profile
        $subscribe = !empty($USER->autosubscribe);
    }
}
$draftid_editor = file_get_submitted_draft_itemid('message');
$currenttext = file_prepare_draft_area($draftid_editor, $modcontext->id, 'mod_forum', 'post', empty($post->id) ? null : $post->id, array('subdirs' => true), $post->message);
$mform_post->set_data(array('attachments' => $draftitemid, 'general' => $heading, 'subject' => $post->subject, 'message' => array('text' => $currenttext, 'format' => empty($post->messageformat) ? editors_get_preferred_format() : $post->messageformat, 'itemid' => $draftid_editor), 'subscribe' => $subscribe ? 1 : 0, 'mailnow' => !empty($post->mailnow), 'userid' => $post->userid, 'parent' => $post->parent, 'discussion' => $post->discussion, 'course' => $course->id) + $page_params + (isset($post->format) ? array('format' => $post->format) : array()) + (isset($discussion->timestart) ? array('timestart' => $discussion->timestart) : array()) + (isset($discussion->timeend) ? array('timeend' => $discussion->timeend) : array()) + (isset($post->groupid) ? array('groupid' => $post->groupid) : array()) + (isset($discussion->id) ? array('discussion' => $discussion->id) : array()));
if ($fromform = $mform_post->get_data()) {
    if (empty($SESSION->fromurl)) {
        $errordestination = "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}";
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:post.php


示例6: test_forum_is_subscribed_numeric

 /**
  * Test that the deprecated forum_is_subscribed accepts numeric forum IDs.
  */
 public function test_forum_is_subscribed_numeric()
 {
     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 students.
     list($author) = $this->helper_create_users($course, 1);
     // Check that the user is currently unsubscribed to the forum.
     $this->assertFalse(forum_is_subscribed($author->id, $forum->id));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // It should match the result of when it's called with the forum object.
     $this->assertFalse(forum_is_subscribed($author->id, $forum));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // And when the user is subscribed, we should also get the correct result.
     \mod_forum\subscriptions::subscribe_user($author->id, $forum);
     $this->assertTrue(forum_is_subscribed($author->id, $forum->id));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // It should match the result of when it's called with the forum object.
     $this->assertTrue(forum_is_subscribed($author->id, $forum));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
 }
开发者ID:Jinelle,项目名称:moodle,代码行数:31,代码来源:subscriptions_test.php


示例7: optional_param

$returnto = optional_param('backtoindex', 0, PARAM_INT) ? "index.php?id=" . $course->id : "view.php?f={$id}";
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)) {
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:subscribe.php


示例8: 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 = forum_subscribed_users($course, $forum);
     // No subscriptions by default.
     $this->assertEquals(0, count($result));
     foreach ($users as $user) {
         $this->assertFalse(forum_is_subscribed($user->id, $forum));
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:25,代码来源:lib_test.php


示例9: forum_get_subscribe_link

/**
 * Generate and return the subscribe or unsubscribe link for a forum.
 * @param object $forum the forum. Fields used are $forum->id and $forum->forcesubscribe.
 * @param object $context the context object for this forum.
 * @param array $messages text used for the link in its various states
 *      (subscribed, unsubscribed, forcesubscribed or cantsubscribe).
 *      Any strings not passed in are taken from the $defaultmessages array
 *      at the top of the function.
 * @param
 */
function forum_get_subscribe_link($forum, $context, $messages = array(), $cantaccessagroup = false, $fakelink = true, $backtoindex = false, $subscribed_forums = null)
{
    global $CFG, $USER;
    $defaultmessages = array('subscribed' => get_string('unsubscribe', 'forum'), 'unsubscribed' => get_string('subscribe', 'forum'), 'cantaccessgroup' => get_string('no'), 'forcesubscribed' => get_string('everyoneissubscribed', 'forum'), 'cantsubscribe' => get_string('disallowsubscribe', 'forum'));
    $messages = $messages + $defaultmessages;
    if (forum_is_forcesubscribed($forum)) {
        return $messages['forcesubscribed'];
    } else {
        if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !has_capability('mod/forum:managesubscriptions', $context)) {
            return $messages['cantsubscribe'];
        } else {
            if ($cantaccessagroup) {
                return $messages['cantaccessgroup'];
            } else {
                if (is_null($subscribed_forums)) {
                    $subscribed = forum_is_subscribed($USER->id, $forum);
                } else {
                    $subscribed = !empty($subscribed_forums[$forum->id]);
                }
                if ($subscribed) {
                    $linktext = $messages['subscribed'];
                    $linktitle = get_string('subscribestop', 'forum');
                } else {
                    $linktext = $messages['unsubscribed'];
                    $linktitle = get_string('subscribestart', 'forum');
                }
                $options = array();
                if ($backtoindex) {
                    $backtoindexlink = '&amp;backtoindex=1';
                    $options['backtoindex'] = 1;
                } else {
                    $backtoindexlink = '';
                }
                $link = '';
                if ($fakelink) {
                    $link .= '<script type="text/javascript">';
                    $link .= '//<![CDATA[' . "\n";
                    $link .= 'document.getElementById("subscriptionlink").innerHTML = "<a title=\\"' . $linktitle . '\\" href=\\"' . $CFG->wwwroot . '/mod/forum/subscribe.php?id=' . $forum->id . $backtoindexlink . '\\">' . $linktext . '<\\/a>";';
                    $link .= '//]]>';
                    $link .= '</script>';
                    // use <noscript> to print button in case javascript is not enabled
                    $link .= '<noscript>';
                }
                $options['id'] = $forum->id;
                $link .= print_single_button($CFG->wwwroot . '/mod/forum/subscribe.php', $options, $linktext, 'post', '_self', true, $linktitle);
                if ($fakelink) {
                    $link .= '</noscript>';
                }
                return $link;
            }
        }
    }
}
开发者ID:r007,项目名称:PMoodle,代码行数:63,代码来源:lib.php


示例10: forum_post_subscription

/**
 * Given a new post, subscribes or unsubscribes as appropriate.
 * Returns some text which describes what happened.
 */
function forum_post_subscription($post)
{
    global $USER;
    $subscribed = forum_is_subscribed($USER->id, $post->forum);
    if (isset($post->subscribe) && $post->subscribe && $subscribed || !$post->subscribe && !$subscribed) {
        return "";
    }
    if (!($forum = get_record("forum", "id", $post->forum))) {
        return "";
    }
    $info->name = fullname($USER);
    $info->forum = $forum->name;
    if (!empty($post->subscribe)) {
        forum_subscribe($USER->id, $post->forum);
        return "<p>" . get_string("nowsubscribed", "forum", $info) . "</p>";
    }
    forum_unsubscribe($USER->id, $post->forum);
    return "<p>" . get_string("nownotsubscribed", "forum", $info) . "</p>";
}
开发者ID:njorth,项目名称:marginalia,代码行数:23,代码来源:lib.php


示例11: cms_render_news

function cms_render_news($course)
{
    global $CFG;
    if ($course->newsitems) {
        // Print forums only when needed
        require_once $CFG->dirroot . '/mod/forum/lib.php';
        if (!($newsforum = forum_get_course_forum($course->id, 'news'))) {
            error('Could not find or create a main news forum for the course');
        }
        if (isset($USER->id)) {
            $SESSION->fromdiscussion = $CFG->wwwroot;
            if (forum_is_subscribed($USER->id, $newsforum->id)) {
                $subtext = get_string('unsubscribe', 'forum');
            } else {
                $subtext = get_string('subscribe', 'forum');
            }
            $headertext = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>' . '<td><div class="title">' . $newsforum->name . '</div></td>' . '<td><div class="link"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div></td>' . '</tr></table>';
        } else {
            $headertext = $newsforum->name;
        }
        ob_start();
        print_heading_block($headertext);
        forum_print_latest_discussions($course, $newsforum, $course->newsitems, 'plain', 'p.modified DESC');
        $return = ob_get_contents();
        ob_end_clean();
        return $return;
    }
    return '';
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:29,代码来源:cmslib.php


示例12: page_frontpage_settings

/**
 * Called from {@link page_print_position()} and it is
 * supposed to print the front page settings in the
 * center column for the site course and only for
 * the default page (EG: the landing page).
 *
 * @return boolean
 **/
function page_frontpage_settings()
{
    global $CFG, $SESSION, $SITE, $PAGE, $COURSE;
    // Cheap check first - course ID
    if ($COURSE->id != SITEID) {
        return false;
    }
    // More expensive check - make sure we are viewing default page
    $default = page_get_default_page();
    $current = $PAGE->get_formatpage();
    if (empty($default->id) or empty($current->id) or $default->id != $current->id) {
        return false;
    }
    $editing = $PAGE->user_is_editing();
    /// START COPY/PASTE FROM INDEX.PHP
    print_container_start();
    /// Print Section
    if ($SITE->numsections > 0) {
        if (!($section = get_record('course_sections', 'course', $SITE->id, 'section', 1))) {
            delete_records('course_sections', 'course', $SITE->id, 'section', 1);
            // Just in case
            $section->course = $SITE->id;
            $section->section = 1;
            $section->summary = '';
            $section->sequence = '';
            $section->visible = 1;
            $section->id = insert_record('course_sections', $section);
        }
        if (!empty($section->sequence) or !empty($section->summary) or $editing) {
            print_box_start('generalbox sitetopic');
            /// If currently moving a file then show the current clipboard
            if (ismoving($SITE->id)) {
                $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
                echo '<p><font size="2">';
                echo "{$stractivityclipboard}&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true&amp;sesskey={$USER->sesskey}\">" . get_string('cancel') . '</a>)';
                echo '</font></p>';
            }
            $options = NULL;
            $options->noclean = true;
            echo format_text($section->summary, FORMAT_HTML, $options);
            if ($editing) {
                $streditsummary = get_string('editsummary');
                echo "<a title=\"{$streditsummary}\" " . " href=\"course/editsection.php?id={$section->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" " . " class=\"iconsmall\" alt=\"{$streditsummary}\" /></a><br /><br />";
            }
            get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
            print_section($SITE, $section, $mods, $modnamesused, true);
            if ($editing) {
                print_section_add_menus($SITE, $section->section, $modnames);
            }
            print_box_end();
        }
    }
    if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) {
        $frontpagelayout = $CFG->frontpageloggedin;
    } else {
        $frontpagelayout = $CFG->frontpage;
    }
    foreach (explode(',', $frontpagelayout) as $v) {
        switch ($v) {
            /// Display the main part of the front page.
            case FRONTPAGENEWS:
                if ($SITE->newsitems) {
                    // Print forums only when needed
                    require_once $CFG->dirroot . '/mod/forum/lib.php';
                    if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) {
                        error('Could not find or create a main news forum for the site');
                    }
                    if (!empty($USER->id)) {
                        $SESSION->fromdiscussion = $CFG->wwwroot;
                        if (forum_is_subscribed($USER->id, $newsforum)) {
                            $subtext = get_string('unsubscribe', 'forum');
                        } else {
                            $subtext = get_string('subscribe', 'forum');
                        }
                        print_heading_block($newsforum->name);
                        echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>';
                    } else {
                        print_heading_block($newsforum->name);
                    }
                    forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
                }
                break;
            case FRONTPAGECOURSELIST:
                if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
                    print_heading_block(get_string('mycourses'));
                    print_my_moodle();
                } else {
                    if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() or count_records('course') <= FRONTPAGECOURSELIMIT) {
                        // admin should not see list of courses when there are too many of them
                        print_heading_block(get_string('availablecourses'));
                        print_courses(0);
                    }
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:lib.php


示例13: local_my_print_latestnews_headers

/**
 * Prints the news forum as simple compact list of discussion headers.
 */
function local_my_print_latestnews_headers()
{
    global $PAGE, $SITE, $CFG, $OUTPUT, $USER, $SESSION;
    $str = '';
    if ($SITE->newsitems) {
        // Print forums only when needed.
        require_once $CFG->dirroot . '/mod/forum/lib.php';
        if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) {
            print_error('cannotfindorcreateforum', 'forum');
        }
        $renderer = $PAGE->get_renderer('local_my');
        $renderer->print_forum_link($newforum);
        if (isloggedin()) {
            if (!isset($SESSION)) {
                $SESSION = new StdClass();
            }
            $SESSION->fromdiscussion = $CFG->wwwroot;
            $subtext = '';
            if (forum_is_subscribed($USER->id, $newsforum)) {
                if (!forum_is_forcesubscribed($newsforum)) {
                    $subtext = get_string('unsubscribe', 'forum');
                }
            } else {
                $subtext = get_string('subscribe', 'forum');
            }
            $str .= '<div class="block block_my_newsheads">';
            $str .= '<div class="header">';
            $str .= '<div class="title">';
            $str .= '<h2>' . $forumname . '</h2>';
            $str .= '</div>';
            $str .= '</div>';
            $str .= '<div class="content">';
            $suburl = new moodle_url('/mod/forum/subscribe.php', array('id' => $newsforum->id, 'sesskey' => sesskey()));
            $str .= html_writer::tag('div', html_writer::link($suburl, $subtext), array('class' => 'subscribelink'));
            $str .= '</div>';
        } else {
            $str .= '<div class="block block_my_newsheads">';
            $str .= '<div class="header">';
            $str .= '<div class="title">';
            $str .= $OUTPUT->heading($forumname, 2, 'headingblock header');
            $str .= '</div>';
            $str .= '</div>';
        }
        ob_start();
        forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'header', 'p.modified DESC');
        $str .= ob_get_clean();
        $str .= '</div>';
        $str .= html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipsitenews'));
    }
    return $str;
}
开发者ID:vfremaux,项目名称:moodle-local_my,代码行数:54,代码来源:modules.php


示例14: forum_post_subscription

/**
 * Given a new post, subscribes or unsubscribes as appropriate.
 * Returns some text which describes what happened.
 */
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', get_context_instance(CONTEXT_COURSE, $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->name = fullname($USER);
    $info->forum = $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:veritech,项目名称:pare-project,代码行数:43,代码来源:lib.php


示例15: forum_get_subscribe_link

/**
 * Generate and return the subscribe or unsubscribe link for a forum.
 * @param object $forum the forum. Fields used are $forum->id and $forum->forcesubscribe.
 * @param object $context the context object for this forum.
 * @param array $messages text used for the link in its various states
 *      (subscribed, unsubscribed, forcesubscribed or cantsubscribe).
 *      Any strings not passed in are taken from the $defaultmessages array
 *      at the top of the function.
 * @param
 */
function forum_get_subscribe_link($forum, $context, $messages = array(), $cantaccessagroup = false, $fakelink = true, $backtoindex = false, $subscribed_forums = null)
{
    global $CFG, $USER;
    $defaultmessages = array('subscribed' => get_string('unsubscribe', 'forum'), 'unsubscribed' => get_string('subscribe', 'forum'), 'cantaccessgroup' => get_string('no'), 'forcesubscribed' => get_string('everyoneissubscribed', 'forum'), 'cantsubscribe' => get_string('disallowsubscribe', 'forum'));
    $messages = $messages + $defaultmessages;
    if (forum_is_forcesubscribed($forum)) {
        return $messages['forcesubscribed'];
    } else {
        if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !has_capability('mod/forum:managesubscriptions', $context)) {
            return $messages['cantsubscribe'];
        } else {
            if ($cantaccessagroup) {
                return $messages['cantaccessgroup'];
            } else {
                if (is_null($subscribed_forums)) {
                    $subscribed = forum_is_subscribed($USER->id, $forum);
                } else {
                    $subscribed = !empty($subscribed_forums[$forum->id]);
                }
                if ($subscribed) {
                    $linktext = $messages['subscribed'];
                    $linktitle = get_string('subscribestop', 'forum');
                } else {
                    $linktext = $messages['unsubscribed'];
                    $linktitle = get_string('subscribestart', 'forum');
                }
                $options = array();
                if ($backtoindex) {
                    $backtoindexlink = '&amp;backtoindex=1';
                    $options['backtoindex'] = 1;
                } else {
                    $backtoindexlink = '';
                }
                $link = '';
                $sesskeylink = '&amp;sesskey=' . sesskey();
                if ($fakelink) {
                    $link .= <<<EOD
<script type="text/javascript">
//<![CDATA[
var subs_link = document.getElementById("subscriptionlink");
if(subs_link){
    subs_link.innerHTML = "<a title=\\"{$linktitle}\\" href='{$CFG->wwwroot}/mod/forum/subscribe.php?id={$forum->id}{$backtoindexlink}{$sesskeylink}'>{$linktext}<\\/a>";
}
//]]>
</script>
<noscript>
EOD;
                }
                $options['id'] = $forum->id;
                $options['sesskey'] = sesskey();
                $link .= print_single_button($CFG->wwwroot . '/mod/forum/subscribe.php', $options, $linktext, 'post', '_self', true, $linktitle);
                if ($fakelink) {
                    $link .= '</noscript>';
                }
                return $link;
            }
        }
    }
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:69,代码来源:lib.php


示例16: forum_get_subscribe_link

/**
 * Generate and return the subscribe or unsubscribe link for a forum.
 *
 * @global object
 * @global object
 * @global object
 * @param object $forum the forum. Fields used are $forum->id and $forum->forcesubscribe.
 * @param object $context the context object for this forum.
 * @param array $messages text used for the link in its various states
 *      (subscribed, unsubscribed, forcesubscribed or cantsubscribe).
 *      Any strings not passed in are taken from the $defaultmessages array
 *      at the top of the function.
 * @param bool $cantaccessagroup
 * @param bool $fakelink
 * @param bool $backtoindex
 * @param array $subscribed_forums
 * @return string
 */
function forum_get_subscribe_link($forum, $context, $messages = array(), $cantaccessagroup = false, $fakelink = true, $backtoindex = false, $subscribed_forums = null)
{
    global $CFG, $USER, $PAGE, $OUTPUT;
    $defaultmessages = array('subscribed' => get_string('unsubscribe', 'forum'), 'unsubscribed' => get_string('subscribe', 'forum'), 'cantaccessgroup' => get_string('no'), 'forcesubscribed' => get_string('everyoneissubscribed', 'forum'), 'cantsubscribe' => get_string('disallowsubscribe', 'forum'));
    $messages = $messages + $defaultmessages;
    if (forum_is_forcesubscribed($forum)) {
        return $messages['forcesubscribed'];
    } else {
        if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !has_capability('mod/forum:managesubscriptions', $context)) {
            return $messages['cantsubscribe'];
        } else {
            if ($cantaccessagroup) {
                return $messages['cantaccessgroup'];
            } else {
                if (is_null($subscribed_forums)) {
                    $subscribed = forum_is_subscribed($USER->id, $forum);
                } else {
                    $subscribed = !empty($subscribed_forums[$forum->id]);
                }
                if ($subscribed) {
                    $linktext = $messages['subscribed'];
                    $linktitle = get_string('subscribestop', 'forum');
                } else {
                    $linktext = $messages['unsubscribed'];
                    $linktitle = get_string('subscribestart', 'forum');
                }
                $options = array();
                if ($backtoindex) {
                    $backtoindexlink = '&amp;backtoindex=1';
                    $options['backtoindex'] = 1;
                } else {
                    $backtoindexlink = '';
                }
                $link = '';
                if ($fakelink) {
                    $PAGE->requires->js('mod/forum/forum.js');
                    $PAGE->requires->js_function_call('forum_produce_subscribe_link', array($forum->id, $backtoindexlink, $linktext, $linktitle));
                    $link = "<noscript>";
                }
                $options['id'] = $forum->id;
                $form = html_form::make_button($CFG->wwwroot . '/mod/forum/subscribe.php', $options, $linktext);
                $form->button->title = $linktitle;
                $link .= $OUTPUT->button($form);
                if ($fakelink) {
                    $link .= '</noscript>';
                }
                return $link;
            }
        }
    }
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:69,代码来源:lib.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP forum_is_user_group_discussion函数代码示例发布时间:2022-05-15
下一篇:
PHP forum_is_forcesubscribed函数代码示例发布时间: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