Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/2624/head
Angel Fernando Quiroz Campos 7 years ago
commit c740acac40
  1. 23
      main/admin/legal_add.php
  2. 24
      main/inc/ajax/admin.ajax.php
  3. 5
      main/inc/lib/extra_field.lib.php
  4. 16
      main/inc/lib/internationalization.lib.php
  5. 30
      main/inc/lib/legal.lib.php
  6. 45
      main/social/personal_data.php
  7. 25
      src/Chamilo/CoreBundle/Entity/Repository/BranchSyncRepository.php
  8. 106
      src/Chamilo/UserBundle/Repository/UserRepository.php

@ -25,6 +25,26 @@ $term_preview = [
'content' => '',
'changes' => '',
];
$extraField = new ExtraField('terms_and_condition');
$types = LegalManager::getTreatmentTypeList();
foreach ($types as $variable => $name) {
$label = 'PersonalData'.ucfirst($name).'Title';
$params = [
'variable' => $variable,
'display_text' => $label,
'field_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'default_value' => '',
'visible' => true,
'changeable' => true,
'filter' => true,
'visible_to_self' => true,
'visible_to_others' => true,
];
$extraField->save($params);
}
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
@ -67,7 +87,7 @@ if ($form->validate()) {
$tok = Security::get_token();
header('Location: legal_list.php?sec_token='.$tok);
exit();
} elseif ($submit == 'preview') {
} elseif ($submit === 'preview') {
$defaults['type'] = $type;
$defaults['content'] = $content;
$defaults['changes'] = $changes;
@ -128,7 +148,6 @@ if (isset($_POST['language'])) {
}
$termId = isset($term_preview['id']) ? $term_preview['id'] : 0;
$extraField = new ExtraField('terms_and_condition');
$returnParams = $extraField->addElements(
$form,
$termId,

@ -1,5 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
use \Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository;
use \Chamilo\CoreBundle\Entity\BranchSync;
use \Doctrine\Common\Collections\Criteria;
/**
* Responses to AJAX calls.
*/
@ -108,13 +113,9 @@ function version_check()
/**
* Check if the current installation is up to date
* The code is borrowed from phpBB and slighlty modified.
*
* @author The phpBB Group <support@phpbb.com> (the code)
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
* @author Yannick Warnier <ywarnier@beeznest.org> for the move to HTTP request
* @copyright (C) 2001 The phpBB Group
*
* @return string language string with some layout (color)
* @throws \Exception
* @throws \InvalidArgumentException
*/
function check_system_version()
{
@ -162,6 +163,16 @@ function check_system_version()
$packager = 'chamilo';
}
$uniqueId = '';
$entityManager = Database::getManager();
/** @var BranchSyncRepository $branch */
$repository = $entityManager->getRepository('ChamiloCoreBundle:BranchSync');
/** @var BranchSync $branch */
$branch = $repository->getTopBranch();
if (is_a($branch, '\Chamilo\CoreBundle\Entity\BranchSync')) {
$uniqueId = $branch->getUniqueId();
}
$data = [
'url' => api_get_path(WEB_PATH),
'campus' => api_get_setting('siteName'),
@ -183,6 +194,7 @@ function check_system_version()
// the default config file (main/install/configuration.dist.php)
// or in the installed config file. The default value is 'chamilo'
'packager' => $packager,
'unique_id' => $uniqueId,
];
$version = null;

@ -1049,6 +1049,11 @@ class ExtraField extends Model
$freezeElement = $field_details['visible_to_self'] == 0 || $field_details['changeable'] == 0;
}
$translatedDisplayText = get_lang($field_details['display_text'], true);
if (!empty($translatedDisplayText)) {
$field_details['display_text'] = $translatedDisplayText;
}
switch ($field_details['field_type']) {
case self::FIELD_TYPE_TEXT:
$form->addElement(

@ -60,11 +60,11 @@ define('PERSON_NAME_EMAIL_ADDRESS', PERSON_NAME_WESTERN_ORDER);
define('PERSON_NAME_DATA_EXPORT', PERSON_NAME_EASTERN_ORDER);
/**
* Returns a translated (localized) string, called by its identificator.
* Returns a translated (localized) string, called by its ID.
*
* @param string $variable this is the identificator (name) of the translated string to be retrieved
* @param string $reserved this parameter has been reserved for future use
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
* @param string $variable this is the ID (name) of the translated string to be retrieved
* @param bool $strict If variable is not found, then: if false: returns variable name with or without brackets; true: returns ''
* @param string $language (optional) Language ID. If it is omitted, the current interface language is assumed.
*
* @return string returns the requested string in the correspondent language
*
@ -82,7 +82,7 @@ define('PERSON_NAME_DATA_EXPORT', PERSON_NAME_EASTERN_ORDER);
*
* @see http://translate.chamilo.org/
*/
function get_lang($variable, $reserved = null, $language = null)
function get_lang($variable, $strict = false, $language = null)
{
// For serving some old hacks:
// By manipulating this global variable the translation may
@ -141,17 +141,18 @@ function get_lang($variable, $reserved = null, $language = null)
// - from a local variable after reloading the language files - on test server mode or when requested language
// is different than the genuine interface language.
$read_global_variables = $is_interface_language;
$langvar = '';
if ($read_global_variables) {
if (isset($GLOBALS[$variable])) {
$langvar = $GLOBALS[$variable];
} elseif (isset($GLOBALS["lang$variable"])) {
$langvar = $GLOBALS["lang$variable"];
} else {
} elseif (!$strict) {
$langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable;
}
}
if (empty($langvar) || !is_string($langvar)) {
if (empty($langvar) || !is_string($langvar) && !$strict) {
$langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable;
}
$ret = $cache[$language][$variable] = $langvar;
@ -168,6 +169,7 @@ function get_lang($variable, $reserved = null, $language = null)
* @param bool $setParentLanguageName
*
* @return string the current language of the interface
* @throws Exception
*/
function api_get_interface_language(
$purified = false,

@ -386,21 +386,21 @@ class LegalManager
public static function getTreatmentTypeList()
{
return [
101 => 'collection',
102 => 'recording',
103 => 'organization',
104 => 'structure',
105 => 'conservation',
106 => 'adaptation',
107 => 'extraction',
108 => 'consultation',
109 => 'usage',
110 => 'communication',
111 => 'interconnection',
112 => 'limitation',
113 => 'deletion',
114 => 'destruction',
115 => 'profiling',
'privacy_terms_collection' => 'collection',
'privacy_terms_recording' => 'recording',
'privacy_terms_organization' => 'organization',
'privacy_terms_structure' => 'structure',
'privacy_terms_conservation' => 'conservation',
'privacy_terms_adaptation' => 'adaptation',
'privacy_terms_extraction' => 'extraction',
'privacy_terms_consultation' => 'consultation',
'privacy_terms_usage' => 'usage',
'privacy_terms_communication' => 'communication',
'privacy_terms_interconnection' => 'interconnection',
'privacy_terms_limitation' => 'limitation',
'privacy_terms_deletion' => 'deletion',
'privacy_terms_destruction' => 'destruction',
'privacy_terms_profiling' => 'profiling',
];
}
}

@ -249,11 +249,34 @@ $webCoursePath = api_get_path(WEB_COURSE_PATH);
foreach ($properties as $key => $value) {
if (is_array($value) || is_object($value)) {
switch ($key) {
case 'classes':
foreach ($value as $category => $subValue) {
$categoryName = 'Social group';
if ($category == 0) {
$categoryName = 'Class';
}
$personalDataContent .= '<li class="advanced_options" id="personal-data-list-'.$category.'">';
$personalDataContent .= '<u>'.$categoryName.'</u> &gt;</li>';
$personalDataContent .= '<ul id="personal-data-list-'.$category.'_options" style="display:none;">';
if (empty($subValue)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($subValue as $subSubValue) {
$personalDataContent .= '<li>'.$subSubValue.'</li>';
}
}
$personalDataContent .= '</ul>';
}
break;
case 'extraFields':
$personalDataContent .= '<li>'.$key.': </li><ul>';
if (empty($value)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($value as $subValue) {
$personalDataContent .= '<li>'.$subValue->variable.': '.$subValue->value.'</li>';
}
}
$personalDataContent .= '</ul>';
break;
case 'dropBoxSentFiles':
@ -261,17 +284,21 @@ foreach ($properties as $key => $value) {
$personalDataContent .= '<li class="advanced_options" id="personal-data-list-'.$category.'">';
$personalDataContent .= '<u>'.get_lang($category).'</u> &gt;</li>';
$personalDataContent .= '<ul id="personal-data-list-'.$category.'_options" style="display:none;">';
if (empty($subValue)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($subValue as $subSubValue) {
if ($category === 'DocumentsAdded') {
$documentLink = Display::url(
$webCoursePath.$subSubValue->directory.'/document'.$subSubValue->path,
$subSubValue->code_path
$subSubValue->code_path,
$webCoursePath.$subSubValue->directory.'/document'.$subSubValue->path
);
$personalDataContent .= '<li>'.$documentLink.'</li>';
} else {
$personalDataContent .= '<li>'.$subSubValue.'</li>';
}
}
}
$personalDataContent .= '</ul>';
}
@ -280,23 +307,30 @@ foreach ($properties as $key => $value) {
case 'roles':
case 'achievedSkills':
case 'sessionAsGeneralCoach':
case 'classes':
case 'courses':
case 'groupNames':
case 'groups':
$personalDataContent .= '<li>'.$key.': </li><ul>';
if (empty($subValue)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($value as $subValue) {
$personalDataContent .= '<li>'.$subValue.'</li>';
}
}
$personalDataContent .= '</ul>';
break;
case 'sessionCourseSubscriptions':
$personalDataContent .= '<li>'.$key.': </li><ul>';
foreach ($value as $session => $courseList) {
$personalDataContent .= '<li>'.$session.'<ul>';
if (empty($courseList)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($courseList as $course) {
$personalDataContent .= '<li>'.$course.'</li>';
}
}
$personalDataContent .= '</ul>';
}
$personalDataContent .= '</ul>';
@ -369,7 +403,7 @@ $legalTermsRepo = $em->getRepository('ChamiloCoreBundle:Legal');
// Get data about the treatment of data
$treatmentTypes = LegalManager::getTreatmentTypeList();
foreach ($treatmentTypes as $id => $item) {
/*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 = '';
@ -377,7 +411,8 @@ foreach ($treatmentTypes as $id => $item) {
$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');

@ -37,4 +37,29 @@ class BranchSyncRepository extends NestedTreeRepository
return $q->execute();
}
/**
* Gets the first branch with parent_id = NULL
* @return mixed
*/
public function getTopBranch()
{
$qb = $this->createQueryBuilder('a');
//Selecting user info
$qb->select('DISTINCT b');
$qb->from('Chamilo\CoreBundle\Entity\BranchSync', 'b');
$qb->where('b.parentId IS NULL');
$qb->add('orderBy', 'b.id ASC');
$qb->setMaxResults(1);
$q = $qb->getQuery()->getResult();
if (empty($q)) {
return null;
} else {
foreach ($q as $result) {
return $result;
}
}
}
}

@ -12,6 +12,7 @@ use Chamilo\CoreBundle\Entity\Message;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\CoreBundle\Entity\TrackEAccess;
use Chamilo\CoreBundle\Entity\TrackEAttempt;
use Chamilo\CoreBundle\Entity\TrackECourseAccess;
@ -22,8 +23,10 @@ use Chamilo\CoreBundle\Entity\TrackELastaccess;
use Chamilo\CoreBundle\Entity\TrackELogin;
use Chamilo\CoreBundle\Entity\TrackEOnline;
use Chamilo\CoreBundle\Entity\TrackEUploads;
use Chamilo\CoreBundle\Entity\UserApiKey;
use Chamilo\CoreBundle\Entity\UserCourseCategory;
use Chamilo\CoreBundle\Entity\UsergroupRelUser;
use Chamilo\CoreBundle\Entity\UserRelCourseVote;
use Chamilo\CourseBundle\Entity\CAttendanceResult;
use Chamilo\CourseBundle\Entity\CAttendanceSheet;
use Chamilo\CourseBundle\Entity\CBlogPost;
@ -43,6 +46,7 @@ use Chamilo\TicketBundle\Entity\Ticket;
use Chamilo\UserBundle\Entity\User;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr\Join;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Serializer;
@ -511,17 +515,31 @@ class UserRepository extends EntityRepository
$courses = $user->getCourses();
$list = [];
$chatFiles = [];
/** @var CourseRelUser $course */
foreach ($courses as $course) {
$list[] = $course->getCourse()->getCode();
$courseDir = api_get_path(SYS_COURSE_PATH).$course->getCourse()->getDirectory();
$documentDir = $courseDir.'/document/chat_files/';
if (is_dir($documentDir)) {
$fs = new Finder();
$fs->files()->in($documentDir);
foreach ($fs as $file) {
$chatFiles[] =
$course->getCourse()->getDirectory().'/document/chat_files/'.$file->getFilename().' - '.
get_lang('ContentNotAccessibleRequestFromDataPrivacyOfficer');
}
}
}
$user->setCourses($list);
$classes = $user->getClasses();
$list = [];
/** @var UsergroupRelUser $class */
foreach ($classes as $class) {
$list[] = $class->getUsergroup()->getName();
$name = $class->getUsergroup()->getName();
$list[$class->getUsergroup()->getGroupType()][] = $name.' - Status: '.$class->getRelationType();
}
$user->setClasses($list);
@ -580,8 +598,8 @@ class UserRepository extends EntityRepository
'IP: '.$item->getUserIp(),
'Start: '.$item->getExeDate()->format($dateFormat),
'Status: '.$item->getStatus(),
'Result: '.$item->getExeResult(),
'Weighting: '.$item->getExeWeighting(),
// 'Result: '.$item->getExeResult(),
// 'Weighting: '.$item->getExeWeighting(),
];
$trackEExercises[] = implode(', ', $list);
}
@ -597,9 +615,9 @@ class UserRepository extends EntityRepository
$list = [
'Attempt #'.$item->getExeId(),
'Course # '.$item->getCId(),
'Answer: '.$item->getAnswer(),
//'Answer: '.$item->getAnswer(),
'Session #'.$item->getSessionId(),
'Marks: '.$item->getMarks(),
//'Marks: '.$item->getMarks(),
'Position: '.$item->getPosition(),
'Date: '.$item->getTms()->format($dateFormat),
];
@ -733,7 +751,7 @@ class UserRepository extends EntityRepository
foreach ($result as $item) {
$list = [
'Evaluation id# '.$item->getEvaluationId(),
'Score: '.$item->getScore(),
//'Score: '.$item->getScore(),
'Creation date: '.$item->getCreatedAt()->format($dateFormat),
];
$gradebookResult[] = implode(', ', $list);
@ -797,6 +815,21 @@ class UserRepository extends EntityRepository
$cForumThreadList[] = implode(', ', $list);
}
// CForumAttachment
/*$criteria = [
'threadPosterId' => $userId,
];
$result = $em->getRepository('ChamiloCourseBundle:CForumAttachment')->findBy($criteria);
$cForumThreadList = [];
* @var CForumThread $item
foreach ($result as $item) {
$list = [
'Title: '.$item->getThreadTitle(),
'Creation date: '.$item->getThreadDate()->format($dateFormat),
];
$cForumThreadList[] = implode(', ', $list);
}*/
// cGroupRelUser
$criteria = [
'userId' => $userId,
@ -869,7 +902,8 @@ class UserRepository extends EntityRepository
$list = [
'Title: '.$item->getTitle(),
'Sent date: '.$item->getSendDate()->format($dateFormat),
'To user# '.$item->getUserReceiverId(),
'To user # '.$item->getUserReceiverId(),
'Status'.$item->getMsgStatus(),
];
$messageList[] = implode(', ', $list);
}
@ -915,6 +949,7 @@ class UserRepository extends EntityRepository
foreach ($result as $item) {
$list = [
'File #'.$item->getFileId(),
'Course #'.$item->getCId(),
];
$cDropboxPerson[] = implode(', ', $list);
}
@ -1042,12 +1077,63 @@ class UserRepository extends EntityRepository
$list = [
'Subject: '.$item->getSubject(),
'IP: '.$item->getIpAddress(),
'Status: '. $item->getStatus(),
'Status: '.$item->getStatus(),
'Creation date: '.$item->getInsertDateTime()->format($dateFormat),
];
$ticketMessage[] = implode(', ', $list);
}
// SkillRelUserComment
$criteria = [
'feedbackGiver' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:SkillRelUserComment')->findBy($criteria);
$skillRelUserComment = [];
/** @var SkillRelUserComment $item */
foreach ($result as $item) {
$list = [
'Feedback: '.$item->getFeedbackText(),
'Value: '.$item->getFeedbackValue(),
'Created at: '.$item->getFeedbackDateTime()->format($dateFormat),
];
$skillRelUserComment[] = implode(', ', $list);
}
// UserRelCourseVote
$criteria = [
'userId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:UserRelCourseVote')->findBy($criteria);
$userRelCourseVote = [];
/** @var UserRelCourseVote $item */
foreach ($result as $item) {
$list = [
'Course #'.$item->getCId(),
'Session #'.$item->getSessionId(),
'Vote: '.$item->getVote(),
];
$userRelCourseVote[] = implode(', ', $list);
}
// UserApiKey
$criteria = [
'userId' => $userId,
];
$result = $em->getRepository('ChamiloCoreBundle:UserApiKey')->findBy($criteria);
$userApiKey = [];
/** @var UserApiKey $item */
foreach ($result as $item) {
$list = [
'ApiKey #'.$item->getApiKey(),
'Service: '.$item->getApiService(),
'EndPoint: '.$item->getApiEndPoint(),
'Validity start date: '.$item->getValidityEndDate()->format($dateFormat),
'Validity enddate: '.$item->getValidityStartDate()->format($dateFormat),
'Created at: '.$item->getCreatedDate()->format($dateFormat),
];
$userApiKey[] = implode(', ', $list);
}
$user->setDropBoxSentFiles(
[
'Friends' => $friendList,
@ -1064,11 +1150,15 @@ class UserRepository extends EntityRepository
'GradebookResult' => $gradebookResult,
'Downloads' => $trackEDownloads,
'UserCourseCategory' => $userCourseCategory,
'SkillRelUserComment' => $skillRelUserComment,
'UserRelCourseVote' => $userRelCourseVote,
'UserApiKey' => $userApiKey,
// courses
'AttendanceResult' => $cAttendanceResult,
'Blog' => $cBlog,
'DocumentsAdded' => $documents,
'Chat' => $chatFiles,
'ForumPost' => $cForumPostList,
'ForumThread' => $cForumThreadList,
'TrackEExercises' => $trackEExercises,

Loading…
Cancel
Save