Example #1
0
/**
 * Print the drop down that allows the user to select how they want to have
 * the discussion displayed.
 *
 * @param int $id forum id if $forumtype is 'single',
 *              discussion id for any other forum type
 * @param mixed $mode forum layout mode
 * @param string $forumtype optional
 */
function forum_print_mode_form($id, $mode, $forumtype='') {
    global $OUTPUT;
    if ($forumtype == 'single') {
        $select = new single_select(new moodle_url("/mod/forum/view.php", array('f'=>$id)), 'mode', forum_get_layout_modes(), $mode, null, "mode");
        $select->set_label(get_string('displaymode', 'forum'), array('class' => 'accesshide'));
        $select->class = "forummode";
    } else {
        $select = new single_select(new moodle_url("/mod/forum/discuss.php", array('d'=>$id)), 'mode', forum_get_layout_modes(), $mode, null, "mode");
        $select->set_label(get_string('displaymode', 'forum'), array('class' => 'accesshide'));
    }
    echo $OUTPUT->render($select);
}
Example #2
0
File: lib.php Project: r007/PMoodle
/**
 * Print the drop down that allows the user to select how they want to have
 * the discussion displayed.
 * @param $id - forum id if $forumtype is 'single',
 *              discussion id for any other forum type
 * @param $mode - forum layout mode
 * @param $forumtype - optional
 */
