Remove custompages code

pull/3064/head
Julio 5 years ago
parent 3853d0acec
commit bdc79907ac
  1. 24
      public/custompages/README.md
  2. 118
      public/custompages/first_login-dist.php
  3. BIN
      public/custompages/images/footer.png
  4. BIN
      public/custompages/images/header.png
  5. BIN
      public/custompages/images/login-form-submit-bg.jpg
  6. BIN
      public/custompages/images/page-background.png
  7. 15
      public/custompages/index-logged-dist.php
  8. 113
      public/custompages/index-unlogged-dist.php
  9. 53
      public/custompages/language.inc.php
  10. 50
      public/custompages/language.php
  11. 54
      public/custompages/loggedout-dist.php
  12. 52
      public/custompages/lostpassword-dist.php
  13. 121
      public/custompages/registration-dist.php
  14. 48
      public/custompages/registration-feedback-dist.php
  15. 5
      public/custompages/url-images/README

@ -1,24 +0,0 @@
Custom pages
=============
CustomPages looks for alternatives in this directory, and displays them if present.
The user-provided custom pages must exactly be named as such :
- index-logged.php for the general landing page before login
- index-unlogged.php for the general landing page when already logged-in
- registration.php for the registration form
- registration-feedback.php for the registration success feedback
- lostpassword.php for the password recovery form
### Installation
- Enable the use_custom_pages setting
- Create your own modifications based in the files with the suffix "-dist.php"
### Important notes
- Do not replace the images in the images/ directory.
Instead, create new images, as the current ones will be overwritten
by each Chamilo upgrade.

@ -1,118 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Quick page to react to first login cases.
*
* @package chamilo.custompages
*/
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
require_once __DIR__.'/language.php';
/**
* Security checks.
*/
if (!isset($_SESSION['conditional_login']['uid'])) {
die("Not Authorised");
}
if (isset($_POST['password'])) {
$u = api_get_user_info($_SESSION['conditional_login']['uid']);
if ($_POST['password'] != $_POST['password2']) {
header('Location: '.api_get_self().'?invalid=2');
exit();
}
if (empty($_POST['password'])) { //|| !api_check_password($password)) { //Pass must be at least 5 char long with 2 digits and 3 letters
header('Location: '.api_get_self().'?invalid=1');
exit();
}
$password = $_POST['password'];
$updated = UserManager::update_user(
$u['user_id'],
$u['firstname'],
$u['lastname'],
$u['username'],
$password,
$u['auth_source'],
$u['email'],
$u['status'],
$u['official_code'],
$u['phone'],
$u['picture_uri'],
$u['expiration_date'],
$u['active'],
$u['creator_id'],
$u['hr_dept_id'],
null,
$u['language'],
''
);
if ($updated !== false) {
UserManager::update_extra_field_value($u['user_id'], 'already_logged_in', 'true');
ConditionalLogin::login();
}
}
if ($_GET['invalid'] == 1) {
$error_message = get_lang('The current password is incorrect');
}
if ($_GET['invalid'] == 2) {
$error_message = get_lang('You have typed two different passwords');
}
$www = api_get_path('WEB_PATH');
/**
* HTML output.
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Custompage - login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="<?php echo $www; ?>web/assets/jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (top.location != location)
top.location.href = document.location.href ;
// Handler pour la touche retour
$('input').keyup(function(e) {
if (e.keyCode == 13) {
$('#changepassword-form').submit();
}
});
});
</script>
</head>
<body>
<div id="backgroundimage">
<img src="/custompages/images/page-background.png" class="backgroundimage" />
</div>
<div id="wrapper">
<div id="header">
<img src="/custompages/images/header.png" alt="Logo" />
</div> <!-- #header -->
<h2> <?php echo custompages_get_lang('First connection'); ?> </h2>
<div id="changepassword-form-box" class="form-box">
<div class="info"> <?php echo custompages_get_lang('First connectionChangePassword'); ?> </div>
<?php if (isset($error_message)) {
echo '<div id="changepassword-form-error" class="form-error">'.$error_message.'</div>';
}?>
<form id="changepassword-form" class="form" method="post">
<div>
<label for="password">*<?php echo custompages_get_lang('Password'); ?></label>
<input name="password" type="password" /><br />
<label for="password2">*<?php echo custompages_get_lang('Password'); ?></label>
<input name="password2" type="password" /><br />
</div>
</form>
<div id="changepassword-form-submit" class="form-submit" onclick="document.forms['changepassword-form'].submit();">
<span><?php echo custompages_get_lang('Login'); ?></span>
</div> <!-- #form-submit -->
</div> <!-- #form -->
<div id="footer">
<img src="/custompages/images/footer.png" />
</div> <!-- #footer -->
</div> <!-- #wrapper -->
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

@ -1,15 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Redirect to normal Chamilo.
*
* @package chamilo.custompages
*/
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
$www = api_get_path('WEB_PATH');
/**
* Redirect.
*/
header("Location: $www/user_portal.php");
exit;

