Exemplo n.º 1
0
 public function formatItems($items, $format, $parameters = null)
 {
     if ($format == self::FORMAT_SHARED_STORAGE) {
         // Only 1 item should come through for this format call
         return array('path' => $items[key($items)]['path'], 'permissions' => $items[key($items)]['permissions']);
     } else {
         if ($format == self::FORMAT_FILE_APP && isset($parameters['folder'])) {
             // Only 1 item should come through for this format call
             $folder = $items[key($items)];
             if (isset($parameters['mimetype_filter'])) {
                 $mimetype_filter = $parameters['mimetype_filter'];
             } else {
                 $mimetype_filter = '';
             }
             $path = $folder['path'] . substr($parameters['folder'], 7 + strlen($folder['file_target']));
             $files = OC_FileCache::getFolderContent($path, '', $mimetype_filter);
             foreach ($files as &$file) {
                 $file['directory'] = $parameters['folder'];
                 $file['type'] = $file['mimetype'] == 'httpd/unix-directory' ? 'dir' : 'file';
                 $file['permissions'] = $folder['permissions'];
                 if ($file['type'] == 'file') {
                     // Remove Create permission if type is file
                     $file['permissions'] &= ~OCP\Share::PERMISSION_CREATE;
                 }
             }
             return $files;
         }
     }
     return array();
 }
Exemplo n.º 2
0
 /**
  * get the content of a directory
  * @param dir $directory
  */
 public static function getDirectoryContent($directory, $mimetype_filter = '')
 {
     if (strpos($directory, OC::$CONFIG_DATADIRECTORY) === 0) {
         $directory = substr($directory, strlen(OC::$CONFIG_DATADIRECTORY));
     }
     $files = OC_FileCache::getFolderContent($directory, '', $mimetype_filter);
     foreach ($files as &$file) {
         $file['directory'] = $directory;
         $file['type'] = $file['mimetype'] == 'httpd/unix-directory' ? 'dir' : 'file';
     }
     usort($files, "fileCmp");
     //TODO: remove this once ajax is merged
     return $files;
 }
Exemplo n.º 3
0
 /**
  * get the content of a directory
  * @param dir $directory path under datadirectory
  */
 public static function getDirectoryContent($directory, $mimetype_filter = '')
 {
     $directory = OC_Filesystem::normalizePath($directory);
     if ($directory == '/') {
         $directory = '';
     }
     $files = array();
     if (($directory == '/Shared' || substr($directory, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
         if ($directory == '/Shared') {
             $files = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP, array('folder' => $directory, 'mimetype_filter' => $mimetype_filter));
         } else {
             $pos = strpos($directory, '/', 8);
             // Get shared folder name
             if ($pos !== false) {
                 $itemTarget = substr($directory, 7, $pos - 7);
             } else {
                 $itemTarget = substr($directory, 7);
             }
             $files = OCP\Share::getItemSharedWith('folder', $itemTarget, OC_Share_Backend_File::FORMAT_FILE_APP, array('folder' => $directory, 'mimetype_filter' => $mimetype_filter));
         }
     } else {
         $files = OC_FileCache::getFolderContent($directory, false, $mimetype_filter);
         foreach ($files as &$file) {
             $file['directory'] = $directory;
             $file['type'] = $file['mimetype'] == 'httpd/unix-directory' ? 'dir' : 'file';
             $permissions = OCP\Share::PERMISSION_READ;
             // NOTE: Remove check when new encryption is merged
             if (!$file['encrypted']) {
                 $permissions |= OCP\Share::PERMISSION_SHARE;
             }
             if ($file['type'] == 'dir' && $file['writable']) {
                 $permissions |= OCP\Share::PERMISSION_CREATE;
             }
             if ($file['writable']) {
                 $permissions |= OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_DELETE;
             }
             $file['permissions'] = $permissions;
         }
         if ($directory == '' && OC_App::isEnabled('files_sharing')) {
             // Add 'Shared' folder
             $files = array_merge($files, OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT));
         }
     }
     usort($files, "fileCmp");
     //TODO: remove this once ajax is merged
     return $files;
 }