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

PHP forum_user_can_post_discussion函数代码示例

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

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



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

示例1: format_string

}
$PAGE->set_title("{$course->shortname}: {$strdiscussionname} " . format_string($toppost->subject));
$PAGE->set_heading($course->fullname);
// #marginalia begin
$moodlemia = moodle_marginalia::get_instance();
$miaprofile = $moodlemia->get_profile($PAGE->url->out(false));
if ($miaprofile) {
    $miaprofile->emit_requires($moodlemia);
}
// #marginalia end
echo $OUTPUT->header();
// checkup
if (!empty($parent) && !forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
    print_error('cannotreply', 'forum');
}
if (empty($parent) && empty($edit) && !forum_user_can_post_discussion($forum, $groupid, -1, $cm, $modcontext)) {
    print_error('cannotcreatediscussion', 'forum');
}
if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $modcontext) && !empty($discussion->id) && !forum_user_has_posted($forum->id, $discussion->id, $USER->id)) {
    echo $OUTPUT->notification(get_string('qandanotify', 'forum'));
}
forum_check_throttling($forum, $cm);
if (!empty($parent)) {
    if (!($discussion = $DB->get_record('forum_discussions', array('id' => $parent->discussion)))) {
        print_error('notpartofdiscussion', 'forum');
    }
    // #marginalia begin
    $moodlemia = moodle_marginalia::get_instance();
    $miaprofile = $moodlemia->get_profile($PAGE->url->out(false));
    if ($miaprofile) {
        $miaprofile->emit_body();
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:post.php


示例2: forum_user_can_post

            }

            $canreply    = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $context);
            $canrate     = has_capability('mod/forum:rate', $context);
            $displaymode = get_user_preferences("forum_displaymode", $CFG->forum_displaymode);

            echo ' '; // this should fix the floating in FF
            forum_print_discussion($course, $cm, $forum, $discussion, $post, $displaymode, $canreply, $canrate);
            break;

        case 'eachuser':
            if (!empty($forum->intro)) {
                echo $OUTPUT->box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
            }
            echo '<p class="mdl-align">';
            if (forum_user_can_post_discussion($forum, null, -1, $cm)) {
                print_string("allowsdiscussions", "forum");
            } else {
                echo '&nbsp;';
            }
            echo '</p>';
            if (!empty($showall)) {
                forum_print_latest_discussions($course, $forum, 0, 'header', '', -1, -1, -1, 0, $cm);
            } else {
                forum_print_latest_discussions($course, $forum, -1, 'header', '', -1, -1, $page, $CFG->forum_manydiscussions, $cm);
            }
            break;

        case 'teacher':
            if (!empty($showall)) {
                forum_print_latest_discussions($course, $forum, 0, 'header', '', -1, -1, -1, 0, $cm);
开发者ID:ncsu-delta,项目名称:moodle,代码行数:31,代码来源:view.php


示例3: format_string

    $navtail = '';
} else {
    // Show the discussion name in the breadcrumbs.
    $strdiscussionname = format_string($discussion->name) . ':';
}
$forcefocus = empty($reply) ? NULL : 'message';
if ($course->id != SITEID) {
    print_header("{$course->shortname}: {$strdiscussionname} " . format_string($toppost->subject), $course->fullname, "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->\n                      {$navmiddle} {$navtail}", $mform_post->focus($forcefocus), "", true, "", navmenu($course, $cm));
} else {
    print_header("{$course->shortname}: {$strdiscussionname} " . format_string($toppost->subject), $course->fullname, "{$navmiddle} {$navtail}", $mform_post->focus($forcefocus), "", true, "", navmenu($course, $cm));
}
// checkup
if (!empty($parent) && !forum_user_can_see_post($forum, $discussion, $post)) {
    error("You cannot reply to this post");
}
if (empty($parent) && empty($edit) && !forum_user_can_post_discussion($forum)) {
    error("You cannot start a new discussion in this forum");
}
if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $modcontext) && !empty($discussion->id) && !forum_user_has_posted($forum->id, $discussion->id, $USER->id)) {
    notify(get_string('qandanotify', 'forum'));
}
forum_check_throttling($forum);
if (!empty($parent)) {
    forum_print_post($parent, $course->id, $ownpost = false, $reply = false, $link = false);
    if (empty($post->edit)) {
        if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) {
            $user_read_array = forum_tp_get_discussion_read_records($USER->id, $discussion->id);
        } else {
            $user_read_array = array();
        }
        if ($forum->type != 'qanda' || forum_user_can_see_discussion($forum, $discussion, $modcontext)) {
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:post.php


示例4: get_content

 function get_content()
 {
     global $CFG, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     if ($this->page->course->newsitems) {
         // Create a nice listing of recent postings
         require_once $CFG->dirroot . '/mod/forum/lib.php';
         // We'll need this
         $text = '';
         if (!($forum = forum_get_course_forum($this->page->course->id, 'news'))) {
             return '';
         }
         $modinfo = get_fast_modinfo($this->page->course);
         if (empty($modinfo->instances['forum'][$forum->id])) {
             return '';
         }
         $cm = $modinfo->instances['forum'][$forum->id];
         if (!$cm->uservisible) {
             return '';
         }
         $context = context_module::instance($cm->id);
         /// User must have perms to view discussions in that forum
         if (!has_capability('mod/forum:viewdiscussion', $context)) {
             return '';
         }
         /// First work out whether we can post to this group and if so, include a link
         $groupmode = groups_get_activity_groupmode($cm);
         $currentgroup = groups_get_activity_group($cm, true);
         if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
             $text .= '<div class="newlink"><a href="' . $CFG->wwwroot . '/mod/forum/post.php?forum=' . $forum->id . '">' . get_string('addanewtopic', 'forum') . '</a>...</div>';
         }
         /// Get all the recent discussions we're allowed to see
         if (!($discussions = forum_get_discussions($cm, 'p.modified DESC', false, $currentgroup, $this->page->course->newsitems))) {
             $text .= '(' . get_string('nonews', 'forum') . ')';
             $this->content->text = $text;
             return $this->content;
         }
         /// Actually create the listing now
         $strftimerecent = get_string('strftimerecent');
         $strmore = get_string('more', 'forum');
         /// Accessibility: markup as a list.
         $text .= "\n<ul class='unlist'>\n";
         foreach ($discussions as $discussion) {
             $discussion->subject = $discussion->name;
             $discussion->subject = format_string($discussion->subject, true, $forum->course);
             $text .= '<li class="post">' . '<div class="head clearfix">' . '<div class="date">' . userdate($discussion->modified, $strftimerecent) . '</div>' . '<div class="name">' . fullname($discussion) . '</div></div>' . '<div class="info"><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $discussion->discussion . '">' . $discussion->subject . '</a></div>' . "</li>\n";
         }
         $text .= "</ul>\n";
         $this->content->text = $text;
         $this->content->footer = '<a href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '">' . get_string('oldertopics', 'forum') . '</a> ...';
         /// If RSS is activated at site and forum level and this forum has rss defined, show link
         if (isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds && $forum->rsstype && $forum->rssarticles) {
             require_once $CFG->dirroot . '/lib/rsslib.php';
             // We'll need this
             if ($forum->rsstype == 1) {
                 $tooltiptext = get_string('rsssubscriberssdiscussions', 'forum');
             } else {
                 $tooltiptext = get_string('rsssubscriberssposts', 'forum');
             }
             if (!isloggedin()) {
                 $userid = $CFG->siteguest;
             } else {
                 $userid = $USER->id;
             }
             $this->content->footer .= '<br />' . rss_get_link($context->id, $userid, 'mod_forum', $forum->id, $tooltiptext);
         }
     }
     return $this->content;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:77,代码来源:block_news_items.php


示例5: site_frontpage_news

    /**
     * Alternative rendering of front page news, called from layout/faux_site_index.php which
     * replaces the standard news output with this.
     *
     * @return string
     */
    public function site_frontpage_news()
    {
        global $CFG, $SITE;
        require_once $CFG->dirroot . '/mod/forum/lib.php';
        if (!($forum = forum_get_course_forum($SITE->id, 'news'))) {
            print_error('cannotfindorcreateforum', 'forum');
        }
        $cm = get_coursemodule_from_instance('forum', $forum->id, $SITE->id, false, MUST_EXIST);
        $context = \context_module::instance($cm->id, MUST_EXIST);
        $output = html_writer::start_tag('div', array('id' => 'site-news-forum', 'class' => 'clearfix'));
        $output .= $this->heading(format_string($forum->name, true, array('context' => $context)));
        $groupmode = groups_get_activity_groupmode($cm, $SITE);
        $currentgroup = groups_get_activity_group($cm);
        if (!($discussions = forum_get_discussions($cm, 'p.modified DESC', true, null, $SITE->newsitems, false, -1, $SITE->newsitems))) {
            $output .= html_writer::tag('div', '(' . get_string('nonews', 'forum') . ')', array('class' => 'forumnodiscuss'));
            if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
                $output .= html_writer::link(new moodle_url('/mod/forum/post.php', array('forum' => $forum->id)), get_string('addanewtopic', 'forum'), array('class' => 'btn btn-primary'));
            } else {
                // No news and user cannot edit, so return nothing.
                return '';
            }
            return $output . '</div>';
        }
        $output .= html_writer::start_div('', array('id' => 'news-articles'));
        foreach ($discussions as $discussion) {
            if (!forum_user_can_see_discussion($forum, $discussion, $context)) {
                continue;
            }
            $message = file_rewrite_pluginfile_urls($discussion->message, 'pluginfile.php', $context->id, 'mod_forum', 'post', $discussion->id);
            $imagestyle = '';
            $imgarr = \theme_snap\local::extract_first_image($message);
            if ($imgarr) {
                $imageurl = s($imgarr['src']);
                $imagestyle = " style=\"background-image:url('{$imageurl}')\"";
            }
            $name = format_string($discussion->name, true, array('context' => $context));
            $date = userdate($discussion->timemodified, get_string('strftimedatetime', 'langconfig'));
            $readmorebtn = "<a class='btn btn-default toggle' href='" . $CFG->wwwroot . "/mod/forum/discuss.php?d=" . $discussion->discussion . "'>" . get_string('readmore', 'theme_snap') . "</a>";
            $preview = '';
            $newsimage = '';
            if (!$imagestyle) {
                $preview = html_to_text($message, 0, false);
                $preview = "<div class='news-article-preview'><p>" . shorten_text($preview, 200) . "</p>\n                <p class='text-right'>" . $readmorebtn . "</p></div>";
            } else {
                $newsimage = '<div class="news-article-image toggle"' . $imagestyle . ' title="' . get_string('readmore', 'theme_snap') . '"></div>';
            }
            $close = get_string('close', 'theme_snap');
            $output .= <<<HTML
<div class="news-article clearfix">
    {$newsimage}
    <div class="news-article-inner">
        <div class="news-article-content">
            <h3 class='toggle'><a href="{$CFG->wwwroot}/mod/forum/discuss.php?d={$discussion->discussion}">{$name}</a></h3>
            <em class="news-article-date">{$date}</em>
        </div>
    </div>
    {$preview}
    <div class="news-article-message" tabindex="-1">
        {$message}
        <div><hr><a class="snap-action-icon toggle" href="#">
        <i class="icon icon-close"></i><small>{$close}</small></a></div>
    </div>
</div>
HTML;
        }
        $actionlinks = html_writer::link(new moodle_url('/mod/forum/view.php', array('id' => $cm->id)), get_string('morenews', 'theme_snap'), array('class' => 'btn btn-default'));
        if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
            $actionlinks .= html_writer::link(new moodle_url('/mod/forum/post.php', array('forum' => $forum->id)), get_string('addanewtopic', 'forum'), array('class' => 'btn btn-primary'));
        }
        $output .= html_writer::end_div();
        $output .= "<br><div class='text-center'>{$actionlinks}</div>";
        $output .= html_writer::end_tag('div');
        return $output;
    }
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:80,代码来源:core_renderer.php


