Skip to content

Commit cc9f0ad

Browse files
committed
Final touch to BuyCourses plugin before 1.9.8 - refs #5464
1 parent 310db66 commit cc9f0ad

35 files changed

+524
-294
lines changed

plugin/buycourses/config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
define('TABLE_BUY_COURSE', 'plugin_buy_course');
55
define('TABLE_BUY_COURSE_COUNTRY', 'plugin_buy_course_country');
66
define('TABLE_BUY_COURSE_PAYPAL', 'plugin_buy_course_paypal');
7-
define('TABLE_BUY_COURSE_TRANSFERENCE', 'plugin_buy_course_transference');
7+
define('TABLE_BUY_COURSE_TRANSFER', 'plugin_buy_course_transfer');
88
define('TABLE_BUY_COURSE_TEMPORAL', 'plugin_buy_course_temporal');
99
define('TABLE_BUY_COURSE_SALE', 'plugin_buy_course_sale');
1010

1111
require_once __DIR__ . '/../../main/inc/global.inc.php';
1212
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
13-
require_once api_get_path(PLUGIN_PATH) . 'buy_courses/src/buy_course_plugin.class.php';
13+
require_once api_get_path(PLUGIN_PATH) . 'buycourses/src/buy_course_plugin.class.php';

plugin/buycourses/database.php

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,55 @@
11
<?php
2+
/* For license terms, see /license.txt */
23
/**
3-
* Created by PhpStorm.
4-
* User: fgonzales
5-
* Date: 21/05/14
6-
* Time: 12:19 PM
4+
* Plugin database installation script. Can only be executed if included
5+
* inside another script loading global.inc.php
6+
* @package chamilo.plugin.buycourses
77
*/
8-
$objPlugin = Buy_CoursesPlugin::create();
8+
/**
9+
* Check if script can be called
10+
*/
11+
if (!function_exists('api_get_path')) {
12+
die('This script must be loaded through the Chamilo plugin installer sequence');
13+
}
14+
/**
15+
* Create the script context, then execute database queries to enable
16+
*/
17+
$objPlugin = BuyCoursesPlugin::create();
918

1019
$table = Database::get_main_table(TABLE_BUY_COURSE);
1120
$sql = "CREATE TABLE IF NOT EXISTS $table (
1221
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
13-
id_course INT unsigned NOT NULL DEFAULT '0',
22+
course_id INT unsigned NOT NULL DEFAULT '0',
1423
code VARCHAR(40),
1524
title VARCHAR(250),
16-
visible int(1),
25+
visible int,
1726
price FLOAT(11,2) NOT NULL DEFAULT '0',
18-
sync int(1))";
27+
sync int)";
1928
Database::query($sql);
2029
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
2130
$sql = "SELECT id, code, title FROM $tableCourse";
2231
$res = Database::query($sql);
2332
while ($row = Database::fetch_assoc($res)) {
24-
$presql = "INSERT INTO $table (id_course, code, title, visible) VALUES ('" . $row['id'] . "','" . $row['code'] . "','" . $row['title'] . "','NO')";
33+
$presql = "INSERT INTO $table (course_id, code, title, visible) VALUES ('" . $row['id'] . "','" . $row['code'] . "','" . $row['title'] . "','NO')";
2534
Database::query($presql);
2635
}
2736

2837
$table = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY);
2938
$sql = "CREATE TABLE IF NOT EXISTS $table (
30-
`id_country` int(5) NOT NULL AUTO_INCREMENT,
31-
`country_code` char(2) NOT NULL DEFAULT '',
32-
`country_name` varchar(45) NOT NULL DEFAULT '',
33-
`currency_code` char(3) DEFAULT NULL,
34-
`iso_alpha3` char(3) DEFAULT NULL,
35-
`status` int(1) DEFAULT '0',
36-
PRIMARY KEY (`id_country`)
39+
country_id int NOT NULL AUTO_INCREMENT,
40+
country_code char(2) NOT NULL DEFAULT '',
41+
country_name varchar(45) NOT NULL DEFAULT '',
42+
currency_code char(3) DEFAULT NULL,
43+
iso_alpha3 char(3) DEFAULT NULL,
44+
status int DEFAULT '0',
45+
PRIMARY KEY (country_id)
3746
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;";
3847
Database::query($sql);
3948

40-
$sql = "CREATE UNIQUE INDEX index_country ON $table (`country_code`)";
49+
$sql = "CREATE UNIQUE INDEX index_country ON $table (country_code)";
4150
Database::query($sql);
4251

