get_lang('Encrypted data'), 'salt' => get_lang('Random data'), 'empty' => get_lang('No data available'), ]; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $formToString = ''; if (api_get_setting('allow_terms_conditions') === 'true') { $form = new FormValidator('delete_term', 'post', api_get_self().'?action=delete_legal&user_id='.$userId); $form->addHtml(Display::return_message(get_lang('You can ask below for your legal agreement to be deleted or your account to be deleted.
In the case of the legal agreement, once deleted you will have to accept it again on your next login to be able to access the platform and recover your access, because we cannot reasonably at the same time give you a personal environment and not treat your personal data.
In the case of an account deletion, your account will be deleted along with all of your course subscriptions and all the information related to your account. Please select the corresponding option with care. In both cases, one of our administrators will review your request before it is effective, to avoid any misunderstanding and definitive loss of your data.'), 'normal', false)); $form->addTextarea('explanation', [get_lang('Delete legal agreement'), get_lang('ExplanationDelete legal agreement')], [], true); $form->addHidden('action', 'delete_legal'); $form->addButtonSave(get_lang('Delete legal agreement')); $formToString = $form->returnForm(); $formDelete = new FormValidator('delete_account', 'post', api_get_self().'?action=delete_account&user_id='.$userId); $formDelete->addTextarea( 'explanation', [get_lang('Delete account'), get_lang('ExplanationDelete account')], [], true ); $formDelete->addHidden('action', 'delete_account'); $formDelete->addButtonDelete(get_lang('Delete account')); $formToString .= $formDelete->returnForm(); } switch ($action) { case 'send_legal': $language = api_get_interface_language(); $language = api_get_language_id($language); $terms = LegalManager::get_last_condition($language); if (!$terms) { //look for the default language $language = api_get_setting('platformLanguage'); $language = api_get_language_id($language); $terms = LegalManager::get_last_condition($language); } $legalAcceptType = $terms['version'].':'.$terms['language_id'].':'.time(); UserManager::update_extra_field_value( $userId, 'legal_accept', $legalAcceptType ); Event::addEvent( LOG_TERM_CONDITION_ACCEPTED, LOG_USER_OBJECT, api_get_user_info($userId), api_get_utc_datetime() ); $bossList = UserManager::getStudentBossList($userId); if (!empty($bossList)) { $bossList = array_column($bossList, 'boss_id'); $currentUserInfo = api_get_user_info($userId); foreach ($bossList as $bossId) { $subjectEmail = sprintf( get_lang('User %s signed the agreement.'), $currentUserInfo['complete_name'] ); $contentEmail = sprintf( get_lang('User %s signed the agreement.TheDateY'), $currentUserInfo['complete_name'], api_get_local_time($time) ); MessageManager::send_message_simple( $bossId, $subjectEmail, $contentEmail, $user_id ); } } Display::addFlash(Display::return_message(get_lang('Saved..'))); header('Location: '.api_get_self()); exit; break; case 'delete_account': if ($formDelete->validate()) { $explanation = $formDelete->getSubmitValue('explanation'); UserManager::createDataPrivacyExtraFields(); UserManager::update_extra_field_value( $userId, 'request_for_delete_account', 1 ); UserManager::update_extra_field_value( $userId, 'request_for_delete_account_justification', $explanation ); Display::addFlash(Display::return_message(get_lang('Saved..'))); Event::addEvent( LOG_USER_DELETE_ACCOUNT_REQUEST, LOG_USER_OBJECT, $userInfo ); $url = api_get_path(WEB_CODE_PATH).'admin/user_list_consent.php'; $link = Display::url($url, $url); $subject = get_lang('Request for account removal'); $content = sprintf( get_lang('User %s asked for the deletion of his/her account, explaining that "%s". You can process the request here: %s'), $userInfo['complete_name'], $explanation, $link ); $email = api_get_configuration_value('data_protection_officer_email'); if (!empty($email)) { api_mail_html('', $email, $subject, $content); } else { MessageManager::sendMessageToAllAdminUsers(api_get_user_id(), $subject, $content); } header('Location: '.api_get_self()); exit; } break; case 'delete_legal': if ($form->validate()) { $explanation = $form->getSubmitValue('explanation'); UserManager::createDataPrivacyExtraFields(); UserManager::update_extra_field_value( $userId, 'request_for_legal_agreement_consent_removal', 1 ); UserManager::update_extra_field_value( $userId, 'request_for_legal_agreement_consent_removal_justification', $explanation ); Display::addFlash(Display::return_message(get_lang('Sent'))); Event::addEvent( LOG_USER_REMOVED_LEGAL_ACCEPT, LOG_USER_OBJECT, $userInfo ); $url = api_get_path(WEB_CODE_PATH).'admin/user_list_consent.php'; $link = Display::url($url, $url); $subject = get_lang('Request for consent withdrawal on legal terms'); $content = sprintf( get_lang('User %s asked for the removal of his/her consent to our legal terms, explaining that "%s". You can process the request here: %s'), $userInfo['complete_name'], $explanation, $link ); $email = api_get_configuration_value('data_protection_officer_email'); if (!empty($email)) { api_mail_html('', $email, $subject, $content); } else { MessageManager::sendMessageToAllAdminUsers(api_get_user_id(), $subject, $content); } header('Location: '.api_get_self()); exit; } break; } $propertiesToJson = UserManager::getRepository()->getPersonalDataToJson($userId, $substitutionTerms); if (!empty($_GET['export'])) { $filename = md5(mt_rand(0, 1000000)).'.json'; $path = api_get_path(SYS_ARCHIVE_PATH).$filename; $writeResult = file_put_contents($path, $propertiesToJson); if ($writeResult !== false) { DocumentManager::file_send_for_download($path, true, $filename); exit; } } $allowSocial = api_get_setting('allow_social_tool') === 'true'; $nameTools = get_lang('Personal data'); $show_message = null; if ($allowSocial) { $this_section = SECTION_SOCIAL; $interbreadcrumb[] = [ 'url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('Social network'), ]; } else { $this_section = SECTION_MYPROFILE; $interbreadcrumb[] = [ 'url' => api_get_path(WEB_PATH).'main/auth/profile.php', 'name' => get_lang('Profile'), ]; } $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Personal data')]; // LEFT CONTENT $socialMenuBlock = ''; if ($allowSocial) { // Block Social Menu $socialMenuBlock = SocialManager::show_social_menu('personal-data'); } // MAIN CONTENT $personalDataContent = ''; // Check terms acceptation $permissionBlock = ''; if (api_get_setting('allow_terms_conditions') === 'true') { $extraFieldValue = new ExtraFieldValue('user'); $value = $extraFieldValue->get_values_by_handler_and_field_variable( $userId, 'legal_accept' ); $permissionBlock .= Display::return_icon('accept_na.png', get_lang('Rejected')); if (isset($value['value']) && !empty($value['value'])) { list($legalId, $legalLanguageId, $legalTime) = explode(':', $value['value']); $permissionBlock = '

'.get_lang('Current status').'

'. get_lang('Legal agreement accepted').' '.Display::return_icon('accept.png', get_lang('Legal agreement accepted'), [], ICON_SIZE_TINY). '
'; $permissionBlock .= get_lang('Date').': '.api_get_local_time($legalTime).'

'; $permissionBlock .= $formToString; /*$permissionBlock .= Display::url( get_lang('Delete legal agreement'), api_get_self().'?action=delete_legal&user_id='.$userId, ['class' => 'btn btn-danger btn-xs'] );*/ } else { // @TODO add action handling for button $permissionBlock .= Display::url( get_lang('Send legal agreement'), api_get_self().'?action=send_legal&user_id='.$userId, ['class' => 'btn btn-primary btn-xs'] ); } } else { $permissionBlock .= get_lang('No terms and conditions available'); } //Build the final array to pass to template $personalData = []; $personalData['data'] = $personalDataContent; //$personalData['responsible'] = api_get_setting('personal_data_responsible_org'); $em = Database::getManager(); /** @var LegalRepository $legalTermsRepo */ $legalTermsRepo = $em->getRepository('ChamiloCoreBundle:Legal'); // Get data about the treatment of data $treatmentTypes = LegalManager::getTreatmentTypeList(); /*foreach ($treatmentTypes as $id => $item) { $personalData['treatment'][$item]['title'] = get_lang('PersonalData'.ucfirst($item).'Title'); $legalTerm = $legalTermsRepo->findOneByTypeAndLanguage($id, api_get_language_id($user_language)); $legalTermContent = ''; if (!empty($legalTerm[0]) && is_array($legalTerm[0])) { $legalTermContent = $legalTerm[0]['content']; } $personalData['treatment'][$item]['content'] = $legalTermContent; }*/ $officerName = api_get_configuration_value('data_protection_officer_name'); $officerRole = api_get_configuration_value('data_protection_officer_role'); $officerEmail = api_get_configuration_value('data_protection_officer_email'); if (!empty($officerName)) { $personalData['officer_name'] = $officerName; $personalData['officer_role'] = $officerRole; $personalData['officer_email'] = $officerEmail; } $tpl = new Template(null); $actions = Display::url( Display::return_icon('excel.png', get_lang('Export'), [], ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'social/personal_data.php?export=1' ); $tpl->assign('actions', Display::toolbarAction('toolbar', [$actions])); $termLink = ''; if (api_get_setting('allow_terms_conditions') === 'true') { $url = api_get_path(WEB_CODE_PATH).'social/terms.php'; $termLink = Display::url(get_lang('Read the Terms and Conditions'), $url); } if ($showWarningMessage) { Display::addFlash(Display::return_message(get_lang('More data available in the database but trunked for efficiency reasons.'))); } // Block Social Avatar SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); if (api_get_setting('allow_social_tool') === 'true') { $tpl->assign('social_menu_block', $socialMenuBlock); } else { $tpl->assign('social_menu_block', ''); $tpl->assign('personal_data_block', $personalDataContent); } $tpl->assign('personal_data', $personalData); $tpl->assign('permission', $permissionBlock); $tpl->assign('term_link', $termLink); $socialLayout = $tpl->get_template('social/personal_data.tpl'); $tpl->display($socialLayout);