コード例 #1
0
 /**
  * Creates a share of either a file or a folder, either publicly or with the tester
  *
  * @param string $nodeType
  * @param string|null $shareWith
  *
  * @return bool|string
  */
 protected function createShare($nodeType, $shareWith = null)
 {
     /**
      * Pick the file or the folder
      */
     if ($nodeType === 'file') {
         $sharedNode = $this->sharedFile;
     } else {
         $sharedNode = $this->sharedFolder;
     }
     $fileInfo = $sharedNode->getFileInfo();
     /**
      * Decide which type of share it is
      */
     $shareType = \OCP\Share::SHARE_TYPE_USER;
     if ($shareWith === null) {
         // We need to make sure sharing via link is enabled
         $this->server->getConfig()->setAppValue('core', 'shareapi_allow_links', 'yes');
         // Only password protect the folders
         if ($nodeType === 'folder') {
             $shareWith = $this->passwordForFolderShare;
         }
         $shareType = \OCP\Share::SHARE_TYPE_LINK;
     }
     /**
      * Share and generate the token if it's a public share
      */
     return Share::shareItem($nodeType, $fileInfo['fileid'], $shareType, $shareWith, \OCP\Constants::PERMISSION_ALL);
 }
コード例 #2
0
 /**
  * Create the federated share provider
  *
  * @return FederatedShareProvider
  */
 protected function federatedShareProvider()
 {
     if ($this->federatedProvider === null) {
         /*
          * Check if the app is enabled
          */
         $appManager = $this->serverContainer->getAppManager();
         if (!$appManager->isEnabledForUser('federatedfilesharing')) {
             return null;
         }
         /*
          * TODO: add factory to federated sharing app
          */
         $l = $this->serverContainer->getL10N('federatedfilessharing');
         $addressHandler = new AddressHandler($this->serverContainer->getURLGenerator(), $l);
         $discoveryManager = new DiscoveryManager($this->serverContainer->getMemCacheFactory(), $this->serverContainer->getHTTPClientService());
         $notifications = new Notifications($addressHandler, $this->serverContainer->getHTTPClientService(), $discoveryManager, $this->serverContainer->getJobList());
         $tokenHandler = new TokenHandler($this->serverContainer->getSecureRandom());
         $this->federatedProvider = new FederatedShareProvider($this->serverContainer->getDatabaseConnection(), $addressHandler, $notifications, $tokenHandler, $l, $this->serverContainer->getLogger(), $this->serverContainer->getLazyRootFolder(), $this->serverContainer->getConfig(), $this->serverContainer->getUserManager());
     }
     return $this->federatedProvider;
 }
コード例 #3
0
ファイル: managerfactory.php プロジェクト: vincchan/core
 /**
  * creates and returns an instance of the ICommentsManager
  *
  * @return ICommentsManager
  * @since 9.0.0
  */
 public function getManager()
 {
     return new Manager($this->serverContainer->getDatabaseConnection(), $this->serverContainer->getLogger(), $this->serverContainer->getConfig());
 }
コード例 #4
0
 /**
  * creates and returns an instance of the ILDAPProvider
  *
  * @return OCP\LDAP\ILDAPProvider
  */
 public function getLDAPProvider()
 {
     $dbConnection = $this->serverContainer->getDatabaseConnection();
     $userMapping = new UserMapping($dbConnection);
     return new LDAPProvider($this->serverContainer, new Helper(), new DeletedUsersIndex($this->serverContainer->getConfig(), $dbConnection, $userMapping));
 }
コード例 #5
0
 /**
  * @param $nodeType
  * @param $nodeId
  *
  * @return bool|string
  */
 private function getToken($nodeType, $nodeId)
 {
     // We need to make sure sharing via link is enabled
     $this->server->getConfig()->setAppValue('core', 'shareapi_allow_links', 'yes');
     return Share::shareItem($nodeType, $nodeId, \OCP\Share::SHARE_TYPE_LINK, 'sh@red p@ssw0rd', \OCP\Constants::PERMISSION_ALL, 'OCA\\GalleryPlus\\Environment\\Environment');
 }