summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-12-01 14:33:22 +0100
committerJoas Schilling <coding@schilljs.com>2020-12-07 14:19:37 +0100
commitda9462b482c77b71d6623be43a6aa1eda3d7cc06 (patch)
treefe78e9c97f50180140fb222a8a0c41c3fcd8ddd8 /apps/provisioning_api
parenteab710c2fd6febbf946be3ce8376fb386b61ee90 (diff)
downloadnextcloud-server-da9462b482c77b71d6623be43a6aa1eda3d7cc06.tar.gz
nextcloud-server-da9462b482c77b71d6623be43a6aa1eda3d7cc06.zip
Make code strict
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/AUserData.php13
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php49
-rw-r--r--apps/provisioning_api/tests/Controller/GroupsControllerTest.php9
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php49
4 files changed, 62 insertions, 58 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php
index 131db91add9..b7b31b18b53 100644
--- a/apps/provisioning_api/lib/Controller/AUserData.php
+++ b/apps/provisioning_api/lib/Controller/AUserData.php
@@ -35,6 +35,7 @@ use OC\Accounts\AccountManager;
use OC\User\Backend;
use OC\User\NoUserException;
use OC_Helper;
+use OCP\Accounts\IAccountManager;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
@@ -135,12 +136,12 @@ abstract class AUserData extends OCSController {
$data['backend'] = $targetUserObject->getBackendClassName();
$data['subadmin'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID());
$data['quota'] = $this->fillStorageInfo($targetUserObject->getUID());
- $data[AccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress();
- $data[AccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName();
- $data[AccountManager::PROPERTY_PHONE] = $userAccount[AccountManager::PROPERTY_PHONE]['value'];
- $data[AccountManager::PROPERTY_ADDRESS] = $userAccount[AccountManager::PROPERTY_ADDRESS]['value'];
- $data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value'];
- $data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value'];
+ $data[IAccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress();
+ $data[IAccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName();
+ $data[IAccountManager::PROPERTY_PHONE] = $userAccount[IAccountManager::PROPERTY_PHONE]['value'];
+ $data[IAccountManager::PROPERTY_ADDRESS] = $userAccount[IAccountManager::PROPERTY_ADDRESS]['value'];
+ $data[IAccountManager::PROPERTY_WEBSITE] = $userAccount[IAccountManager::PROPERTY_WEBSITE]['value'];
+ $data[IAccountManager::PROPERTY_TWITTER] = $userAccount[IAccountManager::PROPERTY_TWITTER]['value'];
$data['groups'] = $gids;
$data['language'] = $this->l10nFactory->getUserLanguage($targetUserObject);
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index fd143a0e466..ddde254ed41 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -46,6 +46,7 @@ use OC\Authentication\Token\RemoteWipe;
use OC\HintException;
use OCA\Provisioning_API\FederatedShareProviderFactory;
use OCA\Settings\Mailer\NewUserMailHelper;
+use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
@@ -431,17 +432,17 @@ class UsersController extends AUserData {
// Editing self (display, email)
if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) {
- $permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME;
- $permittedFields[] = AccountManager::PROPERTY_EMAIL;
+ $permittedFields[] = IAccountManager::PROPERTY_DISPLAYNAME;
+ $permittedFields[] = IAccountManager::PROPERTY_EMAIL;
}
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
$shareProvider = $this->federatedShareProviderFactory->get();
if ($shareProvider->isLookupServerUploadEnabled()) {
- $permittedFields[] = AccountManager::PROPERTY_PHONE;
- $permittedFields[] = AccountManager::PROPERTY_ADDRESS;
- $permittedFields[] = AccountManager::PROPERTY_WEBSITE;
- $permittedFields[] = AccountManager::PROPERTY_TWITTER;
+ $permittedFields[] = IAccountManager::PROPERTY_PHONE;
+ $permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
+ $permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
+ $permittedFields[] = IAccountManager::PROPERTY_TWITTER;
}
}
@@ -474,8 +475,8 @@ class UsersController extends AUserData {
// Editing self (display, email)
if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) {
$permittedFields[] = 'display';
- $permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME;
- $permittedFields[] = AccountManager::PROPERTY_EMAIL;
+ $permittedFields[] = IAccountManager::PROPERTY_DISPLAYNAME;
+ $permittedFields[] = IAccountManager::PROPERTY_EMAIL;
}
$permittedFields[] = 'password';
@@ -492,10 +493,10 @@ class UsersController extends AUserData {
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
$shareProvider = $this->federatedShareProviderFactory->get();
if ($shareProvider->isLookupServerUploadEnabled()) {
- $permittedFields[] = AccountManager::PROPERTY_PHONE;
- $permittedFields[] = AccountManager::PROPERTY_ADDRESS;
- $permittedFields[] = AccountManager::PROPERTY_WEBSITE;
- $permittedFields[] = AccountManager::PROPERTY_TWITTER;
+ $permittedFields[] = IAccountManager::PROPERTY_PHONE;
+ $permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
+ $permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
+ $permittedFields[] = IAccountManager::PROPERTY_TWITTER;
}
}
@@ -510,15 +511,15 @@ class UsersController extends AUserData {
|| $subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
// They have permissions over the user
$permittedFields[] = 'display';
- $permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME;
- $permittedFields[] = AccountManager::PROPERTY_EMAIL;
+ $permittedFields[] = IAccountManager::PROPERTY_DISPLAYNAME;
+ $permittedFields[] = IAccountManager::PROPERTY_EMAIL;
$permittedFields[] = 'password';
$permittedFields[] = 'language';
$permittedFields[] = 'locale';
- $permittedFields[] = AccountManager::PROPERTY_PHONE;
- $permittedFields[] = AccountManager::PROPERTY_ADDRESS;
- $permittedFields[] = AccountManager::PROPERTY_WEBSITE;
- $permittedFields[] = AccountManager::PROPERTY_TWITTER;
+ $permittedFields[] = IAccountManager::PROPERTY_PHONE;
+ $permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
+ $permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
+ $permittedFields[] = IAccountManager::PROPERTY_TWITTER;
$permittedFields[] = 'quota';
} else {
// No rights
@@ -532,7 +533,7 @@ class UsersController extends AUserData {
// Process the edit
switch ($key) {
case 'display':
- case AccountManager::PROPERTY_DISPLAYNAME:
+ case IAccountManager::PROPERTY_DISPLAYNAME:
$targetUser->setDisplayName($value);
break;
case 'quota':
@@ -577,17 +578,17 @@ class UsersController extends AUserData {
}
$this->config->setUserValue($targetUser->getUID(), 'core', 'locale', $value);
break;
- case AccountManager::PROPERTY_EMAIL:
+ case IAccountManager::PROPERTY_EMAIL:
if (filter_var($value, FILTER_VALIDATE_EMAIL) || $value === '') {
$targetUser->setEMailAddress($value);
} else {
throw new OCSException('', 102);
}
break;
- case AccountManager::PROPERTY_PHONE:
- case AccountManager::PROPERTY_ADDRESS:
- case AccountManager::PROPERTY_WEBSITE:
- case AccountManager::PROPERTY_TWITTER:
+ case IAccountManager::PROPERTY_PHONE:
+ case IAccountManager::PROPERTY_ADDRESS:
+ case IAccountManager::PROPERTY_WEBSITE:
+ case IAccountManager::PROPERTY_TWITTER:
$userAccount = $this->accountManager->getUser($targetUser);
if ($userAccount[$key]['value'] !== $value) {
$userAccount[$key]['value'] = $value;
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
index 1973e6f8b6a..bb8ec854390 100644
--- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
@@ -35,6 +35,7 @@ use OC\Group\Manager;
use OC\SubAdmin;
use OC\User\NoUserException;
use OCA\Provisioning_API\Controller\GroupsController;
+use OCP\Accounts\IAccountManager;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IRequest;
@@ -185,10 +186,10 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getUser')
->willReturnCallback(function (IUser $user) {
return [
- AccountManager::PROPERTY_PHONE => ['value' => '0800-call-' . $user->getUID()],
- AccountManager::PROPERTY_ADDRESS => ['value' => 'Holzweg 99, 0601 Herrera, Panama'],
- AccountManager::PROPERTY_WEBSITE => ['value' => 'https://' . $user->getUid() . '.pa'],
- AccountManager::PROPERTY_TWITTER => ['value' => '@' . $user->getUID()],
+ IAccountManager::PROPERTY_PHONE => ['value' => '0800-call-' . $user->getUID()],
+ IAccountManager::PROPERTY_ADDRESS => ['value' => 'Holzweg 99, 0601 Herrera, Panama'],
+ IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://' . $user->getUid() . '.pa'],
+ IAccountManager::PROPERTY_TWITTER => ['value' => '@' . $user->getUID()],
];
});
}
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index d508670d4f6..8bc60551005 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -48,6 +48,7 @@ use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Provisioning_API\Controller\UsersController;
use OCA\Provisioning_API\FederatedShareProviderFactory;
use OCA\Settings\Mailer\NewUserMailHelper;
+use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\DataResponse;
use OCP\EventDispatcher\IEventDispatcher;
@@ -993,10 +994,10 @@ class UsersControllerTest extends TestCase {
->with($targetUser)
->willReturn(
[
- AccountManager::PROPERTY_ADDRESS => ['value' => 'address'],
- AccountManager::PROPERTY_PHONE => ['value' => 'phone'],
- AccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
- AccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ADDRESS => ['value' => 'address'],
+ IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
+ IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
+ IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
]
);
$this->config
@@ -1162,10 +1163,10 @@ class UsersControllerTest extends TestCase {
->with($targetUser)
->willReturn(
[
- AccountManager::PROPERTY_ADDRESS => ['value' => 'address'],
- AccountManager::PROPERTY_PHONE => ['value' => 'phone'],
- AccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
- AccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ADDRESS => ['value' => 'address'],
+ IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
+ IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
+ IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
]
);
@@ -1333,10 +1334,10 @@ class UsersControllerTest extends TestCase {
->with($targetUser)
->willReturn(
[
- AccountManager::PROPERTY_ADDRESS => ['value' => 'address'],
- AccountManager::PROPERTY_PHONE => ['value' => 'phone'],
- AccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
- AccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ADDRESS => ['value' => 'address'],
+ IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
+ IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
+ IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
]
);
@@ -3566,22 +3567,22 @@ class UsersControllerTest extends TestCase {
return [
[false, false, []],
[false, true, [
- AccountManager::PROPERTY_PHONE,
- AccountManager::PROPERTY_ADDRESS,
- AccountManager::PROPERTY_WEBSITE,
- AccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_PHONE,
+ IAccountManager::PROPERTY_ADDRESS,
+ IAccountManager::PROPERTY_WEBSITE,
+ IAccountManager::PROPERTY_TWITTER,
]],
[ true, false, [
- AccountManager::PROPERTY_DISPLAYNAME,
- AccountManager::PROPERTY_EMAIL,
+ IAccountManager::PROPERTY_DISPLAYNAME,
+ IAccountManager::PROPERTY_EMAIL,
]],
[ true, true ,[
- AccountManager::PROPERTY_DISPLAYNAME,
- AccountManager::PROPERTY_EMAIL,
- AccountManager::PROPERTY_PHONE,
- AccountManager::PROPERTY_ADDRESS,
- AccountManager::PROPERTY_WEBSITE,
- AccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_DISPLAYNAME,
+ IAccountManager::PROPERTY_EMAIL,
+ IAccountManager::PROPERTY_PHONE,
+ IAccountManager::PROPERTY_ADDRESS,
+ IAccountManager::PROPERTY_WEBSITE,
+ IAccountManager::PROPERTY_TWITTER,
]]
];
}