diff --git a/main/admin/access_url_add_courses_to_url.php b/main/admin/access_url_add_courses_to_url.php index dab3136ab9..8f12c182a7 100644 --- a/main/admin/access_url_add_courses_to_url.php +++ b/main/admin/access_url_add_courses_to_url.php @@ -38,9 +38,7 @@ $tool_name = get_lang('AddCoursesToURL'); $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); -/* MAIN CODE */ - -Display::display_header($tool_name); +Display :: display_header($tool_name); echo '
'; echo Display::url( @@ -71,19 +69,16 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) { } } - - -/* Display GUI */ - -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 (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) { - // assign a default filter on users names - $first_letter_user = 'A'; - } - unset($result); + //if there are too much num_courses to gracefully handle with the HTML select list, + // assign a default filter on users names + $first_letter_user = 'A'; + } + unset($result); } $first_letter_course = Database::escape_string($first_letter_course); @@ -152,4 +147,5 @@ unset($result); 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); -/* MAIN CODE */ - Display :: display_header($tool_name); echo '
'; @@ -60,31 +57,25 @@ if ($_POST['form_sent']) { } 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')); - //header('Location: access_urls.php?action=show_message&message='.get_lang('AtLeastOneUserAndOneURL')); } else { UrlManager::add_users_to_urls($users,$url_list); Display :: display_confirmation_message(get_lang('UsersBelongURL')); - //header('Location: access_urls.php?action=show_message&message='.get_lang('UsersBelongURL')); } } } - - /* Display GUI */ - - if (empty($first_letter_user)) { $sql = "SELECT count(*) as nb_users FROM $tbl_user"; $result = Database::query($sql); $num_row = Database::fetch_array($result); - if($num_row['nb_users']>1000) { - //if there are too much users to gracefully handle with the HTML select list, - // assign a default filter on users names - $first_letter_user = 'A'; - } + if ($num_row['nb_users']>1000) { + //if there are too much users to gracefully handle with the HTML select list, + // assign a default filter on users names + $first_letter_user = 'A'; + } unset($result); } $first_letter_user = Database::escape_string($first_letter_user); @@ -111,7 +102,7 @@ unset($result);

- + -
- - - + + +
+ + +
- - - - -

- - + + + + +

+ +





-
- '.get_lang('AddUsersToURL').''; - else - echo ''; - ?> + ' . get_lang('AddUsersToURL') . ''; + } else { + echo ''; + } + ?> registerFunction (array('search_courses', 'AddCourseToSession', 'search_courses')); +$xajax->registerFunction(array('search_courses', 'AddCourseToSession', 'search_courses')); // Setting the section (for the tabs) $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; -$xajax -> processRequests(); +$xajax->processRequests(); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); -$htmlHeadXtra[] = ' -'; -$formSent=0; -$errorMsg=$firstLetterCourse=$firstLetterSession=''; -$CourseList=$SessionList=array(); -$courses=$sessions=array(); -$noPHP_SELF=true; +$formSent = 0; +$errorMsg = $firstLetterCourse = $firstLetterSession = ''; +$CourseList = $SessionList = array(); +$courses = $sessions = array(); +$noPHP_SELF = true; if (isset($_POST['formSent']) && $_POST['formSent']) { - $formSent = $_POST['formSent']; - $firstLetterCourse = $_POST['firstLetterCourse']; - $firstLetterSession = $_POST['firstLetterSession']; - $CourseList = $_POST['SessionCoursesList']; + $formSent = $_POST['formSent']; + $firstLetterCourse = $_POST['firstLetterCourse']; + $firstLetterSession = $_POST['firstLetterSession']; + $CourseList = $_POST['SessionCoursesList']; if (!is_array($CourseList)) { $CourseList = array(); } @@ -105,21 +101,20 @@ if (isset($_POST['formSent']) && $_POST['formSent']) { $existingCourses = Database::store_result($rs); // Updating only the RRHH users?? why? - //$sql="SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session AND relation_type=".COURSE_RELATION_TYPE_RRHH." "; - $sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session "; - $result = Database::query($sql); - $UserList = Database::store_result($result); - + $sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session "; + $result = Database::query($sql); + $UserList = Database::store_result($result); - foreach($CourseList as $enreg_course) { + foreach ($CourseList as $enreg_course) { $enreg_course = Database::escape_string($enreg_course); $exists = false; - foreach($existingCourses as $existingCourse) { - if($enreg_course == $existingCourse['course_code']) { - $exists=true; - } - } - if(!$exists) { + foreach ($existingCourses as $existingCourse) { + if ($enreg_course == $existingCourse['course_code']) { + $exists = true; + } + } + + if (!$exists) { $sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course(id_session,course_code) VALUES('$id_session','$enreg_course')"; Database::query($sql_insert_rel_course); @@ -131,7 +126,8 @@ if (isset($_POST['formSent']) && $_POST['formSent']) { $nbr_users=0; foreach ($UserList as $enreg_user) { $enreg_user = Database::escape_string($enreg_user['id_user']); - $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$enreg_user')"; + $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) + VALUES('$id_session','$enreg_course','$enreg_user')"; Database::query($sql_insert); if(Database::affected_rows()) { $nbr_users++; @@ -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_rel_user WHERE course_code='".$existingCourse['course_code']."' AND id_session=$id_session"); SessionManager::unInstallCourse($id_session, $course_info['real_id']); - } } $nbr_courses=count($CourseList); @@ -168,12 +163,12 @@ Display::display_header($tool_name); if ($add_type == 'multiple') { $link_add_type_unique = ''. - Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').''; + Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').''; $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').' '; } else { $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'   '; $link_add_type_multiple = ''. - Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').''; + Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').''; } // 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) WHERE access_url_id = $access_url_id ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title"; - } } @@ -239,7 +233,7 @@ if ($ajax_search) { } $result = Database::query($sql); $Courses = Database::store_result($result); - foreach($Courses as $course) { + foreach ($Courses as $course) { if ($course['id_session'] == $id_session) { $sessionCourses[$course['code']] = $course ; } else { @@ -254,8 +248,7 @@ unset($Courses); @@ -295,10 +288,11 @@ if (!($add_type == 'multiple')) { ?>
@@ -324,7 +318,7 @@ unset($nosessionCourses); ?>





