@@ -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 ();
@@ -1011,7 +1011,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
10111011 }
10121012 // Check if permitted to edit this field
10131013 if (!in_array ($ key , $ permittedFields )) {
1014- throw new OCSException ('' , 103 );
1014+ throw new OCSException ('' , 113 );
10151015 }
10161016 // Process the edit
10171017 switch ($ key ) {
@@ -1032,14 +1032,14 @@ public function editUser(string $userId, string $key, string $value): DataRespon
10321032 $ quota = \OCP \Util::computerFileSize ($ quota );
10331033 }
10341034 if ($ quota === false ) {
1035- throw new OCSException ($ this ->l10n ->t ('Invalid quota value: %1$s ' , [$ value ]), 102 );
1035+ throw new OCSException ($ this ->l10n ->t ('Invalid quota value: %1$s ' , [$ value ]), 101 );
10361036 }
10371037 if ($ quota === -1 ) {
10381038 $ quota = 'none ' ;
10391039 } else {
10401040 $ maxQuota = (int )$ this ->config ->getAppValue ('files ' , 'max_quota ' , '-1 ' );
10411041 if ($ maxQuota !== -1 && $ quota > $ maxQuota ) {
1042- throw new OCSException ($ this ->l10n ->t ('Invalid quota value. %1$s is exceeding the maximum quota ' , [$ value ]), 102 );
1042+ throw new OCSException ($ this ->l10n ->t ('Invalid quota value. %1$s is exceeding the maximum quota ' , [$ value ]), 101 );
10431043 }
10441044 $ quota = \OCP \Util::humanFileSize ($ quota );
10451045 }
@@ -1048,7 +1048,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
10481048 if ($ quota === 'none ' ) {
10491049 $ allowUnlimitedQuota = $ this ->config ->getAppValue ('files ' , 'allow_unlimited_quota ' , '1 ' ) === '1 ' ;
10501050 if (!$ allowUnlimitedQuota ) {
1051- throw new OCSException ($ this ->l10n ->t ('Unlimited quota is forbidden on this instance ' ), 102 );
1051+ throw new OCSException ($ this ->l10n ->t ('Unlimited quota is forbidden on this instance ' ), 101 );
10521052 }
10531053 }
10541054 $ targetUser ->setQuota ($ quota );
@@ -1059,33 +1059,33 @@ public function editUser(string $userId, string $key, string $value): DataRespon
10591059 case self ::USER_FIELD_PASSWORD :
10601060 try {
10611061 if (strlen ($ value ) > IUserManager::MAX_PASSWORD_LENGTH ) {
1062- throw new OCSException ($ this ->l10n ->t ('Invalid password value ' ), 102 );
1062+ throw new OCSException ($ this ->l10n ->t ('Invalid password value ' ), 101 );
10631063 }
10641064 if (!$ targetUser ->canChangePassword ()) {
1065- throw new OCSException ($ this ->l10n ->t ('Setting the password is not supported by the users backend ' ), 103 );
1065+ throw new OCSException ($ this ->l10n ->t ('Setting the password is not supported by the users backend ' ), 112 );
10661066 }
10671067 $ targetUser ->setPassword ($ value );
10681068 } catch (HintException $ e ) { // password policy error
1069- throw new OCSException ($ e ->getMessage (), 103 );
1069+ throw new OCSException ($ e ->getMessage (), 107 );
10701070 }
10711071 break ;
10721072 case self ::USER_FIELD_LANGUAGE :
10731073 $ languagesCodes = $ this ->l10nFactory ->findAvailableLanguages ();
10741074 if (!in_array ($ value , $ languagesCodes , true ) && $ value !== 'en ' ) {
1075- throw new OCSException ($ this ->l10n ->t ('Invalid language ' ), 102 );
1075+ throw new OCSException ($ this ->l10n ->t ('Invalid language ' ), 101 );
10761076 }
10771077 $ this ->config ->setUserValue ($ targetUser ->getUID (), 'core ' , 'lang ' , $ value );
10781078 break ;
10791079 case self ::USER_FIELD_LOCALE :
10801080 if (!$ this ->l10nFactory ->localeExists ($ value )) {
1081- throw new OCSException ($ this ->l10n ->t ('Invalid locale ' ), 102 );
1081+ throw new OCSException ($ this ->l10n ->t ('Invalid locale ' ), 101 );
10821082 }
10831083 $ this ->config ->setUserValue ($ targetUser ->getUID (), 'core ' , 'locale ' , $ value );
10841084 break ;
10851085 case self ::USER_FIELD_FIRST_DAY_OF_WEEK :
10861086 $ intValue = (int )$ value ;
10871087 if ($ intValue < -1 || $ intValue > 6 ) {
1088- throw new OCSException ($ this ->l10n ->t ('Invalid first day of week ' ), 102 );
1088+ throw new OCSException ($ this ->l10n ->t ('Invalid first day of week ' ), 101 );
10891089 }
10901090 if ($ intValue === -1 ) {
10911091 $ this ->config ->deleteUserValue ($ targetUser ->getUID (), 'core ' , AUserData::USER_FIELD_FIRST_DAY_OF_WEEK );
@@ -1110,14 +1110,14 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11101110 }
11111111 }
11121112 if (!$ success ) {
1113- throw new OCSException ('' , 102 );
1113+ throw new OCSException ('' , 101 );
11141114 }
11151115 break ;
11161116 case IAccountManager::PROPERTY_EMAIL :
11171117 if (filter_var ($ value , FILTER_VALIDATE_EMAIL ) || $ value === '' ) {
11181118 $ targetUser ->setEMailAddress ($ value );
11191119 } else {
1120- throw new OCSException ('' , 102 );
1120+ throw new OCSException ('' , 101 );
11211121 }
11221122 break ;
11231123 case IAccountManager::COLLECTION_EMAIL :
@@ -1126,13 +1126,13 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11261126 $ mailCollection = $ userAccount ->getPropertyCollection (IAccountManager::COLLECTION_EMAIL );
11271127
11281128 if ($ mailCollection ->getPropertyByValue ($ value )) {
1129- throw new OCSException ('' , 102 );
1129+ throw new OCSException ('' , 101 );
11301130 }
11311131
11321132 $ mailCollection ->addPropertyWithDefaults ($ value );
11331133 $ this ->accountManager ->updateAccount ($ userAccount );
11341134 } else {
1135- throw new OCSException ('' , 102 );
1135+ throw new OCSException ('' , 101 );
11361136 }
11371137 break ;
11381138 case IAccountManager::PROPERTY_PHONE :
@@ -1156,7 +1156,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11561156 $ this ->knownUserService ->deleteByContactUserId ($ targetUser ->getUID ());
11571157 }
11581158 } catch (InvalidArgumentException $ e ) {
1159- throw new OCSException ('Invalid ' . $ e ->getMessage (), 102 );
1159+ throw new OCSException ('Invalid ' . $ e ->getMessage (), 101 );
11601160 }
11611161 }
11621162 } catch (PropertyDoesNotExistException $ e ) {
@@ -1165,7 +1165,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11651165 try {
11661166 $ this ->accountManager ->updateAccount ($ userAccount );
11671167 } catch (InvalidArgumentException $ e ) {
1168- throw new OCSException ('Invalid ' . $ e ->getMessage (), 102 );
1168+ throw new OCSException ('Invalid ' . $ e ->getMessage (), 101 );
11691169 }
11701170 break ;
11711171 case IAccountManager::PROPERTY_PROFILE_ENABLED :
@@ -1203,12 +1203,12 @@ public function editUser(string $userId, string $key, string $value): DataRespon
12031203 $ userProperty ->setScope ($ value );
12041204 $ this ->accountManager ->updateAccount ($ userAccount );
12051205 } catch (InvalidArgumentException $ e ) {
1206- throw new OCSException ('Invalid ' . $ e ->getMessage (), 102 );
1206+ throw new OCSException ('Invalid ' . $ e ->getMessage (), 101 );
12071207 }
12081208 }
12091209 break ;
12101210 default :
1211- throw new OCSException ('' , 103 );
1211+ throw new OCSException ('' , 113 );
12121212 }
12131213 return new DataResponse ();
12141214 }
0 commit comments