Backend\Core\Engine\Api::microsoftRemoveDevice PHP Метод

microsoftRemoveDevice() публичный статический Метод

Remove a device from a user.
public static microsoftRemoveDevice ( string $uri, string $email )
$uri string The uri of the channel opened for the device.
$email string The emailaddress for the user to link the device to.
    public static function microsoftRemoveDevice($uri, $email)
    {
        trigger_error('The api is deprecated and will be removed in version 5', E_USER_DEPRECATED);
        if (BaseAPI::isAuthorized()) {
            // redefine
            $uri = (string) $uri;
            // validate
            if ($uri == '') {
                BaseAPI::output(BaseAPI::BAD_REQUEST, array('message' => 'No uri-parameter provided.'));
            }
            if ($email == '') {
                BaseAPI::output(BaseAPI::BAD_REQUEST, array('message' => 'No email-parameter provided.'));
            }
            try {
                // load user
                $user = new User(null, $email);
                // get current uris
                $uris = (array) $user->getSetting('microsoft_channel_uri');
                // not already in array?
                $index = array_search($uri, $uris);
                if ($index !== false) {
                    // remove from array
                    unset($uris[$index]);
                    // save it
                    $user->setSetting('microsoft_channel_uri', $uris);
                }
            } catch (Exception $e) {
                BaseAPI::output(BaseAPI::FORBIDDEN, array('message' => 'Can\'t authenticate you.'));
            }
        }
    }