Custom Pages : framework to allors replacing some pages with custom-built ones.

skala
jkbockstael 15 years ago
parent 0ad4994657
commit b72b7ce080
  1. 7
      custompages/README
  2. 11
      index.php
  3. 4
      main/auth/inscription.php
  4. 15
      main/auth/lostPassword.php
  5. 20
      main/inc/lib/custompages.lib.php
  6. 5
      main/install/db_main.sql
  7. 3
      main/install/migrate-db-1.8.6.2-1.8.7-pre.sql
  8. 7
      main/lang/english/admin.inc.php
  9. 3
      main/lang/french/admin.inc.php

@ -0,0 +1,7 @@
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
- lostpassword.php for the password recovery form
- lostpassword-feedback.php for the password recovery feedback page

@ -32,6 +32,8 @@ require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once 'main/chat/chat_functions.lib.php';
require_once api_get_path(LIBRARY_PATH).'custompages.lib.php';
$loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed);
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
@ -123,6 +125,15 @@ else {
event_open();
}
// Custom pages
if (api_get_setting('use_custom_pages') == 'true') {
if (api_get_user_id()) {
CustomPages::displayPage('index-logged');
}
else {
CustomPages::displayPage('index-unlogged');
}
}
// the header
Display::display_header(get_lang('Homepage'));

@ -48,6 +48,10 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
}
}
// Custom pages
if (api_get_setting('use_custom_pages') == 'true') {
CustomPages::displayPage('registration');
}
$tool_name = get_lang('Registration',null,(!empty($_POST['language'])?$_POST['language']:$_user['language']));
Display :: display_header($tool_name);

@ -22,6 +22,17 @@ require_once api_get_path(LIBRARY_PATH).'login.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
// Custom pages
// Had to move the form handling in here, because otherwise there would already be some display output.
if (api_get_setting('use_custom_pages') == 'true') {
if (isset ($_GET['reset']) && isset ($_GET['id'])) {
$msg = Login::reset_password($_GET["reset"], $_GET["id"], true);
CustomPages::displayPage('lostpassword-feedback');
}
else {
CustomPages::displayPage('lostpassword');
}
}
$tool_name = get_lang('LostPassword');
Display :: display_header($tool_name);
@ -38,7 +49,7 @@ echo $tool_name;
echo '</div>';
if (isset ($_GET['reset']) && isset ($_GET['id'])) {
$msg = Login::reset_password($_GET["reset"], $_GET["id"], true);
//$msg = Login::reset_password($_GET["reset"], $_GET["id"], true);
$msg1= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/lostPassword.php" class="fake_button_back" >'.get_lang('Back').'</a>';
echo '<br /><br /><div class="actions" >'.$msg1.'</div>';
@ -104,4 +115,4 @@ if (isset ($_GET['reset']) && isset ($_GET['id'])) {
$form->display();
}
}
Display :: display_footer();
Display :: display_footer();

@ -0,0 +1,20 @@
<?php
// Custom Pages lib
// Used to implement the loading of custom pages
// 2011, Jean-Karim Bockstael <jeankarim@cblue.be>
class CustomPages {
public static function displayPage($page_name) {
$pages_dir = api_get_path(SYS_PATH).'custompages/';
$file_name = $pages_dir.$page_name.'.php';
if (file_exists($file_name)) {
include($file_name);
exit;
}
else {
error_log('CustomPages::displayPage : could not read file '.$file_name);
}
}
}
?>

@ -773,6 +773,7 @@ VALUES
('cas_add_user_email_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddEmailAttributeTitle', 'CasUserAddEmailAttributeComment', NULL, NULL, 0),
('cas_add_user_firstname_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddFirstnameAttributeTitle', 'CasUserAddFirstnameAttributeComment', NULL, NULL, 0),
('cas_add_user_lastname_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddLastnameAttributeTitle', 'CasUserAddLastnameAttributeComment', NULL, NULL, 0),
('use_custom_pages',NULL,'radio','Platform','false','UseCustomPages','useCustomPagesComment','platform',NULL,0),
('student_page_after_login', NULL, 'textfield', 'Platform', '', 'StudentPageAfterLoginTitle', 'StudentPageAfterLoginComment', NULL, NULL, 0),
('teacher_page_after_login', NULL, 'textfield', 'Platform', '', 'TeacherPageAfterLoginTitle', 'TeacherPageAfterLoginComment', NULL, NULL, 0),
('DRH_page_after_login', NULL, 'textfield', 'Platform', '', 'DRHPageAfterLoginTitle', 'DRHPageAfterLoginComment', NULL, NULL, 0),
@ -997,7 +998,9 @@ VALUES
('cas_protocol', 'CAS2', 'CAS2Text'),
('cas_protocol', 'SAML', 'SAMLText'),
('cas_add_user_activate', 'true', 'Yes'),
('cas_add_user_activate', 'false', 'No');
('cas_add_user_activate', 'false', 'No'),
('use_custom_pages','true','Yes'),
('use_custom_pages','false','No');
UNLOCK TABLES;