@ -1,113 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Redirect script.
*
* @package chamilo.custompages
*/
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
require_once __DIR__.'/language.php';
/**
* Homemade micro-controller.
*/
if (isset($_GET['loginFailed'])) {
if (isset($_GET['error'])) {
switch ($_GET['error']) {
case 'account_expired':
$error_message = custompages_get_lang('Account expired');
break;
case 'account_inactive':
$error_message = custompages_get_lang('Account inactive');
break;
case 'user_password_incorrect':
$error_message = custompages_get_lang('Login failed - incorrect login or password.');
break;
case 'access_url_inactive':
$error_message = custompages_get_lang('Account inactive for this URL');
break;
default:
$error_message = custompages_get_lang('Login failed - incorrect login or password.');
}
} else {
$error_message = get_lang('Login failed - incorrect login or password.');
}
}
$rootWeb = api_get_path('WEB_PATH');
/**
* HTML output.
*/
?>
<html>
<head>
<title>Custompage - login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (top.location != location) {
top.location.href = document.location.href;
}
// Handler pour la touche retour
$('input').keyup(function(e) {
if (e.keyCode == 13) {
$('#login-form').submit();
}
});
});
</script>
</head>
<body>
<div id="backgroundimage">
<img src="<?php echo api_get_path(WEB_PATH); ?>/custompages/images/page-background.png" class="backgroundimage" />
</div>
<div id="wrapper">
<div id="header">
<img src="<?php echo api_get_path(WEB_PATH); ?>/custompages/images/header.png" alt="Logo" />
</div> <!-- #header -->
<div id="login-form-box" class="form-box">
<div id="login-form-info" class="form-info">
<?php if (isset($content['info']) && !empty($content['info'])) {
echo $content['info'];
}
?>
</div>
<?php if (isset($error_message)) {
echo '<div id="login-form-info" class="form-error">'.$error_message.'</div>';
}
?>
<form id="login-form" class="form" action="<?php echo api_get_path(WEB_PATH); ?>index.php" method="post">
<div>
<label for="login">*<?php echo custompages_get_lang('User'); ?></label>
<input name="login" type="text" /><br />
<label for="password">*<?php echo custompages_get_lang('Password'); ?></label>
<input name="password" type="password" /><br />
</div>
</form>
<div id="login-form-submit" class="form-submit" onclick="document.forms['login-form'].submit();">
<span><?php echo custompages_get_lang('Login'); ?></span>
</div> <!-- #form-submit -->
<div id="links">
<?php if (api_get_setting('allow_registration') === 'true') {
?>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>auth/inscription.php?language=<?php echo api_get_interface_language(); ?>">
<?php echo custompages_get_lang('Registration'); ?>
</a><br />
<?php
} ?>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>auth/lostPassword.php?language=<?php echo api_get_interface_language(); ?>">
<?php echo custompages_get_lang('I lost my password'); ?>
</a>
</div>
</div> <!-- #form -->
<div id="footer">
<img src="<?php echo api_get_path(WEB_PATH); ?>/custompages/images/footer.png" />
</div> <!-- #footer -->
</div> <!-- #wrapper -->
</body>
</html>