示例6: test_forum_user_can_post_discussion

 /**
  * Test forum_user_can_post_discussion
  */
 public function test_forum_user_can_post_discussion()
 {
     global $CFG, $DB;
     $this->resetAfterTest(true);
     // Create course to add the module.
     $course = self::getDataGenerator()->create_course(array('groupmode' => SEPARATEGROUPS, 'groupmodeforce' => 1));
     $user = self::getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user->id, $course->id);
     // Forum forcing separate gropus.
     $record = new stdClass();
     $record->course = $course->id;
     $forum = self::getDataGenerator()->create_module('forum', $record, array('groupmode' => SEPARATEGROUPS));
     $cm = get_coursemodule_from_instance('forum', $forum->id);
     $context = context_module::instance($cm->id);
     self::setUser($user);
     // The user is not enroled in any group, try to post in a forum with separate groups.
     $can = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
     $this->assertFalse($can);
     // Create a group.
     $group = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
     // Try to post in a group the user is not enrolled.
     $can = forum_user_can_post_discussion($forum, $group->id, -1, $cm, $context);
     $this->assertFalse($can);
     // Add the user to a group.
     groups_add_member($group->id, $user->id);
     // Try to post in a group the user is not enrolled.
     $can = forum_user_can_post_discussion($forum, $group->id + 1, -1, $cm, $context);
     $this->assertFalse($can);
     // Now try to post in the user group. (null means it will guess the group).
     $can = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
     $this->assertTrue($can);
     $can = forum_user_can_post_discussion($forum, $group->id, -1, $cm, $context);
     $this->assertTrue($can);
     // Test all groups.
     $can = forum_user_can_post_discussion($forum, -1, -1, $cm, $context);
     $this->assertFalse($can);
     $this->setAdminUser();
     $can = forum_user_can_post_discussion($forum, -1, -1, $cm, $context);
     $this->assertTrue($can);
     // Change forum type.
     $forum->type = 'news';
     $DB->update_record('forum', $forum);
     // Admin can post news.
     $can = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
     $this->assertTrue($can);
     // Normal users don't.
     self::setUser($user);
     $can = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
     $this->assertFalse($can);
     // Change forum type.
     $forum->type = 'eachuser';
     $DB->update_record('forum', $forum);
     // I didn't post yet, so I should be able to post.
     $can = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
     $this->assertTrue($can);
     // Post now.
     $record = new stdClass();
     $record->course = $course->id;
     $record->userid = $user->id;
     $record->forum = $forum->id;
     $discussion = self::getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
     // I already posted, I shouldn't be able to post.
     $can = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
     $this->assertFalse($can);
     // Last check with no groups, normal forum and course.
     $course->groupmode = NOGROUPS;
     $course->groupmodeforce = 0;
     $DB->update_record('course', $course);
     $forum->type = 'general';
     $forum->groupmode = NOGROUPS;
     $DB->update_record('forum', $forum);
     $can = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
     $this->assertTrue($can);
 }
