Example #1
0
 public function __destruct()
 {
     $this->config->setSystemValue('singleuser', $this->wasSingleUserModeEnabled);
     if ($this->wasTrashbinEnabled) {
         $this->appManager->enableApp('files_trashbin');
     }
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') {
         $shippedFilter = $input->getOption('shipped') === 'true';
     } else {
         $shippedFilter = null;
     }
     $apps = \OC_App::getAllApps();
     $enabledApps = $disabledApps = [];
     $versions = \OC_App::getAppVersions();
     //sort enabled apps above disabled apps
     foreach ($apps as $app) {
         if ($shippedFilter !== null && \OC_App::isShipped($app) !== $shippedFilter) {
             continue;
         }
         if ($this->manager->isInstalled($app)) {
             $enabledApps[] = $app;
         } else {
             $disabledApps[] = $app;
         }
     }
     $apps = ['enabled' => [], 'disabled' => []];
     sort($enabledApps);
     foreach ($enabledApps as $app) {
         $apps['enabled'][$app] = isset($versions[$app]) ? $versions[$app] : true;
     }
     sort($disabledApps);
     foreach ($disabledApps as $app) {
         $apps['disabled'][$app] = null;
     }
     $this->writeAppList($input, $output, $apps);
 }
Example #3
0
 /**
  * Reset the single user mode and re-enable the trashbin app
  */
 protected function resetSingleUserAndTrashbin()
 {
     $this->config->setSystemValue('singleuser', $this->wasSingleUserModeEnabled);
     if ($this->wasTrashbinEnabled) {
         $this->appManager->enableApp('files_trashbin');
     }
 }
 /**
  * check if certificate import is allowed
  *
  * @return bool
  */
 protected function isCertificateImportAllowed()
 {
     $externalStorageEnabled = $this->appManager->isEnabledForUser('files_external');
     if ($externalStorageEnabled) {
         $backends = \OC_Mount_Config::getPersonalBackends();
         if (!empty($backends)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Check whether sharing is enabled
  * @return bool
  */
 private function isSharingEnabled()
 {
     // FIXME: This check is done here since the route is globally defined and not inside the files_sharing app
     // Check whether the sharing application is enabled
     if (!$this->appManager->isEnabledForUser($this->appName)) {
         return false;
     }
     // Check whether public sharing is enabled
     if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
         return false;
     }
     return true;
 }
Example #6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if ($this->manager->isInstalled($appId)) {
         try {
             $this->manager->disableApp($appId);
             $output->writeln($appId . ' disabled');
         } catch (\Exception $e) {
             $output->writeln($e->getMessage());
             return 2;
         }
     } else {
         $output->writeln('No such app enabled: ' . $appId);
     }
 }
Example #7
0
 /**
  * @return \OCP\AppFramework\Http\JSONResponse
  */
 public function buildProviderList()
 {
     $services = ['version' => 2, 'PRIVATE_DATA' => ['version' => 1, 'endpoints' => ['store' => '/ocs/v2.php/privatedata/setattribute', 'read' => '/ocs/v2.php/privatedata/getattribute', 'delete' => '/ocs/v2.php/privatedata/deleteattribute']]];
     if ($this->appManager->isEnabledForUser('files_sharing')) {
         $services['SHARING'] = ['version' => 1, 'endpoints' => ['share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares']];
         $services['FEDERATED_SHARING'] = ['version' => 1, 'endpoints' => ['share' => '/ocs/v2.php/cloud/shares', 'webdav' => '/public.php/webdav/']];
     }
     if ($this->appManager->isEnabledForUser('activity')) {
         $services['ACTIVITY'] = ['version' => 1, 'endpoints' => ['list' => '/ocs/v2.php/cloud/activity']];
     }
     if ($this->appManager->isEnabledForUser('provisioning_api')) {
         $services['PROVISIONING'] = ['version' => 1, 'endpoints' => ['user' => '/ocs/v2.php/cloud/users', 'groups' => '/ocs/v2.php/cloud/groups', 'apps' => '/ocs/v2.php/cloud/apps']];
     }
     return new \OCP\AppFramework\Http\JSONResponse($services);
 }