'.get_lang('NextStep').''; } else { echo ''; @@ -334,11 +328,11 @@ unset($nosessionCourses); '; - foreach ($list as $row ) { + foreach ($list as $row) { if (!in_array($row['id'], array_keys($elements_in))) { $return .= ''; } } $return .= ''; - $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; } -$xajax -> processRequests(); + +$xajax->processRequests(); Display::display_header($tool_name); if ($add_type == 'multiple') { - $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 = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); } else { $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); - $link_add_type_multiple = ''.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').''; + $link_add_type_multiple = ''. + Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').''; } echo '
'; echo ''.Display::return_icon('back.png',get_lang('Back'), array(), ICON_SIZE_MEDIUM).''; +echo Display::url(get_lang('AdvancedSearch'), '#', array('class' => 'advanced_options', 'id' => 'advanced_search')); echo '
'; + +echo ''; + ?>
> '.$data['name'].': '.$tool_name.''; -/* -if ($add_type=='multiple') { - if (is_array($extra_field_list)) { - if (is_array($new_field_list) && count($new_field_list)>0 ) { - echo '

'.get_lang('FilterUsers').'

'; - foreach ($new_field_list as $new_field) { - echo $new_field['name']; - $varname = 'field_'.$new_field['variable']; - echo ' '; - echo '  '; - } - echo ''; - echo '

'; - } - } -}*/ -echo Display::input('hidden','id',$id); -echo Display::input('hidden','form_sent','1'); -echo Display::input('hidden','add_type',null); -if(!empty($errorMsg)) { +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 } ?> @@ -227,12 +245,12 @@ if(!empty($errorMsg)) { : - +   @@ -249,7 +267,7 @@ if(!empty($errorMsg)) { } else { ?>
- 'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?> + 'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?>
- diff --git a/main/admin/add_sessions_to_promotion.php b/main/admin/add_sessions_to_promotion.php index 3d26e8cdc2..eea7617827 100644 --- a/main/admin/add_sessions_to_promotion.php +++ b/main/admin/add_sessions_to_promotion.php @@ -5,18 +5,16 @@ */ // name of the language file that needs to be included -$language_file=array('admin','registration'); +$language_file = array('admin','registration'); // resetting the course id -$cidReset=true; +$cidReset = true; // including some necessary files require_once '../inc/global.inc.php'; $xajax = new xajax(); - -//$xajax->debugOn(); -$xajax -> registerFunction ('search_sessions'); +$xajax->registerFunction ('search_sessions'); // setting the section (for the tabs) $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')); // Database Table Definitions - -// setting the name of the tool -$tool_name=get_lang('SubscribeSessionsToPromotions'); - +$tool_name = get_lang('SubscribeSessionsToPromotions'); $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']); } @@ -79,9 +74,9 @@ $errorMsg = ''; $users =$sessions=array(); $promotion = new Promotion(); $id = intval($_GET['id']); -if($_POST['form_sent']) { - $form_sent = $_POST['form_sent']; - $session_in_promotion_posted = $_POST['session_in_promotion_name']; +if (isset($_POST['form_sent']) && $_POST['form_sent']) { + $form_sent = $_POST['form_sent']; + $session_in_promotion_posted = $_POST['session_in_promotion_name']; if (!is_array($session_in_promotion_posted)) { $session_in_promotion_posted=array(); } @@ -95,12 +90,10 @@ if($_POST['form_sent']) { $promotion_data = $promotion->get($id); $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(); if (!empty($session_list)) { - foreach($session_list as $session) { + foreach ($session_list as $session) { $promotion_id = $session['promotion_id']; if (isset($promotion_id) && !empty($promotion_id)) { if ($promotion_id == $id) { @@ -117,8 +110,9 @@ $ajax_search = $add_type == 'unique' ? true : false; //checking for extra field with filter on -function search_sessions($needle,$type) { - global $tbl_user,$session_in_promotion; +function search_sessions($needle, $type) +{ + global $session_in_promotion; $xajax_response = new XajaxResponse(); $return = ''; if (!empty($needle) && !empty($type)) { @@ -128,44 +122,20 @@ function search_sessions($needle,$type) { $needle = Database::escape_string($needle); $needle = api_convert_encoding($needle, $charset, 'utf-8'); - if ($type == 'single') { - // search users where username or firstname or lastname begins likes $needle - /* $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user - WHERE (username LIKE "'.$needle.'%" - OR firstname LIKE "'.$needle.'%" - 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 .= ''.$person_name.' ('.$user['username'].')
'; - } else { - $return .= '...
'; - } - } - $xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));*/ - } else { - $return .= ''; + foreach ($session_list as $row ) { + if (!in_array($row['id'], array_keys($session_in_promotion))) { + $return .= ''; } - $return .= ''; - $xajax_response -> addAssign('ajax_list_multiple','innerHTML',api_utf8_encode($return)); } + $return .= ''; + $xajax_response -> addAssign('ajax_list_multiple','innerHTML',api_utf8_encode($return)); + } return $xajax_response; } -$xajax -> processRequests(); +$xajax->processRequests(); Display::display_header($tool_name); @@ -187,7 +157,7 @@ echo '
'; if ($add_type=='multiple') { 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 '

'.get_lang('FilterUsers').'

'; foreach ($new_field_list as $new_field) { echo $new_field['name']; @@ -211,10 +181,10 @@ if ($add_type=='multiple') { } } } -echo Display::input('hidden','id',$id); -echo Display::input('hidden','form_sent','1'); -echo Display::input('hidden','add_type',null); -if(!empty($errorMsg)) { +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 } ?> @@ -278,7 +248,13 @@ if(!empty($errorMsg)) { '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); ?> @@ -293,8 +269,40 @@ if(!empty($errorMsg)) { - -"'.$user_anonymous.'" AND user.status<>'.DRH.''. $order_clause. ' LIMIT 11';*/ + } else if ($type == 'searchbox') { + $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "%$needle%")); } else { $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "$needle%")); } @@ -167,24 +169,28 @@ $xajax -> processRequests(); Display::display_header($tool_name); if ($add_type == 'multiple') { - $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 = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); } else { $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); - $link_add_type_multiple = ''.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').''; + $link_add_type_multiple = ''.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').''; } echo '
'; -echo ''.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).''; +echo ''.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).''; +echo ' '.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').''; echo '
'; ?> + +'. get_lang('SearchSessions'); ?> : + +
> '.$data['name'].': '.$tool_name.''; if ($add_type=='multiple') { - /* if (is_array($extra_field_list)) { if (is_array($new_field_list) && count($new_field_list)>0 ) { echo '

'.get_lang('FilterUsers').'

'; @@ -208,7 +214,7 @@ if ($add_type=='multiple') { echo ''; echo '