43-
$sql = "INSERT INTO $table (`country_code`, `country_name`, `currency_code`, `iso_alpha3`) VALUES
52+
$sql = "INSERT INTO $table (country_code, country_name, currency_code, iso_alpha3) VALUES
4453
('AD', 'Andorra', 'EUR', 'AND'),
4554
('AE', 'United Arab Emirates', 'AED', 'ARE'),
4655
('AF', 'Afghanistan', 'AFN', 'AFG'),
@@ -304,7 +313,7 @@
304313
$sql = "INSERT INTO $table (id,username,password,signature) VALUES ('1', 'API_UserName', 'API_Password', 'API_Signature')";
305314
Database::query($sql);
306315

307-
$table = Database::get_main_table(TABLE_BUY_COURSE_TRANSFERENCE);
316+
$table = Database::get_main_table(TABLE_BUY_COURSE_TRANSFER);
308317
$sql = "CREATE TABLE IF NOT EXISTS $table (
309318
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
310319
name VARCHAR(100) NOT NULL DEFAULT '',
@@ -336,8 +345,8 @@
336345
Database::query($sql);
337346

338347
//Menu main tabs
339-
$rsTab = $objPlugin->addTab('Buy Courses', 'plugin/buy_courses/index.php');
348+
$rsTab = $objPlugin->addTab('Buy Courses', 'plugin/buycourses/index.php');
340349

341350
if ($rsTab) {
342-
echo "<script>location.href = '" . $_SERVER['REQUEST_URI'] . "';</script>";
351+
echo "<script>location.href = '" . Security::remove_XSS($_SERVER['REQUEST_URI']) . "';</script>";
343352
}

plugin/buycourses/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
/* For license terms, see /license.txt */
33
/**
44
* Show form
55
*/

plugin/buycourses/install.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?php
2+
/* For license terms, see /license.txt */
23
/**
34
* This script is included by main/admin/settings.lib.php and generally
45
* includes things to execute in the main database (settings_current table)
5-
* @package chamilo.plugin.bigbluebutton
6+
* @package chamilo.plugin.buycourses
67
*/
78
/**
89
* Initialization
910
*/
10-
1111
require_once dirname(__FILE__) . '/config.php';
12-
Buy_CoursesPlugin::create()->install();
12+
if (!api_is_platform_admin()) {
13+
die ('You must have admin permissions to install plugins');
14+
}
15+
BuyCoursesPlugin::create()->install();