Example #8
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * Shows the albums and pictures at the root folder or a message if
  * there are no pictures.
  *
  * This is the entry page for logged-in users accessing the app from
  * within ownCloud.
  * A TemplateResponse response uses a template from the templates folder
  * and parameters provided here to build the page users will see
  *
  * @return TemplateResponse
  */
 public function index()
 {
     $appName = $this->appName;
     if ($this->appManager->isInstalled('gallery')) {
         $message = 'You need to disable the Pictures app before being able to use the Gallery+ app';
         return $this->htmlError($this->urlGenerator, $appName, new \Exception($message));
     } else {
         // Parameters sent to the template
         $params = ['appName' => $appName];
         // Will render the page using the template found in templates/index.php
         $response = new TemplateResponse($appName, 'index', $params);
         $this->addContentSecurityToResponse($response);
         return $response;
     }
 }
 /**
  * Redirects to the file list and highlight the given file id
  *
  * @param string $fileId file id to show
  * @return RedirectResponse redirect response or not found response
  * @throws \OCP\Files\NotFoundException
  *
  * @NoCSRFRequired
  * @NoAdminRequired
  */
 public function showFile($fileId)
 {
     $uid = $this->userSession->getUser()->getUID();
     $baseFolder = $this->rootFolder->get($uid . '/files/');
     $files = $baseFolder->getById($fileId);
     $params = [];
     if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
         $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/');
         $files = $baseFolder->getById($fileId);
         $params['view'] = 'trashbin';
     }
     if (!empty($files)) {
         $file = current($files);
         if ($file instanceof Folder) {
             // set the full path to enter the folder
             $params['dir'] = $baseFolder->getRelativePath($file->getPath());
         } else {
             // set parent path as dir
             $params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
             // and scroll to the entry
             $params['scrollto'] = $file->getName();
         }
         return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
     }
     throw new \OCP\Files\NotFoundException();
 }
Example #10
0
 /**
  * @param MapperEvent $event
  */
 public function mapperEvent(MapperEvent $event)
 {
     $tagIds = $event->getTags();
     if ($event->getObjectType() !== 'files' || empty($tagIds) || !in_array($event->getEvent(), [MapperEvent::EVENT_ASSIGN, MapperEvent::EVENT_UNASSIGN]) || !$this->appManager->isInstalled('activity')) {
         // System tags not for files, no tags, not (un-)assigning or no activity-app enabled (save the energy)
         return;
     }
     try {
         $tags = $this->tagManager->getTagsByIds($tagIds);
     } catch (TagNotFoundException $e) {
         // User assigned/unassigned a non-existing tag, ignore...
         return;
     }
     if (empty($tags)) {
         return;
     }
     // Get all mount point owners
     $cache = $this->mountCollection->getMountCache();
     $mounts = $cache->getMountsForFileId($event->getObjectId());
     if (empty($mounts)) {
         return;
     }
     $users = [];
     foreach ($mounts as $mount) {
         $owner = $mount->getUser()->getUID();
         $ownerFolder = $this->rootFolder->getUserFolder($owner);
         $nodes = $ownerFolder->getById($event->getObjectId());
         if (!empty($nodes)) {
             /** @var Node $node */
             $node = array_shift($nodes);
             $path = $node->getPath();
             if (strpos($path, '/' . $owner . '/files/') === 0) {
                 $path = substr($path, strlen('/' . $owner . '/files'));
             }
             // Get all users that have access to the mount point
             $users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
         }
     }
     $actor = $this->session->getUser();
     if ($actor instanceof IUser) {
         $actor = $actor->getUID();
     } else {
         $actor = '';
     }
     $activity = $this->activityManager->generateEvent();
     $activity->setApp(Extension::APP_NAME)->setType(Extension::APP_NAME)->setAuthor($actor)->setObject($event->getObjectType(), $event->getObjectId());
     foreach ($users as $user => $path) {
         $activity->setAffectedUser($user);
         foreach ($tags as $tag) {
             if ($event->getEvent() === MapperEvent::EVENT_ASSIGN) {
                 $activity->setSubject(Extension::ASSIGN_TAG, [$actor, $path, $this->prepareTagAsParameter($tag)]);
             } else {
                 if ($event->getEvent() === MapperEvent::EVENT_UNASSIGN) {
                     $activity->setSubject(Extension::UNASSIGN_TAG, [$actor, $path, $this->prepareTagAsParameter($tag)]);
                 }
             }
             $this->activityManager->publish($activity);
         }
     }
 }
 /**
  * Check whether sharing is enabled
  * @return bool
  */
 private function isSharingEnabled()
 {
     // FIXME: This check is done here since the route is globally defined and not inside the files_sharing app
     // Check whether the sharing application is enabled
     if (!$this->appManager->isEnabledForUser($this->appName)) {
         return false;
     }
     return true;
 }
	public function testChangeExperimentalConfigStateFalse() {
		$this->config
			->expects($this->once())
			->method('setSystemValue')
			->with('appstore.experimental.enabled', false);
		$this->appManager
			->expects($this->once())
			->method('clearAppsCache');
		$this->assertEquals(new DataResponse(), $this->appSettingsController->changeExperimentalConfigState(false));
	}
