pull/2715/head
Alex Aragón 6 years ago
commit bf907adde9
  1. 22
      main/admin/course_list.php
  2. 6
      main/auth/inscription.php
  3. 6
      main/inc/lib/internationalization.lib.php
  4. 2
      plugin/buycourses/lang/brazilian.php
  5. 2
      plugin/buycourses/lang/dutch.php
  6. 2
      plugin/buycourses/lang/english.php
  7. 2
      plugin/buycourses/lang/french.php
  8. 2
      plugin/buycourses/lang/spanish.php
  9. 33
      plugin/buycourses/src/buy_course_plugin.class.php
  10. 5
      plugin/buycourses/src/buycourses.ajax.php
  11. 12
      plugin/buycourses/src/process.php
  12. 5
      plugin/buycourses/src/sales_report.php
  13. 18
      plugin/buycourses/src/success.php
  14. 4
      plugin/buycourses/view/success.tpl

@ -46,7 +46,9 @@ function get_number_of_courses()
} elseif (isset($_GET['keyword_code'])) {
$keyword_code = Database::escape_string("%".$_GET['keyword_code']."%");
$keyword_title = Database::escape_string("%".$_GET['keyword_title']."%");
$keyword_category = Database::escape_string("%".$_GET['keyword_category']."%");
$keyword_category = isset($_GET['keyword_category'])
? Database::escape_string("%".$_GET['keyword_category']."%")
: null;
$keyword_language = Database::escape_string("%".$_GET['keyword_language']."%");
$keyword_visibility = Database::escape_string("%".$_GET['keyword_visibility']."%");
$keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
@ -55,12 +57,15 @@ function get_number_of_courses()
$sql .= " WHERE
(c.code LIKE '".$keyword_code."' OR c.visual_code LIKE '".$keyword_code."') AND
c.title LIKE '".$keyword_title."' AND
c.category_code LIKE '".$keyword_category."' AND
c.course_language LIKE '".$keyword_language."' AND
c.visibility LIKE '".$keyword_visibility."' AND
c.subscribe LIKE '".$keyword_subscribe."' AND
c.unsubscribe LIKE '".$keyword_unsubscribe."'
";
if (!empty($keyword_category)) {
$sql .= " AND c.category_code LIKE '".$keyword_category."' ";
}
}
// adding the filter to see the user's only of the current access_url
@ -127,7 +132,9 @@ function get_course_data($from, $number_of_items, $column, $direction)
} elseif (isset($_GET['keyword_code'])) {
$keyword_code = Database::escape_string("%".$_GET['keyword_code']."%");
$keyword_title = Database::escape_string("%".$_GET['keyword_title']."%");
$keyword_category = Database::escape_string("%".$_GET['keyword_category']."%");
$keyword_category = isset($_GET['keyword_category'])
? Database::escape_string("%".$_GET['keyword_category']."%")
: null;
$keyword_language = Database::escape_string("%".$_GET['keyword_language']."%");
$keyword_visibility = Database::escape_string("%".$_GET['keyword_visibility']."%");
$keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
@ -136,11 +143,14 @@ function get_course_data($from, $number_of_items, $column, $direction)
$sql .= " WHERE
(code LIKE '".$keyword_code."' OR visual_code LIKE '".$keyword_code."') AND
title LIKE '".$keyword_title."' AND
category_code LIKE '".$keyword_category."' AND
course_language LIKE '".$keyword_language."' AND
visibility LIKE '".$keyword_visibility."' AND
subscribe LIKE '".$keyword_subscribe."' AND
unsubscribe LIKE '".$keyword_unsubscribe."'";
if (!empty($keyword_category)) {
$sql .= " AND category_code LIKE '".$keyword_category."' ";
}
}
// Adding the filter to see the user's only of the current access_url.
@ -531,7 +541,9 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
} elseif (isset($_GET['keyword_code'])) {
$parameters['keyword_code'] = Security::remove_XSS($_GET['keyword_code']);
$parameters['keyword_title'] = Security::remove_XSS($_GET['keyword_title']);
$parameters['keyword_category'] = Security::remove_XSS($_GET['keyword_category']);
if (isset($_GET['keyword_category'])) {
$parameters['keyword_category'] = Security::remove_XSS($_GET['keyword_category']);
}
$parameters['keyword_language'] = Security::remove_XSS($_GET['keyword_language']);
$parameters['keyword_visibility'] = Security::remove_XSS($_GET['keyword_visibility']);
$parameters['keyword_subscribe'] = Security::remove_XSS($_GET['keyword_subscribe']);

@ -1056,7 +1056,11 @@ if ($form->validate()) {
if ($usersCanCreateCourse) {
$form_register->addElement('html', $form_data['button']);
} else {
$form_register->addElement('html', $form_data['go_button']);
if (!empty($redirectBuyCourse)) {
$form_register->addButtonNext(get_lang('Next'));
} else {
$form_register->addElement('html', $form_data['go_button']);
}
}
$text_after_registration .= $form_register->returnForm();

@ -160,7 +160,11 @@ function get_lang($variable)
} elseif (isset($GLOBALS["lang$variable"])) {
$langvar = $GLOBALS["lang$variable"];
} else {
$langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable;
if (!$returnEmptyIfNotFound) {
$langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable;
} else {
return '';
}
}
}
if (empty($langvar) || !is_string($langvar)) {

@ -47,7 +47,7 @@ $strings['CancelOrder'] = "Anular ordem";
$strings['BankAccountInformation'] = "Detalhes da conta bancária";
$strings['BankAccount'] = "Contas bancárias";
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Uma vez confirmada, você receberá um e-mail com os dados bancários e uma referência de ordem.";
$strings['SubscriptionToCourseXSuccessful'] = "Sua inscrição para \"%s\ foi concluída com sucesso.";
$strings['SubscriptionToCourseXSuccessful'] = "Sua inscrição para <a href=\"%s\"><strong>\"%s\"</strong></a> foi concluída com sucesso.";
$strings['OrderCanceled'] = "Ordem cancelada";
$strings['OrderStatus'] = "Status do pedido";
$strings['SearchByStatus'] = "Pesquisar por estado";

@ -82,7 +82,7 @@ $strings['CancelOrder'] = "Annuleer order";
$strings['BankAccountInformation'] = "Bankgegevens";
$strings['BankAccount'] = "Bankrekening";
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Eenmaal bevestigd, ontvangt u een e-mail met de bankgegevens en een orderreferentie.";
$strings['SubscriptionToCourseXSuccessful'] = "Uw aankoop op \"%s \" werd met succes afgerond.";
$strings['SubscriptionToCourseXSuccessful'] = "Uw aankoop op <a href=\"%s\"><strong>\"%s\"</strong></a> werd met succes afgerond.";
$strings['OrderCanceled'] = "Order geannuleerd";
$strings['OrderStatus'] = "Bestelstatus";
$strings['PayoutStatus'] = "Betalingsstatus";

@ -82,7 +82,7 @@ $strings['CancelOrder'] = "Cancel order";
$strings['BankAccountInformation'] = "Bank account details";
$strings['BankAccount'] = "Bank account";
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Once confirmed, you will receive an e-mail with the bank details and an order reference.";
$strings['SubscriptionToCourseXSuccessful'] = "Your subscription to \"%s\" was completed successfully.";
$strings['SubscriptionToCourseXSuccessful'] = "Your subscription to <a href=\"%s\"><strong>\"%s\"</strong></a> was completed successfully.";
$strings['OrderCanceled'] = "Order canceled";
$strings['OrderStatus'] = "Order status";
$strings['PayoutStatus'] = "Payment status";

@ -82,7 +82,7 @@ $strings['CancelOrder'] = "Annuler la commande";
$strings['BankAccountInformation'] = "Détails du compte bancaire";
$strings['BankAccount'] = "Compte bancaire";
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Une fois confirmée, vous recevrez un e-mail avec les données bancaires et la référence de la commande";
$strings['SubscriptionToCourseXSuccessful'] = "Votre inscription au \"%s\" est terminée.";
$strings['SubscriptionToCourseXSuccessful'] = "Votre inscription au <a href=\"%s\"><strong>\"%s\"</strong></a> est terminée.";
$strings['OrderCanceled'] = "Commande annulée";
$strings['OrderStatus'] = "Statut de commande";
$strings['PayoutStatus'] = "État du paiement";

@ -83,7 +83,7 @@ $strings['CancelOrder'] = "Cancelar Orden";
$strings['BankAccountInformation'] = "Información de la Cuenta Bancaria";
$strings['BankAccount'] = "Cuenta Bancaria";
$strings['OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'] = "Una vez confirmado, recibira un e-mail con los datos bancarios y una referencia del pedido.";
$strings['SubscriptionToCourseXSuccessful'] = "Tu subscripción a \"%s\" se realizó correctamente.";
$strings['SubscriptionToCourseXSuccessful'] = "<p class=\"lead\">Tu subscripción a <a href=\"%s\"><strong>\"%s\"</strong></a> se realizó correctamente.</p>";
$strings['OrderCanceled'] = "Pedido cancelado";
$strings['OrderStatus'] = "Estado del pedido";
$strings['PayoutStatus'] = "Estado del pago";

@ -593,7 +593,7 @@ class BuyCoursesPlugin extends Plugin
$courseInfo = [
'id' => $course->getId(),
'title' => $course->getTitle(),
'description' => $courseDescription->getContent(),
'description' => $courseDescription ? $courseDescription->getContent() : null,
'code' => $course->getCode(),
'visual_code' => $course->getVisualCode(),
'teachers' => [],
@ -2542,4 +2542,35 @@ class BuyCoursesPlugin extends Plugin
['id = ?' => (int) $serviceSaleId]
);
}
/**
* @param array $saleInfo
*
* @return string
*/
public function getSubscriptionSuccessMessage(array $saleInfo)
{
switch ($saleInfo['product_type']) {
case self::PRODUCT_TYPE_COURSE:
$courseInfo = api_get_course_info_by_id($saleInfo['product_id']);
$url = api_get_course_url($courseInfo['code']);
break;
case self::PRODUCT_TYPE_SESSION:
$sessionId = (int) $saleInfo['product_id'];
$url = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$sessionId;
break;
default:
$url = '#';
}
return Display::return_message(
sprintf(
$this->get_lang('SubscriptionToCourseXSuccessful'),
$url,
$saleInfo['product_name']
),
'success',
false
);
}
}

