memories/lib/Util.php

92 lines
2.2 KiB
PHP
Raw Normal View History

2022-08-20 02:53:21 +00:00
<?php
2022-10-19 17:10:36 +00:00
2022-08-20 02:53:21 +00:00
declare(strict_types=1);
namespace OCA\Memories;
use OCA\Memories\AppInfo\Application;
use OCP\IConfig;
2022-10-19 17:10:36 +00:00
class Util
{
2022-09-16 21:37:52 +00:00
public static $TAG_DAYID_START = -(1 << 30); // the world surely didn't exist
public static $TAG_DAYID_FOLDERS = -(1 << 30) + 1;
2022-09-25 23:02:26 +00:00
public static $ARCHIVE_FOLDER = '.archive';
2022-08-20 02:53:21 +00:00
/**
* Get the path to the user's configured photos directory.
*/
2022-10-19 17:10:36 +00:00
public static function getPhotosPath(IConfig &$config, string $userId)
{
2022-08-20 02:53:21 +00:00
$p = $config->getUserValue($userId, Application::APPNAME, 'timelinePath', '');
if (empty($p)) {
return '/Photos/';
}
2022-10-19 17:10:36 +00:00
2022-08-20 02:53:21 +00:00
return $p;
}
2022-10-27 20:45:03 +00:00
/**
* Check if albums are enabled for this user.
2022-10-27 20:57:00 +00:00
*
* @param mixed $appManager
2022-10-27 20:45:03 +00:00
*/
public static function albumsIsEnabled(&$appManager): bool
{
if (!$appManager->isEnabledForUser('photos')) {
return false;
}
$v = $appManager->getAppInfo('photos')['version'];
return version_compare($v, '1.7.0', '>=');
}
/**
* Check if tags is enabled for this user.
2022-10-27 20:57:00 +00:00
*
* @param mixed $appManager
2022-10-27 20:45:03 +00:00
*/
public static function tagsIsEnabled(&$appManager): bool
{
return $appManager->isEnabledForUser('systemtags');
}
/**
* Check if recognize is enabled for this user.
2022-10-27 20:57:00 +00:00
*
* @param mixed $appManager
2022-10-27 20:45:03 +00:00
*/
public static function recognizeIsEnabled(&$appManager): bool
{
if (!$appManager->isEnabledForUser('recognize')) {
return false;
}
$v = $appManager->getAppInfo('recognize')['version'];
return version_compare($v, '3.0.0-alpha', '>=');
}
/**
* Check if link sharing is allowed.
*
* @param mixed $config
*/
public static function isLinkSharingEnabled(&$config): bool
{
// Check if the shareAPI is enabled
if ('yes' !== $config->getAppValue('core', 'shareapi_enabled', 'yes')) {
return false;
}
// Check whether public sharing is enabled
if ('yes' !== $config->getAppValue('core', 'shareapi_allow_links', 'yes')) {
return false;
}
return true;
}
2022-10-19 17:10:36 +00:00
}