|
Moodle
2.2.1
http://www.collinsharper.com
|
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 00018 00028 require_once('../config.php'); 00029 require_once('lib.php'); 00030 00031 require_login(); 00032 $context = get_context_instance(CONTEXT_SYSTEM); 00033 $PAGE->set_context($context); 00034 $PAGE->set_url(new moodle_url('/blog/external_blogs.php')); 00035 require_capability('moodle/blog:manageexternal', $context); 00036 00037 $delete = optional_param('delete', null, PARAM_INT); 00038 00039 $strexternalblogs = get_string('externalblogs','blog'); 00040 $straddnewexternalblog = get_string('addnewexternalblog','blog'); 00041 $strblogs = get_string('blogs','blog'); 00042 $message = null; 00043 00044 if ($delete && confirm_sesskey()) { 00045 $externalbloguserid = $DB->get_field('blog_external', 'userid', array('id' => $delete)); 00046 if ($externalbloguserid == $USER->id) { 00047 $DB->delete_records('blog_external', array('id' => $delete)); 00048 $message = get_string('externalblogdeleted', 'blog'); 00049 } 00050 } 00051 00052 $blogs = $DB->get_records('blog_external', array('userid' => $USER->id)); 00053 00054 $PAGE->set_heading("$SITE->shortname: $strblogs: $strexternalblogs", $SITE->fullname); 00055 $PAGE->set_title("$SITE->shortname: $strblogs: $strexternalblogs"); 00056 $PAGE->set_pagelayout('standard'); 00057 00058 echo $OUTPUT->header(); 00059 echo $OUTPUT->heading($strexternalblogs, 2); 00060 00061 if (!empty($message)) { 00062 echo $OUTPUT->notification($message); 00063 } 00064 00065 echo $OUTPUT->box_start('generalbox boxaligncenter'); 00066 00067 if (!empty($blogs)) { 00068 $table = new html_table(); 00069 $table->cellpadding = 4; 00070 $table->attributes['class'] = 'generaltable boxaligncenter'; 00071 $table->head = array(get_string('name'), get_string('url'), get_string('timefetched', 'blog'), get_string('valid', 'blog'), get_string('actions')); 00072 00073 foreach ($blogs as $blog) { 00074 if ($blog->failedlastsync) { 00075 $validicon = $OUTPUT->pix_icon('i/cross_red_big', get_string('feedisinvalid', 'blog')); 00076 } else { 00077 $validicon = $OUTPUT->pix_icon('i/tick_green_big', get_string('feedisvalid', 'blog')); 00078 } 00079 00080 $editurl = new moodle_url('/blog/external_blog_edit.php', array('id' => $blog->id)); 00081 $editicon = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('editexternalblog', 'blog'))); 00082 00083 $deletelink = new moodle_url('/blog/external_blogs.php', array('delete' => $blog->id, 'sesskey'=>sesskey())); 00084 $deleteicon = $OUTPUT->action_icon($deletelink, new pix_icon('t/delete', get_string('deleteexternalblog', 'blog'))); 00085 00086 $table->data[] = new html_table_row(array($blog->name, $blog->url, userdate($blog->timefetched), $validicon, $editicon . ' '. $deleteicon)); 00087 } 00088 echo html_writer::table($table); 00089 } 00090 00091 $newexternalurl = new moodle_url('/blog/external_blog_edit.php'); 00092 echo html_writer::link($newexternalurl, $straddnewexternalblog); 00093 echo $OUTPUT->box_end(); 00094 echo $OUTPUT->footer();