MDL-65788 tool_policy: Prevent two modals rendering for guests.
[moodle.git] / blocks / rss_client / edit_form.php
CommitLineData
f1a34d8f 1<?php
4ca6cfbf
PS
2// This file is part of Moodle - http://moodle.org/
3//
f1a34d8f 4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
4ca6cfbf 13//
f1a34d8f 14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Form for editing RSS client block instances.
19 *
f25a6839 20 * @package block_rss_client
f1a34d8f 21 * @copyright 2009 Tim Hunt
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25/**
26 * Form for editing RSS client block instances.
27 *
28 * @copyright 2009 Tim Hunt
29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 */
31class block_rss_client_edit_form extends block_edit_form {
32 protected function specific_definition($mform) {
33 global $CFG, $DB, $USER;
34
e530f3a9 35 // Fields for editing block contents.
f1a34d8f 36 $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
37
38 $mform->addElement('selectyesno', 'config_display_description', get_string('displaydescriptionlabel', 'block_rss_client'));
39 $mform->setDefault('config_display_description', 0);
40
41 $mform->addElement('text', 'config_shownumentries', get_string('shownumentrieslabel', 'block_rss_client'), array('size' => 5));
1e12c120 42 $mform->setType('config_shownumentries', PARAM_INT);
6d2382b6 43 $mform->addRule('config_shownumentries', null, 'numeric', null, 'client');
f1a34d8f 44 if (!empty($CFG->block_rss_client_num_entries)) {
6d2382b6 45 $mform->setDefault('config_shownumentries', $CFG->block_rss_client_num_entries);
f1a34d8f 46 } else {
6d2382b6 47 $mform->setDefault('config_shownumentries', 5);
f1a34d8f 48 }
49
15d27733 50 $insql = '';
0be8dbd9 51 $params = array('userid' => $USER->id);
af8cab9b 52 $rssconfig = unserialize(base64_decode($this->block->instance->configdata));
15d27733
MN
53 if ($rssconfig && !empty($rssconfig->rssid)) {
54 list($insql, $inparams) = $DB->get_in_or_equal($rssconfig->rssid, SQL_PARAMS_NAMED);
55 $insql = "OR id $insql ";
56 $params += $inparams;
57 }
af8cab9b 58
c561b23d
DP
59 $titlesql = "CASE WHEN {$DB->sql_isempty('block_rss_client','preferredtitle', false, false)}
60 THEN {$DB->sql_compare_text('title', 64)} ELSE preferredtitle END";
0be8dbd9
DP
61
62 $rssfeeds = $DB->get_records_sql_menu("
63 SELECT id, $titlesql
64 FROM {block_rss_client}
15d27733 65 WHERE userid = :userid OR shared = 1 $insql
0be8dbd9
DP
66 ORDER BY $titlesql",
67 $params);
af8cab9b 68
f1a34d8f 69 if ($rssfeeds) {
70 $select = $mform->addElement('select', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'), $rssfeeds);
71 $select->setMultiple(true);
72
73 } else {
15d27733 74 $mform->addElement('static', 'config_rssid_no_feeds', get_string('choosefeedlabel', 'block_rss_client'),
f1a34d8f 75 get_string('nofeeds', 'block_rss_client'));
76 }
77
78 if (has_any_capability(array('block/rss_client:manageanyfeeds', 'block/rss_client:manageownfeeds'), $this->block->context)) {
79 $mform->addElement('static', 'nofeedmessage', '',
80 '<a href="' . $CFG->wwwroot . '/blocks/rss_client/managefeeds.php?courseid=' . $this->page->course->id . '">' .
81 get_string('feedsaddedit', 'block_rss_client') . '</a>');
82 }
83
e530f3a9 84 $mform->addElement('text', 'config_title', get_string('uploadlabel'));
f1a34d8f 85 $mform->setType('config_title', PARAM_NOTAGS);
86
87 $mform->addElement('selectyesno', 'config_block_rss_client_show_channel_link', get_string('clientshowchannellinklabel', 'block_rss_client'));
88 $mform->setDefault('config_block_rss_client_show_channel_link', 0);
89
90 $mform->addElement('selectyesno', 'config_block_rss_client_show_channel_image', get_string('clientshowimagelabel', 'block_rss_client'));
91 $mform->setDefault('config_block_rss_client_show_channel_image', 0);
92 }
e530f3a9 93}