Welcome to mirror list, hosted at ThFree Co, Russian Federation.

2.0.4-b7.php « Updates « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 50030c2e84b50ca43c8cf151a4fd768af8ba36fb (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
66
67
68
69
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */

namespace Piwik\Updates;

use Piwik\Db;
use Piwik\Option;
use Piwik\Plugins\MobileMessaging\MobileMessaging;
use Piwik\Plugins\UsersManager\API as UsersManagerApi;
use Piwik\UpdaterErrorException;
use Piwik\Updates;

/**
 */
class Updates_2_0_4_b7 extends Updates
{
    static function getSql()
    {
        return array();
    }

    static function update()
    {
        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);
        }
    }
}