Fix installation, centralize languages definition, remove unused roles

pull/3924/head
Julio Montoya 3 years ago
parent 727da50e1a
commit ce9f14a733
  1. 4
      config/packages/security.yaml
  2. 3
      public/main/exercise/exercise_show.php
  3. 108
      public/main/inc/lib/api.lib.php
  4. 137
      public/main/inc/lib/internationalization.lib.php
  5. 1
      public/main/inc/lib/usermanager.lib.php
  6. 145
      src/CoreBundle/DataFixtures/LanguageFixtures.php
  7. 9
      src/CoreBundle/Repository/GroupRepository.php

@ -15,12 +15,10 @@ security:
property: username
role_hierarchy:
ROLE_ADMIN:
- ROLE_SUPER_ADMIN
- ROLE_SUPER_ADMIN # Admin that install the platform
- ROLE_QUESTION_MANAGER
- ROLE_SESSION_MANAGER
- ROLE_TEACHER
- ROLE_DIRECTOR
- ROLE_JURY_PRESIDENT
- ROLE_CURRENT_COURSE_TEACHER
- ROLE_CURRENT_COURSE_SESSION_TEACHER
- ROLE_CURRENT_COURSE_GROUP_TEACHER

@ -100,7 +100,8 @@ if (!empty($sessionId) && !$is_allowedToEdit) {
api_get_course_int_id(),
$sessionId
)) {
if (!api_coach_can_edit_view_results(api_get_course_int_id(), $sessionId)) {
if (!api_is_coach($sessionId, api_get_course_int_id())) {
//if (!api_coach_can_edit_view_results(api_get_course_int_id(), $sessionId)) {
api_not_allowed($printHeaders);
}
}

@ -6779,7 +6779,7 @@ function api_set_default_visibility(
if (empty($sessionId)) {
$objExerciseTmp = new Exercise($courseId);
$objExerciseTmp->read($item_id);
if ('visible' == $visibility) {
if ('visible' === $visibility) {
$objExerciseTmp->enable();
$objExerciseTmp->save();
} else {
@ -6792,105 +6792,15 @@ function api_set_default_visibility(
}
}
/**
* @param int $user_id
* @param int $courseId
* @param int $session_id
*
* @return array
*/
function api_detect_user_roles($user_id, $courseId, $session_id = 0)
function api_get_roles()
{
$user_roles = [];
$courseInfo = api_get_course_info_by_id($courseId);
$course_code = $courseInfo['code'];
$url_id = api_get_current_access_url_id();
if (api_is_platform_admin_by_id($user_id, $url_id)) {
$user_roles[] = PLATFORM_ADMIN;
}
/*if (api_is_drh()) {
$user_roles[] = DRH;
}*/
if (!empty($session_id)) {
if (SessionManager::user_is_general_coach($user_id, $session_id)) {
$user_roles[] = SESSION_GENERAL_COACH;
}
}
if (!empty($course_code)) {
if (empty($session_id)) {
if (CourseManager::isCourseTeacher($user_id, $courseInfo['real_id'])) {
$user_roles[] = COURSEMANAGER;
}
if (CourseManager::get_tutor_in_course_status($user_id, $courseInfo['real_id'])) {
$user_roles[] = COURSE_TUTOR;
}
if (CourseManager::is_user_subscribed_in_course($user_id, $course_code)) {
$user_roles[] = COURSE_STUDENT;
}
} else {
$user_status_in_session = SessionManager::get_user_status_in_course_session(
$user_id,
$courseId,
$session_id
);
if (!empty($user_status_in_session)) {
if (0 == $user_status_in_session) {
$user_roles[] = SESSION_STUDENT;
}
if (2 == $user_status_in_session) {
$user_roles[] = SESSION_COURSE_COACH;
}
}
/*if (api_is_course_session_coach($user_id, $course_code, $session_id)) {
$user_roles[] = SESSION_COURSE_COACH;
}*/
}
}
return $user_roles;
}
/**
* @param int $courseId
* @param int $session_id
*
* @return bool
*/
function api_coach_can_edit_view_results($courseId = null, $session_id = null)
{
if (api_is_platform_admin()) {
return true;
}
$user_id = api_get_user_id();
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
if (empty($session_id)) {
$session_id = api_get_session_id();
}
$roles = api_detect_user_roles($user_id, $courseId, $session_id);
if (in_array(SESSION_COURSE_COACH, $roles)) {
//return api_get_setting('session_tutor_reports_visibility') == 'true';
return true;
} else {
if (in_array(COURSEMANAGER, $roles)) {
return true;
}
return false;
}
$hierarchy = Container::$container->getParameter('security.role_hierarchy.roles');
$roles = [];
array_walk_recursive($hierarchy, function($role) use (&$roles) {
$roles[$role] = $role;
});
//echo '<pre>'; var_dump($roles);
return $roles;
}
/**

@ -3,6 +3,7 @@
/* For licensing terms, see /license.txt */
use Carbon\Carbon;
use Chamilo\CoreBundle\DataFixtures\LanguageFixtures;
use Chamilo\CoreBundle\Framework\Container;
use ChamiloSession as Session;
use Westsworld\TimeAgo;
@ -1965,107 +1966,6 @@ function &_api_get_day_month_names($language = null)
return $date_parts[$language];
}
/**
/**
* The following table contains two types of conventions concerning person names:.
*
* "format" - determines how a full person name to be formatted, i.e. in what order the title, the first_name and the last_name to be placed.
* You might need to correct the value for your language. The possible values are:
* title first_name last_name - Western order;
* title last_name first_name - Eastern order;
* title last_name, first_name - Western libraries order.
* Placing the title (Dr, Mr, Miss, etc) depends on the tradition in you country.
*
* @see http://en.wikipedia.org/wiki/Personal_name#Naming_convention
*
* "sort_by" - determines you preferable way of sorting person names. The possible values are:
* first_name - sorting names with priority for the first name;
* last_name - sorting names with priority for the last name.
*/
function getLegacyOrderConventions()
{
return [
'afrikaans' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'albanian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'alemannic' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'amharic' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'armenian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'ar' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'asturian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'bosnian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'brazilian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'breton' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'bulgarian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'catalan' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'croatian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'czech' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'danish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'dari' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'dutch' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'english' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'esperanto' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'estonian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'basque' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'finnish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'french' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'frisian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'friulian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'galician' => ['format' => 'title last_name first_name', 'sort_by' => 'last_name'],
'georgian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'german' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'greek' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'hawaiian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'hebrew' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'hindi' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'hungarian' => ['format' => 'title last_name first_name', 'sort_by' => 'last_name'], // Eastern order
'icelandic' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'indonesian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'irish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'italian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'japanese' => ['format' => 'title last_name first_name', 'sort_by' => 'last_name'], // Eastern order
'korean' => ['format' => 'title last_name first_name', 'sort_by' => 'last_name'], // Eastern order
'latin' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'latvian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'lithuanian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'macedonian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'malay' => ['format' => 'title last_name first_name', 'sort_by' => 'last_name'], // Eastern order
'manx' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'marathi' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'middle_frisian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'mingo' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'nepali' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'norwegian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'occitan' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'pashto' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'persian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'polish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'portuguese' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'quechua_cusco' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'romanian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'rumantsch' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'russian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'sanskrit' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'serbian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'serbian_cyrillic' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'simpl_chinese' => ['format' => 'title last_name first_name', 'sort_by' => 'last_name'], // Eastern order
'slovak' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'slovenian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'spanish' => ['format' => 'title last_name, first_name', 'sort_by' => 'last_name'], // Library order
'swahili' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'swedish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'tagalog' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'tamil' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'thai' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'trad_chinese' => ['format' => 'title last_name first_name', 'sort_by' => 'last_name'], // Eastern order
'turkish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'ukrainian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'vietnamese' => ['format' => 'title last_name first_name', 'sort_by' => 'last_name'], // Eastern order
'welsh' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'yiddish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'yoruba' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
];
}
function getIsoToLegacy()
{
return array_flip(getLegacyToIso());
@ -2086,7 +1986,7 @@ function getLegacyToIso()
'danish' => 'da',
'dari' => 'fa_AF',
'dutch' => 'nl',
'english' => 'en',
'english' => 'en_US',
'estonian' => 'et',
'esperanto' => 'eo',
'faroese' => 'fo',
@ -2150,26 +2050,23 @@ function getLegacyToIso()
*/
function _api_get_person_name_convention($iso, $type)
{
$conventions = getLegacyOrderConventions();
$languageName = '';
if (isset(getIsoToLegacy()[$iso])) {
$languageName = getIsoToLegacy()[$iso];
}
$conventions = LanguageFixtures::getLanguages();
// Overwrite classic conventions
$customConventions = api_get_configuration_value('name_order_conventions');
if (!empty($customConventions)) {
foreach ($customConventions as $key => $data) {
$conventions[$key] = $data;
}
}
//$customConventions = api_get_configuration_value('name_order_conventions');
$search1 = ['FIRST_NAME', 'LAST_NAME', 'TITLE'];
$replacement1 = ['%F', '%L', '%T'];
$search2 = ['first_name', 'last_name', 'title'];
$replacement2 = ['%f', '%l', '%t'];
foreach (array_keys($conventions) as $key) {
$conventions[$key]['format'] = str_replace($search1, $replacement1, $conventions[$key]['format']);
$conventions[$key]['format'] = _api_validate_person_name_format(
$conventionsFormatted = [];
foreach ($conventions as $language) {
$iso = $language['isocode'];
$conventionsFormatted[$iso]['format'] = $language['format'];
$conventionsFormatted[$iso]['sort_by'] = $language['sort_by'];
$conventionsFormatted[$iso]['format'] = str_replace($search1, $replacement1, $conventionsFormatted[$iso]['format']);
$conventionsFormatted[$iso]['format'] = _api_validate_person_name_format(
_api_clean_person_name(
str_replace(
'%',
@ -2177,19 +2074,19 @@ function _api_get_person_name_convention($iso, $type)
str_ireplace(
$search2,
$replacement2,
$conventions[$key]['format']
$conventionsFormatted[$iso]['format']
)
)
)
);
$conventions[$key]['sort_by'] = 'last_name' !== strtolower($conventions[$key]['sort_by']) ? true : false;
$conventionsFormatted[$iso]['sort_by'] = 'last_name' !== strtolower($conventionsFormatted[$iso]['sort_by']) ? true : false;
}
switch ($type) {
case 'format':
return is_string($conventions[$languageName]['format']) ? $conventions[$languageName]['format'] : '%t %f %l';
return is_string($conventionsFormatted[$iso]['format']) ? $conventionsFormatted[$iso]['format'] : '%t %f %l';
case 'sort_by':
return is_bool($conventions[$languageName]['sort_by']) ? $conventions[$languageName]['sort_by'] : true;
return is_bool($conventionsFormatted[$iso]['sort_by']) ? $conventionsFormatted[$iso]['sort_by'] : true;
}
return null;

@ -339,7 +339,6 @@ class UserManager
$group = Container::$container->get(GroupRepository::class)->findOneBy(['code' => $statusToGroup[$status]]);
if ($group) {
$user->addGroup($group);
$repo->updateUser($user);
}
}

@ -20,14 +20,30 @@ class LanguageFixtures extends Fixture
->setOriginalName($data['original_name'])
->setEnglishName($data['english_name'])
->setIsocode($data['isocode'])
->setAvailable(1 === $data['available'])
;
->setAvailable(1 === $data['available']);
$manager->persist($lang);
}
$manager->flush();
}
/**
* The following table contains two types of conventions concerning person names:.
*
* "format" - determines how a full person name to be formatted, i.e. in what order the title,
* the first_name and the last_name to be placed.
* You might need to correct the value for your language. The possible values are:
* title first_name last_name - Western order;
* title last_name first_name - Eastern order;
* title last_name, first_name - Western libraries order.
* Placing the title (Dr, Mr, Miss, etc) depends on the tradition in you country.
*
* @see http://en.wikipedia.org/wiki/Personal_name#Naming_convention
*
* "sort_by" - determines you preferable way of sorting person names. The possible values are:
* first_name - sorting names with priority for the first name;
* last_name - sorting names with priority for the last name.
*/
public static function getLanguages(): array
{
return [
@ -36,84 +52,112 @@ class LanguageFixtures extends Fixture
'english_name' => 'arabic',
'isocode' => 'ar',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Asturianu',
'english_name' => 'asturian',
'isocode' => 'ast_ES',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Euskara',
'english_name' => 'basque',
'isocode' => 'eu_ES',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'ব',
'english_name' => 'bengali',
'isocode' => 'bn_BD',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Bosanski',
'english_name' => 'bosnian',
'isocode' => 'bs_BA',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Português do Brasil',
'english_name' => 'brazilian',
'isocode' => 'pt_PT',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Български',
'english_name' => 'bulgarian',
'isocode' => 'bg',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Català',
'english_name' => 'catalan',
'isocode' => 'ca_ES',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Hrvatski',
'english_name' => 'croatian',
'isocode' => 'hr_HR',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Česky',
'english_name' => 'czech',
'isocode' => 'cs_CZ',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Dansk',
'english_name' => 'danish',
'isocode' => 'da',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'دری',
'english_name' => 'dari',
'isocode' => 'fa_AF',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Nederlands',
'english_name' => 'dutch',
'isocode' => 'nl',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'English',
'english_name' => 'english',
'isocode' => 'en_US',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
/*[
'original_name' => 'Estonian',
@ -126,276 +170,373 @@ class LanguageFixtures extends Fixture
'english_name' => 'esperanto',
'isocode' => 'eo',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Føroyskt',
'english_name' => 'faroese',
'isocode' => 'fo_FO',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Suomi',
'english_name' => 'finnish',
'isocode' => 'fi_FI',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Français',
'english_name' => 'french',
'isocode' => 'fr_FR',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Furlan',
'english_name' => 'friulian',
'isocode' => 'fur',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Galego',
'english_name' => 'galician',
'isocode' => 'gl',
'available' => 0,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => 'ქართული',
'english_name' => 'georgian',
'isocode' => 'ka_GE',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Deutsch',
'english_name' => 'german',
'isocode' => 'de',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Ελληνικά',
'english_name' => 'greek',
'isocode' => 'el',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'עברית',
'english_name' => 'hebrew',
'isocode' => 'he_IL',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'हि',
'english_name' => 'hindi',
'isocode' => 'hi',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Magyar',
'english_name' => 'hungarian',
'isocode' => 'hu_HU',
'available' => 1,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => 'Bahasa Indonesia',
'english_name' => 'indonesian',
'isocode' => 'id_ID',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Italiano',
'english_name' => 'italian',
'isocode' => 'it',
'available' => 1,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => '日本語',
'english_name' => 'japanese',
'isocode' => 'ja',
'available' => 0,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => '한국어',
'english_name' => 'korean',
'isocode' => 'ko_KR',
'available' => 0,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => 'Latviešu',
'english_name' => 'latvian',
'isocode' => 'lv_LV',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Lietuvių',
'english_name' => 'lithuanian',
'isocode' => 'lt_LT',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Македонски',
'english_name' => 'macedonian',
'isocode' => 'mk_MK',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Bahasa Melayu',
'english_name' => 'malay',
'isocode' => 'ms_MY',
'available' => 0,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => 'Norsk',
'english_name' => 'norwegian',
'isocode' => 'nn_NO',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Occitan',
'english_name' => 'occitan',
'isocode' => 'oc',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'پښتو',
'english_name' => 'pashto',
'isocode' => 'ps',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'فارسی',
'english_name' => 'persian',
'isocode' => 'fa_IR',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Polski',
'english_name' => 'polish',
'isocode' => 'pl_PL',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Português europeu',
'english_name' => 'portuguese',
'isocode' => 'pt_PT',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Runasimi',
'english_name' => 'quechua_cusco',
'isocode' => 'quz_PE',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Română',
'english_name' => 'romanian',
'isocode' => 'ro_RO',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Русский',
'english_name' => 'russian',
'isocode' => 'ru_RU',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Srpski',
'english_name' => 'serbian',
'isocode' => 'sr_RS',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => '中文(简体',
'english_name' => 'simpl_chinese',
'isocode' => 'zh_CN',
'available' => 0,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => 'Slovenčina',
'english_name' => 'slovak',
'isocode' => 'sk_SK',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Slovenščina',
'english_name' => 'slovenian',
'isocode' => 'sl_SI',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'الصومالية',
'english_name' => 'somali',
'isocode' => 'so_SO',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Español',
'english_name' => 'spanish',
'isocode' => 'es',
'available' => 0,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => 'Kiswahili',
'english_name' => 'swahili',
'isocode' => 'sw_KE',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Svenska',
'english_name' => 'swedish',
'isocode' => 'sv_SE',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Tagalog',
'english_name' => 'tagalog',
'isocode' => 'tl_PH',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'ไทย',
'english_name' => 'thai',
'isocode' => 'th',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Tibetan',
'english_name' => 'tibetan',
'isocode' => 'bo_CN',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => '繁體中文',
'english_name' => 'trad_chinese',
'isocode' => 'zh_TW',
'available' => 0,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => 'Türkçe',
'english_name' => 'turkish',
'isocode' => 'tr',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Українська',
'english_name' => 'ukrainian',
'isocode' => 'uk_UA',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Tiếng Việt',
'english_name' => 'vietnamese',
'isocode' => 'vi_VN',
'available' => 0,
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
],
[
'original_name' => 'isiXhosa',
'english_name' => 'xhosa',
'isocode' => 'xh_ZA',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
[
'original_name' => 'Yorùbá',
'english_name' => 'yoruba',
'isocode' => 'yo_NG',
'available' => 0,
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
];
}

@ -27,6 +27,7 @@ class GroupRepository extends ServiceEntityRepository
$criteria = [
'name' => 'admins',
];
/** @var Group $group */
$group = $this->findOneBy($criteria);
@ -80,13 +81,9 @@ class GroupRepository extends ServiceEntityRepository
$manager = $this->getEntityManager();
$repo = $manager->getRepository(Group::class);
foreach ($groups as $groupData) {
$criteria = [
'code' => $groupData['code'],
];
$groupExists = $repo->findOneBy($criteria);
if (!$groupExists) {
$groupExists = $this->findOneBy(['code' => $groupData['code']]);
if (null === $groupExists) {
$group = new Group($groupData['title']);
$group
->setCode($groupData['code'])

Loading…
Cancel
Save