public function display($discussion)
 {
     // Obtain list of other forums in this course where the user has the
     // 'move discussion' feature
     $course = $discussion->get_forum()->get_course();
     $modinfo = get_fast_modinfo($course);
     $results = array();
     foreach ($modinfo->instances['forumng'] as $other) {
         // Don't let user move discussion to its current forum
         if ($other->instance == $discussion->get_forum()->get_id() || $other->id == $discussion->get_forum()->get_course_module_id()) {
             continue;
         }
         $othercontext = context_module::instance($other->id);
         if (has_capability('mod/forumng:movediscussions', $othercontext)) {
             $results[$other->id] = $other->name;
         }
     }
     if (count($results) == 0) {
         return '';
     }
     // Make list alphabetical
     uasort($results, array('forumngfeature_move', 'sort_ignore_case'));
     // Build select using the list
     $out = mod_forumng_utils::get_renderer();
     $select = html_writer::select($results, 'target', '', array('' => get_string('movethisdiscussionto', 'forumngfeature_move')));
     return '<form method="post" action="feature/move/move.php"><div>' . $discussion->get_link_params(mod_forumng::PARAM_FORM) . $select . '<input class="forumng-zero-disable" ' . 'type="submit" value="' . get_string('move') . '" /></div></form>';
 }
예제 #2
0
 public function apply($discussion, $all, $selected, $formdata)
 {
     global $COURSE, $USER, $CFG, $PAGE;
     $d = $discussion->get_id();
     $forum = $discussion->get_forum();
     $PAGE->set_pagelayout('embedded');
     $out = mod_forumng_utils::get_renderer();
     print $out->header();
     $backlink = new moodle_url('/mod/forumng/discuss.php', $discussion->get_link_params_array());
     print html_writer::start_tag('div', array('class' => 'forumng-printable-header'));
     print html_writer::tag('div', link_arrow_left($discussion->get_subject(), $backlink), array('class' => 'forumng-printable-backlink'));
     print html_writer::tag('div', get_string('printedat', 'forumngfeature_print', userdate(time())), array('class' => 'forumng-printable-date'));
     print html_writer::tag('div', '', array('class' => 'clearer'));
     print "\n";
     print $out->box(get_string('back', 'forumngfeature_print', $backlink->out()), 'generalbox forumng-donotprint');
     print html_writer::start_tag('div', array('class' => 'forumng-showprintable'));
     if ($all) {
         print $out->render_discussion($discussion, array(mod_forumng_post::OPTION_NO_COMMANDS => true, mod_forumng_post::OPTION_CHILDREN_EXPANDED => true, mod_forumng_post::OPTION_PRINTABLE_VERSION => true));
     } else {
         $allhtml = '';
         $alltext = '';
         $discussion->build_selected_posts_email($selected, $alltext, $allhtml, array(mod_forumng_post::OPTION_PRINTABLE_VERSION));
         print $allhtml;
     }
     print html_writer::end_tag('div');
     $forum->print_js(0, false);
     print $out->footer();
 }
 public function display($forum)
 {
     $out = mod_forumng_utils::get_renderer();
     // Work out current status
     $manualmark = !mod_forumng::mark_read_automatically();
     $current = get_string($manualmark ? 'manualmark_manual' : 'manualmark_auto', 'forumngfeature_manualmark');
     // Make a help button
     $change = get_string('manualmark_change', 'forumngfeature_manualmark');
     $helpbutton = $out->help_icon('manualmark_change', 'forumngfeature_manualmark');
     // Get the button form
     $params = $forum->get_link_params_array();
     return parent::get_button($forum, $change, 'feature/manualmark/change.php', true, $params, $helpbutton, 'forumng-manualmark', $current . '&nbsp;', 'forumng-button-to-link');
 }