@ -1,53 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* CustomPages : Browser language detection
* Include this file in your custom page if you want to set the language variable of the Chamilo session
* to the best pick according to the visitor's browser's options.
* 2011, Jean-Karim Bockstael, CBlue <jeankarim@cblue.be>
* This requires the Chamilo system to be initialized
* (note that it's easier to do the following include in the parent page).
*
* @package chamilo.custompages
*/
/**
* Returns the best match between available languages and visitor preferences.
*
* @return string the best match as 2-chars code, null when none match
*/
function get_preferred_language($available_langs)
{
// Parsing the Accept-languages HTTP header
$langs = [];
foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $httplang) {
$rawlang = explode(';q=', $httplang);
if (strpos($rawlang[0], '-') !== false) {
// We ignore the locale part, as in en-GB vs en-US
$rawlang[0] = substr($rawlang[0], 0, strpos($rawlang[0], '-'));
}
if (count($rawlang) == 1) {
$rawlang[1] = 1.0; // The absence of weighting means a weight of 1 (max)
}
$langs[$rawlang[1]][] = $rawlang[0];
}
krsort($langs, SORT_NUMERIC);
// Choosing the best match
foreach ($langs as $weight => $codes) {
foreach ($codes as $code) {
if (in_array($code, $available_langs)) {
return $code;
}
}
}
// No match
return null;
}
/**
* Get a language variable in a specific language.
*/
function custompages_get_lang($variable)
{
return get_lang($variable, null, $_SESSION['user_language_choice']);
}

@ -1,50 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Definition of language-related functions for cases where th user isn't
* logged in yet.
*
* @package chamilo.custompages
*/
// Get helper functions
require_once __DIR__.'/language.inc.php';
// Define the languages you want to make available for auto-detection here
$available_langs = ['en', 'fr', 'es', 'gl', 'eu'];
// Define the translation of these language codes to Chamilo languages
$chamilo_langs = [
null => 'english',
'en' => 'english',
'fr' => 'french',
'nl' => 'dutch',
'de' => 'german',
'es' => 'spanish',
'gl' => 'galician',
'eu' => 'basque',
];
$lang_match = $chamilo_langs[get_preferred_language($available_langs)];
// recover previous value ...
if (isset($_SESSION['user_language_choice'])) {
$lang_match = $_SESSION['user_language_choice'];
}
// Chamilo parameter, on logout
if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) {
$lang_match = $_REQUEST['language'];
}
// Incoming link parameter
if (isset($_REQUEST['lang']) && !empty($_REQUEST['lang']) && in_array($_REQUEST['lang'], $available_langs)) {
$lang_match = $chamilo_langs[$_REQUEST['lang']];
}
$detect = api_get_setting('auto_detect_language_custom_pages');
if ($detect === 'true') {
// Auto detect
$_user['language'] = $lang_match;
$_SESSION['user_language_choice'] = $lang_match;
} else {
// Chamilo default platform.
$defaultLanguage = api_get_interface_language();
$_user['language'] = $defaultLanguage;
$_SESSION['user_language_choice'] = $defaultLanguage;
}

@ -1,54 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Displayed after the user has been logged out.
*
* @package chamilo.custompages
*/
$called_direcly = !function_exists('api_get_path');
if ($called_direcly) {
return '';
}
require_once __DIR__.'/language.php';
$www = api_get_path('WEB_PATH');
/**
* HTML output.
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Custompage - logged out</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="<?php echo $www; ?>web/assets/jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (top.location != location)
top.location.href = document.location.href ;
});
</script>
</head>
<body>
<div id="backgroundimage">
<img src="<?php echo $www; ?>/custompages/images/page-background.png" class="backgroundimage" alt="background"/>
</div>
<div id="wrapper">
<div id="header">
<img src="<?php echo $www; ?>/custompages/images/header.png" alt="Logo" />
</div>
<div id="login-form-box" class="form-box">
<div id="login-form-info" class="form-info">
You have been logged out.
</div>
</div>
<a href="<?php echo $www.'user_portal.php'; ?>">Go to your portal</a>
<div id="footer">
<img src="<?php echo $www; ?>/custompages/images/footer.png" alt="footer"/>
</div>
</div>
</body>
</html>

@ -1,52 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Quick form to ask for password reminder.
*
* @package chamilo.custompages
*/
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
require_once __DIR__.'/language.php';
$rootWeb = api_get_path('WEB_PATH');
?>
<html>
<head>
<title><?php echo custompages_get_lang('I lost my password'); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Handler pour la touche retour
$('input').keyup(function(e) {
if (e.keyCode == 13) {
$('#lostpassword-form').submit();
}
});
});
</script>
</head>
<body>
<div id="backgroundimage">
<img src="/custompages/images/page-background.png" class="backgroundimage" />
</div>
<div id="wrapper">
<div id="header">
<img src="../../custompages/images/header.png" alt="Ambassador logo" />
</div> <!-- #header -->
<div id="lostpassword-form-box" class="form-box">
<?php
if (isset($content['info']) && !empty($content['info'])) {
echo '<div id="registration-form-error" class="form-error"><ul>'.$content['info'].'</ul></div>';
}
echo isset($content['form']) ? $content['form'] : '';
?>
</div> <!-- #form -->
<div id="footer">
<img src="../../custompages/images/footer.png" />
</div> <!-- #footer -->
</div> <!-- #wrapper -->
</body>
</html>

