diff --git a/main/admin/inactive_user_list.php b/main/admin/inactive_user_list.php index e46546aea1..f22590f9aa 100644 --- a/main/admin/inactive_user_list.php +++ b/main/admin/inactive_user_list.php @@ -13,7 +13,7 @@ $language_file = array ('registration','admin'); $cidReset = true; require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'security.lib.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; @@ -42,4 +42,4 @@ while($row = Database::fetch_array($result)) { } /* FOOTER */ -Display :: display_footer(); \ No newline at end of file +Display :: display_footer(); diff --git a/main/admin/languages.php b/main/admin/languages.php index ec46599eb3..6291a60f22 100644 --- a/main/admin/languages.php +++ b/main/admin/languages.php @@ -23,7 +23,7 @@ $cidReset = true; // include global script require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php'; require_once 'sub_language.class.php'; $this_section = SECTION_PLATFORM_ADMIN; diff --git a/main/admin/ldap_users_list.php b/main/admin/ldap_users_list.php old mode 100755 new mode 100644 index 17ba82c893..5e1bb38ad0 --- a/main/admin/ldap_users_list.php +++ b/main/admin/ldap_users_list.php @@ -12,7 +12,7 @@ $language_file[] = 'registration'; $language_file[] = 'admin'; $cidReset = true; require('../inc/global.inc.php'); -require_once(api_get_path(LIBRARY_PATH).'sortabletable.class.php'); +require_once(api_get_path(LIBRARY_PATH).'sortable_table.class.php'); require_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); require_once(api_get_path(LIBRARY_PATH).'security.lib.php'); require('../auth/ldap/authldap.php'); diff --git a/main/admin/session_list.php b/main/admin/session_list.php index e5a0c54a16..ec2d366c30 100644 --- a/main/admin/session_list.php +++ b/main/admin/session_list.php @@ -37,9 +37,8 @@ if (isset($_REQUEST['keyword'])) { $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=name&searchString='.Security::remove_XSS($_REQUEST['keyword']).'&searchOper=bw'; } - //The order is important you need to check the the $column variable in the model.ajax.php file -$columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('SessionCategoryName'), +$columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('NumberOfUsers'), get_lang('SessionCategoryName'), get_lang('StartDate'), get_lang('EndDate'), get_lang('Coach'), get_lang('Status'), get_lang('Visibility'), get_lang('Actions')); //$activeurl = '?sidx=session_active'; @@ -47,6 +46,7 @@ $columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang( $column_model = array( array('name'=>'name', 'index'=>'name', 'width'=>'120', 'align'=>'left', 'search' => 'true'), array('name'=>'nbr_courses', 'index'=>'nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'), + array('name'=>'nbr_users', 'index'=>'nbr_users', 'width'=>'30', 'align'=>'left', 'search' => 'true'), array('name'=>'category_name', 'index'=>'category_name', 'width'=>'70', 'align'=>'left', 'search' => 'true'), array('name'=>'date_start', 'index'=>'date_start', 'width'=>'40', 'align'=>'left', 'search' => 'true'), array('name'=>'date_end', 'index'=>'date_end', 'width'=>'40', 'align'=>'left', 'search' => 'true'), diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index e23e7557b0..d31cd6fadc 100644 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -591,7 +591,7 @@ function handle_search() { echo ''; if ($search_enabled == 'true') { - require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; + require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php'; $xapian_path = api_get_path(SYS_PATH).'searchdb'; /* @@ -1043,9 +1043,9 @@ function generate_settings_form($settings, $settings_by_access_list) { $default_values = array(); $count_settings = count($settings); - foreach ($settings as $row) { + foreach ($settings as $row) { if (in_array($row['variable'], array_keys($settings_to_avoid))) { continue; } - + $anchor_name = $row['variable'].(!empty($row['subkey']) ? '_'.$row['subkey'] : ''); $form->addElement('html',"\n\n"); @@ -1059,12 +1059,17 @@ function generate_settings_form($settings, $settings_by_access_list) { $i++; if ( $_configuration['multiple_access_urls']) { - if (api_is_global_platform_admin()) { - if ($row['access_url_changeable'] == '1') { - $form->addElement('html', '
'.Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')).'
'); - } else { - $form->addElement('html', '
'.Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')).'
'); + if (api_is_global_platform_admin()) { + if ($row['access_url_locked'] == 0) { + if ($row['access_url_changeable'] == '1') { + $form->addElement('html', '
'. + Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')).'
'); + } else { + $form->addElement('html', '
'. + Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')).'
'); + } } + } } @@ -1096,7 +1101,7 @@ function generate_settings_form($settings, $settings_by_access_list) { switch ($row['type']) { case 'textfield': if (in_array($row['variable'], $convert_byte_to_mega_list)) { - $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment']), get_lang('MB')), array('maxlength' => '8')); + $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment']), get_lang('MB')), array('class' => 'span1', 'maxlength' => '8')); $form->applyFilter($row['variable'], 'html_filter'); $default_values[$row['variable']] = round($row['selected_value']/1024/1024, 1); } elseif ($row['variable'] == 'account_valid_duration') { @@ -1130,7 +1135,8 @@ function generate_settings_form($settings, $settings_by_access_list) { } $form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $valid_encodings); $default_values[$row['variable']] = $current_system_encoding; - } else { + } else { + $hideme['class'] = 'span4'; $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $hideme); $form->applyFilter($row['variable'],'html_filter'); $default_values[$row['variable']] = $row['selected_value']; @@ -1234,131 +1240,8 @@ function generate_settings_form($settings, $settings_by_access_list) { $renderer->setElementTemplate(' {label}
{element} %= ', 'gradebook_display['.$row['variable'].'][text]'); $renderer->setElementTemplate(' {element}

', 'gradebook_display['.$row['variable'].'][score]'); break; - case 'custom': - /*$values = api_get_settings_options($row['variable']); - - //$renderer = & $form->defaultRenderer(); - //$renderer->setElementTemplate('{label} - {element}{label_2}'); - - $numbers = array(); - for($j=1;$j<=20;$j++) { - $numbers[$j] = $j; - } - - if (!empty($values)) { - foreach($values as $option) { - $group = array(); - $id = $option['id']; - $option_id = $row['variable']."[$id]"; - $group[] = $form->createElement('text', $option_id.'[display_text]', array(get_lang($row['title']), get_lang($row['comment'])),'class="begin_model"'); - - $default_values[$option_id.'[display_text]'] = $option['display_text']; - $parts = api_grading_model_functions($option['value'], 'to_array'); - $denominator = $parts['denominator']; - $j = 1; - foreach($parts['items'] as $item) { - $letter = $item['letter']; - $value = $item['value']; - $group[] =$form->createElement('static','
'); - $class = 'number'; - if ($j == 1) { - $class = 'first_number'; - } - $group[] = $form->createElement('select', $option_id.'[items]['.$j.']', array('dd'), $numbers, array('class'=>$class)); - $sum = ' '; - if ($j != count($parts['items'])) { - $sum = ' + '; - } - //$group[] =$form->createElement('static',' * '.$letter.$sum); - - $default_values[$option_id.'[items]['.$j.']'] = $value; - $j++; - } - - $group[] = $form->createElement('select', $option_id.'[denominator]', array('/'), $numbers,'class="denominator"'); - $group[] = $form->createElement('button', "delete", get_lang('Delete'), array('type'=>'button', 'class' => 'btn btn-danger','id'=>$id, 'onclick'=>"delete_grading_model('$id');")); - - $default_values[$option_id.'[denominator]'] = $denominator; - $form->addGroup($group, '', get_lang($row['title']), ' '); - } - } - - //New Grading Model form - $group = array(); - - $group[] = $form->createElement('text', 'new_model', array(get_lang('AddNewModel'))); - $group[] = $form->createElement('select', 'number_evaluations', array(''), $numbers,''); - - $form->addGroup($group, '', get_lang('AddNewModel'), "  ".get_lang('NumberOfSubEvaluations')." "); - - $form->addElement('style_submit_button', null, get_lang('Add'), 'class="add"'); - */ - - break; - /* - * Used to display custom values for the gradebook score display - */ - /* this configuration is moved now inside gradebook tool - case 'gradebook_score_display_custom': - if(api_get_setting('gradebook_score_display_custom', 'my_display_custom') == 'false') { - $form->addElement('static', null, null, get_lang('GradebookActivateScoreDisplayCustom')); - } else { - // Get score displays. - require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php'; - $scoredisplay = ScoreDisplay::instance(); - $customdisplays = $scoredisplay->get_custom_score_display_settings(); - $nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1'; - $form->addElement('hidden', 'gradebook_score_display_custom_values_maxvalue', '100'); - $form->addElement('hidden', 'gradebook_score_display_custom_values_minvalue', '0'); - $form->addElement('static', null, null, get_lang('ScoreInfo')); - $scorenull[] = $form->CreateElement('static', null, null, get_lang('Between')); - $form->setDefaults(array ( - 'beginscore' => '0' - )); - $scorenull[] = $form->CreateElement('text', 'beginscore', null, array ( - 'size' => 5, - 'maxlength' => 5, - 'disabled' => 'disabled' - )); - $scorenull[] = $form->CreateElement('static', null, null, ' %'); - $form->addGroup($scorenull, '', '', ' '); - for ($counter= 1; $counter <= 20; $counter++) { - $renderer = $form->defaultRenderer(); - $elementTemplateTwoLabel = - '
-

* {label} -

{error}
'.get_lang('And').'          {element} % ='; - - $elementTemplateTwoLabel2 = - '{error}
 {element} - '.get_lang('Delete').' - '.get_lang('Add').' -

'; - - $scorebetw= array (); - $form->addElement('text', 'gradebook_score_display_custom_values_endscore[' . $counter . ']', null, array ( - 'size' => 5, - 'maxlength' => 5, - 'id' => 'txta-'.$counter - )); - $form->addElement('text', 'gradebook_score_display_custom_values_displaytext[' . $counter . ']', null,array ( - 'size' => 40, - 'maxlength' => 40, - 'id' => 'txtb-'.$counter - )); - $renderer->setElementTemplate($elementTemplateTwoLabel,'gradebook_score_display_custom_values_endscore[' . $counter . ']'); - $renderer->setElementTemplate($elementTemplateTwoLabel2,'gradebook_score_display_custom_values_displaytext[' . $counter . ']'); - $form->addRule('gradebook_score_display_custom_values_endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric'); - $form->addRule(array('gradebook_score_display_custom_values_endscore[' . $counter . ']', 'gradebook_score_display_custom_values_maxvalue'), get_lang('Over100'), 'compare', '<='); - $form->addRule(array('gradebook_score_display_custom_values_endscore[' . $counter . ']', 'gradebook_score_display_custom_values_minvalue'), get_lang('UnderMin'), 'compare', '>'); - if ($customdisplays[$counter - 1]) { - $default_values['gradebook_score_display_custom_values_endscore['.$counter.']'] = $customdisplays[$counter - 1]['score']; - $default_values['gradebook_score_display_custom_values_displaytext['.$counter.']'] = $customdisplays[$counter - 1]['display']; - } - } - } - break; - */ + case 'custom': + break; } if ($row['variable'] == 'pdf_export_watermark_enable') { @@ -1392,13 +1275,13 @@ function generate_settings_form($settings, $settings_by_access_list) { } /** - * Searchs a platform setting + * Searchs a platform setting in all categories except from the Plugins category * @param string $search * @return array */ function search_setting($search) { $table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT); - $sql = "SELECT * FROM $table_settings_current GROUP BY variable ORDER BY id ASC "; + $sql = "SELECT * FROM $table_settings_current WHERE category <> 'Plugins' GROUP BY variable ORDER BY id ASC "; $result = Database::store_result(Database::query($sql), 'ASSOC'); $settings = array(); diff --git a/main/admin/settings.php b/main/admin/settings.php index 622dc01828..5ca05929fc 100644 --- a/main/admin/settings.php +++ b/main/admin/settings.php @@ -89,8 +89,8 @@ $settings = null; if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', 'stylesheets', 'Search'))) { $my_category = Database::escape_string($_GET['category']); - if ($_configuration['access_url'] == 1) { - $settings = api_get_settings($my_category, 'group', $_configuration['access_url']); + if ($_configuration['access_url'] == 1) { + $settings = api_get_settings($my_category, 'group', $_configuration['access_url']); } else { $url_info = api_get_access_url($_configuration['access_url']); if ($url_info['active'] == 1) { @@ -107,6 +107,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' $row['subkey'] = 0; if (empty($row['category'])) $row['category'] = 0; + // One more validation if is changeable. if ($row['access_url_changeable'] == 1) $settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ] = $row; diff --git a/main/admin/specific_fields.php b/main/admin/specific_fields.php index 757efc9bba..4f542a24f6 100644 --- a/main/admin/specific_fields.php +++ b/main/admin/specific_fields.php @@ -22,7 +22,7 @@ $interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang(' $libpath = api_get_path(LIBRARY_PATH); -require_once $libpath.'sortabletable.class.php'; +require_once $libpath.'sortable_table.class.php'; include_once $libpath.'specific_fields_manager.lib.php'; // Create an add-field box @@ -74,4 +74,4 @@ if (!empty($extra_fields)) { } // Displaying the footer -Display::display_footer(); \ No newline at end of file +Display::display_footer(); diff --git a/main/admin/sub_language.php b/main/admin/sub_language.php index 961ec88271..fd26362d9b 100644 --- a/main/admin/sub_language.php +++ b/main/admin/sub_language.php @@ -5,7 +5,7 @@ $language_file = 'admin'; $cidReset = true; require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php'; require_once 'sub_language.class.php'; require_once api_get_path(LIBRARY_PATH).'array.lib.php'; $this_section=SECTION_PLATFORM_ADMIN; @@ -294,4 +294,4 @@ $table->set_header(5, get_lang('Edit'),false); $table->display(); /* FOOTER */ -Display :: display_footer(); \ No newline at end of file +Display :: display_footer(); diff --git a/main/course_info/infocours.php b/main/course_info/infocours.php index d9e5b901d6..fecb35b889 100644 --- a/main/course_info/infocours.php +++ b/main/course_info/infocours.php @@ -35,15 +35,18 @@ api_block_anonymous_users(); define('MODULE_HELP_NAME', 'Settings'); define('COURSE_CHANGE_PROPERTIES', 'COURSE_CHANGE_PROPERTIES'); -$TABLECOURSE = Database :: get_main_table(TABLE_MAIN_COURSE); -$TABLEFACULTY = Database :: get_main_table(TABLE_MAIN_CATEGORY); -$TABLELANGUAGES = Database :: get_main_table(TABLE_MAIN_LANGUAGE); $currentCourseRepository = $_course['path']; $is_allowedToEdit = $is_courseAdmin || $is_platformAdmin; $course_code = $_course['sysCode']; $course_access_settings = CourseManager :: get_access_settings($course_code); +$video_conference_enabled = false; +if (api_get_setting('bbb_plugin') == 'true') { + $video_conference_enabled = true; +} + + //LOGIC FUNCTIONS function is_settings_editable() { return $GLOBALS['course_info_is_editable']; @@ -245,27 +248,6 @@ $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class= $form->addElement('html', '
'); -// Gradebook SETTINGS -//$form->addElement('html', '

'.Display::return_icon('gradebook.png', Security::remove_XSS(get_lang('Gradebook')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('Gradebook')).'

'); - -/*$group = array(); -$models = api_get_settings_options('grading_model'); -if (!empty($models )) { - foreach ($models as $option) { - $grading_parsed = api_grading_model_functions($option['value'], 'decorate'); - $element = $form->createElement('radio', 'course_grading_model', '', $option['display_text'].': '.$grading_parsed, $option['id']); - $group[] = $element; - } -} - -$element = $form->createElement('radio', 'course_grading_model', '', get_lang('None'), 0); -$group[] = $element; - -$form->addGroup($group, '', array(get_lang('GradingModelTitle')), '', 'li', false); - -$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"'); -$form->addElement('html', '
');*/ - // USER RIGHTS $form->addElement('html', '

'.Display::return_icon('user.png', Security::remove_XSS(get_lang('UserRights')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('UserRights')).'

'); @@ -290,7 +272,6 @@ $group[]=$form->createElement('radio', 'allow_user_view_user_list', null, get_la $form->addGroup($group, '', array(get_lang("AllowUserViewUserList")), ''); $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"'); - $form->addElement('html', '
'); @@ -355,11 +336,44 @@ $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class= $form->addElement('html', ''); +// BBB SETTINGS + +if ($video_conference_enabled) { + $form->addElement('html', '

'.Display::return_icon('visio.png', Security::remove_XSS(get_lang('VideoConferenceSettings')),'', ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('VideoConferenceSettings')).'

'); + +// $form->add_textfield('big_blue_button_welcome_message', get_lang('big_blue_button_welcome_message'), false, array('class' => 'span5')); + +/* $form->add_textfield('big_blue_button_meeting_name', get_lang('big_blue_button_meeting_name'), false, array('class' => 'span5')); + + + $form->add_textfield('big_blue_button_attendee_password', get_lang('big_blue_button_attendee_password'), false, array('class' => 'span5')); + $form->add_textfield('big_blue_button_moderator_password', get_lang('big_blue_button_moderator_password'), false, array('class' => 'span5')); + + + + $form->addElement('checkbox', 'big_blue_button_open_new_window', array(null, null, get_lang('big_blue_button_open_new_window')), null); + + $form->addElement('checkbox', 'big_blue_button_student_must_wait_until_moderator', array(null, null, get_lang('big_blue_button_student_must_wait_until_moderator')), null); + + $form->addElement('datepicker', 'big_blue_button_join_start_date', array(get_lang('big_blue_button_join_start_date')), null); + $form->addElement('datepicker', 'big_blue_button_join_end_date', array(get_lang('big_blue_button_join_end_date')), null);*/ + + $form->add_textfield('big_blue_button_max_students_allowed', get_lang('big_blue_button_max_students_allowed'), false, array('class' => 'span5')); + $form->addElement('checkbox', 'big_blue_button_record_and_store', array(null, null, get_lang('big_blue_button_record_and_store')), null); + + $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"'); + $form->addElement('html', '
'); +} + + + + // Get all the course information $all_course_information = CourseManager::get_course_information($_course['sysCode']); // Set the default values of the form +$values = array(); $values['title'] = $_course['name']; //$values['visual_code'] = $_course['official_code']; @@ -376,8 +390,6 @@ $values['course_registration_password'] = $all_course_information['registration_ $values['legal'] = $all_course_information['legal']; $values['activate_legal'] = $all_course_information['activate_legal']; - - // Get send_mail_setting (auth)from table $values['email_alert_to_teacher_on_new_user_in_course']= api_get_course_setting('email_alert_to_teacher_on_new_user_in_course'); // Get send_mail_setting (work)from table @@ -405,25 +417,45 @@ $values['display_info_advance_inside_homecourse'] = api_get_course_setting('di $values['email_alert_students_on_new_homework'] = api_get_course_setting('email_alert_students_on_new_homework'); $values['enable_lp_auto_launch'] = api_get_course_setting('enable_lp_auto_launch'); - $values['pdf_export_watermark_text'] = api_get_course_setting('pdf_export_watermark_text'); -//$values['course_grading_model'] = api_get_course_setting('course_grading_model'); - +if ($video_conference_enabled) { + + $values['big_blue_button_welcome_message'] = api_get_course_setting('big_blue_button_welcome_message'); + $values['big_blue_button_max_students_allowed'] = api_get_course_setting('big_blue_button_max_students_allowed'); + + + /*$values['big_blue_button_meeting_name'] = api_get_course_setting('big_blue_button_meeting_name'); + + $values['big_blue_button_attendee_password'] = api_get_course_setting('big_blue_button_attendee_password'); + $values['big_blue_button_moderator_password'] = api_get_course_setting('big_blue_button_moderator_password'); + + $values['big_blue_button_open_new_window'] = api_get_course_setting('big_blue_button_open_new_window'); + $values['big_blue_button_student_must_wait_until_moderator'] = api_get_course_setting('big_blue_button_student_must_wait_until_moderator'); + + $start_date = api_get_course_setting('big_blue_button_join_start_date'); + if (empty($start_date)) { + $start_date = date('Y-m-d 12:00:00'); + } + + $values['big_blue_button_join_start_date'] = $start_date; + + $end_date = api_get_course_setting('big_blue_button_join_end_date'); + if (empty($end_date)) { + $end_date = date('Y-m-d 18:00:00'); + } + + $values['big_blue_button_join_end_date'] = $end_date; + */ + $values['big_blue_button_record_and_store'] = api_get_course_setting('big_blue_button_record_and_store'); +} $form->setDefaults($values); // Validate form -if ($form->validate() && is_settings_editable()) { - $update_values = $form->exportValues(); - -/* - // update course picture - $picture = $_FILES['picture']; - if (!empty($picture['name'])) { - $picture_uri = CourseManager::update_course_picture($course_code, $picture['name'], $picture['tmp_name']); - }*/ - +if ($form->validate() && is_settings_editable()) { + $update_values = $form->exportValues(); + $pdf_export_watermark_path = $_FILES['pdf_export_watermark_path']; if (!empty($pdf_export_watermark_path['name'])) { @@ -434,13 +466,11 @@ if ($form->validate() && is_settings_editable()) { //Variables that will be saved in the TABLE_MAIN_COURSE table $update_in_course_table = array('title', 'course_language','category_code','department_name', 'department_url','visibility', 'subscribe', 'unsubscribe','tutor_name','course_registration_password', 'legal', 'activate_legal'); - + foreach ($update_values as $index =>$value) { $update_values[$index] = Database::escape_string($value); - } - unset($value); - //visual_code = '".$update_values['visual_code']."', - //tutor_name = '".$update_values['tutor_name']."', + } + unset($value); $table_course = Database :: get_main_table(TABLE_MAIN_COURSE); $sql = "UPDATE $table_course SET title = '".$update_values['title']."', @@ -456,11 +486,31 @@ if ($form->validate() && is_settings_editable()) { registration_code = '".$update_values['course_registration_password']."' WHERE code = '".$course_code."'"; Database::query($sql); - + + if ($video_conference_enabled) { + /* + if (isset($update_values['big_blue_button_open_new_window']) && $update_values['big_blue_button_open_new_window']) { + $update_values['big_blue_button_open_new_window'] = 1; + } else { + $update_values['big_blue_button_open_new_window'] = 0; + } + if (isset($update_values['big_blue_button_student_must_wait_until_moderator']) && $update_values['big_blue_button_student_must_wait_until_moderator']) { + $update_values['big_blue_button_student_must_wait_until_moderator'] = 1; + } else { + $update_values['big_blue_button_student_must_wait_until_moderator'] = 0; + } + */ + if (isset($update_values['big_blue_button_record_and_store']) && $update_values['big_blue_button_record_and_store']) { + $update_values['big_blue_button_record_and_store'] = 1; + } else { + $update_values['big_blue_button_record_and_store'] = 0; + } + } + // Update course_settings table - this assumes those records exist, otherwise triggers an error $table_course_setting = Database::get_course_table(TABLE_COURSE_SETTING); - foreach($update_values as $key =>$value) { + foreach ($update_values as $key =>$value) { //We do not update variables that were already saved in the TABLE_MAIN_COURSE table if (!in_array($key, $update_in_course_table)) { Database::update($table_course_setting, array('value' => $update_values[$key]), array('variable = ? AND c_id = ?' => array($key, api_get_course_int_id()), true)); @@ -488,7 +538,7 @@ echo ''; diff --git a/main/coursecopy/classes/Course.class.php b/main/coursecopy/classes/Course.class.php index d628fb8659..45d098dbb3 100644 --- a/main/coursecopy/classes/Course.class.php +++ b/main/coursecopy/classes/Course.class.php @@ -320,4 +320,26 @@ class Course } $this->encoding = api_get_system_encoding(); } + + /** + * Serialize the course with the best serializer available + */ + public static function serialize($course) { + if (extension_loaded('igbinary')) { + return igbinary_serialize($course); + } else { + return serialize($course); + } + } + + /** + * Unserialize the course with the best serializer available + */ + public static function unserialize($course) { + if (extension_loaded('igbinary')) { + return igbinary_unserialize($course); + } else { + return unserialize($course); + } + } } \ No newline at end of file diff --git a/main/coursecopy/classes/CourseSelectForm.class.php b/main/coursecopy/classes/CourseSelectForm.class.php index 362506b5b5..aedc53b18e 100644 --- a/main/coursecopy/classes/CourseSelectForm.class.php +++ b/main/coursecopy/classes/CourseSelectForm.class.php @@ -153,7 +153,7 @@ class CourseSelectForm $course->resources['document']= null; } - echo ''; + echo ''; if (is_array($hidden_fields)) { foreach ($hidden_fields as $key => $value) { @@ -218,7 +218,7 @@ class CourseSelectForm * in the form given by display_form(...) */ function get_posted_course($from='', $session_id = 0, $course_code = '') { - $course = unserialize(base64_decode($_POST['course'])); + $course = Course::unserialize(base64_decode($_POST['course'])); //Create the resource DOCUMENT objects //Loading the results from the checkboxes of the javascript @@ -432,7 +432,7 @@ class CourseSelectForm // this is a known issue of serialize $course->resources['document']= null; } - echo ''; + echo ''; if (is_array($hidden_fields)) { foreach ($hidden_fields as $key => $value) { echo "\n"; diff --git a/main/exercice/fill_blanks.class.php b/main/exercice/fill_blanks.class.php index 1dbcae22b0..49720dfc0c 100644 --- a/main/exercice/fill_blanks.class.php +++ b/main/exercice/fill_blanks.class.php @@ -201,7 +201,7 @@ class FillBlanks extends Question $objAnswer->save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { parent::return_header($feedback_type, $counter); $header = ' diff --git a/main/exercice/freeanswer.class.php b/main/exercice/freeanswer.class.php index 5b83cf3ef8..210cd7792b 100644 --- a/main/exercice/freeanswer.class.php +++ b/main/exercice/freeanswer.class.php @@ -58,7 +58,7 @@ class FreeAnswer extends Question { $this->save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { parent::return_header($feedback_type, $counter); $header = '
diff --git a/main/exercice/matching.class.php b/main/exercice/matching.class.php index bb46da4215..65ff50ff62 100644 --- a/main/exercice/matching.class.php +++ b/main/exercice/matching.class.php @@ -244,7 +244,7 @@ class Matching extends Question { $this->save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { parent::return_header($feedback_type, $counter); echo '
'; echo ' diff --git a/main/exercice/multiple_answer.class.php b/main/exercice/multiple_answer.class.php index 2d9de35172..7bba077b47 100644 --- a/main/exercice/multiple_answer.class.php +++ b/main/exercice/multiple_answer.class.php @@ -213,7 +213,7 @@ class MultipleAnswer extends Question { $this->save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { parent::return_header($feedback_type, $counter); $header = '
diff --git a/main/exercice/multiple_answer_combination.class.php b/main/exercice/multiple_answer_combination.class.php index 64880d04e0..baaed773f1 100644 --- a/main/exercice/multiple_answer_combination.class.php +++ b/main/exercice/multiple_answer_combination.class.php @@ -218,7 +218,7 @@ class MultipleAnswerCombination extends Question { $this -> save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { parent::return_header($feedback_type, $counter); $header = '
diff --git a/main/exercice/multiple_answer_true_false.class.php b/main/exercice/multiple_answer_true_false.class.php index 53b77e10c9..feffa2a7f3 100644 --- a/main/exercice/multiple_answer_true_false.class.php +++ b/main/exercice/multiple_answer_true_false.class.php @@ -283,7 +283,7 @@ class MultipleAnswerTrueFalse extends Question { $this -> save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { $header = ""; if ($in_echo == 1) { parent::return_header($feedback_type, $counter, $in_echo); diff --git a/main/exercice/oral_expression.class.php b/main/exercice/oral_expression.class.php index ca73fa2fe0..ac64776d3c 100644 --- a/main/exercice/oral_expression.class.php +++ b/main/exercice/oral_expression.class.php @@ -56,7 +56,7 @@ class OralExpression extends Question { $this->save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { parent::return_header($feedback_type, $counter); $header = '
diff --git a/main/exercice/unique_answer.class.php b/main/exercice/unique_answer.class.php index d50f57dc1c..d7c7af5331 100644 --- a/main/exercice/unique_answer.class.php +++ b/main/exercice/unique_answer.class.php @@ -356,7 +356,7 @@ class UniqueAnswer extends Question { $this -> save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { parent::return_header($feedback_type, $counter); $header = '
diff --git a/main/exercice/unique_answer_no_option.class.php b/main/exercice/unique_answer_no_option.class.php index f1770af7c9..35d7d4a6cc 100644 --- a/main/exercice/unique_answer_no_option.class.php +++ b/main/exercice/unique_answer_no_option.class.php @@ -406,7 +406,7 @@ class UniqueAnswerNoOption extends Question { $this -> save(); } - function return_header($feedback_type, $counter = null) { + function return_header($feedback_type = null, $counter = null) { parent::return_header($feedback_type, $counter); $header = '
diff --git a/main/gradebook/gradebook_showlog_eval.php b/main/gradebook/gradebook_showlog_eval.php index 5a61fafab0..f0bd53698d 100644 --- a/main/gradebook/gradebook_showlog_eval.php +++ b/main/gradebook/gradebook_showlog_eval.php @@ -10,7 +10,7 @@ $language_file = 'gradebook'; //$cidReset = true; require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php'; require_once 'lib/be.inc.php'; require_once 'lib/gradebook_functions.inc.php'; require_once 'lib/fe/evalform.class.php'; diff --git a/main/gradebook/gradebook_showlog_link.php b/main/gradebook/gradebook_showlog_link.php index cc266a5af9..621ac4f256 100644 --- a/main/gradebook/gradebook_showlog_link.php +++ b/main/gradebook/gradebook_showlog_link.php @@ -10,7 +10,7 @@ $language_file = 'gradebook'; //$cidReset = true; require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php'; require_once 'lib/be.inc.php'; require_once 'lib/gradebook_functions.inc.php'; require_once 'lib/fe/evalform.class.php'; diff --git a/main/gradebook/lib/gradebook_functions.inc.php b/main/gradebook/lib/gradebook_functions.inc.php index 9467b95868..5b92ddeb27 100644 --- a/main/gradebook/lib/gradebook_functions.inc.php +++ b/main/gradebook/lib/gradebook_functions.inc.php @@ -205,14 +205,12 @@ function build_edit_icons_cat($cat, $selectcat) { $visibility_icon= ($cat->is_visible() == 0) ? 'invisible' : 'visible'; $visibility_command= ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible'; - if (empty($grade_model_id) || $grade_model_id == -1) { - $modify_icons= ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).''; - } + $modify_icons .= ''.Display::return_icon('view_more_stats.gif', get_lang('Show'),'',ICON_SIZE_SMALL).''; - if (!empty($grade_model_id) && $grade_model_id != -1) { - $modify_icons= ''.Display::return_icon('view_more_stats.gif', get_lang('Show'),'',ICON_SIZE_SMALL).''; + if (empty($grade_model_id) || $grade_model_id == -1) { + $modify_icons .= ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).''; } - + $modify_icons .= ' '.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).''; //no move ability for root categories diff --git a/main/img/icons/22/visio.png b/main/img/icons/22/visio.png new file mode 100644 index 0000000000..83a17a88ca Binary files /dev/null and b/main/img/icons/22/visio.png differ diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 3eb1766214..e984b6b0d2 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -195,7 +195,7 @@ switch ($action) { break; case 'get_sessions': - $columns = array('name', 'nbr_courses','category_name', 'date_start','date_end', 'coach_name', 'session_active', 'visibility'); + $columns = array('name', 'nbr_courses', 'nbr_users', 'category_name', 'date_start','date_end', 'coach_name', 'session_active', 'visibility'); $result = SessionManager::get_sessions_admin(array('where'=> $where_condition, 'order'=>"$sidx $sord", 'limit'=> "$start , $limit")); break; case 'get_timelines': diff --git a/main/inc/conf/add_course.conf.dist.php b/main/inc/conf/add_course.conf.dist.php index 0adce1f5b2..c0ae800fe3 100644 --- a/main/inc/conf/add_course.conf.dist.php +++ b/main/inc/conf/add_course.conf.dist.php @@ -8,7 +8,6 @@ */ $firstExpirationDelay = 31536000; // <- 86400*365 // 60*60*24 = 1 jour = 86400 -//$defaultVisibilityForANewCourse = 2; //Variable is no longer used. Use the platform setting: courses_default_creation_visibility $prefixAntiNumber = 'z'; $DEBUG = false; diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index fab97da78a..bb54902496 100644 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -106,7 +106,7 @@ require_once $lib_path.'events.lib.inc.php'; //require_once $lib_path.'rights.lib.php'; moved to autoload require_once $lib_path.'model.lib.php'; -//require_once $lib_path.'sortabletable.class.php'; moved to autoload +//require_once $lib_path.'sortable_table.class.php'; moved to autoload require_once $lib_path.'usermanager.lib.php'; require_once $lib_path.'message.lib.php'; require_once $lib_path.'social.lib.php'; @@ -583,4 +583,4 @@ if (!isset($_SESSION['login_as']) && isset($_user)) { $s_sql_update_logout_date = "UPDATE $tbl_track_login SET logout_date=NOW() WHERE login_id='$i_id_last_connection'"; Database::query($s_sql_update_logout_date); } -} \ No newline at end of file +} diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index a4062b15c7..113eb07041 100644 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -283,7 +283,7 @@ function get_course_tables() { /** * Creates all the necessary tables for a new course */ -function update_Db_course($course_db_name = null) { +function update_db_course($course_db_name = null) { global $_configuration; $charset_clause = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci'; @@ -2242,32 +2242,21 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu if (is_null($fill_with_exemplary_content)) { $fill_with_exemplary_content = api_get_setting('example_material_course_creation') != 'false'; } - global $_configuration, $_user; + global $_configuration; $course_id = intval($course_id); + if (empty($course_id)) { return false; } $tbl_course_homepage = Database::get_course_table(TABLE_TOOL_LIST); - $TABLEINTROS = Database::get_course_table(TABLE_TOOL_INTRO); - - $TABLEGROUPS = Database::get_course_table(TABLE_GROUP); - $TABLEGROUPCATEGORIES = Database::get_course_table(TABLE_GROUP_CATEGORY); - $TABLEGROUPUSER = Database::get_course_table(TABLE_GROUP_USER); - - $TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); - - $TABLETOOLCOURSEDESC = Database::get_course_table(TABLE_COURSE_DESCRIPTION); + $TABLEINTROS = Database::get_course_table(TABLE_TOOL_INTRO); + $TABLEGROUPCATEGORIES = Database::get_course_table(TABLE_GROUP_CATEGORY); + $TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TABLETOOLAGENDA = Database::get_course_table(TABLE_AGENDA); $TABLETOOLANNOUNCEMENTS = Database::get_course_table(TABLE_ANNOUNCEMENT); - $TABLEADDEDRESOURCES = Database::get_course_table(TABLE_LINKED_RESOURCES); - $TABLETOOLWORKS = Database::get_course_table(TABLE_STUDENT_PUBLICATION); - $TABLETOOLDOCUMENT = Database::get_course_table(TABLE_DOCUMENT); - $TABLETOOLWIKI = Database::get_course_table(TABLE_WIKI); - $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); - $TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST); $TABLEQUIZQUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); $TABLEQUIZQUESTIONLIST = Database::get_course_table(TABLE_QUIZ_QUESTION); @@ -2403,7 +2392,7 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu // FILL THE COURSE DOCUMENT WITH DEFAULT COURSE PICTURES $sys_course_path = api_get_path(SYS_COURSE_PATH); - if (is_array($default_document_array) && count($default_document_array)>0) { + if (is_array($default_document_array) && count($default_document_array) > 0) { foreach ($default_document_array as $media_type => $array_media) { if ($media_type == 'images') { $path_documents = '/images/gallery/'; @@ -2513,9 +2502,7 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu VALUES ( '.$course_id.', '1', '".lang2db(get_lang('SocraticIrony')) . "', '".lang2db(get_lang('ManyAnswers')) . "', '10', '1', '2','',1)"); Database::query("INSERT INTO $TABLEQUIZQUESTION (c_id, question_id, exercice_id, question_order) VALUES ('.$course_id.', 1,1,1)"); - /* - Forum tool - */ + /* Forum tool */ Database::query("INSERT INTO $TABLEFORUMCATEGORIES VALUES ($course_id, 1,'".lang2db(get_lang('ExampleForumCategory'))."', '', 1, 0, 0)"); $insert_id = Database :: insert_id(); @@ -2535,23 +2522,23 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu VALUES ($course_id, 'forum_thread',1,NOW(),NOW(),$insert_id,'ForumThreadAdded',1,0,NULL,1)"); Database::query("INSERT INTO $TABLEFORUMPOSTS VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', '".lang2db(get_lang('ExampleThreadContent'))."', 1, 1, 1, '', NOW(), 0, 0, 1)"); - } // PLUGINS - if an installed plugin has a course_install.php file, execute it - $installed_plugins = api_get_settings('Plugins','list',$_configuration['access_url']); + $installed_plugins = api_get_settings('Plugins','list', $_configuration['access_url']); $shortlist_installed = array(); foreach ($installed_plugins as $plugin) { $shortlist_installed[] = $plugin['subkey']; } $shortlist_installed = array_flip(array_flip($shortlist_installed)); + foreach ($shortlist_installed as $plugin) { - $pluginpath = api_get_path(SYS_PLUGIN_PATH).$plugin.'/course_install.php'; + $pluginpath = api_get_path(SYS_PLUGIN_PATH).$plugin.'/course_install.php'; if (is_file($pluginpath) && is_readable($pluginpath)) { //execute the install procedure include $pluginpath; } - } + } //end of installed plugins alterations $language_interface = $language_interface_original; return true; diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php index 6ae8158423..e13a68847c 100644 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -13,6 +13,7 @@ require_once 'fckeditor/fckeditor.php'; define ('CAREER_STATUS_ACTIVE', 1); define ('CAREER_STATUS_INACTIVE',0); + /** * @package chamilo.library */ @@ -162,7 +163,6 @@ class Career extends Model { return $cid; } - public function save($params) { $id = parent::save($params); if (!empty($id)) { @@ -174,6 +174,5 @@ class Career extends Model { public function delete($id) { parent::delete($id); event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); - } - -} + } +} \ No newline at end of file diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index 047cbde294..f41fc9cc43 100644 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -1174,7 +1174,7 @@ class Database { } $sql = "SELECT $clean_columns FROM $table_name $conditions"; - ///var_dump($sql); + //var_dump($sql); $result = self::query($sql); $array = array(); //if (self::num_rows($result) > 0 ) { @@ -1338,7 +1338,7 @@ class Database { //Parsing and cleaning the where conditions $where_return = self::parse_where_conditions($where_conditions); $sql = "UPDATE $table_name SET $update_sql $where_return "; - if ($show_query) { echo $sql; echo '
'; } + if ($show_query) { var_dump($sql); } $result = self::query($sql); $affected_rows = self::affected_rows(); return $affected_rows; diff --git a/main/inc/lib/link.lib.php b/main/inc/lib/link.lib.php index f1364f1fd6..738686e1ba 100644 --- a/main/inc/lib/link.lib.php +++ b/main/inc/lib/link.lib.php @@ -20,6 +20,31 @@ /* FUNCTIONS */ + +class Link extends Model { + var $table; + var $is_course_model = true; + var $columns = array('id', 'c_id','url','title','description','category_id', 'display_order', 'on_homepage', 'target', 'session_id'); + var $required = array('url', 'title'); + + public function __construct() { + $this->table = Database::get_course_table(TABLE_LINK); + } + + public function save($params) { + $course_info = api_get_course_info(); + $params['session_id'] = api_get_session_id(); + $params['category_id'] = isset($params['category_id']) ? $params['category_id'] : 0; + + $id = parent::save($params); + if (!empty($id)) { + api_item_property_update($course_info, TOOL_LINK, $id, 'LinkAdded', api_get_user_id()); + } + return $id; + } +} + + /** * Used to add a link or a category * @param string $type, "link" or "category" diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index add49caffe..7f1496f37f 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -4223,8 +4223,7 @@ function & api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $u $where_condition = " AND access_url_changeable= '1' "; } if (empty($access_url) or $access_url == -1) { $access_url = 1; } - $sql = "SELECT id, variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable " . - " FROM $t_cs WHERE access_url = $access_url $where_condition "; + $sql = "SELECT * FROM $t_cs WHERE access_url = $access_url $where_condition "; if (!empty($cat)) { $cat = Database::escape_string($cat); diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index a3c0ee3cd5..6907864efc 100644 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -231,7 +231,7 @@ class SessionManager { ('$today' < s.date_end AND '0000-00-00' = s.date_start) , 1, 0) as session_active, - s.name, nbr_courses, s.date_start, s.date_end, $coach_name, sc.name as category_name, s.visibility, u.user_id, s.id"; + s.name, nbr_courses, nbr_users, s.date_start, s.date_end, $coach_name, sc.name as category_name, s.visibility, u.user_id, s.id"; $query = "$select FROM $tbl_session s LEFT JOIN $tbl_session_category sc ON s.session_category_id = sc.id @@ -260,7 +260,6 @@ class SessionManager { $query .= " ORDER BY ".$options['order']." LIMIT ".$options['limit']; - // echo $query; $result = Database::query($query); $formatted_sessions = array(); if (Database::num_rows($result)) { @@ -302,6 +301,7 @@ class SessionManager { $formatted_sessions[] = $session; } } + return $formatted_sessions; } diff --git a/main/inc/lib/skill.lib.php b/main/inc/lib/skill.lib.php index c1cd30f14e..f4dbcf852f 100644 --- a/main/inc/lib/skill.lib.php +++ b/main/inc/lib/skill.lib.php @@ -31,9 +31,9 @@ class SkillProfile extends Model { return $profiles; } - public function save($params) { + public function save($params, $show_query = false) { if (!empty($params)) { - $profile_id = parent::save($params); + $profile_id = parent::save($params, $show_query); if ($profile_id) { $skill_rel_profile = new SkillRelProfile(); if (isset($params['skills'])) { diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 9096af4872..c76e3df737 100644 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -2039,7 +2039,7 @@ class UserManager { if (api_is_allowed_to_create_course()) { foreach($sessions as $enreg) { $id_session = $enreg['id']; - $personal_course_list_sql = "SELECT DISTINCT course.code, + $personal_course_list_sql = "SELECT DISTINCT course.code k, course.title i, ".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name FROM $tbl_session_course_user as session_course_user @@ -2066,7 +2066,7 @@ class UserManager { foreach ($sessions as $enreg) { $id_session = $enreg['id']; // this query is very similar to the above query, but it will check the session_rel_course_user table if there are courses registered to our user or not - $personal_course_list_sql = "SELECT DISTINCT course.code CONCAT(user.lastname,' ',user.firstname) t, email, + $personal_course_list_sql = "SELECT DISTINCT course.code k, course.title i, CONCAT(user.lastname,' ',user.firstname) t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, " . "IF((session_course_user.id_user = 3 AND session_course_user.status=2),'2', '5') FROM $tbl_session_course_user as session_course_user diff --git a/main/install/db_main.sql b/main/install/db_main.sql index 923f0ecac0..9be08747de 100644 --- a/main/install/db_main.sql +++ b/main/install/db_main.sql @@ -560,6 +560,7 @@ CREATE TABLE IF NOT EXISTS settings_current ( subkeytext varchar(255) default NULL, access_url int unsigned not null default 1, access_url_changeable int unsigned not null default 0, + access_url_locked int not null default 0, PRIMARY KEY id (id), INDEX (access_url) ); diff --git a/main/install/install.lib.php b/main/install/install.lib.php index 53755df4ac..f0bc97f377 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -1561,8 +1561,7 @@ function display_database_parameter($install_type, $parameter_name, $form_field_ $maxlength = $form_field_name == 'dbPrefixForm' ? '15' : MAX_FORM_FIELD_LENGTH; if ($install_type == INSTALL_TYPE_UPDATE) { echo ''; - echo '"; - //echo "\n"; + echo '"; } else { echo '"; echo ""; @@ -1685,26 +1684,6 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo } display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, ' ', null, 'id="optional_param4" '.$style); } - - //Database Prefix - //display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, '', null, 'id="optional_param5" '.$style); //get_lang('DbPrefixCom') - - /* Tracking is always available see #2066 - * - - - - - - - - - - - */ ?> - - - - - - - - - - */ - ?> @@ -2008,7 +1970,6 @@ function display_after_install_message($installType, $nbr_courses) { * @return array|string countries list */ function get_countries_list_from_array($combo = false) { - $a_countries = array( "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", @@ -2049,3 +2010,49 @@ function get_countries_list_from_array($combo = false) { return $a_countries; } + +/** + * Lockis settings that can't be changed in other portals + */ +function locking_settings() { + $access_url_locked_settings = array( + 'server_type', + 'use_document_title', + 'permanently_remove_deleted_files', + 'account_valid_duration', + 'service_visio', + 'service_ppt2lp', + 'wcag_anysurfer_public_pages', + 'upload_extensions_list_type', + 'upload_extensions_blacklist', + 'upload_extensions_whitelist', + 'upload_extensions_skip', + 'upload_extensions_replace_by', + 'hide_dltt_markup', + 'split_users_upload_directory', + 'permissions_for_new_directories', + 'permissions_for_new_files', + 'platform_charset', + 'service_visio', + 'ldap_description', + 'cas_activate', + 'cas_server', + 'cas_server_uri', + 'cas_port', + 'cas_protocol', + 'cas_add_user_activate', + 'update_user_info_cas_with_ldap', + 'languagePriority1', + 'languagePriority2', + 'languagePriority3', + 'languagePriority4', + 'login_is_email', + 'chamilo_database_version' + ); + $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); + foreach ($access_url_locked_settings as $setting) { + $sql = "UPDATE $table SET access_url_locked = 1 WHERE variable = '$setting'"; + Database::query($sql); + } + +} \ No newline at end of file diff --git a/main/install/install_db.inc.php b/main/install/install_db.inc.php index 742b81590a..3e60952942 100644 --- a/main/install/install_db.inc.php +++ b/main/install/install_db.inc.php @@ -117,7 +117,7 @@ load_main_database($installation_settings); //Adds the c_XXX courses tables see #3910 require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'; -update_Db_course(); +update_db_course(); load_database_script('db_stats.sql'); @@ -125,3 +125,5 @@ $track_countries_table = "track_c_countries"; fill_track_countries_table($track_countries_table); load_database_script('db_user.sql'); + +locking_settings(); \ No newline at end of file diff --git a/main/install/migrate-db-1.8.8-1.9.0-pre.sql b/main/install/migrate-db-1.8.8-1.9.0-pre.sql index e2597b48e4..45703ec199 100755 --- a/main/install/migrate-db-1.8.8-1.9.0-pre.sql +++ b/main/install/migrate-db-1.8.8-1.9.0-pre.sql @@ -189,6 +189,9 @@ ALTER TABLE gradebook_evaluation MODIFY COLUMN weight FLOAT NOT NULL; INSERT INTO settings_options(variable,value,display_text) VALUES ('page_after_login', 'main/auth/courses.php', 'CourseCatalog'); +ALTER TABLE settings_current ADD COLUMN access_url_locked INTEGER NOT NULL DEFAULT 0; + + -- Do not move this query UPDATE settings_current SET selected_value = '1.9.0.17631' WHERE variable = 'chamilo_database_version'; diff --git a/main/install/update-db-1.8.8-1.9.0.inc.php b/main/install/update-db-1.8.8-1.9.0.inc.php index 3b4f1c2b8d..0f982c14af 100755 --- a/main/install/update-db-1.8.8-1.9.0.inc.php +++ b/main/install/update-db-1.8.8-1.9.0.inc.php @@ -248,9 +248,7 @@ if (defined('SYSTEM_INSTALLATION')) { if ($res === false) { die('Error while querying the courses list in update_db-1.8.6.2-1.8.7.inc.php'); } $errors = array(); - //$filename = api_get_path(SYS_ARCHIVE_PATH).'migration_report.log'; - //$time = date(); file_put_contents($filename, "File creation at $time "); - + if (Database::num_rows($res) > 0) { $i = 0; $list = array(); @@ -258,7 +256,6 @@ if (defined('SYSTEM_INSTALLATION')) { $list[] = $row; $i++; } - $query_id = ''; foreach ($list as $row_course) { // Now use the $c_q_list @@ -378,7 +375,7 @@ if (defined('SYSTEM_INSTALLATION')) { error_log('<<<------- Loading DB course '.$row_course['db_name'].' -------->>'); $count = $old_count = 0; - foreach($table_list as $table) { + foreach ($table_list as $table) { $old_table = $row_course['db_name'].".".$table; if ($singleDbForm) { $old_table = "$prefix{$row_course['db_name']}_".$table; @@ -427,23 +424,8 @@ if (defined('SYSTEM_INSTALLATION')) { error_log("Check the results: "); error_log(print_r($errors, 1)); } - } - error_log('<<<------- end -------->>'); - - //error - /* - //Adding all_day to the calendar event table - $calendar_event_table = $row_course['db_name'].".calendar_event"; - if ($singleDbForm) { - $calendar_event_table = "$prefix{$row_course['db_name']}_calendar_event"; } - $query = "ALTER TABLE `".$calendar_event_table."` ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } */ - - + error_log('<<<------- end -------->>'); } } } diff --git a/main/link/link.php b/main/link/link.php index 4f47235451..ececd2a138 100644 --- a/main/link/link.php +++ b/main/link/link.php @@ -224,7 +224,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) { * URL
- +
'; echo '
@@ -232,7 +232,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) { '.get_lang('LinkName').'
- +
'; echo '
@@ -248,7 +248,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) { '.get_lang('Description').'
- +
'; diff --git a/main/reservation/rsys.php b/main/reservation/rsys.php old mode 100755 new mode 100644 index 829a6ccb9a..577cc9ccc2 --- a/main/reservation/rsys.php +++ b/main/reservation/rsys.php @@ -1741,7 +1741,7 @@ class Rsys { $language_file = 'reservation'; $cidReset = true; require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php'; Rsys :: init(); require_once 'rcalendar.php'; -require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; \ No newline at end of file +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; diff --git a/main/session/index.php b/main/session/index.php index ca6e00df09..6a222c630a 100644 --- a/main/session/index.php +++ b/main/session/index.php @@ -80,7 +80,7 @@ if (!empty($new_session_list)) { $exercise = new Exercise($course_info['real_id']); $exercise->read($exercise_item['id']); $visible_return = $exercise->is_visible(); - if ($visible_return['value'] == false) { + if ($visible_return['value'] != false) { //$exercise_course_list[$exercise_item['id']] = $exercise; //Reading all Exercise results by user, exercise_id, code, and session $user_results = get_exercise_results_by_user(api_get_user_id(), $exercise_item['id'], $my_course['code'], $my_session_id); diff --git a/plugin/bbb/bbb.lib.php b/plugin/bbb/bbb.lib.php index 243bb019bd..ab929ea7cc 100644 --- a/plugin/bbb/bbb.lib.php +++ b/plugin/bbb/bbb.lib.php @@ -1,370 +1,252 @@ course) .", " . - "'".Database::escape_string($object->name)."'," . - "'".Database::escape_string($object->meetingname)."'," . - "'".Database::escape_string($object->meetingid)."'," . - "'".Database::escape_string($object->attendeepw)."'," . - "'".Database::escape_string($object->moderatorpw)."'," . - "'".Database::escape_string($object->autologin)."'," . - "'".Database::escape_string($object->newwindow)."'," . - "'".Database::escape_string($object->welcomemsg)."'" . - ")"; - Database::query($sql); - return Database::insert_id(); -} -/** - * Updates a bigbluebutton record - */ -function bigbluebutton_update_record($table, $object) { - //ignore the first param (used for compatibility with existing code) $table = Database::get_main_table('plugin_bbb'); - $sql = "UPDATE $table (course_id, name, meeting_name, meeting_id, attendee_pw, moderator_pw, auto_login, new_window, welcome_msg)" . - " SET course_id = ".intval($object->course) .", " . - " name = '".Database::escape_string($object->name)."'," . - " meeting_name = '".Database::escape_string($object->meetingname)."'," . - " meeting_id = '".Database::escape_string($object->meetingid)."'," . - " attendee_pw = '".Database::escape_string($object->attendeepw)."'," . - " moderator_pw = '".Database::escape_string($object->moderatorpw)."'," . - " auto_login = '".Database::escape_string($object->autologin)."'," . - " new_window = '".Database::escape_string($object->newwindow)."'," . - " welcome_msg = '".Database::escape_string($object->welcomemsg)."'," . - " WHERE id = " .intval($object->id). - ")"; - Database::query($sql); - return $oject->id; -} -/** - * Gets a bigbluebutton room record from an ID - */ -function bigbluebutton_get_record($table,$field,$id) { - //ignore the first param (used for compatibility with existing code) - $table = Database::get_main_table('plugin_bbb'); - $sql = "SELECT * FROM $table WHERE id = ".intval($id); - $res = Database::query($sql); - if (Database::num_rows($res)>0) { - $row = Database::fetch_assoc($res); - $room = null; - $room->id = $id; - $room->course = $row['course_id']; - $room->name = $row['name']; - $room->meetingname = $row['meeting_name']; - $room->meetingid = $row['meeting_id']; - $room->attendeepw = $row['attendee_pw']; - $room->moderatorpw = $row['moderator_pw']; - $room->autologin = $row['auto_login']; - $room->newwindow = $row['new_window']; - $room->welcomemsg = $row['welcome_msg']; - return $room; - } else { - return null; - } -} -/** - * Gets a bigbluebutton room record from an ID - */ -function bigbluebutton_delete_records($table,$field,$id) { - //ignore the first param (used for compatibility with existing code) - $table = Database::get_main_table('plugin_bbb'); - $sql = "DELETE FROM $table WHERE id = ".intval($id); -} -/** - * Add an event - */ -function bigbluebutton_add_event($event) { - // -} -/** - * Given an object containing all the necessary data, - * (defined by the form in mod.html) this function - * will create a new instance and return the id number - * of the new instance. */ -function bigbluebutton_add_instance($bigbluebutton) { - $bigbluebutton->timemodified = time(); - if ($returnid = bigbluebutton_insert_record('bigbluebutton', $bigbluebutton)) { - $event = NULL; - $event->courseid = $bigbluebutton->course; - $event->name = $bigbluebutton->name; - $event->meetingname = $bigbluebutton->meetingname; - $event->meetingid = $bigbluebutton->meetingid; - $event->attendeepw = $bigbluebutton->attendeepw; - $event->moderatorpw = $bigbluebutton->moderatorpw; - $event->autologin = $bigbluebutton->autologin; - $event->newwindow = $bigbluebutton->newwindow; - $event->welcomemsg = $bigbluebutton->welcomemsg; - bigbluebutton_add_event($event); - } - return $returnid; -} - -/** - * Given an object containing all the necessary data, - * (defined by the form in mod.html) this function - * will update an existing instance with new data. - */ -function bigbluebutton_update_instance($bigbluebutton) { - $bigbluebutton->timemodified = time(); - $bigbluebutton->id = $bigbluebutton->instance; - if ($returnid = bigbluebutton_update_record('bigbluebutton', $bigbluebutton)) { - /* - $event = NULL; - if ($event->id = bigbluebutton_get_field('event', 'id', 'modulename', 'bigbluebutton', 'instance', $bigbluebutton->id)) { - $event->courseid = $bigbluebutton->course; - $event->name = $bigbluebutton->name; - $event->meetingname = $bigbluebutton->meetingname; - $event->meetingid = $bigbluebutton->meetingid; - $event->attendeepw = $bigbluebutton->attendeepw; - $event->moderatorpw = $bigbluebutton->moderatorpw; - $event->autologin = $bigbluebutton->autologin; - $event->newwindow = $bigbluebutton->newwindow; - $event->welcomemsg = $bigbluebutton->welcomemsg; - bigbluebutton_update_event($event); - }*/ - } - return $returnid; -} - - - -/** - * Given an ID of an instance of this module, - * this function will permanently delete the instance - * and any data that depends on it. - */ -function bigbluebutton_delete_instance($id) { - if (! $bigbluebutton = bigbluebutton_get_record('bigbluebutton', 'id', $id)) { +class bbb { + + var $url; + var $salt; + var $api; + var $user_complete_name = null; + var $protocol = 'http://'; + var $debug = true; + var $logout_url = null; + + function __construct() { + + // initialize video server settings from global settings + $settings = api_get_settings('Extra','list',api_get_current_access_url_id()); + $bbb_settings = array(); + foreach ($settings as $setting) { + if (substr($setting['variable'],0,4)==='bbb_') { + $bbb_settings[$setting['variable']] = $setting['selected_value']; + } + } + $bbb_plugin = $bbb_settings['bbb_plugin'] === 'true'; + $bbb_host = $bbb_settings['bbb_plugin_host']; + $bbb_salt = $bbb_settings['bbb_plugin_salt']; + + $course_code = api_get_course_id(); + + $this->logout_url = api_get_path(WEB_COURSE_PATH).$course_code; + + if ($bbb_plugin) { + $user_info = api_get_user_info(); + $this->user_complete_name = $user_info['complete_name']; + $this->salt = $bbb_salt; + $this->url = $bbb_host.'/bigbluebutton/'; + $this->table = Database::get_main_table('plugin_bbb_meeting'); + return true; + } return false; } - - $result = true; - - # Delete any dependent records here # - - if (! bigbluebutton_delete_records('bigbluebutton', 'id', $bigbluebutton->id)) { - $result = false; + + function create_meeting($params) { + $params['c_id'] = api_get_course_int_id(); + $course_code = 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'] : api_get_course_id().'mod'; + + $params['record'] = api_get_course_setting('big_blue_button_record_and_store', $course_code) == 1 ? true : false; + $max = api_get_course_setting('big_blue_button_max_students_allowed', $course_code); + + $max = isset($max) ? $max : -1; + $params['status'] = 1; + + if ($this->debug) error_log("enter create_meeting ".print_r($params, 1)); + + $params['created_at'] = api_get_utc_datetime(); + $id = Database::insert($this->table, $params); + + if ($id) { + if ($this->debug) error_log("create_meeting $id "); + + $meeting_name = isset($params['meeting_name']) ? $params['meeting_name'] : api_get_course_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; + + + // ?? + $voiceBridge = 0; + $metadata = array('maxParticipants' => $max); + return $this->protocol.BigBlueButtonBN::createMeetingAndGetJoinURL($this->user_complete_name, $meeting_name, $id, $welcome_msg, $moderator_password, $attende_password, + $this->salt, $this->url, $this->logout_url, $record, $duration, $voiceBridge, $metadata); + + //$id = Database::update($this->table, array('created_at' => '')); + } } -/* - $pagetypes = page_import_types('mod/bigbluebutton/'); - foreach($pagetypes as $pagetype) { - if(!delete_records('block_instance', 'pageid', $bigbluebutton->id, 'pagetype', $pagetype)) { - $result = false; + + function is_meeting_exist($meeting_name) { + $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'); + if ($this->debug) error_log("is_meeting_exist ".print_r($meeting_data,1)); + if (empty($meeting_data)) { + return false; + } else { + return true; } } -*/ -/* - if (! bigbluebutton_delete_records('event', 'modulename', 'bigbluebutton', 'instance', $bigbluebutton->id)) { - $result = false; + + /** + * @todo implement moderator pass + */ + function join_meeting($meeting_name) { + $pass = $this->get_user_metting_password(); + $meeting_data = Database::select('*', $this->table, array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)), 'first'); + if (empty($meeting_data)) { + if ($this->debug) error_log("meeting does not exist: $meeting_name "); + return false; + } + + $meeting_is_running = BigBlueButtonBN::isMeetingRunning($meeting_data['id'], $this->url, $this->salt); + + + $meeting_info = BigBlueButtonBN::getMeetingInfoArray($meeting['id'], $pass, $this->url, $this->salt); + $meeting_info_exists = false; + + if ($meeting_info['returncode'] != 'FAILED') { + $meeting_info_exists = true; + } + $url = false; + if ($this->debug) error_log("meeting is running".$meeting_is_running); + + if (isset($meeting_is_running) && $meeting_info_exists) { + $url = $this->protocol.BigBlueButtonBN::joinURL($meeting_data['id'], $this->user_complete_name, $pass, $this->salt, $this->url); + } + if ($this->debug) error_log("return url :".$url); + return $url; + } + + /** + * Gets all the course meetings saved in the plugin_bbb_meeting table + * @return string + */ + function get_course_meetings() { + $pass = $this->get_user_metting_password(); + $meeting_list = Database::select('*', $this->table, array('where' => array('c_id = ? ' => api_get_course_int_id()))); + $new_meeting_list = array(); + + foreach ($meeting_list as $meeting) { + $item_meeting = $meeting; + $item_meeting['info'] = BigBlueButtonBN::getMeetingInfoArray($meeting['id'], $pass, $this->url, $this->salt); + + if ($meeting['info']['returncode'] == 'FAILED') { + } else { + $item_meeting['end_url'] = api_get_self().'?action=end&id='.$meeting['id']; + } + $record_array = array(); + + if ($meeting['record'] == 1) { + $records = BigBlueButtonBN::getRecordingsArray($meeting['id'], $this->url, $this->salt); + //var_dump($meeting['id']); + if (!empty($records)) { + foreach ($records as $record) { + if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) { + + //Fix the bbb timestamp + $record['startTime'] = substr($record['startTime'], 0, strlen($record['startTime']) -3); + $record['endTime'] = substr($record['endTime'], 0, strlen($record['endTime']) -3); + + foreach ($record['playbacks'] as $item) { + $url = Display::url(get_lang('ViewRecord'), $item['url'], array('target' => '_blank')).' - '.api_convert_and_format_date($record['startTime']).' - '.api_convert_and_format_date($record['endTime']); + //$url .= Display::url(get_lang('DeleteRecord'), api_get_self().'?action=delete_record&'.$record['recordID']); + $url .= Display::url(get_lang('CopyToLinkTool'), api_get_self().'?action=copy_record_to_link_tool&id='.$meeting['id'].'&record_id='.$record['recordID']); + //$url .= api_get_self().'?action=publish&id='.$record['recordID']; + $record_array[] = $url; + } + } + } + } + $item_meeting['show_links'] = implode('
', $record_array); + } + + $item_meeting['created_at'] = api_get_local_time($item_meeting['created_at']); + //created_at + + $item_meeting['publish_url'] = api_get_self().'?action=publish&id='.$meeting['id']; + $item_meeting['unpublish_url'] = api_get_self().'?action=unpublish&id='.$meeting['id']; + + if ($meeting['status'] == 1) { + $item_meeting['go_url'] = $this->protocol.BigBlueButtonBN::joinURL($meeting['id'], $this->user_complete_name, $pass, $this->salt, $this->url); + } + $new_meeting_list[] = $item_meeting; + } + return $new_meeting_list; } -*/ - return $result; -} - - -/** - * Create string where we check if the meeting is running - */ -function wc_isMeetingRunningURL($myIP,$mySecuritySalt,$myMeetingID) { - $checkAPI = "/bigbluebutton/api/isMeetingRunning?"; - $queryStr = "meetingID=".$myMeetingID; - $checksum = sha1('isMeetingRunning'.$queryStr.$mySecuritySalt); - $secQueryURL = "http://".$myIP.$checkAPI.$queryStr."&checksum=".$checksum; - return $secQueryURL; -} - - -/** - * Determine if the meeting is already running (e.g. has attendees in it) - */ -function wc_isMeetingRunning($myIP,$mySecuritySalt,$myMeetingID) { - $secQueryURL = wc_isMeetingRunningURL($myIP,$mySecuritySalt,$myMeetingID); - $myResponse = @file_get_contents($secQueryURL); - if ($myResponse === false) { return false;} - $doc = new DOMDocument(); - $doc->loadXML($myResponse); - $returnCodeNode = $doc->getElementsByTagName("returncode"); - $returnCode = $returnCodeNode->item(0)->nodeValue; - $runningNode = $doc->getElementsByTagName("running"); - $isRunning = $runningNode->item(0)->nodeValue; - return $isRunning; -} - -/** - * Create meeting if it's not already running - */ -function wc_createMeeting($myIP,$mySecuritySalt,$myMeetingName,$myMeetingID,$myAttendeePW,$myModeratorPW,$myWelcomeMsg,$myLogoutURL) { - $createAPI = "/bigbluebutton/api/create?"; - $myVoiceBridge = rand(70000,79999); - $queryStr = "name=".urlencode($myMeetingName)."&meetingID=".urlencode($myMeetingID)."&attendeePW=".urlencode($myAttendeePW)."&moderatorPW=".urlencode($myModeratorPW)."&voiceBridge=".$myVoiceBridge."&welcome=".urlencode($myWelcomeMsg)."&logoutURL=".urlencode($myLogoutURL); - $checksum = sha1('create'.$queryStr.$mySecuritySalt); - $secQueryURL = "http://".$myIP.$createAPI.$queryStr."&checksum=".$checksum; - $myResponse = @file_get_contents($secQueryURL); - if ($myResponse === false) { return false; } - $doc= new DOMDocument(); - $doc->loadXML($myResponse); - $returnCodeNode = $doc->getElementsByTagName("returncode"); - $returnCode = $returnCodeNode->item(0)->nodeValue; - - if ($returnCode=="SUCCESS") { - return $returnCode; - } else { - $messageKeyNode = $doc->getElementsByTagName("messageKey"); - $messageKey = $messageKeyNode->item(0)->nodeValue; - return $messageKey; + + function publish_meeting($id) { + return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt); } -} - - -/** - * Create a URL to join the meeting - */ -function wc_joinMeetingURL($myIP,$mySecuritySalt,$myName,$myMeetingID,$myPassword,$userID) { - $joinAPI = "/bigbluebutton/api/join?"; - $queryStr = "fullName=".urlencode($myName)."&meetingID=".urlencode($myMeetingID)."&password=".urlencode($myPassword)."&userID=".$userID; - $checksum = sha1('join'.$queryStr.$mySecuritySalt); - $createStr = "http://".$myIP.$joinAPI.$queryStr."&checksum=".$checksum; - return $createStr; -} - -/** - * This API is not yet supported in bigbluebutton - */ -function wc_endMeeting($myIP,$mySecuritySalt,$myMeetingID,$myModeratorPW) { - $endAPI = "/bigbluebutton/api/end?"; - $myVoiceBridge = rand(70000,79999); - $queryStr = "meetingID=".$myMeetingID."&moderatorPW=".$myModeratorPW."&voiceBridge=".$myVoiceBridge; - $checksum = sha1('create'.$queryStr.$mySecuritySalt); - $secQueryURL = "http://".$myIP.$endAPI.$queryStr."&checksum=".$checksum; - $myResponse = @file_get_contents($secQueryURL); - if ($myResponse === false) { return false; } - $doc= new DOMDocument(); - $doc->loadXML($myResponse); - $returnCodeNode = $doc->getElementsByTagName("returncode"); - $returnCode = $returnCodeNode->item(0)->nodeValue; - if ($returnCode=="SUCCESS") { - return $returnCode; - } else { - $messageKeyNode = $doc->getElementsByTagName("messageKey"); - $messageKey = $messageKeyNode->item(0)->nodeValue; - return $messageKey; + function unpublish_meeting($id) { + return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt); } -} - -/** - * This API is not yet supported in bigbluebutton - */ -function wc_listAttendees() { - return false; -} - -/** - * This API is not yet supported in bigbluebutton - */ -function wc_getMeetingInfo($myIP,$mySecuritySalt,$meetingID,$modPW) { - $checkAPI = "/bigbluebutton/api/getMeetingInfo?"; - $queryStr = 'meetingID='.$meetingID.'&password='.$modPW; - $checksum = sha1('getMeetingInfo'.$queryStr.$mySecuritySalt); - $secQueryURL = "http://".$myIP.$checkAPI.$queryStr."&checksum=".$checksum; - $myResponse = @file_get_contents($secQueryURL); - if ($myResponse === false) { return false;} - $doc = new DOMDocument(); - $doc->loadXML($myResponse); - $returnCodeNode = $doc->getElementsByTagName("returncode"); - $returnCode = $returnCodeNode->item(0)->nodeValue; - $createTimeNode = $doc->getElementsByTagName("createTime"); - $createTime = $createTimeNode->item(0)->nodeValue; - $runningNode = $doc->getElementsByTagName("running"); - $running = $runningNode->item(0)->nodeValue; - $attendeesNode = $doc->getElementsByTagName("attendee"); - $attendees = array(); - foreach ($attendeesNode as $attendeeNode) { - $attendee = array(); - if ($attendeeNode->childNodes->length) { - foreach ($attendeeNode->childNodes as $i) { - //see http://code.google.com/p/bigbluebutton/wiki/API#Get_Meeting_Info for details - $attendee[$i->nodeName] = $i->nodeValue; - } + + function end_meeting($id) { + $pass = $this->get_user_metting_password(); + BigBlueButtonBN::endMeeting($id, $pass, $this->url, $this->salt); + Database::update($this->table, array('status' => 0), array('id = ? ' => $id)); + } + + function get_user_metting_password() { + $teacher = api_is_course_admin() || api_is_coach() || api_is_platform_admin(); + if ($teacher) { + return api_get_course_id().'mod'; + } else { + return api_get_course_id(); } - $attendees[] = $attendee; } - $info = array('returnCode'=>$returnCode,'createTime'=>$createTime,'attendees'=>$attendees,'running'=>$running); - return $info; -} - -/** - * Determine the URL of the current page (for logoutURL) - */ -function wc_currentPageURL() { - $isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on"); - $port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443"))); - $port = ($port) ? ':'.$_SERVER["SERVER_PORT"] : ''; - $pageURL = ($isHTTPS ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$port.$_SERVER["REQUEST_URI"]; - return $pageURL; -} - - -/** - * Determine the IP/Domain of the current Corporate University - */ -function wc_currentDomain() { - $currentDomain = $_SERVER["SERVER_NAME"]; - return $currentDomain; -} - - -/** - * Determine if a new version of the plug-in is available - */ -function wc_needUpgrade() { - $returnValue = false; - $installedVersion = "20100805"; - $availableVersion = dc_getVersion(); - if ((int)$installedVersion < (int)$availableVersion) { - $returnValue = true; - } - return $returnValue; -} - -/** - * Gets a list of all meetings currently running - */ -function wc_getRunningMeetings($myIP,$mySecuritySalt) { - $checkAPI = "/bigbluebutton/api/getMeetings?"; - $queryStr = ''; - $checksum = sha1('getMeetings'.$queryStr.$mySecuritySalt); - $secQueryURL = "http://".$myIP.$checkAPI.$queryStr."&checksum=".$checksum; - $myResponse = @file_get_contents($secQueryURL); - if ($myResponse === false) { return false;} - $doc = new DOMDocument(); - $doc->loadXML($myResponse); - $returnCodeNode = $doc->getElementsByTagName("returncode"); - $returnCode = $returnCodeNode->item(0)->nodeValue; - $meetingsNode = $doc->getElementsByTagName("meeting"); - $meetings = array(); - foreach ($meetingsNode as $meetingNode) { - $meeting = array(); - if ($meetingNode->childNodes->length) { - foreach ($meetingNode->childNodes as $i) { - //see http://code.google.com/p/bigbluebutton/wiki/API#Get_Meetings for details - $meeting[$i->nodeName] = $i->nodeValue; + + /** + * Get users online in the current course room + */ + 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'); + if (empty($meeting_data)) { + return 0; + } + $pass = $this->get_user_metting_password(); + //$meeting_is_running = BigBlueButtonBN::isMeetingRunning($meeting_data['id'], $this->url, $this->salt); + $info = BigBlueButtonBN::getMeetingInfoArray($meeting_data['id'], $pass, $this->url, $this->salt); + + if (!empty($info) && isset($info['participantCount'])) { + return $info['participantCount']; + + } + return 0; + } + + /** + * @todo + */ + function delete_record($id) { + } + + function copy_record_to_link_tool($id, $record_id) { + require_once api_get_path(LIBRARY_PATH).'link.lib.php'; + $records = BigBlueButtonBN::getRecordingsArray($id, $this->url, $this->salt); + if (!empty($records)) { + foreach ($records as $record) { + if ($record['recordID'] == $record_id) { + if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) { + foreach ($record['playbacks'] as $item) { + $link = new Link(); + $params['url'] = $item['url']; + $params['title'] = 'bbb 1'; + $id = $link->save($params); + return $id; + } + } + + } } } - $meetings[] = $meeting; + return false; + } - return $meetings; -} +} \ No newline at end of file diff --git a/plugin/bbb/bbb_api.php b/plugin/bbb/bbb_api.php new file mode 100644 index 0000000000..810de50f06 --- /dev/null +++ b/plugin/bbb/bbb_api.php @@ -0,0 +1,760 @@ += 6 ) { + $this->userName = func_get_arg(0); + $this->meetingID = func_get_arg(1); + $this->welcomeString = func_get_arg(2); + $this->modPW = func_get_arg(3); + $this->attPW = func_get_arg(4); + $this->securitySalt = func_get_arg(5); + $this->URL = func_get_arg(6); + + + $arg_list = func_get_args(); + }// end else if + } + + //------------------------------------------------GET URLs------------------------------------------------- + /** + *This method returns the url to join the specified meeting. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param username -- the display name to be used when the user joins the meeting + *@param PW -- the attendee or moderator password of the meeting + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return The url to join the meeting + */ + public static function joinURL( $meetingID, $userName, $PW, $SALT, $URL ) { + $url_join = $URL."api/join?"; + $params = 'meetingID='.urlencode($meetingID).'&fullName='.urlencode($userName).'&password='.urlencode($PW); + return ($url_join.$params.'&checksum='.sha1("join".$params.$SALT) ); + } + + + /** + *This method returns the url to join the specified meeting. + * + *@param name -- a name fot the meeting + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param attendeePW -- the attendee of the meeting + *@param moderatorPW -- the moderator of the meeting + *@param welcome -- the welcome message that gets displayed on the chat window + *@param logoutURL -- the URL that the bbb client will go to after users logouut + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + *@param record -- the flag which indicate if the meetings will be recorded or not record=true|false, default false + *@param duration -- this value indicate the duration of a meeting to be recorded. Duration is represented in munutes + * + *@return The url to join the meeting + */ + public static function createMeetingURL($name, $meetingID, $attendeePW, $moderatorPW, $welcome, $logoutURL, $SALT, $URL, $record = 'false', $duration=0, $voiceBridge=0, $metadata = array() ) { + $url_create = $URL."api/create?"; + if ( $voiceBridge == 0) + $voiceBridge = 70000 + rand(0, 9999); + + $meta = ''; + while ($data = current($metadata)) { + $meta = $meta.'&'.key($metadata).'='.urlencode($data); + next($metadata); + } + + + $params = 'name='.urlencode($name).'&meetingID='.urlencode($meetingID).'&attendeePW='.urlencode($attendeePW).'&moderatorPW='.urlencode($moderatorPW).'&voiceBridge='.$voiceBridge.'&logoutURL='.urlencode($logoutURL).'&record='.$record.$meta; + + $duration = intval($duration); + if( $duration > 0 ) + $params .= '&duration='.$duration; + + if( trim( $welcome ) ) + $params .= '&welcome='.urlencode($welcome); + + return ( $url_create.$params.'&checksum='.sha1("create".$params.$SALT) ); + } + + + /** + *This method returns the url to check if the specified meeting is running. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return The url to check if the specified meeting is running. + */ + public static function isMeetingRunningURL( $meetingID, $URL, $SALT ) { + $base_url = $URL."api/isMeetingRunning?"; + $params = 'meetingID='.urlencode($meetingID); + return ($base_url.$params.'&checksum='.sha1("isMeetingRunning".$params.$SALT) ); + } + + /** + *This method returns the url to getMeetingInfo of the specified meeting. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param modPW -- the moderator password of the meeting + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return The url to check if the specified meeting is running. + */ + public static function getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) { + $base_url = $URL."api/getMeetingInfo?"; + $params = 'meetingID='.urlencode($meetingID).'&password='.urlencode($modPW); + return ( $base_url.$params.'&checksum='.sha1("getMeetingInfo".$params.$SALT)); + } + + /** + *This method returns the url for listing all meetings in the bigbluebuttonbn server. + * + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return The url of getMeetings. + */ + public static function getMeetingsURL($URL, $SALT) { + $base_url = $URL."api/getMeetings?"; + $params = ''; + return ( $base_url.$params.'&checksum='.sha1("getMeetings".$params.$SALT)); + } + + /** + *This method returns the url to end the specified meeting. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param modPW -- the moderator password of the meeting + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return The url to end the specified meeting. + */ + public static function endMeetingURL( $meetingID, $modPW, $URL, $SALT ) { + $base_url = $URL."api/end?"; + $params = 'meetingID='.urlencode($meetingID).'&password='.urlencode($modPW); + return ( $base_url.$params.'&checksum='.sha1("end".$params.$SALT) ); + } + + //-----------------------------------------------CREATE---------------------------------------------------- + /** + *This method creates a meeting and returnS the join url for moderators. + * + *@param username + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param welcomeString -- the welcome message to be displayed when a user logs in to the meeting + *@param mPW -- the moderator password of the meeting + *@param aPW -- the attendee password of the meeting + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + *@param logoutURL -- the url the user should be redirected to when they logout of bigbluebuttonbn + *@param record -- the flag which indicate if the meetings will be recorded or not record=true|false, default false + * + *@return The joinURL if successful or an error message if unsuccessful + */ + public static function createMeetingAndGetJoinURL( $username, $meeting_name, $meetingID, $welcomeString, $mPW, $aPW, $SALT, $URL, $logoutURL, $record = 'false', $duration=0, $voiceBridge=0, $metadata = array()) { + + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::createMeetingURL($meeting_name, $meetingID, $aPW, $mPW, $welcomeString, $logoutURL, $SALT, $URL, $record, $duration, $voiceBridge, $metadata ) ); + + if( $xml && $xml->returncode == 'SUCCESS' ) { + return ( BigBlueButtonBN::joinURL( $meetingID, $username, $mPW, $SALT, $URL ) ); + } + else if( $xml ) { + return ( $xml->messageKey.' : '.$xml->message ); + } + else { + return ('Unable to fetch URL '.$url_create.$params.'&checksum='.sha1("create".$params.$SALT) ); + } + } + + /** + *This method creates a meeting and return an array of the xml packet + * + *@param username + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param welcomeString -- the welcome message to be displayed when a user logs in to the meeting + *@param mPW -- the moderator password of the meeting + *@param aPW -- the attendee password of the meeting + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + *@param logoutURL -- the url the user should be redirected to when they logout of bigbluebuttonbn + *@param record -- the flag which indicate if the meetings will be recorded or not record=true|false, default false + * + *@return + * - Null if unable to reach the bigbluebuttonbn server + * - If failed it returns an array containing a returncode, messageKey, message. + * - If success it returns an array containing a returncode, messageKey, message, meetingID, attendeePW, moderatorPW, hasBeenForciblyEnded. + */ + public static function createMeetingArray( $username, $meetingID, $welcomeString, $mPW, $aPW, $SALT, $URL, $logoutURL, $record='false', $duration=0, $voiceBridge=0, $metadata = array() ) { + + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::createMeetingURL($username, $meetingID, $aPW, $mPW, $welcomeString, $logoutURL, $SALT, $URL, $record, $duration, $voiceBridge, $metadata ) ); + + if( $xml ) { + if($xml->meetingID) return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey, 'meetingID' => $xml->meetingID, 'attendeePW' => $xml->attendeePW, 'moderatorPW' => $xml->moderatorPW, 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded ); + else return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey ); + } + else { + return null; + } + } + + //-------------------------------------------getMeetingInfo--------------------------------------------------- + /** + *This method calls the getMeetingInfo on the bigbluebuttonbn server and returns an xml packet. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param modPW -- the moderator password of the meeting + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return An xml packet. + * If failed it returns an xml packet containing a returncode, messagekey, and message. + * If success it returnsan xml packet containing a returncode, + */ + public static function getMeetingInfo( $meetingID, $modPW, $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) ); + if($xml){ + return ( str_replace('', '', str_replace("\n", '', $xml->asXML()))); + } + return false; + } + + /** + *This method calls the getMeetingInfo on the bigbluebuttonbn server and returns an array. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param modPW -- the moderator password of the meeting + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return An Array. + * - Null if unable to reach the bigbluebuttonbn server + * - If failed it returns an array containing a returncode, messagekey, message. + * - If success it returns an array containing a meetingID, moderatorPW, attendeePW, hasBeenForciblyEnded, running, startTime, endTime, + participantCount, moderatorCount, attendees. + */ + public static function getMeetingInfoArray( $meetingID, $modPW, $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) ); + + if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey == null){//The meetings were returned + return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey ); + } + else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created + return array( 'meetingID' => $xml->meetingID, 'moderatorPW' => $xml->moderatorPW, 'attendeePW' => $xml->attendeePW, 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, 'running' => $xml->running, 'recording' => $xml->recording, 'startTime' => $xml->startTime, 'endTime' => $xml->endTime, 'participantCount' => $xml->participantCount, 'moderatorCount' => $xml->moderatorCount, 'attendees' => $xml->attendees, 'metadata' => $xml->metadata ); + } + else if( ($xml && $xml->returncode == 'FAILED') || $xml) { //If the xml packet returned failure it displays the message to the user + return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); + //return array('returncode' => $xml->returncode, 'message' => $xml->errors->error['message'], 'messageKey' => $xml->errors->error['key']); //For API version 0.8 + } + else { //If the server is unreachable, then prompts the user of the necessary action + return null; + } + + } + + //-----------------------------------------------getMeetings------------------------------------------------------ + /** + *This method calls getMeetings on the bigbluebuttonbn server, then calls getMeetingInfo for each meeting and concatenates the result. + * + *@param URL -- the url of the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + * + *@return + * - If failed then returns a boolean of false. + * - If succeeded then returns an xml of all the meetings. + */ + public static function getMeetings( $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingsURL( $URL, $SALT ) ); + if( $xml && $xml->returncode == 'SUCCESS' ) { + if( $xml->messageKey ) + return ( $xml->message->asXML() ); + ob_start(); + echo ''; + if( count( $xml->meetings ) && count( $xml->meetings->meeting ) ) { + foreach ($xml->meetings->meeting as $meeting) + { + echo ''; + echo BigBlueButtonBN::getMeetingInfo($meeting->meetingID, $meeting->moderatorPW, $URL, $SALT); + echo ''; + } + } + echo ''; + return (ob_get_clean()); + } + else { + return (false); + } + } + + /** + *This method calls getMeetings on the bigbluebuttonbn server, then calls getMeetingInfo for each meeting and concatenates the result. + * + *@param URL -- the url of the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + * + *@return + * - Null if the server is unreachable + * - If FAILED then returns an array containing a returncode, messageKey, message. + * - If SUCCESS then returns an array of all the meetings. Each element in the array is an array containing a meetingID, + moderatorPW, attendeePW, hasBeenForciblyEnded, running. + */ + public static function getMeetingsArray( $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingsURL( $URL, $SALT ) ); + + if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey ) {//The meetings were returned + return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); + } + else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created + + foreach ($xml->meetings->meeting as $meeting) + { + $meetings[] = array( 'meetingID' => $meeting->meetingID, 'moderatorPW' => $meeting->moderatorPW, 'attendeePW' => $meeting->attendeePW, 'hasBeenForciblyEnded' => $meeting->hasBeenForciblyEnded, 'running' => $meeting->running ); + } + + return $meetings; + + } + else if( $xml ) { //If the xml packet returned failure it displays the message to the user + return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); + } + else { //If the server is unreachable, then prompts the user of the necessary action + return null; + } + } + + //----------------------------------------------getUsers--------------------------------------- + /** + *This method prints the usernames of the attendees in the specified conference. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param modPW -- the moderator password of the meeting + *@param URL -- the url of the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param UNAME -- is a boolean to determine how the username is formatted when printed. Default if false. + * + *@return A boolean of true if the attendees were printed successfully and false otherwise. + */ + public static function getUsers( $meetingID, $modPW, $URL, $SALT, $UNAME = false ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) ); + if( $xml && $xml->returncode == 'SUCCESS' ) { + ob_start(); + if( count( $xml->attendees ) && count( $xml->attendees->attendee ) ) { + foreach ( $xml->attendees->attendee as $attendee ) { + if( $UNAME == true ) { + echo "User name: ".$attendee->fullName.'
'; + } + else { + echo $attendee->fullName.'
'; + } + } + } + return (ob_end_flush()); + } + else { + return (false); + } + } + + /** + *This method returns an array of the attendees in the specified meeting. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param modPW -- the moderator password of the meeting + *@param URL -- the url of the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + * + *@return + * - Null if the server is unreachable. + * - If FAILED, returns an array containing a returncode, messageKey, message. + * - If SUCCESS, returns an array of array containing the userID, fullName, role of each attendee + */ + public static function getUsersArray( $meetingID, $modPW, $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) ); + + if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey == null ) {//The meetings were returned + return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); + } + else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created + foreach ($xml->attendees->attendee as $attendee){ + $users[] = array( 'userID' => $attendee->userID, 'fullName' => $attendee->fullName, 'role' => $attendee->role ); + } + return $users; + } + else if( $xml ) { //If the xml packet returned failure it displays the message to the user + return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); + } + else { //If the server is unreachable, then prompts the user of the necessary action + return null; + } + } + + + //------------------------------------------------Other Methods------------------------------------ + /** + *This method calls end meeting on the specified meeting in the bigbluebuttonbn server. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param modPW -- the moderator password of the meeting + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return + * - Null if the server is unreachable + * - An array containing a returncode, messageKey, message. + */ + public static function endMeeting( $meetingID, $modPW, $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::endMeetingURL( $meetingID, $modPW, $URL, $SALT ) ); + + if( $xml ) { //If the xml packet returned failure it displays the message to the user + return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); + } + else { //If the server is unreachable, then prompts the user of the necessary action + return null; + } + + } + + /** + *This method check the BigBlueButton server to see if the meeting is running (i.e. there is someone in the meeting) + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return A boolean of true if the meeting is running and false if it is not running + */ + public static function isMeetingRunning( $meetingID, $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::isMeetingRunningURL( $meetingID, $URL, $SALT ) ); + if( $xml && $xml->returncode == 'SUCCESS' ) + return ( ( $xml->running == 'true' ) ? true : false); + else + return ( false ); + } + + /** + *This method calls isMeetingRunning on the BigBlueButton server. + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return + * - If SUCCESS it returns an xml packet + * - If the FAILED or the server is unreachable returns a string of 'false' + */ + public static function getMeetingXML( $meetingID, $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::isMeetingRunningURL( $meetingID, $URL, $SALT ) ); + if( $xml && $xml->returncode == 'SUCCESS') + return ( str_replace('
', '', str_replace("\n", '', $xml->asXML()))); + else + return 'false'; + } + + + // TODO: WRITE AN ITERATOR WHICH GOES OVER WHATEVER IT IS BEING TOLD IN THE API AND LIST INFORMATION + /* we have to define at least 2 variable fields for getInformation to read out information at any position + The first is: An identifier to chose if we look for attendees or the meetings or something else + The second is: An identifier to chose what integrated functions are supposed to be used + + @param IDENTIFIER -- needs to be put in for the function to identify the information to print out + current values which can be used are 'attendee' and 'meetings' + @param meetingID -- needs to be put in to identify the meeting + @param modPW -- needs to be put in if the users are supposed to be shown or to retrieve information about the meetings + @param URL -- needs to be put in the URL to the bigbluebuttonbn server + @param SALT -- needs to be put in for the security salt calculation + + Note: If 'meetings' is used, then only the parameters URL and SALT needs to be used + If 'attendee' is used, then all the parameters needs to be used + */ + public static function getInformation( $IDENTIFIER, $meetingID, $modPW, $URL, $SALT ) { + // if the identifier is null or '', then return false + if( $IDENTIFIER == "" || $IDENTIFIER == null ) { + echo "You need to type in a valid value into the identifier."; + return false; + } + // if the identifier is attendee, call getUsers + else if( $IDENTIFIER == 'attendee' ) { + return BigBlueButtonBN::getUsers( $meetingID, $modPW, $URL, $SALT ); + } + // if the identifier is meetings, call getMeetings + else if( $IDENTIFIER == 'meetings' ) { + return BigBlueButtonBN::getMeetings( $URL, $SALT ); + } + // return nothing + else { + return true; + } + + } + + + function getServerIP() { + // get the server url + $sIP = $_SERVER['SERVER_ADDR']; + return $serverIP = 'http://'.$sIP.'/bigbluebuttonbn/'; + } + + + /** + *This method check the BigBlueButton server to see if the meeting has been created + * + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + * + *@return A boolean of true if the meeting has been created, doesn't matter if is running or not and false if it does not exist + */ + public static function isMeetingCreated( $meetingID, $URL, $SALT ) { + + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingsURL( $URL, $SALT ) ); + if( $xml && $xml->returncode == 'SUCCESS' ) + foreach ($xml->meetings->meeting as $meeting) + if ( $meeting->meetingID == $meetingID && $meeting->hasBeenForciblyEnded == 'false' ) + return true; + return false; + + } + + /** + *This method creates a new meeting room in the BigBlueButton server + * + *@param name -- a name fot the meeting + *@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server + *@param attendeePW -- the attendee of the meeting + *@param moderatorPW -- the moderator of the meeting + *@param welcome -- the welcome message that gets displayed on the chat window + *@param logoutURL -- the URL that the bbb client will go to after users logouut + *@param SALT -- the security salt of the bigbluebuttonbn server + *@param URL -- the url of the bigbluebuttonbn server + *@param record -- the flag which indicate if the meetings will be recorded or not record=true|false, default false + * + *@return A boolean of true if the meeting has been created, doesn't matter if is running or not and false if it was an error + */ + + public static function createMeeting($name, $meetingID, $attendeePW, $moderatorPW, $welcome, $logoutURL, $SALT, $URL, $record = 'false', $duration=0, $voiceBridge=0, $metadata = array() ) { + + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::createMeetingURL($name, $meetingID, $attendeePW, $moderatorPW, $welcome, $logoutURL, $SALT, $URL, $record, $duration, $voiceBridge, $metadata ) ); + if( $xml && $xml->returncode == 'SUCCESS' ) + return true; + else + return false; + + } + + +////////////////////////TO DO: CHANGE THE DESCRIPTION OF THE NEW METHODS + + public static function getRecordingsURL($meetingID, $URL, $SALT ) { + $base_url_record = $URL."api/getRecordings?"; + $params = "meetingID=".urlencode($meetingID); + + return ($base_url_record.$params."&checksum=".sha1("getRecordings".$params.$SALT) ); + } + + /** + *This method calls getMeetings on the bigbluebuttonbn server, then calls getMeetingInfo for each meeting and concatenates the result. + * + *@param URL -- the url of the bigbluebuttonbn server + *@param SALT -- the security salt of the bigbluebuttonbn server + * + *@return + * - Null if the server is unreachable + * - If FAILED then returns an array containing a returncode, messageKey, message. + * - If SUCCESS then returns an array of all the meetings. Each element in the array is an array containing a meetingID, + moderatorPW, attendeePW, hasBeenForciblyEnded, running. + */ + public static function getRecordingsArray($meetingID, $URL, $SALT ) { + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getRecordingsURL( $meetingID, $URL, $SALT ) ); + if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey ) {//The meetings were returned + return array('returncode' => (string) $xml->returncode, 'message' => (string) $xml->message, 'messageKey' => (string) $xml->messageKey); + } else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created + $recordings = array(); + + foreach ($xml->recordings->recording as $recording) { + $recordings[(string) $recording->recordID] = array( 'recordID' => (string) $recording->recordID, 'meetingID' => (string) $recording->meetingID, 'meetingName' => (string) $recording->name, 'published' => (string) $recording->published, 'startTime' => (string) $recording->startTime, 'endTime' => (string) $recording->endTime ); + $recordings[(string) $recording->recordID]['playbacks'] = array(); + foreach ( $recording->playback->format as $format ){ + $recordings[(string) $recording->recordID]['playbacks'][(string) $format->type] = array( 'type' => (string) $format->type, 'url' => (string) $format->url ); + } + // THIS IS FOR TESTING MULTIPLE FORMATS, DO REMOVE IT FOR FINAL RELEASE + //$recordings[(string) $recording->recordID]['playbacks']['desktop'] = array( 'type' => 'desktop', 'url' => (string) $recording->playback->format->url ); + + //Add the metadata to the recordings array + $metadata = get_object_vars($recording->metadata); + while ($data = current($metadata)) { + $recordings[(string) $recording->recordID]['meta_'.key($metadata)] = $data; + next($metadata); + } + } + + ksort($recordings); + + return $recordings; + + } else if( $xml ) { //If the xml packet returned failure it displays the message to the user + return array('returncode' => (string) $xml->returncode, 'message' => (string) $xml->message, 'messageKey' => (string) $xml->messageKey); + } else { //If the server is unreachable, then prompts the user of the necessary action + return NULL; + } + } + + + public static function deleteRecordingsURL( $recordID, $URL, $SALT ) { + $url_delete = $URL."api/deleteRecordings?"; + $params = 'recordID='.urlencode($recordID); + return ($url_delete.$params.'&checksum='.sha1("deleteRecordings".$params.$SALT) ); + } + + + public static function deleteRecordings( $recordIDs, $URL, $SALT ) { + + $ids = explode(",", $recordIDs); + foreach( $ids as $id){ + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::deleteRecordingsURL($id, $URL, $SALT) ); + if( $xml && $xml->returncode != 'SUCCESS' ) + return false; + } + return true; + } + + + + public static function setPublishRecordingsURL( $recordID, $set, $URL, $SALT ) { + $url_delete = $URL."api/publishRecordings?"; + $params = 'recordID='.$recordID."&publish=".$set; + return ($url_delete.$params.'&checksum='.sha1("publishRecordings".$params.$SALT) ); + } + + + public static function setPublishRecordings( $recordIDs, $set, $URL, $SALT ) { + + $ids = explode(",", $recordIDs); + foreach( $ids as $id){ + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::setPublishRecordingsURL($id, $set, $URL, $SALT) ); + if( $xml && $xml->returncode != 'SUCCESS' ) + return false; + } + return true; + } + + + + public static function getServerVersion( $URL ){ + $base_url_record = $URL."api"; + + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( $base_url_record ); + if( $xml && $xml->returncode == 'SUCCESS' ) + return $xml->version; + else + return NULL; + + } + + public static function isServerRunning( $URL ){ + $base_url_record = $URL."api"; + + $xml = BigBlueButtonBN::_wrap_simplexml_load_file( $base_url_record ); + if( $xml && $xml->returncode == 'SUCCESS' ) + return true; + else + return false; + + } + + + public function _wrap_simplexml_load_file($url){ + + if (extension_loaded('curl')) { + $ch = curl_init() or die ( curl_error() ); + $timeout = 10; + curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt( $ch, CURLOPT_URL, $url ); + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); + curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout); + $data = curl_exec( $ch ); + curl_close( $ch ); + + if($data) + return (new SimpleXMLElement($data,LIBXML_NOCDATA)); + else + return false; + } + + return (simplexml_load_file($url,'SimpleXMLElement', LIBXML_NOCDATA)); + } + + +} +//----End \ No newline at end of file diff --git a/plugin/bbb/config.php b/plugin/bbb/config.php new file mode 100644 index 0000000000..403b3690d1 --- /dev/null +++ b/plugin/bbb/config.php @@ -0,0 +1,9 @@ +copy_record_to_link_tool($_GET['id'], $_GET['record_id']); + if ($result) { + $message = Display::return_message(get_lang('Copied'), 'success'); + } else { + $message = Display::return_message(get_lang('Error'), 'error'); + } + break; + case 'delete_recording': + //$bbb->delete_record($_GET['id']); + break; + case 'end': + $bbb->end_meeting($_GET['id']); + $message = Display::return_message(get_lang('MeetingClosed'), 'success'); + break; + case 'publish': + //$result = $bbb->publish_meeting($_GET['id']); + break; + case 'unpublish': + //$result = $bbb->unpublish_meeting($_GET['id']); + break; +} + +$meetings = $bbb->get_course_meetings(); +$users_online = $bbb->get_users_online_in_current_room(); + +$tool_name = get_lang('OrganisationSVideoconference'); + +$tpl = new Template($tool_name); + +$tpl->assign('meetings', $meetings); +$conference_url = api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?launch=1&'.api_get_cidreq(); +$tpl->assign('conference_url', $conference_url); +$tpl->assign('users_online', $users_online); + +$tpl->assign('actions', $actions); +$tpl->assign('message', $message); +$listing_tpl = 'bbb/listing.tpl'; +$content = $tpl->fetch($listing_tpl); +$tpl->assign('content', $content); +$tpl->display_one_col_template(); diff --git a/plugin/bbb/listing.tpl b/plugin/bbb/listing.tpl new file mode 100644 index 0000000000..5358d655de --- /dev/null +++ b/plugin/bbb/listing.tpl @@ -0,0 +1,52 @@ +
+ +
+ + {{ 'StartConference'|get_lang }} + + {{ users_online }} user(s) online +
+ +
+ + + +
'.api_htmlentities($parameter_value)."$extra_notice'.api_htmlentities($parameter_value)."'."$extra_notice
@@ -1883,23 +1862,6 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo //Parameter 11: institute (short) name display_configuration_parameter($installType, get_lang('InstituteURL'), 'institutionUrlForm', $institutionUrlForm); - /* - //old method -
: - /> - /> -
:
+ + + + + + +{% for meeting in meetings %} + + + + + + +{% endfor %} +
#{{'Meeting'|get_lang}}{{'Date'|get_lang}}{{'Actions'|get_lang}}
{{ meeting.id }}{{ meeting.meeting_name }}{{ meeting.created_at }} + {% if meeting.record == 1 %} + + {# Record list #} + {{ meeting.show_links }} + + + {% endif %} +
+ + {% if meeting.status == 1 %} + {{'MeetingOpened'|get_lang}} + {{'CloseMeeting'|get_lang}} + {% else %} + {{'MeetingClosed'|get_lang}} + {% endif %} + + +
+ + \ No newline at end of file diff --git a/plugin/bbb/plugin.php b/plugin/bbb/plugin.php old mode 100755 new mode 100644 index beec0ba11a..9a61ed7270 --- a/plugin/bbb/plugin.php +++ b/plugin/bbb/plugin.php @@ -15,6 +15,6 @@ $plugin_info['comment']="Open Source Videoconference tool"; //the locations where this plugin can be shown $plugin_info['location']=array('course_tool_plugin'); //the plugin version -$plugin_info['version']='0.9'; +$plugin_info['version']='1.0'; //the plugin author -$plugin_info['author']='Yannick Warnier'; \ No newline at end of file +$plugin_info['author']='Julio Montoya & Yannick Warnier'; \ No newline at end of file diff --git a/plugin/bbb/start.php b/plugin/bbb/start.php index ff1a61d7fd..35923fd0df 100644 --- a/plugin/bbb/start.php +++ b/plugin/bbb/start.php @@ -8,41 +8,56 @@ */ require_once '../../main/inc/global.inc.php'; require_once 'bbb.lib.php'; -//The script receives the course_code (cidReq), which allows it to get the corresponding data -$cid = api_get_real_course_id(); -$ccode = api_get_course_id(); -// initialize conference settings from course settings -$meeting_name = api_get_course_setting('big_blue_button_meeting_name',$ccode); -if (empty($meeting_name) or $meeting_name==-1) { $meeting_name = $ccode; } -$meeting_att_pw = api_get_course_setting('big_blue_button_meeting_attendee_pw',$ccode); -if (empty($meeting_att_pw) or $meeting_att_pw==-1) { $meeting_att_pw = $ccode; } -$meeting_mod_pw = api_get_course_setting('big_blue_button_meeting_moderator_pw',$ccode); -if (empty($meeting_mod_pw) or $meeting_mod_pw==-1) { $meeting_mod_pw = $ccode.'mod'; } -$meeting_wel_ms = api_get_course_setting('big_blue_button_meeting_welcome_message',$ccode); -if (empty($meeting_wel_ms) or $meeting_wel_ms==-1) { $meeting_wel_ms = ''; } +require_once 'bbb_api.php'; -// initialize video server settings from global settings -$settings = api_get_settings('Extra','list',api_get_current_access_url_id()); -$bbb_settings = array(); -foreach ($settings as $setting) { - if (substr($setting['variable'],0,4)==='bbb_') { - $bbb_settings[$setting['variable']] = $setting['selected_value']; - } +$course_code = api_get_course_id(); + +$meeting_params = array(); +$meeting_params['meeting_name'] = api_get_course_id(); + +$teacher = api_is_course_admin() || api_is_coach() || api_is_platform_admin(); + +//If I'm a teacher I'm going to the listing page +if ($teacher && !isset($_GET['launch'])) { + header('location: listing.php?'.api_get_cidreq()); + exit; } -$bbb_plugin = $bbb_settings['bbb_plugin'] === 'true'; -$bbb_host = $bbb_settings['bbb_plugin_host']; -$bbb_salt = $bbb_settings['bbb_plugin_salt']; -if (!$bbb_plugin) { - //the BigBlueButton plugin is not enabled (strangely), return to course homepage - header('location: '.api_get_path(WEB_COURSE_PATH).'/'.$ccode); +$bbb = new bbb(); + +if ($bbb) { + if ($bbb->is_meeting_exist($meeting_params['meeting_name'])) { + $url = $bbb->join_meeting($meeting_params['meeting_name']); + if ($url) { + header('location: '.$url); + exit; + } else { + $url = $bbb->create_meeting($meeting_params); + header('location: '.$url); + exit; + } + } else { + $url = $bbb->create_meeting($meeting_params); + header('location: '.$url); + exit; + } +} else { + if (api_is_platform_admin()) { + Display::display_warning_message(get_lang('NotConfigured')); + } } + +header('location: '.api_get_path(WEB_COURSE_PATH).'/'.$course_code); +exit; + +/* $teacher = api_is_course_admin() || api_is_coach() || api_is_platform_admin(); $user_info = api_get_user_info(api_get_user_id()); $full_user_name = api_get_person_name($user_info['firstname'],$user_info['lastname']); $user_id = api_get_user_id(); -$is_running = wc_isMeetingRunning($bbb_host,$bbb_salt,$meeting_name); +$is_running = wc_isMeetingRunning($bbb_host, $bbb_salt, $meeting_name); + if ($is_running == 'true') { // The conference is running, everything is fine, join header('location: '.wc_joinMeetingURL($bbb_host,$bbb_salt,$full_user_name,$meeting_name,($teacher?$meeting_mod_pw:$meeting_att_pw),$user_id)); @@ -51,33 +66,41 @@ if ($is_running == 'true') { // The conference room does not seem to be running... // First, try harder and ignore the "running" status $meetings = wc_getRunningMeetings($bbb_host,$bbb_salt); - $found = false; - foreach ($meetings as $meeting) { - //Try to find our meeting room in the list... - if ($meeting['meetingID'] == $meeting_name) { - $meeting_info = wc_getMeetingInfo($bbb_host,$bbb_salt,$meeting_name,$meeting_mod_pw); - error_log('Found passive meeting created '.($meeting_info['createTime']).' seconds ago with '.count($meeting_info['attendees']).' attendees - joining as '.($teacher?'teacher':'student')); - //if the user is a teacher, or if there are already attendees in - // the conference room, then allow joining it - if ($teacher or count($meeting_info['attendees'])>0) { - header('location: '.wc_joinMeetingURL($bbb_host,$bbb_salt,$full_user_name,$meeting_name,($teacher?$meeting_mod_pw:$meeting_att_pw),$user_id)); - exit; + + if (!empty($meetings)) { + foreach ($meetings as $meeting) { + //Try to find our meeting room in the list... + if ($meeting['meetingID'] == $meeting_name) { + $meeting_info = wc_getMeetingInfo($bbb_host,$bbb_salt,$meeting_name,$meeting_mod_pw); + error_log('Found passive meeting created '.($meeting_info['createTime']).' seconds ago with '.count($meeting_info['attendees']).' attendees - joining as '.($teacher?'teacher':'student')); + //if the user is a teacher, or if there are already attendees in + // the conference room, then allow joining it + if ($teacher or count($meeting_info['attendees'])>0) { + header('location: '.wc_joinMeetingURL($bbb_host,$bbb_salt,$full_user_name,$meeting_name,($teacher?$meeting_mod_pw:$meeting_att_pw),$user_id)); + exit; + } } } } - // That conference room is really not running or it has no - // accompanying moderator subscribed + + // That conference room is really not running or it has no accompanying moderator subscribed + //if (1) { + if ($teacher) { // The user is a teacher, so he has the right to create the // room, so create it and join it - wc_createMeeting($bbb_host,$bbb_salt,$meeting_name,$meeting_name,$meeting_att_pw,$meeting_mod_pw,$meeting_wel_ms,api_get_path(WEB_COURSE_PATH).'/'.$ccode); - header('location: '.wc_joinMeetingURL($bbb_host,$bbb_salt,$full_user_name,$meeting_name,($teacher?$meeting_mod_pw:$meeting_att_pw),$user_id)); - exit; - } else { - // There is no conference room for this course and the user - // is a mere student, so he cannot start a conference room by - // himself: a teacher has to launch it first - header('location: '.api_get_path(WEB_COURSE_PATH).'/'.$ccode); - exit; + //var_dump($bbb_host,$bbb_salt,$meeting_name,$meeting_name,$meeting_att_pw,$meeting_mod_pw,$meeting_wel_ms,api_get_path(WEB_COURSE_PATH).'/'.$course_code); + $result = wc_createMeeting($bbb_host, $bbb_salt, $meeting_name, $meeting_name, $meeting_att_pw, $meeting_mod_pw, $meeting_wel_ms, api_get_path(WEB_COURSE_PATH).'/'.$course_code, $record_conference); + if ($result) { + header('location: '.wc_joinMeetingURL($bbb_host,$bbb_salt,$full_user_name,$meeting_name,($teacher?$meeting_mod_pw:$meeting_att_pw),$user_id)); + exit; + } } + // There is no conference room for this course and the user + // is a mere student, so he cannot start a conference room by + // himself: a teacher has to launch it first + + header('location: '.api_get_path(WEB_COURSE_PATH).'/'.$course_code); + exit; } +*/ \ No newline at end of file diff --git a/plugin/bbb/uninstall.php b/plugin/bbb/uninstall.php index 0302c1f64c..39b1cf3c4a 100644 --- a/plugin/bbb/uninstall.php +++ b/plugin/bbb/uninstall.php @@ -8,8 +8,12 @@ /** * Queries */ + +require 'config.php'; + $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS); + $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin'"; Database::query($sql); $sql = "DELETE FROM $t_options WHERE variable = 'bbb_plugin'"; @@ -18,22 +22,21 @@ $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_host'"; Database::query($sql); $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_salt'"; Database::query($sql); -$sql = "DROP TABLE IF EXISTS plugin_bbb"; +$sql = "DROP TABLE IF EXISTS plugin_bbb_meeting"; Database::query($sql); // update existing courses to add conference settings $t_courses = Database::get_main_table(TABLE_MAIN_COURSE); -$sql = "SELECT id, code, db_name FROM $t_courses ORDER BY id"; +$sql = "SELECT id, code FROM $t_courses ORDER BY id"; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { $t_course = Database::get_course_table(TABLE_COURSE_SETTING); - $sql_course = "DELETE FROM $t_course WHERE c_id = ".$row['id']." AND variable = 'big_blue_button_meeting_name'"; - $r = Database::query($sql_course); - $sql_course = "DELETE FROM $t_course WHERE c_id = ".$row['id']." AND variable = 'big_blue_button_attendee_password'"; - $r = Database::query($sql_course); - $sql_course = "DELETE FROM $t_course WHERE c_id = ".$row['id']." AND variable = 'big_blue_button_moderator_password'"; - $r = Database::query($sql_course); - $sql_course = "DELETE FROM $t_course WHERE c_id = ".$row['id']." AND variable = 'big_blue_button_welcome_message'"; - $r = Database::query($sql_course); + + foreach ($variables as $variable) { + $sql_course = "DELETE FROM $t_course WHERE c_id = ".$row['id']." AND variable = '$variable'"; + $r = Database::query($sql_course); + } + + $t_tool = Database::get_course_table(TABLE_TOOL_LIST); $sql_course = "DELETE FROM $t_tool WHERE c_id = ".$row['id']." AND link = '../../plugin/bbb/start.php'"; $r = Database::query($sql_course); diff --git a/plugin/share_buttons/plugin.php b/plugin/share_buttons/plugin.php old mode 100644 new mode 100755 index 1d12705ebf..7fb406420f --- a/plugin/share_buttons/plugin.php +++ b/plugin/share_buttons/plugin.php @@ -1,14 +1,11 @@ Plugins) + * This script is a configuration file for the add_this plugin. + * These settings will be used in the administration interface for plugins + * (Chamilo configuration settings->Plugins) * @package chamilo.plugin * @author Julio Montoya */ -/** - * Plugin details (must be present) - */ - /* Plugin config */ //the plugin title @@ -19,6 +16,5 @@ $plugin_info['comment'] = "Show social icons to share a page using addthis.c $plugin_info['version'] = '1.0'; //the plugin author $plugin_info['author'] = 'Julio Montoya'; - //For bigger icons change this value to addthis_32x32_style $plugin_info['icon_class'] = ''; diff --git a/tests/main/announcements/announcements.inc.test.php b/tests/main/announcements/announcements.inc.test.php index c3a5d4a78f..c1faa7ec86 100755 --- a/tests/main/announcements/announcements.inc.test.php +++ b/tests/main/announcements/announcements.inc.test.php @@ -13,7 +13,7 @@ class TestAnnouncements extends UnitTestCase { } /*public function Testdisplay_announcement(){ global $_user, $dateFormatLong, $_course; - global $defaultVisibilityForANewCourse, $error_msg; + global $error_msg; ob_start(); //create course $courseSysCode= '142'; diff --git a/tests/main/inc/lib/sortabletable.class.test.php b/tests/main/inc/lib/sortable_table.class.test.php similarity index 97% rename from tests/main/inc/lib/sortabletable.class.test.php rename to tests/main/inc/lib/sortable_table.class.test.php index 9c6ec2507e..f89a01f568 100755 --- a/tests/main/inc/lib/sortabletable.class.test.php +++ b/tests/main/inc/lib/sortable_table.class.test.php @@ -1,11 +1,11 @@ UnitTestCase('Sortabletable library - main/inc/lib/sortabletable.class.test.php'); + $this->UnitTestCase('Sortabletable library - main/inc/lib/sortable_table.class.test.php'); } function testdisplay() {