plugin/buycourses/js/buycourses.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* For licensing terms, see /license.txt */
2+
/**
3+
* JS library for the Chamilo buy-courses plugin
4+
* @package chamilo.plugin.buycourses
5+
*/
16
$(document).ready(function () {
27
$("input[name='price']").change(function () {
38
$(this).parent().next().children().attr("style", "display:none");
@@ -29,16 +34,16 @@ $(document).ready(function () {
2934
$(".save").click(function () {
3035
var visible = $(this).parent().parent().prev().prev().children().attr("checked");
3136
var price = $(this).parent().parent().prev().children().attr("value");
32-
var id_course = $(this).attr('id');
33-
$.post("function.php", {tab: "save_mod", id_course: id_course, visible: visible, price: price},
37+
var course_id = $(this).attr('id');
38+
$.post("function.php", {tab: "save_mod", course_id: course_id, visible: visible, price: price},
3439
function (data) {
3540
if (data.status == "false") {
3641
alert("Database Error");
3742
} else {
38-
$("#course" + data.id_course).children().attr("style", "display:''");
39-
$("#course" + data.id_course).children().next().attr("style", "display:none");
40-
$("#course" + data.id_course).parent().removeClass("fmod")
41-
$("#course" + data.id_course).parent().children().each(function () {
43+
$("#course" + data.course_id).children().attr("style", "display:''");
44+
$("#course" + data.course_id).children().next().attr("style", "display:none");
45+
$("#course" + data.course_id).parent().removeClass("fmod")
46+
$("#course" + data.course_id).parent().children().each(function () {
4247
$(this).removeClass("btop");
4348
});
4449
}
@@ -216,4 +221,4 @@ function acciones_ajax() {
216221

217222

218223
}
219-
224+

plugin/buycourses/lang/english.php

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,65 @@
1-
<?php
2-
//Needed in order to show the plugin title
3-
$strings['plugin_title'] = "Comprar cursos";
4-
$strings['plugin_comment'] = "Configurar precios, tipos de pago, visibilidad de cursos.";
5-
6-
$strings['Visible'] = "Mostrar en el listado";
7-
$strings['Options'] = "Opciones";
8-
$strings['Price'] = "Precio";
9-
$strings['SyncCourseDatabase'] = "Sincronizar cursos de la base de datos";
10-
11-
$strings['Private'] = "Privado - acceso autorizado s&oacute;lo para los miembros del curso";
12-
$strings['CourseVisibilityClosed'] = "Cerrado - no hay acceso a este curso";
13-
$strings['OpenToThePlatform'] = "Abierto - acceso autorizado s&oacute;lo para los usuarios registrados en la plataforma";
14-
$strings['OpenToTheWorld'] = "P&uacute;blico - acceso autorizado a cualquier persona";
15-
16-
$strings['bc_setting_courses_available'] = "Configuraci&oacute;n de cursos disponibles";
17-
$strings['bc_setting_pay'] = "Configuraci&oacute;n pagos";
18-
19-
$strings['Description'] = "Descripci&oacute;n";
20-
$strings['Buy'] = "Comprar";
21-
$strings['Filtro_buscar'] = "Filtro de busqueda";
22-
$strings['Curso'] = "Curso";
23-
$strings['Price_Maximum'] = "Precio mayor de";
24-
$strings['Price_Minimum'] = "Precio menor de";
25-
$strings['Mostrar_disponibles'] = "Mostrar cursos disponibles";
26-
$strings['Categorias'] = "Categorias";
27-
28-
$strings['paypal_enable'] = "Habilitar PayPal";
29-
$strings['tarjet_credit_enable'] = "Habilitar TPV";
30-
$strings['transference_enable'] = "Habilitar transferencia";
31-
$strings['unregistered_users_enable'] = "Permitir usuarios sin registro en la plataforma";
32-
33-
$strings['EnrollToCourseXSuccessful'] = "Su inscripci�n en el curso %s se ha completado.";
34-
$strings['ErrorContactPlatformAdmin'] = "Se ha producido un error desconocido. Por favor, p�ngase en contacto con el administrador de la plataforma.";
35-
$strings['Cancelacionpedido'] = "El pedido se ha cancelado.";
36-
$strings['AlreadyBuy'] = "Ya est� matriculado en el curso";
37-
$strings['Message_conf_transf'] = "Una vez confirmado, recibira un e-mail con los datos bancarios y una referencia del pedido.";
38-
$strings['bc_subject'] = "Confirmaci�n pedido de cursos";
39-
$strings['bc_message'] = "Estimado {{name}}. <br />En cuanto recibamos confirmaci&oacute;n de pago procederemos a dar de alta su usuario en el curso <strong>{{curso}}</strong>.<br><br><strong>No olvide indicar en el concepto de la transferencia el n&uacute;mero de referencia del pedido: <div style='display:inline;text-align:center; font-weight:bold; font-size:20px; color:#333'>{{reference}}</div></strong>";
40-
$strings['bc_registrado'] = 'Ya se encuentra registrado en el curso';
41-
$strings['bc_tmp_registrado'] = 'Se encuentra a la espera de recibir el pago';
42-
43-
$strings['bc_confi_index'] = 'Configuraci�n cursos y precio';
44-
$strings['bc_pagos_index'] = 'Configuraci�n pagos';
45-
$strings['bc_pending'] = 'Pedidos pendientes de pago';
46-
47-
$strings['Ref_pedido'] = 'Referencia del pedido';
48-
$strings['transferencia_bancaria'] = 'Transferencia Bancaria';
49-
$strings['paypal'] = 'PayPal';
50-
$strings['confirmar_compra'] = 'Confirmar compra de curso';
51-
52-
$strings['The_User_Is_Already_Registered'] = 'El usuario ya está registrado';
1+
<?php
2+
$strings['plugin_title'] = "Sell courses";
3+
$strings['plugin_comment'] = "Sell courses directly through your Chamilo portal, using a PayPal account to receive funds. This plugin is in beta version. Neither the Chamilo association nor the developers involved could be considered responsible of any issue you might suffer using this plugin.";
4+
$strings['Visible'] = "Show list";
5+
$strings['Options'] = "Options";
6+
$strings['Price'] = "Price";
7+
$strings['SyncCourseDatabase'] = "Synchronize courses from database";
8+
$strings['Private'] = "Private - access authorized only for course members";
9+
$strings['CourseVisibilityClosed'] = "Closed - no access to this course";
10+
$strings['OpenToThePlatform'] = "Open - access authorized only for users registered on the platform";
11+
$strings['OpenToTheWorld'] = "Public - access open to anybody";
12+
$strings['Description'] = "Description";
13+
$strings['Buy'] = "Buy";
14+
$strings['Mostrar_disponibles'] = "Show available courses";
15+
$strings['paypal_enable'] = "Enable PayPal";
16+
$strings['transfer_enable'] = "Enable bank transfer";
17+
$strings['unregistered_users_enable'] = "Allow anonymous users";
18+
$strings['Cancelacionpedido'] = "The payment has been cancelled.";
19+
$strings['AlreadyBuy'] = "You are already subscribed to this course.";
20+
$strings['bc_subject'] = "Confirmation of course order";
21+
$strings['paypal'] = 'PayPal';
22+
$strings['confirmar_compra'] = 'Course purchase confirmation';
23+
$strings['TheUserIsAlreadyRegistered'] = 'The user is already registered';
24+
$strings['ProblemToSaveTheCurrencyType'] = 'Problem loading the currency type';
25+
$strings['ProblemToSaveThePaypalParameters'] = 'Problem saving PayPal parameters';
26+
$strings['ProblemToInsertANewAccount'] = 'Problem inserting the new account';
27+
$strings['ProblemToDeleteTheAccount'] = 'Problem removing account';
28+
$strings['ProblemToSaveTheMessage'] = 'Problem saving message';
29+
$strings['ProblemToSubscribeTheUser'] = 'Problem subscribing the user';
30+
$strings['TheSubscriptionAndActivationWereDoneSuccessfully'] = 'The subscription and activation were successful';
31+
$strings['TheUserIsAlreadyRegisteredInTheCourse'] = 'The user is already registered in the course.';
32+
$strings['CourseListOnSale'] = 'List of courses on sale';
33+
$strings['BuyCourses'] = 'Buy courses';
34+
$strings['ConfigurationOfCoursesAndPrices'] = 'Courses and prices configuration';
35+
$strings['ConfigurationOfPayments'] = 'Payments configuration';
36+
$strings['OrdersPendingOfPayment'] = 'Orders awaiting payment';
37+
$strings['AvailableCoursesConfiguration'] = 'Available courses configuration';
38+
$strings['PaymentsConfiguration'] = 'Payments configuration';
39+
$strings['bc_message'] = "Dear {{name}}. <br />We are currently waiting for the payment confirmation. Once received, we will enable your user in course <strong>{{curso}}</strong>.<br><br><strong>Please do not forget to mention your order reference number in your transfer: <div style='display:inline;text-align:center; font-weight:bold; font-size:20px; color:#333'>{{reference}}</div></strong>";
40+
$strings['Categories'] = "Categories";
41+
$strings['BankTransfer'] = 'Bank transfer';
42+
$strings['EnrollToCourseXSuccessful'] = "Your subscription to the course is complete";
43+
$strings['SearchFilter'] = "Search filter";
44+
$strings['MinimumPrice'] = "Minimum price";
45+
$strings['MaximumPrice'] = "Maximum price";
46+
$strings['AvailableCourses'] = "Courses available";
47+
$strings['PaymentConfiguration'] = "Payment configuration";
48+
$strings['WaitingToReceiveThePayment'] = "Currently pending payment";
49+
$strings['CurrencyType'] = "Currency type";
50+
$strings['SelectACurrency'] = "Choose a currency";
51+
$strings['Sandbox'] = "Test environment";
52+
$strings['BankAccount'] = "Bank account";
53+
$strings['SubscribeUser'] = "Subscribe user";
54+
$strings['DeleteTheOrder'] = "Delete order";
55+
$strings['ReferenceOrder'] = 'Order reference';
56+
$strings['UserInformation'] = "Buyer's details";
57+
$strings['OnceItIsConfirmed,YouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Once confirmed, you will receive an e-mail with the bank details and an order reference.";
58+
$strings['BankAccountInformation'] = 'Bank account details';
59+
$strings['ConfirmOrder'] = 'Confirm order';
60+
$strings['PaymentMethods'] = 'Payment methods';
61+
$strings['CancelOrder'] = 'Cancel order';
62+
$strings['ErrorContactPlatformAdmin'] = "Unknown error. Please contact the platform administrator.";
63+
$strings['PayPalConfig'] = "PayPal configuration:";
64+
$strings['TransfersConfig'] = "Bank transfers configuration:";
65+
$strings['PayPalPaymentOKPleaseConfirm'] = "PayPal reports the transaction is ready to be executed. To acknowledge that you are OK to proceed, please click the confirmation button below. Once clicked, you will be registered to the course and the funds will be transferred from your PayPal account to our shop. You can always access your courses through the 'My courses' tab. Thank you for your custom!";

0 commit comments

Comments
 (0)