skala
Noel Dieschburg 14 years ago
commit 4517edc685
  1. 3
      custompages/first_login.php
  2. 2
      custompages/index-logged.php
  3. 21
      custompages/index-unlogged.php
  4. 12
      custompages/lostpassword.php
  5. 34
      custompages/registration-feedback.php
  6. 44
      custompages/registration.php
  7. 140
      custompages/style-ie6.css
  8. 101
      custompages/style.css
  9. 65
      main/admin/cli.php
  10. 2
      main/admin/languages.php
  11. 109
      main/auth/external_login/functions.inc.php
  12. 114
      main/auth/external_login/ldap.conf.php
  13. 181
      main/auth/external_login/ldap.inc.php
  14. 65
      main/auth/external_login/login.ldap.php
  15. 66
      main/auth/external_login/newUser.ldap.php
  16. 56
      main/auth/external_login/newUser.php
  17. 40
      main/auth/external_login/updateUser.php
  18. 127
      main/auth/external_logininfo/updateUser.php
  19. 329
      main/auth/inscription.php
  20. 89
      main/auth/lostPassword.php
  21. 16
      main/auth/profile.php
  22. 4
      main/course_home/activity.php
  23. 4
      main/course_home/vertical_activity.php
  24. 102
      main/document/remote.php
  25. 2
      main/document/upload.php
  26. 2
      main/inc/lib/custompages.lib.php
  27. 6
      main/inc/lib/database.constants.inc.php
  28. 2
      main/inc/lib/events.lib.inc.php
  29. 6
      main/inc/lib/fckeditor/editor/plugins/glossary/fck_glossary_automatic.js
  30. 6
      main/inc/lib/fckeditor/editor/plugins/glossary/fck_glossary_manual.js
  31. 5
      main/inc/lib/javascript/glossary.js
  32. 69
      main/inc/lib/login.lib.php
  33. 3
      main/inc/lib/loginredirection.lib.php
  34. 3
      main/inc/lib/main_api.lib.php
  35. 28
      main/inc/local.inc.php
  36. 13
      main/install/configuration.dist.php
  37. 110
      main/install/db_main.sql
  38. 24
      main/install/migrate-db-1.8.8-1.9.0-pre.sql
  39. 2418
      main/lang/english/trad4all.inc.php
  40. 2362
      main/lang/french/trad4all.inc.php
  41. 28
      main/newscorm/js/documentapi.js
  42. 63
      main/newscorm/js/storageapi.js
  43. 6
      main/newscorm/learnpathItem.class.php
  44. 2
      main/newscorm/learnpathList.class.php
  45. 4
      main/newscorm/lp_ajax_save_item.php
  46. 7
      main/newscorm/lp_controller.php
  47. 44
      main/newscorm/lp_list.php
  48. 14
      main/newscorm/lp_view.php
  49. 8
      main/newscorm/scorm_api.php
  50. 78
      main/newscorm/storageapi.php
  51. 4
      main/reports/reports.lib.php
  52. 119
      main/reports/templates/courseArticulate.reports.php
  53. 62
      main/reports/templates/generic.reports.php
  54. 24
      main/wiki/wiki.inc.php

@ -67,7 +67,10 @@ if ($_GET['invalid'] == 2) {
<div id="header">
<img src="/custompages/images/header.png" alt="Logo" />
</div> <!-- #header -->
<h2> <?php echo cblue_get_lang('FirstLogin');?> </h2>
<div id="changepassword-form-box" class="form-box">
<div class="info"> <?php echo cblue_get_lang('FirstLoginChangePassword');?> </div>
<?php if (isset($error_message)) {
echo '<div id="changepassword-form-error" class="form-error">'.$error_message.'</div>';
}?>

@ -1,5 +1,5 @@
<?php
require_once('main/inc/global.inc.php');
require_once(dirname(__FILE__).'/../main/inc/global.inc.php');
//require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
header("Location: /user_portal.php");

@ -52,22 +52,24 @@ if (isset($_GET['loginFailed'])){
</head>
<body>
<div id="backgroundimage">
<img src="/custompages/images/page-background.png" class="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="/custompages/images/header.png" alt="Logo" />
<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">
<?php if ($values['reset_password']) {
echo '<div id="login-form-info" class="form-info">'.cblue_get_lang('your_password_has_been_reset').'</div>';
}?>
<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="/index.php" method="post">
<form id="login-form" class="form" action="<?php echo api_get_path(WEB_PATH)?>index.php" method="post">
<div>
<label for="login">*<?php echo cblue_get_lang('Username');?></label>
<label for="login">*<?php echo cblue_get_lang('User');?></label>
<input name="login" type="text" /><br />
<label for="password">*<?php echo cblue_get_lang('langPass');?></label>
<input name="password" type="password" /><br />
@ -77,11 +79,12 @@ if (isset($_GET['loginFailed'])){
<span><?php echo cblue_get_lang('LoginEnter');?></span>
</div> <!-- #form-submit -->
<div id="links">
<a href="main/auth/lostPassword.php"><?php echo cblue_get_lang('langLostPassword')?></a>
<a href="<?php echo api_get_path(WEB_PATH)?>main/auth/inscription.php"><?php echo cblue_get_lang('langReg')?></a><br />
<a href="<?php echo api_get_path(WEB_PATH)?>main/auth/lostPassword.php"><?php echo cblue_get_lang('langLostPassword')?></a>
</div>
</div> <!-- #form -->
<div id="footer">
<img src="/custompages/images/footer.png" />
<img src="<?php echo api_get_path(WEB_PATH)?>/custompages/images/footer.png" />
</div> <!-- #footer -->
</div> <!-- #wrapper -->
</body>

@ -32,10 +32,16 @@ require_once('language.php');
<div id="header">
<img src="../../custompages/images/header.png" alt="Ambassador logo" />
</div> <!-- #header -->
<?php echo '<div id="registration-form-info" class="form-info">'.cblue_get_lang('lang_enter_email_and_well_send_you_password').'</div>'; ?>
<div id="registration-form-info" class="form-info">
<?php if(isset($content['error']) && !empty($content['error'])){
echo $content['info'];
} else {
echo cblue_get_lang('lang_enter_email_and_well_send_you_password');
}?>
</div>
<div id="lostpassword-form-box" class="form-box">
<?php if (isset($form_error) && !empty($form_error)) {
echo '<div id="registration-form-error" class="form-error"><ul>'.$form_error.'</ul></div>';
<?php if (isset($content['error']) && !empty($content['error'])) {
echo '<div id="registration-form-error" class="form-error"><ul>'.$content['error'].'</ul></div>';
}?>
<form id="lostpassword-form" class="form" action="lostPassword.php" method="post">
<div>

@ -1,3 +1,31 @@
<?php require_once('../inc/global.inc.php');
header("Location: /user_portal.php");
exit();
<html>
<head>
<title>Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--[if !IE 6]><!-->
<link rel="stylesheet" type="text/css" href="../../custompages/style.css" />
<!--<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="../../custompages/style-ie6.css" />
<![endif]-->
<script type="text/javascript" src="../../custompages/jquery-1.5.1.min.js"></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="registration-feedback-box">
<?php
echo $content['info'];
?>
</div> <!-- #feedback -->
<div id="footer">
<img src="../../custompages/images/footer.png" />
</div> <!-- #footer -->
</div> <!-- #wrapper -->
</body>
</html>

@ -1,7 +1,20 @@
<?php
require_once('../inc/global.inc.php');
require_once('../inc/lib/group_portal_manager.lib.php');
require_once('language.php');
require_once('../inc/global.inc.php');
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(LIBRARY_PATH).'mail.lib.inc.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');
$content['form']->removeElement('status');
$content['form']->removeElement('status');
?>
<html>
<head>
@ -27,29 +40,14 @@ require_once('language.php');
<?php if (isset($form_error) && !empty($form_error)) {
echo '<div id="registration-form-error" class="form-error"><ul>'.$form_error.'</ul></div>';
}?>
<form id="registration-form" class="form" action="inscription.php" method="post">
<div>
<label for="email"><?php echo get_lang('langEmail');?>*</label>
<input name="email" type="text" value="<?php echo $values['email']?>" /><br />
<label for="username"><?php echo get_lang('Username');?>*</label>
<input name="username" type="text" value="<?php echo $values['username']?>" /><br />
<p class="forminfo"><?php echo get_lang('UsernameWrong')?></p>
<label for="pass1"><?php echo get_lang('Pass');?>*</label>
<input name="pass1" type="password" value="<?php echo $values['pass1']?>" /><br />
<label for="pass2"><?php echo get_lang('Confirmation');?>*</label>
<input name="pass2" type="password" value="<?php echo $values['pass2']?>" /><br />
<!--
<label for="phone">*Phone number</label>
<input name="phone" type="text" /><br />
-->
<input name="language" type="hidden" value="<?php echo $_SESSION['user_language_choice']?>" />
<input name="status" type="hidden" value="5" /> <!-- learner -->
</div>
</form>
<div id="registration-form-submit" class="form-submit" onclick="document.forms['registration-form'].submit();">
<span><?php echo get_lang('Subscribe');?></span>
<?php
$content['form']->display();
?>
<div id="registration-form-submit" class="form-submit" onclick="document.forms['registration'].submit();">
<span><?php echo cblue_get_lang('Subscribe');?></span>
</div> <!-- #form-submit -->
<div id="links">
<!--<a href="mailto: support@cblue.be"><?php echo cblue_get_lang('NeedContactAdmin')?></a><br />-->
</div>
</div> <!-- #form -->
<div id="footer">

@ -1,3 +1,75 @@
/* Color easy change */
body, .form, #links a, .form-info {
color: #DF002A;
}
.form-submit, input, select {
background-color: #DF002A;
}
.form-error {
color: red;
font-size: 9pt;
}
.form-submit {
margin: 0;
padding: 0;
width: 310px;
height: 27px;
background-color: #DF002A;
/*background-image: url(/custompages/images/login-form-submit-bg.jpg);*/
color: white;
cursor: pointer;
cursor: hand;
}
/* end easy change */
/* Registration form */
#registration-form-box {
width: 400px;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
border: solid 1px #CCCCCC;
text-align: left;
background-color: white;
}
#registration-form-box .form-submit{
width: 400px;
}
div.row {
clear: both;
padding-top: 5px;
}
div.row div.form_header {
white-space: nowrap;
padding: 2px;
background-color: #f0f0f0;
border: 1px solid #bbb;
}
div.row div.label {
float: left;
width: 53%;
text-align: right;
padding-right:1%
}
div.row div.formw {
width: 46%;
float:left;
}
[dir=ltr] div.row div.label, [dir=rtl] div.row div.formw {
float: left;
text-align: right;
}
[dir=rtl] div.row div.label, [dir=ltr] div.row div.formw {
float: right;
text-align: left;
}
span.form_required {
color: #f00;
}
span.form_error {
color: #f00;
font-size: x-small;
margin: 2px;
}
html, body {
margin: 0;
padding: 0;
@ -8,8 +80,8 @@ body {
font-size: 10pt;
width: 100%;
text-align: center;
/*
background-image: url(images/page-background.png);
color: #1F3660;
/*background-image: url(images/page-background.png);
background-repeat: no-repeat;
background-size: 100%;
*/
@ -36,7 +108,6 @@ body {
left: 0;
width: 100%;
z-index: 1;
text-align: center;
}
#header {
@ -66,22 +137,11 @@ body {
margin-left: 15px;
margin-right: 15px;
margin-top: 30px;
color: #1F3660;
/*color: #1F3660;*/
/*position: relative;*/
text-align: left;
}
.form-submit {
margin: 0;
padding: 0;
width: 310px;
height: 27px;
background-color: #1F3660;
background-image: url(/custompages/images/login-form-submit-bg.jpg);
color: white;
cursor: pointer;
cursor: hand;
}
label {
width: 100px;
@ -98,50 +158,45 @@ input {
margin-bottom: 2em;
width: 150px;
color: white;
background-color: #1F3660;
/*background-color: #1F3660;*/
border: none;
}
.radiobutton {
width: 20px;
background-color: white;
margin: 0;
}
.radiogroup {
margin-bottom: 2em;
}
width: 20px;
background-color: white;
margin: 0;
}
.radiogroup {
margin-bottom: 2em;
}
select {
margin-bottom: 2em;
width: 150px;
color: white;
/*background-color: #1F3660;*/
border: none;
margin-bottom: 2em;
width: 150px;
}
label {
clear: both;
clear: both;
}
input, select, .radiogroup {
float: right;
clear: both;
float: right;
clear: both;
}
.radiogroup input, .radiogroup label {
float: none;
}
float: none;
}
#links {
margin-left: 15px;
margin-right: 15px;
margin-top: 10px;
margin-bottom: 50px;
color: #1F3660;
/*color: #1F3660;*/
}
#links a, #links a:hover, #links a:active, #links a:visited {
color: #1F3660;
}
#links a {
text-decoration: none;
@ -158,11 +213,6 @@ span {
}
.form-info {
color: #1F3660;
font-size: 9pt;
}
.form-error {
color: red;
/*color: #1F3660;*/
font-size: 9pt;
}

