Skip to content

Commit 475b37b

Browse files
author
Francis Gonzales
committed
Improve code, translate some variables and modify some comments
1 parent eee67df commit 475b37b

25 files changed

+275
-252
lines changed

main/inc/lib/plugin.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ public function addTab($tabName, $url)
526526
/**
527527
* Delete a tab to chamilo's platform
528528
* @param string $key
529+
*
530+
* @return boolean $resp Transaction response
529531
*/
530532
public function deleteTab($key)
531533
{

plugin/buy_courses/js/funciones.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ $(document).ready(function () {
6161
});
6262

6363

64-
$('#confirmar_filtro').click(function (e) {
64+
$('#confirm_filter').click(function (e) {
6565
var vcourse = $("#course_name").attr("value");
6666
var pmin = $("#price_min").attr("value");
6767
var pmax = $("#price_max").attr("value");
6868
if ($("#mostrar_disponibles").attr("checked") == "checked") {
69-
var vshow = "SI";
69+
var vshow = "YES";
7070
} else {
7171
var vshow = "NO";
7272
}
@@ -102,7 +102,7 @@ $(document).ready(function () {
102102
var clave = $("#password").attr("value");
103103
var firma = $("#signature").attr("value");
104104
if ($("#sandbox").attr("checked") == "checked") {
105-
var vsandbox = "SI";
105+
var vsandbox = "YES";
106106
} else {
107107
var vsandbox = "NO";
108108
}
@@ -132,8 +132,9 @@ $(document).ready(function () {
132132
});
133133

134134
$(".delete_account").click(function (e) {
135-
var vid = $(this).parent().attr("id");
136-
$.post("function.php", {tab: "delete_account", id: vid},
135+
var fieldName = $(this).parent().attr("id");
136+
var id = $("#id_" + fieldName).val();
137+
$.post("function.php", {tab: "delete_account", id: id},
137138
function (data) {
138139
location.reload();
139140
}, "json");
@@ -142,7 +143,7 @@ $(document).ready(function () {
142143
e.stopPropagation();
143144
});
144145

145-
$("#cancelapedido").click(function (e) {
146+
$("#cancel_order").click(function (e) {
146147
$.post("function.php", {tab: "unset_variables"});
147148
window.location.replace("list.php");
148149
});

plugin/buy_courses/lang/spanish.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,15 @@
1515

1616
$strings['Description'] = "Descripción";
1717
$strings['Buy'] = "Comprar";
18-
$strings['Filtro_buscar'] = "Filtro de busqueda";
19-
$strings['Price_Maximum'] = "Precio mayor de";
20-
$strings['Price_Minimum'] = "Precio menor de";
2118
$strings['Mostrar_disponibles'] = "Mostrar cursos disponibles";
2219

2320
$strings['paypal_enable'] = "Habilitar PayPal";
2421
$strings['transference_enable'] = "Habilitar transferencia";
2522
$strings['unregistered_users_enable'] = "Permitir usuarios sin registro en la plataforma";
26-
27-
$strings['EnrollToCourseXSuccessful'] = "Su inscripci�n en el curso %s se ha completado.";
28-
$strings['ErrorContactPlatformAdmin'] = "Se ha producido un error desconocido. Por favor, p�ngase en contacto con el administrador de la plataforma.";
2923
$strings['Cancelacionpedido'] = "El pedido se ha cancelado.";
3024
$strings['AlreadyBuy'] = "Ya est� matriculado en el curso";
31-
$strings['Message_conf_transf'] = "Una vez confirmado, recibira un e-mail con los datos bancarios y una referencia del pedido.";
3225
$strings['bc_subject'] = "Confirmaci�n pedido de cursos";
33-
$strings['bc_tmp_registrado'] = 'Se encuentra a la espera de recibir el pago';
3426

35-
$strings['Ref_pedido'] = 'Referencia del pedido';
3627
$strings['paypal'] = 'PayPal';
3728
$strings['confirmar_compra'] = 'Confirmar compra de curso';
3829

@@ -55,3 +46,24 @@
5546
$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>";
5647
$strings['Categories'] = "Categorias";
5748
$strings['BankTransference'] = 'Transferencia Bancaria';
49+
$strings['EnrollToCourseXSuccessful'] = "Su inscripción en el curso %s se ha completado.";
50+
$strings['SearchFilter'] = "Filtro de búsqueda";
51+
$strings['MinimumPrice'] = "Precio menor de";
52+
$strings['MaximumPrice'] = "Precio mayor de";
53+
$strings['AvailableCourses'] = "Cursos disponibles";
54+
$strings['PaymentConfiguration'] = "Configuración de Pagos";
55+
$strings['WaitingToReceiveThePayment'] = "Se encuentra a la espera de recibir el pago";
56+
$strings['CurrencyType'] = "Tipo de moneda";
57+
$strings['SelectACurrency'] = "Seleccione una moneda";
58+
$strings['Sandbox'] = "Entorno de Pruebas";
59+
$strings['BankAccount'] = "Cuenta Bancaria";
60+
$strings['SubscribeUser'] = "Suscribir Usuario";
61+
$strings['DeleteTheOrder'] = "Eliminar el Pedido";
62+
$strings['ReferenceOrder'] = 'Referencia del pedido';
63+
$strings['UserInformation'] = 'Información del Usuario';
64+
$strings['OnceItIsConfirmed,YouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Una vez confirmado, recibira un e-mail con los datos bancarios y una referencia del pedido.";
65+
$strings['BankAccountInformation'] = 'Información de la Cuenta Bancaria';
66+
$strings['ConfirmOrder'] = 'Confirmar Orden';
67+
$strings['PaymentMethods'] = 'Métodos de pago';
68+
$strings['CancelOrder'] = 'Cancelar Orden';
69+
$strings['ErrorContactPlatformAdmin'] = "Se ha producido un error desconocido. Por favor, póngase en contacto con el administrador de la plataforma.";

plugin/buy_courses/src/ajax.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
echo Display::tag('h2', $course_info['name']);
1414
echo '<br />';
1515

16-
$sql = "SELECT * FROM $tbl_course_description WHERE c_id = " . intval($course_info['real_id']) . " AND session_id = 0 ORDER BY id";
16+
$sql = "SELECT * FROM $tbl_course_description
17+
WHERE c_id = " . intval($course_info['real_id']) . "
18+
AND session_id = 0 ORDER BY id";
19+
1720
$result = Database::query($sql);
1821
if (Database::num_rows($result) > 0) {
1922
while ($description = Database::fetch_object($result)) {

plugin/buy_courses/src/configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
$plugin = Buy_CoursesPlugin::create();
1010

1111
$_cid = 0;
12+
$templateName = $plugin->get_lang('AvailableCourses');
1213
$interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale'));
1314
$interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => get_lang('Configuration'));
1415

15-
$tpl = new Template('availableCourses');
16+
$tpl = new Template($templateName);
1617

1718
$teacher = api_is_platform_admin();
1819
api_protect_course_script(true);

plugin/buy_courses/src/expresscheckout.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,8 @@
1515
* The currencyCodeType and paymentType
1616
* are set to the selections made on the Integration Assistant
1717
*/
18-
$currencyCodeType = "EUR";
1918
$paymentType = "Sale";
2019

21-
/**
22-
* The returnURL is the location where buyers return to when a
23-
* payment has been succesfully authorized.
24-
* This is set to the value entered on the Integration Assistant
25-
*/
26-
$returnURL = "http://www.nosolored.me/pluging/paypal/confirm.php";
27-
28-
29-
/**
30-
* The cancelURL is the location buyers are sent to when they hit the
31-
* cancel button during authorization of payment during the PayPal flow
32-
*
33-
* This is set to the value entered on the Integration Assistant
34-
*/
35-
$cancelURL = "http://www.nosolored.me/pluging/paypal/error.php";
36-
3720
/**
3821
* Calls the SetExpressCheckout API call
3922
* The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php,

plugin/buy_courses/src/function.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
require_once '../config.php';
4+
require_once 'buy_course.lib.php';
45
require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
56
require_once api_get_path(LIBRARY_PATH) . 'course.lib.php';
67

@@ -96,14 +97,14 @@
9697

9798
$tmp = Database::query($sql);
9899
if (Database::affected_rows() > 0) {
99-
$row['enrolled'] = "SI";
100+
$row['enrolled'] = "YES";
100101
} else {
101102
$row['enrolled'] = "NO";
102103
}
103104
} else {
104105
$row['enrolled'] = "NO";
105106
}
106-
//Comprobamos imagen
107+
// Check img
107108
if (file_exists("../../../courses/" . $row['code'] . "/course-pic85x85.png")) {
108109
$row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png";
109110
} else {
@@ -117,7 +118,7 @@
117118
}
118119

119120
}
120-
121+
$currencyType = findCurrency();
121122
foreach ($aux as $course) {
122123
$content .= '<div class="well_border span8">';
123124
$content .= '<div class="row">';
@@ -131,14 +132,14 @@
131132
$content .= '<div class="span4">';
132133
$content .= '<div class="categories-course-description">';
133134
$content .= '<h3>' . $course['title'] . '</h3>';
134-
$content .= '<h5>' . get_lang('teacher') . ': ' . $course['teacher'] . '</h5>';
135+
$content .= '<h5>' . get_lang('Teacher') . ': ' . $course['teacher'] . '</h5>';
135136
$content .= '</div>';
136137
if ($course['enrolled'] == "YES") {
137138
$content .= '<span class="label label-info">' . $plugin->get_lang('TheUserIsAlreadyRegistered') . '</span>';
138139
}
139140
$content .= '</div>';
140141
$content .= '<div class="span right">';
141-
$content .= '<div class="sprice right">' . $course['price'] . ' &euro; </div>';
142+
$content .= '<div class="sprice right">' . $course['price'] . ' ' . $currencyType . ' </div>';
142143
$content .= '<div class="cleared"></div>';
143144
$content .= '<div class="btn-toolbar right">';
144145
$content .= '<a class="ajax btn btn-primary" title="" href="' . $server . 'main/inc/ajax/course_home.ajax.php?a=show_course_information&code=' . $course['code'] . '">' . get_lang('Description') . '</a>&nbsp;';
@@ -210,7 +211,8 @@
210211

211212
if ($_REQUEST['tab'] == 'delete_account') {
212213
$_REQUEST['id'] = intval($_REQUEST['id']);
213-
$id = substr($_REQUEST['id'], 6);
214+
$id = $_REQUEST['id'];
215+
214216
$sql = "DELETE FROM $tableBuyCourseTransference WHERE id='" . $id . "';";
215217
$res = Database::query($sql);
216218
if (!res) {

plugin/buy_courses/src/index.buycourses.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,18 @@
88

99
if ($guess_enable == "true" || isset($_SESSION['_user'])) {
1010
$title = $plugin->get_lang('CourseListOnSale');
11+
$templateName = $plugin->get_lang('BuyCourses');
1112

12-
echo '<div class="well sidebar-nav static">';
13-
echo '<h4>' . $title . '</h4>';
14-
echo '<ul class="nav nav-list">';
15-
echo '<li>';
16-
echo '<a href="src/list.php">' . $plugin->get_lang('BuyCourses') . '</a>';
17-
echo '</li>';
18-
if (api_is_platform_admin()) {
19-
echo '<li>';
20-
echo '<a href="src/configuration.php">' . $plugin->get_lang('ConfigurationOfCoursesAndPrices') . '</a>';
21-
echo '</li>';
22-
echo '<li>';
23-
echo '<a href="src/paymentsetup.php">' . $plugin->get_lang('ConfigurationOfPayments') . '</a>';
24-
echo '</li>';
25-
echo '<li>';
26-
echo '<a href="src/pending_orders.php">' . $plugin->get_lang('OrdersPendingOfPayment') . '</a>';
27-
echo '</li>';
28-
}
29-
echo '</ul>';
30-
echo '</div>';
13+
$tpl = new Template($templateName);
14+
$tpl->assign('isAdmin', api_is_platform_admin());
15+
$tpl->assign('title', $title);
16+
$tpl->assign('BuyCourses', $templateName);
17+
$tpl->assign('ConfigurationOfCoursesAndPrices', $plugin->get_lang('ConfigurationOfCoursesAndPrices'));
18+
$tpl->assign('ConfigurationOfPayments', $plugin->get_lang('ConfigurationOfPayments'));
19+
$tpl->assign('OrdersPendingOfPayment', $plugin->get_lang('OrdersPendingOfPayment'));
20+
$listing_tpl = 'buy_courses/view/index.tpl';
21+
$content = $tpl->fetch($listing_tpl);
22+
$tpl->assign('content', $content);
23+
$tpl->display_one_col_template();
3124
}
3225

plugin/buy_courses/src/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

plugin/buy_courses/src/inscription.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if (!empty($_POST['language'])) { //quick hack to adapt the registration form result to the selected registration language
1414
$_GET['language'] = $_POST['language'];
1515
}
16-
require_once '../../main/inc/global.inc.php';
16+
require_once '../config.php';
1717
require_once api_get_path(CONFIGURATION_PATH) . 'profile.conf.php';
1818
require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
1919

0 commit comments

Comments
 (0)