From b038c1e98ff707af5671db6405d92e2890b41cb8 Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Wed, 21 May 2014 18:18:07 -0500 Subject: [PATCH 1/9] Add plugin and re organize the code --- plugin/buy_courses/config.php | 13 + plugin/buy_courses/database.php | 333 ++++++++++ plugin/buy_courses/index.php | 7 + plugin/buy_courses/install.php | 12 + plugin/buy_courses/js/funciones.js | 244 ++++++++ plugin/buy_courses/lang/english.php | 45 ++ plugin/buy_courses/lang/spanish.php | 50 ++ plugin/buy_courses/plugin.php | 13 + plugin/buy_courses/readme.txt | 5 + plugin/buy_courses/resources/acces_tool.gif | Bin 0 -> 1207 bytes plugin/buy_courses/resources/borrar.png | Bin 0 -> 1481 bytes plugin/buy_courses/resources/content.css | 105 ++++ plugin/buy_courses/resources/edit_message.gif | Bin 0 -> 2571 bytes .../resources/message_confirmation.png | Bin 0 -> 1732 bytes .../buy_courses/resources/message_warning.png | Bin 0 -> 1746 bytes plugin/buy_courses/resources/more.png | Bin 0 -> 983 bytes plugin/buy_courses/resources/new_message.gif | Bin 0 -> 2162 bytes plugin/buy_courses/resources/plugin.css | 75 +++ plugin/buy_courses/resources/save.png | Bin 0 -> 898 bytes plugin/buy_courses/resources/save2.png | Bin 0 -> 1397 bytes plugin/buy_courses/resources/toggle.png | Bin 0 -> 1820 bytes plugin/buy_courses/src/ajax.php | 26 + plugin/buy_courses/src/buy_course.lib.php | 292 +++++++++ .../src/buy_course_plugin.class.php | 63 ++ plugin/buy_courses/src/configuration.php | 43 ++ plugin/buy_courses/src/error.php | 18 + plugin/buy_courses/src/expresscheckout.php | 62 ++ plugin/buy_courses/src/func.php | 371 ++++++++++++ plugin/buy_courses/src/index.buycourses.php | 32 + plugin/buy_courses/src/inscription.php | 337 ++++++++++ plugin/buy_courses/src/list.php | 58 ++ plugin/buy_courses/src/paymentsetup.php | 54 ++ plugin/buy_courses/src/paypalfunctions.php | 573 ++++++++++++++++++ plugin/buy_courses/src/pending_orders.php | 36 ++ plugin/buy_courses/src/process.php | 81 +++ plugin/buy_courses/src/process_confirm.php | 168 +++++ plugin/buy_courses/src/success.php | 331 ++++++++++ plugin/buy_courses/uninstall.php | 13 + plugin/buy_courses/view/configuration.tpl | 47 ++ plugin/buy_courses/view/list.tpl | 84 +++ plugin/buy_courses/view/paymentsetup.tpl | 80 +++ plugin/buy_courses/view/pending_orders.tpl | 41 ++ plugin/buy_courses/view/process.tpl | 81 +++ plugin/buy_courses/view/process_confirm.tpl | 91 +++ plugin/buy_courses/view/success.tpl | 64 ++ 45 files changed, 3948 insertions(+) create mode 100644 plugin/buy_courses/config.php create mode 100644 plugin/buy_courses/database.php create mode 100644 plugin/buy_courses/index.php create mode 100644 plugin/buy_courses/install.php create mode 100644 plugin/buy_courses/js/funciones.js create mode 100644 plugin/buy_courses/lang/english.php create mode 100644 plugin/buy_courses/lang/spanish.php create mode 100644 plugin/buy_courses/plugin.php create mode 100644 plugin/buy_courses/readme.txt create mode 100644 plugin/buy_courses/resources/acces_tool.gif create mode 100644 plugin/buy_courses/resources/borrar.png create mode 100644 plugin/buy_courses/resources/content.css create mode 100644 plugin/buy_courses/resources/edit_message.gif create mode 100644 plugin/buy_courses/resources/message_confirmation.png create mode 100644 plugin/buy_courses/resources/message_warning.png create mode 100644 plugin/buy_courses/resources/more.png create mode 100644 plugin/buy_courses/resources/new_message.gif create mode 100644 plugin/buy_courses/resources/plugin.css create mode 100644 plugin/buy_courses/resources/save.png create mode 100644 plugin/buy_courses/resources/save2.png create mode 100644 plugin/buy_courses/resources/toggle.png create mode 100644 plugin/buy_courses/src/ajax.php create mode 100644 plugin/buy_courses/src/buy_course.lib.php create mode 100644 plugin/buy_courses/src/buy_course_plugin.class.php create mode 100644 plugin/buy_courses/src/configuration.php create mode 100644 plugin/buy_courses/src/error.php create mode 100644 plugin/buy_courses/src/expresscheckout.php create mode 100644 plugin/buy_courses/src/func.php create mode 100644 plugin/buy_courses/src/index.buycourses.php create mode 100644 plugin/buy_courses/src/inscription.php create mode 100644 plugin/buy_courses/src/list.php create mode 100644 plugin/buy_courses/src/paymentsetup.php create mode 100644 plugin/buy_courses/src/paypalfunctions.php create mode 100644 plugin/buy_courses/src/pending_orders.php create mode 100644 plugin/buy_courses/src/process.php create mode 100644 plugin/buy_courses/src/process_confirm.php create mode 100644 plugin/buy_courses/src/success.php create mode 100644 plugin/buy_courses/uninstall.php create mode 100644 plugin/buy_courses/view/configuration.tpl create mode 100644 plugin/buy_courses/view/list.tpl create mode 100644 plugin/buy_courses/view/paymentsetup.tpl create mode 100644 plugin/buy_courses/view/pending_orders.tpl create mode 100644 plugin/buy_courses/view/process.tpl create mode 100644 plugin/buy_courses/view/process_confirm.tpl create mode 100644 plugin/buy_courses/view/success.tpl diff --git a/plugin/buy_courses/config.php b/plugin/buy_courses/config.php new file mode 100644 index 0000000000..e980fff7e3 --- /dev/null +++ b/plugin/buy_courses/config.php @@ -0,0 +1,13 @@ +install(); \ No newline at end of file diff --git a/plugin/buy_courses/js/funciones.js b/plugin/buy_courses/js/funciones.js new file mode 100644 index 0000000000..7400c63253 --- /dev/null +++ b/plugin/buy_courses/js/funciones.js @@ -0,0 +1,244 @@ +$(document).ready(function () { + $("input[name='price']").change(function () { + $(this).parent().next().children().attr("style", "display:none"); + $(this).parent().next().children().next().attr("style", "display:''"); + $(this).parent().parent().addClass("fmod") + $(this).parent().parent().children().each(function () { + $(this).addClass("btop"); + }); + }); + + $("input[name='price']").keyup(function () { + $(this).parent().next().children().attr("style", "display:none"); + $(this).parent().next().children().next().attr("style", "display:''"); + $(this).parent().parent().addClass("fmod") + $(this).parent().parent().children().each(function () { + $(this).addClass("btop"); + }); + }); + + $("input[name='visible']").change(function () { + $(this).parent().next().next().children().attr("style", "display:none"); + $(this).parent().next().next().children().next().attr("style", "display:''"); + $(this).parent().parent().addClass("fmod") + $(this).parent().parent().children().each(function () { + $(this).addClass("btop"); + }); + }); + + $(".guardar").click(function () { + var vvisible = $(this).parent().parent().prev().prev().children().attr("checked"); + var vprice = $(this).parent().parent().prev().children().attr("value"); + var idcurso = $(this).parent().parent().attr("id"); + $.post("function/func.php", {tab: "guardar_mod", id: idcurso, visible: vvisible, price: vprice}, + function (data) { + if (data.status == "false") { + alert("Error database"); + } else { + $("#curso" + data.id).children().attr("style", "display:''"); + $("#curso" + data.id).children().next().attr("style", "display:none"); + $("#curso" + data.id).parent().removeClass("fmod") + $("#curso" + data.id).parent().children().each(function () { + $(this).removeClass("btop"); + }); + } + }, "json"); + + }); + + $('#sincronizar').click(function (e) { + $.post("function/func.php", {tab: "sincronizar"}, + function (data) { + if (data.status == "false") { + alert(data.contenido); + } else { + alert(data.contenido); + location.reload(); + } + }, "json"); + e.preventDefault(); + e.stopPropagation(); + }); + + + $('#confirmar_filtro').click(function (e) { + var vcurso = $("#course_name").attr("value"); + var pmin = $("#price_min").attr("value"); + var pmax = $("#price_max").attr("value"); + if ($("#mostrar_disponibles").attr("checked") == "checked") { + var vmostrar = "SI"; + } else { + var vmostrar = "NO"; + } + var vcategoria = $("#categoria_cursos").attr("value"); + $.post("function/func.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria}, + function (data) { + if (data.status == "false") { + alert(data.contenido); + $("#resultado_cursos").html(''); + } else { + $("#resultado_cursos").html(data.contenido); + } + $(document).ready(acciones_ajax); + }, "json"); + + e.preventDefault(); + e.stopPropagation(); + }); + + $("#save_money").click(function (e) { + var tipo_moneda = $("#tipo_moneda").attr("value"); + $.post("function/func.php", {tab: "guardar_moneda", moneda: tipo_moneda}, + function (data) { + alert(data.contenido); + }, "json"); + + e.preventDefault(); + e.stopPropagation(); + }); + + $("#save_paypal").click(function (e) { + var name = $("#username").attr("value"); + var clave = $("#password").attr("value"); + var firma = $("#signature").attr("value"); + if ($("#sandbox").attr("checked") == "checked") { + var vsandbox = "SI"; + } else { + var vsandbox = "NO"; + } + $.post("function/func.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox}, + function (data) { + alert(data.contenido); + }, "json"); + + e.preventDefault(); + e.stopPropagation(); + }); + + $("#add_account").click(function (e) { + var tname = $("#tname").attr("value"); + var taccount = $("#taccount").attr("value"); + var tswift = $("#tswift").attr("value"); + if (tname == '' || taccount == '') { + alert("Complete los campos antes de insertar"); + } else { + $.post("function/func.php", {tab: "add_account", name: tname, account: taccount, swift: tswift}, + function (data) { + location.reload(); + }, "json"); + } + e.preventDefault(); + e.stopPropagation(); + }); + + $(".delete_account").click(function (e) { + var vid = $(this).parent().attr("id"); + $.post("function/func.php", {tab: "delete_account", id: vid}, + function (data) { + location.reload(); + }, "json"); + + e.preventDefault(); + e.stopPropagation(); + }); + + $("#cancelapedido").click(function (e) { + $.post("function/func.php", {tab: "borrar_variables"}); + window.location.replace("list.php"); + }); + + $(".borrar_pedido").click(function (e) { + var vid = $(this).parent().attr("id"); + $.post("function/func.php", {tab: "borrar_pedido", id: vid}, + function (data) { + location.reload(); + }, "json"); + + e.preventDefault(); + e.stopPropagation(); + }); + + $(".confirmar_pedido").click(function (e) { + var vid = $(this).parent().attr("id"); + $.post("function/func.php", {tab: "confirmar_pedido", id: vid}, + function (data) { + location.reload(); + }, "json"); + + e.preventDefault(); + e.stopPropagation(); + }); + + $(".setting_tpv").click(function () { + var vcod = $(this).attr("id"); + $.post("function/func.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/func.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/func.php", {tab: "activar_tpv", cod: vcod}); + }); +}); + +function acciones_ajax() { + $('.ajax').on('click', function () { + var url = this.href; + var dialog = $("#dialog"); + if ($("#dialog").length == 0) { + dialog = $('').appendTo('body'); + } + width_value = 580; + height_value = 450; + resizable_value = true; + new_param = get_url_params(url, 'width'); + if (new_param) { + width_value = new_param; + } + new_param = get_url_params(url, 'height') + if (new_param) { + height_value = new_param; + } + new_param = get_url_params(url, 'resizable'); + if (new_param) { + resizable_value = new_param; + } + // load remote content + dialog.load( + url, + {}, + function (responseText, textStatus, XMLHttpRequest) { + dialog.dialog({ + modal: true, + width: width_value, + height: height_value, + resizable: resizable_value + }); + }); + //prevent the browser to follow the link + return false; + }); + + +} + \ No newline at end of file diff --git a/plugin/buy_courses/lang/english.php b/plugin/buy_courses/lang/english.php new file mode 100644 index 0000000000..2e051170da --- /dev/null +++ b/plugin/buy_courses/lang/english.php @@ -0,0 +1,45 @@ + + */ + +//Needed in order to show the plugin title +$strings['plugin_title'] = "Buy Courses"; +$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['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['Description'] = "Descripción"; +$strings['Buy'] = "Comprar"; + +$strings['paypal_enable'] = "Habilitar PayPal"; +$strings['tarjet_credit_enable'] = "Habilitar TPV"; +$strings['transference_enable'] = "Habilitar transferencia"; +$strings['unregistered_users_enable'] = "Permitir usuarios sin registro en la plataforma"; + +$strings['EnrollToCourseXSuccessful'] = "Su inscripci�n en el curso %s se ha completado."; +$strings['ErrorContactPlatformAdmin'] = "Se ha producido un error desconocido. Por favor, p�ngase en contacto con el administrador de la plataforma."; +$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'; \ No newline at end of file diff --git a/plugin/buy_courses/lang/spanish.php b/plugin/buy_courses/lang/spanish.php new file mode 100644 index 0000000000..d65bc1298c --- /dev/null +++ b/plugin/buy_courses/lang/spanish.php @@ -0,0 +1,50 @@ +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'; diff --git a/plugin/buy_courses/plugin.php b/plugin/buy_courses/plugin.php new file mode 100644 index 0000000000..231dc28146 --- /dev/null +++ b/plugin/buy_courses/plugin.php @@ -0,0 +1,13 @@ +Plugins) + * @package chamilo.plugin + * @author Yannick Warnier + */ +/** + * Plugin details (must be present) + */ + +require_once dirname(__FILE__) . '/config.php'; +$plugin_info = Buy_CoursesPlugin::create()->get_info(); diff --git a/plugin/buy_courses/readme.txt b/plugin/buy_courses/readme.txt new file mode 100644 index 0000000000..5bc3ba4dc1 --- /dev/null +++ b/plugin/buy_courses/readme.txt @@ -0,0 +1,5 @@ +Buy Courses

+Users can access to the catalog to buy the visible courses.
+If the user is unregistered this user will be requested to register.
+Once the course is chosen Chamilo is going to show different enabled payment types.
+Finally the user will receive through email the user and password to access to the chosen course.
\ No newline at end of file diff --git a/plugin/buy_courses/resources/acces_tool.gif b/plugin/buy_courses/resources/acces_tool.gif new file mode 100644 index 0000000000000000000000000000000000000000..156f8273e8bfc21c566b1d9d3932cb3a2c8541c5 GIT binary patch literal 1207 zcmV;o1W5ZwNk%w1VHN-u0O$Gup#TDM9U6Zb6@eNMbsraCDl3y38LSfuTQ)VX77S)I zGsYPTaz8z?CmB;wRn#5|-W&$s9tT-hTjC-LR$5$ISX_TgPF!JQp+`euV_;=wWM*e& zX=-z9YHnz3Z)t6Cz)eVLad>oaZf|pTadLanO+#{Xe06qz<4r)nTUdH_hJAQ<-cdx| zQA*cTPI-ERe0qN8Q9bWZI(mPCe|>?UaCLrvh_-2HsBv?HfrWyDjQ>_WhlPoShlIax zX|!~7!EkD*d49!iYKMrCiHnGyf`PmXVU2kd&8`l%A58nUs~El9r{ImYSKDo0piPn3|WCo1L4Potc@VnwyxM znx2}Pq@0|lnVqbkouQqbr<M%ecJEzP!M^zPs?LqQAYty1vfT zwza;&y}-TB)wj0utfj!k$iv0Lz{JzU#>2;n30B&eG!1(%jP2(a+Q4($n43)zZ_{-v7n9 z)YaeB*VNV4;M3RV=F-&I*yGvRfqt)<>Kb#=Hut&>EGw@<>%z+<>u${|KHf;>Fnp}=I!U^=;`z8>Fw$3 z=;`Y8>g)FH>+kLF>+bOF^zQBM@A>fZ@9OjW?(_EZ@%8cZ@bvQb^Y!xf^!W7m^Z51p z_W1Pn_W$(x{QCF&`1<$x`}q3&`S<<*{rms>{rdj=|M~y_{Qvv@|NQ^||NsC0|NsC0 z|NsC0|NsC0A^8LW3IP8AEC2ui02Tli06+--0RIUbNU)$mfodE9OXX`JEnB*Z9Z`d( zf~A9)l2G%*VnF~X>HZm`@yXY*OTDnE`14QCm@NNL*&uc<-8K`l2A`-_zirv6#G|XJ`^oa?EAc5L=ax%xNKvg$ZHDYl9L5NSlm|=@&4^EVL z0)5;Rg#?w>AjF>E%$T}7%uGT+IL$=McXYY-df}KRA;y~-4 zmUfVu{L7_dTDNmw!U)V4iH`~gkOY-x*+uMFp)|3E=~7mO$3I4ID(G=KkQ|RtvtXr~ zmFm*2Y=wv+!6}Y`Qw9tie87MtDOh02JndX@#%|aAkVjDm7*NAA-MnK@8c!Hhi4n<2 z(oq3()WX9hz!WnLGwryg&Of{eK}{bqm^Onq10h2Li?pz!LI$z?0|Fg8JP^PN%^YM6 V4;*x$l|cA_0>&wz?N(4g06PPS&Y%DQ literal 0 HcmV?d00001 diff --git a/plugin/buy_courses/resources/borrar.png b/plugin/buy_courses/resources/borrar.png new file mode 100644 index 0000000000000000000000000000000000000000..630be5631d13143c1b82828675842a2c0f5cc529 GIT binary patch literal 1481 zcmV;)1vdJLP)Px%{ZLF)Mc4oUmjMi*00E)^3#$MCqyq%4011%^38e%8n+FGq4h)hE5sMEErwIq1 z3<-=84vY~Ll@JV`4H3`)0M7sfjT0504+?i08;%qe+5iHo4hVl48qxy*-2edG00Ytk z2cQuWc^n<$004*?8G#!cQFb9Ub2V0Pp|+ z@&Ewy008O(0QCR>-UblW3JK~24*UQEoEjbf007Dl6!!)I)(#Wa4+_H;80`!N*b@xx z4G_B<8|)1koFpaA79Or6BE}pc?hzV`Eh_I466F>Z+Zh-65E+RxG0Gt%@);H0A0gHv z9lR+j&Ltr992UMk$RH8I0EH`y~Z%Q!mZG&KG#E!{RZ?K3j} zE;H>jIQB6%$UZ>VJ3HSwIKx3d-#I?GM@P#-L+Uy>@;E!xK|%aCH2pX_wM zMejd5(ML!BJ3PxtOYcBJ#!O1oNlEfTM72{<)=Nv!PEW*AQS?Pc%u!CcS6cr@Mes^X z_ef3uM@7z5R>@XX+)+^ZN>9dHTlP>-&RbdASXlT`P~%uz;9Oh$RaE;`S@l;}+FxMr zT3h#7S>0k{(`IJvU}F1STl8OF_F-Z7Vq)ECYx!ei-)n93W@7tgW!r9T?rClOW@i6r zXYg!p;Bs;LY;FB+Z}4()|8a5ob9MZ6a`1V3{dRc&d3*bNdhvmO{(po2fPepjfct}l z|AL0`iHZ4$hX03$^NWlBh>7=(j{lB~|BsUUk&*V4k^YpF|CN>Yo16Tao&TGe|DK`w zq@w?%r1__+{i&w^s;B>~sr<09{<5R7v%E|xB z%Ky;K|I*d`*4F*k*Z$bq|JmCA;o$${;r{32|LX1k?eF~V@Bi}h|NZ;^|NPrh;L892 z00DGTPE!Ct=GbNc0004EOGiWihy@);00009a7bBm000XU000XU0RWnu7ytkO2XskI zMF-gg5)>gJEv(Rj0006wNklwF1W{2ya&~oPAz32orxc;aq5B@$sypR!U|Fr4H{(Sp$D=<_UDj!gB z>-V>xPtUI91oQn@O#k`i)0ZFD1Kq$X1U#}Xe*+49yLmMNtUz!6^b23#y?gidvXiwa zP``c5xi3KO$0rx|DnN`>nNxQ1-Rsw{KU{Rskq}TfKk)&`d3*ohW+9lPRHhamef{j& zv)3ndMbvc5N9zA+_L|b*|i^q>1J-xPmsRDAqDA%X&dvy2i z-A8-YfvEfE7t9qx4O->G#7%c^+_-V)4v08Dvz-q;HbnCRH(b2{23HPs)be4*mqfVd z>IDtIP$8G#i@YM3%}>bQUv^z73iD$0{zcv8xsUl zFk{}S9c*9)uG_4PzzQ6Kz~RRloD~OBuwdEE5Qqs2yG%d|yknu^$C})j0#q>b*j`Pj z9kZK(3IfyM;mevm1?YzTTX|su?32oj{7R7GhofLY$M!Y62m!&)mTHvvXKCBAgbi7M j(;Y2+usE|(D_a8qh>`BtNi^Zc00000NkvXXu0mjf$#bnG literal 0 HcmV?d00001 diff --git a/plugin/buy_courses/resources/content.css b/plugin/buy_courses/resources/content.css new file mode 100644 index 0000000000..771e6f3046 --- /dev/null +++ b/plugin/buy_courses/resources/content.css @@ -0,0 +1,105 @@ +body { + background-color: #FFFFFF; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + scrollbar-3dlight-color: #F0F0EE; + scrollbar-arrow-color: #676662; + scrollbar-base-color: #F0F0EE; + scrollbar-darkshadow-color: #DDDDDD; + scrollbar-face-color: #E0E0DD; + scrollbar-highlight-color: #F0F0EE; + scrollbar-shadow-color: #F0F0EE; + scrollbar-track-color: #F5F5F5; +} + +td { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} + +pre { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} + +.example1 { + font-weight: bold; + font-size: 14px +} + +.example2 { + font-weight: bold; + font-size: 12px; + color: #FF0000 +} + +.tablerow1 { + background-color: #BBBBBB; +} + +thead { + background-color: #FFBBBB; +} + +tfoot { + background-color: #BBBBFF; +} + +th { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 13px; +} + +/* Basic formats */ + +.bold { + font-weight: bold; +} + +.italic { + font-style: italic; +} + +.underline { + text-decoration: underline; +} + +/* Global align classes */ + +.left { + text-align: inherit; +} + +.center { + text-align: center; +} + +.right { + text-align: right; +} + +.full { + text-align: justify +} + +/* Image and table specific aligns */ + +img.left, table.left { + float: left; + text-align: inherit; +} + +img.center, table.center { + margin-left: auto; + margin-right: auto; + text-align: inherit; +} + +img.center { + display: block; +} + +img.right, table.right { + float: right; + text-align: inherit; +} diff --git a/plugin/buy_courses/resources/edit_message.gif b/plugin/buy_courses/resources/edit_message.gif new file mode 100644 index 0000000000000000000000000000000000000000..45524e35bb6eb8d4fe392b491a0d03c340cad4e9 GIT binary patch literal 2571 zcmdUw={K7R1I3@j7R0`k5?Q1ev>uMms8)+0327%f+R;vH5=%#E>m8$*=`s;ZQ7y4G z)U?qms-5cCfU2L~qy-w&+4>t7QL4UY_c_%OZR|9)ib!`Q^= z#N_zI$GQ3O@k!D6`U`F^eA-_8v@BcNUS3?4t#5x?l&ySPUfuY-CfizD zS=(4utZgdRtpvVXmo_L%Lptn>ZTEIVm;&d;|J~pG(Y3v%DIrDV*(~nqMuNwm&AaDCLS ziQ_Og*v4evi1kzb$37YGKYV{639T4)i*<>0AEhN0 zf+!3yBX?!qGA|sHhedR9=(|x_zcLX)AxLp(c!gxDzXI_%q^G#C7R z+ZZBOJGAC#EP1+jmzibdTjlL!IW(__5OruA&>gbP=LhTj(g@Y{XpLgUlayzKVO1h9 zghv0kadYH^12M*Xciy#X)=ND09{;;zx31k}IVi*v*`%R7u!U7I5jvsidLH?>jjdsS zzDxvjh$V*JLRay`!|~cHT~>qvYOWu;eod5YdM$@au!(Mi5H4kXH9UUv)`!o;y;(A$ zhVjuciW&;K4)H@~G|+!c*I2F?NxOV~McX>oj_s`z>&CG}h4aund-kHB^G=5|^A;kW zf`L2b_My2t=Xq2Zxu}ipX9Z33vbh4^V00quVXFa-X_d_?#?jKx!N?dML*4w^cHCYB z1tw&I)vQpMIc^bDHNOE)6`-Qy1YJ(s1}R+C=S}lf&y*H$dS6lu4NYW08-@O*q{Yb& z(>P=3NgJ{!qstM#H;xDm>lQ86_Z^MKX||7T2AfeTiTc0fu2EC<4o3?7kk!U#3in|Q z%T)Aq8Fhfg5Iy{j#Y5L32b-iEw5l$?jH=Pv3f6U&Y-s($Q@MX+O;x?gjEge9K}jGx zP}T)c^(cL4VpuWkehuiP4>8zp=_8Vbk)`trfq*7b2pMzxnK3Ckx zT0dtw3#Pr>QbMuKq%r{>3%z(q{{S)(Z2&qdfClii@yP&OB`lGv;~ky_BNQgukzj-V zKIxF0OWHvPPNRetI4n`vX+R~FzEN7t*q2{Mn9O=6kD@Lz2oxQisPw0toY&lL1|^dj<8%to?F}?X^kEdn8P9wBz#0Xb6~*Bi1|a=u zrCf;3fPROC(RwV@bToRI3^Ju6f>mXsVJ6zy?8~LGl1#WX&FZaT&zXeOB{b)nw&0De zl9qAwI^M3xLs}YT+r- zaOiFAO2}2^ihBtz^yfbn)qZ9rWWdUvoeW$80ku8=mVfU#-7!h^;t%k##4xKMDb=Ki zWgeFaB$LCTaMel?phck{@bOE^pYE7-*HA;dV9jt(Q}67eG-ZetU`t9a>Bfb!%oy?+>1@jqz1$H>qQMLxVT`bk3om zB0sax$o8*HleLaFpw)3StEs}UOb=2-HXfUXatyfy-n2wPTt2&)#zV6FASD$lP$a zO-OTvYc1(t?ws#O8u)+TTs2Mng>9SnZ0e->1&vofsp$O<*db*p@3$DrAeMU{l( z^MTJ$$p)?*_f$Z|%!U1wXq=61A*5`VgQ?$ObB>+xObYJuA7Yn#s{O?C!J58IBg3aj z{&bj=3su9Rjjy#w5oLnd(Dni`dR!kha(+{0I$R~|hE&C=wf zGMLRwubIH9gENin>I@$wz)n5j#sOcuJ+|&NXPjfvb<3{~rd;~TVU#(%(G=>H@*@P2 zeoUGKKP}G+3(8ABc%6fhtU_R}?PFs1&6aoT6!?|NXJIfc9PCA6 zS3tqDEbqf~8ZRJ|-1 zZqxCR_LB7N!)luBf^FNG-$OA*1&LgYRzWaG62ZLOV*a+e$mnskac*PDQlbO3JMGk+ ub?<^9a08fonTYTkHQ)VHhfZl9CCSkAi|JU=1eq2ZunR z)3Z+}=?}}fA~Qh55LdAE&$YY*P6%;CIw1@{y$$*LZZjf#88QolRFzG4G=&ycfj92f4v!)n0FXz zX+#$~*f8)hvoier`u71$9w2~NXlC<&2EpII{xxuj^5=w_Xfs7?s4~pGdV^up;VX}s ze*cGu06+lI!~y^Q{4@K-#Ly?FCTX2*sn6ggF3B+A#&w2u2d;f&`td)7k)7#0Of5hF zQQHBme}4ZA4 z_PTlI%@Q_7up{t?#6JdsKmY#Ku!ynex>!iDMeC?A$g>MD{QCQi;oysx42yQ%WBB>( zPb(W6TMsDInSZe}FrrmG009Jd%Ae1Sn?Aqz#SmsC%OI~KeWvlnSQb|6uKBOh^uq^{{HiSHc*NOEqk#8?WkhlW!Y$KD{NfqZph#(Z2M zeai6W%J0o=%q;1QOu#al000Oecp6~($MTo$H{+r!mp=yX)49SNE*Hq~-R(QWJcesA zpRO?cW%|!>{67zKy|NL9WT=G#gO!LbFb!}reEjtpsQD|yHK64S_dR2He){)bHYTQo z|BU~L%1HnLgmAzwRt8{j?EL+l@#LNx*RAZtZ5RTj{TaSHeP>wo`9b`zFHG^K)|?EX z`q~U?TpA2NfB$9p{tsw5;}3=h-ySopI`W+1`KiBG*%_FV{xbi2M{F|(Ab=1K_`?dK zezE>wSaS2qFRK$;M;V+%ycxVCT^T;PZU@Hi9|liFJqBTB8HUflzBBy%{}ots{$P0e z^C83PW6v2L9Qk*b^*3|OfA)WmNGU%60tn%N{}3i4Bg2{>cNq!}-n^}*&Ub@>}6|f2<7ee|`YQ_fMe0UkuNGKVn#O;wi)JeTuct(tjlj){ljqm<85Fte`NUn=O4qjUw;`s{r-pylclWY>Wc|jJ%E-cW7MQ<)c0mdn#(yBp%)kh0Q((a`01!Zk5I_U3>Zl=;Jp)M|@@Y@b@LdvD>d1 zZfxadV0_A6$H>Ysm(uDJAb=1d@P`EjGyi8k&G3R_|Gn$X46l9y9r6D)!-Xer8E)oFI@|0{g!nb>|618dcP)M~*11Q1d| z#Eeb;Gvi;Tj&FM;S{c7Hodp){*+9#GP_qdI5I~Fr-8TdXpaJh00R+&1I{+Yn2HXJv a0R{l;6O2K0J{)=g0000>IF{J`hz@Pdb`8(wXml&iB3NXyE_x0pc_BSaxq4AOEk2uU@KsN$vll zuZ}*VzIRX2hL2Rdxs1k}oa86YT8G zy!oL4q>Gupw_wsFlWSR%ii#x7HGcD3-S6!f9P=(tG^chmu+Oh5 zd#3umM(OREl*0k&7GFgTPa-^D;m;GejoM!=R!bvB(@Ubp!{pz({-*lV` z_8f3&oh1>PB9l`T7wHTPK}k$9qop>j4<7K}I_7r&#{h1vrtQTinqP`co@4Ia=a5P& zVwU8UosxG?Ns8i7S}Yj4=u=ghWN~xRqTM}*cb^-f|NU}Lqy^%s&&9tVud7d8?9Vbd z=rX^-6B%ap1BNsKF(AewHoHa^(+W3ssIB?)P zLfEvl+MqcoYy!_A$lLfq2vJ_1BWAjs?sLJc7^CP?`-|j&!Zf_;ncW&ytwgn%ca!b`y}iX@Dp1=CRwC zRxZzv`Ml9%Gk>8=S*-)Q1EvGQLFR3gXQS{T;(-QcJWqP+7{}kukw4wb!t~`uPk)y0 z-W0&h6!jZEm3RbA=WwrsN1l1@F5sdfE<{}@7x*z?{=L{g9Fxaa@bIcn$JQ%PWBacq>1Ij$9SSrF zrUFwUB9ihNNi3hlz$c6Uc|_Lic4(*2X?*mWqvuCg5%vH&K4@vZdLYWHU5@HfzN*q^l_OQaYB~u$5;-wcL|0l?w0~H`7 z%$N@E{1Gk>Lt{NGp2=-JC+I$R^{*GyjR3|k*YI*WE$T;yBrm?Exc6&{$_9lp6vRRR z5!FCTuxpE=XM3JAz2o#9>7)Igel*<%sXze%Xa-EHfR|r^<{BugBC?>0md)M#EL?Ge z2iDxq18t3T;3icK_nWZ>%JDiM#@nxAIlQRC{pGK zvJhlIW+1o@!h?BDul>GGbJa@}R?lKnEGJjbkU3jpk7jy&qPr&x~z>Is&&9hi$glI%Z2=F|K>v}k@hvP_@!VBLo@>=S+H&JB)Fjwae-^$yKybcb$u8?u3$?Gh(C&xIx_P1>P zU<6G}Q0=IJj?+cSK>|6+pUh oEEOMa2ttRQ2PXXY{J$H20TCt3jSaY&rvLx|07*qoM6N<$g2*sC=>Px# literal 0 HcmV?d00001 diff --git a/plugin/buy_courses/resources/more.png b/plugin/buy_courses/resources/more.png new file mode 100644 index 0000000000000000000000000000000000000000..16e25485f75e6b48f49e2129541fabbe19e2f79b GIT binary patch literal 983 zcmV;|11S87P)Px%8Bk1AMF0Q*|Ns9ntraw{7&fpOHm?~su^Kn98aS~VIItT!vK=!mVAV0JqLAD`4wIM*X zAwsqyL$@PCwj)BdBSg3)MYttKxh6xlB1O0)M!6+Nxg|!pB}lp^N4X|Qxh6=vCrP^} zN4Y0TyC_S$C`-I4OuQ*eyD3h-D^9&DPQENpzAR9`Em6KKP`xZszAaL}E>gcQQ@<}% z!7x?AF;&4aR>3h@!!uUFGFQPeSHd$}#Wh*OG+M+pTEjJ4#5P~ZI$OjvUdA?D#5G;T zHeJLvV8}RL#y4HXH(#1XUjfl%RXqzK4{E8Y0N-s z%|UC;L2S)IZqGw)&O>g`L~qYTa?(d~(MNOAM|adpc-2dK)=hobPJP!-f!k4j*ieGo zQhwJ^gxpkt+EazxRfXMFgxgh!-dKv@T87h zj^SL4;9HO4UXbEmk>XvF1UzrYM|?BpXzC$>uag-aH#Kas_=2E@p9~~2BrW200DGTPE!Ct=GbNc0004EOGiWi zhy@);00009a7bBm000XU000XU0RWnu7ytkPJxN4CR2b7^V1NKgC}2PZk}`6#3hHv` z!VffFXpnU~0n=1al2$upNM&0r`-6BdY{GI_!LBsTPbRkg6NveFhuk4w}j1^}%5RFGBVU84X1002ovPDHLk FV1mTju{!_& literal 0 HcmV?d00001 diff --git a/plugin/buy_courses/resources/new_message.gif b/plugin/buy_courses/resources/new_message.gif new file mode 100644 index 0000000000000000000000000000000000000000..81bccbbc81323ff4a0d06de371a493b983a6ff60 GIT binary patch literal 2162 zcmV-&2#xngNk%w1VL$*t0Oo%H=H}*gvSv)YD(~;_W63+}>gsIHLP515WwKGLtE-OT zT$II!xw*MMv>)*B@ZsU%}+(!VadtKz`(%H&d!Lrdv?=F;^N}M!orl~U{%2}udlC5 zOG}=fo?2R3f!a}ngM*@?qRPt3*x1;Sk&&s|ov5g&rlzKa+*NtWWsBch)z#Ivx3_W8 zMw{qnh0b(Jv@=@7HNL*SPrfW&#WsPza&Ny|Qot@~%RiXsWJtOvSi>`YeSKcWII!TO zkB^Ui*ifRSp@Z90yu7^D*4F<1{`U6v{r&y-_xIi1-T(jp{QUg%^z{1r`rh8&^78Wg z`}>%fnDg`V-{0Swnwq`6z4Q0-+}zyP*VjY0BeAuxUZPBH&qSM_nnQ^(+TPhyzc8NZ zXouZbh~8IZ!A^<7dtk>ou=I7S@p7Qil=b!X`T641ejE#X=T-Das*j!jxl2&~X z4-aS&sbA(==;`VhJP{Ez>hb8!^cZLWVUbuGRa|`k00RmfNU&hQEh8Lod*nq+1uuL0 zNSsKqqQpHIGiuz(agUWA0JuEz#=`?dizq2}T-nhIi!b>cd5bWCSd}UO21xu;G3P{< zKr??zSfDbt?!>!VQKZnoH}2mmfh)+6 z0f1~3KUCiy#Z6$219pI_R6reA)6VTM^#5`^bm9~GDp z0d0%`WCjChB_QBZ_92!bh8JQ6S`8HxSl0+3V9-Y+0C_;dZ9t+#0tnObxCI|R2C3x# zL=5zR9* zVL(8F2Yu84=Tq5%)|f;dmUhJ+p|;A<7bA?&2U9hm<<}P$Xr~<&npse8f0#}%!CGI$ z=j$F_WP7V3R$RdY4@NZL@4pSO;n${pXop{c_0=H5XHAWTnS?4~dxN$|jX_TTzXu$k zMh9vH%tu-OR3SkbGB_Xu2q0`&76@{#rA4I`T!m2=^-g^6C>l@zLBDD&ApjCY9I$}{ zavD^SM4w)DExk0?Ofe%|08oq_4Rr7`6Dz1ObQMM)owUqN(>#W~j(9S2{LqDM&nF(0R|Wj6eq(MHyZ-*zXu?32LT2UutWnH zXY6kYh^=KZ%4EbhK^aOv#THv+(#IYS6uX|+0bn72Ubq4nwqgbjxS$GSNKYafpauaDAr4F^!uJf|gY&^4 z2Rl%J669cj3dW5OS1Ex0y5Il}6o3RA5W@@#P&?ao0ERLoUmI%JKnN;9f_dAqG0Cd0y3fO@XrXT*11kBR3i*t@B$y4 z*TE{FfC6ah0{%oqqDNq%3jj#N1YBUu4=6zeAy5DjHh{l|;?D}(;KDTI`H$Q>^MtqLr#00g+u&;s-T z1=ov&753nP0H}cgCpbYA+OPx>gyX4DC4(-|fB_m*p&b;@=)ny<;DGxz6b)u5z$ayL zg$S_WcK&)p3)afkwzBmFFW^8EBya)g@ZqIfm_b6e1dMN_00({$gJ1_s*uoC>0#J}Z z44M!FD7XLw6nKCJywFf8L|_k<$ix^RkOm5P_OqZ3?Pp7%O%gD`0yl8M1r$ry$CdyM zAV331DUpdRMDKOD&8=>68@pRP00R;5zz|TYS_w$N1-%R^ZMVVP<~sMe5fy14y1+-^ o3bzMCNJCeDA&OwsbPrnr000ul-SYk+7}MYaU(L(jLj(ck literal 0 HcmV?d00001 diff --git a/plugin/buy_courses/resources/plugin.css b/plugin/buy_courses/resources/plugin.css new file mode 100644 index 0000000000..48d9dbb0b4 --- /dev/null +++ b/plugin/buy_courses/resources/plugin.css @@ -0,0 +1,75 @@ +.cleared { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + line-height: 0; +} + +table td.ta-center, table th.ta-center { + text-align: center; +} + +#tabla_cursos td, #tabla_trasferencia td, #tabla_pedidos td { + vertical-align: middle; +} + +#tabla_cursos td input.price, #tabla_trasferencia td input, #tipo_moneda { + margin: 0; +} + +#tabla_cursos td.btop { + border-top: 1px solid red; + border-bottom: 1px solid red; +} + +#tabla_cursos tr.fmod { + border: 1px solid red; + background: #FFE0E0; +} + +.sprice { + color: #FF5555; + font-size: 26px; + font-weight: 500; + margin: 15px 0; + text-shadow: 2px 1px 0 #222222; +} + +.dinline { + display: inline; +} + +.fright { + float: right; +} + +.cursor { + cursor: pointer; +} + +.ta-center { + text-align: center; +} + +textarea#mensaje { + width: 50%; +} + +.envio_resultado { + font-weight: bold; +} + +select#lsesiones, select#lcursos, select#lejercicios, select#estado { + margin-bottom: 0px; +} + +.columna_campo_filtro { + padding: 6px 10px 1px 1px; + text-align: right; +} + +.height5 { + height: 5px; +} diff --git a/plugin/buy_courses/resources/save.png b/plugin/buy_courses/resources/save.png new file mode 100644 index 0000000000000000000000000000000000000000..c673ab073b3fc27005d4dd88cf018fbdd154be7f GIT binary patch literal 898 zcmV-|1AY97P)H3e3dk^Fgs#q>Iw& zw7SK>R$!GkRc&OpLPjr9&*qtt;;x@AF5vw9T&4EY6G#Dw!UyI7*i{x3747wUy$wJX zq*AGv*1%{uG@SQ%Jn;GGhz4afAZ36}@&HawPIR;z?a+(?O8~4mdno`$|IQR}N5nP| zD{Cz=fD_CiYQ0{6bq%=PZipumx*{~J0e&~f$H$f_wo?Pr6flH519k!!&7-_11$J`G zuaTV?z6hlNWDGn!JiNLFTrL-UIy^LIfG-lJ2~s>}48&qFDdnPVnE_cbT1kOOJAb<} z|9c0pE2yl=VJTp2NCEJ9%4V}VFd{g!=eyJpfJoCm0@?z=Gq8`{^CwFDZO8!cI3ABf zCX<0fa+HF>AcR682m}JO!*M#D6!d5`g2%^4==b|D7!0W0YPIN9j`OS43Wnskb~>Hi z4B$eM0Tc`t4u`2-C={UGZi7PFFFby^TyE$2_xt^De}7N?pdF1yw|q+(;CGLK_{F7C zNt>(HYS8QTsN-G2F1GP_OqnwUuv{*6*Rmosnqtn)gwOqKHq+I?)^`D+|L1f%r64dB zj13V0uV(!u510WE!D|4j)#??3z=aG110vQ5|K6~|0P1``*Van`ppdH7Kw#x!5FD9c zO8DL5Nibu9>0+_i>b9kAd85&|!j}*U{KM<@YIT8fb8`cCcX#v+cY1mXkw`?>T*w$; zf_|_&64&bhkR84w!v~_dgM))GaqtZ*xZCa0?kJf|LMoNg?g1ldHk&Y+OtjrP91fa> zjr<|8K9cdD!qY(>zTW_F<59*(8};wuJ9Ns3A&N+l+P}(6KhFtRCmFnwshMiS>3;zR Y0JhpdU1DE*EdT%j07*qoM6N<$g4z6;q5uE@ literal 0 HcmV?d00001 diff --git a/plugin/buy_courses/resources/save2.png b/plugin/buy_courses/resources/save2.png new file mode 100644 index 0000000000000000000000000000000000000000..4b1aced2585ce7c2c99f0c73773407af7be43f88 GIT binary patch literal 1397 zcmV-*1&aEKP)DtVU3@D8>otA=*;V*^IA8MKJ>}r|M@~Y^Xz4v%L*J}RGg~j!pd+%QBTWjxq)am|@S9*H7 zJ0U$IBSZPy$48md>HZTY`fNn6SB!)nE2~Ag8W-^P?OXKs_oJ(`6P=8X4s;M+zkV&~ z?die&`}aW>f$Tw0P>@EDmX@YmxNreXQd3idj~_pZqS4V&jEsy3hKGlRc+iYkC4KYe z4U8n9xVRW(5BBZbhrqxdAOh*i>|p&`6~{~ot* z-^Tv^`w<)*3_m|VjUXv0NueBY?%X+4S6AcRyLV94u`R5yudh$QcC@#*qy5z@ykfk3 ziI)Vn?8c27Qk>Ld`}XY`K|(@;a^}n#P!_1HtQ3W+DkftL4h~8#Le|@hUP2G~-rd!O zE&^v@Fc`3B&mQdBwF{n}o*Kc)lP8swloXIvC@(LU4Ajn0b1=7q37Jf71ogB91qJZ; z_lJ*<4>oPuq!Gl&$1916i6E;`R#qmR!*-}DMQL}pfbD2&YeQ>m>%VAeK?{NHx_b30 zTf^$%=H{jm#Ky)dbP6y^OG_m%CShf&IyD2fgWHr_v}3+SITOCl&(DXKmlvzYx^?R` zg5$@JD{*mgU_5y6Kw6SBF!x@a2`1zm)ZqD)DlT2RB*jTRRC+NcI=oGU$bTnR<2yB z5zyo*bPD+bk;$+eIB-A)CNwk@d-v{@?%2J1H}^MueSIZJZ*OmG-MUp&dw6(A@wIE$ zvU)f>J8J|q97<$lq!gwlCBwoaf9ljJ2|hVFS#bLFX}QN%vY7Dja9#-u!EW5R5w5PT ztR4;y4jKUshr)^(w4@Lc5`w(EJTx>k;OWz+vcz~kcvbMS<2;(0now0$B^I(UJ{g~o zPq2LXax7iCR3o6{D{5g@#9(hOf0 zRwJOvOQ8ZL)n_iK5}Y`30$a9h5ubTaeSQKa;5=5WSRwYTTD1!H_V%!`vC#-9w4ZnE z*zp&K$7&dtFJG1ua26XjY=FDFyX>jY32xoGC1E=`If?faE|x7@25W0;jes8vG$78@ z5p_I;+qP|!448l)9^4%?II_yWM!>&eTPRoo`40;Vi^T-Qp{MrxY5n^3rKEU@A3lwZ zji|4$mpQ1YsE}vG=LCg?h0>y2)XvThOO`BQduFI!Cc)DDe~NGD!ig04Q((W+`uOAS z-Mfazj~^R|#6YJpG&eWPdtF_f;nAZJ00000NkvXXu0mjf Dys?mj literal 0 HcmV?d00001 diff --git a/plugin/buy_courses/resources/toggle.png b/plugin/buy_courses/resources/toggle.png new file mode 100644 index 0000000000000000000000000000000000000000..cf33fdc007ca65dd23f6816a19febe91115a176c GIT binary patch literal 1820 zcmV+%2jlpOP)ge0=1J>#ig!zvlnM}gv!I1y&fr)hrlTG`WWO@N4g$IMU zNI>8Su-CR#!n*rQK*sSAWJ_vfM_f%FQzXT-gUM!&hl%5%XlxM!%-R)&pePE6Gs0tXN*MB!el8emBa>R1mld+fzj9^7#Jfk zMgxX%P&6lC7`*#p9oP$G*mIy4CPE47_>kKUJ2yF@_0j~jtzT7i)59(egy8)juEJ7R z0qlLYnvQ74&IaMrqdvNx3&0?2C1i|j;;tXLAOB;FfOvIFRjO^z^Db&T@#h#Uuq$+4 zSfG$rr(9xCw7>)(ywU(wrFroAv0?J{D~qU2e^xfvff4P*7}OZj8EM+_8=mYKhu^y< z;i={l`10g6c%ab+RV8Nl@UR!WV{rli?V}@J>X&ZV7uoj3Pk#8g#Yb(E5fvWf?aOPe z&^Z{+l~h7tm<9|>Y0SRwJ#g^#M%cY|5iF_7hpT}oeD(7PF-y{bS;kXEl5dEmClG^f zZ-mabuX7M? z+U(4D81_GSY6RZ<(F40Sl)>723dyk_w&V3&(HIU4BgWvDoo37p27L2tfPm@pOu_jp zAy7;#1DFHH{d6tGm|&Fpw45J$6;>~|!*h?8fNwkohued>QNB&d<;c)R@QbTL4EmIH$X>lb^d1hP_W#K%rI1c#ffgQ4|dnMN{Ni zfI$)|Y1$xb8nb#?A-F3o8GX<7hv2cLcBm*e!?&%Y1nM(Q3+bAFJf86!LjxmeWtt&# zvH`<^$Y6{H%;tLwZ|ZyK>==A@IsiK#SqQtIC{MM2*A|3ddP6zE7}OZn^hQfkHs$m5 zFyW-;uFZUHeBD#;$fNTfo^r^XxorQ_7O1VQ6%Nec;2_r+dAcg;8pH0=h=uut`7f<> z-%gn}UMg`Rm1UMW$@_n;gc_6NX{6q8y|2m_+L`k*5+h13970J z-N8eP#(4DvNF3n)CQI^>Qfc-kETGn*7`VyfgVdb4orNw5m zd8@@@af;fRk3=FgQaEC~oKj z9S43cD|%2yFp*^%fk|hMVx)zeNMP{&$W}~iawE+)MaO{ygOw5EFdQ&*rM1W70l(i5 z6%`fWa5$)KVqyY%dwZd-t`6*WJEcNTPY?COa}@Q;%1WrNuD&H>ba2oO1&mBT`ms4@ zr=z2zFf}y=rKP1rd(;JNtEs7>XSBDs6Iciauex*%fx>$iFJAob1V)cF91atEaQ{Zv zCOl#rg3{R7n6bCh*4767{r$um1S@BNp(ixm>Ax@QCa{!&FNb zbLgs~>^77O*)D$#6o6oop=Sb-TkZlHR zNMLY;=ZZzYjw0L8&;S=NUIeSvdXspg?xfG?r`KWAeP){$7+Pbp1w9)u*bh@;U|;~c zySr0uWo2bljgU?08iR{eG^f*<6&PfUAvH!1>UL5|@9TEEsS4@e1Hr=dx^UqFrB!ip zG3gHK5rT$$J-3?R>8v$eD%}ZV&@i2bhK9iB^U*b|IBV9dfiq{$Ku1SM>ON#jb8~an z=g(ve<2NU>)%N)`ETtIy-Q51bDuk3ehicV0000< KMNUMnLSTY`18QLa literal 0 HcmV?d00001 diff --git a/plugin/buy_courses/src/ajax.php b/plugin/buy_courses/src/ajax.php new file mode 100644 index 0000000000..d131ad00fe --- /dev/null +++ b/plugin/buy_courses/src/ajax.php @@ -0,0 +1,26 @@ +'; + +$sql = "SELECT * FROM $tbl_course_description WHERE c_id = " . $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)) { + $descriptions[$description->id] = $description; + } + // Function that displays the details of the course description in html. + echo CourseManager::get_details_course_description_html($descriptions, api_get_system_encoding(), false); +} else { + echo get_lang('NoDescription'); +} \ No newline at end of file diff --git a/plugin/buy_courses/src/buy_course.lib.php b/plugin/buy_courses/src/buy_course.lib.php new file mode 100644 index 0000000000..d554f25b11 --- /dev/null +++ b/plugin/buy_courses/src/buy_course.lib.php @@ -0,0 +1,292 @@ + 0) { + $sql = "UPDATE plugin_buycourses SET synchronized='SI' WHERE id_course='" . $row['id'] . "';"; + Database::query($sql); + } else { + $sql = "INSERT INTO plugin_buycourses (id_course,visible,synchronized) VALUES ('" . $row['id'] . "','NO','SI');"; + Database::query($sql); + } + } + $sql = "DELETE FROM plugin_buycourses WHERE synchronized='NO';"; + Database::query($sql); +} + +function listado_cursos() +{ + $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM plugin_buycourses a, course 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() +{ + $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';"; + $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;"; + $tmp = Database::query($sql); + $fila = Database::fetch_assoc($tmp); + $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname']; + //Comprobamos si el alumno est� matriculado + 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); + if (Database::affected_rows() > 0) { + $row['matriculado'] = "SI"; + } else { + $sql = "SELECT 1 FROM plugin_bc_temporal WHERE course_code='" . $row['code'] . "' AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + $tmp2 = Database::query($sql); + if (Database::affected_rows() > 0) { + $row['matriculado'] = "TMP"; + } else { + $row['matriculado'] = "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); + if (Database::affected_rows() > 0) { + $row['matriculado'] = "TMP"; + } else { + $row['matriculado'] = "NO"; + } + } + //Comprobamos imagen + if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) { + $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png"; + } else { + $row['imagen_curso'] = "main/img/without_picture.png"; + } + $row['price'] = number_format($row['price'], 2, '.', ' '); + $aux[] = $row; + } + return $aux; +} + +function comprueba_curso_user($course, $user) +{ + $sql = "SELECT 1 FROM course_rel_user WHERE course_code='" . $course . "' AND user_id='" . $user . "';"; + $tmp = Database::query($sql); + if (Database::affected_rows() > 0) { + return true; + } else { + return false; + } +} + +function comprueba_curso_user_transf($course, $user) +{ + $sql = "SELECT 1 FROM plugin_bc_temporal WHERE course_code='" . $course . "' AND user_id='" . $user . "';"; + $tmp = Database::query($sql); + if (Database::affected_rows() > 0) { + return true; + } else { + return false; + } +} + +function listado_categorias() +{ + $sql = "SELECT code, name FROM course_category"; + $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) +{ + $style = 'margin-bottom:-5px;margin-right:5px;'; + switch ($v) { + case 0: + return Display::return_icon('bullet_red.gif', get_lang('CourseVisibilityClosed'), array('style' => $style)); + break; + case 1: + return Display::return_icon('bullet_orange.gif', get_lang('Private'), array('style' => $style)); + break; + case 2: + return Display::return_icon('bullet_green.gif', get_lang('OpenToThePlatform'), array('style' => $style)); + break; + case 3: + return Display::return_icon('bullet_blue.gif', get_lang('OpenToTheWorld'), array('style' => $style)); + break; + default: + return ''; + } +} + +function listado_monedas() +{ + $sql = "SELECT * FROM plugin_buycourses_countries 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"; + $res = Database::query($sql); + $aux = array(); + while ($row = Database::fetch_assoc($res)) { + $aux[] = $row; + } + return $aux; +} + +function parametros_paypal() +{ + $sql = "SELECT * FROM plugin_bc_paypal"; + $res = Database::query($sql); + $aux = array(); + $row = Database::fetch_assoc($res); + return $row; +} + +function parametros_transf() +{ + $sql = "SELECT * FROM plugin_bc_transf"; + $res = Database::query($sql); + $aux = array(); + while ($row = Database::fetch_assoc($res)) { + $aux[] = $row; + } + return $aux; +} + +function busca_moneda() +{ + $sql = "SELECT * FROM plugin_buycourses_countries WHERE status='1';"; + $res = Database::query($sql); + $aux = array(); + $row = Database::fetch_assoc($res); + return $row['currency_code']; +} + +function info_curso($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 . "';"; + $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;"; + $tmp = Database::query($sql); + $fila = Database::fetch_assoc($tmp); + $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname']; + //Comprobamos si el alumno est� matriculado + 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); + if (Database::affected_rows() > 0) { + $row['matriculado'] = "SI"; + } else { + $row['matriculado'] = "NO"; + } + } else { + $row['matriculado'] = "NO"; + } + //Comprobamos imagen + if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) { + $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png"; + } else { + $row['imagen_curso'] = "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) +{ + $salt = $letras_min ? 'abchefghknpqrstuvwxyz' : ''; + $salt .= $letras_max ? 'ACDEFHKNPRSTUVWXYZ' : ''; + $salt .= $num ? (strlen($salt) ? '2345679' : '0123456789') : ''; + + if (strlen($salt) == 0) { + return ''; + } + + $i = 0; + $str = ''; + + srand((double)microtime() * 1000000); + + while ($i < $long) { + $num = rand(0, strlen($salt) - 1); + $str .= substr($salt, $num, 1); + $i++; + } + + return $str; +} + +function calculateReference() +{ + $sql = "SELECT MAX(cod) FROM plugin_bc_temporal"; + $res = Database::query($sql); + $row = Database::fetch_assoc($res); + if ($row['MAX(cod)'] != '') { + $reference = $row['MAX(cod)']; + } else { + $reference = '1'; + } + $randomText = texto_aleatorio(); + $reference .= $randomText; + return $reference; +} + +function listado_pendientes() +{ + $sql = "SELECT * FROM plugin_bc_temporal;"; + $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/buy_course_plugin.class.php b/plugin/buy_courses/src/buy_course_plugin.class.php new file mode 100644 index 0000000000..d4fdfdb7f6 --- /dev/null +++ b/plugin/buy_courses/src/buy_course_plugin.class.php @@ -0,0 +1,63 @@ + + */ +class Buy_CoursesPlugin extends Plugin +{ + /** + * + * @return StaticPlugin + */ + static function create() + { + static $result = null; + return $result ? $result : $result = new self(); + } + + protected function __construct() + { + parent::__construct('1.0', 'Jose Angel Ruiz, Francis Gonzales', array('paypal_enable' => 'boolean', 'transference_enable' => 'boolean', 'unregistered_users_enable' => 'boolean')); + } + + /** + * This method creates the tables required to this plugin + */ + function install() + { + require_once api_get_path(SYS_PLUGIN_PATH) . 'buy_courses/database.php'; + } + + /** + * This method drops the plugin tables + */ + function uninstall() + { + $table = Database::get_main_table(TABLE_BUY_COURSE); + $sql = "DROP TABLE IF EXISTS $table"; + Database::query($sql); + + $table = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY); + $sql = "DROP TABLE IF EXISTS $table"; + Database::query($sql); + + $table = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL); + $sql = "DROP TABLE IF EXISTS $table"; + Database::query($sql); + + $table = Database::get_main_table(TABLE_BUY_COURSE_TRANSFERENCE); + $sql = "DROP TABLE IF EXISTS $table"; + Database::query($sql); + + $table = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); + $sql = "DROP TABLE IF EXISTS $table"; + Database::query($sql); + + $table = Database::get_main_table(TABLE_BUY_COURSE_SALE); + $sql = "DROP TABLE IF EXISTS $table"; + Database::query($sql); + } +} \ No newline at end of file diff --git a/plugin/buy_courses/src/configuration.php b/plugin/buy_courses/src/configuration.php new file mode 100644 index 0000000000..fe574c2025 --- /dev/null +++ b/plugin/buy_courses/src/configuration.php @@ -0,0 +1,43 @@ + "list.php", "name" => 'Listado de cursos a la venta'); +$interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => get_lang('Configuración pagos')); + +$tpl = new Template('Configuración de cursos disponibles'); + +$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'); + + $lista_cursos = listado_cursos(); + $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(); + + $tpl->assign('server', $_configuration['root_web']); + $tpl->assign('cursos', $lista_cursos); + $tpl->assign('visibilidad', $visibilidad); + $tpl->assign('ruta_imagen_ok', $ruta); + $tpl->assign('ruta_imagen_save', $ruta2); + $tpl->assign('moneda', $tipo_moneda); + + $listing_tpl = 'buy_courses/view/configuration.tpl'; + $content = $tpl->fetch($listing_tpl); + $tpl->assign('content', $content); + $tpl->display_one_col_template(); +} diff --git a/plugin/buy_courses/src/error.php b/plugin/buy_courses/src/error.php new file mode 100644 index 0000000000..6d714d551a --- /dev/null +++ b/plugin/buy_courses/src/error.php @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/plugin/buy_courses/src/expresscheckout.php b/plugin/buy_courses/src/expresscheckout.php new file mode 100644 index 0000000000..5784e6a24d --- /dev/null +++ b/plugin/buy_courses/src/expresscheckout.php @@ -0,0 +1,62 @@ + \ No newline at end of file diff --git a/plugin/buy_courses/src/func.php b/plugin/buy_courses/src/func.php new file mode 100644 index 0000000000..59aaafa66e --- /dev/null +++ b/plugin/buy_courses/src/func.php @@ -0,0 +1,371 @@ +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 course;"; + $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)); +} + +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 ($priceMin != '') { + if ($filtro == '') { + $filtro .= "a.price >= '" . $priceMin . "'"; + } else { + $filtro .= " AND a.price >= '" . $priceMin . "'"; + } + } + + if ($priceMax != '') { + if ($filtro == '') { + $filtro .= "a.price <= '" . $priceMax . "'"; + } else { + $filtro .= " AND a.price <= '" . $priceMax . "'"; + } + } + + if ($categoria != '') { + if ($filtro == '') { + $filtro .= "b.category_code='" . $categoria . "'"; + } else { + $filtro .= " AND b.category_code='" . $categoria . "'"; + } + } + + if ($filtro == '') { + $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';"; + } else { + $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 " . $filtro . ";"; + } + + //echo $sql; + $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;"; + $tmp = Database::query($sql); + $fila = Database::fetch_assoc($tmp); + $row['profesor'] = $fila['firstname'] . ' ' . $fila['lastname']; + //Comprobamos si el alumno est� matriculado + 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); + if (Database::affected_rows() > 0) { + $row['matriculado'] = "SI"; + } else { + $row['matriculado'] = "NO"; + } + } else { + $row['matriculado'] = "NO"; + } + //Comprobamos imagen + if (file_exists("../../../courses/" . $row['code'] . "/course-pic85x85.png")) { + $row['imagen_curso'] = "courses/" . $row['code'] . "/course-pic85x85.png"; + } else { + $row['imagen_curso'] = "main/img/without_picture.png"; + } + + if ($mostrar == "SI" && $row['matriculado'] == "SI") { + //No hacemos nada + } 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)); + +} + +if ($_REQUEST['tab'] == 'guardar_moneda') { + $id = $_REQUEST['moneda']; + $sql = "UPDATE plugin_buycourses_countries SET status='0';"; + $res = Database::query($sql); + $sql = "UPDATE plugin_buycourses_countries 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)); + } else { + $contenido = 'Guardado'; + echo json_encode(array("status" => "true", "contenido" => $contenido)); + } +} + +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']); + $sql = "UPDATE plugin_bc_paypal SET sandbox='" . $sandbox . "', username='" . $username . "', password='" . $password . "', signature='" . $signature . "' WHERE id='1';"; + //echo $sql; + $res = Database::query($sql); + if (!res) { + $contenido = 'Problema al guardar los parametros de paypal: ' . Database::error(); + echo json_encode(array("status" => "false", "contenido" => $contenido)); + } else { + $contenido = 'Guardado'; + echo json_encode(array("status" => "true", "contenido" => $contenido)); + } +} + +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']); + $sql = "INSERT INTO plugin_bc_transf (name, account, swift) VALUES ('" . $name . "','" . $account . "', '" . $swift . "');"; + //echo $sql; + + + $res = Database::query($sql); + if (!res) { + $contenido = 'Problema al insertar nueva cuenta: ' . Database::error(); + echo json_encode(array("status" => "false", "contenido" => $contenido)); + } else { + $contenido = 'Guardado'; + echo json_encode(array("status" => "true", "contenido" => $contenido)); + } +} + +if ($_REQUEST['tab'] == 'delete_account') { + $id = substr($_REQUEST['id'], 6); + $sql = "DELETE FROM plugin_bc_transf WHERE id='" . $id . "';"; + //echo $sql; + $res = Database::query($sql); + if (!res) { + $contenido = 'Problema al borrar la cuenta: ' . Database::error(); + echo json_encode(array("status" => "false", "contenido" => $contenido)); + } else { + $contenido = 'Guardado'; + echo json_encode(array("status" => "true", "contenido" => $contenido)); + } +} + +if ($_REQUEST['tab'] == 'guardar_mod') { + $id = substr($_REQUEST['id'], 5); + $visible = ($_REQUEST['visible'] == "checked") ? ('SI') : ('NO'); + $price = mysql_real_escape_string($_REQUEST['price']); + $obj = $_REQUEST['obj']; + + + $sql = "UPDATE plugin_buycourses 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)); + } else { + echo json_encode(array("status" => "true", "id" => $id)); + } +} + +if ($_REQUEST['tab'] == 'borrar_variables') { + unset($_SESSION['bc_user_id']); + unset($_SESSION['bc_registrado']); + unset($_SESSION['bc_curso_code']); + unset($_SESSION['bc_curso_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'; + unset($_SESSION['bc_url']); +} + +if ($_REQUEST['tab'] == 'borrar_pedido') { + $id = substr($_REQUEST['id'], 6); + $sql = "DELETE FROM plugin_bc_temporal WHERE cod='" . $id . "';"; + //echo $sql; + $res = Database::query($sql); + if (!res) { + $contenido = 'Problema al borrar la cuenta: ' . Database::error(); + echo json_encode(array("status" => "false", "contenido" => $contenido)); + } else { + $contenido = 'Guardado'; + echo json_encode(array("status" => "true", "contenido" => $contenido)); + } +} + +if ($_REQUEST['tab'] == 'confirmar_pedido') { + $id = substr($_REQUEST['id'], 6); + $sql = "SELECT * FROM plugin_bc_temporal WHERE cod='" . $id . "';"; + $res = Database::query($sql); + $row = Database::fetch_assoc($res); + + $seguir = 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; + } else { + $seguir = false; + } + //Activamos al usuario su cuenta + if ($seguir) { + $TABLE_USER = Database::get_main_table(TABLE_MAIN_USER); + // 1. set account inactive + $sql = "UPDATE " . $TABLE_USER . " SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'"; + Database::query($sql); + + $sql = "DELETE FROM plugin_bc_temporal WHERE cod='" . $id . "';"; + //echo $sql; + $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 activo='NO'"; + Database::query($sql); + $sql = "UPDATE plugin_bc_tpv SET activo='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(); + } else { + $contenido = "Guardado"; + } + 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 new file mode 100644 index 0000000000..0d40962aed --- /dev/null +++ b/plugin/buy_courses/src/index.buycourses.php @@ -0,0 +1,32 @@ +get('unregistered_users_enable'); + +if ($guess_enable == "true" || isset($_SESSION['_user'])) { + $title = "Listado de cursos en venta"; + + echo ''; +} + \ No newline at end of file diff --git a/plugin/buy_courses/src/inscription.php b/plugin/buy_courses/src/inscription.php new file mode 100644 index 0000000000..c95b3d5346 --- /dev/null +++ b/plugin/buy_courses/src/inscription.php @@ -0,0 +1,337 @@ +addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40)); + $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40)); + } else { + // LAST NAME and FIRST NAME + $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40)); + $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40)); + } + $form->applyFilter(array('lastname', 'firstname'), 'trim'); + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); + + // EMAIL + $form->addElement('text', 'email', get_lang('Email'), array('size' => 40)); + if (api_get_setting('registration', 'email') == 'true') { + $form->addRule('email', get_lang('ThisFieldIsRequired'), 'required'); + } + + if (api_get_setting('login_is_email') == 'true') { + $form->applyFilter('email', 'trim'); + if (api_get_setting('registration', 'email') != 'true') { + $form->addRule('email', get_lang('ThisFieldIsRequired'), 'required'); + } + $form->addRule('email', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); + $form->addRule('email', get_lang('UserTaken'), 'username_available'); + } + + $form->addRule('email', get_lang('EmailWrong'), 'email'); + if (api_get_setting('openid_authentication') == 'true') { + $form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40)); + } + + // USERNAME + if (api_get_setting('login_is_email') != 'true') { + $form->addElement('text', 'username', get_lang('UserName'), array('size' => USERNAME_MAX_LENGTH)); + $form->applyFilter('username', 'trim'); + $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required'); + $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); + $form->addRule('username', get_lang('UsernameWrong'), 'username'); + $form->addRule('username', get_lang('UserTaken'), 'username_available'); + } + + // PASSWORD + $form->addElement('password', 'pass1', get_lang('Pass'), array('size' => 20, 'autocomplete' => 'off')); + $form->addElement('password', 'pass2', get_lang('Confirmation'), array('size' => 20, 'autocomplete' => 'off')); + $form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required'); + $form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required'); + $form->addRule(array('pass1', 'pass2'), get_lang('PassTwo'), 'compare'); + + if (CHECK_PASS_EASY_TO_FIND) { + $form->addRule('password1', get_lang('PassTooEasy') . ': ' . api_generate_password(), 'callback', 'api_check_password'); + } + + // PHONE + $form->addElement('text', 'phone', get_lang('Phone'), array('size' => 20)); + if (api_get_setting('registration', 'phone') == 'true') { + $form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required'); + } + + // LANGUAGE + if (api_get_setting('registration', 'language') == 'true') { + $form->addElement('select_language', 'language', get_lang('Language')); + } + +} + +if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') { + $defaults['language'] = $_SESSION['user_language_choice']; +} else { + $defaults['language'] = api_get_setting('platformLanguage'); +} +if (!empty($_GET['username'])) { + $defaults['username'] = Security::remove_XSS($_GET['username']); +} +if (!empty($_GET['email'])) { + $defaults['email'] = Security::remove_XSS($_GET['email']); +} + +if (!empty($_GET['phone'])) { + $defaults['phone'] = Security::remove_XSS($_GET['phone']); +} + +if (api_get_setting('openid_authentication') == 'true' && !empty($_GET['openid'])) { + $defaults['openid'] = Security::remove_XSS($_GET['openid']); +} +$defaults['status'] = STUDENT; + +if (is_array($extra_data)) { + $defaults = array_merge($defaults, $extra_data); +} + +$form->setDefaults($defaults); + +$content = null; + +if (api_get_setting('allow_terms_conditions') == 'true') { + $get = array_keys($_GET); + if (isset($get)) { + if ($get[0] == 'legal') { + $language = api_get_interface_language(); + $language = api_get_language_id($language); + $term_preview = LegalManager::get_last_condition($language); + if (!$term_preview) { + //look for the default language + $language = api_get_setting('platformLanguage'); + $language = api_get_language_id($language); + $term_preview = LegalManager::get_last_condition($language); + } + $tool_name = get_lang('TermsAndConditions'); + Display :: display_header($tool_name); + + if (!empty($term_preview['content'])) { + echo $term_preview['content']; + } else { + echo get_lang('ComingSoon'); + } + Display :: display_footer(); + exit; + } + } +} + +$tool_name = get_lang('Registration', null, (!empty($_POST['language']) ? $_POST['language'] : $_user['language'])); + +if (api_get_setting('allow_terms_conditions') == 'true' && $user_already_registered_show_terms) { + $tool_name = get_lang('TermsAndConditions'); +} + +$home = api_get_path(SYS_PATH) . 'home/'; +if (api_is_multiple_url_enabled()) { + $access_url_id = api_get_current_access_url_id(); + if ($access_url_id != -1) { + $url_info = api_get_access_url($access_url_id); + $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url'])); + $clean_url = replace_dangerous_char($url); + $clean_url = str_replace('/', '-', $clean_url); + $clean_url .= '/'; + $home_old = api_get_path(SYS_PATH) . 'home/'; + $home = api_get_path(SYS_PATH) . 'home/' . $clean_url; + } +} + +if (file_exists($home . 'register_top_' . $user_selected_language . '.html')) { + $home_top_temp = @(string)file_get_contents($home . 'register_top_' . $user_selected_language . '.html'); + $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp); + $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); + if (!empty($open)) { + $content = '
    ' . $open . '
    '; + } +} + +$content .= Display::return_message(get_lang('YourAccountHasToBeApproved')); + +// Terms and conditions +if (api_get_setting('allow_terms_conditions') == 'true') { + $language = api_get_interface_language(); + $language = api_get_language_id($language); + $term_preview = LegalManager::get_last_condition($language); + + if (!$term_preview) { + //we load from the platform + $language = api_get_setting('platformLanguage'); + $language = api_get_language_id($language); + $term_preview = LegalManager::get_last_condition($language); + + //if is false we load from english + if (!$term_preview) { + $language = api_get_language_id('english'); //this must work + $term_preview = LegalManager::get_last_condition($language); + } + } + + // Version and language + $form->addElement('hidden', 'legal_accept_type', $term_preview['version'] . ':' . $term_preview['language_id']); + $form->addElement('hidden', 'legal_info', $term_preview['legal_id'] . ':' . $term_preview['language_id']); + + if ($term_preview['type'] == 1) { + $form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree') . ' ' . get_lang('TermsAndConditions') . ''); + $form->addRule('legal_accept', get_lang('ThisFieldIsRequired'), 'required'); + } else { + $preview = LegalManager::show_last_condition($term_preview); + $form->addElement('label', null, $preview); + } +} + +$form->addElement('button', 'submit', get_lang('RegisterUser'), array('class' => 'btn btn-primary btn-large')); + +if ($form->validate()) { + $values = $form->exportValues(); + $values['username'] = api_substr($values['username'], 0, USERNAME_MAX_LENGTH); //make *sure* the login isn't too long + $values['status'] = STUDENT; + $values['official_code'] = api_strtoupper($values['username']); + + if (api_get_setting('login_is_email') == 'true') { + $values['username'] = $values['email']; + } + + // Creates a new user + $user_id = UserManager::create_user($values['firstname'], $values['lastname'], $values['status'], $values['email'], $values['username'], $values['pass1'], $values['official_code'], $values['language'], $values['phone'], $picture_uri, PLATFORM_AUTH_SOURCE, null, 1, 0, null, null, true); + + // Register extra fields + $extras = array(); + foreach ($values as $key => $value) { + if (substr($key, 0, 6) == 'extra_') { //an extra field + $extras[substr($key, 6)] = $value; + } + } + + //update the extra fields + $count_extra_field = count($extras); + if ($count_extra_field > 0) { + foreach ($extras as $key => $value) { + UserManager::update_extra_field_value($user_id, $key, $value); + } + } + + if ($user_id) { + // storing the extended profile + $store_extended = false; + $sql = "UPDATE " . Database::get_main_table(TABLE_MAIN_USER) . " SET "; + if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true') { + $sql_set[] = "competences = '" . Database::escape_string($values['competences']) . "'"; + $store_extended = true; + } + if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true') { + $sql_set[] = "diplomas = '" . Database::escape_string($values['diplomas']) . "'"; + $store_extended = true; + } + if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'myteach') == 'true') { + $sql_set[] = "teach = '" . Database::escape_string($values['teach']) . "'"; + $store_extended = true; + } + if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true') { + $sql_set[] = "openarea = '" . Database::escape_string($values['openarea']) . "'"; + $store_extended = true; + } + if ($store_extended) { + $sql .= implode(',', $sql_set); + $sql .= " WHERE user_id = '" . Database::escape_string($user_id) . "'"; + Database::query($sql); + } + + // if there is a default duration of a valid account then we have to change the expiration_date accordingly + if (api_get_setting('account_valid_duration') != '') { + $sql = "UPDATE " . Database::get_main_table(TABLE_MAIN_USER) . " SET expiration_date='registration_date+1' WHERE user_id='" . $user_id . "'"; + Database::query($sql); + } + + // if the account has to be approved then we set the account to inactive, sent a mail to the platform admin and exit the page. + + $TABLE_USER = Database::get_main_table(TABLE_MAIN_USER); + // 1. set account inactive + $sql = "UPDATE " . $TABLE_USER . " SET active='0' WHERE user_id='" . $user_id . "'"; + Database::query($sql); + } + + + // Terms & Conditions + if (api_get_setting('allow_terms_conditions') == 'true') { + // update the terms & conditions + + if (isset($values['legal_accept_type'])) { + $cond_array = explode(':', $values['legal_accept_type']); + if (!empty($cond_array[0]) && !empty($cond_array[1])) { + $time = time(); + $condition_to_save = intval($cond_array[0]) . ':' . intval($cond_array[1]) . ':' . $time; + UserManager::update_extra_field_value($user_id, 'legal_accept', $condition_to_save); + } + } + $values = api_get_user_info($user_id); + } + + /* SESSION REGISTERING */ + /* @todo move this in a function */ + $_user['firstName'] = stripslashes($values['firstname']); + $_user['lastName'] = stripslashes($values['lastname']); + $_user['mail'] = $values['email']; + $_user['language'] = $values['language']; + $_user['user_id'] = $user_id; + $_user['username'] = $values['username']; + Session::write('bc_user', $_user); + header('Location:process.php'); +} else { + + Display :: display_header($tool_name); + echo Display::page_header($tool_name); + echo $content; + $form->display(); + Display :: display_footer(); +} diff --git a/plugin/buy_courses/src/list.php b/plugin/buy_courses/src/list.php new file mode 100644 index 0000000000..d8cdab4ff6 --- /dev/null +++ b/plugin/buy_courses/src/list.php @@ -0,0 +1,58 @@ + "configuration.php", "name" => $plugin->get_lang('bc_setting_courses_available')); + $interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => $plugin->get_lang('bc_setting_pay')); +} +//echo var_dump($_SESSION); +//exit; +$tpl = new Template('Listado Cursos en venta'); + +//api_protect_course_script(true); + +if (isset($_SESSION['bc_exito'])) { + $tpl->assign('rmensaje', 'SI'); + if ($_SESSION['bc_exito'] == true) { + $message = sprintf(utf8_encode($plugin->get_lang($_SESSION['bc_mensaje'])), $_SESSION['bc_url']); + unset($_SESSION['bc_url']); + $tpl->assign('estilo', 'confirmation-message'); + } else { + $message = utf8_encode($plugin->get_lang($_SESSION['bc_mensaje'])); + $tpl->assign('estilo', 'warning-message'); + } + $tpl->assign('mensaje', $message); + unset($_SESSION['bc_exito']); + unset($_SESSION['bc_mensaje']); + +} else { + $tpl->assign('rmensaje', 'NO'); +} + +$lista_cursos = listado_cursos_user(); +$lista_categorias = listado_categorias(); +$tipo_moneda = busca_moneda(); + +$tpl->assign('server', $_configuration['root_web']); +$tpl->assign('cursos', $lista_cursos); +$tpl->assign('categorias', $lista_categorias); +$tpl->assign('moneda', $tipo_moneda); + +$listing_tpl = 'buy_courses/view/list.tpl'; +$content = $tpl->fetch($listing_tpl); +$tpl->assign('content', $content); +$tpl->display_one_col_template(); diff --git a/plugin/buy_courses/src/paymentsetup.php b/plugin/buy_courses/src/paymentsetup.php new file mode 100644 index 0000000000..685cf30930 --- /dev/null +++ b/plugin/buy_courses/src/paymentsetup.php @@ -0,0 +1,54 @@ + "list.php", "name" => 'Listado de cursos a la venta'); +$interbreadcrumb[] = array("url" => "configuration.php", "name" => get_lang('Configuración de cursos disponibles')); + +$tpl = new Template('Configuración de Pagos'); + +$teacher = api_is_platform_admin(); +api_protect_course_script(true); + +if ($teacher) { + // SINCRONIZAR TABLA DE CURSOS CON TABLA DEL PLUGIN + $lista_monedas = listado_monedas(); + + $param_paypal = parametros_paypal(); + $param_transf = parametros_transf(); + + $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'; + $ruta3 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/more.png'; + $ruta4 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/borrar.png'; + $ruta5 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/acces_tool.gif'; + + $plugin = Buy_CoursesPlugin::create(); + $paypal_enable = $plugin->get('paypal_enable'); + $tarjeta_enable = $plugin->get('tarjet_credit_enable'); + $transference_enable = $plugin->get('transference_enable'); + + $tpl->assign('server', $_configuration['root_web']); + $tpl->assign('monedas', $lista_monedas); + $tpl->assign('paypal', $param_paypal); + $tpl->assign('transferencia', $param_transf); + $tpl->assign('ruta_imagen_ok', $ruta); + $tpl->assign('ruta_imagen_save', $ruta2); + $tpl->assign('ruta_more', $ruta3); + $tpl->assign('ruta_borrar', $ruta4); + $tpl->assign('ruta_ver', $ruta5); + $tpl->assign('paypal_enable', $paypal_enable); + $tpl->assign('tarjeta_enable', $tarjeta_enable); + $tpl->assign('transference_enable', $transference_enable); + + + $listing_tpl = 'buy_courses/view/paymentsetup.tpl'; + $content = $tpl->fetch($listing_tpl); + $tpl->assign('content', $content); + $tpl->display_one_col_template(); +} diff --git a/plugin/buy_courses/src/paypalfunctions.php b/plugin/buy_courses/src/paypalfunctions.php new file mode 100644 index 0000000000..ca563d5943 --- /dev/null +++ b/plugin/buy_courses/src/paypalfunctions.php @@ -0,0 +1,573 @@ + with your API Username +//' Replace with your API Password +//' Replace with your Signature +//'------------------------------------ +//$API_UserName="vendedor_api1.calidadeorigen.com"; +//$API_Password="1385456693"; +//$API_Signature="An5ns1Kso7MWUdW4ErQKJJJ4qi4-AmFnLvPhhq5VHgESNLWwWusSKk4T"; + +$API_UserName = $paypal_username; +$API_Password = $paypal_password; +$API_Signature = $paypal_firma; + +// BN Code is only applicable for partners +$sBNCode = "PP-ECWizard"; + + +/* +' Define the PayPal Redirect URLs. +' This is the URL that the buyer is first sent to do authorize payment with their paypal account +' change the URL depending if you are testing on the sandbox or the live PayPal site +' +' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= +' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= +*/ + +if ($SandboxFlag == true) { + $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; + $PAYPAL_URL = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; +} else { + $API_Endpoint = "https://api-3t.paypal.com/nvp"; + $PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; +} + +$USE_PROXY = false; +$version = "93"; + +if (session_id() == "") + session_start(); + +/* An express checkout transaction starts with a token, that + identifies to PayPal your transaction + In this example, when the script sees a token, the script + knows that the buyer has already authorized payment through + paypal. If no token was found, the action is to send the buyer + to PayPal to first authorize payment + */ + +/* +'------------------------------------------------------------------------------------------------------------------------------------------- +' Purpose: Prepares the parameters for the SetExpressCheckout API Call. +' Inputs: +' paymentAmount: Total value of the shopping cart +' currencyCodeType: Currency code value the PayPal API +' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization +' returnURL: the page where buyers return to after they are done with the payment review on PayPal +' cancelURL: the page where buyers return to when they cancel the payment review on PayPal +'-------------------------------------------------------------------------------------------------------------------------------------------- +*/ +function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $extra) +{ + //------------------------------------------------------------------------------------------------------------------------------------ + // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation + + $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType; + $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL; + $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType; + + $nvpstr = $nvpstr . $extra; + //echo $nvpstr; + //exit; + + $_SESSION["currencyCodeType"] = $currencyCodeType; + $_SESSION["PaymentType"] = $paymentType; + + //'--------------------------------------------------------------------------------------------------------------- + //' Make the API call to PayPal + //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. + //' If an error occured, show the resulting errors + //'--------------------------------------------------------------------------------------------------------------- + $resArray = hash_call("SetExpressCheckout", $nvpstr); + $ack = strtoupper($resArray["ACK"]); + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { + $token = urldecode($resArray["TOKEN"]); + $_SESSION['TOKEN'] = $token; + } + + return $resArray; +} + +/* +'------------------------------------------------------------------------------------------------------------------------------------------- +' Purpose: Prepares the parameters for the SetExpressCheckout API Call. +' Inputs: +' paymentAmount: Total value of the shopping cart +' currencyCodeType: Currency code value the PayPal API +' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization +' returnURL: the page where buyers return to after they are done with the payment review on PayPal +' cancelURL: the page where buyers return to when they cancel the payment review on PayPal +' shipToName: the Ship to name entered on the merchant's site +' shipToStreet: the Ship to Street entered on the merchant's site +' shipToCity: the Ship to City entered on the merchant's site +' shipToState: the Ship to State entered on the merchant's site +' shipToCountryCode: the Code for Ship to Country entered on the merchant's site +' shipToZip: the Ship to ZipCode entered on the merchant's site +' shipToStreet2: the Ship to Street2 entered on the merchant's site +' phoneNum: the phoneNum entered on the merchant's site +'-------------------------------------------------------------------------------------------------------------------------------------------- +*/ +function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, + $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState, + $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum +) +{ + //------------------------------------------------------------------------------------------------------------------------------------ + // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation + + $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType; + $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL; + $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType; + $nvpstr = $nvpstr . "&ADDROVERRIDE=1"; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTONAME=" . $shipToName; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTREET=" . $shipToStreet; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTREET2=" . $shipToStreet2; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOCITY=" . $shipToCity; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTATE=" . $shipToState; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=" . $shipToCountryCode; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOZIP=" . $shipToZip; + $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOPHONENUM=" . $phoneNum; + + $_SESSION["currencyCodeType"] = $currencyCodeType; + $_SESSION["PaymentType"] = $paymentType; + + //'--------------------------------------------------------------------------------------------------------------- + //' Make the API call to PayPal + //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. + //' If an error occured, show the resulting errors + //'--------------------------------------------------------------------------------------------------------------- + $resArray = hash_call("SetExpressCheckout", $nvpstr); + $ack = strtoupper($resArray["ACK"]); + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { + $token = urldecode($resArray["TOKEN"]); + $_SESSION['TOKEN'] = $token; + } + + return $resArray; +} + +/* +'------------------------------------------------------------------------------------------- +' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. +' +' Inputs: +' None +' Returns: +' The NVP Collection object of the GetExpressCheckoutDetails Call Response. +'------------------------------------------------------------------------------------------- +*/ + +function GetShippingDetails($token) +{ + //'-------------------------------------------------------------- + //' At this point, the buyer has completed authorizing the payment + //' at PayPal. The function will call PayPal to obtain the details + //' of the authorization, incuding any shipping information of the + //' buyer. Remember, the authorization is not a completed transaction + //' at this state - the buyer still needs an additional step to finalize + //' the transaction + //'-------------------------------------------------------------- + + //'--------------------------------------------------------------------------- + //' Build a second API request to PayPal, using the token as the + //' ID to get the details on the payment authorization + //'--------------------------------------------------------------------------- + $nvpstr = "&TOKEN=" . $token; + + //'--------------------------------------------------------------------------- + //' Make the API call and store the results in an array. + //' If the call was a success, show the authorization details, and provide + //' an action to complete the payment. + //' If failed, show the error + //'--------------------------------------------------------------------------- + $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); + $ack = strtoupper($resArray["ACK"]); + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { + $_SESSION['payer_id'] = $resArray['PAYERID']; + } + return $resArray; +} + +/* +'------------------------------------------------------------------------------------------------------------------------------------------- + +' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. + +' + +' Inputs: + +' sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart. + +' Returns: + +' The NVP Collection object of the GetExpressCheckoutDetails Call Response. + +'-------------------------------------------------------------------------------------------------------------------------------------------- + +*/ + +function ConfirmPayment($FinalPaymentAmt) + +{ + + /* Gather the information to make the final call to + + finalize the PayPal payment. The variable nvpstr + + holds the name value pairs + + */ + + + //Format the other parameters that were stored in the session from the previous calls + + $token = urlencode($_SESSION['TOKEN']); + + $paymentType = urlencode($_SESSION['PaymentType']); + + $currencyCodeType = urlencode($_SESSION['currencyCodeType']); + + $payerID = urlencode($_SESSION['payer_id']); + + + $serverName = urlencode($_SERVER['SERVER_NAME']); + + + $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt; + + $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName; + + + /* Make the call to PayPal to finalize payment + + If an error occured, show the resulting errors + + */ + + $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr); + + + /* Display the API response back to the browser. + + If the response from PayPal was a success, display the response parameters' + + If the response was an error, display the errors received using APIError.php. + + */ + + $ack = strtoupper($resArray["ACK"]); + + + return $resArray; + +} + + +/* + +'------------------------------------------------------------------------------------------------------------------------------------------- + +' Purpose: This function makes a DoDirectPayment API call + +' + +' Inputs: + +' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization + +' paymentAmount: total value of the shopping cart + +' currencyCode: currency code value the PayPal API + +' firstName: first name as it appears on credit card + +' lastName: last name as it appears on credit card + +' street: buyer's street address line as it appears on credit card + +' city: buyer's city + +' state: buyer's state + +' countryCode: buyer's country code + +' zip: buyer's zip + +' creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... ) + +' creditCardNumber: buyers credit card number without any spaces, dashes or any other characters + +' expDate: credit card expiration date + +' cvv2: Card Verification Value + +' + +'------------------------------------------------------------------------------------------- + +' + +' Returns: + +' The NVP Collection object of the DoDirectPayment Call Response. + +'-------------------------------------------------------------------------------------------------------------------------------------------- + +*/ + + +function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, + + $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, + + $countryCode, $currencyCode) + +{ + + //Construct the parameter string that describes DoDirectPayment + + $nvpstr = "&AMT=" . $paymentAmount; + + $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCode; + + $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType; + + $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . $creditCardType; + + $nvpstr = $nvpstr . "&ACCT=" . $creditCardNumber; + + $nvpstr = $nvpstr . "&EXPDATE=" . $expDate; + + $nvpstr = $nvpstr . "&CVV2=" . $cvv2; + + $nvpstr = $nvpstr . "&FIRSTNAME=" . $firstName; + + $nvpstr = $nvpstr . "&LASTNAME=" . $lastName; + + $nvpstr = $nvpstr . "&STREET=" . $street; + + $nvpstr = $nvpstr . "&CITY=" . $city; + + $nvpstr = $nvpstr . "&STATE=" . $state; + + $nvpstr = $nvpstr . "&COUNTRYCODE=" . $countryCode; + + $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR']; + + + $resArray = hash_call("DoDirectPayment", $nvpstr); + + + return $resArray; + +} + + +/** + * + * '------------------------------------------------------------------------------------------------------------------------------------------- + * hash_call: Function to perform the API call to PayPal using API signature + * @methodName is name of API method. + * @nvpStr is nvp string. + * returns an associtive array containing the response from the server. + * + * '------------------------------------------------------------------------------------------------------------------------------------------- + + */ + +function hash_call($methodName, $nvpStr) + +{ + + //declaring of global variables + + global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature; + + global $USE_PROXY, $PROXY_HOST, $PROXY_PORT; + + global $gv_ApiErrorURL; + + global $sBNCode; + + + //setting the curl parameters. + + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $API_Endpoint); + + curl_setopt($ch, CURLOPT_VERBOSE, 1); + + + //turning off the server and peer verification(TrustManager Concept). + + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); + + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + curl_setopt($ch, CURLOPT_POST, 1); + + + //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. + + //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php + + if ($USE_PROXY) + + curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT); + + + //NVPRequest for submitting to server + + $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode); + + + //setting the nvpreq as POST FIELD to curl + + curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); + + + //getting response from server + + $response = curl_exec($ch); + + + //convrting NVPResponse to an Associative Array + + $nvpResArray = deformatNVP($response); + + $nvpReqArray = deformatNVP($nvpreq); + + $_SESSION['nvpReqArray'] = $nvpReqArray; + + + if (curl_errno($ch)) { + + // moving to display page to display curl errors + + $_SESSION['curl_error_no'] = curl_errno($ch); + + $_SESSION['curl_error_msg'] = curl_error($ch); + + + //Execute the Error handling module to display errors. + + } else { + + //closing the curl + + curl_close($ch); + + } + + + return $nvpResArray; + +} + + +/*'---------------------------------------------------------------------------------- + + Purpose: Redirects to PayPal.com site. + + Inputs: NVP string. + + Returns: + +---------------------------------------------------------------------------------- + +*/ + +function RedirectToPayPal($token) + +{ + + global $PAYPAL_URL; + + + // Redirect to paypal.com here + + $payPalURL = $PAYPAL_URL . $token; + + header("Location: " . $payPalURL); + + exit; + +} + + +/*'---------------------------------------------------------------------------------- + + * This function will take NVPString and convert it to an Associative Array and it will decode the response. + + * It is usefull to search for a particular key and displaying arrays. + + * @nvpstr is NVPString. + + * @nvpArray is Associative Array. + + ---------------------------------------------------------------------------------- + + */ + +function deformatNVP($nvpstr) + +{ + + $intial = 0; + + $nvpArray = array(); + + + while (strlen($nvpstr)) { + + //postion of Key + + $keypos = strpos($nvpstr, '='); + + //position of value + + $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr); + + + /*getting the Key and Value values and storing in a Associative Array*/ + + $keyval = substr($nvpstr, $intial, $keypos); + + $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1); + + //decoding the respose + + $nvpArray[urldecode($keyval)] = urldecode($valval); + + $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr)); + + } + + return $nvpArray; + +} + + +?> \ No newline at end of file diff --git a/plugin/buy_courses/src/pending_orders.php b/plugin/buy_courses/src/pending_orders.php new file mode 100644 index 0000000000..7ddfd9526a --- /dev/null +++ b/plugin/buy_courses/src/pending_orders.php @@ -0,0 +1,36 @@ + "list.php", "name" => 'Listado de cursos a la venta'); +$interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => get_lang('Configuración pagos')); + + +$tpl = new Template('Configuración de cursos disponibles'); + +$teacher = api_is_platform_admin(); +api_protect_course_script(true); + +if ($teacher) { + $lista_pendientes = listado_pendientes(); + $ruta = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png'; + $ruta2 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/borrar.png'; + $tipo_moneda = busca_moneda(); + + + $tpl->assign('server', $_configuration['root_web']); + $tpl->assign('pendientes', $lista_pendientes); + $tpl->assign('ruta_imagen_ok', $ruta); + $tpl->assign('ruta_imagen_borrar', $ruta2); + $tpl->assign('moneda', $tipo_moneda); + + $listing_tpl = 'buy_courses/view/pending_orders.tpl'; + $content = $tpl->fetch($listing_tpl); + $tpl->assign('content', $content); + $tpl->display_one_col_template(); +} diff --git a/plugin/buy_courses/src/process.php b/plugin/buy_courses/src/process.php new file mode 100644 index 0000000000..abee32f399 --- /dev/null +++ b/plugin/buy_courses/src/process.php @@ -0,0 +1,81 @@ + "list.php", "name" => 'Listado de cursos a la venta'); + +$tpl = new Template('Tipo de pago'); + +if (isset($_GET['code'])) { + $code = (int)$_GET['code']; +} else { + $code = $_SESSION['bc_curso_code']; +} +$sql = "SELECT price, title, code FROM plugin_buycourses a, course b WHERE a.id_course='" . $code . "' AND a.id_course=b.id;"; +$res = Database::query($sql); +$row = Database::fetch_assoc($res); +$_SESSION['Payment_Amount'] = number_format($row['price'], 2, '.', ''); +$_SESSION['bc_curso_code'] = $code; +$_SESSION['bc_curso_title'] = $row['title']; +$_SESSION['bc_curso_codetext'] = $row['code']; + +if (!isset($_SESSION['_user'])) { + //Necesita registro + if (!isset($_SESSION['bc_user'])) { + header('Location:inscription.php'); + exit; + } else { + $_SESSION['bc_user_id'] = $_SESSION['bc_user']['user_id']; + $tpl->assign('name', $_SESSION['bc_user']['firstName'] . ' ' . $_SESSION['bc_user']['lastName']); + $tpl->assign('email', $_SESSION['bc_user']['mail']); + $tpl->assign('user', $_SESSION['bc_user']['username']); + } +} else { + $_SESSION['bc_user_id'] = $_SESSION['_user']['user_id']; + $_SESSION['bc_user'] = $_SESSION['_user']; + $tpl->assign('name', $_SESSION['bc_user']['firstname'] . ' ' . $_SESSION['bc_user']['lastname']); + $tpl->assign('email', $_SESSION['bc_user']['email']); + $tpl->assign('user', $_SESSION['bc_user']['username']); +} + +if (comprueba_curso_user($_SESSION['bc_curso_codetext'], $_SESSION['bc_user_id'])) { + $_SESSION['bc_exito'] = false; + $_SESSION['bc_mensaje'] = 'AlreadyBuy'; + header('Location: list.php'); +} + +if (comprueba_curso_user_transf($_SESSION['bc_curso_codetext'], $_SESSION['bc_user_id'])) { + $_SESSION['bc_exito'] = false; + $_SESSION['bc_mensaje'] = 'bc_tmp_registrado'; + header('Location: list.php'); +} +//echo var_dump($_SESSION); +//exit; +$tipo_moneda = busca_moneda(); + +$plugin = Buy_CoursesPlugin::create(); +$paypal_enable = $plugin->get('paypal_enable'); +$tarjeta_enable = $plugin->get('tarjet_credit_enable'); +$transference_enable = $plugin->get('transference_enable'); + +$infocurso = info_curso($code); + +$tpl->assign('curso', $infocurso); +$tpl->assign('server', $_configuration['root_web']); +$tpl->assign('paypal_enable', $paypal_enable); +$tpl->assign('tarjeta_enable', $tarjeta_enable); +$tpl->assign('transference_enable', $transference_enable); +$tpl->assign('title', $_SESSION['bc_curso_title']); +$tpl->assign('price', $_SESSION['Payment_Amount']); +$tpl->assign('moneda', $tipo_moneda); + + +$listing_tpl = 'buy_courses/view/process.tpl'; +$content = $tpl->fetch($listing_tpl); +$tpl->assign('content', $content); +$tpl->display_one_col_template(); diff --git a/plugin/buy_courses/src/process_confirm.php b/plugin/buy_courses/src/process_confirm.php new file mode 100644 index 0000000000..d1a2f79168 --- /dev/null +++ b/plugin/buy_courses/src/process_confirm.php @@ -0,0 +1,168 @@ +'; + foreach ($accountsList as $account) { + $texto .= ''; + $texto .= ''; + } + $texto .= '

    Datos Bancarios

    '; + $texto .= '' . htmlspecialchars($account['name']) . '
    '; + if ($account['swift'] != '') { + $texto .= 'SWIFT: ' . htmlspecialchars($account['swift']) . '
    '; + } + $texto .= 'Cuenta Bancaria: ' . htmlspecialchars($account['account']) . '
    '; + $texto .= '
    '; + + $plugin = Buy_CoursesPlugin::create(); + $asunto = utf8_encode($plugin->get_lang('bc_subject')); + + + if (!isset($_SESSION['_user'])) { + $name = $_SESSION['bc_user']['firstName'] . ' ' . $_SESSION['bc_user']['lastName']; + $email = $_SESSION['bc_user']['mail']; + } else { + $name = $_SESSION['bc_user']['firstname'] . ' ' . $_SESSION['bc_user']['lastname']; + $email = $_SESSION['bc_user']['email']; + } + + $datos_curso = info_curso($_SESSION['bc_curso_code']); + $title_curso = $datos_curso['title']; + + $message = utf8_encode($plugin->get_lang('bc_message')); + $message = str_replace("{{name}}", $name, $message); + $message = str_replace("{{curso}}", $title_curso, $message); + $message = str_replace("{{reference}}", $reference, $message); + $message .= $texto; + + api_mail($name, $email, $asunto, $message); + // Volvemos al listado de cursos + header('Location:list.php'); +} + + +$tipomoneda = $_POST['tipomoneda']; +$_SESSION['bc_tipomoneda'] = $tipomoneda; +$server = $_POST['server']; + +if ($_POST['payment_type'] == "PayPal") { + $sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + $res = Database::query($sql); + $row = Database::fetch_assoc($res); + $pruebas = ($row['sandbox'] == "SI") ? (true) : (false); + $paypal_username = $row['username']; + $paypal_password = $row['password']; + $paypal_firma = $row['signature']; + require_once("function/paypalfunctions.php"); + // ================================== + // PayPal Express Checkout Module + // ================================== + $paymentAmount = $_SESSION["Payment_Amount"]; + $currencyCodeType = $tipomoneda; + $paymentType = "Sale"; + $returnURL = $server . "plugin/buy_courses/success.php"; + $cancelURL = $server . "plugin/buy_courses/error.php"; + + $datos_curso = info_curso($_SESSION['bc_curso_code']); + $title_curso = $datos_curso['title']; + $i = 0; + $extra = "&L_PAYMENTREQUEST_0_NAME" . $i . "=" . $title_curso; + $extra .= "&L_PAYMENTREQUEST_0_AMT" . $i . "=" . $paymentAmount; + $extra .= "&L_PAYMENTREQUEST_0_QTY" . $i . "=1"; + + $resArray = CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $extra); + $ack = strtoupper($resArray["ACK"]); + + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { + RedirectToPayPal($resArray["TOKEN"]); + } else { + //Mostrar errores + $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); + $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); + $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); + $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); + + echo "
    SetExpressCheckout API call failed. "; + echo "
    Detailed Error Message: " . $ErrorLongMsg; + echo "
    Short Error Message: " . $ErrorShortMsg; + echo "
    Error Code: " . $ErrorCode; + echo "
    Error Severity Code: " . $ErrorSeverityCode; + + } +} + +if ($_POST['payment_type'] == "Transferencia") { + $_cid = 0; + $interbreadcrumb[] = array("url" => "list.php", "name" => 'Listado de cursos a la venta'); + + $tpl = new Template('Tipo de pago'); + + $code = $_SESSION['bc_curso_code']; + $infocurso = info_curso($code); + + $tpl->assign('curso', $infocurso); + $tpl->assign('server', $_configuration['root_web']); + $tpl->assign('title', $_SESSION['bc_curso_title']); + $tpl->assign('price', $_SESSION['Payment_Amount']); + $tpl->assign('moneda', $_SESSION['bc_tipomoneda']); + if (!isset($_SESSION['_user'])) { + $tpl->assign('name', $_SESSION['bc_user']['firstName'] . ' ' . $_SESSION['bc_user']['lastName']); + $tpl->assign('email', $_SESSION['bc_user']['mail']); + $tpl->assign('user', $_SESSION['bc_user']['username']); + } else { + $tpl->assign('name', $_SESSION['bc_user']['firstname'] . ' ' . $_SESSION['bc_user']['lastname']); + $tpl->assign('email', $_SESSION['bc_user']['email']); + $tpl->assign('user', $_SESSION['bc_user']['username']); + } + + //Obtenemos el listado de cuentas bancarias. + $accountsList = listAccounts(); + $tpl->assign('accounts', $accountsList); + + $listing_tpl = 'buy_courses/view/process_confirm.tpl'; + $content = $tpl->fetch($listing_tpl); + $tpl->assign('content', $content); + $tpl->display_one_col_template(); +} + +?> diff --git a/plugin/buy_courses/src/success.php b/plugin/buy_courses/src/success.php new file mode 100644 index 0000000000..045e78a154 --- /dev/null +++ b/plugin/buy_courses/src/success.php @@ -0,0 +1,331 @@ + "list.php", "name" => 'Listado de cursos a la venta'); + + $tpl = new Template('Tipo de pago'); + + $code = $_SESSION['bc_curso_code']; + $infocurso = info_curso($code); + + $tpl->assign('curso', $infocurso); + $tpl->assign('server', $_configuration['root_web']); + $tpl->assign('title', $_SESSION['bc_curso_title']); + $tpl->assign('price', $_SESSION['Payment_Amount']); + $tpl->assign('moneda', $_SESSION['bc_tipomoneda']); + if (!isset($_SESSION['_user'])) { + $tpl->assign('name', $_SESSION['bc_user']['firstName'] . ' ' . $_SESSION['bc_user']['lastName']); + $tpl->assign('email', $_SESSION['bc_user']['mail']); + $tpl->assign('user', $_SESSION['bc_user']['username']); + } else { + $tpl->assign('name', $_SESSION['bc_user']['firstname'] . ' ' . $_SESSION['bc_user']['lastname']); + $tpl->assign('email', $_SESSION['bc_user']['email']); + $tpl->assign('user', $_SESSION['bc_user']['username']); + } + + + $listing_tpl = 'buy_courses/success.tpl'; + $content = $tpl->fetch($listing_tpl); + $tpl->assign('content', $content); + $tpl->display_one_col_template(); + +} else { + /*================================================================== + PayPal Express Checkout Call + =================================================================== + */ + $PaymentOption = $_POST['paymentOption']; + $sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + $res = Database::query($sql); + $row = Database::fetch_assoc($res); + $paypal_username = $row['username']; + $paypal_password = $row['password']; + $paypal_firma = $row['signature']; + require_once("function/paypalfunctions.php"); + if ($PaymentOption == "PayPal") { + /* + '------------------------------------ + ' The paymentAmount is the total value of + ' the shopping cart, that was set + ' earlier in a session variable + ' by the shopping cart page + '------------------------------------ + */ + $finalPaymentAmount = $_SESSION["Payment_Amount"]; + /* + '------------------------------------ + ' Calls the DoExpressCheckoutPayment API call + ' + ' The ConfirmPayment function is defined in the file PayPalFunctions.jsp, + ' that is included at the top of this file. + '------------------------------------------------- + */ + $resArray = ConfirmPayment($finalPaymentAmount); + $ack = strtoupper($resArray["ACK"]); + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { + /* + '******************************************************************************************************************** + ' + ' THE PARTNER SHOULD SAVE THE KEY TRANSACTION RELATED INFORMATION LIKE + ' transactionId & orderTime + ' IN THEIR OWN DATABASE + ' AND THE REST OF THE INFORMATION CAN BE USED TO UNDERSTAND THE STATUS OF THE PAYMENT + ' + '******************************************************************************************************************** + */ + + $transactionId = $resArray["PAYMENTINFO_0_TRANSACTIONID"]; // ' Unique transaction ID of the payment. Note: If the PaymentAction of the request was Authorization or Order, this value is your AuthorizationID for use with the Authorization & Capture APIs. + $transactionType = $resArray["PAYMENTINFO_0_TRANSACTIONTYPE"]; //' The type of transaction Possible values: l cart l express-checkout + $paymentType = $resArray["PAYMENTINFO_0_PAYMENTTYPE"]; //' Indicates whether the payment is instant or delayed. Possible values: l none l echeck l instant + $orderTime = $resArray["PAYMENTINFO_0_ORDERTIME"]; //' Time/date stamp of payment + $amt = $resArray["PAYMENTINFO_0_AMT"]; //' The final amount charged, including any shipping and taxes from your Merchant Profile. + $currencyCode = $resArray["PAYMENTINFO_0_CURRENCYCODE"]; //' A three-character currency code for one of the currencies listed in PayPay-Supported Transactional Currencies. Default: USD. + $feeAmt = $resArray["PAYMENTINFO_0_FEEAMT"]; //' PayPal fee amount charged for the transaction + $settleAmt = $resArray["PAYMENTINFO_0_SETTLEAMT"]; //' Amount deposited in your PayPal account after a currency conversion. + $taxAmt = $resArray["PAYMENTINFO_0_TAXAMT"]; //' Tax charged on the transaction. + $exchangeRate = $resArray["PAYMENTINFO_0_EXCHANGERATE"]; //' Exchange rate if a currency conversion occurred. Relevant only if your are billing in their non-primary currency. If the customer chooses to pay with a currency other than the non-primary currency, the conversion occurs in the customer's account. + + /* + ' Status of the payment: + 'Completed: The payment has been completed, and the funds have been added successfully to your account balance. + + 'Pending: The payment is pending. See the PendingReason element for more information. + */ + + $paymentStatus = $resArray["PAYMENTINFO_0_PAYMENTSTATUS"]; + + /* + 'The reason the payment is pending: + ' none: No pending reason + ' address: The payment is pending because your customer did not include a confirmed shipping address and your Payment Receiving Preferences is set such that you want to manually accept or deny each of these payments. To change your preference, go to the Preferences section of your Profile. + ' echeck: The payment is pending because it was made by an eCheck that has not yet cleared. + ' intl: The payment is pending because you hold a non-U.S. account and do not have a withdrawal mechanism. You must manually accept or deny this payment from your Account Overview. + + ' multi-currency: You do not have a balance in the currency sent, and you do not have your Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment. + ' verify: The payment is pending because you are not yet verified. You must verify your account before you can accept this payment. + ' other: The payment is pending for a reason other than those listed above. For more information, contact PayPal customer service. + */ + + $pendingReason = $resArray["PAYMENTINFO_0_PENDINGREASON"]; + + /* + 'The reason for a reversal if TransactionType is reversal: + ' none: No reason code + ' chargeback: A reversal has occurred on this transaction due to a chargeback by your customer. + ' guarantee: A reversal has occurred on this transaction due to your customer triggering a money-back guarantee. + ' buyer-complaint: A reversal has occurred on this transaction due to a complaint about the transaction from your customer. + ' refund: A reversal has occurred on this transaction because you have given the customer a refund. + ' other: A reversal has occurred on this transaction due to a reason not listed above. + */ + + $reasonCode = $resArray["PAYMENTINFO_0_REASONCODE"]; + +//INSERTAMOS LOS REGISTROS NECESARIOS EN LAS TABLAS DE BASES DE DATOS PARA DAR AL USUARIO DE ALTA + if ($paymentStatus == "Completed") { + $plugin = Buy_CoursesPlugin::create(); + + //echo "Se ha realizado la compra correctamente"; + + $user_id = $_SESSION['bc_user_id']; //api_get_user_id(); + $course_code = $_SESSION['bc_curso_codetext']; + $all_course_information = CourseManager::get_course_information($course_code); + + if (CourseManager::subscribe_user($user_id, $course_code)) { + $send = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course', $course_code); + if ($send == 1) { + CourseManager::email_to_tutor($user_id, $course_code, $send_to_tutor_also = false); + } else if ($send == 2) { + CourseManager::email_to_tutor($user_id, $course_code, $send_to_tutor_also = true); + } + $url = Display::url($all_course_information['title'], api_get_course_url($course_code)); + $_SESSION['bc_mensaje'] = 'EnrollToCourseXSuccessful'; + $_SESSION['bc_url'] = $url; + $_SESSION['bc_exito'] = true; + //$message = sprintf($plugin->get_lang('EnrollToCourseXSuccessful'), $url); + } else { + $_SESSION['bc_mensaje'] = 'ErrorContactPlatformAdmin'; + $_SESSION['bc_exito'] = false; + //$message = $plugin->get_lang('ErrorContactPlatformAdmin'); + } + //Activamos al usuario su cuenta + $TABLE_USER = Database::get_main_table(TABLE_MAIN_USER); + // 1. set account inactive + $sql = "UPDATE " . $TABLE_USER . " SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'"; + Database::query($sql); + + //Logueamos al user + + // a uid is given (log in succeeded) + $user_table = Database::get_main_table(TABLE_MAIN_USER); + $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); + $track_e_login = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); + + $sql = "SELECT user.*, a.user_id is_admin, login.login_date + FROM $user_table + LEFT JOIN $admin_table a + ON user.user_id = a.user_id + LEFT JOIN $track_e_login login + ON user.user_id = login.login_user_id + WHERE user.user_id = '" . $_SESSION['bc_user_id'] . "' + ORDER BY login.login_date DESC LIMIT 1"; + + $result = Database::query($sql); + + if (Database::num_rows($result) > 0) { + // Extracting the user data + + $uData = Database::fetch_array($result); + + $_user = _api_format_user($uData, false); + $_user['lastLogin'] = api_strtotime($uData['login_date'], 'UTC'); + + $is_platformAdmin = (bool)(!is_null($uData['is_admin'])); + $is_allowedCreateCourse = (bool)(($uData ['status'] == COURSEMANAGER) or (api_get_setting('drhCourseManagerRights') and $uData['status'] == DRH)); + ConditionalLogin::check_conditions($uData); + + Session::write('_user', $_user); + + UserManager::update_extra_field_value($_user['user_id'], 'already_logged_in', 'true'); + Session::write('is_platformAdmin', $is_platformAdmin); + Session::write('is_allowedCreateCourse', $is_allowedCreateCourse); + } else { + header('location:' . api_get_path(WEB_PATH)); + } + + //Eliminamos las variables + unset($_SESSION['bc_user_id']); + unset($_SESSION['bc_curso_code']); + unset($_SESSION['bc_curso_codetext']); + unset($_SESSION['bc_curso_title']); + unset($_SESSION['bc_user']); + unset($_SESSION["Payment_Amount"]); + unset($_SESSION["sec_token"]); + unset($_SESSION["currencyCodeType"]); + unset($_SESSION["PaymentType"]); + unset($_SESSION["nvpReqArray"]); + unset($_SESSION['TOKEN']); + header('Location:list.php'); + } else { + $_SESSION['bc_mensaje'] = 'Cancelacionpedido'; + unset($_SESSION['bc_curso_code']); + unset($_SESSION['bc_curso_title']); + unset($_SESSION["Payment_Amount"]); + unset($_SESSION["currencyCodeType"]); + unset($_SESSION["PaymentType"]); + unset($_SESSION["nvpReqArray"]); + unset($_SESSION['TOKEN']); + header('Location:list.php'); + } + } else { + //Display a user friendly Error on the page using any of the following error information returned by PayPal + $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); + $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); + $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); + $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); + $_SESSION['bc_mensaje'] = 'ErrorContactPlatformAdmin'; + unset($_SESSION['bc_curso_code']); + unset($_SESSION['bc_curso_codetext']); + unset($_SESSION['bc_curso_title']); + unset($_SESSION["Payment_Amount"]); + unset($_SESSION["currencyCodeType"]); + unset($_SESSION["PaymentType"]); + unset($_SESSION["nvpReqArray"]); + unset($_SESSION['TOKEN']); + header('Location:list.php'); + } + } +} \ No newline at end of file diff --git a/plugin/buy_courses/uninstall.php b/plugin/buy_courses/uninstall.php new file mode 100644 index 0000000000..62440510ff --- /dev/null +++ b/plugin/buy_courses/uninstall.php @@ -0,0 +1,13 @@ +uninstall(); \ No newline at end of file diff --git a/plugin/buy_courses/view/configuration.tpl b/plugin/buy_courses/view/configuration.tpl new file mode 100644 index 0000000000..436b893e41 --- /dev/null +++ b/plugin/buy_courses/view/configuration.tpl @@ -0,0 +1,47 @@ + + + + +
    +
    + + + + + + + + + {% set i = 0 %} + + {% for curso in cursos %} + {{ i%2==0 ? ' + ' : ' + ' }} + {% set i = i + 1 %} + + + + + + +{% endfor %} + +
    {{ 'Title'|get_lang }}{{ 'OfficialCode'|get_lang }}{{ 'Visible'|get_lang }}{{ 'Price'|get_lang }}{{ 'Options'|get_lang }}
    + {{ visibilidad[curso.visibility] }} + {{curso.title}} + {{ curso.visual_code }} + {{curso.code}} + {% if curso.visible=="SI" %} + + {% else %} + + {% endif %} + {{ moneda }} +
    ok
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/plugin/buy_courses/view/list.tpl b/plugin/buy_courses/view/list.tpl new file mode 100644 index 0000000000..e0daf9c341 --- /dev/null +++ b/plugin/buy_courses/view/list.tpl @@ -0,0 +1,84 @@ + + + +
    +
    +
    + +
    +
    +
    + {% if rmensaje == "SI" %} +
    {{ mensaje }} +
    + {% endif %} + {% for curso in cursos %} +
    +
    +
    +
    + + + +
    +
    +
    +
    +

    {{ curso.title }}

    +
    Profesor: {{ curso.profesor }}
    +
    + {% if curso.matriculado == "SI" %} + {{ 'bc_registrado'|get_lang }} + {% endif %} + {% if curso.matriculado == "TMP" %} + {{ 'bc_tmp_registrado'|get_lang }} + {% endif %} +
    +
    +
    {{ curso.price }} {{ moneda }} +
    +
    +
    + {{ 'Description'|get_lang }} + {% if curso.matriculado == "NO" %} + {{ + 'Buy'|get_lang }} +{% endif %} +
    +
    +
    +
    +{% endfor %} +
    + + + + + + + + +
    \ No newline at end of file diff --git a/plugin/buy_courses/view/paymentsetup.tpl b/plugin/buy_courses/view/paymentsetup.tpl new file mode 100644 index 0000000000..0b72a5f83c --- /dev/null +++ b/plugin/buy_courses/view/paymentsetup.tpl @@ -0,0 +1,80 @@ + + + + +
    +
    +

    Tipo de moneda:

    + + + + + {% if paypal_enable == "true" %} +
    +

    Configuración PayPal:

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

    Configuración Transferencia:

    + + + + + + + + {% set i = 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 }}
    {{ transf.name | e }}{{ transf.account | e }}{{ transf.swift | e }} + +
    + + add account +
    +{% 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 new file mode 100644 index 0000000000..f048f55597 --- /dev/null +++ b/plugin/buy_courses/view/pending_orders.tpl @@ -0,0 +1,41 @@ + + + + +
    +
    + + + + + + + + + + {% set i = 0 %} + + {% for pedido in pendientes %} + {{ i%2==0 ? ' + ' : ' + ' }} + {% set i = i + 1 %} + + + + + + + +{% endfor %} + +
    {{ 'Ref_pedido'|get_lang }}{{ 'Name'|get_lang }}{{ 'Title'|get_lang }}{{ 'Price'|get_lang }}{{ 'Date'|get_lang }}{{ 'Options'|get_lang }}
    {{ pedido.reference }}{{ pedido.name }}{{ pedido.title }}{{ pedido.price }} {{ moneda }}{{ pedido.date }} + ok +    + borrar +
    +
    +
    +
    \ No newline at end of file diff --git a/plugin/buy_courses/view/process.tpl b/plugin/buy_courses/view/process.tpl new file mode 100644 index 0000000000..3b0288f959 --- /dev/null +++ b/plugin/buy_courses/view/process.tpl @@ -0,0 +1,81 @@ + + + + +
    +
    +
    + +
    + +

    + +
    +
    +
    +
    + + + +
    +
    +
    +
    +

    {{ curso.title }}

    +
    Profesor: {{ curso.profesor }}
    +
    +
    +
    +
    {{ curso.price }} {{ moneda }}
    +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    + + + + + {% if paypal_enable == "true" %} + + {% endif %} + + {% if transference_enable == "true" %} + + {% endif %} + +
    +

    Métodos de Pago:

    +
    {{ 'paypal'|get_lang + }}
    {{ + 'transferencia_bancaria'|get_lang }}
    + + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/plugin/buy_courses/view/process_confirm.tpl b/plugin/buy_courses/view/process_confirm.tpl new file mode 100644 index 0000000000..5ae4517950 --- /dev/null +++ b/plugin/buy_courses/view/process_confirm.tpl @@ -0,0 +1,91 @@ + + + + +
    +
    +
    + +
    + +

    + +
    +
    +
    +
    + + + +
    +
    +
    +
    +

    {{ curso.title }}

    +
    Profesor: {{ curso.profesor }}
    +
    +
    +
    +
    {{ curso.price }} {{ moneda }}
    +
    + +
    +
    +
    +
    +
    +
    +
    + + + + + {% set i = 0 %} + {% for account in accounts %} + {{ i%2==0 ? ' + ' : ' + ' }} + {% set i = i + 1 %} + + {% endfor %} +
    Datos Bancarios
    + {{ account.name | e }}
    + {% if account.swift != '' %} + SWIFT: {{ account.swift | e }}
    + {% endif %} + Cuenta Bancaria: {{ account.account | e }}
    +
    +
    +
    {{ 'Message_conf_transf'|get_lang | e}} +
    +
    + +
    + + + + + +
    + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/plugin/buy_courses/view/success.tpl b/plugin/buy_courses/view/success.tpl new file mode 100644 index 0000000000..a85dd2d277 --- /dev/null +++ b/plugin/buy_courses/view/success.tpl @@ -0,0 +1,64 @@ + + + + +
    +
    +
    + +
    + +

    + +
    +
    +
    +
    + + + +
    +
    +
    +
    +

    {{ curso.title }}

    +
    Profesor: {{ curso.profesor }}
    +
    +
    +
    +
    {{ curso.price }} {{ moneda }}
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + + +
    + + +
    +
    +
    +
    +
    \ No newline at end of file From b6dce2af301f607b6398a544f7d19ced1258977e Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Fri, 23 May 2014 12:43:22 -0500 Subject: [PATCH 2/9] Modify Path, names and format code - refs bcourse --- plugin/buy_courses/config.php | 4 +- plugin/buy_courses/database.php | 38 +++++---- plugin/buy_courses/js/funciones.js | 26 +++--- plugin/buy_courses/src/buy_course.lib.php | 8 +- .../src/buy_course_plugin.class.php | 2 +- plugin/buy_courses/src/configuration.php | 4 +- .../src/{func.php => function.php} | 84 ++++++++++++------- plugin/buy_courses/src/paymentsetup.php | 2 +- plugin/buy_courses/view/list.tpl | 4 +- 9 files changed, 102 insertions(+), 70 deletions(-) rename plugin/buy_courses/src/{func.php => function.php} (80%) diff --git a/plugin/buy_courses/config.php b/plugin/buy_courses/config.php index e980fff7e3..f05d63f8df 100644 --- a/plugin/buy_courses/config.php +++ b/plugin/buy_courses/config.php @@ -8,6 +8,6 @@ define('TABLE_BUY_COURSE_TRANSFERENCE', 'plugin_buy_course_transference'); define('TABLE_BUY_COURSE_TEMPORAL', 'plugin_buy_course_temporal'); define('TABLE_BUY_COURSE_SALE', 'plugin_buy_course_sale'); -require_once '../../main/inc/global.inc.php'; +require_once __DIR__ . '/../../main/inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php'; -require_once 'src/buy_course_plugin.class.php'; +require_once api_get_path(PLUGIN_PATH) . 'buy_courses/src/buy_course_plugin.class.php'; diff --git a/plugin/buy_courses/database.php b/plugin/buy_courses/database.php index bb5f4164c0..7209a36a67 100644 --- a/plugin/buy_courses/database.php +++ b/plugin/buy_courses/database.php @@ -10,12 +10,14 @@ $table = Database::get_main_table(TABLE_BUY_COURSE); $sql = "CREATE TABLE IF NOT EXISTS $table ( id INT unsigned NOT NULL auto_increment PRIMARY KEY, id_course INT unsigned NOT NULL DEFAULT '0', + code VARCHAR(40), + title VARCHAR(250), visible CHAR(2) NOT NULL DEFAULT '', price FLOAT(11,2) NOT NULL DEFAULT '0', synchronized CHAR(2) NOT NULL DEFAULT '')"; Database::query($sql); - -$sql = "SELECT id, code, title FROM course"; +$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); +$sql = "SELECT id, code, title FROM $tableCourse"; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { $presql = "INSERT INTO $table (id_course, code, title, visible) VALUES ('" . $row['id'] . "','" . $row['code'] . "','" . $row['title'] . "','NO')"; @@ -311,23 +313,23 @@ Database::query($sql); $table = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); $sql = "CREATE TABLE IF NOT EXISTS $table ( - cod INT unsigned NOT NULL auto_increment PRIMARY KEY, - user_id INT unsigned NOT NULL, - name VARCHAR(255) NOT NULL DEFAULT '', - course_code VARCHAR(200) NOT NULL DEFAULT '', - title VARCHAR(200) NOT NULL DEFAULT '', - reference VARCHAR(20) NOT NULL DEFAULT '', - price FLOAT(11,2) NOT NULL DEFAULT '0', - date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"; + cod INT unsigned NOT NULL auto_increment PRIMARY KEY, + user_id INT unsigned NOT NULL, + name VARCHAR(255) NOT NULL DEFAULT '', + course_code VARCHAR(200) NOT NULL DEFAULT '', + title VARCHAR(200) NOT NULL DEFAULT '', + reference VARCHAR(20) NOT NULL DEFAULT '', + price FLOAT(11,2) NOT NULL DEFAULT '0', + date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"; Database::query($sql); -$table = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); +$table = Database::get_main_table(TABLE_BUY_COURSE_SALE); $sql = "CREATE TABLE IF NOT EXISTS $table ( - cod INT unsigned NOT NULL auto_increment PRIMARY KEY, - user_id INT unsigned NOT NULL, - course_code VARCHAR(200) NOT NULL DEFAULT '', - price FLOAT(11,2) NOT NULL DEFAULT '0', - payment_type VARCHAR(100) NOT NULL DEFAULT '', - status VARCHAR(20) NOT NULL DEFAULT '', - date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"; + cod INT unsigned NOT NULL auto_increment PRIMARY KEY, + user_id INT unsigned NOT NULL, + course_code VARCHAR(200) NOT NULL DEFAULT '', + price FLOAT(11,2) NOT NULL DEFAULT '0', + payment_type VARCHAR(100) NOT NULL DEFAULT '', + status VARCHAR(20) NOT NULL DEFAULT '', + date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"; Database::query($sql); \ No newline at end of file diff --git a/plugin/buy_courses/js/funciones.js b/plugin/buy_courses/js/funciones.js index 7400c63253..b55cd1e0d9 100644 --- a/plugin/buy_courses/js/funciones.js +++ b/plugin/buy_courses/js/funciones.js @@ -30,7 +30,7 @@ $(document).ready(function () { var vvisible = $(this).parent().parent().prev().prev().children().attr("checked"); var vprice = $(this).parent().parent().prev().children().attr("value"); var idcurso = $(this).parent().parent().attr("id"); - $.post("function/func.php", {tab: "guardar_mod", id: idcurso, visible: vvisible, price: vprice}, + $.post("function.php", {tab: "save_mod", id: idcurso, visible: vvisible, price: vprice}, function (data) { if (data.status == "false") { alert("Error database"); @@ -47,7 +47,7 @@ $(document).ready(function () { }); $('#sincronizar').click(function (e) { - $.post("function/func.php", {tab: "sincronizar"}, + $.post("function.php", {tab: "sincronizar"}, 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/func.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria}, + $.post("function.php", {tab: "filtro_cursos", curso: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria}, function (data) { if (data.status == "false") { alert(data.contenido); @@ -88,7 +88,7 @@ $(document).ready(function () { $("#save_money").click(function (e) { var tipo_moneda = $("#tipo_moneda").attr("value"); - $.post("function/func.php", {tab: "guardar_moneda", moneda: tipo_moneda}, + $.post("function.php", {tab: "guardar_moneda", moneda: tipo_moneda}, function (data) { alert(data.contenido); }, "json"); @@ -106,7 +106,7 @@ $(document).ready(function () { } else { var vsandbox = "NO"; } - $.post("function/func.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox}, + $.post("function.php", {tab: "guardar_paypal", username: name, password: clave, signature: firma, sandbox: vsandbox}, function (data) { alert(data.contenido); }, "json"); @@ -122,7 +122,7 @@ $(document).ready(function () { if (tname == '' || taccount == '') { alert("Complete los campos antes de insertar"); } else { - $.post("function/func.php", {tab: "add_account", name: tname, account: taccount, swift: tswift}, + $.post("function.php", {tab: "add_account", name: tname, account: taccount, swift: tswift}, function (data) { location.reload(); }, "json"); @@ -133,7 +133,7 @@ $(document).ready(function () { $(".delete_account").click(function (e) { var vid = $(this).parent().attr("id"); - $.post("function/func.php", {tab: "delete_account", id: vid}, + $.post("function.php", {tab: "delete_account", id: vid}, function (data) { location.reload(); }, "json"); @@ -143,13 +143,13 @@ $(document).ready(function () { }); $("#cancelapedido").click(function (e) { - $.post("function/func.php", {tab: "borrar_variables"}); + $.post("function.php", {tab: "borrar_variables"}); window.location.replace("list.php"); }); $(".borrar_pedido").click(function (e) { var vid = $(this).parent().attr("id"); - $.post("function/func.php", {tab: "borrar_pedido", id: vid}, + $.post("function.php", {tab: "borrar_pedido", id: vid}, function (data) { location.reload(); }, "json"); @@ -160,7 +160,7 @@ $(document).ready(function () { $(".confirmar_pedido").click(function (e) { var vid = $(this).parent().attr("id"); - $.post("function/func.php", {tab: "confirmar_pedido", id: vid}, + $.post("function.php", {tab: "confirmar_pedido", id: vid}, function (data) { location.reload(); }, "json"); @@ -171,7 +171,7 @@ $(document).ready(function () { $(".setting_tpv").click(function () { var vcod = $(this).attr("id"); - $.post("function/func.php", {tab: "cargar_tpv_configuracion", cod: vcod}, + $.post("function.php", {tab: "cargar_tpv_configuracion", cod: vcod}, function (data) { $("#resultado_tpv").html(data.contenido); $("#guardar_datos_tpv").click(function (e) { @@ -183,7 +183,7 @@ $(document).ready(function () { var selector = '#valor_tpv' + i; array.push($(selector).attr("value")); } - $.post("function/func.php", {tab: "save_tpv", cod: vcod, nump: num, action: vaction, parametros: array}, + $.post("function.php", {tab: "save_tpv", cod: vcod, nump: num, action: vaction, parametros: array}, function (data) { alert(data.contenido); $("#resultado_tpv").html(""); @@ -197,7 +197,7 @@ $(document).ready(function () { $(".slt_tpv").change(function () { var vcod = $(this).attr("value"); - $.post("function/func.php", {tab: "activar_tpv", cod: vcod}); + $.post("function.php", {tab: "activar_tpv", cod: vcod}); }); }); diff --git a/plugin/buy_courses/src/buy_course.lib.php b/plugin/buy_courses/src/buy_course.lib.php index d554f25b11..9067a6ffbb 100644 --- a/plugin/buy_courses/src/buy_course.lib.php +++ b/plugin/buy_courses/src/buy_course.lib.php @@ -4,6 +4,7 @@ * @package chamilo.plugin.notify */ require_once '../../../main/inc/global.inc.php'; +require_once '../config.php'; require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php'; function sincronizar() @@ -28,9 +29,12 @@ function sincronizar() Database::query($sql); } -function listado_cursos() +function listCourses() { - $sql = "SELECT a.id_course, a.visible, a.price, b.* FROM plugin_buycourses a, course b WHERE a.id_course=b.id;"; + $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;"; + $res = Database::query($sql); $aux = array(); while ($row = Database::fetch_assoc($res)) { diff --git a/plugin/buy_courses/src/buy_course_plugin.class.php b/plugin/buy_courses/src/buy_course_plugin.class.php index d4fdfdb7f6..1d7d87b58f 100644 --- a/plugin/buy_courses/src/buy_course_plugin.class.php +++ b/plugin/buy_courses/src/buy_course_plugin.class.php @@ -39,7 +39,7 @@ class Buy_CoursesPlugin extends Plugin $table = Database::get_main_table(TABLE_BUY_COURSE); $sql = "DROP TABLE IF EXISTS $table"; Database::query($sql); - + $table = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY); $sql = "DROP TABLE IF EXISTS $table"; Database::query($sql); diff --git a/plugin/buy_courses/src/configuration.php b/plugin/buy_courses/src/configuration.php index fe574c2025..aec7563f84 100644 --- a/plugin/buy_courses/src/configuration.php +++ b/plugin/buy_courses/src/configuration.php @@ -24,13 +24,13 @@ if ($teacher) { $visibilidad[] = get_course_visibility_icon('2'); $visibilidad[] = get_course_visibility_icon('3'); - $lista_cursos = listado_cursos(); + $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(); $tpl->assign('server', $_configuration['root_web']); - $tpl->assign('cursos', $lista_cursos); + $tpl->assign('cursos', $coursesList); $tpl->assign('visibilidad', $visibilidad); $tpl->assign('ruta_imagen_ok', $ruta); $tpl->assign('ruta_imagen_save', $ruta2); diff --git a/plugin/buy_courses/src/func.php b/plugin/buy_courses/src/function.php similarity index 80% rename from plugin/buy_courses/src/func.php rename to plugin/buy_courses/src/function.php index 59aaafa66e..5025bcc6fc 100644 --- a/plugin/buy_courses/src/func.php +++ b/plugin/buy_courses/src/function.php @@ -2,9 +2,18 @@ require_once '../../../main/inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php'; require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php'; -require_once '../lib/buy_course_plugin.class.php'; +require_once 'buy_course_plugin.class.php'; require_once api_get_path(LIBRARY_PATH) . 'course.lib.php'; +$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); +$tableBuyCourseCountry = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY); +$tableBuyCoursePaypal = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL); +$tableBuyCourseTransference = Database::get_main_table(TABLE_BUY_COURSE_TRANSFERENCE); +$tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); +$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); +$tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); +$tableUser = Database::get_main_table(TABLE_MAIN_USER); + $plugin = Buy_CoursesPlugin::create(); $buy_name = $plugin->get_lang('Buy'); @@ -45,7 +54,7 @@ function quitar_html($cadena) } if ($_REQUEST['tab'] == 'sincronizar') { - $sql = "SELECT code,title FROM course;"; + $sql = "SELECT code,title FROM $tableCourse;"; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { $aux_code .= $row['code']; @@ -91,9 +100,15 @@ if ($_REQUEST['tab'] == 'filtro_cursos') { } if ($filtro == '') { - $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';"; + $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';"; } else { - $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 " . $filtro . ";"; + $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 . ";"; } //echo $sql; @@ -101,13 +116,22 @@ if ($_REQUEST['tab'] == 'filtro_cursos') { $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;"; + $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 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'] . "';"; + $sql = "SELECT 1 FROM $tableCourseRelUser + WHERE course_code='" . $row['code'] . "' + AND user_id='" . $_SESSION['_user']['user_id'] . "';"; + $tmp = Database::query($sql); if (Database::affected_rows() > 0) { $row['matriculado'] = "SI"; @@ -132,7 +156,6 @@ if ($_REQUEST['tab'] == 'filtro_cursos') { } - foreach ($aux as $curso) { //{% for curso in cursos %} $contenido .= '
    '; $contenido .= '
    '; @@ -166,16 +189,14 @@ if ($_REQUEST['tab'] == 'filtro_cursos') { $contenido .= '
    '; } //{% endfor %} - echo json_encode(array("status" => "true", "contenido" => $contenido)); - } if ($_REQUEST['tab'] == 'guardar_moneda') { $id = $_REQUEST['moneda']; - $sql = "UPDATE plugin_buycourses_countries SET status='0';"; + $sql = "UPDATE $tableBuyCourseCountry SET status='0';"; $res = Database::query($sql); - $sql = "UPDATE plugin_buycourses_countries SET status='1' WHERE id_country='" . $id . "';"; + $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(); @@ -191,8 +212,13 @@ if ($_REQUEST['tab'] == 'guardar_paypal') { $password = mysql_real_escape_string($_REQUEST['password']); $signature = mysql_real_escape_string($_REQUEST['signature']); $sandbox = mysql_real_escape_string($_REQUEST['sandbox']); - $sql = "UPDATE plugin_bc_paypal SET sandbox='" . $sandbox . "', username='" . $username . "', password='" . $password . "', signature='" . $signature . "' WHERE id='1';"; - //echo $sql; + $sql = "UPDATE $tableBuyCoursePaypal + SET sandbox = '" . $sandbox . "', + username = '" . $username . "', + password = '" . $password . "', + signature = '" . $signature . "' + WHERE id = '1';"; + $res = Database::query($sql); if (!res) { $contenido = 'Problema al guardar los parametros de paypal: ' . Database::error(); @@ -207,9 +233,8 @@ 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']); - $sql = "INSERT INTO plugin_bc_transf (name, account, swift) VALUES ('" . $name . "','" . $account . "', '" . $swift . "');"; - //echo $sql; - + $sql = "INSERT INTO $tableBuyCourseTransference (name, account, swift) + VALUES ('" . $name . "','" . $account . "', '" . $swift . "');"; $res = Database::query($sql); if (!res) { @@ -223,8 +248,7 @@ if ($_REQUEST['tab'] == 'add_account') { if ($_REQUEST['tab'] == 'delete_account') { $id = substr($_REQUEST['id'], 6); - $sql = "DELETE FROM plugin_bc_transf WHERE id='" . $id . "';"; - //echo $sql; + $sql = "DELETE FROM $tableBuyCourseTransference WHERE id='" . $id . "';"; $res = Database::query($sql); if (!res) { $contenido = 'Problema al borrar la cuenta: ' . Database::error(); @@ -235,14 +259,17 @@ if ($_REQUEST['tab'] == 'delete_account') { } } -if ($_REQUEST['tab'] == 'guardar_mod') { +if ($_REQUEST['tab'] == 'save_mod') { $id = substr($_REQUEST['id'], 5); $visible = ($_REQUEST['visible'] == "checked") ? ('SI') : ('NO'); $price = mysql_real_escape_string($_REQUEST['price']); $obj = $_REQUEST['obj']; + $sql = "UPDATE $tableBuyCourse + SET visible='" . $visible . "', + price='" . $price . "' + WHERE id_course='" . $id . "';"; - $sql = "UPDATE plugin_buycourses SET visible='" . $visible . "', price='" . $price . "' WHERE id_course='" . $id . "';"; $res = Database::query($sql); if (!res) { $contenido = 'Problema al guardar el mensaje: ' . Database::error(); @@ -269,8 +296,8 @@ if ($_REQUEST['tab'] == 'borrar_variables') { if ($_REQUEST['tab'] == 'borrar_pedido') { $id = substr($_REQUEST['id'], 6); - $sql = "DELETE FROM plugin_bc_temporal WHERE cod='" . $id . "';"; - //echo $sql; + $sql = "DELETE FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';"; + $res = Database::query($sql); if (!res) { $contenido = 'Problema al borrar la cuenta: ' . Database::error(); @@ -283,7 +310,7 @@ if ($_REQUEST['tab'] == 'borrar_pedido') { if ($_REQUEST['tab'] == 'confirmar_pedido') { $id = substr($_REQUEST['id'], 6); - $sql = "SELECT * FROM plugin_bc_temporal WHERE cod='" . $id . "';"; + $sql = "SELECT * FROM $tableBuyCourseTemporal WHERE cod='" . $id . "';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); @@ -299,14 +326,13 @@ if ($_REQUEST['tab'] == 'confirmar_pedido') { } //Activamos al usuario su cuenta if ($seguir) { - $TABLE_USER = Database::get_main_table(TABLE_MAIN_USER); // 1. set account inactive - $sql = "UPDATE " . $TABLE_USER . " SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'"; + $sql = "UPDATE $tableUser SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'"; Database::query($sql); - $sql = "DELETE FROM plugin_bc_temporal WHERE cod='" . $id . "';"; - //echo $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 { @@ -347,9 +373,9 @@ if ($_REQUEST['tab'] == 'cargar_tpv_configuracion') { if ($_REQUEST['tab'] == 'cargar_tpv_configuracion') { $cod = $_REQUEST['cod']; - $sql = "UDPATE plugin_bc_tpv SET activo='NO'"; + $sql = "UDPATE plugin_bc_tpv SET status='NO'"; Database::query($sql); - $sql = "UPDATE plugin_bc_tpv SET activo='SI' WHERE cod='" . $cod . "';"; + $sql = "UPDATE plugin_bc_tpv SET status='SI' WHERE cod='" . $cod . "';"; Database::query($sql); } diff --git a/plugin/buy_courses/src/paymentsetup.php b/plugin/buy_courses/src/paymentsetup.php index 685cf30930..b9a9cfa6ea 100644 --- a/plugin/buy_courses/src/paymentsetup.php +++ b/plugin/buy_courses/src/paymentsetup.php @@ -4,7 +4,7 @@ */ require_once dirname(__FILE__) . '/buy_course.lib.php'; require_once '../../../main/inc/global.inc.php'; -require_once 'lib/buy_course_plugin.class.php'; +require_once 'buy_course_plugin.class.php'; $_cid = 0; $interbreadcrumb[] = array("url" => "list.php", "name" => 'Listado de cursos a la venta'); diff --git a/plugin/buy_courses/view/list.tpl b/plugin/buy_courses/view/list.tpl index e0daf9c341..c3bb50f396 100644 --- a/plugin/buy_courses/view/list.tpl +++ b/plugin/buy_courses/view/list.tpl @@ -62,9 +62,9 @@
    {{ 'Description'|get_lang }} + href="{{ server }}plugin/buy_courses/src/ajax.php?code={{ curso.code }}">{{ 'Description'|get_lang }} {% if curso.matriculado == "NO" %} - {{ + {{ 'Buy'|get_lang }} {% endif %}
    From 41b0ae55f0a811bebcea417f7b001a3912b5fa6e Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Mon, 26 May 2014 18:19:03 -0500 Subject: [PATCH 3/9] MOdify variables name --- plugin/buy_courses/database.php | 4 +- plugin/buy_courses/js/funciones.js | 54 +-- plugin/buy_courses/lang/english.php | 27 +- plugin/buy_courses/lang/spanish.php | 29 +- plugin/buy_courses/resources/plugin.css | 2 +- plugin/buy_courses/src/ajax.php | 2 +- plugin/buy_courses/src/buy_course.lib.php | 230 ++++++++----- plugin/buy_courses/src/configuration.php | 38 ++- plugin/buy_courses/src/error.php | 22 +- plugin/buy_courses/src/function.php | 354 ++++++++------------ plugin/buy_courses/src/index.buycourses.php | 10 +- plugin/buy_courses/src/inscription.php | 1 - plugin/buy_courses/src/list.php | 39 +-- plugin/buy_courses/src/paymentsetup.php | 18 +- plugin/buy_courses/src/pending_orders.php | 10 +- plugin/buy_courses/src/process.php | 32 +- plugin/buy_courses/src/process_confirm.php | 33 +- plugin/buy_courses/src/success.php | 42 +-- plugin/buy_courses/view/configuration.tpl | 20 +- plugin/buy_courses/view/list.tpl | 44 +-- plugin/buy_courses/view/paymentsetup.tpl | 103 +++--- plugin/buy_courses/view/pending_orders.tpl | 6 +- plugin/buy_courses/view/process.tpl | 13 +- plugin/buy_courses/view/process_confirm.tpl | 6 +- plugin/buy_courses/view/success.tpl | 6 +- 25 files changed, 535 insertions(+), 610 deletions(-) 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 }}
    Date: Tue, 27 May 2014 13:33:47 -0500 Subject: [PATCH 4/9] Rename variables --- plugin/buy_courses/js/funciones.js | 28 ++++++------ plugin/buy_courses/lang/spanish.php | 8 ++-- .../resources/{borrar.png => delete.png} | Bin plugin/buy_courses/resources/plugin.css | 18 ++++---- .../src/buy_course_plugin.class.php | 2 +- plugin/buy_courses/src/configuration.php | 2 +- plugin/buy_courses/src/error.php | 4 +- plugin/buy_courses/src/expresscheckout.php | 3 +- plugin/buy_courses/src/list.php | 12 ++--- plugin/buy_courses/src/paymentsetup.php | 42 ++++++++---------- plugin/buy_courses/src/paypalfunctions.php | 5 +-- plugin/buy_courses/src/pending_orders.php | 19 ++++---- plugin/buy_courses/src/process.php | 30 +++++++------ plugin/buy_courses/src/process_confirm.php | 35 +++++---------- plugin/buy_courses/src/success.php | 11 ++--- plugin/buy_courses/view/configuration.tpl | 8 ++-- plugin/buy_courses/view/list.tpl | 14 +++--- plugin/buy_courses/view/paymentsetup.tpl | 6 +-- plugin/buy_courses/view/pending_orders.tpl | 20 ++++----- plugin/buy_courses/view/process.tpl | 18 ++++---- plugin/buy_courses/view/process_confirm.tpl | 22 ++++----- plugin/buy_courses/view/success.tpl | 14 +++--- 22 files changed, 146 insertions(+), 175 deletions(-) rename plugin/buy_courses/resources/{borrar.png => delete.png} (100%) diff --git a/plugin/buy_courses/js/funciones.js b/plugin/buy_courses/js/funciones.js index e69d30e7b0..aa0802e4b9 100644 --- a/plugin/buy_courses/js/funciones.js +++ b/plugin/buy_courses/js/funciones.js @@ -29,16 +29,16 @@ $(document).ready(function () { $(".guardar").click(function () { var vvisible = $(this).parent().parent().prev().prev().children().attr("checked"); var vprice = $(this).parent().parent().prev().children().attr("value"); - var idcurso = $(this).parent().parent().attr("id"); - $.post("function.php", {tab: "save_mod", id: idcurso, visible: vvisible, price: vprice}, + var courseid = $(this).parent().parent().attr("id"); + $.post("function.php", {tab: "save_mod", id: courseid, visible: vvisible, price: vprice}, function (data) { if (data.status == "false") { alert("Error database"); } else { - $("#curso" + data.id).children().attr("style", "display:''"); - $("#curso" + data.id).children().next().attr("style", "display:none"); - $("#curso" + data.id).parent().removeClass("fmod") - $("#curso" + data.id).parent().children().each(function () { + $("#course" + data.id).children().attr("style", "display:''"); + $("#course" + data.id).children().next().attr("style", "display:none"); + $("#course" + data.id).parent().removeClass("fmod") + $("#course" + data.id).parent().children().each(function () { $(this).removeClass("btop"); }); } @@ -62,22 +62,22 @@ $(document).ready(function () { $('#confirmar_filtro').click(function (e) { - var vcurso = $("#course_name").attr("value"); + var vcourse = $("#course_name").attr("value"); var pmin = $("#price_min").attr("value"); var pmax = $("#price_max").attr("value"); if ($("#mostrar_disponibles").attr("checked") == "checked") { - var vmostrar = "SI"; + var vshow = "SI"; } else { - var vmostrar = "NO"; + var vshow = "NO"; } - var vcategoria = $("#categoria_cursos").attr("value"); - $.post("function.php", {tab: "courses_filter", course: vcurso, pricemin: pmin, pricemax: pmax, mostrar: vmostrar, categoria: vcategoria}, + var vcategory = $("#courses_category").attr("value"); + $.post("function.php", {tab: "courses_filter", course: vcourse, pricemin: pmin, pricemax: pmax, mostrar: vshow, category: vcategory}, function (data) { if (data.status == "false") { - alert(data.contenido); - $("#resultado_cursos").html(''); + alert(data.content); + $("#course_results").html(''); } else { - $("#resultado_cursos").html(data.contenido); + $("#course_results").html(data.content); } $(document).ready(acciones_ajax); }, "json"); diff --git a/plugin/buy_courses/lang/spanish.php b/plugin/buy_courses/lang/spanish.php index 2fd61ff4a6..a89292c970 100644 --- a/plugin/buy_courses/lang/spanish.php +++ b/plugin/buy_courses/lang/spanish.php @@ -16,14 +16,11 @@ $strings['OpenToTheWorld'] = "Público - acceso autorizado a cualquier per $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"; $strings['transference_enable'] = "Habilitar transferencia"; $strings['unregistered_users_enable'] = "Permitir usuarios sin registro en la plataforma"; @@ -36,7 +33,6 @@ $strings['bc_subject'] = "Confirmaci�n pedido de cursos"; $strings['bc_tmp_registrado'] = 'Se encuentra a la espera de recibir el pago'; $strings['Ref_pedido'] = 'Referencia del pedido'; -$strings['transferencia_bancaria'] = 'Transferencia Bancaria'; $strings['paypal'] = 'PayPal'; $strings['confirmar_compra'] = 'Confirmar compra de curso'; @@ -56,4 +52,6 @@ $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 +$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['Categories'] = "Categorias"; +$strings['BankTransference'] = 'Transferencia Bancaria'; diff --git a/plugin/buy_courses/resources/borrar.png b/plugin/buy_courses/resources/delete.png similarity index 100% rename from plugin/buy_courses/resources/borrar.png rename to plugin/buy_courses/resources/delete.png diff --git a/plugin/buy_courses/resources/plugin.css b/plugin/buy_courses/resources/plugin.css index 2f1bbb03d7..3d72411cf7 100644 --- a/plugin/buy_courses/resources/plugin.css +++ b/plugin/buy_courses/resources/plugin.css @@ -11,20 +11,20 @@ table td.ta-center, table th.ta-center { text-align: center; } -#tabla_cursos td, #tabla_trasferencia td, #tabla_pedidos td { +#courses_table td, #transference_table td, #order_table td { vertical-align: middle; } -#tabla_cursos td input.price, #tabla_trasferencia td input, #currency_type { +#courses_table td input.price, #transference_table td input, #currency_type { margin: 0; } -#tabla_cursos td.btop { +#courses_table td.btop { border-top: 1px solid red; border-bottom: 1px solid red; } -#tabla_cursos tr.fmod { +#courses_table tr.fmod { border: 1px solid red; background: #FFE0E0; } @@ -53,23 +53,23 @@ table td.ta-center, table th.ta-center { text-align: center; } -textarea#mensaje { +textarea#message { width: 50%; } -.envio_resultado { +.send_result { font-weight: bold; } -select#lsesiones, select#lcursos, select#lejercicios, select#estado { +select#lsessions, select#lcourses, select#lexercises, select#status { margin-bottom: 0px; } -.columna_campo_filtro { +.column_field_filter { padding: 6px 10px 1px 1px; text-align: right; } .height5 { height: 5px; -} +} \ No newline at end of file diff --git a/plugin/buy_courses/src/buy_course_plugin.class.php b/plugin/buy_courses/src/buy_course_plugin.class.php index 1d7d87b58f..3f60d08714 100644 --- a/plugin/buy_courses/src/buy_course_plugin.class.php +++ b/plugin/buy_courses/src/buy_course_plugin.class.php @@ -18,7 +18,7 @@ class Buy_CoursesPlugin extends Plugin return $result ? $result : $result = new self(); } - protected function __construct() + public function __construct() { parent::__construct('1.0', 'Jose Angel Ruiz, Francis Gonzales', array('paypal_enable' => 'boolean', 'transference_enable' => 'boolean', 'unregistered_users_enable' => 'boolean')); } diff --git a/plugin/buy_courses/src/configuration.php b/plugin/buy_courses/src/configuration.php index de4694beae..e7a8192140 100644 --- a/plugin/buy_courses/src/configuration.php +++ b/plugin/buy_courses/src/configuration.php @@ -42,4 +42,4 @@ if ($teacher) { $content = $tpl->fetch($listing_tpl); $tpl->assign('content', $content); $tpl->display_one_col_template(); -} +} \ No newline at end of file diff --git a/plugin/buy_courses/src/error.php b/plugin/buy_courses/src/error.php index c81e2f234d..d9cc805282 100644 --- a/plugin/buy_courses/src/error.php +++ b/plugin/buy_courses/src/error.php @@ -14,5 +14,5 @@ unset($_SESSION['nvpReqArray']); unset($_SESSION['TOKEN']); $_SESSION['bc_success'] = false; $_SESSION['bc_message'] = 'CancelOrder'; -header('Location:list.php'); -?> \ No newline at end of file + +header('Location:list.php'); \ No newline at end of file diff --git a/plugin/buy_courses/src/expresscheckout.php b/plugin/buy_courses/src/expresscheckout.php index 5784e6a24d..d949faa59e 100644 --- a/plugin/buy_courses/src/expresscheckout.php +++ b/plugin/buy_courses/src/expresscheckout.php @@ -58,5 +58,4 @@ if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/plugin/buy_courses/src/list.php b/plugin/buy_courses/src/list.php index eef9177e66..2e497efc4e 100644 --- a/plugin/buy_courses/src/list.php +++ b/plugin/buy_courses/src/list.php @@ -27,12 +27,12 @@ if (isset($_SESSION['bc_success'])) { if ($_SESSION['bc_success'] == true) { $message = sprintf(utf8_encode($plugin->get_lang($_SESSION['bc_message'])), $_SESSION['bc_url']); unset($_SESSION['bc_url']); - $tpl->assign('estilo', 'confirmation-message'); + $tpl->assign('class', 'confirmation-message'); } else { $message = utf8_encode($plugin->get_lang($_SESSION['bc_message'])); - $tpl->assign('estilo', 'warning-message'); + $tpl->assign('class', 'warning-message'); } - $tpl->assign('mensaje', $message); + $tpl->assign('message', $message); unset($_SESSION['bc_success']); unset($_SESSION['bc_message']); @@ -45,11 +45,11 @@ $categoryList = listCategories(); $currencyType = findCurrency(); $tpl->assign('server', $_configuration['root_web']); -$tpl->assign('cursos', $courseList); -$tpl->assign('categorias', $categoryList); +$tpl->assign('courses', $courseList); +$tpl->assign('category', $categoryList); $tpl->assign('currency', $currencyType); $listing_tpl = 'buy_courses/view/list.tpl'; $content = $tpl->fetch($listing_tpl); $tpl->assign('content', $content); -$tpl->display_one_col_template(); +$tpl->display_one_col_template(); \ No newline at end of file diff --git a/plugin/buy_courses/src/paymentsetup.php b/plugin/buy_courses/src/paymentsetup.php index c180635124..504eed9794 100644 --- a/plugin/buy_courses/src/paymentsetup.php +++ b/plugin/buy_courses/src/paymentsetup.php @@ -5,12 +5,12 @@ 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" => "configuration.php", "name" => get_lang('Configuración de cursos disponibles')); +$interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); +$interbreadcrumb[] = array("url" => "configuration.php", "name" => $plugin->get_lang('AvailableCoursesConfiguration')); -$tpl = new Template('Configuración de Pagos'); +$tpl = new Template('PaymentConfiguration'); $teacher = api_is_platform_admin(); api_protect_course_script(true); @@ -18,34 +18,30 @@ api_protect_course_script(true); if ($teacher) { // Sync course table with the plugin $listCurrency = listCurrency(); - $paypalParams = paypalParameters(); $transferenceParams = transferenceParameters(); - $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'; - $ruta3 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/more.png'; - $ruta4 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/borrar.png'; - $ruta5 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/acces_tool.gif'; + $confirmationImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png'; + $saveImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/save.png'; + $moreImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/more.png'; + $deleteImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/delete.png'; + $showImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/acces_tool.gif'; $plugin = Buy_CoursesPlugin::create(); - $paypal_enable = $plugin->get('paypal_enable'); - $tarjeta_enable = $plugin->get('tarjet_credit_enable'); - $transference_enable = $plugin->get('transference_enable'); + $paypalEnable = $plugin->get('paypal_enable'); + $transferenceEnable = $plugin->get('transference_enable'); $tpl->assign('server', $_configuration['root_web']); $tpl->assign('currencies', $listCurrency); $tpl->assign('paypal', $paypalParams); - $tpl->assign('transferencia', $transferenceParams); - $tpl->assign('confirmation_img', $ruta); - $tpl->assign('save_img', $ruta2); - $tpl->assign('ruta_more', $ruta3); - $tpl->assign('ruta_borrar', $ruta4); - $tpl->assign('ruta_ver', $ruta5); - $tpl->assign('paypal_enable', $paypal_enable); - $tpl->assign('tarjeta_enable', $tarjeta_enable); - $tpl->assign('transference_enable', $transference_enable); - + $tpl->assign('transference', $transferenceParams); + $tpl->assign('confirmation_img', $confirmationImg); + $tpl->assign('save_img', $saveImg); + $tpl->assign('more_img', $moreImg); + $tpl->assign('delete_img', $deleteImg); + $tpl->assign('show_img', $showImg); + $tpl->assign('paypal_enable', $paypalEnable); + $tpl->assign('transference_enable', $transferenceEnable); $listing_tpl = 'buy_courses/view/paymentsetup.tpl'; $content = $tpl->fetch($listing_tpl); diff --git a/plugin/buy_courses/src/paypalfunctions.php b/plugin/buy_courses/src/paypalfunctions.php index ca563d5943..32f33556a4 100644 --- a/plugin/buy_courses/src/paypalfunctions.php +++ b/plugin/buy_courses/src/paypalfunctions.php @@ -567,7 +567,4 @@ function deformatNVP($nvpstr) return $nvpArray; -} - - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/plugin/buy_courses/src/pending_orders.php b/plugin/buy_courses/src/pending_orders.php index 0a6599bc42..0ae1144775 100644 --- a/plugin/buy_courses/src/pending_orders.php +++ b/plugin/buy_courses/src/pending_orders.php @@ -6,27 +6,26 @@ require_once dirname(__FILE__) . '/buy_course.lib.php'; require_once '../../../main/inc/global.inc.php'; require_once 'lib/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" => $plugin->get_lang('PaymentsConfiguration')); - -$tpl = new Template('Configuración de cursos disponibles'); +$tpl = new Template('AvailableCoursesConfiguration'); $teacher = api_is_platform_admin(); api_protect_course_script(true); if ($teacher) { $pendingList = pendingList(); - $ruta = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png'; - $ruta2 = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/borrar.png'; + $confirmationImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/message_confirmation.png'; + $deleteImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/delete.png'; $currencyType = findCurrency(); - $tpl->assign('server', $_configuration['root_web']); - $tpl->assign('pendientes', $pendingList); - $tpl->assign('confirmation_img', $ruta); - $tpl->assign('ruta_imagen_borrar', $ruta2); + $tpl->assign('pending', $pendingList); + $tpl->assign('confirmation_img', $confirmationImg); + $tpl->assign('delete_img', $deleteImg); $tpl->assign('currency', $currencyType); $listing_tpl = 'buy_courses/view/pending_orders.tpl'; diff --git a/plugin/buy_courses/src/process.php b/plugin/buy_courses/src/process.php index 93bafc72af..b1958966b6 100644 --- a/plugin/buy_courses/src/process.php +++ b/plugin/buy_courses/src/process.php @@ -6,17 +6,22 @@ require_once dirname(__FILE__) . '/buy_course.lib.php'; require_once '../../../main/inc/global.inc.php'; require_once 'lib/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" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); -$tpl = new Template('Tipo de pago'); +$tpl = new Template('PaymentType'); if (isset($_GET['code'])) { $code = (int)$_GET['code']; } else { $code = $_SESSION['bc_course_code']; } -$sql = "SELECT price, title, code FROM plugin_buycourses a, course b WHERE a.id_course='" . $code . "' AND a.id_course=b.id;"; + +$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); +$sql = "SELECT price, title, code FROM $tableBuyCourse a, course b + WHERE a.id_course='" . $code . "' + AND a.id_course=b.id;"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $_SESSION['Payment_Amount'] = number_format($row['price'], 2, '.', ''); @@ -25,7 +30,7 @@ $_SESSION['bc_course_title'] = $row['title']; $_SESSION['bc_course_code'] = $row['code']; if (!isset($_SESSION['_user'])) { - //Necesita registro + //Needs to be Registered if (!isset($_SESSION['bc_user'])) { header('Location:inscription.php'); exit; @@ -43,7 +48,7 @@ if (!isset($_SESSION['_user'])) { $tpl->assign('user', $_SESSION['bc_user']['username']); } -if (checkUserCourse($_SESSION['bc_curso_codetext'], $_SESSION['bc_user_id'])) { +if (checkUserCourse($_SESSION['bc_course_codetext'], $_SESSION['bc_user_id'])) { $_SESSION['bc_success'] = false; $_SESSION['bc_message'] = 'AlreadyBuy'; header('Location: list.php'); @@ -51,28 +56,25 @@ if (checkUserCourse($_SESSION['bc_curso_codetext'], $_SESSION['bc_user_id'])) { if (checkUserCourseTransference($_SESSION['bc_course_codetext'], $_SESSION['bc_user_id'])) { $_SESSION['bc_success'] = false; - $_SESSION['bc_message'] = 'bc_tmp_registrado'; + $_SESSION['bc_message'] = 'bc_tmp_registered'; header('Location: list.php'); } $currencyType = findCurrency(); $plugin = Buy_CoursesPlugin::create(); -$paypal_enable = $plugin->get('paypal_enable'); -$tarjeta_enable = $plugin->get('tarjet_credit_enable'); -$transference_enable = $plugin->get('transference_enable'); +$paypalEnable = $plugin->get('paypal_enable'); +$transferenceEnable = $plugin->get('transference_enable'); $courseInfo = courseInfo($code); -$tpl->assign('curso', $courseInfo); +$tpl->assign('course', $courseInfo); $tpl->assign('server', $_configuration['root_web']); -$tpl->assign('paypal_enable', $paypal_enable); -$tpl->assign('tarjeta_enable', $tarjeta_enable); -$tpl->assign('transference_enable', $transference_enable); +$tpl->assign('paypal_enable', $paypalEnable); +$tpl->assign('transference_enable', $transferenceEnable); $tpl->assign('title', $_SESSION['bc_course_title']); $tpl->assign('price', $_SESSION['Payment_Amount']); $tpl->assign('currency', $currencyType); - $listing_tpl = 'buy_courses/view/process.tpl'; $content = $tpl->fetch($listing_tpl); $tpl->assign('content', $content); diff --git a/plugin/buy_courses/src/process_confirm.php b/plugin/buy_courses/src/process_confirm.php index 24a5578398..f3a37bfbf9 100644 --- a/plugin/buy_courses/src/process_confirm.php +++ b/plugin/buy_courses/src/process_confirm.php @@ -6,25 +6,12 @@ require_once '../../../main/inc/lib/mail.lib.inc.php'; require_once dirname(__FILE__) . '/buy_course.lib.php'; require_once 'lib/buy_course_plugin.class.php'; -function completar($valor, $digitos) -{ - $resultado = ''; - if (strlen($valor) < $digitos) { - $ceros = $digitos - strlen(ceil($valor)); - for ($i = 0; $i < $ceros; $i++) { - $resultado .= '0'; - } - } - $resultado .= $valor; - return $resultado; -} - if ($_POST['payment_type'] == '') { header('Location:process.php'); } if (isset($_POST['Aceptar'])) { - //Almacenamos usuario, curso, referencia en tabla temporal + // Save the user, course and reference in a tmp table $user_id = $_SESSION['bc_user_id']; $course_code = $_SESSION['bc_course_codetext']; $reference = calculateReference(); @@ -38,7 +25,7 @@ if (isset($_POST['Aceptar'])) { $sql = "INSERT INTO plugin_bc_temporal (user_id, name, course_code, title, reference, price) VALUES ('" . $user_id . "', '" . $name . "','" . $course_code . "','" . $title . "','" . $reference . "','" . $price . "');"; $res = Database::query($sql); - //Notificamos al usuario y enviamos datos bancarios + // Notify the user and send the bank info $accountsList = listAccounts(); $texto = '
    '; @@ -67,16 +54,16 @@ if (isset($_POST['Aceptar'])) { } $courseInfo = courseInfo($_SESSION['bc_course_code']); - $title_curso = $courseInfo['title']; + $title_course = $courseInfo['title']; $message = utf8_encode($plugin->get_lang('bc_message')); $message = str_replace("{{name}}", $name, $message); - $message = str_replace("{{curso}}", $title_curso, $message); + $message = str_replace("{{course}}", $title_course, $message); $message = str_replace("{{reference}}", $reference, $message); $message .= $texto; api_mail($name, $email, $asunto, $message); - // Volvemos al listado de cursos + // Return to course list header('Location:list.php'); } @@ -128,16 +115,16 @@ if ($_POST['payment_type'] == "PayPal") { } } -if ($_POST['payment_type'] == "Transferencia") { +if ($_POST['payment_type'] == "Transference") { $_cid = 0; - $interbreadcrumb[] = array("url" => "list.php", "name" => 'Listado de cursos a la venta'); + $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); $tpl = new Template('Tipo de pago'); $code = $_SESSION['bc_course_code']; $courseInfo = courseInfo($code); - $tpl->assign('curso', $courseInfo); + $tpl->assign('course', $courseInfo); $tpl->assign('server', $_configuration['root_web']); $tpl->assign('title', $_SESSION['bc_course_title']); $tpl->assign('price', $_SESSION['Payment_Amount']); @@ -152,7 +139,7 @@ if ($_POST['payment_type'] == "Transferencia") { $tpl->assign('user', $_SESSION['bc_user']['username']); } - //Obtenemos el listado de cuentas bancarias. + //Get bank list account $accountsList = listAccounts(); $tpl->assign('accounts', $accountsList); @@ -160,6 +147,4 @@ if ($_POST['payment_type'] == "Transferencia") { $content = $tpl->fetch($listing_tpl); $tpl->assign('content', $content); $tpl->display_one_col_template(); -} - -?> +} \ No newline at end of file diff --git a/plugin/buy_courses/src/success.php b/plugin/buy_courses/src/success.php index 605cca9f55..31d05b328b 100644 --- a/plugin/buy_courses/src/success.php +++ b/plugin/buy_courses/src/success.php @@ -8,6 +8,7 @@ require_once 'lib/buy_course_plugin.class.php'; require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php'; require_once api_get_path(LIBRARY_PATH) . 'course.lib.php'; +$plugin = Buy_CoursesPlugin::create(); /* ================================================================== // DATOS DE PAYPAL // @@ -95,14 +96,14 @@ if ($token != "") { if (!isset($_POST['paymentOption'])) { //PANTALLA DE CONFIRMACION DEL PEDIDO $_cid = 0; - $interbreadcrumb[] = array("url" => "list.php", "name" => 'Listado de cursos a la venta'); + $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); - $tpl = new Template('Tipo de pago'); + $tpl = new Template('PaymentType'); $code = $_SESSION['bc_course_code']; $courseInfo = courseInfo($code); - $tpl->assign('curso', $courseInfo); + $tpl->assign('course', $courseInfo); $tpl->assign('server', $_configuration['root_web']); $tpl->assign('title', $_SESSION['bc_course_title']); $tpl->assign('price', $_SESSION['Payment_Amount']); @@ -216,10 +217,6 @@ if (!isset($_POST['paymentOption'])) { //INSERTAMOS LOS REGISTROS NECESARIOS EN LAS TABLAS DE BASES DE DATOS PARA DAR AL USUARIO DE ALTA if ($paymentStatus == "Completed") { - $plugin = Buy_CoursesPlugin::create(); - - //echo "Se ha realizado la compra correctamente"; - $user_id = $_SESSION['bc_user_id']; //api_get_user_id(); $course_code = $_SESSION['bc_course_codetext']; $all_course_information = CourseManager::get_course_information($course_code); diff --git a/plugin/buy_courses/view/configuration.tpl b/plugin/buy_courses/view/configuration.tpl index e8857fea33..27cfbb7c63 100644 --- a/plugin/buy_courses/view/configuration.tpl +++ b/plugin/buy_courses/view/configuration.tpl @@ -4,7 +4,7 @@
    -

    Datos Bancarios

    +
    @@ -14,7 +14,7 @@ {% set i = 0 %} - {% for curso in cursos %} + {% for course in courses %} {{ i%2==0 ? ' ' : ' ' }} @@ -24,9 +24,9 @@ {{course.title}}{{ course.visual_code }} - + {% set i = 0 %} - {% for transf in transferencia %} + {% for transf in transference %} {{ i%2==0 ? ' ' : ' ' }} @@ -54,7 +54,7 @@ {% endfor %} @@ -65,7 +65,7 @@
    {{ 'Title'|get_lang }} {{ 'OfficialCode'|get_lang }}
    {{curso.code}}{{course.code}} - {% if curso.visible == 1 %} + {% if course.visible == 1 %} {% else %} diff --git a/plugin/buy_courses/view/list.tpl b/plugin/buy_courses/view/list.tpl index 369132205b..08cea72dfc 100644 --- a/plugin/buy_courses/view/list.tpl +++ b/plugin/buy_courses/view/list.tpl @@ -15,22 +15,22 @@ - -
  • - {% for categoria in categorias %} - + {% for category in categories %} + {% endfor %}

  • -
  • +
  • -
    +
    {% if rmessage == "YES" %} -
    {{ mensaje }} +
    {{ message }}
    {% endif %} {% for course in courses %} diff --git a/plugin/buy_courses/view/paymentsetup.tpl b/plugin/buy_courses/view/paymentsetup.tpl index 49cba584c8..4578da8b4a 100644 --- a/plugin/buy_courses/view/paymentsetup.tpl +++ b/plugin/buy_courses/view/paymentsetup.tpl @@ -45,7 +45,7 @@
    {{ transf.account | e }} {{ transf.swift | e }} - +
    - add account + add account
    diff --git a/plugin/buy_courses/view/pending_orders.tpl b/plugin/buy_courses/view/pending_orders.tpl index aee853269b..26fad299d1 100644 --- a/plugin/buy_courses/view/pending_orders.tpl +++ b/plugin/buy_courses/view/pending_orders.tpl @@ -4,7 +4,7 @@
    - +
    @@ -15,22 +15,22 @@ {% set i = 0 %} - {% for pedido in pendientes %} + {% for order in pending %} {{ i%2==0 ? ' ' : ' ' }} {% set i = i + 1 %} - - - - - - + + + + + {% endfor %} diff --git a/plugin/buy_courses/view/process.tpl b/plugin/buy_courses/view/process.tpl index c35762675a..22de8db224 100644 --- a/plugin/buy_courses/view/process.tpl +++ b/plugin/buy_courses/view/process.tpl @@ -24,23 +24,23 @@
    -

    {{ curso.title }}

    -
    {{ 'Teacher'|get_lang }}: {{ curso.teacher }}
    +

    {{ course.title }}

    +
    {{ 'Teacher'|get_lang }}: {{ course.teacher }}
    @@ -60,13 +60,11 @@ {% if paypal_enable == "true" %} - + {% endif %} {% if transference_enable == "true" %} - + {% endif %}
    {{ 'Ref_pedido'|get_lang }} {{ 'Name'|get_lang }}
    {{ pedido.reference }}{{ pedido.name }}{{ pedido.title }}{{ pedido.price }} {{ currency }}{{ pedido.date }} + {{ order.reference }}{{ order.name }}{{ order.title }}{{ order.price }} {{ currency }}{{ order.date }} ok    - borrar + delete
    {{ 'paypal'|get_lang - }}
    {{ 'paypal'|get_lang }}
    {{ - 'transferencia_bancaria'|get_lang }}
    {{ 'BankTransference'|get_lang }}
    diff --git a/plugin/buy_courses/view/process_confirm.tpl b/plugin/buy_courses/view/process_confirm.tpl index d80512fe1c..7dc2c14673 100644 --- a/plugin/buy_courses/view/process_confirm.tpl +++ b/plugin/buy_courses/view/process_confirm.tpl @@ -24,23 +24,23 @@
    -

    {{ curso.title }}

    -
    {{ 'Teacher'|get_lang }}: {{ curso.teacher }}
    +

    {{ course.title }}

    +
    {{ 'Teacher'|get_lang }}: {{ course.teacher }}
    -
    {{ curso.price }} {{ currency }}
    +
    {{ course.price }} {{ currency }}
    @@ -76,14 +76,14 @@
    - + - - + +
    - - +
    diff --git a/plugin/buy_courses/view/success.tpl b/plugin/buy_courses/view/success.tpl index d7d1c4da9f..f83c772e9c 100644 --- a/plugin/buy_courses/view/success.tpl +++ b/plugin/buy_courses/view/success.tpl @@ -24,23 +24,23 @@
    -

    {{ curso.title }}

    -
    {{ 'Teacher'|get_lang }}: {{ curso.teacher }}
    +

    {{ course.title }}

    +
    {{ 'Teacher'|get_lang }}: {{ course.teacher }}
    -
    {{ curso.price }} {{ currency }}
    +
    {{ course.price }} {{ currency }}
    @@ -55,7 +55,7 @@
    - +
    From 9f4876c815fd123f43736c8b8cf356bc81fbdc75 Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Tue, 27 May 2014 13:36:04 -0500 Subject: [PATCH 5/9] Add plugin tab --- plugin/buy_courses/database.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugin/buy_courses/database.php b/plugin/buy_courses/database.php index d8e83f1928..b46dc9ace5 100644 --- a/plugin/buy_courses/database.php +++ b/plugin/buy_courses/database.php @@ -5,6 +5,7 @@ * Date: 21/05/14 * Time: 12:19 PM */ +$objPlugin = new Buy_CoursesPlugin(); $table = Database::get_main_table(TABLE_BUY_COURSE); $sql = "CREATE TABLE IF NOT EXISTS $table ( @@ -332,4 +333,11 @@ $sql = "CREATE TABLE IF NOT EXISTS $table ( payment_type VARCHAR(100) NOT NULL DEFAULT '', status VARCHAR(20) NOT NULL DEFAULT '', date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"; -Database::query($sql); \ No newline at end of file +Database::query($sql); + +//Menu main tabs +$rsTab = $objPlugin->addTab('Buy Courses', 'plugin/buy_courses/index.php'); + +if ($rsTab) { + echo ""; +} From daa94d70f2fa6da5cc714f5de79813e168f2dc48 Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Tue, 27 May 2014 17:58:17 -0500 Subject: [PATCH 6/9] rename variables --- plugin/buy_courses/js/funciones.js | 20 +- plugin/buy_courses/resources/plugin.css | 4 + plugin/buy_courses/src/ajax.php | 8 +- plugin/buy_courses/src/expresscheckout.php | 63 ++- plugin/buy_courses/src/function.php | 17 +- plugin/buy_courses/src/paypalfunctions.php | 470 ++++++-------------- plugin/buy_courses/src/pending_orders.php | 3 +- plugin/buy_courses/src/process.php | 3 +- plugin/buy_courses/src/process_confirm.php | 36 +- plugin/buy_courses/src/success.php | 180 ++++---- plugin/buy_courses/view/configuration.tpl | 33 +- plugin/buy_courses/view/list.tpl | 2 +- plugin/buy_courses/view/paymentsetup.tpl | 2 +- plugin/buy_courses/view/process.tpl | 49 +- plugin/buy_courses/view/process_confirm.tpl | 4 +- 15 files changed, 344 insertions(+), 550 deletions(-) diff --git a/plugin/buy_courses/js/funciones.js b/plugin/buy_courses/js/funciones.js index aa0802e4b9..d59f194287 100644 --- a/plugin/buy_courses/js/funciones.js +++ b/plugin/buy_courses/js/funciones.js @@ -26,19 +26,19 @@ $(document).ready(function () { }); }); - $(".guardar").click(function () { - var vvisible = $(this).parent().parent().prev().prev().children().attr("checked"); - var vprice = $(this).parent().parent().prev().children().attr("value"); - var courseid = $(this).parent().parent().attr("id"); - $.post("function.php", {tab: "save_mod", id: courseid, visible: vvisible, price: vprice}, + $(".save").click(function () { + var visible = $(this).parent().parent().prev().prev().children().attr("checked"); + var price = $(this).parent().parent().prev().children().attr("value"); + var id_course = $(this).attr('id'); + $.post("function.php", {tab: "save_mod", id_course: id_course, visible: visible, price: price}, function (data) { if (data.status == "false") { - alert("Error database"); + alert("Database Error"); } else { - $("#course" + data.id).children().attr("style", "display:''"); - $("#course" + data.id).children().next().attr("style", "display:none"); - $("#course" + data.id).parent().removeClass("fmod") - $("#course" + data.id).parent().children().each(function () { + $("#course" + data.id_course).children().attr("style", "display:''"); + $("#course" + data.id_course).children().next().attr("style", "display:none"); + $("#course" + data.id_course).parent().removeClass("fmod") + $("#course" + data.id_course).parent().children().each(function () { $(this).removeClass("btop"); }); } diff --git a/plugin/buy_courses/resources/plugin.css b/plugin/buy_courses/resources/plugin.css index 3d72411cf7..1b32b9091d 100644 --- a/plugin/buy_courses/resources/plugin.css +++ b/plugin/buy_courses/resources/plugin.css @@ -72,4 +72,8 @@ select#lsessions, select#lcourses, select#lexercises, select#status { .height5 { height: 5px; +} + +.margin-left-fifty{ + margin-left: 50px !important; } \ No newline at end of file diff --git a/plugin/buy_courses/src/ajax.php b/plugin/buy_courses/src/ajax.php index 75332aea38..8e9bfed230 100644 --- a/plugin/buy_courses/src/ajax.php +++ b/plugin/buy_courses/src/ajax.php @@ -1,15 +1,15 @@ '; diff --git a/plugin/buy_courses/src/expresscheckout.php b/plugin/buy_courses/src/expresscheckout.php index d949faa59e..727698385c 100644 --- a/plugin/buy_courses/src/expresscheckout.php +++ b/plugin/buy_courses/src/expresscheckout.php @@ -1,47 +1,44 @@ '; $content .= '' . get_lang('Description') . ' '; if ($course['enrolled'] != "YES") { - $content .= '' . $buy_name . ''; + $content .= '' . $buy_name . ''; } $content .= '
    '; $content .= ''; @@ -224,23 +223,23 @@ if ($_REQUEST['tab'] == 'delete_account') { } if ($_REQUEST['tab'] == 'save_mod') { - $_REQUEST['id'] = intval($_REQUEST['id']); - $id = substr($_REQUEST['id'], 5); + $_REQUEST['id'] = Database::escape_string($_REQUEST['id']); + $idCourse = intval($_REQUEST['id_course']); $visible = ($_REQUEST['visible'] == "checked") ? 1 : 0; - $price = mysql_real_escape_string($_REQUEST['price']); + $price = Database::escape_string($_REQUEST['price']); $obj = $_REQUEST['obj']; $sql = "UPDATE $tableBuyCourse SET visible = " . $visible . ", price = '" . $price . "' - WHERE id_course = '" . $id . "';"; + WHERE id_course = '" . $idCourse . "';"; $res = Database::query($sql); if (!res) { $content = $plugin->get_lang('ProblemToSaveTheMessage') . Database::error(); echo json_encode(array("status" => "false", "content" => $content)); } else { - echo json_encode(array("status" => "true", "id" => $id)); + echo json_encode(array("status" => "true", "id_course" => $idCourse)); } } diff --git a/plugin/buy_courses/src/paypalfunctions.php b/plugin/buy_courses/src/paypalfunctions.php index 32f33556a4..96921e4321 100644 --- a/plugin/buy_courses/src/paypalfunctions.php +++ b/plugin/buy_courses/src/paypalfunctions.php @@ -9,33 +9,27 @@ $PROXY_PORT = '808'; $SandboxFlag = $pruebas; - -//'------------------------------------ -//' PayPal API Credentials -//' Replace with your API Username -//' Replace with your API Password -//' Replace with your Signature -//'------------------------------------ -//$API_UserName="vendedor_api1.calidadeorigen.com"; -//$API_Password="1385456693"; -//$API_Signature="An5ns1Kso7MWUdW4ErQKJJJ4qi4-AmFnLvPhhq5VHgESNLWwWusSKk4T"; - +/** + * PayPal API Credentials + * Replace with your API Username + * Replace with your API Password + * Replace with your Signature + */ $API_UserName = $paypal_username; $API_Password = $paypal_password; $API_Signature = $paypal_firma; -// BN Code is only applicable for partners +// BN Code is only applicable for partners $sBNCode = "PP-ECWizard"; - -/* -' Define the PayPal Redirect URLs. -' This is the URL that the buyer is first sent to do authorize payment with their paypal account -' change the URL depending if you are testing on the sandbox or the live PayPal site -' -' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= -' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= -*/ +/** + * Define the PayPal Redirect URLs. + * This is the URL that the buyer is first sent to do authorize payment with their paypal account + * change the URL depending if you are testing on the sandbox or the live PayPal site + * + * For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= + * For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= + */ if ($SandboxFlag == true) { $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; @@ -51,28 +45,26 @@ $version = "93"; if (session_id() == "") session_start(); -/* An express checkout transaction starts with a token, that - identifies to PayPal your transaction - In this example, when the script sees a token, the script - knows that the buyer has already authorized payment through - paypal. If no token was found, the action is to send the buyer - to PayPal to first authorize payment - */ - -/* -'------------------------------------------------------------------------------------------------------------------------------------------- -' Purpose: Prepares the parameters for the SetExpressCheckout API Call. -' Inputs: -' paymentAmount: Total value of the shopping cart -' currencyCodeType: Currency code value the PayPal API -' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization -' returnURL: the page where buyers return to after they are done with the payment review on PayPal -' cancelURL: the page where buyers return to when they cancel the payment review on PayPal -'-------------------------------------------------------------------------------------------------------------------------------------------- -*/ +/** + * An express checkout transaction starts with a token, that + * identifies to PayPal your transaction + * In this example, when the script sees a token, the script + * knows that the buyer has already authorized payment through + * paypal. If no token was found, the action is to send the buyer + * to PayPal to first authorize payment + */ + +/** + * Purpose: Prepares the parameters for the SetExpressCheckout API Call. + * Inputs: + * paymentAmount: Total value of the shopping cart + * currencyCodeType: Currency code value the PayPal API + * paymentType: paymentType has to be one of the following values: Sale or Order or Authorization + * returnURL: the page where buyers return to after they are done with the payment review on PayPal + * cancelURL: the page where buyers return to when they cancel the payment review on PayPal + */ function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $extra) { - //------------------------------------------------------------------------------------------------------------------------------------ // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount; @@ -82,17 +74,15 @@ function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $payment $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType; $nvpstr = $nvpstr . $extra; - //echo $nvpstr; - //exit; $_SESSION["currencyCodeType"] = $currencyCodeType; $_SESSION["PaymentType"] = $paymentType; - //'--------------------------------------------------------------------------------------------------------------- - //' Make the API call to PayPal - //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. - //' If an error occured, show the resulting errors - //'--------------------------------------------------------------------------------------------------------------- + /** + * Make the API call to PayPal + * If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. + * If an error occured, show the resulting errors + */ $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { @@ -103,33 +93,29 @@ function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $payment return $resArray; } -/* -'------------------------------------------------------------------------------------------------------------------------------------------- -' Purpose: Prepares the parameters for the SetExpressCheckout API Call. -' Inputs: -' paymentAmount: Total value of the shopping cart -' currencyCodeType: Currency code value the PayPal API -' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization -' returnURL: the page where buyers return to after they are done with the payment review on PayPal -' cancelURL: the page where buyers return to when they cancel the payment review on PayPal -' shipToName: the Ship to name entered on the merchant's site -' shipToStreet: the Ship to Street entered on the merchant's site -' shipToCity: the Ship to City entered on the merchant's site -' shipToState: the Ship to State entered on the merchant's site -' shipToCountryCode: the Code for Ship to Country entered on the merchant's site -' shipToZip: the Ship to ZipCode entered on the merchant's site -' shipToStreet2: the Ship to Street2 entered on the merchant's site -' phoneNum: the phoneNum entered on the merchant's site -'-------------------------------------------------------------------------------------------------------------------------------------------- -*/ +/** + * Purpose: Prepares the parameters for the SetExpressCheckout API Call. + * Inputs: + * paymentAmount: Total value of the shopping cart + * currencyCodeType: Currency code value the PayPal API + * paymentType: paymentType has to be one of the following values: Sale or Order or Authorization + * returnURL: the page where buyers return to after they are done with the payment review on PayPal + * cancelURL: the page where buyers return to when they cancel the payment review on PayPal + * shipToName: the Ship to name entered on the merchant's site + * shipToStreet: the Ship to Street entered on the merchant's site + * shipToCity: the Ship to City entered on the merchant's site + * shipToState: the Ship to State entered on the merchant's site + * shipToCountryCode: the Code for Ship to Country entered on the merchant's site + * shipToZip: the Ship to ZipCode entered on the merchant's site + * shipToStreet2: the Ship to Street2 entered on the merchant's site + * phoneNum: the phoneNum entered on the merchant's site + */ function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum ) { - //------------------------------------------------------------------------------------------------------------------------------------ // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation - $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount; $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType; $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL; @@ -148,11 +134,11 @@ function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType $_SESSION["currencyCodeType"] = $currencyCodeType; $_SESSION["PaymentType"] = $paymentType; - //'--------------------------------------------------------------------------------------------------------------- - //' Make the API call to PayPal - //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. - //' If an error occured, show the resulting errors - //'--------------------------------------------------------------------------------------------------------------- + /** + * Make the API call to PayPal + * If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. + * If an error occured, show the resulting errors + */ $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { @@ -163,40 +149,37 @@ function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType return $resArray; } -/* -'------------------------------------------------------------------------------------------- -' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. -' -' Inputs: -' None -' Returns: -' The NVP Collection object of the GetExpressCheckoutDetails Call Response. -'------------------------------------------------------------------------------------------- -*/ +/** + * + * Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. + * + * Inputs: + * None + * Returns: + * The NVP Collection object of the GetExpressCheckoutDetails Call Response. + */ function GetShippingDetails($token) { - //'-------------------------------------------------------------- - //' At this point, the buyer has completed authorizing the payment - //' at PayPal. The function will call PayPal to obtain the details - //' of the authorization, incuding any shipping information of the - //' buyer. Remember, the authorization is not a completed transaction - //' at this state - the buyer still needs an additional step to finalize - //' the transaction - //'-------------------------------------------------------------- - - //'--------------------------------------------------------------------------- - //' Build a second API request to PayPal, using the token as the - //' ID to get the details on the payment authorization - //'--------------------------------------------------------------------------- + /** + * At this point, the buyer has completed authorizing the payment + * at PayPal. The function will call PayPal to obtain the details + * of the authorization, incuding any shipping information of the + * buyer. Remember, the authorization is not a completed transaction + * at this state - the buyer still needs an additional step to finalize + * the transaction + * + * Build a second API request to PayPal, using the token as the + * ID to get the details on the payment authorization + */ $nvpstr = "&TOKEN=" . $token; - //'--------------------------------------------------------------------------- - //' Make the API call and store the results in an array. - //' If the call was a success, show the authorization details, and provide - //' an action to complete the payment. - //' If failed, show the error - //'--------------------------------------------------------------------------- + /** + * Make the API call and store the results in an array. + * If the call was a success, show the authorization details, and provide + * an action to complete the payment. + * If failed, show the error + */ $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { @@ -205,366 +188,197 @@ function GetShippingDetails($token) return $resArray; } -/* -'------------------------------------------------------------------------------------------------------------------------------------------- - -' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. - -' - -' Inputs: - -' sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart. - -' Returns: - -' The NVP Collection object of the GetExpressCheckoutDetails Call Response. - -'-------------------------------------------------------------------------------------------------------------------------------------------- - -*/ +/** + * Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. + * Inputs: + * sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart. + * Returns: + * The NVP Collection object of the GetExpressCheckoutDetails Call Response. + */ function ConfirmPayment($FinalPaymentAmt) - { - - /* Gather the information to make the final call to - - finalize the PayPal payment. The variable nvpstr - - holds the name value pairs - - */ - + /** + * Gather the information to make the final call to + * finalize the PayPal payment. The variable nvpstr + * holds the name value pairs + */ //Format the other parameters that were stored in the session from the previous calls $token = urlencode($_SESSION['TOKEN']); - $paymentType = urlencode($_SESSION['PaymentType']); - $currencyCodeType = urlencode($_SESSION['currencyCodeType']); - $payerID = urlencode($_SESSION['payer_id']); - - $serverName = urlencode($_SERVER['SERVER_NAME']); - $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt; - $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName; - - /* Make the call to PayPal to finalize payment - - If an error occured, show the resulting errors - - */ + /** + * Make the call to PayPal to finalize payment + * If an error occured, show the resulting errors + */ $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr); - - /* Display the API response back to the browser. - - If the response from PayPal was a success, display the response parameters' - - If the response was an error, display the errors received using APIError.php. - - */ + /** + * Display the API response back to the browser. + * If the response from PayPal was a success, display the response parameters + * If the response was an error, display the errors received using APIError.php. + */ $ack = strtoupper($resArray["ACK"]); - - return $resArray; - } -/* - -'------------------------------------------------------------------------------------------------------------------------------------------- - -' Purpose: This function makes a DoDirectPayment API call - -' - -' Inputs: - -' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization - -' paymentAmount: total value of the shopping cart - -' currencyCode: currency code value the PayPal API - -' firstName: first name as it appears on credit card - -' lastName: last name as it appears on credit card - -' street: buyer's street address line as it appears on credit card - -' city: buyer's city - -' state: buyer's state - -' countryCode: buyer's country code - -' zip: buyer's zip - -' creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... ) - -' creditCardNumber: buyers credit card number without any spaces, dashes or any other characters - -' expDate: credit card expiration date - -' cvv2: Card Verification Value - -' - -'------------------------------------------------------------------------------------------- - -' - -' Returns: - -' The NVP Collection object of the DoDirectPayment Call Response. - -'-------------------------------------------------------------------------------------------------------------------------------------------- - -*/ - +/** + * Purpose: This function makes a DoDirectPayment API call + * Inputs: + * paymentType: paymentType has to be one of the following values: Sale or Order or Authorization + * paymentAmount: total value of the shopping cart + * currencyCode: currency code value the PayPal API + * firstName: first name as it appears on credit card + * lastName: last name as it appears on credit card + * street: buyer's street address line as it appears on credit card + * city: buyer's city + * state: buyer's state + * countryCode: buyer's country code + * zip: buyer's zip + * creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... ) + * creditCardNumber: buyers credit card number without any spaces, dashes or any other characters + * expDate: credit card expiration date + * cvv2: Card Verification Value + * Returns: + * The NVP Collection object of the DoDirectPayment Call Response. + */ function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, - $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, - $countryCode, $currencyCode) - { - //Construct the parameter string that describes DoDirectPayment - $nvpstr = "&AMT=" . $paymentAmount; - $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCode; - $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType; - $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . $creditCardType; - $nvpstr = $nvpstr . "&ACCT=" . $creditCardNumber; - $nvpstr = $nvpstr . "&EXPDATE=" . $expDate; - $nvpstr = $nvpstr . "&CVV2=" . $cvv2; - $nvpstr = $nvpstr . "&FIRSTNAME=" . $firstName; - $nvpstr = $nvpstr . "&LASTNAME=" . $lastName; - $nvpstr = $nvpstr . "&STREET=" . $street; - $nvpstr = $nvpstr . "&CITY=" . $city; - $nvpstr = $nvpstr . "&STATE=" . $state; - $nvpstr = $nvpstr . "&COUNTRYCODE=" . $countryCode; - $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR']; - $resArray = hash_call("DoDirectPayment", $nvpstr); - return $resArray; } - /** * - * '------------------------------------------------------------------------------------------------------------------------------------------- * hash_call: Function to perform the API call to PayPal using API signature * @methodName is name of API method. * @nvpStr is nvp string. * returns an associtive array containing the response from the server. * - * '------------------------------------------------------------------------------------------------------------------------------------------- - */ - function hash_call($methodName, $nvpStr) - { - //declaring of global variables - global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature; - global $USE_PROXY, $PROXY_HOST, $PROXY_PORT; - global $gv_ApiErrorURL; - global $sBNCode; - //setting the curl parameters. - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $API_Endpoint); - curl_setopt($ch, CURLOPT_VERBOSE, 1); - - //turning off the server and peer verification(TrustManager Concept). - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); - - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, 1); - //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. - //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php - if ($USE_PROXY) - + if ($USE_PROXY) { curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT); - + } //NVPRequest for submitting to server - - $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode); - + $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . + "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . + "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode); //setting the nvpreq as POST FIELD to curl - curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); - - //getting response from server - $response = curl_exec($ch); - - - //convrting NVPResponse to an Associative Array - + //converting NVPResponse to an Associative Array $nvpResArray = deformatNVP($response); - $nvpReqArray = deformatNVP($nvpreq); $_SESSION['nvpReqArray'] = $nvpReqArray; - if (curl_errno($ch)) { - // moving to display page to display curl errors - $_SESSION['curl_error_no'] = curl_errno($ch); - $_SESSION['curl_error_msg'] = curl_error($ch); - - //Execute the Error handling module to display errors. - } else { - //closing the curl - curl_close($ch); - } - return $nvpResArray; - } - -/*'---------------------------------------------------------------------------------- - - Purpose: Redirects to PayPal.com site. - - Inputs: NVP string. - - Returns: - ----------------------------------------------------------------------------------- - -*/ +/** + * Purpose: Redirects to PayPal.com site. + * Inputs: NVP string. + */ function RedirectToPayPal($token) - { - global $PAYPAL_URL; - - // Redirect to paypal.com here - $payPalURL = $PAYPAL_URL . $token; - header("Location: " . $payPalURL); - exit; - } - -/*'---------------------------------------------------------------------------------- - +/** * This function will take NVPString and convert it to an Associative Array and it will decode the response. - - * It is usefull to search for a particular key and displaying arrays. - - * @nvpstr is NVPString. - - * @nvpArray is Associative Array. - - ---------------------------------------------------------------------------------- - - */ + * It is usefull to search for a particular key and displaying arrays. + * @nvpstr is NVPString. + * @nvpArray is Associative Array. + */ function deformatNVP($nvpstr) - { - $intial = 0; - $nvpArray = array(); - while (strlen($nvpstr)) { - //postion of Key - $keypos = strpos($nvpstr, '='); - //position of value - $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr); - - /*getting the Key and Value values and storing in a Associative Array*/ - $keyval = substr($nvpstr, $intial, $keypos); - $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1); - //decoding the respose - $nvpArray[urldecode($keyval)] = urldecode($valval); - $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr)); - } return $nvpArray; - } \ No newline at end of file diff --git a/plugin/buy_courses/src/pending_orders.php b/plugin/buy_courses/src/pending_orders.php index 0ae1144775..c34cafee2c 100644 --- a/plugin/buy_courses/src/pending_orders.php +++ b/plugin/buy_courses/src/pending_orders.php @@ -2,9 +2,8 @@ /** * Initialization */ +require_once '../config.php'; require_once dirname(__FILE__) . '/buy_course.lib.php'; -require_once '../../../main/inc/global.inc.php'; -require_once 'lib/buy_course_plugin.class.php'; $plugin = Buy_CoursesPlugin::create(); $_cid = 0; diff --git a/plugin/buy_courses/src/process.php b/plugin/buy_courses/src/process.php index b1958966b6..9f557f179f 100644 --- a/plugin/buy_courses/src/process.php +++ b/plugin/buy_courses/src/process.php @@ -2,9 +2,8 @@ /** * Initialization */ +require_once '../config.php'; require_once dirname(__FILE__) . '/buy_course.lib.php'; -require_once '../../../main/inc/global.inc.php'; -require_once 'lib/buy_course_plugin.class.php'; $plugin = Buy_CoursesPlugin::create(); $_cid = 0; diff --git a/plugin/buy_courses/src/process_confirm.php b/plugin/buy_courses/src/process_confirm.php index f3a37bfbf9..ade9156d3f 100644 --- a/plugin/buy_courses/src/process_confirm.php +++ b/plugin/buy_courses/src/process_confirm.php @@ -1,15 +1,16 @@ '; + $text = '

    Datos Bancarios

    '; foreach ($accountsList as $account) { - $texto .= ''; - $texto .= ''; + $text .= ''; + $text .= 'Cuenta Bancaria: ' . htmlspecialchars($account['account']) . '
    '; + $text .= ''; } - $texto .= '

    Datos Bancarios

    '; - $texto .= '' . htmlspecialchars($account['name']) . '
    '; + $text .= '
    '; + $text .= '' . htmlspecialchars($account['name']) . '
    '; if ($account['swift'] != '') { - $texto .= 'SWIFT: ' . htmlspecialchars($account['swift']) . '
    '; + $text .= 'SWIFT: ' . htmlspecialchars($account['swift']) . '
    '; } - $texto .= 'Cuenta Bancaria: ' . htmlspecialchars($account['account']) . '
    '; - $texto .= '
    '; + $text .= '
    '; $plugin = Buy_CoursesPlugin::create(); $asunto = utf8_encode($plugin->get_lang('bc_subject')); @@ -60,7 +62,7 @@ if (isset($_POST['Aceptar'])) { $message = str_replace("{{name}}", $name, $message); $message = str_replace("{{course}}", $title_course, $message); $message = str_replace("{{reference}}", $reference, $message); - $message .= $texto; + $message .= $text; api_mail($name, $email, $asunto, $message); // Return to course list @@ -73,14 +75,14 @@ $_SESSION['bc_currency_type'] = $currencyType; $server = $_POST['server']; if ($_POST['payment_type'] == "PayPal") { - $sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $pruebas = ($row['sandbox'] == "YES") ? true: false; $paypal_username = $row['username']; $paypal_password = $row['password']; $paypal_firma = $row['signature']; - require_once("function/paypalfunctions.php"); + require_once("paypalfunctions.php"); // PayPal Express Checkout Module $paymentAmount = $_SESSION["Payment_Amount"]; $currencyCodeType = $currencyType; @@ -119,7 +121,7 @@ if ($_POST['payment_type'] == "Transference") { $_cid = 0; $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); - $tpl = new Template('Tipo de pago'); + $tpl = new Template('PaymentType'); $code = $_SESSION['bc_course_code']; $courseInfo = courseInfo($code); diff --git a/plugin/buy_courses/src/success.php b/plugin/buy_courses/src/success.php index 31d05b328b..5aa56c5267 100644 --- a/plugin/buy_courses/src/success.php +++ b/plugin/buy_courses/src/success.php @@ -2,31 +2,31 @@ use ChamiloSession as Session; +require_once '../config.php'; require_once dirname(__FILE__) . '/buy_course.lib.php'; -require_once '../../../main/inc/global.inc.php'; -require_once 'lib/buy_course_plugin.class.php'; require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php'; require_once api_get_path(LIBRARY_PATH) . 'course.lib.php'; +$tableBuyCoursePaypal = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL); + $plugin = Buy_CoursesPlugin::create(); -/* -================================================================== - // DATOS DE PAYPAL // -================================================================== -*/ -$sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + +/** + * Paypal data + */ +$sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $pruebas = ($row['sandbox'] == "YES") ? true: false; $paypal_username = $row['username']; $paypal_password = $row['password']; $paypal_firma = $row['signature']; -require_once("function/paypalfunctions.php"); +require_once("paypalfunctions.php"); + +/** + * PayPal Express Checkout Call + */ -/*================================================================== - PayPal Express Checkout Call - =================================================================== -*/ // Check to see if the Request object contains a variable named 'token' $token = ""; if (isset($_REQUEST['token'])) { @@ -35,28 +35,26 @@ if (isset($_REQUEST['token'])) { // If the Request object contains the variable 'token' then it means that the user is coming from PayPal site. if ($token != "") { - $sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $paypal_username = $row['username']; $paypal_password = $row['password']; $paypal_firma = $row['signature']; - require_once("function/paypalfunctions.php"); - /* - '------------------------------------ - ' Calls the GetExpressCheckoutDetails API call - ' - ' The GetShippingDetails function is defined in PayPalFunctions.jsp - ' included at the top of this file. - '------------------------------------------------- - */ + require_once 'paypalfunctions.php'; + + /** + * Calls the GetExpressCheckoutDetails API call + * The GetShippingDetails function is defined in PayPalFunctions.jsp + *included at the top of this file. + */ $resArray = GetShippingDetails($token); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCESSWITHWARNING") { - /* - ' The information that is returned by the GetExpressCheckoutDetails call should be integrated by the partner into his Order Review - ' page - */ + /** + * The information that is returned by the GetExpressCheckoutDetails + * call should be integrated by the partner into his Order Review page + */ $email = $resArray["EMAIL"]; // ' Email address of payer. $payerId = $resArray["PAYERID"]; // ' Unique PayPal customer account identification number. $payerStatus = $resArray["PAYERSTATUS"]; // ' Status of payer. Character length and limitations: 10 single-byte alphabetic characters. @@ -94,7 +92,7 @@ if ($token != "") { if (!isset($_POST['paymentOption'])) { - //PANTALLA DE CONFIRMACION DEL PEDIDO + // Confirm the order $_cid = 0; $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); @@ -125,49 +123,41 @@ if (!isset($_POST['paymentOption'])) { $tpl->display_one_col_template(); } else { - /*================================================================== - PayPal Express Checkout Call - =================================================================== - */ + /** + * PayPal Express Checkout Call + */ $PaymentOption = $_POST['paymentOption']; - $sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $paypal_username = $row['username']; $paypal_password = $row['password']; $paypal_firma = $row['signature']; - require_once("function/paypalfunctions.php"); + require_once("paypalfunctions.php"); if ($PaymentOption == "PayPal") { - /* - '------------------------------------ - ' The paymentAmount is the total value of - ' the shopping cart, that was set - ' earlier in a session variable - ' by the shopping cart page - '------------------------------------ - */ + + /** + * The paymentAmount is the total value of + * the shopping cart, that was set + * earlier in a session variable + * by the shopping cart page + */ $finalPaymentAmount = $_SESSION["Payment_Amount"]; - /* - '------------------------------------ - ' Calls the DoExpressCheckoutPayment API call - ' - ' The ConfirmPayment function is defined in the file PayPalFunctions.jsp, - ' that is included at the top of this file. - '------------------------------------------------- - */ + + /** + * Calls the DoExpressCheckoutPayment API call + * The ConfirmPayment function is defined in the file PayPalFunctions.jsp, + * that is included at the top of this file. + */ $resArray = ConfirmPayment($finalPaymentAmount); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { - /* - '******************************************************************************************************************** - ' - ' THE PARTNER SHOULD SAVE THE KEY TRANSACTION RELATED INFORMATION LIKE - ' transactionId & orderTime - ' IN THEIR OWN DATABASE - ' AND THE REST OF THE INFORMATION CAN BE USED TO UNDERSTAND THE STATUS OF THE PAYMENT - ' - '******************************************************************************************************************** - */ + + /** + * THE PARTNER SHOULD SAVE THE KEY TRANSACTION RELATED INFORMATION LIKE transactionId & orderTime + * IN THEIR OWN DATABASE + * AND THE REST OF THE INFORMATION CAN BE USED TO UNDERSTAND THE STATUS OF THE PAYMENT + */ $transactionId = $resArray["PAYMENTINFO_0_TRANSACTIONID"]; // ' Unique transaction ID of the payment. Note: If the PaymentAction of the request was Authorization or Order, this value is your AuthorizationID for use with the Authorization & Capture APIs. $transactionType = $resArray["PAYMENTINFO_0_TRANSACTIONTYPE"]; //' The type of transaction Possible values: l cart l express-checkout @@ -180,44 +170,45 @@ if (!isset($_POST['paymentOption'])) { $taxAmt = $resArray["PAYMENTINFO_0_TAXAMT"]; //' Tax charged on the transaction. $exchangeRate = $resArray["PAYMENTINFO_0_EXCHANGERATE"]; //' Exchange rate if a currency conversion occurred. Relevant only if your are billing in their non-primary currency. If the customer chooses to pay with a currency other than the non-primary currency, the conversion occurs in the customer's account. - /* - ' Status of the payment: - 'Completed: The payment has been completed, and the funds have been added successfully to your account balance. - - 'Pending: The payment is pending. See the PendingReason element for more information. - */ + /** + * Status of the payment: + * Completed: The payment has been completed, and the funds have been added successfully to your account balance. + * Pending: The payment is pending. See the PendingReason element for more information. + */ $paymentStatus = $resArray["PAYMENTINFO_0_PAYMENTSTATUS"]; - /* - 'The reason the payment is pending: - ' none: No pending reason - ' address: The payment is pending because your customer did not include a confirmed shipping address and your Payment Receiving Preferences is set such that you want to manually accept or deny each of these payments. To change your preference, go to the Preferences section of your Profile. - ' echeck: The payment is pending because it was made by an eCheck that has not yet cleared. - ' intl: The payment is pending because you hold a non-U.S. account and do not have a withdrawal mechanism. You must manually accept or deny this payment from your Account Overview. - - ' multi-currency: You do not have a balance in the currency sent, and you do not have your Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment. - ' verify: The payment is pending because you are not yet verified. You must verify your account before you can accept this payment. - ' other: The payment is pending for a reason other than those listed above. For more information, contact PayPal customer service. - */ - + /** + * The reason the payment is pending: + * none: No pending reason + * address: The payment is pending because your customer did not include a confirmed + * shipping address and your Payment Receiving Preferences is set such that you want to + * manually accept or deny each of these payments. To change your preference, go to the Preferences section of your Profile. + * echeck: The payment is pending because it was made by an eCheck that has not yet cleared. + * intl: The payment is pending because you hold a non-U.S. account and do not have a withdrawal mechanism. + * You must manually accept or deny this payment from your Account Overview. + * multi-currency: You do not have a balance in the currency sent, and you do not have your + * Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment. + * verify: The payment is pending because you are not yet verified. You must verify your account before you can accept this payment. + * other: The payment is pending for a reason other than those listed above. For more information, contact PayPal customer service. + */ $pendingReason = $resArray["PAYMENTINFO_0_PENDINGREASON"]; - /* - 'The reason for a reversal if TransactionType is reversal: - ' none: No reason code - ' chargeback: A reversal has occurred on this transaction due to a chargeback by your customer. - ' guarantee: A reversal has occurred on this transaction due to your customer triggering a money-back guarantee. - ' buyer-complaint: A reversal has occurred on this transaction due to a complaint about the transaction from your customer. - ' refund: A reversal has occurred on this transaction because you have given the customer a refund. - ' other: A reversal has occurred on this transaction due to a reason not listed above. - */ + /** + * The reason for a reversal if TransactionType is reversal: + * none: No reason code + * chargeback: A reversal has occurred on this transaction due to a chargeback by your customer. + * guarantee: A reversal has occurred on this transaction due to your customer triggering a money-back guarantee. + * buyer-complaint: A reversal has occurred on this transaction due to a complaint about the transaction from your customer. + * refund: A reversal has occurred on this transaction because you have given the customer a refund. + * other: A reversal has occurred on this transaction due to a reason not listed above. + */ $reasonCode = $resArray["PAYMENTINFO_0_REASONCODE"]; -//INSERTAMOS LOS REGISTROS NECESARIOS EN LAS TABLAS DE BASES DE DATOS PARA DAR AL USUARIO DE ALTA + // Insert the user information to activate the user if ($paymentStatus == "Completed") { - $user_id = $_SESSION['bc_user_id']; //api_get_user_id(); + $user_id = $_SESSION['bc_user_id']; $course_code = $_SESSION['bc_course_codetext']; $all_course_information = CourseManager::get_course_information($course_code); @@ -232,21 +223,15 @@ if (!isset($_POST['paymentOption'])) { $_SESSION['bc_message'] = 'EnrollToCourseXSuccessful'; $_SESSION['bc_url'] = $url; $_SESSION['bc_success'] = true; - //$message = sprintf($plugin->get_lang('EnrollToCourseXSuccessful'), $url); } else { $_SESSION['bc_message'] = 'ErrorContactPlatformAdmin'; $_SESSION['bc_success'] = false; - //$message = $plugin->get_lang('ErrorContactPlatformAdmin'); } - //Activamos al usuario su cuenta + // Activate the use $TABLE_USER = Database::get_main_table(TABLE_MAIN_USER); - // 1. set account inactive $sql = "UPDATE " . $TABLE_USER . " SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'"; Database::query($sql); - //Logueamos al user - - // a uid is given (log in succeeded) $user_table = Database::get_main_table(TABLE_MAIN_USER); $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); $track_e_login = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); @@ -264,7 +249,6 @@ if (!isset($_POST['paymentOption'])) { if (Database::num_rows($result) > 0) { // Extracting the user data - $uData = Database::fetch_array($result); $_user = _api_format_user($uData, false); @@ -283,7 +267,7 @@ if (!isset($_POST['paymentOption'])) { header('location:' . api_get_path(WEB_PATH)); } - //Eliminamos las variables + // Delete variables unset($_SESSION['bc_user_id']); unset($_SESSION['bc_course_code']); unset($_SESSION['bc_course_codetext']); diff --git a/plugin/buy_courses/view/configuration.tpl b/plugin/buy_courses/view/configuration.tpl index 27cfbb7c63..c27fdf4320 100644 --- a/plugin/buy_courses/view/configuration.tpl +++ b/plugin/buy_courses/view/configuration.tpl @@ -15,28 +15,27 @@ {% set i = 0 %} {% for course in courses %} - {{ i%2==0 ? ' - ' : ' - ' }} + {{ i%2 == 0 ? '' : '' }} {% set i = i + 1 %} - {{ $visibility[course.visibility] }} - {{course.title}} - {{ course.visual_code }} - - {{course.code}} + {{ visibility[course.visibility] }} + {{course.title}} + {{ course.visual_code }} + + + {{course.code}} + - {% if course.visible == 1 %} - - {% else %} - - {% endif %} + {% if course.visible == 1 %} + + {% else %} + + {% endif %} {{ currency }} - -
    ok
    - + +
    ok
    + {% endfor %} diff --git a/plugin/buy_courses/view/list.tpl b/plugin/buy_courses/view/list.tpl index 08cea72dfc..3fa9f515b8 100644 --- a/plugin/buy_courses/view/list.tpl +++ b/plugin/buy_courses/view/list.tpl @@ -38,7 +38,7 @@
    diff --git a/plugin/buy_courses/view/paymentsetup.tpl b/plugin/buy_courses/view/paymentsetup.tpl index 4578da8b4a..5388954891 100644 --- a/plugin/buy_courses/view/paymentsetup.tpl +++ b/plugin/buy_courses/view/paymentsetup.tpl @@ -16,7 +16,7 @@ {% endif %} {% endfor %} - + {% if paypal_enable == "true" %}
    diff --git a/plugin/buy_courses/view/process.tpl b/plugin/buy_courses/view/process.tpl index 22de8db224..41c7b79453 100644 --- a/plugin/buy_courses/view/process.tpl +++ b/plugin/buy_courses/view/process.tpl @@ -24,7 +24,7 @@
    - -
    -
    -
    -
    - - - - - {% if paypal_enable == "true" %} - - {% endif %} - - {% if transference_enable == "true" %} - - {% endif %} - -
    -

    Métodos de Pago:

    -
    {{ 'paypal'|get_lang }}
    {{ 'BankTransference'|get_lang }}
    + +
    + {{ 'PaymentMethods'|get_lang }} +
    +
    + {% if paypal_enable == "true" %} + + {% endif %} + {% if transference_enable == "true" %} + + {% endif %} +
    +
    - -
    -
    -
    + +
    + +
    \ No newline at end of file diff --git a/plugin/buy_courses/view/process_confirm.tpl b/plugin/buy_courses/view/process_confirm.tpl index 7dc2c14673..2022b58bb1 100644 --- a/plugin/buy_courses/view/process_confirm.tpl +++ b/plugin/buy_courses/view/process_confirm.tpl @@ -24,7 +24,7 @@
    @@ -40,7 +40,7 @@
    From bfbf3168fc5b39cc76c0dbf65e77a4bfbc46ae85 Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Fri, 30 May 2014 12:41:05 -0500 Subject: [PATCH 7/9] add plugin lang to templates --- main/inc/lib/internationalization.lib.php | 11 +++++++++++ main/inc/lib/template.lib.php | 1 + 2 files changed, 12 insertions(+) diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 935191d7d5..2ab6ee5ca5 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -3315,6 +3315,7 @@ function api_is_valid_date($date, $format = 'Y-m-d H:i:s') { $d = DateTime::createFromFormat($format, $date); return $d && $d->format($format) == $date; } + /** * Return the encoding country code for jquery datepicker * used for exemple in main/exercice/exercise_report.php @@ -3331,6 +3332,16 @@ function get_datepicker_langage_code() { return $languaje; } +/** + * Returns the variable translated + * @param $variable the string to translate + * @param $pluginName the Plugin name + * @return string the variable translated + */ +function get_plugin_lang($variable, $pluginName) { + eval("\$plugin = {$pluginName}::create();"); + return $plugin->get_lang($variable); +} /** * Functions for internal use behind this API */ diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 257319e58e..148cbb5dd8 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -91,6 +91,7 @@ class Template $this->twig = new Twig_Environment($loader, $options); + $this->twig->addFilter('get_plugin_lang', new Twig_Filter_Function('get_plugin_lang')); $this->twig->addFilter('get_lang', new Twig_Filter_Function('get_lang')); $this->twig->addFilter('get_path', new Twig_Filter_Function('api_get_path')); $this->twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting')); From eee67df13c954a59d90c4ddabcc98aca66c09ed5 Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Fri, 30 May 2014 12:45:14 -0500 Subject: [PATCH 8/9] Instance protected plugin correctly and modify default sanbox value --- plugin/buy_courses/database.php | 4 ++-- plugin/buy_courses/src/buy_course_plugin.class.php | 2 +- plugin/ticket/database.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/buy_courses/database.php b/plugin/buy_courses/database.php index b46dc9ace5..cee19a0626 100644 --- a/plugin/buy_courses/database.php +++ b/plugin/buy_courses/database.php @@ -5,7 +5,7 @@ * Date: 21/05/14 * Time: 12:19 PM */ -$objPlugin = new Buy_CoursesPlugin(); +$objPlugin = Buy_CoursesPlugin::create(); $table = Database::get_main_table(TABLE_BUY_COURSE); $sql = "CREATE TABLE IF NOT EXISTS $table ( @@ -295,7 +295,7 @@ Database::query($sql); $table = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL); $sql = "CREATE TABLE IF NOT EXISTS $table ( id INT unsigned NOT NULL auto_increment PRIMARY KEY, - sandbox VARCHAR(5) NOT NULL DEFAULT 'SI', + sandbox VARCHAR(5) NOT NULL DEFAULT 'YES', username VARCHAR(100) NOT NULL DEFAULT '', password VARCHAR(100) NOT NULL DEFAULT '', signature VARCHAR(100) NOT NULL DEFAULT '')"; diff --git a/plugin/buy_courses/src/buy_course_plugin.class.php b/plugin/buy_courses/src/buy_course_plugin.class.php index 3f60d08714..1d7d87b58f 100644 --- a/plugin/buy_courses/src/buy_course_plugin.class.php +++ b/plugin/buy_courses/src/buy_course_plugin.class.php @@ -18,7 +18,7 @@ class Buy_CoursesPlugin extends Plugin return $result ? $result : $result = new self(); } - public function __construct() + protected function __construct() { parent::__construct('1.0', 'Jose Angel Ruiz, Francis Gonzales', array('paypal_enable' => 'boolean', 'transference_enable' => 'boolean', 'unregistered_users_enable' => 'boolean')); } diff --git a/plugin/ticket/database.php b/plugin/ticket/database.php index 9d3dce07c8..8035f0a651 100644 --- a/plugin/ticket/database.php +++ b/plugin/ticket/database.php @@ -3,7 +3,7 @@ * Contains the SQL for the tickets management plugin database structure */ -$objPlugin = new TicketPlugin(); +$objPlugin = TicketPlugin::create(); $table = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG); $sql = "CREATE TABLE IF NOT EXISTS ".$table." ( From 475b37ba70b06abe8975843a617cc76dd1d801d6 Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Fri, 30 May 2014 12:48:34 -0500 Subject: [PATCH 9/9] Improve code, translate some variables and modify some comments --- main/inc/lib/plugin.class.php | 2 + plugin/buy_courses/js/funciones.js | 13 ++- plugin/buy_courses/lang/spanish.php | 30 +++-- plugin/buy_courses/src/ajax.php | 5 +- plugin/buy_courses/src/configuration.php | 3 +- plugin/buy_courses/src/expresscheckout.php | 17 --- plugin/buy_courses/src/function.php | 14 ++- plugin/buy_courses/src/index.buycourses.php | 31 ++---- plugin/buy_courses/src/index.php | 1 + plugin/buy_courses/src/inscription.php | 2 +- plugin/buy_courses/src/list.php | 12 +- plugin/buy_courses/src/paymentsetup.php | 5 +- plugin/buy_courses/src/paypalfunctions.php | 35 +++--- plugin/buy_courses/src/pending_orders.php | 3 +- plugin/buy_courses/src/process.php | 19 ++-- plugin/buy_courses/src/process_confirm.php | 18 +-- plugin/buy_courses/src/success.php | 33 +++--- plugin/buy_courses/view/configuration.tpl | 57 +++++----- plugin/buy_courses/view/index.tpl | 19 ++++ plugin/buy_courses/view/list.tpl | 115 +++++++++++--------- plugin/buy_courses/view/paymentsetup.tpl | 19 ++-- plugin/buy_courses/view/pending_orders.tpl | 10 +- plugin/buy_courses/view/process.tpl | 14 +-- plugin/buy_courses/view/process_confirm.tpl | 31 +++--- plugin/buy_courses/view/success.tpl | 19 ++-- 25 files changed, 275 insertions(+), 252 deletions(-) create mode 100644 plugin/buy_courses/src/index.php create mode 100644 plugin/buy_courses/view/index.tpl diff --git a/main/inc/lib/plugin.class.php b/main/inc/lib/plugin.class.php index 30cd23786a..41e86876c5 100755 --- a/main/inc/lib/plugin.class.php +++ b/main/inc/lib/plugin.class.php @@ -526,6 +526,8 @@ class Plugin /** * Delete a tab to chamilo's platform * @param string $key + * + * @return boolean $resp Transaction response */ public function deleteTab($key) { diff --git a/plugin/buy_courses/js/funciones.js b/plugin/buy_courses/js/funciones.js index d59f194287..227604ab3f 100644 --- a/plugin/buy_courses/js/funciones.js +++ b/plugin/buy_courses/js/funciones.js @@ -61,12 +61,12 @@ $(document).ready(function () { }); - $('#confirmar_filtro').click(function (e) { + $('#confirm_filter').click(function (e) { var vcourse = $("#course_name").attr("value"); var pmin = $("#price_min").attr("value"); var pmax = $("#price_max").attr("value"); if ($("#mostrar_disponibles").attr("checked") == "checked") { - var vshow = "SI"; + var vshow = "YES"; } else { var vshow = "NO"; } @@ -102,7 +102,7 @@ $(document).ready(function () { var clave = $("#password").attr("value"); var firma = $("#signature").attr("value"); if ($("#sandbox").attr("checked") == "checked") { - var vsandbox = "SI"; + var vsandbox = "YES"; } else { var vsandbox = "NO"; } @@ -132,8 +132,9 @@ $(document).ready(function () { }); $(".delete_account").click(function (e) { - var vid = $(this).parent().attr("id"); - $.post("function.php", {tab: "delete_account", id: vid}, + var fieldName = $(this).parent().attr("id"); + var id = $("#id_" + fieldName).val(); + $.post("function.php", {tab: "delete_account", id: id}, function (data) { location.reload(); }, "json"); @@ -142,7 +143,7 @@ $(document).ready(function () { e.stopPropagation(); }); - $("#cancelapedido").click(function (e) { + $("#cancel_order").click(function (e) { $.post("function.php", {tab: "unset_variables"}); window.location.replace("list.php"); }); diff --git a/plugin/buy_courses/lang/spanish.php b/plugin/buy_courses/lang/spanish.php index a89292c970..2ac9f6d4e9 100644 --- a/plugin/buy_courses/lang/spanish.php +++ b/plugin/buy_courses/lang/spanish.php @@ -15,24 +15,15 @@ $strings['OpenToTheWorld'] = "Público - acceso autorizado a cualquier per $strings['Description'] = "Descripción"; $strings['Buy'] = "Comprar"; -$strings['Filtro_buscar'] = "Filtro de busqueda"; -$strings['Price_Maximum'] = "Precio mayor de"; -$strings['Price_Minimum'] = "Precio menor de"; $strings['Mostrar_disponibles'] = "Mostrar cursos disponibles"; $strings['paypal_enable'] = "Habilitar PayPal"; $strings['transference_enable'] = "Habilitar transferencia"; $strings['unregistered_users_enable'] = "Permitir usuarios sin registro en la plataforma"; - -$strings['EnrollToCourseXSuccessful'] = "Su inscripci�n en el curso %s se ha completado."; -$strings['ErrorContactPlatformAdmin'] = "Se ha producido un error desconocido. Por favor, p�ngase en contacto con el administrador de la plataforma."; $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_tmp_registrado'] = 'Se encuentra a la espera de recibir el pago'; -$strings['Ref_pedido'] = 'Referencia del pedido'; $strings['paypal'] = 'PayPal'; $strings['confirmar_compra'] = 'Confirmar compra de curso'; @@ -55,3 +46,24 @@ $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}}
    "; $strings['Categories'] = "Categorias"; $strings['BankTransference'] = 'Transferencia Bancaria'; +$strings['EnrollToCourseXSuccessful'] = "Su inscripción en el curso %s se ha completado."; +$strings['SearchFilter'] = "Filtro de búsqueda"; +$strings['MinimumPrice'] = "Precio menor de"; +$strings['MaximumPrice'] = "Precio mayor de"; +$strings['AvailableCourses'] = "Cursos disponibles"; +$strings['PaymentConfiguration'] = "Configuración de Pagos"; +$strings['WaitingToReceiveThePayment'] = "Se encuentra a la espera de recibir el pago"; +$strings['CurrencyType'] = "Tipo de moneda"; +$strings['SelectACurrency'] = "Seleccione una moneda"; +$strings['Sandbox'] = "Entorno de Pruebas"; +$strings['BankAccount'] = "Cuenta Bancaria"; +$strings['SubscribeUser'] = "Suscribir Usuario"; +$strings['DeleteTheOrder'] = "Eliminar el Pedido"; +$strings['ReferenceOrder'] = 'Referencia del pedido'; +$strings['UserInformation'] = 'Información del Usuario'; +$strings['OnceItIsConfirmed,YouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Una vez confirmado, recibira un e-mail con los datos bancarios y una referencia del pedido."; +$strings['BankAccountInformation'] = 'Información de la Cuenta Bancaria'; +$strings['ConfirmOrder'] = 'Confirmar Orden'; +$strings['PaymentMethods'] = 'Métodos de pago'; +$strings['CancelOrder'] = 'Cancelar Orden'; +$strings['ErrorContactPlatformAdmin'] = "Se ha producido un error desconocido. Por favor, póngase en contacto con el administrador de la plataforma."; \ No newline at end of file diff --git a/plugin/buy_courses/src/ajax.php b/plugin/buy_courses/src/ajax.php index 8e9bfed230..272ddf5313 100644 --- a/plugin/buy_courses/src/ajax.php +++ b/plugin/buy_courses/src/ajax.php @@ -13,7 +13,10 @@ $course_info = api_get_course_info($code); echo Display::tag('h2', $course_info['name']); echo '
    '; -$sql = "SELECT * FROM $tbl_course_description WHERE c_id = " . intval($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/configuration.php b/plugin/buy_courses/src/configuration.php index e7a8192140..435acbd4cc 100644 --- a/plugin/buy_courses/src/configuration.php +++ b/plugin/buy_courses/src/configuration.php @@ -9,10 +9,11 @@ require_once 'buy_course_plugin.class.php'; $plugin = Buy_CoursesPlugin::create(); $_cid = 0; +$templateName = $plugin->get_lang('AvailableCourses'); $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); $interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => get_lang('Configuration')); -$tpl = new Template('availableCourses'); +$tpl = new Template($templateName); $teacher = api_is_platform_admin(); api_protect_course_script(true); diff --git a/plugin/buy_courses/src/expresscheckout.php b/plugin/buy_courses/src/expresscheckout.php index 727698385c..bf763125e0 100644 --- a/plugin/buy_courses/src/expresscheckout.php +++ b/plugin/buy_courses/src/expresscheckout.php @@ -15,25 +15,8 @@ $paymentAmount = $_SESSION["Payment_Amount"]; * The currencyCodeType and paymentType * are set to the selections made on the Integration Assistant */ -$currencyCodeType = "EUR"; $paymentType = "Sale"; -/** - * The returnURL is the location where buyers return to when a - * payment has been succesfully authorized. - * This is set to the value entered on the Integration Assistant - */ -$returnURL = "http://www.nosolored.me/pluging/paypal/confirm.php"; - - -/** - * The cancelURL is the location buyers are sent to when they hit the - * cancel button during authorization of payment during the PayPal flow - * - * This is set to the value entered on the Integration Assistant - */ -$cancelURL = "http://www.nosolored.me/pluging/paypal/error.php"; - /** * Calls the SetExpressCheckout API call * The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php, diff --git a/plugin/buy_courses/src/function.php b/plugin/buy_courses/src/function.php index d47e5bc569..c24d1f92d5 100644 --- a/plugin/buy_courses/src/function.php +++ b/plugin/buy_courses/src/function.php @@ -1,6 +1,7 @@ 0) { - $row['enrolled'] = "SI"; + $row['enrolled'] = "YES"; } else { $row['enrolled'] = "NO"; } } else { $row['enrolled'] = "NO"; } - //Comprobamos imagen + // Check img if (file_exists("../../../courses/" . $row['code'] . "/course-pic85x85.png")) { $row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png"; } else { @@ -117,7 +118,7 @@ if ($_REQUEST['tab'] == 'courses_filter') { } } - + $currencyType = findCurrency(); foreach ($aux as $course) { $content .= '
    '; $content .= '
    '; @@ -131,14 +132,14 @@ if ($_REQUEST['tab'] == 'courses_filter') { $content .= '
    '; $content .= '
    '; $content .= '

    ' . $course['title'] . '

    '; - $content .= '
    ' . get_lang('teacher') . ': ' . $course['teacher'] . '
    '; + $content .= '
    ' . get_lang('Teacher') . ': ' . $course['teacher'] . '
    '; $content .= '
    '; if ($course['enrolled'] == "YES") { $content .= '' . $plugin->get_lang('TheUserIsAlreadyRegistered') . ''; } $content .= '
    '; $content .= '
    '; - $content .= '
    ' . $course['price'] . ' €
    '; + $content .= '
    ' . $course['price'] . ' ' . $currencyType . '
    '; $content .= '
    '; $content .= '
    '; $content .= '' . get_lang('Description') . ' '; @@ -210,7 +211,8 @@ if ($_REQUEST['tab'] == 'add_account') { if ($_REQUEST['tab'] == 'delete_account') { $_REQUEST['id'] = intval($_REQUEST['id']); - $id = substr($_REQUEST['id'], 6); + $id = $_REQUEST['id']; + $sql = "DELETE FROM $tableBuyCourseTransference WHERE id='" . $id . "';"; $res = Database::query($sql); if (!res) { diff --git a/plugin/buy_courses/src/index.buycourses.php b/plugin/buy_courses/src/index.buycourses.php index 9ece98c961..9ad5d22d4c 100644 --- a/plugin/buy_courses/src/index.buycourses.php +++ b/plugin/buy_courses/src/index.buycourses.php @@ -8,25 +8,18 @@ $guess_enable = $plugin->get('unregistered_users_enable'); if ($guess_enable == "true" || isset($_SESSION['_user'])) { $title = $plugin->get_lang('CourseListOnSale'); + $templateName = $plugin->get_lang('BuyCourses'); - echo ''; + $tpl = new Template($templateName); + $tpl->assign('isAdmin', api_is_platform_admin()); + $tpl->assign('title', $title); + $tpl->assign('BuyCourses', $templateName); + $tpl->assign('ConfigurationOfCoursesAndPrices', $plugin->get_lang('ConfigurationOfCoursesAndPrices')); + $tpl->assign('ConfigurationOfPayments', $plugin->get_lang('ConfigurationOfPayments')); + $tpl->assign('OrdersPendingOfPayment', $plugin->get_lang('OrdersPendingOfPayment')); + $listing_tpl = 'buy_courses/view/index.tpl'; + $content = $tpl->fetch($listing_tpl); + $tpl->assign('content', $content); + $tpl->display_one_col_template(); } \ No newline at end of file diff --git a/plugin/buy_courses/src/index.php b/plugin/buy_courses/src/index.php new file mode 100644 index 0000000000..6fd199e66e --- /dev/null +++ b/plugin/buy_courses/src/index.php @@ -0,0 +1 @@ + "configuration.php", "name" => $plugin->get_lang('AvailableCoursesConfiguration')); $interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => $plugin->get_lang('PaymentsConfiguration')); } -$tpl = new Template('CourseListOnSale'); +$templateName = $plugin->get_lang('CourseListOnSale'); +$tpl = new Template($templateName); if (isset($_SESSION['bc_success'])) { $tpl->assign('rmessage', 'YES'); if ($_SESSION['bc_success'] == true) { - $message = sprintf(utf8_encode($plugin->get_lang($_SESSION['bc_message'])), $_SESSION['bc_url']); + $message = sprintf($plugin->get_lang($_SESSION['bc_message']), $_SESSION['bc_url']); unset($_SESSION['bc_url']); $tpl->assign('class', 'confirmation-message'); } else { - $message = utf8_encode($plugin->get_lang($_SESSION['bc_message'])); + $message = $plugin->get_lang($_SESSION['bc_message']); $tpl->assign('class', 'warning-message'); } - $tpl->assign('message', $message); + $tpl->assign('responseMessage', $message); unset($_SESSION['bc_success']); unset($_SESSION['bc_message']); diff --git a/plugin/buy_courses/src/paymentsetup.php b/plugin/buy_courses/src/paymentsetup.php index 504eed9794..d9134f525b 100644 --- a/plugin/buy_courses/src/paymentsetup.php +++ b/plugin/buy_courses/src/paymentsetup.php @@ -7,11 +7,11 @@ require_once '../../../main/inc/global.inc.php'; require_once 'buy_course_plugin.class.php'; $plugin = Buy_CoursesPlugin::create(); $_cid = 0; +$templateName = $plugin->get_lang('PaymentConfiguration'); $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); $interbreadcrumb[] = array("url" => "configuration.php", "name" => $plugin->get_lang('AvailableCoursesConfiguration')); -$tpl = new Template('PaymentConfiguration'); - +$tpl = new Template($templateName); $teacher = api_is_platform_admin(); api_protect_course_script(true); @@ -27,7 +27,6 @@ if ($teacher) { $deleteImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/delete.png'; $showImg = api_get_path(WEB_PLUGIN_PATH) . 'buy_courses/resources/acces_tool.gif'; - $plugin = Buy_CoursesPlugin::create(); $paypalEnable = $plugin->get('paypal_enable'); $transferenceEnable = $plugin->get('transference_enable'); diff --git a/plugin/buy_courses/src/paypalfunctions.php b/plugin/buy_courses/src/paypalfunctions.php index 96921e4321..6bf4b6b109 100644 --- a/plugin/buy_courses/src/paypalfunctions.php +++ b/plugin/buy_courses/src/paypalfunctions.php @@ -15,9 +15,9 @@ $SandboxFlag = $pruebas; * Replace with your API Password * Replace with your Signature */ -$API_UserName = $paypal_username; -$API_Password = $paypal_password; -$API_Signature = $paypal_firma; +$API_UserName = $paypalUsername; +$API_Password = $paypalPassword; +$API_Signature = $paypalSignature; // BN Code is only applicable for partners $sBNCode = "PP-ECWizard"; @@ -42,8 +42,9 @@ if ($SandboxFlag == true) { $USE_PROXY = false; $version = "93"; -if (session_id() == "") +if (session_id() == "") { session_start(); +} /** * An express checkout transaction starts with a token, that @@ -66,14 +67,13 @@ if (session_id() == "") function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $extra) { // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation - $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount; - $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType; - $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL; - $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL; - $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType; - - $nvpstr = $nvpstr . $extra; + $nvpstr .= "&PAYMENTREQUEST_0_ITEMAMT=" . $paymentAmount; + $nvpstr .= "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType; + $nvpstr .= "&RETURNURL=" . $returnURL; + $nvpstr .= "&CANCELURL=" . $cancelURL; + $nvpstr .= "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType; + $nvpstr .= $extra; $_SESSION["currencyCodeType"] = $currencyCodeType; $_SESSION["PaymentType"] = $paymentType; @@ -164,27 +164,28 @@ function GetShippingDetails($token) /** * At this point, the buyer has completed authorizing the payment * at PayPal. The function will call PayPal to obtain the details - * of the authorization, incuding any shipping information of the + * of the authorization, including any shipping information of the * buyer. Remember, the authorization is not a completed transaction * at this state - the buyer still needs an additional step to finalize * the transaction * * Build a second API request to PayPal, using the token as the - * ID to get the details on the payment authorization + * ID to get the details on the payment authorization */ $nvpstr = "&TOKEN=" . $token; /** * Make the API call and store the results in an array. - * If the call was a success, show the authorization details, and provide - * an action to complete the payment. - * If failed, show the error + * If the call was a success, show the authorization details, and provide + * an action to complete the payment. + * If failed, show the error */ $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $_SESSION['payer_id'] = $resArray['PAYERID']; } + return $resArray; } @@ -293,7 +294,6 @@ function hash_call($methodName, $nvpStr) //declaring of global variables global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature; global $USE_PROXY, $PROXY_HOST, $PROXY_PORT; - global $gv_ApiErrorURL; global $sBNCode; //setting the curl parameters. @@ -308,7 +308,6 @@ function hash_call($methodName, $nvpStr) //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php - if ($USE_PROXY) { curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT); } diff --git a/plugin/buy_courses/src/pending_orders.php b/plugin/buy_courses/src/pending_orders.php index c34cafee2c..f18cfe02a5 100644 --- a/plugin/buy_courses/src/pending_orders.php +++ b/plugin/buy_courses/src/pending_orders.php @@ -7,10 +7,11 @@ require_once dirname(__FILE__) . '/buy_course.lib.php'; $plugin = Buy_CoursesPlugin::create(); $_cid = 0; +$tableName = $plugin->get_lang('AvailableCoursesConfiguration'); $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); $interbreadcrumb[] = array("url" => "paymentsetup.php", "name" => $plugin->get_lang('PaymentsConfiguration')); -$tpl = new Template('AvailableCoursesConfiguration'); +$tpl = new Template($tableName); $teacher = api_is_platform_admin(); api_protect_course_script(true); diff --git a/plugin/buy_courses/src/process.php b/plugin/buy_courses/src/process.php index 9f557f179f..99a6cf2ab0 100644 --- a/plugin/buy_courses/src/process.php +++ b/plugin/buy_courses/src/process.php @@ -7,26 +7,31 @@ require_once dirname(__FILE__) . '/buy_course.lib.php'; $plugin = Buy_CoursesPlugin::create(); $_cid = 0; +$templateName = $plugin->get_lang('PaymentMethods'); $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); -$tpl = new Template('PaymentType'); +$tpl = new Template($templateName); -if (isset($_GET['code'])) { +if (!empty($_GET['code'])) { $code = (int)$_GET['code']; } else { $code = $_SESSION['bc_course_code']; } +$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); -$sql = "SELECT price, title, code FROM $tableBuyCourse a, course b - WHERE a.id_course='" . $code . "' - AND a.id_course=b.id;"; + +$sql = "SELECT a.price, a.title, b.code + FROM $tableBuyCourse a, $tableCourse b + WHERE a.id_course = " . $code . " + AND a.id_course = b.id;"; $res = Database::query($sql); $row = Database::fetch_assoc($res); + $_SESSION['Payment_Amount'] = number_format($row['price'], 2, '.', ''); $_SESSION['bc_course_code'] = $code; $_SESSION['bc_course_title'] = $row['title']; -$_SESSION['bc_course_code'] = $row['code']; +$_SESSION['bc_course_codetext'] = $row['code']; if (!isset($_SESSION['_user'])) { //Needs to be Registered @@ -60,7 +65,7 @@ if (checkUserCourseTransference($_SESSION['bc_course_codetext'], $_SESSION['bc_u } $currencyType = findCurrency(); -$plugin = Buy_CoursesPlugin::create(); + $paypalEnable = $plugin->get('paypal_enable'); $transferenceEnable = $plugin->get('transference_enable'); diff --git a/plugin/buy_courses/src/process_confirm.php b/plugin/buy_courses/src/process_confirm.php index ade9156d3f..8d11e490e0 100644 --- a/plugin/buy_courses/src/process_confirm.php +++ b/plugin/buy_courses/src/process_confirm.php @@ -11,7 +11,7 @@ if ($_POST['payment_type'] == '') { $tableBuyCourseTemporal = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); $tableBuyCoursePaypal = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL); -if (isset($_POST['Aceptar'])) { +if (isset($_POST['Confirm'])) { // Save the user, course and reference in a tmp table $user_id = $_SESSION['bc_user_id']; $course_code = $_SESSION['bc_course_codetext']; @@ -58,7 +58,7 @@ if (isset($_POST['Aceptar'])) { $courseInfo = courseInfo($_SESSION['bc_course_code']); $title_course = $courseInfo['title']; - $message = utf8_encode($plugin->get_lang('bc_message')); + $message = $plugin->get_lang('bc_message'); $message = str_replace("{{name}}", $name, $message); $message = str_replace("{{course}}", $title_course, $message); $message = str_replace("{{reference}}", $reference, $message); @@ -79,16 +79,16 @@ if ($_POST['payment_type'] == "PayPal") { $res = Database::query($sql); $row = Database::fetch_assoc($res); $pruebas = ($row['sandbox'] == "YES") ? true: false; - $paypal_username = $row['username']; - $paypal_password = $row['password']; - $paypal_firma = $row['signature']; + $paypalUsername = $row['username']; + $paypalPassword = $row['password']; + $paypalSignature = $row['signature']; require_once("paypalfunctions.php"); // PayPal Express Checkout Module $paymentAmount = $_SESSION["Payment_Amount"]; $currencyCodeType = $currencyType; $paymentType = "Sale"; - $returnURL = $server . "plugin/buy_courses/success.php"; - $cancelURL = $server . "plugin/buy_courses/error.php"; + $returnURL = $server . "plugin/buy_courses/src/success.php"; + $cancelURL = $server . "plugin/buy_courses/src/error.php"; $courseInfo = courseInfo($_SESSION['bc_course_code']); $courseTitle = $courseInfo['title']; @@ -113,15 +113,15 @@ if ($_POST['payment_type'] == "PayPal") { echo "
    Short Error Message: " . $ErrorShortMsg; echo "
    Error Code: " . $ErrorCode; echo "
    Error Severity Code: " . $ErrorSeverityCode; - } } if ($_POST['payment_type'] == "Transference") { $_cid = 0; + $templateName = $plugin->get_lang('PaymentMethods'); $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); - $tpl = new Template('PaymentType'); + $tpl = new Template($templateName); $code = $_SESSION['bc_course_code']; $courseInfo = courseInfo($code); diff --git a/plugin/buy_courses/src/success.php b/plugin/buy_courses/src/success.php index 5aa56c5267..896402e979 100644 --- a/plugin/buy_courses/src/success.php +++ b/plugin/buy_courses/src/success.php @@ -18,9 +18,9 @@ $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $pruebas = ($row['sandbox'] == "YES") ? true: false; -$paypal_username = $row['username']; -$paypal_password = $row['password']; -$paypal_firma = $row['signature']; +$paypalUsername = $row['username']; +$paypalPassword = $row['password']; +$paypalSignature = $row['signature']; require_once("paypalfunctions.php"); /** @@ -38,9 +38,9 @@ if ($token != "") { $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); - $paypal_username = $row['username']; - $paypal_password = $row['password']; - $paypal_firma = $row['signature']; + $paypalUsername = $row['username']; + $paypalPassword = $row['password']; + $paypalSignature = $row['signature']; require_once 'paypalfunctions.php'; /** @@ -82,11 +82,11 @@ if ($token != "") { $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); - echo "GetExpressCheckoutDetails API call failed. "; - echo "Detailed Error Message: " . $ErrorLongMsg; - echo "Short Error Message: " . $ErrorShortMsg; - echo "Error Code: " . $ErrorCode; - echo "Error Severity Code: " . $ErrorSeverityCode; + echo "
    GetExpressCheckoutDetails API call failed. "; + echo "
    Detailed Error Message: " . $ErrorLongMsg; + echo "
    Short Error Message: " . $ErrorShortMsg; + echo "
    Error Code: " . $ErrorCode; + echo "
    Error Severity Code: " . $ErrorSeverityCode; } } @@ -94,9 +94,10 @@ if ($token != "") { if (!isset($_POST['paymentOption'])) { // Confirm the order $_cid = 0; + $templateName = $plugin->get_lang('PaymentMethods'); $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); - $tpl = new Template('PaymentType'); + $tpl = new Template($templateName); $code = $_SESSION['bc_course_code']; $courseInfo = courseInfo($code); @@ -117,7 +118,7 @@ if (!isset($_POST['paymentOption'])) { } - $listing_tpl = 'buy_courses/success.tpl'; + $listing_tpl = 'buy_courses/view/success.tpl'; $content = $tpl->fetch($listing_tpl); $tpl->assign('content', $content); $tpl->display_one_col_template(); @@ -130,9 +131,9 @@ if (!isset($_POST['paymentOption'])) { $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); - $paypal_username = $row['username']; - $paypal_password = $row['password']; - $paypal_firma = $row['signature']; + $paypalUsername = $row['username']; + $paypalPassword = $row['password']; + $paypalSignature = $row['signature']; require_once("paypalfunctions.php"); if ($PaymentOption == "PayPal") { diff --git a/plugin/buy_courses/view/configuration.tpl b/plugin/buy_courses/view/configuration.tpl index c27fdf4320..d66fe945a1 100644 --- a/plugin/buy_courses/view/configuration.tpl +++ b/plugin/buy_courses/view/configuration.tpl @@ -9,38 +9,37 @@ {{ 'Title'|get_lang }} {{ 'OfficialCode'|get_lang }} {{ 'Visible'|get_lang }} - {{ 'Price'|get_lang }} - {{ 'Options'|get_lang }} + {{ 'Price'|get_plugin_lang('Buy_CoursesPlugin') }} + {{ 'Option'|get_lang }} {% set i = 0 %} {% for course in courses %} - {{ i%2 == 0 ? '' : '' }} - {% set i = i + 1 %} - - {{ visibility[course.visibility] }} - {{course.title}} - {{ course.visual_code }} - - - {{course.code}} - - - {% if course.visible == 1 %} - - {% else %} - - {% endif %} - - {{ currency }} - -
    ok
    - - - -{% endfor %} - - -
    + {{ i%2 == 0 ? '' : '' }} + {% set i = i + 1 %} + + {{ visibility[course.visibility] }} + {{course.title}} + {{ course.visual_code }} + + + {{course.code}} + + + {% if course.visible == 1 %} + + {% else %} + + {% endif %} + + {{ currency }} + +
    ok
    + + + + {% endfor %} + +
    \ No newline at end of file diff --git a/plugin/buy_courses/view/index.tpl b/plugin/buy_courses/view/index.tpl new file mode 100644 index 0000000000..4210c78755 --- /dev/null +++ b/plugin/buy_courses/view/index.tpl @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/plugin/buy_courses/view/list.tpl b/plugin/buy_courses/view/list.tpl index 3fa9f515b8..28fdcad4b3 100644 --- a/plugin/buy_courses/view/list.tpl +++ b/plugin/buy_courses/view/list.tpl @@ -5,70 +5,77 @@
    -
    + +
  • +
    +
  • + +
  • + + + +
    + {% if rmessage == "YES" %} +
    + {{ responseMessage }} +
    + {% endif %} + {% for course in courses %} +
    +
    +
    + -
    - {% if rmessage == "YES" %} -
    {{ message }} +
    +
    +
    +

    {{ course.title }}

    +
    {{ 'Teacher'|get_lang }}: {{ course.teacher }}
    + {% if course.enrolled == "YES" %} + {{ 'TheUserIsAlreadyRegisteredInTheCourse'|get_plugin_lang('Buy_CoursesPlugin') }} {% endif %} - {% for course in courses %} -
    -
    -
    -
    - - - -
    -
    -
    -
    -

    {{ course.title }}

    -
    {{ 'Teacher'|get_lang }}: {{ course.teacher }}
    -
    - {% if course.enrolled == "YES" %} - {{ 'TheUserIsAlreadyRegisteredInTheCourse'|get_lang }} - {% endif %} - {% if course.enrolled == "TMP" %} - {{ 'bc_tmp_registrado'|get_lang }} - {% endif %} + {% if course.enrolled == "TMP" %} + {{ 'WaitingToReceiveThePayment'|get_plugin_lang('Buy_CoursesPlugin') }} + {% endif %} +
    +
    +
    + {{ course.price }} {{ currency }} +
    +
    + +
    +
    +
    + {% endfor %}
    -
    -
    {{ course.price }} {{ currency }} -
    -
    -
    - {{ 'Description'|get_lang }} - {% if course.enrolled == "NO" %} - {{'Buy'|get_lang }} - {% endif %} -
    -
    -
    -
    -{% endfor %} -
    \ No newline at end of file diff --git a/plugin/buy_courses/view/paymentsetup.tpl b/plugin/buy_courses/view/paymentsetup.tpl index 5388954891..dd19ab2cce 100644 --- a/plugin/buy_courses/view/paymentsetup.tpl +++ b/plugin/buy_courses/view/paymentsetup.tpl @@ -4,9 +4,9 @@
    -

    Tipo de moneda:

    +

    {{ 'CurrencyType'|get_plugin_lang('Buy_CoursesPlugin') }}:

    - + {% if paypal_enable == "true" %}

    Configuración PayPal:

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

    Configuración Transferencia:

    - +
    - + - + {% set i = 0 %} @@ -55,6 +55,7 @@ {% endfor %} diff --git a/plugin/buy_courses/view/pending_orders.tpl b/plugin/buy_courses/view/pending_orders.tpl index 26fad299d1..daf0e90f05 100644 --- a/plugin/buy_courses/view/pending_orders.tpl +++ b/plugin/buy_courses/view/pending_orders.tpl @@ -6,7 +6,7 @@
    {{ 'Name'|get_lang }}{{ 'Account'|get_lang }}{{ 'BankAccount'|get_plugin_lang('Buy_CoursesPlugin') }} {{ 'SWIFT'|get_lang }}{{ 'Options'|get_lang }}{{ 'Option'|get_lang }}
    {{ transf.swift | e }} +
    - + @@ -16,9 +16,7 @@ {% set i = 0 %} {% for order in pending %} - {{ i%2==0 ? ' - ' : ' - ' }} + {{ i%2==0 ? '' : '' }} {% set i = i + 1 %} @@ -27,10 +25,10 @@ {% endfor %} diff --git a/plugin/buy_courses/view/process.tpl b/plugin/buy_courses/view/process.tpl index 41c7b79453..873cdd9c26 100644 --- a/plugin/buy_courses/view/process.tpl +++ b/plugin/buy_courses/view/process.tpl @@ -6,12 +6,12 @@
    @@ -50,7 +50,7 @@
    - {{ 'PaymentMethods'|get_lang }} + {{ 'PaymentMethods'|get_plugin_lang('Buy_CoursesPlugin') }}
    {% if paypal_enable == "true" %} @@ -60,14 +60,14 @@ {% endif %} {% if transference_enable == "true" %} {% endif %}

    - +
    diff --git a/plugin/buy_courses/view/process_confirm.tpl b/plugin/buy_courses/view/process_confirm.tpl index 2022b58bb1..c3bd6363fd 100644 --- a/plugin/buy_courses/view/process_confirm.tpl +++ b/plugin/buy_courses/view/process_confirm.tpl @@ -6,12 +6,12 @@
    @@ -40,9 +40,8 @@
    {{ - 'Description'|get_lang }} - + href="{{ server }}plugin/buy_courses/src/ajax.php?code={{ course.code }}">{{'Description'|get_lang }} +
    @@ -53,37 +52,35 @@
    {{ 'Ref_pedido'|get_lang }}{{ 'ReferenceOrder'|get_plugin_lang('Buy_CoursesPlugin') }} {{ 'Name'|get_lang }} {{ 'Title'|get_lang }} {{ 'Price'|get_lang }}
    {{ order.reference }} {{ order.name }}{{ order.date }} ok + title="{{ 'SubscribeUser'|get_plugin_lang('Buy_CoursesPlugin') }}"/>    delete + title="{{ 'DeleteTheOrder'|get_plugin_lang('Buy_CoursesPlugin') }}"/>
    - + {% set i = 0 %} {% for account in accounts %} - {{ i%2==0 ? ' - ' : ' - ' }} + {{ i%2==0 ? '' : '' }} {% set i = i + 1 %} {% endfor %}
    Datos Bancarios{{ 'BankAccountInformation'|get_plugin_lang('Buy_CoursesPlugin') }}
    {{ account.name | e }}
    {% if account.swift != '' %} SWIFT: {{ account.swift | e }}
    {% endif %} - Cuenta Bancaria: {{ account.account | e }}
    + {{ 'BankAccount'|get_plugin_lang('Buy_CoursesPlugin') }}: {{ account.account | e }}

    -
    {{ 'Message_conf_transf'|get_lang | e}} +
    {{ 'OnceItIsConfirmed,YouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'|get_plugin_lang('Buy_CoursesPlugin') | e}}

    -
    + -
    - +
    + +
    diff --git a/plugin/buy_courses/view/success.tpl b/plugin/buy_courses/view/success.tpl index f83c772e9c..2f66f74f7d 100644 --- a/plugin/buy_courses/view/success.tpl +++ b/plugin/buy_courses/view/success.tpl @@ -6,12 +6,12 @@
    @@ -40,8 +40,7 @@
    {{ - 'Description'|get_lang }} + href="{{ server }}plugin/buy_courses/function/ajax.php?code={{ course.code }}">{{'Description'|get_lang }}
    @@ -51,12 +50,12 @@

    -
    + -
    - - +
    + +