~eduroam/eduroam-configurator

a961e2e019cf63c2fe0df948018451628c594577 — Jørn Åne de Jong 2 years ago aefe68c
Bump php-cat-client
M lib/git.sr.ht/eduroam/php-cat-client => lib/git.sr.ht/eduroam/php-cat-client +1 -1
@@ 1,1 1,1 @@
Subproject commit 9b13bafa70cc73c36df0fe5c7e7b6abba153c116
Subproject commit 82c446510ebe9eb3c2d0e37e74d35a9d916fc6f6

M src/eduroam/cat/cat.php => src/eduroam/cat/cat.php +2 -2
@@ 5,7 5,7 @@
 * A client to download data from https://cat.eduroam.org/
 *
 * Copyright: 2018-2020, Jørn Åne de Jong, Uninett AS <jorn.dejong@uninett.no>
 * SPDX-License-Identifier: BSD-3-Clause
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace eduroam\CAT;


@@ 328,7 328,7 @@ class CAT

		$result = \curl_exec( $this->ch );
		if ( !\is_string( $result ) ) {
			throw new DomainException( 'Unable to retrieve ' . $url );
			throw new DomainException( \curl_error( $this->ch ) . ': ' . $url );
		}

		return $result;

M src/eduroam/cat/device.php => src/eduroam/cat/device.php +6 -11
@@ 5,7 5,7 @@
 * A client to download data from https://cat.eduroam.org/
 *
 * Copyright: 2018-2020, Jørn Åne de Jong, Uninett AS <jorn.dejong@uninett.no>
 * SPDX-License-Identifier: BSD-3-Clause
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace eduroam\CAT;


@@ 44,7 44,7 @@ class Device
		'android_nougat' => ['/Android 7[._][0-9]/'],
		'android_oreo' => ['/Android 8[._][0-9]/'],
		'android_pie' => ['/Android 9[._][0-9]/'],
		'android_q' => ['/Android 10[._][0-9]/', '/Android 1[0-9]/', '/Android [2-9][0-9]/'],
		'android_q' => ['/Android 10[._][0-9]/', '/Android 1[1-9]/', '/Android [2-9][0-9]/'],
		0 => ['//'],
	];



@@ 244,7 244,10 @@ class Device
	/**
	 * Get the status of this device.
	 *
	 * It's not clear what this means, but 0 appears to mean success.
	 * It's not clear what this means,
	 * 0 appears to mean success (observed in many profiles)
	 * 1 appears to be unavailble (observed in idp=627&profile=1052 and idp=2180&profile=3830)
	 * -1 has not been observed, we use it as default value
	 *
	 * @return int status
	 */


@@ 263,10 266,6 @@ class Device
	 * obtained.  This feature may be used by an identity provider that has custom
	 * profiles or those that want to push extra settings through their profiles.
	 *
	 * If this device is available through CAT, this function will return a falsey
	 * value.  Use #getDownloadLink() to always get a link you can send your user
	 * to.
	 *
	 * @return string Redirect URL
	 */
	public function getRedirect(): string


@@ 372,10 371,6 @@ class Device
	 */
	public function getDownloadLink(): string
	{
		if ( $this->isRedirect() ) {
			return $this->getRaw()->redirect;
		}

		return $this->cat->getDownloadInstallerURL( $this->deviceID, $this->profileID );
	}


M src/eduroam/cat/identityprovider.php => src/eduroam/cat/identityprovider.php +14 -4
@@ 5,7 5,7 @@
 * A client to download data from https://cat.eduroam.org/
 *
 * Copyright: 2018-2020, Jørn Åne de Jong, Uninett AS <jorn.dejong@uninett.no>
 * SPDX-License-Identifier: BSD-3-Clause
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace eduroam\CAT;


@@ 249,15 249,25 @@ class IdentityProvider
	 * This function returns a list of objects that have <code>lat</code> and <code>lon</code> properties.
	 * If no geolocation information is known, it returns an empty array.
	 *
	 * @param ?int $precision The optional number of decimal digits to round to (omit for no rounding)
	 * @param int  $mode      Use one of the following constants to specify the mode in which rounding occurs
	 *
	 * @see http://php.net/round
	 *
	 * @return stdClass[] Objects with lat and lon
	 */
	public function getGeo(): array
	public function getGeo( ?int $precision = null, int $mode = \PHP_ROUND_HALF_UP ): array
	{
		$idp = $this->getRaw();
		foreach ( $idp->geo ?? [] as $geo ) {
			if ( \is_numeric( $geo->lat ) && \is_numeric( $geo->lon ) ) {
				$geo->lat = (float)$geo->lat;
				$geo->lon = (float)$geo->lon;
				if ( null === $precision ) {
					$geo->lat = (float)$geo->lat;
					$geo->lon = (float)$geo->lon;
				} else {
					$geo->lat = \round( (float)$geo->lat, $precision, $mode );
					$geo->lon = \round( (float)$geo->lon, $precision, $mode );
				}
			}
		}


M src/eduroam/cat/pemdevice.php => src/eduroam/cat/pemdevice.php +1 -1
@@ 5,7 5,7 @@
 * A client to download data from https://cat.eduroam.org/
 *
 * Copyright: 2018-2020, Jørn Åne de Jong, Uninett AS <jorn.dejong@uninett.no>
 * SPDX-License-Identifier: BSD-3-Clause
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace eduroam\CAT;

M src/eduroam/cat/profile.php => src/eduroam/cat/profile.php +18 -2
@@ 5,7 5,7 @@
 * A client to download data from https://cat.eduroam.org/
 *
 * Copyright: 2018-2020, Jørn Åne de Jong, Uninett AS <jorn.dejong@uninett.no>
 * SPDX-License-Identifier: BSD-3-Clause
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace eduroam\CAT;


@@ 267,7 267,7 @@ class Profile
		$devices = [];
		$addPem = false;
		foreach ( $this->getRaw()->devices as $device ) {
			if ( ( $device->redirect || $device->status >= 0 ) && ( !isset( $device->options->hidden ) || !$device->options->hidden ) ) {
			if ( ( $device->redirect || $device->status === 0 ) && ( !isset( $device->options->hidden ) || !$device->options->hidden ) ) {
				$devices[$device->id] = new Device( $this->cat, $this->idpID, $this->profileID, $device->id, $this->lang );
			}
			//$addPem |= !$device->redirect;


@@ 356,6 356,22 @@ class Profile

		return true;
	}
	/**
	 * Attempt to get the redirect url for this profile.
	 *
	 * @return ?string The redirect URL
	 */
	public function getRedirectUrl(): ?string{
		$raw = $this->getRaw();
		if ( isset( $raw->devices ) && 1 === \count( $raw->devices ) && isset( $raw->devices[0] ) ) {
			if ( isset( $raw->devices[0]->redirect ) ) {
				if ( $raw->devices[0]->redirect ) {
					return $raw->devices[0]->redirect;
				}
			}
		}
		return null;
	}

	/**
	 * Fill lazy loaded $profiles.