[svn r14967] Added contributed scripts for LDAP import of users into sessions from Mustapha Alouani, Sorbonne. Currently undergoing improvements and cleanup. Will probably use only a subset in 1.8.5 beta.
parent
780100d63b
commit
039de96700
@ -0,0 +1,65 @@ |
||||
<?php //$id: $
|
||||
/* |
||||
============================================================================== |
||||
Dokeos - elearning and course management software |
||||
|
||||
Copyright (c) 2008 Dokeos SPRL |
||||
Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) |
||||
|
||||
For a full list of contributors, see "credits.txt". |
||||
The full license can be read in "license.txt". |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License |
||||
as published by the Free Software Foundation; either version 2 |
||||
of the License, or (at your option) any later version. |
||||
|
||||
See the GNU General Public License for more details. |
||||
|
||||
Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com |
||||
============================================================================== |
||||
*/ |
||||
/** |
||||
* This form is included by ldap_import_students.php |
||||
*/ |
||||
$nbre=0; |
||||
echo '<form name="form" method="post" action="ldap_users_list.php">'; |
||||
if($statut==1) |
||||
{ |
||||
echo get_lang('Notification par courriel de l\'inscription').': <input type="checkbox" name="mailling" value="1" checked="checked"><i>'.get_lang('ne pas décocher').'</i>'; |
||||
} |
||||
else |
||||
{ |
||||
echo '<input type="hidden" name="mailling" value="1">'; |
||||
} |
||||
|
||||
echo '<table border="0" cellspacing="0" width="100%">'; |
||||
echo '<tr align="center" id="header3">' . |
||||
'<td width="15%"><input type="button" value="'.get_lang('AllSlashNone').'" onClick="checkAll();"></td>' . |
||||
'<td width="40%"><b>'.get_lang('Email').'</b></td>' . |
||||
'<td width="15%"><b>'.get_lang('Name').'</b></td>' . |
||||
'<td width="15%"><b>'.get_lang('Firstname').'</b></td>' . |
||||
'<td width="15%"><b>'.get_lang('Login').'</b></td>' . |
||||
'</tr>'."\n"; |
||||
while (list ($key, $val) = each($nom_form)) { |
||||
$nbre=$nbre+1; |
||||
if($nbre & 1) $ndiv=2; else $ndiv=3; |
||||
echo '<tr align="center" id="header'.$ndiv.'">'; |
||||
echo '<td><input type="checkbox" name="checkboxes[]" value="'.$key.'" checked="checked"></td>'; |
||||
echo '<td>'.$email_form[$key].'<input type="hidden" name="email_form['.$key.']" size="40" value="'.$email_form[$key].'"></td>'; |
||||
echo '<td>'.$nom_form[$key].'<input type="hidden" name="nom_form['.$key.']" size="20" value="'.$nom_form[$key].'"></td>'; |
||||
echo '<td>'.$prenom_form[$key].'<input type="hidden" name="prenom_form['.$key.']" size="20" value="'.$prenom_form[$key].'"></td>'; |
||||
echo '<td>'.$username_form[$key].'<input type="hidden" name="username_form['.$key.']" size="10" value="'.$username_form[$key].'">'; |
||||
echo '<input type="hidden" name="tutor_form['.$key.']" value="0">'; |
||||
echo '<input type="hidden" name="admin_form['.$key.']" value="1">'; |
||||
echo '<input type="hidden" name="password_form['.$key.']" value="'.$password_form[$key].'">'; |
||||
echo '<input type="hidden" name="statut['.$key.']" value="'.$statut.'">'; |
||||
echo '</td>'; |
||||
echo '</tr>'; |
||||
} |
||||
echo '</table>'; |
||||
echo '<br />'; |
||||
echo '<br />'; |
||||
echo '<input type="submit" name="submit" value="'.get_lang('Submit').'">'; |
||||
echo '</form>'; |
||||
?> |
@ -0,0 +1,258 @@ |
||||
<?php //$id: $
|
||||
/* |
||||
============================================================================== |
||||
Dokeos - elearning and course management software |
||||
|
||||
Copyright (c) 2008 Dokeos SPRL |
||||
Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) |
||||
|
||||
For a full list of contributors, see "credits.txt". |
||||
The full license can be read in "license.txt". |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License |
||||
as published by the Free Software Foundation; either version 2 |
||||
of the License, or (at your option) any later version. |
||||
|
||||
See the GNU General Public License for more details. |
||||
|
||||
Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com |
||||
============================================================================== |
||||
*/ |
||||
// name of the language file that needs to be included |
||||
$language_file[]='admin'; |
||||
$language_file[]='registration'; |
||||
require_once('../inc/global.inc.php'); |
||||
// resetting the course id |
||||
$cidReset=true; |
||||
// setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
// Access restrictions |
||||
api_protect_admin_script(); |
||||
require('../auth/ldap/authldap.php'); |
||||
|
||||
$annee_base=date('Y'); |
||||
|
||||
$tool_name = get_lang('LDAPImport'); |
||||
// setting breadcrumbs |
||||
$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
||||
|
||||
$htmlHeadXtra[] = '<script language="JavaScript" type="text/javascript"> |
||||
var buttoncheck = "false"; |
||||
function checkAll() { |
||||
var boxes = document.form.elements[\'checkboxes[]\']; |
||||
if (buttoncheck == "false") { |
||||
for (i = 0; i < boxes.length; i++) { |
||||
boxes[i].checked = true; |
||||
} |
||||
buttoncheck = "true"; |
||||
return "'.get_lang('None').'"; |
||||
} |
||||
else { |
||||
for (i = 0; i < boxes.length; i++) { |
||||
boxes[i].checked = false; |
||||
} |
||||
buttoncheck = "false"; |
||||
return " '.get_lang('All').' "; |
||||
} |
||||
} |
||||
</script>'; |
||||
|
||||
Display::display_header($tool_name); |
||||
|
||||
$annee = $_GET['annee']; |
||||
$composante = $_GET['composante']; |
||||
$etape = $_GET['etape']; |
||||
|
||||
// form1 annee = 0; composante= 0 etape = 0 |
||||
if ($annee == "" && $composante == "" && $etape == "") { |
||||
|
||||
echo '<div style="align:center">'; |
||||
echo '<h3><img src="../img/group.gif" alt="'.get_lang('SAISIE DES ETUDIANTS POUR LESQUELS VOUS SOUHAITEZ ADRESSER VOTRE COURS').'" />'.get_lang('SAISIE DES ETUDIANTS POUR LESQUELS VOUS SOUHAITEZ ADRESSER VOTRE COURS').'</h3>'; |
||||
echo '<em>'.get_lang('POUR CELA, IL FAUT SAISIR LA DATE, LA COMPOSANTE ET L\'ETAPE DE LA COMPOSANTE').'</b><br />'; |
||||
echo get_lang('Suivre chacune de ces etapes pas a pas').'<br />'; |
||||
|
||||
echo '<form method="get" action="'.api_get_self().'"><br />'; |
||||
echo '<b>'.get_lang('ANNEE D\'INSCRIPTION - <i>Ex: %s pour l\'annee %s/%s</i>').' :</b> '; |
||||
echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />'; |
||||
echo '<input type="submit" value="'.get_lang('Submit').'">'; |
||||
echo '</form>'; |
||||
echo '</div>'; |
||||
|
||||
} |
||||
elseif ($annee <> "" && $composante == "" && $etape == "") // form 2 annee != 0; composante= 0 etape = 0 |
||||
{ |
||||
|
||||
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('Impossible de se connecter au serveur LDAP')); |
||||
ldap_set_version($ds); |
||||
|
||||
if ($ds) { |
||||
$r = false; |
||||
$res = ldap_handle_bind($ds, $r); |
||||
|
||||
//$sr = @ ldap_search($ds, "o=groups,$ldap_basedn", "(&(description=etape*)(cn=*$annee))", array ('cn')); |
||||
//$sr = @ ldap_search($ds, "ou=$annee, ou=diploma, o=paris1, $ldap_basedn", "ou=02*", array ('description')); |
||||
//$sr = @ ldap_search($ds, "ou=structures, o=paris1, $ldap_basedn", "businessCategory=pedagogy", array ('ou','description')); |
||||
$sr = @ ldap_search($ds, "$ldap_basedn", "", array ('ou','description')); |
||||
// "ou=2006,ou=diploma,o=Paris1,dc=univ-paris1,dc=fr |
||||
|
||||
$info = ldap_get_entries($ds, $sr); |
||||
$composante = array(); |
||||
for($i = 0; $i < $info['count']; $i ++) |
||||
{ |
||||
//on suppose que le serveur LDAP est en UTF-8 |
||||
$composante[$info[$i]['ou'][0]] = iconv('utf-8', api_get_setting('platform_charset'), $info[$i]['description'][0]); |
||||
} |
||||
$oucompotab3=$composante; |
||||
|
||||
echo '<div style="align: center">'; |
||||
echo '<br />'; |
||||
echo '<h3><img src="../img/group.gif" alt="'.get_lang('SELECTIONNER VOTRE COMPOSANTE').'" />'.get_lang('SELECTIONNER VOTRE COMPOSANTE').'</h3>'; |
||||
echo '<form method="get" action="'.api_get_self().'">'; |
||||
echo '<b>'.get_lang('ANNEE D\'INSCRIPTION').'</b> : '; |
||||
echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee.'">'; |
||||
echo '<b>'.get_lang('COMPOSANTE').' : </b> '; |
||||
echo '<select name="composante" size="1">'; |
||||
while (list ($key, $val) = each($oucompotab3)) { |
||||
echo '<option value="'.$key.'">'.$oucompotab3[$key].'</option>'; |
||||
} |
||||
echo '</select>'; |
||||
echo '<br />'; |
||||
echo '<br />'; |
||||
echo '<input type="submit" name="valider" value="'.get_lang('Submit').'">'; |
||||
echo '</form>'; |
||||
ldap_close($ds); |
||||
|
||||
} |
||||
echo '<br />'; |
||||
echo '<br />'; |
||||
echo '<br />'; |
||||
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('RETOUR : nouvelle recherche').'</a>'; |
||||
echo '<br />'; |
||||
echo '</div>'; |
||||
} |
||||
elseif ($annee <> "" && $composante <> "" && $etape == "") // form3 :annee!=0composante=0etape=0 |
||||
{ |
||||
|
||||
echo '<div style="align: center">'; |
||||
echo '<h3><img src="../img/group.gif" alt="'.get_lang('SearchResults').'" />'.get_lang('LE RESULTAT DE VOTRE RECHERCHE').'</h3>'; |
||||
$ds = ldap_connect($ldap_host, $ldap_port); |
||||
ldap_set_version($ds); |
||||
|
||||
if ($ds) { |
||||
|
||||
$r = false; |
||||
$res = ldap_handle_bind($ds, $r); |
||||
|
||||
// $sr = @ ldap_search($ds, "ou=groups, $LDAPbasedn", "(&(cn=*$annee*)(cn=*$composante*))"); |
||||
|
||||
$sr = @ ldap_search($ds, "ou=$annee, ou=diploma, o=paris1, $ldap_basedn", "seeAlso=ou=$composante,ou=structures,o=Paris1,$ldap_basedn", array ('ou','description')); |
||||
|
||||
//echo "Le nombre de resultats est : ".ldap_count_entries($ds,$sr)."<p>"; |
||||
$info = ldap_get_entries($ds, $sr); |
||||
|
||||
for ($i = 0; $i <= $info['count']; $i ++) { |
||||
|
||||
$description = $info[$i]['description']; |
||||
$ouetapetab[$i] = $description[0]; |
||||
$description2 = $info[$i]['ou']; |
||||
$ouetapetab2[$i] = $description2[0]; |
||||
|
||||
} |
||||
|
||||
asort($ouetapetab); |
||||
reset($ouetapetab); |
||||
|
||||
echo '<form method="get" action="'.api_get_self().'">'; |
||||
|
||||
echo '<b>'.get_lang('ANNEE D\'INSCRIPTION').':</b><input type="text" name="annee" size="4" maxlength="30" value="'.$annee.'">'; |
||||
echo '<br /><br />'; |
||||
echo '<b>'.get_lang('COMPOSANTE').' :</b><input type="text" name="composante" size="4" maxlength="30" value="'.$composante.'">'; |
||||
echo '<br />'; |
||||
echo '<h4>'.get_lang('SELECTIONNER VOTRE ETAPE (ANNEE PEDAGOGIQUE)').'</h4>'; |
||||
echo '<br />'; |
||||
|
||||
echo '<b>'.get_lang('ETAPE').': </b>'; |
||||
echo '<select name="etape" size="1">'; |
||||
$tempcomp = ""; |
||||
|
||||
while (list ($key, $val) = each($ouetapetab)) { |
||||
if ($ouetapetab[$key] != $tempcomp) { |
||||
$etape = $ouetapetab2[$key]; |
||||
$tempcomp = '"'.$ouetapetab[$key].'"'; |
||||
$tempcomp = iconv('utf-8',api_get_setting('platform_charset'),$tempcomp); |
||||
|
||||
$annee = str_word_count($etape, 1); |
||||
echo '<option value="'.$etape.'">'.$tempcomp.'</option>'; |
||||
} |
||||
} |
||||
echo '</select>'; |
||||
echo '<input type="hidden" name="displayname" value="'.$displayname.'">'; |
||||
|
||||
echo '<br />'; |
||||
echo '<input type="submit" name="envoi" value="'.get_lang('Submit').'">'; |
||||
echo '</form>'; |
||||
|
||||
ldap_close($ds); |
||||
|
||||
} else { |
||||
// echo "<h4>Unable to connect to LDAP server</h4>"; |
||||
} |
||||
echo '<br />'; |
||||
echo '<br />'; |
||||
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('RETOUR : nouvelle recherche').'</a>'; |
||||
echo '</div>'; |
||||
} |
||||
|
||||
// form4 annee != 0; composante != 0 etape != 0 |
||||
elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != yes) { |
||||
echo '<div style="align: center;">'; |
||||
echo '<br />'; |
||||
echo '<br />'; |
||||
echo '<h3><img src="../img/group.gif" alt="'.get_lang('SELECTION DES ETUDIANTS').'" />'.get_lang('SELECTION DES ETUDIANTS').'</h3>'; |
||||
//echo "Connection ..."; |
||||
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('Impossible de se connecter au serveur LDAP')); |
||||
ldap_set_version($ds); |
||||
|
||||
if ($ds) { |
||||
|
||||
$r = false; |
||||
$res = ldap_handle_bind($ds, $r); |
||||
|
||||
//$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))"); |
||||
$sr = @ ldap_search($ds, "ou=people,$ldap_basedn", "edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$ldap_basedn"); |
||||
|
||||
$info = ldap_get_entries($ds, $sr); |
||||
|
||||
for ($key = 0; $key < $info["count"]; $key ++) { |
||||
$nom_form[] = $info[$key]["sn"][0];//iconv("utf-8",api_get_setting('platform_charset'), $info[$key]["sn"][0]); |
||||
$prenom_form[] = $info[$key]["givenname"][0];//iconv("utf-8",api_get_setting('platform_charset'), $info[$key]["givenname"][0]); |
||||
$email_form[] = $info[$key]["mail"][0]; |
||||
// Get uid from dn |
||||
$dn_array=ldap_explode_dn($info[$key]["dn"],1); |
||||
$username_form[] = $dn_array[0]; // uid is first key |
||||
$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student" |
||||
$val = ldap_get_values_len($ds, $entry, "userPassword"); |
||||
$password_form[] = $val[0]; |
||||
} |
||||
|
||||
/*-----------------------------------------------*/ |
||||
|
||||
asort($nom_form); |
||||
reset($nom_form); |
||||
|
||||
$statut=5; |
||||
ldap_close($ds); |
||||
include ('ldap_form_add_users_group.php'); |
||||
ldap_unbind($ds); |
||||
} else { |
||||
echo '<h4>'.get_lang('Unable to connect to').' '.$host.'</h4>'; |
||||
} |
||||
echo '<br /><br />'; |
||||
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('RETOUR : nouvelle recherche').'</a>'; |
||||
echo '<br /><br />'; |
||||
echo '</div>'; |
||||
|
||||
} |
||||
Display::display_footer(); |
||||
?> |
@ -0,0 +1,90 @@ |
||||
<?php //$id: $
|
||||
/* |
||||
============================================================================== |
||||
Dokeos - elearning and course management software |
||||
|
||||
Copyright (c) 2008 Dokeos SPRL |
||||
Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) |
||||
|
||||
For a full list of contributors, see "credits.txt". |
||||
The full license can be read in "license.txt". |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License |
||||
as published by the Free Software Foundation; either version 2 |
||||
of the License, or (at your option) any later version. |
||||
|
||||
See the GNU General Public License for more details. |
||||
|
||||
Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com |
||||
============================================================================== |
||||
*/ |
||||
/** |
||||
============================================================================== |
||||
* @package dokeos.admin |
||||
============================================================================== |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file='admin'; |
||||
|
||||
$cidReset=true; |
||||
|
||||
require('../inc/global.inc.php'); |
||||
$libpath = api_get_path(LIBRARY_PATH); |
||||
require_once($libpath.'formvalidator/FormValidator.class.php'); |
||||
require_once($libpath.'usermanager.lib.php'); |
||||
require("../auth/ldap/authldap.php"); |
||||
$annee_base=date('Y'); |
||||
// setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
api_protect_admin_script(); |
||||
|
||||
// setting breadcrumbs |
||||
$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[]=array('url' => api_get_self(),"name" => get_lang('SessionsList')); |
||||
|
||||
// Database Table Definitions |
||||
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
||||
$tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
||||
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
||||
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
||||
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
||||
$tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
||||
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
||||
$tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
||||
$tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
||||
|
||||
$tbl_session_rel_etape = "session_rel_etape"; |
||||
|
||||
$id_session=intval($_GET['id_session']); |
||||
|
||||
$formSent=0; |
||||
$errorMsg=$firstLetterUser=$firstLetterSession=''; |
||||
$UserList=$SessionList=array(); |
||||
$users=$sessions=array(); |
||||
$noPHP_SELF=true; |
||||
|
||||
$page=intval($_GET['page']); |
||||
$action=$_REQUEST['action']; |
||||
|
||||
$tool_name = get_lang('Synchro LDAP : Import Etudiants/Etapes dans session'); |
||||
Display::display_header($tool_name); |
||||
//api_display_tool_title($tool_name); |
||||
|
||||
?> |
||||
<form method="get" action="<?php echo api_get_self(); ?>" onsubmit="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;">
|
||||
<select name="action"> |
||||
<option value="synchro"><?php echo get_lang('Synchro LDAP : Import Etudiants/Etapes dans toutes les sessions'); ?></option>
|
||||
</select> |
||||
<input type="submit" value="<?php echo get_lang('Ok'); ?>">
|
||||
</form> |
||||
|
||||
<?php |
||||
if (isset($action) && ($action=="synchro")) { |
||||
$included=true; |
||||
require('ldap_synchro.php'); |
||||
Display :: display_normal_message($message,false); |
||||
} |
||||
Display::display_footer(); |
||||
?> |
Loading…
Reference in new issue