2013-02-22 16:21:57 +00:00
|
|
|
<?php
|
|
|
|
// Check if we are a user
|
|
|
|
|
|
|
|
OCP\JSON::callCheck();
|
|
|
|
OC_JSON::checkLoggedIn();
|
|
|
|
|
2013-04-23 19:45:12 +00:00
|
|
|
$l=OC_L10N::get('core');
|
|
|
|
|
2013-02-22 16:21:57 +00:00
|
|
|
$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
|
|
|
|
$displayName = $_POST["displayName"];
|
|
|
|
|
|
|
|
$userstatus = null;
|
|
|
|
if(OC_User::isAdminUser(OC_User::getUser())) {
|
|
|
|
$userstatus = 'admin';
|
|
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return Success story
|
|
|
|
if( OC_User::setDisplayName( $username, $displayName )) {
|
2013-04-23 21:31:35 +00:00
|
|
|
OC_JSON::success(array("data" => array( "message" => $l->t('Your display name has been changed.'), "username" => $username, 'displayName' => $displayName )));
|
2013-02-22 16:21:57 +00:00
|
|
|
}
|
|
|
|
else{
|
2013-02-21 23:49:44 +00:00
|
|
|
OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change display name"), 'displayName' => OC_User::getDisplayName($username) )));
|
|
|
|
}
|