Updating from 1.9.x

1.10.x
Julio Montoya 11 years ago
parent b028ae3e91
commit b89edaceb6
  1. 26
      main/admin/access_url_add_courses_to_url.php
  2. 25
      main/admin/access_url_add_users_to_url.php
  3. 2
      main/admin/access_url_check_user_session.php
  4. 110
      main/admin/access_url_edit.php
  5. 2
      main/admin/access_url_edit_course_category_to_url.php
  6. 26
      main/admin/access_url_edit_courses_to_url.php
  7. 284
      main/admin/access_url_edit_users_to_url.php
  8. 96
      main/admin/add_courses_to_session.php
  9. 227
      main/admin/add_courses_to_usergroup.php
  10. 139
      main/admin/add_sessions_to_promotion.php
  11. 21
      main/admin/add_sessions_to_usergroup.php
  12. 54
      main/admin/add_users_to_group.php
  13. 19
      main/admin/configure_plugin.php
  14. 25
      main/admin/course_add.php
  15. 42
      main/admin/course_create_content.php
  16. 16
      main/admin/course_export.php
  17. 5
      main/admin/course_import.php
  18. 5
      main/admin/course_request_accepted.php
  19. 4
      main/admin/course_request_edit.php
  20. 68
      main/admin/course_request_review.php
  21. 28
      main/admin/dashboard_add_courses_to_user.php
  22. 19
      main/admin/dashboard_add_users_to_user.php
  23. 2
      main/admin/extra_fields.php
  24. 4
      main/admin/group_add.php
  25. 13
      main/admin/statistics/index.php
  26. 13
      main/gradebook/lib/be/category.class.php
  27. 9
      main/gradebook/lib/fe/linkform.class.php
  28. 21
      main/group/group.php
  29. 23
      main/group/group_category.php
  30. 2
      main/group/group_creation.php
  31. 4
      main/inc/ajax/admin.ajax.php
  32. 209
      main/inc/ajax/course.ajax.php
  33. 4
      main/inc/ajax/events.ajax.php
  34. 2
      plugin/bbb/config.php
  35. 2
      plugin/bbb/lang/english.php
  36. 1
      plugin/bbb/lang/french.php
  37. 1
      plugin/bbb/lang/spanish.php
  38. 276
      plugin/bbb/lib/bbb.lib.php
  39. 4
      plugin/bbb/lib/bbb_api.php
  40. 33
      plugin/bbb/lib/bbb_plugin.class.php
  41. 34
      plugin/bbb/listing.php
  42. 3
      plugin/bbb/plugin.php
  43. 58
      plugin/bbb/start.php
  44. 2
      plugin/before_login/plugin.php

@ -38,9 +38,7 @@ $tool_name = get_lang('AddCoursesToURL');
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); $interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs'));
/* MAIN CODE */ Display :: display_header($tool_name);
Display::display_header($tool_name);
echo '<div class="actions">'; echo '<div class="actions">';
echo Display::url( echo Display::url(
@ -71,19 +69,16 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
} }
} }
if (empty($first_letter_user)) {
$sql = "SELECT count(*) as num_courses FROM $tbl_course";
/* Display GUI */ $result = Database::query($sql);
$num_row = Database::fetch_array($result);
if(empty($first_letter_user)) {
$sql = "SELECT count(*) as num_courses FROM $tbl_course";
$result = Database::query($sql);
$num_row = Database::fetch_array($result);
if ($num_row['num_courses']>1000) { if ($num_row['num_courses']>1000) {
// assign a default filter on users names //if there are too much num_courses to gracefully handle with the HTML select list,
$first_letter_user = 'A'; // assign a default filter on users names
} $first_letter_user = 'A';
unset($result); }
unset($result);
} }
$first_letter_course = Database::escape_string($first_letter_course); $first_letter_course = Database::escape_string($first_letter_course);
@ -152,4 +147,5 @@ unset($result);
</table> </table>
</form> </form>
<?php <?php
Display :: display_footer(); Display :: display_footer();

@ -20,7 +20,6 @@ if (!api_get_multiple_access_url()) {
exit; exit;
} }
$form_sent = 0; $form_sent = 0;
$first_letter_user = ''; $first_letter_user = '';
$first_letter_course = ''; $first_letter_course = '';
@ -37,8 +36,6 @@ $tool_name = get_lang('AddUsersToURL');
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); $interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs'));
/* MAIN CODE */
Display :: display_header($tool_name); Display :: display_header($tool_name);
echo '<div class="actions">'; echo '<div class="actions">';
@ -60,31 +57,25 @@ if ($_POST['form_sent']) {
} }
if ($form_sent == 1) { if ($form_sent == 1) {
if ( count($users) == 0 || count($url_list) == 0) { if (count($users) == 0 || count($url_list) == 0) {
Display :: display_error_message(get_lang('AtLeastOneUserAndOneURL')); Display :: display_error_message(get_lang('AtLeastOneUserAndOneURL'));
//header('Location: access_urls.php?action=show_message&message='.get_lang('AtLeastOneUserAndOneURL'));
} else { } else {
UrlManager::add_users_to_urls($users,$url_list); UrlManager::add_users_to_urls($users,$url_list);
Display :: display_confirmation_message(get_lang('UsersBelongURL')); Display :: display_confirmation_message(get_lang('UsersBelongURL'));
//header('Location: access_urls.php?action=show_message&message='.get_lang('UsersBelongURL'));
} }
} }
} }
/* Display GUI */ /* Display GUI */
if (empty($first_letter_user)) { if (empty($first_letter_user)) {
$sql = "SELECT count(*) as nb_users FROM $tbl_user"; $sql = "SELECT count(*) as nb_users FROM $tbl_user";
$result = Database::query($sql); $result = Database::query($sql);
$num_row = Database::fetch_array($result); $num_row = Database::fetch_array($result);
if($num_row['nb_users']>1000) { if ($num_row['nb_users']>1000) {
//if there are too much users to gracefully handle with the HTML select list, //if there are too much users to gracefully handle with the HTML select list,
// assign a default filter on users names // assign a default filter on users names
$first_letter_user = 'A'; $first_letter_user = 'A';
} }
unset($result); unset($result);
} }
$first_letter_user = Database::escape_string($first_letter_user); $first_letter_user = Database::escape_string($first_letter_user);
@ -111,7 +102,7 @@ unset($result);
<td width="40%" align="center"> <td width="40%" align="center">
<b><?php echo get_lang('UserList'); ?></b> <b><?php echo get_lang('UserList'); ?></b>
<br/><br/> <br/><br/>
<?php echo get_lang('Select').' ' ; echo $target_name == 'firstname'? get_lang('FirstName') : get_lang('LastName'); ?> <?php echo get_lang('Select').' ' ; echo $target_name == 'firstname'? get_lang('FirstName') : get_lang('LastName'); ?>
<select name="first_letter_user" onchange="javascript:document.formulaire.form_sent.value='2'; document.formulaire.submit();"> <select name="first_letter_user" onchange="javascript:document.formulaire.form_sent.value='2'; document.formulaire.submit();">
<option value="">--</option> <option value="">--</option>
<?php <?php
@ -158,5 +149,5 @@ unset($result);
</table> </table>
</form> </form>
<?php <?php
/* FOOTER */
Display :: display_footer(); Display :: display_footer();

@ -11,6 +11,8 @@ $language_file = 'admin';
$cidReset = true; $cidReset = true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
//require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;

@ -23,24 +23,26 @@ if (!api_get_multiple_access_url()) {
// Create the form // Create the form
$form = new FormValidator('add_url'); $form = new FormValidator('add_url');
if( $form->validate()) { if ($form->validate()) {
$check = Security::check_token('post'); $check = Security::check_token('post');
if($check) { if ($check) {
$url_array = $form->getSubmitValues(); $url_array = $form->getSubmitValues();
$url = Security::remove_XSS($url_array['url']); $url = Security::remove_XSS($url_array['url']);
$description = Security::remove_XSS($url_array['description']); $description = Security::remove_XSS($url_array['description']);
$active = intval($url_array['active']); $active = intval($url_array['active']);
$url_id = $url_array['id']; $url_id = $url_array['id'];
$url_to_go='access_urls.php'; $url_to_go='access_urls.php';
if ($url_id!='') { if ($url_id != '') {
//we can't change the status of the url with id=1 //we can't change the status of the url with id=1
if ($url_id==1) if ($url_id == 1) {
$active=1; $active = 1;
}
//checking url //checking url
if (substr($url,-1)!=='/') { if (substr($url, strlen($url)-1, strlen($url)) == '/') {
$url_id .= '/'; UrlManager::update($url_id, $url, $description, $active);
} else {
UrlManager::update($url_id, $url.'/', $description, $active);
} }
UrlManager::udpate($url_id, $url, $description, $active, $url_array['url_type'], $url_array);
// URL Images // URL Images
$url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/'; $url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
$image_fields = array("url_image_1", "url_image_2", "url_image_3"); $image_fields = array("url_image_1", "url_image_2", "url_image_3");
@ -48,7 +50,10 @@ if( $form->validate()) {
if ($_FILES[$image_field]['error'] == 0) { if ($_FILES[$image_field]['error'] == 0) {
// Hardcoded: only PNG files allowed // Hardcoded: only PNG files allowed
if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') { if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') {
move_uploaded_file($_FILES[$image_field]['tmp_name'], $url_images_dir.$url_id.'_'.$image_field.'.png'); move_uploaded_file(
$_FILES[$image_field]['tmp_name'],
$url_images_dir.$url_id.'_'.$image_field.'.png'
);
} }
// else fail silently // else fail silently
} }
@ -56,49 +61,50 @@ if( $form->validate()) {
} }
$url_to_go='access_urls.php'; $url_to_go='access_urls.php';
$message=get_lang('URLEdited'); $message=get_lang('URLEdited');
} else { } else {
$num = UrlManager::url_exist($url); $num = UrlManager::url_exist($url);
if ($num == 0) { if ($num == 0) {
//checking url //checking url
if (substr($url,-1)!='/' && $url_array['url_type'] == 1) { if (substr($url, strlen($url)-1, strlen($url))=='/') {
$url.='/'; UrlManager::add($url, $description, $active);
} } else {
$url_array['ip'] = $url_array['url']; //create
UrlManager::add($url, $description, $active, $url_array['url_type'], $url_array); UrlManager::add($url.'/', $description, $active);
$message = get_lang('URLAdded'); }
$url_to_go='access_urls.php'; $message = get_lang('URLAdded');
} else { $url_to_go='access_urls.php';
$url_to_go='access_url_edit.php'; } else {
$message = get_lang('URLAlreadyAdded'); $url_to_go='access_url_edit.php';
} $message = get_lang('URLAlreadyAdded');
// URL Images }
$url .= (substr($url,strlen($url)-1, strlen($url))=='/') ? '' : '/'; // URL Images
$url_id = UrlManager::get_url_id($url); $url .= (substr($url,strlen($url)-1, strlen($url))=='/') ? '' : '/';
$url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/'; $url_id = UrlManager::get_url_id($url);
$image_fields = array("url_image_1", "url_image_2", "url_image_3"); $url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
foreach ($image_fields as $image_field) { $image_fields = array("url_image_1", "url_image_2", "url_image_3");
if ($_FILES[$image_field]['error'] == 0) { foreach ($image_fields as $image_field) {
// Hardcoded: only PNG files allowed if ($_FILES[$image_field]['error'] == 0) {
if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') { // Hardcoded: only PNG files allowed
move_uploaded_file($_FILES[$image_field]['tmp_name'], $url_images_dir.$url_id.'_'.$image_field.'.png'); if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') {
} move_uploaded_file($_FILES[$image_field]['tmp_name'], $url_images_dir.$url_id.'_'.$image_field.'.png');
// else fail silently }
} // else fail silently
// else fail silently }
} // else fail silently
} }
Security::clear_token(); }
$tok = Security::get_token(); Security::clear_token();
header('Location: '.$url_to_go.'?action=show_message&message='.urlencode($message).'&sec_token='.$tok); $tok = Security::get_token();
exit(); header('Location: '.$url_to_go.'?action=show_message&message='.urlencode($message).'&sec_token='.$tok);
} exit();
}
} else { } else {
if(isset($_POST['submit'])) { if(isset($_POST['submit'])) {
Security::clear_token(); Security::clear_token();
} }
$token = Security::get_token(); $token = Security::get_token();
$form->addElement('hidden','sec_token'); $form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token)); $form->setConstants(array('sec_token' => $token));
} }
@ -165,6 +171,4 @@ $form->addElement('file','url_image_3','URL Image 3 (PNG)');
// Submit button // Submit button
$form->addElement('style_submit_button', 'submit', $submit_name, 'class="add"'); $form->addElement('style_submit_button', 'submit', $submit_name, 'class="add"');
$form->display(); $form->display();
Display::display_footer();

