diff --git a/plugin/buy_courses/database.php b/plugin/buy_courses/database.php index 7209a36a67..d8e83f1928 100644 --- a/plugin/buy_courses/database.php +++ b/plugin/buy_courses/database.php @@ -12,9 +12,9 @@ $sql = "CREATE TABLE IF NOT EXISTS $table ( id_course INT unsigned NOT NULL DEFAULT '0', code VARCHAR(40), title VARCHAR(250), - visible CHAR(2) NOT NULL DEFAULT '', + visible int(1), price FLOAT(11,2) NOT NULL DEFAULT '0', - synchronized CHAR(2) NOT NULL DEFAULT '')"; + sync int(1))"; Database::query($sql); $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); $sql = "SELECT id, code, title FROM $tableCourse"; diff --git a/plugin/buy_courses/js/funciones.js b/plugin/buy_courses/js/funciones.js index b55cd1e0d9..e69d30e7b0 100644 --- a/plugin/buy_courses/js/funciones.js +++ b/plugin/buy_courses/js/funciones.js @@ -46,8 +46,8 @@ $(document).ready(function () { }); - $('#sincronizar').click(function (e) { - $.post("function.php", {tab: "sincronizar"}, + $('#sync').click(function (e) { + $.post("function.php", {tab: "sync"}, function (data) { if (data.status == "false") { alert(data.contenido); @@ -71,7 +71,7 @@ $(document).ready(function () { var vmostrar = "NO"; } var vcategoria = $("#categoria_cursos").attr("value"); - $.post("function.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria}, + $.post("function.php", {tab: "courses_filter", course: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria}, function (data) { if (data.status == "false") { alert(data.contenido); @@ -86,11 +86,11 @@ $(document).ready(function () { e.stopPropagation(); }); - $("#save_money").click(function (e) { - var tipo_moneda = $("#tipo_moneda").attr("value"); - $.post("function.php", {tab: "guardar_moneda", moneda: tipo_moneda}, + $("#save_currency").click(function (e) { + var currency_type = $("#currency_type").attr("value"); + $.post("function.php", {tab: "save_currency", currency: currency_type}, function (data) { - alert(data.contenido); + alert(data.content); }, "json"); e.preventDefault(); @@ -106,9 +106,9 @@ $(document).ready(function () { } else { var vsandbox = "NO"; } - $.post("function.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox}, + $.post("function.php", {tab: "save_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox}, function (data) { - alert(data.contenido); + alert(data.content); }, "json"); e.preventDefault(); @@ -143,13 +143,13 @@ $(document).ready(function () { }); $("#cancelapedido").click(function (e) { - $.post("function.php", {tab: "borrar_variables"}); + $.post("function.php", {tab: "unset_variables"}); window.location.replace("list.php"); }); - $(".borrar_pedido").click(function (e) { + $(".clear_order").click(function (e) { var vid = $(this).parent().attr("id"); - $.post("function.php", {tab: "borrar_pedido", id: vid}, + $.post("function.php", {tab: "clear_order", id: vid}, function (data) { location.reload(); }, "json"); @@ -158,9 +158,9 @@ $(document).ready(function () { e.stopPropagation(); }); - $(".confirmar_pedido").click(function (e) { + $(".confirm_order").click(function (e) { var vid = $(this).parent().attr("id"); - $.post("function.php", {tab: "confirmar_pedido", id: vid}, + $.post("function.php", {tab: "confirm_order", id: vid}, function (data) { location.reload(); }, "json"); @@ -169,32 +169,6 @@ $(document).ready(function () { e.stopPropagation(); }); - $(".setting_tpv").click(function () { - var vcod = $(this).attr("id"); - $.post("function.php", {tab: "cargar_tpv_configuracion", cod: vcod}, - function (data) { - $("#resultado_tpv").html(data.contenido); - $("#guardar_datos_tpv").click(function (e) { - var vcod = $("#conf_tpv").attr("value"); - var num = $("#num_parametros").attr("value"); - var vaction = $("#action").attr("value"); - var array = []; - for (var i = 0; i < num; i++) { - var selector = '#valor_tpv' + i; - array.push($(selector).attr("value")); - } - $.post("function.php", {tab: "save_tpv", cod: vcod, nump: num, action: vaction, parametros: array}, - function (data) { - alert(data.contenido); - $("#resultado_tpv").html(""); - }, "json"); - - e.preventDefault(); - e.stopPropagation(); - }); - }, "json"); - }); - $(".slt_tpv").change(function () { var vcod = $(this).attr("value"); $.post("function.php", {tab: "activar_tpv", cod: vcod}); diff --git a/plugin/buy_courses/lang/english.php b/plugin/buy_courses/lang/english.php index 2e051170da..bf8bbf21ad 100644 --- a/plugin/buy_courses/lang/english.php +++ b/plugin/buy_courses/lang/english.php @@ -1,27 +1,29 @@ - */ - //Needed in order to show the plugin title -$strings['plugin_title'] = "Buy Courses"; +$strings['plugin_title'] = "Comprar cursos"; $strings['plugin_comment'] = "Configurar precios, tipos de pago, visibilidad de cursos."; $strings['Visible'] = "Mostrar en el listado"; $strings['Options'] = "Opciones"; $strings['Price'] = "Precio"; -$strings['sincronizar'] = "Sincronizar cursos de la base de datos"; +$strings['SyncCourseDatabase'] = "Sincronizar cursos de la base de datos"; $strings['Private'] = "Privado - acceso autorizado sólo para los miembros del curso"; $strings['CourseVisibilityClosed'] = "Cerrado - no hay acceso a este curso"; $strings['OpenToThePlatform'] = "Abierto - acceso autorizado sólo para los usuarios registrados en la plataforma"; $strings['OpenToTheWorld'] = "Público - acceso autorizado a cualquier persona"; +$strings['bc_setting_courses_available'] = "Configuración de cursos disponibles"; +$strings['bc_setting_pay'] = "Configuración pagos"; + $strings['Description'] = "Descripción"; $strings['Buy'] = "Comprar"; +$strings['Filtro_buscar'] = "Filtro de busqueda"; +$strings['Curso'] = "Curso"; +$strings['Price_Maximum'] = "Precio mayor de"; +$strings['Price_Minimum'] = "Precio menor de"; +$strings['Mostrar_disponibles'] = "Mostrar cursos disponibles"; +$strings['Categorias'] = "Categorias"; $strings['paypal_enable'] = "Habilitar PayPal"; $strings['tarjet_credit_enable'] = "Habilitar TPV"; @@ -42,4 +44,9 @@ $strings['bc_confi_index'] = 'Configuraci�n cursos y precio'; $strings['bc_pagos_index'] = 'Configuraci�n pagos'; $strings['bc_pending'] = 'Pedidos pendientes de pago'; -$strings['Ref_pedido'] = 'Referencia del pedido'; \ No newline at end of file +$strings['Ref_pedido'] = 'Referencia del pedido'; +$strings['transferencia_bancaria'] = 'Transferencia Bancaria'; +$strings['paypal'] = 'PayPal'; +$strings['confirmar_compra'] = 'Confirmar compra de curso'; + +$strings['The_User_Is_Already_Registered'] = 'El usuario ya está registrado'; diff --git a/plugin/buy_courses/lang/spanish.php b/plugin/buy_courses/lang/spanish.php index d65bc1298c..2fd61ff4a6 100644 --- a/plugin/buy_courses/lang/spanish.php +++ b/plugin/buy_courses/lang/spanish.php @@ -6,16 +6,13 @@ $strings['plugin_comment'] = "Configurar precios, tipos de pago, visibilidad de $strings['Visible'] = "Mostrar en el listado"; $strings['Options'] = "Opciones"; $strings['Price'] = "Precio"; -$strings['sincronizar'] = "Sincronizar cursos de la base de datos"; +$strings['SyncCourseDatabase'] = "Sincronizar cursos de la base de datos"; $strings['Private'] = "Privado - acceso autorizado sólo para los miembros del curso"; $strings['CourseVisibilityClosed'] = "Cerrado - no hay acceso a este curso"; $strings['OpenToThePlatform'] = "Abierto - acceso autorizado sólo para los usuarios registrados en la plataforma"; $strings['OpenToTheWorld'] = "Público - acceso autorizado a cualquier persona"; -$strings['bc_setting_courses_available'] = "Configuración de cursos disponibles"; -$strings['bc_setting_pay'] = "Configuración pagos"; - $strings['Description'] = "Descripción"; $strings['Buy'] = "Comprar"; $strings['Filtro_buscar'] = "Filtro de busqueda"; @@ -36,15 +33,27 @@ $strings['Cancelacionpedido'] = "El pedido se ha cancelado."; $strings['AlreadyBuy'] = "Ya est� matriculado en el curso"; $strings['Message_conf_transf'] = "Una vez confirmado, recibira un e-mail con los datos bancarios y una referencia del pedido."; $strings['bc_subject'] = "Confirmaci�n pedido de cursos"; -$strings['bc_message'] = "Estimado {{name}}.
En cuanto recibamos confirmación de pago procederemos a dar de alta su usuario en el curso {{curso}}.

