Exemple #1
0
    $count = $DB->count_records_sql("SELECT COUNT(*) FROM {glossary_entries} WHERE (glossaryid = ? OR sourceglossaryid = ?)", array($glossary->id, $glossary->id));

    //If this glossary has RSS activated, calculate it
    if ($show_rss) {
        $rsslink = '';
        if ($glossary->rsstype and $glossary->rssarticles) {
            //Calculate the tolltip text
            $tooltiptext = get_string("rsssubscriberss","glossary",format_string($glossary->name));
            if (!isloggedin()) {
                $userid = 0;
            } else {
                $userid = $USER->id;
            }
            //Get html code for RSS link
            $rsslink = rss_get_link($context->id, $userid, 'mod_glossary', $glossary->id, $tooltiptext);
        }
    }

    if ($usesections) {
        $linedata = array ($printsection, $link, $count);
    } else {
        $linedata = array ($link, $count);
    }

    if ($show_rss) {
        $linedata[] = $rsslink;
    }

    $table->data[] = $linedata;
}
Exemple #2
0
        $link = "<a href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>";
    }

    // TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page

    $numrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =?', array($data->id));

    if ($data->approval == 1) {
        $numunapprovedrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =? AND r.approved <> 1', array($data->id));
    } else {
        $numunapprovedrecords = '-';
    }

    $rsslink = '';
    if ($rss && $data->rssarticles > 0) {
        $rsslink = rss_get_link($context->id, $USER->id, 'mod_data', $data->id, 'RSS');
    }

    if ($usesections) {
        if ($data->section !== $currentsection) {
            if ($data->section) {
                $printsection = get_section_name($course, $data->section);
            }
            if ($currentsection !== '') {
                $table->data[] = 'hr';
            }
            $currentsection = $data->section;
        }
        $row = array ($printsection, $link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords);

    } else {
Exemple #3
0
/**
 * Print the link for the RSS feed with the correct RSS icon (Theme based)
 *
 * @param stdClass    $contextid     The id of the context under which the URL should be created
 * @param int         $userid        The source of the RSS feed (site/course/group/user)
 * @param string      $componentname The name of the component for which the feed exists
 * @param string      $id            The name by which to call the RSS File
 * @param string      $tooltiptext   The tooltip to be displayed with the link
 */
function rss_print_link($contextid, $userid, $componentname, $id, $tooltiptext = '')
{
    print rss_get_link($contextid, $userid, $componentname, $id, $tooltiptext);
}
Exemple #4
0
                    $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes, 'unsubscribed' => $strno, 'forcesubscribed' => $stryes, 'cantsubscribe' => '-'), false, false, true, $subscribed_forums);
                } else {
                    $row[] = '-';
                }
            }
            //If this forum has RSS activated, calculate it
            if ($show_rss) {
                if ($forum->rsstype and $forum->rssarticles) {
                    //Calculate the tolltip text
                    if ($forum->rsstype == 1) {
                        $tooltiptext = get_string('rsssubscriberssdiscussions', 'forum', format_string($forum->name));
                    } else {
                        $tooltiptext = get_string('rsssubscriberssposts', 'forum', format_string($forum->name));
                    }
                    //Get html code for RSS link
                    $row[] = rss_get_link($course->id, $USER->id, 'forum', $forum->id, $tooltiptext);
                } else {
                    $row[] = '&nbsp;';
                }
            }
            $learningtable->data[] = $row;
        }
    }
}
/// Output the page
$navlinks = array();
$navlinks[] = array('name' => $strforums, 'link' => '', 'type' => 'activity');
print_header("{$course->shortname}: {$strforums}", $course->fullname, build_navigation($navlinks), "", "", true, $searchform, navmenu($course));
if (!isguest()) {
    print_box_start('subscription');
    echo '<span class="helplink">';
function rss_print_link($courseid, $userid, $modulename, $id, $tooltiptext = '')
{
    print rss_get_link($courseid, $userid, $modulename, $id, $tooltiptext);
}
Exemple #6
0
 /**
  * Returns a specific rss link.
  *
  * @return string HTML fragment
  */
 public function get_rss_link()
 {
     global $CFG, $USER;
     // Link to the RSS feed.
     if (!empty($CFG->enablerssfeeds) && !empty($CFG->dataform_enablerssfeeds)) {
         $dataformid = $this->df->id;
         $viewid = $this->id;
         $componentinstance = "{$dataformid}/{$viewid}";
         return rss_get_link($this->df->context->id, $USER->id, 'mod_dataform', $componentinstance);
     }
     return null;
 }
 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;
 }