'; } - }*/ + } } echo Display::input('hidden','id',$id); echo Display::input('hidden','form_sent','1'); @@ -236,6 +242,7 @@ if(!empty($errorMsg)) { echo Display :: get_alphabet_options(); ?> +'; ?>   @@ -243,8 +250,8 @@ if(!empty($errorMsg)) {
-
diff --git a/main/admin/add_users_to_group.php b/main/admin/add_users_to_group.php index ea56a0aa9a..54f6146659 100644 --- a/main/admin/add_users_to_group.php +++ b/main/admin/add_users_to_group.php @@ -5,10 +5,10 @@ */ // 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 -$cidReset=true; +$cidReset = true; // including some necessary files require_once '../inc/global.inc.php'; @@ -16,27 +16,29 @@ require_once '../inc/global.inc.php'; // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; -global $_configuration; // Access restrictions api_protect_admin_script(true); // setting breadcrumbs -$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); -$interbreadcrumb[]=array('url' => 'group_list.php','name' => get_lang('GroupList')); +$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); +$interbreadcrumb[] = array('url' => 'group_list.php','name' => get_lang('GroupList')); // Database Table Definitions $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $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); +$needle = null; +$user_anonymous = api_get_anonymous_id(); // setting the name of the tool $tool_name = get_lang('SubscribeUsersToGroup'); $group_id = intval($_GET['id']); +$without_user_id = null; $add_type = 'multiple'; -if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ - $add_type = Security::remove_XSS($_REQUEST['add_type']); +if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') { + $add_type = Security::remove_XSS($_REQUEST['add_type']); } //checking for extra field with filter on @@ -177,16 +179,10 @@ function search_users($needle,$type,$relation_type) { $xajax->processRequests(); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); - $htmlHeadXtra[] = ' '; -$form_sent=0; -$errorMsg=$firstLetterUser=$firstLetterSession=''; -$UserList=$SessionList=array(); -$users=$sessions=array(); -$noPHP_SELF=true; - +$form_sent = 0; +$errorMsg = $firstLetterUser = $firstLetterSession=''; +$UserList = $SessionList = array(); +$users = $sessions = array(); +$noPHP_SELF = true; $group_info = GroupPortalManager::get_group_data($group_id); $group_name = $group_info['name']; Display::display_header($group_name); -if ($_POST['form_sent']) { - - $form_sent = $_POST['form_sent']; - $firstLetterUser = $_POST['firstLetterUser']; - $UserList = $_POST['sessionUsersList']; - $group_id = intval($_POST['id']); - $relation_type = intval($_POST['relation']); +if (isset($_POST['form_sent']) && $_POST['form_sent']) { + $form_sent = $_POST['form_sent']; + $firstLetterUser = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null; + $UserList = $_POST['sessionUsersList']; + $group_id = intval($_POST['id']); + $relation_type = intval($_POST['relation']); if(!is_array($UserList)) { $UserList=array(); diff --git a/main/admin/configure_plugin.php b/main/admin/configure_plugin.php index 9df28e23a1..052508e6ee 100644 --- a/main/admin/configure_plugin.php +++ b/main/admin/configure_plugin.php @@ -16,7 +16,7 @@ api_protect_admin_script(); $plugin_name = $_GET['name']; $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)) { api_not_allowed(); @@ -29,7 +29,7 @@ if (!in_array($plugin_name, $installed_plugins)) { } global $_configuration; - +$message = null; $content = null; if (isset($plugin_info['settings_form'])) { @@ -55,8 +55,19 @@ if (isset($form)) { array('Plugins', $access_url_id, $plugin_name, 'setting', "status"))); foreach ($values as $key => $value) { $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'); } diff --git a/main/admin/course_add.php b/main/admin/course_add.php index 5c0ff1c59c..59ce5023f4 100644 --- a/main/admin/course_add.php +++ b/main/admin/course_add.php @@ -37,14 +37,13 @@ if (api_is_multiple_url_enabled()) { $res = Database::query($sql); $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); } // Build the form. $form = new FormValidator('update_course'); -$form->addElement('header', '', $tool_name); +$form->addElement('header', $tool_name); // Title $form->add_textfield('title', get_lang('Title'), true, array ('class' => 'span6')); @@ -52,15 +51,12 @@ $form->applyFilter('title', 'html_filter'); $form->applyFilter('title', 'trim'); // 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', 'html_filter'); $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->applyFilter('course_teachers', 'html_filter'); @@ -125,23 +121,26 @@ if (isset($default_course_visibility)) { } $values['subscribe'] = 1; $values['unsubscribe'] = 0; -reset($teachers); -//$values['course_teachers'] = key($teachers); $form->setDefaults($values); // Validate the form if ($form->validate()) { $course = $form->exportValues(); - //$tutor_name = $teachers[$course['tutor_id']]; - $course['user_id'] = isset($course['tutor_id']) ? $course['tutor_id'] : null; - $course['teachers'] = isset($course['course_teachers']) ? $course['course_teachers'] : null; + $teacher_id = $course['tutor_id']; + $course_teachers = $course['course_teachers']; + $course['disk_quota'] = $course['disk_quota']*1024*1024; + $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['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); + header('Location: course_list.php'.($course_info===false?'?action=show_msg&warn='.api_get_last_failure():'')); exit; } diff --git a/main/admin/course_create_content.php b/main/admin/course_create_content.php index c904c07fae..5aae8943a0 100755 --- a/main/admin/course_create_content.php +++ b/main/admin/course_create_content.php @@ -7,31 +7,39 @@ * @package chamilo.admin */ /** - * INIT SECTION + * INIT SECTION */ // name of the language file that needs to be included $language_file = 'admin'; -include('../inc/global.inc.php'); -$this_section = SECTION_PLATFORM_ADMIN; +include ('../inc/global.inc.php'); +$this_section=SECTION_PLATFORM_ADMIN; api_protect_admin_script(); $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); //api_display_tool_title($tool_name); -if (api_get_setting('server_type') != 'test') { - echo get_lang('DummyCourseOnlyOnTestServer'); -} elseif (isset($_POST['action'])) { - require_once api_get_path(SYS_CODE_PATH).'coursecopy/classes/DummyCourseCreator.class.php'; - - $dcc = new DummyCourseCreator(); - $dcc->create_dummy_course($_POST['course_code']); - echo get_lang('Done'); -} else { - echo get_lang('DummyCourseDescription'); - echo ''; +if(api_get_setting('server_type') != 'test') +{ + echo get_lang('DummyCourseOnlyOnTestServer'); +} +elseif( isset($_POST['action'])) +{ + require_once('../coursecopy/classes/DummyCourseCreator.class.php'); + $dcc = new DummyCourseCreator(); + $dcc->create_dummy_course($_POST['course_code']); + echo get_lang('Done'); +} +else +{ + echo get_lang('DummyCourseDescription'); + echo '
'; } +/* +============================================================================== + FOOTER +============================================================================== +*/ Display::display_footer(); +?> diff --git a/main/admin/course_export.php b/main/admin/course_export.php index a5129d0146..aa3e017560 100644 --- a/main/admin/course_export.php +++ b/main/admin/course_export.php @@ -53,15 +53,27 @@ if ($_POST['formSent']) { $archiveFile = 'export_courses_list_'.date('Y-m-d_H-i-s').'.'.$file_type; $fp = fopen($archivePath.$archiveFile,'w'); 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) { $course['code'] = str_replace(';',',',$course['code']); $course['title'] = str_replace(';',',',$course['title']); $course['category_code'] = str_replace(';',',',$course['category_code']); $course['tutor_name'] = str_replace(';',',',$course['tutor_name']); $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); } diff --git a/main/admin/course_import.php b/main/admin/course_import.php index 383fed04a2..31a8b6f380 100644 --- a/main/admin/course_import.php +++ b/main/admin/course_import.php @@ -119,11 +119,10 @@ function save_data($courses) { $teacherInfo = api_get_user_info_from_username($teacher); if (!empty($teacherInfo)) { $teacherList[] = $teacherInfo; + } } } - } - $params = array(); $params['title'] = $course['Title']; $params['wanted_code'] = $course['Code']; @@ -220,7 +219,7 @@ if (isset($errors) && count($errors) != 0) {
-
+
diff --git a/main/admin/course_request_accepted.php b/main/admin/course_request_accepted.php index ace9f8cf67..a74ed4506c 100644 --- a/main/admin/course_request_accepted.php +++ b/main/admin/course_request_accepted.php @@ -89,7 +89,7 @@ function get_number_of_requests() { * Get course data to display */ 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); $sql = "SELECT id AS col0, @@ -99,8 +99,7 @@ function get_request_data($from, $number_of_items, $column, $direction) { tutor_name AS col4, request_date AS col5, id AS col6 - FROM $course_request_table - WHERE status = ".COURSE_REQUEST_ACCEPTED; + FROM $course_request_table WHERE status = ".COURSE_REQUEST_ACCEPTED; if ($keyword != '') { $sql .= " AND (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')"; diff --git a/main/admin/course_request_edit.php b/main/admin/course_request_edit.php index 96e51acdb8..a641708e3a 100644 --- a/main/admin/course_request_edit.php +++ b/main/admin/course_request_edit.php @@ -65,7 +65,6 @@ if ($course_validation_feature) { // The teacher. $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. $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); } header('location:'.$back_url); - + exit; } else { - $message = $course_request_values['wanted_code'].' - '.get_lang('CourseCodeAlreadyExists'); $is_error_message = true; } diff --git a/main/admin/course_request_review.php b/main/admin/course_request_review.php index 98ca48b386..03b2a854ea 100644 --- a/main/admin/course_request_review.php +++ b/main/admin/course_request_review.php @@ -21,6 +21,17 @@ $this_section = SECTION_PLATFORM_ADMIN; 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. // Better reject the target request, after that you can delete it. define(DELETE_ACTION_ENABLED, false); @@ -53,12 +64,10 @@ if ($course_validation_feature) { $message = sprintf(get_lang('CourseRequestAcceptanceFailed'), $course_request_code); $is_error_message = true; } - } - - /** - * Course rejection - */ - elseif (!empty($reject_course_request)) { + } elseif (!empty($reject_course_request)) { + /** + * Course rejection + */ $course_request_code = CourseRequestManager::get_course_request_code($reject_course_request); $result = CourseRequestManager::reject_course_request($reject_course_request); if ($result) { @@ -68,12 +77,12 @@ if ($course_validation_feature) { $message = sprintf(get_lang('CourseRequestRejectionFailed'), $course_request_code); $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); $result = CourseRequestManager::ask_for_additional_info($request_info); if ($result) { @@ -83,12 +92,10 @@ if ($course_validation_feature) { $message = sprintf(get_lang('CourseRequestInfoFailed'), $course_request_code); $is_error_message = true; } - } - - /** - * Deletion of a course request. - */ - elseif (!empty($delete_course_request)) { + } elseif (!empty($delete_course_request)) { + /** + * Deletion of a course request. + */ $course_request_code = CourseRequestManager::get_course_request_code($delete_course_request); $result = CourseRequestManager::delete_course_request($delete_course_request); if ($result) { @@ -98,15 +105,13 @@ if ($course_validation_feature) { $message = sprintf(get_lang('CourseRequestDeletionFailed'), $course_request_code); $is_error_message = true; } - } - - /** - * Form actions: delete. - */ - elseif (DELETE_ACTION_ENABLED && isset($_POST['action'])) { + } elseif (DELETE_ACTION_ENABLED && isset($_POST['action'])) { + /** + * Form actions: delete. + */ switch ($_POST['action']) { // Delete selected courses - case 'delete_course_requests' : + case 'delete_course_requests': $course_requests = $_POST['course_request']; if (is_array($_POST['course_request']) && !empty($_POST['course_request'])) { $success = true; @@ -140,7 +145,6 @@ function get_number_of_requests() { */ function get_request_data($from, $number_of_items, $column, $direction) { global $keyword; - $course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); if (DELETE_ACTION_ENABLED) { @@ -151,8 +155,7 @@ function get_request_data($from, $number_of_items, $column, $direction) { tutor_name AS col4, request_date AS col5, id AS col6 - FROM $course_request_table - WHERE status = ".COURSE_REQUEST_PENDING; + FROM $course_request_table WHERE status = ".COURSE_REQUEST_PENDING; } else { $sql = "SELECT code AS col0, @@ -161,8 +164,7 @@ function get_request_data($from, $number_of_items, $column, $direction) { tutor_name AS col3, request_date AS col4, id AS col5 - FROM $course_request_table - WHERE status = ".COURSE_REQUEST_PENDING; + FROM $course_request_table WHERE status = ".COURSE_REQUEST_PENDING; } if ($keyword != '') { @@ -201,13 +203,13 @@ function email_filter($teacher) { function modify_filter($id) { $code = CourseRequestManager::get_course_request_code($id); $result = ''.Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align: middle;')).''. - ' '.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).''. - ' '.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).''; + ' '.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).''. + ' '.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).''; if (!CourseRequestManager::additional_info_asked($id)) { - $result .= ' '.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;')).''; + $result .= ' '.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;')).''; } if (DELETE_ACTION_ENABLED) { - $result .= ' '.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;')).''; + $result .= ' '.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;')).''; } return $result; } diff --git a/main/admin/dashboard_add_courses_to_user.php b/main/admin/dashboard_add_courses_to_user.php index ff3100e40f..14aed32cdb 100644 --- a/main/admin/dashboard_add_courses_to_user.php +++ b/main/admin/dashboard_add_courses_to_user.php @@ -7,9 +7,9 @@ */ // name of the language file that needs to be included -$language_file='admin'; +$language_file = 'admin'; // resetting the course id -$cidReset=true; +$cidReset = true; // including some necessary dokeos files require_once '../inc/global.inc.php'; @@ -17,7 +17,7 @@ require_once '../inc/global.inc.php'; global $_configuration; // create an ajax object $xajax = new xajax(); -$xajax -> registerFunction ('search_courses'); +$xajax->registerFunction('search_courses'); // setting the section (for the tabs) $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')); // Database Table Definitions -$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); -$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 = Database::get_main_table(TABLE_MAIN_COURSE); +$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); // initializing variables $id_session=intval($_GET['id_session']); @@ -51,7 +51,7 @@ if (UserManager::is_admin($user_id)) { } $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']); } @@ -145,14 +145,14 @@ function remove_item(origin) { $formSent=0; $errorMsg = $firstLetterCourse = ''; $UserList = array(); -$msg = ''; -if (intval($_POST['formSent']) == 1) { - $courses_list = $_POST['CoursesList']; - $affected_rows = CourseManager::suscribe_courses_to_hr_manager($user_id, $courses_list); - if ($affected_rows) { - $msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully'); - } +$msg = ''; +if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) { + $courses_list = $_POST['CoursesList']; + $affected_rows = CourseManager::suscribe_courses_to_hr_manager($user_id,$courses_list); + if ($affected_rows) { + $msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully'); + } } // Display header diff --git a/main/admin/dashboard_add_users_to_user.php b/main/admin/dashboard_add_users_to_user.php index ed7e0d59c9..775dbd9a1c 100644 --- a/main/admin/dashboard_add_users_to_user.php +++ b/main/admin/dashboard_add_users_to_user.php @@ -11,14 +11,11 @@ $language_file='admin'; // resetting the course id $cidReset=true; -// including some necessary dokeos files -require_once '../inc/global.inc.php'; - global $_configuration; - +$ajax_search = false; // create an ajax object $xajax = new xajax(); -$xajax -> registerFunction ('search_users'); +$xajax->registerFunction('search_users'); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; @@ -41,22 +38,24 @@ $user_info = api_get_user_info($user_id); $user_anonymous = api_get_anonymous_id(); $current_user_id = api_get_user_id(); +$firstLetterUser = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null; + // setting the name of the tool if (UserManager::is_admin($user_id)) { - $tool_name= get_lang('AssignUsersToPlatformAdministrator'); + $tool_name= get_lang('AssignUsersToPlatformAdministrator'); } else if ($user_info['status'] == SESSIONADMIN) { - $tool_name= get_lang('AssignUsersToSessionsAdministrator'); + $tool_name= get_lang('AssignUsersToSessionsAdministrator'); } else { - $tool_name= get_lang('AssignUsersToHumanResourcesManager'); + $tool_name= get_lang('AssignUsersToHumanResourcesManager'); } $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']); } if (!api_is_platform_admin()) { - api_not_allowed(true); + api_not_allowed(true); } function search_users($needle,$type) { diff --git a/main/admin/extra_fields.php b/main/admin/extra_fields.php index 46ce0e5253..89f0e6ac4b 100644 --- a/main/admin/extra_fields.php +++ b/main/admin/extra_fields.php @@ -196,6 +196,8 @@ CREATE TABLE IF NOT EXISTS lp_field_options ( option_display_text varchar(64), option_order int, tms DATETIME NOT NULL default '0000-00-00 00:00:00', + priority VARCHAR(255), + priority_message VARCHAR(255), PRIMARY KEY (id) ); DROP TABLE IF EXISTS lp_field_values; diff --git a/main/admin/group_add.php b/main/admin/group_add.php index 5df37d58e8..dfc91f44be 100644 --- a/main/admin/group_add.php +++ b/main/admin/group_add.php @@ -1,8 +1,8 @@ '; $course_categories = Statistics::get_course_categories(); echo '

