@@ -488,7 +488,7 @@ public function addUser(
488488 $ group = $ this ->groupManager ->get ($ groupid );
489489 // Check if group exists
490490 if ($ group === null ) {
491- throw new OCSException ($ this ->l10n ->t ('Sub-admin group does not exist ' ), 102 );
491+ throw new OCSException ($ this ->l10n ->t ('Sub-admin group does not exist ' ), 109 );
492492 }
493493 // Check if trying to make subadmin of admin group
494494 if ($ group ->getGID () === 'admin ' ) {
@@ -508,7 +508,7 @@ public function addUser(
508508 }
509509 if ($ password === '' ) {
510510 if ($ email === '' ) {
511- throw new OCSException ($ this ->l10n ->t ('To send a password link to the user an email address is required . ' ), 108 );
511+ throw new OCSException ($ this ->l10n ->t ('An email address is required, to send a password link to the user. ' ), 108 );
512512 }
513513
514514 $ passwordEvent = new GenerateSecurePasswordEvent ();
@@ -1007,7 +1007,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
10071007 }
10081008 // Check if permitted to edit this field
10091009 if (!in_array ($ key , $ permittedFields )) {
1010- throw new OCSException ('' , 103 );
1010+ throw new OCSException ('' , 113 );
10111011 }
10121012 // Process the edit
10131013 switch ($ key ) {
@@ -1028,14 +1028,14 @@ public function editUser(string $userId, string $key, string $value): DataRespon
10281028 $ quota = \OCP \Util::computerFileSize ($ quota );
10291029 }
10301030 if ($ quota === false ) {
1031- throw new OCSException ($ this ->l10n ->t ('Invalid quota value: %1$s ' , [$ value ]), 102 );
1031+ throw new OCSException ($ this ->l10n ->t ('Invalid quota value: %1$s ' , [$ value ]), 101 );
10321032 }
10331033 if ($ quota === -1 ) {
10341034 $ quota = 'none ' ;
10351035 } else {
10361036 $ maxQuota = (int ) $ this ->config ->getAppValue ('files ' , 'max_quota ' , '-1 ' );
10371037 if ($ maxQuota !== -1 && $ quota > $ maxQuota ) {
1038- throw new OCSException ($ this ->l10n ->t ('Invalid quota value. %1$s is exceeding the maximum quota ' , [$ value ]), 102 );
1038+ throw new OCSException ($ this ->l10n ->t ('Invalid quota value. %1$s is exceeding the maximum quota ' , [$ value ]), 101 );
10391039 }
10401040 $ quota = \OCP \Util::humanFileSize ($ quota );
10411041 }
@@ -1044,7 +1044,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
10441044 if ($ quota === 'none ' ) {
10451045 $ allowUnlimitedQuota = $ this ->config ->getAppValue ('files ' , 'allow_unlimited_quota ' , '1 ' ) === '1 ' ;
10461046 if (!$ allowUnlimitedQuota ) {
1047- throw new OCSException ($ this ->l10n ->t ('Unlimited quota is forbidden on this instance ' ), 102 );
1047+ throw new OCSException ($ this ->l10n ->t ('Unlimited quota is forbidden on this instance ' ), 101 );
10481048 }
10491049 }
10501050 $ targetUser ->setQuota ($ quota );
@@ -1055,33 +1055,33 @@ public function editUser(string $userId, string $key, string $value): DataRespon
10551055 case self ::USER_FIELD_PASSWORD :
10561056 try {
10571057 if (strlen ($ value ) > IUserManager::MAX_PASSWORD_LENGTH ) {
1058- throw new OCSException ($ this ->l10n ->t ('Invalid password value ' ), 102 );
1058+ throw new OCSException ($ this ->l10n ->t ('Invalid password value ' ), 101 );
10591059 }
10601060 if (!$ targetUser ->canChangePassword ()) {
1061- throw new OCSException ($ this ->l10n ->t ('Setting the password is not supported by the users backend ' ), 103 );
1061+ throw new OCSException ($ this ->l10n ->t ('Setting the password is not supported by the users backend ' ), 112 );
10621062 }
10631063 $ targetUser ->setPassword ($ value );
10641064 } catch (HintException $ e ) { // password policy error
1065- throw new OCSException ($ e ->getMessage (), 103 );
1065+ throw new OCSException ($ e ->getMessage (), 107 );
10661066 }
10671067 break ;
10681068 case self ::USER_FIELD_LANGUAGE :
10691069 $ languagesCodes = $ this ->l10nFactory ->findAvailableLanguages ();
10701070 if (!in_array ($ value , $ languagesCodes , true ) && $ value !== 'en ' ) {
1071- throw new OCSException ($ this ->l10n ->t ('Invalid language ' ), 102 );
1071+ throw new OCSException ($ this ->l10n ->t ('Invalid language ' ), 101 );
10721072 }
10731073 $ this ->config ->setUserValue ($ targetUser ->getUID (), 'core ' , 'lang ' , $ value );
10741074 break ;
10751075 case self ::USER_FIELD_LOCALE :
10761076 if (!$ this ->l10nFactory ->localeExists ($ value )) {
1077- throw new OCSException ($ this ->l10n ->t ('Invalid locale ' ), 102 );
1077+ throw new OCSException ($ this ->l10n ->t ('Invalid locale ' ), 101 );
10781078 }
10791079 $ this ->config ->setUserValue ($ targetUser ->getUID (), 'core ' , 'locale ' , $ value );
10801080 break ;
10811081 case self ::USER_FIELD_FIRST_DAY_OF_WEEK :
10821082 $ intValue = (int )$ value ;
10831083 if ($ intValue < -1 || $ intValue > 6 ) {
1084- throw new OCSException ($ this ->l10n ->t ('Invalid first day of week ' ), 102 );
1084+ throw new OCSException ($ this ->l10n ->t ('Invalid first day of week ' ), 101 );
10851085 }
10861086 if ($ intValue === -1 ) {
10871087 $ this ->config ->deleteUserValue ($ targetUser ->getUID (), 'core ' , AUserData::USER_FIELD_FIRST_DAY_OF_WEEK );
@@ -1106,14 +1106,14 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11061106 }
11071107 }
11081108 if (!$ success ) {
1109- throw new OCSException ('' , 102 );
1109+ throw new OCSException ('' , 101 );
11101110 }
11111111 break ;
11121112 case IAccountManager::PROPERTY_EMAIL :
11131113 if (filter_var ($ value , FILTER_VALIDATE_EMAIL ) || $ value === '' ) {
11141114 $ targetUser ->setEMailAddress ($ value );
11151115 } else {
1116- throw new OCSException ('' , 102 );
1116+ throw new OCSException ('' , 101 );
11171117 }
11181118 break ;
11191119 case IAccountManager::COLLECTION_EMAIL :
@@ -1122,13 +1122,13 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11221122 $ mailCollection = $ userAccount ->getPropertyCollection (IAccountManager::COLLECTION_EMAIL );
11231123
11241124 if ($ mailCollection ->getPropertyByValue ($ value )) {
1125- throw new OCSException ('' , 102 );
1125+ throw new OCSException ('' , 101 );
11261126 }
11271127
11281128 $ mailCollection ->addPropertyWithDefaults ($ value );
11291129 $ this ->accountManager ->updateAccount ($ userAccount );
11301130 } else {
1131- throw new OCSException ('' , 102 );
1131+ throw new OCSException ('' , 101 );
11321132 }
11331133 break ;
11341134 case IAccountManager::PROPERTY_PHONE :
@@ -1151,7 +1151,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11511151 $ this ->knownUserService ->deleteByContactUserId ($ targetUser ->getUID ());
11521152 }
11531153 } catch (InvalidArgumentException $ e ) {
1154- throw new OCSException ('Invalid ' . $ e ->getMessage (), 102 );
1154+ throw new OCSException ('Invalid ' . $ e ->getMessage (), 101 );
11551155 }
11561156 }
11571157 } catch (PropertyDoesNotExistException $ e ) {
@@ -1160,7 +1160,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11601160 try {
11611161 $ this ->accountManager ->updateAccount ($ userAccount );
11621162 } catch (InvalidArgumentException $ e ) {
1163- throw new OCSException ('Invalid ' . $ e ->getMessage (), 102 );
1163+ throw new OCSException ('Invalid ' . $ e ->getMessage (), 101 );
11641164 }
11651165 break ;
11661166 case IAccountManager::PROPERTY_PROFILE_ENABLED :
@@ -1197,12 +1197,12 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11971197 $ userProperty ->setScope ($ value );
11981198 $ this ->accountManager ->updateAccount ($ userAccount );
11991199 } catch (InvalidArgumentException $ e ) {
1200- throw new OCSException ('Invalid ' . $ e ->getMessage (), 102 );
1200+ throw new OCSException ('Invalid ' . $ e ->getMessage (), 101 );
12011201 }
12021202 }
12031203 break ;
12041204 default :
1205- throw new OCSException ('' , 103 );
1205+ throw new OCSException ('' , 113 );
12061206 }
12071207 return new DataResponse ();
12081208 }
0 commit comments