3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Form for editing RSS client block instances.
22 * @copyright 2009 Tim Hunt
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 * Form for editing RSS client block instances.
29 * @copyright 2009 Tim Hunt
30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 class block_rss_client_edit_form extends block_edit_form {
33 protected function specific_definition($mform) {
34 global $CFG, $DB, $USER;
36 // Fields for editing block contents.
37 $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
39 $mform->addElement('selectyesno', 'config_display_description', get_string('displaydescriptionlabel', 'block_rss_client'));
40 $mform->setDefault('config_display_description', 0);
42 $mform->addElement('text', 'config_shownumentries', get_string('shownumentrieslabel', 'block_rss_client'), array('size' => 5));
43 $mform->setType('config_shownumentries', PARAM_INTEGER);
44 $mform->addRule('config_shownumentries', null, 'numeric', null, 'client');
45 if (!empty($CFG->block_rss_client_num_entries)) {
46 $mform->setDefault('config_shownumentries', $CFG->block_rss_client_num_entries);
48 $mform->setDefault('config_shownumentries', 5);
51 $rssfeeds = $DB->get_records_sql_menu('
53 CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) .' ELSE preferredtitle END
54 FROM {block_rss_client}
55 WHERE userid = ? OR shared = 1
56 ORDER BY CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) . ' ELSE preferredtitle END ',
57 array($DB->sql_empty(), $USER->id, $DB->sql_empty()));
59 $select = $mform->addElement('select', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'), $rssfeeds);
60 $select->setMultiple(true);
63 $mform->addElement('static', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'),
64 get_string('nofeeds', 'block_rss_client'));
67 if (has_any_capability(array('block/rss_client:manageanyfeeds', 'block/rss_client:manageownfeeds'), $this->block->context)) {
68 $mform->addElement('static', 'nofeedmessage', '',
69 '<a href="' . $CFG->wwwroot . '/blocks/rss_client/managefeeds.php?courseid=' . $this->page->course->id . '">' .
70 get_string('feedsaddedit', 'block_rss_client') . '</a>');
73 $mform->addElement('text', 'config_title', get_string('uploadlabel'));
74 $mform->setType('config_title', PARAM_NOTAGS);
76 $mform->addElement('selectyesno', 'config_block_rss_client_show_channel_link', get_string('clientshowchannellinklabel', 'block_rss_client'));
77 $mform->setDefault('config_block_rss_client_show_channel_link', 0);
79 $mform->addElement('selectyesno', 'config_block_rss_client_show_channel_image', get_string('clientshowimagelabel', 'block_rss_client'));
80 $mform->setDefault('config_block_rss_client_show_channel_image', 0);