function setUp() { parent::setUp(); \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER1, 'User One'); \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER2, 'User Two'); self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $this->user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files'); // prepare user1's dir structure $this->view->mkdir('container'); $this->view->mkdir('container/shareddir'); $this->view->mkdir('container/shareddir/subdir'); $this->view->mkdir('container/shareddir/emptydir'); $textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $this->view->file_put_contents('container/not shared.txt', $textData); $this->view->file_put_contents('container/shared single file.txt', $textData); $this->view->file_put_contents('container/shareddir/bar.txt', $textData); $this->view->file_put_contents('container/shareddir/subdir/another.txt', $textData); $this->view->file_put_contents('container/shareddir/subdir/another too.txt', $textData); $this->view->file_put_contents('container/shareddir/subdir/not a text file.xml', '<xml></xml>'); list($this->ownerStorage, $internalPath) = $this->view->resolvePath(''); $this->ownerCache = $this->ownerStorage->getCache(); $this->ownerStorage->getScanner()->scan(''); // share "shareddir" with user2 $fileinfo = $this->view->getFileInfo('container/shareddir'); \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31); $fileinfo = $this->view->getFileInfo('container/shared single file.txt'); \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31); // login as user2 self::loginHelper(self::TEST_FILES_SHARING_API_USER2); // retrieve the shared storage $secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2); list($this->sharedStorage, $internalPath) = $secondView->resolvePath('files/shareddir'); $this->sharedCache = $this->sharedStorage->getCache(); }
protected function setUp() { parent::setUp(); $this->shareManager = \OC::$server->getShareManager(); \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER1, 'User One'); \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER2, 'User Two'); self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $this->user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files'); // prepare user1's dir structure $this->view->mkdir('container'); $this->view->mkdir('container/shareddir'); $this->view->mkdir('container/shareddir/subdir'); $this->view->mkdir('container/shareddir/emptydir'); $textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $this->view->file_put_contents('container/not shared.txt', $textData); $this->view->file_put_contents('container/shared single file.txt', $textData); $this->view->file_put_contents('container/shareddir/bar.txt', $textData); $this->view->file_put_contents('container/shareddir/subdir/another.txt', $textData); $this->view->file_put_contents('container/shareddir/subdir/another too.txt', $textData); $this->view->file_put_contents('container/shareddir/subdir/not a text file.xml', '<xml></xml>'); list($this->ownerStorage, ) = $this->view->resolvePath(''); $this->ownerCache = $this->ownerStorage->getCache(); $this->ownerStorage->getScanner()->scan(''); // share "shareddir" with user2 $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1); $node = $rootFolder->get('container/shareddir'); $share = $this->shareManager->newShare(); $share->setNode($node)->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith(self::TEST_FILES_SHARING_API_USER2)->setSharedBy(self::TEST_FILES_SHARING_API_USER1)->setPermissions(\OCP\Constants::PERMISSION_ALL); $this->shareManager->createShare($share); $node = $rootFolder->get('container/shared single file.txt'); $share = $this->shareManager->newShare(); $share->setNode($node)->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith(self::TEST_FILES_SHARING_API_USER2)->setSharedBy(self::TEST_FILES_SHARING_API_USER1)->setPermissions(\OCP\Constants::PERMISSION_ALL & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE)); $this->shareManager->createShare($share); // login as user2 self::loginHelper(self::TEST_FILES_SHARING_API_USER2); // retrieve the shared storage $secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2); list($this->sharedStorage, ) = $secondView->resolvePath('files/shareddir'); $this->sharedCache = $this->sharedStorage->getCache(); }
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)))); }
private static function update_display_name($uid, $displayName) { // I inject directly into the database here rather than using the method setDisplayName(), // which doesn't work. -CB // because we're using the user_saml backend, and not the default one - see app.php. - FO //$query = OC_DB::prepare('UPDATE `*PREFIX*users` SET `displayname` = ? WHERE LOWER(`uid`) = ?'); //$query->execute(array($displayName, $uid)); OC_User::setDisplayName($uid, $displayName); }
function update_display_name($uid, $displayName) { OC_User::setDisplayName($uid, $displayName); }