Minor - merge from 1.11.x

pull/2650/head^2
Julio Montoya 6 years ago
parent 6249c6e4af
commit e2f219141a
  1. 46
      main/social/personal_data.php
  2. 97
      src/UserBundle/Repository/UserRepository.php

@ -41,7 +41,12 @@ if (api_get_setting('allow_terms_conditions') === 'true') {
$formToString = $form->returnForm();
$formDelete = new FormValidator('delete_account', 'post', api_get_self().'?action=delete_account&user_id='.$userId);
$formDelete->addTextarea('explanation', [get_lang('DeleteAccount'), get_lang('ExplanationDeleteAccount')], [], true);
$formDelete->addTextarea(
'explanation',
[get_lang('DeleteAccount'), get_lang('ExplanationDeleteAccount')],
[],
true
);
$formDelete->addHidden('action', 'delete_account');
$formDelete->addButtonDelete(get_lang('DeleteAccount'));
$formToString .= $formDelete->returnForm();
@ -105,19 +110,6 @@ switch ($action) {
$explanation = $formDelete->getSubmitValue('explanation');
UserManager::createDataPrivacyExtraFields();
// Remove delete agreement if it was sent:
/*UserManager::update_extra_field_value(
$userId,
'request_for_legal_agreement_consent_removal',
''
);
UserManager::update_extra_field_value(
$userId,
'request_for_legal_agreement_consent_removal_justification',
''
);*/
UserManager::update_extra_field_value(
$userId,
'request_for_delete_account',
@ -174,13 +166,6 @@ switch ($action) {
$explanation
);
/*$extraFieldValue = new ExtraFieldValue('user');
$value = $extraFieldValue->get_values_by_handler_and_field_variable(
$userId,
'legal_accept'
);
$result = $extraFieldValue->delete($value['id']);*/
Display::addFlash(Display::return_message(get_lang('Sent')));
Event::addEvent(
@ -255,7 +240,7 @@ if ($allowSocial) {
$personalDataContent = '<ul>';
$properties = json_decode($propertiesToJson);
$webCoursePath = api_get_path(WEB_COURSE_PATH);
$showWarningMessage = false;
foreach ($properties as $key => $value) {
if (is_array($value) || is_object($value)) {
switch ($key) {
@ -297,6 +282,9 @@ foreach ($properties as $key => $value) {
if (empty($subValue)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
if (count($subValue) === 1000) {
$showWarningMessage = true;
}
foreach ($subValue as $subSubValue) {
if ($category === 'DocumentsAdded') {
$documentLink = Display::url(
@ -385,11 +373,11 @@ if (api_get_setting('allow_terms_conditions') === 'true') {
$permissionBlock .= get_lang('Date').': '.api_get_local_time($legalTime).'<br /><br />';
$permissionBlock .= $formToString;
/*$permissionBlock .= Display::url(
get_lang('DeleteLegal'),
api_get_self().'?action=delete_legal&user_id='.$userId,
['class' => 'btn btn-danger btn-xs']
);*/
/*$permissionBlock .= Display::url(
get_lang('DeleteLegal'),
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(
@ -447,6 +435,10 @@ if (api_get_setting('allow_terms_conditions') === 'true') {
$termLink = Display::url(get_lang('ReadTermsAndConditions'), $url);
}
if ($showWarningMessage) {
Display::addFlash(Display::return_message(get_lang('MoreDataAvailableInTheDatabaseButTrunkedForEfficiencyReasons')));
}
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
if (api_get_setting('allow_social_tool') === 'true') {

@ -609,8 +609,8 @@ class UserRepository extends EntityRepository
'IP: '.$item->getUserIp(),
'Start: '.$date,
'Status: '.$item->getStatus(),
// 'Result: '.$item->getExeResult(),
// 'Weighting: '.$item->getExeWeighting(),
// 'Result: '.$item->getExeResult(),
// 'Weighting: '.$item->getExeWeighting(),
];
$trackEExercises[] = implode(', ', $list);
}
@ -623,6 +623,7 @@ class UserRepository extends EntityRepository
$trackEAttempt = [];
/** @var TrackEAttempt $item */
foreach ($result as $item) {
$date = $item->getTms() ? $item->getTms()->format($dateFormat) : '';
$list = [
'Attempt #'.$item->getExeId(),
'Course # '.$item->getCId(),
@ -653,14 +654,51 @@ class UserRepository extends EntityRepository
$trackECourseAccessList[] = implode(', ', $list);
}
// TrackELogin
$criteria = [
'loginUserId' => $userId,
$checkEntities = [
'ChamiloCoreBundle:TrackELogin' => 'loginUserId',
'ChamiloCoreBundle:TrackEAccess' => 'accessUserId',
'ChamiloCoreBundle:TrackEOnline' => 'loginUserId',
'ChamiloCoreBundle:TrackEDefault' => 'defaultUserId',
'ChamiloCoreBundle:TrackELastaccess' => 'accessUserId',
'ChamiloCoreBundle:TrackEUploads' => 'uploadUserId',
'ChamiloCoreBundle:GradebookResult' => 'userId',
'ChamiloCoreBundle:TrackEDownloads' => 'downUserId',
];
$result = $em->getRepository('ChamiloCoreBundle:TrackELogin')->findBy($criteria);
$maxResults = 1000;
$trackResults = [];
foreach ($checkEntities as $entity => $field) {
$qb = $em->createQueryBuilder();
$qb->select($qb->expr()->count('l'))
->from($entity, 'l')
->where("l.$field = :login")
->setParameter('login', $userId);
$query = $qb->getQuery();
$count = $query->getSingleScalarResult();
if ($count > $maxResults) {
$qb = $em->getRepository($entity)->createQueryBuilder('l');
$qb
->select('l')
->where("l.$field = :login")
->setParameter('login', $userId);
$qb
->setFirstResult(0)
->setMaxResults($maxResults)
;
$result = $qb->getQuery()->getResult();
} else {
$criteria = [
$field => $userId,
];
$result = $em->getRepository($entity)->findBy($criteria);
}
$trackResults[$entity] = $result;
}
$trackELoginList = [];
/** @var TrackELogin $item */
foreach ($result as $item) {
foreach ($trackResults['ChamiloCoreBundle:TrackELogin'] as $item) {
$startDate = $item->getLoginDate() ? $item->getLoginDate()->format($dateFormat) : '';
$endDate = $item->getLogoutDate() ? $item->getLogoutDate()->format($dateFormat) : '';
$list = [
@ -672,13 +710,9 @@ class UserRepository extends EntityRepository
}
// TrackEAccess
$criteria = [
'accessUserId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:TrackEAccess')->findBy($criteria);
$trackEAccessList = [];
/** @var TrackEAccess $item */
foreach ($result as $item) {
foreach ($trackResults['ChamiloCoreBundle:TrackEAccess'] as $item) {
$date = $item->getAccessDate() ? $item->getAccessDate()->format($dateFormat) : '';
$list = [
'IP: '.$item->getUserIp(),
@ -689,13 +723,8 @@ class UserRepository extends EntityRepository
}
// TrackEOnline
$criteria = [
'loginUserId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:TrackEOnline')->findBy($criteria);
$trackEOnlineList = [];
/** @var TrackEOnline $item */
foreach ($result as $item) {
foreach ($trackResults['ChamiloCoreBundle:TrackEOnline'] as $item) {
$date = $item->getLoginDate() ? $item->getLoginDate()->format($dateFormat) : '';
$list = [
'IP: '.$item->getUserIp(),
@ -707,13 +736,9 @@ class UserRepository extends EntityRepository
}
// TrackEDefault
$criteria = [
'defaultUserId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:TrackEDefault')->findBy($criteria);
$trackEDefault = [];
/** @var TrackEDefault $item */
foreach ($result as $item) {
foreach ($trackResults['ChamiloCoreBundle:TrackEDefault'] as $item) {
$date = $item->getDefaultDate() ? $item->getDefaultDate()->format($dateFormat) : '';
$list = [
'Type: '.$item->getDefaultEventType(),
@ -727,13 +752,9 @@ class UserRepository extends EntityRepository
}
// TrackELastaccess
$criteria = [
'accessUserId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:TrackELastaccess')->findBy($criteria);
$trackELastaccess = [];
/** @var TrackELastaccess $item */
foreach ($result as $item) {
foreach ($trackResults['ChamiloCoreBundle:TrackELastaccess'] as $item) {
$date = $item->getAccessDate() ? $item->getAccessDate()->format($dateFormat) : '';
$list = [
'Course #'.$item->getCId(),
@ -745,13 +766,9 @@ class UserRepository extends EntityRepository
}
// TrackEUploads
$criteria = [
'uploadUserId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:TrackEUploads')->findBy($criteria);
$trackEUploads = [];
/** @var TrackEUploads $item */
foreach ($result as $item) {
foreach ($trackResults['ChamiloCoreBundle:TrackEUploads'] as $item) {
$date = $item->getUploadDate() ? $item->getUploadDate()->format($dateFormat) : '';
$list = [
'Course #'.$item->getCId(),
@ -761,13 +778,9 @@ class UserRepository extends EntityRepository
$trackEUploads[] = implode(', ', $list);
}
$criteria = [
'userId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:GradebookResult')->findBy($criteria);
$gradebookResult = [];
/** @var GradebookResult $item */
foreach ($result as $item) {
foreach ($trackResults['ChamiloCoreBundle:GradebookResult'] as $item) {
$date = $item->getCreatedAt() ? $item->getCreatedAt()->format($dateFormat) : '';
$list = [
'Evaluation id# '.$item->getEvaluationId(),
@ -777,13 +790,9 @@ class UserRepository extends EntityRepository
$gradebookResult[] = implode(', ', $list);
}
$criteria = [
'downUserId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:TrackEDownloads')->findBy($criteria);
$trackEDownloads = [];
/** @var TrackEDownloads $item */
foreach ($result as $item) {
foreach ($trackResults['ChamiloCoreBundle:TrackEDownloads'] as $item) {
$date = $item->getDownDate() ? $item->getDownDate()->format($dateFormat) : '';
$list = [
'File: '.$item->getDownDocPath(),
@ -1228,7 +1237,7 @@ class UserRepository extends EntityRepository
$list = [];
/** @var AccessUrlRelUser $portal */
foreach ($portals as $portal) {
$portalInfo = \UrlManager::get_url_data_from_id($portal->getUrl()->getId());
$portalInfo = \UrlManager::get_url_data_from_id($portal->getAccessUrlId());
$list[] = $portalInfo['url'];
}
}

Loading…
Cancel
Save