[svn r22368] logic changes-improvements in new features of "terms and conditions" - (partial FS#4320)

skala
Isaac Flores 16 years ago
parent 2bf9880dd9
commit f5d27acf0a
  1. 14
      index.php
  2. 7
      main/admin/legal_add.php
  3. 101
      main/auth/inscription.php
  4. 7
      main/inc/lib/fckeditor/toolbars/default/simple.php
  5. 89
      main/inc/local.inc.php

@ -1,4 +1,4 @@
<?php // $Id: index.php 22352 2009-07-24 12:44:02Z herodoto $
<?php // $Id: index.php 22368 2009-07-24 23:25:57Z iflorespaz $
/*
==============================================================================
@ -27,7 +27,7 @@
/**
* @package dokeos.main
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Refactoring
* @version $Id: index.php 22352 2009-07-24 12:44:02Z herodoto $
* @version $Id: index.php 22368 2009-07-24 23:25:57Z iflorespaz $
* @todo check the different @todos in this page and really do them
* @todo check if the news management works as expected
*/
@ -76,6 +76,7 @@ $this_section = SECTION_CAMPUS;
* will see it.
*/
$my_user_id=api_get_user_id();
if (!empty($_GET['logout'])) {
logout();
}
@ -118,13 +119,18 @@ if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) {
session_destroy();
die();
}
//Delete session neccesary for legal terms
if (get_setting('allow_terms_conditions')=='true') {
unset($_SESSION['update_term_and_condition']);
unset($_SESSION['info_current_user']);
}
/**
* @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
* @todo check if this code is used. I think this code is never executed because after clicking the submit button
* the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
* on api_get_setting('page_after_login')
*/
if (!empty($_POST["submitAuth"])) {
// the user is already authenticated, we now find the last login of the user.
if (isset ($_user['user_id'])) {
@ -148,9 +154,11 @@ if (!empty($_POST["submitAuth"])) {
decodeOpenInfos();
}
}
} // end login -- if($_POST["submitAuth"])
else {
// only if login form was not sent because if the form is sent the user was already on the page.
event_open();
}

