From 5f79f57ca2f2011c7da08dc89048b11b302c7031 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 13 Aug 2020 12:55:20 +0200 Subject: [PATCH] Internal: Update from 1.11.x --- public/main/inc/lib/plugin.class.php | 60 +- public/main/inc/lib/social.lib.php | 49 + public/main/inc/lib/tracking.lib.php | 45 +- .../plugin/azure_active_directory/README.md | 11 +- .../plugin/azure_active_directory/index.php | 5 +- .../plugin/azure_active_directory/install.php | 1 - .../azure_active_directory/lang/dutch.php | 10 + .../azure_active_directory/lang/english.php | 1 + .../layout/login_form.tpl | 9 +- .../plugin/azure_active_directory/login.php | 3 +- .../plugin/azure_active_directory/plugin.php | 3 +- .../src/AzureActiveDirectory.php | 9 +- .../azure_active_directory/src/callback.php | 78 +- .../azure_active_directory/view/login.tpl | 11 +- public/plugin/bbb/listing.php | 2 +- public/plugin/customcertificate/config.php | 3 +- public/plugin/customcertificate/database.php | 5 +- public/plugin/customcertificate/index.php | 1 - public/plugin/customcertificate/install.php | 3 +- .../plugin/customcertificate/lang/english.php | 146 +- .../plugin/customcertificate/lang/spanish.php | 148 +- public/plugin/customcertificate/plugin.php | 3 +- .../src/CustomCertificatePlugin.php | 21 +- .../src/customcertificate.ajax.php | 7 +- .../src/export_pdf_all_in_one.php | 708 +++++++++ public/plugin/customcertificate/src/index.php | 93 +- .../src/print_certificate.php | 244 +-- public/plugin/customcertificate/start.php | 4 +- public/plugin/customcertificate/uninstall.php | 3 +- public/plugin/customcertificate/update.php | 3 +- public/plugin/pausetraining/PauseTraining.php | 274 +++- public/plugin/pausetraining/cron.php | 1 + public/plugin/pausetraining/cronTest.php | 7 + public/plugin/pausetraining/lang/english.php | 5 +- public/plugin/pausetraining/lang/french.php | 5 +- public/plugin/zoom/Entity/Meeting.php | 608 +++++++ public/plugin/zoom/Entity/MeetingActivity.php | 208 +++ public/plugin/zoom/Entity/Recording.php | 193 +++ public/plugin/zoom/Entity/Registrant.php | 265 ++++ public/plugin/zoom/README.code.md | 70 + public/plugin/zoom/README.md | 37 + public/plugin/zoom/activity.php | 55 + public/plugin/zoom/config.php | 5 + public/plugin/zoom/endpoint.php | 151 ++ public/plugin/zoom/global.php | 13 + public/plugin/zoom/index.php | 1 + public/plugin/zoom/install.php | 8 + public/plugin/zoom/join_meeting.php | 65 + public/plugin/zoom/lang/english.php | 144 ++ public/plugin/zoom/lang/french.php | 138 ++ public/plugin/zoom/lang/spanish.php | 138 ++ .../plugin/zoom/lib/API/BaseMeetingTrait.php | 32 + public/plugin/zoom/lib/API/Client.php | 56 + .../zoom/lib/API/CreatedRegistration.php | 42 + public/plugin/zoom/lib/API/CustomQuestion.php | 18 + .../zoom/lib/API/GlobalDialInNumber.php | 39 + public/plugin/zoom/lib/API/JWTClient.php | 94 ++ .../zoom/lib/API/JsonDeserializableTrait.php | 122 ++ public/plugin/zoom/lib/API/Meeting.php | 84 + public/plugin/zoom/lib/API/MeetingInfo.php | 34 + public/plugin/zoom/lib/API/MeetingInfoGet.php | 148 ++ .../plugin/zoom/lib/API/MeetingInstance.php | 50 + .../plugin/zoom/lib/API/MeetingInstances.php | 53 + public/plugin/zoom/lib/API/MeetingList.php | 58 + .../plugin/zoom/lib/API/MeetingListItem.php | 44 + .../plugin/zoom/lib/API/MeetingRegistrant.php | 105 ++ .../zoom/lib/API/MeetingRegistrantList.php | 53 + .../lib/API/MeetingRegistrantListItem.php | 29 + .../plugin/zoom/lib/API/MeetingSettings.php | 143 ++ public/plugin/zoom/lib/API/Pagination.php | 68 + .../plugin/zoom/lib/API/PaginationToken.php | 71 + .../plugin/zoom/lib/API/ParticipantList.php | 57 + .../zoom/lib/API/ParticipantListItem.php | 22 + public/plugin/zoom/lib/API/PastMeeting.php | 74 + public/plugin/zoom/lib/API/RecordingFile.php | 115 ++ public/plugin/zoom/lib/API/RecordingList.php | 65 + .../plugin/zoom/lib/API/RecordingMeeting.php | 95 ++ public/plugin/zoom/lib/API/TrackingField.php | 29 + public/plugin/zoom/lib/MeetingRepository.php | 204 +++ .../plugin/zoom/lib/RecordingRepository.php | 65 + .../plugin/zoom/lib/RegistrantRepository.php | 33 + public/plugin/zoom/lib/ZoomPlugin.php | 1400 +++++++++++++++++ public/plugin/zoom/meeting.php | 94 ++ public/plugin/zoom/meetings.php | 28 + public/plugin/zoom/plugin.php | 4 + public/plugin/zoom/start.php | 118 ++ public/plugin/zoom/uninstall.php | 8 + public/plugin/zoom/view/activity.tpl | 57 + public/plugin/zoom/view/meeting.tpl | 116 ++ public/plugin/zoom/view/meetings.tpl | 62 + public/plugin/zoom/view/start.tpl | 56 + 91 files changed, 7704 insertions(+), 421 deletions(-) create mode 100644 public/plugin/azure_active_directory/lang/dutch.php create mode 100644 public/plugin/customcertificate/src/export_pdf_all_in_one.php create mode 100644 public/plugin/pausetraining/cronTest.php create mode 100644 public/plugin/zoom/Entity/Meeting.php create mode 100644 public/plugin/zoom/Entity/MeetingActivity.php create mode 100644 public/plugin/zoom/Entity/Recording.php create mode 100644 public/plugin/zoom/Entity/Registrant.php create mode 100644 public/plugin/zoom/README.code.md create mode 100644 public/plugin/zoom/README.md create mode 100644 public/plugin/zoom/activity.php create mode 100644 public/plugin/zoom/config.php create mode 100644 public/plugin/zoom/endpoint.php create mode 100644 public/plugin/zoom/global.php create mode 100644 public/plugin/zoom/index.php create mode 100644 public/plugin/zoom/install.php create mode 100644 public/plugin/zoom/join_meeting.php create mode 100644 public/plugin/zoom/lang/english.php create mode 100644 public/plugin/zoom/lang/french.php create mode 100644 public/plugin/zoom/lang/spanish.php create mode 100644 public/plugin/zoom/lib/API/BaseMeetingTrait.php create mode 100644 public/plugin/zoom/lib/API/Client.php create mode 100644 public/plugin/zoom/lib/API/CreatedRegistration.php create mode 100644 public/plugin/zoom/lib/API/CustomQuestion.php create mode 100644 public/plugin/zoom/lib/API/GlobalDialInNumber.php create mode 100644 public/plugin/zoom/lib/API/JWTClient.php create mode 100644 public/plugin/zoom/lib/API/JsonDeserializableTrait.php create mode 100644 public/plugin/zoom/lib/API/Meeting.php create mode 100644 public/plugin/zoom/lib/API/MeetingInfo.php create mode 100644 public/plugin/zoom/lib/API/MeetingInfoGet.php create mode 100644 public/plugin/zoom/lib/API/MeetingInstance.php create mode 100644 public/plugin/zoom/lib/API/MeetingInstances.php create mode 100644 public/plugin/zoom/lib/API/MeetingList.php create mode 100644 public/plugin/zoom/lib/API/MeetingListItem.php create mode 100644 public/plugin/zoom/lib/API/MeetingRegistrant.php create mode 100644 public/plugin/zoom/lib/API/MeetingRegistrantList.php create mode 100644 public/plugin/zoom/lib/API/MeetingRegistrantListItem.php create mode 100644 public/plugin/zoom/lib/API/MeetingSettings.php create mode 100644 public/plugin/zoom/lib/API/Pagination.php create mode 100644 public/plugin/zoom/lib/API/PaginationToken.php create mode 100644 public/plugin/zoom/lib/API/ParticipantList.php create mode 100644 public/plugin/zoom/lib/API/ParticipantListItem.php create mode 100644 public/plugin/zoom/lib/API/PastMeeting.php create mode 100644 public/plugin/zoom/lib/API/RecordingFile.php create mode 100644 public/plugin/zoom/lib/API/RecordingList.php create mode 100644 public/plugin/zoom/lib/API/RecordingMeeting.php create mode 100644 public/plugin/zoom/lib/API/TrackingField.php create mode 100644 public/plugin/zoom/lib/MeetingRepository.php create mode 100644 public/plugin/zoom/lib/RecordingRepository.php create mode 100644 public/plugin/zoom/lib/RegistrantRepository.php create mode 100644 public/plugin/zoom/lib/ZoomPlugin.php create mode 100644 public/plugin/zoom/meeting.php create mode 100644 public/plugin/zoom/meetings.php create mode 100644 public/plugin/zoom/plugin.php create mode 100644 public/plugin/zoom/start.php create mode 100644 public/plugin/zoom/uninstall.php create mode 100644 public/plugin/zoom/view/activity.tpl create mode 100644 public/plugin/zoom/view/meeting.tpl create mode 100644 public/plugin/zoom/view/meetings.tpl create mode 100644 public/plugin/zoom/view/start.tpl diff --git a/public/main/inc/lib/plugin.class.php b/public/main/inc/lib/plugin.class.php index f8cbce7ae2..995ab032f8 100644 --- a/public/main/inc/lib/plugin.class.php +++ b/public/main/inc/lib/plugin.class.php @@ -275,6 +275,7 @@ class Plugin $selectedValue = 'checked'; } } + $element = $result->createElement( $type, $name, @@ -294,6 +295,21 @@ class Plugin $attributes ); break; + case 'user': + $options = []; + if (!empty($value)) { + $userInfo = api_get_user_info($value); + if ($userInfo) { + $options[$value] = $userInfo['complete_name']; + } + } + $result->addSelectAjax( + $name, + [$this->get_lang($name), $help], + $options, + ['url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_like'] + ); + break; } } @@ -301,7 +317,7 @@ class Plugin $result->addGroup( $checkboxGroup, null, - [$this->get_lang('sms_types'), $help] + ['', $help] ); } $result->setDefaults($defaults); @@ -459,7 +475,7 @@ class Plugin * * @return bool|null False on error, null otherwise */ - public function install_course_fields($courseId, $add_tool_link = true) + public function install_course_fields($courseId, $add_tool_link = true, $iconName = '') { $plugin_name = $this->get_name(); $t_course = Database::get_course_table(TABLE_COURSE_SETTING); @@ -478,6 +494,11 @@ class Plugin $value = $setting['init_value']; } + $pluginGlobalValue = api_get_plugin_setting($plugin_name, $variable); + if (null !== $pluginGlobalValue) { + $value = 1; + } + $type = 'textfield'; if (isset($setting['type'])) { $type = $setting['type']; @@ -531,7 +552,7 @@ class Plugin } // Add an icon in the table tool list - $this->createLinkToCourseTool($plugin_name, $courseId); + $this->createLinkToCourseTool($plugin_name, $courseId, $iconName); } /** @@ -585,14 +606,14 @@ class Plugin * * @param bool $add_tool_link Whether we want to add a plugin link on the course homepage */ - public function install_course_fields_in_all_courses($add_tool_link = true) + public function install_course_fields_in_all_courses($add_tool_link = true, $iconName = '') { // Update existing courses to add plugin settings $table = Database::get_main_table(TABLE_MAIN_COURSE); $sql = "SELECT id FROM $table ORDER BY id"; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { - $this->install_course_fields($row['id'], $add_tool_link); + $this->install_course_fields($row['id'], $add_tool_link, $iconName); } } @@ -619,6 +640,10 @@ class Plugin $settings = []; if (is_array($this->course_settings)) { foreach ($this->course_settings as $item) { + // Skip html type + if ('html' === $item['type']) { + continue; + } if (isset($item['group'])) { if (!in_array($item['group'], $settings)) { $settings[] = $item['group']; @@ -846,9 +871,11 @@ class Plugin /** * Returns true if the plugin is installed, false otherwise. * + * @param bool $checkEnabled Also check if enabled (instead of only installed) + * * @return bool True if plugin is installed/enabled, false otherwise */ - public function isEnabled() + public function isEnabled($checkEnabled = false) { $settings = api_get_settings_params_simple( [ @@ -859,7 +886,26 @@ class Plugin ], ] ); - if (is_array($settings) && isset($settings['selected_value']) && 'installed' == $settings['selected_value']) { + if (is_array($settings) && isset($settings['selected_value']) && $settings['selected_value'] == 'installed') { + // The plugin is installed + // If we need a check on whether it is enabled, also check for + // *plugin*_tool_enable and make sure it is *NOT* false + if ($checkEnabled) { + $enabled = api_get_settings_params_simple( + [ + "variable = ? AND subkey = ? AND category = 'Plugins' " => [ + $this->get_name().'_tool_enable', + $this->get_name(), + ], + ] + ); + if (is_array($enabled) && isset($enabled['selected_value']) && $enabled['selected_value'] == 'false') { + // Only return false if the setting exists and it is + // *specifically* set to false + return false; + } + } + return true; } diff --git a/public/main/inc/lib/social.lib.php b/public/main/inc/lib/social.lib.php index 65cbb875af..3627d12030 100644 --- a/public/main/inc/lib/social.lib.php +++ b/public/main/inc/lib/social.lib.php @@ -3111,6 +3111,55 @@ class SocialManager extends UserManager return $social_group_block; } + /** + * @param string $selected + * + * @return string + */ + public static function getHomeProfileTabs($selected = 'home') + { + $headers = [ + [ + 'url' => api_get_path(WEB_CODE_PATH).'auth/profile.php', + 'content' => get_lang('Profile'), + ], + ]; + $allowJustification = api_get_plugin_setting('justification', 'tool_enable') === 'true'; + if ($allowJustification) { + $plugin = Justification::create(); + $headers[] = [ + 'url' => api_get_path(WEB_CODE_PATH).'auth/justification.php', + 'content' => $plugin->get_lang('Justification'), + ]; + } + + $allowPauseTraining = api_get_plugin_setting('pausetraining', 'tool_enable') === 'true'; + $allowEdit = api_get_plugin_setting('pausetraining', 'allow_users_to_edit_pause_formation') === 'true'; + if ($allowPauseTraining && $allowEdit) { + $plugin = PauseTraining::create(); + $headers[] = [ + 'url' => api_get_path(WEB_CODE_PATH).'auth/pausetraining.php', + 'content' => $plugin->get_lang('PauseTraining'), + ]; + } + + $selectedItem = 1; + foreach ($headers as $header) { + $info = pathinfo($header['url']); + if ($selected === $info['filename']) { + break; + } + $selectedItem++; + } + + $tabs = ''; + if (count($headers) > 1) { + $tabs = Display::tabsOnlyLink($headers, $selectedItem); + } + + return $tabs; + } + /** * Returns the formatted header message post. * diff --git a/public/main/inc/lib/tracking.lib.php b/public/main/inc/lib/tracking.lib.php index 93470c0922..1c522f26c4 100644 --- a/public/main/inc/lib/tracking.lib.php +++ b/public/main/inc/lib/tracking.lib.php @@ -2112,6 +2112,34 @@ class Tracking return false; } + /** + * Get last course access by course/session. + */ + public static function getLastConnectionDateByCourse($courseId, $sessionId = 0) + { + $courseId = (int) $courseId; + $sessionId = (int) $sessionId; + $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); + + $sql = "SELECT logout_course_date + FROM $table + WHERE + c_id = $courseId AND + session_id = $sessionId + ORDER BY logout_course_date DESC + LIMIT 0,1"; + + $result = Database::query($sql); + if (Database::num_rows($result)) { + $row = Database::fetch_array($result); + if ($row) { + return $row['logout_course_date']; + } + } + + return ''; + } + /** * Get count of the connections to the course during a specified period. * @@ -4452,9 +4480,24 @@ class Tracking } $rs = Database::query($sql); + + $allow = api_get_plugin_setting('pausetraining', 'tool_enable') === 'true'; + $allowPauseFormation = api_get_plugin_setting('pausetraining', 'allow_users_to_edit_pause_formation') === 'true'; + + $extraFieldValue = new ExtraFieldValue('user'); $users = []; while ($user = Database::fetch_array($rs)) { - $users[] = $user['user_id']; + $userId = $user['user_id']; + + if ($allow && $allowPauseFormation) { + $pause = $extraFieldValue->get_values_by_handler_and_field_variable($userId, 'pause_formation'); + if (!empty($pause) && isset($pause['value']) && 1 == $pause['value']) { + // Skip user because he paused his formation. + continue; + } + } + + $users[] = $userId; } return $users; diff --git a/public/plugin/azure_active_directory/README.md b/public/plugin/azure_active_directory/README.md index d91db27bd2..39f2426f6c 100644 --- a/public/plugin/azure_active_directory/README.md +++ b/public/plugin/azure_active_directory/README.md @@ -1,6 +1,10 @@ # The Azure Active Directory Plugin Allow authentication (with OAuth2) with Microsoft's Azure Active Directory. +This plugin add two extra fields for users: +- `organisationemail`, the email registered in Azure Active Directory for each user. +- `azure_id`, to save the internal ID for each user in Azure. + > This plugin use the [`thenetworg/oauth2-azure`](https://github.com/TheNetworg/oauth2-azure) package. ### To configure Azure Active Directory @@ -17,5 +21,10 @@ Allow authentication (with OAuth2) with Microsoft's Azure Active Directory. * _Management login_: (Optional) Disable the chamilo login and enable an alternative login page for users. You will need copy the `/plugin/azure_active_directory/layout/login_form.tpl` file to `/main/template/overrides/layout/` directory. * _Name for the management login_: A name for the management login. By default is "Management Login". +* And assign a region. Preferably `login_bottom`. -And assign a region. Preferably `login_bottom`. +Also, you can configure the external login to work with the classic Chamilo form login. +Adding this line in `configuration.php` file. +```php +$extAuthSource["azure"]["login"] = $_configuration['root_sys']."main/auth/external_login/login.azure.php"; +``` diff --git a/public/plugin/azure_active_directory/index.php b/public/plugin/azure_active_directory/index.php index 4777d3a543..2f9183f341 100644 --- a/public/plugin/azure_active_directory/index.php +++ b/public/plugin/azure_active_directory/index.php @@ -1,14 +1,15 @@ + * + * @package chamilo.plugin.azure_active_directory */ /** @var AzureActiveDirectory $activeDirectoryPlugin */ $activeDirectoryPlugin = AzureActiveDirectory::create(); -if ('true' === $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_ENABLE)) { +if ($activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_ENABLE) === 'true') { $_template['block_title'] = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_BLOCK_NAME); $_template['signin_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_AUTHORIZE); diff --git a/public/plugin/azure_active_directory/install.php b/public/plugin/azure_active_directory/install.php index 14929c0f76..d1e7fac719 100644 --- a/public/plugin/azure_active_directory/install.php +++ b/public/plugin/azure_active_directory/install.php @@ -1,5 +1,4 @@ + * + * @package chamilo.plugin.azure_active_directory + */ +$strings['InvalidId'] = 'Deze identificatie is niet geldig (verkeerde log-in of wachtwoord). Errocode: AZMNF'; diff --git a/public/plugin/azure_active_directory/lang/english.php b/public/plugin/azure_active_directory/lang/english.php index 2a3f36798a..2e4f4f7e29 100644 --- a/public/plugin/azure_active_directory/lang/english.php +++ b/public/plugin/azure_active_directory/lang/english.php @@ -24,3 +24,4 @@ $strings['management_login_name_help'] = 'By default is "Management Login".'; $strings['OrganisationEmail'] = 'Organisation e-mail'; $strings['AzureId'] = 'Azure ID (mailNickname)'; $strings['ManagementLogin'] = 'Management Login'; +$strings['InvalidId'] = 'Login failed - incorrect login or password. Errocode: AZMNF'; diff --git a/public/plugin/azure_active_directory/layout/login_form.tpl b/public/plugin/azure_active_directory/layout/login_form.tpl index bed575acaf..a8506afe5b 100644 --- a/public/plugin/azure_active_directory/layout/login_form.tpl +++ b/public/plugin/azure_active_directory/layout/login_form.tpl @@ -24,8 +24,15 @@ {% endif %} {% if "allow_lostpassword"|api_get_setting == 'true' %} + {% set pass_reminder_link = 'pass_reminder_custom_link'|api_get_configuration_value %} + {% set lost_password_link = _p.web_main ~ 'auth/lostPassword.php' %} + + {% if not pass_reminder_link is empty %} + {% set lost_password_link = pass_reminder_link %} + {% endif %} +
  • - {{ 'LostPassword'|get_lang }} + {{ 'LostPassword' | get_lang }}
  • {% endif %} diff --git a/public/plugin/azure_active_directory/login.php b/public/plugin/azure_active_directory/login.php index d9653a0138..a6f790f4bb 100644 --- a/public/plugin/azure_active_directory/login.php +++ b/public/plugin/azure_active_directory/login.php @@ -1,5 +1,4 @@ get(AzureActiveDirectory::SETTING_MANAGEMENT_LOGIN_NAME); if (empty($managementLoginName)) { diff --git a/public/plugin/azure_active_directory/plugin.php b/public/plugin/azure_active_directory/plugin.php index 75d5c9b504..c9f699a730 100644 --- a/public/plugin/azure_active_directory/plugin.php +++ b/public/plugin/azure_active_directory/plugin.php @@ -1,8 +1,9 @@ + * + * @package chamilo.plugin.azure_active_directory */ $plugin_info = AzureActiveDirectory::create()->get_info(); diff --git a/public/plugin/azure_active_directory/src/AzureActiveDirectory.php b/public/plugin/azure_active_directory/src/AzureActiveDirectory.php index cb8c01a0fe..c942cc9022 100644 --- a/public/plugin/azure_active_directory/src/AzureActiveDirectory.php +++ b/public/plugin/azure_active_directory/src/AzureActiveDirectory.php @@ -1,5 +1,4 @@ + * + * @package chamilo.plugin.azure_active_directory */ class AzureActiveDirectory extends Plugin { @@ -54,7 +55,7 @@ class AzureActiveDirectory extends Plugin { static $result = null; - return $result ?: $result = new self(); + return $result ? $result : $result = new self(); } /** @@ -70,11 +71,13 @@ class AzureActiveDirectory extends Plugin */ public function getProvider() { - return new Azure([ + $provider = new Azure([ 'clientId' => $this->get(self::SETTING_APP_ID), 'clientSecret' => $this->get(self::SETTING_APP_SECRET), 'redirectUri' => api_get_path(WEB_PLUGIN_PATH).'azure_active_directory/src/callback.php', ]); + + return $provider; } /** diff --git a/public/plugin/azure_active_directory/src/callback.php b/public/plugin/azure_active_directory/src/callback.php index 1c58edf76c..4a382f49ca 100644 --- a/public/plugin/azure_active_directory/src/callback.php +++ b/public/plugin/azure_active_directory/src/callback.php @@ -1,5 +1,4 @@ get('me', $token); -} catch (Exception $e) { - exit; -} -$userInfo = []; + if (empty($me)) { + throw new Exception('Token not found.'); + } -if (!empty($me['email'])) { - $userInfo = api_get_user_info_from_email($me['email']); -} + if (empty($me['mail']) || empty($me['mailNickname'])) { + throw new Exception('Mail empty'); + } -if (empty($userInfo) && !empty($me['email'])) { $extraFieldValue = new ExtraFieldValue('user'); - $itemValue = $extraFieldValue->get_item_id_from_field_variable_and_field_value( - 'organisationemail', - $me['email'] + $organisationValue = $extraFieldValue->get_item_id_from_field_variable_and_field_value( + AzureActiveDirectory::EXTRA_FIELD_ORGANISATION_EMAIL, + $me['mail'] ); - - $userInfo = api_get_user_info($itemValue['item_id']); -} - -if (empty($userInfo) && !empty($me['mailNickname'])) { - $extraFieldValue = new ExtraFieldValue('user'); - $itemValue = $extraFieldValue->get_item_id_from_field_variable_and_field_value( - 'azure_id', + $azureValue = $extraFieldValue->get_item_id_from_field_variable_and_field_value( + AzureActiveDirectory::EXTRA_FIELD_AZURE_ID, $me['mailNickname'] ); - $userInfo = api_get_user_info($itemValue['item_id']); -} + $userId = null; + // Check EXTRA_FIELD_ORGANISATION_EMAIL + if (!empty($organisationValue) && isset($organisationValue['item_id'])) { + $userId = $organisationValue['item_id']; + } + + if (empty($userId)) { + // Check EXTRA_FIELD_AZURE_ID + if (!empty($azureValue) && isset($azureValue['item_id'])) { + $userId = $azureValue['item_id']; + } + } + + /*$emptyValues = empty($organisationValue['item_id']) || empty($azureValue['item_id']); + $differentValues = !$emptyValues && $organisationValue['item_id'] != $azureValue['item_id']; + + if ($emptyValues || $differentValues) { + throw new Exception('Empty values'); + }*/ + + if (empty($userId)) { + throw new Exception('User not found when checking the extra fields.'); + } + + $userInfo = api_get_user_info($userId); + + if (empty($userInfo)) { + throw new Exception('User not found'); + } + + if ($userInfo['active'] != '1') { + throw new Exception('account_inactive'); + } +} catch (Exception $exception) { + $message = Display::return_message($plugin->get_lang('InvalidId'), 'error'); -if (empty($userInfo)) { - header('Location: '.api_get_path(WEB_PATH).'index.php?loginFailed=1&error=user_password_incorrect'); + if ($exception->getMessage() === 'account_inactive') { + $message = Display::return_message(get_lang('AccountInactive'), 'error'); + } + Display::addFlash($message); + header('Location: '.api_get_path(WEB_PATH)); exit; } @@ -77,5 +104,4 @@ $_user['uidReset'] = true; ChamiloSession::write('_user', $_user); ChamiloSession::write('_user_auth_source', 'azure_active_directory'); -header('Location: '.api_get_path(WEB_PATH)); -exit; +Redirect::session_request_uri(true, $userInfo['user_id']); diff --git a/public/plugin/azure_active_directory/view/login.tpl b/public/plugin/azure_active_directory/view/login.tpl index fc86f27e20..89810414a6 100644 --- a/public/plugin/azure_active_directory/view/login.tpl +++ b/public/plugin/azure_active_directory/view/login.tpl @@ -10,8 +10,15 @@
  • {{ 'SignUp'|get_lang }}
  • {% endif %} - {% if "allow_lostpassword"|api_get_setting == 'true' %} -
  • {{ 'LostPassword'|get_lang }}
  • + {% if "allow_lostpassword" | api_get_setting == 'true' %} + {% set pass_reminder_link = 'pass_reminder_custom_link'|api_get_configuration_value %} + {% set lost_password_link = _p.web_main ~ 'auth/lostPassword.php' %} + + {% if not pass_reminder_link is empty %} + {% set lost_password_link = pass_reminder_link %} + {% endif %} + +
  • {{ 'LostPassword' | get_lang }}
  • {% endif %} {% endif %} diff --git a/public/plugin/bbb/listing.php b/public/plugin/bbb/listing.php index d47f7bd0e2..ccf7c64573 100644 --- a/public/plugin/bbb/listing.php +++ b/public/plugin/bbb/listing.php @@ -353,7 +353,7 @@ if ($bbb->isGlobalConference() === false && ) { $url = api_get_self().'?'.api_get_cidreq(true, false).'&gidReq='; $htmlHeadXtra[] = ''; + +$tool_name = $plugin->get_lang('ZoomVideoConferences'); +$tpl = new Template($tool_name); + +$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; + +$isManager = $plugin->userIsCourseConferenceManager(); +if ($isManager) { + $groupId = api_get_group_id(); + $groups = GroupManager::get_groups(); + if (!empty($groups)) { + $form = new FormValidator('group_filter'); + $groupList[0] = get_lang('Select'); + foreach ($groups as $groupData) { + $itemGroupId = $groupData['iid']; + /*if (isset($meetingsGroup[$itemGroupId]) && $meetingsGroup[$itemGroupId] == 1) { + $groupData['name'] .= ' ('.get_lang('Active').')'; + }*/ + $groupList[$itemGroupId] = $groupData['name']; + } + $form->addSelect('group_id', get_lang('Groups'), $groupList, ['id' => 'group_select']); + $form->setDefaults(['group_id' => $groupId]); + $formToString = $form->returnForm(); + + $tpl->assign('group_form', $formToString); + } + + switch ($action) { + case 'delete': + $meeting = $plugin->getMeetingRepository()->findOneBy(['meetingId' => $_REQUEST['meetingId']]); + if ($meeting && $meeting->isCourseMeeting()) { + $plugin->deleteMeeting($meeting, api_get_self().'?'.api_get_cidreq()); + } + break; + } + + $user = api_get_user_entity(api_get_user_id()); + + $tpl->assign( + 'instant_meeting_form', + $plugin->getCreateInstantMeetingForm( + $user, + $course, + $group, + $session + )->returnForm() + ); + $tpl->assign( + 'schedule_meeting_form', + $plugin->getScheduleMeetingForm( + $user, + $course, + $group, + $session + )->returnForm() + ); +} + +try { + $tpl->assign( + 'meetings', + $plugin->getMeetingRepository()->courseMeetings($course, $group, $session) + ); +} catch (Exception $exception) { + Display::addFlash( + Display::return_message('Could not retrieve scheduled meeting list: '.$exception->getMessage(), 'error') + ); +} + +$tpl->assign('is_manager', $isManager); +$tpl->assign('content', $tpl->fetch('zoom/view/start.tpl')); +$tpl->display_one_col_template(); diff --git a/public/plugin/zoom/uninstall.php b/public/plugin/zoom/uninstall.php new file mode 100644 index 0000000000..d6ef421e77 --- /dev/null +++ b/public/plugin/zoom/uninstall.php @@ -0,0 +1,8 @@ +uninstall(); diff --git a/public/plugin/zoom/view/activity.tpl b/public/plugin/zoom/view/activity.tpl new file mode 100644 index 0000000000..494f2e25a8 --- /dev/null +++ b/public/plugin/zoom/view/activity.tpl @@ -0,0 +1,57 @@ +

    + {{ meeting.typeName }} {{ meeting.meetingId }} +

    + + + {{ 'Edit'|get_lang }} + + + + + + + +{# #} + + + + + + {% for activity in meeting.activities %} + + + + +{# #} + + + {% endfor %} + +
    {{ 'Type'|get_lang }}{{ 'Action'|get_plugin_lang('ZoomPlugin') }}{{ 'User'|get_lang }}{{ 'Date'|get_lang }}{{ 'Details'|get_lang }}
    + {{ activity.type }} + + {{ activity.name }} + + {{ activity.createdAt | api_convert_and_format_date(3)}} + #} +{# {% if _u.is_admin %}#} +{# #} +{# {{ activity.user.firstname }} {{ activity.user.lastname }} ({{ activity.user.username }})#} +{# #} +{# {% else %}#} +{# {{ activity.user.firstname }} {{ activity.user.lastname }} ({{ activity.user.username }})#} +{# {% endif %}#} +{# + {% if activity.eventDecoded.registrant %} + {{ 'User' | get_lang }} : + {{ activity.eventDecoded.registrant.first_name }} - + {{ activity.eventDecoded.registrant.last_name }} - + {{ activity.eventDecoded.registrant.email }} - + {{ activity.eventDecoded.registrant.status }} + {% endif %} + + {% if activity.eventDecoded.participant %} + {{ 'User' | get_lang }} : + {{ activity.eventDecoded.participant.user_name }} + {% endif %} +
    \ No newline at end of file diff --git a/public/plugin/zoom/view/meeting.tpl b/public/plugin/zoom/view/meeting.tpl new file mode 100644 index 0000000000..1cbd0b4ef5 --- /dev/null +++ b/public/plugin/zoom/view/meeting.tpl @@ -0,0 +1,116 @@ +

    + {{ meeting.typeName }} {{ meeting.meetingId }} ({{ meeting.meetingInfoGet.status }}) +

    + +
    + +{% if meeting.meetingInfoGet.status != 'finished' %} + + {{ 'ViewMeeting'|get_plugin_lang('ZoomPlugin') }} + +{% endif %} + +{% if isConferenceManager %} + {% if meeting.status == 'waiting' %} + + {{ 'StartMeeting'|get_plugin_lang('ZoomPlugin') }} + + {% endif %} + + + {{ 'Activity'|get_plugin_lang('ZoomPlugin') }} + +{% endif %} +
    + +{% if isConferenceManager %} +
    +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    +{% endif %} + +{% if currentUserJoinURL %} +{#

    #} +{# #} +{# {{ 'JoinMeeting'|get_plugin_lang('ZoomPlugin') }}#} +{# #} +{#

    #} +{% endif %} + +{% if isConferenceManager %} + {{ editMeetingForm }} + {{ deleteMeetingForm }} + {{ registerParticipantForm }} + {{ fileForm }} + + {# {% if registrants and meeting.meetingInfoGet.settings.approval_type != 2 %}#} + {% if registrants.count > 0 %} + +

    {{ 'Users' | get_lang }}

    +
    + + {% for registrant in registrants %} + + + + + {% endfor %} +
    + {{ registrant.fullName }} + +{# {% if registrant.joinUrl %}#} +{# #} +{# {{ 'CopyJoinAsURL'|get_plugin_lang('ZoomPlugin') }}#} +{# #} +{# {% else %}#} +{# #} +{# {{ 'JoinURLNotAvailable'|get_plugin_lang('ZoomPlugin') }}#} +{# #} +{# {% endif %}#} +
    + {% endif %} +{% else %} +

    {{ meeting.meetingInfoGet.topic }}

    + {% if meeting.meetingInfoGet.agenda %} +
    {{ meeting.meetingInfoGet.agenda| nl2br }}
    + {% endif %} + + {% if meeting.meetingInfoGet.type == 2 or meeting.meetingInfoGet.type == 8 %} +
    +
    {{ 'StartTime'|get_lang }}
    +
    {{ meeting.formattedStartTime }}
    + +
    {{ 'Duration'|get_lang }}
    +
    {{ meeting.formattedDuration }}
    +
    + {% endif %} +{% endif %} diff --git a/public/plugin/zoom/view/meetings.tpl b/public/plugin/zoom/view/meetings.tpl new file mode 100644 index 0000000000..022ddf4b7f --- /dev/null +++ b/public/plugin/zoom/view/meetings.tpl @@ -0,0 +1,62 @@ +{% import "default/document/recycle.tpl" as macro %} + +{{ schedule_form }} +{{ search_form }} + +{% if meetings %} +

    {{ 'MeetingsFound'|get_plugin_lang('ZoomPlugin') }}:

    + + + + + + +{# #} +{# #} + {% if allow_recording %} + + {% endif %} + + + + + {% for meeting in meetings %} + + + + +{# #} +{# #} + + + + {% endfor %} + +
    {{ 'Topic'|get_plugin_lang('ZoomPlugin') }}{{ 'StartTime'|get_lang }}{{ 'ForEveryone'|get_plugin_lang('ZoomPlugin') }}{{ 'Course'|get_lang }}{{ 'Session'|get_lang }}{{ 'Recordings'|get_plugin_lang('ZoomPlugin') }}
    {{ meeting.meetingInfoGet.topic }}{{ meeting.formattedStartTime }}{{ meeting.user ? 'No' : 'Yes' }}{{ meeting.course ? meeting.course : '-' }}{{ meeting.session ? meeting.session : '-' }} + {% if allow_recording and meeting.recordings.count > 0 %} + {% for recording in meeting.recordings %} +
    +
    + {{ recording.formattedStartTime }} ({{ recording.formattedDuration }}) {{ 'Password' | get_lang }}: {{ recording.recordingMeeting.password }} +
    +
    + +
    +
    + {% endfor %} + {% endif %} +
    + + {{ 'Details'|get_lang }} + +
    +{% endif %} \ No newline at end of file diff --git a/public/plugin/zoom/view/start.tpl b/public/plugin/zoom/view/start.tpl new file mode 100644 index 0000000000..e0290d3626 --- /dev/null +++ b/public/plugin/zoom/view/start.tpl @@ -0,0 +1,56 @@ +{% if instant_meeting_form %} + {{ instant_meeting_form }} +{% endif %} + +{% if group_form %} + {{ group_form }} +{% endif %} + +{% if meetings.count %} + + + + + + + + + + {% for meeting in meetings %} + + + + + + + + {% endfor %} +
    {{ 'Topic'|get_plugin_lang('ZoomPlugin') }}{{ 'Agenda'|get_plugin_lang('ZoomPlugin') }}{{ 'StartTime'|get_lang }}{{ 'Duration'|get_lang }}{{ 'Actions'|get_lang }}
    + {{ meeting.meetingInfoGet.topic }} + + {{ meeting.meetingInfoGet.agenda|nl2br }} + {{ meeting.formattedStartTime }}{{ meeting.formattedDuration }} + + {{ 'Join'|get_plugin_lang('ZoomPlugin') }} + + + {% if is_manager %} + + {{ 'Details'|get_plugin_lang('ZoomPlugin') }} + + + + {{ 'Delete'|get_lang }} + + {% endif %} +
    +{% endif %} + +{% if schedule_meeting_form %} + {{ schedule_meeting_form }} +{% endif %} \ No newline at end of file