diff --git a/public/main/admin/configure_inscription.php b/public/main/admin/configure_inscription.php
deleted file mode 100644
index 87212fb2d3..0000000000
--- a/public/main/admin/configure_inscription.php
+++ /dev/null
@@ -1,359 +0,0 @@
-';
- echo $tool_name;
- echo '';
- if (!empty($term_preview['content'])) {
- echo $term_preview['content'];
- } else {
- echo get_lang('Coming soon...');
- }
- Display :: display_footer();
- exit;
- }
- }
-}
-
-$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
-
-$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
-$tool_name = get_lang('Setting the registration page');
-if (!empty($action)) {
- $interbreadcrumb[] = ['url' => 'configure_inscription.php', 'name' => get_lang('Setting the registration page')];
- switch ($action) {
- case 'edit_top':
- $tool_name = get_lang('Edit Note');
-
- break;
- }
-}
-
-$lang = ''; //el for "Edit Language"
-if (!empty($_SESSION['user_language_choice'])) {
- $lang = $_SESSION['user_language_choice'];
-} elseif (!empty($_SESSION['_user']['language'])) {
- $lang = $_SESSION['_user']['language'];
-} else {
- $lang = api_get_setting('platformLanguage');
-}
-
-// ----- Ensuring availability of main files in the corresponding language -----
-/*if (api_is_multiple_url_enabled()) {
- $access_url_id = api_get_current_access_url_id();
- if ($access_url_id != -1) {
- $url_info = api_get_access_url($access_url_id);
- $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
-
- $clean_url = api_replace_dangerous_char($url);
- $clean_url = str_replace('/', '-', $clean_url);
- $clean_url .= '/';
-
- $homep = api_get_path(SYS_APP_PATH).'home/'; //homep for Home Path
- $homep_new = api_get_path(SYS_APP_PATH).'home/'.$clean_url; //homep for Home Path added the url
- $new_url_dir = api_get_path(SYS_APP_PATH).'home/'.$clean_url;
- //we create the new dir for the new sites
- if (!is_dir($new_url_dir)) {
- mkdir($new_url_dir, api_get_permissions_for_new_directories());
- }
- }
-} else {
- $homep_new = '';
- $homep = api_get_path(SYS_APP_PATH).'home/'; //homep for Home Path
-}
-
-$topf = 'register_top'; //topf for Top File
-$ext = '.html'; //ext for HTML Extension - when used frequently, variables are
-$homef = [$topf];
-
-// If language-specific file does not exist, create it by copying default file
-foreach ($homef as $my_file) {
- if (api_is_multiple_url_enabled()) {
- if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
- copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
- }
- } else {
- if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
- copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext);
- }
- }
-}
-
-if (!empty($homep_new)) {
- $homep = $homep_new;
-}
-
-if (!empty($action)) {
- if (isset($_POST['formSent'])) {
- switch ($action) {
- case 'edit_top':
- // Filter
- $home_top = trim(stripslashes($_POST['register_top']));
- // Write
- if (file_exists($homep.$topf.'_'.$lang.$ext)) {
- if (is_writable($homep.$topf.'_'.$lang.$ext)) {
- $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
- fputs($fp, $home_top);
- fclose($fp);
- } else {
- $errorMsg = get_lang('Homepage-files are not writable!');
- }
- } else {
- //File does not exist
- $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
- fputs($fp, $home_top);
- fclose($fp);
- }
- break;
- }
- if (empty($errorMsg)) {
- header('Location: '.api_get_self());
- exit();
- }
- } else {
- switch ($action) {
- case 'edit_top':
- // This request is only the preparation for the update of the home_top
- $home_top = '';
- if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
- $home_top = @(string) file_get_contents($homep.$topf.'_'.$lang.$ext);
- } elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
- $home_top = @(string) file_get_contents($homep.$topf.$lang.$ext);
- } else {
- $errorMsg = get_lang('Homepage files are not readable');
- }
- $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
- break;
- }
- }
-}*/
-
-$form = new FormValidator('registration');
-if ('true' === api_get_setting('allow_terms_conditions')) {
- $display_all_form = !isset($_SESSION['update_term_and_condition']['user_id']);
-} else {
- $display_all_form = true;
-}
-
-if ($display_all_form) {
- if (api_is_western_name_order()) {
- // FIRST NAME and LAST NAME
- $form->addElement('text', 'firstname', get_lang('First name'), ['size' => 40, 'disabled' => 'disabled']);
- $form->addElement('text', 'lastname', get_lang('Last name'), ['size' => 40, 'disabled' => 'disabled']);
- } else {
- // LAST NAME and FIRST NAME
- $form->addElement('text', 'lastname', get_lang('Last name'), ['size' => 40, 'disabled' => 'disabled']);
- $form->addElement('text', 'firstname', get_lang('First name'), ['size' => 40, 'disabled' => 'disabled']);
- }
- $form->applyFilter('firstname', 'trim');
- $form->applyFilter('lastname', 'trim');
- $form->addRule('lastname', get_lang('Required field'), 'required');
- $form->addRule('firstname', get_lang('Required field'), 'required');
-
- // EMAIL
- $form->addElement('text', 'email', get_lang('e-mail'), ['size' => 40, 'disabled' => 'disabled']);
- if ('true' == api_get_setting('registration', 'email')) {
- $form->addRule('email', get_lang('Required field'), 'required');
- }
- $form->addEmailRule('email');
-
- // USERNAME
- $form->addElement('text', 'username', get_lang('Username'), ['size' => \Chamilo\CoreBundle\Entity\User::USERNAME_MAX_LENGTH, 'disabled' => 'disabled']);
- $form->addRule('username', get_lang('Required field'), 'required');
- $form->addRule('username', get_lang('Your login can only contain letters, numbers and _.-'), 'username');
- $form->addRule('username', get_lang('This login is already in use'), 'username_available');
- $form->addRule('username', sprintf(get_lang('The login needs to be maximum %s characters long'), (string) \Chamilo\CoreBundle\Entity\User::USERNAME_MAX_LENGTH), 'maxlength', \Chamilo\CoreBundle\Entity\User::USERNAME_MAX_LENGTH);
-
- // PASSWORD
- $form->addElement('password', 'pass1', get_lang('Pass'), ['size' => 40, 'disabled' => 'disabled']);
- $form->addElement('password', 'pass2', get_lang('Confirm password'), ['size' => 40, 'disabled' => 'disabled']);
- $form->addRule('pass1', get_lang('Required field'), 'required');
- $form->addRule('pass2', get_lang('Required field'), 'required');
- $form->addRule(['pass1', 'pass2'], get_lang('You have typed two different passwords'), 'compare');
- $form->addPasswordRule('pass1');
-
- // PHONE
- $form->addElement('text', 'phone', get_lang('Phone'), ['size' => 40, 'disabled' => 'disabled']);
- if ('true' == api_get_setting('registration', 'phone')) {
- $form->addRule('phone', get_lang('Required field'), 'required');
- }
-
- // LANGUAGE
- if ('true' == api_get_setting('registration', 'language')) {
- $form->addSelectLanguage(
- 'language',
- get_lang('Language'),
- '',
- ['disabled' => 'disabled']
- );
- }
-
- // STUDENT/TEACHER
- if ('false' != api_get_setting('allow_registration_as_teacher')) {
- $form->addElement('radio', 'status', get_lang('Status'), get_lang('Student (follows courses)'), STUDENT, ['disabled' => 'disabled']);
- $form->addElement('radio', 'status', null, get_lang('Teacher (creates courses)'), COURSEMANAGER, ['disabled' => 'disabled']);
- }
-
- // EXTENDED FIELDS
- if ('true' == api_get_setting('extended_profile') &&
- 'true' == api_get_setting('extendedprofile_registration', 'mycomptetences')
- ) {
- $form->addHtmlEditor('competences', get_lang('My competences'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']);
- }
-
- if ('true' == api_get_setting('extended_profile') &&
- 'true' == api_get_setting('extendedprofile_registration', 'mydiplomas')
- ) {
- $form->addHtmlEditor('diplomas', get_lang('My diplomas'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']);
- }
-
- if ('true' == api_get_setting('extended_profile') &&
- 'true' == api_get_setting('extendedprofile_registration', 'myteach')
- ) {
- $form->addHtmlEditor('teach', get_lang('What I am able to teach'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']);
- }
-
- if ('true' == api_get_setting('extended_profile') &&
- 'true' == api_get_setting('extendedprofile_registration', 'mypersonalopenarea')
- ) {
- $form->addHtmlEditor('openarea', get_lang('My personal open area'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']);
- }
-
- if ('true' == api_get_setting('extended_profile')) {
- if ('true' == api_get_setting('extendedprofile_registrationrequired', 'mycomptetences')) {
- $form->addRule('competences', get_lang('Required field'), 'required');
- }
- if ('true' == api_get_setting('extendedprofile_registrationrequired', 'mydiplomas')) {
- $form->addRule('diplomas', get_lang('Required field'), 'required');
- }
- if ('true' == api_get_setting('extendedprofile_registrationrequired', 'myteach')) {
- $form->addRule('teach', get_lang('Required field'), 'required');
- }
- if ('true' == api_get_setting('extendedprofile_registrationrequired', 'mypersonalopenarea')) {
- $form->addRule('openarea', get_lang('Required field'), 'required');
- }
- }
-
- $extraField = new ExtraField('user');
- $extraField->addElements($form);
-}
-
-// Terms and conditions
-if ('true' == api_get_setting('allow_terms_conditions')) {
- $language = api_get_language_isocode();
- $language = api_get_language_id($language);
- $term_preview = LegalManager::get_last_condition($language);
-
- if (!$term_preview) {
- //we load from the platform
- $language = api_get_setting('platformLanguage');
- $language = api_get_language_id($language);
- $term_preview = LegalManager::get_last_condition($language);
- //if is false we load from english
- if (!$term_preview) {
- $language = api_get_language_id('english'); //this must work
- $term_preview = LegalManager::get_last_condition($language);
- }
- }
-
- // Version and language //password
- $form->addElement('hidden', 'legal_accept_type', $term_preview['version'].':'.$term_preview['language_id']);
- $form->addElement('hidden', 'legal_info', $term_preview['id'].':'.$term_preview['language_id']);
-
- if (1 == $term_preview['type']) {
- $form->addElement(
- 'checkbox',
- 'legal_accept',
- null,
- get_lang('I have read and agree to the').' '.get_lang('Terms and Conditions').''
- );
- $form->addRule('legal_accept', get_lang('Required field'), 'required');
- } else {
- if (!empty($term_preview['content'])) {
- $preview = LegalManager::show_last_condition($term_preview);
- $form->addElement('label', get_lang('Terms and Conditions'), $preview);
- }
- }
-}
-
-$form->addButtonSave(get_lang('Register'));
-
-$defaults['status'] = STUDENT;
-
-if (isset($_SESSION['user_language_choice']) && '' != $_SESSION['user_language_choice']) {
- $defaults['language'] = $_SESSION['user_language_choice'];
-} else {
- $defaults['language'] = api_get_setting('platformLanguage');
-}
-
-if (!empty($_GET['username'])) {
- $defaults['username'] = Security::remove_XSS($_GET['username']);
-}
-
-if (!empty($_GET['email'])) {
- $defaults['email'] = Security::remove_XSS($_GET['email']);
-}
-
-if (!empty($_GET['phone'])) {
- $defaults['phone'] = Security::remove_XSS($_GET['phone']);
-}
-
-$form->setDefaults($defaults);
-
-$tpl = new Template();
-
-$content = Display::page_header($tool_name);
-
-// The following security condition has been removed, because it makes no sense here. See Bug #1846.
-//// Forbidden to self-register
-//if (api_get_setting('allow_registration') == 'false') {
-// api_not_allowed();
-//}
-
-//Display::page_subheader2($tool_name);
-if ('approval' == api_get_setting('allow_registration')) {
- $content .= Display::return_message(get_lang('Your account has to be approved'), 'normal');
-}
-
-$url = api_get_path(WEB_PUBLIC_PATH).'internal_page/edit/inscription';
-//Form of language
-//$content .= api_display_language_form();
-$content .= ' '.
- Display::return_icon('edit.gif', get_lang('Edit')).'
- '.get_lang('Edit notice').'';
-
-$content .= $form->returnForm();
-
-//$page = Container::getPage('inscription');
-//$tpl->assign('page', $page);
-$tpl->assign('form', $content);
-
-$templateName = $tpl->get_template('auth/inscription_edit.html.twig');
-$tpl->display($templateName);
diff --git a/public/main/cron/lang/check_parse_lang.php b/public/main/cron/lang/check_parse_lang.php
deleted file mode 100644
index e17f1abe8a..0000000000
--- a/public/main/cron/lang/check_parse_lang.php
+++ /dev/null
@@ -1,41 +0,0 @@
-db_type) {
- case 'sqlite':
- if (!class_exists('SQLite3')) {
- $this->error = 'SQLiteNotAvailable';
-
- return false; //cannot use if sqlite not installed
- }
- if (empty($file)) {
- $file = api_get_path(SYS_ARCHIVE_PATH).'/langstasdb';
- }
- if (is_file($file) && is_writeable($file)) {
- $this->db = new SQLite3($file, SQLITE3_OPEN_READWRITE);
- } else {
- try {
- $this->db = new SQLite3($file);
- } catch (Exception $e) {
- $this->error = 'DatabaseCreateError';
- error_log('Exception: '.$e->getMessage());
-
- return false;
- }
- $err = $this->db->exec(
- 'CREATE TABLE lang_freq ('
- .' id integer PRIMARY KEY AUTOINCREMENT, ' //autoincrement in SQLITE
- .' term_name text, term_file text, term_count integer default 0)'
- );
- if (false === $err) {
- $this->error = 'CouldNotCreateTable';
-
- return false;
- }
- $err = $this->db->exec(
- 'CREATE INDEX lang_freq_terms_idx ON lang_freq(term_name, term_file)'
- );
- if (false === $err) {
- $this->error = 'CouldNotCreateIndex';
-
- return false;
- }
- // Table and index created, move on.
- }
- break;
- case 'mysql': //implementation not finished
- if (!function_exists('mysql_connect')) {
- $this->error = 'SQLiteNotAvailable';
-
- return false; //cannot use if sqlite not installed
- }
- $err = Database::query('SELECT * FROM lang_freq');
- if (false === $err) { //the database probably does not exist, create it
- $err = Database::query(
- 'CREATE TABLE lang_freq ('
- .' id int PRIMARY KEY AUTO_INCREMENT, '
- .' term_name text, term_file text default \'\', term_count int default 0)'
- );
- if (false === $err) {
- $this->error = 'CouldNotCreateTable';
-
- return false;
- }
- } // if no error, we assume the table exists
- break;
- }
-
- return $this->db;
- }
-
- /**
- * Add a count for a specific term.
- *
- * @param string The language term used
- * @param string The file from which the language term came from
- *
- * @return mixed
- */
- public function add_use($term, $term_file = '')
- {
- $term = $this->db->escapeString($term);
- $term_file = $this->db->escapeString($term_file);
- $sql = "SELECT id, term_name, term_file, term_count FROM lang_freq WHERE term_name='$term' and term_file='$term_file'";
- $ress = $this->db->query($sql);
- if (false === $ress) {
- $this->error = 'CouldNotQueryTermFromTable';
-
- return false;
- }
- $i = 0;
- while ($row = $ress->fetchArray(SQLITE3_BOTH)) {
- $num = $row[3];
- $num++;
- $i++;
- $res = $this->db->query(
- 'UPDATE lang_freq SET term_count = '.$num.' WHERE id = '.$row[0]
- );
- if (false === $res) {
- $this->error = 'CouldNotUpdateTerm';
-
- return false;
- } else {
- return $row[0];
- }
- }
- if (0 == $i) {
- //No term found in the table, register as new term
- $resi = $this->db->query(
- "INSERT INTO lang_freq(term_name, term_file, term_count) VALUES ('$term', '$term_file', 1)"
- );
- if (false === $resi) {
- $this->error = 'CouldNotInsertRow';
-
- return false;
- } else {
- return $this->db->lastInsertRowID();
- }
- }
-
- return true;
- }
-
- /**
- * Function to get a list of the X most-requested terms.
- *
- * @param int Limit of terms to show
- *
- * @return array List of most requested terms
- */
- public function get_popular_terms($num = 1000)
- {
- $num = (int) $num;
- $res = $this->db->query(
- 'SELECT * FROM lang_freq
- ORDER BY term_count DESC LIMIT '.$num
- );
- $list = [];
- while ($row = $res->fetchArray()) {
- $list[] = $row;
- }
-
- return $list;
- }
-
- /**
- * Clear all records in lang_freq.
- *
- * @return resource true
- */
- public function clear_all()
- {
- $res = sqlite_query($this->db, 'DELETE FROM lang_freq WHERE 1=1');
-
- return $res;
- }
-
- /**
- * Returns an array of all the language variables with their corresponding
- * file of origin. This function tolerates a certain rate of error due to
- * the duplication of variables in language files.
- *
- * @return array variable => origin file
- */
- public function get_variables_origin()
- {
- $path = api_get_path(SYS_LANG_PATH).'english/';
- $vars = [];
- $priority = ['trad4all'];
- foreach ($priority as $file) {
- $list = SubLanguageManager::get_all_language_variable_in_file(
- $path.$file.'.inc.php',
- true
- );
- foreach ($list as $var => $trad) {
- $vars[$var] = $file.'.inc.php';
- }
- }
- $files = scandir($path);
- foreach ($files as $file) {
- if ('.' == substr($file, 0, 1) or in_array($file, $priority)) {
- continue;
- }
- $list = SubLanguageManager::get_all_language_variable_in_file(
- $path.$file,
- true
- );
- foreach ($list as $var => $trad) {
- $vars[$var] = $file;
- }
- }
-
- return $vars;
- }
-}
diff --git a/public/main/cron/lang/langstats.php b/public/main/cron/lang/langstats.php
deleted file mode 100644
index 118ed52bc9..0000000000
--- a/public/main/cron/lang/langstats.php
+++ /dev/null
@@ -1,84 +0,0 @@
-error);
-}
-$list = $ls->get_popular_terms($x_most_popular);
-if (1 == $_GET['output']) {
- $output = true;
- $variables_origin = $ls->get_variables_origin();
-}
-/**
- * Display.
- */
-if (0 == count($list)) {
- echo 'No terms loaded so far';
-}
-if (count($list) > 0) {
- $i = 1;
- $j = 1;
- $k = 0;
- $files = [];
- $trans = [];
- echo 'Number of records: '.count($list).'
';
- echo '
| Index | Registration order | Term | '.(1 == $output ? 'Origin | ' : '').'Count |
';
- foreach ($list as $elem) {
- if ($k > $terms_limit) {
- break;
- }
- $fixed_elem = $elem;
- if ($output) {
- if (empty($variables_origin[$elem['term_name']]) && !empty($variables_origin['lang'.$elem['term_name']])) {
- $fixed_elem = ['id' => $elem['id'], 'term_name' => 'lang'.$elem['term_name'], 'term_count' => $elem['term_count']];
- }
- if (empty($variables_origin[$fixed_elem['term_name']])) {
- continue;
- }
- $files[$variables_origin[$fixed_elem['term_name']]][] = $fixed_elem['term_name'];
- $translation = get_lang($fixed_elem['term_name']);
- $k += str_word_count($translation);
- $trans[$fixed_elem['term_name']] = $translation;
- $j++;
- }
- echo '| ', $i,
- ' | ', $fixed_elem['id'],
- ' | ', $fixed_elem['term_name'];
- if ($output) {
- echo ' | '.$variables_origin[$fixed_elem['term_name']];
- }
- echo ' | ', $fixed_elem['term_count'], ' |
';
- $i++;
- }
- echo '
';
- if ($output) {
- @mkdir('/tmp/lang');
- foreach ($files as $file => $terms) {
- @touch('/tmp/lang/'.$file);
- file_put_contents('/tmp/lang/'.$file, "get_popular_terms($terms_limit);
-$words_counter = 0;
-$i = 0;
-$terms_in_limit = [];
-$lang_dir = api_get_path(SYS_LANG_PATH);
-$arch_dir = api_get_path(SYS_ARCHIVE_PATH);
-/**
- * Code run.
- */
-foreach ($terms as $row) {
- if ($words_counter > 10000) {
- break;
- }
- $words = str_word_count(get_lang($row['term_name'], null, $orig_lang));
- $words_counter += $words;
- $terms_in_limit[$row['term_name']] = $i;
- //echo "Term ".$row['term_name']." is '".get_lang($row['term_name'],null,$orig_lang)."' which means $words words
\n";
- //if ($words_counter%1000 >= 0) {
- //echo "Reached $words_counter words at term $i (".$row['term_name']." used ".$row['term_count']." times)...
\n";
- //}
- $i++;
-}
-//echo $words_counter.'
';
-
-echo "Reached ".count($terms_in_limit)." terms for the $words_counter most-used words
\n";
-
-echo "Scanning English files, trying to find these terms...
\n";
-if (!is_dir($arch_dir.'/langstats')) {
- mkdir($arch_dir.'/langstats');
- mkdir($arch_dir.'/langstats/'.$orig_lang);
-}
-$list_files = scandir($lang_dir.'/'.$orig_lang);
-$j = 1;
-$terms_found = [];
-$words_found = 0;
-$global_var = []; //keep the combination of all vars
-$terms_in_limit = array_flip($terms_in_limit);
-foreach ($list_files as $file) {
- if ('.' == substr($file, 0, 1)) {
- continue;
- }
- //echo "'".substr($file,0,-8)."',
"; //print in a PHP array format
- $vars = file($lang_dir.'/'.$orig_lang.'/'.$file);
- $local_var = [];
- $file_string = ' 0) {
- //echo $var[1]."
";
-
- if (in_array(substr($var[1], 1), $terms_in_limit)) {
- //echo "Var ".$var[1]." was in the limit
";
- $local_var[$var[1]] = $line;
- $file_string .= $line;
- $terms_found[] = substr($var[1], 1); //e.g. store Tools
- $words_found += str_word_count(get_lang($var[1], null, $orig_lang));
- } elseif (in_array(substr($var[1], 5), $terms_in_limit)) {
- //echo "Var ".$var[1]." was in the limit
";
- $local_var[$var[1]] = $line;
- $file_string .= $line;
- $terms_found[] = substr($var[1], 5); //e.g. store langTools
- $words_found += str_word_count(get_lang(substr($var[1], 5), null, $orig_lang));
- } //else do not care
- }
- }
- echo "Writing ".$arch_dir.'/langstats/'.$orig_lang.'/'.$file."
\n";
- file_put_contents($arch_dir.'/langstats/'.$orig_lang.'/'.$file, $file_string);
- $global_var += $local_var;
-}
-$terms_diff = count($global_var) - count($terms_in_limit);
-echo count(
- $global_var
- )." terms found in English files (summing up to $words_found words). Some terms ($terms_diff in this case) might have appeared in two different files
";
-/**
- * Display results.
- */
-echo "Difference between filtered and found in English:
";
-//print_r($terms_found);
-echo "".print_r(array_diff($terms_in_limit, $terms_found), 1)."
";
-echo "#";
diff --git a/public/main/cron/lang/list_undefined_langvars.php b/public/main/cron/lang/list_undefined_langvars.php
deleted file mode 100644
index ef2882633f..0000000000
--- a/public/main/cron/lang/list_undefined_langvars.php
+++ /dev/null
@@ -1,81 +0,0 @@
-";
- $shortfile = substr($file, $l);
- $lines = file($file);
- foreach ($lines as $line) {
- $myterms = [];
- $res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myterms);
- if ($res > 0) {
- foreach ($myterms[1] as $term) {
- if (!isset($defined_terms[$term]) && !isset($defined_terms['lang'.$term])) {
- $undefined_terms[$term] = $shortfile;
- //echo "Undefined: $term
";
- }
- }
- }
- $res = 0;
- $res = preg_match_all('/\{[\'"](\\w*)[\'"]\|get_lang\}/', $line, $myterms);
- if ($res > 0) {
- foreach ($myterms[1] as $term) {
- if (!isset($defined_terms[$term]) && !isset($defined_terms['lang'.$term])) {
- $undefined_terms[$term] = $shortfile;
- //echo "Undefined: $term
";
- }
- }
- }
- }
- flush();
-}
-//$undefined_terms = array_flip($undefined_terms);
-if (count($undefined_terms) < 1) {
- exit("No missing terms
\n");
-} else {
- echo "The following terms were nowhere to be found:
\n";
-}
-$i = 1;
-foreach ($undefined_terms as $term => $file) {
- $isPlugin = 'plugin/' == substr($file, 0, 7);
- echo "| $i | $term | in $file";
- if ($isPlugin) {
- echo " (this one should be taken care of by the plugin's language files)";
- }
- echo " |
\n";
- $i++;
-}
-echo "
\n";
diff --git a/public/main/cron/lang/list_unused_langvars.php b/public/main/cron/lang/list_unused_langvars.php
deleted file mode 100644
index 5861a24616..0000000000
--- a/public/main/cron/lang/list_unused_langvars.php
+++ /dev/null
@@ -1,127 +0,0 @@
-";
-
-// now get all terms found in all PHP files of Chamilo (this takes some
-// time and memory)
-$usedTerms = [];
-$l = strlen(api_get_path(SYS_PATH));
-$files = getAllPhpFiles(api_get_path(SYS_PATH));
-$files[] = api_get_path(SYS_PATH).'main/install/data.sql';
-// Browse files
-foreach ($files as $file) {
- //echo 'Analyzing '.$file."
";
- $shortFile = substr($file, $l);
- //echo 'Analyzing '.$shortFile."
";
- $lines = file($file);
- $isDataSQL = false;
- if ('main/install/data.sql' === substr($file, -21)) {
- $isDataSQL = true;
- }
- // Browse lines inside file $file
- foreach ($lines as $line) {
- if ($isDataSQL) {
- // Check main/install/data.sql
- // Should recognize stuff like
- // INSERT INTO settings_current (variable, type, category, selected_value, title, comment) VALUES ('enable_profile_user_address_geolocalization', 'radio', 'User', 'false', 'EnableProfileUsersAddressGeolocalizationTitle', 'EnableProfileUsersAddressGeolocalizationComment');
- // INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_profile_user_address_geolocalization', 'true', 'Yes');
- // ('show_teacher_data',NULL,'radio','Platform','true','ShowTeacherDataTitle','ShowTeacherDataComment',NULL,NULL, 1),
- $res = 0;
- $myTerms = [];
- $res = preg_match_all('/\'(\w*)\',/', $line, $myTerms);
- if ($res > 0) {
- foreach ($myTerms[1] as $term) {
- if ('lang' == substr($term, 0, 4)) {
- $term = substr($term, 4);
- }
- $usedTerms[$term] = $shortFile;
- }
- }
- } else {
- $myTerms = [];
- $res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myTerms);
- if ($res > 0) {
- foreach ($myTerms[1] as $term) {
- if ('lang' == substr($term, 0, 4)) {
- $term = substr($term, 4);
- }
- $usedTerms[$term] = $shortFile;
- }
- } else {
- $res = 0;
- $myTerms = [];
- // Should catch:
- // {{ 'CopyTextToClipboard' | get_lang }}
- // {{ "HelloX" | get_lang | format(show_user_info.user_info.complete_name) }}
- // {{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
- $res = preg_match_all('/\{\s*[\'"](\w*)[\'"]\s*\|\s*get_lang\s*(\|\s*\w*(\s*\([\w_\.,\s]*\))?\s*)?\}/', $line, $myTerms);
- if ($res > 0) {
- foreach ($myTerms[1] as $term) {
- if ('lang' == substr($term, 0, 4)) {
- $term = substr($term, 4);
- }
- $usedTerms[$term] = $shortFile;
- }
- }
- // {{ display.panel('PersonalDataResponsibleOrganizationTitle' | get_lang , personal_data.responsible ) }}
- // {{ display.panel('PersonalDataIntroductionTitle' | get_lang , 'PersonalDataIntroductionText' | get_lang) }}
- $myTerms = [];
- $res = preg_match_all('/\{\s*[\w\.]*\([\'"](\w*)[\'"]\s*\|\s*get_lang\s*(,\s*[\w_\.,\s\|\'"]*\s*)?\)\s*\}/', $line, $myTerms);
- if ($res > 0) {
- foreach ($myTerms[1] as $term) {
- if ('lang' == substr($term, 0, 4)) {
- $term = substr($term, 4);
- }
- $usedTerms[$term] = $shortFile;
- }
- }
- }
- }
- }
- flush();
-}
-
-// Compare defined terms VS used terms. Used terms should be smaller than
-// defined terms, and this should prove the concept that there are much
-// more variables than what we really use
-if (count($usedTerms) < 1) {
- exit("No used terms
\n");
-} else {
- echo "The following terms were defined but never used:
\n";
-}
-$i = 1;
-foreach ($defined_terms as $term => $file) {
- // remove "lang" prefix just in case
- if ('lang' == substr($term, 0, 4)) {
- $term = substr($term, 4);
- }
- if (!isset($usedTerms[$term])) {
- echo "| $i | $term |
\n";
- $i++;
- }
-}
-echo "
\n";
diff --git a/public/main/cron/lang/switch_files_to_gettext.php b/public/main/cron/lang/switch_files_to_gettext.php
deleted file mode 100644
index 0acd9ab42e..0000000000
--- a/public/main/cron/lang/switch_files_to_gettext.php
+++ /dev/null
@@ -1,90 +0,0 @@
- $translation) {
- $terms[$index] = trim(rtrim($translation, ';'), '"');
-}
-// get only the array keys (the language variables defined in language files)
-$defined_terms = array_flip(array_keys($terms));
-echo count($defined_terms)." terms were found in language files".PHP_EOL;
-
-// now get all terms found in all PHP files of Chamilo (this takes some
-// time and memory)
-$usedTerms = [];
-$l = strlen(api_get_path(SYS_PATH));
-$files = getAllPhpFiles(api_get_path(SYS_PATH));
-$rootLength = strlen(api_get_path(SYS_PATH));
-$countFiles = 0;
-$countReplaces = 0;
-// Browse files
-foreach ($files as $file) {
- if ('vendor' === substr($file, $rootLength, 6) || 'web' === substr($file, $rootLength, 3)) {
- continue;
- }
- //echo 'Analyzing '.$file.PHP_EOL;
- $shortFile = substr($file, $l);
- //echo 'Analyzing '.$shortFile.PHP_EOL;
- $lines = file($file);
- // Browse lines inside file $file
- foreach ($lines as $line) {
- $myTerms = [];
- $res = preg_match_all('/get_lang\(([\'"](\\w*)[\'"])\)/m', $line, $myTerms);
- if ($res > 0) {
- foreach ($myTerms[2] as $term) {
- echo "Found term $term - ".print_r($myTerms, 1).PHP_EOL;
- if ('lang' == substr($term, 0, 4)) {
- $term = substr($term, 4);
- }
- if (!empty($terms[$term])) {
- $translation = $terms[$term];
- $quotedTerm = $myTerms[1][0];
- //echo "Would do sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
- system("sed -i \"s#$term#'$translation'#g\" $file");
- $countReplaces++;
- }
- }
- } else {
- $res = 0;
- $res = preg_match_all('/\{\s*([\'"](\\w*)[\'"])\s*\|get_lang\}/m', $line, $myTerms);
- if ($res > 0) {
- foreach ($myTerms[2] as $term) {
- echo "Found term $term".PHP_EOL;
- if ('lang' == substr($term, 0, 4)) {
- $term = substr($term, 4);
- }
- if (!empty($terms[$term])) {
- $translation = $terms[$term];
- $quotedTerm = $myTerms[1][0];
- //echo "Would do sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
- system("sed -i \"s#$term#'$translation'#g\" $file");
- $countReplaces++;
- }
- }
- }
- }
- }
- $countFiles++;
- flush();
-}
-
-echo "Done analyzing $countFiles files, with $countReplaces replacements!\n";
diff --git a/public/main/inc/lib/usermanager.lib.php b/public/main/inc/lib/usermanager.lib.php
index 38026dcab6..3d8cf7c59e 100644
--- a/public/main/inc/lib/usermanager.lib.php
+++ b/public/main/inc/lib/usermanager.lib.php
@@ -3750,19 +3750,6 @@ class UserManager
* @todo we don't create tags with numbers
*
*/
- if (is_numeric($tag)) {
- //the form is sending an id this means that the user select it from the list so it MUST exists
- /* $new_tag_id = self::get_tag_id_from_id($tag,$field_id);
- if ($new_tag_id !== false) {
- $sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id = $new_tag_id";
- $result = Database::query($sql);
- $last_insert_id = $new_tag_id;
- } else {
- $sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)";
- $result = Database::query($sql);
- $last_insert_id = Database::insert_id();
- } */
- }
//this is a new tag
if (0 == $tag_id) {
diff --git a/public/main/index.html b/public/main/index.html
deleted file mode 100644
index 74651721e8..0000000000
--- a/public/main/index.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/public/main/survey/survey.lib.php b/public/main/survey/survey.lib.php
index 4af239d4a9..f6dbb054be 100644
--- a/public/main/survey/survey.lib.php
+++ b/public/main/survey/survey.lib.php
@@ -360,15 +360,6 @@ class SurveyManager
api_get_course_int_id(),
api_get_session_id()
);
-
- // Insert into item_property
- /*api_item_property_update(
- api_get_course_info(),
- TOOL_SURVEY,
- $survey_id,
- 'SurveyAdded',
- api_get_user_id()
- );*/
}
if (1 == $values['survey_type'] && !empty($values['parent_id'])) {
@@ -611,17 +602,6 @@ class SurveyManager
$params['invited'] = 0;
$params['answered'] = 0;
$new_survey_id = Database::insert($table_survey, $params);
-
- if ($new_survey_id) {
- // Insert into item_property
- /*api_item_property_update(
- api_get_course_info(),
- TOOL_SURVEY,
- $new_survey_id,
- 'SurveyAdded',
- api_get_user_id()
- );*/
- }
} else {
$new_survey_id = (int) $new_survey_id;
}