@ -1,3 +1,75 @@
/* Color easy change */
body, .form, #links a, .form-info {
color: #DF002A;
}
.form-submit, input, select {
background-color: #DF002A;
}
.form-error {
color: red;
font-size: 9pt;
}
.form-submit {
margin: 0;
padding: 0;
width: 310px;
height: 27px;
background-color: #DF002A;
/*background-image: url(/custompages/images/login-form-submit-bg.jpg);*/
color: white;
cursor: pointer;
cursor: hand;
}
/* end easy change */
/* Registration form */
#registration-form-box {
width: 400px;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
border: solid 1px #CCCCCC;
text-align: left;
background-color: white;
}
#registration-form-box .form-submit{
width: 400px;
}
div.row {
clear: both;
padding-top: 5px;
}
div.row div.form_header {
white-space: nowrap;
padding: 2px;
background-color: #f0f0f0;
border: 1px solid #bbb;
}
div.row div.label {
float: left;
width: 53%;
text-align: right;
padding-right:1%
}
div.row div.formw {
width: 46%;
float:left;
}
[dir=ltr] div.row div.label, [dir=rtl] div.row div.formw {
float: left;
text-align: right;
}
[dir=rtl] div.row div.label, [dir=ltr] div.row div.formw {
float: right;
text-align: left;
}
span.form_required {
color: #f00;
}
span.form_error {
color: #f00;
font-size: x-small;
margin: 2px;
}
html, body {
margin: 0;
padding: 0;
@ -8,6 +80,7 @@ body {
font-size: 10pt;
width: 100%;
text-align: center;
/*color: #1F3660;*/
/*background-image: url(images/page-background.png);
background-repeat: no-repeat;
background-size: 100%;
@ -64,22 +137,11 @@ body {
margin-left: 15px;
margin-right: 15px;
margin-top: 30px;
color: #1F3660;
/*color: #1F3660;*/
position: relative;
text-align: left;
}
.form-submit {
margin: 0;
padding: 0;
width: 310px;
height: 27px;
background-color: #1F3660;
background-image: url(/custompages/images/login-form-submit-bg.jpg);
color: white;
cursor: pointer;
cursor: hand;
}
label {
width: 100px;
@ -96,14 +158,14 @@ input {
margin-bottom: 2em;
width: 150px;
color: white;
background-color: #1F3660;
/*background-color: #1F3660;*/
border: none;
}
select {
width: 150px;
color: white;
background-color: #1F3660;
/*background-color: #1F3660;*/
border: none;
margin-bottom: 2em;
}
@ -112,12 +174,9 @@ select {
margin-right: 15px;
margin-top: 10px;
margin-bottom: 50px;
color: #1F3660;
/*color: #1F3660;*/
}
#links a, #links a:hover, #links a:active, #links a:visited {
color: #1F3660;
}
#links a {
text-decoration: none;
@ -134,10 +193,6 @@ span {
}
.form-info {
color: #1F3660;
font-size: 9pt;
}
.form-error {
color: red;
/*color: #1F3660;*/
font-size: 9pt;
}

@ -0,0 +1,65 @@
<?php
/* For licensing terms, see /dokeos_license.txt */
/**
==============================================================================
* Used for external support of chamilo's users
*
* @author Arnaud Ligot, CBlue SPRL
* @package dokeos.admin
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
$language_file = 'admin';
// we are in the admin area so we do not need a course id
$cidReset = true;
// include global script
require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
/*
==============================================================================
MAIN CODE
==============================================================================
*/
// setting the name of the tool
$tool_name = get_lang('CLI');
// setting breadcrumbs
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
// including the header file (which includes the banner itself)
Display :: display_header($tool_name);
switch ($_GET["cmd"]) {
case "clear_stapi":
echo "Are you sure you are willing to erease all storage api data (no backup)? <a href='cli.php?cmd=clear_stapi_confirm' >Yes</a>";
break;
case "clear_stapi_confirm":
Database::query("delete from ".Database::get_main_table(TABLE_MAIN_STORED_VALUES));
Database::query("delete from ".Database::get_main_table(TABLE_MAIN_STORED_STACK));
echo "Done";
break;
default:
echo "UNKNOWN COMMAND";
break;
}
/*
==============================================================================
FOOTER
==============================================================================
*/
Display :: display_footer();
?>

@ -76,7 +76,7 @@ $htmlHeadXtra[] ='<script type="text/javascript">
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {
$("#id_content_message").html("<div class=\"normal-message\"><img src=\'/main/inc/lib/javascript/indicator.gif\' /></div>");
$("#id_content_message").html("<div class=\"normal-message\"><img src='.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif\' /></div>");
},
type: "POST",

@ -1,16 +1,8 @@
<?php
/*
Template to automatically create a new user with information from anywhere.
This file is loaded by main/inc/local.inc.php
To use it please add this line to main/inc/conf/configuration.php :
$extAuthSource["external_logininfo"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_logininfo/newUser.php";
You also have to implements the external_get_user_info function in this file.
*/
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
define('USERINFO_TABLE', 'userinfo');
define('DEFAULT_PASSWORD', 'boumbalah');
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
//define('USERINFO_TABLE', 'danone_userinfo');
//define('DEFAULT_PASSWORD', 'danonelearning');
//TODO : Please implements this function for this module to work.
/**
@ -29,9 +21,6 @@
function external_get_user_info($login, $password){
//Those are the mandatory fields for user creation.
//See external_add_user function for all the fields you can have.
if ($password != DEFAULT_PASSWORD) {
return false;
}
$table = USERINFO_TABLE;
$sql = "SELECT * from $table where username='".Database::escape_string($login)."'";
$result = Database::query($sql);
@ -68,6 +57,9 @@ function external_get_user_info($login, $password){
$language = 'english';
break;
}
//Can Send Message ?
$can_send_message = ($user_info['can_send_message'] == 1) ? 'yes' : 'no';
$u = array(
'firstname' => $user_info['firstname'],
@ -75,18 +67,21 @@ function external_get_user_info($login, $password){
'status' => $status,
'admin' => $admin,
'email' => $user_info['email'],
'login' => $user_info['username'],
'username' => $user_info['username'],
'language' => $language,
'password' => DEFAULT_PASSWORD,
'courses' => $user_info['courses'],
'profile_link' => $user_info['profile_link'],
'worldwide_bu' => $user_info['worlwide_bu'],
'manager' => $user_info['manager'],
'country_bu' => $user_info['country_bu'],
'extra' => array(
'position_title' => $user_info['position_title'],
'country' => $user_info['country'],
'job_family' => $user_info['job_family'],
'country_bu' => $user_info['country_bu'],
'worldwide_bu' => $user_info['worldwide_bu'],
'profile_link' => $user_info['profile_link'],
'can_send_message' => $can_send_message,
'update_type' => 'external_logininfo')
);
@ -123,43 +118,57 @@ function external_add_user($u){
if (! isset($u['encrypt_method']) )
$u['encrypt_method'] = '';
$chamilo_uid = UserManager::create_user($u['firstname'], $u['lastname'],$u['status'], $u['email'], $u['login'], $u['password'], $u['official_code'], $u['language'], $u['phone'],$u['picture_uri'], $u['auth_source'], $u['expiration_date'], $u['active'], $u['hr_dept_id'], $u['extra'], $u['encrypt_method']);
$chamilo_uid = UserManager::create_user($u['firstname'], $u['lastname'],$u['status'], $u['email'], $u['username'], $u['password'], $u['official_code'], $u['language'], $u['phone'],$u['picture_uri'], $u['auth_source'], $u['expiration_date'], $u['active'], $u['hr_dept_id'], $u['extra'], $u['encrypt_method']);
return $chamilo_uid;
}
//MAIN CODE
//$login and $password variables are setted in main/inc/local.inc.php
$user = external_get_user_info($login, $password);
if ($user !== false && ($chamilo_uid = external_add_user($user)) !== false) {
//log in the user
$loginFailed = false;
$_user['user_id'] = $chamilo_uid;
api_session_register('_user');
//Autosubscribe to courses
if(!empty($user['courses'])){
$autoSubscribe = explode('|', $user['courses']);
foreach ($autoSubscribe as $code) {
if (CourseManager::course_exists($code)) {
CourseManager::subscribe_user($_user['user_id'], $code);
}
/**
* Update the user in chamilo database. It upgrade only info that is present in the
* new_user array
*
* @param $new_user associative array with the value to upgrade
* WARNING user_id key is MANDATORY
* Possible keys are :
* - firstname
* - lastname
* - username
* - auth_source
* - email
* - status
* - official_code
* - phone
* - picture_uri
* - expiration_date
* - active
* - creator_id
* - hr_dept_id
* - extra : array of custom fields
* - language
* - courses : string of all courses code separated by '|'
* - admin : boolean
* @return boolean
* @author ndiechburg <noel@cblue.be>
**/
function external_update_user($new_user){
$old_user = UserManager::get_user_info_by_id($new_user['user_id']);
$u = array_merge($old_user, $new_user);
$updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], null, $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'], $u['extra'], $u['language'],'');
if(isset($u['courses']) && !empty($u['courses'])){
$autoSubscribe = explode('|', $u['courses']);
foreach ($autoSubscribe as $code) {
if (CourseManager::course_exists($code)) {
CourseManager::subscribe_user($u['user_id'], $code);
}
}
// Is User Admin ?
if ($user['admin']){
$is_platformAdmin = true;
Database::query("INSERT INTO admin values ('$chamilo_uid')");
}
// Can user create course
$is_allowedCreateCourse = (bool) (($user['status'] == COURSEMANAGER) or (api_get_setting('drhCourseManagerRights') and $user['status'] == SESSIONADMIN));
}
// Is User Admin ?
//TODO decomments and check that user_is is not already in admin table
/*
if (isset($u['admin']) && $u['admin']){
$table = Database::get_main_table(TABLE_MAIN_ADMIN);
$res = Database::query("SELECT * from $table WHERE user_id = ".$u['user_id']);
}*/
event_login();
} else {
$loginFailed = true;
unset($_user['user_id']);
$uidReset = false;
}
?>

@ -0,0 +1,114 @@
<?php // External login module : LDAP
/**
* Configuration file
* Please edit this file to match with your LDAP settings
**/
require_once dirname(__FILE__).'/ldap.inc.php';
/**
* Array of connection parameters
**/
$extldap_config = array(
//base dommain string
'base_dn' => 'DC=cblue,DC=be',
//admin distinguished name
'admin_dn' => 'CN=admin,dc=cblue,dc=be',
//admin password
'admin_password' => 'pass',
//ldap host
'host' => array('1.2.3.4', '2.3.4.5', '3.4.5.6'),
// filter
// 'filter' => '', // no () arround the string
//'port' => , default on 389
//protocl version (2 or 3)
'protocol_version' => 3,
// set this to 0 to connect to AD server
'referrals' => 0,
//String used to search the user in ldap. %username will ber replaced by the username.
//See extldap_get_user_search_string() function below
// 'user_search' => 'sAMAccountName=%username%', // no () arround the string
'user_search' => 'uid=%username%', // no () arround the string
//encoding used in ldap (most common are UTF-8 and ISO-8859-1
'encoding' => 'UTF-8',
//Set to true if user info have to be update at each login
'update_userinfo' => true
);
/**
* return the string used to search a user in ldap
*
* @param string username
* @return string the serach string
* @author ndiechburg <noel@cblue.be>
**/
function extldap_get_user_search_string($username)
{
global $extldap_config;
// init
$filter = '('.$extldap_config['user_search'].')';
// replacing %username% by the actual username
$filter = str_replace('%username%',$username,$filter);
// append a global filter if needed
if (isset($extldap_config['filter']) && $extldap_config['filter'] != "")
$filter = '(&'.$filter.'('.$extldap_config['filter'].'))';
return $filter;
}
/**
* Correspondance array between chamilo user info and ldap user info
* This array is of this form :
* '<chamilo_field> => <ldap_field>
*
* If <ldap_field> is "func", then the value of <chamilo_field> will be the return value of the function
* extldap_get_<chamilo_field>($ldap_array)
* In this cas you will have to declare the extldap_get_<chamilo_field> function
*
* If <ldap_field> is a string beginning with "!", then the value will be this string without "!"
*
* If <ldap_field> is any other string then the value of <chamilo_field> will be
* $ldap_array[<ldap_field>][0]
*
* If <ldap_field> is an array then its value will be an array of values with the same rules as above
*
**/
$extldap_user_correspondance = array(
'firstname' => 'givenName',
'lastname' => 'sn',
'status' => 'func',
'admin' => 'func',
'email' => 'mail',
'auth_source' => '!extldap',
//'username' => ,
'language' => '!english',
'password' => '!PLACEHOLDER',
'extra' => array(
'title' => 'title',
'globalid' => 'employeeID',
'department' => 'department',
'country' => 'co',
'bu' => 'Company')
);
/**
* Please declare here all the function you use in extldap_user_correspondance
* All these functions must have an $ldap_user parameter. This parameter is the
* array returned by the ldap for the user
**/
/**
* example function for email
**/
/*
function extldap_get_email($ldap_user){
return $ldap_user['cn'].$ldap['sn'].'@gmail.com';
}
*/
function extldap_get_status($ldap_user){
return STUDENT;
}
function extldap_get_admin($ldap_user){
return false;
}
?>

@ -0,0 +1,181 @@
<?php // External login module : LDAP
/**
* This files is included by newUser.ldap.php and login.ldap.php
* It implements the functions nedded by both files
**/
//Includes the configuration file
require_once dirname(__FILE__).'/../../inc/global.inc.php';
require_once dirname(__FILE__).'/ldap.conf.php';
/**
* Returns a transcoded and trimmed string
*
* @param string
* @return string
* @author ndiechburg <noel@cblue.be>
**/
function extldap_purify_string($string)
{
global $extldap_config;
if(isset($extldap_config['encoding'])) {
return trim(api_to_system_encoding($string, $extldap_config['encoding']));
}
else {
return trim($string);
}
}
/**
* Establishes a connection to the LDAP server and sets the protocol version
*
* @return resource ldap link identifier or false
* @author ndiechburg <noel@cblue.be>
**/
function extldap_connect()
{
global $extldap_config;
if (!is_array($extldap_config['host']))
$extldap_config['host'] = array($extldap_config['host']);
foreach($extldap_config['host'] as $host) {
//Trying to connect
if (isset($extldap_config['port'])) {
$ds = ldap_connect($host,$extldap_config['port']);
} else {
$ds = ldap_connect($host);
}
if (!$ds) {
$port = isset($extldap_config['port']) ? $ldap_config['port'] : 389;
error_log('EXTLDAP ERROR : cannot connect to '.$extldap_config['host'].':'. $port);
} else
break;
}
if (!$ds) {
error_log('EXTLDAP ERROR : no valid server found');
return false;
}
//Setting protocol version
if (isset($extldap_config['protocol_version'])) {
if ( ! ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $extldap_config['protocol_version'])) {
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 2);
}
}
//Setting protocol version
if (isset($extldap_config['referrals'])) {
if ( ! ldap_set_option($ds, LDAP_OPT_REFERRALS, $extldap_config['referrals'])) {
ldap_set_option($ds, LDAP_OPT_REFERRALS, $extldap_config['referrals']);
}
}
return $ds;
}
/**
* Authenticate user on external ldap server and return user ldap entry if that succeeds
*
* @return mixed false if user cannot authenticate on ldap, user ldap entry if tha succeeds
* @author ndiechburg <noel@cblue.be>
**/
function extldap_authenticate($username, $password)
{
global $extldap_config;
if (empty($username) or empty($password)){
return false;
}
$ds = extldap_connect();
if (!$ds) {
return false;
}
//Connection as admin to search dn of user
$ldapbind = @ldap_bind($ds, $extldap_config['admin_dn'], $extldap_config['admin_password']);
if ($ldapbind === false){
error_log('EXTLDAP ERROR : cannot connect with admin login/password');
return false;
}
$user_search = extldap_get_user_search_string($username);
//Search distinguish name of user
$sr = ldap_search($ds, $extldap_config['base_dn'], $user_search);
if ( !$sr ){
error_log('EXTLDAP ERROR : ldap_search('.$ds.', '.$extldap_config['base_dn'].", $user_search) failed");
return false;
}
$entries_count = ldap_count_entries($ds,$sr);
if ($entries_count > 1) {
error_log('EXTLDAP ERROR : more than one entry for that user ( ldap_search(ds, '.$extldap_config['base_dn'].", $user_search) )");
return false;
}
if ($entries_count < 1) {
error_log('EXTLDAP ERROR : No entry for that user ( ldap_search(ds, '.$extldap_config['base_dn'].", $user_search) )");
return false;
}
$users = ldap_get_entries($ds,$sr);
$user = $users[0];
//now we try to autenthicate the user in the ldap
$ubind = @ldap_bind($ds, $user['dn'], $password);
if($ubind !== false){
return $user;
}
else {
error_log('EXTLDAP : Wrong password for '.$user['dn']);
}
}
/**
* Return an array with userinfo compatible with chamilo using $extldap_user_correspondance
* configuration array declared in ldap.conf.php file
*
* @param array ldap user
* @param array correspondance array (if not set use extldap_user_correspondance declared
* in ldap.conf.php
* @return array userinfo array
* @author ndiechburg <noel@cblue.be>
**/
function extldap_get_chamilo_user($ldap_user, $cor = null)
{
global $extldap_user_correspondance;
if ( is_null($cor) ) {
$cor = $extldap_user_correspondance;
}
$chamilo_user =array();
foreach ($cor as $chamilo_field => $ldap_field) {
if (is_array($ldap_field)){
$chamilo_user[$chamilo_field] = extldap_get_chamilo_user($ldap_user, $ldap_field);
continue;
}
switch ($ldap_field) {
case 'func':
$func = "extldap_get_$chamilo_field";
if (function_exists($func)) {
$chamilo_user[$chamilo_field] = extldap_purify_string($func($ldap_user));
} else {
error_log("EXTLDAP WARNING : You forgot to declare $func");
}
break;
default:
//if string begins with "!", then this is a constant
if($ldap_field[0] === '!' ){
$chamilo_user[$chamilo_field] = trim($ldap_field, "!\t\n\r\0");
break;
}
if ( isset($ldap_user[$ldap_field][0]) ) {
$chamilo_user[$chamilo_field] = extldap_purify_string($ldap_user[$ldap_field][0]);
} else {
error_log('EXTLDAP WARNING : '.$ldap_field. '[0] field is not set in ldap array');
}
break;
}
}
return $chamilo_user;
}
?>

