}
$shareTmpl = [];
- $shareTmpl['displayName'] = $share->getShareOwner()->getDisplayName();
- $shareTmpl['owner'] = $share->getShareOwner()->getUID();
+ $shareTmpl['displayName'] = $this->userManager->get($share->getShareOwner())->getDisplayName();
+ $shareTmpl['owner'] = $share->getShareOwner();
$shareTmpl['filename'] = $share->getNode()->getName();
$shareTmpl['directory_path'] = $share->getTarget();
$shareTmpl['mimetype'] = $share->getNode()->getMimetype();
}
}
- $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID());
+ $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
$originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath());
// Single file share
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($share->getNode()->getPath())])
- ->setAffectedUser($share->getShareOwner()->getUID())
+ ->setAffectedUser($share->getShareOwner())
->setObject('files', $share->getNode()->getId(), $userFolder->getRelativePath($share->getNode()->getPath()));
$this->activityManager->publish($event);
}
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($node->getPath())])
- ->setAffectedUser($share->getShareOwner()->getUID())
+ ->setAffectedUser($share->getShareOwner())
->setObject('files', $node->getId(), $userFolder->getRelativePath($node->getPath()));
$this->activityManager->publish($event);
} else if (!empty($files_list)) {
$event = $this->activityManager->generateEvent();
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
- ->setAffectedUser($share->getShareOwner()->getUID())
+ ->setAffectedUser($share->getShareOwner())
->setObject('files', $subNode->getId(), $userFolder->getRelativePath($subNode->getPath()));
if ($subNode instanceof \OCP\Files\File) {
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED, [$userFolder->getRelativePath($node->getPath())])
- ->setAffectedUser($share->getShareOwner()->getUID())
+ ->setAffectedUser($share->getShareOwner())
->setObject('files', $node->getId(), $userFolder->getRelativePath($node->getPath()));
$this->activityManager->publish($event);
}
/* FIXME: We should do this all nicely in OCP */
OC_Util::tearDownFS();
- OC_Util::setupFS($share->getShareOwner()->getUID());
+ OC_Util::setupFS($share->getShareOwner());
/**
* this sets a cookie to be able to recognize the start of the download
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\ISession;
+use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use OCP\IURLGenerator;
private $config;
/** @var \OC\Share20\Manager | \PHPUnit_Framework_MockObject_MockObject */
private $shareManager;
+ /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject */
+ private $userManager;
protected function setUp() {
$this->appName = 'files_sharing';
$this->session = $this->getMock('\OCP\ISession');
$this->previewManager = $this->getMock('\OCP\IPreview');
$this->config = $this->getMock('\OCP\IConfig');
+ $this->userManager = $this->getMock('\OCP\IUserManager');
$this->shareController = new \OCA\Files_Sharing\Controllers\ShareController(
$this->appName,
$this->getMock('\OCP\IRequest'),
$this->config,
$this->urlGenerator,
- $this->getMock('\OCP\IUserManager'),
+ $this->userManager,
$this->getMock('\OCP\ILogger'),
$this->getMock('\OCP\Activity\IManager'),
$this->shareManager,
}
public function testShowAuthenticateNotAuthenticated() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = \OC::$server->getShareManager()->newShare();
$this->shareManager
->expects($this->once())
}
public function testShowAuthenticateAuthenticatedForDifferentShare() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(1);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(1);
$this->shareManager
->expects($this->once())
}
public function testShowAuthenticateCorrectShare() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(1);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(1);
$this->shareManager
->expects($this->once())
}
public function testAuthenticateValidPassword() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(42);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(42);
$this->shareManager
->expects($this->once())
}
public function testAuthenticateInvalidPassword() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(42);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(42);
$this->shareManager
->expects($this->once())
}
public function testShowShareNotAuthenticated() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getPassword')->willReturn('password');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setPassword('password');
$this->shareManager
->expects($this->once())
$file->method('getMimetype')->willReturn('text/plain');
$file->method('getSize')->willReturn(33);
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn('42');
- $share->method('getPassword')->willReturn('password');
- $share->method('getShareOwner')->willReturn($owner);
- $share->method('getNode')->willReturn($file);
- $share->method('getTarget')->willReturn('/file1.txt');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(42);
+ $share->setPassword('password')
+ ->setShareOwner('ownerUID')
+ ->setNode($file)
+ ->setTarget('/file1.txt');
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
$this->session->method('get')->with('public_link_authenticated')->willReturn('42');
->with('token')
->willReturn($share);
+ $this->userManager->method('get')->with('ownerUID')->willReturn($owner);
+
$response = $this->shareController->showShare('token');
$sharedTmplParams = array(
'displayName' => 'ownerDisplay',