예제 #4
0
/**
 * Library for Atom feeds, sort of like the system RSS library. (Originally
 * by Matt Clarkson from Catalyst.)
 * @package mod
 * @subpackage forumng
 * @copyright 2011 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function atom_standard_header($uniqueid, $link, $updated, $title = NULL, $description = NULL)
{
    global $CFG, $USER;
    $status = true;
    $result = "";
    if (!($site = get_site())) {
        $status = false;
    }
    if ($status) {
        //Calculate title, link and description
        if (empty($title)) {
            $title = format_string($site->fullname);
        }
        //xml headers
        $result .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
        $result .= "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n";
        //open the channel
        //write channel info
        $result .= atom_full_tag('id', 1, false, htmlspecialchars($uniqueid));
        $result .= atom_full_tag('updated', 1, false, date_format_rfc3339($updated));
        $result .= atom_full_tag('title', 1, false, htmlspecialchars(html_to_text($title)));
        $result .= atom_full_tag('link', 1, false, null, array('href' => $link, 'rel' => 'self'));
        if (!empty($description)) {
            $result .= atom_full_tag('subtitle', 1, false, $description);
        }
        $result .= atom_full_tag('generator', 1, false, 'Moodle');
        $today = getdate();
        $result .= atom_full_tag('rights', 1, false, '&#169; ' . $today['year'] . ' ' . format_string($site->fullname));
        //write image info
        $out = mod_forumng_utils::get_renderer();
        $atompix = $out->pix_url('/i/rsssitelogo');
        //write the info
        $result .= atom_full_tag('logo', 1, false, $atompix);
    }
    if (!$status) {
        return false;
    } else {
        return $result;
    }
}
 public function display($discussion)
 {
     require_once dirname(__FILE__) . '/lib.php';
     if (is_a($discussion, 'mod_forumng_discussion')) {
         // Obtain list of other forums in this course where the user has the
         // 'move discussion' feature.
         $course = $discussion->get_forum()->get_course();
         $modinfo = get_fast_modinfo($course);
         $results = array();
         foreach ($modinfo->instances['forumng'] as $other) {
             // Don't let user move discussion to its current forum.
             if ($other->instance == $discussion->get_forum()->get_id() || $other->id == $discussion->get_forum()->get_course_module_id()) {
                 continue;
             }
             $othercontext = context_module::instance($other->id);
             if (has_capability('mod/forumng:movediscussions', $othercontext)) {
                 $results[$other->id] = $other->name;
             }
         }
         if (count($results) == 0) {
             return '';
         }
         // Make list alphabetical.
         uasort($results, 'sort_ignore_case');
         // Build select using the list.
         $out = mod_forumng_utils::get_renderer();
         $select = html_writer::select($results, 'target', '', array('' => get_string('movethisdiscussionto', 'forumngfeature_move')));
         return '<form method="post" action="feature/move/move.php"><div>' . $discussion->get_link_params(mod_forumng::PARAM_FORM) . $select . '<input class="forumng-zero-disable" ' . 'type="submit" value="' . get_string('move') . '" /></div></form>';
     } else {
         // Display button.
         $params['exclude'] = 'forumng-deleted';
         $excludedget = array_merge($params, $_GET);
         if (is_a($discussion, 'mod_forumng')) {
             return forumngfeature_discussion_list::get_button($discussion, get_string('move', 'forumngfeature_move'), 'feature/move/moveall.php', false, $excludedget, '', 'forumng-dselectorbutton', '', '');
         }
     }
 }
$inputdata = new stdClass();
$inputdata->query = $query;
$inputdata->author = $author;
$editform->set_data($inputdata);
if ($editform->is_cancelled()) {
    if (isset($forum)) {
        $returnurl = $forum->get_url(mod_forumng::PARAM_PLAIN);
    } else {
        $returnurl = $CFG->wwwroot . '/course/view.php?id=' . $course->id;
    }
    redirect($returnurl, '', 0);
}
// Process form data.
$data = $editform->get_data();
// Display header
$out = mod_forumng_utils::get_renderer();
print $out->header();
$searchtitle = forumng_get_search_results_title($query, $data ? $data->author : '', $data ? $data->datefrom : 0, $data ? $data->dateto : 0);
if (!$allforums) {
    // Display group selector if required
    groups_print_activity_menu($cm, $url);
    $groupid = mod_forumng::get_activity_group($cm, true);
    $forum->require_view($groupid, 0, true);
    print '<br/><br/>';
}
$editform->display();
if ($data) {
    // Searching for free text with or without filtering author and date range.
    if ($query) {
        $result = new local_ousearch_search($query);
        if ($allforums) {
 /**
  * @return string HTML links for RSS/Atom feeds to this discussion (if
  *   enabled etc)
  */
 public function display_feed_links()
 {
     // Check they're allowed to see it
     if ($this->get_forum()->get_effective_feed_option() != mod_forumng::FEEDTYPE_ALL_POSTS) {
         return '';
     }
     $out = mod_forumng_utils::get_renderer();
     return $out->render_feed_links($this->get_feed_url(mod_forumng::FEEDFORMAT_ATOM), $this->get_feed_url(mod_forumng::FEEDFORMAT_RSS));
 }
 /**
  * Displays the discussion page.
  * @param mod_forumng_discussion $discussion Discussion
  */
 public function print_discussion_page($discussion)
 {
     global $PAGE;
     $out = mod_forumng_utils::get_renderer();
     $previousread = (int) $discussion->get_time_read();
     // 'Read date' option (used when viewing all posts so that they keep
     // their read/unread colouring)
     $timeread = optional_param('timeread', 0, PARAM_INT);
     if ($timeread) {
         $discussion->pretend_time_read($timeread);
         $previousread = $timeread;
     }
     // 'Expand all' option (always chosen for non-JS browsers)
     $expandall = optional_param('expand', 0, PARAM_INT) || $PAGE->devicetypeinuse == 'legacy';
     // 'Expand all' option (always chosen for non-JS browsers)
     $collapseall = optional_param('collapse', 0, PARAM_INT);
     if (!$collapseall && !$expandall && $PAGE->devicetypeinuse == 'mobile') {
         $collapseall = 1;
     }
     // Link back to first unread post if there is one
     print $discussion->display_unread_skip_link();
     // Magic expand tracker (for use in JS only, never set server-side).
     // This tracks expanded posts, and makes the Back button 'work' in
     // the sense that it will expand these posts again.
     print '<form method="post" action="."><div>' . '<input type="hidden" id="expanded_posts" name="expanded_posts" ' . 'value="" /></div></form>';
     // Get content for all posts in the discussion
     $options = array();
     if ($expandall) {
         $options[mod_forumng_post::OPTION_CHILDREN_EXPANDED] = true;
     }
     if ($collapseall) {
         $options[mod_forumng_post::OPTION_CHILDREN_COLLAPSED] = true;
     }
     $content = $out->render_discussion($discussion, $options);
     // Some post display options use the read time to construct links
     // (usually for non-JS version) so that unread state is maintained.
     $options[mod_forumng_post::OPTION_READ_TIME] = $previousread;
     // Display expand all option if there are any 'Expand' links in content
     $fakedate = '&amp;timeread=' . $previousread;
     print '<div id="forumng-expandall">';
     $showexpandall = preg_match('~<a [^>]*href="discuss\\.php\\?d=[0-9]+[^"]*&amp;expand=1#p[0-9]+">~', $content);
     // Note: On bad browsers we always expand all posts
     $showcollapseall = preg_match('~<div class="forumng-post forumng-full.*<div class="forumng-post forumng-full~s', $content) && $PAGE->devicetypeinuse != 'legacy';
     if ($showexpandall) {
         print '<a class="forumng-expandall-link" href="' . $discussion->get_url(mod_forumng::PARAM_HTML) . '&amp;expand=1' . $fakedate . '">' . get_string('expandall', 'forumng') . '</a>';
         if ($showcollapseall) {
             print '<span class="forumng-dot-separator"> &#x2022; </span>';
         }
     }
     if ($showcollapseall) {
         print '<a class="forumng-collapseall-link" href="' . $discussion->get_url(mod_forumng::PARAM_HTML) . '&amp;collapse=1' . $fakedate . '">' . get_string('collapseall', 'forumng') . '</a> ';
     }
     print '</div>';
     // Display content
     print $content;
     // Link back to forum
     print $discussion->display_link_back_to_forum();
     // Display discussion features (row of buttons)
     print $discussion->display_forumngfeature_discussions();
     // Display the subscription options to this disucssion if available
     print $discussion->display_subscribe_options();
     // Atom/RSS links
     print $discussion->display_feed_links();
     // Set read data [shouldn't this logic be somewhere else as it is not
     // part of display?]
     if (mod_forumng::mark_read_automatically()) {
         $discussion->mark_read();
     }
 }