No olvide indicar en el concepto de la transferencia el número de referencia del pedido:
{{reference}}
"; -$strings['bc_registrado'] = 'Ya se encuentra registrado en el curso'; $strings['bc_tmp_registrado'] = 'Se encuentra a la espera de recibir el pago'; -$strings['bc_confi_index'] = 'Configuraci�n cursos y precio'; -$strings['bc_pagos_index'] = 'Configuraci�n pagos'; -$strings['bc_pending'] = 'Pedidos pendientes de pago'; - $strings['Ref_pedido'] = 'Referencia del pedido'; $strings['transferencia_bancaria'] = 'Transferencia Bancaria'; $strings['paypal'] = 'PayPal'; $strings['confirmar_compra'] = 'Confirmar compra de curso'; + +$strings['TheUserIsAlreadyRegistered'] = 'El usuario ya está registrado'; +$strings['ProblemToSaveTheCurrencyType'] = 'Problema al guardar el tipo de moneda'; +$strings['ProblemToSaveThePaypalParameters'] = 'Problema para guardar los parametros de Paypal'; +$strings['ProblemToInsertANewAccount'] = 'Problemas para insertar una nueva cuenta'; +$strings['ProblemToDeleteTheAccount'] = 'Problema para eliminar la cuenta'; +$strings['ProblemToSaveTheMessage'] = 'Problema para guardar el mensaje'; +$strings['ProblemToSubscribeTheUser'] = 'Problema para suscribir el usuario'; +$strings['TheSubscriptionAndActivationWereDoneSuccessfully'] = 'La suscripción y la activación se realizaron con éxito.'; +$strings['TheUserIsAlreadyRegisteredInTheCourse'] = 'El usuario ya está registrado en el curso.'; +$strings['CourseListOnSale'] = 'Lista de cursos a la venta'; +$strings['BuyCourses'] = 'Comprar cursos'; +$strings['ConfigurationOfCoursesAndPrices'] = 'Configuración de los cursos y precios'; +$strings['ConfigurationOfPayments'] = 'Configuración de pagos'; +$strings['OrdersPendingOfPayment'] = 'Pedidos pendientes de pago'; +$strings['AvailableCoursesConfiguration'] = 'Configuración de cursos disponibles'; +$strings['PaymentsConfiguration'] = 'Configuración de Pagos'; +$strings['bc_message'] = "Estimado {{name}}.
En cuanto recibamos confirmación de pago procederemos a dar de alta su usuario en el curso {{curso}}.