Example #13
0
 /**
  * @dataProvider dataCheckAppUpdates
  *
  * @param string[] $apps
  * @param array $isUpdateAvailable
  * @param array $notifications
  */
 public function testCheckAppUpdates(array $apps, array $isUpdateAvailable, array $notifications)
 {
     $job = $this->getJob(['isUpdateAvailable', 'createNotifications']);
     $this->appManager->expects($this->once())->method('getInstalledApps')->willReturn($apps);
     $job->expects($this->exactly(sizeof($apps)))->method('isUpdateAvailable')->willReturnMap($isUpdateAvailable);
     $this->urlGenerator->expects($this->exactly(sizeof($notifications)))->method('linkToRouteAbsolute')->with('settings.AppSettings.viewApps')->willReturn('apps-url');
     $mockedMethod = $job->expects($this->exactly(sizeof($notifications)))->method('createNotifications');
     call_user_func_array([$mockedMethod, 'withConsecutive'], $notifications);
     $this->invokePrivate($job, 'checkAppUpdates');
 }
Example #14
0
 /**
  * @param CommentsEvent $event
  */
 public function commentEvent(CommentsEvent $event)
 {
     if ($event->getComment()->getObjectType() !== 'files' || !in_array($event->getEvent(), [CommentsEvent::EVENT_ADD]) || !$this->appManager->isInstalled('activity')) {
         // Comment not for file, not adding a comment or no activity-app enabled (save the energy)
         return;
     }
     // Get all mount point owners
     $cache = $this->mountCollection->getMountCache();
     $mounts = $cache->getMountsForFileId($event->getComment()->getObjectId());
     if (empty($mounts)) {
         return;
     }
     $users = [];
     foreach ($mounts as $mount) {
         $owner = $mount->getUser()->getUID();
         $ownerFolder = $this->rootFolder->getUserFolder($owner);
         $nodes = $ownerFolder->getById($event->getComment()->getObjectId());
         if (!empty($nodes)) {
             /** @var Node $node */
             $node = array_shift($nodes);
             $path = $node->getPath();
             if (strpos($path, '/' . $owner . '/files/') === 0) {
                 $path = substr($path, strlen('/' . $owner . '/files'));
             }
             // Get all users that have access to the mount point
             $users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
         }
     }
     $actor = $this->session->getUser();
     if ($actor instanceof IUser) {
         $actor = $actor->getUID();
     } else {
         $actor = '';
     }
     $activity = $this->activityManager->generateEvent();
     $activity->setApp(Extension::APP_NAME)->setType(Extension::APP_NAME)->setAuthor($actor)->setObject($event->getComment()->getObjectType(), $event->getComment()->getObjectId())->setMessage(Extension::ADD_COMMENT_MESSAGE, [$event->getComment()->getId()]);
     foreach ($users as $user => $path) {
         $activity->setAffectedUser($user);
         $activity->setSubject(Extension::ADD_COMMENT_SUBJECT, [$actor, $path]);
         $this->activityManager->publish($activity);
     }
 }
Example #15
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appId = $input->getArgument('app-id');
     if (!\OC_App::getAppPath($appId)) {
         $output->writeln($appId . ' not found');
         return 1;
     }
     $groups = $input->getOption('groups');
     if ($this->manager->isInstalled($appId) && empty($groups)) {
         $output->writeln($appId . ' is already enabled');
     }
     if (empty($groups)) {
         \OC_App::enable($appId);
         $output->writeln($appId . ' enabled');
     } else {
         \OC_App::enable($appId, $groups);
         $output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups));
     }
     return 0;
 }
