Exemplo n.º 1
0
 /**
  * Set single user mode and disable the trashbin app
  */
 protected function forceSingleUserAndTrashbin()
 {
     $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
     $this->wasSingleUserModeEnabled = $this->config->getSystemValue('singleuser', false);
     $this->config->setSystemValue('singleuser', true);
     $this->appManager->disableApp('files_trashbin');
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  * @param IManager $encryptionManager
  * @param IAppManager $appManager
  * @param IConfig $config
  * @param QuestionHelper $questionHelper
  */
 public function __construct(IManager $encryptionManager, IAppManager $appManager, IConfig $config, QuestionHelper $questionHelper)
 {
     parent::__construct();
     $this->appManager = $appManager;
     $this->encryptionManager = $encryptionManager;
     $this->config = $config;
     $this->questionHelper = $questionHelper;
     $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
     $this->wasSingleUserModeEnabled = $this->config->getSystemValue('singleuser', false);
     $this->config->setSystemValue('singleuser', true);
     $this->appManager->disableApp('files_trashbin');
 }
 /**
  * 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;
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
 /**
  * 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();
 }
Exemplo n.º 7
0
 public function testIsEnabledForUserLoggedIn()
 {
     $user = new User('user1', null);
     $this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($user));
     $this->groupManager->expects($this->once())->method('getUserGroupIds')->with($user)->will($this->returnValue(array('foo', 'bar')));
     $this->appConfig->setValue('test', 'enabled', '["foo"]');
     $this->assertTrue($this->manager->isEnabledForUser('test'));
 }
 /**
  * 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;
 }
Exemplo n.º 9
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;
 }
Exemplo n.º 10
0
 /**
  * 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;
 }
Exemplo n.º 11
0
 /**
  * @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 IMailer $mailer
  * @param string $fromMailAddress
  * @param IURLGenerator $urlGenerator
  * @param IAppManager $appManager
  */
 public function __construct($appName, IRequest $request, IUserManager $userManager, IGroupManager $groupManager, IUserSession $userSession, IConfig $config, $isAdmin, IL10N $l10n, ILogger $log, \OC_Defaults $defaults, IMailer $mailer, $fromMailAddress, IURLGenerator $urlGenerator, IAppManager $appManager)
 {
     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->mailer = $mailer;
     $this->fromMailAddress = $fromMailAddress;
     $this->urlGenerator = $urlGenerator;
     // check for encryption state - TODO see formatUserForIndex
     $this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption');
     if ($this->isEncryptionAppEnabled) {
         // putting this directly in empty is possible in PHP 5.5+
         $result = $config->getAppValue('encryption', 'recoveryAdminEnabled', 0);
         $this->isRestoreEnabled = !empty($result);
     }
 }
Exemplo n.º 12
0
 /**
  * This method is called before any HTTP after auth and checks if the user has access to the app
  *
  * @throws \Sabre\DAV\Exception\Forbidden
  * @return bool
  */
 public function checkAppEnabled()
 {
     if (!$this->appManager->isEnabledForUser($this->app)) {
         throw new Forbidden();
     }
 }