parent
1cb2025528
commit
cd441c99ec
@ -0,0 +1,128 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* This script allows platform admins to add users to urls. |
||||
* It displays a list of users and a list of courses; |
||||
* you can select multiple users and courses and then click on |
||||
* @package chamilo.admin |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file = 'admin'; |
||||
$cidReset = true; |
||||
require_once '../inc/global.inc.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php'; |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
api_protect_global_admin_script(); |
||||
if (!api_get_multiple_access_url()) { |
||||
header('Location: index.php'); |
||||
exit; |
||||
} |
||||
|
||||
$userGroup = new UserGroup(); |
||||
|
||||
$form_sent = 0; |
||||
$firstLetterUserGroup = null; |
||||
$courses = array(); |
||||
$url_list = array(); |
||||
|
||||
$tbl_access_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
||||
$tbl_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
||||
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
||||
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); |
||||
|
||||
$tool_name = get_lang('AddUserGroupToURL'); |
||||
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); |
||||
|
||||
Display::display_header($tool_name); |
||||
|
||||
echo '<div class="actions">'; |
||||
echo Display::url( |
||||
Display::return_icon('edit.png', get_lang('EditUserGroupToURL'), ''), |
||||
api_get_path(WEB_CODE_PATH).'admin/access_url_edit_usergroup_to_url.php' |
||||
); |
||||
echo '</div>'; |
||||
|
||||
api_display_tool_title($tool_name); |
||||
|
||||
if (isset($_POST['form_sent']) && $_POST['form_sent']) { |
||||
$form_sent = $_POST['form_sent']; |
||||
$userGroups = is_array($_POST['user_group_list']) ? $_POST['user_group_list'] : array() ; |
||||
$urlList = is_array($_POST['url_list']) ? $_POST['url_list'] : array() ; |
||||
$firstLetterUserGroup = $_POST['first_letter_user_group']; |
||||
|
||||
if ($form_sent == 1) { |
||||
if (count($userGroups) == 0 || count($urlList) == 0) { |
||||
Display :: display_error_message(get_lang('AtLeastOneUserGroupAndOneURL')); |
||||
} else { |
||||
UrlManager::addUserGroupListToUrl($userGroups, $urlList); |
||||
Display::display_confirmation_message(get_lang('UserGroupBelongURL')); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$firstLetterUser = null; |
||||
if ($userGroup->getTotalCount() > 1000) { |
||||
//if there are too much num_courses to gracefully handle with the HTML select list, |
||||
// assign a default filter on users names |
||||
$firstLetterUser = 'A'; |
||||
} |
||||
|
||||
$dbUserGroups = $userGroup->filterByFirstLetter($firstLetterUserGroup); |
||||
|
||||
$sql = "SELECT id, url FROM $tbl_access_url WHERE active = 1 ORDER BY url"; |
||||
$result = Database::query($sql); |
||||
$db_urls = Database::store_result($result); |
||||
?> |
||||
|
||||
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>" style="margin:0px;">
|
||||
<input type="hidden" name="form_sent" value="1"/> |
||||
<table border="0" cellpadding="5" cellspacing="0" width="100%"> |
||||
<tr> |
||||
<td width="40%" align="center"> |
||||
<b><?php echo get_lang('UserGroupList'); ?></b>
|
||||
<br/><br/> |
||||
<?php echo get_lang('FirstLetter'); ?> :
|
||||
<select name="first_letter_user_group" onchange="javascript:document.formulaire.form_sent.value='2'; document.formulaire.submit();"> |
||||
<option value="">--</option> |
||||
<?php |
||||
echo Display::get_alphabet_options($firstLetterUserGroup); |
||||
echo Display::get_numeric_options(0, 9, $firstLetterUserGroup); |
||||
?> |
||||
</select> |
||||
</td> |
||||
<td width="20%"> </td> |
||||
<td width="40%" align="center"> |
||||
<b><?php echo get_lang('URLList'); ?> :</b>
|
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td width="40%" align="center"> |
||||
<select name="user_group_list[]" multiple="multiple" size="20" style="width:400px;"> |
||||
<?php foreach ($dbUserGroups as $item) { ?> |
||||
<option value="<?php echo $item['id']; ?>" <?php if (in_array($item['id'], $courses)) echo 'selected="selected"'; ?>><?php echo $item['name']; ?> |
||||
</option> |
||||
<?php } ?> |
||||
</select> |
||||
</td> |
||||
<td width="20%" valign="middle" align="center"> |
||||
<button type="submit" class="add"> <?php echo get_lang('AddUserGroupToThatURL'); ?> </button>
|
||||
</td> |
||||
<td width="40%" align="center"> |
||||
<select name="url_list[]" multiple="multiple" size="20" style="width:300px;"> |
||||
<?php foreach ($db_urls as $url_obj) { ?> |
||||
<option value="<?php echo $url_obj['id']; ?>" <?php if (in_array($url_obj['id'], $url_list)) echo 'selected="selected"'; ?>><?php echo $url_obj['url']; ?> |
||||
</option> |
||||
<?php } ?> |
||||
</select> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</form> |
||||
<?php |
||||
|
||||
Display :: display_footer(); |
@ -0,0 +1,337 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.admin |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file = 'admin'; |
||||
|
||||
// resetting the course id |
||||
$cidReset = true; |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'course_category.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php'; |
||||
|
||||
$xajax = new xajax(); |
||||
$xajax->registerFunction(array('searchCourseCategoryAjax', 'UrlManager', 'searchCourseCategoryAjax')); |
||||
|
||||
// Setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
// Access restrictions |
||||
api_protect_global_admin_script(); |
||||
if (!api_get_multiple_access_url()) { |
||||
header('Location: index.php'); |
||||
exit; |
||||
} |
||||
|
||||
// Setting breadcrumbs |
||||
$tool_name = get_lang('EditUserGroupToURL'); |
||||
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); |
||||
|
||||
$add_type = 'multiple'; |
||||
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') { |
||||
$add_type = Security::remove_XSS($_REQUEST['add_type']); |
||||
} |
||||
|
||||
$access_url_id = 1; |
||||
if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id'] != '') { |
||||
$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']); |
||||
} |
||||
|
||||
$xajax->processRequests(); |
||||
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); |
||||
$htmlHeadXtra[] = ' |
||||
<script> |
||||
function add_user_to_url(code, content) { |
||||
|
||||
document.getElementById("course_to_add").value = ""; |
||||
document.getElementById("ajax_list_courses").innerHTML = ""; |
||||
|
||||
destination = document.getElementById("destination_users"); |
||||
destination.options[destination.length] = new Option(content,code); |
||||
|
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function send() { |
||||
|
||||
if (document.formulaire.access_url_id.value!=0) { |
||||
document.formulaire.form_sent.value=0; |
||||
document.formulaire.add_type.value=\''.$add_type.'\'; |
||||
document.formulaire.submit(); |
||||
} |
||||
} |
||||
|
||||
function remove_item(origin) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
} |
||||
</script>'; |
||||
|
||||
$form_sent=0; |
||||
$errorMsg=''; |
||||
$UserList=$SessionList = array(); |
||||
$users=$sessions = array(); |
||||
|
||||
if (isset($_POST['form_sent']) && $_POST['form_sent']) { |
||||
$form_sent = $_POST['form_sent']; |
||||
$list = $_POST['course_list']; |
||||
|
||||
if (!is_array($list)) { |
||||
$list = array(); |
||||
} |
||||
|
||||
if ($form_sent == 1) { |
||||
if ($access_url_id == 0) { |
||||
header('Location: access_url_edit_users_to_url.php?action=show_message&message='.get_lang('SelectURL')); |
||||
} elseif (is_array($list)) { |
||||
UrlManager::updateUrlRelCourseCategory($list, $access_url_id); |
||||
header('Location: access_urls.php?action=show_message&message='.get_lang('Updated')); |
||||
} |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
Display::display_header($tool_name); |
||||
|
||||
api_display_tool_title($tool_name); |
||||
|
||||
if ($_GET['action'] == 'show_message') { |
||||
Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message']))); |
||||
} |
||||
|
||||
$noUserGroupList = $userGroupList = array(); |
||||
$ajax_search = $add_type == 'unique' ? true : false; |
||||
|
||||
if ($ajax_search) { |
||||
$userGroups = UrlManager::getUrlRelCourseCategory($access_url_id); |
||||
foreach ($userGroups as $item) { |
||||
$userGroupList[$item['id']] = $item; |
||||
} |
||||
} else { |
||||
$userGroups = UrlManager::getUrlRelCourseCategory(); |
||||
|
||||
foreach ($userGroups as $item) { |
||||
if ($item['access_url_id'] == $access_url_id) { |
||||
$userGroupList[$item['id']] = $item ; |
||||
} |
||||
} |
||||
$noUserGroupList = getCourseCategoryNotInList(array_keys($userGroupList)); |
||||
} |
||||
|
||||
if ($add_type == 'multiple') { |
||||
$link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'.get_lang('SessionAddTypeUnique').'</a>'; |
||||
$link_add_type_multiple = get_lang('SessionAddTypeMultiple'); |
||||
} else { |
||||
$link_add_type_unique = get_lang('SessionAddTypeUnique'); |
||||
$link_add_type_multiple = '<a href="'.api_get_self().'?add_type=multiple&access_url_id='.$access_url_id.'">'.get_lang('SessionAddTypeMultiple').'</a>'; |
||||
} |
||||
|
||||
$url_list = UrlManager::get_url_data(); |
||||
?> |
||||
<div style="text-align: left;"> |
||||
<?php echo $link_add_type_unique ?> | <?php echo $link_add_type_multiple ?> |
||||
</div> |
||||
<br /><br /> |
||||
<form |
||||
name="formulaire" |
||||
method="post" |
||||
action="<?php echo api_get_self(); ?>"
|
||||
style="margin:0px;" <?php if ($ajax_search) { echo ' onsubmit="valide();"'; } ?> |
||||
> |
||||
<?php echo get_lang('SelectUrl').' : '; ?> |
||||
<select name="access_url_id" onchange="javascript:send();"> |
||||
<option value="0">-- <?php echo get_lang('SelectUrl')?> -- </option>
|
||||
<?php |
||||
$url_selected = ''; |
||||
foreach ($url_list as $url_obj) { |
||||
$checked = ''; |
||||
if (!empty($access_url_id)) { |
||||
if ($url_obj[0] == $access_url_id) { |
||||
$checked = 'selected=true'; |
||||
$url_selected=$url_obj[1]; |
||||
} |
||||
} |
||||
if ($url_obj['active']==1) { ?> |
||||
<option <?php echo $checked;?> value="<?php echo $url_obj[0]; ?>"> <?php echo $url_obj[1]; ?> |
||||
</option> |
||||
<?php |
||||
} |
||||
} |
||||
?> |
||||
</select> |
||||
<br /><br /> |
||||
<input type="hidden" name="form_sent" value="1" /> |
||||
<input type="hidden" name="add_type" value = "<?php echo $add_type ?>" />
|
||||
|
||||
<?php |
||||
if (!empty($errorMsg)) { |
||||
Display::display_normal_message($errorMsg); //main API |
||||
} |
||||
?> |
||||
|
||||
<table border="0" cellpadding="5" cellspacing="0" width="100%"> |
||||
<!-- Users --> |
||||
<tr> |
||||
<td align="center"><b><?php echo get_lang('CourseCategoryInPlatform') ?> :</b>
|
||||
</td> |
||||
<td></td> |
||||
<td align="center"><b><?php echo get_lang('CourseCategoryListIn').' '.$url_selected; ?></b></td>
|
||||
</tr> |
||||
|
||||
<tr> |
||||
<td align="center"> |
||||
<div id="content_source"> |
||||
<?php if ($ajax_search) { ?> |
||||
<input type="text" id="course_to_add" onkeyup="xajax_searchCourseCategoryAjax(this.value,document.formulaire.access_url_id.options[document.formulaire.access_url_id.selectedIndex].value)" /> |
||||
<div id="ajax_list_courses"></div> |
||||
<?php } else { ?> |
||||
<select id="origin_users" name="no_course_list[]" multiple="multiple" size="15" style="width:380px;"> |
||||
<?php |
||||
foreach ($noUserGroupList as $noItem) { |
||||
?> |
||||
<option value="<?php echo $noItem['id']; ?>">
|
||||
<?php echo $noItem['name']; ?> |
||||
</option> |
||||
<?php |
||||
} |
||||
?> |
||||
</select> |
||||
<?php |
||||
} |
||||
?> |
||||
</div> |
||||
</td> |
||||
<td width="10%" valign="middle" align="center"> |
||||
<?php |
||||
if ($ajax_search) { |
||||
?> |
||||
<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))" ></button> |
||||
<?php |
||||
} else { |
||||
?> |
||||
<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" ></button> |
||||
<br /><br /> |
||||
<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))" ></button> |
||||
<?php |
||||
} |
||||
?> |
||||
<br /><br /><br /><br /><br /><br /> |
||||
</td> |
||||
<td align="center"> |
||||
<select id="destination_users" name="course_list[]" multiple="multiple" size="15" style="width:380px;"> |
||||
<?php |
||||
foreach($userGroupList as $item) { |
||||
?> |
||||
<option value="<?php echo $item['id']; ?>">
|
||||
<?php echo $item['name']; ?> |
||||
</option> |
||||
<?php |
||||
} |
||||
?> |
||||
</select> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td colspan="3" align="center"> |
||||
<br /> |
||||
<?php |
||||
if(isset($_GET['add'])) |
||||
echo '<button class="save" onclick="valide()" >'.get_lang('Add').'</button>'; |
||||
else |
||||
echo '<button class="save" onclick="valide()" >'.get_lang('Edit').'</button>'; |
||||
?> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</form> |
||||
<script> |
||||
|
||||
function moveItem(origin , destination) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value); |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function sortOptions(options) { |
||||
newOptions = new Array(); |
||||
for (i = 0 ; i<options.length ; i++) |
||||
newOptions[i] = options[i]; |
||||
|
||||
newOptions = newOptions.sort(mysort); |
||||
options.length = 0; |
||||
for(i = 0 ; i < newOptions.length ; i++) |
||||
options[i] = newOptions[i]; |
||||
|
||||
} |
||||
|
||||
function mysort(a, b) { |
||||
if(a.text.toLowerCase() > b.text.toLowerCase()){ |
||||
return 1; |
||||
} |
||||
if(a.text.toLowerCase() < b.text.toLowerCase()){ |
||||
return -1; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
function valide(){ |
||||
var options = document.getElementById('destination_users').options; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
options[i].selected = true; |
||||
document.forms.formulaire.submit(); |
||||
} |
||||
|
||||
function loadUsersInSelect(select){ |
||||
|
||||
var xhr_object = null; |
||||
|
||||
if(window.XMLHttpRequest) // Firefox |
||||
xhr_object = new XMLHttpRequest(); |
||||
else if(window.ActiveXObject) // Internet Explorer |
||||
xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); |
||||
else // XMLHttpRequest non supporté par le navigateur |
||||
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); |
||||
|
||||
xhr_object.open("POST", "loadUsersInSelect.ajax.php"); |
||||
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
||||
nosessionUsers = makepost(document.getElementById('origin_users')); |
||||
sessionUsers = makepost(document.getElementById('destination_users')); |
||||
nosessionClasses = makepost(document.getElementById('origin_classes')); |
||||
sessionClasses = makepost(document.getElementById('destination_classes')); |
||||
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses); |
||||
|
||||
xhr_object.onreadystatechange = function() { |
||||
if(xhr_object.readyState == 4) { |
||||
document.getElementById('content_source').innerHTML = result = xhr_object.responseText; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function makepost(select){ |
||||
var options = select.options; |
||||
var ret = ""; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
ret = ret + options[i].value +'::'+options[i].text+";;"; |
||||
return ret; |
||||
} |
||||
</script> |
||||
<?php |
||||
Display::display_footer(); |
@ -0,0 +1,346 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.admin |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file = 'admin'; |
||||
|
||||
// resetting the course id |
||||
$cidReset = true; |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php'; |
||||
|
||||
$xajax = new xajax(); |
||||
$xajax->registerFunction(array('searchUserGroupAjax', 'UserGroup', 'searchUserGroupAjax')); |
||||
$userGroup = new UserGroup(); |
||||
|
||||
// Setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
// Access restrictions |
||||
api_protect_global_admin_script(); |
||||
if (!api_get_multiple_access_url()) { |
||||
header('Location: index.php'); |
||||
exit; |
||||
} |
||||
|
||||
// setting breadcrumbs |
||||
$tool_name = get_lang('EditUserGroupToURL'); |
||||
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); |
||||
|
||||
$add_type = 'multiple'; |
||||
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') { |
||||
$add_type = Security::remove_XSS($_REQUEST['add_type']); |
||||
} |
||||
|
||||
$access_url_id = 1; |
||||
if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id'] != '') { |
||||
$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']); |
||||
} |
||||
|
||||
$xajax->processRequests(); |
||||
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); |
||||
$htmlHeadXtra[] = ' |
||||
<script> |
||||
function add_user_to_url(code, content) { |
||||
|
||||
document.getElementById("course_to_add").value = ""; |
||||
document.getElementById("ajax_list_courses").innerHTML = ""; |
||||
|
||||
destination = document.getElementById("destination_users"); |
||||
destination.options[destination.length] = new Option(content,code); |
||||
|
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function send() { |
||||
|
||||
if (document.formulaire.access_url_id.value!=0) { |
||||
document.formulaire.form_sent.value=0; |
||||
document.formulaire.add_type.value=\''.$add_type.'\'; |
||||
document.formulaire.submit(); |
||||
} |
||||
} |
||||
|
||||
function remove_item(origin) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
} |
||||
</script>'; |
||||
|
||||
$form_sent=0; |
||||
$errorMsg=''; |
||||
$UserList=$SessionList=array(); |
||||
$users=$sessions=array(); |
||||
|
||||
if (isset($_POST['form_sent']) && $_POST['form_sent']) { |
||||
$form_sent = $_POST['form_sent']; |
||||
$course_list = $_POST['course_list']; |
||||
|
||||
if (!is_array($course_list)) { |
||||
$course_list = array(); |
||||
} |
||||
|
||||
if ($form_sent == 1) { |
||||
if ($access_url_id == 0) { |
||||
header('Location: access_url_edit_users_to_url.php?action=show_message&message='.get_lang('SelectURL')); |
||||
} elseif (is_array($course_list)) { |
||||
UrlManager::update_urls_rel_usergroup($course_list, $access_url_id); |
||||
header('Location: access_urls.php?action=show_message&message='.get_lang('Updated')); |
||||
} |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
Display::display_header($tool_name); |
||||
|
||||
echo '<div class="actions">'; |
||||
echo Display::url( |
||||
Display::return_icon('view_more_stats.gif', get_lang('AddUserGroupToURL'), ''), |
||||
api_get_path(WEB_CODE_PATH).'admin/access_url_add_usergroup_to_url.php' |
||||
); |
||||
echo '</div>'; |
||||
|
||||
api_display_tool_title($tool_name); |
||||
|
||||
if ($_GET['action'] == 'show_message') { |
||||
Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message']))); |
||||
} |
||||
|
||||
$noUserGroupList = $userGroupList = array(); |
||||
$ajax_search = $add_type == 'unique' ? true : false; |
||||
|
||||
if ($ajax_search) { |
||||
$userGroups = UrlManager::get_url_rel_usergroup_data($access_url_id); |
||||
foreach ($userGroups as $item) { |
||||
$userGroupList[$item['id']] = $item; |
||||
} |
||||
} else { |
||||
$userGroups = UrlManager::get_url_rel_usergroup_data(); |
||||
|
||||
foreach ($userGroups as $item) { |
||||
if ($item['access_url_id'] == $access_url_id) { |
||||
$userGroupList[$item['id']] = $item ; |
||||
} |
||||
} |
||||
$noUserGroupList = $userGroup->getUserGroupNotInList(array_keys($userGroupList)); |
||||
} |
||||
|
||||
if ($add_type == 'multiple') { |
||||
$link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'.get_lang('SessionAddTypeUnique').'</a>'; |
||||
$link_add_type_multiple = get_lang('SessionAddTypeMultiple'); |
||||
} else { |
||||
$link_add_type_unique = get_lang('SessionAddTypeUnique'); |
||||
$link_add_type_multiple = '<a href="'.api_get_self().'?add_type=multiple&access_url_id='.$access_url_id.'">'.get_lang('SessionAddTypeMultiple').'</a>'; |
||||
} |
||||
|
||||
$url_list = UrlManager::get_url_data(); |
||||
?> |
||||
<div style="text-align: left;"> |
||||
<?php echo $link_add_type_unique ?> | <?php echo $link_add_type_multiple ?> |
||||
</div> |
||||
<br /><br /> |
||||
<form |
||||
name="formulaire" |
||||
method="post" |
||||
action="<?php echo api_get_self(); ?>"
|
||||
style="margin:0px;" <?php if ($ajax_search){ echo ' onsubmit="valide();"'; } ?> |
||||
> |
||||
<?php echo get_lang('SelectUrl').' : '; ?> |
||||
<select name="access_url_id" onchange="javascript:send();"> |
||||
<option value="0">-- <?php echo get_lang('SelectUrl')?> -- </option>
|
||||
<?php |
||||
$url_selected = ''; |
||||
foreach ($url_list as $url_obj) { |
||||
$checked = ''; |
||||
if (!empty($access_url_id)) { |
||||
if ($url_obj[0] == $access_url_id) { |
||||
$checked = 'selected=true'; |
||||
$url_selected=$url_obj[1]; |
||||
} |
||||
} |
||||
if ($url_obj['active']==1) { ?> |
||||
<option <?php echo $checked;?> value="<?php echo $url_obj[0]; ?>"> <?php echo $url_obj[1]; ?> |
||||
</option> |
||||
<?php |
||||
} |
||||
} |
||||
?> |
||||
</select> |
||||
<br /><br /> |
||||
<input type="hidden" name="form_sent" value="1" /> |
||||
<input type="hidden" name="add_type" value = "<?php echo $add_type ?>" />
|
||||
|
||||
<?php |
||||
if (!empty($errorMsg)) { |
||||
Display::display_normal_message($errorMsg); //main API |
||||
} |
||||
?> |
||||
|
||||
<table border="0" cellpadding="5" cellspacing="0" width="100%"> |
||||
<!-- Users --> |
||||
<tr> |
||||
<td align="center"><b><?php echo get_lang('UserGroupListInPlatform') ?> :</b>
|
||||
</td> |
||||
<td></td> |
||||
<td align="center"><b><?php printf(get_lang('UserGroupListInX'),$url_selected); ?></b></td>
|
||||
</tr> |
||||
|
||||
<tr> |
||||
<td align="center"> |
||||
<div id="content_source"> |
||||
<?php if ($ajax_search) { ?> |
||||
<input type="text" id="course_to_add" onkeyup="xajax_searchUserGroupAjax(this.value,document.formulaire.access_url_id.options[document.formulaire.access_url_id.selectedIndex].value)" /> |
||||
<div id="ajax_list_courses"></div> |
||||
<?php } else { ?> |
||||
<select id="origin_users" name="no_course_list[]" multiple="multiple" size="15" style="width:380px;"> |
||||
<?php |
||||
foreach ($noUserGroupList as $noItem) { |
||||
?> |
||||
<option value="<?php echo $noItem['id']; ?>">
|
||||
<?php echo $noItem['name']; ?> |
||||
</option> |
||||
<?php |
||||
} |
||||
?> |
||||
</select> |
||||
<?php |
||||
} |
||||
?> |
||||
</div> |
||||
</td> |
||||
<td width="10%" valign="middle" align="center"> |
||||
<?php |
||||
if ($ajax_search) { |
||||
?> |
||||
<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))" ></button> |
||||
<?php |
||||
} else { |
||||
?> |
||||
<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" ></button> |
||||
<br /><br /> |
||||
<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))" ></button> |
||||
<?php |
||||
} |
||||
?> |
||||
<br /><br /><br /><br /><br /><br /> |
||||
</td> |
||||
<td align="center"> |
||||
<select id="destination_users" name="course_list[]" multiple="multiple" size="15" style="width:380px;"> |
||||
<?php |
||||
foreach($userGroupList as $item) { |
||||
?> |
||||
<option value="<?php echo $item['id']; ?>">
|
||||
<?php echo $item['name']; ?> |
||||
</option> |
||||
<?php |
||||
} |
||||
?> |
||||
</select> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td colspan="3" align="center"> |
||||
<br /> |
||||
<?php |
||||
if(isset($_GET['add'])) |
||||
echo '<button class="save" onclick="valide()" >'.get_lang('AddUserGroupToURL').'</button>'; |
||||
else |
||||
echo '<button class="save" onclick="valide()" >'.get_lang('EditUserGroupToURL').'</button>'; |
||||
?> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</form> |
||||
<script> |
||||
|
||||
function moveItem(origin , destination) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value); |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function sortOptions(options) { |
||||
newOptions = new Array(); |
||||
for (i = 0 ; i<options.length ; i++) |
||||
newOptions[i] = options[i]; |
||||
|
||||
newOptions = newOptions.sort(mysort); |
||||
options.length = 0; |
||||
for(i = 0 ; i < newOptions.length ; i++) |
||||
options[i] = newOptions[i]; |
||||
|
||||
} |
||||
|
||||
function mysort(a, b) { |
||||
if(a.text.toLowerCase() > b.text.toLowerCase()){ |
||||
return 1; |
||||
} |
||||
if(a.text.toLowerCase() < b.text.toLowerCase()){ |
||||
return -1; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
function valide(){ |
||||
var options = document.getElementById('destination_users').options; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
options[i].selected = true; |
||||
document.forms.formulaire.submit(); |
||||
} |
||||
|
||||
function loadUsersInSelect(select){ |
||||
|
||||
var xhr_object = null; |
||||
|
||||
if(window.XMLHttpRequest) // Firefox |
||||
xhr_object = new XMLHttpRequest(); |
||||
else if(window.ActiveXObject) // Internet Explorer |
||||
xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); |
||||
else // XMLHttpRequest non supporté par le navigateur |
||||
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); |
||||
|
||||
//xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=<?php echo $id_session ?>&letter="+select.options[select.selectedIndex].text, false);
|
||||
xhr_object.open("POST", "loadUsersInSelect.ajax.php"); |
||||
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
||||
nosessionUsers = makepost(document.getElementById('origin_users')); |
||||
sessionUsers = makepost(document.getElementById('destination_users')); |
||||
nosessionClasses = makepost(document.getElementById('origin_classes')); |
||||
sessionClasses = makepost(document.getElementById('destination_classes')); |
||||
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses); |
||||
|
||||
xhr_object.onreadystatechange = function() { |
||||
if(xhr_object.readyState == 4) { |
||||
document.getElementById('content_source').innerHTML = result = xhr_object.responseText; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function makepost(select){ |
||||
var options = select.options; |
||||
var ret = ""; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
ret = ret + options[i].value +'::'+options[i].text+";;"; |
||||
return ret; |
||||
} |
||||
</script> |
||||
<?php |
||||
Display::display_footer(); |
@ -0,0 +1,396 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.admin |
||||
* @todo use formvalidator |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included. |
||||
$language_file = 'admin'; |
||||
|
||||
// resetting the course id. |
||||
$cidReset = true; |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'add_courses_to_session_functions.lib.php'; |
||||
|
||||
$id_session = isset($_GET['id_session']) ? intval($_GET['id_session']) : null; |
||||
$add = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null; |
||||
|
||||
SessionManager::protect_session_edit($id_session); |
||||
|
||||
$xajax = new xajax(); |
||||
$xajax->registerFunction (array('search_courses', 'AddCourseToSession', 'search_courses')); |
||||
|
||||
// Setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
// setting breadcrumbs |
||||
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList')); |
||||
$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session, "name" => get_lang('SessionOverview')); |
||||
|
||||
// Database Table Definitions |
||||
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
||||
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
||||
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
||||
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
||||
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
||||
|
||||
// setting the name of the tool |
||||
$tool_name= get_lang('SubscribeCoursesToSession'); |
||||
|
||||
$add_type = 'multiple'; |
||||
if(isset($_GET['add_type']) && $_GET['add_type']!=''){ |
||||
$add_type = Security::remove_XSS($_REQUEST['add_type']); |
||||
} |
||||
|
||||
$page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null; |
||||
|
||||
$xajax -> processRequests(); |
||||
|
||||
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); |
||||
$htmlHeadXtra[] = ' |
||||
<script type="text/javascript"> |
||||
function add_course_to_session (code, content) { |
||||
|
||||
document.getElementById("course_to_add").value = ""; |
||||
document.getElementById("ajax_list_courses_single").innerHTML = ""; |
||||
|
||||
destination = document.getElementById("destination"); |
||||
|
||||
for (i=0;i<destination.length;i++) { |
||||
if(destination.options[i].text == content) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
destination.options[destination.length] = new Option(content,code); |
||||
|
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
function remove_item(origin) |
||||
{ |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
} |
||||
</script>'; |
||||
|
||||
$formSent=0; |
||||
$errorMsg=$firstLetterCourse=$firstLetterSession=''; |
||||
$CourseList=$SessionList=array(); |
||||
$courses=$sessions=array(); |
||||
$noPHP_SELF=true; |
||||
|
||||
if (isset($_POST['formSent']) && $_POST['formSent']) { |
||||
$formSent = $_POST['formSent']; |
||||
$firstLetterCourse = $_POST['firstLetterCourse']; |
||||
$firstLetterSession = $_POST['firstLetterSession']; |
||||
$CourseList = $_POST['SessionCoursesList']; |
||||
if (!is_array($CourseList)) { |
||||
$CourseList = array(); |
||||
} |
||||
$nbr_courses=0; |
||||
|
||||
$id_coach = Database::query("SELECT id_coach FROM $tbl_session WHERE id=$id_session"); |
||||
$id_coach = Database::fetch_array($id_coach); |
||||
$id_coach = $id_coach[0]; |
||||
|
||||
$rs = Database::query("SELECT course_code FROM $tbl_session_rel_course WHERE id_session=$id_session"); |
||||
$existingCourses = Database::store_result($rs); |
||||
|
||||
// Updating only the RRHH users?? why? |
||||
//$sql="SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session AND relation_type=".COURSE_RELATION_TYPE_RRHH." "; |
||||
$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session "; |
||||
$result = Database::query($sql); |
||||
$UserList = Database::store_result($result); |
||||
|
||||
|
||||
foreach($CourseList as $enreg_course) { |
||||
$enreg_course = Database::escape_string($enreg_course); |
||||
$exists = false; |
||||
foreach($existingCourses as $existingCourse) { |
||||
if($enreg_course == $existingCourse['course_code']) { |
||||
$exists=true; |
||||
} |
||||
} |
||||
if(!$exists) { |
||||
$sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course(id_session,course_code) VALUES('$id_session','$enreg_course')"; |
||||
Database::query($sql_insert_rel_course); |
||||
|
||||
$course_info = api_get_course_info($enreg_course); |
||||
CourseManager::update_course_ranking($course_info['real_id'], $id_session); |
||||
|
||||
//We add in the existing courses table the current course, to not try to add another time the current course |
||||
$existingCourses[]=array('course_code'=>$enreg_course); |
||||
$nbr_users=0; |
||||
foreach ($UserList as $enreg_user) { |
||||
$enreg_user = Database::escape_string($enreg_user['id_user']); |
||||
$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$enreg_user')"; |
||||
Database::query($sql_insert); |
||||
if(Database::affected_rows()) { |
||||
$nbr_users++; |
||||
} |
||||
} |
||||
SessionManager::installCourse($id_session, $course_info['real_id']); |
||||
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'"); |
||||
} |
||||
} |
||||
|
||||
foreach ($existingCourses as $existingCourse) { |
||||
if (!in_array($existingCourse['course_code'], $CourseList)) { |
||||
$course_info = api_get_course_info($existingCourse['course_code']); |
||||
CourseManager::remove_course_ranking($course_info['real_id'], $id_session); |
||||
Database::query("DELETE FROM $tbl_session_rel_course WHERE course_code='".$existingCourse['course_code']."' AND id_session=$id_session"); |
||||
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE course_code='".$existingCourse['course_code']."' AND id_session=$id_session"); |
||||
SessionManager::unInstallCourse($id_session, $course_info['real_id']); |
||||
|
||||
} |
||||
} |
||||
$nbr_courses=count($CourseList); |
||||
Database::query("UPDATE $tbl_session SET nbr_courses=$nbr_courses WHERE id='$id_session'"); |
||||
|
||||
if (isset($add)) { |
||||
header('Location: add_users_to_session.php?id_session='.$id_session.'&add=true'); |
||||
} else { |
||||
header('Location: resume_session.php?id_session='.$id_session); |
||||
} |
||||
exit; |
||||
} |
||||
|
||||
// display the header |
||||
Display::display_header($tool_name); |
||||
|
||||
if ($add_type == 'multiple') { |
||||
$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$add.'&add_type=unique">'. |
||||
Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; |
||||
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').' '; |
||||
} else { |
||||
$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').' '; |
||||
$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$add.'&add_type=multiple">'. |
||||
Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; |
||||
} |
||||
|
||||
// the form header |
||||
$session_info = SessionManager::fetch($id_session); |
||||
echo '<div class="actions">'; |
||||
echo $link_add_type_unique.$link_add_type_multiple; |
||||
echo '</div>'; |
||||
|
||||
$ajax_search = $add_type == 'unique' ? true : false; |
||||
$nosessionCourses = $sessionCourses = array(); |
||||
if ($ajax_search) { |
||||
|
||||
$sql="SELECT code, title, visual_code, id_session |
||||
FROM $tbl_course course |
||||
INNER JOIN $tbl_session_rel_course session_rel_course |
||||
ON course.code = session_rel_course.course_code |
||||
AND session_rel_course.id_session = ".intval($id_session)." |
||||
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; |
||||
|
||||
if (api_is_multiple_url_enabled()) { |
||||
$tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
||||
$access_url_id = api_get_current_access_url_id(); |
||||
if ($access_url_id != -1){ |
||||
$sql="SELECT code, title, visual_code, id_session |
||||
FROM $tbl_course course |
||||
INNER JOIN $tbl_session_rel_course session_rel_course |
||||
ON course.code = session_rel_course.course_code |
||||
AND session_rel_course.id_session = ".intval($id_session)." |
||||
INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.course_code=course.code) |
||||
WHERE access_url_id = $access_url_id |
||||
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; |
||||
|
||||
} |
||||
} |
||||
|
||||
$result = Database::query($sql); |
||||
$Courses = Database::store_result($result); |
||||
|
||||
foreach ($Courses as $course) { |
||||
$sessionCourses[$course['code']] = $course ; |
||||
} |
||||
} else { |
||||
$sql = "SELECT code, title, visual_code, id_session |
||||
FROM $tbl_course course |
||||
LEFT JOIN $tbl_session_rel_course session_rel_course |
||||
ON course.code = session_rel_course.course_code |
||||
AND session_rel_course.id_session = ".intval($id_session)." |
||||
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; |
||||
|
||||
if (api_is_multiple_url_enabled()) { |
||||
$tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
||||
$access_url_id = api_get_current_access_url_id(); |
||||
if ($access_url_id != -1){ |
||||
$sql="SELECT code, title, visual_code, id_session |
||||
FROM $tbl_course course |
||||
LEFT JOIN $tbl_session_rel_course session_rel_course |
||||
ON course.code = session_rel_course.course_code |
||||
AND session_rel_course.id_session = ".intval($id_session)." |
||||
INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.course_code=course.code) |
||||
WHERE access_url_id = $access_url_id |
||||
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; |
||||
} |
||||
} |
||||
$result = Database::query($sql); |
||||
$Courses = Database::store_result($result); |
||||
foreach($Courses as $course) { |
||||
if ($course['id_session'] == $id_session) { |
||||
$sessionCourses[$course['code']] = $course ; |
||||
} else { |
||||
$nosessionCourses[$course['code']] = $course ; |
||||
} |
||||
} |
||||
} |
||||
unset($Courses); |
||||
?> |
||||
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $id_session; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
|
||||
<legend><?php echo $tool_name.' ('.$session_info['name'].')'; ?></legend>
|
||||
<input type="hidden" name="formSent" value="1" /> |
||||
|
||||
<?php |
||||
if(!empty($errorMsg)) |
||||
{ |
||||
Display::display_normal_message($errorMsg); //main API |
||||
} |
||||
?> |
||||
|
||||
<table border="0" cellpadding="5" cellspacing="0" width="100%" align="center"> |
||||
<tr> |
||||
<td width="45%" align="center"><b><?php echo get_lang('CourseListInPlatform') ?> :</b></td>
|
||||
|
||||
<td width="10%"> </td> |
||||
<td align="center" width="45%"><b><?php echo get_lang('CourseListInSession') ?> :</b></td>
|
||||
</tr> |
||||
|
||||
<?php if($add_type == 'multiple') { ?> |
||||
<tr><td width="45%" align="center"> |
||||
<?php echo get_lang('FirstLetterCourse'); ?> :
|
||||
<select name="firstLetterCourse" onchange = "xajax_search_courses(this.value,'multiple')"> |
||||
<option value="%">--</option> |
||||
<?php |
||||
echo Display :: get_alphabet_options(); |
||||
echo Display :: get_numeric_options(0,9,''); |
||||
?> |
||||
</select> |
||||
</td> |
||||
<td> </td></tr> |
||||
<?php } ?> |
||||
|
||||
<tr> |
||||
<td width="45%" align="center"> |
||||
|
||||
<?php |
||||
if (!($add_type == 'multiple')) { |
||||
?> |
||||
<input type="text" id="course_to_add" onkeyup="xajax_search_courses(this.value,'single')" /> |
||||
<div id="ajax_list_courses_single"></div> |
||||
<?php |
||||
} else { |
||||
?> |
||||
<div id="ajax_list_courses_multiple"> |
||||
<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:360px;"> <?php |
||||
foreach($nosessionCourses as $enreg) |
||||
{ |
||||
?> |
||||
<option value="<?php echo $enreg['code']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')',ENT_QUOTES).'"'; if(in_array($enreg['code'],$CourseList)) echo 'selected="selected"'; ?>><?php echo $enreg['title'].' ('.$enreg['visual_code'].')'; ?></option>
|
||||
<?php |
||||
} |
||||
?></select> |
||||
</div> |
||||
<?php |
||||
} |
||||
unset($nosessionCourses); |
||||
?> |
||||
</td> |
||||
<td width="10%" valign="middle" align="center"> |
||||
<?php |
||||
if ($ajax_search) { |
||||
?> |
||||
<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination'))"></button> |
||||
<?php |
||||
} else { |
||||
?> |
||||
<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))"></button> |
||||
<br /><br /> |
||||
<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))"></button> |
||||
<?php |
||||
} |
||||
?> |
||||
<br /><br /><br /><br /><br /><br /> |
||||
<?php |
||||
if(isset($_GET['add'])) { |
||||
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('NextStep').'</button>'; |
||||
} else { |
||||
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeCoursesToSession').'</button>'; |
||||
} |
||||
?> |
||||
</td> |
||||
<td width="45%" align="center"><select id='destination' name="SessionCoursesList[]" multiple="multiple" size="20" style="width:360px;"> |
||||
|
||||
<?php |
||||
foreach($sessionCourses as $enreg) |
||||
{ |
||||
?> |
||||
<option value="<?php echo $enreg['code']; ?>" title="<?php echo htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')',ENT_QUOTES); ?>"><?php echo $enreg['title'].' ('.$enreg['visual_code'].')'; ?></option>
|
||||
|
||||
<?php |
||||
} |
||||
unset($sessionCourses); |
||||
?> |
||||
</select></td> |
||||
</tr> |
||||
</table> |
||||
</form> |
||||
<script type="text/javascript"> |
||||
function moveItem(origin , destination) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value); |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function sortOptions(options) { |
||||
newOptions = new Array(); |
||||
for (i = 0 ; i<options.length ; i++) { |
||||
newOptions[i] = options[i]; |
||||
} |
||||
|
||||
newOptions = newOptions.sort(mysort); |
||||
options.length = 0; |
||||
|
||||
for(i = 0 ; i < newOptions.length ; i++){ |
||||
options[i] = newOptions[i]; |
||||
} |
||||
} |
||||
|
||||
function mysort(a, b){ |
||||
if(a.text.toLowerCase() > b.text.toLowerCase()){ |
||||
return 1; |
||||
} |
||||
if(a.text.toLowerCase() < b.text.toLowerCase()){ |
||||
return -1; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
function valide(){ |
||||
var options = document.getElementById('destination').options; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
options[i].selected = true; |
||||
|
||||
document.forms.formulaire.submit(); |
||||
} |
||||
</script> |
||||
<?php |
||||
Display::display_footer(); |
@ -0,0 +1,189 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.admin |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file = array('admin','registration'); |
||||
|
||||
// resetting the course id |
||||
$cidReset = true; |
||||
|
||||
// including some necessary files |
||||
require_once '../inc/global.inc.php'; |
||||
require_once '../inc/lib/xajax/xajax.inc.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php'; |
||||
|
||||
// setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
// Access restrictions |
||||
api_protect_admin_script(true); |
||||
|
||||
// setting breadcrumbs |
||||
$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList')); |
||||
|
||||
// Setting the name of the tool |
||||
$tool_name = get_lang('SubscribeStudentsToSession'); |
||||
$add_type = 'multiple'; |
||||
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') { |
||||
$add_type = Security::remove_XSS($_REQUEST['add_type']); |
||||
} |
||||
$form_sent = 0; |
||||
$errorMsg = ''; |
||||
$users = $sessions = array(); |
||||
|
||||
$id = intval($_GET['id']); |
||||
$htmlResult = null; |
||||
|
||||
if (isset($_POST['form_sent']) && $_POST['form_sent']) { |
||||
$form_sent = $_POST['form_sent']; |
||||
if ($form_sent == 1) { |
||||
$sessionSourceList = $_POST['sessions']; |
||||
$sessionDestinationList = $_POST['sessions_destination']; |
||||
$result = SessionManager::copyStudentsFromSession($sessionSourceList, $sessionDestinationList); |
||||
foreach ($result as $message) { |
||||
$htmlResult .= $message; |
||||
} |
||||
} |
||||
} |
||||
|
||||
$session_list = SessionManager::get_sessions_list(array(), array('name')); |
||||
$sessionList = array(); |
||||
foreach ($session_list as $session) { |
||||
$sessionList[$session['id']] = $session['name']; |
||||
} |
||||
Display::display_header($tool_name); |
||||
?> |
||||
|
||||
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>" style="margin:0px;" >
|
||||
<?php echo '<legend>'.$tool_name.' </legend>'; |
||||
echo $htmlResult; |
||||
echo Display::input('hidden', 'form_sent', '1'); |
||||
?> |
||||
<table border="0" cellpadding="5" cellspacing="0" width="100%"> |
||||
<tr> |
||||
<td align="center"> |
||||
<b><?php echo get_lang('Sessions') ?> :</b>
|
||||
</td> |
||||
<td></td> |
||||
<td align="center"> |
||||
<b><?php echo get_lang('Sessions') ?> :</b>
|
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td align="center"> |
||||
<?php |
||||
echo Display::select( |
||||
'sessions[]', |
||||
$sessionList, |
||||
'', |
||||
array('style'=>'width:360px', 'multiple'=>'multiple', 'id'=>'sessions', 'size'=>'15px'), |
||||
false |
||||
); |
||||
?> |
||||
</td> |
||||
<td align="center"> |
||||
</td> |
||||
<td align="center"> |
||||
<?php |
||||
echo Display::select( |
||||
'sessions_destination[]', |
||||
$sessionList, |
||||
'', |
||||
array('style'=>'width:360px', 'id'=>'courses', 'size'=>'15px'), |
||||
false |
||||
); |
||||
?> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td colspan="3" align="center"> |
||||
<br /> |
||||
<?php |
||||
echo '<button class="save" type="submit"" >'. |
||||
get_lang('SubscribeStudentsToSession').'</button>'; |
||||
?> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</form> |
||||
<script> |
||||
function moveItem(origin , destination) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value); |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function sortOptions(options) { |
||||
newOptions = new Array(); |
||||
for (i = 0 ; i<options.length ; i++) |
||||
newOptions[i] = options[i]; |
||||
|
||||
newOptions = newOptions.sort(mysort); |
||||
options.length = 0; |
||||
for(i = 0 ; i < newOptions.length ; i++) |
||||
options[i] = newOptions[i]; |
||||
} |
||||
|
||||
function mysort(a, b){ |
||||
if (a.text.toLowerCase() > b.text.toLowerCase()){ |
||||
return 1; |
||||
} |
||||
if (a.text.toLowerCase() < b.text.toLowerCase()){ |
||||
return -1; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
function valide(){ |
||||
var options = document.getElementById('session_in_promotion').options; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
options[i].selected = true; |
||||
document.forms.formulaire.submit(); |
||||
} |
||||
|
||||
function loadUsersInSelect(select) { |
||||
var xhr_object = null; |
||||
if(window.XMLHttpRequest) // Firefox |
||||
xhr_object = new XMLHttpRequest(); |
||||
else if(window.ActiveXObject) // Internet Explorer |
||||
xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); |
||||
else // XMLHttpRequest non supporté par le navigateur |
||||
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); |
||||
|
||||
//xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=<?php echo $id_session ?>&letter="+select.options[select.selectedIndex].text, false);
|
||||
xhr_object.open("POST", "loadUsersInSelect.ajax.php"); |
||||
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
||||
nosessionUsers = makepost(document.getElementById('session_not_in_promotion')); |
||||
sessionUsers = makepost(document.getElementById('session_in_promotion')); |
||||
nosessionClasses = makepost(document.getElementById('origin_classes')); |
||||
sessionClasses = makepost(document.getElementById('destination_classes')); |
||||
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses); |
||||
|
||||
xhr_object.onreadystatechange = function() { |
||||
if(xhr_object.readyState == 4) { |
||||
document.getElementById('content_source').innerHTML = result = xhr_object.responseText; |
||||
//alert(xhr_object.responseText); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function makepost(select) { |
||||
var options = select.options; |
||||
var ret = ""; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
ret = ret + options[i].value +'::'+options[i].text+";;"; |
||||
return ret; |
||||
} |
||||
</script> |
||||
<?php |
||||
Display::display_footer(); |
@ -0,0 +1,193 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.admin |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file = array('admin','registration'); |
||||
|
||||
// resetting the course id |
||||
$cidReset = true; |
||||
|
||||
// including some necessary files |
||||
require_once '../inc/global.inc.php'; |
||||
require_once '../inc/lib/xajax/xajax.inc.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php'; |
||||
|
||||
// setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
// Access restrictions |
||||
api_protect_admin_script(true); |
||||
|
||||
// setting breadcrumbs |
||||
$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList')); |
||||
|
||||
// Setting the name of the tool |
||||
$tool_name = get_lang('EnrollTrainersFromExistingSessions'); |
||||
$add_type = 'multiple'; |
||||
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') { |
||||
$add_type = Security::remove_XSS($_REQUEST['add_type']); |
||||
} |
||||
$form_sent = 0; |
||||
$errorMsg = ''; |
||||
$users = $sessions = array(); |
||||
|
||||
$id = intval($_GET['id']); |
||||
$htmlResult = null; |
||||
|
||||
if (isset($_POST['form_sent']) && $_POST['form_sent']) { |
||||
$form_sent = $_POST['form_sent']; |
||||
if ($form_sent == 1) { |
||||
$sessions = $_POST['sessions']; |
||||
$courses = $_POST['courses']; |
||||
|
||||
$htmlResult = SessionManager::copyCoachesFromSessionToCourse($sessions, $courses); |
||||
} |
||||
} |
||||
|
||||
$session_list = SessionManager::get_sessions_list(array(), array('name')); |
||||
$sessionList = array(); |
||||
foreach ($session_list as $session) { |
||||
$sessionList[$session['id']] = $session['name']; |
||||
} |
||||
|
||||
$courseList = CourseManager::get_courses_list(0, 0, 'title'); |
||||
$courseOptions = array(); |
||||
foreach ($courseList as $course) { |
||||
$courseOptions[$course['id']] = $course['title']; |
||||
} |
||||
Display::display_header($tool_name); |
||||
?> |
||||
|
||||
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>" style="margin:0px;" >
|
||||
<?php echo '<legend>'.$tool_name.' </legend>'; |
||||
echo $htmlResult; |
||||
echo Display::input('hidden', 'form_sent', '1'); |
||||
?> |
||||
<table border="0" cellpadding="5" cellspacing="0" width="100%"> |
||||
<tr> |
||||
<td align="center"> |
||||
<b><?php echo get_lang('Sessions') ?> :</b>
|
||||
</td> |
||||
<td></td> |
||||
<td align="center"> |
||||
<b><?php echo get_lang('Courses') ?> :</b>
|
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td align="center"> |
||||
<?php |
||||
echo Display::select( |
||||
'sessions[]', |
||||
$sessionList, |
||||
'', |
||||
array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'sessions', 'size'=>'15px'), |
||||
false |
||||
); |
||||
?> |
||||
</td> |
||||
<td align="center"> |
||||
</td> |
||||
<td align="center"> |
||||
<?php |
||||
echo Display::select( |
||||
'courses[]', |
||||
$courseOptions, |
||||
'', |
||||
array('style'=>'width:360px', 'id'=>'courses', 'size'=>'15px'), |
||||
false |
||||
); |
||||
?> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td colspan="3" align="center"> |
||||
<br /> |
||||
<?php |
||||
echo '<button class="save" type="submit"" >'. |
||||
get_lang('SubscribeTeachersToSession').'</button>'; |
||||
?> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</form> |
||||
<script> |
||||
function moveItem(origin , destination) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value); |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function sortOptions(options) { |
||||
newOptions = new Array(); |
||||
for (i = 0 ; i<options.length ; i++) |
||||
newOptions[i] = options[i]; |
||||
|
||||
newOptions = newOptions.sort(mysort); |
||||
options.length = 0; |
||||
for(i = 0 ; i < newOptions.length ; i++) |
||||
options[i] = newOptions[i]; |
||||
} |
||||
|
||||
function mysort(a, b){ |
||||
if (a.text.toLowerCase() > b.text.toLowerCase()){ |
||||
return 1; |
||||
} |
||||
if (a.text.toLowerCase() < b.text.toLowerCase()){ |
||||
return -1; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
function valide(){ |
||||
var options = document.getElementById('session_in_promotion').options; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
options[i].selected = true; |
||||
document.forms.formulaire.submit(); |
||||
} |
||||
|
||||
function loadUsersInSelect(select) { |
||||
var xhr_object = null; |
||||
if(window.XMLHttpRequest) // Firefox |
||||
xhr_object = new XMLHttpRequest(); |
||||
else if(window.ActiveXObject) // Internet Explorer |
||||
xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); |
||||
else // XMLHttpRequest non supporté par le navigateur |
||||
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); |
||||
|
||||
//xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=<?php echo $id_session ?>&letter="+select.options[select.selectedIndex].text, false);
|
||||
xhr_object.open("POST", "loadUsersInSelect.ajax.php"); |
||||
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
||||
nosessionUsers = makepost(document.getElementById('session_not_in_promotion')); |
||||
sessionUsers = makepost(document.getElementById('session_in_promotion')); |
||||
nosessionClasses = makepost(document.getElementById('origin_classes')); |
||||
sessionClasses = makepost(document.getElementById('destination_classes')); |
||||
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses); |
||||
|
||||
xhr_object.onreadystatechange = function() { |
||||
if(xhr_object.readyState == 4) { |
||||
document.getElementById('content_source').innerHTML = result = xhr_object.responseText; |
||||
//alert(xhr_object.responseText); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function makepost(select) { |
||||
var options = select.options; |
||||
var ret = ""; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
ret = ret + options[i].value +'::'+options[i].text+";;"; |
||||
return ret; |
||||
} |
||||
</script> |
||||
<?php |
||||
Display::display_footer(); |
@ -0,0 +1,674 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.admin |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file = array('admin','registration'); |
||||
|
||||
// resetting the course id |
||||
$cidReset = true; |
||||
|
||||
// including some necessary files |
||||
require_once '../inc/global.inc.php'; |
||||
require_once '../inc/lib/xajax/xajax.inc.php'; |
||||
$xajax = new xajax(); |
||||
|
||||
$xajax->registerFunction('search_users'); |
||||
|
||||
// setting the section (for the tabs) |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
$id_session = intval($_GET['id_session']); |
||||
|
||||
$addProcess = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null; |
||||
|
||||
SessionManager::protect_session_edit($id_session); |
||||
|
||||
// setting breadcrumbs |
||||
$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList')); |
||||
$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview')); |
||||
|
||||
// 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_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
||||
|
||||
// setting the name of the tool |
||||
$tool_name = get_lang('SubscribeUsersToSession'); |
||||
|
||||
$add_type = 'unique'; |
||||
|
||||
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') { |
||||
$add_type = Security::remove_XSS($_REQUEST['add_type']); |
||||
} |
||||
|
||||
$page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null; |
||||
|
||||
//checking for extra field with filter on |
||||
|
||||
$extra_field_list = UserManager::get_extra_fields(); |
||||
|
||||
$new_field_list = array(); |
||||
if (is_array($extra_field_list)) { |
||||
foreach ($extra_field_list as $extra_field) { |
||||
//if is enabled to filter and is a "<select>" field type |
||||
if ($extra_field[8]==1 && $extra_field[2]==4) { |
||||
$new_field_list[] = array('name'=> $extra_field[3], 'variable'=>$extra_field[1], 'data'=> $extra_field[9]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function search_users($needle, $type) |
||||
{ |
||||
global $tbl_user,$tbl_session_rel_user,$id_session; |
||||
$xajax_response = new XajaxResponse(); |
||||
$return = ''; |
||||
|
||||
if (!empty($needle) && !empty($type)) { |
||||
|
||||
//normal behaviour |
||||
if ($type == 'any_session' && $needle == 'false') { |
||||
$type = 'multiple'; |
||||
$needle = ''; |
||||
} |
||||
|
||||
// xajax send utf8 datas... datas in db can be non-utf8 datas |
||||
$charset = api_get_system_encoding(); |
||||
$needle = Database::escape_string($needle); |
||||
$needle = api_convert_encoding($needle, $charset, 'utf-8'); |
||||
|
||||
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; |
||||
$cond_user_id = ''; |
||||
|
||||
//Only for single & multiple |
||||
if (in_array($type, array('single','multiple'))) |
||||
if (!empty($id_session)) { |
||||
$id_session = intval($id_session); |
||||
// check id_user from session_rel_user table |
||||
$sql = 'SELECT id_user FROM '.$tbl_session_rel_user.' |
||||
WHERE id_session ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' '; |
||||
$res = Database::query($sql); |
||||
$user_ids = array(); |
||||
if (Database::num_rows($res) > 0) { |
||||
while ($row = Database::fetch_row($res)) { |
||||
$user_ids[] = (int)$row[0]; |
||||
} |
||||
} |
||||
if (count($user_ids) > 0) { |
||||
$cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')'; |
||||
} |
||||
} |
||||
|
||||
switch ($type) { |
||||
case 'single': |
||||
// search users where username or firstname or lastname begins likes $needle |
||||
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code |
||||
FROM '.$tbl_user.' user |
||||
WHERE (username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%" |
||||
OR lastname LIKE "'.$needle.'%") AND user.status<>6 AND user.status<>'.DRH.''. |
||||
$order_clause. |
||||
' LIMIT 11'; |
||||
break; |
||||
case 'multiple': |
||||
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code |
||||
FROM '.$tbl_user.' user |
||||
WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.status<>6 '.$cond_user_id. |
||||
$order_clause; |
||||
break; |
||||
case 'any_session': |
||||
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code |
||||
FROM '.$tbl_user.' user |
||||
LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id) |
||||
WHERE s.id_user IS null AND user.status<>'.DRH.' AND |
||||
user.status<>6 '.$cond_user_id. |
||||
$order_clause; |
||||
break; |
||||
} |
||||
|
||||
if (api_is_multiple_url_enabled()) { |
||||
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
||||
$access_url_id = api_get_current_access_url_id(); |
||||
if ($access_url_id != -1) { |
||||
switch($type) { |
||||
case 'single': |
||||
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code |
||||
FROM '.$tbl_user.' user |
||||
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id) |
||||
WHERE access_url_id = '.$access_url_id.' AND (username LIKE "'.$needle.'%" |
||||
OR firstname LIKE "'.$needle.'%" |
||||
OR lastname LIKE "'.$needle.'%") AND user.status<>6 AND user.status<>'.DRH.' '. |
||||
$order_clause. |
||||
' LIMIT 11'; |
||||
break; |
||||
case 'multiple': |
||||
$sql = 'SELECT user.user_id, username, lastname, firstname , official_code |
||||
FROM '.$tbl_user.' user |
||||
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id) |
||||
WHERE access_url_id = '.$access_url_id.' AND |
||||
'.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND |
||||
user.status<>'.DRH.' AND |
||||
user.status<>6 '.$cond_user_id. |
||||
$order_clause; |
||||
break; |
||||
case 'any_session' : |
||||
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code |
||||
FROM '.$tbl_user.' user |
||||
LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id) |
||||
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id) |
||||
WHERE |
||||
access_url_id = '.$access_url_id.' AND |
||||
s.id_user IS null AND |
||||
user.status<>'.DRH.' AND |
||||
user.status<>6 '.$cond_user_id. |
||||
$order_clause; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
$rs = Database::query($sql); |
||||
$i = 0; |
||||
if ($type=='single') { |
||||
while ($user = Database :: fetch_array($rs)) { |
||||
$i++; |
||||
if ($i<=10) { |
||||
$person_name = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') '.$user['official_code']; |
||||
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' '.'\')">'.$person_name.' </a><br />'; |
||||
} else { |
||||
$return .= '...<br />'; |
||||
} |
||||
} |
||||
|
||||
$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return)); |
||||
} else { |
||||
global $nosessionUsersList; |
||||
$return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">'; |
||||
while ($user = Database :: fetch_array($rs)) { |
||||
$person_name = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') '.$user['official_code']; |
||||
$return .= '<option value="'.$user['user_id'].'">'.$person_name.' </option>'; |
||||
} |
||||
$return .= '</select>'; |
||||
$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return)); |
||||
} |
||||
} |
||||
return $xajax_response; |
||||
} |
||||
|
||||
$xajax->processRequests(); |
||||
|
||||
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); |
||||
$htmlHeadXtra[] = ' |
||||
<script type="text/javascript"> |
||||
function add_user_to_session (code, content) { |
||||
document.getElementById("user_to_add").value = ""; |
||||
document.getElementById("ajax_list_users_single").innerHTML = ""; |
||||
|
||||
destination = document.getElementById("destination_users"); |
||||
|
||||
for (i=0;i<destination.length;i++) { |
||||
if(destination.options[i].text == content) { |
||||
return false; |
||||
} |
||||
} |
||||
destination.options[destination.length] = new Option(content,code); |
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function remove_item(origin) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function validate_filter() { |
||||
document.formulaire.add_type.value = \''.$add_type.'\'; |
||||
document.formulaire.form_sent.value=0; |
||||
document.formulaire.submit(); |
||||
} |
||||
|
||||
function checked_in_no_session(checked) { |
||||
$("#first_letter_user") |
||||
.find("option") |
||||
.attr("selected", false); |
||||
xajax_search_users(checked, "any_session"); |
||||
} |
||||
|
||||
function change_select(val) { |
||||
$("#user_with_any_session_id").attr("checked", false); |
||||
xajax_search_users(val,"multiple"); |
||||
} |
||||
</script>'; |
||||
|
||||
$form_sent=0; |
||||
$errorMsg=$firstLetterUser=$firstLetterSession=''; |
||||
$UserList=$SessionList=array(); |
||||
$sessions=array(); |
||||
$noPHP_SELF=true; |
||||
|
||||
if (isset($_POST['form_sent']) && $_POST['form_sent']) { |
||||
$form_sent = $_POST['form_sent']; |
||||
$firstLetterUser = $_POST['firstLetterUser']; |
||||
$firstLetterSession = $_POST['firstLetterSession']; |
||||
$UserList = $_POST['sessionUsersList']; |
||||
|
||||
if (!is_array($UserList)) { |
||||
$UserList=array(); |
||||
} |
||||
|
||||
if ($form_sent == 1) { |
||||
// Added a parameter to send emails when registering a user |
||||
SessionManager::suscribe_users_to_session($id_session, $UserList, null, true); |
||||
header('Location: resume_session.php?id_session='.$id_session); |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
$session_info = SessionManager::fetch($id_session); |
||||
Display::display_header($tool_name); |
||||
|
||||
$nosessionUsersList = $sessionUsersList = array(); |
||||
|
||||
$ajax_search = $add_type == 'unique' ? true : false; |
||||
|
||||
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; |
||||
if ($ajax_search) { |
||||
$sql = "SELECT user_id, lastname, firstname, username, id_session, official_code |
||||
FROM $tbl_user u |
||||
INNER JOIN $tbl_session_rel_user |
||||
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." |
||||
AND $tbl_session_rel_user.id_session = ".intval($id_session)." |
||||
WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; |
||||
|
||||
if (api_is_multiple_url_enabled()) { |
||||
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
||||
$access_url_id = api_get_current_access_url_id(); |
||||
if ($access_url_id != -1) { |
||||
$sql="SELECT u.user_id, lastname, firstname, username, id_session, official_code |
||||
FROM $tbl_user u |
||||
INNER JOIN $tbl_session_rel_user |
||||
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." |
||||
AND $tbl_session_rel_user.id_session = ".intval($id_session)." |
||||
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) |
||||
WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 |
||||
$order_clause"; |
||||
} |
||||
} |
||||
$result = Database::query($sql); |
||||
$users = Database::store_result($result); |
||||
foreach ($users as $user) { |
||||
$sessionUsersList[$user['user_id']] = $user ; |
||||
} |
||||
unset($users); //clean to free memory |
||||
} else { |
||||
//Filter by Extra Fields |
||||
$use_extra_fields = false; |
||||
if (is_array($extra_field_list)) { |
||||
if (is_array($new_field_list) && count($new_field_list)>0 ) { |
||||
$result_list=array(); |
||||
foreach ($new_field_list as $new_field) { |
||||
$varname = 'field_'.$new_field['variable']; |
||||
if (UserManager::is_extra_field_available($new_field['variable'])) { |
||||
if (isset($_POST[$varname]) && $_POST[$varname]!='0') { |
||||
$use_extra_fields = true; |
||||
$extra_field_result[]= UserManager::get_extra_user_data_by_value($new_field['variable'], $_POST[$varname]); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ($use_extra_fields) { |
||||
$final_result = array(); |
||||
if (count($extra_field_result)>1) { |
||||
for($i=0;$i<count($extra_field_result)-1;$i++) { |
||||
if (is_array($extra_field_result[$i+1])) { |
||||
$final_result = array_intersect($extra_field_result[$i],$extra_field_result[$i+1]); |
||||
} |
||||
} |
||||
} else { |
||||
$final_result = $extra_field_result[0]; |
||||
} |
||||
|
||||
$where_filter =''; |
||||
if (api_is_multiple_url_enabled()) { |
||||
if (is_array($final_result) && count($final_result)>0) { |
||||
$where_filter = " AND u.user_id IN ('".implode("','",$final_result)."') "; |
||||
} else { |
||||
//no results |
||||
$where_filter = " AND u.user_id = -1"; |
||||
} |
||||
} else { |
||||
if (is_array($final_result) && count($final_result)>0) { |
||||
$where_filter = " WHERE u.user_id IN ('".implode("','", $final_result)."') "; |
||||
} else { |
||||
//no results |
||||
$where_filter = " WHERE u.user_id = -1"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ($use_extra_fields) { |
||||
$sql = "SELECT user_id, lastname, firstname, username, id_session, official_code |
||||
FROM $tbl_user u |
||||
LEFT JOIN $tbl_session_rel_user |
||||
ON $tbl_session_rel_user.id_user = u.user_id AND |
||||
$tbl_session_rel_user.id_session = '$id_session' AND |
||||
$tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." |
||||
$where_filter AND u.status<>".DRH." AND u.status<>6 |
||||
$order_clause"; |
||||
|
||||
} else { |
||||
$sql = "SELECT user_id, lastname, firstname, username, id_session, official_code |
||||
FROM $tbl_user u |
||||
LEFT JOIN $tbl_session_rel_user |
||||
ON $tbl_session_rel_user.id_user = u.user_id AND |
||||
$tbl_session_rel_user.id_session = '$id_session' AND |
||||
$tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." |
||||
WHERE u.status<>".DRH." AND u.status<>6 |
||||
$order_clause"; |
||||
} |
||||
if (api_is_multiple_url_enabled()) { |
||||
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
||||
$access_url_id = api_get_current_access_url_id(); |
||||
if ($access_url_id != -1) { |
||||
$sql = "SELECT u.user_id, lastname, firstname, username, id_session, official_code |
||||
FROM $tbl_user u |
||||
LEFT JOIN $tbl_session_rel_user |
||||
ON $tbl_session_rel_user.id_user = u.user_id AND |
||||
$tbl_session_rel_user.id_session = '$id_session' AND |
||||
$tbl_session_rel_user.relation_type <> ".SESSION_RELATION_TYPE_RRHH." |
||||
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) |
||||
WHERE access_url_id = $access_url_id $where_filter AND u.status<>".DRH." AND u.status<>6 |
||||
$order_clause"; |
||||
} |
||||
} |
||||
|
||||
$result = Database::query($sql); |
||||
$users = Database::store_result($result,'ASSOC'); |
||||
foreach ($users as $uid => $user) { |
||||
if ($user['id_session'] != $id_session) { |
||||
$nosessionUsersList[$user['user_id']] = array( |
||||
'fn' => $user['firstname'], |
||||
'ln' => $user['lastname'], |
||||
'un' => $user['username'], |
||||
'official_code' => $user['official_code'] |
||||
) ; |
||||
unset($users[$uid]); |
||||
} |
||||
} |
||||
unset($users); //clean to free memory |
||||
|
||||
//filling the correct users in list |
||||
$sql="SELECT user_id, lastname, firstname, username, id_session, official_code |
||||
FROM $tbl_user u |
||||
LEFT JOIN $tbl_session_rel_user |
||||
ON $tbl_session_rel_user.id_user = u.user_id AND |
||||
$tbl_session_rel_user.id_session = '$id_session' AND |
||||
$tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." |
||||
WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; |
||||
|
||||
if (api_is_multiple_url_enabled()) { |
||||
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
||||
$access_url_id = api_get_current_access_url_id(); |
||||
if ($access_url_id != -1) { |
||||
$sql="SELECT u.user_id, lastname, firstname, username, id_session, official_code |
||||
FROM $tbl_user u |
||||
LEFT JOIN $tbl_session_rel_user |
||||
ON $tbl_session_rel_user.id_user = u.user_id AND |
||||
$tbl_session_rel_user.id_session = '$id_session' AND |
||||
$tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." |
||||
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) |
||||
WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 |
||||
$order_clause"; |
||||
} |
||||
} |
||||
$result = Database::query($sql); |
||||
$users = Database::store_result($result,'ASSOC'); |
||||
foreach ($users as $uid => $user) { |
||||
if ($user['id_session'] == $id_session) { |
||||
$sessionUsersList[$user['user_id']] = $user; |
||||
if (array_key_exists($user['user_id'],$nosessionUsersList)) { |
||||
unset($nosessionUsersList[$user['user_id']]); |
||||
} |
||||
} |
||||
unset($users[$uid]); |
||||
} |
||||
unset($users); //clean to free memory |
||||
} |
||||
|
||||
if ($add_type == 'multiple') { |
||||
$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; |
||||
$link_add_type_multiple = Display::url(Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'), ''); |
||||
} else { |
||||
$link_add_type_unique = Display::url(Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'), ''); |
||||
$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; |
||||
} |
||||
$link_add_group = '<a href="usergroups.php">'.Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>'; |
||||
|
||||
$newLinks = Display::url(get_lang('EnrollTrainersFromExistingSessions'), api_get_path(WEB_CODE_PATH).'admin/add_teachers_to_session.php'); |
||||
$newLinks .= Display::url(get_lang('EnrollStudentsFromExistingSessions'), api_get_path(WEB_CODE_PATH).'admin/add_students_to_session.php'); |
||||
?> |
||||
<div class="actions"> |
||||
<?php |
||||
echo $link_add_type_unique; |
||||
echo $link_add_type_multiple; |
||||
echo $link_add_group; |
||||
echo $newLinks; |
||||
?> |
||||
</div> |
||||
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $id_session; ?><?php if(!empty($addProcess)) echo '&add=true' ; ?>" style="margin:0px;" <?php if ($ajax_search) { echo ' onsubmit="valide();"';}?>>
|
||||
<?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?> |
||||
<?php |
||||
if ($add_type=='multiple') { |
||||
if (is_array($extra_field_list)) { |
||||
if (is_array($new_field_list) && count($new_field_list)>0 ) { |
||||
echo '<h3>'.get_lang('FilterUsers').'</h3>'; |
||||
foreach ($new_field_list as $new_field) { |
||||
echo $new_field['name']; |
||||
$varname = 'field_'.$new_field['variable']; |
||||
echo ' <select name="'.$varname.'">'; |
||||
echo '<option value="0">--'.get_lang('Select').'--</option>'; |
||||
foreach ($new_field['data'] as $option) { |
||||
$checked=''; |
||||
if (isset($_POST[$varname])) { |
||||
if ($_POST[$varname]==$option[1]) { |
||||
$checked = 'selected="true"'; |
||||
} |
||||
} |
||||
echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>'; |
||||
} |
||||
echo '</select>'; |
||||
echo ' '; |
||||
} |
||||
echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />'; |
||||
echo '<br /><br />'; |
||||
} |
||||
} |
||||
} |
||||
?> |
||||
<input type="hidden" name="form_sent" value="1" /> |
||||
<input type="hidden" name="add_type" /> |
||||
|
||||
<?php |
||||
if (!empty($errorMsg)) { |
||||
Display::display_normal_message($errorMsg); //main API |
||||
} |
||||
?> |
||||
<div class="row"> |
||||
<div class="span5"> |
||||
<div class="multiple_select_header"> |
||||
<b><?php echo get_lang('UserListInPlatform') ?> :</b>
|
||||
|
||||
<?php if ($add_type=='multiple') { ?> |
||||
<?php echo get_lang('FirstLetterUser'); ?> :
|
||||
<select id="first_letter_user" name="firstLetterUser" onchange = "change_select(this.value);" > |
||||
<option value = "%">--</option> |
||||
<?php |
||||
echo Display :: get_alphabet_options(); |
||||
?> |
||||
</select> |
||||
<?php } ?> |
||||
</div> |
||||
<div id="content_source"> |
||||
<?php |
||||
if (!($add_type=='multiple')) { |
||||
?> |
||||
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" /> |
||||
<div id="ajax_list_users_single"></div> |
||||
<?php |
||||
} else { |
||||
?> |
||||
<div id="ajax_list_users_multiple"> |
||||
<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" class="span5"> |
||||
<?php |
||||
foreach ($nosessionUsersList as $uid => $enreg) { |
||||
?> |
||||
<option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>>
|
||||
<?php echo api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].') '.$enreg['official_code']; ?> |
||||
</option> |
||||
<?php |
||||
} |
||||
?> |
||||
</select> |
||||
</div> |
||||
<input type="checkbox" onchange="checked_in_no_session(this.checked);" name="user_with_any_session" id="user_with_any_session_id"> |
||||
<label for="user_with_any_session_id"><?php echo get_lang('UsersRegisteredInNoSession'); ?></label>
|
||||
<?php |
||||
} |
||||
unset($nosessionUsersList); |
||||
?> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="span2"> |
||||
<div style="padding-top:54px;width:auto;text-align: center;"> |
||||
<?php |
||||
if ($ajax_search) { |
||||
?> |
||||
<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))" ></button> |
||||
<?php |
||||
} else { |
||||
?> |
||||
<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))"> |
||||
</button> |
||||
<br /><br /> |
||||
<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))"> |
||||
</button> |
||||
<?php |
||||
} |
||||
?> |
||||
</div> |
||||
<br /> |
||||
<br /> |
||||
<?php |
||||
if (!empty($addProcess)) { |
||||
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>'; |
||||
} else { |
||||
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>'; |
||||
} |
||||
?> |
||||
</div> |
||||
|
||||
<div class="span5"> |
||||
<div class="multiple_select_header"> |
||||
<b><?php echo get_lang('UserListInSession') ?> :</b>
|
||||
</div> |
||||
<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" class="span5"> |
||||
<?php |
||||
foreach ($sessionUsersList as $enreg) { |
||||
?> |
||||
<option value="<?php echo $enreg['user_id']; ?>">
|
||||
<?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].') '.$enreg['official_code']; ?> |
||||
</option> |
||||
<?php |
||||
} |
||||
unset($sessionUsersList); |
||||
?> |
||||
</select> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
<script> |
||||
function moveItem(origin , destination) { |
||||
for(var i = 0 ; i<origin.options.length ; i++) { |
||||
if(origin.options[i].selected) { |
||||
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value); |
||||
origin.options[i]=null; |
||||
i = i-1; |
||||
} |
||||
} |
||||
destination.selectedIndex = -1; |
||||
sortOptions(destination.options); |
||||
} |
||||
|
||||
function sortOptions(options) { |
||||
newOptions = new Array(); |
||||
for (i = 0 ; i<options.length ; i++) |
||||
newOptions[i] = options[i]; |
||||
|
||||
newOptions = newOptions.sort(mysort); |
||||
options.length = 0; |
||||
for(i = 0 ; i < newOptions.length ; i++) |
||||
options[i] = newOptions[i]; |
||||
} |
||||
|
||||
function mysort(a, b){ |
||||
if(a.text.toLowerCase() > b.text.toLowerCase()){ |
||||
return 1; |
||||
} |
||||
if(a.text.toLowerCase() < b.text.toLowerCase()){ |
||||
return -1; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
function valide(){ |
||||
var options = document.getElementById('destination_users').options; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
options[i].selected = true; |
||||
document.forms.formulaire.submit(); |
||||
} |
||||
|
||||
function loadUsersInSelect(select){ |
||||
var xhr_object = null; |
||||
if(window.XMLHttpRequest) // Firefox |
||||
xhr_object = new XMLHttpRequest(); |
||||
else if(window.ActiveXObject) // Internet Explorer |
||||
xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); |
||||
else // XMLHttpRequest non supporté par le navigateur |
||||
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); |
||||
|
||||
xhr_object.open("POST", "loadUsersInSelect.ajax.php"); |
||||
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
||||
nosessionUsers = makepost(document.getElementById('origin_users')); |
||||
sessionUsers = makepost(document.getElementById('destination_users')); |
||||
nosessionClasses = makepost(document.getElementById('origin_classes')); |
||||
sessionClasses = makepost(document.getElementById('destination_classes')); |
||||
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses); |
||||
|
||||
xhr_object.onreadystatechange = function() { |
||||
if (xhr_object.readyState == 4) { |
||||
document.getElementById('content_source').innerHTML = result = xhr_object.responseText; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function makepost(select) { |
||||
var options = select.options; |
||||
var ret = ""; |
||||
for (i = 0 ; i<options.length ; i++) |
||||
ret = ret + options[i].value +'::'+options[i].text+";;"; |
||||
return ret; |
||||
} |
||||
</script> |
||||
<?php |
||||
|
||||
Display::display_footer(); |
@ -0,0 +1,57 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @package chamilo.calendar |
||||
*/ |
||||
/** |
||||
* INIT SECTION |
||||
*/ |
||||
// name of the language file that needs to be included |
||||
$language_file = array('agenda', 'group', 'announcements'); |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
require_once 'agenda.lib.php'; |
||||
require_once 'agenda.inc.php'; |
||||
|
||||
$interbreadcrumb[] = array( |
||||
'url' => api_get_path(WEB_CODE_PATH)."calendar/agenda_js.php?".api_get_cidreq(), |
||||
'name' => get_lang('Agenda') |
||||
); |
||||
|
||||
$tpl = new Template(get_lang('Events')); |
||||
|
||||
$agenda = new Agenda(); |
||||
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null; |
||||
$agenda->type = $type; |
||||
$events = $agenda->get_events( |
||||
null, |
||||
null, |
||||
api_get_course_int_id(), |
||||
api_get_group_id(), |
||||
null, |
||||
'array' |
||||
); |
||||
$url = api_get_path(WEB_CODE_PATH).'calendar/agenda_list.php?'.api_get_cidreq(); |
||||
$tpl->assign('url', $url); |
||||
$tpl->assign('agenda_events', $events); |
||||
|
||||
$actions = $agenda->displayActions('list'); |
||||
$tpl->assign('actions', $actions); |
||||
$tpl->assign('is_allowed_to_edit', api_is_allowed_to_edit()); |
||||
|
||||
if (api_is_allowed_to_edit()) { |
||||
if (isset($_GET['action']) && $_GET['action'] == 'change_visibility') { |
||||
$courseInfo = api_get_course_info(); |
||||
$agenda->changeVisibility($_GET['id'], $_GET['visibility'], $courseInfo); |
||||
header('Location: '.$url); |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
// Loading Agenda template |
||||
$content = $tpl->fetch('default/agenda/event_list.tpl'); |
||||
|
||||
$tpl->assign('content', $content); |
||||
|
||||
// Loading main Chamilo 1 col template |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,4 @@ |
||||
<?php |
||||
require_once '../inc/global.inc.php'; |
||||
header('location: '.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidReq()); |
||||
exit; |
Loading…
Reference in new issue