Example #16
0
 /**
  * check if certificate import is allowed
  *
  * @return bool
  */
 protected function isCertificateImportAllowed()
 {
     $externalStorageEnabled = $this->appManager->isEnabledForUser('files_external');
     if ($externalStorageEnabled) {
         $backendService = \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\BackendService');
         if ($backendService->getBackendsVisibleFor(\OCA\Files_External\Service\BackendService::VISIBILITY_PERSONAL)) {
             return true;
         }
     }
     return false;
 }
Example #17
0
 /**
  * Check all installed apps for updates
  */
 protected function checkAppUpdates()
 {
     $apps = $this->appManager->getInstalledApps();
     foreach ($apps as $app) {
         $update = $this->isUpdateAvailable($app);
         if ($update !== false) {
             $url = $this->urlGenerator->linkToRouteAbsolute('settings.AppSettings.viewApps') . '#app-' . $app;
             $this->createNotifications($app, $update, $url);
         }
     }
 }
 /**
  * check if certificate import is allowed
  *
  * @return bool
  */
 protected function isCertificateImportAllowed()
 {
     $externalStorageEnabled = $this->appManager->isEnabledForUser('files_external');
     if ($externalStorageEnabled) {
         /** @var \OCA\Files_External\Service\BackendService $backendService */
         $backendService = \OC_Mount_Config::$app->getContainer()->query('\\OCA\\Files_External\\Service\\BackendService');
         if ($backendService->isUserMountingAllowed()) {
             return true;
         }
     }
     return false;
 }
Example #19
0
	public function testGetAppsForUser() {
		$user = new User('user1', null);
		$this->groupManager->expects($this->any())
			->method('getUserGroupIds')
			->with($user)
			->will($this->returnValue(array('foo', 'bar')));

		$this->appConfig->setValue('test1', 'enabled', 'yes');
		$this->appConfig->setValue('test2', 'enabled', 'no');
		$this->appConfig->setValue('test3', 'enabled', '["foo"]');
		$this->appConfig->setValue('test4', 'enabled', '["asd"]');
		$this->assertEquals(['test1', 'test3'], $this->manager->getEnabledAppsForUser($user));
	}
Example #20
0
	public function testBuildProviderListWithEverythingEnabled() {
		$this->appManager
			->expects($this->any())
			->method('isEnabledForUser')
			->will($this->returnValue(true));

		$expected = new \OCP\AppFramework\Http\JSONResponse(
			[
				'version' => 2,
				'PRIVATE_DATA' => [
					'version' => 1,
					'endpoints' => [
						'store' => '/ocs/v1.php/privatedata/setattribute',
						'read' => '/ocs/v1.php/privatedata/getattribute',
						'delete' => '/ocs/v1.php/privatedata/deleteattribute',
					],
				],
				'FEDERATED_SHARING' => [
					'version' => 1,
					'endpoints' => [
						'share' => '/ocs/v1.php/cloud/shares',
						'webdav' => '/public.php/webdav/',
					],
				],
				'SHARING' => [
					'version' => 1,
					'endpoints' => [
						'share' => '/ocs/v1.php/apps/files_sharing/api/v1/shares',
					],
				],
				'ACTIVITY' => [
					'version' => 1,
					'endpoints' => [
						'list' => '/ocs/v1.php/cloud/activity',
					],
				],
				'PROVISIONING' => [
					'version' => 1,
					'endpoints' => [
						'user' => '/ocs/v1.php/cloud/users',
						'groups' => '/ocs/v1.php/cloud/groups',
						'apps' => '/ocs/v1.php/cloud/apps',
					],
				],
			]
		);

		$this->assertEquals($expected, $this->ocsProvider->buildProviderList());
	}
Example #21
0
 public function testGetIncompatibleApps()
 {
     $this->manager = $this->getMockBuilder('\\OC\\App\\AppManager')->setConstructorArgs([$this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher])->setMethods(['getAppInfo'])->getMock();
     $appInfos = ['dav' => ['id' => 'dav'], 'files' => ['id' => 'files'], 'federatedfilesharing' => ['id' => 'federatedfilesharing'], 'test1' => ['id' => 'test1', 'version' => '1.0.1', 'requiremax' => '8.0.0'], 'test2' => ['id' => 'test2', 'version' => '1.0.0', 'requiremin' => '8.2.0'], 'test3' => ['id' => 'test3', 'version' => '1.2.4', 'requiremin' => '9.0.0'], 'testnoversion' => ['id' => 'testnoversion', 'requiremin' => '8.2.0']];
     $this->manager->expects($this->any())->method('getAppInfo')->will($this->returnCallback(function ($appId) use($appInfos) {
         return $appInfos[$appId];
     }));
     $this->appConfig->setValue('test1', 'enabled', 'yes');
     $this->appConfig->setValue('test2', 'enabled', 'yes');
     $this->appConfig->setValue('test3', 'enabled', 'yes');
     $apps = $this->manager->getIncompatibleApps('8.2.0');
     $this->assertCount(2, $apps);
     $this->assertEquals('test1', $apps[0]['id']);
     $this->assertEquals('test3', $apps[1]['id']);
 }