Exemple #8
0
 if (!$data->visible) {
     //Show dimmed if the mod is hidden
     $link = "<a class=\"dimmed\" href=\"view.php?id={$data->coursemodule}\">" . format_string($data->name, true) . "</a>";
 } else {
     //Show normal if the mod is visible
     $link = "<a href=\"view.php?id={$data->coursemodule}\">" . format_string($data->name, true) . "</a>";
 }
 $numrecords = count_records_sql('SELECT COUNT(r.id) FROM ' . $CFG->prefix . 'data_records r WHERE r.dataid =' . $data->id);
 if ($data->approval == 1) {
     $numunapprovedrecords = count_records_sql('SELECT COUNT(r.id) FROM ' . $CFG->prefix . 'data_records r WHERE r.dataid =' . $data->id . ' AND r.approved <> 1');
 } else {
     $numunapprovedrecords = '-';
 }
 $rsslink = '';
 if ($rss && $data->rssarticles > 0) {
     $rsslink = rss_get_link($course->id, $USER->id, 'data', $data->id, 'RSS');
 }
 if ($course->format == 'weeks' or $course->format == 'topics') {
     if ($data->section !== $currentsection) {
         if ($data->section) {
             $printsection = $data->section;
         }
         if ($currentsection !== '') {
             $table->data[] = 'hr';
         }
         $currentsection = $data->section;
     }
     $row = array($printsection, $link, $data->intro, $numrecords, $numunapprovedrecords);
 } else {
     $row = array($link, $data->intro, $numrecords, $numunapprovedrecords);
 }