开发者ID:rushi963,项目名称:moodle,代码行数:77,代码来源:lib_test.php


示例7: 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 ($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.
             $groupdata[] = (object) array('id' => 0, 'name' => get_string('allparticipants'));
             $groupcount++;
         }
         $contextcheck = has_capability('mod/forum:movediscussions', $modulecontext) && empty($post->parent) && $groupcount > 1;
         if ($contextcheck) {
             foreach ($groupdata as $grouptemp) {
                 if (!forum_user_can_post_discussion($forum, $grouptemp->id, -1, $cm, $modcontext)) {
                     continue;
                 }
                 $groupinfo[$grouptemp->id] = $grouptemp->name;
             }
         }
         if (count($groupinfo) > 1) {
//.........这里部分代码省略.........
开发者ID:educacionbe,项目名称:cursos,代码行数:101,代码来源:post_form.php


示例8: can_add_discussion

 /**
  * Check if the current user can add discussions in the given forum (and optionally for the given group).
  *
  * @param int $forumid the forum instance id
  * @param int $groupid the group to check, default to active group. Use -1 to check if the user can post in all the groups.
  * @return array of warnings and the status (true if the user can add discussions)
  * @since Moodle 3.1
  * @throws moodle_exception
  */
 public static function can_add_discussion($forumid, $groupid = null)
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . "/mod/forum/lib.php";
     $params = self::validate_parameters(self::can_add_discussion_parameters(), array('forumid' => $forumid, 'groupid' => $groupid));
     $warnings = array();
     // Request and permission validation.
     $forum = $DB->get_record('forum', array('id' => $params['forumid']), '*', MUST_EXIST);
     list($course, $cm) = get_course_and_cm_from_instance($forum, 'forum');
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     $status = forum_user_can_post_discussion($forum, $params['groupid'], -1, $cm, $context);
     $result = array();
     $result['status'] = $status;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:26,代码来源:externallib.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: leaf_frontpage_carrousel

 public function leaf_frontpage_carrousel($device)
 {
     global $COURSE, $CFG;
     if (isloggedin() && !is_siteadmin() && $COURSE->id != 1) {
         return '';
     }
     if (!($this->page->bodyid == 'page-login-index' || $this->page->bodyid == 'page-my-index')) {
         return '';
     }
     require_once $CFG->dirroot . '/mod/forum/lib.php';
     // We'll need this
     $content = '';
     if (!($forum = forum_get_course_forum($COURSE->id, 'news'))) {
         return '';
     }
     $modinfo = get_fast_modinfo($COURSE);
     if (empty($modinfo->instances['forum'][$forum->id])) {
         return '';
     }
     $cm = $modinfo->instances['forum'][$forum->id];
     if (!$cm->uservisible) {
         return '';
     }
     $context = context_module::instance($cm->id);
     /// First work out whether we can post to this group and if so, include a link
     $groupmode = groups_get_activity_groupmode($cm);
     $currentgroup = groups_get_activity_group($cm, true);
     if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm)) {
         $link = '<li><a href="' . $CFG->wwwroot . '/mod/forum/post.php?forum=' . $forum->id . '">' . get_string('addsitenews', 'theme_leaf') . '</a></li>';
         return $link;
     }
     if (!($discussions = leaf_forum_get_discussions($cm, 'p.modified DESC', true, $currentgroup, $COURSE->newsitems))) {
         return '';
     }
     $strftimerecent = get_string('strftimerecent');
     $indicators = '';
     $carousel_items = '';
     $extra = 'active ';
     $count = 0;
     $prev = html_writer::link('#myCarousel' . $device, "&lsaquo;", array('class' => 'carousel-control left', 'data-slide' => 'prev'));
     $next = html_writer::link('#myCarousel' . $device, "&rsaquo;", array('class' => 'carousel-control right', 'data-slide' => 'next'));
     foreach ($discussions as $discussion) {
         $strmore = get_string('read_more', 'theme_leaf');
         if (isset($discussion->message)) {
             if (strlen(strip_tags($discussion->message)) > 400) {
                 $message = substr(strip_tags($discussion->message), 0, 400) . '..';
             } else {
                 $message = $discussion->message;
                 $strmore = '';
             }
         } else {
             $message = '';
         }
         $discussion->subject = format_string($discussion->subject, true, $forum->course);
         $carousel_items .= '<div class="' . $extra . 'item forumpost ">' . '<div class="head clearfix">' . '<div class="info"><h2>' . get_string('sitenews', 'theme_leaf') . '</h2></div>' . '<h3>' . $discussion->subject . '</h3>' . userdate($discussion->modified, $strftimerecent) . '
                      </div><br>' . '<div class="message">' . $message . ' </div>' . '<div class="readmore"><a href="' . $CFG->wwwroot . '/theme/leaf/layout/index.php?d=' . $discussion->discussion . '">' . $strmore . '</a></div>' . "</div>\n";
         $extra = '';
     }
     // Carrousel markup
     $content .= html_writer::start_tag('div', array('class' => 'sitenews' . $device));
     $content .= html_writer::start_tag('div', array('id' => 'myCarousel' . $device, 'class' => 'carousel slide'));
     $content .= html_writer::start_tag('div', array('class' => 'carousel-inner'));
     $content .= '<div class="newscontrols">' . $next . $prev . '</div>';
     $content .= $carousel_items;
     $content .= html_writer::end_tag('div');
     $content .= html_writer::end_tag('div');
     $content .= html_writer::end_tag('div');
     return $content;
 }