Example #22
0
 public function testRunInstanceVerification()
 {
     $this->checker = $this->getMockBuilder('\\OC\\IntegrityCheck\\Checker')->setConstructorArgs([$this->environmentHelper, $this->fileAccessHelper, $this->appLocator, $this->config, $this->cacheFactory, $this->appManager])->setMethods(['verifyCoreSignature', 'verifyAppSignature'])->getMock();
     $this->checker->expects($this->at(0))->method('verifyCoreSignature');
     $this->appLocator->expects($this->at(0))->Method('getAllApps')->will($this->returnValue(['files', 'calendar', 'contacts', 'dav']));
     $this->appManager->expects($this->at(0))->method('isShipped')->with('files')->will($this->returnValue(true));
     $this->checker->expects($this->at(1))->method('verifyAppSignature')->with('files');
     $this->appManager->expects($this->at(1))->method('isShipped')->with('calendar')->will($this->returnValue(false));
     $this->appLocator->expects($this->at(1))->method('getAppPath')->with('calendar')->will($this->returnValue('/apps/calendar'));
     $this->fileAccessHelper->expects($this->at(0))->method('file_exists')->with('/apps/calendar/appinfo/signature.json')->will($this->returnValue(true));
     $this->checker->expects($this->at(2))->method('verifyAppSignature')->with('calendar');
     $this->appManager->expects($this->at(2))->method('isShipped')->with('contacts')->will($this->returnValue(false));
     $this->appLocator->expects($this->at(2))->method('getAppPath')->with('contacts')->will($this->returnValue('/apps/contacts'));
     $this->fileAccessHelper->expects($this->at(1))->method('file_exists')->with('/apps/contacts/appinfo/signature.json')->will($this->returnValue(false));
     $this->appManager->expects($this->at(3))->method('isShipped')->with('dav')->will($this->returnValue(true));
     $this->checker->expects($this->at(3))->method('verifyAppSignature')->with('dav');
     $this->checker->runInstanceVerification();
 }