@ -187,7 +187,7 @@ if (!empty($errorMsg)) {
<td align="center"><b><?php echo get_lang('CourseCategoryInPlatform') ?> :</b> <td align="center"><b><?php echo get_lang('CourseCategoryInPlatform') ?> :</b>
</td> </td>
<td></td> <td></td>
<td align="center"><b><?php echo get_lang('CourseCategoryListIn').' '.$url_selected; ?></b></td> <td align="center"><b><?php printf(get_lang('CourseCategoryListInX'),$url_selected); ?></b></td>
</tr> </tr>
<tr> <tr>

@ -39,13 +39,12 @@ $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAd
$interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); $interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs'));
$add_type = 'multiple'; $add_type = 'multiple';
if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') {
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
$access_url_id = 1; $access_url_id=1;
if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id']!=''){ if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id']!='') {
$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']); $access_url_id = Security::remove_XSS($_REQUEST['access_url_id']);
} }
@ -65,7 +64,6 @@ function add_user_to_url(code, content) {
} }
function send() { function send() {
if (document.formulaire.access_url_id.value != 0) { if (document.formulaire.access_url_id.value != 0) {
document.formulaire.form_sent.value=0; document.formulaire.form_sent.value=0;
document.formulaire.add_type.value=\''.$add_type.'\'; document.formulaire.add_type.value=\''.$add_type.'\';
@ -73,8 +71,7 @@ function send() {
} }
} }
function remove_item(origin) function remove_item(origin) {
{
for(var i = 0 ; i<origin.options.length ; i++) { for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) { if(origin.options[i].selected) {
origin.options[i]=null; origin.options[i]=null;
@ -84,14 +81,14 @@ function remove_item(origin)
} }
</script>'; </script>';
$form_sent=0; $form_sent = 0;
$errorMsg=''; $errorMsg = '';
$UserList=$SessionList=array(); $UserList = $SessionList = array();
$users=$sessions=array(); $users = $sessions = array();
if (isset($_POST['form_sent']) && $_POST['form_sent']) { if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent']; $form_sent=$_POST['form_sent'];
$course_list = $_POST['course_list']; $course_list=$_POST['course_list'];
if (!is_array($course_list)) { if (!is_array($course_list)) {
$course_list=array(); $course_list=array();
@ -302,9 +299,7 @@ function loadUsersInSelect(select){
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr_object.open("POST", "loadUsersInSelect.ajax.php"); xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById('origin_users')); nosessionUsers = makepost(document.getElementById('origin_users'));
sessionUsers = makepost(document.getElementById('destination_users')); sessionUsers = makepost(document.getElementById('destination_users'));
nosessionClasses = makepost(document.getElementById('origin_classes')); nosessionClasses = makepost(document.getElementById('origin_classes'));
@ -326,7 +321,6 @@ function makepost(select){
ret = ret + options[i].value +'::'+options[i].text+";;"; ret = ret + options[i].value +'::'+options[i].text+";;";
return ret; return ret;
} }
</script> </script>
<?php <?php

@ -1,14 +1,23 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* @package chamilo.admin * @package chamilo.admin
* @author Julio Montoya <gugli100@gmail.com> * @author Julio Montoya <gugli100@gmail.com>
*/ */
require_once __DIR__.'/../inc/lib/xajax/xajax.inc.php'; $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) . 'access_url_edit_users_to_url_functions.lib.php';
require_once '../inc/lib/xajax/xajax.inc.php';
$xajax = new xajax(); $xajax = new xajax();
$xajax -> registerFunction (array('search_users', 'Accessurledituserstourl', 'search_users')); $xajax->registerFunction(array('search_users', 'Accessurledituserstourl', 'search_users'));
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
@ -17,31 +26,32 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_global_admin_script(); api_protect_global_admin_script();
if (!api_get_multiple_access_url()) { if (!api_get_multiple_access_url()) {
header('Location: index.php'); header('Location: index.php');
exit; exit;
} }
// Database Table Definitions // Database Table Definitions
$tbl_user = Database::get_main_table(TABLE_MAIN_USER); // Database Table Definitions
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_access_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $tbl_access_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$tbl_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $tbl_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
// setting breadcrumbs // setting breadcrumbs
$tool_name = get_lang('EditUsersToURL'); $tool_name = get_lang('EditUsersToURL');
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); $interbreadcrumb[] = array('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs'));
$add_type = 'multiple'; $add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
$access_url_id=1; $access_url_id = 1;
if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id']!=''){ if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id'] != '') {
$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']); $access_url_id = Security::remove_XSS($_REQUEST['access_url_id']);
} }
$xajax -> processRequests(); $xajax->processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = '<script> $htmlHeadXtra[] = '<script>
function add_user_to_url(code, content) { function add_user_to_url(code, content) {
@ -56,7 +66,6 @@ function add_user_to_url(code, content) {
} }
function send() { function send() {
if (document.formulaire.access_url_id.value!=0) { if (document.formulaire.access_url_id.value!=0) {
document.formulaire.form_sent.value=0; document.formulaire.form_sent.value=0;
document.formulaire.add_type.value=\''.$add_type.'\'; document.formulaire.add_type.value=\''.$add_type.'\';
@ -64,8 +73,7 @@ function send() {
} }
} }
function remove_item(origin) function remove_item(origin) {
{
for(var i = 0 ; i<origin.options.length ; i++) { for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) { if(origin.options[i].selected) {
origin.options[i]=null; origin.options[i]=null;
@ -75,39 +83,38 @@ function remove_item(origin)
} }
</script>'; </script>';
$form_sent=0; $form_sent = 0;
$errorMsg=''; $errorMsg = '';
$UserList=array(); $UserList = array();
$message = ''; $message = '';
if (isset($_POST['form_sent']) && $_POST['form_sent']) { if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent']; $form_sent = $_POST['form_sent'];
$UserList = $_POST['sessionUsersList']; $UserList = $_POST['sessionUsersList'];
if (!is_array($UserList)) { if (!is_array($UserList)) {
$UserList=array(); $UserList = array();
} }
if ($form_sent == 1) {
if ($form_sent == 1) { if ($access_url_id == 0) {
if ($access_url_id == 0) { header('Location: access_url_edit_users_to_url.php?action=show_message&message=' . get_lang('SelectURL'));
header('Location: access_url_edit_users_to_url.php?action=show_message&message='.get_lang('SelectURL'));
exit; exit;
} elseif (is_array($UserList)) { } elseif (is_array($UserList)) {
$result = UrlManager::update_urls_rel_user($UserList, $access_url_id); $result = UrlManager::update_urls_rel_user($UserList, $access_url_id);
$url_info = UrlManager::get_url_data_from_id($access_url_id); $url_info = UrlManager::get_url_data_from_id($access_url_id);
if (!empty($result)) { if (!empty($result)) {
$message .= 'URL: '.$url_info['url'].'<br />'; $message .= 'URL: ' . $url_info['url'] . '<br />';
} }
if (!empty($result['users_added'])) { if (!empty($result['users_added'])) {
$message .= '<h4>'.get_lang('UsersAdded').':</h4>'; $message .= '<h4>' . get_lang('UsersAdded') . ':</h4>';
$i = 1; $i = 1;
$user_added_list = array(); $user_added_list = array();
foreach ($result['users_added'] as $user) { foreach ($result['users_added'] as $user) {
$user_info = api_get_user_info($user); $user_info = api_get_user_info($user);
if (!empty($user_info)) { if (!empty($user_info)) {
$user_added_list[] = $i.'. '.api_get_person_name($user_info['firstname'], $user_info['lastname']); $user_added_list[] = $i . '. ' . api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, null, null, $user_info['username']);
$i++; $i++;
} }
} }
@ -142,41 +149,44 @@ if (!empty($message)) {
} }
echo '<div class="actions">'; echo '<div class="actions">';
echo Display::url(Display::return_icon('view_more_stats.gif',get_lang('AddUserToURL'),''), api_get_path(WEB_CODE_PATH).'admin/access_url_add_users_to_url.php'); echo Display::url(Display::return_icon('view_more_stats.gif', get_lang('AddUserToURL'), ''), api_get_path(WEB_CODE_PATH) . 'admin/access_url_add_users_to_url.php');
echo '</div>'; echo '</div>';
api_display_tool_title($tool_name); api_display_tool_title($tool_name);
if (isset($_GET['action']) && $_GET['action'] == 'show_message') { if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message']))); Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message'])));
} }
$nosessionUsersList = $sessionUsersList = array(); $nosessionUsersList = $sessionUsersList = array();
$ajax_search = $add_type == 'unique' ? true : false; $ajax_search = $add_type == 'unique' ? true : false;
if ($ajax_search) { if ($ajax_search) {
$Users = UrlManager::get_url_rel_user_data($access_url_id); $Users = UrlManager::get_url_rel_user_data($access_url_id);
foreach ($Users as $user) { foreach ($Users as $user) {
$sessionUsersList[$user['user_id']] = $user ; $sessionUsersList[$user['user_id']] = $user;
} }
} else { } else {
$Users = UrlManager::get_url_rel_user_data(); $order_clause = api_sort_by_first_name() ? ' ORDER BY username, firstname, lastname' : ' ORDER BY username, lastname, firstname';
foreach ($Users as $user) {
if ($user['access_url_id'] == $access_url_id) { $Users = UrlManager::get_url_rel_user_data(null, $order_clause);
$sessionUsersList[$user['user_id']] = $user ; foreach ($Users as $user) {
} if ($user['access_url_id'] == $access_url_id) {
} $sessionUsersList[$user['user_id']] = $user;
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; }
$sql = "SELECT u.user_id, lastname, firstname, username ". }
" FROM $tbl_user u WHERE status <> ".ANONYMOUS." ".
$order_clause; $sql = "SELECT u.user_id, lastname, firstname, username
$result = Database::query($sql); FROM $tbl_user u WHERE status <> " . ANONYMOUS . " " .
$Users = Database::store_result($result); $order_clause;
$user_list_leys = array_keys($sessionUsersList); $result = Database::query($sql);
foreach ($Users as $user) { $Users = Database::store_result($result);
if (!in_array($user['user_id'],$user_list_leys)) $user_list_leys = array_keys($sessionUsersList);
$nosessionUsersList[$user['user_id']] = $user ; foreach ($Users as $user) {
} if (!in_array($user['user_id'], $user_list_leys)) {
$nosessionUsersList[$user['user_id']] = $user;
}
}
} }
if ($add_type == 'multiple') { if ($add_type == 'multiple') {
@ -186,9 +196,7 @@ if ($add_type == 'multiple') {
$link_add_type_unique = get_lang('SessionAddTypeUnique'); $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>'; $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(); $url_list = UrlManager::get_url_data();
?> ?>
<div style="text-align: left;"> <div style="text-align: left;">
@ -224,7 +232,7 @@ $url_list = UrlManager::get_url_data();
<?php <?php
if (!empty($errorMsg)) { if (!empty($errorMsg)) {
Display::display_normal_message($errorMsg); //main API Display::display_normal_message($errorMsg); //main API
} }
?> ?>
@ -243,93 +251,110 @@ if (!empty($errorMsg)) {
<td align="center"><b><?php echo get_lang('UserListInPlatform') ?> : <?php echo count($nosessionUsersList); ?></b> <td align="center"><b><?php echo get_lang('UserListInPlatform') ?> : <?php echo count($nosessionUsersList); ?></b>
</td> </td>
<td></td> <td></td>
<td align="center"><b><?php echo get_lang('UserListIn').' '.$url_selected; ?> :</b></td> <td align="center"><b><?php echo get_lang('UserListIn') . ' ' . $url_selected; ?> : <?php echo count($sessionUsersList); ?></b></td>
</tr> </tr>
<tr> <tr>
<td align="center"> <td align="center">
<div id="content_source"> <div id="content_source">
<?php <?php if ($ajax_search) { ?>
if ($ajax_search) { <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,document.formulaire.access_url_id.options[document.formulaire.access_url_id.selectedIndex].value)" />
?> <div id="ajax_list_users"></div>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,document.formulaire.access_url_id.options[document.formulaire.access_url_id.selectedIndex].value)" /> <?php } else { ?>
<div id="ajax_list_users"></div> <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:380px;">
<?php <?php
} else { foreach ($nosessionUsersList as $enreg) {
?> ?>
<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:380px;"> <option value="<?php echo $enreg['user_id']; ?>"><?php echo $enreg['username'].' - '.api_get_person_name($enreg['firstname'], $enreg['lastname']); ?></option>
<?php <?php
foreach ($nosessionUsersList as $enreg) { }
?> unset($nosessionUsersList);
<option value="<?php echo $enreg['user_id']; ?>"><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option> ?>
<?php </select>
} <?php
unset($nosessionUsersList); }
?> ?>
</select>
<?php
}
?>
</div> </div>
</td> </td>
<td width="10%" valign="middle" align="center"> <td width="10%" valign="middle" align="center">
<?php <?php if ($ajax_search) { ?>
if ($ajax_search) { <button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))"> </button>
?> <?php } else { ?>
<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))"> </button> <button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" ></button>
<?php <br /><br />
} else { <button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))" ></button>
?> <?php } ?>
<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 /> <br /><br /><br /><br /><br /><br />
</td> </td>
<td align="center"> <td align="center">
<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:380px;"> <select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:380px;">
<?php
<?php foreach ($sessionUsersList as $enreg) {
foreach ($sessionUsersList as $enreg) { ?>
?> <option value="<?php echo $enreg['user_id']; ?>">
<option value="<?php echo $enreg['user_id']; ?>"><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option> <?php echo $enreg['username'].' - '.api_get_person_name($enreg['firstname'], $enreg['lastname']); ?>
<?php </option>
} <?php
unset($sessionUsersList); }
?> unset($sessionUsersList);
?>
</select></td> </select></td>
</tr> </tr>
<tr> <tr>
<td colspan="3" align="center"> <td colspan="3" align="center">
<br /> <br />
<?php <?php
if (isset($_GET['add'])) if (isset($_GET['add'])) {
echo '<button class="save" type="button" onclick="valide()" >'.get_lang('AddUsersToURL').'</button>'; echo '<button class="save" type="button" onclick="valide()" >' . get_lang('AddUsersToURL') . '</button>';
else } else {
echo '<button class="save" type="button" onclick="valide()" >'.get_lang('EditUsersToURL').'</button>'; echo '<button class="save" type="button" onclick="valide()" >' . get_lang('EditUsersToURL') . '</button>';
?> }
?>
</td> </td>
</tr> </tr>
</table> </table>
</form> </form>
<script> <script>
function valide(){ 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; var options = document.getElementById('destination_users').options;
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
options[i].selected = true; options[i].selected = true;
document.forms.formulaire.submit(); document.forms.formulaire.submit();
} }
function loadUsersInSelect(select) {
function loadUsersInSelect(select){
var xhr_object = null; var xhr_object = null;
if(window.XMLHttpRequest) // Firefox if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest(); xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer else if(window.ActiveXObject) // Internet Explorer
@ -338,20 +363,15 @@ function loadUsersInSelect(select){
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr_object.open("POST", "loadUsersInSelect.ajax.php"); xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById('origin_users')); nosessionUsers = makepost(document.getElementById('origin_users'));
sessionUsers = makepost(document.getElementById('destination_users')); sessionUsers = makepost(document.getElementById('destination_users'));
nosessionClasses = makepost(document.getElementById('origin_classes')); nosessionClasses = makepost(document.getElementById('origin_classes'));
sessionClasses = makepost(document.getElementById('destination_classes')); sessionClasses = makepost(document.getElementById('destination_classes'));
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses); xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses);
xhr_object.onreadystatechange = function() { xhr_object.onreadystatechange = function() {
if(xhr_object.readyState == 4) { if (xhr_object.readyState == 4) {
document.getElementById('content_source').innerHTML = result = xhr_object.responseText; document.getElementById('content_source').innerHTML = result = xhr_object.responseText;
//alert(xhr_object.responseText);
} }
} }
} }
@ -361,9 +381,7 @@ function makepost(select){
var ret = ""; var ret = "";
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
ret = ret + options[i].value +'::'+options[i].text+";;"; ret = ret + options[i].value +'::'+options[i].text+";;";
return ret; return ret;
} }
</script> </script>
<?php <?php