$meta = '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/lightboxgallery/css/lightbox.css" />';
$allowrssfeed = lightboxgallery_rss_enabled() && $gallery->rss;
if ($allowrssfeed) {
    $rsspath = rss_get_url($course->id, $userid, 'lightboxgallery', $gallery->id);
    $meta .= "\n" . '<link rel="alternate" href="' . $rsspath . '" type="application/rss+xml" title="' . format_string($gallery->name) . '" id="gallery" />';
}
$meta .= "\n" . '<style type="text/css">';
$meta .= "\n" . '#navbar_bg {display:none;}';
$meta .= "\n" . '#header_bg {display:none;}';
$meta .= "\n" . '#banner_bg {display:none;}';
$meta .= "\n" . '</style>';
print_header();
//$course->shortname . ': ' . $gallery->name, $course->fullname, $navigation, '', $meta, true, $update, navmenu($course, $cm));
$heading = get_string('displayinggallery', 'lightboxgallery', $gallery->name);
if ($allowrssfeed) {
    $heading .= ' ' . rss_get_link($course->id, $userid, 'lightboxgallery', $gallery->id, get_string('rsssubscribe', 'lightboxgallery'));
}
print_heading($heading);
lightboxgallery_print_js_config($gallery->autoresize);
$fobj = new object();
$fobj->para = false;
if ($gallery->description && !$editing) {
    print_simple_box(format_text($gallery->description, FORMAT_MOODLE, $fobj), 'center');
}
print_simple_box_start('center');
$dataroot = $CFG->dataroot . '/' . $course->id . '/' . $gallery->folder;
$webroot = lightboxgallery_get_image_url($gallery->id);
$allimages = lightboxgallery_directory_images($dataroot);
$images = $gallery->perpage == 0 ? $allimages : array_slice($allimages, $page * $gallery->perpage, $gallery->perpage);
$captions = array();
if ($cobjs = get_records_select('lightboxgallery_image_meta', "metatype = 'caption' AND gallery = {$gallery->id}")) {
Exemple #10
0
    $url_params = array('id' => $id, 'page' => $page, 'editing' => $editing ? '0' : '1');
    $url = new moodle_url('/mod/lightboxgallery/view.php', $url_params);
    $strediting = get_string('turnediting' . ($editing ? 'off' : 'on'));
    $button = $OUTPUT->single_button($url, $strediting, 'get') . ' ';
}
$button .= update_module_button($cm->id, $course->id, get_string('modulename', 'lightboxgallery'));
$PAGE->set_button($button);
$PAGE->requires->css('/mod/lightboxgallery/assets/skins/sam/gallery-lightbox-skin.css');
$PAGE->requires->js('/mod/lightboxgallery/gallery-lightbox-min.js');
$PAGE->requires->js('/mod/lightboxgallery/module.js');
$allowrssfeed = lightboxgallery_rss_enabled() && $gallery->rss;
$heading = get_string('displayinggallery', 'lightboxgallery', $gallery->name);
if ($allowrssfeed) {
    rss_add_http_header($context, 'mod_lightboxgallery', $gallery->id, $gallery->name);
    $strrsssub = get_string('rsssubscribe', 'lightboxgallery');
    $heading .= ' ' . rss_get_link($context->id, $userid, 'mod_lightboxgallery', $gallery->id, $strrsssub);
}
echo $OUTPUT->header();
echo $OUTPUT->heading($heading);
if ($gallery->intro && !$editing) {
    echo $OUTPUT->box(format_module_intro('lightboxgallery', $gallery, $cm->id), 'generalbox', 'intro');
}
echo $OUTPUT->box_start('generalbox lightbox-gallery clearfix');
$fs = get_file_storage();
$stored_files = $fs->get_area_files($context->id, 'mod_lightboxgallery', 'gallery_images');
$image_count = 1;
foreach ($stored_files as $stored_file) {
    if (!$stored_file->is_valid_image()) {
        continue;
    }
    if ($gallery->perpage > 0 && ($image_count > $gallery->perpage * $page + $gallery->perpage || $image_count < $gallery->perpage * $page + 1)) {
$table = new html_table();
$table->head = array(get_string($course->format == 'weeks' ? 'week' : 'topic'), '&nbsp;', get_string('modulenameshort', 'lightboxgallery'), get_string('description'), 'RSS');
$table->align = array('center', 'center', 'left', 'left', 'center');
$table->width = '*';
$fobj = new object();
$fobj->para = false;
$prevsection = '';
// TODO: Put this in a renderer.
foreach ($galleries as $gallery) {
    $cm = context_module::instance($gallery->coursemodule);
    $printsection = $gallery->section !== $prevsection ? true : false;
    if ($printsection) {
        $table->data[] = 'hr';
    }
    if (lightboxgallery_rss_enabled() && $gallery->rss) {
        $rss = rss_get_link($course->id, $USER->id, 'lightboxgallery', $gallery->id, get_string('rsssubscribe', 'lightboxgallery'));
    }
    $fs = get_file_storage();
    $files = $fs->get_area_files($cm->id, 'mod_lightboxgallery', 'gallery_images');
    foreach ($files as $file) {
        if ($file->get_filename() != '.') {
            $imagecount++;
        }
    }
    $commentcount = $DB->count_records('lightboxgallery_comments', array('gallery' => $gallery->id));
    $viewurl = new moodle_url('/mod/lightboxgallery/view.php', array('id' => $gallery->coursemodule));
    $table->data[] = array($printsection ? $gallery->section : '', lightboxgallery_index_thumbnail($course->id, $gallery), html_writer::link($viewurl, $gallery->name) . '<br />' . get_string('imagecounta', 'lightboxgallery', $imagecount) . get_string('commentcount', 'lightboxgallery', $commentcount), format_text($gallery->description, FORMAT_MOODLE, $fobj), isset($rss) ? $rss : get_string('norssfeedavailable', 'lightboxgallery'));
    $prevsection = $gallery->section;
}
echo $OUTPUT->heading(get_string('modulenameplural', 'lightboxgallery'), 2);
echo html_writer::table($table);
$strhead = get_string($course->format == 'weeks' ? 'week' : 'topic');
$table = new object();
$table->head = array($strhead, '&nbsp;', get_string('modulenameshort', 'lightboxgallery'), get_string('description'), 'RSS');
$table->align = array('center', 'center', 'left', 'left', 'center');
$table->width = '*';
$fobj = new object();
$fobj->para = false;
$currentsection = '';
foreach ($galleries as $gallery) {
    $printsection = '&nbsp;';
    $rss = '&nbsp;';
    $rsssubscribe = get_string('rsssubscribe', 'lightboxgallery');
    if ($currentsection !== $gallery->section) {
        $printsection = $gallery->section;
        if ($currentsection !== '') {
            $table->data[] = 'hr';
        }
        $currentsection = $gallery->section;
    }
    if (lightboxgallery_rss_enabled() && $gallery->rss) {
        $rss = rss_get_link($course->id, $USER->id, 'lightboxgallery', $gallery->id, $rsssubscribe);
    }
    $imagecount = count(lightboxgallery_directory_images($CFG->dataroot . '/' . $course->id . '/' . $gallery->folder));
    $extra = get_string('imagecounta', 'lightboxgallery', $imagecount);
    if ($commentcount = count_records('lightboxgallery_comments', 'gallery', $gallery->id)) {
        $extra .= ', ' . get_string('commentcount', 'lightboxgallery', $commentcount);
    }
    $table->data[] = array($printsection, lightboxgallery_index_thumbnail($course->id, $gallery), '<a href="' . $CFG->wwwroot . '/mod/lightboxgallery/view.php?l=' . $gallery->id . '">' . $gallery->name . '</a><br />' . $extra, format_text($gallery->description, FORMAT_MOODLE, $fobj), $rss);
}
print_table($table);
print_footer($course);
    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>";
                }
                         
            }
            $text .= "</ul>\n";

            $this->content->text = "<div>".$text."</div>";

            $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;
    }
