blob: 2d4f4a32923344a5fe5e5b4af0fc96dc816c0315 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Option;
use Piwik\Plugins\MobileMessaging\MobileMessaging;
use Piwik\Plugins\UsersManager\API as UsersManagerApi;
use Piwik\UpdaterErrorException;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_0_4_b7 extends Updates
{
public function doUpdate(Updater $updater)
{
try {
self::migrateExistingMobileMessagingOptions();
} catch (\Exception $e) {
throw new UpdaterErrorException($e->getMessage());
}
}
private static function migrateExistingMobileMessagingOptions()
{
if (Option::get(MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true') {
return;
}
// copy $superUserLogin_MobileMessagingSettings -> _MobileMessagingSettings as settings are managed globally
$optionName = MobileMessaging::USER_SETTINGS_POSTFIX_OPTION;
$superUsers = UsersManagerApi::getInstance()->getUsersHavingSuperUserAccess();
if (empty($superUsers)) {
return;
}
$firstSuperUser = array_shift($superUsers);
if (empty($firstSuperUser)) {
return;
}
$superUserLogin = $firstSuperUser['login'];
$optionPrefixed = $superUserLogin . $optionName;
// $superUserLogin_MobileMessagingSettings
$value = Option::get($optionPrefixed);
if (false !== $value) {
// _MobileMessagingSettings
Option::set($optionName, $value);
}
}
}
|