Example #23
0
 /**
  * Verify the core code of the instance as well as all applicable applications
  * and store the results.
  */
 public function runInstanceVerification()
 {
     $this->verifyCoreSignature();
     $appIds = $this->appLocator->getAllApps();
     foreach ($appIds as $appId) {
         // If an application is shipped a valid signature is required
         $isShipped = $this->appManager->isShipped($appId);
         $appNeedsToBeChecked = false;
         if ($isShipped) {
             $appNeedsToBeChecked = true;
         } elseif ($this->fileAccessHelper->file_exists($this->appLocator->getAppPath($appId) . '/appinfo/signature.json')) {
             // Otherwise only if the application explicitly ships a signature.json file
             $appNeedsToBeChecked = true;
         }
         if ($appNeedsToBeChecked) {
             $this->verifyAppSignature($appId);
         }
     }
 }
 /**
  * @dataProvider showFileMethodProvider
  */
 public function testShowFileRouteWithTrashedFile($useShowFile)
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_trashbin')->will($this->returnValue(true));
     $parentNode = $this->getMock('\\OCP\\Files\\Folder');
     $parentNode->expects($this->once())->method('getPath')->will($this->returnValue('testuser1/files_trashbin/files/test.d1462861890/sub'));
     $baseFolderFiles = $this->getMock('\\OCP\\Files\\Folder');
     $baseFolderTrash = $this->getMock('\\OCP\\Files\\Folder');
     $this->rootFolder->expects($this->at(0))->method('get')->with('testuser1/files/')->will($this->returnValue($baseFolderFiles));
     $this->rootFolder->expects($this->at(1))->method('get')->with('testuser1/files_trashbin/files/')->will($this->returnValue($baseFolderTrash));
     $baseFolderFiles->expects($this->once())->method('getById')->with(123)->will($this->returnValue([]));
     $node = $this->getMock('\\OCP\\Files\\File');
     $node->expects($this->once())->method('getParent')->will($this->returnValue($parentNode));
     $node->expects($this->once())->method('getName')->will($this->returnValue('somefile.txt'));
     $baseFolderTrash->expects($this->at(0))->method('getById')->with(123)->will($this->returnValue([$node]));
     $baseFolderTrash->expects($this->at(1))->method('getRelativePath')->with('testuser1/files_trashbin/files/test.d1462861890/sub')->will($this->returnValue('/test.d1462861890/sub'));
     $this->urlGenerator->expects($this->once())->method('linkToRoute')->with('files.view.index', ['view' => 'trashbin', 'dir' => '/test.d1462861890/sub', 'scrollto' => 'somefile.txt'])->will($this->returnValue('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt'));
     $expected = new Http\RedirectResponse('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt');
     if ($useShowFile) {
         $this->assertEquals($expected, $this->viewController->showFile(123));
     } else {
         $this->assertEquals($expected, $this->viewController->index('/whatever', '', '123'));
     }
 }
 /**
  * @param string $appName
  * @param IRequest $request
  * @param IUserManager $userManager
  * @param IGroupManager $groupManager
  * @param IUserSession $userSession
  * @param IConfig $config
  * @param bool $isAdmin
  * @param IL10N $l10n
  * @param ILogger $log
  * @param \OC_Defaults $defaults
  * @param \OC_Mail $mail
  * @param string $fromMailAddress
  * @param IURLGenerator $urlGenerator
  * @param IAppManager $appManager
  * @param SubAdminFactory $subAdminFactory
  */
 public function __construct($appName, IRequest $request, IUserManager $userManager, IGroupManager $groupManager, IUserSession $userSession, IConfig $config, $isAdmin, IL10N $l10n, ILogger $log, \OC_Defaults $defaults, \OC_Mail $mail, $fromMailAddress, IURLGenerator $urlGenerator, IAppManager $appManager, SubAdminFactory $subAdminFactory)
 {
     parent::__construct($appName, $request);
     $this->userManager = $userManager;
     $this->groupManager = $groupManager;
     $this->userSession = $userSession;
     $this->config = $config;
     $this->isAdmin = $isAdmin;
     $this->l10n = $l10n;
     $this->log = $log;
     $this->defaults = $defaults;
     $this->mail = $mail;
     $this->fromMailAddress = $fromMailAddress;
     $this->urlGenerator = $urlGenerator;
     $this->subAdminFactory = $subAdminFactory;
     // check for encryption state - TODO see formatUserForIndex
     $this->isEncryptionAppEnabled = $appManager->isEnabledForUser('files_encryption');
     if ($this->isEncryptionAppEnabled) {
         // putting this directly in empty is possible in PHP 5.5+
         $result = $config->getAppValue('files_encryption', 'recoveryAdminEnabled', 0);
         $this->isRestoreEnabled = !empty($result);
     }
 }
 private function mockBadAppEnabled($app)
 {
     $this->appManager->expects($this->once())->method('isInstalled')->with($app)->willReturn(true);
 }
 /**
  * Enables or disables the display of experimental apps
  * @param bool $state
  * @return DataResponse
  */
 public function changeExperimentalConfigState($state)
 {
     $this->config->setSystemValue('appstore.experimental.enabled', $state);
     $this->appManager->clearAppsCache();
     return new DataResponse();
 }
 public function testIsSharingEnabledWithSharingDisabled()
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_sharing')->will($this->returnValue(true));
     $this->config->expects($this->once())->method('getAppValue')->with('core', 'shareapi_allow_links', 'yes')->will($this->returnValue('no'));
     $this->assertFalse(\Test_Helper::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled'));
 }
 /**
  * @expectedException \OCP\Files\NotFoundException
  * @expectedExceptionMessage Sharing is disabled.
  */
 public function testBeforeControllerWithSharingDisabled()
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_sharing')->will($this->returnValue(false));
     $this->sharingCheckMiddleware->beforeController($this->controllerMock, 'myMethod');
 }
Example #30
0
 /**
  * @param array $parameters
  * @return OC_OCS_Result
  */
 public function disable($parameters)
 {
     $app = $parameters['appid'];
     $this->appManager->disableApp($app);
     return new OC_OCS_Result(null, 100);
 }