@ -103,6 +103,9 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value,
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_email_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddEmailAttributeTitle', 'CasUserAddEmailAttributeComment', NULL, NULL, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_firstname_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddFirstnameAttributeTitle', 'CasUserAddFirstnameAttributeComment', NULL, NULL, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_lastname_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddLastnameAttributeTitle', 'CasUserAddLastnameAttributeComment', NULL, NULL, 0);
-- Custom Pages
INSERT INTO settings_options (variable, value, display_text) VALUES ('use_custom_pages', 'true', 'Yes'), ('use_custom_pages', 'false', 'No');
INSERT INTO settings_current (variable, type, category, selected_value, title, comment, scope) VALUES ('use_custom_pages','radio','Platform','false','UseCustomPages','UseCustomPagesComment', 'platform');
ALTER TABLE gradebook_score_display ADD category_id int NOT NULL DEFAULT 0;
ALTER TABLE gradebook_score_display ADD INDEX (category_id);

@ -171,7 +171,7 @@ $CourseCoach = "Training coach";
$UsersNumber = "Users number";
$DokeosClassic = "Chamilo classic";
$PublicAdmin = "Public administration";
$PageAfterLoginTitle = "After login page";
$PageAfterLoginTitle = "Page after login";
$PageAfterLoginComment = "The page which is seen by the user entering the platform";
$DokeosAdminWebLinks = "Chamilo Web";
$TabsMyProfile = "My Profile tab";
@ -1284,7 +1284,7 @@ $SAMLText = "SAML";
$CasMainProtocolTitle = "CAS Protocol used";
$CasMainProtocolComment = "CAS Protocol used. If you want to use your cas server to pass information within the cas ticket, choose SAML";
$CasUserAddActivateTitle = "User add by CAS activation";
$CasUserAddActivateComment = "Choose this oprtion if you want chamilo to automatically add user with information sent by the CAS server (using SAML)";
$CasUserAddActivateComment = "Choose this oprtion if you want dokeos to automatically add user with information sent by the CAS server (using SAML)";
$CasUserAddLoginAttributeTitle = "XML field for user login";
$CasUserAddLoginAttributeComment = "The XML field of the CAS ticket containing the user login";
$CasUserAddEmailAttributeTitle = "XML field for user email";
@ -1293,6 +1293,8 @@ $CasUserAddFirstnameAttributeTitle = "XML field for user firstname";
$CasUserAddFirstnameAttributeComment = "The XML field of the CAS ticket containing the user firstname";
$CasUserAddLastnameAttributeTitle = "XML field for user firsstname";
$CasUserAddLastnameAttributeComment = "The XML field of the CAS ticket containing the user firstname";
$UseCustomPages = "Use custom landing pages";
$UseCustomPagesComment = "Allows the platform admin to override some pages by supplying an alternate page in the /custompages/ directory. See the README file in this directory for details.";
$StudentPageAfterLoginTitle = "After login page for students";
$StudentPageAfterLoginComment = "Leave blank for chamilo default page after login.";
$TeacherPageAfterLoginTitle = "After login page for teachers";
@ -1301,5 +1303,4 @@ $DRHPageAfterLoginTitle = "After login page for DRH";
$DRHPageAfterLoginComment = "Leave blank for chamilo default page after login.";
$SessionAdminPageAfterLoginTitle = "After login page for session admin";
$SessionAdminPageAfterLoginComment = "Leave blank for chamilo default page after login.";
?>

@ -1270,6 +1270,8 @@ $ErrorReadingZip = "Erreur de lecture du fichier ZIP";
$ErrorStylesheetFilesExtensionsInsideZip = "Les seules extensions acceptées pour les fichiers contenus dans le ZIP sont jpg, jpeg, png, gif et css.";
$MyTextHere = "Introduisez votre texte ici...";
$FieldTypeSocialProfile = "Lien réseau social";
$UseCustomPages = "Utiliser des pages d'acceuil personnalis&eacute;es";
$UseCustomPagesComment = "Permet &agrave; l'administrateur de la plateforme de remplacer certaines pages en fournissant une alternative dans le r&eacute;pertoire /custompages/. Voyez le fichier README dans ce r&eacute;pertoire pour plus de d&eacute;tails.";
$StudentPageAfterLoginTitle = "Page à montrer pour les étudiants une fois authentifiés";
$StudentPageAfterLoginComment = "Laisser vide pour le comportement normal de chamilo.";
$TeacherPageAfterLoginTitle = "Page à montrer pour les professeurs une fois authentifiés";
@ -1278,5 +1280,4 @@ $DRHPageAfterLoginTitle = "Page à montrer pour les DRH une fois authentifiés"
$DRHPageAfterLoginComment = "Laisser vide pour le comportement normal de chamilo.";
$SessionAdminPageAfterLoginTitle = "Page à montrer pour les adminsitrateurs de sessions une fois authentifiés";
$SessionAdminPageAfterLoginComment = "Laisser vide pour le comportement normal de chamilo.";
?>

Loading…
Cancel
Save