forked from megamuf/eexcess
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser_settings_interests_form.php
78 lines (69 loc) · 2.98 KB
/
user_settings_interests_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Form for user interests tags settings.
*
* @package block_eexcess
* @copyright bit media e-solutions GmbH <gerhard.doppler@bitmedia.cc>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once($CFG->libdir . '/formslib.php');
/**
* Extend moodle interests form
*
* @copyright bit media e-solutions GmbH <gerhard.doppler@bitmedia.cc>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_eexcess_interests_form extends moodleform {
/**
* Define this form - called from the parent constructor.
*/
public function definition() {
global $CFG;
global $USER;
global $DB;
$deletebuturl = $CFG->wwwroot."/blocks/eexcess/delete_interests_from_db.php";
$tablename = "block_eexcess_interests";
$mform =& $this->_form;
$cats = $DB->get_records($tablename, array("userid" => $USER->id));
foreach ($cats as $cat) {
$tags = explode(",", $cat->interests);
$listr = "";
foreach ($tags as $tag) {
$listr .= "<li>$tag</li>";
}
$catid = $cat->id;
if ($cat->active > 0) {
$checked = "checked=\"true\"";
$activeclass = "active-cat";
} else {
$checked = "";
$activeclass = "inactive-cat";
}
$sesskey = sesskey();
$html = "<div data-catid=\"{$catid}\" data-sesskey=\"{$sesskey}\"class=\"int-category $activeclass \">";
$html .= "<a data-catid=\"{$catid}\" href=\"{$deletebuturl}\" class=\"delete_interests\">x</a>";
$html .= "<span><h4>{$cat->title}</h4></span><label>Use -</label>";
$html .= "<input type=\"checkbox\" $checked value=\"1\" class=\"active\"/><ul >$listr</ul></div>";
$mform->addElement('html', $html);
}
$mform->addElement('html', '<input type="hidden" id="interest_json" name="interest_json">');
$buttitle = get_string('interests_tags', 'block_eexcess');
$mform->addElement('html', '<button type="button" id="id_area_for_tags" class="area_for_tags">'.$buttitle.'</button>');
$this->add_action_buttons(true, get_string('savechanges'));
}
}