Fix many coding style issues, warnings and notice messages. Test and working. Please, DO NOT consider this as a minor commit - refs #7272

1.9.x
Imanol Losada 11 years ago
parent 744e719e5f
commit 66db634798
  1. 2
      plugin/buycourses/config.php
  2. 4
      plugin/buycourses/database.php
  3. 4
      plugin/buycourses/lang/english.php
  4. 4
      plugin/buycourses/lang/french.php
  5. 40
      plugin/buycourses/src/buy_course.lib.php
  6. 6
      plugin/buycourses/src/buy_course_plugin.class.php
  7. 11
      plugin/buycourses/src/configuration.php
  8. 73
      plugin/buycourses/src/function.php
  9. 11
      plugin/buycourses/src/list.php
  10. 11
      plugin/buycourses/src/process.php
  11. 18
      plugin/buycourses/src/success.php

@ -3,7 +3,7 @@
define('TABLE_BUY_SESSION', 'plugin_buy_session'); define('TABLE_BUY_SESSION', 'plugin_buy_session');
define('TABLE_BUY_SESSION_COURSE', 'plugin_buy_session_course'); define('TABLE_BUY_SESSION_COURSE', 'plugin_buy_session_course');
define('TABLE_BUY_SESSION_TEMPORAL', 'plugin_buy_session_temporal'); define('TABLE_BUY_SESSION_TEMPORARY', 'plugin_buy_session_temporary');
define('TABLE_BUY_SESSION_SALE', 'plugin_buy_session_sale'); define('TABLE_BUY_SESSION_SALE', 'plugin_buy_session_sale');
define('TABLE_BUY_COURSE', 'plugin_buy_course'); define('TABLE_BUY_COURSE', 'plugin_buy_course');
define('TABLE_BUY_COURSE_COUNTRY', 'plugin_buy_course_country'); define('TABLE_BUY_COURSE_COUNTRY', 'plugin_buy_course_country');

