Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Paypal utility script
19
 *
20
 * @package    enrol_paypal
21
 * @copyright  2004 onwards Martin Dougiamas (http://dougiamas.com)
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require("../../config.php");
26
require_once("$CFG->dirroot/enrol/paypal/lib.php");
27
 
28
$id = required_param('id', PARAM_INT);
29
 
30
if (!$course = $DB->get_record("course", array("id"=>$id))) {
31
    redirect($CFG->wwwroot);
32
}
33
 
34
$context = context_course::instance($course->id, MUST_EXIST);
35
$PAGE->set_context($context);
36
 
37
require_login();
38
 
39
if (!empty($SESSION->wantsurl)) {
40
    $destination = $SESSION->wantsurl;
41
    unset($SESSION->wantsurl);
42
} else {
43
    $destination = "$CFG->wwwroot/course/view.php?id=$course->id";
44
}
45
 
46
$fullname = format_string($course->fullname, true, array('context' => $context));
47
 
48
if (is_enrolled($context, NULL, '', true)) { // TODO: use real paypal check
49
    redirect($destination, get_string('paymentthanks', '', $fullname));
50
 
51
} else {   /// Somehow they aren't enrolled yet!  :-(
52
    $PAGE->set_url($destination);
53
    echo $OUTPUT->header();
54
    $a = new stdClass();
55
    $a->teacher = get_string('defaultcourseteacher');
56
    $a->fullname = $fullname;
57
    notice(get_string('paymentsorry', '', $a), $destination);
58
}
59
 
60