Merge branch 'install_master' of https://git.in.moodle.com/amosbot/moodle-install
[moodle.git] / analytics / classes / bulk_action.php
blobe615816ab641df7084c9d575916edabe93c52bd1
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
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.
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/>.
17 /**
18 * Representation of a suggested bulk action.
20 * @package core_analytics
21 * @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace core_analytics;
27 defined('MOODLE_INTERNAL') || die();
29 /**
30 * Representation of a suggested bulk action.
32 * @package core_analytics
33 * @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 class bulk_action extends action {
38 /**
39 * Prediction action constructor.
41 * @param string $actionname They should match a-zA-Z_0-9-, as we apply a PARAM_ALPHANUMEXT filter
42 * @param \moodle_url $actionurl The final URL where the user should be forwarded.
43 * @param \pix_icon $icon Link icon
44 * @param string $text Link text
45 * @param bool $primary Primary button or secondary.
46 * @param array $attributes Link attributes
47 * @param string|false $type
48 * @return void
50 public function __construct($actionname, \moodle_url $actionurl, \pix_icon $icon,
51 $text, $primary = false, $attributes = array(), $type = false) {
52 global $OUTPUT;
54 $this->actionname = $actionname;
55 $this->text = $text;
56 $this->set_type($type);
58 // We want to track how effective are our suggested actions, we pass users through a script that will log these actions.
59 $params = array('action' => $this->actionname, 'forwardurl' => $actionurl->out(false));
60 $this->url = new \moodle_url('/report/insights/action.php', $params);
62 $label = $OUTPUT->render($icon) . $this->text;
63 $this->actionlink = new \single_button($this->url, $label, 'get', $primary, $attributes);