Add comments. Fix french translation. Change redirection process to a much cleaner one. - refs #7272

1.9.x
Imanol Losada 10 years ago
parent 1f565793d0
commit b2fb1b8800
  1. 10
      main/inc/lib/plugin.class.php
  2. 2
      plugin/buycourses/lang/french.php
  3. 6
      plugin/buycourses/src/buy_course.lib.php
  4. 7
      plugin/buycourses/src/index.buycourses.php

@ -645,15 +645,17 @@ class Plugin
/** /**
* This method shows or hides plugin's tab * This method shows or hides plugin's tab
* @param boolean Shows or hides the main menu plugin tab * @param boolean Shows or hides the main menu plugin tab
* @param string Plugin starter file path
*/ */
public function manageTab($showTab) public function manageTab($showTab, $filePath = 'index.php')
{ {
$langString = str_replace('Plugin', '', get_class($this)); $langString = str_replace('Plugin', '', get_class($this));
$pluginName = strtolower($langString); $pluginName = strtolower($langString);
$pluginUrl = 'plugin/'.$pluginName.'/index.php'; $pluginUrl = 'plugin/'.$pluginName.'/'.$filePath;
if ($showTab === 'true') { if ($showTab === 'true') {
$rsTab = $this->addTab($this->get_lang($langString), $pluginUrl); $tabAdded = $this->addTab($this->get_lang($langString), $pluginUrl);
if ($rsTab) { if ($tabAdded) {
// The page must be refreshed to show the recently created tab
echo "<script>location.href = '".Security::remove_XSS($_SERVER['REQUEST_URI'])."';</script>"; echo "<script>location.href = '".Security::remove_XSS($_SERVER['REQUEST_URI'])."';</script>";
} }
} else { } else {

@ -2,7 +2,7 @@
$strings['plugin_title'] = "Vente de cours"; $strings['plugin_title'] = "Vente de cours";
$strings['plugin_comment'] = "Vendez vos cours directement depuis votre portail Chamilo, au travers d'un compte PayPal. Plugin en version beta, à utiliser avec précaution. Ni l'association Chamilo ni les développeurs impliqués dans le développement de ce plugin ne sauraient être tenus responsables d'un quelconque inconvénient causé par celui-ci."; $strings['plugin_comment'] = "Vendez vos cours directement depuis votre portail Chamilo, au travers d'un compte PayPal. Plugin en version beta, à utiliser avec précaution. Ni l'association Chamilo ni les développeurs impliqués dans le développement de ce plugin ne sauraient être tenus responsables d'un quelconque inconvénient causé par celui-ci.";
$strings['show_main_menu_tab'] = "Montrer l'onglet dans le menu principal"; $strings['show_main_menu_tab'] = "Montrer l'onglet dans le menu principal";
$strings['show_main_menu_tab_help'] = "Dans le cas où l'onglet ne se montre pas, il est possible de rajouter le lien suivant à votre portail Chamilo: %s"; $strings['show_main_menu_tab_help'] = "Dans le cas où vous ne souhaitez pas montrer l'onglet, il est possible de rajouter le lien suivant à votre portail Chamilo: %s";
$strings['Visible'] = "Montrer dans la liste"; $strings['Visible'] = "Montrer dans la liste";
$strings['Options'] = "Options"; $strings['Options'] = "Options";
$strings['Price'] = "Prix"; $strings['Price'] = "Prix";

@ -196,8 +196,8 @@ function userSessionList()
//check if the user is enrolled in the current session //check if the user is enrolled in the current session
if ($currentUserId > 0) { if ($currentUserId > 0) {
$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 ='" . $currentUserId . "';"; id_user = $currentUserId";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$rowSession['enrolled'] = "YES"; $rowSession['enrolled'] = "YES";
@ -521,7 +521,7 @@ function sessionInfo($code)
//check if the user is enrolled in the current session //check if the user is enrolled in the current session
if ($currentUserId > 0) { if ($currentUserId > 0) {
$sql = "SELECT 1 FROM $tableSessionRelUser $sql = "SELECT 1 FROM $tableSessionRelUser
WHERE id_user='".$currentUserId."';"; WHERE id_user = $currentUserId";
Database::query($sql); Database::query($sql);
if (Database::affected_rows() > 0) { if (Database::affected_rows() > 0) {
$rowSession['enrolled'] = "YES"; $rowSession['enrolled'] = "YES";

@ -11,11 +11,12 @@ $plugin = BuyCoursesPlugin::create();
$guess_enable = $plugin->get('unregistered_users_enable'); $guess_enable = $plugin->get('unregistered_users_enable');
if ($guess_enable == "true" || isset($_SESSION['_user'])) { if ($guess_enable == "true" || isset($_SESSION['_user'])) {
$isAdmin = api_is_platform_admin();
$title = $plugin->get_lang('CourseListOnSale'); $title = $plugin->get_lang('CourseListOnSale');
$templateName = $plugin->get_lang('BuyCourses'); $templateName = $plugin->get_lang('BuyCourses');
$tpl = new Template($templateName); $tpl = new Template($templateName);
$tpl->assign('isAdmin', api_is_platform_admin()); $tpl->assign('isAdmin', $isAdmin);
$tpl->assign('title', $title); $tpl->assign('title', $title);
$tpl->assign('BuySessions', $plugin->get_lang('BuySessions')); $tpl->assign('BuySessions', $plugin->get_lang('BuySessions'));
$tpl->assign('BuyCourses', $templateName); $tpl->assign('BuyCourses', $templateName);
@ -26,6 +27,6 @@ if ($guess_enable == "true" || isset($_SESSION['_user'])) {
$listing_tpl = 'buycourses/view/index.tpl'; $listing_tpl = 'buycourses/view/index.tpl';
$content = $tpl->fetch($listing_tpl); $content = $tpl->fetch($listing_tpl);
$tpl->assign('content', $content); $tpl->assign('content', $content);
preg_match_all('/src\/.*\.php/', $content, $matches); // If the user is NOT an administrator, redirect it to course/session buy list
count($matches[0]) > 1 ? $tpl->display_one_col_template() : header('Location: '.$matches[0][0]); $isAdmin ? $tpl->display_one_col_template() : header('Location: src/list.php');
} }

Loading…
Cancel
Save