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. |
13
|
|
|
// |
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
|
|
|
* Pagseguro enrol plugin implementation. |
19
|
|
|
* |
20
|
|
|
* @package enrol_pagseguro |
21
|
|
|
* @copyright 2015 Daniel Neis |
22
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
defined('MOODLE_INTERNAL') || die(); |
26
|
|
|
|
27
|
|
|
require_once("$CFG->libdir/formslib.php"); |
28
|
|
|
|
29
|
|
|
class enrol_pagseguro_enrol_form extends moodleform { |
30
|
|
|
|
31
|
|
|
public function definition() { |
32
|
|
|
$mform = $this->_form; |
|
|
|
|
33
|
|
|
$mform = $this->_form; |
34
|
|
|
$instance = $this->_customdata; |
35
|
|
|
$plugin = enrol_get_plugin('pagseguro'); |
36
|
|
|
|
37
|
|
|
$heading = $plugin->get_instance_name($instance); |
38
|
|
|
$mform->addElement('header', 'pagseguroheader', $heading); |
39
|
|
|
|
40
|
|
|
$mform->addElement('static', 'paymentrequired', '', get_string('paymentrequired', 'enrol_pagseguro', $instance)); |
41
|
|
|
|
42
|
|
|
$pagseguroimgurl = "https://p.simg.uol.com.br/out/pagseguro/i/botoes/pagamentos/99x61-pagar-assina.gif"; |
43
|
|
|
$mform->addElement('static', 'paymentrequired', '', |
44
|
|
|
html_writer::empty_tag('img', array('alt' => get_string('pagseguroaccepted', 'enrol_pagseguro'), |
45
|
|
|
'src' => $pagseguroimgurl))); |
46
|
|
|
|
47
|
|
|
$mform->addElement('hidden', 'courseid', $instance->courseid); |
48
|
|
|
$mform->setType('courseid', PARAM_INT); |
49
|
|
|
|
50
|
|
|
$mform->addElement('hidden', 'instanceid', $instance->id); |
51
|
|
|
$mform->setType('instanceid', PARAM_INT); |
52
|
|
|
|
53
|
|
|
$mform->addElement('hidden', 'cost', $instance->cost); |
54
|
|
|
$mform->setType('cost', PARAM_INT); |
55
|
|
|
|
56
|
|
|
$mform->addElement('hidden', 'usersubmitted', 1); |
57
|
|
|
$mform->setType('usersubmitted', PARAM_INT); |
58
|
|
|
|
59
|
|
|
$this->add_action_buttons(false, get_string('sendpaymentbutton', 'enrol_pagseguro'), '1'); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.