]> git.mxchange.org Git - friendica.git/commitdiff
Fixes some more things
authorJeroen De Meerleer <me@jeroened.be>
Mon, 24 Dec 2018 09:53:44 +0000 (10:53 +0100)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 21 Jan 2019 14:45:37 +0000 (09:45 -0500)
config/dbstructure.config.php
mod/profiles.php
update.php

index a59b7c361ea034cf6ac35f053d49d769089ffe8c..0be6ba4028460de32a3adf57a3826ccd9e3215dc 100644 (file)
@@ -34,7 +34,7 @@
 use Friendica\Database\DBA;
 
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1297);
+       define('DB_UPDATE_VERSION', 1298);
 }
 
 return [
index 6a32fbee5a75e916d0143b4b880ce35552d41b97..70917d7df8ff019cba3e0e10b1ee202e4ad5b055 100644 (file)
@@ -618,11 +618,11 @@ function profiles_content(App $a) {
                        '$postal_code' => ['postal_code', L10n::t('Postal/Zip Code:'), $r[0]['postal-code']],
                        '$country_name' => ['country_name', L10n::t('Country:'), $r[0]['country-name']],
                        '$age' => ((intval($r[0]['dob'])) ? '(' . L10n::t('Age: ') . Temporal::getAgeByTimezone($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
-                       '$gender' => ContactSelector::gender($r[0]['gender']),
-                       '$marital' => ['selector' => ContactSelector::maritalStatus($r[0]['marital']), 'value' => $r[0]['marital']],
+                       '$gender' => L10n::t(ContactSelector::gender($r[0]['gender'])),
+                       '$marital' => ['selector' => ContactSelector::maritalStatus($r[0]['marital']), 'value' => L10n::t($r[0]['marital'])],
                        '$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],
                        '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= DBA::NULL_DATETIME ? '' : DateTimeFormat::local($r[0]['howlong']))],
-                       '$sexual' => ['selector' => ContactSelector::sexualPreference($r[0]['sexual']), 'value' => $r[0]['sexual']],
+                       '$sexual' => ['selector' => ContactSelector::sexualPreference($r[0]['sexual']), 'value' => L10n::t($r[0]['sexual'])],
                        '$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']],
                        '$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")],
                        '$homepage' => ['homepage', L10n::t('Homepage URL:'), $r[0]['homepage']],
index 4fb3144920778a1db49bef25642b59541758e5f8..d608669f169f66dda39b8e6af07bdd06ccf38a32 100644 (file)
@@ -291,16 +291,17 @@ function update_1288()
        return Update::SUCCESS;
 }
 
-       
 // Post-update script of PR 5751
-function update_1293()
+function update_1296()
 {
-       $allGenders = DBA::select('contact', ['id', 'gender']);
+       $translateKey = 'gender';
+       $allData = DBA::select('profile', ['id', $translateKey]);
        $allLangs = L10n::getAvailableLanguages();
        $success = 0;
        $fail = 0;
-       foreach ($allGenders as $key => $gender) {
-               if ($gender['gender'] != '') {
+       foreach ($allData as $key => $data) {
+               $toTranslate = $data[$translateKey];
+               if ($toTranslate != '') {
                        foreach ($allLangs as $key => $lang) {
                                $a = new \stdClass();
                                $a->strings = [];
@@ -316,7 +317,7 @@ function update_1293()
                                $localizedStrings = $a->strings;
                                unset($a);
 
-                               $key = array_search($gender['gender'], $localizedStrings);
+                               $key = array_search($toTranslate, $localizedStrings);
                                if ($key !== false) {
                                        break;
                                }
@@ -328,14 +329,122 @@ function update_1293()
                        if ($key == '') {
                                $fail++;
                        } else {
-                               DBA::update('contact', ['gender' => $key], ['id' => $gender['id']]);
-                               logger::log('Updated contact ' . $gender['id'] . ' to gender ' . $key .
-                                       ' (was: ' . $gender['gender'] . ')');
+                               DBA::update('profile', [$translateKey => $key], ['id' => $data['id']]);
+                               logger::log('Updated contact ' . $data['id'] . " to $translateKey " . $key .
+                                       ' (was: ' . $data[$translateKey] . ')');
+                               Worker::add(PRIORITY_LOW, 'ProfileUpdate', $data['id']);                
+                               Contact::updateSelfFromUserID($data['id']);
+                               GContact::updateForUser($data['id']);
                                $success++;
                        }
                }
        }
 
-       Logger::log("Gender fix completed. Success: $success. Fail: $fail");
+       Logger::log($translateKey . " fix completed. Success: $success. Fail: $fail");
        return Update::SUCCESS;
 }
+// Post-update script of PR 5751
+function update_1297()
+{
+       $translateKey = 'marital';
+       $allData = DBA::select('profile', ['id', $translateKey]);
+       $allLangs = L10n::getAvailableLanguages();
+       $success = 0;
+       $fail = 0;
+       foreach ($allData as $key => $data) {
+               $toTranslate = $data[$translateKey];
+               if ($toTranslate != '') {
+                       foreach ($allLangs as $key => $lang) {
+                               $a = new \stdClass();
+                               $a->strings = [];
+
+                               // First we get the the localizations
+                               if (file_exists("view/lang/$lang/strings.php")) {
+                                       include "view/lang/$lang/strings.php";
+                               }
+                               if (file_exists("addon/morechoice/lang/$lang/strings.php")) {
+                                       include "addon/morechoice/lang/$lang/strings.php";
+                               }
+
+                               $localizedStrings = $a->strings;
+                               unset($a);
+
+                               $key = array_search($toTranslate, $localizedStrings);
+                               if ($key !== false) {
+                                       break;
+                               }
+
+                               // defaulting to empty string
+                               $key = '';
+                       }
+
+                       if ($key == '') {
+                               $fail++;
+                       } else {
+                               DBA::update('profile', [$translateKey => $key], ['id' => $data['id']]);
+                               logger::log('Updated contact ' . $data['id'] . " to $translateKey " . $key .
+                                       ' (was: ' . $data[$translateKey] . ')');
+                               Worker::add(PRIORITY_LOW, 'ProfileUpdate', $data['id']);                
+                               Contact::updateSelfFromUserID($data['id']);
+                               GContact::updateForUser($data['id']);
+                               $success++;
+                       }
+               }
+       }
+
+       Logger::log($translateKey . " fix completed. Success: $success. Fail: $fail");
+       return Update::SUCCESS;
+}
+
+// Post-update script of PR 5751
+function update_1298()
+{
+       $translateKey = 'sexual';
+       $allData = DBA::select('profile', ['id', $translateKey]);
+       $allLangs = L10n::getAvailableLanguages();
+       $success = 0;
+       $fail = 0;
+       foreach ($allData as $key => $data) {
+               $toTranslate = $data[$translateKey];
+               if ($toTranslate != '') {
+                       foreach ($allLangs as $key => $lang) {
+                               $a = new \stdClass();
+                               $a->strings = [];
+
+                               // First we get the the localizations
+                               if (file_exists("view/lang/$lang/strings.php")) {
+                                       include "view/lang/$lang/strings.php";
+                               }
+                               if (file_exists("addon/morechoice/lang/$lang/strings.php")) {
+                                       include "addon/morechoice/lang/$lang/strings.php";
+                               }
+
+                               $localizedStrings = $a->strings;
+                               unset($a);
+
+                               $key = array_search($toTranslate, $localizedStrings);
+                               if ($key !== false) {
+                                       break;
+                               }
+
+                               // defaulting to empty string
+                               $key = '';
+                       }
+
+                       if ($key == '') {
+                               $fail++;
+                       } else {
+                               DBA::update('profile', [$translateKey => $key], ['id' => $data['id']]);
+                               logger::log('Updated contact ' . $data['id'] . " to $translateKey " . $key .
+                                       ' (was: ' . $data[$translateKey] . ')');
+                               Worker::add(PRIORITY_LOW, 'ProfileUpdate', $data['id']);                
+                               Contact::updateSelfFromUserID($data['id']);
+                               GContact::updateForUser($data['id']);
+                               $success++;
+                       }
+               }
+       }
+
+       Logger::log($translateKey . " fix completed. Success: $success. Fail: $fail");
+       return Update::SUCCESS;
+}
\ No newline at end of file