Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blocks/rss_client/managefeeds.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00026 require_once(dirname(__FILE__) . '/../../config.php');
00027 require_once($CFG->libdir . '/tablelib.php');
00028 
00029 require_login();
00030 
00031 $returnurl = optional_param('returnurl', '', PARAM_LOCALURL);
00032 $courseid = optional_param('courseid', 0, PARAM_INTEGER);
00033 $deleterssid = optional_param('deleterssid', 0, PARAM_INTEGER);
00034 
00035 if ($courseid == SITEID) {
00036     $courseid = 0;
00037 }
00038 if ($courseid) {
00039     $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
00040     $PAGE->set_course($course);
00041     $context = $PAGE->context;
00042 } else {
00043     $context = get_context_instance(CONTEXT_SYSTEM);
00044     $PAGE->set_context($context);
00045 }
00046 
00047 $managesharedfeeds = has_capability('block/rss_client:manageanyfeeds', $context);
00048 if (!$managesharedfeeds) {
00049     require_capability('block/rss_client:manageownfeeds', $context);
00050 }
00051 
00052 $urlparams = array();
00053 $extraparams = '';
00054 if ($courseid) {
00055     $urlparams['courseid'] = $courseid;
00056     $extraparams = '&courseid=' . $courseid;
00057 }
00058 if ($returnurl) {
00059     $urlparams['returnurl'] = $returnurl;
00060     $extraparams = '&returnurl=' . $returnurl;
00061 }
00062 $baseurl = new moodle_url('/blocks/rss_client/managefeeds.php', $urlparams);
00063 $PAGE->set_url($baseurl);
00064 
00065 // Process any actions
00066 if ($deleterssid && confirm_sesskey()) {
00067     $DB->delete_records('block_rss_client', array('id'=>$deleterssid));
00068 
00069     redirect($PAGE->url, get_string('feeddeleted', 'block_rss_client'));
00070 }
00071 
00072 // Display the list of feeds.
00073 if ($managesharedfeeds) {
00074     $select = '(userid = ' . $USER->id . ' OR shared = 1)';
00075 } else {
00076     $select = 'userid = ' . $USER->id;
00077 }
00078 $feeds = $DB->get_records_select('block_rss_client', $select, null, $DB->sql_order_by_text('title'));
00079 
00080 $strmanage = get_string('managefeeds', 'block_rss_client');
00081 
00082 $PAGE->set_pagelayout('standard');
00083 $PAGE->set_title($strmanage);
00084 $PAGE->set_heading($strmanage);
00085 
00086 $settingsurl = new moodle_url('/admin/settings.php?section=blocksettingrss_client');
00087 $managefeeds = new moodle_url('/blocks/rss_client/managefeeds.php', $urlparams);
00088 $PAGE->navbar->add(get_string('blocks'));
00089 $PAGE->navbar->add(get_string('feedstitle', 'block_rss_client'), $settingsurl);
00090 $PAGE->navbar->add(get_string('managefeeds', 'block_rss_client'), $managefeeds);
00091 echo $OUTPUT->header();
00092 
00093 $table = new flexible_table('rss-display-feeds');
00094 
00095 $table->define_columns(array('feed', 'actions'));
00096 $table->define_headers(array(get_string('feed', 'block_rss_client'), get_string('actions', 'moodle')));
00097 $table->define_baseurl($baseurl);
00098 
00099 $table->set_attribute('cellspacing', '0');
00100 $table->set_attribute('id', 'rssfeeds');
00101 $table->set_attribute('class', 'generaltable generalbox');
00102 $table->column_class('feed', 'feed');
00103 $table->column_class('actions', 'actions');
00104 
00105 $table->setup();
00106 
00107 foreach($feeds as $feed) {
00108     if (!empty($feed->preferredtitle)) {
00109         $feedtitle = s($feed->preferredtitle);
00110     } else {
00111         $feedtitle =  s($feed->title);
00112     }
00113 
00114     $viewlink = html_writer::link($CFG->wwwroot .'/blocks/rss_client/viewfeed.php?rssid=' . $feed->id . $extraparams, $feedtitle);
00115 
00116     $feedinfo = '<div class="title">' . $viewlink . '</div>' .
00117         '<div class="url">' . html_writer::link($feed->url, $feed->url) .'</div>' .
00118         '<div class="description">' . $feed->description . '</div>';
00119 
00120     $editurl = new moodle_url('/blocks/rss_client/editfeed.php?rssid=' . $feed->id . $extraparams);
00121     $editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')));
00122 
00123     $deleteurl = new moodle_url('/blocks/rss_client/managefeeds.php?deleterssid=' . $feed->id . '&sesskey=' . sesskey() . $extraparams);
00124     $deleteicon = new pix_icon('t/delete', get_string('delete'));
00125     $deleteaction = $OUTPUT->action_icon($deleteurl, $deleteicon, new confirm_action(get_string('deletefeedconfirm', 'block_rss_client')));
00126 
00127     $feedicons = $editaction . ' ' . $deleteaction;
00128 
00129     $table->add_data(array($feedinfo, $feedicons));
00130 }
00131 
00132 $table->print_html();
00133 
00134 $url = $CFG->wwwroot . '/blocks/rss_client/editfeed.php?' . substr($extraparams, 1);
00135 echo '<div class="actionbuttons">' . $OUTPUT->single_button($url, get_string('addnewfeed', 'block_rss_client'), 'get') . '</div>';
00136 
00137 
00138 if ($returnurl) {
00139     echo '<div class="backlink">' . html_writer::link($returnurl, get_string('back')) . '</div>';
00140 }
00141 
00142 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations