Exemplo n.º 1
0
 function testGetParents()
 {
     $fileinfo1 = $this->view->getFileInfo($this->folder);
     $fileinfo2 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder);
     $fileinfo3 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder . $this->filename);
     $this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31));
     $this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER3, 31));
     $backend = new \OC_Share_Backend_Folder();
     $result = $backend->getParents($fileinfo3['fileid']);
     $this->assertSame(2, count($result));
     $count1 = 0;
     $count2 = 0;
     foreach ($result as $r) {
         if ($r['path'] === 'files' . $this->folder) {
             $this->assertSame(ltrim($this->folder, '/'), $r['collection']['path']);
             $count1++;
         } elseif ($r['path'] === 'files' . $this->folder . $this->subfolder . $this->subsubfolder) {
             $this->assertSame(ltrim($this->subsubfolder, '/'), $r['collection']['path']);
             $count2++;
         } else {
             $this->assertTrue(false, 'unexpected result');
         }
     }
     $this->assertSame(1, $count1);
     $this->assertSame(1, $count2);
     $result1 = $backend->getParents($fileinfo3['fileid'], self::TEST_FILES_SHARING_API_USER3);
     $this->assertSame(1, count($result1));
     $elemet = reset($result1);
     $this->assertSame('files' . $this->folder . $this->subfolder . $this->subsubfolder, $elemet['path']);
     $this->assertSame(ltrim($this->subsubfolder, '/'), $elemet['collection']['path']);
 }
Exemplo n.º 2
0
 /**
  * Invoke auto update of music database after item gets shared
  * @param array $params contains the params of the added share
  */
 public static function itemShared($params)
 {
     $app = new Music();
     $container = $app->getContainer();
     if ($params['itemType'] === 'folder') {
         $backend = new \OC_Share_Backend_Folder();
         foreach ($backend->getChildren($params['itemSource']) as $child) {
             $container->query('Scanner')->updateById((int) $child['source'], $params['shareWith']);
         }
     } else {
         if ($params['itemType'] === 'file') {
             $container->query('Scanner')->updateById((int) $params['itemSource'], $params['shareWith']);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Invoke auto update of music database after item gets shared
  * @param array $params contains the params of the added share
  */
 public static function itemShared($params)
 {
     $container = new DIContainer();
     if ($params['itemType'] === 'folder') {
         $backend = new \OC_Share_Backend_Folder();
         foreach ($backend->getChildren($params['itemSource']) as $child) {
             $filePath = $container['API']->getPath((int) $child['source']);
             $container['Scanner']->update($filePath, $params['shareWith']);
         }
     } else {
         if ($params['itemType'] === 'file') {
             $filePath = $container['API']->getPath((int) $params['itemSource']);
             $container['Scanner']->update($filePath, $params['shareWith']);
         }
     }
 }