diff --git a/config/config.sample.php b/config/config.sample.php index cfef3d5117dd51220f9ba0ea7d5ac384a48e96d0..2f394c41a3bdc8a044659817a223c5b647713ab6 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -114,6 +114,9 @@ $CONFIG = array( /* How long should ownCloud keep deleted files in the trash bin, default value: 180 days */ 'trashbin_retention_obligation' => 180, +/* allow user to change his display name, if it is supported by the back-end */ +'allow_user_to_change_display_name' => true, + /* Check 3rdparty apps for malicious code fragments */ "appcodechecker" => "", diff --git a/lib/user.php b/lib/user.php index 9dc8cca97a66e8a9c2c0b5f375643477441d6de5..37b461188896fa85d4af25d38d391ef8d87b031d 100644 --- a/lib/user.php +++ b/lib/user.php @@ -445,10 +445,12 @@ class OC_User { * Check whether a specified user can change his display name */ public static function canUserChangeDisplayName($uid) { - foreach(self::$_usedBackends as $backend) { - if($backend->implementsActions(OC_USER_BACKEND_SET_DISPLAYNAME)) { - if($backend->userExists($uid)) { - return true; + if (OC_Config::getValue('allow_user_to_change_display_name', true)) { + foreach(self::$_usedBackends as $backend) { + if($backend->implementsActions(OC_USER_BACKEND_SET_DISPLAYNAME)) { + if($backend->userExists($uid)) { + return true; + } } } } diff --git a/settings/ajax/changedisplayname.php b/settings/ajax/changedisplayname.php index 8f2ff865bd5f0d3ad4f89d7c1372c87b0b1b1968..69462330765f0a6766a90be1a68d714b9697313c 100644 --- a/settings/ajax/changedisplayname.php +++ b/settings/ajax/changedisplayname.php @@ -15,6 +15,10 @@ if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { $userstatus = 'subadmin'; } +if ($username == OC_User::getUser() && OC_User::canUserChangeDisplayName($username)) { + $userstatus = 'changeOwnDisplayName'; +} + if(is_null($userstatus)) { OC_JSON::error( array( "data" => array( "message" => $l->t("Authentication error") ))); exit();