开发者ID:bmbrands,项目名称:moodle-theme_leaf,代码行数:69,代码来源:leaf_renderer.php


示例11: get_content

    function get_content() {
        global $CFG, $USER,$DB;

        if ($this->content !== NULL) {
            return $this->content;
        }

        $this->content = new stdClass;
        $this->content->text = '';
        $this->content->footer = '';

        if (empty($this->instance)) {
            return $this->content;
        }


        if ($this->page->course->newsitems) {   // Create a nice listing of recent postings

            require_once($CFG->dirroot.'/mod/forum/lib.php');   // We'll need this

            $text = '';

            if (!$forum = forum_get_course_forum($this->page->course->id, 'news')) {
                return '';
            }

            $modinfo = get_fast_modinfo($this->page->course);
            if (empty($modinfo->instances['forum'][$forum->id])) {
                return '';
            }
            $cm = $modinfo->instances['forum'][$forum->id];

            if (!$cm->uservisible) {
                return '';
            }

            $context = context_module::instance($cm->id);

        /// User must have perms to view discussions in that forum
            if (!has_capability('mod/forum:viewdiscussion', $context)) {
                return '';
            }

        /// First work out whether we can post to this group and if so, include a link
            $groupmode    = groups_get_activity_groupmode($cm);
            $currentgroup = groups_get_activity_group($cm, true);


            if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
                $text .= '<div class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
                          get_string('addanewtopic', 'forum').'</a></div>';
            }

        /// Get all the recent discussions we're allowed to see

            if (! $discussions = forum_get_discussions($cm, 'p.modified DESC', false,
                                                       $currentgroup, $this->page->course->newsitems) ) {
                $text .= '('.get_string('nonews', 'forum').')';
                $this->content->text = $text;
                return $this->content;
            }

        /// Actually create the listing now

            $strftimerecent = get_string('strftimerecent');
            $strmore = get_string('more', 'forum');

        /// Accessibility: markup as a list.
            $text .= "\n<ul class='unlist'>\n";
          
            foreach ($discussions as $discussion) {
                $discussion->subject = $discussion->name;

                $discussion->subject = format_string($discussion->subject, true, $forum->course);
                /******************code by sreekanth*****************/
                $subject1 = html_writer::tag('b',get_string('subject', 'block_site_blog'),array());
                $message = $DB->get_record_sql("SELECT * FROM {forum_posts} WHERE id = $discussion->id");
               
               
                //print_object($message);
                $text .= '<li class="post">'.
                         '<div class="head clearfix">'.
                         '<div class="date">'.userdate($discussion->modified, $strftimerecent).'</div>'.
                         '<div class="name">'.fullname($discussion).'</div></div>'.
                         '<div class="info">'.$subject1. ':  <a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$discussion->discussion.'">'.$discussion->subject.'</a></div>'.
                         "</li>\n";
                 $string1= $message->message;
                 
                 //$text .= $message->message;
                 $string = strip_tags($string1);
                if (strlen($string) > 480) {
                    // truncate string
                    $stringCut = substr($string, 0, 480);
                    //print_object($stringCut);
                    // make sure it ends in a word so assassinate doesn't become ass...
                    $view = html_writer::tag('a',get_string('view', 'block_my_blog'),array('href'=>$CFG->wwwroot.'/mod/forum/discuss.php?d='.$discussion->discussion));
                    $text .= "<div class='bulletin_message'>".substr($stringCut, 0, strrpos($stringCut, ' '))."...".$view."</div>";
                } else{
                    $text .= "<div class='bulletin_message'>". $message->message ."</div>";
                }
//.........这里部分代码省略.........
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:101,代码来源:block_news_items.php


示例12: get_content

 function get_content()
 {
     global $CFG, $USER, $COURSE;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     if ($COURSE->newsitems) {
         // Create a nice listing of recent postings
         require_once $CFG->dirroot . '/mod/forum/lib.php';
         // We'll need this
         if (!($forum = forum_get_course_forum($COURSE->id, 'news'))) {
             return '';
         }
         $modinfo = get_fast_modinfo($COURSE);
         if (empty($modinfo->instances['forum'][$forum->id])) {
             return '';
         }
         $cm = $modinfo->instances['forum'][$forum->id];
         $context = get_context_instance(CONTEXT_MODULE, $cm->id);
         /// First work out whether we can post to this group and if so, include a link
         $groupmode = groups_get_activity_groupmode($cm);
         $currentgroup = groups_get_activity_group($cm, true);
         /// Get all the recent discussions we're allowed to see
         if (!($discussions = forum_get_discussions($cm, 'p.modified DESC', false, $currentgroup, $COURSE->newsitems))) {
             $this->content->text = '(' . get_string('nonews', 'forum') . ')';
             // add a link to add "a new news item" (nadavkav)
             if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
                 $this->content->footer = '<div class="newlink"><a href="' . $CFG->wwwroot . '/mod/forum/post.php?forum=' . $forum->id . '">' . get_string('addanewitem', 'block_news_items_scrolling') . '</a>...</div>';
             }
             return $this->content;
         }
         // add scrolling effect <marquee> (nadavkav)
         $text = '<marquee width="100%" height="120" align="right" direction="up" scrolldelay="50" scrollamount="1" onmouseout="this.start();" style="padding-top: 2px;" onmouseover="this.stop();" dir="rtl">';
         /// Actually create the listing now
         $strftimerecent = get_string('strftimerecent');
         $strmore = get_string('more', 'block_news_items_scrolling');
         /// Accessibility: markup as a list.
         $text .= "\n<ul class='unlist'>\n";
         foreach ($discussions as $discussion) {
             $discussion->subject = $discussion->name;
             $discussion->subject = format_string($discussion->subject, true, $forum->course);
             //if (! $post = forum_get_post_full($discussion->discussion)) {
             //error("Could not find the first post in this forum");
             //}
             $post = get_record("forum_posts", "discussion", $discussion->discussion);
             $text .= '<li class="post">' . '<div class="head">' . '<div class="info">' . format_text($post->message) . ' ' . '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $discussion->discussion . '">' . $strmore . '...</a></div>' . "</li>\n";
         }
         $text .= "</ul>\n";
         $text .= '</marquee>';
         $this->content->text = $text;
         $this->content->footer = '<a href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '">' . get_string('olditems', 'block_news_items_scrolling') . '</a> ...';
         if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
             $this->content->footer = '<div class="newlink"><a href="' . $CFG->wwwroot . '/mod/forum/post.php?forum=' . $forum->id . '">' . get_string('addanewitem', 'block_news_items_scrolling') . '</a>...</div>';
         }
         /// If RSS is activated at site and forum level and this forum has rss defined, show link
         if (isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds && $forum->rsstype && $forum->rssarticles) {
             require_once $CFG->dirroot . '/lib/rsslib.php';
             // We'll need this
             if ($forum->rsstype == 1) {
                 $tooltiptext = get_string('rsssubscriberssdiscussions', 'forum', format_string($forum->name));
             } else {
                 $tooltiptext = get_string('rsssubscriberssposts', 'forum', format_string($forum->name));
             }
             if (empty($USER->id)) {
                 $userid = 0;
             } else {
                 $userid = $USER->id;
             }
             $this->content->footer .= '<br />' . rss_get_link($COURSE->id, $userid, 'forum', $forum->id, $tooltiptext);
         }
     }
     return $this->content;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:79,代码来源:block_news_items_scrolling.php


示例13: forum_print_latest_discussions

该文章已有0人参与评论

请发表评论

全部评论

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