@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | <ul> |
| 33 | 33 | <li class="settings-caption">Personal</li> |
| 34 | 34 | <?php |
| 35 | - foreach($_['forms']['personal'] as $form) { |
|
| 36 | - if (isset($form['anchor'])) { |
|
| 37 | - $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => $form['anchor']]); |
|
| 38 | - $class = 'nav-icon-' . $form['anchor']; |
|
| 39 | - $sectionName = $form['section-name']; |
|
| 40 | - $active = $form['active'] ? ' class="active"' : ''; |
|
| 41 | - ?> |
|
| 35 | + foreach($_['forms']['personal'] as $form) { |
|
| 36 | + if (isset($form['anchor'])) { |
|
| 37 | + $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => $form['anchor']]); |
|
| 38 | + $class = 'nav-icon-' . $form['anchor']; |
|
| 39 | + $sectionName = $form['section-name']; |
|
| 40 | + $active = $form['active'] ? ' class="active"' : ''; |
|
| 41 | + ?> |
|
| 42 | 42 | <li <?php print_unescaped($form['active'] ? ' class="active"' : ''); ?>> |
| 43 | 43 | <a href="<?php p($anchor); ?>"> |
| 44 | 44 | <?php if (!empty($form['icon'])) { ?> |
@@ -50,24 +50,24 @@ discard block |
||
| 50 | 50 | </a> |
| 51 | 51 | </li> |
| 52 | 52 | <?php |
| 53 | - } |
|
| 54 | - } |
|
| 55 | - ?> |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + ?> |
|
| 56 | 56 | |
| 57 | 57 | <?php |
| 58 | - if(!empty($_['forms']['admin'])) { |
|
| 59 | - ?> |
|
| 58 | + if(!empty($_['forms']['admin'])) { |
|
| 59 | + ?> |
|
| 60 | 60 | <li class="settings-caption">Administration</li> |
| 61 | 61 | <?php |
| 62 | - } |
|
| 63 | - foreach($_['forms']['admin'] as $form) { |
|
| 64 | - if (isset($form['anchor'])) { |
|
| 62 | + } |
|
| 63 | + foreach($_['forms']['admin'] as $form) { |
|
| 64 | + if (isset($form['anchor'])) { |
|
| 65 | 65 | |
| 66 | - $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); |
|
| 67 | - $class = 'nav-icon-' . $form['anchor']; |
|
| 68 | - $sectionName = $form['section-name']; |
|
| 69 | - $active = $form['active'] ? ' class="active"' : ''; |
|
| 70 | - ?> |
|
| 66 | + $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); |
|
| 67 | + $class = 'nav-icon-' . $form['anchor']; |
|
| 68 | + $sectionName = $form['section-name']; |
|
| 69 | + $active = $form['active'] ? ' class="active"' : ''; |
|
| 70 | + ?> |
|
| 71 | 71 | <li <?php print_unescaped($form['active'] ? ' class="active"' : ''); ?>> |
| 72 | 72 | <a href="<?php p($anchor); ?>"> |
| 73 | 73 | <?php if (!empty($form['icon'])) { ?> |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | </a> |
| 80 | 80 | </li> |
| 81 | 81 | <?php |
| 82 | - } |
|
| 83 | - } |
|
| 84 | - ?> |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + ?> |
|
| 85 | 85 | </ul> |
| 86 | 86 | </div> |
| 87 | 87 | |
@@ -36,77 +36,77 @@ |
||
| 36 | 36 | |
| 37 | 37 | $application = new Application(); |
| 38 | 38 | $application->registerRoutes($this, [ |
| 39 | - 'resources' => [ |
|
| 40 | - 'users' => ['url' => '/settings/users/users'], |
|
| 41 | - 'AuthSettings' => ['url' => '/settings/personal/authtokens'], |
|
| 42 | - ], |
|
| 43 | - 'routes' => [ |
|
| 44 | - ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'], |
|
| 45 | - ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'], |
|
| 46 | - ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'], |
|
| 47 | - ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'], |
|
| 48 | - ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], |
|
| 49 | - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], |
|
| 50 | - ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], |
|
| 51 | - ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], |
|
| 52 | - ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], |
|
| 53 | - ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], |
|
| 54 | - ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], |
|
| 55 | - ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], |
|
| 56 | - ['name' => 'Users#setEnabled', 'url' => '/settings/users/{id}/setEnabled', 'verb' => 'POST'], |
|
| 57 | - ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], |
|
| 58 | - ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], |
|
| 59 | - ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], |
|
| 60 | - ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], |
|
| 61 | - ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'], |
|
| 62 | - ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'], |
|
| 63 | - ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'], |
|
| 64 | - ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'], |
|
| 65 | - ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
| 66 | - ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'], |
|
| 67 | - ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
| 68 | - ['name' => 'PersonalSettings#index', 'url' => '/settings/user/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']], |
|
| 69 | - ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']], |
|
| 70 | - ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'], |
|
| 71 | - ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'], |
|
| 72 | - ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'], |
|
| 73 | - ['name' => 'Personal#setLanguage', 'url' => '/settings/ajax/setlanguage.php', 'verb' => 'POST'], |
|
| 74 | - ['name' => 'Groups#index', 'url' => '/settings/users/groups', 'verb' => 'GET'], |
|
| 75 | - ['name' => 'Groups#show', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'GET'], |
|
| 76 | - ['name' => 'Groups#create', 'url' => '/settings/users/groups', 'verb' => 'POST'], |
|
| 77 | - ['name' => 'Groups#update', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'PUT'], |
|
| 78 | - ['name' => 'Groups#destroy', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'DELETE'], |
|
| 79 | - ] |
|
| 39 | + 'resources' => [ |
|
| 40 | + 'users' => ['url' => '/settings/users/users'], |
|
| 41 | + 'AuthSettings' => ['url' => '/settings/personal/authtokens'], |
|
| 42 | + ], |
|
| 43 | + 'routes' => [ |
|
| 44 | + ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'], |
|
| 45 | + ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'], |
|
| 46 | + ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'], |
|
| 47 | + ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'], |
|
| 48 | + ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], |
|
| 49 | + ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], |
|
| 50 | + ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], |
|
| 51 | + ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], |
|
| 52 | + ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], |
|
| 53 | + ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], |
|
| 54 | + ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], |
|
| 55 | + ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], |
|
| 56 | + ['name' => 'Users#setEnabled', 'url' => '/settings/users/{id}/setEnabled', 'verb' => 'POST'], |
|
| 57 | + ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], |
|
| 58 | + ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], |
|
| 59 | + ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], |
|
| 60 | + ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], |
|
| 61 | + ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'], |
|
| 62 | + ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'], |
|
| 63 | + ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'], |
|
| 64 | + ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'], |
|
| 65 | + ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
| 66 | + ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'], |
|
| 67 | + ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
| 68 | + ['name' => 'PersonalSettings#index', 'url' => '/settings/user/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']], |
|
| 69 | + ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']], |
|
| 70 | + ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'], |
|
| 71 | + ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'], |
|
| 72 | + ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'], |
|
| 73 | + ['name' => 'Personal#setLanguage', 'url' => '/settings/ajax/setlanguage.php', 'verb' => 'POST'], |
|
| 74 | + ['name' => 'Groups#index', 'url' => '/settings/users/groups', 'verb' => 'GET'], |
|
| 75 | + ['name' => 'Groups#show', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'GET'], |
|
| 76 | + ['name' => 'Groups#create', 'url' => '/settings/users/groups', 'verb' => 'POST'], |
|
| 77 | + ['name' => 'Groups#update', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'PUT'], |
|
| 78 | + ['name' => 'Groups#destroy', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'DELETE'], |
|
| 79 | + ] |
|
| 80 | 80 | ]); |
| 81 | 81 | |
| 82 | 82 | /** @var $this \OCP\Route\IRouter */ |
| 83 | 83 | |
| 84 | 84 | // Settings pages |
| 85 | 85 | $this->create('settings_help', '/settings/help') |
| 86 | - ->actionInclude('settings/help.php'); |
|
| 86 | + ->actionInclude('settings/help.php'); |
|
| 87 | 87 | $this->create('settings_users', '/settings/users') |
| 88 | - ->actionInclude('settings/users.php'); |
|
| 88 | + ->actionInclude('settings/users.php'); |
|
| 89 | 89 | // Settings ajax actions |
| 90 | 90 | // users |
| 91 | 91 | $this->create('settings_ajax_setquota', '/settings/ajax/setquota.php') |
| 92 | - ->actionInclude('settings/ajax/setquota.php'); |
|
| 92 | + ->actionInclude('settings/ajax/setquota.php'); |
|
| 93 | 93 | $this->create('settings_ajax_togglegroups', '/settings/ajax/togglegroups.php') |
| 94 | - ->actionInclude('settings/ajax/togglegroups.php'); |
|
| 94 | + ->actionInclude('settings/ajax/togglegroups.php'); |
|
| 95 | 95 | $this->create('settings_ajax_togglesubadmins', '/settings/ajax/togglesubadmins.php') |
| 96 | - ->actionInclude('settings/ajax/togglesubadmins.php'); |
|
| 96 | + ->actionInclude('settings/ajax/togglesubadmins.php'); |
|
| 97 | 97 | $this->create('settings_ajax_changegorupname', '/settings/ajax/changegroupname.php') |
| 98 | - ->actionInclude('settings/ajax/changegroupname.php'); |
|
| 98 | + ->actionInclude('settings/ajax/changegroupname.php'); |
|
| 99 | 99 | // apps |
| 100 | 100 | $this->create('settings_ajax_enableapp', '/settings/ajax/enableapp.php') |
| 101 | - ->actionInclude('settings/ajax/enableapp.php'); |
|
| 101 | + ->actionInclude('settings/ajax/enableapp.php'); |
|
| 102 | 102 | $this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php') |
| 103 | - ->actionInclude('settings/ajax/disableapp.php'); |
|
| 103 | + ->actionInclude('settings/ajax/disableapp.php'); |
|
| 104 | 104 | $this->create('settings_ajax_updateapp', '/settings/ajax/updateapp.php') |
| 105 | - ->actionInclude('settings/ajax/updateapp.php'); |
|
| 105 | + ->actionInclude('settings/ajax/updateapp.php'); |
|
| 106 | 106 | $this->create('settings_ajax_uninstallapp', '/settings/ajax/uninstallapp.php') |
| 107 | - ->actionInclude('settings/ajax/uninstallapp.php'); |
|
| 107 | + ->actionInclude('settings/ajax/uninstallapp.php'); |
|
| 108 | 108 | $this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php') |
| 109 | - ->actionInclude('settings/ajax/navigationdetect.php'); |
|
| 109 | + ->actionInclude('settings/ajax/navigationdetect.php'); |
|
| 110 | 110 | // admin |
| 111 | 111 | $this->create('settings_ajax_excludegroups', '/settings/ajax/excludegroups.php') |
| 112 | - ->actionInclude('settings/ajax/excludegroups.php'); |
|
| 112 | + ->actionInclude('settings/ajax/excludegroups.php'); |
|
@@ -30,56 +30,56 @@ |
||
| 30 | 30 | |
| 31 | 31 | class SyncClients implements ISettings { |
| 32 | 32 | |
| 33 | - /** @var IConfig */ |
|
| 34 | - private $config; |
|
| 35 | - /** @var \OC_Defaults */ |
|
| 36 | - private $defaults; |
|
| 33 | + /** @var IConfig */ |
|
| 34 | + private $config; |
|
| 35 | + /** @var \OC_Defaults */ |
|
| 36 | + private $defaults; |
|
| 37 | 37 | |
| 38 | - public function __construct(IConfig $config, \OC_Defaults $defaults) { |
|
| 39 | - $this->config = $config; |
|
| 40 | - $this->defaults = $defaults; |
|
| 41 | - } |
|
| 38 | + public function __construct(IConfig $config, \OC_Defaults $defaults) { |
|
| 39 | + $this->config = $config; |
|
| 40 | + $this->defaults = $defaults; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 45 | - * @since 9.1 |
|
| 46 | - */ |
|
| 47 | - public function getForm() { |
|
| 48 | - $parameters = [ 'clients' => $this->getClientLinks() ]; |
|
| 49 | - return new TemplateResponse('settings', 'settings/personal/sync-clients', $parameters); |
|
| 50 | - } |
|
| 43 | + /** |
|
| 44 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 45 | + * @since 9.1 |
|
| 46 | + */ |
|
| 47 | + public function getForm() { |
|
| 48 | + $parameters = [ 'clients' => $this->getClientLinks() ]; |
|
| 49 | + return new TemplateResponse('settings', 'settings/personal/sync-clients', $parameters); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return string the section ID, e.g. 'sharing' |
|
| 54 | - * @since 9.1 |
|
| 55 | - */ |
|
| 56 | - public function getSection() { |
|
| 57 | - return 'sync-clients'; |
|
| 58 | - } |
|
| 52 | + /** |
|
| 53 | + * @return string the section ID, e.g. 'sharing' |
|
| 54 | + * @since 9.1 |
|
| 55 | + */ |
|
| 56 | + public function getSection() { |
|
| 57 | + return 'sync-clients'; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @return int whether the form should be rather on the top or bottom of |
|
| 62 | - * the admin section. The forms are arranged in ascending order of the |
|
| 63 | - * priority values. It is required to return a value between 0 and 100. |
|
| 64 | - * |
|
| 65 | - * E.g.: 70 |
|
| 66 | - * @since 9.1 |
|
| 67 | - */ |
|
| 68 | - public function getPriority() { |
|
| 69 | - return 20; |
|
| 70 | - } |
|
| 60 | + /** |
|
| 61 | + * @return int whether the form should be rather on the top or bottom of |
|
| 62 | + * the admin section. The forms are arranged in ascending order of the |
|
| 63 | + * priority values. It is required to return a value between 0 and 100. |
|
| 64 | + * |
|
| 65 | + * E.g.: 70 |
|
| 66 | + * @since 9.1 |
|
| 67 | + */ |
|
| 68 | + public function getPriority() { |
|
| 69 | + return 20; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * returns an array containing links to the various clients |
|
| 74 | - * |
|
| 75 | - * @return array |
|
| 76 | - */ |
|
| 77 | - private function getClientLinks() { |
|
| 78 | - $clients = [ |
|
| 79 | - 'desktop' => $this->config->getSystemValue('customclient_desktop', $this->defaults->getSyncClientUrl()), |
|
| 80 | - 'android' => $this->config->getSystemValue('customclient_android', $this->defaults->getAndroidClientUrl()), |
|
| 81 | - 'ios' => $this->config->getSystemValue('customclient_ios', $this->defaults->getiOSClientUrl()) |
|
| 82 | - ]; |
|
| 83 | - return $clients; |
|
| 84 | - } |
|
| 72 | + /** |
|
| 73 | + * returns an array containing links to the various clients |
|
| 74 | + * |
|
| 75 | + * @return array |
|
| 76 | + */ |
|
| 77 | + private function getClientLinks() { |
|
| 78 | + $clients = [ |
|
| 79 | + 'desktop' => $this->config->getSystemValue('customclient_desktop', $this->defaults->getSyncClientUrl()), |
|
| 80 | + 'android' => $this->config->getSystemValue('customclient_android', $this->defaults->getAndroidClientUrl()), |
|
| 81 | + 'ios' => $this->config->getSystemValue('customclient_ios', $this->defaults->getiOSClientUrl()) |
|
| 82 | + ]; |
|
| 83 | + return $clients; |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -41,241 +41,241 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | 43 | class NavigationManager implements INavigationManager { |
| 44 | - protected $entries = []; |
|
| 45 | - protected $closureEntries = []; |
|
| 46 | - protected $activeEntry; |
|
| 47 | - /** @var bool */ |
|
| 48 | - protected $init = false; |
|
| 49 | - /** @var IAppManager|AppManager */ |
|
| 50 | - protected $appManager; |
|
| 51 | - /** @var IURLGenerator */ |
|
| 52 | - private $urlGenerator; |
|
| 53 | - /** @var IFactory */ |
|
| 54 | - private $l10nFac; |
|
| 55 | - /** @var IUserSession */ |
|
| 56 | - private $userSession; |
|
| 57 | - /** @var IGroupManager|Manager */ |
|
| 58 | - private $groupManager; |
|
| 59 | - /** @var IConfig */ |
|
| 60 | - private $config; |
|
| 44 | + protected $entries = []; |
|
| 45 | + protected $closureEntries = []; |
|
| 46 | + protected $activeEntry; |
|
| 47 | + /** @var bool */ |
|
| 48 | + protected $init = false; |
|
| 49 | + /** @var IAppManager|AppManager */ |
|
| 50 | + protected $appManager; |
|
| 51 | + /** @var IURLGenerator */ |
|
| 52 | + private $urlGenerator; |
|
| 53 | + /** @var IFactory */ |
|
| 54 | + private $l10nFac; |
|
| 55 | + /** @var IUserSession */ |
|
| 56 | + private $userSession; |
|
| 57 | + /** @var IGroupManager|Manager */ |
|
| 58 | + private $groupManager; |
|
| 59 | + /** @var IConfig */ |
|
| 60 | + private $config; |
|
| 61 | 61 | |
| 62 | - public function __construct(IAppManager $appManager, |
|
| 63 | - IURLGenerator $urlGenerator, |
|
| 64 | - IFactory $l10nFac, |
|
| 65 | - IUserSession $userSession, |
|
| 66 | - IGroupManager $groupManager, |
|
| 67 | - IConfig $config) { |
|
| 68 | - $this->appManager = $appManager; |
|
| 69 | - $this->urlGenerator = $urlGenerator; |
|
| 70 | - $this->l10nFac = $l10nFac; |
|
| 71 | - $this->userSession = $userSession; |
|
| 72 | - $this->groupManager = $groupManager; |
|
| 73 | - $this->config = $config; |
|
| 74 | - } |
|
| 62 | + public function __construct(IAppManager $appManager, |
|
| 63 | + IURLGenerator $urlGenerator, |
|
| 64 | + IFactory $l10nFac, |
|
| 65 | + IUserSession $userSession, |
|
| 66 | + IGroupManager $groupManager, |
|
| 67 | + IConfig $config) { |
|
| 68 | + $this->appManager = $appManager; |
|
| 69 | + $this->urlGenerator = $urlGenerator; |
|
| 70 | + $this->l10nFac = $l10nFac; |
|
| 71 | + $this->userSession = $userSession; |
|
| 72 | + $this->groupManager = $groupManager; |
|
| 73 | + $this->config = $config; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Creates a new navigation entry |
|
| 78 | - * |
|
| 79 | - * @param array|\Closure $entry Array containing: id, name, order, icon and href key |
|
| 80 | - * The use of a closure is preferred, because it will avoid |
|
| 81 | - * loading the routing of your app, unless required. |
|
| 82 | - * @return void |
|
| 83 | - */ |
|
| 84 | - public function add($entry) { |
|
| 85 | - if ($entry instanceof \Closure) { |
|
| 86 | - $this->closureEntries[] = $entry; |
|
| 87 | - return; |
|
| 88 | - } |
|
| 76 | + /** |
|
| 77 | + * Creates a new navigation entry |
|
| 78 | + * |
|
| 79 | + * @param array|\Closure $entry Array containing: id, name, order, icon and href key |
|
| 80 | + * The use of a closure is preferred, because it will avoid |
|
| 81 | + * loading the routing of your app, unless required. |
|
| 82 | + * @return void |
|
| 83 | + */ |
|
| 84 | + public function add($entry) { |
|
| 85 | + if ($entry instanceof \Closure) { |
|
| 86 | + $this->closureEntries[] = $entry; |
|
| 87 | + return; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - $entry['active'] = false; |
|
| 91 | - if(!isset($entry['icon'])) { |
|
| 92 | - $entry['icon'] = ''; |
|
| 93 | - } |
|
| 94 | - if(!isset($entry['type'])) { |
|
| 95 | - $entry['type'] = 'link'; |
|
| 96 | - } |
|
| 97 | - $this->entries[] = $entry; |
|
| 98 | - } |
|
| 90 | + $entry['active'] = false; |
|
| 91 | + if(!isset($entry['icon'])) { |
|
| 92 | + $entry['icon'] = ''; |
|
| 93 | + } |
|
| 94 | + if(!isset($entry['type'])) { |
|
| 95 | + $entry['type'] = 'link'; |
|
| 96 | + } |
|
| 97 | + $this->entries[] = $entry; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * returns all the added Menu entries |
|
| 102 | - * @param string $type |
|
| 103 | - * @return array an array of the added entries |
|
| 104 | - */ |
|
| 105 | - public function getAll($type = 'link') { |
|
| 106 | - $this->init(); |
|
| 107 | - foreach ($this->closureEntries as $c) { |
|
| 108 | - $this->add($c()); |
|
| 109 | - } |
|
| 110 | - $this->closureEntries = array(); |
|
| 100 | + /** |
|
| 101 | + * returns all the added Menu entries |
|
| 102 | + * @param string $type |
|
| 103 | + * @return array an array of the added entries |
|
| 104 | + */ |
|
| 105 | + public function getAll($type = 'link') { |
|
| 106 | + $this->init(); |
|
| 107 | + foreach ($this->closureEntries as $c) { |
|
| 108 | + $this->add($c()); |
|
| 109 | + } |
|
| 110 | + $this->closureEntries = array(); |
|
| 111 | 111 | |
| 112 | - if ($type === 'all') { |
|
| 113 | - return $this->entries; |
|
| 114 | - } |
|
| 112 | + if ($type === 'all') { |
|
| 113 | + return $this->entries; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - return array_filter($this->entries, function($entry) use ($type) { |
|
| 117 | - return $entry['type'] === $type; |
|
| 118 | - }); |
|
| 119 | - } |
|
| 116 | + return array_filter($this->entries, function($entry) use ($type) { |
|
| 117 | + return $entry['type'] === $type; |
|
| 118 | + }); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * removes all the entries |
|
| 123 | - */ |
|
| 124 | - public function clear($loadDefaultLinks = true) { |
|
| 125 | - $this->entries = []; |
|
| 126 | - $this->closureEntries = []; |
|
| 127 | - $this->init = !$loadDefaultLinks; |
|
| 128 | - } |
|
| 121 | + /** |
|
| 122 | + * removes all the entries |
|
| 123 | + */ |
|
| 124 | + public function clear($loadDefaultLinks = true) { |
|
| 125 | + $this->entries = []; |
|
| 126 | + $this->closureEntries = []; |
|
| 127 | + $this->init = !$loadDefaultLinks; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Sets the current navigation entry of the currently running app |
|
| 132 | - * @param string $id of the app entry to activate (from added $entry) |
|
| 133 | - */ |
|
| 134 | - public function setActiveEntry($id) { |
|
| 135 | - $this->activeEntry = $id; |
|
| 136 | - } |
|
| 130 | + /** |
|
| 131 | + * Sets the current navigation entry of the currently running app |
|
| 132 | + * @param string $id of the app entry to activate (from added $entry) |
|
| 133 | + */ |
|
| 134 | + public function setActiveEntry($id) { |
|
| 135 | + $this->activeEntry = $id; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * gets the active Menu entry |
|
| 140 | - * @return string id or empty string |
|
| 141 | - * |
|
| 142 | - * This function returns the id of the active navigation entry (set by |
|
| 143 | - * setActiveEntry |
|
| 144 | - */ |
|
| 145 | - public function getActiveEntry() { |
|
| 146 | - return $this->activeEntry; |
|
| 147 | - } |
|
| 138 | + /** |
|
| 139 | + * gets the active Menu entry |
|
| 140 | + * @return string id or empty string |
|
| 141 | + * |
|
| 142 | + * This function returns the id of the active navigation entry (set by |
|
| 143 | + * setActiveEntry |
|
| 144 | + */ |
|
| 145 | + public function getActiveEntry() { |
|
| 146 | + return $this->activeEntry; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - private function init() { |
|
| 150 | - if ($this->init) { |
|
| 151 | - return; |
|
| 152 | - } |
|
| 153 | - $this->init = true; |
|
| 149 | + private function init() { |
|
| 150 | + if ($this->init) { |
|
| 151 | + return; |
|
| 152 | + } |
|
| 153 | + $this->init = true; |
|
| 154 | 154 | |
| 155 | - $l = $this->l10nFac->get('lib'); |
|
| 156 | - if ($this->config->getSystemValue('knowledgebaseenabled', true)) { |
|
| 157 | - $this->add([ |
|
| 158 | - 'type' => 'settings', |
|
| 159 | - 'id' => 'help', |
|
| 160 | - 'order' => 5, |
|
| 161 | - 'href' => $this->urlGenerator->linkToRoute('settings_help'), |
|
| 162 | - 'name' => $l->t('Help'), |
|
| 163 | - 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), |
|
| 164 | - ]); |
|
| 165 | - } |
|
| 155 | + $l = $this->l10nFac->get('lib'); |
|
| 156 | + if ($this->config->getSystemValue('knowledgebaseenabled', true)) { |
|
| 157 | + $this->add([ |
|
| 158 | + 'type' => 'settings', |
|
| 159 | + 'id' => 'help', |
|
| 160 | + 'order' => 5, |
|
| 161 | + 'href' => $this->urlGenerator->linkToRoute('settings_help'), |
|
| 162 | + 'name' => $l->t('Help'), |
|
| 163 | + 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), |
|
| 164 | + ]); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - if ($this->userSession->isLoggedIn()) { |
|
| 168 | - if ($this->isAdmin()) { |
|
| 169 | - // App management |
|
| 170 | - $this->add([ |
|
| 171 | - 'type' => 'settings', |
|
| 172 | - 'id' => 'core_apps', |
|
| 173 | - 'order' => 3, |
|
| 174 | - 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), |
|
| 175 | - 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), |
|
| 176 | - 'name' => $l->t('Apps'), |
|
| 177 | - ]); |
|
| 178 | - } |
|
| 167 | + if ($this->userSession->isLoggedIn()) { |
|
| 168 | + if ($this->isAdmin()) { |
|
| 169 | + // App management |
|
| 170 | + $this->add([ |
|
| 171 | + 'type' => 'settings', |
|
| 172 | + 'id' => 'core_apps', |
|
| 173 | + 'order' => 3, |
|
| 174 | + 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), |
|
| 175 | + 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), |
|
| 176 | + 'name' => $l->t('Apps'), |
|
| 177 | + ]); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // Personal and (if applicable) admin settings |
|
| 181 | - $this->add([ |
|
| 182 | - 'type' => 'settings', |
|
| 183 | - 'id' => 'settings', |
|
| 184 | - 'order' => 1, |
|
| 185 | - 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'), |
|
| 186 | - 'name' => $l->t('Settings'), |
|
| 187 | - 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), |
|
| 188 | - ]); |
|
| 180 | + // Personal and (if applicable) admin settings |
|
| 181 | + $this->add([ |
|
| 182 | + 'type' => 'settings', |
|
| 183 | + 'id' => 'settings', |
|
| 184 | + 'order' => 1, |
|
| 185 | + 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'), |
|
| 186 | + 'name' => $l->t('Settings'), |
|
| 187 | + 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), |
|
| 188 | + ]); |
|
| 189 | 189 | |
| 190 | - // Logout |
|
| 191 | - $this->add([ |
|
| 192 | - 'type' => 'settings', |
|
| 193 | - 'id' => 'logout', |
|
| 194 | - 'order' => 99999, |
|
| 195 | - 'href' => $this->urlGenerator->linkToRouteAbsolute( |
|
| 196 | - 'core.login.logout', |
|
| 197 | - ['requesttoken' => \OCP\Util::callRegister()] |
|
| 198 | - ), |
|
| 199 | - 'name' => $l->t('Log out'), |
|
| 200 | - 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), |
|
| 201 | - ]); |
|
| 190 | + // Logout |
|
| 191 | + $this->add([ |
|
| 192 | + 'type' => 'settings', |
|
| 193 | + 'id' => 'logout', |
|
| 194 | + 'order' => 99999, |
|
| 195 | + 'href' => $this->urlGenerator->linkToRouteAbsolute( |
|
| 196 | + 'core.login.logout', |
|
| 197 | + ['requesttoken' => \OCP\Util::callRegister()] |
|
| 198 | + ), |
|
| 199 | + 'name' => $l->t('Log out'), |
|
| 200 | + 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), |
|
| 201 | + ]); |
|
| 202 | 202 | |
| 203 | - if ($this->isSubadmin()) { |
|
| 204 | - // User management |
|
| 205 | - $this->add([ |
|
| 206 | - 'type' => 'settings', |
|
| 207 | - 'id' => 'core_users', |
|
| 208 | - 'order' => 4, |
|
| 209 | - 'href' => $this->urlGenerator->linkToRoute('settings_users'), |
|
| 210 | - 'name' => $l->t('Users'), |
|
| 211 | - 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), |
|
| 212 | - ]); |
|
| 213 | - } |
|
| 214 | - } |
|
| 203 | + if ($this->isSubadmin()) { |
|
| 204 | + // User management |
|
| 205 | + $this->add([ |
|
| 206 | + 'type' => 'settings', |
|
| 207 | + 'id' => 'core_users', |
|
| 208 | + 'order' => 4, |
|
| 209 | + 'href' => $this->urlGenerator->linkToRoute('settings_users'), |
|
| 210 | + 'name' => $l->t('Users'), |
|
| 211 | + 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), |
|
| 212 | + ]); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - if ($this->appManager === 'null') { |
|
| 217 | - return; |
|
| 218 | - } |
|
| 219 | - foreach ($this->appManager->getInstalledApps() as $app) { |
|
| 220 | - // load plugins and collections from info.xml |
|
| 221 | - $info = $this->appManager->getAppInfo($app); |
|
| 222 | - if (empty($info['navigations'])) { |
|
| 223 | - continue; |
|
| 224 | - } |
|
| 225 | - foreach ($info['navigations'] as $nav) { |
|
| 226 | - if (!isset($nav['name'])) { |
|
| 227 | - continue; |
|
| 228 | - } |
|
| 229 | - if (!isset($nav['route'])) { |
|
| 230 | - continue; |
|
| 231 | - } |
|
| 232 | - $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; |
|
| 233 | - if ($role === 'admin' && !$this->isAdmin()) { |
|
| 234 | - continue; |
|
| 235 | - } |
|
| 236 | - $l = $this->l10nFac->get($app); |
|
| 237 | - $id = isset($nav['id']) ? $nav['id'] : $app; |
|
| 238 | - $order = isset($nav['order']) ? $nav['order'] : 100; |
|
| 239 | - $type = isset($nav['type']) ? $nav['type'] : 'link'; |
|
| 240 | - $route = $this->urlGenerator->linkToRoute($nav['route']); |
|
| 241 | - $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |
|
| 242 | - foreach ([$icon, "$app.svg"] as $i) { |
|
| 243 | - try { |
|
| 244 | - $icon = $this->urlGenerator->imagePath($app, $i); |
|
| 245 | - break; |
|
| 246 | - } catch (\RuntimeException $ex) { |
|
| 247 | - // no icon? - ignore it then |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - if ($icon === null) { |
|
| 251 | - $icon = $this->urlGenerator->imagePath('core', 'default-app-icon'); |
|
| 252 | - } |
|
| 216 | + if ($this->appManager === 'null') { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 219 | + foreach ($this->appManager->getInstalledApps() as $app) { |
|
| 220 | + // load plugins and collections from info.xml |
|
| 221 | + $info = $this->appManager->getAppInfo($app); |
|
| 222 | + if (empty($info['navigations'])) { |
|
| 223 | + continue; |
|
| 224 | + } |
|
| 225 | + foreach ($info['navigations'] as $nav) { |
|
| 226 | + if (!isset($nav['name'])) { |
|
| 227 | + continue; |
|
| 228 | + } |
|
| 229 | + if (!isset($nav['route'])) { |
|
| 230 | + continue; |
|
| 231 | + } |
|
| 232 | + $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; |
|
| 233 | + if ($role === 'admin' && !$this->isAdmin()) { |
|
| 234 | + continue; |
|
| 235 | + } |
|
| 236 | + $l = $this->l10nFac->get($app); |
|
| 237 | + $id = isset($nav['id']) ? $nav['id'] : $app; |
|
| 238 | + $order = isset($nav['order']) ? $nav['order'] : 100; |
|
| 239 | + $type = isset($nav['type']) ? $nav['type'] : 'link'; |
|
| 240 | + $route = $this->urlGenerator->linkToRoute($nav['route']); |
|
| 241 | + $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |
|
| 242 | + foreach ([$icon, "$app.svg"] as $i) { |
|
| 243 | + try { |
|
| 244 | + $icon = $this->urlGenerator->imagePath($app, $i); |
|
| 245 | + break; |
|
| 246 | + } catch (\RuntimeException $ex) { |
|
| 247 | + // no icon? - ignore it then |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + if ($icon === null) { |
|
| 251 | + $icon = $this->urlGenerator->imagePath('core', 'default-app-icon'); |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - $this->add([ |
|
| 255 | - 'id' => $id, |
|
| 256 | - 'order' => $order, |
|
| 257 | - 'href' => $route, |
|
| 258 | - 'icon' => $icon, |
|
| 259 | - 'type' => $type, |
|
| 260 | - 'name' => $l->t($nav['name']), |
|
| 261 | - ]); |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - } |
|
| 254 | + $this->add([ |
|
| 255 | + 'id' => $id, |
|
| 256 | + 'order' => $order, |
|
| 257 | + 'href' => $route, |
|
| 258 | + 'icon' => $icon, |
|
| 259 | + 'type' => $type, |
|
| 260 | + 'name' => $l->t($nav['name']), |
|
| 261 | + ]); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - private function isAdmin() { |
|
| 267 | - $user = $this->userSession->getUser(); |
|
| 268 | - if ($user !== null) { |
|
| 269 | - return $this->groupManager->isAdmin($user->getUID()); |
|
| 270 | - } |
|
| 271 | - return false; |
|
| 272 | - } |
|
| 266 | + private function isAdmin() { |
|
| 267 | + $user = $this->userSession->getUser(); |
|
| 268 | + if ($user !== null) { |
|
| 269 | + return $this->groupManager->isAdmin($user->getUID()); |
|
| 270 | + } |
|
| 271 | + return false; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - private function isSubadmin() { |
|
| 275 | - $user = $this->userSession->getUser(); |
|
| 276 | - if ($user !== null) { |
|
| 277 | - return $this->groupManager->getSubAdmin()->isSubAdmin($user); |
|
| 278 | - } |
|
| 279 | - return false; |
|
| 280 | - } |
|
| 274 | + private function isSubadmin() { |
|
| 275 | + $user = $this->userSession->getUser(); |
|
| 276 | + if ($user !== null) { |
|
| 277 | + return $this->groupManager->getSubAdmin()->isSubAdmin($user); |
|
| 278 | + } |
|
| 279 | + return false; |
|
| 280 | + } |
|
| 281 | 281 | } |
@@ -27,99 +27,99 @@ |
||
| 27 | 27 | * @since 9.1 |
| 28 | 28 | */ |
| 29 | 29 | interface IManager { |
| 30 | - /** |
|
| 31 | - * @since 9.1.0 |
|
| 32 | - */ |
|
| 33 | - const KEY_ADMIN_SETTINGS = 'admin'; |
|
| 30 | + /** |
|
| 31 | + * @since 9.1.0 |
|
| 32 | + */ |
|
| 33 | + const KEY_ADMIN_SETTINGS = 'admin'; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @since 9.1.0 |
|
| 37 | - */ |
|
| 38 | - const KEY_ADMIN_SECTION = 'admin-section'; |
|
| 35 | + /** |
|
| 36 | + * @since 9.1.0 |
|
| 37 | + */ |
|
| 38 | + const KEY_ADMIN_SECTION = 'admin-section'; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @since 12.0.0 |
|
| 42 | - */ |
|
| 43 | - const KEY_PERSONAL_SETTINGS = 'personal'; |
|
| 40 | + /** |
|
| 41 | + * @since 12.0.0 |
|
| 42 | + */ |
|
| 43 | + const KEY_PERSONAL_SETTINGS = 'personal'; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @since 12.0.0 |
|
| 47 | - */ |
|
| 48 | - const KEY_PERSONAL_SECTION = 'personal-section'; |
|
| 45 | + /** |
|
| 46 | + * @since 12.0.0 |
|
| 47 | + */ |
|
| 48 | + const KEY_PERSONAL_SECTION = 'personal-section'; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * sets up settings according to data specified by an apps info.xml, within |
|
| 52 | - * the <settings> element. |
|
| 53 | - * |
|
| 54 | - * @param array $settings an associative array, allowed keys are as specified |
|
| 55 | - * by the KEY_ constant of this interface. The value |
|
| 56 | - * must always be a class name, implement either |
|
| 57 | - * IAdmin or ISection. I.e. only one section and admin |
|
| 58 | - * setting can be configured per app. |
|
| 59 | - * @since 9.1.0 |
|
| 60 | - */ |
|
| 61 | - public function setupSettings(array $settings); |
|
| 50 | + /** |
|
| 51 | + * sets up settings according to data specified by an apps info.xml, within |
|
| 52 | + * the <settings> element. |
|
| 53 | + * |
|
| 54 | + * @param array $settings an associative array, allowed keys are as specified |
|
| 55 | + * by the KEY_ constant of this interface. The value |
|
| 56 | + * must always be a class name, implement either |
|
| 57 | + * IAdmin or ISection. I.e. only one section and admin |
|
| 58 | + * setting can be configured per app. |
|
| 59 | + * @since 9.1.0 |
|
| 60 | + */ |
|
| 61 | + public function setupSettings(array $settings); |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * attempts to remove an apps section and/or settings entry. A listener is |
|
| 65 | - * added centrally making sure that this method is called ones an app was |
|
| 66 | - * disabled. |
|
| 67 | - * |
|
| 68 | - * What this does not help with is when applications change their settings |
|
| 69 | - * or section classes during their life time. New entries will be added, |
|
| 70 | - * but inactive ones will still reside in the database. |
|
| 71 | - * |
|
| 72 | - * @param string $appId |
|
| 73 | - * @since 9.1.0 |
|
| 74 | - */ |
|
| 75 | - public function onAppDisabled($appId); |
|
| 63 | + /** |
|
| 64 | + * attempts to remove an apps section and/or settings entry. A listener is |
|
| 65 | + * added centrally making sure that this method is called ones an app was |
|
| 66 | + * disabled. |
|
| 67 | + * |
|
| 68 | + * What this does not help with is when applications change their settings |
|
| 69 | + * or section classes during their life time. New entries will be added, |
|
| 70 | + * but inactive ones will still reside in the database. |
|
| 71 | + * |
|
| 72 | + * @param string $appId |
|
| 73 | + * @since 9.1.0 |
|
| 74 | + */ |
|
| 75 | + public function onAppDisabled($appId); |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * The method should check all registered classes whether they are still |
|
| 79 | - * instantiable and remove them, if not. This method is called by a |
|
| 80 | - * background job once, after one or more apps were updated. |
|
| 81 | - * |
|
| 82 | - * An app`s info.xml can change during an update and make it unknown whether |
|
| 83 | - * a registered class name was changed or not. An old one would just stay |
|
| 84 | - * registered. Another case is if an admin takes a radical approach and |
|
| 85 | - * simply removes an app from the app folder. These unregular checks will |
|
| 86 | - * take care of such situations. |
|
| 87 | - * |
|
| 88 | - * @since 9.1.0 |
|
| 89 | - */ |
|
| 90 | - public function checkForOrphanedClassNames(); |
|
| 77 | + /** |
|
| 78 | + * The method should check all registered classes whether they are still |
|
| 79 | + * instantiable and remove them, if not. This method is called by a |
|
| 80 | + * background job once, after one or more apps were updated. |
|
| 81 | + * |
|
| 82 | + * An app`s info.xml can change during an update and make it unknown whether |
|
| 83 | + * a registered class name was changed or not. An old one would just stay |
|
| 84 | + * registered. Another case is if an admin takes a radical approach and |
|
| 85 | + * simply removes an app from the app folder. These unregular checks will |
|
| 86 | + * take care of such situations. |
|
| 87 | + * |
|
| 88 | + * @since 9.1.0 |
|
| 89 | + */ |
|
| 90 | + public function checkForOrphanedClassNames(); |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * returns a list of the admin sections |
|
| 94 | - * |
|
| 95 | - * @return array array of ISection[] where key is the priority |
|
| 96 | - * @since 9.1.0 |
|
| 97 | - */ |
|
| 98 | - public function getAdminSections(); |
|
| 92 | + /** |
|
| 93 | + * returns a list of the admin sections |
|
| 94 | + * |
|
| 95 | + * @return array array of ISection[] where key is the priority |
|
| 96 | + * @since 9.1.0 |
|
| 97 | + */ |
|
| 98 | + public function getAdminSections(); |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * returns a list of the personal sections |
|
| 102 | - * |
|
| 103 | - * @return array array of ISection[] where key is the priority |
|
| 104 | - * @since 12.0.0 |
|
| 105 | - */ |
|
| 106 | - public function getPersonalSections(); |
|
| 100 | + /** |
|
| 101 | + * returns a list of the personal sections |
|
| 102 | + * |
|
| 103 | + * @return array array of ISection[] where key is the priority |
|
| 104 | + * @since 12.0.0 |
|
| 105 | + */ |
|
| 106 | + public function getPersonalSections(); |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * returns a list of the admin settings |
|
| 110 | - * |
|
| 111 | - * @param string $section the section id for which to load the settings |
|
| 112 | - * @return array array of IAdmin[] where key is the priority |
|
| 113 | - * @since 9.1.0 |
|
| 114 | - */ |
|
| 115 | - public function getAdminSettings($section); |
|
| 108 | + /** |
|
| 109 | + * returns a list of the admin settings |
|
| 110 | + * |
|
| 111 | + * @param string $section the section id for which to load the settings |
|
| 112 | + * @return array array of IAdmin[] where key is the priority |
|
| 113 | + * @since 9.1.0 |
|
| 114 | + */ |
|
| 115 | + public function getAdminSettings($section); |
|
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * returns a list of the personal settings |
|
| 119 | - * |
|
| 120 | - * @param string $section the section id for which to load the settings |
|
| 121 | - * @return array array of IPersonal[] where key is the priority |
|
| 122 | - * @since 12.0.0 |
|
| 123 | - */ |
|
| 124 | - public function getPersonalSettings($section); |
|
| 117 | + /** |
|
| 118 | + * returns a list of the personal settings |
|
| 119 | + * |
|
| 120 | + * @param string $section the section id for which to load the settings |
|
| 121 | + * @return array array of IPersonal[] where key is the priority |
|
| 122 | + * @since 12.0.0 |
|
| 123 | + */ |
|
| 124 | + public function getPersonalSettings($section); |
|
| 125 | 125 | } |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | /** @var array $_ */ |
| 26 | 26 | |
| 27 | 27 | script('settings', [ |
| 28 | - 'usersettings', |
|
| 29 | - 'federationsettingsview', |
|
| 30 | - 'federationscopemenu', |
|
| 31 | - 'settings/personalInfo', |
|
| 28 | + 'usersettings', |
|
| 29 | + 'federationsettingsview', |
|
| 30 | + 'federationscopemenu', |
|
| 31 | + 'settings/personalInfo', |
|
| 32 | 32 | ]); |
| 33 | 33 | vendor_script('strengthify/jquery.strengthify'); |
| 34 | 34 | vendor_style('strengthify/strengthify'); |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | <p id="quotatext"> |
| 47 | 47 | <?php if ($_['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED): ?> |
| 48 | 48 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong>', |
| 49 | - [$_['usage'], $_['total_space']]));?> |
|
| 49 | + [$_['usage'], $_['total_space']]));?> |
|
| 50 | 50 | <?php else: ?> |
| 51 | 51 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong> (<strong>%s %%</strong>)', |
| 52 | - [$_['usage'], $_['total_space'], $_['usage_relative']]));?> |
|
| 52 | + [$_['usage'], $_['total_space'], $_['usage_relative']]));?> |
|
| 53 | 53 | <?php endif ?> |
| 54 | 54 | </p> |
| 55 | 55 | </div> |
@@ -118,17 +118,17 @@ discard block |
||
| 118 | 118 | <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
| 119 | 119 | <img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src=" |
| 120 | 120 | <?php |
| 121 | - switch($_['emailVerification']) { |
|
| 122 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 123 | - p(image_path('core', 'actions/verifying.svg')); |
|
| 124 | - break; |
|
| 125 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
| 126 | - p(image_path('core', 'actions/verified.svg')); |
|
| 127 | - break; |
|
| 128 | - default: |
|
| 129 | - p(image_path('core', 'actions/verify.svg')); |
|
| 130 | - } |
|
| 131 | - ?>"> |
|
| 121 | + switch($_['emailVerification']) { |
|
| 122 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 123 | + p(image_path('core', 'actions/verifying.svg')); |
|
| 124 | + break; |
|
| 125 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
| 126 | + p(image_path('core', 'actions/verified.svg')); |
|
| 127 | + break; |
|
| 128 | + default: |
|
| 129 | + p(image_path('core', 'actions/verify.svg')); |
|
| 130 | + } |
|
| 131 | + ?>"> |
|
| 132 | 132 | </div> |
| 133 | 133 | <input type="email" name="email" id="email" value="<?php p($_['email']); ?>" |
| 134 | 134 | <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
@@ -185,17 +185,17 @@ discard block |
||
| 185 | 185 | <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
| 186 | 186 | <img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src=" |
| 187 | 187 | <?php |
| 188 | - switch($_['websiteVerification']) { |
|
| 189 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 190 | - p(image_path('core', 'actions/verifying.svg')); |
|
| 191 | - break; |
|
| 192 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
| 193 | - p(image_path('core', 'actions/verified.svg')); |
|
| 194 | - break; |
|
| 195 | - default: |
|
| 196 | - p(image_path('core', 'actions/verify.svg')); |
|
| 197 | - } |
|
| 198 | - ?>" |
|
| 188 | + switch($_['websiteVerification']) { |
|
| 189 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 190 | + p(image_path('core', 'actions/verifying.svg')); |
|
| 191 | + break; |
|
| 192 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
| 193 | + p(image_path('core', 'actions/verified.svg')); |
|
| 194 | + break; |
|
| 195 | + default: |
|
| 196 | + p(image_path('core', 'actions/verify.svg')); |
|
| 197 | + } |
|
| 198 | + ?>" |
|
| 199 | 199 | <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
| 200 | 200 | > |
| 201 | 201 | <div class="verification-dialog popovermenu bubble menu"> |
@@ -222,17 +222,17 @@ discard block |
||
| 222 | 222 | <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
| 223 | 223 | <img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src=" |
| 224 | 224 | <?php |
| 225 | - switch($_['twitterVerification']) { |
|
| 226 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 227 | - p(image_path('core', 'actions/verifying.svg')); |
|
| 228 | - break; |
|
| 229 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
| 230 | - p(image_path('core', 'actions/verified.svg')); |
|
| 231 | - break; |
|
| 232 | - default: |
|
| 233 | - p(image_path('core', 'actions/verify.svg')); |
|
| 234 | - } |
|
| 235 | - ?>" |
|
| 225 | + switch($_['twitterVerification']) { |
|
| 226 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 227 | + p(image_path('core', 'actions/verifying.svg')); |
|
| 228 | + break; |
|
| 229 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
| 230 | + p(image_path('core', 'actions/verified.svg')); |
|
| 231 | + break; |
|
| 232 | + default: |
|
| 233 | + p(image_path('core', 'actions/verify.svg')); |
|
| 234 | + } |
|
| 235 | + ?>" |
|
| 236 | 236 | <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
| 237 | 237 | > |
| 238 | 238 | <div class="verification-dialog popovermenu bubble menu"> |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | <?php |
| 267 | 267 | if($_['passwordChangeSupported']) { |
| 268 | - script('jquery-showpassword'); |
|
| 269 | - ?> |
|
| 268 | + script('jquery-showpassword'); |
|
| 269 | + ?> |
|
| 270 | 270 | <form id="passwordform" class="section"> |
| 271 | 271 | <h2 class="inlineblock"><?php p($l->t('Password'));?></h2> |
| 272 | 272 | <div id="password-error-msg" class="msg success inlineblock" style="display: none;">Saved</div> |
@@ -42,15 +42,15 @@ |
||
| 42 | 42 | |
| 43 | 43 | <p> |
| 44 | 44 | <?php print_unescaped(str_replace( |
| 45 | - [ |
|
| 46 | - '{contributeopen}', |
|
| 47 | - '{linkclose}', |
|
| 48 | - ], |
|
| 49 | - [ |
|
| 50 | - '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer">', |
|
| 51 | - '</a>', |
|
| 52 | - ], |
|
| 53 | - $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
|
| 45 | + [ |
|
| 46 | + '{contributeopen}', |
|
| 47 | + '{linkclose}', |
|
| 48 | + ], |
|
| 49 | + [ |
|
| 50 | + '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer">', |
|
| 51 | + '</a>', |
|
| 52 | + ], |
|
| 53 | + $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
|
| 54 | 54 | </p> |
| 55 | 55 | |
| 56 | 56 | <?php if(OC_APP::isEnabled('firstrunwizard')) {?> |
@@ -29,31 +29,31 @@ |
||
| 29 | 29 | |
| 30 | 30 | class Additional implements ISettings { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 34 | - * @since 9.1 |
|
| 35 | - */ |
|
| 36 | - public function getForm() { |
|
| 37 | - return new TemplateResponse('settings', 'settings/empty'); |
|
| 38 | - } |
|
| 32 | + /** |
|
| 33 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 34 | + * @since 9.1 |
|
| 35 | + */ |
|
| 36 | + public function getForm() { |
|
| 37 | + return new TemplateResponse('settings', 'settings/empty'); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @return string the section ID, e.g. 'sharing' |
|
| 42 | - * @since 9.1 |
|
| 43 | - */ |
|
| 44 | - public function getSection() { |
|
| 45 | - return 'additional'; |
|
| 46 | - } |
|
| 40 | + /** |
|
| 41 | + * @return string the section ID, e.g. 'sharing' |
|
| 42 | + * @since 9.1 |
|
| 43 | + */ |
|
| 44 | + public function getSection() { |
|
| 45 | + return 'additional'; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @return int whether the form should be rather on the top or bottom of |
|
| 50 | - * the admin section. The forms are arranged in ascending order of the |
|
| 51 | - * priority values. It is required to return a value between 0 and 100. |
|
| 52 | - * |
|
| 53 | - * E.g.: 70 |
|
| 54 | - * @since 9.1 |
|
| 55 | - */ |
|
| 56 | - public function getPriority() { |
|
| 57 | - return '5'; |
|
| 58 | - } |
|
| 48 | + /** |
|
| 49 | + * @return int whether the form should be rather on the top or bottom of |
|
| 50 | + * the admin section. The forms are arranged in ascending order of the |
|
| 51 | + * priority values. It is required to return a value between 0 and 100. |
|
| 52 | + * |
|
| 53 | + * E.g.: 70 |
|
| 54 | + * @since 9.1 |
|
| 55 | + */ |
|
| 56 | + public function getPriority() { |
|
| 57 | + return '5'; |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -26,189 +26,189 @@ |
||
| 26 | 26 | use OCP\IDBConnection; |
| 27 | 27 | |
| 28 | 28 | class Mapper { |
| 29 | - const TABLE_ADMIN_SETTINGS = 'admin_settings'; |
|
| 30 | - const TABLE_ADMIN_SECTIONS = 'admin_sections'; |
|
| 31 | - const TABLE_PERSONAL_SETTINGS = 'personal_settings'; |
|
| 32 | - const TABLE_PERSONAL_SECTIONS = 'personal_sections'; |
|
| 33 | - |
|
| 34 | - /** @var IDBConnection */ |
|
| 35 | - private $dbc; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @param IDBConnection $dbc |
|
| 39 | - */ |
|
| 40 | - public function __construct(IDBConnection $dbc) { |
|
| 41 | - $this->dbc = $dbc; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Get the configured admin settings from the database for the provided section |
|
| 46 | - * |
|
| 47 | - * @param string $section |
|
| 48 | - * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 49 | - */ |
|
| 50 | - public function getAdminSettingsFromDB($section) { |
|
| 51 | - return $this->getSettingsFromDB(self::TABLE_ADMIN_SETTINGS, $section); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Get the configured personal settings from the database for the provided section |
|
| 56 | - * |
|
| 57 | - * @param string $section |
|
| 58 | - * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 59 | - */ |
|
| 60 | - public function getPersonalSettingsFromDB($section) { |
|
| 61 | - return $this->getSettingsFromDB(self::TABLE_PERSONAL_SETTINGS, $section); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Get the configured settings from the database for the provided table and section |
|
| 66 | - * |
|
| 67 | - * @param $table |
|
| 68 | - * @param $section |
|
| 69 | - * @return array |
|
| 70 | - */ |
|
| 71 | - private function getSettingsFromDB($table, $section) { |
|
| 72 | - $query = $this->dbc->getQueryBuilder(); |
|
| 73 | - $query->select(['class', 'priority']) |
|
| 74 | - ->from($table) |
|
| 75 | - ->where($query->expr()->eq('section', $this->dbc->getQueryBuilder()->createParameter('section'))) |
|
| 76 | - ->setParameter('section', $section); |
|
| 77 | - |
|
| 78 | - $result = $query->execute(); |
|
| 79 | - return $result->fetchAll(); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Get the configured admin sections from the database |
|
| 84 | - * |
|
| 85 | - * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 86 | - */ |
|
| 87 | - public function getAdminSectionsFromDB() { |
|
| 88 | - return $this->getSectionsFromDB('admin'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Get the configured admin sections from the database |
|
| 93 | - * |
|
| 94 | - * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 95 | - */ |
|
| 96 | - public function getPersonalSectionsFromDB() { |
|
| 97 | - return $this->getSectionsFromDB('personal'); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Get the configured sections from the database by table |
|
| 102 | - * |
|
| 103 | - * @param string $type either 'personal' or 'admin' |
|
| 104 | - * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 105 | - */ |
|
| 106 | - public function getSectionsFromDB($type) { |
|
| 107 | - if($type === 'admin') { |
|
| 108 | - $sectionsTable = self::TABLE_ADMIN_SECTIONS; |
|
| 109 | - $settingsTable = self::TABLE_ADMIN_SETTINGS; |
|
| 110 | - } else if($type === 'personal') { |
|
| 111 | - $sectionsTable = self::TABLE_PERSONAL_SECTIONS; |
|
| 112 | - $settingsTable = self::TABLE_PERSONAL_SETTINGS; |
|
| 113 | - } else { |
|
| 114 | - throw new \InvalidArgumentException('"admin" or "personal" expected'); |
|
| 115 | - } |
|
| 116 | - $query = $this->dbc->getQueryBuilder(); |
|
| 117 | - $query->selectDistinct('s.class') |
|
| 118 | - ->addSelect('s.priority') |
|
| 119 | - ->from($sectionsTable, 's') |
|
| 120 | - ->from($settingsTable, 'f') |
|
| 121 | - ->where($query->expr()->eq('s.id', 'f.section')); |
|
| 122 | - $result = $query->execute(); |
|
| 123 | - return array_map(function ($row) { |
|
| 124 | - $row['priority'] = (int)$row['priority']; |
|
| 125 | - return $row; |
|
| 126 | - }, $result->fetchAll()); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @param string $table one of the Mapper::TABLE_* constants |
|
| 131 | - * @param array $values |
|
| 132 | - */ |
|
| 133 | - public function add($table, array $values) { |
|
| 134 | - $query = $this->dbc->getQueryBuilder(); |
|
| 135 | - $values = array_map(function ($value) use ($query) { |
|
| 136 | - return $query->createNamedParameter($value); |
|
| 137 | - }, $values); |
|
| 138 | - $query->insert($table)->values($values); |
|
| 139 | - $query->execute(); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * returns the registered classes in the given table |
|
| 144 | - * |
|
| 145 | - * @param string $table one of the Mapper::TABLE_* constants |
|
| 146 | - * @return string[] |
|
| 147 | - */ |
|
| 148 | - public function getClasses($table) { |
|
| 149 | - $q = $this->dbc->getQueryBuilder(); |
|
| 150 | - $resultStatement = $q->select('class') |
|
| 151 | - ->from($table) |
|
| 152 | - ->execute(); |
|
| 153 | - $data = $resultStatement->fetchAll(); |
|
| 154 | - $resultStatement->closeCursor(); |
|
| 155 | - |
|
| 156 | - return array_map(function ($row) { |
|
| 157 | - return $row['class']; |
|
| 158 | - }, $data); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Check if a class is configured in the database |
|
| 163 | - * |
|
| 164 | - * @param string $table one of the Mapper::TABLE_* constants |
|
| 165 | - * @param string $className |
|
| 166 | - * @return bool |
|
| 167 | - */ |
|
| 168 | - public function has($table, $className) { |
|
| 169 | - $query = $this->dbc->getQueryBuilder(); |
|
| 170 | - $query->select('class') |
|
| 171 | - ->from($table) |
|
| 172 | - ->where($query->expr()->eq('class', $query->createNamedParameter($className))) |
|
| 173 | - ->setMaxResults(1); |
|
| 174 | - |
|
| 175 | - $result = $query->execute(); |
|
| 176 | - $row = $result->fetch(); |
|
| 177 | - $result->closeCursor(); |
|
| 178 | - |
|
| 179 | - return (bool)$row; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * deletes an settings or admin entry from the given table |
|
| 184 | - * |
|
| 185 | - * @param string $table one of the Mapper::TABLE_* constants |
|
| 186 | - * @param string $className |
|
| 187 | - */ |
|
| 188 | - public function remove($table, $className) { |
|
| 189 | - $query = $this->dbc->getQueryBuilder(); |
|
| 190 | - $query->delete($table) |
|
| 191 | - ->where($query->expr()->eq('class', $query->createNamedParameter($className))); |
|
| 192 | - |
|
| 193 | - $query->execute(); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @param string $table one of the Mapper::TABLE_* constants |
|
| 198 | - * @param string $idCol |
|
| 199 | - * @param string $id |
|
| 200 | - * @param array $values |
|
| 201 | - */ |
|
| 202 | - public function update($table, $idCol, $id, $values) { |
|
| 203 | - $query = $this->dbc->getQueryBuilder(); |
|
| 204 | - $query->update($table); |
|
| 205 | - foreach ($values as $key => $value) { |
|
| 206 | - $query->set($key, $query->createNamedParameter($value)); |
|
| 207 | - } |
|
| 208 | - $query |
|
| 209 | - ->where($query->expr()->eq($idCol, $query->createParameter($idCol))) |
|
| 210 | - ->setParameter($idCol, $id) |
|
| 211 | - ->execute(); |
|
| 212 | - } |
|
| 29 | + const TABLE_ADMIN_SETTINGS = 'admin_settings'; |
|
| 30 | + const TABLE_ADMIN_SECTIONS = 'admin_sections'; |
|
| 31 | + const TABLE_PERSONAL_SETTINGS = 'personal_settings'; |
|
| 32 | + const TABLE_PERSONAL_SECTIONS = 'personal_sections'; |
|
| 33 | + |
|
| 34 | + /** @var IDBConnection */ |
|
| 35 | + private $dbc; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @param IDBConnection $dbc |
|
| 39 | + */ |
|
| 40 | + public function __construct(IDBConnection $dbc) { |
|
| 41 | + $this->dbc = $dbc; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Get the configured admin settings from the database for the provided section |
|
| 46 | + * |
|
| 47 | + * @param string $section |
|
| 48 | + * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 49 | + */ |
|
| 50 | + public function getAdminSettingsFromDB($section) { |
|
| 51 | + return $this->getSettingsFromDB(self::TABLE_ADMIN_SETTINGS, $section); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Get the configured personal settings from the database for the provided section |
|
| 56 | + * |
|
| 57 | + * @param string $section |
|
| 58 | + * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 59 | + */ |
|
| 60 | + public function getPersonalSettingsFromDB($section) { |
|
| 61 | + return $this->getSettingsFromDB(self::TABLE_PERSONAL_SETTINGS, $section); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Get the configured settings from the database for the provided table and section |
|
| 66 | + * |
|
| 67 | + * @param $table |
|
| 68 | + * @param $section |
|
| 69 | + * @return array |
|
| 70 | + */ |
|
| 71 | + private function getSettingsFromDB($table, $section) { |
|
| 72 | + $query = $this->dbc->getQueryBuilder(); |
|
| 73 | + $query->select(['class', 'priority']) |
|
| 74 | + ->from($table) |
|
| 75 | + ->where($query->expr()->eq('section', $this->dbc->getQueryBuilder()->createParameter('section'))) |
|
| 76 | + ->setParameter('section', $section); |
|
| 77 | + |
|
| 78 | + $result = $query->execute(); |
|
| 79 | + return $result->fetchAll(); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Get the configured admin sections from the database |
|
| 84 | + * |
|
| 85 | + * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 86 | + */ |
|
| 87 | + public function getAdminSectionsFromDB() { |
|
| 88 | + return $this->getSectionsFromDB('admin'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Get the configured admin sections from the database |
|
| 93 | + * |
|
| 94 | + * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 95 | + */ |
|
| 96 | + public function getPersonalSectionsFromDB() { |
|
| 97 | + return $this->getSectionsFromDB('personal'); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Get the configured sections from the database by table |
|
| 102 | + * |
|
| 103 | + * @param string $type either 'personal' or 'admin' |
|
| 104 | + * @return array[] [['class' => string, 'priority' => int], ...] |
|
| 105 | + */ |
|
| 106 | + public function getSectionsFromDB($type) { |
|
| 107 | + if($type === 'admin') { |
|
| 108 | + $sectionsTable = self::TABLE_ADMIN_SECTIONS; |
|
| 109 | + $settingsTable = self::TABLE_ADMIN_SETTINGS; |
|
| 110 | + } else if($type === 'personal') { |
|
| 111 | + $sectionsTable = self::TABLE_PERSONAL_SECTIONS; |
|
| 112 | + $settingsTable = self::TABLE_PERSONAL_SETTINGS; |
|
| 113 | + } else { |
|
| 114 | + throw new \InvalidArgumentException('"admin" or "personal" expected'); |
|
| 115 | + } |
|
| 116 | + $query = $this->dbc->getQueryBuilder(); |
|
| 117 | + $query->selectDistinct('s.class') |
|
| 118 | + ->addSelect('s.priority') |
|
| 119 | + ->from($sectionsTable, 's') |
|
| 120 | + ->from($settingsTable, 'f') |
|
| 121 | + ->where($query->expr()->eq('s.id', 'f.section')); |
|
| 122 | + $result = $query->execute(); |
|
| 123 | + return array_map(function ($row) { |
|
| 124 | + $row['priority'] = (int)$row['priority']; |
|
| 125 | + return $row; |
|
| 126 | + }, $result->fetchAll()); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @param string $table one of the Mapper::TABLE_* constants |
|
| 131 | + * @param array $values |
|
| 132 | + */ |
|
| 133 | + public function add($table, array $values) { |
|
| 134 | + $query = $this->dbc->getQueryBuilder(); |
|
| 135 | + $values = array_map(function ($value) use ($query) { |
|
| 136 | + return $query->createNamedParameter($value); |
|
| 137 | + }, $values); |
|
| 138 | + $query->insert($table)->values($values); |
|
| 139 | + $query->execute(); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * returns the registered classes in the given table |
|
| 144 | + * |
|
| 145 | + * @param string $table one of the Mapper::TABLE_* constants |
|
| 146 | + * @return string[] |
|
| 147 | + */ |
|
| 148 | + public function getClasses($table) { |
|
| 149 | + $q = $this->dbc->getQueryBuilder(); |
|
| 150 | + $resultStatement = $q->select('class') |
|
| 151 | + ->from($table) |
|
| 152 | + ->execute(); |
|
| 153 | + $data = $resultStatement->fetchAll(); |
|
| 154 | + $resultStatement->closeCursor(); |
|
| 155 | + |
|
| 156 | + return array_map(function ($row) { |
|
| 157 | + return $row['class']; |
|
| 158 | + }, $data); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Check if a class is configured in the database |
|
| 163 | + * |
|
| 164 | + * @param string $table one of the Mapper::TABLE_* constants |
|
| 165 | + * @param string $className |
|
| 166 | + * @return bool |
|
| 167 | + */ |
|
| 168 | + public function has($table, $className) { |
|
| 169 | + $query = $this->dbc->getQueryBuilder(); |
|
| 170 | + $query->select('class') |
|
| 171 | + ->from($table) |
|
| 172 | + ->where($query->expr()->eq('class', $query->createNamedParameter($className))) |
|
| 173 | + ->setMaxResults(1); |
|
| 174 | + |
|
| 175 | + $result = $query->execute(); |
|
| 176 | + $row = $result->fetch(); |
|
| 177 | + $result->closeCursor(); |
|
| 178 | + |
|
| 179 | + return (bool)$row; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * deletes an settings or admin entry from the given table |
|
| 184 | + * |
|
| 185 | + * @param string $table one of the Mapper::TABLE_* constants |
|
| 186 | + * @param string $className |
|
| 187 | + */ |
|
| 188 | + public function remove($table, $className) { |
|
| 189 | + $query = $this->dbc->getQueryBuilder(); |
|
| 190 | + $query->delete($table) |
|
| 191 | + ->where($query->expr()->eq('class', $query->createNamedParameter($className))); |
|
| 192 | + |
|
| 193 | + $query->execute(); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * @param string $table one of the Mapper::TABLE_* constants |
|
| 198 | + * @param string $idCol |
|
| 199 | + * @param string $id |
|
| 200 | + * @param array $values |
|
| 201 | + */ |
|
| 202 | + public function update($table, $idCol, $id, $values) { |
|
| 203 | + $query = $this->dbc->getQueryBuilder(); |
|
| 204 | + $query->update($table); |
|
| 205 | + foreach ($values as $key => $value) { |
|
| 206 | + $query->set($key, $query->createNamedParameter($value)); |
|
| 207 | + } |
|
| 208 | + $query |
|
| 209 | + ->where($query->expr()->eq($idCol, $query->createParameter($idCol))) |
|
| 210 | + ->setParameter($idCol, $id) |
|
| 211 | + ->execute(); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | 214 | } |