예제 #9
0
 /**
  * Prints out (immediately; must be after header) script tags and JS code
  * for the forum's JavaScript library, and required YUI libraries.
  * @param int $cmid If specified, passes this through to JS
  */
 public function print_js($cmid = 0)
 {
     global $CFG, $PAGE;
     $simple = get_user_preferences('forumng_simplemode', '');
     if ($PAGE->devicetypeinuse == 'legacy' || $simple) {
         return;
     }
     // Prepare strings
     $mainstrings = array('rate' => null, 'expand' => '#', 'jserr_load' => null, 'jserr_save' => null, 'jserr_alter' => null, 'jserr_attachments' => null, 'confirmdelete' => null, 'confirmundelete' => null, 'confirmdeletediscuss' => null, 'deleteemailpostbutton' => null, 'deletepostbutton' => null, 'undeletepostbutton' => null, 'js_nratings' => null, 'js_nratings1' => null, 'js_nopublicrating' => null, 'js_publicrating' => null, 'js_nouserrating' => null, 'js_userrating' => null, 'js_outof' => null, 'js_clicktosetrating' => null, 'js_clicktosetrating1' => null, 'js_clicktoclearrating' => null, 'selectlabel' => null, 'selectintro' => null, 'confirmselection' => null, 'selectedposts' => null, 'discussion' => null, 'selectorall' => null, 'selectoralldisc' => null, 'selectorselecteddisc' => null, 'selectordiscall' => null, 'selectdiscintro' => null, 'flagon' => null, 'flagoff' => null, 'clearflag' => null, 'setflag' => null, 'flagpost' => null);
     if ($this->has_post_quota()) {
         $mainstrings['quotaleft_plural'] = (object) array('posts' => '#', 'period' => $this->get_max_posts_period(true, true));
         $mainstrings['quotaleft_singular'] = (object) array('posts' => '#', 'period' => $this->get_max_posts_period(true, true));
     }
     $stringlist = array();
     foreach ($mainstrings as $string => $value) {
         $stringlist[] = array($string, 'forumng', $value);
     }
     foreach (array('cancel', 'delete', 'add', 'selectall', 'deselectall') as $string) {
         $stringlist[] = array($string, 'moodle');
     }
     // Use star ratings where the scale is between 2 and 5 (3 and 6 stars)
     $out = mod_forumng_utils::get_renderer();
     $scale = $this->get_rating_scale();
     if ($scale > 1 && $scale < 6) {
         $ratingstars = $scale;
     } else {
         $ratingstars = 0;
     }
     $starurls = array();
     foreach (array('circle', 'star') as $base) {
         foreach (array('y', 'n') as $user) {
             foreach (array('y', 'n') as $public) {
                 $key = "{$base}-{$user}-{$public}";
                 $starurls[$key] = $out->pix_url($key, 'forumng')->out(false);
             }
         }
     }
     $module = array('name' => 'mod_forumng', 'fullpath' => '/mod/forumng/module.js', 'requires' => array('base', 'node', 'node-event-simulate', 'dom', 'event', 'io', 'anim', 'json-parse'), 'strings' => $stringlist);
     $PAGE->requires->js_init_call('M.mod_forumng.init', array($cmid ? $cmid : 0, $this->is_shared() ? $this->get_course_module_id() : 0, $ratingstars, $this->get_remaining_post_quota(), $out->pix_url('i/ajaxloader')->out(false), $starurls), false, $module);
 }
 /**
  * Displays a Moodle standard paging bar for this result.
  * @param string $baseurl Base URL (may include page= if you like)
  * @return string HTML code for paging bar
  */
 public function display_paging_bar($baseurl)
 {
     // Don't do anything if no pages
     if ($this->pagecount < 2) {
         return '';
     }
     // Remove page= if included and append &
     $baseurl = preg_replace('~&page=[0-9]+~', '', $baseurl) . '&';
     $out = mod_forumng_utils::get_renderer();
     $result = $out->render(new paging_bar($this->pagecount, $this->page - 1, 1, htmlspecialchars($baseurl)));
     // This is really damn annoying but discussionlist pages start from 1
     // not 0, so need to change the params
     $result = preg_replace_callback('~(&amp;page=)([0-9]+)~', 'mod_forumng_discussion_list::munge_page_number', $result);
     return $result;
 }
 /** @return string User picture HTML (for post author) */
 public function display_user_picture()
 {
     $out = mod_forumng_utils::get_renderer();
     return $out->user_picture($this->get_user(), array('courseid' => $this->get_forum()->get_course_id()));
 }