@ -0,0 +1,65 @@
<?php // External login module : LDAP
/**
*
* This file is included in main/inc/local.inc.php at user login if the user have 'external_ldap' in
* his auth_source field insted of platform
*
* Variables that can be used :
* - $login : string containing the username posted by the user
* - $password : string containing the password posted by the user
* - $uData : associative array with those keys :
* -username
* -password
* -auth_source
* -active
* -expiration_date
*
* If login succeeds, we have 2 choices :
* 1. - set $loginFailed to false,
* - set $_SESSION['_user']['user_id'] with the dokeos user_id
* - set $uidReset to true
* - upgrade user info in dokeos database if needeed
* - let the script local.inc.php continue
*
* 2. - set $_SESSION['_user']['user_id'] with the dokeos user_id
* - set $_SESSION['_user']['uidReset'] to true
* - upgrade user info in dokeos database if needeed
* - redirect to any page and let local.inc.php do the magic
*
* If login fails we have to redirect to index.php with the right message
* Possible messages are :
* - index.php?loginFailed=1&error=access_url_inactive
* - index.php?loginFailed=1&error=account_expired
* - index.php?loginFailed=1&error=account_inactive
* - index.php?loginFailed=1&error=user_password_incorrect
* - index.php?loginFailed=1&error=unrecognize_sso_origin');
*
**/
require_once(dirname(__FILE__).'/ldap.conf.php');
require_once(dirname(__FILE__).'/functions.inc.php');
$ldap_user = extldap_authenticate($login,$password);
if ($ldap_user !== false) {
$chamilo_user = extldap_get_chamilo_user($ldap_user);
//userid is not on the ldap, we have to use $uData variable from local.inc.php
$chamilo_user['user_id'] = $uData['user_id'];
//Update user info
if(isset($extldap_config['update_userinfo']) && $extldap_config['update_userinfo'])
{
external_update_user($chamilo_user);
}
$loginFailed = false;
$_user['user_id'] = $chamilo_user['user_id'];
$_user['uidReset'] = true;
api_session_register('_user');
$uidReset=true;
event_login();
} else {
$loginFailed = true;
$uidReset = false;
unset($_user['user_id']);
}
?>

@ -0,0 +1,66 @@
<?php // External login module : LDAP
/**
* This file is included by main/inc/local.inc.php when extldap is activated, a user try to login
* and chamilo does not find his user
* Variables that can be used :
* - $login : string containing the username posted by the user
* - $password : string containing the password posted by the user
*
* Please configure the exldap module in main/auth/external_login/ldap.conf.php
*
* If login succeeds, we have to add the user in the chamilo database and then
* we have 2 choices :
* 1. - set $loginFailed to false,
* - set $_SESSION['_user']['user_id'] with the dokeos user_id
* - set $uidReset to true
* - let the script local.inc.php continue
*
* 2. - set $_SESSION['_user']['user_id'] with the dokeos user_id
* - set $_SESSION['_user']['uidReset'] to true
* - upgrade user info in dokeos database if needeed
* - redirect to any page and let local.inc.php do the magic
*
* If login fails we have also 2 choices :
* 1. - unset $_user['user_id']
* - set $loginFailed=true
* - set $uidReset = false
* User wil then have the user password incorrect message
*
* 2. We redirect the user to index.php with appropriate message :
* Possible messages are :
* - index.php?loginFailed=1&error=access_url_inactive
* - index.php?loginFailed=1&error=account_expired
* - index.php?loginFailed=1&error=account_inactive
* - index.php?loginFailed=1&error=user_password_incorrect
* - index.php?loginFailed=1&error=unrecognize_sso_origin');
**/
require_once(dirname(__FILE__).'/ldap.conf.php');
require_once(dirname(__FILE__).'/functions.inc.php');
$ldap_user = extldap_authenticate($login,$password);
if ($ldap_user !== false) {
$chamilo_user = extldap_get_chamilo_user($ldap_user);
//username is not on the ldap, we have to use $login variable
$chamilo_user['username'] = $login;
$chamilo_uid = external_add_user($chamilo_user);
if ($chamilo_uid !==false) {
$loginFailed = false;
$_user['user_id'] = $chamilo_uid;
$_user['uidReset'] = true;
api_session_register('_user');
$uidReset=true;
// Is user admin?
if ($chamilo_user['admin']=== true){
$is_platformAdmin = true;
Database::query("INSERT INTO admin values ('$chamilo_uid')");
}
}
event_login();
} else {
$loginFailed = true;
$uidReset = false;
unset($_user['user_id']);
}
?>

@ -0,0 +1,56 @@
<?php
/*
Template to automatically create a new user with information from anywhere.
This file is loaded by main/inc/local.inc.php
To use it please add this line to main/inc/conf/configuration.php :
$extAuthSource["external_logininfo"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_logininfo/newUser.php";
You also have to implements the external_get_user_info function in functions.inc.php
*/
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
require_once(dirname(__FILE__).'/functions.inc.php');
//MAIN CODE
//$login and $password variables are setted in main/inc/local.inc.php
if ($password != DEFAULT_PASSWORD) {
$user = false;
} else {
$user = external_get_user_info($login, $password);
}
if ($user !== false && ($chamilo_uid = external_add_user($user)) !== false) {
//log in the user
$loginFailed = false;
$_user['user_id'] = $chamilo_uid;
$_user['uidReset'] = true;
api_session_register('_user');
$uidReset=true;
//Autosubscribe to courses
if(!empty($user['courses'])){
$autoSubscribe = explode('|', $user['courses']);
foreach ($autoSubscribe as $code) {
if (CourseManager::course_exists($code)) {
CourseManager::subscribe_user($_user['user_id'], $code);
}
}
}
// Is User Admin ?
if ($user['admin']){
$is_platformAdmin = true;
Database::query("INSERT INTO admin values ('$chamilo_uid')");
}
// Can user create course
$is_allowedCreateCourse = (bool) (($user['status'] == COURSEMANAGER) or (api_get_setting('drhCourseManagerRights') and $user['status'] == SESSIONADMIN));
event_login();
} else {
$loginFailed = true;
unset($_user['user_id']);
$uidReset = false;
}
?>

@ -0,0 +1,40 @@
<?php //Script loaded by local.inc.php providing update user information of type external_logininfo.
/*
This script must not exit.
*/
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
require_once(dirname(__FILE__).'/functions.inc.php');
//MAIN CODE
//$uData variable is set in local.inc.php
$user = UserManager::get_user_info_by_id($uData['user_id']);
$new_user = external_get_user_info($login);
$user['firstname'] = $new_user['firstname'];
$user['lastname'] = $new_user['lastname'];
$user['status'] = $new_user['status'];
$user['admin'] = $new_user['admin'];
$user['email'] = $new_user['email'];
$user['username'] = $new_user['username'];
$user['profile_link'] = $new_user['profile_link'];
$user['worldwide_bu'] = $new_user['worldwide_bu'];
$user['manager'] = $new_user['manager'];
$user['country_bu'] = $new_user['country_bu'];
$user['extra'] = $new_user['extra'];
if ($new_user !== false) { //User can login
external_update_user($user);
$loginFailed = false;
$_user['user_id'] = $user['user_id'];
$_user['uidReset'] = true;
$uidReset=true;
api_session_register('_user');
} else { //User cannot login
$loginFailed = true;
api_session_unregister('_uid');
header('Location: '.api_get_path(WEB_PATH).'index.php?loginFailed=1&error=user_password_incorrect');
exit;
}
?>

@ -1,127 +0,0 @@
<?php //Script loaded by local.inc.php providing update user information of type external_logininfo.
/*
This script must not exit.
*/
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
define('USERINFO_TABLE', 'userinfo');
//TODO : Please implements this function for this module to work.
/**
* Gets user info from external source
* @param string login
* @param string password
* @return user array with at least the following fields:
* firstname
* lastname
* status
* email
* login
* password
* or false if no data
**/
function external_get_user_info($login, $password){
//Those are the mandatory fields for user creation.
//See external_add_user function for all the fields you can have.
$table = USERINFO_TABLE;
$sql = "SELECT * from $table where username='".Database::escape_string($login)."'";
$result = Database::query($sql);
if (Database::num_rows($result) == 0 ) { //false password
return false;
}
$user_info = Database::fetch_assoc($result);
// User status
$admin = false;
switch($user_info['status']){
case 'admin':
$status = COURSEMANAGER;
$admin = true;
break;
case 'teacher':
$status = COURSEMANAGER;
break;
case 'user':
$status = STUDENT;
break;
default:
$status = STUDENT;
}
// Language
switch($user_info['language']){
case 'FR' :
$language = 'french';
break;
case 'EN' :
$language = 'english';
break;
default :
$language = 'english';
break;
}
$u = array(
'firstname' => $user_info['firstname'],
'lastname' => $user_info['lastname'],
'status' => $status,
'admin' => $admin,
'email' => $user_info['email'],
'login' => $user_info['username'],
'language' => $language,
'password' => DEFAULT_PASSWORD,
'courses' => $user_info['courses'],
'profile_link' => $user_info['profile_link'],
'worldwide_bu' => $user_info['worlwide_bu'],
'manager' => $user_info['manager'],
'country_bu' => $user_info['country_bu'],
'extra' => array(
'position_title' => $user_info['position_title'],
'country' => $user_info['country'],
'job_family' => $user_info['job_family'],
'update_type' => 'external_logininfo')
);
return $u; //Please return false if user does not exist
}
/**
* update user info in database
**/
function external_update_user($u){
$updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['login'], null, $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'], $u['extra'], $u['language'],'');
if(!empty($user['courses'])){
$autoSubscribe = explode('|', $u['courses']);
foreach ($autoSubscribe as $code) {
if (CourseManager::course_exists($code)) {
CourseManager::subscribe_user($_user['user_id'], $code);
}
}
}
// Is User Admin ?
if ($user['admin']){
$is_platformAdmin = true;
Database::query("INSERT INTO admin values ('$chamilo_uid')");
}
}
//MAIN CODE
//$uData variable is set in local.inc.php
$user = UserManager::get_user_info_by_id($uData['user_id']);
$new_user = external_get_user_info($login);
$user['firstname'] = $new_user['firstname'];
$user['lastname'] = $new_user['lastname'];
$user['status'] = $new_user['status'];
$user['admin'] = $new_user['admin'];
$user['email'] = $new_user['email'];
$user['username'] = $new_user['login'];
$user['profile_link'] = $new_user['profile_link'];
$user['worldwide_bu'] = $new_user['worldwide_bu'];
$user['manager'] = $new_user['manager'];
$user['country_bu'] = $new_user['country_bu'];
$user['extra'] = $new_user['extra'];
if ($new_user !== false) {
$new_user['user_id'] = $uData['user_id'];
external_update_user($new_user);
}
?>

