本文整理汇总了PHP中OCP\IUser类的典型用法代码示例。如果您正苦于以下问题:PHP IUser类的具体用法?PHP IUser怎么用?PHP IUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
$this->createUser('userid', 'pass');
$this->loginAsUser('userid');
$app = new Application();
$this->container = $app->getContainer();
$this->container['AppName'] = 'core';
$this->container['AvatarManager'] = $this->getMock('OCP\\IAvatarManager');
$this->container['Cache'] = $this->getMockBuilder('OC\\Cache\\File')->disableOriginalConstructor()->getMock();
$this->container['L10N'] = $this->getMock('OCP\\IL10N');
$this->container['L10N']->method('t')->will($this->returnArgument(0));
$this->container['UserManager'] = $this->getMock('OCP\\IUserManager');
$this->container['UserSession'] = $this->getMock('OCP\\IUserSession');
$this->container['Request'] = $this->getMock('OCP\\IRequest');
$this->container['UserFolder'] = $this->getMock('OCP\\Files\\Folder');
$this->container['Logger'] = $this->getMock('OCP\\ILogger');
$this->avatarMock = $this->getMock('OCP\\IAvatar');
$this->userMock = $this->getMock('OCP\\IUser');
$this->avatarController = $this->container['AvatarController'];
// Configure userMock
$this->userMock->method('getDisplayName')->willReturn('displayName');
$this->userMock->method('getUID')->willReturn('userId');
$this->container['UserManager']->method('get')->willReturnMap([['userId', $this->userMock]]);
$this->container['UserSession']->method('getUser')->willReturn($this->userMock);
$this->avatarFile = $this->getMock('OCP\\Files\\File');
$this->avatarFile->method('getContnet')->willReturn('image data');
$this->avatarFile->method('getMimeType')->willReturn('image type');
$this->avatarFile->method('getEtag')->willReturn('my etag');
}
示例2: onPostRemoveUser
public function onPostRemoveUser(IGroup $group, IUser $targetUser)
{
$targetUserId = $targetUser->getUID();
$sharesAfter = $this->getUserShares($targetUserId);
$this->propagateSharesDiff($targetUserId, $this->userShares[$targetUserId], $sharesAfter);
unset($this->userShares[$targetUserId]);
}
示例3: getHomeMountForUser
/**
* Get the cache mount for a user
*
* @param IUser $user
* @param IStorageFactory $loader
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getHomeMountForUser(IUser $user, IStorageFactory $loader)
{
$arguments = ['user' => $user];
if (\OC\Files\Cache\Storage::exists('local::' . $user->getHome() . '/')) {
$arguments['legacy'] = true;
}
return new MountPoint('\\OC\\Files\\Storage\\Home', '/' . $user->getUID(), $arguments, $loader);
}
示例4: __construct
/**
* @param IUser $user current user, must match the propagator's
* user
* @param \OC\Files\Cache\ChangePropagator $changePropagator change propagator
* initialized with a view for $user
* @param \OCP\IConfig $config
* @param PropagationManager $manager
* @param IGroupManager $groupManager
*/
public function __construct(IUser $user, $changePropagator, $config, PropagationManager $manager, IGroupManager $groupManager)
{
$this->userId = $user->getUID();
$this->user = $user;
$this->changePropagator = $changePropagator;
$this->config = $config;
$this->manager = $manager;
$this->groupManager = $groupManager;
}
示例5: runScanner
/**
* @param IUser $user
*/
protected function runScanner(IUser $user)
{
try {
$scanner = new Scanner($user->getUID(), $this->dbConnection, $this->logger);
$scanner->backgroundScan('');
} catch (\Exception $e) {
$this->logger->logException($e, ['app' => 'files']);
}
\OC_Util::tearDownFS();
}
示例6: getNode
public function getNode($isAdmin = true)
{
$this->user = $this->getMock('\\OCP\\IUser');
$this->user->expects($this->any())->method('getUID')->will($this->returnValue('testuser'));
$userSession = $this->getMock('\\OCP\\IUserSession');
$userSession->expects($this->any())->method('getUser')->will($this->returnValue($this->user));
$groupManager = $this->getMock('\\OCP\\IGroupManager');
$groupManager->expects($this->any())->method('isAdmin')->with('testuser')->will($this->returnValue($isAdmin));
return new \OCA\DAV\SystemTag\SystemTagsByIdCollection($this->tagManager, $userSession, $groupManager);
}
示例7: setUp
protected function setUp()
{
$this->shareManager = $this->getMockBuilder('OC\\Share20\\Manager')->disableOriginalConstructor()->getMock();
$this->groupManager = $this->getMock('OCP\\IGroupManager');
$this->userManager = $this->getMock('OCP\\IUserManager');
$this->request = $this->getMock('OCP\\IRequest');
$this->rootFolder = $this->getMock('OCP\\Files\\IRootFolder');
$this->urlGenerator = $this->getMock('OCP\\IURLGenerator');
$this->currentUser = $this->getMock('OCP\\IUser');
$this->currentUser->method('getUID')->willReturn('currentUser');
$this->ocs = new Share20OCS($this->shareManager, $this->groupManager, $this->userManager, $this->request, $this->rootFolder, $this->urlGenerator, $this->currentUser);
}
示例8: getMountsForUser
/**
* Get all mountpoints applicable for the user and check for shares where we need to update the etags
*
* @param \OCP\IUser $user
* @param \OCP\Files\Storage\IStorageFactory $storageFactory
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getMountsForUser(IUser $user, IStorageFactory $storageFactory)
{
$shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID());
$shares = array_filter($shares, function ($share) {
return $share['permissions'] > 0;
});
$shares = array_map(function ($share) use($user, $storageFactory) {
return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('share' => $share, 'user' => $user->getUID()), $storageFactory);
}, $shares);
// array_filter removes the null values from the array
return array_filter($shares);
}
示例9: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
{
if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) {
$uid = '';
} else {
$uid = $user->getUID();
}
$credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
if (is_array($credentials)) {
$storage->setBackendOption('user', $credentials['user']);
$storage->setBackendOption('password', $credentials['password']);
}
}
示例10: getMountsForUser
/**
* Get the cache mount for a user
*
* @param IUser $user
* @param IStorageFactory $loader
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getMountsForUser(IUser $user, IStorageFactory $loader)
{
$cacheBaseDir = $this->config->getSystemValue('cache_path', '');
if ($cacheBaseDir !== '') {
$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID();
if (!file_exists($cacheDir)) {
mkdir($cacheDir, 0770, true);
}
return [new MountPoint('\\OC\\Files\\Storage\\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir, $loader])];
} else {
return [];
}
}
示例11: runForUser
/**
* @param IUser $user
*/
public function runForUser($user)
{
$principal = 'principals/users/' . $user->getUID();
$calendars = $this->calDavBackend->getCalendarsForUser($principal);
foreach ($calendars as $calendar) {
$objects = $this->calDavBackend->getCalendarObjects($calendar['id']);
foreach ($objects as $object) {
$calObject = $this->calDavBackend->getCalendarObject($calendar['id'], $object['uri']);
$classification = $this->extractClassification($calObject['calendardata']);
$this->calDavBackend->setClassification($object['id'], $classification);
}
}
}
示例12: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
{
if (!isset($user)) {
throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
}
$uid = $user->getUID();
$credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
if (!isset($credentials)) {
throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
}
$storage->setBackendOption('user', $credentials['user']);
$storage->setBackendOption('password', $credentials['password']);
}
示例13: prepareStorageConfig
/**
* Process storage ready for mounting
*
* @param StorageConfig $storage
* @param IUser $user
*/
private function prepareStorageConfig(StorageConfig &$storage, IUser $user)
{
foreach ($storage->getBackendOptions() as $option => $value) {
$storage->setBackendOption($option, \OC_Mount_Config::setUserVars($user->getUID(), $value));
}
$objectStore = $storage->getBackendOption('objectstore');
if ($objectStore) {
$objectClass = $objectStore['class'];
$storage->setBackendOption('objectstore', new $objectClass($objectStore));
}
$storage->getAuthMechanism()->manipulateStorageConfig($storage);
$storage->getBackend()->manipulateStorageConfig($storage);
}
示例14: getMountsForUser
/**
* Get all mountpoints applicable for the user and check for shares where we need to update the etags
*
* @param \OCP\IUser $user
* @param \OCP\Files\Storage\IStorageFactory $storageFactory
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getMountsForUser(IUser $user, IStorageFactory $storageFactory)
{
$shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1);
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1));
$shares = array_filter($shares, function (\OCP\Share\IShare $share) {
return $share->getPermissions() > 0;
});
$mounts = [];
foreach ($shares as $share) {
$mounts[] = new SharedMount('\\OC\\Files\\Storage\\Shared', $mounts, ['user' => $user->getUID(), 'newShare' => $share], $storageFactory);
}
// array_filter removes the null values from the array
return array_filter($mounts);
}
示例15: testMergeShares
/**
* Tests merging shares.
*
* Happens when sharing the same entry to a user through multiple ways,
* like several groups and also direct shares at the same time.
*
* @dataProvider mergeSharesDataProvider
*
* @param array $userShares array of user share specs
* @param array $groupShares array of group share specs
* @param array $expectedShares array of expected supershare specs
*/
public function testMergeShares($userShares, $groupShares, $expectedShares)
{
$rootFolder = $this->getMock('\\OCP\\Files\\IRootFolder');
$userManager = $this->getMock('\\OCP\\IUserManager');
$userShares = array_map(function ($shareSpec) {
return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]);
}, $userShares);
$groupShares = array_map(function ($shareSpec) {
return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]);
}, $groupShares);
$this->user->expects($this->any())->method('getUID')->will($this->returnValue('user1'));
$this->shareManager->expects($this->at(0))->method('getSharedWith')->with('user1', \OCP\Share::SHARE_TYPE_USER)->will($this->returnValue($userShares));
$this->shareManager->expects($this->at(1))->method('getSharedWith')->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)->will($this->returnValue($groupShares));
$this->shareManager->expects($this->any())->method('newShare')->will($this->returnCallback(function () use($rootFolder, $userManager) {
return new \OC\Share20\Share($rootFolder, $userManager);
}));
$mounts = $this->provider->getMountsForUser($this->user, $this->loader);
$this->assertCount(count($expectedShares), $mounts);
foreach ($mounts as $index => $mount) {
$expectedShare = $expectedShares[$index];
$this->assertInstanceOf('OCA\\Files_Sharing\\SharedMount', $mount);
// supershare
$share = $mount->getShare();
$this->assertEquals($expectedShare[0], $share->getId());
$this->assertEquals($expectedShare[1], $share->getNodeId());
$this->assertEquals($expectedShare[2], $share->getShareOwner());
$this->assertEquals($expectedShare[3], $share->getTarget());
$this->assertEquals($expectedShare[4], $share->getPermissions());
}
}