示例#1
0
OCP\JSON::callCheck();
OC_JSON::checkLoggedIn();
$l = \OC::$server->getL10N('settings');
$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
$displayName = (string) $_POST["displayName"];
$userstatus = null;
if (OC_User::isAdminUser(OC_User::getUser())) {
    $userstatus = 'admin';
}
$isUserAccessible = false;
$subadminUserObject = \OC::$server->getUserManager()->get(\OC_User::getUser());
$targetUserObject = \OC::$server->getUserManager()->get($username);
if ($subadminUserObject !== null && $targetUserObject !== null) {
    $isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($subadminUserObject, $targetUserObject);
}
if ($isUserAccessible) {
    $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)) {
    OC_JSON::success(array("data" => array("message" => $l->t('Your full name has been changed.'), "username" => $username, 'displayName' => $displayName)));
} else {
    OC_JSON::error(array("data" => array("message" => $l->t("Unable to change full name"), 'displayName' => OC_User::getDisplayName($username))));
}
示例#2
0
文件: personal.php 项目: nseps/core
    /** @var \OCA\Files_External\Service\BackendService $backendService */
    $backendService = \OC_Mount_Config::$app->getContainer()->query('\\OCA\\Files_External\\Service\\BackendService');
    $enableCertImport = $backendService->isUserMountingAllowed();
}
// Return template
$tmpl = new OC_Template('settings', 'personal', 'user');
$tmpl->assign('usage', OC_Helper::humanFileSize($storageInfo['used']));
$tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total']));
$tmpl->assign('usage_relative', $storageInfo['relative']);
$tmpl->assign('clients', $clients);
$tmpl->assign('email', $email);
$tmpl->assign('languages', $languages);
$tmpl->assign('commonlanguages', $commonLanguages);
$tmpl->assign('activelanguage', $userLang);
$tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
$tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
$tmpl->assign('displayName', OC_User::getDisplayName());
$tmpl->assign('enableAvatars', $config->getSystemValue('enable_avatars', true));
$tmpl->assign('avatarChangeSupported', OC_User::canUserChangeAvatar(OC_User::getUser()));
$tmpl->assign('certs', $certificateManager->listCertificates());
$tmpl->assign('showCertificates', $enableCertImport);
$tmpl->assign('urlGenerator', $urlGenerator);
// Get array of group ids for this user
$groups = \OC::$server->getGroupManager()->getUserIdGroups(OC_User::getUser());
$groups2 = array_map(function ($group) {
    return $group->getGID();
}, $groups);
sort($groups2);
$tmpl->assign('groups', $groups2);
// add hardcoded forms from the template
$l = \OC::$server->getL10N('settings');