'; -//@todo: spaces between elements should be handled in the css, br should be removed if only there for presentation -$report = isset($_GET['report']) ? $_GET['report'] : null; - -switch ($report) { +switch ($_REQUEST['report']) { case 'courses': // total amount of courses foreach ($course_categories as $code => $name) { @@ -88,9 +85,10 @@ switch ($report) { case 'users': // total amount of users Statistics::print_stats( - get_lang('NumberOfUsers'), array( - get_lang('Teachers') => Statistics::count_users(1, null, $_GET['count_invisible_courses']), - get_lang('Students') => Statistics::count_users(5, null, $_GET['count_invisible_courses']) + get_lang('NumberOfUsers'), + array( + 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(); @@ -136,4 +134,5 @@ switch ($report) { Statistics::print_stats(get_lang('CountFriends'), $friends); break; } + Display::display_footer(); diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index 5032bb2f50..2cd7dc6fbe 100644 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -261,12 +261,12 @@ class Category implements GradebookItem } $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); - $sql = 'SELECT * FROM '.$tbl_grade_categories; - $paramcount = 0; + $sql = 'SELECT * FROM '.$tbl_grade_categories; + $paramcount = 0; if (isset($id)) { $id = Database::escape_string($id); - $sql .= ' WHERE id = '.intval($id); - $paramcount++; + $sql.= ' WHERE id = '.intval($id); + $paramcount ++; } if (isset($user_id)) { @@ -395,7 +395,7 @@ class Category implements GradebookItem if (isset($this->name) && isset($this->user_id)) { $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)) { $sql .= ',description'; } @@ -403,7 +403,7 @@ class Category implements GradebookItem $sql .= ',course_code'; } if (isset($this->parent)) { - $sql .= ',parent_id'; + $sql .= ',parent_id'; } if (!empty($this->session_id)) { $sql .= ', session_id'; @@ -416,7 +416,6 @@ class Category implements GradebookItem $sql .= ', certif_min_score '; } - /* $setting = api_get_setting('tool_visible_by_default_at_creation'); $visible = 1; diff --git a/main/gradebook/lib/fe/linkform.class.php b/main/gradebook/lib/fe/linkform.class.php index c9a3558071..6a46e206b0 100644 --- a/main/gradebook/lib/fe/linkform.class.php +++ b/main/gradebook/lib/fe/linkform.class.php @@ -84,7 +84,7 @@ class LinkForm extends FormValidator // The hot potatoe link will be added "inside" the exercise option. if ($linkType == LINK_HOTPOTATOES) { continue; - } + } $link = $this->createLink($linkType, $courseCode); // disable this element if the link works with a dropdownlist // and if there are no links left @@ -110,6 +110,7 @@ class LinkForm extends FormValidator $this->setDefaults(array('select_link' => $this->extra)); } } + /** * @param $link * @param $courseCode @@ -122,4 +123,8 @@ class LinkForm extends FormValidator $link->set_course_code($courseCode); } elseif(!empty($_GET['course_code'])) { $link->set_course_code(Database::escape_string($_GET['course_code'])); -} \ No newline at end of file + } + + return $link; + } +} diff --git a/main/group/group.php b/main/group/group.php index 7820ed5e9e..06c80011fd 100644 --- a/main/group/group.php +++ b/main/group/group.php @@ -58,12 +58,12 @@ Display::display_introduction_section(TOOL_GROUP); /* * Self-registration and un-registration */ - $my_group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : null; - $my_msg = isset($_GET['msg']) ? Security::remove_XSS($_GET['msg']) : 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_id2 = isset($_GET['id2']) ? Security::remove_XSS($_GET['id2']) : null; - $my_get_id = isset($_GET['id']) ? Security::remove_XSS($_GET['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_group = isset($_REQUEST['group']) ? Security::remove_XSS($_REQUEST['group']) : 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_id = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : null; if (isset($_GET['action']) && $is_allowed_in_course) { switch ($_GET['action']) { @@ -80,13 +80,13 @@ if (isset($_GET['action']) && $is_allowed_in_course) { } break; case 'show_msg': - Display :: display_confirmation_message($my_msg); + Display::display_confirmation_message($my_msg); break; case 'warning_message': - Display :: display_warning_message($my_msg); + Display::display_warning_message($my_msg); break; case 'success_message': - Display :: display_confirmation_message($my_msg); + Display::display_confirmation_message($my_msg); break; } } @@ -102,7 +102,7 @@ if (api_is_allowed_to_edit(false, true)) { switch ($_POST['action']) { case 'delete_selected': if (is_array($_POST['group'])) { - GroupManager :: delete_groups($my_group); + GroupManager::delete_groups($my_group); Display :: display_confirmation_message(get_lang('SelectedGroupsDeleted')); } break; @@ -184,7 +184,6 @@ if (api_is_allowed_to_edit(false, true)) { $group_cats = GroupManager::get_categories(api_get_course_id()); echo '
'; - /* List all categories */ if (api_get_setting('allow_group_categories') == 'true') { foreach ($group_cats as $index => $category) { diff --git a/main/group/group_category.php b/main/group/group_category.php index 0f7990c3a7..fe0bbf9c03 100644 --- a/main/group/group_category.php +++ b/main/group/group_category.php @@ -88,7 +88,7 @@ $interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups')); $course_id = api_get_course_int_id(); // Build the form -if (isset ($_GET['id'])) { +if (isset($_GET['id'])) { // Update settings of existing category $action = 'update_settings'; $form = new FormValidator('group_category', 'post', '?id='.$category['id']); @@ -110,18 +110,19 @@ if (api_get_setting('allow_group_categories') == 'true') { $form->addElement('html', '
'); $form->add_textfield('title', get_lang('Title')); -// Action -$possible_values = array (); -for ($i = 1; $i <= 10; $i ++) { - $possible_values[$i] = $i; -} -$possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All'); + // Action + $possible_values = array (); + for ($i = 1; $i <= 10; $i ++) { + $possible_values[$i] = $i; + } + + $possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All'); $group = array( $form->createElement('select', 'groups_per_user', null, $possible_values), $form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartAfterNumber')) ); -$form->addGroup($group, 'limit_group', get_lang('GroupLimit'), ' ', false); -$form->addRule('limit_group', get_lang('MaxGroupsPerUserInvalid'), 'callback', 'check_groups_per_user'); + $form->addGroup($group, 'limit_group', get_lang('GroupLimit'), ' ', false); + $form->addRule('limit_group', get_lang('MaxGroupsPerUserInvalid'), 'callback', 'check_groups_per_user'); // Members per group $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->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members'); -$form->addElement('html', '
'); + $form->addElement('html', '
'); $form->addElement('html', '
'); -// Members per group + // Members per group $form->addElement('textarea', 'description', get_lang('Description'), array ('class' => 'span6', 'rows' => 6)); $form->addElement('html', '
'); $form->addElement('html', '
'); diff --git a/main/group/group_creation.php b/main/group/group_creation.php index 2184efe5f4..c90c2cbdf7 100644 --- a/main/group/group_creation.php +++ b/main/group/group_creation.php @@ -19,7 +19,7 @@ api_protect_course_script(true); /* Create the groups */ -if (isset ($_POST['action'])) { +if (isset($_POST['action'])) { switch ($_POST['action']) { case 'create_groups': $groups = array(); diff --git a/main/inc/ajax/admin.ajax.php b/main/inc/ajax/admin.ajax.php index 84e867b378..fa08af3a28 100644 --- a/main/inc/ajax/admin.ajax.php +++ b/main/inc/ajax/admin.ajax.php @@ -108,6 +108,9 @@ function check_system_version() $number_of_users = Statistics::count_users(); $number_of_active_users = Statistics::count_users(null, null, null, true); + // The number of sessions + $number_of_sessions = Statistics::count_sessions(); + $data = array( 'url' => api_get_path(WEB_PATH), 'campus' => api_get_setting('siteName'), @@ -116,6 +119,7 @@ function check_system_version() 'numberofcourses' => $number_of_courses, 'numberofusers' => $number_of_users, 'numberofactiveusers' => $number_of_active_users, + 'numberofsessions' => $number_of_sessions, //The donotlistcampus setting recovery should be improved to make // it true by default - this does not affect numbers counting 'donotlistcampus' => api_get_setting('donotlistcampus'), diff --git a/main/inc/ajax/course.ajax.php b/main/inc/ajax/course.ajax.php index a9b7ab21b8..a024108c46 100644 --- a/main/inc/ajax/course.ajax.php +++ b/main/inc/ajax/course.ajax.php @@ -10,25 +10,24 @@ $user_id = api_get_user_id(); switch ($action) { case 'add_course_vote': - - $course_id = intval($_REQUEST['course_id']); + $course_id = intval($_REQUEST['course_id']); $star = intval($_REQUEST['star']); if (!api_is_anonymous()) { CourseManager::add_course_vote($user_id, $star, $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'; - $rating = Display::return_rating_system('star_'.$course_id, $ajax_url.'&course_id='.$course_id, $point_info, false); - echo $rating; + $point_info = CourseManager::get_course_ranking($course_id, 0); + $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.'&course_id='.$course_id, $point_info, false); + echo $rating; break; - case 'get_user_courses': + case 'get_user_courses': if (api_is_platform_admin()) { $user_id = intval($_POST['user_id']); $list_course_all_info = CourseManager::get_courses_list_by_user_id($user_id, false); 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']); echo $course_info['title'].'
'; } @@ -37,6 +36,200 @@ switch ($action) { } } 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: echo ''; } diff --git a/main/inc/ajax/events.ajax.php b/main/inc/ajax/events.ajax.php index f5ec86a4a6..ee153087b7 100644 --- a/main/inc/ajax/events.ajax.php +++ b/main/inc/ajax/events.ajax.php @@ -7,7 +7,7 @@ $event_name = isset($_REQUEST['eventName']) ? $_REQUEST['eventName'] : null; api_protect_admin_script(); switch ($action) { - case 'getEventTypes': + case 'getEventTypes': $events = get_all_event_types(); print json_encode($events); break; @@ -15,7 +15,7 @@ switch ($action) { $users = UserManager::get_user_list(); print json_encode($users); break; - case 'get_event_users' : + case 'get_event_users': $users = get_event_users($event_name); print json_encode($users); break; diff --git a/plugin/bbb/config.php b/plugin/bbb/config.php index 2eb503d6ee..4f74dc1c5e 100644 --- a/plugin/bbb/config.php +++ b/plugin/bbb/config.php @@ -3,7 +3,7 @@ /* 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 'lib/bbb.lib.php'; diff --git a/plugin/bbb/lang/english.php b/plugin/bbb/lang/english.php index 9660d35221..9f78ae4ae9 100644 --- a/plugin/bbb/lang/english.php +++ b/plugin/bbb/lang/english.php @@ -52,4 +52,4 @@ $strings['plugin_tool_bbb'] = 'Video'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'There are not recording for the meeting sessions'; $strings['NoRecording'] = 'No recording'; - +$strings['ClickToContinue'] = 'Click to continue'; diff --git a/plugin/bbb/lang/french.php b/plugin/bbb/lang/french.php index 638cafd860..a349ade9b3 100644 --- a/plugin/bbb/lang/french.php +++ b/plugin/bbb/lang/french.php @@ -46,3 +46,4 @@ $strings['plugin_tool_bbb'] = 'Vidéo'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'Aucun enregistrement disponible'; $strings['NoRecording'] = "Pas d'enregistrement"; +$strings['ClickToContinue'] = 'Cliquez pour continuer'; diff --git a/plugin/bbb/lang/spanish.php b/plugin/bbb/lang/spanish.php index f2ac9a27e8..a74d72ffa5 100644 --- a/plugin/bbb/lang/spanish.php +++ b/plugin/bbb/lang/spanish.php @@ -46,3 +46,4 @@ $strings['plugin_tool_bbb'] = 'Video'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'No hay grabaciones de sesiones de videoconferencia'; $strings['NoRecording'] = 'No hay grabación'; +$strings['ClickToContinue'] = 'Hacer click para continuar'; diff --git a/plugin/bbb/lib/bbb.lib.php b/plugin/bbb/lib/bbb.lib.php index 945ae62cf3..59e7269568 100644 --- a/plugin/bbb/lib/bbb.lib.php +++ b/plugin/bbb/lib/bbb.lib.php @@ -1,39 +1,51 @@ 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'); if ($bbb_plugin == true) { @@ -55,15 +67,17 @@ class bbb { $this->plugin_enabled = true; } } + /** * 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 */ - function is_teacher() { + public function is_teacher() + { return api_is_course_admin() || api_is_coach() || api_is_platform_admin(); } - /* + /** * See this file in you BBB to set up default values /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties @@ -94,9 +108,11 @@ class bbb { defaultMeetingCreateJoinDuration=5 * */ - function create_meeting($params) { + public function create_meeting($params) + { $params['c_id'] = api_get_course_int_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(); $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 ($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; $record = isset($params['record']) && $params['record'] ? 'true' : 'false'; $duration = isset($params['duration']) ? intval($params['duration']) : 0; // This setting currently limits the maximum conference duration, - // to avoid llingering sessions on the videoconference server #6261 - $duration = 300; + // to avoid lingering sessions on the videoconference server #6261 + $duration = 300; $bbb_params = array( 'meetingId' => $id, // REQUIRED @@ -137,27 +153,59 @@ class bbb { '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. ); + 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') { - if ($this->debug) error_log("create_meeting result: ".print_r($result,1)); - return $this->join_meeting($meeting_name); + + $status = false; + $meeting = null; + + 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; } } + /** - * Tells whether the given meeting exists and is running + * Tells whether the given meeting exists and is running * (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 * @assert ('') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false */ - function meeting_exists($meeting_name) { + public function meeting_exists($meeting_name) + { if (empty($meeting_name)) { return false; } $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 (empty($meeting_data)) { return false; @@ -174,28 +222,68 @@ class bbb { * @assert ('') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false */ - function join_meeting($meeting_name) { - if (empty($meeting_name)) { return false; } + public function join_meeting($meeting_name, $loop = false) + { + if (empty($meeting_name)) { + return false; + } + $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 "); + return false; } - $meeting_is_running_info = $this->api->isMeetingRunningWithXmlResponseArray($meeting_data['id']); - $meeting_is_running = $meeting_is_running_info['running'] == 'true' ? true : false; + $params = array( + '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( - '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_is_running_info = $this->get_meeting_info($params); - $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( '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 @@ -212,13 +300,15 @@ class bbb { if ($this->debug) error_log("return url :".$url); return $url; } + /** * Get information about the given meeting * @param array ...? * @return mixed Array of information on success, false on error * @assert (array()) === false */ - function get_meeting_info($params) { + public function get_meeting_info($params) + { try { $result = $this->api->getMeetingInfoWithXmlResponseArray($params); if ($result == null) { @@ -236,9 +326,10 @@ class bbb { * Gets all the course meetings saved in the plugin_bbb_meeting table * @return array Array of current open meeting rooms */ - function get_course_meetings() { + public function get_course_meetings() + { $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(); $item = array(); @@ -315,6 +406,7 @@ class bbb { $item['created_at'] = api_convert_and_format_date($meeting_db['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['unpublish_url'] = api_get_self().'?'.api_get_cidreq().'&action=unpublish&id='.$meeting_db['id']; @@ -335,18 +427,23 @@ class bbb { } return $new_meeting_list; } + /** * Function disabled */ - function publish_meeting($id) { + public function publish_meeting($id) + { //return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt); } + /** * Function disabled */ - function unpublish_meeting($id) { + public function unpublish_meeting($id) + { //return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt); } + /** * Closes a meeting (usually when the user click on the close button from * the conferences listing. @@ -354,7 +451,8 @@ class bbb { * @return void * @assert (0) === false */ - function end_meeting($id) { + public function end_meeting($id) + { if (empty($id)) { return false; } $pass = $this->get_user_meeting_password(); $endParams = array( @@ -364,22 +462,26 @@ class bbb { $this->api->endMeetingWithXmlResponseArray($endParams); 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 * @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()) { return $this->get_mod_meeting_password(); } else { return api_get_course_id(); } } + /** * Generated a moderator password for the meeting * @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'; } @@ -388,9 +490,11 @@ class bbb { * @return int The number of users currently connected to the videoconference * @assert () > -1 */ - function get_users_online_in_current_room() { + public function get_users_online_in_current_room() + { $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)) { return 0; } @@ -403,19 +507,21 @@ class bbb { } return 0; } + /** * Deletes a previous recording of a meeting - * @param int intergal ID of the recording + * @param int integral ID of the recording * @return array ? * @assert () === false * @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; } $recordingParams = array( /* - * NOTE: Set the recordId below to a valid id after you have - * created a recorded meeting, and received a real recordID + * NOTE: Set the recordId below to a valid id after you have + * created a recorded meeting, and received a real recordID * back from your BBB server using the * getRecordingsWithXmlResponseArray method. */ @@ -425,6 +531,7 @@ class bbb { ); return $this->api->deleteRecordingsWithXmlResponseArray($recordingParams); } + /** * Creates a link in the links tool from the given videoconference recording * @param int ID of the item in the plugin_bbb_meeting table @@ -434,7 +541,8 @@ class bbb { * @assert (1, null) === 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)) { return false; } @@ -456,16 +564,56 @@ class bbb { } } } + return false; } + /** * Checks if the videoconference server is running. * Function currently disabled (always returns 1) * @return bool True if server is running, false otherwise * @assert () === false */ - function is_server_running() { + public function is_server_running() + { return true; //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 ''; + exit;*/ + } } diff --git a/plugin/bbb/lib/bbb_api.php b/plugin/bbb/lib/bbb_api.php index 630d52d3be..7c67feb301 100644 --- a/plugin/bbb/lib/bbb_api.php +++ b/plugin/bbb/lib/bbb_api.php @@ -164,7 +164,7 @@ class BigBlueButtonBN { */ $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams)); - if($xml) { + if ($xml) { if($xml->meetingID) return array( 'returncode' => $xml->returncode, @@ -247,7 +247,7 @@ class BigBlueButtonBN { ); */ $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams)); - if($xml) { + if ($xml) { return array( 'returncode' => $xml->returncode, 'message' => $xml->message, diff --git a/plugin/bbb/lib/bbb_plugin.class.php b/plugin/bbb/lib/bbb_plugin.class.php index fc4284671c..9d0919ab5f 100644 --- a/plugin/bbb/lib/bbb_plugin.class.php +++ b/plugin/bbb/lib/bbb_plugin.class.php @@ -6,26 +6,35 @@ * main/img/icons/64/plugin_name.png * main/img/icons/64/plugin_name_na.png */ + +/** + * Class BBBPlugin + */ class BBBPlugin extends Plugin { - public $is_course_plugin = true; + public $isCoursePlugin = true; //When creating a new course this settings are added to the course public $course_settings = array( -// array('name' => 'big_blue_button_welcome_message', 'type' => 'text'), - array('name' => 'big_blue_button_record_and_store', 'type' => 'checkbox') + array( + 'name' => 'big_blue_button_record_and_store', + 'type' => 'checkbox' + ) ); - static function create() { + static function create() + { static $result = null; return $result ? $result : $result = new self(); } - protected function __construct() { - parent::__construct('2.0', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text')); + protected function __construct() + { + 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'); $sql = "CREATE TABLE IF NOT EXISTS $table ( id INT unsigned NOT NULL auto_increment PRIMARY KEY, @@ -38,14 +47,16 @@ class BBBPlugin extends Plugin created_at VARCHAR(255) NOT NULL, closed_at VARCHAR(255) NOT NULL, 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); //Installing course settings $this->install_course_fields_in_all_courses(); } - function uninstall() { + public function uninstall() + { $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS); $t_tool = Database::get_course_table(TABLE_TOOL_LIST); @@ -70,13 +81,13 @@ class BBBPlugin extends Plugin Database::query($sql); //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); $sql = "DROP TABLE IF EXISTS plugin_bbb_meeting"; Database::query($sql); //Deleting course settings - $this->uninstall_course_fields_in_all_courses(); + $this->uninstall_course_fields_in_all_courses($this->course_settings); } } diff --git a/plugin/bbb/listing.php b/plugin/bbb/listing.php index 265d06786e..2b152a951f 100644 --- a/plugin/bbb/listing.php +++ b/plugin/bbb/listing.php @@ -32,7 +32,14 @@ if ($teacher) { $title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $course_info['name']); $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)) { $message = Display::return_message(get_lang('VideoConferenceAddedToTheCalendar'), 'success'); } else { @@ -57,7 +64,28 @@ if ($teacher) { break; case 'end': $bbb->end_meeting($_GET['id']); - $message = Display::return_message(get_lang('MeetingClosed').'
'.get_lang('MeetingClosedComment'), 'success', false); + $message = Display::return_message( + get_lang('MeetingClosed') . '
' . 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; case 'publish': //$result = $bbb->publish_meeting($_GET['id']); @@ -76,7 +104,7 @@ if (!empty($meetings)) { } $users_online = $bbb->get_users_online_in_current_room(); $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; if ($meeting_exists || $teacher) { $show_join_button = true; diff --git a/plugin/bbb/plugin.php b/plugin/bbb/plugin.php index 4c38a011e1..a9ad573475 100644 --- a/plugin/bbb/plugin.php +++ b/plugin/bbb/plugin.php @@ -1,4 +1,5 @@ get_info(); \ No newline at end of file + +$plugin_info = BBBPlugin::create()->get_info(); diff --git a/plugin/bbb/start.php b/plugin/bbb/start.php index 96afc2949e..e51f9dde2d 100644 --- a/plugin/bbb/start.php +++ b/plugin/bbb/start.php @@ -1,16 +1,23 @@ plugin_enabled) { @@ -18,33 +25,52 @@ if ($bbb->plugin_enabled) { 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['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'])) { $url = $bbb->join_meeting($meeting_params['meeting_name']); if ($url) { - header('location: '.$url); - exit; + $bbb->redirectToBBB($url); } else { $url = $bbb->create_meeting($meeting_params); - header('location: '.$url); - exit; + $bbb->redirectToBBB($url); } } else { if ($bbb->is_teacher()) { $url = $bbb->create_meeting($meeting_params); - header('location: '.$url); - exit; + $bbb->redirectToBBB($url); } else { - $url = 'listing.php'; - header('location: '.$url); - exit; + $url = 'listing.php?'.api_get_cidreq(); + $bbb->redirectToBBB($url); } } } else { - $url = 'listing.php'; - header('location: '.$url); + $url = 'listing.php?'.api_get_cidreq(); + header('Location: ' . $url); exit; } } else { diff --git a/plugin/before_login/plugin.php b/plugin/before_login/plugin.php index 35b486b2c6..290584e74e 100644 --- a/plugin/before_login/plugin.php +++ b/plugin/before_login/plugin.php @@ -8,7 +8,7 @@ */ /* Plugin config */ -return; + // The plugin title. $plugin_info['title'] = 'Show HTML before login'; // The comments that go with the plugin.