@ -1,121 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script allows for specific registration rules (see CustomPages feature of Chamilo)
* Please contact CBlue regarding any licences issues.
* Author: noel@cblue.be
* Copyright: CBlue SPRL, 20XX (GNU/GPLv3).
*
* @package chamilo.custompages
*/
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
require_once __DIR__.'/language.php';
/**
* Removes some unwanted elementend of the form object.
*/
$content['form']->removeElement('extra_mail_notify_invitation');
$content['form']->removeElement('extra_mail_notify_message');
$content['form']->removeElement('extra_mail_notify_group_message');
$content['form']->removeElement('official_code');
$content['form']->removeElement('phone');
$content['form']->removeElement('submit');
if (isset($content['form']->_elementIndex['status'])) {
$content['form']->removeElement('status');
$content['form']->removeElement('status');
}
$rootWeb = api_get_path('WEB_PATH');
// Deprecated since 2015-03-26
/**
* Code to change the way QuickForm render html.
*/
/*
$renderer = & $content['form']->defaultRenderer();
$form_template = <<<EOT
<form {attributes}>
{content}
<div class="clear">
&nbsp;
</div>
<p><a href="#" class="btn btn-primary" onclick="$('#registration-form').submit()"><span>S'inscrire</span></a></p>
</form>
EOT;
$renderer->setFormTemplate($form_template);
$element_template = <<<EOT
<div class="field decalle">
<label>
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
</label>
<div class="formw">
<!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error --> {element}
</div>
</div>
EOT;
$element_template_wimage = <<<EOT
<div class="field decalle display">
<label>
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
</label>
<div class="formw">
<!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error --> {element}
<img src="/custompages/images/perso.jpg" alt="" />
</div>
</div>
EOT;
$renderer->setElementTemplate($element_template_wimage,'pass1');
$renderer->setElementTemplate($element_template);
$header_template = <<<EOT
<div class="row">
<div class="form_header">{header}</div>
</div>
EOT;
*/
?>
<html>
<head>
<title><?php echo custompages_get_lang('Registration'); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/jquery/dist/jquery.min.js"></script>
</head>
<body>
<img id="backgroundimage" src="/custompages/images/page-background.png"">
<section id="registration">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="form-wrap">
<div class="logo">
<img src="/custompages/images/header.png">
</div>
<?php if (isset($content['error']) && !empty($content['error'])) {
echo '<div id="registration-form-error" class="alert alert-danger">'.$content['error'].'</div>';
}?>
<div id="registration-form-box" class="form-box">
<div class="block-form-login">
<?php
$content['form']->display();
?>
</div>
<div id="links">
<!--<a href="mailto: support@cblue.be"><?php echo custompages_get_lang('Click here to contact the administrator'); ?></a><br />-->
</div>
</div>
<div id="footer">
<img src="/custompages/images/footer.png" />
</div> <!-- #footer -->
</div>
</div>
</div>
</div>
</section>
</body>
</html>

@ -1,48 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Quick display for user registration.
*
* @package chamilo.custompages
*/
/**
* HTML output.
*/
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
require_once __DIR__.'/language.php';
$rootWeb = api_get_path('WEB_PATH');
?>
<html>
<head>
<title><?php echo custompages_get_lang('Registration'); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/jquery/dist/jquery.min.js"></script>
</head>
<body>
<img src="/custompages/images/page-background.png" class="backgroundimage" />
<section id="registration">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="form-wrap">
<div class="logo">
<img src="/custompages/images/header.png">
</div>
<div id="registration-form-box" class="form-box">
<div class="block-form-login">
<?php echo $content['info']; ?>
</div>
</div>
<div id="footer">
<img src="../../custompages/images/footer.png" />
</div> <!-- #footer -->
</div>
</div>
</div>
</div>
</section>
</body>
</html>

@ -1,5 +0,0 @@
Custom Pages : URL Images
This features allows each access URL to have a number of images (currently three) specific to this URL. This allows easier customization of landing pages by access URL.
You can access a URL's images by calling the static function CustomPages::getURLImages() in your custom page.
Loading…
Cancel
Save