Skip to content

Commit

Permalink
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Aug 10, 2018
2 parents 4075364 + 905f3fa commit c740aca
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 56 deletions.
23 changes: 21 additions & 2 deletions main/admin/legal_add.php
Expand Up @@ -25,6 +25,26 @@
'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) {
Expand Down Expand Up @@ -67,7 +87,7 @@
$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;
Expand Down Expand Up @@ -128,7 +148,6 @@
}

$termId = isset($term_preview['id']) ? $term_preview['id'] : 0;
$extraField = new ExtraField('terms_and_condition');
$returnParams = $extraField->addElements(
$form,
$termId,
Expand Down
24 changes: 18 additions & 6 deletions main/inc/ajax/admin.ajax.php
@@ -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.
*/
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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'),
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions main/inc/lib/extra_field.lib.php
Expand Up @@ -1049,6 +1049,11 @@ public function set_extra_fields_in_form(
$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(
Expand Down
16 changes: 9 additions & 7 deletions main/inc/lib/internationalization.lib.php
Expand Up @@ -60,11 +60,11 @@
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
*
Expand All @@ -82,7 +82,7 @@
*
* @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
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down
30 changes: 15 additions & 15 deletions main/inc/lib/legal.lib.php
Expand Up @@ -386,21 +386,21 @@ public static function deleteLegal($userId)
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',
];
}
}
71 changes: 53 additions & 18 deletions main/social/personal_data.php
Expand Up @@ -249,10 +249,33 @@
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>';
foreach ($value as $subValue) {
$personalDataContent .= '<li>'.$subValue->variable.': '.$subValue->value.'</li>';
if (empty($value)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($value as $subValue) {
$personalDataContent .= '<li>'.$subValue->variable.': '.$subValue->value.'</li>';
}
}
$personalDataContent .= '</ul>';
break;
Expand All @@ -261,15 +284,19 @@
$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;">';
foreach ($subValue as $subSubValue) {
if ($category === 'DocumentsAdded') {
$documentLink = Display::url(
$webCoursePath.$subSubValue->directory.'/document'.$subSubValue->path,
$subSubValue->code_path
);
$personalDataContent .= '<li>'.$documentLink.'</li>';
} else {
$personalDataContent .= '<li>'.$subSubValue.'</li>';
if (empty($subValue)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($subValue as $subSubValue) {
if ($category === 'DocumentsAdded') {
$documentLink = Display::url(
$subSubValue->code_path,
$webCoursePath.$subSubValue->directory.'/document'.$subSubValue->path
);
$personalDataContent .= '<li>'.$documentLink.'</li>';
} else {
$personalDataContent .= '<li>'.$subSubValue.'</li>';
}
}
}
$personalDataContent .= '</ul>';
Expand All @@ -280,22 +307,29 @@
case 'roles':
case 'achievedSkills':
case 'sessionAsGeneralCoach':
case 'classes':
case 'courses':
case 'groupNames':
case 'groups':
$personalDataContent .= '<li>'.$key.': </li><ul>';
foreach ($value as $subValue) {
$personalDataContent .= '<li>'.$subValue.'</li>';
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>';
foreach ($courseList as $course) {
$personalDataContent .= '<li>'.$course.'</li>';
if (empty($courseList)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($courseList as $course) {
$personalDataContent .= '<li>'.$course.'</li>';
}
}
$personalDataContent .= '</ul>';
}
Expand Down Expand Up @@ -369,15 +403,16 @@
// 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 = '';
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');
Expand Down
25 changes: 25 additions & 0 deletions src/Chamilo/CoreBundle/Entity/Repository/BranchSyncRepository.php
Expand Up @@ -37,4 +37,29 @@ public function searchByKeyword($keyword)

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;
}
}
}
}

0 comments on commit c740aca

Please sign in to comment.