@ -27,7 +27,7 @@ if( $form->validate()) {
$content = $values['content'];
$changes = $values['changes'];
$submit = $values['send'];
$default[content]=$content;
if (isset($values['language'])){
if($submit=='back') {
header('Location: legal_add.php');
@ -82,7 +82,7 @@ if( $form->validate()) {
$defaults['changes']=$term_preview['changes'];
}*/
}
$form->setDefaults($default);
//var_dump($term_preview);
if(isset($_POST['send'])) {
Security::clear_token();
@ -108,7 +108,8 @@ if (isset($_POST['language'])) {
//$form->addElement('html_editor', 'content', null, null, array('ToolbarSet' => 'Basic', 'Width' => '100%', 'Height' => '250'));
$form->addElement('static', $_POST['language']);
$form->addElement('hidden', 'language',$_POST['language']);
$form->addElement('textarea', 'content', get_lang('Content'),array('cols'=>'120','rows'=>'10'));
$form->add_html_editor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'simple', 'Width' => '65%', 'Height' => '250'));
//$form->addElement('textarea', 'content', get_lang('Content'),array('cols'=>'120','rows'=>'10'));
$form->addElement('radio', 'type', '', get_lang('HTMLText') ,'0');
$form->addElement('radio', 'type', '', get_lang('PageLink') ,'1');
$form->addElement('textarea', 'changes', get_lang('ExplainChanges'),array('width'=>'20'));

@ -1,5 +1,5 @@
<?php
// $Id: inscription.php 22233 2009-07-20 09:54:05Z ivantcholakov $
// $Id: inscription.php 22368 2009-07-24 23:25:57Z iflorespaz $
/*
==============================================================================
Dokeos - elearning and course management software
@ -39,12 +39,45 @@ require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'
require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
require_once (api_get_path(CONFIGURATION_PATH).'profile.conf.php');
require_once(api_get_path(INCLUDE_PATH).'lib/mail.lib.inc.php');
require_once(api_get_path(INCLUDE_PATH).'lib/legal.lib.php');
//require_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
//require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
//require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
// Load terms & conditions from the current lang
if (get_setting('allow_terms_conditions')=='true') {
$get = array_keys($_GET);
if (isset($get)) {
if ($get[0]=='legal'){
//$language = api_get_setting('platformLanguage');
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview= LegalManager::get_last_condition($language);
if ($term_preview==false) {
//look for the default language
$language = api_get_setting('platformLanguage');
$language = api_get_language_id($language);
$term_preview= LegalManager::get_last_condition($language);
}
$tool_name = get_lang('TermsAndConditions');
Display :: display_header('');
echo '<div class="actions-title">';
echo $tool_name;
echo '</div>';
if (!empty($term_preview['content']))
echo $term_preview['content'];
else
echo get_lang('ComingSoon');
Display :: display_footer();
exit;
}
}
}
$tool_name = get_lang('Registration');
Display :: display_header($tool_name);
echo '<div class="actions-title">';
echo $tool_name;
echo '</div>';
@ -62,6 +95,17 @@ if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') {
}
$form = new FormValidator('registration');
if (get_setting('allow_terms_conditions')=='true') {
if (!isset($_SESSION['update_term_and_condition'][1])) {
$display_all_form=true;
} else {
$display_all_form=false;
}
} else {
$display_all_form=true;
}
if ($display_all_form===true) {
// LAST NAME and FIRST NAME
$form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
$form->applyFilter('lastname','trim');
@ -256,7 +300,47 @@ foreach ($extra as $id => $field_details) {
break;
}
}
}
//------------ Terms and conditions
if (get_setting('allow_terms_conditions')=='true') {
//$language = api_get_setting('platformLanguage');
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview= LegalManager::get_last_condition($language);
if ($term_preview==false) {
//we load from the platform
$language = api_get_setting('platformLanguage');
$language = api_get_language_id($language);
$term_preview= LegalManager::get_last_condition($language);
}
// Version and language //password
$form->addElement('hidden', 'legal_accept_type',$term_preview['version'].':'.$term_preview['language_id']);
if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) {
$form->addElement('hidden', 'login',$_SESSION['info_current_user'][1]);
$form->addElement('hidden', 'password',$_SESSION['info_current_user'][2]);
}
if($term_preview['type'] == 1) {
$form->addElement('checkbox', 'legal_accept', null, get_lang('IhaveReadAndAgree').'&nbsp;<a href="inscription.php?legal" target="_blank">'.get_lang('TermsAndConditions').'</a>');
$form->addRule('extra_legal_accept', get_lang('ThisFieldIsRequired'), 'required');
} else {
if (!empty($term_preview['content'])) {
$preview = LegalManager::show_last_condition($term_preview);
$term_preview = '<div class="row">
<div class="label">'.get_lang('Conditions').'</div>
<div class="formw">
'.$preview.'
<br />
</div>
</div>';
$form->addElement('html', $term_preview);
}
}
}
$form->addElement('style_submit_button', 'submit', get_lang('RegisterUser'),'class="save"');
if(isset($_SESSION["user_language_choice"]) && $_SESSION["user_language_choice"]!=""){
$defaults['language'] = $_SESSION["user_language_choice"];
}
@ -297,7 +381,20 @@ if ($form->validate()) {
}
// creating a new user
$user_id = UserManager::create_user($values['firstname'],$values['lastname'],$values['status'],$values['email'],$values['username'],$values['pass1'],$values['official_code'], $values['language'],$values['phone'],$picture_uri);
$user_id = UserManager::create_user($values['firstname'],$values['lastname'],$values['status'],$values['email'],$values['username'],$values['pass1'],$values['official_code'], $values['language'],$values['phone'],$picture_uri);
// Terms & Conditions
if (get_setting('allow_terms_conditions')=='true') {
// update the terms & conditions
if (isset($values['legal_accept_type'])) {
$cond_array = explode(':',$values['legal_accept_type']);
if (!empty($cond_array[0]) && !empty($cond_array[1])){
$time = time();
$condition_to_save = intval($cond_array[0]).':'.intval($cond_array[1]).':'.$time;
UserManager::update_extra_field_value($user_id,'legal_accept',$condition_to_save);
}
}
}
/****** register extra fields*************/
$extras=array();

@ -0,0 +1,7 @@
<?php
$config['ToolbarSets']['Normal'] = array(
array('Style','FontFormat','FontName','FontSize'),
array('Bold','Italic','Underline'),
array('JustifyLeft','JustifyCenter','JustifyRight')
);
?>

@ -156,7 +156,10 @@ The course id is stored in $_cid session variable.
variables should be initialised here
==============================================================================
*/
// verified if exists the username and password in session current
if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) {
require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
}
// parameters passed via GET
$logout = isset($_GET["logout"]) ? $_GET["logout"] : '';
$gidReq = isset($_GET["gidReq"]) ? Database::escape_string($_GET["gidReq"]) : '';
@ -198,8 +201,36 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
if (isset($_user['user_id'])) {
unset($_user['user_id']);
}
//$_SESSION['info_current_user'][1] is user name
//$_SESSION['info_current_user'][2] is current password encrypted
//$_SESSION['update_term_and_condition'][1] is current user id, of user in session
if (get_setting('allow_terms_conditions')=='true') {
if (isset($_POST['login']) && isset($_POST['password']) && isset($_SESSION['update_term_and_condition'][1])) {
$user_id=$_SESSION['update_term_and_condition'][1]; // user id
// update the terms & conditions
if ((isset($_POST['legal_accept']) && $_POST['legal_accept']=='1') || !isset($_POST['legal_accept'])) {
$legal_option=true;
} else {
$legal_option=false;
}
if (isset($_POST['legal_accept_type']) && $legal_option===true) {
$cond_array = explode(':',$_POST['legal_accept_type']);
if (!empty($cond_array[0]) && !empty($cond_array[1])){
$time = time();
$condition_to_save = intval($cond_array[0]).':'.intval($cond_array[1]).':'.$time;
UserManager::update_extra_field_value($user_id,'legal_accept',$condition_to_save);
}
}
}
if (isset($_POST['login']) && isset($_POST['password'])) {
}
if ((isset($_POST['login']) && isset($_POST['password']))) {
// $login && $password are given to log in
$login = $_POST['login'];
$password = $_POST['password'];
@ -211,24 +242,46 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
WHERE username = '".trim(addslashes($login))."'";
$result = api_sql_query($sql,__FILE__,__LINE__);
if (Database::num_rows($result) > 0) {
$uData = Database::fetch_array($result);
if ($uData['auth_source'] == PLATFORM_AUTH_SOURCE) {
//the authentification of this user is managed by Dokeos itself
$password = trim(stripslashes($password));
// determine if the password needs to be encrypted before checking
// $userPasswordCrypted is set in an external configuration file
/*if ($userPasswordCrypted) {
$password = md5($password);
} */
$password = api_get_encrypted_password($password);
// check the user's password
if (get_setting('allow_terms_conditions')=='true') {
if (isset($_POST['password']) && isset($_SESSION['info_current_user'][2]) && $_POST['password']==$_SESSION['info_current_user'][2]) {
$password=$_POST['password'];
} else {
$password = api_get_encrypted_password($password);
}
} else {
$password = api_get_encrypted_password($password);
}
if (get_setting('allow_terms_conditions')=='true') {
if ($password == $uData['password'] AND (trim($login) == $uData['username'])) {
$temp_user_id = $uData['user_id'];
$term_and_condition_status=api_check_term_condition($temp_user_id);//false or true
if ($term_and_condition_status===false) {
$_SESSION['update_term_and_condition']=array(true,$temp_user_id);
$_SESSION['info_current_user']=array(true,$login,$password);
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php');
exit;
} else {
unset($_SESSION['update_term_and_condition']);
unset($_SESSION['info_current_user']);
}
}
}
// check the user's password
if ($password == $uData['password'] AND (trim($login) == $uData['username'])) {
// check if the account is active (not locked)
if ($uData['active']=='1') {
@ -246,10 +299,8 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
// the user have the permissions to enter at this site
if (in_array($current_access_url_id, $my_url_list)) {
$_user['user_id'] = $uData['user_id'];
api_session_register('_user');
event_login();
api_session_register('_user');
event_login();
} else {
$loginFailed = true;
api_session_unregister('_uid');
@ -257,6 +308,7 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
exit;
}
} else {
$loginFailed = true;
api_session_unregister('_uid');
header('Location: '.api_get_path(WEB_PATH).'index.php?loginFailed=1&error=access_url_inactive');
@ -317,11 +369,14 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
unset($_SESSION['request_uri']);
header('location: '.$req);
} else {
if (isset($param)) {
if (isset($param)) {
header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login').$param);
} else {
// here is the main redirect of a *normal* login page in Dokeos
header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login'));
}
}
} else {
@ -433,8 +488,8 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
// the user has permission to enter at this site
$_user['user_id'] = $uData['user_id'];
api_session_register('_user');
event_login();
event_login();
// Redirect to homepage
$sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) .'.index.php';
@ -457,7 +512,7 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
//single URL access
$_user['user_id'] = $uData['user_id'];
api_session_register('_user');
event_login();
// Redirect to homepage
@ -1047,4 +1102,4 @@ if (isset($_cid)) {
$time = api_get_datetime();
$sql="UPDATE $tbl_course SET last_visit= '$time' WHERE code='$_cid'";
api_sql_query($sql,__FILE__,__LINE__);
}
}
Loading…
Cancel
Save