2013-01-30 00:52:03 +04:00
|
|
|
<?php
|
|
|
|
// Check if we are a user
|
2013-02-06 14:38:03 +04:00
|
|
|
|
2013-01-30 00:52:03 +04:00
|
|
|
OCP\JSON::callCheck();
|
|
|
|
OC_JSON::checkLoggedIn();
|
|
|
|
|
|
|
|
$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
|
|
|
|
$displayName = $_POST["displayName"];
|
|
|
|
|
2013-01-30 01:20:15 +04:00
|
|
|
$userstatus = null;
|
|
|
|
if(OC_User::isAdminUser(OC_User::getUser())) {
|
|
|
|
$userstatus = 'admin';
|
|
|
|
}
|
|
|
|
if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
|
|
|
|
$userstatus = 'subadmin';
|
|
|
|
}
|
|
|
|
|
2013-02-10 17:43:31 +04:00
|
|
|
if ($username == OC_User::getUser() && OC_User::canUserChangeDisplayName($username)) {
|
|
|
|
$userstatus = 'changeOwnDisplayName';
|
|
|
|
}
|
|
|
|
|
2013-01-30 01:20:15 +04:00
|
|
|
if(is_null($userstatus)) {
|
2013-02-06 14:55:19 +04:00
|
|
|
OC_JSON::error( array( "data" => array( "message" => $l->t("Authentication error") )));
|
2013-01-30 01:20:15 +04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2013-01-30 00:52:03 +04:00
|
|
|
// Return Success story
|
|
|
|
if( OC_User::setDisplayName( $username, $displayName )) {
|
2013-02-06 14:38:03 +04:00
|
|
|
OC_JSON::success(array("data" => array( "username" => $username, 'displayName' => $displayName )));
|
2013-01-30 00:52:03 +04:00
|
|
|
}
|
|
|
|
else{
|
2013-02-06 14:55:19 +04:00
|
|
|
OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change display name"), displayName => OC_User::getDisplayName($username) )));
|
2013-01-30 00:52:03 +04:00
|
|
|
}
|