@ -1,141 +1,23 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a form for registering new users.
* @package chamilo.auth
*/
/**
* Code
*/
$language_file = array('registration', 'admin');
if (!empty($_POST['language'])) { //quick hack to adapt the registration form result to the selected registration language
$_GET['language'] = $_POST['language'];
}
require_once '../inc/global.inc.php';
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(LIBRARY_PATH).'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'legal.lib.php';
require_once api_get_path(LIBRARY_PATH).'custompages.lib.php';
// Load terms & conditions from the current lang
if (api_get_setting('allow_terms_conditions') == 'true') {
$get = array_keys($_GET);
if (isset($get)) {
if ($get[0] == 'legal'){
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview = LegalManager::get_last_condition($language);
if (!$term_preview) {
//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;
}
}
}
// Custom pages
if (api_get_setting('use_custom_pages') == 'true') {
if (isset($_POST['username'])) {
$values = array();
$values['firstname'] = $_POST['firstname'];
$values['lastname'] = $_POST['lastname'];
$values['status'] = $_POST['status'];
$values['email'] = $_POST['email'];
$values['username'] = $_POST['username'];
$values['pass1'] = $_POST['pass1'];
$values['official_code'] = '';
$values['language'] = $_POST['language'];
$values['phone'] = $_POST['phone'];
$picture_uri = null;
$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);
if ($user_id) {
/*
SESSION REGISTERING
*/
$_user['firstName'] = stripslashes($values['firstname']);
$_user['lastName'] = stripslashes($values['lastname']);
$_user['mail'] = $values['email'];
$_user['language'] = $values['language'];
$_user['user_id'] = $user_id;
$is_allowedCreateCourse = $values['status'] == 1;
api_session_register('_user');
api_session_register('is_allowedCreateCourse');
//stats
event_login();
// last user login date is now
$user_last_login_datetime = 0; // used as a unix timestamp it will correspond to : 1 1 1970
api_session_register('user_last_login_datetime');
/*
EMAIL NOTIFICATION
*/
if (strpos($values['email'], '@') !== false) {
// Let us predefine some variables. Be sure to change the from address!
$recipient_name = api_get_person_name($values['firstname'], $values['lastname']);
$email = $values['email'];
$emailfromaddr = api_get_setting('emailAdministrator');
$emailfromname = api_get_setting('siteName');
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg',null,$_user['language']).' '.api_get_setting('siteName');
// The body can be as long as you wish, and any combination of text and variables
$portal_url = $_configuration['root_web'];
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1 ){
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
$emailbody = get_lang('Dear',null,$_user['language']).' '.stripslashes(Security::remove_XSS($recipient_name)).",\n\n".get_lang('YouAreReg',null,$_user['language']).' '.api_get_setting('siteName').' '.get_lang('WithTheFollowingSettings',null,$_user['language'])."\n\n".get_lang('Username',null,$_user['language']).' : '.$values['username']."\n".get_lang('Pass',null,$_user['language']).' : '.stripslashes($values['pass1'])."\n\n".get_lang('Address',null,$_user['language']).' '.api_get_setting('siteName').' '.get_lang('Is',null,$_user['language']).' : '.$portal_url."\n\n".get_lang('Problem',null,$_user['language'])."\n\n".get_lang('Formula',null,$_user['language']).",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager',null,$_user['language']).' '.api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email',null,$_user['language']).' : '.api_get_setting('emailAdministrator');
// Here we are forming one large header line
// Every header must be followed by a \n except the last
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
@api_mail($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin);
}
CustomPages::displayPage('registration-feedback');
}
} else {
CustomPages::displayPage('registration');
}
}
$tool_name = get_lang('Registration',null,(!empty($_POST['language'])?$_POST['language']:$_user['language']));
Display :: display_header($tool_name);
$home = api_get_path(SYS_PATH).'home/';
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$url_info = api_get_access_url($access_url_id);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
$home_old = api_get_path(SYS_PATH).'home/';
$home = api_get_path(SYS_PATH).'home/'.$clean_url;
}
}
if (!empty($_SESSION['user_language_choice'])) {
$user_selected_language = $_SESSION['user_language_choice'];
} elseif (!empty($_SESSION['_user']['language'])) {
@ -143,33 +25,7 @@ if (!empty($_SESSION['user_language_choice'])) {
} else {
$user_selected_language = get_setting('platformLanguage');
}
if (file_exists($home.'register_top_'.$user_selected_language.'.html')) {
$home_top_temp = @(string)file_get_contents($home.'register_top_'.$user_selected_language.'.html');
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
if (!empty($open)) {
echo '<div style="border:1px solid #E1E1E1; padding:2px;">'.$open.'</div>';
}
}
// Forbidden to self-register
if (api_get_setting('allow_registration') == 'false') {
api_not_allowed();
}
//api_display_tool_title($tool_name);
if (api_get_setting('allow_registration') == 'approval') {
Display::display_normal_message(get_lang('YourAccountHasToBeApproved'));
}
//if openid was not found
if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') {
Display::display_warning_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));
}
$form = new FormValidator('registration');
$form->addElement('header', '', $tool_name);
if (api_get_setting('allow_terms_conditions') == 'true') {
$display_all_form = !isset($_SESSION['update_term_and_condition'][1]);
} else {
@ -317,7 +173,7 @@ if ($display_all_form) {
if ($get_lang_variables) {
$field_details[3] = get_lang($field_details[3]);
}
$form->addElement('select', 'extra_'.$field_details[1], $field_details[3], $options, array('class'=>'chzn-select', 'id'=>'extra_'.$field_details[1]));
$form->addElement('select', 'extra_'.$field_details[1], $field_details[3], $options, '');
break;
case USER_FIELD_TYPE_SELECT_MULTIPLE:
$options = array();
@ -383,6 +239,111 @@ if ($display_all_form) {
}
}
$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'];
} else {
$defaults['language'] = api_get_setting('platformLanguage');
}
if (!empty($_GET['username'])) {
$defaults['username'] = Security::remove_XSS($_GET['username']);
}
if (!empty($_GET['email'])) {
$defaults['email'] = Security::remove_XSS($_GET['email']);
}
if (!empty($_GET['phone'])) {
$defaults['phone'] = Security::remove_XSS($_GET['phone']);
}
if (api_get_setting('openid_authentication') == 'true' && !empty($_GET['openid'])) {
$defaults['openid'] = Security::remove_XSS($_GET['openid']);
}
$defaults['status'] = STUDENT;
if (is_array($extra_data)) {
$defaults = array_merge($defaults, $extra_data);
}
$form->setDefaults($defaults);
if (api_get_setting('use_custom_pages') != 'true') {
// Load terms & conditions from the current lang
if (api_get_setting('allow_terms_conditions') == 'true') {
$get = array_keys($_GET);
if (isset($get)) {
if ($get[0] == 'legal'){
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview = LegalManager::get_last_condition($language);
if (!$term_preview) {
//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',null,(!empty($_POST['language'])?$_POST['language']:$_user['language']));
Display :: display_header($tool_name);
echo Display::tag('h1', $tool_name);
$home = api_get_path(SYS_PATH).'home/';
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$url_info = api_get_access_url($access_url_id);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
$home_old = api_get_path(SYS_PATH).'home/';
$home = api_get_path(SYS_PATH).'home/'.$clean_url;
}
}
if (file_exists($home.'register_top_'.$user_selected_language.'.html')) {
$home_top_temp = @(string)file_get_contents($home.'register_top_'.$user_selected_language.'.html');
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
if (!empty($open)) {
echo '<div style="border:1px solid #E1E1E1; padding:2px;">'.$open.'</div>';
}
}
// Forbidden to self-register
if (api_get_setting('allow_registration') == 'false') {
api_not_allowed();
}
//api_display_tool_title($tool_name);
if (api_get_setting('allow_registration') == 'approval') {
Display::display_normal_message(get_lang('YourAccountHasToBeApproved'));
}
//if openid was not found
if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') {
Display::display_warning_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));
}
}
// Terms and conditions
if (api_get_setting('allow_terms_conditions') == 'true') {
@ -426,34 +387,6 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
}
}
$form->addElement('style_submit_button', 'submit', get_lang('RegisterUser'), 'class="a_button gray"');
if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') {
$defaults['language'] = $_SESSION['user_language_choice'];
} else {
$defaults['language'] = api_get_setting('platformLanguage');
}
if (!empty($_GET['username'])) {
$defaults['username'] = Security::remove_XSS($_GET['username']);
}
if (!empty($_GET['email'])) {
$defaults['email'] = Security::remove_XSS($_GET['email']);
}
if (!empty($_GET['phone'])) {
$defaults['phone'] = Security::remove_XSS($_GET['phone']);
}
if (api_get_setting('openid_authentication') == 'true' && !empty($_GET['openid'])) {
$defaults['openid'] = Security::remove_XSS($_GET['openid']);
}
$defaults['status'] = STUDENT;
if (is_array($extra_data)) {
$defaults = array_merge($defaults, $extra_data);
}
$form->setDefaults($defaults);
if ($form->validate()) {
/*
@ -582,7 +515,10 @@ if ($form->validate()) {
}
// 3. exit the page
unset($user_id);
Display :: display_footer();
if (api_get_setting('use_custom_pages') != 'true') {
Display :: display_footer();
}
exit;
}
@ -637,15 +573,15 @@ if ($form->validate()) {
}
}
echo '<p>'.get_lang('Dear',null,$_user['language']).' '.stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'.get_lang('PersonalSettings',null,$_user['language']).".</p>\n";
$display_text = '<p>'.get_lang('Dear',null,$_user['language']).' '.stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'.get_lang('PersonalSettings',null,$_user['language']).".</p>\n";
if (!empty ($values['email'])) {
echo '<p>'.get_lang('MailHasBeenSent',null,$_user['language']).'.</p>';
$display_text.= '<p>'.get_lang('MailHasBeenSent',null,$_user['language']).'.</p>';
}
$button_text = '';
if ($is_allowedCreateCourse) {
echo '<p>', get_lang('NowGoCreateYourCourse',null,$_user['language']), ".</p>\n";
$display_text .= '<p>'. get_lang('NowGoCreateYourCourse',null,$_user['language']). ".</p>\n";
$action_url = '../create_course/add_course.php';
$button_text = api_get_setting('course_validation') == 'true'
? get_lang('CreateCourseRequest', null, $_user['language'])
@ -655,15 +591,36 @@ if ($form->validate()) {
$action_url = 'courses.php?action=subscribe';
else
$action_url = api_get_path(WEB_PATH).'user_portal.php';
echo '<p>', get_lang('NowGoChooseYourCourses',null,$_user['language']), ".</p>\n";
$display_text.='<p>'. get_lang('NowGoChooseYourCourses',null,$_user['language']). ".</p>\n";
$button_text = get_lang('Next',null,$_user['language']);
}
// ?uidReset=true&uidReq=$_user['user_id']
echo '<form action="', $action_url, '" method="post">', "\n", '<button type="submit" class="next" name="next" value="', get_lang('Next',null,$_user['language']), '" validationmsg=" ', get_lang('Next',null,$_user['language']), ' ">', $button_text, '</button>', "\n", '</form><br />', "\n";
$display_text .= '<form action="'. $action_url. '" method="post">'. "\n". '<button type="submit" class="next" name="next" value="'. get_lang('Next',null,$_user['language']). '" validationmsg=" '. get_lang('Next',null,$_user['language']). ' ">'. $button_text. '</button>'. "\n". '</form><br />'. "\n";
if (api_get_setting('use_custom_pages') == 'true') {
CustomPages::displayPage('registration-feedback', array('info' => $display_text));
}
echo $display_text;
} else {
// Custom pages
if (api_get_setting('use_custom_pages') == 'true') {
CustomPages::displayPage('registration', array('form' => $form));
} else {
$form->display();
}
}
?>
<br />
<?php
if (!isset($_POST['username'])) {
/*
<div class="actions">
<a href="<?php echo api_get_path(WEB_PATH); ?>" class="fake_button_back" ><?php echo get_lang('Back'); ?></a>
</div>
*/
?>
<?php
}
Display :: display_footer();
Display :: display_footer();

@ -18,7 +18,7 @@
* Code
*/
// name of the language file that needs to be included
$language_file = 'registration';
$language_file = array('registration', 'index');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'login.lib.php';
@ -30,49 +30,58 @@ require_once api_get_path(LIBRARY_PATH).'custompages.lib.php';
// already be some display output.
global $_configuration;
if (api_get_setting('use_custom_pages') == 'true') {
if (isset ($_POST['user']) && isset ($_POST['email'])) {
$user = $_POST['user'];
$email = $_POST['email'];
$condition = '';
if (!empty($email)) {
$condition = " AND LOWER(email) = '".Database::escape_string($email)."' ";
}
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$query = " SELECT user_id AS uid, lastname AS lastName, firstname AS firstName,
username AS loginName, password, email, status AS status,
official_code, phone, picture_uri, creator_id
FROM ".$tbl_user."
WHERE ( username = '".Database::escape_string($user)."' $condition ) ";
$result = Database::query($query);
$num_rows = Database::num_rows($result);
if ($result && $num_rows > 0) {
if ($num_rows > 1) {
$by_username = false; // more than one user
while ($data = Database::fetch_array($result)) {
$user[] = $data;
}
} else {
$by_username = true; // single user (valid user + email)
$user = Database::fetch_array($result);
}
//Reset Password when user goes to the link
if($_GET['reset'] && $_GET['id']){
$mesg = Login::reset_password($_GET["reset"], $_GET["id"], true);
CustomPages::displayPage('index-unlogged', array('info' => $mesg));
}
//Check email/username and do the right thing
if (isset ($_POST['user']) && isset ($_POST['email'])) {
$user = $_POST['user'];
$email = $_POST['email'];
$condition = '';
if (!empty($email)) {
$condition = " AND LOWER(email) = '".Database::escape_string($email)."' ";
}
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$query = " SELECT user_id AS uid, lastname AS lastName, firstname AS firstName,
username AS loginName, password, email, status AS status,
official_code, phone, picture_uri, creator_id
FROM ".$tbl_user."
WHERE ( username = '".Database::escape_string($user)."' $condition ) ";
$result = Database::query($query);
$num_rows = Database::num_rows($result);
if ($result && $num_rows > 0) {
if ($num_rows > 1) {
$by_username = false; // more than one user
while ($data = Database::fetch_array($result)) {
$user[] = $data;
}
} else {
$by_username = true; // single user (valid user + email)
$user = Database::fetch_array($result);
}
if ($_configuration['password_encryption'] != 'none') {
Login::handle_encrypted_password($user, $by_username);
} else {
Login::send_password_to_user($user, $by_username);
}
} else {
Display::display_error_message(get_lang('NoUserAccountWithThisEmailAddress'));
}
$msg = Login::reset_password($_GET["reset"], $_GET["id"], true);
CustomPages::displayPage('lostpassword-feedback');
//Send email with secret link to user
Login::handle_encrypted_password($user, $by_username);
} else {
Login::send_password_to_user($user, $by_username);
}
} else {
CustomPages::displayPage('lostpassword',array('error' => get_lang('NoUserAccountWithThisEmailAddress')));
}
} else {
CustomPages::displayPage('lostpassword');
}
CustomPages::displayPage('lostpassword');
}
CustomPages::displayPage('index-unlogged', array('info' => get_lang('YourPasswordHasBeenEmailed')));
}
$tool_name = get_lang('LostPassword');
Display :: display_header($tool_name);

@ -278,7 +278,7 @@ if (is_profile_editable() && api_get_setting('profile', 'password') == 'true') {
// user must enter identical password twice so we can prevent some user errors
$form->addRule(array('password1', 'password2'), get_lang('PassTwo'), 'compare');
if (CHECK_PASS_EASY_TO_FIND) {
$form->addRule('password1', get_lang('PassTooEasy').': '.api_generate_password(), 'callback', 'api_check_password');
$form->addRule('password1', get_lang('CurrentPasswordEmptyOrIncorrect'), 'callback', 'api_check_password');
}
}
@ -735,10 +735,11 @@ if ($form->validate()) {
if (!empty($changeemail) && !isset($password) && in_array('email', $available_values_to_modify)) {
$sql .= " email = '".Database::escape_string($changeemail)."'";
} elseif (isset($password) && isset($changeemail) && in_array('email', $available_values_to_modify) && in_array('password', $available_values_to_modify)) {
$sql .= " email = '".Database::escape_string($changeemail)."',";
$password = api_get_encrypted_password($password);
$sql .= " password = '".Database::escape_string($password)."'";
} elseif (isset($password) && !isset($changeemail) && in_array('password', $available_values_to_modify)) {
} elseif (isset($password) && in_array('password', $available_values_to_modify)) {
$password = api_get_encrypted_password($password);
$sql .= " password = '".Database::escape_string($password)."'";
} else {
@ -770,9 +771,12 @@ if ($form->validate()) {
}
// re-init the system to take new settings into account
$uidReset = true;
include api_get_path(INCLUDE_PATH).'local.inc.php';
exit;
$_SESSION['_user']['uidReset'] = true;
$_SESSION['noredirection'] = true;
$_SESSION['profile_update'] = 'success';
$url = api_get_self()."?{$_SERVER['QUERY_STRING']}".($filtered_extension && strpos($_SERVER['QUERY_STRING'], '&fe=1') === false ? '&fe=1' : '');
header("Location: ".$url);
exit;
}
@ -834,7 +838,7 @@ if (!empty($msg_is_not_password)){
$image_syspath = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system', false, true);
$image_syspath['dir'].$image_syspath['file'];
$image_size = api_getimagesize($image_syspath['dir'].$image_syspath['file']);
//$image_size = api_getimagesize($image_syspath['dir'].$image_syspath['file']);
//Web path
$image_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', false, true);

@ -71,7 +71,7 @@ if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
$content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
<div class="normal-message" id="id_normal_message" style="display:none">';
$content .= '<img src="'.$server_protocol.$current_host.'/'.$path_work.'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
$content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
$content .= get_lang('PleaseStandBy');
$content .= '</div>
@ -131,4 +131,4 @@ if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
$content .= CourseHome::show_tools_category($my_list);
$content .= '</div>';
}
}
}

