parent
8e3c8be5d5
commit
b5cc8f2694
@ -1,71 +0,0 @@ |
||||
<?php //$id: $
|
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Form to add users through LDAP (deprecated?) |
||||
* @package chamilo.admin |
||||
* Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) |
||||
*/ |
||||
/** |
||||
* This form is included by ldap_import_students.php and ldap_import_students_to_session.php |
||||
*/ |
||||
$nbre=0; |
||||
echo '<form name="form" method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'">'; |
||||
if($statut==1) |
||||
{ |
||||
echo get_lang('EmailNotifySubscription').': <input type="checkbox" name="mailling" value="1" checked="checked"><i>'.get_lang('DontUnchek').'</i>'; |
||||
} |
||||
else |
||||
{ |
||||
echo '<input type="hidden" name="mailling" value="1">'; |
||||
} |
||||
if(!empty($course)) |
||||
{ |
||||
echo '<input type="hidden" name="course" value="'.Security::remove_XSS($course).'">'; |
||||
} |
||||
elseif(!empty($id_session)) |
||||
{ |
||||
echo '<input type="hidden" name="id_session" value="'.Security::remove_XSS($id_session).'">'; |
||||
} |
||||
$is_western_name_order = api_is_western_name_order(); |
||||
echo '<input type="hidden" name="confirmed" value="yes">'; |
||||
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>' . |
||||
($is_western_name_order |
||||
? '<td width="15%"><b>'.get_lang('FirstName').'</b></td>' . |
||||
'<td width="15%"><b>'.get_lang('Name').'</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>'; |
||||
if ($is_western_name_order) |
||||
{ |
||||
echo '<td>'.$prenom_form[$key].'<input type="hidden" name="prenom_form['.$key.']" size="20" value="'.$prenom_form[$key].'"></td>'; |
||||
echo '<td>'.$nom_form[$key].'<input type="hidden" name="nom_form['.$key.']" size="20" value="'.$nom_form[$key].'"></td>'; |
||||
} |
||||
else |
||||
{ |
||||
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>'; |
||||
?> |
@ -1,319 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Script to import students from LDAP |
||||
* @package chamilo.admin |
||||
* Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
// name of the language file that needs to be included |
||||
$language_file[] = 'admin'; |
||||
$language_file[] = 'registration'; |
||||
// resetting the course id |
||||
$cidReset = true; |
||||
require_once('../inc/global.inc.php'); |
||||
// setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
require_once(api_get_path(LIBRARY_PATH).'course.lib.php'); |
||||
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php'); |
||||
// 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> |
||||
var buttoncheck = 1; |
||||
function checkAll() { |
||||
//var boxes = document.form.elements[\'checkboxes[]\']; |
||||
var boxes = document.getElementsByName(\'checkboxes[]\'); |
||||
if (buttoncheck == 0) { |
||||
for (i = 0; i < boxes.length; i++) { |
||||
boxes[i].checked = true; |
||||
} |
||||
buttoncheck = 1; |
||||
return "'.get_lang('None').'"; |
||||
} |
||||
else { |
||||
for (i = 0; i < boxes.length; i++) { |
||||
boxes[i].checked = false; |
||||
} |
||||
buttoncheck = 0; |
||||
return " '.get_lang('All').' "; |
||||
} |
||||
} |
||||
</script>'; |
||||
|
||||
$annee = $_GET['annee']; |
||||
$composante = $_GET['composante']; |
||||
$etape = $_GET['etape']; |
||||
$course = $_POST['course']; |
||||
|
||||
|
||||
// form1 annee = 0; composante= 0 etape = 0 |
||||
//if ($annee == "" && $composante == "" && $etape == "") { |
||||
if (empty($annee) && empty($course)) { |
||||
Display::display_header($tool_name); |
||||
echo '<div style="align:center">'; |
||||
Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')); |
||||
echo get_lang('LDAPSelectFilterOnUsersOU'); |
||||
//echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />'; |
||||
///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />'; |
||||
|
||||
echo '<form method="get" action="'.api_get_self().'"><br />'; |
||||
echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> '; |
||||
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 |
||||
{ |
||||
Display::display_header($tool_name); |
||||
|
||||
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); |
||||
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, "(ou=*$annee)", 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 ++) |
||||
{ |
||||
//presupose LDAP server is UTF-8 |
||||
$composante[$info[$i]['ou'][0]] = api_utf8_decode($info[$i]['description'][0], api_get_system_encoding()); |
||||
} |
||||
$oucompotab3=$composante; |
||||
|
||||
echo '<div style="align: center">'; |
||||
echo '<br />'; |
||||
echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectComponent')).' '.get_lang('SelectComponent').'</h3>'; |
||||
echo '<form method="get" action="'.api_get_self().'">'; |
||||
echo '<b>'.get_lang('RegistrationYear').'</b> : '; |
||||
echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee.'">'; |
||||
echo '<b>'.get_lang('Component').' : </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('BackToNewSearch').'</a>'; |
||||
echo '<br />'; |
||||
echo '</div>'; |
||||
} |
||||
elseif ($annee <> "" && $composante <> "" && $etape == "") // form3 :annee!=0composante=0etape=0 |
||||
{ |
||||
|
||||
Display::display_header($tool_name); |
||||
echo '<div style="align: center">'; |
||||
echo '<h3>'.Display::return_icon('group.gif', get_lang('SearchResults')).' '.get_lang('SearchResults').'</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, $ldap_basedn, "ou=$composante", 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('RegistrationYear').':</b><input type="text" name="annee" size="4" maxlength="30" value="'.$annee.'">'; |
||||
echo '<br /><br />'; |
||||
echo '<b>'.get_lang('Component').' :</b><input type="text" name="composante" size="4" maxlength="30" value="'.$composante.'">'; |
||||
echo '<br />'; |
||||
echo '<h4>'.get_lang('SelectStepAcademicYear').'</h4>'; |
||||
echo '<br />'; |
||||
|
||||
echo '<b>'.get_lang('Step').': </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 = api_utf8_decode($tempcomp, api_get_system_encoding()); |
||||
|
||||
$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('BackToNewSearch').'</a>'; |
||||
echo '</div>'; |
||||
} |
||||
*/ |
||||
elseif (!empty($annee) && empty($course)) { |
||||
Display::display_header($tool_name); |
||||
echo '<div style="align:center">'; |
||||
echo Display::return_icon('course.gif', get_lang('SelectCourseToImportUsersTo')).' '.get_lang( |
||||
'SelectCourseToImportUsersTo' |
||||
).'<br />'; |
||||
echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />'; |
||||
echo '<select name="course">'; |
||||
$courses = CourseManager::get_courses_list(); |
||||
foreach ($courses as $row) { |
||||
echo '<option value="'.$row['code'].'">'.api_htmlentities( |
||||
$row['title'], |
||||
ENT_COMPAT, |
||||
api_get_system_encoding() |
||||
).'</option>'; |
||||
} |
||||
echo '</select>'; |
||||
echo '<input type="submit" value="'.get_lang('Submit').'">'; |
||||
echo '</form>'; |
||||
echo '</div>'; |
||||
} // form4 annee != 0; composante != 0 etape != 0 |
||||
//elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') { |
||||
elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed'])) { |
||||
Display::display_header($tool_name); |
||||
echo '<div style="align: center;">'; |
||||
echo '<br />'; |
||||
echo '<br />'; |
||||
echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>'; |
||||
//echo "Connection ..."; |
||||
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); |
||||
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))"); |
||||
//echo "(ou=*$annee,ou=$composante)"; |
||||
$sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)"); |
||||
|
||||
$info = ldap_get_entries($ds, $sr); |
||||
|
||||
for ($key = 0; $key < $info["count"]; $key++) { |
||||
$nom_form[] = $info[$key]["sn"][0]; //api_utf8_decode($info[$key]["sn"][0], api_get_system_encoding()); |
||||
$prenom_form[] = $info[$key]["givenname"][0]; //api_utf8_decode($info[$key]["givenname"][0], api_get_system_encoding()); |
||||
$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 |
||||
$username_form[] = $info[$key]['uid'][0]; |
||||
$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student" |
||||
//$val = ldap_get_values_len($ds, $entry, "userPassword"); |
||||
//$password_form[] = $val[0]; |
||||
$password_form[] = $info[$key]['userPassword'][0]; |
||||
} |
||||
ldap_unbind($ds); |
||||
asort($nom_form); |
||||
reset($nom_form); |
||||
|
||||
$statut = 5; |
||||
include('ldap_form_add_users_group.php'); |
||||
} else { |
||||
echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>'; |
||||
} |
||||
echo '<br /><br />'; |
||||
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>'; |
||||
echo '<br /><br />'; |
||||
echo '</div>'; |
||||
|
||||
} elseif (!empty($annee) && !empty($course) && ($_POST['confirmed'] == 'yes')) { |
||||
$id = $_POST['username_form']; |
||||
$UserList = array(); |
||||
$userid_match_login = array(); |
||||
foreach ($id as $form_index => $user_id) { |
||||
if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes']))) { |
||||
$tmp = ldap_add_user($user_id); |
||||
$UserList[] = $tmp; |
||||
$userid_match_login[$tmp] = $user_id; |
||||
} |
||||
} |
||||
$courseInfo = api_get_course_info($_POST['course']); |
||||
if (!empty($courseInfo)) { |
||||
foreach ($UserList as $user_id) { |
||||
CourseManager::add_user_to_course($user_id, $courseInfo['real_id']); |
||||
} |
||||
header('Location: course_information.php?code='.Security::remove_XSS($_POST['course'])); |
||||
exit; |
||||
} /* |
||||
else |
||||
{ |
||||
Display :: display_header($tool_name); |
||||
if(count($userid_match_login)>0) |
||||
{ |
||||
$message=get_lang('LDAPUsersAddedOrUpdated').':<br />'; |
||||
foreach($userid_match_login as $user_id => $login) |
||||
{ |
||||
$message .= '- '.$login.'<br />'; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
$message=get_lang('NoUserAdded'); |
||||
} |
||||
Display :: display_normal_message($message,false); |
||||
} |
||||
*/ |
||||
else { |
||||
Display::display_header($tool_name); |
||||
$message = get_lang('NoUserAdded'); |
||||
Display :: display_normal_message($message, false); |
||||
} |
||||
echo '<br /><br />'; |
||||
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>'; |
||||
echo '<br /><br />'; |
||||
} |
||||
Display::display_footer(); |
@ -1,211 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Edition script for sessions categories |
||||
* @package chamilo.admin |
||||
* Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
// name of the language file that needs to be included |
||||
$language_file[]='admin'; |
||||
$language_file[]='registration'; |
||||
// resetting the course id |
||||
$cidReset=true; |
||||
require_once('../inc/global.inc.php'); |
||||
// setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
require_once(api_get_path(LIBRARY_PATH).'course.lib.php'); |
||||
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php'); |
||||
// 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> |
||||
var buttoncheck = 1; |
||||
function checkAll() { |
||||
//var boxes = document.form.elements[\'checkboxes[]\']; |
||||
var boxes = document.getElementsByName(\'checkboxes[]\'); |
||||
if (buttoncheck == 0) { |
||||
for (i = 0; i < boxes.length; i++) { |
||||
boxes[i].checked = true; |
||||
} |
||||
buttoncheck = 1; |
||||
return "'.get_lang('None').'"; |
||||
} |
||||
else { |
||||
for (i = 0; i < boxes.length; i++) { |
||||
boxes[i].checked = false; |
||||
} |
||||
buttoncheck = 0; |
||||
return " '.get_lang('All').' "; |
||||
} |
||||
} |
||||
</script>'; |
||||
|
||||
$annee = $_GET['annee']; |
||||
$id_session = $_POST['id_session']; |
||||
|
||||
|
||||
// form1 annee = 0; composante= 0 etape = 0 |
||||
//if ($annee == "" && $composante == "" && $etape == "") { |
||||
if (empty($annee) && empty($id_session)) |
||||
{ |
||||
Display::display_header($tool_name); |
||||
echo '<div style="align:center">'; |
||||
echo Display::return_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')).' '.get_lang('LDAPSelectFilterOnUsersOU'); |
||||
echo '<form method="get" action="'.api_get_self().'"><br />'; |
||||
echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> '; |
||||
echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"> '; |
||||
echo '<input type="submit" value="'.get_lang('Submit').'">'; |
||||
echo '</form>'; |
||||
echo '</div>'; |
||||
|
||||
} |
||||
elseif(!empty($annee) && empty($id_session)) |
||||
{ |
||||
Display::display_header($tool_name); |
||||
echo '<div style="align:center">'; |
||||
echo Display::return_icon('course.gif', get_lang('SelectSessionToImportUsersTo')).' '.get_lang('SelectSessionToImportUsersTo').'<br />'; |
||||
echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />'; |
||||
echo '<select name="id_session">'; |
||||
|
||||
$sessions = SessionManager::get_sessions_list(); |
||||
foreach ($sessions as $row) { |
||||
echo '<option value="'.$row['id'].'">'.api_htmlentities($row['name'], ENT_COMPAT, api_get_system_encoding()).' ('.api_get_local_time($row['access_start_date']).' - '.api_get_local_time($row['access_end_date']).')</option>'; |
||||
} |
||||
echo '</select>'; |
||||
echo '<input type="submit" value="'.get_lang('Submit').'">'; |
||||
echo '</form>'; |
||||
echo '</div>'; |
||||
} |
||||
// form4 annee != 0; composante != 0 etape != 0 |
||||
//elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') { |
||||
elseif (!empty($annee) && !empty($id_session) && empty($_POST['confirmed'])) |
||||
{ |
||||
Display::display_header($tool_name); |
||||
echo '<div style="align: center;">'; |
||||
echo '<br />'; |
||||
echo '<br />'; |
||||
echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>'; |
||||
//echo "Connection ..."; |
||||
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); |
||||
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))"); |
||||
//echo "(ou=*$annee,ou=$composante)"; |
||||
$sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)"); |
||||
|
||||
$info = ldap_get_entries($ds, $sr); |
||||
|
||||
for ($key = 0; $key < $info["count"]; $key ++) { |
||||
$nom_form[] = $info[$key]["sn"][0];//api_utf8_decode($info[$key]["sn"][0], api_get_system_encoding()); |
||||
$prenom_form[] = $info[$key]["givenname"][0];//api_utf8_decode($info[$key]["givenname"][0], api_get_system_encoding()); |
||||
$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 |
||||
$username_form[] = $info[$key]['uid'][0]; |
||||
$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student" |
||||
//$val = ldap_get_values_len($ds, $entry, "userPassword"); |
||||
//$password_form[] = $val[0]; |
||||
$password_form[] = $info[$key]['userPassword'][0]; |
||||
} |
||||
ldap_unbind($ds); |
||||
|
||||
/*-----------------------------------------------*/ |
||||
|
||||
asort($nom_form); |
||||
reset($nom_form); |
||||
|
||||
$statut=5; |
||||
include ('ldap_form_add_users_group.php'); |
||||
} else { |
||||
echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>'; |
||||
} |
||||
echo '<br /><br />'; |
||||
echo '<a href="ldap_import_students.php?annee=">'.get_lang('BackToNewSearch').'</a>'; |
||||
echo '<br /><br />'; |
||||
echo '</div>'; |
||||
|
||||
} |
||||
elseif (!empty($annee) && !empty($id_session) && ($_POST['confirmed']=='yes')) |
||||
{ |
||||
$id=$_POST['username_form']; |
||||
$UserList=array(); |
||||
$userid_match_login = array(); |
||||
foreach ($id as $form_index=>$user_id) |
||||
{ |
||||
if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes']))) |
||||
{ |
||||
$tmp = ldap_add_user($user_id); |
||||
$UserList[]= $tmp; |
||||
$userid_match_login[$tmp] = $user_id; |
||||
} |
||||
} |
||||
if (!empty($_POST['id_session'])) |
||||
{ |
||||
$num = 0; |
||||
$tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
||||
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
||||
foreach($UserList as $user_id) |
||||
{ |
||||
$sql = 'INSERT INTO '.$tbl_session_user.' SET |
||||
id_user="'.intval($user_id).'", |
||||
id_session = "'.intval($id_session).'"'; |
||||
$res_user = Database::query($sql); |
||||
if ($res_user) |
||||
{ |
||||
$num++; |
||||
} |
||||
} |
||||
if($num>0) |
||||
{ |
||||
$sql = 'UPDATE '.$tbl_session.' SET nbr_users = (nbr_users + '.$num.') WHERE id = '.intval($id_session); |
||||
$res = Database::query($sql); |
||||
} |
||||
header('Location: resume_session.php?id_session='.Security::remove_XSS($_POST['id_session'])); |
||||
} |
||||
/* |
||||
else |
||||
{ |
||||
Display :: display_header($tool_name); |
||||
if(count($userid_match_login)>0) |
||||
{ |
||||
$message=get_lang('LDAPUsersAddedOrUpdated').':<br />'; |
||||
foreach($userid_match_login as $user_id => $login) |
||||
{ |
||||
$message .= '- '.$login.'<br />'; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
$message=get_lang('NoUserAdded'); |
||||
} |
||||
Display :: display_normal_message($message,false); |
||||
} |
||||
*/ |
||||
else |
||||
{ |
||||
Display::display_header($tool_name); |
||||
$message=get_lang('NoUserAdded'); |
||||
Display :: display_normal_message($message,false); |
||||
} |
||||
echo '<br /><br />'; |
||||
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>'; |
||||
echo '<br /><br />'; |
||||
} |
||||
Display::display_footer(); |
||||
?> |
@ -1,249 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @author Mustapha Alouani |
||||
* @package chamilo.admin |
||||
*/ |
||||
/** |
||||
* Init |
||||
*/ |
||||
// name of the language file that needs to be included |
||||
$language_file[] = 'registration'; |
||||
$language_file[] = 'admin'; |
||||
$cidReset = true; |
||||
require('../inc/global.inc.php'); |
||||
require_once(api_get_path(LIBRARY_PATH).'sortable_table.class.php'); |
||||
require_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); |
||||
require_once(api_get_path(LIBRARY_PATH).'security.lib.php'); |
||||
require('../auth/ldap/authldap.php'); |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
/** |
||||
============================================================================== |
||||
INIT SECTION |
||||
============================================================================== |
||||
*/ |
||||
require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php'); |
||||
$action = $_GET["action"]; |
||||
$login_as_user_id = $_GET["user_id"]; |
||||
|
||||
// Login as ... |
||||
if ($_GET['action'] == "login_as" && isset ($login_as_user_id)) |
||||
{ |
||||
login_user($login_as_user_id); |
||||
} |
||||
|
||||
//if we already have a session id and a user... |
||||
/* |
||||
if (($_GET['action']=="add_user") && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && $_GET['id_session']>0 ){ |
||||
header('Location: ldap_import_students_to_session.php?id_session='.$_GET['id_session'].'&ldap_user='.$_GET['id']); |
||||
} |
||||
*/ |
||||
|
||||
$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
||||
$tool_name = get_lang('SearchLDAPUsers'); |
||||
//Display :: display_header($tool_name); //cannot display now as we need to redirect |
||||
//api_display_tool_title($tool_name); |
||||
|
||||
if (isset ($_GET['action'])) |
||||
{ |
||||
$check = Security::check_token('get'); |
||||
if($check) |
||||
{ |
||||
switch ($_GET['action']) |
||||
{ |
||||
case 'show_message' : |
||||
Display :: display_header($tool_name); |
||||
Display :: display_normal_message($_GET['message']); |
||||
break; |
||||
case 'delete_user' : |
||||
Display :: display_header($tool_name); |
||||
if ($user_id != $_user['user_id'] && UserManager :: delete_user($_GET['user_id'])) |
||||
{ |
||||
Display :: display_normal_message(get_lang('UserDeleted')); |
||||
} |
||||
else |
||||
{ |
||||
Display :: display_error_message(get_lang('CannotDeleteUser')); |
||||
} |
||||
break; |
||||
case 'lock' : |
||||
Display :: display_header($tool_name); |
||||
$message=lock_unlock_user('lock',$_GET['user_id']); |
||||
Display :: display_normal_message($message); |
||||
break; |
||||
case 'unlock'; |
||||
Display :: display_header($tool_name); |
||||
$message=lock_unlock_user('unlock',$_GET['user_id']); |
||||
Display :: display_normal_message($message); |
||||
break; |
||||
case 'add_user'; |
||||
$id=$_GET['id']; |
||||
$UserList=array(); |
||||
$userid_match_login = array(); |
||||
foreach ($id as $user_id) { |
||||
$tmp = ldap_add_user($user_id); |
||||
$UserList[]= $tmp; |
||||
$userid_match_login[$tmp] = $user_id; |
||||
} |
||||
if (isset($_GET['id_session']) && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && ($_GET['id_session']>0)) { |
||||
ldap_add_user_to_session($UserList, $_GET['id_session']); |
||||
header('Location: resume_session.php?id_session='.$_GET['id_session']); |
||||
} else { |
||||
Display :: display_header($tool_name); |
||||
if(count($userid_match_login)>0) |
||||
{ |
||||
$message=get_lang('LDAPUsersAddedOrUpdated').':<br />'; |
||||
foreach($userid_match_login as $user_id => $login) |
||||
{ |
||||
$message .= '- '.$login.'<br />'; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
$message=get_lang('NoUserAdded'); |
||||
} |
||||
Display :: display_normal_message($message,false); |
||||
} |
||||
break; |
||||
default : |
||||
Display :: display_header($tool_name); |
||||
} |
||||
Security::clear_token(); |
||||
} |
||||
else |
||||
{ |
||||
Display::display_header($tool_name); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
Display::display_header($tool_name); |
||||
} |
||||
if (isset ($_POST['action'])) |
||||
{ |
||||
$check = Security::check_token('get'); |
||||
if($check) |
||||
{ |
||||
switch ($_POST['action']) |
||||
{ |
||||
case 'delete' : |
||||
$number_of_selected_users = count($_POST['id']); |
||||
$number_of_deleted_users = 0; |
||||
foreach ($_POST['id'] as $index => $user_id) |
||||
{ |
||||
if($user_id != $_user['user_id']) |
||||
{ |
||||
if(UserManager :: delete_user($user_id)) |
||||
{ |
||||
$number_of_deleted_users++; |
||||
} |
||||
} |
||||
} |
||||
if($number_of_selected_users == $number_of_deleted_users) |
||||
{ |
||||
Display :: display_normal_message(get_lang('SelectedUsersDeleted')); |
||||
} |
||||
else |
||||
{ |
||||
Display :: display_error_message(get_lang('SomeUsersNotDeleted')); |
||||
} |
||||
break; |
||||
case 'add_user' : |
||||
$number_of_selected_users = count($_POST['id']); |
||||
$number_of_added_users = 0; |
||||
$UserList=array(); |
||||
foreach ($_POST['id'] as $index => $user_id) |
||||
{ |
||||
if($user_id != $_user['user_id']) |
||||
{ |
||||
$UserList[] = ldap_add_user($user_id); |
||||
} |
||||
} |
||||
if (isset($_GET['id_session']) && (trim($_GET['id_session'])!="")) |
||||
addUserToSession($UserList, $_GET['id_session']); |
||||
if(count($UserList)>0) |
||||
{ |
||||
Display :: display_normal_message(count($UserList)." ".get_lang('LDAPUsersAdded')); |
||||
} |
||||
else |
||||
{ |
||||
Display :: display_normal_message(get_lang('NoUserAdded')); |
||||
} |
||||
break; |
||||
|
||||
} |
||||
Security::clear_token(); |
||||
} |
||||
} |
||||
|
||||
$form = new FormValidator('advanced_search','get'); |
||||
$form->add_textfield('keyword_username',get_lang('LoginName'),false); |
||||
if (api_is_western_name_order()) |
||||
{ |
||||
$form->add_textfield('keyword_firstname', get_lang('FirstName'), false); |
||||
$form->add_textfield('keyword_lastname', get_lang('LastName'), false); |
||||
} |
||||
else |
||||
{ |
||||
$form->add_textfield('keyword_lastname',get_lang('LastName'),false); |
||||
$form->add_textfield('keyword_firstname',get_lang('FirstName'),false); |
||||
} |
||||
if (isset($_GET['id_session'])) |
||||
$form->addElement('hidden','id_session',$_GET['id_session']); |
||||
|
||||
$type = array(); |
||||
$type["all"] = get_lang('All'); |
||||
$type["employee"] = get_lang('Teacher'); |
||||
$type["student"] = get_lang('Student'); |
||||
|
||||
$form->addElement('select','keyword_type',get_lang('Status'),$type); |
||||
// Structure a rajouer ?? |
||||
$form->addElement('submit','submit',get_lang('Ok')); |
||||
//$defaults['keyword_active'] = 1; |
||||
//$defaults['keyword_inactive'] = 1; |
||||
//$form->setDefaults($defaults); |
||||
$form->display(); |
||||
|
||||
|
||||
|
||||
$parameters['keyword_username'] = $_GET['keyword_username']; |
||||
$parameters['keyword_firstname'] = $_GET['keyword_firstname']; |
||||
$parameters['keyword_lastname'] = $_GET['keyword_lastname']; |
||||
$parameters['keyword_email'] = $_GET['keyword_email']; |
||||
if (isset($_GET['id_session'])) |
||||
$parameters['id_session'] = $_GET['id_session']; |
||||
// Create a sortable table with user-data |
||||
|
||||
$parameters['sec_token'] = Security::get_token(); |
||||
$table = new SortableTable('users', 'ldap_get_number_of_users', 'ldap_get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2); |
||||
$table->set_additional_parameters($parameters); |
||||
$table->set_header(0, '', false); |
||||
$table->set_header(1, get_lang('LoginName')); |
||||
if (api_is_western_name_order()) |
||||
{ |
||||
$table->set_header(2, get_lang('FirstName')); |
||||
$table->set_header(3, get_lang('LastName')); |
||||
} |
||||
else |
||||
{ |
||||
$table->set_header(2, get_lang('LastName')); |
||||
$table->set_header(3, get_lang('FirstName')); |
||||
} |
||||
$table->set_header(4, get_lang('Email')); |
||||
$table->set_header(5, get_lang('Actions')); |
||||
//$table->set_column_filter(5, 'email_filter'); |
||||
//$table->set_column_filter(5, 'active_filter'); |
||||
$table->set_column_filter(5, 'modify_filter'); |
||||
$table->set_form_actions(array ('add_user' => get_lang('AddLDAPUsers'))); |
||||
$table->display(); |
||||
|
||||
/* |
||||
============================================================================== |
||||
FOOTER |
||||
============================================================================== |
||||
*/ |
||||
Display :: display_footer(); |
||||
?> |
@ -1,67 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.admin |
||||
* @deprecated ? |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
exit(); //not yet functional, needs to be revised |
||||
// 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_course = Database::get_main_table(TABLE_MAIN_COURSE); |
||||
$tbl_user = Database::get_main_table(TABLE_MAIN_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