public function GetResults()
 {
     $mimes =& get_mimes();
     // Get the library owner ID
     $userID = NULL;
     if (!get_library_owner($userID)) {
         log_message('warn', '[inventory_skel_lib] failed to get library owner');
         return array();
     } else {
         // Get the root folder ID
         $rootFolderID = $userID;
         if (!get_library_root_folder($userID, $rootFolderID)) {
             log_message('warn', '[inventory_skel_lib] failed to get library root');
             return array();
         }
         // Get the items from the inventory folder
         $items = NULL;
         if (!get_inventory_items($userID, $rootFolderID, 0, $items)) {
             log_message('warn', '[inventory_skel_lib] failed to get library contents');
             return array();
         }
         // Build the output folder structure
         $folders = array();
         foreach ($items as $item) {
             $type = isset($mimes[$item['ContentType']]) ? $mimes[$item['ContentType']] : -1;
             $parentid = $item['ParentID'];
             $folderid = $item['ID'];
             $foldername = $item['Name'];
             if ($folderid == $rootFolderID) {
                 $parentid = '00000000-0000-0000-0000-000000000000';
             }
             $folders[] = array('folder_id' => $folderid, 'name' => $foldername, 'parent_id' => $parentid, 'version' => (int) $item['Version'], 'type_default' => (int) $type);
         }
         log_message('debug', sprintf('[inventory_skel_lib] %d folders from %s owned by %s', count($folders), $rootFolderID, $userID));
         return $folders;
     }
 }
예제 #2
0
function get_inventory_folder_by_path($userID, &$folderID, $path)
{
    // check to see if we are done parsing the path
    if (!is_array($path) || count($path) == 0) {
        return true;
    }
    $folders = NULL;
    if (get_inventory_items($userID, $folderID, 1, $folders)) {
        $pathelem = array_shift($path);
        foreach ($folders as $folder) {
            if ($folder['Name'] == $pathelem) {
                $folderID = $folder['ID'];
                return get_inventory_folder_by_path($userID, $folderID, $path);
            }
        }
    }
    return false;
}