Exemple #14
0
                } else {
                    $digestoptions_selector->selected = $quora->maildigest;
                }
                $row[] = $OUTPUT->render($digestoptions_selector);
            }
            //If this quora has RSS activated, calculate it
            if ($show_rss) {
                if ($quora->rsstype and $quora->rssarticles) {
                    //Calculate the tolltip text
                    if ($quora->rsstype == 1) {
                        $tooltiptext = get_string('rsssubscriberssdiscussions', 'quora');
                    } else {
                        $tooltiptext = get_string('rsssubscriberssposts', 'quora');
                    }
                    //Get html code for RSS link
                    $row[] = rss_get_link($context->id, $USER->id, 'mod_quora', $quora->id, $tooltiptext);
                } else {
                    $row[] = '&nbsp;';
                }
            }
            $learningtable->data[] = $row;
        }
    }
}
/// Output the page
$PAGE->navbar->add($strquoras);
$PAGE->set_title("{$course->shortname}: {$strquoras}");
$PAGE->set_heading($course->fullname);
$PAGE->set_button($searchform);
echo $OUTPUT->header();
// Show the subscribe all options only to non-guest, enrolled users
 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;
 }
Exemple #16
0
        $currentsection = $glossary->section;
    }
    $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = {$glossary->id} or sourceglossaryid = {$glossary->id})");
    //If this glossary has RSS activated, calculate it
    if ($show_rss) {
        $rsslink = '';
        if ($glossary->rsstype and $glossary->rssarticles) {
            //Calculate the tolltip text
            $tooltiptext = get_string("rsssubscriberss", "glossary", format_string($glossary->name));
            if (empty($USER->id)) {
                $userid = 0;
            } else {
                $userid = $USER->id;
            }
            //Get html code for RSS link
            $rsslink = rss_get_link($course->id, $userid, "glossary", $glossary->id, $tooltiptext);
        }
    }
    if ($course->format == "weeks" or $course->format == "topics") {
        $linedata = array($printsection, $link, $count);
    } else {
        $linedata = array($link, $count);
    }
    if ($show_rss) {
        $linedata[] = $rsslink;
    }
    $table->data[] = $linedata;
}
echo "<br />";
print_table($table);
/// Finish the page
Exemple #17
0
            }
            //If this forum has RSS activated, calculate it
            if ($show_rss and $forum->rsstype and $forum->rssarticles) {
                //Calculate the tolltip text
                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;
                }
                //Get html code for RSS link
                $row[] = rss_get_link($course->id, $userid, "forum", $forum->id, $tooltiptext);
            }
            $learningtable->data[] = $row;
        }
    }
}
/// Output the page
$navlinks = array();
$navlinks[] = array('name' => $strforums, 'link' => '', 'type' => 'activity');
print_header("{$course->shortname}: {$strforums}", $course->fullname, build_navigation($navlinks), "", "", true, $searchform, navmenu($course));
if (!isguest()) {
    print_box_start('subscription');
    echo '<span class="helplink">';
    echo '<a href="index.php?id=' . $course->id . '&amp;subscribe=1">' . get_string('allsubscribe', 'forum') . '</a>';
    echo '</span><br /><span class="helplink">';
    echo '<a href="index.php?id=' . $course->id . '&amp;subscribe=0">' . get_string('allunsubscribe', 'forum') . '</a>';
Exemple #18
0
 /**
  * This function display the hub homepage
  * It is called early when loading any Moodle page.
  * @return integer return true if Moodle index.php home page must continue normal display
  */
 public function display_homepage()
 {
     global $PAGE, $SITE, $OUTPUT, $CFG, $USER;
     //check if the front page search should not be displayed
     //=> hand over the home page to Moodle index.php
     //Two cases possible:
     //1- the hub is private and the users are not logged in
     //2- the hub is set with no search form on the login page
     $hubprivacy = get_config('local_hub', 'privacy');
     $searchfornologin = get_config('local_hub', 'searchfornologin');
     if (($hubprivacy == HUBPRIVATE or $searchfornologin === '0') and !isloggedin()) {
         return true;
     }
     require_once $CFG->dirroot . "/local/hub/forms.php";
     $PAGE->set_url('/');
     $PAGE->set_pagetype('site-index');
     $PAGE->set_docs_path('');
     $PAGE->set_pagelayout('frontpage');
     $PAGE->set_title($SITE->fullname);
     $PAGE->set_heading($SITE->fullname);
     //little trick to require login in order to rate or comment
     $mustbelogged = optional_param('mustbelogged', false, PARAM_BOOL);
     if ($mustbelogged) {
         require_login();
     }
     //log redirection to a course page
     $redirectcourseid = optional_param('redirectcourseid', false, PARAM_INT);
     if (!empty($redirectcourseid)) {
         //do not check sesskey because can be call by RSS feed
         $course = $this->get_course($redirectcourseid);
         if (!empty($course->courseurl)) {
             $courseurl = new moodle_url($course->courseurl);
         } else {
             if (!empty($course->demourl)) {
                 $courseurl = new moodle_url($course->demourl);
             } else {
                 //we try to display a demo site but none has been set
                 echo $OUTPUT->header();
                 echo get_string('nodemo', 'local_hub');
                 echo $OUTPUT->footer();
                 die;
             }
         }
         $rss = optional_param('rss', false, PARAM_BOOL);
         $rss = empty($rss) ? '' : 'rss';
         add_to_log(SITEID, 'local_hub', 'course redirection ' . $rss, '', $redirectcourseid);
         redirect(new moodle_url($courseurl));
     }
     $search = optional_param('search', null, PARAM_TEXT);
     $renderer = $PAGE->get_renderer('local_hub');
     //forms
     //Warning: because we want to support GET and we want people to be able to give the url,
     // we need to bypass the sesskey form checking
     $_GET['sesskey'] = sesskey();
     $fromformdata['coverage'] = optional_param('coverage', 'all', PARAM_TEXT);
     $fromformdata['licence'] = optional_param('licence', 'all', PARAM_ALPHANUMEXT);
     $fromformdata['subject'] = optional_param('subject', 'all', PARAM_ALPHANUMEXT);
     $fromformdata['siteid'] = optional_param('siteid', 'all', PARAM_ALPHANUMEXT);
     $fromformdata['lastmodified'] = optional_param('lastmodified', HUB_LASTMODIFIED_WEEK, PARAM_ALPHANUMEXT);
     $fromformdata['audience'] = optional_param('audience', 'all', PARAM_ALPHANUMEXT);
     $currentlanguage = explode('_', current_language());
     $fromformdata['language'] = optional_param('language', $currentlanguage[0], PARAM_ALPHANUMEXT);
     $fromformdata['educationallevel'] = optional_param('educationallevel', 'all', PARAM_ALPHANUMEXT);
     $fromformdata['downloadable'] = optional_param('downloadable', 1, PARAM_ALPHANUM);
     $fromformdata['orderby'] = optional_param('orderby', 'newest', PARAM_ALPHA);
     $fromformdata['search'] = $search;
     $coursesearchform = new course_search_form('', $fromformdata, 'get');
     $fromform = $coursesearchform->get_data();
     $coursesearchform->set_data($fromformdata);
     $fromform = (object) $fromformdata;
     //Retrieve courses by web service
     $options = array();
     //special shortcut if a course id is given in param, we search straight forward this id
     if ($courseid = optional_param('courseid', 0, PARAM_INTEGER)) {
         $options['onlyvisible'] = true;
         $options['ids'] = array($courseid);
         $options['downloadable'] = true;
         $options['enrollable'] = true;
         $courses = $this->get_courses($options);
         $coursetotal = 1;
         //Add the name of the course to the page title
         //(useful because some sites as Facebook is going to read it to build a shared link name)
         foreach ($courses as $course) {
             $PAGE->set_title($course->fullname . ' - ' . $SITE->fullname);
         }
     } else {
         if (!empty($fromform) and optional_param('submitbutton', 0, PARAM_ALPHANUMEXT)) {
             $downloadable = optional_param('downloadable', false, PARAM_INTEGER);
             if (!empty($fromform->coverage)) {
                 $options['coverage'] = $fromform->coverage;
             }
             if ($fromform->licence != 'all') {
                 $options['licenceshortname'] = $fromform->licence;
             }
             if ($fromform->subject != 'all') {
                 $options['subject'] = $fromform->subject;
             }
             if ($fromform->audience != 'all') {
                 $options['audience'] = $fromform->audience;
             }
             if ($fromform->educationallevel != 'all') {
                 $options['educationallevel'] = $fromform->educationallevel;
             }
             if ($fromform->language != 'all') {
                 $options['language'] = $fromform->language;
             }
             //sort method
             switch ($fromform->orderby) {
                 case 'newest':
                     $options['orderby'] = 'timemodified DESC';
                     break;
                 case 'eldest':
                     $options['orderby'] = 'timemodified ASC';
                     break;
                 case 'publisher':
                     $options['orderby'] = 'publishername ASC';
                     break;
                 case 'fullname':
                     $options['orderby'] = 'fullname ASC';
                     break;
                 case 'ratingaverage':
                     $options['orderby'] = 'ratingaverage DESC';
                     break;
                 default:
                     break;
             }
             //get courses
             $options['search'] = $search;
             $options['onlyvisible'] = true;
             $options['downloadable'] = $downloadable;
             $options['enrollable'] = !$downloadable;
             $page = optional_param('page', 0, PARAM_INT);
             $courses = $this->get_courses($options, $page * HUB_COURSE_PER_PAGE, HUB_COURSE_PER_PAGE);
             $coursetotal = $this->get_courses($options, 0, 0, true);
             //reset the options
             $options['orderby'] = $fromform->orderby;
             unset($options['onlyvisible']);
         }
     }
     if (!empty($courses)) {
         //load javascript
         $courseids = array();
         //all result courses
         $courseimagenumbers = array();
         //number of screenshots of all courses (must be exact same order than $courseids)
         foreach ($courses as $course) {
             $courseids[] = $course->id;
             $courseimagenumbers[] = $course->screenshots;
         }
         $PAGE->requires->yui_module('moodle-block_community-imagegallery', 'M.blocks_community.init_imagegallery', array(array('imageids' => $courseids, 'imagenumbers' => $courseimagenumbers, 'huburl' => $CFG->wwwroot)));
         //get courses content
         foreach ($courses as $course) {
             $contents = $this->get_course_contents($course->id);
             if (!empty($contents)) {
                 foreach ($contents as $content) {
                     $course->contents[] = $content;
                 }
             }
         }
         //load ratings and comments
         require_once $CFG->dirroot . '/rating/lib.php';
         $ratingoptions = new stdclass();
         $ratingoptions->context = context_course::instance(SITEID);
         //front page course
         $ratingoptions->items = $courses;
         $ratingoptions->aggregate = RATING_AGGREGATE_COUNT;
         //the aggregation method
         $ratingoptions->scaleid = 0 - get_config('local_hub', 'courseratingscaleid');
         //rating API is expecting "minus scaleid"
         $ratingoptions->userid = $USER->id;
         $ratingoptions->returnurl = $CFG->wwwroot . "/local/hub/index.php";
         $ratingoptions->component = 'local_hub';
         $ratingoptions->ratingarea = 'featured';
         $rm = new rating_manager();
         $courses = $rm->get_ratings($ratingoptions);
         //this function return $ratingoptions->items with information about the ratings
         foreach ($courses as $course) {
             $course->rating->settings->permissions->viewany = 1;
         }
         require_once $CFG->dirroot . '/comment/lib.php';
         foreach ($courses as $course) {
             $commentoptions = new stdClass();
             $commentoptions->context = context_course::instance(SITEID);
             $commentoptions->area = 'local_hub';
             $commentoptions->itemid = $course->id;
             $commentoptions->showcount = true;
             $commentoptions->component = 'local_hub';
             $course->comment = new comment($commentoptions);
             $course->comment->set_view_permission(true);
         }
     }
     //create rss feed link
     $enablerssfeeds = get_config('local_hub', 'enablerssfeeds');
     if (!empty($enablerssfeeds)) {
         require $CFG->libdir . '/rsslib.php';
         $audience = key_exists('audience', $options) ? $options['audience'] : 'all';
         $educationallevel = key_exists('educationallevel', $options) ? $options['educationallevel'] : 'all';
         if (key_exists('downloadable', $options)) {
             $downloadable = empty($options['downloadable']) ? 0 : 1;
         } else {
             $downloadable = 'all';
         }
         $subject = key_exists('subject', $options) ? $options['subject'] : 'all';
         $licence = key_exists('licence', $options) ? $options['licence'] : 'all';
         $language = key_exists('language', $options) ? $options['language'] : 'all';
         $audience = key_exists('audience', $options) ? $options['audience'] : 'all';
         $orderby = key_exists('orderby', $options) ? $options['orderby'] : 'newest';
         $search = empty($search) ? 0 : urlencode($search);
         //retrieve guest user if user not logged in
         $userid = empty($USER->id) ? $CFG->siteguest : $USER->id;
         $ctx = context_course::instance(SITEID);
         //add the link tage to the header
         $rsslink = rss_get_url($ctx->id, $userid, 'local_hub', $downloadable . '/' . $audience . '/' . $educationallevel . '/' . $subject . '/' . $licence . '/' . $language . '/' . $search . '/');
         $PAGE->add_alternate_version('RSS', $rsslink, 'application/rss+xml');
         //create the rss icon
         $rssicon = rss_get_link($ctx->id, $userid, 'local_hub', $downloadable . '/' . $audience . '/' . $educationallevel . '/' . $subject . '/' . $licence . '/' . $language . '/' . $search . '/' . $orderby . '/', get_string('rsstooltip', 'local_hub'));
     }
     /// OUTPUT
     echo $OUTPUT->header();
     //notification message sent to publisher
     if (optional_param('messagesent', 0, PARAM_INTEGER)) {
         echo $OUTPUT->notification(get_string('messagesentsuccess', 'local_hub'), 'notifysuccess');
     }
     //search form
     $coursesearchform->display();
     //Course listing
     $options['submitbutton'] = 1;
     //need to set up the submitbutton to 1 for the paging bar (simulate search)
     //and paramlink
     //set language value back to 'all'
     if (!key_exists('language', $options)) {
         $options['language'] = 'all';
     }
     if (isset($courses) and empty($courseid)) {
         if (empty($coursetotal)) {
             $coursetotalhtml = get_string('nocourse', 'local_hub');
         } else {
             $coursetotalhtml = get_string('coursetotal', 'local_hub', $coursetotal);
         }
         echo html_writer::tag('div', $coursetotalhtml, array('class' => 'hubcoursetotal'));
     }
     if (!empty($courses)) {
         //paging bar
         if ($coursetotal > HUB_COURSE_PER_PAGE) {
             $baseurl = new moodle_url('', $options);
             $pagingbarhtml = $OUTPUT->paging_bar($coursetotal, $page, HUB_COURSE_PER_PAGE, $baseurl);
             $pagingbarhtml = html_writer::tag('div', $pagingbarhtml, array('class' => 'pagingbar'));
             echo $pagingbarhtml;
         }
         echo highlight($search, $renderer->course_list($courses));
         if (!empty($pagingbarhtml)) {
             echo $pagingbarhtml;
         }
     }
     //rss icon
     if (!empty($enablerssfeeds)) {
         echo html_writer::tag('div', $rssicon, array('class' => 'hubrsslink'));
     }
     //permalink
     if (!empty($courses)) {
         $permalinkparams = array();
         //special case: course list is a unique course for a given ID
         if (!empty($courseid)) {
             $permalinkparams['courseid'] = $courseid;
         } else {
             $permalinkparams = $options;
         }
         $permalink = html_writer::tag('div', html_writer::tag('a', get_string('permalink', 'local_hub'), array('href' => new moodle_url('', $permalinkparams))), array('class' => 'hubcoursepermalink'));
         echo $permalink;
     }
     echo $OUTPUT->footer();
 }
Exemple #19
0
                } else {
                    $digestoptions_selector->selected = $forum->maildigest;
                }
                $row[] = $OUTPUT->render($digestoptions_selector);
            }
            //If this forum has RSS activated, calculate it
            if ($show_rss) {
                if ($forum->rsstype and $forum->rssarticles) {
                    //Calculate the tolltip text
                    if ($forum->rsstype == 1) {
                        $tooltiptext = get_string('rsssubscriberssdiscussions', 'forum');
                    } else {
                        $tooltiptext = get_string('rsssubscriberssposts', 'forum');
                    }
                    //Get html code for RSS link
                    $row[] = rss_get_link($context->id, $USER->id, 'mod_forum', $forum->id, $tooltiptext);
                } else {
                    $row[] = '&nbsp;';
                }
            }
            $learningtable->data[] = $row;
        }
    }
}
/// Output the page
$PAGE->navbar->add($strforums);
$PAGE->set_title("{$course->shortname}: {$strforums}");
$PAGE->set_heading($course->fullname);
$PAGE->set_button($searchform);
echo $OUTPUT->header();
// Show the subscribe all options only to non-guest, enrolled users
Exemple #20
0
                } else {
                    $digestoptions_selector->selected = $twf->maildigest;
                }
                $row[] = $OUTPUT->render($digestoptions_selector);
            }
            //If this twf has RSS activated, calculate it
            if ($show_rss) {
                if ($twf->rsstype and $twf->rssarticles) {
                    //Calculate the tolltip text
                    if ($twf->rsstype == 1) {
                        $tooltiptext = get_string('rsssubscriberssdiscussions', 'twf');
                    } else {
                        $tooltiptext = get_string('rsssubscriberssposts', 'twf');
                    }
                    //Get html code for RSS link
                    $row[] = rss_get_link($context->id, $USER->id, 'mod_twf', $twf->id, $tooltiptext);
                } else {
                    $row[] = '&nbsp;';
                }
            }
            $learningtable->data[] = $row;
        }
    }
}
/// Output the page
$PAGE->navbar->add($strtwfs);
$PAGE->set_title("{$course->shortname}: {$strtwfs}");
$PAGE->set_heading($course->fullname);
$PAGE->set_button($searchform);
echo $OUTPUT->header();
// Show the subscribe all options only to non-guest, enrolled users