@@ -29,58 +29,58 @@ |
||
29 | 29 | use OCP\Settings\IIconSection; |
30 | 30 | |
31 | 31 | class PersonalSection implements IIconSection { |
32 | - /** @var IURLGenerator */ |
|
33 | - private $urlGenerator; |
|
34 | - /** @var IL10N */ |
|
35 | - private $l; |
|
32 | + /** @var IURLGenerator */ |
|
33 | + private $urlGenerator; |
|
34 | + /** @var IL10N */ |
|
35 | + private $l; |
|
36 | 36 | |
37 | - public function __construct(IURLGenerator $urlGenerator, IL10N $l) { |
|
38 | - $this->urlGenerator = $urlGenerator; |
|
39 | - $this->l = $l; |
|
40 | - } |
|
37 | + public function __construct(IURLGenerator $urlGenerator, IL10N $l) { |
|
38 | + $this->urlGenerator = $urlGenerator; |
|
39 | + $this->l = $l; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * returns the relative path to an 16*16 icon describing the section. |
|
44 | - * e.g. '/core/img/places/files.svg' |
|
45 | - * |
|
46 | - * @returns string |
|
47 | - * @since 12 |
|
48 | - */ |
|
49 | - public function getIcon() { |
|
50 | - return $this->urlGenerator->imagePath('core', 'actions/share.svg'); |
|
51 | - } |
|
42 | + /** |
|
43 | + * returns the relative path to an 16*16 icon describing the section. |
|
44 | + * e.g. '/core/img/places/files.svg' |
|
45 | + * |
|
46 | + * @returns string |
|
47 | + * @since 12 |
|
48 | + */ |
|
49 | + public function getIcon() { |
|
50 | + return $this->urlGenerator->imagePath('core', 'actions/share.svg'); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * returns the ID of the section. It is supposed to be a lower case string, |
|
55 | - * e.g. 'ldap' |
|
56 | - * |
|
57 | - * @returns string |
|
58 | - * @since 9.1 |
|
59 | - */ |
|
60 | - public function getID() { |
|
61 | - return 'sharing'; |
|
62 | - } |
|
53 | + /** |
|
54 | + * returns the ID of the section. It is supposed to be a lower case string, |
|
55 | + * e.g. 'ldap' |
|
56 | + * |
|
57 | + * @returns string |
|
58 | + * @since 9.1 |
|
59 | + */ |
|
60 | + public function getID() { |
|
61 | + return 'sharing'; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
66 | - * integration'. Use the L10N service to translate it. |
|
67 | - * |
|
68 | - * @return string |
|
69 | - * @since 9.1 |
|
70 | - */ |
|
71 | - public function getName() { |
|
72 | - return $this->l->t('Sharing'); |
|
73 | - } |
|
64 | + /** |
|
65 | + * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
66 | + * integration'. Use the L10N service to translate it. |
|
67 | + * |
|
68 | + * @return string |
|
69 | + * @since 9.1 |
|
70 | + */ |
|
71 | + public function getName() { |
|
72 | + return $this->l->t('Sharing'); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @return int whether the form should be rather on the top or bottom of |
|
77 | - * the settings navigation. The sections are arranged in ascending order of |
|
78 | - * the priority values. It is required to return a value between 0 and 99. |
|
79 | - * |
|
80 | - * E.g.: 70 |
|
81 | - * @since 9.1 |
|
82 | - */ |
|
83 | - public function getPriority() { |
|
84 | - return 15; |
|
85 | - } |
|
75 | + /** |
|
76 | + * @return int whether the form should be rather on the top or bottom of |
|
77 | + * the settings navigation. The sections are arranged in ascending order of |
|
78 | + * the priority values. It is required to return a value between 0 and 99. |
|
79 | + * |
|
80 | + * E.g.: 70 |
|
81 | + * @since 9.1 |
|
82 | + */ |
|
83 | + public function getPriority() { |
|
84 | + return 15; |
|
85 | + } |
|
86 | 86 | } |
@@ -33,69 +33,69 @@ |
||
33 | 33 | |
34 | 34 | class Personal implements ISettings { |
35 | 35 | |
36 | - /** @var FederatedShareProvider */ |
|
37 | - private $federatedShareProvider; |
|
38 | - /** @var IUserSession */ |
|
39 | - private $userSession; |
|
40 | - /** @var IL10N */ |
|
41 | - private $l; |
|
42 | - /** @var IURLGenerator */ |
|
43 | - private $urlGenerator; |
|
44 | - /** @var \OC_Defaults */ |
|
45 | - private $defaults; |
|
36 | + /** @var FederatedShareProvider */ |
|
37 | + private $federatedShareProvider; |
|
38 | + /** @var IUserSession */ |
|
39 | + private $userSession; |
|
40 | + /** @var IL10N */ |
|
41 | + private $l; |
|
42 | + /** @var IURLGenerator */ |
|
43 | + private $urlGenerator; |
|
44 | + /** @var \OC_Defaults */ |
|
45 | + private $defaults; |
|
46 | 46 | |
47 | - public function __construct( |
|
48 | - FederatedShareProvider $federatedShareProvider, # |
|
49 | - IUserSession $userSession, |
|
50 | - IL10N $l, |
|
51 | - IURLGenerator $urlGenerator, |
|
52 | - \OC_Defaults $defaults |
|
53 | - ) { |
|
54 | - $this->federatedShareProvider = $federatedShareProvider; |
|
55 | - $this->userSession = $userSession; |
|
56 | - $this->l = $l; |
|
57 | - $this->urlGenerator = $urlGenerator; |
|
58 | - $this->defaults = $defaults; |
|
59 | - } |
|
47 | + public function __construct( |
|
48 | + FederatedShareProvider $federatedShareProvider, # |
|
49 | + IUserSession $userSession, |
|
50 | + IL10N $l, |
|
51 | + IURLGenerator $urlGenerator, |
|
52 | + \OC_Defaults $defaults |
|
53 | + ) { |
|
54 | + $this->federatedShareProvider = $federatedShareProvider; |
|
55 | + $this->userSession = $userSession; |
|
56 | + $this->l = $l; |
|
57 | + $this->urlGenerator = $urlGenerator; |
|
58 | + $this->defaults = $defaults; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
63 | - * @since 9.1 |
|
64 | - */ |
|
65 | - public function getForm() { |
|
66 | - $cloudID = $this->userSession->getUser()->getCloudId(); |
|
67 | - $url = 'https://nextcloud.com/federation#' . $cloudID; |
|
61 | + /** |
|
62 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
63 | + * @since 9.1 |
|
64 | + */ |
|
65 | + public function getForm() { |
|
66 | + $cloudID = $this->userSession->getUser()->getCloudId(); |
|
67 | + $url = 'https://nextcloud.com/federation#' . $cloudID; |
|
68 | 68 | |
69 | - $parameters = [ |
|
70 | - 'outgoingServer2serverShareEnabled' => $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(), |
|
71 | - 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]), |
|
72 | - 'message_without_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]), |
|
73 | - 'logoPath' => $this->urlGenerator->imagePath('core', 'logo-icon.svg'), |
|
74 | - 'reference' => $url, |
|
75 | - 'cloudId' => $cloudID, |
|
76 | - 'color' => $this->defaults->getColorPrimary(), |
|
77 | - 'textColor' => "#ffffff", |
|
78 | - ]; |
|
79 | - return new TemplateResponse('federatedfilesharing', 'settings-personal', $parameters, ''); |
|
80 | - } |
|
69 | + $parameters = [ |
|
70 | + 'outgoingServer2serverShareEnabled' => $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(), |
|
71 | + 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]), |
|
72 | + 'message_without_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]), |
|
73 | + 'logoPath' => $this->urlGenerator->imagePath('core', 'logo-icon.svg'), |
|
74 | + 'reference' => $url, |
|
75 | + 'cloudId' => $cloudID, |
|
76 | + 'color' => $this->defaults->getColorPrimary(), |
|
77 | + 'textColor' => "#ffffff", |
|
78 | + ]; |
|
79 | + return new TemplateResponse('federatedfilesharing', 'settings-personal', $parameters, ''); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return string the section ID, e.g. 'sharing' |
|
84 | - * @since 9.1 |
|
85 | - */ |
|
86 | - public function getSection() { |
|
87 | - return 'sharing'; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return string the section ID, e.g. 'sharing' |
|
84 | + * @since 9.1 |
|
85 | + */ |
|
86 | + public function getSection() { |
|
87 | + return 'sharing'; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return int whether the form should be rather on the top or bottom of |
|
92 | - * the admin section. The forms are arranged in ascending order of the |
|
93 | - * priority values. It is required to return a value between 0 and 100. |
|
94 | - * |
|
95 | - * E.g.: 70 |
|
96 | - * @since 9.1 |
|
97 | - */ |
|
98 | - public function getPriority() { |
|
99 | - return 40; |
|
100 | - } |
|
90 | + /** |
|
91 | + * @return int whether the form should be rather on the top or bottom of |
|
92 | + * the admin section. The forms are arranged in ascending order of the |
|
93 | + * priority values. It is required to return a value between 0 and 100. |
|
94 | + * |
|
95 | + * E.g.: 70 |
|
96 | + * @since 9.1 |
|
97 | + */ |
|
98 | + public function getPriority() { |
|
99 | + return 40; |
|
100 | + } |
|
101 | 101 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | */ |
65 | 65 | public function getForm() { |
66 | 66 | $cloudID = $this->userSession->getUser()->getCloudId(); |
67 | - $url = 'https://nextcloud.com/federation#' . $cloudID; |
|
67 | + $url = 'https://nextcloud.com/federation#'.$cloudID; |
|
68 | 68 | |
69 | 69 | $parameters = [ |
70 | 70 | 'outgoingServer2serverShareEnabled' => $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(), |
@@ -34,86 +34,86 @@ |
||
34 | 34 | |
35 | 35 | class Application extends App { |
36 | 36 | |
37 | - /** @var FederatedShareProvider */ |
|
38 | - protected $federatedShareProvider; |
|
37 | + /** @var FederatedShareProvider */ |
|
38 | + protected $federatedShareProvider; |
|
39 | 39 | |
40 | - public function __construct() { |
|
41 | - parent::__construct('federatedfilesharing'); |
|
40 | + public function __construct() { |
|
41 | + parent::__construct('federatedfilesharing'); |
|
42 | 42 | |
43 | - $container = $this->getContainer(); |
|
44 | - $server = $container->getServer(); |
|
43 | + $container = $this->getContainer(); |
|
44 | + $server = $container->getServer(); |
|
45 | 45 | |
46 | - $container->registerService('RequestHandlerController', function(SimpleContainer $c) use ($server) { |
|
47 | - $addressHandler = new AddressHandler( |
|
48 | - $server->getURLGenerator(), |
|
49 | - $server->getL10N('federatedfilesharing'), |
|
50 | - $server->getCloudIdManager() |
|
51 | - ); |
|
52 | - $notification = new Notifications( |
|
53 | - $addressHandler, |
|
54 | - $server->getHTTPClientService(), |
|
55 | - $server->query(\OCP\OCS\IDiscoveryService::class), |
|
56 | - \OC::$server->getJobList() |
|
57 | - ); |
|
58 | - return new RequestHandlerController( |
|
59 | - $c->query('AppName'), |
|
60 | - $server->getRequest(), |
|
61 | - $this->getFederatedShareProvider(), |
|
62 | - $server->getDatabaseConnection(), |
|
63 | - $server->getShareManager(), |
|
64 | - $notification, |
|
65 | - $addressHandler, |
|
66 | - $server->getUserManager(), |
|
67 | - $server->getCloudIdManager() |
|
68 | - ); |
|
69 | - }); |
|
70 | - } |
|
46 | + $container->registerService('RequestHandlerController', function(SimpleContainer $c) use ($server) { |
|
47 | + $addressHandler = new AddressHandler( |
|
48 | + $server->getURLGenerator(), |
|
49 | + $server->getL10N('federatedfilesharing'), |
|
50 | + $server->getCloudIdManager() |
|
51 | + ); |
|
52 | + $notification = new Notifications( |
|
53 | + $addressHandler, |
|
54 | + $server->getHTTPClientService(), |
|
55 | + $server->query(\OCP\OCS\IDiscoveryService::class), |
|
56 | + \OC::$server->getJobList() |
|
57 | + ); |
|
58 | + return new RequestHandlerController( |
|
59 | + $c->query('AppName'), |
|
60 | + $server->getRequest(), |
|
61 | + $this->getFederatedShareProvider(), |
|
62 | + $server->getDatabaseConnection(), |
|
63 | + $server->getShareManager(), |
|
64 | + $notification, |
|
65 | + $addressHandler, |
|
66 | + $server->getUserManager(), |
|
67 | + $server->getCloudIdManager() |
|
68 | + ); |
|
69 | + }); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * get instance of federated share provider |
|
74 | - * |
|
75 | - * @return FederatedShareProvider |
|
76 | - */ |
|
77 | - public function getFederatedShareProvider() { |
|
78 | - if ($this->federatedShareProvider === null) { |
|
79 | - $this->initFederatedShareProvider(); |
|
80 | - } |
|
81 | - return $this->federatedShareProvider; |
|
82 | - } |
|
72 | + /** |
|
73 | + * get instance of federated share provider |
|
74 | + * |
|
75 | + * @return FederatedShareProvider |
|
76 | + */ |
|
77 | + public function getFederatedShareProvider() { |
|
78 | + if ($this->federatedShareProvider === null) { |
|
79 | + $this->initFederatedShareProvider(); |
|
80 | + } |
|
81 | + return $this->federatedShareProvider; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * initialize federated share provider |
|
86 | - */ |
|
87 | - protected function initFederatedShareProvider() { |
|
88 | - $c = $this->getContainer(); |
|
89 | - $addressHandler = new \OCA\FederatedFileSharing\AddressHandler( |
|
90 | - \OC::$server->getURLGenerator(), |
|
91 | - \OC::$server->getL10N('federatedfilesharing'), |
|
92 | - \OC::$server->getCloudIdManager() |
|
93 | - ); |
|
94 | - $notifications = new \OCA\FederatedFileSharing\Notifications( |
|
95 | - $addressHandler, |
|
96 | - \OC::$server->getHTTPClientService(), |
|
97 | - \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
98 | - \OC::$server->getJobList() |
|
99 | - ); |
|
100 | - $tokenHandler = new \OCA\FederatedFileSharing\TokenHandler( |
|
101 | - \OC::$server->getSecureRandom() |
|
102 | - ); |
|
84 | + /** |
|
85 | + * initialize federated share provider |
|
86 | + */ |
|
87 | + protected function initFederatedShareProvider() { |
|
88 | + $c = $this->getContainer(); |
|
89 | + $addressHandler = new \OCA\FederatedFileSharing\AddressHandler( |
|
90 | + \OC::$server->getURLGenerator(), |
|
91 | + \OC::$server->getL10N('federatedfilesharing'), |
|
92 | + \OC::$server->getCloudIdManager() |
|
93 | + ); |
|
94 | + $notifications = new \OCA\FederatedFileSharing\Notifications( |
|
95 | + $addressHandler, |
|
96 | + \OC::$server->getHTTPClientService(), |
|
97 | + \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
98 | + \OC::$server->getJobList() |
|
99 | + ); |
|
100 | + $tokenHandler = new \OCA\FederatedFileSharing\TokenHandler( |
|
101 | + \OC::$server->getSecureRandom() |
|
102 | + ); |
|
103 | 103 | |
104 | - $this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider( |
|
105 | - \OC::$server->getDatabaseConnection(), |
|
106 | - $addressHandler, |
|
107 | - $notifications, |
|
108 | - $tokenHandler, |
|
109 | - \OC::$server->getL10N('federatedfilesharing'), |
|
110 | - \OC::$server->getLogger(), |
|
111 | - \OC::$server->getLazyRootFolder(), |
|
112 | - \OC::$server->getConfig(), |
|
113 | - \OC::$server->getUserManager(), |
|
114 | - \OC::$server->getCloudIdManager(), |
|
115 | - $c->query(IConfig::class) |
|
116 | - ); |
|
117 | - } |
|
104 | + $this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider( |
|
105 | + \OC::$server->getDatabaseConnection(), |
|
106 | + $addressHandler, |
|
107 | + $notifications, |
|
108 | + $tokenHandler, |
|
109 | + \OC::$server->getL10N('federatedfilesharing'), |
|
110 | + \OC::$server->getLogger(), |
|
111 | + \OC::$server->getLazyRootFolder(), |
|
112 | + \OC::$server->getConfig(), |
|
113 | + \OC::$server->getUserManager(), |
|
114 | + \OC::$server->getCloudIdManager(), |
|
115 | + $c->query(IConfig::class) |
|
116 | + ); |
|
117 | + } |
|
118 | 118 | |
119 | 119 | } |
@@ -77,7 +77,7 @@ |
||
77 | 77 | * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
78 | 78 | * integration'. Use the L10N service to translate it. |
79 | 79 | * |
80 | - * @return string |
|
80 | + * @return \OC_L10N_String |
|
81 | 81 | * @since 9.1 |
82 | 82 | */ |
83 | 83 | public function getName() { |
@@ -32,67 +32,67 @@ |
||
32 | 32 | |
33 | 33 | class PersonalSection implements IIconSection { |
34 | 34 | |
35 | - /** @var IURLGenerator */ |
|
36 | - private $urlGenerator; |
|
37 | - /** @var IL10N */ |
|
38 | - private $l; |
|
39 | - /** @var BackupCodesProvider */ |
|
40 | - private $provider; |
|
41 | - /** @var IUserSession */ |
|
42 | - private $userSession; |
|
35 | + /** @var IURLGenerator */ |
|
36 | + private $urlGenerator; |
|
37 | + /** @var IL10N */ |
|
38 | + private $l; |
|
39 | + /** @var BackupCodesProvider */ |
|
40 | + private $provider; |
|
41 | + /** @var IUserSession */ |
|
42 | + private $userSession; |
|
43 | 43 | |
44 | - public function __construct(IURLGenerator $urlGenerator, IL10N $l, BackupCodesProvider $provider, IUserSession $userSession) { |
|
45 | - $this->urlGenerator = $urlGenerator; |
|
46 | - $this->l = $l; |
|
47 | - $this->provider = $provider; |
|
48 | - $this->userSession = $userSession; |
|
49 | - } |
|
44 | + public function __construct(IURLGenerator $urlGenerator, IL10N $l, BackupCodesProvider $provider, IUserSession $userSession) { |
|
45 | + $this->urlGenerator = $urlGenerator; |
|
46 | + $this->l = $l; |
|
47 | + $this->provider = $provider; |
|
48 | + $this->userSession = $userSession; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * returns the relative path to an 16*16 icon describing the section. |
|
53 | - * e.g. '/core/img/places/files.svg' |
|
54 | - * |
|
55 | - * @returns string |
|
56 | - * @since 12 |
|
57 | - */ |
|
58 | - public function getIcon() { |
|
59 | - return $this->urlGenerator->imagePath('settings', 'password.svg'); |
|
60 | - } |
|
51 | + /** |
|
52 | + * returns the relative path to an 16*16 icon describing the section. |
|
53 | + * e.g. '/core/img/places/files.svg' |
|
54 | + * |
|
55 | + * @returns string |
|
56 | + * @since 12 |
|
57 | + */ |
|
58 | + public function getIcon() { |
|
59 | + return $this->urlGenerator->imagePath('settings', 'password.svg'); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * returns the ID of the section. It is supposed to be a lower case string, |
|
64 | - * e.g. 'ldap' |
|
65 | - * |
|
66 | - * @returns string |
|
67 | - * @since 9.1 |
|
68 | - */ |
|
69 | - public function getID() { |
|
70 | - if (!$this->provider->isActive($this->userSession->getUser())) { |
|
71 | - return null; |
|
72 | - } |
|
73 | - return 'twofactor'; |
|
74 | - } |
|
62 | + /** |
|
63 | + * returns the ID of the section. It is supposed to be a lower case string, |
|
64 | + * e.g. 'ldap' |
|
65 | + * |
|
66 | + * @returns string |
|
67 | + * @since 9.1 |
|
68 | + */ |
|
69 | + public function getID() { |
|
70 | + if (!$this->provider->isActive($this->userSession->getUser())) { |
|
71 | + return null; |
|
72 | + } |
|
73 | + return 'twofactor'; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
78 | - * integration'. Use the L10N service to translate it. |
|
79 | - * |
|
80 | - * @return string |
|
81 | - * @since 9.1 |
|
82 | - */ |
|
83 | - public function getName() { |
|
84 | - return $this->l->t('Second factor auth'); |
|
85 | - } |
|
76 | + /** |
|
77 | + * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
78 | + * integration'. Use the L10N service to translate it. |
|
79 | + * |
|
80 | + * @return string |
|
81 | + * @since 9.1 |
|
82 | + */ |
|
83 | + public function getName() { |
|
84 | + return $this->l->t('Second factor auth'); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @return int whether the form should be rather on the top or bottom of |
|
89 | - * the settings navigation. The sections are arranged in ascending order of |
|
90 | - * the priority values. It is required to return a value between 0 and 99. |
|
91 | - * |
|
92 | - * E.g.: 70 |
|
93 | - * @since 9.1 |
|
94 | - */ |
|
95 | - public function getPriority() { |
|
96 | - return 8; |
|
97 | - } |
|
87 | + /** |
|
88 | + * @return int whether the form should be rather on the top or bottom of |
|
89 | + * the settings navigation. The sections are arranged in ascending order of |
|
90 | + * the priority values. It is required to return a value between 0 and 99. |
|
91 | + * |
|
92 | + * E.g.: 70 |
|
93 | + * @since 9.1 |
|
94 | + */ |
|
95 | + public function getPriority() { |
|
96 | + return 8; |
|
97 | + } |
|
98 | 98 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | * |
22 | 22 | */ |
23 | 23 | |
24 | - # used for Personal/Additional settings as fallback for legacy settings |
|
24 | + # used for Personal/Additional settings as fallback for legacy settings |
|
25 | 25 | ?> |
@@ -32,51 +32,51 @@ |
||
32 | 32 | |
33 | 33 | class Personal implements ISettings { |
34 | 34 | |
35 | - /** @var Application */ |
|
36 | - private $app; |
|
37 | - /** @var BackupCodesProvider */ |
|
38 | - private $provider; |
|
39 | - /** @var IUserSession */ |
|
40 | - private $userSession; |
|
35 | + /** @var Application */ |
|
36 | + private $app; |
|
37 | + /** @var BackupCodesProvider */ |
|
38 | + private $provider; |
|
39 | + /** @var IUserSession */ |
|
40 | + private $userSession; |
|
41 | 41 | |
42 | - public function __construct(Application $app, BackupCodesProvider $provider, IUserSession $userSession) { |
|
43 | - $this->app = $app; |
|
44 | - $this->provider = $provider; |
|
45 | - $this->userSession = $userSession; |
|
46 | - } |
|
42 | + public function __construct(Application $app, BackupCodesProvider $provider, IUserSession $userSession) { |
|
43 | + $this->app = $app; |
|
44 | + $this->provider = $provider; |
|
45 | + $this->userSession = $userSession; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
50 | - * @since 9.1 |
|
51 | - */ |
|
52 | - public function getForm() { |
|
53 | - $templateOwner = 'settings'; |
|
54 | - $templateName = 'settings/empty'; |
|
55 | - if ($this->provider->isActive($this->userSession->getUser())) { |
|
56 | - $templateOwner = $this->app->getContainer()->getAppName(); |
|
57 | - $templateName = 'personal'; |
|
58 | - } |
|
48 | + /** |
|
49 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
50 | + * @since 9.1 |
|
51 | + */ |
|
52 | + public function getForm() { |
|
53 | + $templateOwner = 'settings'; |
|
54 | + $templateName = 'settings/empty'; |
|
55 | + if ($this->provider->isActive($this->userSession->getUser())) { |
|
56 | + $templateOwner = $this->app->getContainer()->getAppName(); |
|
57 | + $templateName = 'personal'; |
|
58 | + } |
|
59 | 59 | |
60 | - return new TemplateResponse($templateOwner, $templateName, [], ''); |
|
61 | - } |
|
60 | + return new TemplateResponse($templateOwner, $templateName, [], ''); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return string the section ID, e.g. 'sharing' |
|
65 | - * @since 9.1 |
|
66 | - */ |
|
67 | - public function getSection() { |
|
68 | - return 'twofactor'; |
|
69 | - } |
|
63 | + /** |
|
64 | + * @return string the section ID, e.g. 'sharing' |
|
65 | + * @since 9.1 |
|
66 | + */ |
|
67 | + public function getSection() { |
|
68 | + return 'twofactor'; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return int whether the form should be rather on the top or bottom of |
|
73 | - * the admin section. The forms are arranged in ascending order of the |
|
74 | - * priority values. It is required to return a value between 0 and 100. |
|
75 | - * |
|
76 | - * E.g.: 70 |
|
77 | - * @since 9.1 |
|
78 | - */ |
|
79 | - public function getPriority() { |
|
80 | - return 85; |
|
81 | - } |
|
71 | + /** |
|
72 | + * @return int whether the form should be rather on the top or bottom of |
|
73 | + * the admin section. The forms are arranged in ascending order of the |
|
74 | + * priority values. It is required to return a value between 0 and 100. |
|
75 | + * |
|
76 | + * E.g.: 70 |
|
77 | + * @since 9.1 |
|
78 | + */ |
|
79 | + public function getPriority() { |
|
80 | + return 85; |
|
81 | + } |
|
82 | 82 | } |
@@ -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 | } |
@@ -51,6 +51,9 @@ discard block |
||
51 | 51 | ]; |
52 | 52 | } |
53 | 53 | |
54 | + /** |
|
55 | + * @param string $type |
|
56 | + */ |
|
54 | 57 | protected function formatSections($sections, $currentSection, $type, $currentType) { |
55 | 58 | $templateParameters = []; |
56 | 59 | /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
@@ -84,6 +87,9 @@ discard block |
||
84 | 87 | return $templateParameters; |
85 | 88 | } |
86 | 89 | |
90 | + /** |
|
91 | + * @param string $currentSections |
|
92 | + */ |
|
87 | 93 | protected function formatPersonalSections($currentType, $currentSections) { |
88 | 94 | $sections = $this->settingsManager->getPersonalSections(); |
89 | 95 | $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); |
@@ -91,6 +97,9 @@ discard block |
||
91 | 97 | return $templateParameters; |
92 | 98 | } |
93 | 99 | |
100 | + /** |
|
101 | + * @param string $currentSections |
|
102 | + */ |
|
94 | 103 | protected function formatAdminSections($currentType, $currentSections) { |
95 | 104 | $sections = $this->settingsManager->getAdminSections(); |
96 | 105 | $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); |
@@ -114,6 +123,10 @@ discard block |
||
114 | 123 | return ['content' => $html]; |
115 | 124 | } |
116 | 125 | |
126 | + /** |
|
127 | + * @param string $type |
|
128 | + * @param string $section |
|
129 | + */ |
|
117 | 130 | private function getIndexResponse($type, $section) { |
118 | 131 | $templateParams = []; |
119 | 132 | $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); |
@@ -29,98 +29,98 @@ |
||
29 | 29 | use OCP\Settings\ISettings; |
30 | 30 | |
31 | 31 | trait CommonSettingsTrait { |
32 | - /** @var ISettingsManager */ |
|
33 | - private $settingsManager; |
|
34 | - |
|
35 | - /** |
|
36 | - * @param string $currentSection |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - private function getNavigationParameters($currentType, $currentSection) { |
|
40 | - $templateParameters = [ |
|
41 | - 'personal' => $this->formatPersonalSections($currentType, $currentSection), |
|
42 | - 'admin' => [] |
|
43 | - ]; |
|
44 | - |
|
45 | - if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | - $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
|
47 | - } |
|
48 | - |
|
49 | - return [ |
|
50 | - 'forms' => $templateParameters |
|
51 | - ]; |
|
52 | - } |
|
53 | - |
|
54 | - protected function formatSections($sections, $currentSection, $type, $currentType) { |
|
55 | - $templateParameters = []; |
|
56 | - /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
|
57 | - foreach($sections as $prioritizedSections) { |
|
58 | - foreach ($prioritizedSections as $section) { |
|
59 | - if($type === 'admin') { |
|
60 | - $settings = $this->settingsManager->getAdminSettings($section->getID()); |
|
61 | - } else if($type === 'personal') { |
|
62 | - $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
|
63 | - } |
|
64 | - if (empty($settings)) { |
|
65 | - continue; |
|
66 | - } |
|
67 | - |
|
68 | - $icon = ''; |
|
69 | - if ($section instanceof IIconSection) { |
|
70 | - $icon = $section->getIcon(); |
|
71 | - } |
|
72 | - |
|
73 | - $active = $section->getID() === $currentSection |
|
74 | - && $type === $currentType; |
|
75 | - |
|
76 | - $templateParameters[] = [ |
|
77 | - 'anchor' => $section->getID(), |
|
78 | - 'section-name' => $section->getName(), |
|
79 | - 'active' => $active, |
|
80 | - 'icon' => $icon, |
|
81 | - ]; |
|
82 | - } |
|
83 | - } |
|
84 | - return $templateParameters; |
|
85 | - } |
|
86 | - |
|
87 | - protected function formatPersonalSections($currentType, $currentSections) { |
|
88 | - $sections = $this->settingsManager->getPersonalSections(); |
|
89 | - $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); |
|
90 | - |
|
91 | - return $templateParameters; |
|
92 | - } |
|
93 | - |
|
94 | - protected function formatAdminSections($currentType, $currentSections) { |
|
95 | - $sections = $this->settingsManager->getAdminSections(); |
|
96 | - $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); |
|
97 | - |
|
98 | - return $templateParameters; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @param ISettings[] $settings |
|
103 | - * @return array |
|
104 | - */ |
|
105 | - private function formatSettings($settings) { |
|
106 | - $html = ''; |
|
107 | - foreach ($settings as $prioritizedSettings) { |
|
108 | - foreach ($prioritizedSettings as $setting) { |
|
109 | - /** @var \OCP\Settings\ISettings $setting */ |
|
110 | - $form = $setting->getForm(); |
|
111 | - $html .= $form->renderAs('')->render(); |
|
112 | - } |
|
113 | - } |
|
114 | - return ['content' => $html]; |
|
115 | - } |
|
116 | - |
|
117 | - private function getIndexResponse($type, $section) { |
|
118 | - $templateParams = []; |
|
119 | - $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); |
|
120 | - $templateParams = array_merge($templateParams, $this->getSettings($section)); |
|
121 | - |
|
122 | - return new TemplateResponse('settings', 'settings/frame', $templateParams); |
|
123 | - } |
|
124 | - |
|
125 | - abstract protected function getSettings($section); |
|
32 | + /** @var ISettingsManager */ |
|
33 | + private $settingsManager; |
|
34 | + |
|
35 | + /** |
|
36 | + * @param string $currentSection |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + private function getNavigationParameters($currentType, $currentSection) { |
|
40 | + $templateParameters = [ |
|
41 | + 'personal' => $this->formatPersonalSections($currentType, $currentSection), |
|
42 | + 'admin' => [] |
|
43 | + ]; |
|
44 | + |
|
45 | + if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | + $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
|
47 | + } |
|
48 | + |
|
49 | + return [ |
|
50 | + 'forms' => $templateParameters |
|
51 | + ]; |
|
52 | + } |
|
53 | + |
|
54 | + protected function formatSections($sections, $currentSection, $type, $currentType) { |
|
55 | + $templateParameters = []; |
|
56 | + /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
|
57 | + foreach($sections as $prioritizedSections) { |
|
58 | + foreach ($prioritizedSections as $section) { |
|
59 | + if($type === 'admin') { |
|
60 | + $settings = $this->settingsManager->getAdminSettings($section->getID()); |
|
61 | + } else if($type === 'personal') { |
|
62 | + $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
|
63 | + } |
|
64 | + if (empty($settings)) { |
|
65 | + continue; |
|
66 | + } |
|
67 | + |
|
68 | + $icon = ''; |
|
69 | + if ($section instanceof IIconSection) { |
|
70 | + $icon = $section->getIcon(); |
|
71 | + } |
|
72 | + |
|
73 | + $active = $section->getID() === $currentSection |
|
74 | + && $type === $currentType; |
|
75 | + |
|
76 | + $templateParameters[] = [ |
|
77 | + 'anchor' => $section->getID(), |
|
78 | + 'section-name' => $section->getName(), |
|
79 | + 'active' => $active, |
|
80 | + 'icon' => $icon, |
|
81 | + ]; |
|
82 | + } |
|
83 | + } |
|
84 | + return $templateParameters; |
|
85 | + } |
|
86 | + |
|
87 | + protected function formatPersonalSections($currentType, $currentSections) { |
|
88 | + $sections = $this->settingsManager->getPersonalSections(); |
|
89 | + $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); |
|
90 | + |
|
91 | + return $templateParameters; |
|
92 | + } |
|
93 | + |
|
94 | + protected function formatAdminSections($currentType, $currentSections) { |
|
95 | + $sections = $this->settingsManager->getAdminSections(); |
|
96 | + $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); |
|
97 | + |
|
98 | + return $templateParameters; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @param ISettings[] $settings |
|
103 | + * @return array |
|
104 | + */ |
|
105 | + private function formatSettings($settings) { |
|
106 | + $html = ''; |
|
107 | + foreach ($settings as $prioritizedSettings) { |
|
108 | + foreach ($prioritizedSettings as $setting) { |
|
109 | + /** @var \OCP\Settings\ISettings $setting */ |
|
110 | + $form = $setting->getForm(); |
|
111 | + $html .= $form->renderAs('')->render(); |
|
112 | + } |
|
113 | + } |
|
114 | + return ['content' => $html]; |
|
115 | + } |
|
116 | + |
|
117 | + private function getIndexResponse($type, $section) { |
|
118 | + $templateParams = []; |
|
119 | + $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); |
|
120 | + $templateParams = array_merge($templateParams, $this->getSettings($section)); |
|
121 | + |
|
122 | + return new TemplateResponse('settings', 'settings/frame', $templateParams); |
|
123 | + } |
|
124 | + |
|
125 | + abstract protected function getSettings($section); |
|
126 | 126 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | use OCP\Settings\IIconSection; |
29 | 29 | use OCP\Settings\ISettings; |
30 | 30 | |
31 | -trait CommonSettingsTrait { |
|
31 | +trait CommonSettingsTrait { |
|
32 | 32 | /** @var ISettingsManager */ |
33 | 33 | private $settingsManager; |
34 | 34 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'admin' => [] |
43 | 43 | ]; |
44 | 44 | |
45 | - if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
45 | + if (\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | 46 | $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
47 | 47 | } |
48 | 48 | |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | protected function formatSections($sections, $currentSection, $type, $currentType) { |
55 | 55 | $templateParameters = []; |
56 | 56 | /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
57 | - foreach($sections as $prioritizedSections) { |
|
57 | + foreach ($sections as $prioritizedSections) { |
|
58 | 58 | foreach ($prioritizedSections as $section) { |
59 | - if($type === 'admin') { |
|
59 | + if ($type === 'admin') { |
|
60 | 60 | $settings = $this->settingsManager->getAdminSettings($section->getID()); |
61 | - } else if($type === 'personal') { |
|
61 | + } else if ($type === 'personal') { |
|
62 | 62 | $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
63 | 63 | } |
64 | 64 | if (empty($settings)) { |
@@ -33,63 +33,63 @@ |
||
33 | 33 | |
34 | 34 | class Personal implements ISettings { |
35 | 35 | |
36 | - /** @var IConfig */ |
|
37 | - private $config; |
|
38 | - /** @var Session */ |
|
39 | - private $session; |
|
40 | - /** @var Util */ |
|
41 | - private $util; |
|
42 | - /** @var IUserSession */ |
|
43 | - private $userSession; |
|
36 | + /** @var IConfig */ |
|
37 | + private $config; |
|
38 | + /** @var Session */ |
|
39 | + private $session; |
|
40 | + /** @var Util */ |
|
41 | + private $util; |
|
42 | + /** @var IUserSession */ |
|
43 | + private $userSession; |
|
44 | 44 | |
45 | - public function __construct(IConfig $config, Session $session, Util $util, IUserSession $userSession) { |
|
46 | - $this->config = $config; |
|
47 | - $this->session = $session; |
|
48 | - $this->util = $util; |
|
49 | - $this->userSession = $userSession; |
|
50 | - } |
|
45 | + public function __construct(IConfig $config, Session $session, Util $util, IUserSession $userSession) { |
|
46 | + $this->config = $config; |
|
47 | + $this->session = $session; |
|
48 | + $this->util = $util; |
|
49 | + $this->userSession = $userSession; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
54 | - * @since 9.1 |
|
55 | - */ |
|
56 | - public function getForm() { |
|
57 | - $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled'); |
|
58 | - $privateKeySet = $this->session->isPrivateKeySet(); |
|
52 | + /** |
|
53 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
54 | + * @since 9.1 |
|
55 | + */ |
|
56 | + public function getForm() { |
|
57 | + $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled'); |
|
58 | + $privateKeySet = $this->session->isPrivateKeySet(); |
|
59 | 59 | |
60 | - if (!$recoveryAdminEnabled && $privateKeySet) { |
|
61 | - return new TemplateResponse('settings', 'settings/empty', [], ''); |
|
62 | - } |
|
60 | + if (!$recoveryAdminEnabled && $privateKeySet) { |
|
61 | + return new TemplateResponse('settings', 'settings/empty', [], ''); |
|
62 | + } |
|
63 | 63 | |
64 | - $userId = $this->userSession->getUser()->getUID(); |
|
65 | - $recoveryEnabledForUser = $this->util->isRecoveryEnabledForUser($userId); |
|
64 | + $userId = $this->userSession->getUser()->getUID(); |
|
65 | + $recoveryEnabledForUser = $this->util->isRecoveryEnabledForUser($userId); |
|
66 | 66 | |
67 | - $parameters = [ |
|
68 | - 'recoveryEnabled' => $recoveryAdminEnabled, |
|
69 | - 'recoveryEnabledForUser' => $recoveryEnabledForUser, |
|
70 | - 'privateKeySet' => $privateKeySet, |
|
71 | - 'initialized' => $this->session->getStatus(), |
|
72 | - ]; |
|
73 | - return new TemplateResponse('encryption', 'settings-personal', $parameters, ''); |
|
74 | - } |
|
67 | + $parameters = [ |
|
68 | + 'recoveryEnabled' => $recoveryAdminEnabled, |
|
69 | + 'recoveryEnabledForUser' => $recoveryEnabledForUser, |
|
70 | + 'privateKeySet' => $privateKeySet, |
|
71 | + 'initialized' => $this->session->getStatus(), |
|
72 | + ]; |
|
73 | + return new TemplateResponse('encryption', 'settings-personal', $parameters, ''); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return string the section ID, e.g. 'sharing' |
|
78 | - * @since 9.1 |
|
79 | - */ |
|
80 | - public function getSection() { |
|
81 | - return 'encryption'; |
|
82 | - } |
|
76 | + /** |
|
77 | + * @return string the section ID, e.g. 'sharing' |
|
78 | + * @since 9.1 |
|
79 | + */ |
|
80 | + public function getSection() { |
|
81 | + return 'encryption'; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return int whether the form should be rather on the top or bottom of |
|
86 | - * the admin section. The forms are arranged in ascending order of the |
|
87 | - * priority values. It is required to return a value between 0 and 100. |
|
88 | - * |
|
89 | - * E.g.: 70 |
|
90 | - * @since 9.1 |
|
91 | - */ |
|
92 | - public function getPriority() { |
|
93 | - return 10; |
|
94 | - } |
|
84 | + /** |
|
85 | + * @return int whether the form should be rather on the top or bottom of |
|
86 | + * the admin section. The forms are arranged in ascending order of the |
|
87 | + * priority values. It is required to return a value between 0 and 100. |
|
88 | + * |
|
89 | + * E.g.: 70 |
|
90 | + * @since 9.1 |
|
91 | + */ |
|
92 | + public function getPriority() { |
|
93 | + return 10; |
|
94 | + } |
|
95 | 95 | } |