@ -40,7 +40,7 @@ while ($row = Database::fetch_assoc($res)) {
$table = Database::get_main_table(TABLE_BUY_COURSE); $table = Database::get_main_table(TABLE_BUY_COURSE);
$sql = "CREATE TABLE IF NOT EXISTS $table ( $sql = "CREATE TABLE IF NOT EXISTS $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY, id INT unsigned NOT NULL auto_increment PRIMARY KEY,
session_id INT unsigned NOT NULL DEFAULT '0', session_id INT unsigned NOT NULL DEFAULT 0,
course_id INT unsigned NOT NULL DEFAULT '0', course_id INT unsigned NOT NULL DEFAULT '0',
code VARCHAR(40), code VARCHAR(40),
title VARCHAR(250), title VARCHAR(250),
@ -362,7 +362,7 @@ $sql = "CREATE TABLE IF NOT EXISTS $table (
swift VARCHAR(100) NOT NULL DEFAULT '')"; swift VARCHAR(100) NOT NULL DEFAULT '')";
Database::query($sql); Database::query($sql);
$table = Database::get_main_table(TABLE_BUY_SESSION_TEMPORAL); $table = Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY);
$sql = "CREATE TABLE IF NOT EXISTS $table ( $sql = "CREATE TABLE IF NOT EXISTS $table (
cod INT unsigned NOT NULL auto_increment PRIMARY KEY, cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
user_id INT unsigned NOT NULL, user_id INT unsigned NOT NULL,

@ -29,7 +29,7 @@ $strings['ProblemToDeleteTheAccount'] = 'Problem removing account';
$strings['ProblemToSaveTheMessage'] = 'Problem saving message'; $strings['ProblemToSaveTheMessage'] = 'Problem saving message';
$strings['ProblemToSubscribeTheUser'] = 'Problem subscribing the user'; $strings['ProblemToSubscribeTheUser'] = 'Problem subscribing the user';
$strings['TheSubscriptionAndActivationWereDoneSuccessfully'] = 'The subscription and activation were successful'; $strings['TheSubscriptionAndActivationWereDoneSuccessfully'] = 'The subscription and activation were successful';
$strings['TheUserIsAlreadyRegisteredInTheCourse'] = 'The user is already registered in the course.'; $strings['TheUserIsAlreadyRegisteredInTheCourse'] = 'You are already registered in the course.';
$strings['CourseListOnSale'] = 'List of courses on sale'; $strings['CourseListOnSale'] = 'List of courses on sale';
$strings['BuySessions'] = "Buy sessions"; $strings['BuySessions'] = "Buy sessions";
$strings['BuyCourses'] = 'Buy courses'; $strings['BuyCourses'] = 'Buy courses';
@ -66,4 +66,4 @@ $strings['PayPalConfig'] = "PayPal configuration:";
$strings['TransfersConfig'] = "Bank transfers configuration:"; $strings['TransfersConfig'] = "Bank transfers configuration:";
$strings['PayPalPaymentOKPleaseConfirm'] = "PayPal reports the transaction is ready to be executed. To acknowledge that you are OK to proceed, please click the confirmation button below. Once clicked, you will be registered to the course and the funds will be transferred from your PayPal account to our shop. You can always access your courses through the 'My courses' tab. Thank you for your custom!"; $strings['PayPalPaymentOKPleaseConfirm'] = "PayPal reports the transaction is ready to be executed. To acknowledge that you are OK to proceed, please click the confirmation button below. Once clicked, you will be registered to the course and the funds will be transferred from your PayPal account to our shop. You can always access your courses through the 'My courses' tab. Thank you for your custom!";
$strings['EnrollToSessionXSuccessful'] = "Your subscription to the session is complete"; $strings['EnrollToSessionXSuccessful'] = "Your subscription to the session is complete";
$strings['TheUserIsAlreadyRegisteredInTheSession'] = 'The user is already registered in the session.'; $strings['TheUserIsAlreadyRegisteredInTheSession'] = 'You are already registered in the session';

@ -65,5 +65,5 @@ $strings['ErrorContactPlatformAdmin'] = "Une erreur inconnue s'est produite. Veu
$strings['PayPalConfig'] = "Configuration PayPal:"; $strings['PayPalConfig'] = "Configuration PayPal:";
$strings['TransfersConfig'] = "Configuration des transfers bancaires:"; $strings['TransfersConfig'] = "Configuration des transfers bancaires:";
$strings['PayPalPaymentOKPleaseConfirm'] = "PayPal nous indique que la transaction est prête à être exécutée. Par mesure de sécurité, nous vous demandons de bien vouloir confirmer une dernière fois la transaction en cliquant sur le bouton de confirmation ci-dessous. Une fois cliqué, vous serez immédiatement enregistré au cours, et les fonds correspondants seront soustraits de votre compte PayPal. Vous pouvez accéder à vos cours à tout moment à partir de l'onglet 'Mes cours'. Merci de votre fidélité!"; $strings['PayPalPaymentOKPleaseConfirm'] = "PayPal nous indique que la transaction est prête à être exécutée. Par mesure de sécurité, nous vous demandons de bien vouloir confirmer une dernière fois la transaction en cliquant sur le bouton de confirmation ci-dessous. Une fois cliqué, vous serez immédiatement enregistré au cours, et les fonds correspondants seront soustraits de votre compte PayPal. Vous pouvez accéder à vos cours à tout moment à partir de l'onglet 'Mes cours'. Merci de votre fidélité!";
$strings['EnrollToSessionXSuccessful'] = "Votre inscription au session %s est terminée."; $strings['EnrollToSessionXSuccessful'] = "Votre inscription à la session %s est terminée.";
$strings['TheUserIsAlreadyRegisteredInTheSession'] = "L'utilisateur est déjà inscrit au session"; $strings['TheUserIsAlreadyRegisteredInTheSession'] = "Vous êtes déjà inscrit à cette session";

@ -25,10 +25,10 @@ function sync()
$sql = "SELECT id_session, course_code, nbr_users FROM $tableSessionRelCourse"; $sql = "SELECT id_session, course_code, nbr_users FROM $tableSessionRelCourse";
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) { while ($row = Database::fetch_assoc($res)) {
$sql = "SELECT 1 FROM $tableBuySessionRelCourse WHERE id_session='" . $row['id'] . "';"; $sql = "SELECT 1 FROM $tableBuySessionRelCourse WHERE id_session='" . $row['id_session'] . "';";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$sql = "UPDATE $tableBuySessionRelCourse SET sync = 1 WHERE id_session='" . $row['id'] . "';"; $sql = "UPDATE $tableBuySessionRelCourse SET sync = 1 WHERE id_session='" . $row['id_session'] . "';";
Database::query($sql); Database::query($sql);
} else { } else {
$sql = "INSERT INTO $tableBuySessionRelCourse (id_session, course_code, nbr_users, sync) $sql = "INSERT INTO $tableBuySessionRelCourse (id_session, course_code, nbr_users, sync)
@ -147,7 +147,7 @@ function userSessionList()
$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$tableSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tableSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tableBuySessionTemporal = Database::get_main_table(TABLE_BUY_SESSION_TEMPORAL); $tableBuySessionTemporal = Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY);
// get existing sessions // get existing sessions
$sql = "SELECT a.session_id, a.visible, a.price, b.* $sql = "SELECT a.session_id, a.visible, a.price, b.*
@ -182,8 +182,8 @@ function userSessionList()
$rowTmp = Database::fetch_assoc($tmp); $rowTmp = Database::fetch_assoc($tmp);
$row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname'];
//check images //check images
if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) { if (file_exists(api_get_path(SYS_COURSE_PATH) . $row['directory'] . "/course-pic85x85.png")) {
$row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png"; $row['course_img'] = "courses/" . $row['directory'] . "/course-pic85x85.png";
} else { } else {
$row['course_img'] = "main/img/without_picture.png"; $row['course_img'] = "main/img/without_picture.png";
} }
@ -195,14 +195,14 @@ function userSessionList()
if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') {
$sql = "SELECT 1 FROM $tableSessionRelUser $sql = "SELECT 1 FROM $tableSessionRelUser
WHERE id_session='".$rowSession['session_id']."' AND WHERE id_session='".$rowSession['session_id']."' AND
id_user='" . $_SESSION['_user']['user_id'] . "';"; id_user ='" . $_SESSION['_user']['user_id'] . "';";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$rowSession['enrolled'] = "YES"; $rowSession['enrolled'] = "YES";
} else { } else {
$sql = "SELECT 1 FROM $tableBuySessionTemporal $sql = "SELECT 1 FROM $tableBuySessionTemporal
WHERE id_session='".$rowSession['session_id']."' AND WHERE session_id ='".$rowSession['session_id']."' AND
id_user='" . $_SESSION['_user']['user_id'] . "';"; user_id='" . $_SESSION['_user']['user_id'] . "';";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$rowSession['enrolled'] = "TMP"; $rowSession['enrolled'] = "TMP";
@ -212,8 +212,8 @@ function userSessionList()
} }
} else { } else {
$sql = "SELECT 1 FROM $tableBuySessionTemporal $sql = "SELECT 1 FROM $tableBuySessionTemporal
WHERE id_session='".$rowSession['session_id']."' AND WHERE session_id ='".$rowSession['session_id']."' AND
id_user='" . $_SESSION['_user']['user_id'] . "';"; user_id='" . $_SESSION['_user']['user_id'] . "';";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$rowSession['enrolled'] = "TMP"; $rowSession['enrolled'] = "TMP";
@ -320,7 +320,7 @@ function checkUserBuyTransfer($parameter, $user, $type = 'COURSE')
{ {
$sql = "SELECT 1 FROM %s WHERE %s ='" . $parameter . "' AND id_user='" . $user . "';"; $sql = "SELECT 1 FROM %s WHERE %s ='" . $parameter . "' AND id_user='" . $user . "';";
$sql = $type === 'SESSION' ? $sql = $type === 'SESSION' ?
sprintf($sql, Database::get_main_table(TABLE_BUY_SESSION_TEMPORAL), 'session_id') : sprintf($sql, Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY), 'session_id') :
sprintf($sql, Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL), 'course_code'); sprintf($sql, Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL), 'course_code');
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
@ -461,7 +461,7 @@ function sessionInfo($code)
$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$tableSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tableSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tableBuySessionTemporal = Database::get_main_table(TABLE_BUY_SESSION_TEMPORAL); $tableBuySessionTemporal = Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY);
$code = Database::escape_string($code); $code = Database::escape_string($code);
$sql = "SELECT a.session_id, a.visible, a.price, b.* $sql = "SELECT a.session_id, a.visible, a.price, b.*
@ -495,8 +495,8 @@ function sessionInfo($code)
$rowTmp = Database::fetch_assoc($tmp); $rowTmp = Database::fetch_assoc($tmp);
$row['teacher'] = $rowTmp['firstname'].' '.$rowTmp['lastname']; $row['teacher'] = $rowTmp['firstname'].' '.$rowTmp['lastname'];
//check images //check images
if (file_exists("../../courses/".$row['code']."/course-pic85x85.png")) { if (file_exists(api_get_path(SYS_COURSE_PATH).$row['directory']."/course-pic85x85.png")) {
$row['course_img'] = "courses/".$row['code']."/course-pic85x85.png"; $row['course_img'] = "courses/".$row['directory']."/course-pic85x85.png";
} else { } else {
$row['course_img'] = "main/img/without_picture.png"; $row['course_img'] = "main/img/without_picture.png";
} }
@ -622,10 +622,10 @@ function randomText($long = 6, $minWords = true, $maxWords = true, $number = tru
* Generates an order reference * Generates an order reference
* @result string A reference number * @result string A reference number
*/ */
function calculateReference($bc_codetext) function calculateReference($bcCodetext)
{ {
$tableBuyTemporal = $bc_codetext === 'THIS_IS_A_SESSION' ? $tableBuyTemporal = $bcCodetext === 'THIS_IS_A_SESSION' ?
Database::get_main_table(TABLE_BUY_SESSION_TEMPORAL) : Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY) :
Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
$sql = "SELECT MAX(cod) as cod FROM $tableBuyTemporal"; $sql = "SELECT MAX(cod) as cod FROM $tableBuyTemporal";
$res = Database::query($sql); $res = Database::query($sql);
@ -640,10 +640,10 @@ function calculateReference($bc_codetext)
* @result array List of orders * @result array List of orders
* @todo Enable pagination * @todo Enable pagination
*/ */
function pendingList($bc_codetext) function pendingList($bcCodetext)
{ {
$tableBuyTemporal = $bc_codetext === 'THIS_IS_A_SESSION' ? $tableBuyTemporal = $bcCodetext === 'THIS_IS_A_SESSION' ?
Database::get_main_table(TABLE_BUY_SESSION_TEMPORAL) : Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY) :
Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL); Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
$sql = "SELECT * FROM $tableBuyTemporal;"; $sql = "SELECT * FROM $tableBuyTemporal;";
$res = Database::query($sql); $res = Database::query($sql);

@ -4,6 +4,7 @@
* Description of buy_courses_plugin * Description of buy_courses_plugin
* @package chamilo.plugin.buycourses * @package chamilo.plugin.buycourses
* @author Jose Angel Ruiz <jaruiz@nosolored.com> * @author Jose Angel Ruiz <jaruiz@nosolored.com>
* @author Imanol Losada <imanol.losada@beeznest.com>
*/ */
/** /**
* Plugin class for the BuyCourses plugin * Plugin class for the BuyCourses plugin
@ -25,7 +26,8 @@ class BuyCoursesPlugin extends Plugin
parent::__construct( parent::__construct(
'1.0', '1.0',
'Jose Angel Ruiz - NoSoloRed (original author), 'Jose Angel Ruiz - NoSoloRed (original author),
Francis Gonzales and Yannick Warnier - BeezNest (integration)', Francis Gonzales and Yannick Warnier - BeezNest (integration),
Imanol Losada - BeezNest',
array( array(
'include_sessions' => 'boolean', 'include_sessions' => 'boolean',
'paypal_enable' => 'boolean', 'paypal_enable' => 'boolean',
@ -51,7 +53,7 @@ class BuyCoursesPlugin extends Plugin
$tablesToBeDeleted = array( $tablesToBeDeleted = array(
TABLE_BUY_SESSION, TABLE_BUY_SESSION,
TABLE_BUY_SESSION_COURSE, TABLE_BUY_SESSION_COURSE,
TABLE_BUY_SESSION_TEMPORAL, TABLE_BUY_SESSION_TEMPORARY,
TABLE_BUY_SESSION_SALE, TABLE_BUY_SESSION_SALE,
TABLE_BUY_COURSE, TABLE_BUY_COURSE,
TABLE_BUY_COURSE_COUNTRY, TABLE_BUY_COURSE_COUNTRY,

@ -44,13 +44,12 @@ if ($teacher) {
$tpl->assign('save_img', $saveImgPath); $tpl->assign('save_img', $saveImgPath);
$tpl->assign('currency', $currencyType); $tpl->assign('currency', $currencyType);
$result = array_shift( $selectedValue = Database::select(
Database::select( 'selected_value',
'selected_value', Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT),
Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT), array('where'=> array('variable = ?' => array('buycourses_include_sessions')))
array('where'=> array('variable = ?' => array('buycourses_include_sessions')))
)
); );
$result = array_shift($selectedValue);
if ($result['selected_value'] === 'true') { if ($result['selected_value'] === 'true') {
$tpl->assign('sessionsAreIncluded', 'YES'); $tpl->assign('sessionsAreIncluded', 'YES');
$tpl->assign('sessions', listSessions()); $tpl->assign('sessions', listSessions());

@ -13,6 +13,7 @@ require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'course.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'course.lib.php';
$tableBuySession = Database::get_main_table(TABLE_BUY_SESSION); $tableBuySession = Database::get_main_table(TABLE_BUY_SESSION);
$tableBuySessionTemporal = Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY);
$tableBuySessionRelCourse = Database::get_main_table(TABLE_BUY_SESSION_COURSE); $tableBuySessionRelCourse = Database::get_main_table(TABLE_BUY_SESSION_COURSE);
$tableSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tableSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE); $tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
@ -30,14 +31,12 @@ $plugin = BuyCoursesPlugin::create();
$buy_name = $plugin->get_lang('Buy'); $buy_name = $plugin->get_lang('Buy');
if ($_REQUEST['tab'] == 'sync') { if ($_REQUEST['tab'] == 'sync') {
$sql = "SELECT code, title FROM $tableCourse;"; $sql = "SELECT code, title FROM $tableCourse;";
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) { while ($row = Database::fetch_assoc($res)) {
$aux_code .= $row['code']; $aux_code .= $row['code'];
$aux_title .= $row['title']; $aux_title .= $row['title'];
} }
$sql = "SELECT name, date_start, date_end FROM $tableSession;"; $sql = "SELECT name, date_start, date_end FROM $tableSession;";
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) { while ($row = Database::fetch_assoc($res)) {
@ -45,16 +44,14 @@ if ($_REQUEST['tab'] == 'sync') {
$aux_date_start .= $row['date_start']; $aux_date_start .= $row['date_start'];
$aux_date_end .= $row['date_end']; $aux_date_end .= $row['date_end'];
} }
echo json_encode(array("status" => "true", "content" => $content)); echo json_encode(array("status" => "true", "content" => $content));
} }
if ($_REQUEST['tab'] == 'sessions_filter') { if ($_REQUEST['tab'] == 'sessions_filter') {
$session = Database::escape_string($_REQUEST['session']); $session = isset($_REQUEST['session']) ? Database::escape_string($_REQUEST['session']) : '';
$priceMin = Database::escape_string($_REQUEST['pricemin']); $priceMin = isset($_REQUEST['pricemin']) ? Database::escape_string($_REQUEST['pricemin']) : '';
$priceMax = Database::escape_string($_REQUEST['pricemax']); $priceMax = isset($_REQUEST['pricemax']) ? Database::escape_string($_REQUEST['pricemax']) : '';
$show = Database::escape_string($_REQUEST['show']); $category = isset($_REQUEST['category']) ? Database::escape_string($_REQUEST['category']) : '';
$category = Database::escape_string($_REQUEST['category']);
$server = api_get_path(WEB_PATH); $server = api_get_path(WEB_PATH);
$filter = ''; $filter = '';
@ -125,7 +122,7 @@ if ($_REQUEST['tab'] == 'sessions_filter') {
$rowTmp = Database::fetch_assoc($tmp); $rowTmp = Database::fetch_assoc($tmp);
$row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname']; $row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname'];
//check images //check images
if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) { if (file_exists(api_get_path(SYS_COURSE_PATH) . $row['code'] . "/course-pic85x85.png")) {
$row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png"; $row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png";
} else { } else {
$row['course_img'] = "main/img/without_picture.png"; $row['course_img'] = "main/img/without_picture.png";
@ -137,13 +134,15 @@ if ($_REQUEST['tab'] == 'sessions_filter') {
//check if the user is enrolled in the current session //check if the user is enrolled in the current session
if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') { if (isset($_SESSION['_user']) || $_SESSION['_user']['user_id'] != '') {
$sql = "SELECT 1 FROM $tableSessionRelUser $sql = "SELECT 1 FROM $tableSessionRelUser
WHERE user_id='" . $_SESSION['_user']['user_id'] . "';"; WHERE id_session='".$rowSession['session_id']."' AND
id_user ='" . $_SESSION['_user']['user_id'] . "';";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$rowSession['enrolled'] = "YES"; $rowSession['enrolled'] = "YES";
} else { } else {
$sql = "SELECT 1 FROM $tableBuySessionTemporal $sql = "SELECT 1 FROM $tableBuySessionTemporal
WHERE user_id='" . $_SESSION['_user']['user_id'] . "';"; WHERE session_id ='".$rowSession['session_id']."' AND
user_id='" . $_SESSION['_user']['user_id'] . "';";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$rowSession['enrolled'] = "TMP"; $rowSession['enrolled'] = "TMP";
@ -153,7 +152,8 @@ if ($_REQUEST['tab'] == 'sessions_filter') {
} }
} else { } else {
$sql = "SELECT 1 FROM $tableBuySessionTemporal $sql = "SELECT 1 FROM $tableBuySessionTemporal
WHERE user_id='" . $_SESSION['_user']['user_id'] . "';"; WHERE session_id ='".$rowSession['session_id']."' AND
user_id='" . $_SESSION['_user']['user_id'] . "';";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$rowSession['enrolled'] = "TMP"; $rowSession['enrolled'] = "TMP";
@ -168,7 +168,7 @@ if ($_REQUEST['tab'] == 'sessions_filter') {
} }
$currencyType = findCurrency(); $currencyType = findCurrency();
$content = '';;
foreach ($auxSessions as $session) { foreach ($auxSessions as $session) {
$content .= '<div class="well_border span8">'; $content .= '<div class="well_border span8">';
$content .= '<div class="row">'; $content .= '<div class="row">';
@ -177,6 +177,9 @@ if ($_REQUEST['tab'] == 'sessions_filter') {
$content .= '<h3>'.$session['name'].'</h3>'; $content .= '<h3>'.$session['name'].'</h3>';
$content .= '<h5>'.get_lang('From').' '.$session['date_start']; $content .= '<h5>'.get_lang('From').' '.$session['date_start'];
$content .= ' '.get_lang('Until').' '.$session['date_end'].'</h5>'; $content .= ' '.get_lang('Until').' '.$session['date_end'].'</h5>';
if ($session['enrolled'] == "YES") {
$content .= '<span class="label label-info">'.$plugin->get_lang('TheUserIsAlreadyRegisteredInTheSession').'</span>';
}
$content .= '</div>'; $content .= '</div>';
$content .= '</div>'; $content .= '</div>';
$content .= '<div class="span right">'; $content .= '<div class="span right">';
@ -200,7 +203,7 @@ if ($_REQUEST['tab'] == 'sessions_filter') {
$content .= '<div class="span">'; $content .= '<div class="span">';
$content .= '<div class="thumbnail">'; $content .= '<div class="thumbnail">';
$content .= '<a class="ajax" rel="gb_page_center[778]" title=""'; $content .= '<a class="ajax" rel="gb_page_center[778]" title=""';
$content .= 'href="'.$server.'main/inc/src/course_home.ajax.php?'; $content .= 'href="'.$server.'plugin/buycourses/src/ajax.php?';
$content .= 'a=show_course_information&code='.$course['code'].'">'; $content .= 'a=show_course_information&code='.$course['code'].'">';
$content .= '<img alt="" src="' . $server . $course['course_img'] . '">'; $content .= '<img alt="" src="' . $server . $course['course_img'] . '">';
$content .= '</a>'; $content .= '</a>';
@ -211,15 +214,12 @@ if ($_REQUEST['tab'] == 'sessions_filter') {
$content .= '<h3>' . $course['title'] . '</h3>'; $content .= '<h3>' . $course['title'] . '</h3>';
$content .= '<h5>' . get_lang('Teacher') . ': ' . $course['teacher'] . '</h5>'; $content .= '<h5>' . get_lang('Teacher') . ': ' . $course['teacher'] . '</h5>';
$content .= '</div>'; $content .= '</div>';
if ($course['enrolled'] == "YES") {
$content .= '<span class="label label-info">'.$plugin->get_lang('TheUserIsAlreadyRegistered').'</span>';
}
$content .= '</div>'; $content .= '</div>';
$content .= '<div class="span right">'; $content .= '<div class="span right">';
$content .= '<div class="cleared"></div>'; $content .= '<div class="cleared"></div>';
$content .= '<div class="btn-toolbar right">'; $content .= '<div class="btn-toolbar right">';
$content .= '<a class="ajax btn btn-primary" title=""'; $content .= '<a class="ajax btn btn-primary" title=""';
$content .= 'href="'.$server.'main/inc/src/course_home.ajax.php?'; $content .= 'href="'.$server.'plugin/buycourses/src/ajax.php?';
$content .= 'a=show_course_information&code='.$course['code'].'">'.get_lang('Description').'</a>'; $content .= 'a=show_course_information&code='.$course['code'].'">'.get_lang('Description').'</a>';
$content .= '</div>'; $content .= '</div>';
$content .= '</div>'; $content .= '</div>';
@ -235,7 +235,7 @@ if ($_REQUEST['tab'] == 'courses_filter') {
$course = Database::escape_string($_REQUEST['course']); $course = Database::escape_string($_REQUEST['course']);
$priceMin = Database::escape_string($_REQUEST['pricemin']); $priceMin = Database::escape_string($_REQUEST['pricemin']);
$priceMax = Database::escape_string($_REQUEST['pricemax']); $priceMax = Database::escape_string($_REQUEST['pricemax']);
$show = Database::escape_string($_REQUEST['show']); //$show = Database::escape_string($_REQUEST['show']);
$category = Database::escape_string($_REQUEST['category']); $category = Database::escape_string($_REQUEST['category']);
$server = api_get_path(WEB_PATH); $server = api_get_path(WEB_PATH);
@ -315,21 +315,22 @@ if ($_REQUEST['tab'] == 'courses_filter') {
$row['course_img'] = "main/img/without_picture.png"; $row['course_img'] = "main/img/without_picture.png";
} }
if ($show == "YES" && $row['enrolled'] == "YES") { //if ($show == "YES" && $row['enrolled'] == "YES") {
; // ;
} else { //} else {
$aux[] = $row; $aux[] = $row;
} //}
} }
$currencyType = findCurrency(); $currencyType = findCurrency();
$content = '';
foreach ($aux as $course) { foreach ($aux as $course) {
$content .= '<div class="well_border span8">'; $content .= '<div class="well_border span8">';
$content .= '<div class="row">'; $content .= '<div class="row">';
$content .= '<div class="span">'; $content .= '<div class="span">';
$content .= '<div class="thumbnail">'; $content .= '<div class="thumbnail">';
$content .= '<a class="ajax" rel="gb_page_center[778]" title=""'; $content .= '<a class="ajax" rel="gb_page_center[778]" title=""';
$content .= 'href="'.$server.'main/inc/src/course_home.ajax.php?'; $content .= 'href="'.$server.'plugin/buycourses/src/ajax.php?';
$content .= 'a=show_course_information&code='.$course['code'].'">'; $content .= 'a=show_course_information&code='.$course['code'].'">';
$content .= '<img alt="" src="'.$server.$course['course_img'].'">'; $content .= '<img alt="" src="'.$server.$course['course_img'].'">';
$content .= '</a>'; $content .= '</a>';
@ -341,7 +342,7 @@ if ($_REQUEST['tab'] == 'courses_filter') {
$content .= '<h5>'.get_lang('Teacher').': '.$course['teacher'].'</h5>'; $content .= '<h5>'.get_lang('Teacher').': '.$course['teacher'].'</h5>';
$content .= '</div>'; $content .= '</div>';
if ($course['enrolled'] == "YES") { if ($course['enrolled'] == "YES") {
$content .= '<span class="label label-info">'.$plugin->get_lang('TheUserIsAlreadyRegistered').'</span>'; $content .= '<span class="label label-info">'.$plugin->get_lang('TheUserIsAlreadyRegisteredInTheCourse').'</span>';
} }
$content .= '</div>'; $content .= '</div>';
$content .= '<div class="span right">'; $content .= '<div class="span right">';
@ -349,7 +350,7 @@ if ($_REQUEST['tab'] == 'courses_filter') {
$content .= '<div class="cleared"></div>'; $content .= '<div class="cleared"></div>';
$content .= '<div class="btn-toolbar right">'; $content .= '<div class="btn-toolbar right">';
$content .= '<a class="ajax btn btn-primary" title=""'; $content .= '<a class="ajax btn btn-primary" title=""';
$content .= 'href="'.$server.'main/inc/src/course_home.ajax.php?'; $content .= 'href="'.$server.'plugin/buycourses/src/ajax.php?';
$content .= 'a=show_course_information&code='.$course['code'].'">'.get_lang('Description').'</a>&nbsp;'; $content .= 'a=show_course_information&code='.$course['code'].'">'.get_lang('Description').'</a>&nbsp;';
if ($course['enrolled'] != "YES") { if ($course['enrolled'] != "YES") {
$content .= '<a class="btn btn-success" title=""'; $content .= '<a class="btn btn-success" title=""';
@ -360,7 +361,6 @@ if ($_REQUEST['tab'] == 'courses_filter') {
$content .= '</div>'; $content .= '</div>';
$content .= '</div>'; $content .= '</div>';
} }
echo json_encode(array("status" => "true", "content" => $content)); echo json_encode(array("status" => "true", "content" => $content));
} }
@ -433,19 +433,22 @@ if ($_REQUEST['tab'] == 'delete_account') {
} }
if ($_REQUEST['tab'] == 'save_mod') { if ($_REQUEST['tab'] == 'save_mod') {
$_REQUEST['id'] = Database::escape_string($_REQUEST['id']);
$id = intval($_REQUEST['course_id']); $id;
$tableBuy = $tableBuyCourse; $tableBuy;
$tableField = 'course_id'; $tableField;
if (isset($_REQUEST['session_id'])) { if (isset($_REQUEST['course_id'])) {
$id = intval($_REQUEST['course_id']);
$tableBuy = $tableBuyCourse;
$tableField = 'course_id';
} else {
$id = intval($_REQUEST['session_id']); $id = intval($_REQUEST['session_id']);
$tableBuy = $tableBuySession; $tableBuy = $tableBuySession;
$tableField = 'session_id'; $tableField = 'session_id';
} }
$visible = ($_REQUEST['visible'] == "checked") ? 1 : 0; $visible = (isset($_REQUEST['visible'])) ? 1 : 0;
$price = Database::escape_string($_REQUEST['price']); $price = Database::escape_string($_REQUEST['price']);
$sql = "UPDATE $tableBuy $sql = "UPDATE $tableBuy
@ -454,7 +457,7 @@ if ($_REQUEST['tab'] == 'save_mod') {
WHERE " . $tableField . " = '" . $id . "';"; WHERE " . $tableField . " = '" . $id . "';";
$res = Database::query($sql); $res = Database::query($sql);
if (!res) { if (!$res) {
$content = $plugin->get_lang('ProblemToSaveTheMessage') . Database::error(); $content = $plugin->get_lang('ProblemToSaveTheMessage') . Database::error();
echo json_encode(array("status" => "false", "content" => $content)); echo json_encode(array("status" => "false", "content" => $content));
} else { } else {

@ -50,13 +50,12 @@ $tpl->assign('courses', $courseList);
$tpl->assign('category', $categoryList); $tpl->assign('category', $categoryList);
$tpl->assign('currency', $currencyType); $tpl->assign('currency', $currencyType);
$result = array_shift( $selectedValue = Database::select(
Database::select( 'selected_value',
'selected_value', Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT),
Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT), array('where'=> array('variable = ?' => array('buycourses_include_sessions')))
array('where'=> array('variable = ?' => array('buycourses_include_sessions')))
)
); );
$result = array_shift($selectedValue);
if ($result['selected_value'] === 'true') { if ($result['selected_value'] === 'true') {
$tpl->assign('sessionsAreIncluded', 'YES'); $tpl->assign('sessionsAreIncluded', 'YES');

@ -27,13 +27,12 @@ if (!empty($_GET['code'])) {
$code = $_SESSION['bc_code']; $code = $_SESSION['bc_code'];
} }
$result = array_shift( $selectedValue = Database::select(
Database::select( 'selected_value',
'selected_value', Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT),
Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT), array('where'=> array('variable = ?' => array('buycourses_include_sessions')))
array('where'=> array('variable = ?' => array('buycourses_include_sessions')))
)
); );
$result = array_shift($selectedValue);
if ($codeType === 'SESSION' && $result['selected_value'] === 'true') { if ($codeType === 'SESSION' && $result['selected_value'] === 'true') {
$tableSession = Database::get_main_table(TABLE_MAIN_SESSION); $tableSession = Database::get_main_table(TABLE_MAIN_SESSION);

@ -65,23 +65,23 @@ if ($token != "") {
$email = $resArray["EMAIL"]; // ' Email address of payer. $email = $resArray["EMAIL"]; // ' Email address of payer.
$payerId = $resArray["PAYERID"]; // ' Unique PayPal customer account identification number. $payerId = $resArray["PAYERID"]; // ' Unique PayPal customer account identification number.
$payerStatus = $resArray["PAYERSTATUS"]; // ' Status of payer. Character length and limitations: 10 single-byte alphabetic characters. $payerStatus = $resArray["PAYERSTATUS"]; // ' Status of payer. Character length and limitations: 10 single-byte alphabetic characters.
$salutation = $resArray["SALUTATION"]; // ' Payer's salutation. $salutation = isset($resArray["SALUTATION"]) ? $resArray["SALUTATION"] : null; // ' Payer's salutation.
$firstName = $resArray["FIRSTNAME"]; // ' Payer's first name. $firstName = $resArray["FIRSTNAME"]; // ' Payer's first name.
$middleName = $resArray["MIDDLENAME"]; // ' Payer's middle name. $middleName = isset($resArray["MIDDLENAME"]) ? $resArray["MIDDLENAME"] : null; // ' Payer's middle name.
$lastName = $resArray["LASTNAME"]; // ' Payer's last name. $lastName = $resArray["LASTNAME"]; // ' Payer's last name.
$suffix = $resArray["SUFFIX"]; // ' Payer's suffix. $suffix = isset($resArray["SUFFIX"]) ? $resArray["SUFFIX"] : null; // ' Payer's suffix.
$cntryCode = $resArray["COUNTRY_CODE"]; // ' Payer's country of residence in the form of ISO standard 3166 two-character country codes. $cntryCode = isset($resArray["COUNTRY_CODE"]) ? $resArray["COUNTRY_CODE"] : null; // ' Payer's country of residence in the form of ISO standard 3166 two-character country codes.
$business = $resArray["BUSINESS"]; // ' Payer's business name. $business = isset($resArray["BUSINESS"]) ? $resArray["BUSINESS"] : null; // ' Payer's business name.
$shipToName = $resArray["PAYMENTREQUEST_0_SHIPTONAME"]; // ' Person's name associated with this address. $shipToName = $resArray["PAYMENTREQUEST_0_SHIPTONAME"]; // ' Person's name associated with this address.
$shipToStreet = $resArray["PAYMENTREQUEST_0_SHIPTOSTREET"]; // ' First street address. $shipToStreet = $resArray["PAYMENTREQUEST_0_SHIPTOSTREET"]; // ' First street address.
$shipToStreet2 = $resArray["PAYMENTREQUEST_0_SHIPTOSTREET2"]; // ' Second street address. $shipToStreet2 = isset($resArray["PAYMENTREQUEST_0_SHIPTOSTREET2"]) ? $resArray["PAYMENTREQUEST_0_SHIPTOSTREET2"] : null; // ' Second street address.
$shipToCity = $resArray["PAYMENTREQUEST_0_SHIPTOCITY"]; // ' Name of city. $shipToCity = $resArray["PAYMENTREQUEST_0_SHIPTOCITY"]; // ' Name of city.
$shipToState = $resArray["PAYMENTREQUEST_0_SHIPTOSTATE"]; // ' State or province $shipToState = $resArray["PAYMENTREQUEST_0_SHIPTOSTATE"]; // ' State or province
$shipToCntryCode = $resArray["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"]; // ' Country code. $shipToCntryCode = $resArray["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"]; // ' Country code.
$shipToZip = $resArray["PAYMENTREQUEST_0_SHIPTOZIP"]; // ' U.S. Zip code or other country-specific postal code. $shipToZip = $resArray["PAYMENTREQUEST_0_SHIPTOZIP"]; // ' U.S. Zip code or other country-specific postal code.
$addressStatus = $resArray["ADDRESSSTATUS"]; // ' Status of street address on file with PayPal $addressStatus = $resArray["ADDRESSSTATUS"]; // ' Status of street address on file with PayPal
$invoiceNumber = $resArray["INVNUM"]; // ' Your own invoice or tracking number, as set by you in the element of the same name in SetExpressCheckout request . $invoiceNumber = isset($resArray["INVNUM"]) ? $resArray["INVNUM"] : null; // ' Your own invoice or tracking number, as set by you in the element of the same name in SetExpressCheckout request .
$phonNumber = $resArray["PHONENUM"]; // ' Payer's contact telephone number. Note: PayPal returns a contact telephone number only if your Merchant account profile settings require that the buyer enter one. $phonNumber = isset($resArray["PHONENUM"]) ? $resArray["PHONENUM"] : null; // ' Payer's contact telephone number. Note: PayPal returns a contact telephone number only if your Merchant account profile settings require that the buyer enter one.
} else { } else {
//Display a user friendly Error on the page using any of the following error information returned by PayPal //Display a user friendly Error on the page using any of the following error information returned by PayPal
$ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
@ -231,7 +231,7 @@ if (!isset($_POST['paymentOption'])) {
); );
$url = Display::url( $url = Display::url(
$all_session_information['name'], $all_session_information['name'],
$_configuration['root_web']."main/session/index.php?session_id=".$sessionId api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$sessionId
); );
$_SESSION['bc_message'] = 'EnrollToSessionXSuccessful'; $_SESSION['bc_message'] = 'EnrollToSessionXSuccessful';
$_SESSION['bc_url'] = $url; $_SESSION['bc_url'] = $url;

Loading…
Cancel
Save