]> git.mxchange.org Git - friendica.git/commitdiff
1 update to rule them all
authorJeroen De Meerleer <me@jeroened.be>
Mon, 24 Dec 2018 10:15:32 +0000 (11:15 +0100)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 21 Jan 2019 14:47:45 +0000 (09:47 -0500)
update.php

index d608669f169f66dda39b8e6af07bdd06ccf38a32..6b8dc5d9e22aa139a63a4c2442e81b023c8a3def 100644 (file)
@@ -292,159 +292,56 @@ function update_1288()
 }
 
 // Post-update script of PR 5751
-function update_1296()
+function update_1298()
 {
-       $translateKey = 'gender';
-       $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";
+       $keys = ['gender', 'marital', 'sexual'];
+       foreach ($keys as $translateKey) {
+               $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 = '';
                                }
 
-                               $localizedStrings = $a->strings;
-                               unset($a);
-
-                               $key = array_search($toTranslate, $localizedStrings);
-                               if ($key !== false) {
-                                       break;
+                               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++;
                                }
-
-                               // 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_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");  
        }
-
-       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