PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/core/Updates/2.0.4-b7.php

https://github.com/CodeYellowBV/piwik
PHP | 69 lines | 44 code | 13 blank | 12 comment | 5 complexity | ad882df217a8a9c17f5eacf48baf7bc0 MD5 | raw file
Possible License(s): LGPL-3.0, JSON, MIT, GPL-3.0, LGPL-2.1, GPL-2.0, AGPL-1.0, BSD-2-Clause, BSD-3-Clause
  1. <?php
  2. /**
  3. * Piwik - free/libre analytics platform
  4. *
  5. * @link http://piwik.org
  6. * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
  7. *
  8. */
  9. namespace Piwik\Updates;
  10. use Piwik\Db;
  11. use Piwik\Option;
  12. use Piwik\Plugins\MobileMessaging\MobileMessaging;
  13. use Piwik\Plugins\UsersManager\API as UsersManagerApi;
  14. use Piwik\UpdaterErrorException;
  15. use Piwik\Updates;
  16. /**
  17. */
  18. class Updates_2_0_4_b7 extends Updates
  19. {
  20. static function getSql()
  21. {
  22. return array();
  23. }
  24. static function update()
  25. {
  26. try {
  27. self::migrateExistingMobileMessagingOptions();
  28. } catch (\Exception $e) {
  29. throw new UpdaterErrorException($e->getMessage());
  30. }
  31. }
  32. private static function migrateExistingMobileMessagingOptions()
  33. {
  34. if (Option::get(MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true') {
  35. return;
  36. }
  37. // copy $superUserLogin_MobileMessagingSettings -> _MobileMessagingSettings as settings are managed globally
  38. $optionName = MobileMessaging::USER_SETTINGS_POSTFIX_OPTION;
  39. $superUsers = UsersManagerApi::getInstance()->getUsersHavingSuperUserAccess();
  40. if (empty($superUsers)) {
  41. return;
  42. }
  43. $firstSuperUser = array_shift($superUsers);
  44. if (empty($firstSuperUser)) {
  45. return;
  46. }
  47. $superUserLogin = $firstSuperUser['login'];
  48. $optionPrefixed = $superUserLogin . $optionName;
  49. // $superUserLogin_MobileMessagingSettings
  50. $value = Option::get($optionPrefixed);
  51. if (false !== $value) {
  52. // _MobileMessagingSettings
  53. Option::set($optionName, $value);
  54. }
  55. }
  56. }