2013-02-22 16:21:57 +00:00
|
|
|
<?php
|
2015-03-26 10:44:34 +00:00
|
|
|
/**
|
|
|
|
* @author Bart Visscher <bartv@thisnet.nl>
|
|
|
|
* @author Christopher Schäpers <kondou@ts.unde.re>
|
|
|
|
* @author David Reagan <reagand@lanecc.edu>
|
|
|
|
* @author Jan-Christoph Borchardt <hey@jancborchardt.net>
|
|
|
|
* @author Lukas Reschke <lukas@owncloud.com>
|
|
|
|
* @author Robin Appelman <icewind@owncloud.com>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
2013-02-22 16:21:57 +00:00
|
|
|
// Check if we are a user
|
|
|
|
|
|
|
|
OCP\JSON::callCheck();
|
|
|
|
OC_JSON::checkLoggedIn();
|
|
|
|
|
2014-08-31 08:05:59 +00:00
|
|
|
$l = \OC::$server->getL10N('settings');
|
2013-04-23 19:45:12 +00:00
|
|
|
|
2013-02-22 16:21:57 +00:00
|
|
|
$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
|
2015-02-13 12:33:20 +00:00
|
|
|
$displayName = (string)$_POST["displayName"];
|
2013-02-22 16:21:57 +00:00
|
|
|
|
|
|
|
$userstatus = null;
|
|
|
|
if(OC_User::isAdminUser(OC_User::getUser())) {
|
|
|
|
$userstatus = 'admin';
|
|
|
|
}
|
|
|
|
if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
|
|
|
|
$userstatus = 'subadmin';
|
|
|
|
}
|
|
|
|
|
2013-04-17 13:32:03 +00:00
|
|
|
if ($username === OC_User::getUser() && OC_User::canUserChangeDisplayName($username)) {
|
2013-02-22 16:21:57 +00:00
|
|
|
$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-11-06 13:20:43 +00:00
|
|
|
OC_JSON::success(array("data" => array( "message" => $l->t('Your full name has been changed.'), "username" => $username, 'displayName' => $displayName )));
|
2013-02-22 16:21:57 +00:00
|
|
|
}
|
|
|
|
else{
|
2013-11-06 13:20:43 +00:00
|
|
|
OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change full name"), 'displayName' => OC_User::getDisplayName($username) )));
|
2013-02-21 23:49:44 +00:00
|
|
|
}
|