@@ -28,7 +28,7 @@ |
||
| 28 | 28 | use OCP\Util; |
| 29 | 29 | |
| 30 | 30 | class Application extends App { |
| 31 | - public function __construct () { |
|
| 31 | + public function __construct() { |
|
| 32 | 32 | parent::__construct('twofactor_backupcodes'); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -28,27 +28,27 @@ |
||
| 28 | 28 | use OCP\Util; |
| 29 | 29 | |
| 30 | 30 | class Application extends App { |
| 31 | - public function __construct () { |
|
| 32 | - parent::__construct('twofactor_backupcodes'); |
|
| 33 | - } |
|
| 31 | + public function __construct () { |
|
| 32 | + parent::__construct('twofactor_backupcodes'); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Register the different app parts |
|
| 37 | - */ |
|
| 38 | - public function register() { |
|
| 39 | - $this->registerHooksAndEvents(); |
|
| 40 | - } |
|
| 35 | + /** |
|
| 36 | + * Register the different app parts |
|
| 37 | + */ |
|
| 38 | + public function register() { |
|
| 39 | + $this->registerHooksAndEvents(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Register the hooks and events |
|
| 44 | - */ |
|
| 45 | - public function registerHooksAndEvents() { |
|
| 46 | - Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser'); |
|
| 47 | - } |
|
| 42 | + /** |
|
| 43 | + * Register the hooks and events |
|
| 44 | + */ |
|
| 45 | + public function registerHooksAndEvents() { |
|
| 46 | + Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser'); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function deleteUser($params) { |
|
| 50 | - /** @var BackupCodeMapper $mapper */ |
|
| 51 | - $mapper = $this->getContainer()->query(BackupCodeMapper::class); |
|
| 52 | - $mapper->deleteCodesByUserId($params['uid']); |
|
| 53 | - } |
|
| 49 | + public function deleteUser($params) { |
|
| 50 | + /** @var BackupCodeMapper $mapper */ |
|
| 51 | + $mapper = $this->getContainer()->query(BackupCodeMapper::class); |
|
| 52 | + $mapper->deleteCodesByUserId($params['uid']); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | |
| 15 | 15 | <?php if ($_['tooBig']) { ?> |
| 16 | 16 | <div class="warning updateAnyways"> |
| 17 | - <?php p($l->t('I know that if I continue doing the update via web UI has the risk, that the request runs into a timeout and could cause data loss, but I have a backup and know how to restore my instance in case of a failure.' )); ?> |
|
| 18 | - <a href="?IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup=IAmSuperSureToDoThis" class="button updateAnywaysButton"><?php p($l->t('Upgrade via web on my own risk' )); ?></a> |
|
| 17 | + <?php p($l->t('I know that if I continue doing the update via web UI has the risk, that the request runs into a timeout and could cause data loss, but I have a backup and know how to restore my instance in case of a failure.')); ?> |
|
| 18 | + <a href="?IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup=IAmSuperSureToDoThis" class="button updateAnywaysButton"><?php p($l->t('Upgrade via web on my own risk')); ?></a> |
|
| 19 | 19 | </div> |
| 20 | 20 | <?php } ?> |
| 21 | 21 | |
@@ -3,12 +3,12 @@ |
||
| 3 | 3 | <h2 class="title"><?php p($l->t('Update needed')) ?></h2> |
| 4 | 4 | <div class="infogroup"> |
| 5 | 5 | <?php if ($_['tooBig']) { |
| 6 | - p($l->t('Please use the command line updater because you have a big instance with more than 50 users.')); |
|
| 7 | - } else { |
|
| 8 | - p($l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
| 9 | - } ?><br><br> |
|
| 6 | + p($l->t('Please use the command line updater because you have a big instance with more than 50 users.')); |
|
| 7 | + } else { |
|
| 8 | + p($l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
| 9 | + } ?><br><br> |
|
| 10 | 10 | <?php |
| 11 | - print_unescaped($l->t('For help, see the <a target="_blank" rel="noreferrer noopener" href="%s">documentation</a>.', [link_to_docs('admin-cli-upgrade')])); ?><br><br> |
|
| 11 | + print_unescaped($l->t('For help, see the <a target="_blank" rel="noreferrer noopener" href="%s">documentation</a>.', [link_to_docs('admin-cli-upgrade')])); ?><br><br> |
|
| 12 | 12 | </div> |
| 13 | 13 | </div> |
| 14 | 14 | |
@@ -28,39 +28,39 @@ |
||
| 28 | 28 | |
| 29 | 29 | class SecurityFilter implements IFilter { |
| 30 | 30 | |
| 31 | - /** @var IURLGenerator */ |
|
| 32 | - private $urlGenerator; |
|
| 31 | + /** @var IURLGenerator */ |
|
| 32 | + private $urlGenerator; |
|
| 33 | 33 | |
| 34 | - /** @var IL10N */ |
|
| 35 | - private $l10n; |
|
| 34 | + /** @var IL10N */ |
|
| 35 | + private $l10n; |
|
| 36 | 36 | |
| 37 | - public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) { |
|
| 38 | - $this->urlGenerator = $urlGenerator; |
|
| 39 | - $this->l10n = $l10n; |
|
| 40 | - } |
|
| 37 | + public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) { |
|
| 38 | + $this->urlGenerator = $urlGenerator; |
|
| 39 | + $this->l10n = $l10n; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function allowedApps() { |
|
| 43 | - return []; |
|
| 44 | - } |
|
| 42 | + public function allowedApps() { |
|
| 43 | + return []; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function filterTypes(array $types) { |
|
| 47 | - return array_intersect(['security'], $types); |
|
| 48 | - } |
|
| 46 | + public function filterTypes(array $types) { |
|
| 47 | + return array_intersect(['security'], $types); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function getIcon() { |
|
| 51 | - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')); |
|
| 52 | - } |
|
| 50 | + public function getIcon() { |
|
| 51 | + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getIdentifier() { |
|
| 55 | - return 'security'; |
|
| 56 | - } |
|
| 54 | + public function getIdentifier() { |
|
| 55 | + return 'security'; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function getName() { |
|
| 59 | - return $this->l10n->t('Security'); |
|
| 60 | - } |
|
| 58 | + public function getName() { |
|
| 59 | + return $this->l10n->t('Security'); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function getPriority() { |
|
| 63 | - return 30; |
|
| 64 | - } |
|
| 62 | + public function getPriority() { |
|
| 63 | + return 30; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | } |
@@ -27,39 +27,39 @@ |
||
| 27 | 27 | |
| 28 | 28 | class SecuritySetting implements ISetting { |
| 29 | 29 | |
| 30 | - /** @var IL10N */ |
|
| 31 | - private $l10n; |
|
| 30 | + /** @var IL10N */ |
|
| 31 | + private $l10n; |
|
| 32 | 32 | |
| 33 | - public function __construct(IL10N $l10n) { |
|
| 34 | - $this->l10n = $l10n; |
|
| 35 | - } |
|
| 33 | + public function __construct(IL10N $l10n) { |
|
| 34 | + $this->l10n = $l10n; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function canChangeMail() { |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 37 | + public function canChangeMail() { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function canChangeStream() { |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 41 | + public function canChangeStream() { |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function getIdentifier() { |
|
| 46 | - return 'security'; |
|
| 47 | - } |
|
| 45 | + public function getIdentifier() { |
|
| 46 | + return 'security'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function getName() { |
|
| 50 | - return $this->l10n->t('Security'); |
|
| 51 | - } |
|
| 49 | + public function getName() { |
|
| 50 | + return $this->l10n->t('Security'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function getPriority() { |
|
| 54 | - return 30; |
|
| 55 | - } |
|
| 53 | + public function getPriority() { |
|
| 54 | + return 30; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function isDefaultEnabledMail() { |
|
| 58 | - return true; |
|
| 59 | - } |
|
| 57 | + public function isDefaultEnabledMail() { |
|
| 58 | + return true; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function isDefaultEnabledStream() { |
|
| 62 | - return true; |
|
| 63 | - } |
|
| 61 | + public function isDefaultEnabledStream() { |
|
| 62 | + return true; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | } |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | |
| 85 | 85 | if (isset($this->namespaces[$namespace])) { |
| 86 | 86 | if (!isset($this->hasNoAppContainer[$namespace])) { |
| 87 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
| 87 | + $applicationClassName = 'OCA\\'.$sensitiveNamespace.'\\AppInfo\\Application'; |
|
| 88 | 88 | if (class_exists($applicationClassName)) { |
| 89 | 89 | new $applicationClassName(); |
| 90 | 90 | if (isset($this->appContainers[$namespace])) { |
@@ -34,101 +34,101 @@ |
||
| 34 | 34 | * @package OC |
| 35 | 35 | */ |
| 36 | 36 | class ServerContainer extends SimpleContainer { |
| 37 | - /** @var DIContainer[] */ |
|
| 38 | - protected $appContainers; |
|
| 37 | + /** @var DIContainer[] */ |
|
| 38 | + protected $appContainers; |
|
| 39 | 39 | |
| 40 | - /** @var string[] */ |
|
| 41 | - protected $hasNoAppContainer; |
|
| 40 | + /** @var string[] */ |
|
| 41 | + protected $hasNoAppContainer; |
|
| 42 | 42 | |
| 43 | - /** @var string[] */ |
|
| 44 | - protected $namespaces; |
|
| 43 | + /** @var string[] */ |
|
| 44 | + protected $namespaces; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * ServerContainer constructor. |
|
| 48 | - */ |
|
| 49 | - public function __construct() { |
|
| 50 | - parent::__construct(); |
|
| 51 | - $this->appContainers = []; |
|
| 52 | - $this->namespaces = []; |
|
| 53 | - $this->hasNoAppContainer = []; |
|
| 54 | - } |
|
| 46 | + /** |
|
| 47 | + * ServerContainer constructor. |
|
| 48 | + */ |
|
| 49 | + public function __construct() { |
|
| 50 | + parent::__construct(); |
|
| 51 | + $this->appContainers = []; |
|
| 52 | + $this->namespaces = []; |
|
| 53 | + $this->hasNoAppContainer = []; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @param string $appName |
|
| 58 | - * @param string $appNamespace |
|
| 59 | - */ |
|
| 60 | - public function registerNamespace($appName, $appNamespace) { |
|
| 61 | - // Cut of OCA\ and lowercase |
|
| 62 | - $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
| 63 | - $this->namespaces[$appNamespace] = $appName; |
|
| 64 | - } |
|
| 56 | + /** |
|
| 57 | + * @param string $appName |
|
| 58 | + * @param string $appNamespace |
|
| 59 | + */ |
|
| 60 | + public function registerNamespace($appName, $appNamespace) { |
|
| 61 | + // Cut of OCA\ and lowercase |
|
| 62 | + $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
| 63 | + $this->namespaces[$appNamespace] = $appName; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @param string $appName |
|
| 68 | - * @param DIContainer $container |
|
| 69 | - */ |
|
| 70 | - public function registerAppContainer($appName, DIContainer $container) { |
|
| 71 | - $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
| 72 | - } |
|
| 66 | + /** |
|
| 67 | + * @param string $appName |
|
| 68 | + * @param DIContainer $container |
|
| 69 | + */ |
|
| 70 | + public function registerAppContainer($appName, DIContainer $container) { |
|
| 71 | + $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @param string $namespace |
|
| 76 | - * @param string $sensitiveNamespace |
|
| 77 | - * @return DIContainer |
|
| 78 | - * @throws QueryException |
|
| 79 | - */ |
|
| 80 | - protected function getAppContainer($namespace, $sensitiveNamespace) { |
|
| 81 | - if (isset($this->appContainers[$namespace])) { |
|
| 82 | - return $this->appContainers[$namespace]; |
|
| 83 | - } |
|
| 74 | + /** |
|
| 75 | + * @param string $namespace |
|
| 76 | + * @param string $sensitiveNamespace |
|
| 77 | + * @return DIContainer |
|
| 78 | + * @throws QueryException |
|
| 79 | + */ |
|
| 80 | + protected function getAppContainer($namespace, $sensitiveNamespace) { |
|
| 81 | + if (isset($this->appContainers[$namespace])) { |
|
| 82 | + return $this->appContainers[$namespace]; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - if (isset($this->namespaces[$namespace])) { |
|
| 86 | - if (!isset($this->hasNoAppContainer[$namespace])) { |
|
| 87 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
| 88 | - if (class_exists($applicationClassName)) { |
|
| 89 | - new $applicationClassName(); |
|
| 90 | - if (isset($this->appContainers[$namespace])) { |
|
| 91 | - return $this->appContainers[$namespace]; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - $this->hasNoAppContainer[$namespace] = true; |
|
| 95 | - } |
|
| 85 | + if (isset($this->namespaces[$namespace])) { |
|
| 86 | + if (!isset($this->hasNoAppContainer[$namespace])) { |
|
| 87 | + $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
| 88 | + if (class_exists($applicationClassName)) { |
|
| 89 | + new $applicationClassName(); |
|
| 90 | + if (isset($this->appContainers[$namespace])) { |
|
| 91 | + return $this->appContainers[$namespace]; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + $this->hasNoAppContainer[$namespace] = true; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return new DIContainer($this->namespaces[$namespace]); |
|
| 98 | - } |
|
| 99 | - throw new QueryException(); |
|
| 100 | - } |
|
| 97 | + return new DIContainer($this->namespaces[$namespace]); |
|
| 98 | + } |
|
| 99 | + throw new QueryException(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * @param string $name name of the service to query for |
|
| 104 | - * @return mixed registered service for the given $name |
|
| 105 | - * @throws QueryException if the query could not be resolved |
|
| 106 | - */ |
|
| 107 | - public function query($name) { |
|
| 108 | - $name = $this->sanitizeName($name); |
|
| 102 | + /** |
|
| 103 | + * @param string $name name of the service to query for |
|
| 104 | + * @return mixed registered service for the given $name |
|
| 105 | + * @throws QueryException if the query could not be resolved |
|
| 106 | + */ |
|
| 107 | + public function query($name) { |
|
| 108 | + $name = $this->sanitizeName($name); |
|
| 109 | 109 | |
| 110 | - // In case the service starts with OCA\ we try to find the service in |
|
| 111 | - // the apps container first. |
|
| 112 | - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
| 113 | - $segments = explode('\\', $name); |
|
| 114 | - try { |
|
| 115 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
| 116 | - return $appContainer->queryNoFallback($name); |
|
| 117 | - } catch (QueryException $e) { |
|
| 118 | - // Didn't find the service or the respective app container, |
|
| 119 | - // ignore it and fall back to the core container. |
|
| 120 | - } |
|
| 121 | - } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) { |
|
| 122 | - $segments = explode('\\', $name); |
|
| 123 | - try { |
|
| 124 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
| 125 | - return $appContainer->queryNoFallback($name); |
|
| 126 | - } catch (QueryException $e) { |
|
| 127 | - // Didn't find the service or the respective app container, |
|
| 128 | - // ignore it and fall back to the core container. |
|
| 129 | - } |
|
| 130 | - } |
|
| 110 | + // In case the service starts with OCA\ we try to find the service in |
|
| 111 | + // the apps container first. |
|
| 112 | + if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
| 113 | + $segments = explode('\\', $name); |
|
| 114 | + try { |
|
| 115 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
| 116 | + return $appContainer->queryNoFallback($name); |
|
| 117 | + } catch (QueryException $e) { |
|
| 118 | + // Didn't find the service or the respective app container, |
|
| 119 | + // ignore it and fall back to the core container. |
|
| 120 | + } |
|
| 121 | + } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) { |
|
| 122 | + $segments = explode('\\', $name); |
|
| 123 | + try { |
|
| 124 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
| 125 | + return $appContainer->queryNoFallback($name); |
|
| 126 | + } catch (QueryException $e) { |
|
| 127 | + // Didn't find the service or the respective app container, |
|
| 128 | + // ignore it and fall back to the core container. |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - return parent::query($name); |
|
| 133 | - } |
|
| 132 | + return parent::query($name); |
|
| 133 | + } |
|
| 134 | 134 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | /** |
| 72 | 72 | * get color for on-page elements: |
| 73 | 73 | * theme color by default, grey if theme color is to bright |
| 74 | - * @param $color |
|
| 74 | + * @param string $color |
|
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | 77 | public function elementColor($color) { |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @param $app string app name |
| 117 | - * @return string|ISimpleFile path to app icon / file of logo |
|
| 117 | + * @return string path to app icon / file of logo |
|
| 118 | 118 | */ |
| 119 | 119 | public function getAppIcon($app) { |
| 120 | 120 | $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | /** |
| 191 | 191 | * replace default color with a custom one |
| 192 | 192 | * |
| 193 | - * @param $svg string content of a svg file |
|
| 194 | - * @param $color string color to match |
|
| 193 | + * @param string $svg string content of a svg file |
|
| 194 | + * @param string $color string color to match |
|
| 195 | 195 | * @return string |
| 196 | 196 | */ |
| 197 | 197 | public function colorizeSvg($svg, $color) { |
@@ -36,215 +36,215 @@ |
||
| 36 | 36 | |
| 37 | 37 | class Util { |
| 38 | 38 | |
| 39 | - /** @var IConfig */ |
|
| 40 | - private $config; |
|
| 41 | - |
|
| 42 | - /** @var IAppManager */ |
|
| 43 | - private $appManager; |
|
| 44 | - |
|
| 45 | - /** @var IAppData */ |
|
| 46 | - private $appData; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Util constructor. |
|
| 50 | - * |
|
| 51 | - * @param IConfig $config |
|
| 52 | - * @param IAppManager $appManager |
|
| 53 | - * @param IAppData $appData |
|
| 54 | - */ |
|
| 55 | - public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData) { |
|
| 56 | - $this->config = $config; |
|
| 57 | - $this->appManager = $appManager; |
|
| 58 | - $this->appData = $appData; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @param string $color rgb color value |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - public function invertTextColor($color) { |
|
| 66 | - $l = $this->calculateLuma($color); |
|
| 67 | - if($l>0.6) { |
|
| 68 | - return true; |
|
| 69 | - } else { |
|
| 70 | - return false; |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * get color for on-page elements: |
|
| 76 | - * theme color by default, grey if theme color is to bright |
|
| 77 | - * @param $color |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public function elementColor($color) { |
|
| 81 | - $l = $this->calculateLuminance($color); |
|
| 82 | - if($l>0.8) { |
|
| 83 | - return '#555555'; |
|
| 84 | - } |
|
| 85 | - return $color; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @param string $color rgb color value |
|
| 90 | - * @return float |
|
| 91 | - */ |
|
| 92 | - public function calculateLuminance($color) { |
|
| 93 | - list($red, $green, $blue) = $this->hexToRGB($color); |
|
| 94 | - $compiler = new Compiler(); |
|
| 95 | - $hsl = $compiler->toHSL($red, $green, $blue); |
|
| 96 | - return $hsl[3]/100; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @param string $color rgb color value |
|
| 101 | - * @return float |
|
| 102 | - */ |
|
| 103 | - public function calculateLuma($color) { |
|
| 104 | - list($red, $green, $blue) = $this->hexToRGB($color); |
|
| 105 | - return (0.2126 * $red + 0.7152 * $green + 0.0722 * $blue) / 255; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @param string $color rgb color value |
|
| 110 | - * @return int[] |
|
| 111 | - */ |
|
| 112 | - public function hexToRGB($color) { |
|
| 113 | - $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); |
|
| 114 | - if (strlen($hex) === 3) { |
|
| 115 | - $hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2}; |
|
| 116 | - } |
|
| 117 | - if (strlen($hex) !== 6) { |
|
| 118 | - return 0; |
|
| 119 | - } |
|
| 120 | - return [ |
|
| 121 | - hexdec(substr($hex, 0, 2)), |
|
| 122 | - hexdec(substr($hex, 2, 2)), |
|
| 123 | - hexdec(substr($hex, 4, 2)) |
|
| 124 | - ]; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @param $color |
|
| 129 | - * @return string base64 encoded radio button svg |
|
| 130 | - */ |
|
| 131 | - public function generateRadioButton($color) { |
|
| 132 | - $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' . |
|
| 133 | - '<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>'; |
|
| 134 | - return base64_encode($radioButtonIcon); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @param $app string app name |
|
| 140 | - * @return string|ISimpleFile path to app icon / file of logo |
|
| 141 | - */ |
|
| 142 | - public function getAppIcon($app) { |
|
| 143 | - $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
| 144 | - try { |
|
| 145 | - $appPath = $this->appManager->getAppPath($app); |
|
| 146 | - $icon = $appPath . '/img/' . $app . '.svg'; |
|
| 147 | - if (file_exists($icon)) { |
|
| 148 | - return $icon; |
|
| 149 | - } |
|
| 150 | - $icon = $appPath . '/img/app.svg'; |
|
| 151 | - if (file_exists($icon)) { |
|
| 152 | - return $icon; |
|
| 153 | - } |
|
| 154 | - } catch (AppPathNotFoundException $e) {} |
|
| 155 | - |
|
| 156 | - if ($this->config->getAppValue('theming', 'logoMime', '') !== '') { |
|
| 157 | - $logoFile = null; |
|
| 158 | - try { |
|
| 159 | - $folder = $this->appData->getFolder('images'); |
|
| 160 | - if ($folder !== null) { |
|
| 161 | - return $folder->getFile('logo'); |
|
| 162 | - } |
|
| 163 | - } catch (NotFoundException $e) {} |
|
| 164 | - } |
|
| 165 | - return \OC::$SERVERROOT . '/core/img/logo.svg'; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @param $app string app name |
|
| 170 | - * @param $image string relative path to image in app folder |
|
| 171 | - * @return string|false absolute path to image |
|
| 172 | - */ |
|
| 173 | - public function getAppImage($app, $image) { |
|
| 174 | - $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
| 175 | - $image = str_replace(array('\0', '\\', '..'), '', $image); |
|
| 176 | - if ($app === "core") { |
|
| 177 | - $icon = \OC::$SERVERROOT . '/core/img/' . $image; |
|
| 178 | - if (file_exists($icon)) { |
|
| 179 | - return $icon; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - try { |
|
| 184 | - $appPath = $this->appManager->getAppPath($app); |
|
| 185 | - } catch (AppPathNotFoundException $e) { |
|
| 186 | - return false; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - $icon = $appPath . '/img/' . $image; |
|
| 190 | - if (file_exists($icon)) { |
|
| 191 | - return $icon; |
|
| 192 | - } |
|
| 193 | - $icon = $appPath . '/img/' . $image . '.svg'; |
|
| 194 | - if (file_exists($icon)) { |
|
| 195 | - return $icon; |
|
| 196 | - } |
|
| 197 | - $icon = $appPath . '/img/' . $image . '.png'; |
|
| 198 | - if (file_exists($icon)) { |
|
| 199 | - return $icon; |
|
| 200 | - } |
|
| 201 | - $icon = $appPath . '/img/' . $image . '.gif'; |
|
| 202 | - if (file_exists($icon)) { |
|
| 203 | - return $icon; |
|
| 204 | - } |
|
| 205 | - $icon = $appPath . '/img/' . $image . '.jpg'; |
|
| 206 | - if (file_exists($icon)) { |
|
| 207 | - return $icon; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - return false; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * replace default color with a custom one |
|
| 215 | - * |
|
| 216 | - * @param $svg string content of a svg file |
|
| 217 | - * @param $color string color to match |
|
| 218 | - * @return string |
|
| 219 | - */ |
|
| 220 | - public function colorizeSvg($svg, $color) { |
|
| 221 | - $svg = preg_replace('/#0082c9/i', $color, $svg); |
|
| 222 | - return $svg; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Check if a custom theme is set in the server configuration |
|
| 227 | - * |
|
| 228 | - * @return bool |
|
| 229 | - */ |
|
| 230 | - public function isAlreadyThemed() { |
|
| 231 | - $theme = $this->config->getSystemValue('theme', ''); |
|
| 232 | - if ($theme !== '') { |
|
| 233 | - return true; |
|
| 234 | - } |
|
| 235 | - return false; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - public function isBackgroundThemed() { |
|
| 239 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false); |
|
| 240 | - |
|
| 241 | - $backgroundExists = true; |
|
| 242 | - try { |
|
| 243 | - $this->appData->getFolder('images')->getFile('background'); |
|
| 244 | - } catch (\Exception $e) { |
|
| 245 | - $backgroundExists = false; |
|
| 246 | - } |
|
| 247 | - return $backgroundLogo && $backgroundLogo !== 'backgroundColor' && $backgroundExists; |
|
| 248 | - } |
|
| 39 | + /** @var IConfig */ |
|
| 40 | + private $config; |
|
| 41 | + |
|
| 42 | + /** @var IAppManager */ |
|
| 43 | + private $appManager; |
|
| 44 | + |
|
| 45 | + /** @var IAppData */ |
|
| 46 | + private $appData; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Util constructor. |
|
| 50 | + * |
|
| 51 | + * @param IConfig $config |
|
| 52 | + * @param IAppManager $appManager |
|
| 53 | + * @param IAppData $appData |
|
| 54 | + */ |
|
| 55 | + public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData) { |
|
| 56 | + $this->config = $config; |
|
| 57 | + $this->appManager = $appManager; |
|
| 58 | + $this->appData = $appData; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @param string $color rgb color value |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + public function invertTextColor($color) { |
|
| 66 | + $l = $this->calculateLuma($color); |
|
| 67 | + if($l>0.6) { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * get color for on-page elements: |
|
| 76 | + * theme color by default, grey if theme color is to bright |
|
| 77 | + * @param $color |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public function elementColor($color) { |
|
| 81 | + $l = $this->calculateLuminance($color); |
|
| 82 | + if($l>0.8) { |
|
| 83 | + return '#555555'; |
|
| 84 | + } |
|
| 85 | + return $color; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @param string $color rgb color value |
|
| 90 | + * @return float |
|
| 91 | + */ |
|
| 92 | + public function calculateLuminance($color) { |
|
| 93 | + list($red, $green, $blue) = $this->hexToRGB($color); |
|
| 94 | + $compiler = new Compiler(); |
|
| 95 | + $hsl = $compiler->toHSL($red, $green, $blue); |
|
| 96 | + return $hsl[3]/100; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @param string $color rgb color value |
|
| 101 | + * @return float |
|
| 102 | + */ |
|
| 103 | + public function calculateLuma($color) { |
|
| 104 | + list($red, $green, $blue) = $this->hexToRGB($color); |
|
| 105 | + return (0.2126 * $red + 0.7152 * $green + 0.0722 * $blue) / 255; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @param string $color rgb color value |
|
| 110 | + * @return int[] |
|
| 111 | + */ |
|
| 112 | + public function hexToRGB($color) { |
|
| 113 | + $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); |
|
| 114 | + if (strlen($hex) === 3) { |
|
| 115 | + $hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2}; |
|
| 116 | + } |
|
| 117 | + if (strlen($hex) !== 6) { |
|
| 118 | + return 0; |
|
| 119 | + } |
|
| 120 | + return [ |
|
| 121 | + hexdec(substr($hex, 0, 2)), |
|
| 122 | + hexdec(substr($hex, 2, 2)), |
|
| 123 | + hexdec(substr($hex, 4, 2)) |
|
| 124 | + ]; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @param $color |
|
| 129 | + * @return string base64 encoded radio button svg |
|
| 130 | + */ |
|
| 131 | + public function generateRadioButton($color) { |
|
| 132 | + $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' . |
|
| 133 | + '<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>'; |
|
| 134 | + return base64_encode($radioButtonIcon); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @param $app string app name |
|
| 140 | + * @return string|ISimpleFile path to app icon / file of logo |
|
| 141 | + */ |
|
| 142 | + public function getAppIcon($app) { |
|
| 143 | + $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
| 144 | + try { |
|
| 145 | + $appPath = $this->appManager->getAppPath($app); |
|
| 146 | + $icon = $appPath . '/img/' . $app . '.svg'; |
|
| 147 | + if (file_exists($icon)) { |
|
| 148 | + return $icon; |
|
| 149 | + } |
|
| 150 | + $icon = $appPath . '/img/app.svg'; |
|
| 151 | + if (file_exists($icon)) { |
|
| 152 | + return $icon; |
|
| 153 | + } |
|
| 154 | + } catch (AppPathNotFoundException $e) {} |
|
| 155 | + |
|
| 156 | + if ($this->config->getAppValue('theming', 'logoMime', '') !== '') { |
|
| 157 | + $logoFile = null; |
|
| 158 | + try { |
|
| 159 | + $folder = $this->appData->getFolder('images'); |
|
| 160 | + if ($folder !== null) { |
|
| 161 | + return $folder->getFile('logo'); |
|
| 162 | + } |
|
| 163 | + } catch (NotFoundException $e) {} |
|
| 164 | + } |
|
| 165 | + return \OC::$SERVERROOT . '/core/img/logo.svg'; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @param $app string app name |
|
| 170 | + * @param $image string relative path to image in app folder |
|
| 171 | + * @return string|false absolute path to image |
|
| 172 | + */ |
|
| 173 | + public function getAppImage($app, $image) { |
|
| 174 | + $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
| 175 | + $image = str_replace(array('\0', '\\', '..'), '', $image); |
|
| 176 | + if ($app === "core") { |
|
| 177 | + $icon = \OC::$SERVERROOT . '/core/img/' . $image; |
|
| 178 | + if (file_exists($icon)) { |
|
| 179 | + return $icon; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + try { |
|
| 184 | + $appPath = $this->appManager->getAppPath($app); |
|
| 185 | + } catch (AppPathNotFoundException $e) { |
|
| 186 | + return false; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + $icon = $appPath . '/img/' . $image; |
|
| 190 | + if (file_exists($icon)) { |
|
| 191 | + return $icon; |
|
| 192 | + } |
|
| 193 | + $icon = $appPath . '/img/' . $image . '.svg'; |
|
| 194 | + if (file_exists($icon)) { |
|
| 195 | + return $icon; |
|
| 196 | + } |
|
| 197 | + $icon = $appPath . '/img/' . $image . '.png'; |
|
| 198 | + if (file_exists($icon)) { |
|
| 199 | + return $icon; |
|
| 200 | + } |
|
| 201 | + $icon = $appPath . '/img/' . $image . '.gif'; |
|
| 202 | + if (file_exists($icon)) { |
|
| 203 | + return $icon; |
|
| 204 | + } |
|
| 205 | + $icon = $appPath . '/img/' . $image . '.jpg'; |
|
| 206 | + if (file_exists($icon)) { |
|
| 207 | + return $icon; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + return false; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * replace default color with a custom one |
|
| 215 | + * |
|
| 216 | + * @param $svg string content of a svg file |
|
| 217 | + * @param $color string color to match |
|
| 218 | + * @return string |
|
| 219 | + */ |
|
| 220 | + public function colorizeSvg($svg, $color) { |
|
| 221 | + $svg = preg_replace('/#0082c9/i', $color, $svg); |
|
| 222 | + return $svg; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Check if a custom theme is set in the server configuration |
|
| 227 | + * |
|
| 228 | + * @return bool |
|
| 229 | + */ |
|
| 230 | + public function isAlreadyThemed() { |
|
| 231 | + $theme = $this->config->getSystemValue('theme', ''); |
|
| 232 | + if ($theme !== '') { |
|
| 233 | + return true; |
|
| 234 | + } |
|
| 235 | + return false; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + public function isBackgroundThemed() { |
|
| 239 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false); |
|
| 240 | + |
|
| 241 | + $backgroundExists = true; |
|
| 242 | + try { |
|
| 243 | + $this->appData->getFolder('images')->getFile('background'); |
|
| 244 | + } catch (\Exception $e) { |
|
| 245 | + $backgroundExists = false; |
|
| 246 | + } |
|
| 247 | + return $backgroundLogo && $backgroundLogo !== 'backgroundColor' && $backgroundExists; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function invertTextColor($color) { |
| 66 | 66 | $l = $this->calculateLuma($color); |
| 67 | - if($l>0.6) { |
|
| 67 | + if ($l > 0.6) { |
|
| 68 | 68 | return true; |
| 69 | 69 | } else { |
| 70 | 70 | return false; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function elementColor($color) { |
| 81 | 81 | $l = $this->calculateLuminance($color); |
| 82 | - if($l>0.8) { |
|
| 82 | + if ($l > 0.8) { |
|
| 83 | 83 | return '#555555'; |
| 84 | 84 | } |
| 85 | 85 | return $color; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | list($red, $green, $blue) = $this->hexToRGB($color); |
| 94 | 94 | $compiler = new Compiler(); |
| 95 | 95 | $hsl = $compiler->toHSL($red, $green, $blue); |
| 96 | - return $hsl[3]/100; |
|
| 96 | + return $hsl[3] / 100; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function calculateLuma($color) { |
| 104 | 104 | list($red, $green, $blue) = $this->hexToRGB($color); |
| 105 | - return (0.2126 * $red + 0.7152 * $green + 0.0722 * $blue) / 255; |
|
| 105 | + return (0.2126 * $red + 0.7152 * $green + 0.0722 * $blue) / 255; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | public function hexToRGB($color) { |
| 113 | 113 | $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); |
| 114 | 114 | if (strlen($hex) === 3) { |
| 115 | - $hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2}; |
|
| 115 | + $hex = $hex{0}.$hex{0}.$hex{1}.$hex{1}.$hex{2}.$hex{2}; |
|
| 116 | 116 | } |
| 117 | 117 | if (strlen($hex) !== 6) { |
| 118 | 118 | return 0; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return string base64 encoded radio button svg |
| 130 | 130 | */ |
| 131 | 131 | public function generateRadioButton($color) { |
| 132 | - $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' . |
|
| 132 | + $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">'. |
|
| 133 | 133 | '<path d="M8 1a7 7 0 0 0-7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0-7-7zm0 1a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm0 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="'.$color.'"/></svg>'; |
| 134 | 134 | return base64_encode($radioButtonIcon); |
| 135 | 135 | } |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
| 144 | 144 | try { |
| 145 | 145 | $appPath = $this->appManager->getAppPath($app); |
| 146 | - $icon = $appPath . '/img/' . $app . '.svg'; |
|
| 146 | + $icon = $appPath.'/img/'.$app.'.svg'; |
|
| 147 | 147 | if (file_exists($icon)) { |
| 148 | 148 | return $icon; |
| 149 | 149 | } |
| 150 | - $icon = $appPath . '/img/app.svg'; |
|
| 150 | + $icon = $appPath.'/img/app.svg'; |
|
| 151 | 151 | if (file_exists($icon)) { |
| 152 | 152 | return $icon; |
| 153 | 153 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | } catch (NotFoundException $e) {} |
| 164 | 164 | } |
| 165 | - return \OC::$SERVERROOT . '/core/img/logo.svg'; |
|
| 165 | + return \OC::$SERVERROOT.'/core/img/logo.svg'; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
| 175 | 175 | $image = str_replace(array('\0', '\\', '..'), '', $image); |
| 176 | 176 | if ($app === "core") { |
| 177 | - $icon = \OC::$SERVERROOT . '/core/img/' . $image; |
|
| 177 | + $icon = \OC::$SERVERROOT.'/core/img/'.$image; |
|
| 178 | 178 | if (file_exists($icon)) { |
| 179 | 179 | return $icon; |
| 180 | 180 | } |
@@ -186,23 +186,23 @@ discard block |
||
| 186 | 186 | return false; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - $icon = $appPath . '/img/' . $image; |
|
| 189 | + $icon = $appPath.'/img/'.$image; |
|
| 190 | 190 | if (file_exists($icon)) { |
| 191 | 191 | return $icon; |
| 192 | 192 | } |
| 193 | - $icon = $appPath . '/img/' . $image . '.svg'; |
|
| 193 | + $icon = $appPath.'/img/'.$image.'.svg'; |
|
| 194 | 194 | if (file_exists($icon)) { |
| 195 | 195 | return $icon; |
| 196 | 196 | } |
| 197 | - $icon = $appPath . '/img/' . $image . '.png'; |
|
| 197 | + $icon = $appPath.'/img/'.$image.'.png'; |
|
| 198 | 198 | if (file_exists($icon)) { |
| 199 | 199 | return $icon; |
| 200 | 200 | } |
| 201 | - $icon = $appPath . '/img/' . $image . '.gif'; |
|
| 201 | + $icon = $appPath.'/img/'.$image.'.gif'; |
|
| 202 | 202 | if (file_exists($icon)) { |
| 203 | 203 | return $icon; |
| 204 | 204 | } |
| 205 | - $icon = $appPath . '/img/' . $image . '.jpg'; |
|
| 205 | + $icon = $appPath.'/img/'.$image.'.jpg'; |
|
| 206 | 206 | if (file_exists($icon)) { |
| 207 | 207 | return $icon; |
| 208 | 208 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | public function isBackgroundThemed() { |
| 239 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false); |
|
| 239 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
| 240 | 240 | |
| 241 | 241 | $backgroundExists = true; |
| 242 | 242 | try { |
@@ -24,25 +24,25 @@ |
||
| 24 | 24 | namespace OC\Files\Cache\Wrapper; |
| 25 | 25 | |
| 26 | 26 | class CachePermissionsMask extends CacheWrapper { |
| 27 | - /** |
|
| 28 | - * @var int |
|
| 29 | - */ |
|
| 30 | - protected $mask; |
|
| 27 | + /** |
|
| 28 | + * @var int |
|
| 29 | + */ |
|
| 30 | + protected $mask; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param \OCP\Files\Cache\ICache $cache |
|
| 34 | - * @param int $mask |
|
| 35 | - */ |
|
| 36 | - public function __construct($cache, $mask) { |
|
| 37 | - parent::__construct($cache); |
|
| 38 | - $this->mask = $mask; |
|
| 39 | - } |
|
| 32 | + /** |
|
| 33 | + * @param \OCP\Files\Cache\ICache $cache |
|
| 34 | + * @param int $mask |
|
| 35 | + */ |
|
| 36 | + public function __construct($cache, $mask) { |
|
| 37 | + parent::__construct($cache); |
|
| 38 | + $this->mask = $mask; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - protected function formatCacheEntry($entry) { |
|
| 42 | - if (isset($entry['permissions'])) { |
|
| 43 | - $entry['scan_permissions'] = $entry['permissions']; |
|
| 44 | - $entry['permissions'] &= $this->mask; |
|
| 45 | - } |
|
| 46 | - return $entry; |
|
| 47 | - } |
|
| 41 | + protected function formatCacheEntry($entry) { |
|
| 42 | + if (isset($entry['permissions'])) { |
|
| 43 | + $entry['scan_permissions'] = $entry['permissions']; |
|
| 44 | + $entry['permissions'] &= $this->mask; |
|
| 45 | + } |
|
| 46 | + return $entry; |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -28,62 +28,62 @@ |
||
| 28 | 28 | |
| 29 | 29 | class ClientMapper extends Mapper { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @param IDBConnection $db |
|
| 33 | - */ |
|
| 34 | - public function __construct(IDBConnection $db) { |
|
| 35 | - parent::__construct($db, 'oauth2_clients'); |
|
| 36 | - } |
|
| 31 | + /** |
|
| 32 | + * @param IDBConnection $db |
|
| 33 | + */ |
|
| 34 | + public function __construct(IDBConnection $db) { |
|
| 35 | + parent::__construct($db, 'oauth2_clients'); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param string $clientIdentifier |
|
| 40 | - * @return Client |
|
| 41 | - * @throws ClientNotFoundException |
|
| 42 | - */ |
|
| 43 | - public function getByIdentifier($clientIdentifier) { |
|
| 44 | - $qb = $this->db->getQueryBuilder(); |
|
| 45 | - $qb |
|
| 46 | - ->select('*') |
|
| 47 | - ->from($this->tableName) |
|
| 48 | - ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
| 49 | - $result = $qb->execute(); |
|
| 50 | - $row = $result->fetch(); |
|
| 51 | - $result->closeCursor(); |
|
| 52 | - if($row === false) { |
|
| 53 | - throw new ClientNotFoundException(); |
|
| 54 | - } |
|
| 55 | - return Client::fromRow($row); |
|
| 56 | - } |
|
| 38 | + /** |
|
| 39 | + * @param string $clientIdentifier |
|
| 40 | + * @return Client |
|
| 41 | + * @throws ClientNotFoundException |
|
| 42 | + */ |
|
| 43 | + public function getByIdentifier($clientIdentifier) { |
|
| 44 | + $qb = $this->db->getQueryBuilder(); |
|
| 45 | + $qb |
|
| 46 | + ->select('*') |
|
| 47 | + ->from($this->tableName) |
|
| 48 | + ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
| 49 | + $result = $qb->execute(); |
|
| 50 | + $row = $result->fetch(); |
|
| 51 | + $result->closeCursor(); |
|
| 52 | + if($row === false) { |
|
| 53 | + throw new ClientNotFoundException(); |
|
| 54 | + } |
|
| 55 | + return Client::fromRow($row); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @param string $uid internal uid of the client |
|
| 60 | - * @return Client |
|
| 61 | - * @throws ClientNotFoundException |
|
| 62 | - */ |
|
| 63 | - public function getByUid($uid) { |
|
| 64 | - $qb = $this->db->getQueryBuilder(); |
|
| 65 | - $qb |
|
| 66 | - ->select('*') |
|
| 67 | - ->from($this->tableName) |
|
| 68 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT))); |
|
| 69 | - $result = $qb->execute(); |
|
| 70 | - $row = $result->fetch(); |
|
| 71 | - $result->closeCursor(); |
|
| 72 | - if($row === false) { |
|
| 73 | - throw new ClientNotFoundException(); |
|
| 74 | - } |
|
| 75 | - return Client::fromRow($row); |
|
| 76 | - } |
|
| 58 | + /** |
|
| 59 | + * @param string $uid internal uid of the client |
|
| 60 | + * @return Client |
|
| 61 | + * @throws ClientNotFoundException |
|
| 62 | + */ |
|
| 63 | + public function getByUid($uid) { |
|
| 64 | + $qb = $this->db->getQueryBuilder(); |
|
| 65 | + $qb |
|
| 66 | + ->select('*') |
|
| 67 | + ->from($this->tableName) |
|
| 68 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT))); |
|
| 69 | + $result = $qb->execute(); |
|
| 70 | + $row = $result->fetch(); |
|
| 71 | + $result->closeCursor(); |
|
| 72 | + if($row === false) { |
|
| 73 | + throw new ClientNotFoundException(); |
|
| 74 | + } |
|
| 75 | + return Client::fromRow($row); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @return Client[] |
|
| 80 | - */ |
|
| 81 | - public function getClients() { |
|
| 82 | - $qb = $this->db->getQueryBuilder(); |
|
| 83 | - $qb |
|
| 84 | - ->select('*') |
|
| 85 | - ->from($this->tableName); |
|
| 78 | + /** |
|
| 79 | + * @return Client[] |
|
| 80 | + */ |
|
| 81 | + public function getClients() { |
|
| 82 | + $qb = $this->db->getQueryBuilder(); |
|
| 83 | + $qb |
|
| 84 | + ->select('*') |
|
| 85 | + ->from($this->tableName); |
|
| 86 | 86 | |
| 87 | - return $this->findEntities($qb->getSQL()); |
|
| 88 | - } |
|
| 87 | + return $this->findEntities($qb->getSQL()); |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $result = $qb->execute(); |
| 50 | 50 | $row = $result->fetch(); |
| 51 | 51 | $result->closeCursor(); |
| 52 | - if($row === false) { |
|
| 52 | + if ($row === false) { |
|
| 53 | 53 | throw new ClientNotFoundException(); |
| 54 | 54 | } |
| 55 | 55 | return Client::fromRow($row); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $result = $qb->execute(); |
| 70 | 70 | $row = $result->fetch(); |
| 71 | 71 | $result->closeCursor(); |
| 72 | - if($row === false) { |
|
| 72 | + if ($row === false) { |
|
| 73 | 73 | throw new ClientNotFoundException(); |
| 74 | 74 | } |
| 75 | 75 | return Client::fromRow($row); |
@@ -28,43 +28,43 @@ |
||
| 28 | 28 | |
| 29 | 29 | class AccessTokenMapper extends Mapper { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @param IDBConnection $db |
|
| 33 | - */ |
|
| 34 | - public function __construct(IDBConnection $db) { |
|
| 35 | - parent::__construct($db, 'oauth2_access_tokens'); |
|
| 36 | - } |
|
| 31 | + /** |
|
| 32 | + * @param IDBConnection $db |
|
| 33 | + */ |
|
| 34 | + public function __construct(IDBConnection $db) { |
|
| 35 | + parent::__construct($db, 'oauth2_access_tokens'); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param string $code |
|
| 40 | - * @return AccessToken |
|
| 41 | - * @throws AccessTokenNotFoundException |
|
| 42 | - */ |
|
| 43 | - public function getByCode($code) { |
|
| 44 | - $qb = $this->db->getQueryBuilder(); |
|
| 45 | - $qb |
|
| 46 | - ->select('*') |
|
| 47 | - ->from($this->tableName) |
|
| 48 | - ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
| 49 | - $result = $qb->execute(); |
|
| 50 | - $row = $result->fetch(); |
|
| 51 | - $result->closeCursor(); |
|
| 52 | - if($row === false) { |
|
| 53 | - throw new AccessTokenNotFoundException(); |
|
| 54 | - } |
|
| 55 | - return AccessToken::fromRow($row); |
|
| 56 | - } |
|
| 38 | + /** |
|
| 39 | + * @param string $code |
|
| 40 | + * @return AccessToken |
|
| 41 | + * @throws AccessTokenNotFoundException |
|
| 42 | + */ |
|
| 43 | + public function getByCode($code) { |
|
| 44 | + $qb = $this->db->getQueryBuilder(); |
|
| 45 | + $qb |
|
| 46 | + ->select('*') |
|
| 47 | + ->from($this->tableName) |
|
| 48 | + ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
| 49 | + $result = $qb->execute(); |
|
| 50 | + $row = $result->fetch(); |
|
| 51 | + $result->closeCursor(); |
|
| 52 | + if($row === false) { |
|
| 53 | + throw new AccessTokenNotFoundException(); |
|
| 54 | + } |
|
| 55 | + return AccessToken::fromRow($row); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * delete all access token from a given client |
|
| 60 | - * |
|
| 61 | - * @param int $id |
|
| 62 | - */ |
|
| 63 | - public function deleteByClientId($id) { |
|
| 64 | - $qb = $this->db->getQueryBuilder(); |
|
| 65 | - $qb |
|
| 66 | - ->delete($this->tableName) |
|
| 67 | - ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
| 68 | - $qb->execute(); |
|
| 69 | - } |
|
| 58 | + /** |
|
| 59 | + * delete all access token from a given client |
|
| 60 | + * |
|
| 61 | + * @param int $id |
|
| 62 | + */ |
|
| 63 | + public function deleteByClientId($id) { |
|
| 64 | + $qb = $this->db->getQueryBuilder(); |
|
| 65 | + $qb |
|
| 66 | + ->delete($this->tableName) |
|
| 67 | + ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
| 68 | + $qb->execute(); |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $result = $qb->execute(); |
| 50 | 50 | $row = $result->fetch(); |
| 51 | 51 | $result->closeCursor(); |
| 52 | - if($row === false) { |
|
| 52 | + if ($row === false) { |
|
| 53 | 53 | throw new AccessTokenNotFoundException(); |
| 54 | 54 | } |
| 55 | 55 | return AccessToken::fromRow($row); |