@ -69,7 +69,7 @@ if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
$content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:5px;">
<div class="normal-message" id="id_normal_message" style="display:none">';
$content .= '<img src="'.$server_protocol.$current_host.'/'.$path_work.'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
$content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
$content .= get_lang('PleaseStandBy');
$content .= '</div>
@ -145,4 +145,4 @@ $content .= '</div>';
$content .= '</div>';
}
}
$content .= '</div>';
$content .= '</div>';

@ -0,0 +1,102 @@
<?php
// By Arnaud Ligot <arnaud@cblue.be>
// Based on work done for old videoconference application
// params:
// action=list cidReq=course_Code cwd=folder result: json output
// I have about 30 minutes to write this peace of code so if somebody has more time, feel free to rewrite it...
/* See license terms in /license.txt */
/* FIX for IE cache when using https */
session_cache_limiter("none");
/*==== DEBUG ====*/
$debug=0;
if ($debug>0)
{
// dump the request
$v = array_keys(get_defined_vars());
error_log(var_export($v, true),3, '/tmp/log');
foreach (array_keys(get_defined_vars()) as $k) {
if ($k == 'GLOBALS')
continue;
error_log($k, 3, '/tmp/log');
error_log(var_export($$k, true), 3, '/tmp/log');
}
}
/*==== INCLUDE ====*/
require_once '../inc/global.inc.php';
api_block_anonymous_users();
require_once (api_get_path(LIBRARY_PATH)."course.lib.php");
require_once (api_get_path(LIBRARY_PATH)."document.lib.php");
require_once ("../newscorm/learnpath.class.php");
/*==== Variables initialisation ====*/
$action = $_REQUEST["action"]; //safe as only used in if()'s
$seek = array('/','%2F','..');
$destroy = array('','','');
$cidReq = str_replace($seek,$destroy,$_REQUEST["cidReq"]);
$cidReq = Security::remove_XSS($cidReq);
$user_id = api_get_user_id();
$coursePath = api_get_path(SYS_COURSE_PATH).$cidReq.'/document';
$_course = CourseManager::get_course_information($cidReq);
if ($_course == null) die ("problem when fetching course information");
// stupid variable initialisation for old version of DocumentManager functions.
$_course['path'] = $_course['directory'];
$_course['dbName'] = $_course['db_name'];
$is_manager = (CourseManager::get_user_in_course_status($user_id, $cidReq) == COURSEMANAGER);
if ($debug>0) error_log($coursePath, 0);
// FIXME: check security around $_REQUEST["cwd"]
$cwd = $_REQUEST["cwd"];
// treat /..
$nParent = 0; // the number of /.. into the url
while (substr($cwd, -3, 3) == "/..")
{
// go to parent directory
$cwd= substr($cwd, 0, -3);
if (strlen($cwd) == 0) $cwd="/";
$nParent++;
}
for (;$nParent >0; $nParent--){
$cwd = (strrpos($cwd,'/')>-1 ? substr($cwd, 0, strrpos($cwd,'/')) : $cwd);
}
if (strlen($cwd) == 0) $cwd="/";
if (Security::check_abs_path($cwd,api_get_path(SYS_PATH)))
die();
if ($action == "list")
{
/*==== List files ====*/
if ($debug>0) error_log("sending file list",0);
// get files list
$files = DocumentManager::get_all_document_data($_course, $cwd, 0, NULL, false);
// adding download link to files
foreach($files as $k=>$f)
if ($f['filetype'] == 'file')
// $files[$k]['download'] = api_get_path(WEB_CODE_PATH)."/document/document.php?cidReq=$cidReq&action=download&id=".urlencode($f['path']);
$files[$k]['download'] = api_get_path(WEB_COURSE_PATH).$cidReq."/document".$f['path'];
print json_encode($files);
exit;
}
?>

@ -306,4 +306,4 @@ if ($nav_info ['name'] == 'Internet Explorer') {
echo Display::tabs($headers, array($multiple_form, $simple_form),'tabs');
}
Display::display_footer();
Display::display_footer();

@ -7,7 +7,7 @@ require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
class CustomPages {
public static function displayPage($page_name) {
public static function displayPage($page_name, $content=array()) {
$pages_dir = api_get_path(SYS_PATH).'custompages/';
$file_name = $pages_dir.$page_name.'.php';
if (file_exists($file_name)) {

@ -320,11 +320,9 @@ define('TABLE_MAIN_STORED_VALUES_STACK', 'stored_values_stack');
//Event tables
/*
define('TABLE_MAIN_EVENT_TYPE', 'event_type');
define('TABLE_MAIN_EVENT_TYPE_MESSAGE', 'event_type_message');
define('TABLE_MAIN_EVENT_TYPE_MESSAGE', 'event_type_email_template');
define('TABLE_MAIN_EVENT_TYPE_REL_USER', 'user_rel_event_type');
*/
define('TABLE_MAIN_SKILL', 'skill');
define('TABLE_MAIN_SKILL_REL_SKILL', 'skill_rel_skill');
@ -334,4 +332,4 @@ define('TABLE_MAIN_SKILL_REL_USER', 'skill_rel_user');
define('TABLE_MAIN_SKILL_PROFILE', 'skill_profile');
define('TABLE_MAIN_SKILL_REL_PROFILE', 'skill_rel_profile');
define('TABLE_MAIN_CHAT', 'chat');
define('TABLE_MAIN_CHAT', 'chat');

@ -582,7 +582,7 @@ function event_system($event_type, $event_value_type, $event_value, $datetime =
'$event_value')";
$res = Database::query($sql);
//Sending notofications to users
//Sending notifications to users
$send_event_setting = api_get_setting('activate_send_event_by_mail');
if (!empty($send_event_setting) && $send_event_setting == 'true') {
global $language_file;

@ -78,9 +78,9 @@ newscorm/scorm_api.php
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(content_object) {
$("div#"+div_content_id).html("<img src="+my_protocol+"//"+location.host+work_path+"/main/inc/lib/javascript/indicator.gif />"); },
$("div#"+div_content_id).html("<img src='../../../../../../../main/inc/lib/javascript/indicator.gif' />"); },
type: "POST",
url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
url: "../../../../../../../main/glossary/glossary_ajax_request.php",
data: "glossary_id="+my_glossary_id,
success: function(datas) {
$("div#"+div_content_id).html(datas);
@ -101,4 +101,4 @@ newscorm/scorm_api.php
});
/*
});
});*/
});*/

@ -25,10 +25,10 @@ newscorm/scorm_api.php
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(result) {
$("div#"+div_content_id).html("<img src="+my_protocol+"//"+location.host+work_path+"/main/inc/lib/javascript/indicator.gif />");
$("div#"+div_content_id).html("<img src='../../../../../../../main/inc/lib/javascript/indicator.gif' />"); },
},
type: "POST",
url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
url: "../../../../../../../main/glossary/glossary_ajax_request.php",
data: "glossary_name="+is_glossary_name,
success: function(data) {
$("div#"+div_content_id).html(data);
@ -42,4 +42,4 @@ newscorm/scorm_api.php
});
// });
//});
//});

