예제 #1
0
 /**
  * @medium
  */
 function testStripPartialFileExtensionWithTransferIdPath()
 {
     $partFilename = 'testfile.txt.ocTransferId643653835.part';
     $filename = 'testfile.txt';
     $this->assertTrue(Encryption\Helper::isPartialFilePath($partFilename));
     $this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($partFilename));
     $this->assertFalse(Encryption\Helper::isPartialFilePath($filename));
     $this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($filename));
 }
예제 #2
0
파일: util.php 프로젝트: Combustible/core
 /**
  * Find, sanitise and format users sharing a file
  * @note This wraps other methods into a portable bundle
  * @param boolean $sharingEnabled
  * @param string $filePath path relativ to current users files folder
  */
 public function getSharingUsersArray($sharingEnabled, $filePath)
 {
     $appConfig = \OC::$server->getAppConfig();
     // Check if key recovery is enabled
     if ($appConfig->getValue('files_encryption', 'recoveryAdminEnabled') && $this->recoveryEnabledForUser()) {
         $recoveryEnabled = true;
     } else {
         $recoveryEnabled = false;
     }
     // Make sure that a share key is generated for the owner too
     list($owner, $ownerPath) = $this->getUidAndFilename($filePath);
     $ownerPath = \OCA\Encryption\Helper::stripPartialFileExtension($ownerPath);
     // always add owner to the list of users with access to the file
     $userIds = array($owner);
     if ($sharingEnabled) {
         // Find out who, if anyone, is sharing the file
         $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner);
         $userIds = \array_merge($userIds, $result['users']);
         if ($result['public']) {
             $userIds[] = $this->publicShareKeyId;
         }
     }
     // If recovery is enabled, add the
     // Admin UID to list of users to share to
     if ($recoveryEnabled) {
         // Find recoveryAdmin user ID
         $recoveryKeyId = $appConfig->getValue('files_encryption', 'recoveryKeyId');
         // Add recoveryAdmin to list of users sharing
         $userIds[] = $recoveryKeyId;
     }
     // check if it is a group mount
     if (\OCP\App::isEnabled("files_external")) {
         $mounts = \OC_Mount_Config::getSystemMountPoints();
         foreach ($mounts as $mount) {
             if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) {
                 $userIds = array_merge($userIds, $this->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']));
             }
         }
     }
     // Remove duplicate UIDs
     $uniqueUserIds = array_unique($userIds);
     return $uniqueUserIds;
 }