commit
4517edc685
@ -1,3 +1,31 @@ |
|||||||
<?php require_once('../inc/global.inc.php'); |
<html> |
||||||
header("Location: /user_portal.php"); |
<head> |
||||||
exit(); |
<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> |
||||||
|
|||||||
@ -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(); |
||||||
|
?> |
||||||
@ -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); |
|
||||||
} |
|
||||||
?> |
|
||||||
@ -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; |
||||||
|
} |
||||||
|
?> |
||||||
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(); |
||||||
@ -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; |
||||||
|
} |
||||||
|
|
||||||
Loading…
Reference in new issue