@ -61,10 +61,9 @@ $(document).ready(function() {
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(content_object) {
$("div#"+div_content_id).html("<img src="+my_protocol+"//"+location.host+work_path+"/main/inc/lib/javascript/indicator.gif />");
},
$("div#"+div_content_id).html("<img src='../../../../main/inc/lib/javascript/indicator.gif' />"); },
type: "POST",
url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
url: "../../../../main/glossary/glossary_ajax_request.php",
data: "glossary_id="+my_glossary_id,
success: function(datas) {
$("div#"+div_content_id).html(datas);

@ -107,7 +107,10 @@ class Login
$email_admin = api_get_setting('emailAdministrator');
if (@api_mail('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed'));
if (api_get_setting('use_custom_pages') == 'true')
return get_lang('your_password_has_been_reset');
else
Display::display_confirmation_message(get_lang('your_password_has_been_reset'));
} else {
$message = get_lang('SystemUnableToSendEmailContact').' '.Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), get_lang('PlatformAdmin')).".</p>";
}
@ -121,35 +124,41 @@ class Login
*
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
public static function handle_encrypted_password($user, $by_username = false) {
global $_configuration;
$email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
if ($by_username) { // Show only for lost password
$user_account_list = self::get_user_account_list($user, true, $by_username); // BODY
$email_to = $user['email'];
} else {
$user_account_list = self::get_user_account_list($user, true); // BODY
$email_to = $user[0]['email'];
}
$secret_word = self::get_secret_word($email_to);
$email_body = get_lang('DearUser')." :\n".get_lang('password_request')."\n";
$email_body .= $user_account_list."\n-----------------------------------------------\n\n";
$email_body .= get_lang('PasswordEncryptedForSecurity');
//$email_body .= "\n\n".get_lang('Formula').",\n".get_lang('PlataformAdmin');
$email_body .= "\n\n".get_lang('Formula').",\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n".get_lang('PlataformAdmin')." - ".api_get_setting('siteName');
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
if (@api_mail('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed'));
} else {
$message = get_lang('SystemUnableToSendEmailContact').' '.Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), get_lang('PlatformAdmin')).".</p>";
Display::display_error_message($message, false);
}
}
public static function handle_encrypted_password($user, $by_username = false) {
global $_configuration;
$email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
if ($by_username) { // Show only for lost password
$user_account_list = self::get_user_account_list($user, true, $by_username); // BODY
$email_to = $user['email'];
} else {
$user_account_list = self::get_user_account_list($user, true); // BODY
$email_to = $user[0]['email'];
}
$secret_word = self::get_secret_word($email_to);
$email_body = get_lang('DearUser')." :\n".get_lang('password_request')."\n";
$email_body .= $user_account_list."\n-----------------------------------------------\n\n";
$email_body .= get_lang('PasswordEncryptedForSecurity');
//$email_body .= "\n\n".get_lang('Formula').",\n".get_lang('PlataformAdmin');
$email_body .= "\n\n".get_lang('Formula').",\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n".get_lang('PlataformAdmin')." - ".api_get_setting('siteName');
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
if (@api_mail('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
if (api_get_setting('use_custom_pages') == 'true')
return get_lang('YourPasswordHasBeenEmailed');
else
Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed'));
} else {
$message = get_lang('SystemUnableToSendEmailContact').' '.Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), get_lang('PlatformAdmin')).".</p>";
if (api_get_setting('use_custom_pages') == 'true')
return $message;
else
Display::display_error_message($message, false);
}
}
/**
* Gets the secret word

@ -11,7 +11,7 @@ Class LoginRedirection {
global $param;
$param = isset($param) ? $param : '';
$redirect_url = '';
/*
//If session request url is setted, we go there
if (!empty($_SESSION['request_uri'])) {
$req = $_SESSION['request_uri'];
@ -19,6 +19,7 @@ Class LoginRedirection {
header('location: '.$req);
exit();
}
*/
if ( api_is_student() && !api_get_setting('student_page_after_login') == '' ){
$redirect_url = html_entity_decode(api_get_setting('student_page_after_login'));

@ -2553,8 +2553,7 @@ function api_not_allowed($print_headers = false) {
$course = api_get_course_id();
global $this_section;
if (api_get_setting('use_custom_pages') == 'true') {
if (api_get_setting('use_custom_pages') == 'true' && !isset($_SESSION['_user']['user_id'])) {
$_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
require_once api_get_path(LIBRARY_PATH).'custompages.lib.php';
CustomPages::displayPage('index-unlogged');

@ -184,6 +184,11 @@ $login = isset($_POST["login"]) ? $_POST["login"] : '';
if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
// uid is in session => login already done, continue with this value
$_user['user_id'] = $_SESSION['_user']['user_id'];
//Check if we have to reset user data
//This param can be used to reload user data if user has been logged by external script
if (isset($_SESSION['_user']['uidReset']) && $_SESSION['_user']['uidReset']){
$uidReset=true;
}
} else {
if (isset($_user['user_id'])) {
unset($_user['user_id']);
@ -608,12 +613,13 @@ if ($gidReq && $gidReq != $gid) {
/* USER INIT */
if (isset($uidReset) && $uidReset) { // session data refresh requested
unset($_SESSION['_user']['uidReset']);
$is_platformAdmin = false;
$is_allowedCreateCourse = false;
if (isset($uidReset) && $uidReset) { // session data refresh requested
$is_platformAdmin = false;
$is_allowedCreateCourse = false;
if (isset($_user['user_id']) && $_user['user_id']) {
if (isset($_user['user_id']) && $_user['user_id'] && ! api_is_anonymous()) // a uid is given (log in succeeded)
// a uid is given (log in succeeded)
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
@ -656,10 +662,13 @@ if (isset($uidReset) && $uidReset) { // session data refresh requested
api_session_register('is_platformAdmin');
api_session_register('is_allowedCreateCourse');
// If request_uri is settd we have to go further to have course permissions
// If request_uri is setted we have to go further to have course permissions
if (empty($_SESSION['request_uri']) || !isset($_SESSION['request_uri'])) {
require_once api_get_path(LIBRARY_PATH).'loginredirection.lib.php';
LoginRedirection::redirect();
if( $_SESSION['noredirection'] ) {//If we just want to reser info without redirecting user
unset($_SESSION['noredirection']);
} else {
require_once api_get_path(LIBRARY_PATH).'loginredirection.lib.php';
LoginRedirection::redirect();
}
} else {
@ -1129,8 +1138,9 @@ if (isset($_cid)) {
$sql="UPDATE $tbl_course SET last_visit= '$time' WHERE code='$_cid'";
Database::query($sql);
}
if (!empty($_SESSION['request_uri'])){
if (isset($_SESSION['request_uri']) && !empty($_SESSION['request_uri'])){
$req= $_SESSION['request_uri'];
unset($_SESSION['request_uri']);
header('Location: '.$req);
exit;
}

@ -87,10 +87,15 @@ $_configuration['db_admin_path'] = '';
// $extAuthSource["ldap"]["login"] = $_configuration['root_sys'].$_configuration['code_append']."auth/ldap/login.php";
// $extAuthSource["ldap"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/ldap/newUser.php";
//
// To fetch external login information, uncomment thoss 2 lines and modify files auth/external_logininfo/newUser.php and auth/external_logininfo/updateUser.php files
// $extAuthSource["external_logininfo"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_logininfo/newUser.php";
// $extAuthSource["external_logininfo"]["updateUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_logininfo/updateUser.php";
// To fetch external login information, uncomment those 2 lines and modify files auth/external_login/newUser.php and auth/external_login/updateUser.php files
// $extAuthSource["external_login"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/newUser.php";
// $extAuthSource["external_login"]["updateUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/updateUser.php";
//
//NEW LDAP IMPLEMENTATION BASED ON external_logininfo
// Please edit main/auth/external_login/ldap.conf.php
//$extAuthSource["extldap"]["login"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/login.ldap.php";
//$extAuthSource["extldap"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_ldap/newUser.ldap.php";
//
/**
*
* Hosting settings - Allows you to set limits to the Chamilo portal when

@ -857,10 +857,13 @@ VALUES
('allow_users_to_change_email_with_no_password', NULL, 'radio', 'User', 'false', 'AllowUsersToChangeEmailWithNoPasswordTitle', 'AllowUsersToChangeEmailWithNoPasswordComment', NULL, NULL, 0),
('show_admin_toolbar', NULL, 'radio', 'Platform', 'show_to_admin', 'ShowAdminToolbarTitle', 'ShowAdminToolbarComment', NULL, NULL, 1),
('allow_global_chat', NULL, 'radio', 'Platform', 'true', 'AllowGlobalChatTitle', 'AllowGlobalChatComment', NULL, NULL, 1),
('languagePriority1', NULL, 'radio', 'Languages', 'course_lang', 'LanguagePriority1Title', 'LanguagePriority1Comment', NULL, NULL, 0),
('languagePriority2', NULL, 'radio', 'Languages','user_profil_lang', 'LanguagePriority2Title', 'LanguagePriority2Comment', NULL, NULL, 0),
('languagePriority3', NULL, 'radio', 'Languages','user_selected_lang', 'LanguagePriority3Title', 'LanguagePriority3Comment', NULL, NULL, 0),
('languagePriority4', NULL, 'radio', 'Languages', 'platform_lang','LanguagePriority4Title', 'LanguagePriority4Comment', NULL, NULL, 0),
('chamilo_database_version',NULL,'textfield',NULL, '1.9.0.16427','DokeosDatabaseVersion','', NULL, NULL, 0);
/*
('use_custom_pages',NULL,'radio','Platform','false','UseCustomPages','useCustomPagesComment','platform',NULL,0),
('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1),
('show_tabs', 'custom_tab_2', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom2', 1),
('show_tabs', 'custom_tab_3', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom3', 1),
@ -870,10 +873,8 @@ VALUES
('custom_tab_2_url', NULL, 'textfield', 'Platform', '', 'CustomTab2URLTitle', 'CustomTab2URLComment', NULL, NULL, 0),
('custom_tab_3_name', NULL, 'textfield', 'Platform', '', 'CustomTab3NameTitle', 'CustomTab3NameComment', NULL, NULL, 0),
('custom_tab_3_url', NULL, 'textfield', 'Platform', '', 'CustomTab3URLTitle', 'CustomTab3URLComment', NULL, NULL, 0),
('languagePriority1', NULL, 'radio', 'Languages', 'course_lang', 'LanguagePriority1Title', 'LanguagePriority1Comment', NULL, NULL, 0),
('languagePriority2', NULL, 'radio', 'Languages','user_profil_lang', 'LanguagePriority2Title', 'LanguagePriority2Comment', NULL, NULL, 0),
('languagePriority3', NULL, 'radio', 'Languages','user_selected_lang', 'LanguagePriority3Title', 'LanguagePriority3Comment', NULL, NULL, 0),
('languagePriority4', NULL, 'radio', 'Languages', 'platform_lang','LanguagePriority4Title', 'LanguagePriority4Comment', NULL, NULL, 0),
('activate_send_event_by_mail', NULL, 'radio', 'Platform', 'false', 'ActivateSendEventByMailTitle', 'ActivateSendEventByMailComment', NULL, NULL, 0),
('use_custom_pages',NULL,'radio','Platform','false','UseCustomPages','useCustomPagesComment','platform',NULL,0),
('activate_send_event_by_mail', NULL, 'radio', 'Platform', 'false', 'ActivateSendEventByMailTitle', 'ActivateSendEventByMailComment', NULL, NULL, 0),
*/
UNLOCK TABLES;
@ -1170,10 +1171,6 @@ VALUES
('show_admin_toolbar', 'show_to_admin', 'ShowToAdminsOnly'),
('show_admin_toolbar', 'show_to_admin_and_teachers', 'ShowToAdminsAndTeachers'),
('show_admin_toolbar', 'show_to_all', 'ShowToAllUsers'),
('allow_global_chat', 'true', 'Yes'),
('allow_global_chat', 'false', 'No');
/*
('use_custom_pages','true','Yes'),
('use_custom_pages','false','No'),
('languagePriority1','platform_lang','PlatformLanguage'),
@ -1192,13 +1189,18 @@ VALUES
('languagePriority4','user_profil_lang','UserLanguage'),
('languagePriority4','user_selected_lang','UserSelectedLanguage'),
('languagePriority4','course_lang','CourseLanguage'),
('allow_global_chat', 'true', 'Yes'),
('allow_global_chat', 'false', 'No');
UNLOCK TABLES;
/*
('activate_send_event_by_mail', 'true', 'Yes'),
('activate_send_event_by_mail', 'false', 'No'),
*/
UNLOCK TABLES;
/*!40000 ALTER TABLE settings_options ENABLE KEYS */;
--
-- Table structure for table sys_announcement
--
@ -2818,6 +2820,92 @@ CREATE TABLE skill_rel_profile (
PRIMARY KEY (id)
);
-- Custom reports
CREATE TABLE `reports_keys` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`course_id` integer DEFAULT NULL,
`tool_id` int(11) DEFAULT NULL,
`child_id` int(11) DEFAULT NULL,
`child_name` varchar(64) DEFAULT NULL,
`subchild_id` int(11) DEFAULT NULL,
`subchild_name` varchar(64) DEFAULT NULL,
`subsubchild_id` int(11) DEFAULT NULL,
`subsubchild_name` varchar(64) DEFAULT NULL,
`link` varchar(256) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `course_id` (`course_id`),
KEY `course_id_2` (`course_id`,`tool_id`,`child_id`,`subchild_id`,`subsubchild_id`));
CREATE TABLE `reports_values` (
`key_id` int(11) NOT NULL,
`uid` int(11) DEFAULT NULL,
`session_id` int(11) DEFAULT NULL,
`attempt` int(11) DEFAULT NULL,
`score` decimal(5,3) DEFAULT NULL,
`progress` int(11) DEFAULT NULL,
`time` int(11) DEFAULT NULL,
KEY `uid` (`uid`),
PRIMARY KEY (`key_id`,`uid`,`session_id`, `attempt`));
--
-- Table structure for event email sending
--
CREATE TABLE `event_type` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`name_lang_var` varchar(40) NOT NULL,
`desc_lang_var` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `event_type_email_template` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`event_type_id` int(11) NOT NULL,
`language_id` int(11) NOT NULL,
`message` varchar(200) NOT NULL,
`subject` varchar(60) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `user_rel_event_type` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`event_type_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `event_type` VALUES (1, 'course_deleted','courseDeletedTitle','courseDeletedComment'),(2,'course_created','courseCreatedTitle','courseCreatedComment'),(3,'user_deleted','userDeletedTitle','userDeletedComment'),(4,'user_created','userCreatedTitle','userCreatedComment'), (5, 'session_created','sessionCreatedTitle','sessionCreatedComment'), (6,'session_deleted','sessionDeletedTitle','sessionDeletedComment'), (7,'session_category_created','sessionCategoryCreatedTitle','sessionCategoryCreatedComment'),(8,'session_category_deleted','sessionCategoryDeletedTitle','sessionCategoryDeletedComment'),(9,'settings_changed','settingsChangedTitle','settingsChangedComment'),(10,'user_subscribed','userSubscribedTitle','userSubscribedComment'), (11,'user_unsubscribed','userUnsubscribedTitle','userUnsubscribedComment');
INSERT INTO `event_type_email_template` (`id`,`event_type_id`, `language_id`, `message`,`subject`) VALUES (1,4,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a é créé.\r\nEmail : %mail%\r\n\r\nBien à vous.',''),(2,1,10,'Delete formation',''),(3,2,10,'Create formation',''),(4,3,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a été supprimé.\r\n\r\nBien à vous.',''),(6,5,10,'Create session test',''),(7,6,10,'Delete session',''),(8,7,10,'Create category session',''),(9,8,10,'Delete category session',''),(10,9,10,'Change setting',''),(11,10,10,'Subscribe',''),(12,11,10,'Unsubscribe','');
--
-- Table structure for LP custom storage API
--
DROP TABLE IF EXISTS stored_value;
CREATE TABLE stored_values (
user_id INT NOT NULL,
sco_id INT NOT NULL,
course_id CHAR(40) NOT NULL,
sv_key CHAR(64) NOT NULL,
sv_value TEXT NOT NULL
);
ALTER TABLE stored_values ADD KEY (user_id, sco_id, course_id, sv_key);
ALTER TABLE stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key);
DROP TABLE IF EXISTS stored_value_stack;
CREATE TABLE stored_values_stack (
user_id INT NOT NULL,
sco_id INT NOT NULL,
stack_order INT NOT NULL,
course_id CHAR(40) NOT NULL,
sv_key CHAR(64) NOT NULL,
sv_value TEXT NOT NULL
);
ALTER TABLE stored_values_stack ADD KEY (user_id, sco_id, course_id, sv_key, stack_order);
ALTER TABLE stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv_key, stack_order);
-- Course ranking
@ -2862,4 +2950,4 @@ CREATE TABLE chat (
);
ALTER TABLE chat ADD INDEX idx_chat_to_user (to_user);
ALTER TABLE chat ADD INDEX idx_chat_from_user (from_user);
ALTER TABLE chat ADD INDEX idx_chat_from_user (from_user);

@ -48,8 +48,8 @@ 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_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_current (variable, type, category, selected_value, title, comment, scope) VALUES ('use_custom_pages','radio','Platform','false','UseCustomPages','UseCustomPagesComment', 'platform');
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');
--INSERT INTO settings_options (variable, value, display_text) VALUES ('use_custom_pages', 'true', 'Yes'), ('use_custom_pages', 'false', 'No');
-- Pages after login by role
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('student_page_after_login', NULL, 'textfield', 'Platform', '', 'StudentPageAfterLoginTitle', 'StudentPageAfterLoginComment', NULL, NULL, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('teacher_page_after_login', NULL, 'textfield', 'Platform', '', 'TeacherPageAfterLoginTitle', 'TeacherPageAfterLoginComment', NULL, NULL, 0);
@ -68,20 +68,20 @@ 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('custom_tab_2_url', NULL, 'textfield', 'Platform', '', 'CustomTab2URLTitle', 'CustomTab2URLComment', NULL, NULL, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('custom_tab_3_name', NULL, 'textfield', 'Platform', '', 'CustomTab3NameTitle', 'CustomTab3NameComment', NULL, NULL, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('custom_tab_3_url', NULL, 'textfield', 'Platform', '', 'CustomTab3URLTitle', 'CustomTab3URLComment', NULL, NULL, 0);
-- INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority1', NULL, 'radio', 'Languages', 'course_lang', 'LanguagePriority1Title', 'LanguagePriority1Comment', NULL, NULL, 0);
-- INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority2', NULL, 'radio', 'Languages', 'user_profil_lang', 'LanguagePriority2Title', 'LanguagePriority2Comment', NULL, NULL, 0);
-- INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority3', NULL, 'radio', 'Languages', 'user_selected_lang', 'LanguagePriority3Title', 'LanguagePriority3Comment', NULL, NULL, 0);
-- INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority4', NULL, 'radio', 'Languages', 'platform_lang', 'LanguagePriority4Title', 'LanguagePriority4Comment', NULL, NULL, 0);
-- INSERT INTO settings_options (variable, value, display_text) VALUES ('languagePriority1','platform_lang','PlatformLanguage'), ('languagePriority1','user_profil_lang','UserLanguage'), ('languagePriority1','user_selected_lang','UserSelectedLanguage'), ('languagePriority1','course_lang','CourseLanguage'), ('languagePriority2','platform_lang','PlatformLanguage'), ('languagePriority2','user_profil_lang','UserLanguage'), ('languagePriority2','user_selected_lang','UserSelectedLanguage'), ('languagePriority2','course_lang','CourseLanguage'), ('languagePriority3','platform_lang','PlatformLanguage'), ('languagePriority3','user_profil_lang','UserLanguage'), ('languagePriority3','user_selected_lang','UserSelectedLanguage'), ('languagePriority3','course_lang','CourseLanguage'), ('languagePriority4','platform_lang','PlatformLanguage'), ('languagePriority4','user_profil_lang','UserLanguage'), ('languagePriority4','user_selected_lang','UserSelectedLanguage'), ('languagePriority4','course_lang','CourseLanguage');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority1', NULL, 'radio', 'Languages', 'course_lang', 'LanguagePriority1Title', 'LanguagePriority1Comment', NULL, NULL, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority2', NULL, 'radio', 'Languages', 'user_profil_lang', 'LanguagePriority2Title', 'LanguagePriority2Comment', NULL, NULL, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority3', NULL, 'radio', 'Languages', 'user_selected_lang', 'LanguagePriority3Title', 'LanguagePriority3Comment', NULL, NULL, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority4', NULL, 'radio', 'Languages', 'platform_lang', 'LanguagePriority4Title', 'LanguagePriority4Comment', NULL, NULL, 0);
INSERT INTO settings_options (variable, value, display_text) VALUES ('languagePriority1','platform_lang','PlatformLanguage'), ('languagePriority1','user_profil_lang','UserLanguage'), ('languagePriority1','user_selected_lang','UserSelectedLanguage'), ('languagePriority1','course_lang','CourseLanguage'), ('languagePriority2','platform_lang','PlatformLanguage'), ('languagePriority2','user_profil_lang','UserLanguage'), ('languagePriority2','user_selected_lang','UserSelectedLanguage'), ('languagePriority2','course_lang','CourseLanguage'), ('languagePriority3','platform_lang','PlatformLanguage'), ('languagePriority3','user_profil_lang','UserLanguage'), ('languagePriority3','user_selected_lang','UserSelectedLanguage'), ('languagePriority3','course_lang','CourseLanguage'), ('languagePriority4','platform_lang','PlatformLanguage'), ('languagePriority4','user_profil_lang','UserLanguage'), ('languagePriority4','user_selected_lang','UserSelectedLanguage'), ('languagePriority4','course_lang','CourseLanguage');
-- INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('activate_send_event_by_mail', NULL, 'radio', 'Platform', 'false', 'ActivateSendEventByMailTitle', 'ActivateSendEventByMailComment', NULL, NULL, 0);
-- INSERT INTO settings_options (variable, value, display_text) VALUES ('activate_send_event_by_mail', 'true', 'Yes'),('activate_send_event_by_mail', 'false', 'No');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('scorm_cumulative_session_time', NULL, 'radio', 'Course', 'true', 'ScormCumulativeSessionTimeTitle', 'ScormCumulativeSessionTimeComment', NULL, NULL, 0);
INSERT INTO settings_options (variable, value, display_text) VALUES ('scorm_cumulative_session_time','true','Yes'), ('scorm_cumulative_session_time','false','No');
-- CREATE TABLE event_type ( id int unsigned NOT NULL AUTO_INCREMENT, name varchar(50) NOT NULL, name_lang_var varchar(40) NOT NULL, desc_lang_var varchar(50) NOT NULL, PRIMARY KEY (id));
-- CREATE TABLE event_type_message ( id int unsigned NOT NULL AUTO_INCREMENT, event_type_id int NOT NULL, language_id int NOT NULL, message varchar(200) NOT NULL, subject varchar(60) NOT NULL, PRIMARY KEY (id));
-- CREATE TABLE user_rel_event_type ( id int NOT NULL AUTO_INCREMENT, user_id int unsigned NOT NULL, event_type_id int unsigned NOT NULL, PRIMARY KEY (id));
-- INSERT INTO `event_type` VALUES (1, 'course_deleted','courseDeletedTitle','courseDeletedComment'),(2,'course_created','courseCreatedTitle','courseCreatedComment'),(3,'user_deleted','userDeletedTitle','userDeletedComment'),(4,'user_created','userCreatedTitle','userCreatedComment'), (5, 'session_created','sessionCreatedTitle','sessionCreatedComment'), (6,'session_deleted','sessionDeletedTitle','sessionDeletedComment'), (7,'session_category_created','sessionCategoryCreatedTitle','sessionCategoryCreatedComment'),(8,'session_category_deleted','sessionCategoryDeletedTitle','sessionCategoryDeletedComment'),(9,'settings_changed','settingsChangedTitle','settingsChangedComment'),(10,'user_subscribed','userSubscribedTitle','userSubscribedComment'), (11,'user_unsubscribed','userUnsubscribedTitle','userUnsubscribedComment');
-- INSERT INTO `event_type_message` (`id`,`event_type_id`, `language_id`, `message`,`subject`) VALUES (1,4,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a été créé.\r\nEmail : %mail%\r\n\r\nBien à vous.',''),(2,1,10,'Delete formation',''),(3,2,10,'Create formation',''),(4,3,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a été supprimé.\r\n\r\nBien à vous.',''),(6,5,10,'Create session test',''),(7,6,10,'Delete session',''),(8,7,10,'Create category session',''),(9,8,10,'Delete category session',''),(10,9,10,'Change setting',''),(11,10,10,'Subscribe',''),(12,11,10,'Unsubscribe','');
CREATE TABLE event_type ( id int unsigned NOT NULL AUTO_INCREMENT, name varchar(50) NOT NULL, name_lang_var varchar(40) NOT NULL, desc_lang_var varchar(50) NOT NULL, PRIMARY KEY (id));
CREATE TABLE event_type_email_template ( id int unsigned NOT NULL AUTO_INCREMENT, event_type_id int NOT NULL, language_id int NOT NULL, message varchar(200) NOT NULL, subject varchar(60) NOT NULL, PRIMARY KEY (id));
CREATE TABLE user_rel_event_type ( id int NOT NULL AUTO_INCREMENT, user_id int unsigned NOT NULL, event_type_id int unsigned NOT NULL, PRIMARY KEY (id));
INSERT INTO `event_type` VALUES (1, 'course_deleted','courseDeletedTitle','courseDeletedComment'),(2,'course_created','courseCreatedTitle','courseCreatedComment'),(3,'user_deleted','userDeletedTitle','userDeletedComment'),(4,'user_created','userCreatedTitle','userCreatedComment'), (5, 'session_created','sessionCreatedTitle','sessionCreatedComment'), (6,'session_deleted','sessionDeletedTitle','sessionDeletedComment'), (7,'session_category_created','sessionCategoryCreatedTitle','sessionCategoryCreatedComment'),(8,'session_category_deleted','sessionCategoryDeletedTitle','sessionCategoryDeletedComment'),(9,'settings_changed','settingsChangedTitle','settingsChangedComment'),(10,'user_subscribed','userSubscribedTitle','userSubscribedComment'), (11,'user_unsubscribed','userUnsubscribedTitle','userUnsubscribedComment');
INSERT INTO `event_type_email_template` (`id`,`event_type_id`, `language_id`, `message`,`subject`) VALUES (1,4,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a é créé.\r\nEmail : %mail%\r\n\r\nBien à vous.',''),(2,1,10,'Delete formation',''),(3,2,10,'Create formation',''),(4,3,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a été supprimé.\r\n\r\nBien à vous.',''),(6,5,10,'Create session test',''),(7,6,10,'Delete session',''),(8,7,10,'Create category session',''),(9,8,10,'Delete category session',''),(10,9,10,'Change setting',''),(11,10,10,'Subscribe',''),(12,11,10,'Unsubscribe','');
INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) values (1, 'already_logged_in','Already logged in',0,0);
INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) values (1, 'update_type','Update script type',0,0);
CREATE TABLE announcement_rel_group (group_id int NOT NULL, announcement_id int NOT NULL, PRIMARY KEY (group_id, announcement_id));

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,28 @@
// JS interface enabling scrom content to use main/document/remote.php easily
// CBlue SPRL, Arnaud Ligot <arnaud@cblue.be>
lms_documents_list = function(path) {
var result;
$.ajax({
async: false,
type: "POST",
datatype: "json",
url: "../document/remote.php",
data: {
action: "list",
cwd: path,
cidReq: chamilo_courseCode,
},
success: function(data) {
result = eval("("+data+")");
}
});
return result;
}
// Accessor object
function DOCUMENTAPIobject() {
this.list = lms_documents_list;
}
var DOCUMENTAPI = new DOCUMENTAPIobject();

@ -48,6 +48,51 @@ lms_storage_getValue_user = function(sv_key, sv_user) {
return result;
}
lms_storage_getPosition_user = function(sv_key, sv_user, sv_asc) {
var result;
$.ajax({
async: false,
type: "POST",
url: "storageapi.php",
data: {
action: "getposition",
svkey: sv_key,
svuser: sv_user,
svcourse: sv_course,
svsco: sv_sco,
svasc: sv_asc
},
success: function(data) {
result = data;
}
});
return result;
}
lms_storage_getLeaders_user = function(sv_key, sv_user, sv_asc, sv_length) {
var result;
$.ajax({
async: false,
type: "POST",
url: "storageapi.php",
data: {
action: "getleaders",
svkey: sv_key,
svuser: sv_user,
svcourse: sv_course,
svsco: sv_sco,
svasc: sv_asc,
svlength: sv_length
},
success: function(data) {
result = eval("("+data+")");
}
});
return result;
}
lms_storage_getAll_user = function(sv_user) {
var result;
$.ajax({
@ -61,7 +106,7 @@ lms_storage_getAll_user = function(sv_user) {
svsco: sv_sco
},
success: function(data) {
result = eval(data);
result = eval("("+data+")");
}
});
return result;
@ -162,7 +207,7 @@ lms_storage_stack_getAll_user = function(sv_key, sv_user) {
svsco: sv_sco
},
success: function(data) {
result = eval(data);
result = eval("("+data+")");
}
});
return result;
@ -178,7 +223,7 @@ lms_storage_getAllUsers = function() {
action: "usersgetall"
},
success: function(data) {
result = eval(data);
result = eval("("+data+")");
}
});
return result;
@ -192,6 +237,14 @@ lms_storage_getValue = function(sv_key) {
return lms_storage_getValue_user(sv_key, sv_user);
}
lms_storage_getPosition = function(sv_key, sv_asc) {
return lms_storage_getPosition_user(sv_key, sv_user, sv_asc);
}
lms_storage_getLeaders = function(sv_key, sv_asc, sv_length) {
return lms_storage_getLeaders_user(sv_key, sv_user, sv_asc, sv_length);
}
lms_storage_getAll = function() {
return lms_storage_getAll_user(sv_user);
}
@ -226,6 +279,10 @@ function STORAGEAPIobject() {
this.getValue_user = lms_storage_getValue_user;
this.getAll = lms_storage_getAll;
this.getAll_user = lms_storage_getAll_user;
this.getPosition_user = lms_storage_getPosition_user;
this.getPosition = lms_storage_getPosition;
this.getLeaders_user = lms_storage_getLeaders_user;
this.getLeaders = lms_storage_getLeaders;
this.stack_push = lms_storage_stack_push;
this.stack_push_user = lms_storage_stack_push_user;
this.stack_pop = lms_storage_stack_pop;

@ -1154,7 +1154,7 @@ class learnpathItem {
* @return bool True if the item is done ('completed','passed','succeeded'), false otherwise
*/
function is_done(){
if ($this->status_is(array('completed', 'passed', 'succeeded'))) {
if ($this->status_is(array('completed', 'passed', 'succeeded', 'failed'))) {
if (self::debug > 2) { error_log('New LP - In learnpath::is_done() - Item '.$this->get_id().' is complete', 0); }
return true;
}else{
@ -2197,7 +2197,7 @@ class learnpathItem {
$this->last_scorm_session_time = $total_sec;
}
//Step 3 update db only if status != completed, passed, browsed or seriousgamemode not activated
$case_completed=array('completed','passed','browsed'); //TODO COMPLETE
$case_completed=array('completed','passed','browsed','failed'); //TODO COMPLETE
if ($this->seriousgame_mode!=1 || !in_array($row['status'], $case_completed)){
$update_view_sql='UPDATE '.$item_view_table." SET total_time =$total_time".'
WHERE c_id = '.$course_id.' AND lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
@ -2422,7 +2422,7 @@ class learnpathItem {
} else {
$my_type_lp = learnpath::get_type_static($this->lp_id);
// This is a array containing values finished
$case_completed = array('completed', 'passed', 'browsed');
$case_completed = array('completed', 'passed', 'browsed', 'failed');
//is not multiple attempts
if ($this->seriousgame_mode==1 && $this->type=='sco') {

@ -123,7 +123,7 @@ class learnpathList {
'lp_visibility' => $vis,
'lp_published' => $pub,
'lp_prevent_reinit' => $row['prevent_reinit'],
'seriousgame_mode' => $row['seriousgame_mode'],
'seriousgame_mode' => $row['seriousgame_mode'],
'lp_scorm_debug' => $row['debug'],
'lp_display_order' => $row['display_order'],
'lp_preview_image' => stripslashes($row['preview_image']),

@ -143,7 +143,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
return $return;
}
$mystatus_in_db = $mylpi->get_status(true);
if ($mystatus_in_db != 'completed' && $mystatus_in_db != 'passed' && $mystatus_in_db != 'browsed') {
if ($mystatus_in_db != 'completed' && $mystatus_in_db != 'passed' && $mystatus_in_db != 'browsed' && $mystatus_in_db != 'failed') {
$mystatus_in_memory = $mylpi->get_status(false);
if ($mystatus_in_memory != $mystatus_in_db) {
$mystatus = $mystatus_in_memory;
@ -202,6 +202,8 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
if ($mylp->get_type() == 2) {
$return .= "update_stats();";
}
//To be sure progress is updated
$mylp->save_last();
return $return;
//return $objResponse;
}

@ -48,13 +48,6 @@ $(window).load(function () {
});
</script>';
// Storage API
$htmlHeadXtra[] = '<script type="text/javascript">
var sv_user = \''.api_get_user_id().'\';
var sv_course = \''.api_get_course_id().'\';
var sv_sco = \''.$_REQUEST['lp_id'].'\';
</script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="js/storageapi.js"></script>';
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;

@ -353,30 +353,34 @@ if (!empty($flat_list)) {
$dsp_publish = Display::return_icon('lp_publish_na.png', get_lang('_no_publish'),'',ICON_SIZE_SMALL);
}
/* MULTIPLE ATTEMPTS OR SERIOUS GAME MODE */
/* MULTIPLE ATTEMPTS OR SERIOUS GAME MODE
SERIOUSGAME MODE is a special mode where :
* If a user exits the learning path before finishing it, he comes back where he left next time he tries
* When lp status is completed, user can still modify the attempt (adds/time change score, and browse it)
* It is thus a mix betwenn multiple attempt and mono attempt
*/
if ($current_session == $details['lp_session']) {
if ($details['seriousgame_mode'] == 1 && $details['lp_prevent_reinit'] == 1) { //seriousgame mode | next = single
dir('serious');
Display::return_icon('reload_na.png', get_lang('AllowMultipleAttempts'),'',ICON_SIZE_SMALL).'</a>';
'<img src="../img/gamepad.gif" border="0" alt="Prevent reinit" title="'.get_lang("PreventMultipleAttempts").'"/>' .
'</a>&nbsp;';
}
if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 1) { //single mode | next = multiple
$dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_attempt_mode&lp_id='.$id.'">' .
'<img src="../img/kaboodleloop_gray.gif" border="0" alt="Allow reinit" title="'.get_lang("AllowMultipleAttempts").'"/>' .
'</a>&nbsp;';
}
if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 0) { //multiple mode | next = seriousgame
$dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_attempt_mode&lp_id='.$id.'">' .
'<img src="../img/kaboodleloop.gif" border="0" alt="Serious game mode" title="'.get_lang("SeriousGameMode").'"/>' .
'</a>&nbsp;';
'</a>&nbsp;';
}
if ($details['seriousgame_mode'] == 1 && $details['lp_prevent_reinit'] == 1) { //seriousgame mode | next = single
$dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_attempt_mode&lp_id='.$id.'">' .
'<img src="../img/gamepad.gif" border="0" alt="Prevent reinit" title="'.get_lang("PreventMultipleAttempts").'"/>' .
'</a>&nbsp;';
}
if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 1) { //single mode | next = multiple
$dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_attempt_mode&lp_id='.$id.'">' .
'<img src="../img/kaboodleloop_gray.gif" border="0" alt="Allow reinit" title="'.get_lang("AllowMultipleAttempts").'"/>' .
'</a>&nbsp;';
}
if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 0) { //multiple mode | next = seriousgame
$dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_attempt_mode&lp_id='.$id.'">' .
'<img src="../img/kaboodleloop.gif" border="0" alt="Serious game mode" title="'.get_lang("SeriousGameMode").'"/>' .
'</a>&nbsp;';
}
} else {
$dsp_reinit = Display::return_icon('reload_na.png', get_lang('AllowMultipleAttempts'),'',ICON_SIZE_SMALL);
$dsp_reinit = Display::return_icon('kaboodleloop_gray.png', get_lang('AllowMultipleAttempts'),'',ICON_SIZE_SMALL);
}
/* FUll screen VIEW */
if ($current_session == $details['lp_session']) {
@ -522,4 +526,4 @@ if (!empty($flat_list)) {
}
}
Display::display_footer();
Display::display_footer();

@ -93,6 +93,20 @@ if (isset($exerciseResult) || isset($_SESSION['exerciseResult'])) {
unset($_SESSION['objExercise']);
unset($_SESSION['questionList']);
///// additional APIs
$htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
chamilo_courseCode = "'.$course_code.'";
</script>';
// Document API
$htmlHeadXtra[] = '<script src="js/documentapi.js" type="text/javascript" language="javascript"></script>';
// Storage API
$htmlHeadXtra[] = '<script type="text/javascript">
var sv_user = \''.api_get_user_id().'\';
var sv_course = chamilo_courseCode;
var sv_sco = \''.$_REQUEST['lp_id'].'\';
</script>'; // FIXME fetch sco and userid from a more reliable source directly in sotrageapi.js
$htmlHeadXtra[] = '<script type="text/javascript" src="js/storageapi.js"></script>';
/**
* Get a link to the corresponding document.
*/

@ -1818,9 +1818,9 @@ function attach_glossary_into_scorm(type) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(content_object) {
$("iframe").contents().find("div#"+div_content_id).html("<img src="+my_protocol+"//"+location.host+work_path+"/main/inc/lib/javascript/indicator.gif />"); },
$("iframe").contents().find("div#"+div_content_id).html("<img src='<?php echo api_get_path(WEB_PATH); ?>main/inc/lib/javascript/indicator.gif' />"); },
type: "POST",
url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
url: "<?php echo api_get_path(WEB_PATH); ?>/main/glossary/glossary_ajax_request.php",
data: "glossary_id="+my_glossary_id,
success: function(data) {
$("iframe").contents().find("div#"+div_content_id).html(data);
@ -1854,9 +1854,9 @@ function attach_glossary_into_scorm(type) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {
$("iframe").contents().find("div#"+div_content_id).html("<img src="+my_protocol+"//"+location.host+work_path+"/main/inc/lib/javascript/indicator.gif />"); },
$("iframe").contents().find("<img src='<?php echo api_get_path(WEB_PATH); ?>main/inc/lib/javascript/indicator.gif' />"); },
type: "POST",
url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
url: "<?php echo api_get_path(WEB_PATH); ?>/main/glossary/glossary_ajax_request.php",
data: "glossary_name="+is_glossary_name,
success: function(data) {
$("iframe").contents().find("div#"+div_content_id).html(data);

@ -5,6 +5,14 @@
require_once('../inc/global.inc.php');
// variable cleaning...
foreach (Array("svkey", "svvalue") as $key)
//FIXME use chamilo api
$_REQUEST[$key] = mysql_escape_string($_REQUEST[$key]);
foreach (Array("svuser", "svcourse", "svsco", "svlength", "svasc") as $key)
$_REQUEST[$key] = intval($_REQUEST[$key]);
switch ($_REQUEST['action']) {
case "get":
print storage_get($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
@ -36,10 +44,19 @@ switch ($_REQUEST['action']) {
}
break;
case "stackgetall":
print storage_stack_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
if (storage_can_set($_REQUEST['svuser']))
print storage_stack_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
break;
case "getposition":
print storage_get_position($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc']);
break;
case "getleaders":
print storage_get_leaders($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc'], $_REQUEST['svlength']);
break;
case "usersgetall":
print storage_get_all_users();
// security issue
print "NOT allowed, security issue, see sources";
// print storage_get_all_users();
break;
default:
// Do nothing
@ -75,6 +92,63 @@ function storage_get($sv_user, $sv_course, $sv_sco, $sv_key) {
return null;
}
}
function storage_get_leaders($sv_user, $sv_course, $sv_sco, $sv_key, $sv_asc, $sv_length) {
// get leaders
$sql_leaders = "select u.user_id, firstname, lastname, email, username, sv_value as value
from ".Database::get_main_table(TABLE_MAIN_STORED_VALUES)." sv,
".Database::get_main_table(TABLE_MAIN_USER)." u
where u.user_id=sv.user_id
and sco_id = '$sv_sco'
and course_id = '$sv_course'
and sv_key = '$sv_key'
order by sv_value ".($sv_asc ? "ASC": "DESC")." limit $sv_length";
// $sql_data = "select sv.user_id as user_id, sv_key as variable, sv_value as value
// from ".Database::get_main_table(TABLE_MAIN_STORED_VALUES)." sv
// where sv.user_id in (select u2.user_id from ($sql_leaders) u2)
// and sco_id = '$sv_sco'
// and course_id = '$sv_course'";
// $resData = Database::query($sql_data);
// $data = Array();
// while($row = Database::fetch_assoc($resData))
// $data[] = $row; // fetching all data
//
$resLeaders = Database::query($sql_leaders);
$result = array();
while ($row = Database::fetch_assoc($resLeaders)) {
$row["values"] = array();
// foreach($data as $dataRow) {
// if ($dataRow["user_id"] = $row["user_id"])
// $row["values"][$dataRow["variable"]] = $dataRow["value"];
// }
$result[] = $row;
}
return json_encode($result);
}
function storage_get_position($sv_user, $sv_course, $sv_sco, $sv_key, $sv_asc, $sv_length) {
$sql = "select count(list.user_id) as position
from ".Database::get_main_table(TABLE_MAIN_STORED_VALUES)." search,
".Database::get_main_table(TABLE_MAIN_STORED_VALUES)." list
where search.user_id= '$sv_user'
and search.sco_id = '$sv_sco'
and search.course_id = '$sv_course'
and search.sv_key = '$sv_key'
and list.sv_value ".($sv_asc ? "<=": ">=")." search.sv_value
and list.sco_id = search.sco_id
and list.course_id = search.course_id
and list.sv_key = search.sv_key
order by list.sv_value" ;
$res = Database::query($sql);
if (mysql_num_rows($res) > 0) {
$row = Database::fetch_assoc($res);
return $row['position'];
}
else {
return null;
}
}
function storage_set($sv_user, $sv_course, $sv_sco, $sv_key, $sv_value) {
$sv_value = mysql_real_escape_string($sv_value);

@ -9,7 +9,7 @@ $reports_modules = array();
$reports_enabled_modules = array('quiz','course','scorm');
$reports_enabled_templates = array('exercicesMultiCourses', 'courseTime');
$reports_enabled_templates = array('exercicesMultiCourses', 'courseTime', 'courseArticulate');
// load templates
@ -160,7 +160,7 @@ function reports_getToolId($tool) {
// return a sql clause returning triplet of (course, $session, $uid) the
// current user is authorized to reed
function reports_getVisibilitySQL () {
return "select cru.user_id, c.id, null from course c, course_rel_user cru where cru.course_code = c.code";
return "select cru.user_id from ".Database::get_main_table(TABLE_MAIN_COURSE_USER).' cru';
// fixme sessions
}

@ -0,0 +1,119 @@
<?php
$reports_template['CourseArticulate'] = array(
'description' => 'CourseArticulate',
'getSQL' => 'reports_template_CourseArticulate_getSQL',
'wizard' =>
'
<span id="CourseArticulate" class="step">
<span class="font_normal_07em_black">This report does not need any particular settings</span><br />
<input type="hidden" class="link" value="format" />
</span>
');
function reports_template_CourseArticulate_getSQL() {
// settings
// Nom, prenom
$query = 'select u.lastname as "Last name", u.firstname as "First name" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' order by u.user_id ';
$queries[0] = $query;
// Custom Field
foreach (array("tags" => "tags") as $k => $v) { // FIXME
$query = 'select ufv.field_value as "'.$v.'" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= 'left join'.Database::get_main_table(TABLE_MAIN_USER_FIELD).' uf ';
$query .= ' on uf.field_variable="'.$k.'" ';
$query .= 'left outer join '.Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES).' ufv ';
$query .= ' on ufv.user_id = u.user_id and ufv.field_id = uf.id ';
$query .= 'where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' order by u.user_id ';
$queries[] = $query;
}
// Stored Value
$sv = array();
foreach ($sv as $k => $v) {
if (!isset($v['sql']))
$v['sql'] = 'FIELD';
$sqlField = str_replace('FIELD', 'sv.sv_value', $v['sql']);
$query = 'select '.$sqlField.' as "'.$v['title'].'" ';
// $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= ' left outer join '.Database::get_main_database().'.stored_values sv ';
$query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' group by u.user_id ';
$query .= ' order by u.user_id ';
$queries[] = $query;
}
// first and last connection
$query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
$query .= ' on tel.login_user_id = u.user_id ';
$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' group by u.user_id ';
$query .= ' order by u.user_id ';
$queries[] = $query;
// SCORM Data
$scormData = array();
foreach (CourseManager::get_real_course_list() as $code => $details) {
$list = Database::query('select l.id as lid, l.name as lname, li.id as liid, li.title as lititle '.
' from '.Database::get_course_table(TABLE_LP_MAIN, $details['db_name']).' l, '.
' '.Database::get_course_table(TABLE_LP_ITEM, $details['db_name']).' li '.
' where l.id = li.lp_id');
while ($lpItem = Database::fetch_assoc($list)) {
$scormData[] = array('coursedb' => $details['db_name'],
'lid' => $lpItem['lid'],
'liid' => $lpItem['liid'],
'target_view_count' => 1,
'target_indicator' => 'score',
'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/1/score',
'sql' => 'FIELD');
$scormData[] = array('coursedb' => $details['db_name'],
'lid' => $lpItem['lid'],
'liid' => $lpItem['liid'],
'target_view_count' => 2,
'target_indicator' => 'score',
'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/2/score',
'sql' => 'FIELD');
$scormData[] = array('coursedb' => $details['db_name'],
'lid' => $lpItem['lid'],
'liid' => $lpItem['liid'],
'target_view_count' => null,
'target_indicator' => 'score',
'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/all/score',
'sql' => 'avg(FIELD)');
}
}
foreach($scormData as $v) {
if (!isset($v['sql']))
$v['sql'] = 'FIELD';
$sqlField = str_replace('FIELD', $v['target_indicator'], $v['sql']);
$query = 'select '.$sqlField.' as "'.$v['title'].'" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= 'left outer join '.Database::get_course_table(TABLE_LP_VIEW, $details['db_name']).' lv ';
$query .= ' on u.user_id = lv.user_id and lv.lp_id = '.$v['lid'];
$query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW, $details['db_name']).' liv ';
$query .= ' on lv.id = liv.lp_view_id ';
if ($v['target_view_count'])
$query .= ' and liv.view_count = '.$v['target_view_count'];
$query .= ' and liv.lp_item_id = '.$v['liid'].' ';
$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' group by u.user_id ';
$query .= ' order by u.user_id ';
$queries[] = $query;
}
return $queries;
}

@ -0,0 +1,62 @@
<?php
$reports_template['Generic'] = array(
'description' => 'Generic',
'getSQL' => 'reports_template_Generic_getSQL',
'wizard' =>
'
<span id="Generic" class="step">
<span class="font_normal_07em_black">This report does not need any particular settings</span><br />
<input type="hidden" class="link" value="format" />
</span>
');
function reports_template_Generic_getSQL() {
// settings
// Nom, prenom
$query = 'select u.lastname as "Last name", u.firstname as "First name" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' order by u.user_id ';
$queries[0] = $query;
// Custom Field
foreach (array(10 => "description") as $k => $v) {
$query = 'select ufv.field_value as "'.$v.'" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= 'left outer join '.Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES).' ufv ';
$query .= ' on ufv.user_id = u.user_id and ufv.field_id = '.$k;
$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' order by u.user_id ';
$queries[] = $query;
}
// Stored Value
$sv = array();
foreach ($sv as $k => $v) {
$query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= ' left outer join '.Database::get_main_database().'.stored_values sv ';
$query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' order by u.user_id ';
$queries[] = $query;
}
// premiere connexion
$query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
$query .= ' on tel.login_user_id = u.user_id ';
$query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
$query .= ' group by u.user_id ';
$query .= ' order by u.user_id ';
$queries[] = $query;
return $queries;
}

@ -1740,9 +1740,10 @@ function export2doc($doc_id) {
$exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path(). '/document'.$groupPath;
$exportFile = replace_dangerous_char($wikiTitle, 'strict') . $groupPart;
$clean_wikiContents = trim(preg_replace("/\[\[|\]\]/", " ", $wikiContents));
$array_clean_wikiContents= explode('|', $clean_wikiContents);
//$wikiContents= $array_clean_wikiContents[1];
//$clean_wikiContents = trim(preg_replace("/\[\[|\]\]/", " ", $wikiContents));
//$array_clean_wikiContents= explode('|', $clean_wikiContents);
$wikiContents = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $wikiContents));
//TODO: put link instead of title
$wikiContents = str_replace('{CONTENT}', $wikiContents, $template);
@ -1770,18 +1771,20 @@ function export2doc($doc_id) {
*/
function export_to_pdf($id, $course_code) {
$data = get_wiki_data($id);
require_once api_get_path(LIBRARY_PATH).'pdf.lib.php';
$data = get_wiki_data($id);
$content_pdf = api_html_entity_decode($data['content'], ENT_QUOTES, api_get_system_encoding());
//clean wiki links
$content_pdf=trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
//TODO: It should be better to display the link insted of the tile but it is hard for [[title]] links
$clean_pdf_content = trim(preg_replace("/\[\[|\]\]/", " ", $content_pdf));
//@todo this line breaks the pdf export. TODO:clean compound wiki names
//$array_clean_pdf_content= explode('|', $clean_pdf_content);//delete and reworking
//$clean_pdf_content = $array_clean_pdf_content[1];//delete and reworking
$content_pdf= $clean_pdf_content;
$title_pdf = api_html_entity_decode($data['title'], ENT_QUOTES, api_get_system_encoding());
$title_pdf = api_utf8_encode($title_pdf, api_get_system_encoding());
$content_pdf = api_utf8_encode($content_pdf, api_get_system_encoding());
@ -2197,3 +2200,4 @@ function get_wiki_data($id) {
}
return $data;
}

Loading…
Cancel
Save