diff options
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 41 | ||||
-rw-r--r-- | apps/provisioning_api/tests/Controller/UsersControllerTest.php | 12 |
2 files changed, 37 insertions, 16 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 0ccbc978a69..9684c7f5656 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -296,12 +296,12 @@ class UsersController extends OCSController { // Find the data $data['id'] = $targetUserObject->getUID(); $data['quota'] = $this->fillStorageInfo($userId); - $data['email'] = $targetUserObject->getEMailAddress(); - $data['displayname'] = $targetUserObject->getDisplayName(); - $data['phone'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_PHONE]['value']; - $data['address'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_ADDRESS]['value']; - $data['webpage'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_WEBSITE]['value']; - $data['twitter'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_TWITTER]['value']; + $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['groups'] = $gids; return $data; @@ -333,8 +333,13 @@ class UsersController extends OCSController { if($userId === $currentLoggedInUser->getUID()) { // Editing self (display, email) $permittedFields[] = 'display'; - $permittedFields[] = 'email'; + $permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME; + $permittedFields[] = AccountManager::PROPERTY_EMAIL; $permittedFields[] = 'password'; + $permittedFields[] = AccountManager::PROPERTY_PHONE; + $permittedFields[] = AccountManager::PROPERTY_ADDRESS; + $permittedFields[] = AccountManager::PROPERTY_WEBSITE; + $permittedFields[] = AccountManager::PROPERTY_TWITTER; // If admin they can edit their own quota if($this->groupManager->isAdmin($currentLoggedInUser->getUID())) { $permittedFields[] = 'quota'; @@ -346,9 +351,14 @@ class UsersController extends OCSController { || $this->groupManager->isAdmin($currentLoggedInUser->getUID())) { // They have permissions over the user $permittedFields[] = 'display'; - $permittedFields[] = 'quota'; + $permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME; + $permittedFields[] = AccountManager::PROPERTY_EMAIL; $permittedFields[] = 'password'; - $permittedFields[] = 'email'; + $permittedFields[] = AccountManager::PROPERTY_PHONE; + $permittedFields[] = AccountManager::PROPERTY_ADDRESS; + $permittedFields[] = AccountManager::PROPERTY_WEBSITE; + $permittedFields[] = AccountManager::PROPERTY_TWITTER; + $permittedFields[] = 'quota'; } else { // No rights throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); @@ -361,6 +371,7 @@ class UsersController extends OCSController { // Process the edit switch($key) { case 'display': + case AccountManager::PROPERTY_DISPLAYNAME: $targetUser->setDisplayName($value); break; case 'quota': @@ -387,13 +398,23 @@ class UsersController extends OCSController { case 'password': $targetUser->setPassword($value); break; - case 'email': + case AccountManager::PROPERTY_EMAIL: if(filter_var($value, FILTER_VALIDATE_EMAIL)) { $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: + $userAccount = $this->accountManager->getUser($targetUser); + if ($userAccount[$key]['value'] !== $value) { + $userAccount[$key]['value'] = $value; + $this->accountManager->updateUser($targetUser, $userAccount); + } + break; default: throw new OCSException('', 103); } diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 0cbcccebf6f..24516840a7a 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -729,7 +729,7 @@ class UsersControllerTest extends TestCase { 'displayname' => 'Demo User', 'phone' => 'phone', 'address' => 'address', - 'webpage' => 'website', + 'website' => 'website', 'twitter' => 'twitter', 'groups' => ['group0', 'group1', 'group2'] ]; @@ -818,7 +818,7 @@ class UsersControllerTest extends TestCase { 'displayname' => 'Demo User', 'phone' => 'phone', 'address' => 'address', - 'webpage' => 'website', + 'website' => 'website', 'twitter' => 'twitter', 'groups' => [] ]; @@ -947,7 +947,7 @@ class UsersControllerTest extends TestCase { 'displayname' => 'Subadmin User', 'phone' => 'phone', 'address' => 'address', - 'webpage' => 'website', + 'website' => 'website', 'twitter' => 'twitter', 'groups' => [] ]; @@ -2632,7 +2632,7 @@ class UsersControllerTest extends TestCase { 'displayname' => 'Demo User', 'phone' => 'phone', 'address' => 'address', - 'webpage' => 'website', + 'website' => 'website', 'twitter' => 'twitter' ] ); @@ -2644,7 +2644,7 @@ class UsersControllerTest extends TestCase { 'email' => 'demo@owncloud.org', 'phone' => 'phone', 'address' => 'address', - 'webpage' => 'website', + 'website' => 'website', 'twitter' => 'twitter', 'display-name' => 'Demo User' ]; @@ -2693,7 +2693,7 @@ class UsersControllerTest extends TestCase { 'email' => 'demo@owncloud.org', 'phone' => 'phone', 'address' => 'address', - 'webpage' => 'website', + 'website' => 'website', 'twitter' => 'twitter', 'displayname' => 'Demo User' ]; |