@@ -23,33 +23,33 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | if(\OC::$server->getConfig()->getSystemValue('updatechecker', true) === true) { |
| 26 | - $updater = new \OC\Updater\VersionCheck( |
|
| 27 | - \OC::$server->getHTTPClientService(), |
|
| 28 | - \OC::$server->getConfig() |
|
| 29 | - ); |
|
| 30 | - $updateChecker = new \OCA\UpdateNotification\UpdateChecker( |
|
| 31 | - $updater |
|
| 32 | - ); |
|
| 26 | + $updater = new \OC\Updater\VersionCheck( |
|
| 27 | + \OC::$server->getHTTPClientService(), |
|
| 28 | + \OC::$server->getConfig() |
|
| 29 | + ); |
|
| 30 | + $updateChecker = new \OCA\UpdateNotification\UpdateChecker( |
|
| 31 | + $updater |
|
| 32 | + ); |
|
| 33 | 33 | |
| 34 | - $userObject = \OC::$server->getUserSession()->getUser(); |
|
| 35 | - if($userObject !== null) { |
|
| 36 | - if(\OC::$server->getGroupManager()->isAdmin($userObject->getUID()) && |
|
| 37 | - !\OC::$server->getAppManager()->isEnabledForUser('notifications')) { |
|
| 38 | - if($updateChecker->getUpdateState() !== []) { |
|
| 39 | - \OCP\Util::addScript('updatenotification', 'notification'); |
|
| 40 | - OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'getJavaScript'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 34 | + $userObject = \OC::$server->getUserSession()->getUser(); |
|
| 35 | + if($userObject !== null) { |
|
| 36 | + if(\OC::$server->getGroupManager()->isAdmin($userObject->getUID()) && |
|
| 37 | + !\OC::$server->getAppManager()->isEnabledForUser('notifications')) { |
|
| 38 | + if($updateChecker->getUpdateState() !== []) { |
|
| 39 | + \OCP\Util::addScript('updatenotification', 'notification'); |
|
| 40 | + OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'getJavaScript'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $manager = \OC::$server->getNotificationManager(); |
|
| 46 | - $manager->registerNotifier(function() use ($manager) { |
|
| 47 | - return \OC::$server->query(\OCA\UpdateNotification\Notification\Notifier::class); |
|
| 48 | - }, function() { |
|
| 49 | - $l = \OC::$server->getL10N('updatenotification'); |
|
| 50 | - return [ |
|
| 51 | - 'id' => 'updatenotification', |
|
| 52 | - 'name' => $l->t('Update notifications'), |
|
| 53 | - ]; |
|
| 54 | - }); |
|
| 45 | + $manager = \OC::$server->getNotificationManager(); |
|
| 46 | + $manager->registerNotifier(function() use ($manager) { |
|
| 47 | + return \OC::$server->query(\OCA\UpdateNotification\Notification\Notifier::class); |
|
| 48 | + }, function() { |
|
| 49 | + $l = \OC::$server->getL10N('updatenotification'); |
|
| 50 | + return [ |
|
| 51 | + 'id' => 'updatenotification', |
|
| 52 | + 'name' => $l->t('Update notifications'), |
|
| 53 | + ]; |
|
| 54 | + }); |
|
| 55 | 55 | } |
@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - |
|
| 4 | 3 | * |
| 5 | 4 | * @author Bjoern Schiessle <[email protected]> |
| 6 | 5 | * @author Jan-Christoph Borchardt <[email protected]> |
@@ -30,164 +30,164 @@ |
||
| 30 | 30 | |
| 31 | 31 | class Util { |
| 32 | 32 | |
| 33 | - /** @var IConfig */ |
|
| 34 | - private $config; |
|
| 35 | - |
|
| 36 | - /** @var IRootFolder */ |
|
| 37 | - private $rootFolder; |
|
| 38 | - |
|
| 39 | - /** @var IAppManager */ |
|
| 40 | - private $appManager; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Util constructor. |
|
| 44 | - * |
|
| 45 | - * @param IConfig $config |
|
| 46 | - * @param IRootFolder $rootFolder |
|
| 47 | - * @param IAppManager $appManager |
|
| 48 | - */ |
|
| 49 | - public function __construct(IConfig $config, IRootFolder $rootFolder, IAppManager $appManager) { |
|
| 50 | - $this->config = $config; |
|
| 51 | - $this->rootFolder = $rootFolder; |
|
| 52 | - $this->appManager = $appManager; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @param string $color rgb color value |
|
| 57 | - * @return bool |
|
| 58 | - */ |
|
| 59 | - public function invertTextColor($color) { |
|
| 60 | - $l = $this->calculateLuminance($color); |
|
| 61 | - if($l>0.5) { |
|
| 62 | - return true; |
|
| 63 | - } else { |
|
| 64 | - return false; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * get color for on-page elements: |
|
| 70 | - * theme color by default, grey if theme color is to bright |
|
| 71 | - * @param $color |
|
| 72 | - * @return string |
|
| 73 | - */ |
|
| 74 | - public function elementColor($color) { |
|
| 75 | - $l = $this->calculateLuminance($color); |
|
| 76 | - if($l>0.8) { |
|
| 77 | - return '#555555'; |
|
| 78 | - } else { |
|
| 79 | - return $color; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @param string $color rgb color value |
|
| 85 | - * @return float |
|
| 86 | - */ |
|
| 87 | - public function calculateLuminance($color) { |
|
| 88 | - $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); |
|
| 89 | - if (strlen($hex) === 3) { |
|
| 90 | - $hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2}; |
|
| 91 | - } |
|
| 92 | - if (strlen($hex) !== 6) { |
|
| 93 | - return 0; |
|
| 94 | - } |
|
| 95 | - $r = hexdec(substr($hex, 0, 2)); |
|
| 96 | - $g = hexdec(substr($hex, 2, 2)); |
|
| 97 | - $b = hexdec(substr($hex, 4, 2)); |
|
| 98 | - return (0.299 * $r + 0.587 * $g + 0.114 * $b)/255; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * @param $color |
|
| 103 | - * @return string base64 encoded radio button svg |
|
| 104 | - */ |
|
| 105 | - public function generateRadioButton($color) { |
|
| 106 | - $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' . |
|
| 107 | - '<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>'; |
|
| 108 | - return base64_encode($radioButtonIcon); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @param $app string app name |
|
| 114 | - * @return string path to app icon / logo |
|
| 115 | - */ |
|
| 116 | - public function getAppIcon($app) { |
|
| 117 | - $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
| 118 | - try { |
|
| 119 | - $appPath = $this->appManager->getAppPath($app); |
|
| 120 | - $icon = $appPath . '/img/' . $app . '.svg'; |
|
| 121 | - if (file_exists($icon)) { |
|
| 122 | - return $icon; |
|
| 123 | - } |
|
| 124 | - $icon = $appPath . '/img/app.svg'; |
|
| 125 | - if (file_exists($icon)) { |
|
| 126 | - return $icon; |
|
| 127 | - } |
|
| 128 | - } catch (AppPathNotFoundException $e) {} |
|
| 129 | - |
|
| 130 | - if($this->config->getAppValue('theming', 'logoMime', '') !== '' && $this->rootFolder->nodeExists('/themedinstancelogo')) { |
|
| 131 | - return $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/themedinstancelogo'; |
|
| 132 | - } |
|
| 133 | - return \OC::$SERVERROOT . '/core/img/logo.svg'; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * @param $app string app name |
|
| 138 | - * @param $image string relative path to image in app folder |
|
| 139 | - * @return string|false absolute path to image |
|
| 140 | - */ |
|
| 141 | - public function getAppImage($app, $image) { |
|
| 142 | - $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
| 143 | - $image = str_replace(array('\0', '\\', '..'), '', $image); |
|
| 144 | - if ($app === "core") { |
|
| 145 | - $icon = \OC::$SERVERROOT . '/core/img/' . $image; |
|
| 146 | - if (file_exists($icon)) { |
|
| 147 | - return $icon; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - try { |
|
| 152 | - $appPath = $this->appManager->getAppPath($app); |
|
| 153 | - } catch (AppPathNotFoundException $e) { |
|
| 154 | - return false; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - $icon = $appPath . '/img/' . $image; |
|
| 158 | - if (file_exists($icon)) { |
|
| 159 | - return $icon; |
|
| 160 | - } |
|
| 161 | - $icon = $appPath . '/img/' . $image . '.svg'; |
|
| 162 | - if (file_exists($icon)) { |
|
| 163 | - return $icon; |
|
| 164 | - } |
|
| 165 | - $icon = $appPath . '/img/' . $image . '.png'; |
|
| 166 | - if (file_exists($icon)) { |
|
| 167 | - return $icon; |
|
| 168 | - } |
|
| 169 | - $icon = $appPath . '/img/' . $image . '.gif'; |
|
| 170 | - if (file_exists($icon)) { |
|
| 171 | - return $icon; |
|
| 172 | - } |
|
| 173 | - $icon = $appPath . '/img/' . $image . '.jpg'; |
|
| 174 | - if (file_exists($icon)) { |
|
| 175 | - return $icon; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - return false; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * replace default color with a custom one |
|
| 183 | - * |
|
| 184 | - * @param $svg string content of a svg file |
|
| 185 | - * @param $color string color to match |
|
| 186 | - * @return string |
|
| 187 | - */ |
|
| 188 | - public function colorizeSvg($svg, $color) { |
|
| 189 | - $svg = preg_replace('/#0082c9/i', $color, $svg); |
|
| 190 | - return $svg; |
|
| 191 | - } |
|
| 33 | + /** @var IConfig */ |
|
| 34 | + private $config; |
|
| 35 | + |
|
| 36 | + /** @var IRootFolder */ |
|
| 37 | + private $rootFolder; |
|
| 38 | + |
|
| 39 | + /** @var IAppManager */ |
|
| 40 | + private $appManager; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Util constructor. |
|
| 44 | + * |
|
| 45 | + * @param IConfig $config |
|
| 46 | + * @param IRootFolder $rootFolder |
|
| 47 | + * @param IAppManager $appManager |
|
| 48 | + */ |
|
| 49 | + public function __construct(IConfig $config, IRootFolder $rootFolder, IAppManager $appManager) { |
|
| 50 | + $this->config = $config; |
|
| 51 | + $this->rootFolder = $rootFolder; |
|
| 52 | + $this->appManager = $appManager; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param string $color rgb color value |
|
| 57 | + * @return bool |
|
| 58 | + */ |
|
| 59 | + public function invertTextColor($color) { |
|
| 60 | + $l = $this->calculateLuminance($color); |
|
| 61 | + if($l>0.5) { |
|
| 62 | + return true; |
|
| 63 | + } else { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * get color for on-page elements: |
|
| 70 | + * theme color by default, grey if theme color is to bright |
|
| 71 | + * @param $color |
|
| 72 | + * @return string |
|
| 73 | + */ |
|
| 74 | + public function elementColor($color) { |
|
| 75 | + $l = $this->calculateLuminance($color); |
|
| 76 | + if($l>0.8) { |
|
| 77 | + return '#555555'; |
|
| 78 | + } else { |
|
| 79 | + return $color; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @param string $color rgb color value |
|
| 85 | + * @return float |
|
| 86 | + */ |
|
| 87 | + public function calculateLuminance($color) { |
|
| 88 | + $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color); |
|
| 89 | + if (strlen($hex) === 3) { |
|
| 90 | + $hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2}; |
|
| 91 | + } |
|
| 92 | + if (strlen($hex) !== 6) { |
|
| 93 | + return 0; |
|
| 94 | + } |
|
| 95 | + $r = hexdec(substr($hex, 0, 2)); |
|
| 96 | + $g = hexdec(substr($hex, 2, 2)); |
|
| 97 | + $b = hexdec(substr($hex, 4, 2)); |
|
| 98 | + return (0.299 * $r + 0.587 * $g + 0.114 * $b)/255; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * @param $color |
|
| 103 | + * @return string base64 encoded radio button svg |
|
| 104 | + */ |
|
| 105 | + public function generateRadioButton($color) { |
|
| 106 | + $radioButtonIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">' . |
|
| 107 | + '<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>'; |
|
| 108 | + return base64_encode($radioButtonIcon); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @param $app string app name |
|
| 114 | + * @return string path to app icon / logo |
|
| 115 | + */ |
|
| 116 | + public function getAppIcon($app) { |
|
| 117 | + $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
| 118 | + try { |
|
| 119 | + $appPath = $this->appManager->getAppPath($app); |
|
| 120 | + $icon = $appPath . '/img/' . $app . '.svg'; |
|
| 121 | + if (file_exists($icon)) { |
|
| 122 | + return $icon; |
|
| 123 | + } |
|
| 124 | + $icon = $appPath . '/img/app.svg'; |
|
| 125 | + if (file_exists($icon)) { |
|
| 126 | + return $icon; |
|
| 127 | + } |
|
| 128 | + } catch (AppPathNotFoundException $e) {} |
|
| 129 | + |
|
| 130 | + if($this->config->getAppValue('theming', 'logoMime', '') !== '' && $this->rootFolder->nodeExists('/themedinstancelogo')) { |
|
| 131 | + return $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/themedinstancelogo'; |
|
| 132 | + } |
|
| 133 | + return \OC::$SERVERROOT . '/core/img/logo.svg'; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * @param $app string app name |
|
| 138 | + * @param $image string relative path to image in app folder |
|
| 139 | + * @return string|false absolute path to image |
|
| 140 | + */ |
|
| 141 | + public function getAppImage($app, $image) { |
|
| 142 | + $app = str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
| 143 | + $image = str_replace(array('\0', '\\', '..'), '', $image); |
|
| 144 | + if ($app === "core") { |
|
| 145 | + $icon = \OC::$SERVERROOT . '/core/img/' . $image; |
|
| 146 | + if (file_exists($icon)) { |
|
| 147 | + return $icon; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + try { |
|
| 152 | + $appPath = $this->appManager->getAppPath($app); |
|
| 153 | + } catch (AppPathNotFoundException $e) { |
|
| 154 | + return false; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + $icon = $appPath . '/img/' . $image; |
|
| 158 | + if (file_exists($icon)) { |
|
| 159 | + return $icon; |
|
| 160 | + } |
|
| 161 | + $icon = $appPath . '/img/' . $image . '.svg'; |
|
| 162 | + if (file_exists($icon)) { |
|
| 163 | + return $icon; |
|
| 164 | + } |
|
| 165 | + $icon = $appPath . '/img/' . $image . '.png'; |
|
| 166 | + if (file_exists($icon)) { |
|
| 167 | + return $icon; |
|
| 168 | + } |
|
| 169 | + $icon = $appPath . '/img/' . $image . '.gif'; |
|
| 170 | + if (file_exists($icon)) { |
|
| 171 | + return $icon; |
|
| 172 | + } |
|
| 173 | + $icon = $appPath . '/img/' . $image . '.jpg'; |
|
| 174 | + if (file_exists($icon)) { |
|
| 175 | + return $icon; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + return false; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * replace default color with a custom one |
|
| 183 | + * |
|
| 184 | + * @param $svg string content of a svg file |
|
| 185 | + * @param $color string color to match |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 188 | + public function colorizeSvg($svg, $color) { |
|
| 189 | + $svg = preg_replace('/#0082c9/i', $color, $svg); |
|
| 190 | + return $svg; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | } |
@@ -36,142 +36,142 @@ |
||
| 36 | 36 | use OCP\IConfig; |
| 37 | 37 | |
| 38 | 38 | class IconController extends Controller { |
| 39 | - /** @var ThemingDefaults */ |
|
| 40 | - private $themingDefaults; |
|
| 41 | - /** @var Util */ |
|
| 42 | - private $util; |
|
| 43 | - /** @var ITimeFactory */ |
|
| 44 | - private $timeFactory; |
|
| 45 | - /** @var IConfig */ |
|
| 46 | - private $config; |
|
| 47 | - /** @var IconBuilder */ |
|
| 48 | - private $iconBuilder; |
|
| 49 | - /** @var ImageManager */ |
|
| 50 | - private $imageManager; |
|
| 39 | + /** @var ThemingDefaults */ |
|
| 40 | + private $themingDefaults; |
|
| 41 | + /** @var Util */ |
|
| 42 | + private $util; |
|
| 43 | + /** @var ITimeFactory */ |
|
| 44 | + private $timeFactory; |
|
| 45 | + /** @var IConfig */ |
|
| 46 | + private $config; |
|
| 47 | + /** @var IconBuilder */ |
|
| 48 | + private $iconBuilder; |
|
| 49 | + /** @var ImageManager */ |
|
| 50 | + private $imageManager; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * IconController constructor. |
|
| 54 | - * |
|
| 55 | - * @param string $appName |
|
| 56 | - * @param IRequest $request |
|
| 57 | - * @param ThemingDefaults $themingDefaults |
|
| 58 | - * @param Util $util |
|
| 59 | - * @param ITimeFactory $timeFactory |
|
| 60 | - * @param IConfig $config |
|
| 61 | - * @param IconBuilder $iconBuilder |
|
| 62 | - * @param ImageManager $imageManager |
|
| 63 | - */ |
|
| 64 | - public function __construct( |
|
| 65 | - $appName, |
|
| 66 | - IRequest $request, |
|
| 67 | - ThemingDefaults $themingDefaults, |
|
| 68 | - Util $util, |
|
| 69 | - ITimeFactory $timeFactory, |
|
| 70 | - IConfig $config, |
|
| 71 | - IconBuilder $iconBuilder, |
|
| 72 | - ImageManager $imageManager |
|
| 73 | - ) { |
|
| 74 | - parent::__construct($appName, $request); |
|
| 52 | + /** |
|
| 53 | + * IconController constructor. |
|
| 54 | + * |
|
| 55 | + * @param string $appName |
|
| 56 | + * @param IRequest $request |
|
| 57 | + * @param ThemingDefaults $themingDefaults |
|
| 58 | + * @param Util $util |
|
| 59 | + * @param ITimeFactory $timeFactory |
|
| 60 | + * @param IConfig $config |
|
| 61 | + * @param IconBuilder $iconBuilder |
|
| 62 | + * @param ImageManager $imageManager |
|
| 63 | + */ |
|
| 64 | + public function __construct( |
|
| 65 | + $appName, |
|
| 66 | + IRequest $request, |
|
| 67 | + ThemingDefaults $themingDefaults, |
|
| 68 | + Util $util, |
|
| 69 | + ITimeFactory $timeFactory, |
|
| 70 | + IConfig $config, |
|
| 71 | + IconBuilder $iconBuilder, |
|
| 72 | + ImageManager $imageManager |
|
| 73 | + ) { |
|
| 74 | + parent::__construct($appName, $request); |
|
| 75 | 75 | |
| 76 | - $this->themingDefaults = $themingDefaults; |
|
| 77 | - $this->util = $util; |
|
| 78 | - $this->timeFactory = $timeFactory; |
|
| 79 | - $this->config = $config; |
|
| 80 | - $this->iconBuilder = $iconBuilder; |
|
| 81 | - $this->imageManager = $imageManager; |
|
| 82 | - } |
|
| 76 | + $this->themingDefaults = $themingDefaults; |
|
| 77 | + $this->util = $util; |
|
| 78 | + $this->timeFactory = $timeFactory; |
|
| 79 | + $this->config = $config; |
|
| 80 | + $this->iconBuilder = $iconBuilder; |
|
| 81 | + $this->imageManager = $imageManager; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @PublicPage |
|
| 86 | - * @NoCSRFRequired |
|
| 87 | - * |
|
| 88 | - * @param $app string app name |
|
| 89 | - * @param $image string image file name (svg required) |
|
| 90 | - * @return FileDisplayResponse|NotFoundResponse |
|
| 91 | - */ |
|
| 92 | - public function getThemedIcon($app, $image) { |
|
| 93 | - try { |
|
| 94 | - $iconFile = $this->imageManager->getCachedImage("icon-" . $app . '-' . str_replace("/","_",$image)); |
|
| 95 | - } catch (NotFoundException $exception) { |
|
| 96 | - $icon = $this->iconBuilder->colorSvg($app, $image); |
|
| 97 | - if ($icon === false || $icon === "") { |
|
| 98 | - return new NotFoundResponse(); |
|
| 99 | - } |
|
| 100 | - $iconFile = $this->imageManager->setCachedImage("icon-" . $app . '-' . str_replace("/","_",$image), $icon); |
|
| 101 | - } |
|
| 102 | - if ($iconFile !== false) { |
|
| 103 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']); |
|
| 104 | - $response->cacheFor(86400); |
|
| 105 | - $expires = new \DateTime(); |
|
| 106 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 107 | - $expires->add(new \DateInterval('PT24H')); |
|
| 108 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 109 | - $response->addHeader('Pragma', 'cache'); |
|
| 110 | - return $response; |
|
| 111 | - } else { |
|
| 112 | - return new NotFoundResponse(); |
|
| 113 | - } |
|
| 114 | - } |
|
| 84 | + /** |
|
| 85 | + * @PublicPage |
|
| 86 | + * @NoCSRFRequired |
|
| 87 | + * |
|
| 88 | + * @param $app string app name |
|
| 89 | + * @param $image string image file name (svg required) |
|
| 90 | + * @return FileDisplayResponse|NotFoundResponse |
|
| 91 | + */ |
|
| 92 | + public function getThemedIcon($app, $image) { |
|
| 93 | + try { |
|
| 94 | + $iconFile = $this->imageManager->getCachedImage("icon-" . $app . '-' . str_replace("/","_",$image)); |
|
| 95 | + } catch (NotFoundException $exception) { |
|
| 96 | + $icon = $this->iconBuilder->colorSvg($app, $image); |
|
| 97 | + if ($icon === false || $icon === "") { |
|
| 98 | + return new NotFoundResponse(); |
|
| 99 | + } |
|
| 100 | + $iconFile = $this->imageManager->setCachedImage("icon-" . $app . '-' . str_replace("/","_",$image), $icon); |
|
| 101 | + } |
|
| 102 | + if ($iconFile !== false) { |
|
| 103 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']); |
|
| 104 | + $response->cacheFor(86400); |
|
| 105 | + $expires = new \DateTime(); |
|
| 106 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 107 | + $expires->add(new \DateInterval('PT24H')); |
|
| 108 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 109 | + $response->addHeader('Pragma', 'cache'); |
|
| 110 | + return $response; |
|
| 111 | + } else { |
|
| 112 | + return new NotFoundResponse(); |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Return a 32x32 favicon as png |
|
| 118 | - * |
|
| 119 | - * @PublicPage |
|
| 120 | - * @NoCSRFRequired |
|
| 121 | - * |
|
| 122 | - * @param $app string app name |
|
| 123 | - * @return FileDisplayResponse|NotFoundResponse |
|
| 124 | - */ |
|
| 125 | - public function getFavicon($app = "core") { |
|
| 126 | - if ($this->themingDefaults->shouldReplaceIcons()) { |
|
| 127 | - try { |
|
| 128 | - $iconFile = $this->imageManager->getCachedImage('favIcon-' . $app); |
|
| 129 | - } catch (NotFoundException $exception) { |
|
| 130 | - $icon = $this->iconBuilder->getFavicon($app); |
|
| 131 | - $iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon); |
|
| 132 | - } |
|
| 133 | - if ($iconFile !== false) { |
|
| 134 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); |
|
| 135 | - $response->cacheFor(86400); |
|
| 136 | - $expires = new \DateTime(); |
|
| 137 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 138 | - $expires->add(new \DateInterval('PT24H')); |
|
| 139 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 140 | - $response->addHeader('Pragma', 'cache'); |
|
| 141 | - return $response; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - return new NotFoundResponse(); |
|
| 145 | - } |
|
| 116 | + /** |
|
| 117 | + * Return a 32x32 favicon as png |
|
| 118 | + * |
|
| 119 | + * @PublicPage |
|
| 120 | + * @NoCSRFRequired |
|
| 121 | + * |
|
| 122 | + * @param $app string app name |
|
| 123 | + * @return FileDisplayResponse|NotFoundResponse |
|
| 124 | + */ |
|
| 125 | + public function getFavicon($app = "core") { |
|
| 126 | + if ($this->themingDefaults->shouldReplaceIcons()) { |
|
| 127 | + try { |
|
| 128 | + $iconFile = $this->imageManager->getCachedImage('favIcon-' . $app); |
|
| 129 | + } catch (NotFoundException $exception) { |
|
| 130 | + $icon = $this->iconBuilder->getFavicon($app); |
|
| 131 | + $iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon); |
|
| 132 | + } |
|
| 133 | + if ($iconFile !== false) { |
|
| 134 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); |
|
| 135 | + $response->cacheFor(86400); |
|
| 136 | + $expires = new \DateTime(); |
|
| 137 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 138 | + $expires->add(new \DateInterval('PT24H')); |
|
| 139 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 140 | + $response->addHeader('Pragma', 'cache'); |
|
| 141 | + return $response; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + return new NotFoundResponse(); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Return a 512x512 icon for touch devices |
|
| 149 | - * |
|
| 150 | - * @PublicPage |
|
| 151 | - * @NoCSRFRequired |
|
| 152 | - * |
|
| 153 | - * @param $app string app name |
|
| 154 | - * @return FileDisplayResponse|NotFoundResponse |
|
| 155 | - */ |
|
| 156 | - public function getTouchIcon($app = "core") { |
|
| 157 | - if ($this->themingDefaults->shouldReplaceIcons()) { |
|
| 158 | - try { |
|
| 159 | - $iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app); |
|
| 160 | - } catch (NotFoundException $exception) { |
|
| 161 | - $icon = $this->iconBuilder->getTouchIcon($app); |
|
| 162 | - $iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon); |
|
| 163 | - } |
|
| 164 | - if ($iconFile !== false) { |
|
| 165 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); |
|
| 166 | - $response->cacheFor(86400); |
|
| 167 | - $expires = new \DateTime(); |
|
| 168 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 169 | - $expires->add(new \DateInterval('PT24H')); |
|
| 170 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 171 | - $response->addHeader('Pragma', 'cache'); |
|
| 172 | - return $response; |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - return new NotFoundResponse(); |
|
| 176 | - } |
|
| 147 | + /** |
|
| 148 | + * Return a 512x512 icon for touch devices |
|
| 149 | + * |
|
| 150 | + * @PublicPage |
|
| 151 | + * @NoCSRFRequired |
|
| 152 | + * |
|
| 153 | + * @param $app string app name |
|
| 154 | + * @return FileDisplayResponse|NotFoundResponse |
|
| 155 | + */ |
|
| 156 | + public function getTouchIcon($app = "core") { |
|
| 157 | + if ($this->themingDefaults->shouldReplaceIcons()) { |
|
| 158 | + try { |
|
| 159 | + $iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app); |
|
| 160 | + } catch (NotFoundException $exception) { |
|
| 161 | + $icon = $this->iconBuilder->getTouchIcon($app); |
|
| 162 | + $iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon); |
|
| 163 | + } |
|
| 164 | + if ($iconFile !== false) { |
|
| 165 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); |
|
| 166 | + $response->cacheFor(86400); |
|
| 167 | + $expires = new \DateTime(); |
|
| 168 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 169 | + $expires->add(new \DateInterval('PT24H')); |
|
| 170 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 171 | + $response->addHeader('Pragma', 'cache'); |
|
| 172 | + return $response; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + return new NotFoundResponse(); |
|
| 176 | + } |
|
| 177 | 177 | } |
@@ -28,55 +28,55 @@ |
||
| 28 | 28 | use OCP\Settings\IIconSection; |
| 29 | 29 | |
| 30 | 30 | class Section implements IIconSection { |
| 31 | - /** @var IL10N */ |
|
| 32 | - private $l; |
|
| 33 | - /** @var IURLGenerator */ |
|
| 34 | - private $url; |
|
| 31 | + /** @var IL10N */ |
|
| 32 | + private $l; |
|
| 33 | + /** @var IURLGenerator */ |
|
| 34 | + private $url; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param IURLGenerator $url |
|
| 38 | - * @param IL10N $l |
|
| 39 | - */ |
|
| 40 | - public function __construct(IURLGenerator $url, IL10N $l) { |
|
| 41 | - $this->url = $url; |
|
| 42 | - $this->l = $l; |
|
| 43 | - } |
|
| 36 | + /** |
|
| 37 | + * @param IURLGenerator $url |
|
| 38 | + * @param IL10N $l |
|
| 39 | + */ |
|
| 40 | + public function __construct(IURLGenerator $url, IL10N $l) { |
|
| 41 | + $this->url = $url; |
|
| 42 | + $this->l = $l; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * returns the ID of the section. It is supposed to be a lower case string, |
|
| 47 | - * e.g. 'ldap' |
|
| 48 | - * |
|
| 49 | - * @returns string |
|
| 50 | - */ |
|
| 51 | - public function getID() { |
|
| 52 | - return 'theming'; |
|
| 53 | - } |
|
| 45 | + /** |
|
| 46 | + * returns the ID of the section. It is supposed to be a lower case string, |
|
| 47 | + * e.g. 'ldap' |
|
| 48 | + * |
|
| 49 | + * @returns string |
|
| 50 | + */ |
|
| 51 | + public function getID() { |
|
| 52 | + return 'theming'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
| 57 | - * integration'. Use the L10N service to translate it. |
|
| 58 | - * |
|
| 59 | - * @return string |
|
| 60 | - */ |
|
| 61 | - public function getName() { |
|
| 62 | - return $this->l->t('Theming'); |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
| 57 | + * integration'. Use the L10N service to translate it. |
|
| 58 | + * |
|
| 59 | + * @return string |
|
| 60 | + */ |
|
| 61 | + public function getName() { |
|
| 62 | + return $this->l->t('Theming'); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @return int whether the form should be rather on the top or bottom of |
|
| 67 | - * the settings navigation. The sections are arranged in ascending order of |
|
| 68 | - * the priority values. It is required to return a value between 0 and 99. |
|
| 69 | - * |
|
| 70 | - * E.g.: 70 |
|
| 71 | - */ |
|
| 72 | - public function getPriority() { |
|
| 73 | - return 30; |
|
| 74 | - } |
|
| 65 | + /** |
|
| 66 | + * @return int whether the form should be rather on the top or bottom of |
|
| 67 | + * the settings navigation. The sections are arranged in ascending order of |
|
| 68 | + * the priority values. It is required to return a value between 0 and 99. |
|
| 69 | + * |
|
| 70 | + * E.g.: 70 |
|
| 71 | + */ |
|
| 72 | + public function getPriority() { |
|
| 73 | + return 30; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * {@inheritdoc} |
|
| 78 | - */ |
|
| 79 | - public function getIcon() { |
|
| 80 | - return $this->url->imagePath('theming', 'app-dark.svg'); |
|
| 81 | - } |
|
| 76 | + /** |
|
| 77 | + * {@inheritdoc} |
|
| 78 | + */ |
|
| 79 | + public function getIcon() { |
|
| 80 | + return $this->url->imagePath('theming', 'app-dark.svg'); |
|
| 81 | + } |
|
| 82 | 82 | } |
@@ -25,58 +25,58 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | return ['routes' => [ |
| 28 | - [ |
|
| 29 | - 'name' => 'Theming#updateStylesheet', |
|
| 30 | - 'url' => '/ajax/updateStylesheet', |
|
| 31 | - 'verb' => 'POST' |
|
| 32 | - ], |
|
| 33 | - [ |
|
| 34 | - 'name' => 'Theming#undo', |
|
| 35 | - 'url' => '/ajax/undoChanges', |
|
| 36 | - 'verb' => 'POST' |
|
| 37 | - ], |
|
| 38 | - [ |
|
| 39 | - 'name' => 'Theming#updateLogo', |
|
| 40 | - 'url' => '/ajax/updateLogo', |
|
| 41 | - 'verb' => 'POST' |
|
| 42 | - ], |
|
| 43 | - [ |
|
| 44 | - 'name' => 'Theming#getStylesheet', |
|
| 45 | - 'url' => '/styles', |
|
| 46 | - 'verb' => 'GET', |
|
| 47 | - ], |
|
| 48 | - [ |
|
| 49 | - 'name' => 'Theming#getLogo', |
|
| 50 | - 'url' => '/logo', |
|
| 51 | - 'verb' => 'GET', |
|
| 52 | - ], |
|
| 53 | - [ |
|
| 54 | - 'name' => 'Theming#getLoginBackground', |
|
| 55 | - 'url' => '/loginbackground', |
|
| 56 | - 'verb' => 'GET', |
|
| 57 | - ], |
|
| 58 | - [ |
|
| 59 | - 'name' => 'Theming#getJavascript', |
|
| 60 | - 'url' => '/js/theming', |
|
| 61 | - 'verb' => 'GET', |
|
| 62 | - ], |
|
| 63 | - [ |
|
| 64 | - 'name' => 'Icon#getFavicon', |
|
| 65 | - 'url' => '/favicon/{app}', |
|
| 66 | - 'verb' => 'GET', |
|
| 67 | - 'defaults' => array('app' => 'core'), |
|
| 68 | - ], |
|
| 69 | - [ |
|
| 70 | - 'name' => 'Icon#getTouchIcon', |
|
| 71 | - 'url' => '/icon/{app}', |
|
| 72 | - 'verb' => 'GET', |
|
| 73 | - 'defaults' => array('app' => 'core'), |
|
| 74 | - ], |
|
| 75 | - [ |
|
| 76 | - 'name' => 'Icon#getThemedIcon', |
|
| 77 | - 'url' => '/img/{app}/{image}', |
|
| 78 | - 'verb' => 'GET', |
|
| 79 | - 'requirements' => array('image' => '.+') |
|
| 80 | - ], |
|
| 28 | + [ |
|
| 29 | + 'name' => 'Theming#updateStylesheet', |
|
| 30 | + 'url' => '/ajax/updateStylesheet', |
|
| 31 | + 'verb' => 'POST' |
|
| 32 | + ], |
|
| 33 | + [ |
|
| 34 | + 'name' => 'Theming#undo', |
|
| 35 | + 'url' => '/ajax/undoChanges', |
|
| 36 | + 'verb' => 'POST' |
|
| 37 | + ], |
|
| 38 | + [ |
|
| 39 | + 'name' => 'Theming#updateLogo', |
|
| 40 | + 'url' => '/ajax/updateLogo', |
|
| 41 | + 'verb' => 'POST' |
|
| 42 | + ], |
|
| 43 | + [ |
|
| 44 | + 'name' => 'Theming#getStylesheet', |
|
| 45 | + 'url' => '/styles', |
|
| 46 | + 'verb' => 'GET', |
|
| 47 | + ], |
|
| 48 | + [ |
|
| 49 | + 'name' => 'Theming#getLogo', |
|
| 50 | + 'url' => '/logo', |
|
| 51 | + 'verb' => 'GET', |
|
| 52 | + ], |
|
| 53 | + [ |
|
| 54 | + 'name' => 'Theming#getLoginBackground', |
|
| 55 | + 'url' => '/loginbackground', |
|
| 56 | + 'verb' => 'GET', |
|
| 57 | + ], |
|
| 58 | + [ |
|
| 59 | + 'name' => 'Theming#getJavascript', |
|
| 60 | + 'url' => '/js/theming', |
|
| 61 | + 'verb' => 'GET', |
|
| 62 | + ], |
|
| 63 | + [ |
|
| 64 | + 'name' => 'Icon#getFavicon', |
|
| 65 | + 'url' => '/favicon/{app}', |
|
| 66 | + 'verb' => 'GET', |
|
| 67 | + 'defaults' => array('app' => 'core'), |
|
| 68 | + ], |
|
| 69 | + [ |
|
| 70 | + 'name' => 'Icon#getTouchIcon', |
|
| 71 | + 'url' => '/icon/{app}', |
|
| 72 | + 'verb' => 'GET', |
|
| 73 | + 'defaults' => array('app' => 'core'), |
|
| 74 | + ], |
|
| 75 | + [ |
|
| 76 | + 'name' => 'Icon#getThemedIcon', |
|
| 77 | + 'url' => '/img/{app}/{image}', |
|
| 78 | + 'verb' => 'GET', |
|
| 79 | + 'requirements' => array('image' => '.+') |
|
| 80 | + ], |
|
| 81 | 81 | ]]; |
| 82 | 82 | |
@@ -24,31 +24,31 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | $linkToCSS = \OC::$server->getURLGenerator()->linkToRoute( |
| 27 | - 'theming.Theming.getStylesheet', |
|
| 28 | - [ |
|
| 29 | - 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), |
|
| 30 | - ] |
|
| 27 | + 'theming.Theming.getStylesheet', |
|
| 28 | + [ |
|
| 29 | + 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), |
|
| 30 | + ] |
|
| 31 | 31 | ); |
| 32 | 32 | \OCP\Util::addHeader( |
| 33 | - 'link', |
|
| 34 | - [ |
|
| 35 | - 'rel' => 'stylesheet', |
|
| 36 | - 'href' => $linkToCSS, |
|
| 37 | - ] |
|
| 33 | + 'link', |
|
| 34 | + [ |
|
| 35 | + 'rel' => 'stylesheet', |
|
| 36 | + 'href' => $linkToCSS, |
|
| 37 | + ] |
|
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | $linkToJs = \OC::$server->getURLGenerator()->linkToRoute( |
| 41 | - 'theming.Theming.getJavascript', |
|
| 42 | - [ |
|
| 43 | - 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), |
|
| 44 | - ] |
|
| 41 | + 'theming.Theming.getJavascript', |
|
| 42 | + [ |
|
| 43 | + 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), |
|
| 44 | + ] |
|
| 45 | 45 | ); |
| 46 | 46 | \OCP\Util::addHeader( |
| 47 | - 'script', |
|
| 48 | - [ |
|
| 49 | - 'src' => $linkToJs, |
|
| 50 | - 'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() |
|
| 51 | - ], '' |
|
| 47 | + 'script', |
|
| 48 | + [ |
|
| 49 | + 'src' => $linkToJs, |
|
| 50 | + 'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() |
|
| 51 | + ], '' |
|
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | 54 | $app = new \OCP\AppFramework\App('theming'); |
@@ -30,73 +30,73 @@ |
||
| 30 | 30 | |
| 31 | 31 | class BackupCodesProvider implements IProvider { |
| 32 | 32 | |
| 33 | - /** @var BackupCodeStorage */ |
|
| 34 | - private $storage; |
|
| 33 | + /** @var BackupCodeStorage */ |
|
| 34 | + private $storage; |
|
| 35 | 35 | |
| 36 | - /** @var IL10N */ |
|
| 37 | - private $l10n; |
|
| 36 | + /** @var IL10N */ |
|
| 37 | + private $l10n; |
|
| 38 | 38 | |
| 39 | - public function __construct(BackupCodeStorage $storage, IL10N $l10n) { |
|
| 40 | - $this->l10n = $l10n; |
|
| 41 | - $this->storage = $storage; |
|
| 42 | - } |
|
| 39 | + public function __construct(BackupCodeStorage $storage, IL10N $l10n) { |
|
| 40 | + $this->l10n = $l10n; |
|
| 41 | + $this->storage = $storage; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Get unique identifier of this 2FA provider |
|
| 46 | - * |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - public function getId() { |
|
| 50 | - return 'backup_codes'; |
|
| 51 | - } |
|
| 44 | + /** |
|
| 45 | + * Get unique identifier of this 2FA provider |
|
| 46 | + * |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + public function getId() { |
|
| 50 | + return 'backup_codes'; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Get the display name for selecting the 2FA provider |
|
| 55 | - * |
|
| 56 | - * @return string |
|
| 57 | - */ |
|
| 58 | - public function getDisplayName() { |
|
| 59 | - return $this->l10n->t('Backup code'); |
|
| 60 | - } |
|
| 53 | + /** |
|
| 54 | + * Get the display name for selecting the 2FA provider |
|
| 55 | + * |
|
| 56 | + * @return string |
|
| 57 | + */ |
|
| 58 | + public function getDisplayName() { |
|
| 59 | + return $this->l10n->t('Backup code'); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Get the description for selecting the 2FA provider |
|
| 64 | - * |
|
| 65 | - * @return string |
|
| 66 | - */ |
|
| 67 | - public function getDescription() { |
|
| 68 | - return $this->l10n->t('Use backup code'); |
|
| 69 | - } |
|
| 62 | + /** |
|
| 63 | + * Get the description for selecting the 2FA provider |
|
| 64 | + * |
|
| 65 | + * @return string |
|
| 66 | + */ |
|
| 67 | + public function getDescription() { |
|
| 68 | + return $this->l10n->t('Use backup code'); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Get the template for rending the 2FA provider view |
|
| 73 | - * |
|
| 74 | - * @param IUser $user |
|
| 75 | - * @return Template |
|
| 76 | - */ |
|
| 77 | - public function getTemplate(IUser $user) { |
|
| 78 | - $tmpl = new Template('twofactor_backupcodes', 'challenge'); |
|
| 79 | - return $tmpl; |
|
| 80 | - } |
|
| 71 | + /** |
|
| 72 | + * Get the template for rending the 2FA provider view |
|
| 73 | + * |
|
| 74 | + * @param IUser $user |
|
| 75 | + * @return Template |
|
| 76 | + */ |
|
| 77 | + public function getTemplate(IUser $user) { |
|
| 78 | + $tmpl = new Template('twofactor_backupcodes', 'challenge'); |
|
| 79 | + return $tmpl; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Verify the given challenge |
|
| 84 | - * |
|
| 85 | - * @param IUser $user |
|
| 86 | - * @param string $challenge |
|
| 87 | - */ |
|
| 88 | - public function verifyChallenge(IUser $user, $challenge) { |
|
| 89 | - return $this->storage->validateCode($user, $challenge); |
|
| 90 | - } |
|
| 82 | + /** |
|
| 83 | + * Verify the given challenge |
|
| 84 | + * |
|
| 85 | + * @param IUser $user |
|
| 86 | + * @param string $challenge |
|
| 87 | + */ |
|
| 88 | + public function verifyChallenge(IUser $user, $challenge) { |
|
| 89 | + return $this->storage->validateCode($user, $challenge); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Decides whether 2FA is enabled for the given user |
|
| 94 | - * |
|
| 95 | - * @param IUser $user |
|
| 96 | - * @return boolean |
|
| 97 | - */ |
|
| 98 | - public function isTwoFactorAuthEnabledForUser(IUser $user) { |
|
| 99 | - return $this->storage->hasBackupCodes($user); |
|
| 100 | - } |
|
| 92 | + /** |
|
| 93 | + * Decides whether 2FA is enabled for the given user |
|
| 94 | + * |
|
| 95 | + * @param IUser $user |
|
| 96 | + * @return boolean |
|
| 97 | + */ |
|
| 98 | + public function isTwoFactorAuthEnabledForUser(IUser $user) { |
|
| 99 | + return $this->storage->hasBackupCodes($user); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | 102 | } |
@@ -31,42 +31,42 @@ |
||
| 31 | 31 | |
| 32 | 32 | class Provider implements IProvider { |
| 33 | 33 | |
| 34 | - /** @var L10nFactory */ |
|
| 35 | - private $l10n; |
|
| 34 | + /** @var L10nFactory */ |
|
| 35 | + private $l10n; |
|
| 36 | 36 | |
| 37 | - /** @var IURLGenerator */ |
|
| 38 | - private $urlGenerator; |
|
| 37 | + /** @var IURLGenerator */ |
|
| 38 | + private $urlGenerator; |
|
| 39 | 39 | |
| 40 | - /** @var ILogger */ |
|
| 41 | - private $logger; |
|
| 40 | + /** @var ILogger */ |
|
| 41 | + private $logger; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param L10nFactory $l10n |
|
| 45 | - * @param IURLGenerator $urlGenerator |
|
| 46 | - * @param ILogger $logger |
|
| 47 | - */ |
|
| 48 | - public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, ILogger $logger) { |
|
| 49 | - $this->logger = $logger; |
|
| 50 | - $this->urlGenerator = $urlGenerator; |
|
| 51 | - $this->l10n = $l10n; |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * @param L10nFactory $l10n |
|
| 45 | + * @param IURLGenerator $urlGenerator |
|
| 46 | + * @param ILogger $logger |
|
| 47 | + */ |
|
| 48 | + public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, ILogger $logger) { |
|
| 49 | + $this->logger = $logger; |
|
| 50 | + $this->urlGenerator = $urlGenerator; |
|
| 51 | + $this->l10n = $l10n; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
| 55 | - if ($event->getApp() !== 'twofactor_backupcodes') { |
|
| 56 | - throw new InvalidArgumentException(); |
|
| 57 | - } |
|
| 54 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
| 55 | + if ($event->getApp() !== 'twofactor_backupcodes') { |
|
| 56 | + throw new InvalidArgumentException(); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $l = $this->l10n->get('twofactor_backupcodes', $language); |
|
| 59 | + $l = $this->l10n->get('twofactor_backupcodes', $language); |
|
| 60 | 60 | |
| 61 | - switch ($event->getSubject()) { |
|
| 62 | - case 'codes_generated': |
|
| 63 | - $event->setParsedSubject($l->t('You created two-factor backup codes for your account')); |
|
| 64 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg'))); |
|
| 65 | - break; |
|
| 66 | - default: |
|
| 67 | - throw new InvalidArgumentException(); |
|
| 68 | - } |
|
| 69 | - return $event; |
|
| 70 | - } |
|
| 61 | + switch ($event->getSubject()) { |
|
| 62 | + case 'codes_generated': |
|
| 63 | + $event->setParsedSubject($l->t('You created two-factor backup codes for your account')); |
|
| 64 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg'))); |
|
| 65 | + break; |
|
| 66 | + default: |
|
| 67 | + throw new InvalidArgumentException(); |
|
| 68 | + } |
|
| 69 | + return $event; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | } |