Пример #1
0
 private static function getOC6FileList($user, $path, $onlyID, $indexed)
 {
     $result = array();
     $dirView = new \OC\Files\View('/' . $user);
     $dirContent = $dirView->getDirectoryContent($path);
     foreach ($dirContent as $item) {
         $itemRes = array();
         if (strpos($item['mimetype'], 'directory') === FALSE) {
             $fileData = array('fileid' => $item['fileid'], 'name' => $item['name'], 'mimetype' => $item['mimetype']);
             $fileData['path'] = isset($item['usersPath']) ? $item['usersPath'] : $item['path'];
             $itemRes[] = $onlyID ? $item['fileid'] : $fileData;
         } else {
             // Case by case build appropriate path
             if (isset($item['usersPath'])) {
                 // - this condition when usersPath is set - i.e. Shared files
                 $itemPath = $item['usersPath'];
             } elseif (isset($item['path'])) {
                 // - Standard case - Normal user's folder
                 $itemPath = $item['path'];
             } else {
                 // - Special folders - i.e. sharings
                 $itemPath = 'files/' . $item['name'];
             }
             $itemRes = \OCA\OCLife\utilities::getOC6FileList($user, $itemPath, $onlyID, $indexed);
         }
         foreach ($itemRes as $item) {
             if ($onlyID) {
                 $result[] = intval($item);
             } else {
                 if ($indexed) {
                     $result[intval($item['fileid'])] = $item;
                 } else {
                     $result[] = $item;
                 }
             }
         }
     }
     return $result;
 }