@ -20,7 +20,7 @@ $add = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null;
SessionManager::protect_session_edit($id_session); SessionManager::protect_session_edit($id_session);
$xajax = new xajax(); $xajax = new xajax();
$xajax->registerFunction (array('search_courses', 'AddCourseToSession', 'search_courses')); $xajax->registerFunction(array('search_courses', 'AddCourseToSession', 'search_courses'));
// Setting the section (for the tabs) // Setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
@ -47,29 +47,25 @@ if(isset($_GET['add_type']) && $_GET['add_type']!=''){
$page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null; $page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null;
$xajax -> processRequests(); $xajax->processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = ' $htmlHeadXtra[] = '<script>
<script type="text/javascript"> function add_course_to_session(code, content) {
function add_course_to_session (code, content) {
document.getElementById("course_to_add").value = ""; document.getElementById("course_to_add").value = "";
document.getElementById("ajax_list_courses_single").innerHTML = ""; document.getElementById("ajax_list_courses_single").innerHTML = "";
destination = document.getElementById("destination"); destination = document.getElementById("destination");
for (i=0;i<destination.length;i++) { for (i=0;i<destination.length;i++) {
if(destination.options[i].text == content) { if (destination.options[i].text == content) {
return false; return false;
} }
} }
destination.options[destination.length] = new Option(content,code); destination.options[destination.length] = new Option(content,code);
destination.selectedIndex = -1; destination.selectedIndex = -1;
sortOptions(destination.options); sortOptions(destination.options);
} }
function remove_item(origin) function remove_item(origin)
{ {
for(var i = 0 ; i<origin.options.length ; i++) { for(var i = 0 ; i<origin.options.length ; i++) {
@ -81,17 +77,17 @@ function remove_item(origin)
} }
</script>'; </script>';
$formSent=0; $formSent = 0;
$errorMsg=$firstLetterCourse=$firstLetterSession=''; $errorMsg = $firstLetterCourse = $firstLetterSession = '';
$CourseList=$SessionList=array(); $CourseList = $SessionList = array();
$courses=$sessions=array(); $courses = $sessions = array();
$noPHP_SELF=true; $noPHP_SELF = true;
if (isset($_POST['formSent']) && $_POST['formSent']) { if (isset($_POST['formSent']) && $_POST['formSent']) {
$formSent = $_POST['formSent']; $formSent = $_POST['formSent'];
$firstLetterCourse = $_POST['firstLetterCourse']; $firstLetterCourse = $_POST['firstLetterCourse'];
$firstLetterSession = $_POST['firstLetterSession']; $firstLetterSession = $_POST['firstLetterSession'];
$CourseList = $_POST['SessionCoursesList']; $CourseList = $_POST['SessionCoursesList'];
if (!is_array($CourseList)) { if (!is_array($CourseList)) {
$CourseList = array(); $CourseList = array();
} }
@ -105,21 +101,20 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$existingCourses = Database::store_result($rs); $existingCourses = Database::store_result($rs);
// Updating only the RRHH users?? why? // 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 ";
$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session "; $result = Database::query($sql);
$result = Database::query($sql); $UserList = Database::store_result($result);
$UserList = Database::store_result($result);
foreach($CourseList as $enreg_course) { foreach ($CourseList as $enreg_course) {
$enreg_course = Database::escape_string($enreg_course); $enreg_course = Database::escape_string($enreg_course);
$exists = false; $exists = false;
foreach($existingCourses as $existingCourse) { foreach ($existingCourses as $existingCourse) {
if($enreg_course == $existingCourse['course_code']) { if ($enreg_course == $existingCourse['course_code']) {
$exists=true; $exists = true;
} }
} }
if(!$exists) {
if (!$exists) {
$sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course(id_session,course_code) VALUES('$id_session','$enreg_course')"; $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); Database::query($sql_insert_rel_course);
@ -131,7 +126,8 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$nbr_users=0; $nbr_users=0;
foreach ($UserList as $enreg_user) { foreach ($UserList as $enreg_user) {
$enreg_user = Database::escape_string($enreg_user['id_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')"; $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); Database::query($sql_insert);
if(Database::affected_rows()) { if(Database::affected_rows()) {
$nbr_users++; $nbr_users++;
@ -149,7 +145,6 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
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 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"); 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']); SessionManager::unInstallCourse($id_session, $course_info['real_id']);
} }
} }
$nbr_courses=count($CourseList); $nbr_courses=count($CourseList);
@ -168,12 +163,12 @@ Display::display_header($tool_name);
if ($add_type == 'multiple') { if ($add_type == 'multiple') {
$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$add.'&add_type=unique">'. $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>'; Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').' '; $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').' ';
} else { } else {
$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'&nbsp;&nbsp;&nbsp;'; $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'&nbsp;&nbsp;&nbsp;';
$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$add.'&add_type=multiple">'. $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>'; Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
} }
// the form header // the form header
@ -205,7 +200,6 @@ if ($ajax_search) {
INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.course_code=course.code) INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.course_code=course.code)
WHERE access_url_id = $access_url_id WHERE access_url_id = $access_url_id
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
} }
} }
@ -239,7 +233,7 @@ if ($ajax_search) {
} }
$result = Database::query($sql); $result = Database::query($sql);
$Courses = Database::store_result($result); $Courses = Database::store_result($result);
foreach($Courses as $course) { foreach ($Courses as $course) {
if ($course['id_session'] == $id_session) { if ($course['id_session'] == $id_session) {
$sessionCourses[$course['code']] = $course ; $sessionCourses[$course['code']] = $course ;
} else { } else {
@ -254,8 +248,7 @@ unset($Courses);
<input type="hidden" name="formSent" value="1" /> <input type="hidden" name="formSent" value="1" />
<?php <?php
if(!empty($errorMsg)) if (!empty($errorMsg)) {
{
Display::display_normal_message($errorMsg); //main API Display::display_normal_message($errorMsg); //main API
} }
?> ?>
@ -295,10 +288,11 @@ if (!($add_type == 'multiple')) {
?> ?>
<div id="ajax_list_courses_multiple"> <div id="ajax_list_courses_multiple">
<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:360px;"> <?php <select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:360px;"> <?php
foreach($nosessionCourses as $enreg) 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> <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 <?php
} }
?></select> ?></select>
@ -324,7 +318,7 @@ unset($nosessionCourses);
?> ?>
<br /><br /><br /><br /><br /><br /> <br /><br /><br /><br /><br /><br />
<?php <?php
if(isset($_GET['add'])) { if (isset($_GET['add'])) {
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('NextStep').'</button>'; echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('NextStep').'</button>';
} else { } else {
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeCoursesToSession').'</button>'; echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeCoursesToSession').'</button>';
@ -334,11 +328,11 @@ unset($nosessionCourses);
<td width="45%" align="center"><select id='destination' name="SessionCoursesList[]" multiple="multiple" size="20" style="width:360px;"> <td width="45%" align="center"><select id='destination' name="SessionCoursesList[]" multiple="multiple" size="20" style="width:360px;">
<?php <?php
foreach($sessionCourses as $enreg) 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> <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 <?php
} }
unset($sessionCourses); unset($sessionCourses);
@ -347,7 +341,7 @@ unset($sessionCourses);
</tr> </tr>
</table> </table>
</form> </form>
<script type="text/javascript"> <script>
function moveItem(origin , destination) { function moveItem(origin , destination) {
for(var i = 0 ; i<origin.options.length ; i++) { for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) { if(origin.options[i].selected) {
@ -374,7 +368,7 @@ function sortOptions(options) {
} }
} }
function mysort(a, b){ function mysort(a, b) {
if(a.text.toLowerCase() > b.text.toLowerCase()){ if(a.text.toLowerCase() > b.text.toLowerCase()){
return 1; return 1;
} }
@ -384,7 +378,7 @@ function mysort(a, b){
return 0; return 0;
} }
function valide(){ function valide() {
var options = document.getElementById('destination').options; var options = document.getElementById('destination').options;
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
options[i].selected = true; options[i].selected = true;

@ -4,44 +4,43 @@
* @package chamilo.admin * @package chamilo.admin
*/ */
// name of the language file that needs to be included // Name of the language file that needs to be included.
$language_file = array('admin','registration'); $language_file = array('admin', 'registration');
// resetting the course id // Resetting the course id.
$cidReset = true; $cidReset = true;
// including some necessary files // Including some necessary files.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once '../inc/lib/xajax/xajax.inc.php';
require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php';
$xajax = new xajax(); $xajax = new xajax();
//$xajax->debugOn();
$xajax->registerFunction('search'); $xajax->registerFunction('search');
// setting the section (for the tabs) // Setting the section (for the tabs).
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
// Access restrictions // Access restrictions.
api_protect_admin_script(true); api_protect_admin_script(true);
// setting breadcrumbs // Setting breadcrumbs.
$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes')); $interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes'));
// Database Table Definitions // Setting the name of the tool.
$tool_name = get_lang('SubscribeClassToCourses');
// setting the name of the tool
$tool_name=get_lang('SubscribeClassToCourses');
$add_type = 'multiple'; $add_type = 'multiple';
if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
$add = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null;
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = '<script> $htmlHeadXtra[] = '<script>
function add_user_to_session (code, content) { function add_user_to_session (code, content) {
document.getElementById("user_to_add").value = ""; document.getElementById("user_to_add").value = "";
document.getElementById("ajax_list_users_single").innerHTML = ""; document.getElementById("ajax_list_users_single").innerHTML = "";
@ -67,23 +66,23 @@ function remove_item(origin) {
} }
function validate_filter() { function validate_filter() {
document.formulaire.add_type.value = \''.$add_type.'\'; document.formulaire.add_type.value = \''.$add_type.'\';
document.formulaire.form_sent.value=0; document.formulaire.form_sent.value=0;
document.formulaire.submit(); document.formulaire.submit();
} }
</script>'; </script>';
$form_sent = 0; $form_sent = 0;
$errorMsg = ''; $errorMsg = '';
$sessions=array(); $sessions = array();
$usergroup = new UserGroup(); $usergroup = new UserGroup();
$id = intval($_GET['id']); $id = intval($_GET['id']);
if (isset($_POST['form_sent']) && $_POST['form_sent']) { if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent']; $form_sent = $_POST['form_sent'];
$elements_posted = $_POST['elements_in_name']; $elements_posted = $_POST['elements_in_name'];
if (!is_array($elements_posted)) { if (!is_array($elements_posted)) {
$elements_posted=array(); $elements_posted = array();
} }
if ($form_sent == 1) { if ($form_sent == 1) {
$usergroup->subscribe_courses_to_usergroup($id, $elements_posted); $usergroup->subscribe_courses_to_usergroup($id, $elements_posted);
@ -91,28 +90,66 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
exit; exit;
} }
} }
$data = $usergroup->get($id);
$course_list_in = $usergroup->get_courses_by_usergroup($id);
$course_list = CourseManager::get_courses_list(0,0,'title');
//api_display_tool_title($tool_name.' ('.$session_info['name'].')');
$elements_not_in = $elements_in= array();
if (!empty($course_list)) { // Filters
foreach($course_list as $item) { $filters = array(
if (in_array($item['id'], $course_list_in)) { array('type' => 'text', 'name' => 'code', 'label' => get_lang('CourseCode')),
$elements_in[$item['id']] = $item['title']." (".$item['visual_code'].")"; array('type' => 'text', 'name' => 'title', 'label' => get_lang('Title')),
} else { /*array('type' => 'text', 'name' => 'lastname', 'label' => get_lang('LastName')),
$elements_not_in[$item['id']] = $item['title']." (".$item['visual_code'].")"; array('type' => 'text', 'name' => 'official_code', 'label' => get_lang('OfficialCode')),
array('type' => 'text', 'name' => 'email', 'label' => get_lang('Email'))*/
);
$searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id);
$searchForm->add_header(get_lang('AdvancedSearch'));
$renderer =& $searchForm->defaultRenderer();
$searchForm->addElement('hidden', 'id', $id);
foreach ($filters as $param) {
$searchForm->addElement($param['type'], $param['name'], $param['label']);
}
$searchForm->addElement('button', 'submit', get_lang('Search'));
$filterData = array();
if ($searchForm->validate()) {
$filterData = $searchForm->getSubmitValues();
}
$conditions = array();
if (!empty($filters) && !empty($filterData)) {
foreach ($filters as $filter) {
if (isset($filter['name']) && isset($filterData[$filter['name']])) {
$value = $filterData[$filter['name']];
if (!empty($value)) {
$conditions[$filter['name']] = $value;
}
} }
} }
} }
$data = $usergroup->get($id);
$course_list_in = $usergroup->get_courses_by_usergroup($id, true);
$course_list = CourseManager::get_courses_list(0, 0, 'title', 'asc', -1, null, api_get_current_access_url_id(), false, $conditions);
$elements_not_in = $elements_in = array();
foreach ($course_list_in as $course) {
$elements_in[$course['id']] = $course['title']." (".$course['visual_code'].")";
}
if (!empty($course_list)) {
foreach ($course_list as $item) {
$elements_not_in[$item['id']] = $item['title']." (".$item['visual_code'].")";
}
}
$ajax_search = $add_type == 'unique' ? true : false; $ajax_search = $add_type == 'unique' ? true : false;
//checking for extra field with filter on //checking for extra field with filter on
function search($needle,$type) { function search($needle,$type)
global $tbl_user,$elements_in; {
global $elements_in;
$xajax_response = new XajaxResponse(); $xajax_response = new XajaxResponse();
$return = ''; $return = '';
if (!empty($needle) && !empty($type)) { if (!empty($needle) && !empty($type)) {
@ -133,7 +170,6 @@ function search($needle,$type) {
} else { } else {
$list = CourseManager::get_courses_list(0, 0, 2, 'ASC', -1, $needle); $list = CourseManager::get_courses_list(0, 0, 2, 'ASC', -1, $needle);
} }
$i=0;
if ($type=='single') { if ($type=='single') {
/* /*
while ($user = Database :: fetch_array($rs)) { while ($user = Database :: fetch_array($rs)) {
@ -149,68 +185,50 @@ function search($needle,$type) {
} else { } else {
$return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">'; $return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">';
foreach ($list as $row ) { foreach ($list as $row) {
if (!in_array($row['id'], array_keys($elements_in))) { if (!in_array($row['id'], array_keys($elements_in))) {
$return .= '<option value="'.$row['id'].'">'.$row['title'].' ('.$row['visual_code'].')</option>'; $return .= '<option value="'.$row['id'].'">'.$row['title'].' ('.$row['visual_code'].')</option>';
} }
} }
$return .= '</select>'; $return .= '</select>';
$xajax_response -> addAssign('ajax_list_multiple','innerHTML',api_utf8_encode($return)); $xajax_response->addAssign('ajax_list_multiple', 'innerHTML', api_utf8_encode($return));
} }
} }
return $xajax_response; return $xajax_response;
} }
$xajax -> processRequests();
$xajax->processRequests();
Display::display_header($tool_name); Display::display_header($tool_name);
if ($add_type == 'multiple') { if ($add_type == 'multiple') {
$link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; $link_add_type_unique = '<a href="'.api_get_self().'?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'); $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
} else { } else {
$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
$link_add_type_multiple = '<a href="'.api_get_self().'?add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; $link_add_type_multiple = '<a href="'.api_get_self().'?add='.$add.'&add_type=multiple">'.
Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
} }
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'), array(), ICON_SIZE_MEDIUM).'</a>'; echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'), array(), ICON_SIZE_MEDIUM).'</a>';
echo Display::url(get_lang('AdvancedSearch'), '#', array('class' => 'advanced_options', 'id' => 'advanced_search'));
echo '</div>'; echo '</div>';
echo '<div id="advanced_search_options" style="display:none">';
$searchForm->display();
echo '</div>';
?> ?>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
<?php echo '<legend>'.$data['name'].': '.$tool_name.'</legend>'; <?php echo '<legend>'.$data['name'].': '.$tool_name.'</legend>';
/* echo Display::input('hidden', 'id', $id);
if ($add_type=='multiple') { echo Display::input('hidden', 'form_sent', '1');
if (is_array($extra_field_list)) { echo Display::input('hidden', 'add_type', null);
if (is_array($new_field_list) && count($new_field_list)>0 ) { if (!empty($errorMsg)) {
echo '<h3>'.get_lang('FilterUsers').'</h3>';
foreach ($new_field_list as $new_field) {
echo $new_field['name'];
$varname = 'field_'.$new_field['variable'];
echo '&nbsp;<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 '&nbsp;&nbsp;';
}
echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
echo '<br /><br />';
}
}
}*/
echo Display::input('hidden','id',$id);
echo Display::input('hidden','form_sent','1');
echo Display::input('hidden','add_type',null);
if(!empty($errorMsg)) {
Display::display_normal_message($errorMsg); //main API Display::display_normal_message($errorMsg); //main API
} }
?> ?>
@ -227,12 +245,12 @@ if(!empty($errorMsg)) {
<tr> <tr>
<td align="center"> <td align="center">
<?php echo get_lang('FirstLetterCourseTitle'); ?> : <?php echo get_lang('FirstLetterCourseTitle'); ?> :
<select name="firstLetterUser" onchange = "xajax_search(this.value,'multiple')" > <select name="firstLetterUser" onchange = "xajax_search(this.value,'multiple')" >
<option value = "%">--</option> <option value = "%">--</option>
<?php <?php
echo Display :: get_alphabet_options(); echo Display :: get_alphabet_options();
?> ?>
</select> </select>
</td> </td>
<td align="center">&nbsp;</td> <td align="center">&nbsp;</td>
</tr> </tr>
@ -249,7 +267,7 @@ if(!empty($errorMsg)) {
} else { } else {
?> ?>
<div id="ajax_list_multiple"> <div id="ajax_list_multiple">
<?php echo Display::select('elements_not_in_name',$elements_not_in, '',array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?> <?php echo Display::select('elements_not_in_name', $elements_not_in, '', array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?>
</div> </div>
<?php <?php
} }
@ -290,7 +308,44 @@ if(!empty($errorMsg)) {
</table> </table>
</form> </form>
<script> <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(){ function valide(){
var options = document.getElementById('elements_in').options; var options = document.getElementById('elements_in').options;
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
@ -298,9 +353,7 @@ function valide(){
document.forms.formulaire.submit(); document.forms.formulaire.submit();
} }
function loadUsersInSelect(select) {
function loadUsersInSelect(select){
var xhr_object = null; var xhr_object = null;
if(window.XMLHttpRequest) // Firefox if(window.XMLHttpRequest) // Firefox
@ -308,13 +361,11 @@ function loadUsersInSelect(select){
else if(window.ActiveXObject) // Internet Explorer else if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporté par le navigateur else // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr_object.open("POST", "loadUsersInSelect.ajax.php"); xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById('elements_not_in')); nosessionUsers = makepost(document.getElementById('elements_not_in'));
sessionUsers = makepost(document.getElementById('elements_in')); sessionUsers = makepost(document.getElementById('elements_in'));
nosessionClasses = makepost(document.getElementById('origin_classes')); nosessionClasses = makepost(document.getElementById('origin_classes'));
@ -324,7 +375,6 @@ function loadUsersInSelect(select){
xhr_object.onreadystatechange = function() { xhr_object.onreadystatechange = function() {
if(xhr_object.readyState == 4) { if(xhr_object.readyState == 4) {
document.getElementById('content_source').innerHTML = result = xhr_object.responseText; document.getElementById('content_source').innerHTML = result = xhr_object.responseText;
//alert(xhr_object.responseText);
} }
} }
} }
@ -334,7 +384,6 @@ function makepost(select){
var ret = ""; var ret = "";
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
ret = ret + options[i].value +'::'+options[i].text+";;"; ret = ret + options[i].value +'::'+options[i].text+";;";
return ret; return ret;
} }
</script> </script>

@ -5,18 +5,16 @@
*/ */
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file=array('admin','registration'); $language_file = array('admin','registration');
// resetting the course id // resetting the course id
$cidReset=true; $cidReset = true;
// including some necessary files // including some necessary files
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
$xajax = new xajax(); $xajax = new xajax();
$xajax->registerFunction ('search_sessions');
//$xajax->debugOn();
$xajax -> registerFunction ('search_sessions');
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
@ -29,12 +27,9 @@ $interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'
$interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions')); $interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions'));
// Database Table Definitions // Database Table Definitions
$tool_name = get_lang('SubscribeSessionsToPromotions');
// setting the name of the tool
$tool_name=get_lang('SubscribeSessionsToPromotions');
$add_type = 'multiple'; $add_type = 'multiple';
if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
@ -79,9 +74,9 @@ $errorMsg = '';
$users =$sessions=array(); $users =$sessions=array();
$promotion = new Promotion(); $promotion = new Promotion();
$id = intval($_GET['id']); $id = intval($_GET['id']);
if($_POST['form_sent']) { if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent']; $form_sent = $_POST['form_sent'];
$session_in_promotion_posted = $_POST['session_in_promotion_name']; $session_in_promotion_posted = $_POST['session_in_promotion_name'];
if (!is_array($session_in_promotion_posted)) { if (!is_array($session_in_promotion_posted)) {
$session_in_promotion_posted=array(); $session_in_promotion_posted=array();
} }
@ -95,12 +90,10 @@ if($_POST['form_sent']) {
$promotion_data = $promotion->get($id); $promotion_data = $promotion->get($id);
$session_list = SessionManager::get_sessions_list(array(), array('name')); $session_list = SessionManager::get_sessions_list(array(), array('name'));
//api_display_tool_title($tool_name.' ('.$session_info['name'].')');
$session_not_in_promotion = $session_in_promotion= array(); $session_not_in_promotion = $session_in_promotion= array();
if (!empty($session_list)) { if (!empty($session_list)) {
foreach($session_list as $session) { foreach ($session_list as $session) {
$promotion_id = $session['promotion_id']; $promotion_id = $session['promotion_id'];
if (isset($promotion_id) && !empty($promotion_id)) { if (isset($promotion_id) && !empty($promotion_id)) {
if ($promotion_id == $id) { if ($promotion_id == $id) {
@ -117,8 +110,9 @@ $ajax_search = $add_type == 'unique' ? true : false;
//checking for extra field with filter on //checking for extra field with filter on
function search_sessions($needle,$type) { function search_sessions($needle, $type)
global $tbl_user,$session_in_promotion; {
global $session_in_promotion;
$xajax_response = new XajaxResponse(); $xajax_response = new XajaxResponse();
$return = ''; $return = '';
if (!empty($needle) && !empty($type)) { if (!empty($needle) && !empty($type)) {
@ -128,44 +122,20 @@ function search_sessions($needle,$type) {
$needle = Database::escape_string($needle); $needle = Database::escape_string($needle);
$needle = api_convert_encoding($needle, $charset, 'utf-8'); $needle = api_convert_encoding($needle, $charset, 'utf-8');
if ($type == 'single') { $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "$needle%"));
// search users where username or firstname or lastname begins likes $needle $return .= '<select id="session_not_in_promotion" name="session_not_in_promotion_name[]" multiple="multiple" size="15" style="width:360px;">';
/* $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user foreach ($session_list as $row ) {
WHERE (username LIKE "'.$needle.'%" if (!in_array($row['id'], array_keys($session_in_promotion))) {
OR firstname LIKE "'.$needle.'%" $return .= '<option value="'.$row['id'].'">'.$row['name'].'</option>';
OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.''.
$order_clause.
' LIMIT 11';*/
} else {
$session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "$needle%"));
}
$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']);
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
} else {
$return .= '...<br />';
}
}
$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));*/
} else {
$return .= '<select id="session_not_in_promotion" name="session_not_in_promotion_name[]" multiple="multiple" size="15" style="width:360px;">';
foreach ($session_list as $row ) {
if (!in_array($row['id'], array_keys($session_in_promotion))) {
$return .= '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
} }
$return .= '</select>';
$xajax_response -> addAssign('ajax_list_multiple','innerHTML',api_utf8_encode($return));
} }
$return .= '</select>';
$xajax_response -> addAssign('ajax_list_multiple','innerHTML',api_utf8_encode($return));
} }
return $xajax_response; return $xajax_response;
} }
$xajax -> processRequests(); $xajax->processRequests();
Display::display_header($tool_name); Display::display_header($tool_name);
@ -187,7 +157,7 @@ echo '</div>';
if ($add_type=='multiple') { if ($add_type=='multiple') {
if (is_array($extra_field_list)) { if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list)>0 ) { if (is_array($new_field_list) && count($new_field_list) > 0) {
echo '<h3>'.get_lang('FilterUsers').'</h3>'; echo '<h3>'.get_lang('FilterUsers').'</h3>';
foreach ($new_field_list as $new_field) { foreach ($new_field_list as $new_field) {
echo $new_field['name']; echo $new_field['name'];
@ -211,10 +181,10 @@ if ($add_type=='multiple') {
} }
} }
} }
echo Display::input('hidden','id',$id); echo Display::input('hidden', 'id', $id);
echo Display::input('hidden','form_sent','1'); echo Display::input('hidden', 'form_sent', '1');
echo Display::input('hidden','add_type',null); echo Display::input('hidden', 'add_type', null);
if(!empty($errorMsg)) { if (!empty($errorMsg)) {
Display::display_normal_message($errorMsg); //main API Display::display_normal_message($errorMsg); //main API
} }
?> ?>
@ -278,7 +248,13 @@ if(!empty($errorMsg)) {
</td> </td>
<td align="center"> <td align="center">
<?php <?php
echo Display::select('session_in_promotion_name[]', $session_in_promotion, '', array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'session_in_promotion','size'=>'15px'),false ); echo Display::select(
'session_in_promotion_name[]',
$session_in_promotion,
'',
array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'session_in_promotion','size'=>'15px'),
false
);
unset($sessionUsersList); unset($sessionUsersList);
?> ?>
</td> </td>
@ -293,8 +269,40 @@ if(!empty($errorMsg)) {
</tr> </tr>
</table> </table>
</form> </form>
<script> <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(){ function valide(){
var options = document.getElementById('session_in_promotion').options; var options = document.getElementById('session_in_promotion').options;
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
@ -302,11 +310,8 @@ function valide(){
document.forms.formulaire.submit(); document.forms.formulaire.submit();
} }
function loadUsersInSelect(select) {
function loadUsersInSelect(select){
var xhr_object = null; var xhr_object = null;
if(window.XMLHttpRequest) // Firefox if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest(); xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer else if(window.ActiveXObject) // Internet Explorer
@ -316,10 +321,7 @@ function loadUsersInSelect(select){
//xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=<?php echo $id_session ?>&letter="+select.options[select.selectedIndex].text, false); //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.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById('session_not_in_promotion')); nosessionUsers = makepost(document.getElementById('session_not_in_promotion'));
sessionUsers = makepost(document.getElementById('session_in_promotion')); sessionUsers = makepost(document.getElementById('session_in_promotion'));
nosessionClasses = makepost(document.getElementById('origin_classes')); nosessionClasses = makepost(document.getElementById('origin_classes'));
@ -334,16 +336,11 @@ function loadUsersInSelect(select){
} }
} }
function makepost(select){ function makepost(select) {
var options = select.options; var options = select.options;
var ret = ""; var ret = "";
for (i = 0 ; i<options.length ; i++) for (i = 0 ; i<options.length ; i++)
ret = ret + options[i].value +'::'+options[i].text+";;"; ret = ret + options[i].value +'::'+options[i].text+";;";
return ret; return ret;
} }
</script> </script>
<?php
Display::display_footer();

@ -132,6 +132,8 @@ function search_sessions($needle,$type) {
OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.''. OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.''.
$order_clause. $order_clause.
' LIMIT 11';*/ ' LIMIT 11';*/
} else if ($type == 'searchbox') {
$session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "%$needle%"));
} else { } else {
$session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "$needle%")); $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "$needle%"));
} }
@ -167,24 +169,28 @@ $xajax -> processRequests();
Display::display_header($tool_name); Display::display_header($tool_name);
if ($add_type == 'multiple') { if ($add_type == 'multiple') {
$link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; $link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['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'); $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
} else { } else {
$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
$link_add_type_multiple = '<a href="'.api_get_self().'?add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; $link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
} }
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>'; echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="javascript://" class="advanced_parameters" style="margin-top: 8px" onclick="display_advanced_search();"><span id="img_plus_and_minus">&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').'</span></a>';
echo '</div>'; echo '</div>';
?> ?>
<?php echo '<div id="advancedSearch" style="display: none">'. get_lang('SearchSessions'); ?> :
<input name="SearchSession" onchange = "xajax_search_sessions(this.value,'searchbox')" onkeyup="this.onchange()">
</div>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
<?php <?php
echo '<legend>'.$data['name'].': '.$tool_name.'</legend>'; echo '<legend>'.$data['name'].': '.$tool_name.'</legend>';
if ($add_type=='multiple') { if ($add_type=='multiple') {
/*
if (is_array($extra_field_list)) { if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list)>0 ) { if (is_array($new_field_list) && count($new_field_list)>0 ) {
echo '<h3>'.get_lang('FilterUsers').'</h3>'; echo '<h3>'.get_lang('FilterUsers').'</h3>';
@ -208,7 +214,7 @@ if ($add_type=='multiple') {
echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />'; echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
echo '<br /><br />'; echo '<br /><br />';
} }
}*/ }
} }
echo Display::input('hidden','id',$id); echo Display::input('hidden','id',$id);
echo Display::input('hidden','form_sent','1'); echo Display::input('hidden','form_sent','1');
@ -236,6 +242,7 @@ if(!empty($errorMsg)) {
echo Display :: get_alphabet_options(); echo Display :: get_alphabet_options();
?> ?>
</select> </select>
<?php echo '<br />'; ?>
</td> </td>
<td align="center">&nbsp;</td> <td align="center">&nbsp;</td>
</tr> </tr>
@ -243,8 +250,8 @@ if(!empty($errorMsg)) {
<tr> <tr>
<td align="center"> <td align="center">
<div id="content_source"> <div id="content_source">
<?php <?php
if (!($add_type=='multiple')) { if (!($add_type=='multiple')) {
?> ?>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" /> <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
<div id="ajax_list_users_single"></div> <div id="ajax_list_users_single"></div>

@ -5,10 +5,10 @@
*/ */
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file=array('admin','registration','userInfo'); $language_file = array('admin','registration','userInfo');
// resetting the course id // resetting the course id
$cidReset=true; $cidReset = true;
// including some necessary files // including some necessary files
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
@ -16,27 +16,29 @@ require_once '../inc/global.inc.php';
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
global $_configuration;
// Access restrictions // Access restrictions
api_protect_admin_script(true); api_protect_admin_script(true);
// setting breadcrumbs // setting breadcrumbs
$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[]=array('url' => 'group_list.php','name' => get_lang('GroupList')); $interbreadcrumb[] = array('url' => 'group_list.php','name' => get_lang('GroupList'));
// Database Table Definitions // Database Table Definitions
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $tbl_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$needle = null;
$user_anonymous = api_get_anonymous_id();
// setting the name of the tool // setting the name of the tool
$tool_name = get_lang('SubscribeUsersToGroup'); $tool_name = get_lang('SubscribeUsersToGroup');
$group_id = intval($_GET['id']); $group_id = intval($_GET['id']);
$without_user_id = null;
$add_type = 'multiple'; $add_type = 'multiple';
if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
//checking for extra field with filter on //checking for extra field with filter on
@ -177,16 +179,10 @@ function search_users($needle,$type,$relation_type) {
$xajax->processRequests(); $xajax->processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = ' $htmlHeadXtra[] = '
<script> <script>
function add_user (code, content) { function add_user (code, content) {
// document.getElementById("user_to_add").value = "";
//document.getElementById("ajax_list_users_single").innerHTML = "";
destination = document.getElementById("destination_users"); destination = document.getElementById("destination_users");
for (i=0;i<destination.length;i++) { for (i=0;i<destination.length;i++) {
if(destination.options[i].text == content) { if(destination.options[i].text == content) {
return false; return false;
@ -196,8 +192,8 @@ function add_user (code, content) {
destination.options[destination.length] = new Option(content,code); destination.options[destination.length] = new Option(content,code);
destination.selectedIndex = -1; destination.selectedIndex = -1;
sortOptions(destination.options); sortOptions(destination.options);
} }
function remove_item(origin) function remove_item(origin)
{ {
for(var i = 0 ; i<origin.options.length ; i++) { for(var i = 0 ; i<origin.options.length ; i++) {
@ -209,30 +205,28 @@ function remove_item(origin)
} }
function validate_filter() { function validate_filter() {
document.formulaire.add_type.value = \''.$add_type.'\'; document.formulaire.add_type.value = \''.$add_type.'\';
document.formulaire.form_sent.value=0; document.formulaire.form_sent.value=0;
document.formulaire.submit(); document.formulaire.submit();
} }
</script>'; </script>';
$form_sent=0; $form_sent = 0;
$errorMsg=$firstLetterUser=$firstLetterSession=''; $errorMsg = $firstLetterUser = $firstLetterSession='';
$UserList=$SessionList=array(); $UserList = $SessionList = array();
$users=$sessions=array(); $users = $sessions = array();
$noPHP_SELF=true; $noPHP_SELF = true;
$group_info = GroupPortalManager::get_group_data($group_id); $group_info = GroupPortalManager::get_group_data($group_id);
$group_name = $group_info['name']; $group_name = $group_info['name'];
Display::display_header($group_name); Display::display_header($group_name);
if ($_POST['form_sent']) { if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$form_sent = $_POST['form_sent']; $firstLetterUser = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null;
$firstLetterUser = $_POST['firstLetterUser']; $UserList = $_POST['sessionUsersList'];
$UserList = $_POST['sessionUsersList']; $group_id = intval($_POST['id']);
$group_id = intval($_POST['id']); $relation_type = intval($_POST['relation']);
$relation_type = intval($_POST['relation']);
if(!is_array($UserList)) { if(!is_array($UserList)) {
$UserList=array(); $UserList=array();

@ -16,7 +16,7 @@ api_protect_admin_script();
$plugin_name = $_GET['name']; $plugin_name = $_GET['name'];
$plugin_obj = new AppPlugin(); $plugin_obj = new AppPlugin();
$plugin_info = $plugin_obj->get_plugin_info($plugin_name, true); $plugin_info = $plugin_obj->getPluginInfo($plugin_name, true);
if (empty($plugin_info)) { if (empty($plugin_info)) {
api_not_allowed(); api_not_allowed();
@ -29,7 +29,7 @@ if (!in_array($plugin_name, $installed_plugins)) {
} }
global $_configuration; global $_configuration;
$message = null;
$content = null; $content = null;
if (isset($plugin_info['settings_form'])) { if (isset($plugin_info['settings_form'])) {
@ -55,8 +55,19 @@ if (isset($form)) {
array('Plugins', $access_url_id, $plugin_name, 'setting', "status"))); array('Plugins', $access_url_id, $plugin_name, 'setting', "status")));
foreach ($values as $key => $value) { foreach ($values as $key => $value) {
$key = Database::escape_string($plugin_name.'_'.$key); $key = Database::escape_string($plugin_name.'_'.$key);
api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, api_get_current_access_url_id(), 1); api_add_setting(
$value,
$key,
$plugin_name,
'setting',
'Plugins',
$plugin_name,
null,
null,
null,
$_configuration['access_url'],
1
);
} }
$message = Display::return_message(get_lang('Updated'), 'success'); $message = Display::return_message(get_lang('Updated'), 'success');
} }

@ -37,14 +37,13 @@ if (api_is_multiple_url_enabled()) {
$res = Database::query($sql); $res = Database::query($sql);
$teachers = array(); $teachers = array();
//$teachers[0] = '-- '.get_lang('NoManager').' --'; while ($obj = Database::fetch_object($res)) {
while($obj = Database::fetch_object($res)) {
$teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname); $teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
} }
// Build the form. // Build the form.
$form = new FormValidator('update_course'); $form = new FormValidator('update_course');
$form->addElement('header', '', $tool_name); $form->addElement('header', $tool_name);
// Title // Title
$form->add_textfield('title', get_lang('Title'), true, array ('class' => 'span6')); $form->add_textfield('title', get_lang('Title'), true, array ('class' => 'span6'));
@ -52,15 +51,12 @@ $form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim'); $form->applyFilter('title', 'trim');
// Code // Code
$form->add_textfield('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')), false, array('class' => 'span3', 'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE)); $form->add_textfield('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')) , false, array('class' => 'span3', 'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE));
$form->applyFilter('visual_code', 'api_strtoupper'); $form->applyFilter('visual_code', 'api_strtoupper');
$form->applyFilter('visual_code', 'html_filter'); $form->applyFilter('visual_code', 'html_filter');
$form->addRule('visual_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE); $form->addRule('visual_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE);
//$form->addElement('select', 'tutor_id', get_lang('CourseTitular'), $teachers, array('style' => 'width:350px', 'class'=>'chzn-select', 'id'=>'tutor_id'));
//$form->applyFilter('tutor_id', 'html_filter');
$form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, ' id="course_teachers" class="chzn-select" style="width:350px" multiple="multiple" '); $form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, ' id="course_teachers" class="chzn-select" style="width:350px" multiple="multiple" ');
$form->applyFilter('course_teachers', 'html_filter'); $form->applyFilter('course_teachers', 'html_filter');
@ -125,23 +121,26 @@ if (isset($default_course_visibility)) {
} }
$values['subscribe'] = 1; $values['subscribe'] = 1;
$values['unsubscribe'] = 0; $values['unsubscribe'] = 0;
reset($teachers);
//$values['course_teachers'] = key($teachers);
$form->setDefaults($values); $form->setDefaults($values);
// Validate the form // Validate the form
if ($form->validate()) { if ($form->validate()) {
$course = $form->exportValues(); $course = $form->exportValues();
//$tutor_name = $teachers[$course['tutor_id']]; $teacher_id = $course['tutor_id'];
$course['user_id'] = isset($course['tutor_id']) ? $course['tutor_id'] : null; $course_teachers = $course['course_teachers'];
$course['teachers'] = isset($course['course_teachers']) ? $course['course_teachers'] : null;
$course['disk_quota'] = $course['disk_quota']*1024*1024; $course['disk_quota'] = $course['disk_quota']*1024*1024;
$course['exemplary_content'] = empty($course['exemplary_content']) ? false : true; $course['exemplary_content'] = empty($course['exemplary_content']) ? false : true;
//$course['tutor_name'] = $tutor_name; $course['teachers'] = $course_teachers;
$course['user_id'] = $teacher_id;
$course['wanted_code'] = $course['visual_code']; $course['wanted_code'] = $course['visual_code'];
$course['gradebook_model_id'] = isset($course['gradebook_model_id']) ? $course['gradebook_model_id'] : null; $course['gradebook_model_id'] = isset($course['gradebook_model_id']) ? $course['gradebook_model_id'] : null;
// Fixing category code
$course['course_category'] = $course['category_code'];
$course_info = CourseManager::create_course($course); $course_info = CourseManager::create_course($course);
header('Location: course_list.php'.($course_info===false?'?action=show_msg&warn='.api_get_last_failure():'')); header('Location: course_list.php'.($course_info===false?'?action=show_msg&warn='.api_get_last_failure():''));
exit; exit;
} }

@ -7,31 +7,39 @@
* @package chamilo.admin * @package chamilo.admin
*/ */
/** /**
* INIT SECTION * INIT SECTION
*/ */
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file = 'admin'; $language_file = 'admin';
include('../inc/global.inc.php'); include ('../inc/global.inc.php');
$this_section = SECTION_PLATFORM_ADMIN; $this_section=SECTION_PLATFORM_ADMIN;
api_protect_admin_script(); api_protect_admin_script();
$tool_name = get_lang('DummyCourseCreator'); $tool_name = get_lang('DummyCourseCreator');
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
Display::display_header($tool_name); Display::display_header($tool_name);
//api_display_tool_title($tool_name); //api_display_tool_title($tool_name);
if (api_get_setting('server_type') != 'test') { if(api_get_setting('server_type') != 'test')
echo get_lang('DummyCourseOnlyOnTestServer'); {
} elseif (isset($_POST['action'])) { echo get_lang('DummyCourseOnlyOnTestServer');
require_once api_get_path(SYS_CODE_PATH).'coursecopy/classes/DummyCourseCreator.class.php'; }
elseif( isset($_POST['action']))
$dcc = new DummyCourseCreator(); {
$dcc->create_dummy_course($_POST['course_code']); require_once('../coursecopy/classes/DummyCourseCreator.class.php');
echo get_lang('Done'); $dcc = new DummyCourseCreator();
} else { $dcc->create_dummy_course($_POST['course_code']);
echo get_lang('DummyCourseDescription'); echo get_lang('Done');
echo '<form method="post"><input type="hidden" name="course_code" value="'.Security::remove_XSS( }
$_GET['course_code'] else
).'"/><input type="submit" name="action" value="'.get_lang('Ok').'"/></form>'; {
echo get_lang('DummyCourseDescription');
echo '<form method="post"><input type="hidden" name="course_code" value="'.Security::remove_XSS($_GET['course_code']).'"/><input type="submit" name="action" value="'.get_lang('Ok').'"/></form>';
} }
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer(); Display::display_footer();
?>

@ -53,15 +53,27 @@ if ($_POST['formSent']) {
$archiveFile = 'export_courses_list_'.date('Y-m-d_H-i-s').'.'.$file_type; $archiveFile = 'export_courses_list_'.date('Y-m-d_H-i-s').'.'.$file_type;
$fp = fopen($archivePath.$archiveFile,'w'); $fp = fopen($archivePath.$archiveFile,'w');
if ($file_type == 'csv') { if ($file_type == 'csv') {
$add = "Code;Title;CourseCategory;Teacher;Language;".PHP_EOL; $add = "Code;Title;CourseCategory;Teacher;Language;OtherTeachers;Users;".PHP_EOL;
foreach($courses as $course) { foreach($courses as $course) {
$course['code'] = str_replace(';',',',$course['code']); $course['code'] = str_replace(';',',',$course['code']);
$course['title'] = str_replace(';',',',$course['title']); $course['title'] = str_replace(';',',',$course['title']);
$course['category_code'] = str_replace(';',',',$course['category_code']); $course['category_code'] = str_replace(';',',',$course['category_code']);
$course['tutor_name'] = str_replace(';',',',$course['tutor_name']); $course['tutor_name'] = str_replace(';',',',$course['tutor_name']);
$course['course_language'] = str_replace(';',',',$course['course_language']); $course['course_language'] = str_replace(';',',',$course['course_language']);
$course['course_users'] = CourseManager::get_user_list_from_course_code($course['code']);
$course['students'] = '';
$course['teachers'] = '';
foreach ($course['course_users'] as $user) {
if ($user['status_rel'] == 1) {
$course['teachers'] .= $user['username'].'|';
} else {
$course['students'] .= $user['username'].'|';
}
}
$course['students'] = substr($course['students'],0,-1);
$course['teachers'] = substr($course['teachers'],0,-1);
$add.= $course['code'].';'.$course['title'].';'.$course['category_code'].';'.$course['tutor_name'].';'.$course['course_language'].';'.PHP_EOL; $add.= $course['code'].';'.$course['title'].';'.$course['category_code'].';'.$course['tutor_name'].';'.$course['course_language'].';'.$course['teachers'].';'.$course['students'].';'.PHP_EOL;
} }
fputs($fp, $add); fputs($fp, $add);
} }

@ -119,11 +119,10 @@ function save_data($courses) {
$teacherInfo = api_get_user_info_from_username($teacher); $teacherInfo = api_get_user_info_from_username($teacher);
if (!empty($teacherInfo)) { if (!empty($teacherInfo)) {
$teacherList[] = $teacherInfo; $teacherList[] = $teacherInfo;
}
} }
} }
}
$params = array(); $params = array();
$params['title'] = $course['Title']; $params['title'] = $course['Title'];
$params['wanted_code'] = $course['Code']; $params['wanted_code'] = $course['Code'];
@ -220,7 +219,7 @@ if (isset($errors) && count($errors) != 0) {
<input type="file" name="import_file"/> <input type="file" name="import_file"/>
</div> </div>
</div> </div>
<div class="control-group "> <div class="control-group">
<div class="control"> <div class="control">
<button type="submit" class="save" value="<?php echo get_lang('Import'); ?>"><?php echo get_lang('Import'); ?></button> <button type="submit" class="save" value="<?php echo get_lang('Import'); ?>"><?php echo get_lang('Import'); ?></button>
</div> </div>

@ -89,7 +89,7 @@ function get_number_of_requests() {
* Get course data to display * Get course data to display
*/ */
function get_request_data($from, $number_of_items, $column, $direction) { function get_request_data($from, $number_of_items, $column, $direction) {
global $keyword; $keyword = Database::escape_string(trim($_GET['keyword']));
$course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); $course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
$sql = "SELECT id AS col0, $sql = "SELECT id AS col0,
@ -99,8 +99,7 @@ function get_request_data($from, $number_of_items, $column, $direction) {
tutor_name AS col4, tutor_name AS col4,
request_date AS col5, request_date AS col5,
id AS col6 id AS col6
FROM $course_request_table FROM $course_request_table WHERE status = ".COURSE_REQUEST_ACCEPTED;
WHERE status = ".COURSE_REQUEST_ACCEPTED;
if ($keyword != '') { if ($keyword != '') {
$sql .= " AND (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')"; $sql .= " AND (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')";

@ -65,7 +65,6 @@ if ($course_validation_feature) {
// The teacher. // The teacher.
$titular = $form->add_textfield('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled')); $titular = $form->add_textfield('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled'));
//$form->applyFilter('tutor_name', 'html_filter');
// Description of the requested course. // Description of the requested course.
$form->addElement('textarea', 'description', get_lang('Description'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116')); $form->addElement('textarea', 'description', get_lang('Description'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
@ -212,9 +211,8 @@ if ($course_validation_feature) {
$back_url = api_add_url_param($back_url, 'is_error_message=1', false); $back_url = api_add_url_param($back_url, 'is_error_message=1', false);
} }
header('location:'.$back_url); header('location:'.$back_url);
exit;
} else { } else {
$message = $course_request_values['wanted_code'].' - '.get_lang('CourseCodeAlreadyExists'); $message = $course_request_values['wanted_code'].' - '.get_lang('CourseCodeAlreadyExists');
$is_error_message = true; $is_error_message = true;
} }

@ -21,6 +21,17 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(); api_protect_admin_script();
require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
require_once api_get_path(CONFIGURATION_PATH).'course_info.conf.php';
require_once api_get_path(LIBRARY_PATH).'course_request.lib.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
// Including a configuration file.
require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
// Including additional libraries.
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
// The delete action should be deactivated in this page. // The delete action should be deactivated in this page.
// Better reject the target request, after that you can delete it. // Better reject the target request, after that you can delete it.
define(DELETE_ACTION_ENABLED, false); define(DELETE_ACTION_ENABLED, false);
@ -53,12 +64,10 @@ if ($course_validation_feature) {
$message = sprintf(get_lang('CourseRequestAcceptanceFailed'), $course_request_code); $message = sprintf(get_lang('CourseRequestAcceptanceFailed'), $course_request_code);
$is_error_message = true; $is_error_message = true;
} }
} } elseif (!empty($reject_course_request)) {
/**
/** * Course rejection
* Course rejection */
*/
elseif (!empty($reject_course_request)) {
$course_request_code = CourseRequestManager::get_course_request_code($reject_course_request); $course_request_code = CourseRequestManager::get_course_request_code($reject_course_request);
$result = CourseRequestManager::reject_course_request($reject_course_request); $result = CourseRequestManager::reject_course_request($reject_course_request);
if ($result) { if ($result) {
@ -68,12 +77,12 @@ if ($course_validation_feature) {
$message = sprintf(get_lang('CourseRequestRejectionFailed'), $course_request_code); $message = sprintf(get_lang('CourseRequestRejectionFailed'), $course_request_code);
$is_error_message = true; $is_error_message = true;
} }
} } elseif (!empty($request_info)) {
/**
* Sending to the teacher a request for additional information about the proposed course.
*/
/**
* Sending to the teacher a request for additional information about the proposed course.
*/
elseif (!empty($request_info)) {
$course_request_code = CourseRequestManager::get_course_request_code($request_info); $course_request_code = CourseRequestManager::get_course_request_code($request_info);
$result = CourseRequestManager::ask_for_additional_info($request_info); $result = CourseRequestManager::ask_for_additional_info($request_info);
if ($result) { if ($result) {
@ -83,12 +92,10 @@ if ($course_validation_feature) {
$message = sprintf(get_lang('CourseRequestInfoFailed'), $course_request_code); $message = sprintf(get_lang('CourseRequestInfoFailed'), $course_request_code);
$is_error_message = true; $is_error_message = true;
} }
} } elseif (!empty($delete_course_request)) {
/**
/** * Deletion of a course request.
* Deletion of a course request. */
*/
elseif (!empty($delete_course_request)) {
$course_request_code = CourseRequestManager::get_course_request_code($delete_course_request); $course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);
$result = CourseRequestManager::delete_course_request($delete_course_request); $result = CourseRequestManager::delete_course_request($delete_course_request);
if ($result) { if ($result) {
@ -98,15 +105,13 @@ if ($course_validation_feature) {
$message = sprintf(get_lang('CourseRequestDeletionFailed'), $course_request_code); $message = sprintf(get_lang('CourseRequestDeletionFailed'), $course_request_code);
$is_error_message = true; $is_error_message = true;
} }
} } elseif (DELETE_ACTION_ENABLED && isset($_POST['action'])) {
/**
/** * Form actions: delete.
* Form actions: delete. */
*/
elseif (DELETE_ACTION_ENABLED && isset($_POST['action'])) {
switch ($_POST['action']) { switch ($_POST['action']) {
// Delete selected courses // Delete selected courses
case 'delete_course_requests' : case 'delete_course_requests':
$course_requests = $_POST['course_request']; $course_requests = $_POST['course_request'];
if (is_array($_POST['course_request']) && !empty($_POST['course_request'])) { if (is_array($_POST['course_request']) && !empty($_POST['course_request'])) {
$success = true; $success = true;
@ -140,7 +145,6 @@ function get_number_of_requests() {
*/ */
function get_request_data($from, $number_of_items, $column, $direction) { function get_request_data($from, $number_of_items, $column, $direction) {
global $keyword; global $keyword;
$course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); $course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
if (DELETE_ACTION_ENABLED) { if (DELETE_ACTION_ENABLED) {
@ -151,8 +155,7 @@ function get_request_data($from, $number_of_items, $column, $direction) {
tutor_name AS col4, tutor_name AS col4,
request_date AS col5, request_date AS col5,
id AS col6 id AS col6
FROM $course_request_table FROM $course_request_table WHERE status = ".COURSE_REQUEST_PENDING;
WHERE status = ".COURSE_REQUEST_PENDING;
} else { } else {
$sql = "SELECT $sql = "SELECT
code AS col0, code AS col0,
@ -161,8 +164,7 @@ function get_request_data($from, $number_of_items, $column, $direction) {
tutor_name AS col3, tutor_name AS col3,
request_date AS col4, request_date AS col4,
id AS col5 id AS col5
FROM $course_request_table FROM $course_request_table WHERE status = ".COURSE_REQUEST_PENDING;
WHERE status = ".COURSE_REQUEST_PENDING;
} }
if ($keyword != '') { if ($keyword != '') {
@ -201,13 +203,13 @@ function email_filter($teacher) {
function modify_filter($id) { function modify_filter($id) {
$code = CourseRequestManager::get_course_request_code($id); $code = CourseRequestManager::get_course_request_code($id);
$result = '<a href="course_request_edit.php?id='.$id.'&caller=0">'.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).'</a>'. $result = '<a href="course_request_edit.php?id='.$id.'&caller=0">'.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).'</a>'.
'&nbsp;<a href="?accept_course_request='.$id.'">'.Display::return_icon('accept.png', get_lang('AcceptThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(sprintf(get_lang('ANewCourseWillBeCreated'), $code)).'\')) return false;'),16).'</a>'. '&nbsp;<a href="?accept_course_request='.$id.'">'.Display::return_icon('accept.png', get_lang('AcceptThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ANewCourseWillBeCreated'), $code), ENT_QUOTES)).'\')) return false;'),16).'</a>'.
'&nbsp;<a href="?reject_course_request='.$id.'">'.Display::return_icon('error.png', get_lang('RejectThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(sprintf(get_lang('ACourseRequestWillBeRejected'), $code)).'\')) return false;'),16).'</a>'; '&nbsp;<a href="?reject_course_request='.$id.'">'.Display::return_icon('error.png', get_lang('RejectThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeRejected'), $code), ENT_QUOTES)).'\')) return false;'),16).'</a>';
if (!CourseRequestManager::additional_info_asked($id)) { if (!CourseRequestManager::additional_info_asked($id)) {
$result .= '&nbsp;<a href="?request_info='.$id.'">'.Display::return_icon('request_info.gif', get_lang('AskAdditionalInfo'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(sprintf(get_lang('AdditionalInfoWillBeAsked'), $code)).'\')) return false;')).'</a>'; $result .= '&nbsp;<a href="?request_info='.$id.'">'.Display::return_icon('request_info.gif', get_lang('AskAdditionalInfo'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('AdditionalInfoWillBeAsked'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
} }
if (DELETE_ACTION_ENABLED) { if (DELETE_ACTION_ENABLED) {
$result .= '&nbsp;<a href="?delete_course_request='.$id.'">'.Display::return_icon('delete.gif', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code)).'\')) return false;')).'</a>'; $result .= '&nbsp;<a href="?delete_course_request='.$id.'">'.Display::return_icon('delete.gif', get_lang('DeleteThisCourseRequest'), array('style' => 'vertical-align: middle;', 'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('ACourseRequestWillBeDeleted'), $code), ENT_QUOTES)).'\')) return false;')).'</a>';
} }
return $result; return $result;
} }

@ -7,9 +7,9 @@
*/ */
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file='admin'; $language_file = 'admin';
// resetting the course id // resetting the course id
$cidReset=true; $cidReset = true;
// including some necessary dokeos files // including some necessary dokeos files
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
@ -17,7 +17,7 @@ require_once '../inc/global.inc.php';
global $_configuration; global $_configuration;
// create an ajax object // create an ajax object
$xajax = new xajax(); $xajax = new xajax();
$xajax -> registerFunction ('search_courses'); $xajax->registerFunction('search_courses');
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
@ -30,9 +30,9 @@ $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdm
$interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList')); $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList'));
// Database Table Definitions // Database Table Definitions
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); $tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
// initializing variables // initializing variables
$id_session=intval($_GET['id_session']); $id_session=intval($_GET['id_session']);
@ -51,7 +51,7 @@ if (UserManager::is_admin($user_id)) {
} }
$add_type = 'multiple'; $add_type = 'multiple';
if(isset($_GET['add_type']) && $_GET['add_type']!=''){ if(isset($_GET['add_type']) && $_GET['add_type']!='') {
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
@ -145,14 +145,14 @@ function remove_item(origin) {
$formSent=0; $formSent=0;
$errorMsg = $firstLetterCourse = ''; $errorMsg = $firstLetterCourse = '';
$UserList = array(); $UserList = array();
$msg = '';
if (intval($_POST['formSent']) == 1) { $msg = '';
$courses_list = $_POST['CoursesList']; if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
$affected_rows = CourseManager::suscribe_courses_to_hr_manager($user_id, $courses_list); $courses_list = $_POST['CoursesList'];
if ($affected_rows) { $affected_rows = CourseManager::suscribe_courses_to_hr_manager($user_id,$courses_list);
$msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully'); if ($affected_rows) {
} $msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully');
}
} }
// Display header // Display header

@ -11,14 +11,11 @@ $language_file='admin';
// resetting the course id // resetting the course id
$cidReset=true; $cidReset=true;
// including some necessary dokeos files
require_once '../inc/global.inc.php';
global $_configuration; global $_configuration;
$ajax_search = false;
// create an ajax object // create an ajax object
$xajax = new xajax(); $xajax = new xajax();
$xajax -> registerFunction ('search_users'); $xajax->registerFunction('search_users');
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
@ -41,22 +38,24 @@ $user_info = api_get_user_info($user_id);
$user_anonymous = api_get_anonymous_id(); $user_anonymous = api_get_anonymous_id();
$current_user_id = api_get_user_id(); $current_user_id = api_get_user_id();
$firstLetterUser = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null;
// setting the name of the tool // setting the name of the tool
if (UserManager::is_admin($user_id)) { if (UserManager::is_admin($user_id)) {
$tool_name= get_lang('AssignUsersToPlatformAdministrator'); $tool_name= get_lang('AssignUsersToPlatformAdministrator');
} else if ($user_info['status'] == SESSIONADMIN) { } else if ($user_info['status'] == SESSIONADMIN) {
$tool_name= get_lang('AssignUsersToSessionsAdministrator'); $tool_name= get_lang('AssignUsersToSessionsAdministrator');
} else { } else {
$tool_name= get_lang('AssignUsersToHumanResourcesManager'); $tool_name= get_lang('AssignUsersToHumanResourcesManager');
} }
$add_type = 'multiple'; $add_type = 'multiple';
if(isset($_GET['add_type']) && $_GET['add_type']!=''){ if(isset($_GET['add_type']) && $_GET['add_type']!='') {
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
if (!api_is_platform_admin()) { if (!api_is_platform_admin()) {
api_not_allowed(true); api_not_allowed(true);
} }
function search_users($needle,$type) { function search_users($needle,$type) {

@ -196,6 +196,8 @@ CREATE TABLE IF NOT EXISTS lp_field_options (
option_display_text varchar(64), option_display_text varchar(64),
option_order int, option_order int,
tms DATETIME NOT NULL default '0000-00-00 00:00:00', tms DATETIME NOT NULL default '0000-00-00 00:00:00',
priority VARCHAR(255),
priority_message VARCHAR(255),
PRIMARY KEY (id) PRIMARY KEY (id)
); );
DROP TABLE IF EXISTS lp_field_values; DROP TABLE IF EXISTS lp_field_values;

@ -1,8 +1,8 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /dokeos_license.txt */
/** /**
* @package chamilo.admin * @package chamilo.admin
*/ */
// Language files that should be included // Language files that should be included
$language_file = array('admin', 'registration', 'userInfo'); $language_file = array('admin', 'registration', 'userInfo');

@ -64,10 +64,7 @@ echo '</tr></table>';
$course_categories = Statistics::get_course_categories(); $course_categories = Statistics::get_course_categories();
echo '<br/><br/>'; echo '<br/><br/>';
//@todo: spaces between elements should be handled in the css, br should be removed if only there for presentation switch ($_REQUEST['report']) {
$report = isset($_GET['report']) ? $_GET['report'] : null;
switch ($report) {
case 'courses': case 'courses':
// total amount of courses // total amount of courses
foreach ($course_categories as $code => $name) { foreach ($course_categories as $code => $name) {
@ -88,9 +85,10 @@ switch ($report) {
case 'users': case 'users':
// total amount of users // total amount of users
Statistics::print_stats( Statistics::print_stats(
get_lang('NumberOfUsers'), array( get_lang('NumberOfUsers'),
get_lang('Teachers') => Statistics::count_users(1, null, $_GET['count_invisible_courses']), array(
get_lang('Students') => Statistics::count_users(5, null, $_GET['count_invisible_courses']) get_lang('Teachers') => Statistics::count_users(1, null, $_GET['count_invisible_courses']),
get_lang('Students') => Statistics::count_users(5, null, $_GET['count_invisible_courses'])
) )
); );
$teachers = $students = array(); $teachers = $students = array();
@ -136,4 +134,5 @@ switch ($report) {
Statistics::print_stats(get_lang('CountFriends'), $friends); Statistics::print_stats(get_lang('CountFriends'), $friends);
break; break;
} }
Display::display_footer(); Display::display_footer();

@ -261,12 +261,12 @@ class Category implements GradebookItem
} }
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'SELECT * FROM '.$tbl_grade_categories; $sql = 'SELECT * FROM '.$tbl_grade_categories;
$paramcount = 0; $paramcount = 0;
if (isset($id)) { if (isset($id)) {
$id = Database::escape_string($id); $id = Database::escape_string($id);
$sql .= ' WHERE id = '.intval($id); $sql.= ' WHERE id = '.intval($id);
$paramcount++; $paramcount ++;
} }
if (isset($user_id)) { if (isset($user_id)) {
@ -395,7 +395,7 @@ class Category implements GradebookItem
if (isset($this->name) && isset($this->user_id)) { if (isset($this->name) && isset($this->user_id)) {
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'INSERT INTO '.$tbl_grade_categories.' (name,user_id,weight,visible'; $sql = 'INSERT INTO '.$tbl_grade_categories.' (name,user_id,weight,visible';
if (isset($this->description)) { if (isset($this->description)) {
$sql .= ',description'; $sql .= ',description';
} }
@ -403,7 +403,7 @@ class Category implements GradebookItem
$sql .= ',course_code'; $sql .= ',course_code';
} }
if (isset($this->parent)) { if (isset($this->parent)) {
$sql .= ',parent_id'; $sql .= ',parent_id';
} }
if (!empty($this->session_id)) { if (!empty($this->session_id)) {
$sql .= ', session_id'; $sql .= ', session_id';
@ -416,7 +416,6 @@ class Category implements GradebookItem
$sql .= ', certif_min_score '; $sql .= ', certif_min_score ';
} }
/* /*
$setting = api_get_setting('tool_visible_by_default_at_creation'); $setting = api_get_setting('tool_visible_by_default_at_creation');
$visible = 1; $visible = 1;

@ -84,7 +84,7 @@ class LinkForm extends FormValidator
// The hot potatoe link will be added "inside" the exercise option. // The hot potatoe link will be added "inside" the exercise option.
if ($linkType == LINK_HOTPOTATOES) { if ($linkType == LINK_HOTPOTATOES) {
continue; continue;
} }
$link = $this->createLink($linkType, $courseCode); $link = $this->createLink($linkType, $courseCode);
// disable this element if the link works with a dropdownlist // disable this element if the link works with a dropdownlist
// and if there are no links left // and if there are no links left
@ -110,6 +110,7 @@ class LinkForm extends FormValidator
$this->setDefaults(array('select_link' => $this->extra)); $this->setDefaults(array('select_link' => $this->extra));
} }
} }
/** /**
* @param $link * @param $link
* @param $courseCode * @param $courseCode
@ -122,4 +123,8 @@ class LinkForm extends FormValidator
$link->set_course_code($courseCode); $link->set_course_code($courseCode);
} elseif(!empty($_GET['course_code'])) { } elseif(!empty($_GET['course_code'])) {
$link->set_course_code(Database::escape_string($_GET['course_code'])); $link->set_course_code(Database::escape_string($_GET['course_code']));
} }
return $link;
}
}

@ -58,12 +58,12 @@ Display::display_introduction_section(TOOL_GROUP);
/* /*
* Self-registration and un-registration * Self-registration and un-registration
*/ */
$my_group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : null; $my_group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : null;
$my_msg = isset($_GET['msg']) ? Security::remove_XSS($_GET['msg']) : null; $my_msg = isset($_GET['msg']) ? Security::remove_XSS($_GET['msg']) : null;
$my_group = isset($_REQUEST['group']) ? Security::remove_XSS($_REQUEST['group']) : null; $my_group = isset($_REQUEST['group']) ? Security::remove_XSS($_REQUEST['group']) : null;
$my_get_id1 = isset($_GET['id1']) ? Security::remove_XSS($_GET['id1']) : null; $my_get_id1 = isset($_GET['id1']) ? Security::remove_XSS($_GET['id1']) : null;
$my_get_id2 = isset($_GET['id2']) ? Security::remove_XSS($_GET['id2']) : null; $my_get_id2 = isset($_GET['id2']) ? Security::remove_XSS($_GET['id2']) : null;
$my_get_id = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : null; $my_get_id = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : null;
if (isset($_GET['action']) && $is_allowed_in_course) { if (isset($_GET['action']) && $is_allowed_in_course) {
switch ($_GET['action']) { switch ($_GET['action']) {
@ -80,13 +80,13 @@ if (isset($_GET['action']) && $is_allowed_in_course) {
} }
break; break;
case 'show_msg': case 'show_msg':
Display :: display_confirmation_message($my_msg); Display::display_confirmation_message($my_msg);
break; break;
case 'warning_message': case 'warning_message':
Display :: display_warning_message($my_msg); Display::display_warning_message($my_msg);
break; break;
case 'success_message': case 'success_message':
Display :: display_confirmation_message($my_msg); Display::display_confirmation_message($my_msg);
break; break;
} }
} }
@ -102,7 +102,7 @@ if (api_is_allowed_to_edit(false, true)) {
switch ($_POST['action']) { switch ($_POST['action']) {
case 'delete_selected': case 'delete_selected':
if (is_array($_POST['group'])) { if (is_array($_POST['group'])) {
GroupManager :: delete_groups($my_group); GroupManager::delete_groups($my_group);
Display :: display_confirmation_message(get_lang('SelectedGroupsDeleted')); Display :: display_confirmation_message(get_lang('SelectedGroupsDeleted'));
} }
break; break;
@ -184,7 +184,6 @@ if (api_is_allowed_to_edit(false, true)) {
$group_cats = GroupManager::get_categories(api_get_course_id()); $group_cats = GroupManager::get_categories(api_get_course_id());
echo '</div>'; echo '</div>';
/* List all categories */ /* List all categories */
if (api_get_setting('allow_group_categories') == 'true') { if (api_get_setting('allow_group_categories') == 'true') {
foreach ($group_cats as $index => $category) { foreach ($group_cats as $index => $category) {

@ -88,7 +88,7 @@ $interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Build the form // Build the form
if (isset ($_GET['id'])) { if (isset($_GET['id'])) {
// Update settings of existing category // Update settings of existing category
$action = 'update_settings'; $action = 'update_settings';
$form = new FormValidator('group_category', 'post', '?id='.$category['id']); $form = new FormValidator('group_category', 'post', '?id='.$category['id']);
@ -110,18 +110,19 @@ if (api_get_setting('allow_group_categories') == 'true') {
$form->addElement('html', '<div class="row"><div class="span6">'); $form->addElement('html', '<div class="row"><div class="span6">');
$form->add_textfield('title', get_lang('Title')); $form->add_textfield('title', get_lang('Title'));
// Action // Action
$possible_values = array (); $possible_values = array ();
for ($i = 1; $i <= 10; $i ++) { for ($i = 1; $i <= 10; $i ++) {
$possible_values[$i] = $i; $possible_values[$i] = $i;
} }
$possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All');
$possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All');
$group = array( $group = array(
$form->createElement('select', 'groups_per_user', null, $possible_values), $form->createElement('select', 'groups_per_user', null, $possible_values),
$form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartAfterNumber')) $form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartAfterNumber'))
); );
$form->addGroup($group, 'limit_group', get_lang('GroupLimit'), ' ', false); $form->addGroup($group, 'limit_group', get_lang('GroupLimit'), ' ', false);
$form->addRule('limit_group', get_lang('MaxGroupsPerUserInvalid'), 'callback', 'check_groups_per_user'); $form->addRule('limit_group', get_lang('MaxGroupsPerUserInvalid'), 'callback', 'check_groups_per_user');
// Members per group // Members per group
$group = array( $group = array(
@ -133,10 +134,10 @@ $form->addRule('limit_group', get_lang('MaxGroupsPerUserInvalid'), 'callback', '
$form->addGroup($group, 'max_member_group', get_lang('GroupLimit'), '', false); $form->addGroup($group, 'max_member_group', get_lang('GroupLimit'), '', false);
$form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members'); $form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members');
$form->addElement('html', '</div>'); $form->addElement('html', '</div>');
$form->addElement('html', '<div class="span6">'); $form->addElement('html', '<div class="span6">');
// Members per group // Members per group
$form->addElement('textarea', 'description', get_lang('Description'), array ('class' => 'span6', 'rows' => 6)); $form->addElement('textarea', 'description', get_lang('Description'), array ('class' => 'span6', 'rows' => 6));
$form->addElement('html', '</div>'); $form->addElement('html', '</div>');
$form->addElement('html', '</div>'); $form->addElement('html', '</div>');

@ -19,7 +19,7 @@ api_protect_course_script(true);
/* Create the groups */ /* Create the groups */
if (isset ($_POST['action'])) { if (isset($_POST['action'])) {
switch ($_POST['action']) { switch ($_POST['action']) {
case 'create_groups': case 'create_groups':
$groups = array(); $groups = array();

@ -108,6 +108,9 @@ function check_system_version()
$number_of_users = Statistics::count_users(); $number_of_users = Statistics::count_users();
$number_of_active_users = Statistics::count_users(null, null, null, true); $number_of_active_users = Statistics::count_users(null, null, null, true);
// The number of sessions
$number_of_sessions = Statistics::count_sessions();
$data = array( $data = array(
'url' => api_get_path(WEB_PATH), 'url' => api_get_path(WEB_PATH),
'campus' => api_get_setting('siteName'), 'campus' => api_get_setting('siteName'),
@ -116,6 +119,7 @@ function check_system_version()
'numberofcourses' => $number_of_courses, 'numberofcourses' => $number_of_courses,
'numberofusers' => $number_of_users, 'numberofusers' => $number_of_users,
'numberofactiveusers' => $number_of_active_users, 'numberofactiveusers' => $number_of_active_users,
'numberofsessions' => $number_of_sessions,
//The donotlistcampus setting recovery should be improved to make //The donotlistcampus setting recovery should be improved to make
// it true by default - this does not affect numbers counting // it true by default - this does not affect numbers counting
'donotlistcampus' => api_get_setting('donotlistcampus'), 'donotlistcampus' => api_get_setting('donotlistcampus'),

@ -10,25 +10,24 @@ $user_id = api_get_user_id();
switch ($action) { switch ($action) {
case 'add_course_vote': case 'add_course_vote':
$course_id = intval($_REQUEST['course_id']);
$course_id = intval($_REQUEST['course_id']);
$star = intval($_REQUEST['star']); $star = intval($_REQUEST['star']);
if (!api_is_anonymous()) { if (!api_is_anonymous()) {
CourseManager::add_course_vote($user_id, $star, $course_id, 0); CourseManager::add_course_vote($user_id, $star, $course_id, 0);
} }
$point_info = CourseManager::get_course_ranking($course_id, 0); $point_info = CourseManager::get_course_ranking($course_id, 0);
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$rating = Display::return_rating_system('star_'.$course_id, $ajax_url.'&amp;course_id='.$course_id, $point_info, false); $rating = Display::return_rating_system('star_'.$course_id, $ajax_url.'&amp;course_id='.$course_id, $point_info, false);
echo $rating; echo $rating;
break; break;
case 'get_user_courses': case 'get_user_courses':
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
$user_id = intval($_POST['user_id']); $user_id = intval($_POST['user_id']);
$list_course_all_info = CourseManager::get_courses_list_by_user_id($user_id, false); $list_course_all_info = CourseManager::get_courses_list_by_user_id($user_id, false);
if (!empty($list_course_all_info)) { if (!empty($list_course_all_info)) {
foreach($list_course_all_info as $course_item) { foreach ($list_course_all_info as $course_item) {
$course_info = api_get_course_info($course_item['code']); $course_info = api_get_course_info($course_item['code']);
echo $course_info['title'].'<br />'; echo $course_info['title'].'<br />';
} }
@ -37,6 +36,200 @@ switch ($action) {
} }
} }
break; break;
case 'search_category':
require_once api_get_path(LIBRARY_PATH).'course_category.lib.php';
if (api_is_platform_admin() || api_is_allowed_to_create_course()) {
$results = searchCategoryByKeyword($_REQUEST['q']);
if (!empty($results)) {
foreach ($results as &$item) {
$item['id'] = $item['code'];
}
echo json_encode($results);
} else {
echo json_encode(array());
}
}
break;
case 'search_course':
if (api_is_platform_admin()) {
if (!empty($_GET['session_id']) && intval($_GET['session_id'])) {
//if session is defined, lets find only courses of this session
$courseList = SessionManager::get_course_list_by_session_id(
$_GET['session_id'],
$_GET['q']
);
} else {
//if session is not defined lets search all courses STARTING with $_GET['q']
//TODO change this function to search not only courses STARTING with $_GET['q']
$courseList = CourseManager::get_courses_list(
0, //offset
0, //howMany
1, //$orderby = 1
'ASC',
-1, //visibility
$_GET['q'],
null, //$urlId
true //AlsoSearchCode
);
}
$results = array();
require_once api_get_path(LIBRARY_PATH).'course_category.lib.php';
if (!empty($courseList)) {
foreach ($courseList as $courseInfo) {
$title = $courseInfo['title'];
if (!empty($courseInfo['category_code'])) {
$parents = getParentsToString($courseInfo['category_code']);
$title = $parents.$courseInfo['title'];
}
$results[] = array(
'id' => $courseInfo['id'],
'text' => $title
);
}
echo json_encode($results);
} else {
echo json_encode(array());
}
}
break;
case 'search_course_by_session':
if (api_is_platform_admin()) {
$results = SessionManager::get_course_list_by_session_id($_GET['session_id'], $_GET['q']);
//$results = SessionManager::get_sessions_list(array('s.name LIKE' => "%".$_REQUEST['q']."%"));
$results2 = array();
if (!empty($results)) {
foreach ($results as $item) {
$item2 = array();
foreach ($item as $id => $internal) {
if ($id == 'id') {
$item2[$id] = $internal;
}
if ($id == 'title') {
$item2['text'] = $internal;
}
}
$results2[] = $item2;
}
echo json_encode($results2);
} else {
echo json_encode(array());
}
}
break;
case 'search_course_by_session_all':
if (api_is_platform_admin()) {
if ($_GET['session_id'] == 'TODOS' || $_GET['session_id'] == 'T') {
$_GET['session_id'] = '%';
}
$results = SessionManager::get_course_list_by_session_id_like(
$_GET['session_id'],
$_GET['q']
);
$results2 = array();
if (!empty($results)) {
foreach ($results as $item) {
$item2 = array();
foreach ($item as $id => $internal) {
if ($id == 'id') {
$item2[$id] = $internal;
}
if ($id == 'title') {
$item2['text'] = $internal;
}
}
$results2[] = $item2;
}
echo json_encode($results2);
} else {
echo json_encode(array());
}
}
break;
case 'search_user_by_course':
if (api_is_platform_admin()) {
$user = Database :: get_main_table(TABLE_MAIN_USER);
$session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$course = api_get_course_info_by_id($_GET['course_id']);
$sql = "SELECT u.user_id as id, u.username, u.lastname, u.firstname
FROM $user u
INNER JOIN $session_course_user r ON u.user_id = r.id_user
WHERE id_session = %d AND course_code = '%s'
AND (u.firstname LIKE '%s' OR u.username LIKE '%s' OR u.lastname LIKE '%s')";
$needle = '%' . $_GET['q'] . '%';
$sql_query = sprintf($sql, $_GET['session_id'], $course['code'], $needle, $needle, $needle);
$result = Database::query($sql_query);
while ($user = Database::fetch_assoc($result)) {
$data[] = array('id' => $user['id'], 'text' => $user['username'] . ' (' . $user['firstname'] . ' ' . $user['lastname'] . ')');
}
if (!empty($data)) {
echo json_encode($data);
} else {
echo json_encode(array());
}
}
break;
case 'search_exercise_by_course':
if (api_is_platform_admin()) {
$course = api_get_course_info_by_id($_GET['course_id']);
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
$session_id = (!empty($_GET['session_id'])) ? intval($_GET['session_id']) : 0 ;
$exercises = get_all_exercises($course, $session_id, false, $_GET['q'], true, 3);
foreach ($exercises as $exercise) {
$data[] = array('id' => $exercise['id'], 'text' => html_entity_decode($exercise['title']) );
}
if (!empty($data)) {
$data[] = array('id' => 'T', 'text' => 'TODOS');
echo json_encode($data);
} else {
echo json_encode(array(array('id' => 'T', 'text' => 'TODOS')));
}
}
break;
case 'search_survey_by_course':
if (api_is_platform_admin()) {
$survey = Database :: get_course_table(TABLE_SURVEY);
$sql = "SELECT survey_id as id, title, anonymous
FROM $survey
WHERE
c_id = %d AND
session_id = %d AND
title LIKE '%s'";
$sql_query = sprintf(
$sql,
intval($_GET['course_id']),
intval($_GET['session_id']),
'%' . Database::escape_string($_GET['q']).'%'
);
$result = Database::query($sql_query);
while ($survey = Database::fetch_assoc($result)) {
$survey['title'] .= ($survey['anonymous'] == 1) ? ' (' . get_lang('Anonymous') . ')' : '';
$data[] = array(
'id' => $survey['id'],
'text' => strip_tags(html_entity_decode($survey['title']))
);
}
if (!empty($data)) {
echo json_encode($data);
} else {
echo json_encode(array());
}
}
break;
default: default:
echo ''; echo '';
} }

@ -7,7 +7,7 @@ $event_name = isset($_REQUEST['eventName']) ? $_REQUEST['eventName'] : null;
api_protect_admin_script(); api_protect_admin_script();
switch ($action) { switch ($action) {
case 'getEventTypes': case 'getEventTypes':
$events = get_all_event_types(); $events = get_all_event_types();
print json_encode($events); print json_encode($events);
break; break;
@ -15,7 +15,7 @@ switch ($action) {
$users = UserManager::get_user_list(); $users = UserManager::get_user_list();
print json_encode($users); print json_encode($users);
break; break;
case 'get_event_users' : case 'get_event_users':
$users = get_event_users($event_name); $users = get_event_users($event_name);
print json_encode($users); print json_encode($users);
break; break;

@ -3,7 +3,7 @@
/* bbb parameters that will be registered in the course settings */ /* bbb parameters that will be registered in the course settings */
//require_once '../../main/inc/global.inc.php'; require_once __DIR__ . '/../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'plugin.class.php'; require_once api_get_path(LIBRARY_PATH).'plugin.class.php';
require_once 'lib/bbb.lib.php'; require_once 'lib/bbb.lib.php';

@ -52,4 +52,4 @@ $strings['plugin_tool_bbb'] = 'Video';
$strings['ThereAreNotRecordingsForTheMeetings'] = 'There are not recording for the meeting sessions'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'There are not recording for the meeting sessions';
$strings['NoRecording'] = 'No recording'; $strings['NoRecording'] = 'No recording';
$strings['ClickToContinue'] = 'Click to continue';

@ -46,3 +46,4 @@ $strings['plugin_tool_bbb'] = 'Vidéo';
$strings['ThereAreNotRecordingsForTheMeetings'] = 'Aucun enregistrement disponible'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'Aucun enregistrement disponible';
$strings['NoRecording'] = "Pas d'enregistrement"; $strings['NoRecording'] = "Pas d'enregistrement";
$strings['ClickToContinue'] = 'Cliquez pour continuer';

@ -46,3 +46,4 @@ $strings['plugin_tool_bbb'] = 'Video';
$strings['ThereAreNotRecordingsForTheMeetings'] = 'No hay grabaciones de sesiones de videoconferencia'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'No hay grabaciones de sesiones de videoconferencia';
$strings['NoRecording'] = 'No hay grabación'; $strings['NoRecording'] = 'No hay grabación';
$strings['ClickToContinue'] = 'Hacer click para continuar';

@ -1,39 +1,51 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* This script initiates a videoconference session, calling the BigBlueButton * Class bbb
* This script initiates a video conference session, calling the BigBlueButton
* API * API
* @package chamilo.plugin.bigbluebutton * @package chamilo.plugin.bigbluebutton
*/ *
/**
* BigBlueButton-Chamilo connector class * BigBlueButton-Chamilo connector class
*/ */
class bbb { class bbb
{
var $url; public $url;
var $salt; public $salt;
var $api; public $api;
var $user_complete_name = null; public $user_complete_name = null;
var $protocol = 'http://'; public $protocol = 'http://';
var $debug = false; public $debug = false;
var $logout_url = null; public $logout_url = null;
var $plugin_enabled = false; public $plugin_enabled = false;
/** /**
*
* Constructor (generates a connection to the API and the Chamilo settings * Constructor (generates a connection to the API and the Chamilo settings
* required for the connection to the videoconference server) * required for the connection to the video conference server)
* @param string $host
* @param string $salt
*/ */
function __construct() { public function __construct($host = null, $salt = null)
{
// initialize video server settings from global settings // Initialize video server settings from global settings
$plugin = BBBPlugin::create(); $plugin = BBBPlugin::create();
$bbb_plugin = $plugin->get('tool_enable'); $bbb_plugin = $plugin->get('tool_enable');
$bbb_host = $plugin->get('host');
$bbb_salt = $plugin->get('salt');
//$course_code = api_get_course_id(); if (empty($host)) {
$bbb_host = $plugin->get('host');
} else {
$bbb_host = $host;
}
if (empty($salt)) {
$bbb_salt = $plugin->get('salt');
} else {
$bbb_salt = $salt;
}
$this->logout_url = api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php'; $this->logout_url = api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq();
$this->table = Database::get_main_table('plugin_bbb_meeting'); $this->table = Database::get_main_table('plugin_bbb_meeting');
if ($bbb_plugin == true) { if ($bbb_plugin == true) {
@ -55,15 +67,17 @@ class bbb {
$this->plugin_enabled = true; $this->plugin_enabled = true;
} }
} }
/** /**
* Checks whether a user is teacher in the current course * Checks whether a user is teacher in the current course
* @return bool True if the user can be considered a teacher in this course, false otherwise * @return bool True if the user can be considered a teacher in this course, false otherwise
*/ */
function is_teacher() { public function is_teacher()
{
return api_is_course_admin() || api_is_coach() || api_is_platform_admin(); return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
} }
/* /**
* See this file in you BBB to set up default values * See this file in you BBB to set up default values
/var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
@ -94,9 +108,11 @@ class bbb {
defaultMeetingCreateJoinDuration=5 defaultMeetingCreateJoinDuration=5
* *
*/ */
function create_meeting($params) { public function create_meeting($params)
{
$params['c_id'] = api_get_course_int_id(); $params['c_id'] = api_get_course_int_id();
$course_code = api_get_course_id(); $course_code = api_get_course_id();
$params['session_id'] = api_get_session_id();
$attende_password = $params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id(); $attende_password = $params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id();
$moderator_password = $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->get_mod_meeting_password(); $moderator_password = $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->get_mod_meeting_password();
@ -114,13 +130,13 @@ class bbb {
if ($id) { if ($id) {
if ($this->debug) error_log("create_meeting: $id "); if ($this->debug) error_log("create_meeting: $id ");
$meeting_name = isset($params['meeting_name']) ? $params['meeting_name'] : api_get_course_id(); $meeting_name = isset($params['meeting_name']) ? $params['meeting_name'] : api_get_course_id().'-'.api_get_session_id();
$welcome_msg = isset($params['welcome_msg']) ? $params['welcome_msg'] : null; $welcome_msg = isset($params['welcome_msg']) ? $params['welcome_msg'] : null;
$record = isset($params['record']) && $params['record'] ? 'true' : 'false'; $record = isset($params['record']) && $params['record'] ? 'true' : 'false';
$duration = isset($params['duration']) ? intval($params['duration']) : 0; $duration = isset($params['duration']) ? intval($params['duration']) : 0;
// This setting currently limits the maximum conference duration, // This setting currently limits the maximum conference duration,
// to avoid llingering sessions on the videoconference server #6261 // to avoid lingering sessions on the videoconference server #6261
$duration = 300; $duration = 300;
$bbb_params = array( $bbb_params = array(
'meetingId' => $id, // REQUIRED 'meetingId' => $id, // REQUIRED
@ -137,27 +153,59 @@ class bbb {
'duration' => $duration, // Default = 0 which means no set duration in minutes. [number] 'duration' => $duration, // Default = 0 which means no set duration in minutes. [number]
//'meta_category' => '', // Use to pass additional info to BBB server. See API docs. //'meta_category' => '', // Use to pass additional info to BBB server. See API docs.
); );
if ($this->debug) error_log("create_meeting params: ".print_r($bbb_params,1)); if ($this->debug) error_log("create_meeting params: ".print_r($bbb_params,1));
$result = $this->api->createMeetingWithXmlResponseArray($bbb_params);
if (isset($result) && (string)$result['returncode'] == 'SUCCESS') { $status = false;
if ($this->debug) error_log("create_meeting result: ".print_r($result,1)); $meeting = null;
return $this->join_meeting($meeting_name);
while ($status == false) {
$result = $this->api->createMeetingWithXmlResponseArray(
$bbb_params
);
if (isset($result) && strval(
$result['returncode']
) == 'SUCCESS'
) {
if ($this->debug) {
error_log(
"create_meeting result: " . print_r($result, 1)
);
}
$meeting = $this->join_meeting($meeting_name, true);
return $meeting;
}
} }
return $this->logout; return $this->logout;
} }
} }
/** /**
* Tells whether the given meeting exists and is running * Tells whether the given meeting exists and is running
* (using course code as name) * (using course code as name)
* @param string Meeting name (usually the course code) * @param string $meeting_name Meeting name (usually the course code)
*
* @return bool True if meeting exists, false otherwise * @return bool True if meeting exists, false otherwise
* @assert ('') === false * @assert ('') === false
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
*/ */
function meeting_exists($meeting_name) { public function meeting_exists($meeting_name)
{
if (empty($meeting_name)) { return false; } if (empty($meeting_name)) { return false; }
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND meeting_name = ? AND status = 1 ' => array($course_id, $meeting_name))), 'first'); $session_id = api_get_session_id();
$meeting_data = Database::select(
'*',
$this->table,
array(
'where' => array(
'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 ' =>
array($course_id, $session_id, $meeting_name)
)
),
'first'
);
if ($this->debug) error_log("meeting_exists ".print_r($meeting_data,1)); if ($this->debug) error_log("meeting_exists ".print_r($meeting_data,1));
if (empty($meeting_data)) { if (empty($meeting_data)) {
return false; return false;
@ -174,28 +222,68 @@ class bbb {
* @assert ('') === false * @assert ('') === false
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
*/ */
function join_meeting($meeting_name) { public function join_meeting($meeting_name, $loop = false)
if (empty($meeting_name)) { return false; } {
if (empty($meeting_name)) {
return false;
}
$pass = $this->get_user_meeting_password(); $pass = $this->get_user_meeting_password();
$meeting_data = Database::select('*', $this->table, array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)), 'first');
if (empty($meeting_data)) { $meeting_data = Database::select(
'*',
$this->table,
array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)),
'first'
);
if (empty($meeting_data) || !is_array($meeting_data)) {
if ($this->debug) error_log("meeting does not exist: $meeting_name "); if ($this->debug) error_log("meeting does not exist: $meeting_name ");
return false; return false;
} }
$meeting_is_running_info = $this->api->isMeetingRunningWithXmlResponseArray($meeting_data['id']); $params = array(
$meeting_is_running = $meeting_is_running_info['running'] == 'true' ? true : false; 'meetingId' => $meeting_data['id'],
// -- REQUIRED - The unique id for the meeting
'password' => $this->get_mod_meeting_password()
// -- REQUIRED - The moderator password for the meeting
);
if ($this->debug) error_log("meeting is running: ".$meeting_is_running); $status = false;
$meeting_info_exists = false;
while ($status == false) {
$params = array( $meeting_is_running_info = $this->get_meeting_info($params);
'meetingId' => $meeting_data['id'], // -- REQUIRED - The unique id for the meeting
'password' => $this->get_mod_meeting_password() // -- REQUIRED - The moderator password for the meeting
);
$meeting_info_exists = $this->get_meeting_info($params); error_log(print_r($meeting_is_running_info, 1));
if (isset($meeting_is_running) && $meeting_info_exists) { if (strval($meeting_is_running_info['returncode']) == 'SUCCESS' &&
isset($meeting_is_running_info['meetingName']) &&
!empty($meeting_is_running_info['meetingName'])
//strval($meeting_is_running_info['running']) == 'true'
) {
$meeting_info_exists = true;
}
if ($this->debug) {
error_log(
"meeting is running: " . intval($meeting_info_exists)
);
}
if ($meeting_info_exists) {
$status = true;
}
if ($loop) {
continue;
} else {
break;
}
}
if ($meeting_info_exists) {
$joinParams = array( $joinParams = array(
'meetingId' => $meeting_data['id'], // -- REQUIRED - A unique id for the meeting 'meetingId' => $meeting_data['id'], // -- REQUIRED - A unique id for the meeting
'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting 'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting
@ -212,13 +300,15 @@ class bbb {
if ($this->debug) error_log("return url :".$url); if ($this->debug) error_log("return url :".$url);
return $url; return $url;
} }
/** /**
* Get information about the given meeting * Get information about the given meeting
* @param array ...? * @param array ...?
* @return mixed Array of information on success, false on error * @return mixed Array of information on success, false on error
* @assert (array()) === false * @assert (array()) === false
*/ */
function get_meeting_info($params) { public function get_meeting_info($params)
{
try { try {
$result = $this->api->getMeetingInfoWithXmlResponseArray($params); $result = $this->api->getMeetingInfoWithXmlResponseArray($params);
if ($result == null) { if ($result == null) {
@ -236,9 +326,10 @@ class bbb {
* Gets all the course meetings saved in the plugin_bbb_meeting table * Gets all the course meetings saved in the plugin_bbb_meeting table
* @return array Array of current open meeting rooms * @return array Array of current open meeting rooms
*/ */
function get_course_meetings() { public function get_course_meetings()
{
$pass = $this->get_user_meeting_password(); $pass = $this->get_user_meeting_password();
$meeting_list = Database::select('*', $this->table, array('where' => array('c_id = ? ' => api_get_course_int_id()))); $meeting_list = Database::select('*', $this->table, array('where' => array('c_id = ? AND session_id = ? ' => array(api_get_course_int_id(), api_get_session_id()))));
$new_meeting_list = array(); $new_meeting_list = array();
$item = array(); $item = array();
@ -315,6 +406,7 @@ class bbb {
$item['created_at'] = api_convert_and_format_date($meeting_db['created_at']); $item['created_at'] = api_convert_and_format_date($meeting_db['created_at']);
//created_at //created_at
$meeting_db['created_at'] = $item['created_at']; //avoid overwrite in array_merge() below
$item['publish_url'] = api_get_self().'?'.api_get_cidreq().'&action=publish&id='.$meeting_db['id']; $item['publish_url'] = api_get_self().'?'.api_get_cidreq().'&action=publish&id='.$meeting_db['id'];
$item['unpublish_url'] = api_get_self().'?'.api_get_cidreq().'&action=unpublish&id='.$meeting_db['id']; $item['unpublish_url'] = api_get_self().'?'.api_get_cidreq().'&action=unpublish&id='.$meeting_db['id'];
@ -335,18 +427,23 @@ class bbb {
} }
return $new_meeting_list; return $new_meeting_list;
} }
/** /**
* Function disabled * Function disabled
*/ */
function publish_meeting($id) { public function publish_meeting($id)
{
//return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt); //return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt);
} }
/** /**
* Function disabled * Function disabled
*/ */
function unpublish_meeting($id) { public function unpublish_meeting($id)
{
//return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt); //return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
} }
/** /**
* Closes a meeting (usually when the user click on the close button from * Closes a meeting (usually when the user click on the close button from
* the conferences listing. * the conferences listing.
@ -354,7 +451,8 @@ class bbb {
* @return void * @return void
* @assert (0) === false * @assert (0) === false
*/ */
function end_meeting($id) { public function end_meeting($id)
{
if (empty($id)) { return false; } if (empty($id)) { return false; }
$pass = $this->get_user_meeting_password(); $pass = $this->get_user_meeting_password();
$endParams = array( $endParams = array(
@ -364,22 +462,26 @@ class bbb {
$this->api->endMeetingWithXmlResponseArray($endParams); $this->api->endMeetingWithXmlResponseArray($endParams);
Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $id)); Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $id));
} }
/** /**
* Gets the password for a specific meeting for the current user * Gets the password for a specific meeting for the current user
* @return string A moderator password if user is teacher, or the course code otherwise * @return string A moderator password if user is teacher, or the course code otherwise
*/ */
function get_user_meeting_password() { public function get_user_meeting_password()
{
if ($this->is_teacher()) { if ($this->is_teacher()) {
return $this->get_mod_meeting_password(); return $this->get_mod_meeting_password();
} else { } else {
return api_get_course_id(); return api_get_course_id();
} }
} }
/** /**
* Generated a moderator password for the meeting * Generated a moderator password for the meeting
* @return string A password for the moderation of the videoconference * @return string A password for the moderation of the videoconference
*/ */
function get_mod_meeting_password() { public function get_mod_meeting_password()
{
return api_get_course_id().'mod'; return api_get_course_id().'mod';
} }
@ -388,9 +490,11 @@ class bbb {
* @return int The number of users currently connected to the videoconference * @return int The number of users currently connected to the videoconference
* @assert () > -1 * @assert () > -1
*/ */
function get_users_online_in_current_room() { public function get_users_online_in_current_room()
{
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND status = 1 ' => $course_id)), 'first'); $session_id = api_get_session_id();
$meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND session_id = ? AND status = 1 ' => array($course_id, $session_id))), 'first');
if (empty($meeting_data)) { if (empty($meeting_data)) {
return 0; return 0;
} }
@ -403,19 +507,21 @@ class bbb {
} }
return 0; return 0;
} }
/** /**
* Deletes a previous recording of a meeting * Deletes a previous recording of a meeting
* @param int intergal ID of the recording * @param int integral ID of the recording
* @return array ? * @return array ?
* @assert () === false * @assert () === false
* @todo Also delete links and agenda items created from this recording * @todo Also delete links and agenda items created from this recording
*/ */
function delete_record($ids) { public function delete_record($ids)
{
if (empty($ids) or (is_array($ids) && count($ids)==0)) { return false; } if (empty($ids) or (is_array($ids) && count($ids)==0)) { return false; }
$recordingParams = array( $recordingParams = array(
/* /*
* NOTE: Set the recordId below to a valid id after you have * NOTE: Set the recordId below to a valid id after you have
* created a recorded meeting, and received a real recordID * created a recorded meeting, and received a real recordID
* back from your BBB server using the * back from your BBB server using the
* getRecordingsWithXmlResponseArray method. * getRecordingsWithXmlResponseArray method.
*/ */
@ -425,6 +531,7 @@ class bbb {
); );
return $this->api->deleteRecordingsWithXmlResponseArray($recordingParams); return $this->api->deleteRecordingsWithXmlResponseArray($recordingParams);
} }
/** /**
* Creates a link in the links tool from the given videoconference recording * Creates a link in the links tool from the given videoconference recording
* @param int ID of the item in the plugin_bbb_meeting table * @param int ID of the item in the plugin_bbb_meeting table
@ -434,7 +541,8 @@ class bbb {
* @assert (1, null) === false * @assert (1, null) === false
* @assert (null, 'abcdefabcdefabcdefabcdef') === false * @assert (null, 'abcdefabcdefabcdefabcdef') === false
*/ */
function copy_record_to_link_tool($id, $record_id) { public function copy_record_to_link_tool($id, $record_id)
{
if (empty($id) or empty($record_id)) { if (empty($id) or empty($record_id)) {
return false; return false;
} }
@ -456,16 +564,56 @@ class bbb {
} }
} }
} }
return false; return false;
} }
/** /**
* Checks if the videoconference server is running. * Checks if the videoconference server is running.
* Function currently disabled (always returns 1) * Function currently disabled (always returns 1)
* @return bool True if server is running, false otherwise * @return bool True if server is running, false otherwise
* @assert () === false * @assert () === false
*/ */
function is_server_running() { public function is_server_running()
{
return true; return true;
//return BigBlueButtonBN::isServerRunning($this->protocol.$this->url); //return BigBlueButtonBN::isServerRunning($this->protocol.$this->url);
} }
/**
* Get active session in the all platform
*/
public function getActiveSessionsCount()
{
$meetingList = Database::select(
'count(id) as count',
$this->table,
array('where' => array('status = ?' => array(1))),
'first'
);
return $meetingList['count'];
}
/**
* @param string $url
*/
public function redirectToBBB($url)
{
if (file_exists(__DIR__ . '/../config.vm.php')) {
// Using VM
echo Display::url(get_lang('ClickToContinue'), $url);
exit;
} else {
// Classic
header("Location: $url");
exit;
}
// js
/*echo '<script>';
echo 'window.location = "'.$url.'"';
echo '</script>';
exit;*/
}
} }

@ -164,7 +164,7 @@ class BigBlueButtonBN {
*/ */
$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams)); $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
if($xml) { if ($xml) {
if($xml->meetingID) if($xml->meetingID)
return array( return array(
'returncode' => $xml->returncode, 'returncode' => $xml->returncode,
@ -247,7 +247,7 @@ class BigBlueButtonBN {
); );
*/ */
$xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams)); $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams));
if($xml) { if ($xml) {
return array( return array(
'returncode' => $xml->returncode, 'returncode' => $xml->returncode,
'message' => $xml->message, 'message' => $xml->message,

@ -6,26 +6,35 @@
* main/img/icons/64/plugin_name.png * main/img/icons/64/plugin_name.png
* main/img/icons/64/plugin_name_na.png * main/img/icons/64/plugin_name_na.png
*/ */
/**
* Class BBBPlugin
*/
class BBBPlugin extends Plugin class BBBPlugin extends Plugin
{ {
public $is_course_plugin = true; public $isCoursePlugin = true;
//When creating a new course this settings are added to the course //When creating a new course this settings are added to the course
public $course_settings = array( public $course_settings = array(
// array('name' => 'big_blue_button_welcome_message', 'type' => 'text'), array(
array('name' => 'big_blue_button_record_and_store', 'type' => 'checkbox') 'name' => 'big_blue_button_record_and_store',
'type' => 'checkbox'
)
); );
static function create() { static function create()
{
static $result = null; static $result = null;
return $result ? $result : $result = new self(); return $result ? $result : $result = new self();
} }
protected function __construct() { protected function __construct()
parent::__construct('2.0', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text')); {
parent::__construct('2.1', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text'));
} }
function install() { public function install()
{
$table = Database::get_main_table('plugin_bbb_meeting'); $table = Database::get_main_table('plugin_bbb_meeting');
$sql = "CREATE TABLE IF NOT EXISTS $table ( $sql = "CREATE TABLE IF NOT EXISTS $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY, id INT unsigned NOT NULL auto_increment PRIMARY KEY,
@ -38,14 +47,16 @@ class BBBPlugin extends Plugin
created_at VARCHAR(255) NOT NULL, created_at VARCHAR(255) NOT NULL,
closed_at VARCHAR(255) NOT NULL, closed_at VARCHAR(255) NOT NULL,
calendar_id INT DEFAULT 0, calendar_id INT DEFAULT 0,
welcome_msg VARCHAR(255) NOT NULL DEFAULT '')"; welcome_msg VARCHAR(255) NOT NULL DEFAULT '',
session_id INT unsigned DEFAULT 0)";
Database::query($sql); Database::query($sql);
//Installing course settings //Installing course settings
$this->install_course_fields_in_all_courses(); $this->install_course_fields_in_all_courses();
} }
function uninstall() { public function uninstall()
{
$t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS); $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST); $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
@ -70,13 +81,13 @@ class BBBPlugin extends Plugin
Database::query($sql); Database::query($sql);
//hack to get rid of Database::query warning (please add c_id...) //hack to get rid of Database::query warning (please add c_id...)
$sql = "DELETE FROM $t_tool WHERE name = 'bbb' AND c_id = c_id"; $sql = "DELETE FROM $t_tool WHERE name = 'bbb'";//" AND c_id = c_id";
Database::query($sql); Database::query($sql);
$sql = "DROP TABLE IF EXISTS plugin_bbb_meeting"; $sql = "DROP TABLE IF EXISTS plugin_bbb_meeting";
Database::query($sql); Database::query($sql);
//Deleting course settings //Deleting course settings
$this->uninstall_course_fields_in_all_courses(); $this->uninstall_course_fields_in_all_courses($this->course_settings);
} }
} }

@ -32,7 +32,14 @@ if ($teacher) {
$title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $course_info['name']); $title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $course_info['name']);
$content = Display::url(get_lang('GoToTheVideoConference'), $_GET['url']); $content = Display::url(get_lang('GoToTheVideoConference'), $_GET['url']);
$event_id = $agenda->add_event($_REQUEST['start'], null, 'true', null, $title, $content, array('everyone')); $event_id = $agenda->add_event(
$_REQUEST['start'],
null,
'true',
$title,
$content,
array('everyone')
);
if (!empty($event_id)) { if (!empty($event_id)) {
$message = Display::return_message(get_lang('VideoConferenceAddedToTheCalendar'), 'success'); $message = Display::return_message(get_lang('VideoConferenceAddedToTheCalendar'), 'success');
} else { } else {
@ -57,7 +64,28 @@ if ($teacher) {
break; break;
case 'end': case 'end':
$bbb->end_meeting($_GET['id']); $bbb->end_meeting($_GET['id']);
$message = Display::return_message(get_lang('MeetingClosed').'<br />'.get_lang('MeetingClosedComment'), 'success', false); $message = Display::return_message(
get_lang('MeetingClosed') . '<br />' . get_lang(
'MeetingClosedComment'
),
'success',
false
);
if (file_exists(__DIR__ . '/config.vm.php')) {
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/lib/vm/AbstractVM.php';
require __DIR__ . '/lib/vm/VMInterface.php';
require __DIR__ . '/lib/vm/DigitalOceanVM.php';
require __DIR__ . '/lib/VM.php';
$config = require __DIR__ . '/config.vm.php';
$vm = new VM($config);
$vm->resizeToMinLimit();
}
break; break;
case 'publish': case 'publish':
//$result = $bbb->publish_meeting($_GET['id']); //$result = $bbb->publish_meeting($_GET['id']);
@ -76,7 +104,7 @@ if (!empty($meetings)) {
} }
$users_online = $bbb->get_users_online_in_current_room(); $users_online = $bbb->get_users_online_in_current_room();
$status = $bbb->is_server_running(); $status = $bbb->is_server_running();
$meeting_exists = $bbb->meeting_exists(api_get_course_id()); $meeting_exists = $bbb->meeting_exists(api_get_course_id().'-'.api_get_session_id());
$show_join_button = false; $show_join_button = false;
if ($meeting_exists || $teacher) { if ($meeting_exists || $teacher) {
$show_join_button = true; $show_join_button = true;

@ -1,4 +1,5 @@
<?php <?php
require_once dirname(__FILE__).'/config.php'; require_once dirname(__FILE__).'/config.php';
$plugin_info = BBBPlugin::create()->get_info();
$plugin_info = BBBPlugin::create()->get_info();

@ -1,16 +1,23 @@
<?php <?php
/** /**
* This script initiates a videoconference session, calling the BigBlueButton API * This script initiates a video conference session, calling the BigBlueButton API
* @package chamilo.plugin.bigbluebutton * @package chamilo.plugin.bigbluebutton
*/ */
/**
* Initialization require __DIR__ . '/../../vendor/autoload.php';
*/
$course_plugin = 'bbb'; //needed in order to load the plugin lang variables $course_plugin = 'bbb'; //needed in order to load the plugin lang variables
require_once dirname(__FILE__).'/config.php'; require_once dirname(__FILE__).'/config.php';
$tool_name = get_lang('Videoconference'); $tool_name = get_lang('Videoconference');
$tpl = new Template($tool_name); $tpl = new Template($tool_name);
$vmIsEnabled = false;
$host = null;
$salt = null;
$bbb = new bbb(); $bbb = new bbb();
if ($bbb->plugin_enabled) { if ($bbb->plugin_enabled) {
@ -18,33 +25,52 @@ if ($bbb->plugin_enabled) {
if (isset($_GET['launch']) && $_GET['launch'] == 1) { if (isset($_GET['launch']) && $_GET['launch'] == 1) {
if (file_exists(__DIR__ . '/config.vm.php')) {
$config = require __DIR__ . '/config.vm.php';
$vmIsEnabled = true;
$host = null;
$salt = null;
require __DIR__ . '/lib/vm/AbstractVM.php';
require __DIR__ . '/lib/vm/VMInterface.php';
require __DIR__ . '/lib/vm/DigitalOceanVM.php';
require __DIR__ . '/lib/VM.php';
$vm = new VM($config);
if ($vm->IsEnabled()) {
try {
$vm->resizeToMaxLimit();
} catch (\Exception $e) {
echo $e->getMessage();
exit;
}
}
}
$meeting_params = array(); $meeting_params = array();
$meeting_params['meeting_name'] = api_get_course_id(); $meeting_params['meeting_name'] = api_get_course_id().'-'.api_get_session_id();
if ($bbb->meeting_exists($meeting_params['meeting_name'])) { if ($bbb->meeting_exists($meeting_params['meeting_name'])) {
$url = $bbb->join_meeting($meeting_params['meeting_name']); $url = $bbb->join_meeting($meeting_params['meeting_name']);
if ($url) { if ($url) {
header('location: '.$url); $bbb->redirectToBBB($url);
exit;
} else { } else {
$url = $bbb->create_meeting($meeting_params); $url = $bbb->create_meeting($meeting_params);
header('location: '.$url); $bbb->redirectToBBB($url);
exit;
} }
} else { } else {
if ($bbb->is_teacher()) { if ($bbb->is_teacher()) {
$url = $bbb->create_meeting($meeting_params); $url = $bbb->create_meeting($meeting_params);
header('location: '.$url); $bbb->redirectToBBB($url);
exit;
} else { } else {
$url = 'listing.php'; $url = 'listing.php?'.api_get_cidreq();
header('location: '.$url); $bbb->redirectToBBB($url);
exit;
} }
} }
} else { } else {
$url = 'listing.php'; $url = 'listing.php?'.api_get_cidreq();
header('location: '.$url); header('Location: ' . $url);
exit; exit;
} }
} else { } else {

@ -8,7 +8,7 @@
*/ */
/* Plugin config */ /* Plugin config */
return;
// The plugin title. // The plugin title.
$plugin_info['title'] = 'Show HTML before login'; $plugin_info['title'] = 'Show HTML before login';
// The comments that go with the plugin. // The comments that go with the plugin.

Loading…
Cancel
Save