// Get convenience variables $discussion = $post->get_discussion(); $forum = $post->get_forum(); $course = $forum->get_course(); $cm = $forum->get_course_module(); // Do all access security checks $post->require_view(); if (!$post->can_view_history($whynot)) { print_error($whynot, 'forumng'); } // Work out navigation for header $pagename = get_string('historypage', 'forumng', $post->get_effective_subject(true)); $navigation = array(); $navigation[] = array('name' => shorten_text(htmlspecialchars($discussion->get_subject())), 'link' => $discussion->get_url(), 'type' => 'forumng'); $navigation[] = array('name' => $pagename, 'type' => 'forumng'); if (class_exists('ouflags') && ou_get_is_mobile()) { ou_mobile_configure_theme(); } $PAGEWILLCALLSKIPMAINDESTINATION = true; print_header_simple(format_string($forum->get_name()) . ': ' . $pagename, "", build_navigation($navigation, $cm), "", "", true, '', navmenu($course, $cm)); print skip_main_destination(); // Print current post print '<h2>' . get_string('currentpost', 'forumng') . '</h2>'; print $post->display(true, array(forum_post::OPTION_NO_COMMANDS => true, forum_post::OPTION_EXPANDED => true)); print '<h2>' . get_string('olderversions', 'forumng') . '</h2>'; $oldversions = $post->get_old_versions(); foreach ($oldversions as $oldpost) { print $oldpost->display(true, array(forum_post::OPTION_NO_COMMANDS => true, forum_post::OPTION_EXPANDED => true)); } // Display footer print_footer($course);
* View page. Displays wiki pages. * * @copyright © 2007 The Open University * @author s.marshall@open.ac.uk * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package ouwiki */ /** */ $countasview = true; require 'basicpage.php'; if (class_exists('ouflags')) { require_once '../../local/mobile/ou_lib.php'; global $OUMOBILESUPPORT; $OUMOBILESUPPORT = true; ou_set_is_mobile(ou_get_is_mobile_from_cookies()); if (ou_get_is_mobile()) { ou_mobile_configure_theme(); } } ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context); global $CFG; //cheeck consistency in setting Sub-wikis and group mode; $urllink = $CFG->wwwroot . '/course/view.php?id=' . $cm->course; if ($cm->groupmode == 0 && isset($subwiki->groupid)) { error("Sub-wikis is set to 'One wiki per group'. \n Please change Group mode to 'Separate groups' or 'Visible groups'.", $urllink); } if ($cm->groupmode > 0 && !isset($subwiki->groupid)) { error("Sub-wikis is NOT set to 'One wiki per group'. \n Please change Group mode to 'No groups'.", $urllink); } if (ajaxenabled() || class_exists('ouflags')) { // YUI and basic script
function definition() { global $CFG, $USER; $mform = $this->_form; $params = $this->_customdata['params']; $forum = $this->_customdata['forum']; $edit = $this->_customdata['edit']; $isdiscussion = $this->_customdata['isdiscussion']; $isroot = $this->_customdata['isroot']; $ispost = $this->_customdata['ispost']; $islock = $this->_customdata['islock']; $post = $this->_customdata['post']; $ajaxversion = $this->_customdata['ajaxversion']; $timelimit = isset($this->_customdata['timelimit']) ? $this->_customdata['timelimit'] : 0; $draft = isset($this->_customdata['draft']) ? $this->_customdata['draft'] : null; if (!$ajaxversion) { $ajaxversion = ''; } if ($ajaxversion && !array_key_exists('draft', $params)) { $params['draft'] = 0; } // Keeps track of whether we add a group selector box $groupselector = false; if ($ispost) { $mform->addElement('header', 'general' . $ajaxversion, ''); if ($edit && ($timelimit || $ajaxversion)) { // For AJAX version, add empty string, which will be // populated when retrieving each message. Otherwise, // display a 'slightly safer' version of the time limit. (30 // seconds will display as 1 minute before the real one usually; // I used 30 seconds becuase it makes more logical, if not // practical, sense compared to the option for a 1-minute timeout.) $mform->addElement('static', '', '', '<div id="id_editlimit' . $ajaxversion . '">' . ($timelimit ? get_string('editlimited', 'forumng', userdate($timelimit - 30, get_string('strftimetime', 'langconfig'))) : '') . '</div>'); } $quotaleft = $forum->get_remaining_post_quota(); if (!$edit && $quotaleft != forum::QUOTA_DOES_NOT_APPLY && ($quotaleft <= 2 || $ajaxversion)) { $a = (object) array('posts' => $quotaleft, 'period' => $forum->get_max_posts_period(true, true)); $text = ''; $script = ''; if ($ajaxversion) { $script = '<script type="text/javascript">forumng_quotaleft = ' . $quotaleft . '</script>'; } else { $text = $quotaleft <= 2 ? get_string($quotaleft == 1 ? 'quotaleft_singular' : 'quotaleft_plural', 'forumng', $a) : ''; } $mform->addElement('static', '', '', '<div id="id_postlimit' . $ajaxversion . '">' . $text . $script . '</div>'); } $mform->addElement('text', 'subject', $isroot ? get_string('subject', 'forumng') : get_string('optionalsubject', 'forumng'), array('size' => 48, 'id' => 'id_subject' . $ajaxversion)); $mform->setType('subject', PARAM_TEXT); $mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); if ($isroot) { $mform->addRule('subject', get_string('required'), 'required', null, 'client'); $mform->addRule('subject', get_string('required'), 'regex', '/\\S+/', 'client'); } if ($islock) { $mform->setDefault('subject', get_string('locksubject', 'forumng')); } // Special field just to tell javascript that we're trying to use the // html editor $mform->addElement('hidden', 'tryinghtmleditor', can_use_html_editor() ? 1 : 0); if (class_exists('ouflags')) { $message_type = 'htmleditor'; $message_rows = 30; if (ou_get_is_mobile()) { $message_type = 'textarea'; $message_rows = 20; } $mform->addElement($message_type, 'message', get_string('message', 'forumng'), array('cols' => 50, 'rows' => $ajaxversion ? 15 : $message_rows), array('id' => 'id_message' . $ajaxversion)); } else { $mform->addElement('htmleditor', 'message', get_string('message', 'forumng'), array('cols' => 50, 'rows' => $ajaxversion ? 15 : 30), array('id' => 'id_message' . $ajaxversion)); } $mform->setType('message', PARAM_RAW); $mform->addRule('message', get_string('required'), 'required', null, 'client'); $mform->setHelpButton('message', array('reading', 'writing', 'questions', 'richtext'), false, 'editorhelpbutton'); $showformat = true; if ($showformat) { $mform->addElement('format', 'format', get_string('format'), array('id' => 'id_format' . $ajaxversion)); } // If you can create attachments... if ($forum->can_create_attachments()) { $mform->addElement('header', 'id_attachments' . $ajaxversion, ''); $attachmentlist = ''; $attachmentnames = array(); if ($edit && $post) { $attachmentnames = $post->get_attachment_names(); } else { if ($draft) { $attachmentnames = $draft->get_attachment_names(); } } $filenum = 0; foreach ($attachmentnames as $name) { $id = 'id_deletefile' . $ajaxversion . '_' . $filenum++; $attachmentlist .= '<li>' . htmlspecialchars($name) . ' ' . '<span class="forumng-deletefilecheck">' . '<input type="checkbox" name="deletefile[]" value="' . htmlspecialchars($name) . '" id="' . $id . '" /> <label for="' . $id . '">' . get_string('delete') . '</label></span></li>'; } if (!$ajaxversion) { // ...the non-AJAX version shows boxes for three new ones // and a 'Delete existing' checkbox with the existing info if ($edit || $draft) { if ($attachmentlist) { $mform->addElement('static', '', get_string('existingattachments', 'forumng'), '<ul class="forumng-form-attachments">' . $attachmentlist . '</ul>'); } } $this->set_upload_manager($forum->get_upload_manager()); for ($k = 0; $k < 3; $k++) { $mform->addElement('file', 'attachment_' . $k, get_string('attachmentnum', 'forumng', $k + 1), array('id' => 'id_attachment' . $ajaxversion . '_' . $k)); if (!$k) { $mform->setHelpButton('attachment_' . $k, array('attachment', get_string('attachment', 'forumng'), 'forumng')); } } } else { // ...the AJAX version includes a magic AJAX attachments // component // Create a playspace for editing attachments. (Note that // this logic would NOT work in a normal form which can // be submitted more than once.) if (!$attachmentlist) { $attachmentlist = '<li class="forumng-deleteme"></li>'; } $mform->addElement('static', '', '<span class="forumng-attachments-label">' . get_string('attachments', 'forumng') . '</span>', '<ul class="forumng-form-attachments">' . $attachmentlist . '</ul>'); $mform->addElement('hidden', 'attachmentplayspace', 0); $mform->setType('attachmentplayspace', PARAM_SEQUENCE); } } // If you can mail now, we show this option $mform->addElement('header', 'id_importance' . $ajaxversion, ''); $attachmentlist = ''; if (!$edit && $forum->can_mail_now()) { $mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forumng')); $mform->setHelpButton('mailnow', array('mailnow', get_string('mailnow', 'forumng'), 'forumng')); } if ($forum->can_set_important() && !$isdiscussion && !$isroot && !$islock) { $mform->addElement('checkbox', 'setimportant', get_string('setimportant', 'forumng')); } } // Additional options apply only to discussion if ($isdiscussion && $forum->can_manage_discussions()) { // Restrict to specific time period $mform->addElement('header', 'id_displayperiod', get_string('displayperiod', 'forumng')); $mform->addElement('date_selector', 'timestart', get_string('timestart', 'forumng'), array('optional' => true)); $mform->setHelpButton('timestart', array('displayperiod', get_string('displayperiod', 'forumng'), 'forumng')); $mform->addElement('date_selector', 'timeend', get_string('timeend', 'forumng'), array('optional' => true)); // Discussion options... $mform->addElement('header', 'id_stickyoptions', get_string('discussionoptions', 'forumng')); // Sticky discussion $options = array(); $options[0] = get_string('sticky_no', 'forumng'); $options[1] = get_string('sticky_yes', 'forumng'); $mform->addElement('select', 'sticky', get_string('sticky', 'forumng'), $options); $mform->setHelpButton('sticky', array('sticky', get_string('sticky', 'forumng'), 'forumng')); // Group if ($forum->get_group_mode()) { // Group ID comes from the post (if provided) or the params if ($post) { $groupid = $post->get_discussion()->get_group_id(); } else { $groupid = $params['group']; } // Display as static or dropdown if (has_capability('moodle/site:accessallgroups', $forum->get_context())) { // Users with 'access all groups' can move discussions, so // show dropdown with all groups $cm = $forum->get_course_module(); $groups = groups_get_all_groups($cm->course, has_capability('moodle/site:accessallgroups', $forum->get_context()) ? 0 : $USER->id, $cm->groupingid); $options = array(); $options[forum::ALL_GROUPS] = get_string('allparticipants'); foreach ($groups as $group) { $options[$group->id] = format_string($group->name); } $mform->addElement('select', 'group', get_string('group'), $options); $mform->setDefault('group', $groupid); $groupselector = true; } else { // Users without 'access all groups' only see the current // group of the discussion if ($groupid == forum::ALL_GROUPS) { $groupname = get_string('allparticipants'); } else { $group = groups_get_group($groupid); $groupname = format_string($group->name); } $mform->addElement('static', 'groupinfo', get_string('group'), $groupname); } } // Note: Lock/unlock is not available here. When locking a // discussion you are prompted to give a reason (=new post). // This is available from the discussion page. Unlocking is // available from a link in the special 'discussion is locked' // message that appears at the top of the discussion page. } // Post / save changes button if ($edit) { $submitlabel = get_string('savechanges'); } else { if ($islock) { $submitlabel = get_string('lockdiscussionbutton', 'forumng'); } else { if ($isdiscussion) { $submitlabel = get_string('postdiscussion', 'forumng'); } else { $submitlabel = get_string('postreply', 'forumng'); } } } $buttonarray = array(); $buttonarray[] =& $mform->createElement('submit', 'submitbutton', $submitlabel, array('id' => 'id_submitbutton' . $ajaxversion)); $buttonarray[] =& $mform->createElement('cancel', '', '', array('id' => 'id_cancel' . $ajaxversion)); if (!$edit) { // Can't save draft while editing $buttonarray[] =& $mform->createElement('submit', 'savedraft', get_string('savedraft', 'forumng'), array('id' => 'id_savedraft' . $ajaxversion)); } $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); // Hidden fields foreach ($params as $param => $value) { // If there's a group selector, don't duplicate the group param if ($param == 'group' && $groupselector) { continue; } $mform->addElement('hidden', $param, $value); } if (!$ajaxversion) { // Prevent multiple submits (except of AJAX version) $mform->addElement('hidden', 'random', rand()); } }
function definition() { global $CFG; $maxvisibility = $this->_customdata['maxvisibility']; $edit = $this->_customdata['edit']; $commentid = $this->_customdata['commentid']; $moderated = $this->_customdata['moderated']; $confirmed = $this->_customdata['confirmed']; $blogid = $this->_customdata['blogid']; $postid = $this->_customdata['postid']; $mform =& $this->_form; // Get comment content, if editing existing comment $comment = get_record('oublog_comments', 'id', $commentid); $mform->addElement('header', 'general', ''); if ($moderated) { $mform->addElement('static', '', '', get_string('moderated_info', 'oublog', $CFG->wwwroot . '/mod/oublog/bloglogin.php?returnurl=editcomment.php?blog=' . $blogid . '%26post=' . $postid)); $mform->addElement('text', 'authorname', get_string('moderated_authorname', 'oublog'), 'size="48"'); $mform->setType('authorname', PARAM_TEXT); $mform->addRule('authorname', get_string('required'), 'required', null, 'client'); if ($edit) { $mform->setDefault('authorname', $comment->authorname); } } $mform->addElement('text', 'title', get_string('title', 'oublog'), 'size="48"'); $mform->setType('title', PARAM_TEXT); if ($edit) { $mform->setDefault('title', $comment->title); } $message_type = 'htmleditor'; if ($moderated) { $message_type = 'textarea'; } $message_rows = 30; if (class_exists('ouflags') && ou_get_is_mobile()) { $message_type = 'textarea'; $message_rows = 20; } $mform->addElement($message_type, 'message', get_string('message', 'oublog'), array('cols' => 50, 'rows' => $message_rows)); if ($edit) { $mform->setDefault('message', $comment->message); } $mform->setType('message', PARAM_CLEANHTML); $mform->addRule('message', get_string('required'), 'required', null, 'client'); $mform->setHelpButton('message', array('reading', 'writing', 'questions', 'richtext'), false, 'editorhelpbutton'); // When using moderation, we include the world's dumbest capcha (the // user is told to type 'yes' into the box). Because there is moderation // we do not really need a capcha; this is only meant to exclude the // stupidest spam robots and reduce the quantity of email sent to // moderators. A cookie can skip this step. if ($moderated && !$confirmed) { $mform->addElement('static', '', '', get_string('moderated_confirminfo', 'oublog')); $mform->addElement('text', 'confirm', get_string('moderated_confirm', 'oublog')); } if ($edit) { $submitstring = get_string('savechanges'); } else { $submitstring = get_string('addcomment', 'oublog'); } $this->add_action_buttons(true, $submitstring); /// Hidden form vars $mform->addElement('hidden', 'blog'); $mform->setType('blog', PARAM_INT); $mform->addElement('hidden', 'post'); $mform->setType('post', PARAM_INT); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); if ($edit) { $mform->setDefault('id', $comment->id); } }
/** * Displays a short version (suitable for including in discussion list) * of this discussion including a link to view the discussion and to * mark it read (if enabled). * @param forum_discussion $discussion Discussion * @param int $groupid Group ID for display; may be NO_GROUPS or ALL_GROUPS * @param bool $last True if this is the last item in the list * @return string HTML code to print out for this discussion */ public function display_discussion_list_item($discussion, $groupid, $last) { global $CFG; $showgroups = $groupid == forum::ALL_GROUPS; // Work out CSS classes to use for discussion $classes = ''; $alts = array(); $icons = array(); if ($discussion->is_deleted()) { $classes .= ' forumng-deleted'; $alts[] = get_string('alt_discussion_deleted', 'forumng'); $icons[] = ''; // No icon, text will be output on its own } if (!$discussion->is_within_time_period()) { $classes .= ' forumng-timeout'; $icon = 'timeout'; $alts[] = get_string('alt_discussion_timeout', 'forumng'); $icons[] = $CFG->modpixpath . '/forumng/timeout.png'; } if ($discussion->is_sticky()) { $classes .= ' forumng-sticky'; $alts[] = get_string('alt_discussion_sticky', 'forumng'); $icons[] = $CFG->modpixpath . '/forumng/sticky.png'; } if ($discussion->is_locked()) { $classes .= ' forumng-locked'; $alts[] = get_string('alt_discussion_locked', 'forumng'); $icons[] = $CFG->pixpath . '/i/unlock.gif'; } // Classes for Moodle table styles static $rownum = 0; $classes .= ' r' . $rownum; $rownum = 1 - $rownum; if ($last) { $classes .= ' lastrow'; } $courseid = $discussion->get_forum()->get_course_id(); // Start row $result = "<tr class='forumng-discussion-short{$classes}'>"; // Subject, with icons $result .= "<td class='forumng-subject cell c0'>"; foreach ($icons as $index => $icon) { $alt = $alts[$index]; if ($icon) { $result .= "<img src='{$icon}' alt='{$alt}' title='{$alt}' /> "; } else { $result .= "<span class='accesshide'>{$alt}:</span> "; } } $result .= "<a href='discuss.php?" . $discussion->get_link_params(forum::PARAM_HTML) . "'>" . format_string($discussion->get_subject(), true, $courseid) . "</a></td>"; // Author $poster = $discussion->get_poster(); $result .= "<td class='forumng-startedby cell c1'>" . print_user_picture($poster, $courseid, null, 0, true) . $discussion->get_forum()->display_user_link($poster) . "</td>"; $num = 2; // Group if ($showgroups) { $result .= '<td class="cell c' . $num . '">' . $discussion->get_group_name() . '</td>'; $num++; } // Number of posts $result .= '<td class="cell c' . $num . '">' . $discussion->get_num_posts(); if (!class_exists('ouflags') || !ou_get_is_mobile()) { $result .= '</td>'; } $num++; // Number of unread posts if ($discussion->get_forum()->can_mark_read()) { $unreadposts = $discussion->get_num_unread_posts(); if (!class_exists('ouflags') || !ou_get_is_mobile()) { $result .= '<td class="cell forumng-unreadcount c3">'; } else { $result .= ' ('; } if ($unreadposts) { $result .= '<a href="discuss.php?' . $discussion->get_link_params(forum::PARAM_HTML) . '#firstunread">' . $unreadposts . '</a>' . '<form method="post" action="markread.php"><div> ' . $discussion->get_link_params(forum::PARAM_FORM) . '<input type="hidden" name="back" value="view" />' . '<input type="image" title="' . get_string('markdiscussionread', 'forumng') . '" src="' . $CFG->pixpath . '/t/clear.gif" ' . 'class="iconsmall" alt="' . get_string('markdiscussionread', 'forumng') . '" /></div></form>'; } else { $result .= $unreadposts; } if (class_exists('ouflags') && ou_get_is_mobile()) { $result .= ')'; } $result .= '</td>'; $num = 4; } // Last post $last = $discussion->get_last_post_user(); $result .= '<td class="cell c' . $num . ' lastcol forumng-lastpost">' . forum_utils::display_date($discussion->get_time_modified()) . "<br/>" . "<a href='{$CFG->wwwroot}/user/view.php?id={$last->id}&" . "course={$courseid}'>" . fullname($last, has_capability('moodle/site:viewfullnames', $discussion->get_forum()->get_context())) . "</a></td>"; $result .= "</tr>"; return $result; }
function ouwiki_print_tabs($selected, $pagename, $subwiki, $cm, $context, $pageexists = true, $pagelocked = false) { global $CFG; $tabrow = array(); if (class_exists('ouflags')) { // OpenLearn insitu editing // Now we have to check if we are in an insitu edited course and display // the extra tabs for versions and the main mod settings (tidyer this way) // means you don't need to go back to the course homepage to edit the other // mod settings if (has_capability('local/course:revisioneditor', get_context_instance(CONTEXT_COURSE, $cm->course), null, false)) { if (!empty($revisionedit)) { // We don't need a URL as the current tab is always empty, and this tab // will only display while you are viewing a revision $tabrow[] = new tabobject('viewrevision', '', 'View Revision'); $current_tab = 'viewrevision'; } $tabrow[] = new tabobject('edit_settings', $CFG->wwwroot . '/course/modedit.php?update=' . $cm->id . '&return=1', 'Edit Settings'); $tabrow[] = new tabobject('revisions', $CFG->wwwroot . '/local/insitu/activity_revisions.php?id=' . $cm->id, get_string('revisions', 'course')); } } $params = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm); $tabrow[] = new tabobject('view', 'view.php?' . $params, get_string('tab_view', 'ouwiki')); if ($subwiki->canedit && !$pagelocked) { $tabrow[] = new tabobject('edit', 'edit.php?' . $params, get_string('tab_edit', 'ouwiki')); } if (ouwiki_get_commenting($subwiki->commenting) == OUWIKI_COMMENTS_ANNOTATION || ouwiki_get_commenting($subwiki->commenting) == OUWIKI_COMMENTS_BOTH) { if ($subwiki->canannotate) { $tabrow[] = new tabobject('annotate', 'annotate.php?' . $params, get_string('tab_annotate', 'ouwiki')); } } if (!class_exists('ouflags') && $pageexists || class_exists('ouflags') && !ou_get_is_mobile() && $pageexists) { $tabrow[] = new tabobject('history', 'history.php?' . $params, get_string('tab_history', 'ouwiki')); } $tabs = array(); $tabs[] = $tabrow; print_tabs($tabs, $selected, $pageexists ? '' : array('edit', 'annotate')); print '<div id="ouwiki_belowtabs">'; }