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

PHP forum_is_forcesubscribed函数代码示例

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

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



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

示例1: foreach

 }
 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:
             if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:31,代码来源:index.php


示例2: 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 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_enrolled($context, $USER, '', true)) {
            return '';
        }
        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;
        $options['sesskey'] = sesskey();
        $url = new moodle_url('/mod/forum/subscribe.php', $options);
        $link .= $OUTPUT->single_button($url, $linktext, 'get', array('title'=>$linktitle));
        if ($fakelink) {
            $link .= '</noscript>';
        }

        return $link;
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:74,代码来源:lib.php


示例3: definition

 function definition()
 {
     global $CFG;
     $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'];
     // if $forum->maxbytes == '0' means we should use $course->maxbytes
     if ($forum->maxbytes == '0') {
         $forum->maxbytes = $course->maxbytes;
     }
     // TODO: add max files and max size support
     $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'trusttext' => true, 'context' => $modcontext);
     $mform->addElement('header', 'general', '');
     //fill in the data depending on page params later using set_data
     $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, $editoroptions);
     $mform->setType('message', PARAM_RAW);
     $mform->addRule('message', get_string('required'), 'required', null, 'client');
     if (isset($forum->id) && forum_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', 'subscription', 'forum');
     } else {
         if (isset($forum->forcesubscribe) && $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE || has_capability('moodle/course:manageactivities', $coursecontext)) {
             $options = array();
             $options[0] = get_string('subscribestop', 'forum');
             $options[1] = get_string('subscribestart', 'forum');
             $mform->addElement('select', 'subscribe', get_string('subscription', 'forum'), $options);
             $mform->addHelpButton('subscribe', 'subscription', 'forum');
         } else {
             if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
                 $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum'));
                 $mform->addElement('hidden', 'subscribe');
                 $mform->setType('subscribe', PARAM_INT);
                 $mform->addHelpButton('subscribemessage', 'subscription', '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, array('subdirs' => 0, 'maxbytes' => $forum->maxbytes, 'maxfiles' => $forum->maxattachments, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL));
         $mform->addHelpButton('attachments', 'attachment', 'forum');
     }
     if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) {
         // hack alert
         $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', '', 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 (groups_get_activity_groupmode($cm, $course)) {
         // hack alert
         $groupdata = groups_get_activity_allowed_groups($cm);
         $groupcount = count($groupdata);
         $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
         $contextcheck = has_capability('mod/forum:movediscussions', $modulecontext) && empty($post->parent) && $groupcount > 1;
         if ($contextcheck) {
             $groupinfo = array('0' => get_string('allparticipants'));
             foreach ($groupdata as $grouptemp) {
                 $groupinfo[$grouptemp->id] = $grouptemp->name;
             }
             $mform->addElement('select', 'groupinfo', get_string('group'), $groupinfo);
             $mform->setDefault('groupinfo', $post->groupid);
         } else {
             if (empty($post->groupid)) {
                 $groupname = get_string('allparticipants');
             } else {
                 $groupname = format_string($groupdata[$post->groupid]->name);
             }
             $mform->addElement('static', 'groupinfo', get_string('group'), $groupname);
         }
     }
     //-------------------------------------------------------------------------------
     // buttons
     if (isset($post->edit)) {
         // hack alert
         $submit_string = get_string('savechanges');
     } else {
         $submit_string = get_string('posttoforum', 'forum');
     }
     $this->add_action_buttons(false, $submit_string);
//.........这里部分代码省略.........
开发者ID:nmicha,项目名称:moodle,代码行数:101,代码来源:post_form.php


示例4: redirect

 if (isguestuser() or !$can_subscribe) {
     // 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 {
开发者ID:gwsd2015,项目名称:LogiClass,代码行数:31,代码来源:index.php


示例5: definition

 function definition()
 {
     global $CFG;
     $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'];
     // hack alert
     // the upload manager is used directly in post precessing, moodleform::save_files() is not used yet
     $this->set_upload_manager(new upload_manager('attachment', true, false, $course, false, $forum->maxbytes, true, true));
     $mform->addElement('header', 'general', '');
     //fill in the data depending on page params
     //later using set_data
     $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('htmleditor', 'message', get_string('message', 'forum'), array('cols' => 50, 'rows' => 30));
     $mform->setType('message', PARAM_RAW);
     $mform->addRule('message', get_string('required'), 'required', null, 'client');
     $mform->setHelpButton('message', array('reading', 'writing', 'questions', 'richtext'), false, 'editorhelpbutton');
     $mform->addElement('format', 'format', get_string('format'));
     if (isset($forum->id) && forum_is_forcesubscribed($forum)) {
         $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('everyoneissubscribed', 'forum'));
         $mform->addElement('hidden', 'subscribe');
         $mform->setHelpButton('subscribemessage', array('subscription', get_string('subscription', 'forum'), 'forum'));
     } else {
         if (isset($forum->forcesubscribe) && $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE || has_capability('moodle/course:manageactivities', $coursecontext)) {
             $options = array();
             $options[0] = get_string('subscribestop', 'forum');
             $options[1] = get_string('subscribestart', 'forum');
             $mform->addElement('select', 'subscribe', get_string('subscription', 'forum'), $options);
             $mform->setHelpButton('subscribe', array('subscription', get_string('subscription', 'forum'), 'forum'));
         } else {
             if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
                 $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum'));
                 $mform->addElement('hidden', 'subscribe');
                 $mform->setHelpButton('subscribemessage', array('subscription', get_string('subscription', 'forum'), 'forum'));
             }
         }
     }
     if ($forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) {
         //  1 = No attachments at all
         $mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
         $mform->setHelpButton('attachment', array('attachment', get_string('attachment', 'forum'), 'forum'));
     }
     if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) {
         // hack alert
         $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', '', get_string('displayperiod', 'forum'));
         $mform->addElement('date_selector', 'timestart', get_string('displaystart', 'forum'), array('optional' => true));
         $mform->setHelpButton('timestart', array('displayperiod', get_string('displayperiod', 'forum'), 'forum'));
         $mform->addElement('date_selector', 'timeend', get_string('displayend', 'forum'), array('optional' => true));
         $mform->setHelpButton('timeend', array('displayperiod', get_string('displayperiod', 'forum'), '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 (groups_get_activity_groupmode($cm, $course)) {
         // hack alert
         if (empty($post->groupid)) {
             $groupname = get_string('allparticipants');
         } else {
             $group = groups_get_group($post->groupid);
             $groupname = format_string($group->name);
         }
         $mform->addElement('static', 'groupinfo', get_string('group'), $groupname);
     }
     //-------------------------------------------------------------------------------
     // buttons
     if (isset($post->edit)) {
         // hack alert
         $submit_string = get_string('savechanges');
     } else {
         $submit_string = get_string('posttoforum', 'forum');
     }
     $this->add_action_buttons(false, $submit_string);
     $mform->addElement('hidden', 'course');
     $mform->setType('course', PARAM_INT);
     $mform->addElement('hidden', 'forum');
     $mform->setType('forum', PARAM_INT);
     $mform->addElement('hidden', 'discussion');
     $mform->setType('discussion', PARAM_INT);
     $mform->addElement('hidden', 'parent');
     $mform->setType('parent', PARAM_INT);
     $mform->addElement('hidden', 'userid');
     $mform->setType('userid', PARAM_INT);
     $mform->addElement('hidden', 'groupid');
     $mform->setType('groupid', PARAM_INT);
     $mform->addElement('hidden', 'edit');
     $mform->setType('edit', PARAM_INT);
//.........这里部分代码省略.........
开发者ID:kai707,项目名称:ITSA-backup,代码行数:101,代码来源:post_form.php


示例6: 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


示例7: forum_is_subscribed

/**
 * TODO document
 */
function forum_is_subscribed($userid, $forumid)
{
    if (forum_is_forcesubscribed($forumid)) {
        return true;
    }
    return record_exists("forum_subscriptions", "userid", $userid, "forum", $forumid);
}
开发者ID:njorth,项目名称:marginalia,代码行数:10,代码来源:lib.php


示例8: 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'];
     $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');
     if (isset($forum->id) && forum_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', 'subscription', 'forum');
     } else {
         if (isset($forum->forcesubscribe) && $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE || has_capability('moodle/course:manageactivities', $coursecontext)) {
             $options = array();
             $options[0] = get_string('subscribestop', 'forum');
             $options[1] = get_string('subscribestart', 'forum');
             $mform->addElement('select', 'subscribe', get_string('subscription', 'forum'), $options);
             $mform->addHelpButton('subscribe', 'subscription', 'forum');
         } else {
             if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
                 $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum'));
                 $mform->addElement('hidden', 'subscribe');
                 $mform->setType('subscribe', PARAM_INT);
                 $mform->addHelpButton('subscribemessage', 'subscription', '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) && has_capability('moodle/course:manageactivities', $coursecontext)) {
         // hack alert
         $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 (groups_get_activity_groupmode($cm, $course)) {
         // hack alert
         $groupdata = groups_get_activity_allowed_groups($cm);
         $groupcount = count($groupdata);
         $modulecontext = context_module::instance($cm->id);
         $contextcheck = has_capability('mod/forum:movediscussions', $modulecontext) && empty($post->parent) && $groupcount;
         if ($contextcheck) {
             $groupinfo = array('0' => get_string('allparticipants'));
             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');
             } else {
                 $groupname = format_string($groupdata[$post->groupid]->name);
             }
             $mform->addElement('static', 'groupinfo', get_string('group'), $groupname);
         }
//.........这里部分代码省略.........
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:101,代码来源:post_form.php


示例9: 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


示例10: forum_is_subscribed

/**
 * TODO document
 */
function forum_is_subscribed($userid, $forum)
{
    if (!is_object($forum)) {
        $forum = get_record('forum', 'id', $forum);
    }
    if (forum_is_forcesubscribed($forum)) {
        return true;
    }
    return record_exists("forum_subscriptions", "userid", $userid, "forum", $forum->id);
}
开发者ID:veritech,项目名称:pare-project,代码行数:13,代码来源:lib.php


示例11: 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


示例12: definition

 function definition()
 {
     //--------------- ENHANCED POODLL FORUM BEGIN -------------------
     //global $CFG;
     global $CFG, $COURSE, $USER;
     //--------------- ENHANCED POODLL FORUM END -------------------
     $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'];
     // hack alert
     // the upload manager is used directly in post precessing, moodleform::save_files() is not used yet
     $this->set_upload_manager(new upload_manager('attachment', true, false, $course, false, $forum->maxbytes, true, true));
     $mform->addElement('header', 'general', '');
     //fill in the data depending on page params
     //later using set_data
     $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');
     //--------------- ENHANCED POODLL FORUM BEGIN -------------------
     if ($CFG->filter_poodll_forum_video || $CFG->filter_poodll_forum_audio) {
         // $rtmptime  = optional_param('rtmptime', time());
         $mform->addElement('header', 'flvvideo', 'Voice posting');
         $siteid = explode("/", $CFG->wwwroot);
         $siteid = str_replace(".", "_", $siteid[2]);
         //Justin 20081112 : add this for URLs with ports spec. by colon
         $siteid = str_replace(":", "-", $siteid[2]);
         $rtmplink = $CFG->poodll_media_server;
         $mediadata = '<a href="#" onclick="document.getElementById(\'teacherrecorder\').style.display=\'block\';">Record Audio/Video</a>';
         $mediadata .= "<div id='teacherrecorder' style='display: none'>";
         //toggle these lines to use video or audio forums
         if ($CFG->filter_poodll_forum_video) {
             //need to figure out a way to get post id on a new post ...
             //   $mediadata .= fetchSimpleVideoRecorder('forum/' .$forum->id , $post->id);
             $mediadata .= fetchSimpleVideoRecorder('forum/' . $forum->id, $USER->id);
         } else {
             $mediadata .= fetchSimpleAudioRecorder('forum/' . $forum->id, $USER->id);
         }
         $mediadata .= "</div>";
         $mform->addElement('static', 'description', 'Audio/Video Posting:', $mediadata);
         //Here we modify the existing post format, so that the html message is small and not required
         $mform->addElement('htmleditor', 'message', get_string('message', 'forum'), array('cols' => 50, 'rows' => 10));
         $mform->setType('message', PARAM_RAW);
         $mform->setHelpButton('message', array('reading', 'writing', 'questions', 'richtext'), false, 'editorhelpbutton');
     } else {
         // Old Moodle Forum Stuff
         $mform->addElement('htmleditor', 'message', get_string('message', 'forum'), array('cols' => 50, 'rows' => 30));
         $mform->setType('message', PARAM_RAW);
         $mform->addRule('message', get_string('required'), 'required', null, 'client');
         $mform->setHelpButton('message', array('reading', 'writing', 'questions', 'richtext'), false, 'editorhelpbutton');
     }
     //--------------- ENHANCED POODLL FORUM END -------------------
     $mform->addElement('format', 'format', get_string('format'));
     if (isset($forum->id) && forum_is_forcesubscribed($forum)) {
         $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('everyoneissubscribed', 'forum'));
         $mform->addElement('hidden', 'subscribe');
         $mform->setHelpButton('subscribemessage', array('subscription', get_string('subscription', 'forum'), 'forum'));
     } else {
         if (isset($forum->forcesubscribe) && $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE || has_capability('moodle/course:manageactivities', $coursecontext)) {
             $options = array();
             $options[0] = get_string('subscribestop', 'forum');
             $options[1] = get_string('subscribestart', 'forum');
             $mform->addElement('select', 'subscribe', get_string('subscription', 'forum'), $options);
             $mform->setHelpButton('subscribe', array('subscription', get_string('subscription', 'forum'), 'forum'));
         } else {
             if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
                 $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum'));
                 $mform->addElement('hidden', 'subscribe');
                 $mform->setHelpButton('subscribemessage', array('subscription', get_string('subscription', 'forum'), 'forum'));
             }
         }
     }
     if ($forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) {
         //  1 = No attachments at all
         $mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
         $mform->setHelpButton('attachment', array('attachment', get_string('attachment', 'forum'), 'forum'));
     }
     if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) {
         // hack alert
         $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', '', get_string('displayperiod', 'forum'));
         $mform->addElement('date_selector', 'timestart', get_string('displaystart', 'forum'), array('optional' => true));
         $mform->setHelpButton('timestart', array('displayperiod', get_string('displayperiod', 'forum'), 'forum'));
         $mform->addElement('date_selector', 'timeend', get_string('displayend', 'forum'), array('optional' => true));
         $mform->setHelpButton('timeend', array('displayperiod', get_string('displayperiod', 'forum'), '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 (groups_get_activity_groupmode($cm, $course)) {
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:poodll,代码行数:101,代码来源:post_form.php


示例13: 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)) {
    if ($edit != -1) {
        $USER->subscriptionsediting = $edit;
    }
    $PAGE->set_button(forum_update_subscriptions_button($course->id, $id));
} else {
    unset($USER->subscriptionsediting);
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('forum', 'forum').' '.$strsubscribers);
if (empty($USER->subscriptionsediting)) {
    echo $forumoutput->subscriber_overview(forum_subscribed_users($course, $forum, $currentgroup, $context), $forum, $course);
} else if (forum_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:narasimhaeabyas,项目名称:tataaiapro,代码行数:31,代码来源:subscribers.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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