function forum_print_mode_form($id, $mode, $forumtype = '')
{
    if ($forumtype == 'single') {
        echo '<div class="forummode">';
        popup_form("view.php?f={$id}&amp;mode=", forum_get_layout_modes(), "mode", $mode, "");
        echo '</div>';
    } else {
        popup_form("discuss.php?d={$id}&amp;mode=", forum_get_layout_modes(), "mode", $mode, "");
    }
}
Example #3
0
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package   mod_forum
 * @copyright  2009 Petr Skoda (http://skodak.org)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    require_once $CFG->dirroot . '/mod/forum/lib.php';
    $settings->add(new admin_setting_configselect('forum_displaymode', get_string('displaymode', 'forum'), get_string('configdisplaymode', 'forum'), FORUM_MODE_NESTED, forum_get_layout_modes()));
    $settings->add(new admin_setting_configcheckbox('forum_replytouser', get_string('replytouser', 'forum'), get_string('configreplytouser', 'forum'), 1));
    // Less non-HTML characters than this is short
    $settings->add(new admin_setting_configtext('forum_shortpost', get_string('shortpost', 'forum'), get_string('configshortpost', 'forum'), 300, PARAM_INT));
    // More non-HTML characters than this is long
    $settings->add(new admin_setting_configtext('forum_longpost', get_string('longpost', 'forum'), get_string('configlongpost', 'forum'), 600, PARAM_INT));
    // Number of discussions on a page
    $settings->add(new admin_setting_configtext('forum_manydiscussions', get_string('manydiscussions', 'forum'), get_string('configmanydiscussions', 'forum'), 100, PARAM_INT));
    if (isset($CFG->maxbytes)) {
        $maxbytes = 0;
        if (isset($CFG->forum_maxbytes)) {
            $maxbytes = $CFG->forum_maxbytes;
        }
        $settings->add(new admin_setting_configselect('forum_maxbytes', get_string('maxattachmentsize', 'forum'), get_string('configmaxbytes', 'forum'), 512000, get_max_upload_sizes($CFG->maxbytes, 0, 0, $maxbytes)));
    }
    // Default number of attachments allowed per post in all forums
Example #4
0
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * @package mod-forum
 * @copyright  2009 Petr Skoda (http://skodak.org)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

defined('MOODLE_INTERNAL') || die;

if ($ADMIN->fulltree) {
    require_once($CFG->dirroot.'/mod/forum/lib.php');

    $settings->add(new admin_setting_configselect('forum_displaymode', get_string('displaymode', 'forum'),
                       get_string('configdisplaymode', 'forum'), FORUM_MODE_NESTED, forum_get_layout_modes()));

    $settings->add(new admin_setting_configcheckbox('forum_replytouser', get_string('replytouser', 'forum'),
                       get_string('configreplytouser', 'forum'), 1));

    // Less non-HTML characters than this is short
    $settings->add(new admin_setting_configtext('forum_shortpost', get_string('shortpost', 'forum'),
                       get_string('configshortpost', 'forum'), 300, PARAM_INT));

    // More non-HTML characters than this is long
    $settings->add(new admin_setting_configtext('forum_longpost', get_string('longpost', 'forum'),
                       get_string('configlongpost', 'forum'), 600, PARAM_INT));

    // Number of discussions on a page
    $settings->add(new admin_setting_configtext('forum_manydiscussions', get_string('manydiscussions', 'forum'),
                       get_string('configmanydiscussions', 'forum'), 100, PARAM_INT));
 /**
  * Makes the pop up contents for the grading interface
  *
  * @param array $params
  * @param $coursemodule
  * @global moodle_database $DB
  * @global $PAGE
  * @global stdClass $CFG
  * @global $SESSION
  * @global $USER
  * @global $OUTPUT
  * @params object $coursemodule
  * @return string HTML
  */
 public function grading_popup($params, $coursemodule)
 {
     global $DB, $PAGE, $CFG, $SESSION, $USER, $OUTPUT;
     $output = '';
     // Lifted from /mod/forum/discuss.php...
     /*
      $parent = $params['parent'];       // If set, then display this post and all children.
      $mode   = $params['mode'];         // If set, changes the layout of the thread
      $move   = $params['move'];         // If set, moves this discussion to another forum
      $mark   = $params['mark'];       // Used for tracking read posts if user initiated.
      $postid = $params['postid'];       // Used for tracking read posts if user initiated.
     */
     $discussion = $DB->get_record('forum_discussions', array('id' => $params['discussionid']), '*', MUST_EXIST);
     $course = $DB->get_record('course', array('id' => $discussion->course), '*', MUST_EXIST);
     $forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST);
     $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
     $modcontext = context_module::instance($cm->id);
     // Security - cmid is used to check context permissions earlier on, so it must match when
     // derived from the discussion.
     if (!($cm->id == $params['coursemoduleid'])) {
         print_error('Bad params!');
         return false;
     }
     // Add ajax-related libs.
     $PAGE->requires->yui2_lib('event');
     $PAGE->requires->yui2_lib('connection');
     $PAGE->requires->yui2_lib('json');
     // Move this down fix for MDL-6926.
     require_once $CFG->dirroot . '/mod/forum/lib.php';
     // Restrict news forums - should not be graded.
     if ($forum->type == 'news') {
         print_error('invaliddiscussionid', 'forum', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
     }
     unset($SESSION->fromdiscussion);
     // In case the user has used the drop-down to change from threaded to flat or something.
     if (isset($params['mode'])) {
         set_user_preference('forum_displaymode', $params['mode']);
     }
     $displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
     $parent = $discussion->firstpost;
     $post = forum_get_post_full($parent);
     if (!$post) {
         print_error("notexists", 'forum', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
     }
     if (!forum_user_can_view_post($post, $course, $cm, $forum, $discussion)) {
         print_error('nopermissiontoview', 'forum', "{$CFG->wwwroot}/mod/forum/view.php?id={$forum->id}");
     }
     // For now, restrict to rating only.
     $canreply = false;
     // Without this, the nesting doesn't work properly as the css isn't picked up.
     $output .= html_writer::start_tag('div', array('class' => 'path-mod-forum'));
     $output .= html_writer::start_tag('div', array('class' => 'discussioncontrols clearfix'));
     $output .= html_writer::start_tag('div', array('class' => 'discussioncontrol displaymode'));
     // We don't want to have the current mode returned in the url as well as the new one.
     unset($params['mode']);
     $newurl = new moodle_url('/blocks/ajax_marking/actions/grading_popup.php', $params);
     $select = new single_select($newurl, 'mode', forum_get_layout_modes(), $displaymode, null, "mode");
     $output .= $OUTPUT->render($select);
     $output .= html_writer::end_tag('div');
     // If user has not already posted and it's a Q & A forum...
     $forumisqanda = $forum->type == 'qanda';
     $noviewwithoutposting = !has_capability('mod/forum:viewqandawithoutposting', $modcontext);
     $hasnotposted = !forum_user_has_posted($forum->id, $discussion->id, $USER->id);
     if ($forumisqanda && $noviewwithoutposting && $hasnotposted) {
         $output .= $OUTPUT->notification(get_string('qandanotify', 'forum'));
     }
     $canrate = has_capability('mod/forum:rate', $modcontext);
     ob_start();
     forum_print_discussion($course, $cm, $forum, $discussion, $post, $displaymode, $canreply, $canrate);
     $output .= ob_get_contents();
     ob_end_clean();
     $output .= html_writer::end_tag('div');
     $output .= html_writer::end_tag('div');
     return $output;
 }
Example #6
0
/**
 * Print the drop down that allows the user to select how they want to have
 * the discussion displayed.
 *
 * @param int $id forum id if $forumtype is 'single',
 *              discussion id for any other forum type
 * @param mixed $mode forum layout mode
 * @param string $forumtype optional
 */
function forum_print_mode_form($id, $mode, $forumtype = '')
{
    global $OUTPUT;
    $select = html_select::make_popup_form("view.php?f={$id}", 'mode', forum_get_layout_modes(), "mode", $mode);
    $select->nothinglabel = false;
    if ($forumtype == 'single') {
        echo '<div class="forummode">';
        echo $OUTPUT->select($select);
        echo '</div>';
    } else {
        echo $OUTPUT->select($select);
    }
}