@ -328,10 +328,7 @@ switch ($action) {
if ($saleIsCompleted) {
Display::addFlash(
Display::return_message(
sprintf($plugin->get_lang('SubscriptionToCourseXSuccessful'), $sale['product_name']),
'success'
)
$plugin->getSubscriptionSuccessMessage($sale)
);
}
}

@ -11,11 +11,7 @@ use ChamiloSession as Session;
require_once '../config.php';
$currentUserId = api_get_user_id();
if (empty($currentUserId)) {
Session::write('buy_course_redirect', Security::remove_XSS($_SERVER['REQUEST_URI']));
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php');
exit;
}
$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(
WEB_PLUGIN_PATH
).'buycourses/resources/css/style.css"/>';
@ -37,6 +33,12 @@ $buyingCourse = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_COURSE
$buyingSession = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_SESSION;
$queryString = 'i='.intval($_REQUEST['i']).'&t='.intval($_REQUEST['t']);
if (empty($currentUserId)) {
Session::write('buy_course_redirect', api_get_self().'?'.$queryString);
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php');
exit;
}
if ($buyingCourse) {
$courseInfo = $plugin->getCourseInfo($_REQUEST['i']);
$item = $plugin->getItemByProduct($_REQUEST['i'], BuyCoursesPlugin::PRODUCT_TYPE_COURSE);

@ -33,10 +33,7 @@ if (isset($_GET['order'])) {
$plugin->completeSale($sale['id']);
$plugin->storePayouts($sale['id']);
Display::addFlash(
Display::return_message(
sprintf($plugin->get_lang('SubscriptionToCourseXSuccessful'), $sale['product_name']),
'success'
)
$plugin->getSubscriptionSuccessMessage($sale)
);
$urlToRedirect .= http_build_query([

@ -83,23 +83,9 @@ if ($form->validate()) {
switch ($confirmPayments['PAYMENTINFO_0_PAYMENTSTATUS']) {
case 'Completed':
$saleIsCompleted = $plugin->completeSale($sale['id']);
if ($saleIsCompleted && $buyingSession) {
if ($saleIsCompleted) {
Display::addFlash(
Display::return_message(
sprintf($plugin->get_lang('SubscriptionToCourseXSuccessful'), $session['name']),
'success'
)
);
$plugin->storePayouts($sale['id']);
break;
}
if ($saleIsCompleted && $buyingCourse) {
Display::addFlash(
Display::return_message(
sprintf($plugin->get_lang('SubscriptionToCourseXSuccessful'), $course['title']),
'success'
)
$plugin->getSubscriptionSuccessMessage($sale)
);
$plugin->storePayouts($sale['id']);
break;

@ -30,7 +30,7 @@
<h3 class="page-header">{{ course.title }}</h3>
<ul class="items-teacher list-unstyled">
{% for teacher in course.teachers %}
<li><em class="fa fa-user"></em> {{ teacher }}</li>
<li><em class="fa fa-user" aria-hidden="true"></em> {{ teacher.name }}</li>
{% endfor %}
</ul>
<p>
@ -57,7 +57,7 @@
{% for course in session.courses %}
<dt>{{ course.title }}</dt>
{% for coach in course.coaches %}
<dd><em class="fa fa-user fa-fw"></em> {{ coach }}</dd>
<dd><em class="fa fa-user fa-fw" aria-hidden="true"></em> {{ coach.name }}</dd>
{% endfor %}
{% endfor %}
</dl>

Loading…
Cancel
Save