No olvide indicar en el concepto de la transferencia el número de referencia del pedido:
{{reference}}
"; \ No newline at end of file diff --git a/plugin/buy_courses/resources/plugin.css b/plugin/buy_courses/resources/plugin.css index 48d9dbb0b4..2f1bbb03d7 100644 --- a/plugin/buy_courses/resources/plugin.css +++ b/plugin/buy_courses/resources/plugin.css @@ -15,7 +15,7 @@ table td.ta-center, table th.ta-center { vertical-align: middle; } -#tabla_cursos td input.price, #tabla_trasferencia td input, #tipo_moneda { +#tabla_cursos td input.price, #tabla_trasferencia td input, #currency_type { margin: 0; } diff --git a/plugin/buy_courses/src/ajax.php b/plugin/buy_courses/src/ajax.php index d131ad00fe..75332aea38 100644 --- a/plugin/buy_courses/src/ajax.php +++ b/plugin/buy_courses/src/ajax.php @@ -13,7 +13,7 @@ $course_info = api_get_course_info($_GET['code']); echo Display::tag('h2', $course_info['name']); echo '
'; -$sql = "SELECT * FROM $tbl_course_description WHERE c_id = " . $course_info['real_id'] . " AND session_id = 0 ORDER BY id"; +$sql = "SELECT * FROM $tbl_course_description WHERE c_id = " . intval($course_info['real_id']) . " AND session_id = 0 ORDER BY id"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { while ($description = Database::fetch_object($result)) { diff --git a/plugin/buy_courses/src/buy_course.lib.php b/plugin/buy_courses/src/buy_course.lib.php index 9067a6ffbb..2ef98e3fad 100644 --- a/plugin/buy_courses/src/buy_course.lib.php +++ b/plugin/buy_courses/src/buy_course.lib.php @@ -7,25 +7,28 @@ require_once '../../../main/inc/global.inc.php'; require_once '../config.php'; require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php'; -function sincronizar() +function sync() { - $sql = "UPDATE plugin_buycourses SET synchronized='NO'"; + $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); + $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); + + $sql = "UPDATE $tableBuyCourse SET sync = 0"; Database::query($sql); - $sql = "SELECT id FROM course"; + $sql = "SELECT id FROM $tableCourse"; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { - $sql = "SELECT 1 FROM plugin_buycourses WHERE id_course='" . $row['id'] . "';"; - $tmp = Database::query($sql); + $sql = "SELECT 1 FROM $tableBuyCourse WHERE id_course='" . $row['id'] . "';"; + Database::query($sql); if (Database::affected_rows() > 0) { - $sql = "UPDATE plugin_buycourses SET synchronized='SI' WHERE id_course='" . $row['id'] . "';"; + $sql = "UPDATE $tableBuyCourse SET sync = 1 WHERE id_course='" . $row['id'] . "';"; Database::query($sql); } else { - $sql = "INSERT INTO plugin_buycourses (id_course,visible,synchronized) VALUES ('" . $row['id'] . "','NO','SI');"; + $sql = "INSERT INTO $tableBuyCourse (id_course, visible, sync) VALUES ('" . $row['id'] . "', 0, 1);"; Database::query($sql); } } - $sql = "DELETE FROM plugin_buycourses WHERE synchronized='NO';"; + $sql = "DELETE FROM $tableBuyCourse WHERE sync = 0;"; Database::query($sql); } @@ -33,67 +36,92 @@ function listCourses() { $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); - $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM $tableBuyCourse a, $tableCourse b WHERE a.id_course = b.id;"; + $sql = "SELECT a.id_course, a.visible, a.price, b.* + FROM $tableBuyCourse a, $tableCourse b + WHERE a.id_course = b.id;"; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { $aux[] = $row; } + return $aux; } -function listado_cursos_user() +function userCourseList() { - $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM plugin_buycourses a, course b WHERE a.id_course=b.id AND a.visible='SI';"; + $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); + $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); + $tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); + + $sql = "SELECT a.id_course, a.visible, a.price, b.* + FROM $tableBuyCourse a, $tableCourse b + WHERE a.id_course = b.id AND a.visible = 1;"; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { - //Comprobamos profesor - $sql = "SELECT lastname,firstname FROM course_rel_user a, user b WHERE a.course_code='" . $row['code'] . "' AND a.role<>'' AND a.role<>'NULL' AND a.user_id=b.user_id;"; + //check teacher + $sql = "SELECT lastname, firstname + FROM course_rel_user a, user b + WHERE a.course_code='" . $row['code'] . "' + AND a.role<>'' AND a.role<>'NULL' + AND a.user_id=b.user_id;"; + $tmp = Database::query($sql); - $fila = Database::fetch_assoc($tmp); - $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname']; - //Comprobamos si el alumno est� matriculado + $rowTmp = Database::fetch_assoc($tmp); + $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; + //check if the user is enrolled if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { - $sql = "SELECT 1 FROM course_rel_user WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';"; - $tmp = Database::query($sql); + $sql = "SELECT 1 FROM $tableCourseRelUser + WHERE course_code='" . $row['code'] . "' + AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + Database::query($sql); if (Database::affected_rows() > 0) { - $row['matriculado'] = "SI"; + $row['enrolled'] = "YES"; } else { - $sql = "SELECT 1 FROM plugin_bc_temporal WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';"; - $tmp2 = Database::query($sql); + $sql = "SELECT 1 FROM $tableBuyCourseTemporal + WHERE course_code='" . $row['code'] . "' + AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + Database::query($sql); if (Database::affected_rows() > 0) { - $row['matriculado'] = "TMP"; + $row['enrolled'] = "TMP"; } else { - $row['matriculado'] = "NO"; + $row['enrolled'] = "NO"; } } } else { - $sql = "SELECT 1 FROM plugin_bc_temporal WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';"; - $tmp2 = Database::query($sql); + $sql = "SELECT 1 FROM $tableBuyCourseTemporal + WHERE course_code='" . $row['code'] . "' + AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + Database::query($sql); if (Database::affected_rows() > 0) { - $row['matriculado'] = "TMP"; + $row['enrolled'] = "TMP"; } else { - $row['matriculado'] = "NO"; + $row['enrolled'] = "NO"; } } - //Comprobamos imagen + //check images if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) { - $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png"; + $row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png"; } else { - $row['imagen_curso'] = "main/img/without_picture.png"; + $row['course_img'] = "main/img/without_picture.png"; } $row['price'] = number_format($row['price'], 2, '.', ' '); $aux[] = $row; } + return $aux; } -function comprueba_curso_user($course, $user) +function checkUserCourse($course, $user) { - $sql = "SELECT 1 FROM course_rel_user WHERE course_code='" . $course . "' AND user_id='" . $user . "';"; - $tmp = Database::query($sql); + $tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $sql = "SELECT 1 FROM $tableCourseRelUser + WHERE course_code='" . $course . "' + AND user_id='" . $user . "';"; + Database::query($sql); if (Database::affected_rows() > 0) { return true; } else { @@ -101,10 +129,13 @@ function comprueba_curso_user($course, $user) } } -function comprueba_curso_user_transf($course, $user) +function checkUserCourseTransference($course, $user) { - $sql = "SELECT 1 FROM plugin_bc_temporal WHERE course_code='" . $course . "' AND user_id='" . $user . "';"; - $tmp = Database::query($sql); + $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); + $sql = "SELECT 1 FROM $tableBuyCourseTemporal + WHERE course_code='" . $course . "' + AND user_id='" . $user . "';"; + Database::query($sql); if (Database::affected_rows() > 0) { return true; } else { @@ -112,24 +143,26 @@ function comprueba_curso_user_transf($course, $user) } } -function listado_categorias() +function listCategories() { - $sql = "SELECT code, name FROM course_category"; + $tblCourseCategory = Database::get_main_table(TABLE_MAIN_CATEGORY); + $sql = "SELECT code, name FROM $tblCourseCategory"; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { $aux[] = $row; } + return $aux; } /** * Return an icon representing the visibility of the course */ -function get_course_visibility_icon($v) +function getCourseVisibilityIcon($option) { $style = 'margin-bottom:-5px;margin-right:5px;'; - switch ($v) { + switch ($option) { case 0: return Display::return_icon('bullet_red.gif', get_lang('CourseVisibilityClosed'), array('style' => $style)); break; @@ -147,109 +180,118 @@ function get_course_visibility_icon($v) } } -function listado_monedas() +function listCurrency() { - $sql = "SELECT * FROM plugin_buycourses_countries ORDER BY country_name ASC"; + $tableBuyCourseCountry = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY); + $sql = "SELECT * FROM $tableBuyCourseCountry + ORDER BY country_name ASC"; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { $aux[] = $row; } + return $aux; } function listAccounts() { - $sql = "SELECT * FROM plugin_bc_transf"; + $tableBuyCourseTransference = Database::get_main_table(TABLE_BUY_COURSE_TRANSFERENCE); + $sql = "SELECT * FROM $tableBuyCourseTransference"; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { $aux[] = $row; } + return $aux; } -function parametros_paypal() +function paypalParameters() { - $sql = "SELECT * FROM plugin_bc_paypal"; + $tableBuyCoursePaypal = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL); + $sql = "SELECT * FROM $tableBuyCoursePaypal"; $res = Database::query($sql); - $aux = array(); $row = Database::fetch_assoc($res); + return $row; } -function parametros_transf() +function transferenceParameters() { - $sql = "SELECT * FROM plugin_bc_transf"; + $tableBuyCourseTransference = Database::get_main_table(TABLE_BUY_COURSE_TRANSFERENCE); + $sql = "SELECT * FROM $tableBuyCourseTransference"; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { $aux[] = $row; } + return $aux; } -function busca_moneda() +function findCurrency() { - $sql = "SELECT * FROM plugin_buycourses_countries WHERE status='1';"; + $tableBuyCourseCountry = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY); + $sql = "SELECT * FROM $tableBuyCourseCountry WHERE status='1';"; $res = Database::query($sql); - $aux = array(); $row = Database::fetch_assoc($res); + return $row['currency_code']; } -function info_curso($code) +function courseInfo($code) { - $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM plugin_buycourses a, course b WHERE a.id_course=b.id AND a.visible='SI' AND b.id='" . $code . "';"; + $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); + $tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $tableUser = Database::get_main_table(TABLE_MAIN_USER); + + $sql = "SELECT a.id_course, a.visible, a.price, b.* + FROM $tableBuyCourse a, course b + WHERE a.id_course=b.id + AND a.visible = 1 + AND b.id = '" . $code . "';"; $res = Database::query($sql); - $aux = array(); $row = Database::fetch_assoc($res); - //Comprobamos profesor - $sql = "SELECT lastname,firstname FROM course_rel_user a, user b WHERE a.course_code='" . $row['code'] . "' AND a.role<>'' AND a.role<>'NULL' AND a.user_id=b.user_id;"; + // Check teacher + $sql = "SELECT lastname, firstname + FROM $tableCourseRelUser a, $tableUser b + WHERE a.course_code = '" . $row['code'] . "' + AND a.role <> '' AND a.role <> 'NULL' + AND a.user_id = b.user_id;"; $tmp = Database::query($sql); - $fila = Database::fetch_assoc($tmp); - $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname']; - //Comprobamos si el alumno est� matriculado + $rowTmp = Database::fetch_assoc($tmp); + $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; + //Check if student is enrolled if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { - $sql = "SELECT 1 FROM course_rel_user WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';"; - $tmp = Database::query($sql); + $sql = "SELECT 1 FROM $tableCourseRelUser + WHERE course_code='" . $row['code'] . "' + AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + Database::query($sql); if (Database::affected_rows() > 0) { - $row['matriculado'] = "SI"; + $row['enrolled'] = "YES"; } else { - $row['matriculado'] = "NO"; + $row['enrolled'] = "NO"; } } else { - $row['matriculado'] = "NO"; + $row['enrolled'] = "NO"; } - //Comprobamos imagen + //check img if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) { - $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png"; + $row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png"; } else { - $row['imagen_curso'] = "main/img/without_picture.png"; + $row['course_img'] = "main/img/without_picture.png"; } $row['price'] = number_format($row['price'], 2, '.', ' '); return $row; } - -/** - * function texto_aleatorio (integer $long = 5, boolean $lestras_min = true, boolean $letras_max = true, boolean $num = true)) - * - * Permite generar contrasenhas de manera aleatoria. - * - * @$long: Especifica la longitud de la contrasenha - * @$letras_min: Podra usar letas en minusculas - * @$letras_max: Podra usar letas en mayusculas - * @$num: Podra usar numeros - * - * return string - */ -function texto_aleatorio($long = 6, $letras_min = true, $letras_max = true, $num = true) +function randomText($long = 6, $minWords = true, $maxWords = true, $number = true) { - $salt = $letras_min ? 'abchefghknpqrstuvwxyz' : ''; - $salt .= $letras_max ? 'ACDEFHKNPRSTUVWXYZ' : ''; - $salt .= $num ? (strlen($salt) ? '2345679' : '0123456789') : ''; + $salt = $minWords ? 'abchefghknpqrstuvwxyz' : ''; + $salt .= $maxWords ? 'ACDEFHKNPRSTUVWXYZ' : ''; + $salt .= $number ? (strlen($salt) ? '2345679' : '0123456789') : ''; if (strlen($salt) == 0) { return ''; @@ -261,8 +303,8 @@ function texto_aleatorio($long = 6, $letras_min = true, $letras_max = true, $num srand((double)microtime() * 1000000); while ($i < $long) { - $num = rand(0, strlen($salt) - 1); - $str .= substr($salt, $num, 1); + $number = rand(0, strlen($salt) - 1); + $str .= substr($salt, $number, 1); $i++; } @@ -271,26 +313,30 @@ function texto_aleatorio($long = 6, $letras_min = true, $letras_max = true, $num function calculateReference() { - $sql = "SELECT MAX(cod) FROM plugin_bc_temporal"; + $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); + $sql = "SELECT MAX(cod) as cod FROM $tableBuyCourseTemporal"; $res = Database::query($sql); $row = Database::fetch_assoc($res); - if ($row['MAX(cod)'] != '') { - $reference = $row['MAX(cod)']; + if ($row['cod'] != '') { + $reference = $row['cod']; } else { $reference = '1'; } - $randomText = texto_aleatorio(); + $randomText = randomText(); $reference .= $randomText; + return $reference; } -function listado_pendientes() +function pendingList() { - $sql = "SELECT * FROM plugin_bc_temporal;"; + $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); + $sql = "SELECT * FROM $tableBuyCourseTemporal;"; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { $aux[] = $row; } + return $aux; } \ No newline at end of file diff --git a/plugin/buy_courses/src/configuration.php b/plugin/buy_courses/src/configuration.php index aec7563f84..de4694beae 100644 --- a/plugin/buy_courses/src/configuration.php +++ b/plugin/buy_courses/src/configuration.php @@ -6,35 +6,37 @@ require_once dirname(__FILE__) . '/buy_course.lib.php'; require_once '../../../main/inc/global.inc.php'; require_once 'buy_course_plugin.class.php'; +$plugin = Buy_CoursesPlugin::create(); + $_cid = 0; -$interbreadcrumb[] = array("url" => "list.php", "name" => 'Listado de cursos a la venta'); -$interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => get_lang('Configuración pagos')); +$interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); +$interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => get_lang('Configuration')); -$tpl = new Template('Configuración de cursos disponibles'); +$tpl = new Template('availableCourses'); $teacher = api_is_platform_admin(); api_protect_course_script(true); if ($teacher) { - // SINCRONIZAR TABLA DE CURSOS CON TABLA DEL PLUGIN - sincronizar(); - $visibilidad = array(); - $visibilidad[] = get_course_visibility_icon('0'); - $visibilidad[] = get_course_visibility_icon('1'); - $visibilidad[] = get_course_visibility_icon('2'); - $visibilidad[] = get_course_visibility_icon('3'); + // sync course table with the plugin + sync(); + $visibility = array(); + $visibility[] = getCourseVisibilityIcon('0'); + $visibility[] = getCourseVisibilityIcon('1'); + $visibility[] = getCourseVisibilityIcon('2'); + $visibility[] = getCourseVisibilityIcon('3'); $coursesList = listCourses(); - $ruta = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png'; - $ruta2 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/save.png'; - $tipo_moneda = busca_moneda(); + $confirmationImgPath = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png'; + $saveImgPath = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/save.png'; + $currencyType = findCurrency(); $tpl->assign('server', $_configuration['root_web']); - $tpl->assign('cursos', $coursesList); - $tpl->assign('visibilidad', $visibilidad); - $tpl->assign('ruta_imagen_ok', $ruta); - $tpl->assign('ruta_imagen_save', $ruta2); - $tpl->assign('moneda', $tipo_moneda); + $tpl->assign('courses', $coursesList); + $tpl->assign('visibility', $visibility); + $tpl->assign('confirmation_img', $confirmationImgPath); + $tpl->assign('save_img', $saveImgPath); + $tpl->assign('currency', $currencyType); $listing_tpl = 'buy_courses/view/configuration.tpl'; $content = $tpl->fetch($listing_tpl); diff --git a/plugin/buy_courses/src/error.php b/plugin/buy_courses/src/error.php index 6d714d551a..c81e2f234d 100644 --- a/plugin/buy_courses/src/error.php +++ b/plugin/buy_courses/src/error.php @@ -1,18 +1,18 @@ \ No newline at end of file diff --git a/plugin/buy_courses/src/function.php b/plugin/buy_courses/src/function.php index 5025bcc6fc..9faa85599b 100644 --- a/plugin/buy_courses/src/function.php +++ b/plugin/buy_courses/src/function.php @@ -17,105 +17,68 @@ $tableUser = Database::get_main_table(TABLE_MAIN_USER); $plugin = Buy_CoursesPlugin::create(); $buy_name = $plugin->get_lang('Buy'); -function quitar_html($cadena) -{ - $txt = str_replace("
", chr(13) . chr(10), $cadena); - $txt = str_replace("
", chr(13) . chr(10), $txt); - $txt = str_replace("
  •  ", chr(13) . chr(10) . " � ", $txt); - $txt = str_replace("
  • ", chr(13) . chr(10) . "� ", $txt); - $txt = str_replace("
    ", chr(13) . chr(10), $txt); - $txt = str_replace("

    ", chr(13) . chr(10), $txt); - $txt = str_replace("

    ", "", $txt); - $txt = str_replace("", chr(13) . chr(10), $txt); - $txt = str_replace("", " algo ", $txt); - $txt = str_replace("", chr(13) . chr(10), $txt); - $txt = strip_tags($txt); - $txt = str_replace(" ", " ", $txt); - $txt = str_replace("Á", "�", $txt); - $txt = str_replace("á", "�", $txt); - $txt = str_replace("É", "�", $txt); - $txt = str_replace("é", "�", $txt); - $txt = str_replace("Í", "�", $txt); - $txt = str_replace("í", "�", $txt); - $txt = str_replace("Ó", "�", $txt); - $txt = str_replace("ó", "�", $txt); - $txt = str_replace("Ú", "�", $txt); - $txt = str_replace("ú", "�", $txt); - $txt = str_replace("Ñ", "�", $txt); - $txt = str_replace("ñ", "�", $txt); - $txt = str_replace(""", '"', $txt); - $txt = str_replace("ª", '�', $txt); - $txt = str_replace("º", '�', $txt); - $txt = str_replace("&", '&', $txt); - $txt = str_replace("•", '�', $txt); - $txt = str_replace("€", '�', $txt); - - return $txt; -} - -if ($_REQUEST['tab'] == 'sincronizar') { - $sql = "SELECT code,title FROM $tableCourse;"; +if ($_REQUEST['tab'] == 'sync') { + $sql = "SELECT code, title FROM $tableCourse;"; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { $aux_code .= $row['code']; $aux_title .= $row['title']; } - echo json_encode(array("status" => "true", "contenido" => $contenido)); + echo json_encode(array("status" => "true", "content" => $content)); } -if ($_REQUEST['tab'] == 'filtro_cursos') { - $curso = $_REQUEST['curso']; - $priceMin = $_REQUEST['pricemin']; - $priceMax = $_REQUEST['pricemax']; - $mostrar = $_REQUEST['mostrar']; - $categoria = $_REQUEST['categoria']; - $server = $_configuration['root_web']; - - $filtro = ''; - if ($curso != '') { - $filtro .= "b.title LIKE '%" . $curso . "%'"; +if ($_REQUEST['tab'] == 'courses_filter') { + $course = Database::escape_string($_REQUEST['course']); + $priceMin = Database::escape_string($_REQUEST['pricemin']); + $priceMax = Database::escape_string($_REQUEST['pricemax']); + $show = Database::escape_string($_REQUEST['show']); + $category = Database::escape_string($_REQUEST['category']); + $server = Database::escape_string($_configuration['root_web']); + + $filter = ''; + if ($course != '') { + $filter .= "b.title LIKE '%" . $course . "%'"; } if ($priceMin != '') { - if ($filtro == '') { - $filtro .= "a.price >= '" . $priceMin . "'"; + if ($filter == '') { + $filter .= "a.price >= '" . $priceMin . "'"; } else { - $filtro .= " AND a.price >= '" . $priceMin . "'"; + $filter .= " AND a.price >= '" . $priceMin . "'"; } } if ($priceMax != '') { - if ($filtro == '') { - $filtro .= "a.price <= '" . $priceMax . "'"; + if ($filter == '') { + $filter .= "a.price <= '" . $priceMax . "'"; } else { - $filtro .= " AND a.price <= '" . $priceMax . "'"; + $filter .= " AND a.price <= '" . $priceMax . "'"; } } - if ($categoria != '') { - if ($filtro == '') { - $filtro .= "b.category_code='" . $categoria . "'"; + if ($category != '') { + if ($filter == '') { + $filter .= "b.category_code='" . $category . "'"; } else { - $filtro .= " AND b.category_code='" . $categoria . "'"; + $filter .= " AND b.category_code='" . $category . "'"; } } - if ($filtro == '') { + if ($filter == '') { $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM $tableBuyCourse a, $tableCourse b WHERE a.id_course = b.id - AND a.visible = 'SI';"; + AND a.visible = 1;"; } else { $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM $tableBuyCourse a, $tableCourse b - WHERE a.id_course=b.id - AND a.visible='SI' AND " . $filtro . ";"; + WHERE a.id_course = b.id + AND a.visible = 1 AND " . $filter . ";"; } - //echo $sql; $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { - //Comprobamos profesor + //Check teacher $sql = "SELECT lastname, firstname FROM $tableCourseRelUser a, $tableUser b WHERE a.course_code = '" . $row['code'] . "' @@ -124,94 +87,94 @@ if ($_REQUEST['tab'] == 'filtro_cursos') { AND a.user_id = b.user_id;"; $tmp = Database::query($sql); - $fila = Database::fetch_assoc($tmp); - $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname']; - //Comprobamos si el alumno est� matriculado + $rowTmp = Database::fetch_assoc($tmp); + $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; + //Check if the student is enrolled if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { $sql = "SELECT 1 FROM $tableCourseRelUser - WHERE course_code='" . $row['code'] . "' - AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + WHERE course_code = '" . $row['code'] . "' + AND user_id = " . intval($_SESSION['_user']['user_id']) . ";"; $tmp = Database::query($sql); if (Database::affected_rows() > 0) { - $row['matriculado'] = "SI"; + $row['enrolled'] = "SI"; } else { - $row['matriculado'] = "NO"; + $row['enrolled'] = "NO"; } } else { - $row['matriculado'] = "NO"; + $row['enrolled'] = "NO"; } //Comprobamos imagen if (file_exists("../../../courses/" . $row['code'] . "/course-pic85x85.png")) { - $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png"; + $row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png"; } else { - $row['imagen_curso'] = "main/img/without_picture.png"; + $row['course_img'] = "main/img/without_picture.png"; } - if ($mostrar == "SI" && $row['matriculado'] == "SI") { - //No hacemos nada + if ($show == "YES" && $row['enrolled'] == "YES") { + ; } else { $aux[] = $row; } } - foreach ($aux as $curso) { //{% for curso in cursos %} - $contenido .= '

    '; - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= ''; - $contenido .= ''; - $contenido .= ''; - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= '

    ' . $curso['title'] . '

    '; - $contenido .= '
    Profesor: ' . $curso['profesor'] . '
    '; - $contenido .= '
    '; - if ($curso['matriculado'] == "SI") { //{% if curso.matriculado == "SI" %} - $contenido .= 'Ya se encuentra registrado en el curso'; - } //{% endif %} - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= '
    ' . $curso['price'] . ' €
    '; - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= '' . get_lang('Description') . ' '; - if ($curso['matriculado'] != "SI") { //{% if curso.matriculado != "SI" %} - $contenido .= '' . $buy_name . ''; - } //{% endif %} - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= '
    '; - $contenido .= '
    '; - } //{% endfor %} - - echo json_encode(array("status" => "true", "contenido" => $contenido)); + foreach ($aux as $course) { + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= ''; + $content .= ''; + $content .= ''; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '

    ' . $course['title'] . '

    '; + $content .= '
    ' . get_lang('teacher') . ': ' . $course['teacher'] . '
    '; + $content .= '
    '; + if ($course['enrolled'] == "YES") { + $content .= '' . $plugin->get_lang('TheUserIsAlreadyRegistered') . ''; + } + $content .= '
    '; + $content .= '
    '; + $content .= '
    ' . $course['price'] . ' €
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '' . get_lang('Description') . ' '; + if ($course['enrolled'] != "YES") { + $content .= '' . $buy_name . ''; + } + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + } + + echo json_encode(array("status" => "true", "content" => $content)); } -if ($_REQUEST['tab'] == 'guardar_moneda') { - $id = $_REQUEST['moneda']; +if ($_REQUEST['tab'] == 'save_currency') { + $id = $_REQUEST['currency']; $sql = "UPDATE $tableBuyCourseCountry SET status='0';"; $res = Database::query($sql); $sql = "UPDATE $tableBuyCourseCountry SET status='1' WHERE id_country='" . $id . "';"; $res = Database::query($sql); if (!res) { - $contenido = 'Problema al guardar el tipo de moneda: ' . Database::error(); - echo json_encode(array("status" => "false", "contenido" => $contenido)); + $content = $plugin->get_lang('ProblemToSaveTheCurrencyType') . Database::error(); + echo json_encode(array("status" => "false", "content" => $content)); } else { - $contenido = 'Guardado'; - echo json_encode(array("status" => "true", "contenido" => $contenido)); + $content = get_lang('Saved'); + echo json_encode(array("status" => "true", "content" => $content)); } } -if ($_REQUEST['tab'] == 'guardar_paypal') { - $username = mysql_real_escape_string($_REQUEST['username']); - $password = mysql_real_escape_string($_REQUEST['password']); - $signature = mysql_real_escape_string($_REQUEST['signature']); - $sandbox = mysql_real_escape_string($_REQUEST['sandbox']); +if ($_REQUEST['tab'] == 'save_paypal') { + $username = Database::escape_string($_REQUEST['username']); + $password = Database::escape_string($_REQUEST['password']); + $signature = Database::escape_string($_REQUEST['signature']); + $sandbox = Database::escape_string($_REQUEST['sandbox']); $sql = "UPDATE $tableBuyCoursePaypal SET sandbox = '" . $sandbox . "', username = '" . $username . "', @@ -221,177 +184,126 @@ if ($_REQUEST['tab'] == 'guardar_paypal') { $res = Database::query($sql); if (!res) { - $contenido = 'Problema al guardar los parametros de paypal: ' . Database::error(); - echo json_encode(array("status" => "false", "contenido" => $contenido)); + $content = $plugin->get_lang('ProblemToSaveThePaypalParameters') . Database::error(); + echo json_encode(array("status" => "false", "content" => $content)); } else { - $contenido = 'Guardado'; - echo json_encode(array("status" => "true", "contenido" => $contenido)); + $content = get_lang('Saved'); + echo json_encode(array("status" => "true", "content" => $content)); } } if ($_REQUEST['tab'] == 'add_account') { - $name = mysql_real_escape_string($_REQUEST['name']); - $account = mysql_real_escape_string($_REQUEST['account']); - $swift = mysql_real_escape_string($_REQUEST['swift']); + $name = Database::escape_string($_REQUEST['name']); + $account = Database::escape_string($_REQUEST['account']); + $swift = Database::escape_string($_REQUEST['swift']); $sql = "INSERT INTO $tableBuyCourseTransference (name, account, swift) VALUES ('" . $name . "','" . $account . "', '" . $swift . "');"; $res = Database::query($sql); if (!res) { - $contenido = 'Problema al insertar nueva cuenta: ' . Database::error(); - echo json_encode(array("status" => "false", "contenido" => $contenido)); + $content = $plugin->get_lang('ProblemToInsertANewAccount') . Database::error(); + echo json_encode(array("status" => "false", "content" => $content)); } else { - $contenido = 'Guardado'; - echo json_encode(array("status" => "true", "contenido" => $contenido)); + $content = get_lang('Saved'); + echo json_encode(array("status" => "true", "content" => $content)); } } if ($_REQUEST['tab'] == 'delete_account') { + $_REQUEST['id'] = intval($_REQUEST['id']); $id = substr($_REQUEST['id'], 6); $sql = "DELETE FROM $tableBuyCourseTransference WHERE id='" . $id . "';"; $res = Database::query($sql); if (!res) { - $contenido = 'Problema al borrar la cuenta: ' . Database::error(); - echo json_encode(array("status" => "false", "contenido" => $contenido)); + $content = $plugin->get_lang('ProblemToDeleteTheAccount') . Database::error(); + echo json_encode(array("status" => "false", "content" => $content)); } else { - $contenido = 'Guardado'; - echo json_encode(array("status" => "true", "contenido" => $contenido)); + $content = get_lang('Saved'); + echo json_encode(array("status" => "true", "content" => $content)); } } if ($_REQUEST['tab'] == 'save_mod') { + $_REQUEST['id'] = intval($_REQUEST['id']); $id = substr($_REQUEST['id'], 5); - $visible = ($_REQUEST['visible'] == "checked") ? ('SI') : ('NO'); + $visible = ($_REQUEST['visible'] == "checked") ? 1 : 0; $price = mysql_real_escape_string($_REQUEST['price']); $obj = $_REQUEST['obj']; $sql = "UPDATE $tableBuyCourse - SET visible='" . $visible . "', - price='" . $price . "' - WHERE id_course='" . $id . "';"; + SET visible = " . $visible . ", + price = '" . $price . "' + WHERE id_course = '" . $id . "';"; $res = Database::query($sql); if (!res) { - $contenido = 'Problema al guardar el mensaje: ' . Database::error(); - echo json_encode(array("status" => "false", "contenido" => $contenido)); + $content = $plugin->get_lang('ProblemToSaveTheMessage') . Database::error(); + echo json_encode(array("status" => "false", "content" => $content)); } else { echo json_encode(array("status" => "true", "id" => $id)); } } -if ($_REQUEST['tab'] == 'borrar_variables') { +if ($_REQUEST['tab'] == 'unset_variables') { unset($_SESSION['bc_user_id']); - unset($_SESSION['bc_registrado']); - unset($_SESSION['bc_curso_code']); - unset($_SESSION['bc_curso_title']); + unset($_SESSION['bc_registered']); + unset($_SESSION['bc_course_code']); + unset($_SESSION['bc_course_title']); unset($_SESSION["Payment_Amount"]); unset($_SESSION["currencyCodeType"]); unset($_SESSION["PaymentType"]); unset($_SESSION["nvpReqArray"]); unset($_SESSION['TOKEN']); - $_SESSION['bc_exito'] = false; - $_SESSION['bc_mensaje'] = 'Cancelacionpedido'; + $_SESSION['bc_success'] = false; + $_SESSION['bc_message'] = 'CancelOrder'; unset($_SESSION['bc_url']); } -if ($_REQUEST['tab'] == 'borrar_pedido') { +if ($_REQUEST['tab'] == 'clear_order') { + $_REQUEST['id'] = intval($_REQUEST['id']); $id = substr($_REQUEST['id'], 6); $sql = "DELETE FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';"; $res = Database::query($sql); if (!res) { - $contenido = 'Problema al borrar la cuenta: ' . Database::error(); - echo json_encode(array("status" => "false", "contenido" => $contenido)); + $content = $plugin->get_lang('ProblemToDeleteTheAccount') . Database::error(); + echo json_encode(array("status" => "false", "content" => $content)); } else { - $contenido = 'Guardado'; - echo json_encode(array("status" => "true", "contenido" => $contenido)); + $content = get_lang('Saved'); + echo json_encode(array("status" => "true", "content" => $content)); } } -if ($_REQUEST['tab'] == 'confirmar_pedido') { +if ($_REQUEST['tab'] == 'confirm_order') { + $_REQUEST['id'] = intval($_REQUEST['id']); $id = substr($_REQUEST['id'], 6); $sql = "SELECT * FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); - $seguir = false; + $isAllowed = false; $user_id = $row['user_id']; $course_code = $row['course_code']; $all_course_information = CourseManager::get_course_information($course_code); if (CourseManager::subscribe_user($user_id, $course_code)) { - $seguir = true; + $isAllowed = true; } else { - $seguir = false; + $isAllowed = false; } - //Activamos al usuario su cuenta - if ($seguir) { + //Activate user account + if ($isAllowed) { // 1. set account inactive - $sql = "UPDATE $tableUser SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'"; + $sql = "UPDATE $tableUser SET active = '1' WHERE user_id = " . intval($_SESSION['bc_user_id']) . ""; Database::query($sql); $sql = "DELETE FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';"; $res = Database::query($sql); - $contenido = 'Se ha realizado con exito la subscripcion y activacion del usuario'; - echo json_encode(array("status" => "true", "contenido" => $contenido)); - } else { - $contenido = 'Problema subscribir al usuario '; - echo json_encode(array("status" => "false", "contenido" => $contenido)); - } -} - -if ($_REQUEST['tab'] == 'cargar_tpv_configuracion') { - $cod = substr($_REQUEST['cod'], 3); - - $contenido = ''; - $sql = "SELECT * FROM plugin_bc_tpv WHERE cod='" . $cod . "';"; - $res = Database::query($sql); - $row = Database::fetch_assoc($res); - - $parametros = explode(";", $row['parametros']); - $valores = explode(";", $row['valores']); - - $i = 0; - $contenido .= ""; - $contenido .= ""; - $contenido .= ""; - while ($i < count($parametros)) { - $contenido .= ""; - $i++; - } - $contenido .= ""; - $contenido .= ""; - $contenido .= "
     Configuración TPV " . $row['title'] . ":
    URL TPV:
    " . $parametros[$i] . ":
     "; - $contenido .= ""; - $contenido .= ""; - $contenido .= ""; - $contenido .= "
    "; - - echo json_encode(array("contenido" => $contenido)); -} - -if ($_REQUEST['tab'] == 'cargar_tpv_configuracion') { - $cod = $_REQUEST['cod']; - $sql = "UDPATE plugin_bc_tpv SET status='NO'"; - Database::query($sql); - $sql = "UPDATE plugin_bc_tpv SET status='SI' WHERE cod='" . $cod . "';"; - Database::query($sql); -} - -if ($_REQUEST['tab'] == 'save_tpv') { - $cod = $_REQUEST['cod']; - $nump = $_REQUEST['nump']; - $action = $_REQUEST['action']; - $parametros = $_REQUEST['parametros']; - - $valores = implode(";", $parametros); - $sql = "UPDATE plugin_bc_tpv SET action='" . $action . "', valores='" . $valores . "' WHERE cod='" . $cod . "';"; - $res = Database::query($sql); - if (!$res) { - $contenido = Database::error(); + $content = $plugin->get_lang('TheSubscriptionAndActivationWereDoneSuccessfully'); + echo json_encode(array("status" => "true", "content" => $content)); } else { - $contenido = "Guardado"; + $content = $plugin->get_lang('ProblemToSubscribeTheUser'); + echo json_encode(array("status" => "false", "content" => $content)); } - echo json_encode(array("contenido" => $contenido)); } \ No newline at end of file diff --git a/plugin/buy_courses/src/index.buycourses.php b/plugin/buy_courses/src/index.buycourses.php index 0d40962aed..9ece98c961 100644 --- a/plugin/buy_courses/src/index.buycourses.php +++ b/plugin/buy_courses/src/index.buycourses.php @@ -7,23 +7,23 @@ $plugin = Buy_CoursesPlugin::create(); $guess_enable = $plugin->get('unregistered_users_enable'); if ($guess_enable == "true" || isset($_SESSION['_user'])) { - $title = "Listado de cursos en venta"; + $title = $plugin->get_lang('CourseListOnSale'); echo ' \ No newline at end of file diff --git a/plugin/buy_courses/view/paymentsetup.tpl b/plugin/buy_courses/view/paymentsetup.tpl index 0b72a5f83c..49cba584c8 100644 --- a/plugin/buy_courses/view/paymentsetup.tpl +++ b/plugin/buy_courses/view/paymentsetup.tpl @@ -5,76 +5,71 @@

    Tipo de moneda:

    - - {% for moneda in monedas %} - {% if moneda.status == 1 %} - - {% else %} - - {% endif %} + {% for currency in currencies %} + {% if currency.status == 1 %} + + {% else %} + + {% endif %} {% endfor %} - - + + - - {% if paypal_enable == "true" %} + {% if paypal_enable == "true" %}

    Configuración PayPal:

    - {% if paypal.sandbox == "SI" %} - Sandbox(entorno de pruebas): - {% else %} - Sandbox(entorno de pruebas): - {% endif %} + {% if paypal.sandbox == "YES" %} + Sandbox(entorno de pruebas): + {% else %} + Sandbox(entorno de pruebas): + {% endif %}
    API_UserName:
    API_Password:
    API_Signature:
    + {% endif %} - {% endif %} - - {% if transference_enable == "true" %} + {% if transference_enable == "true" %}

    Configuración Transferencia:

    - - - - - - - {% set i = 0 %} + + + + + + + {% set i = 0 %} - {% for transf in transferencia %} - {{ i%2==0 ? ' - ' : ' - ' }} - {% set i = i + 1 %} - - - - - - {% endfor %} - {{ i%2==0 ? ' - ' : ' - ' }} - - - - + {% for transf in transferencia %} + {{ i%2==0 ? ' + ' : ' + ' }} + {% set i = i + 1 %} + + + + + + {% endfor %} + {{ i%2==0 ? ' + ' : ' + ' }} + + + +
    {{ 'Name'|get_lang }}{{ 'Account'|get_lang }}{{ 'SWIFT'|get_lang }}{{ 'Options'|get_lang }}
    {{ 'Name'|get_lang }}{{ 'Account'|get_lang }}{{ 'SWIFT'|get_lang }}{{ 'Options'|get_lang }}
    {{ transf.name | e }}{{ transf.account | e }}{{ transf.swift | e }} - -
    - - add account -
    {{ transf.name | e }}{{ transf.account | e }}{{ transf.swift | e }} + +
    + + add account +
    -{% endif %} - - + {% endif %}
    \ No newline at end of file diff --git a/plugin/buy_courses/view/pending_orders.tpl b/plugin/buy_courses/view/pending_orders.tpl index f048f55597..aee853269b 100644 --- a/plugin/buy_courses/view/pending_orders.tpl +++ b/plugin/buy_courses/view/pending_orders.tpl @@ -23,13 +23,13 @@ {{ pedido.reference }} {{ pedido.name }} {{ pedido.title }} - {{ pedido.price }} {{ moneda }} + {{ pedido.price }} {{ currency }} {{ pedido.date }} - ok    - borrar diff --git a/plugin/buy_courses/view/process.tpl b/plugin/buy_courses/view/process.tpl index 3b0288f959..c35762675a 100644 --- a/plugin/buy_courses/view/process.tpl +++ b/plugin/buy_courses/view/process.tpl @@ -25,24 +25,23 @@
    - +

    {{ curso.title }}

    -
    Profesor: {{ curso.profesor }}
    +
    {{ 'Teacher'|get_lang }}: {{ curso.teacher }}
    -
    {{ curso.price }} {{ moneda }}
    +
    {{ curso.price }} {{ currency }}
    {{ - 'Description'|get_lang }} - + href="{{ server }}plugin/buy_courses/function/ajax.php?code={{ curso.code }}">{{'Description'|get_lang }} +
    @@ -70,7 +69,7 @@ 'transferencia_bancaria'|get_lang }} {% endif %} - + diff --git a/plugin/buy_courses/view/process_confirm.tpl b/plugin/buy_courses/view/process_confirm.tpl index 5ae4517950..d80512fe1c 100644 --- a/plugin/buy_courses/view/process_confirm.tpl +++ b/plugin/buy_courses/view/process_confirm.tpl @@ -25,18 +25,18 @@
    - +

    {{ curso.title }}

    -
    Profesor: {{ curso.profesor }}
    +
    {{ 'Teacher'|get_lang }}: {{ curso.teacher }}
    -
    {{ curso.price }} {{ moneda }}
    +
    {{ curso.price }} {{ currency }}

    {{ curso.title }}

    -
    Profesor: {{ curso.profesor }}
    +
    {{ 'Teacher'|get_lang }}: {{ curso.teacher }}
    -
    {{ curso.price }} {{ moneda }}
    +
    {{ curso.price }} {{ currency }}