Esempio n. 1
0
function getStorageRevisions()
{
    $storage = new StorageAPIs($_SESSION['sHost'], $_SESSION['sApp'], $_SESSION['sTr']);
    $var0 = trim($_POST['var0'], " ");
    $var1 = trim($_POST['var1'], " ");
    echo "\nGET STORAGE REVISIONS: \n\n";
    if (strlen($var0) == 0) {
        echo "\n Error: Empty mandatory field(s)!\n";
    } else {
        $storage->setAuthToken($var0);
        if (strlen($var1) == 0) {
            $responseObject = $storage->getStorageRevisions();
        } else {
            $responseObject = $storage->getStorageRevisions($var1);
        }
        $current = $responseObject->getErrorStatus();
        if (!empty($current)) {
            echo "Error Status: \n";
            echo " Error code: " . $current->getCode() . "\n";
            echo " Error message: " . $current->getMessage() . "\n";
        } else {
            $current = $responseObject->getCurrentUsage();
            if (strlen($current) !== 0) {
                echo " Current Usage: " . $current . "\n";
            } else {
                echo " Current Usage: N/A\n";
            }
            $current = $responseObject->getRevision();
            if (strlen($current) !== 0) {
                echo " Revision: " . $current . "\n";
            } else {
                echo " Revision: N/A\n";
            }
            $current = $responseObject->getRevisionCount();
            if (strlen($current) !== 0) {
                echo " Revision Count: " . $current . "\n";
            } else {
                echo " Revision Count: N/A\n";
            }
            $current = $responseObject->getStatusDisplay();
            if (strlen($current) !== 0) {
                echo " Status Display: " . $current . "\n";
            } else {
                echo " Status Display: N/A\n";
            }
            $current = $responseObject->getStorageQuota();
            if (strlen($current) !== 0) {
                echo " Storage Quota: " . $current . "\n";
            } else {
                echo " Storage Quota: N/A\n";
            }
            $current = $responseObject->getWorkspaceId();
            if (strlen($current) !== 0) {
                echo " Workspace Id: " . $current . "\n";
            } else {
                echo " Workspace Id: N/A\n";
            }
            $files = $responseObject->getFiles();
            if (!empty($files)) {
                echo "\nFiles: \n";
                foreach ($files as $file) {
                    echo "\nFile: \n";
                    $current = $file->getCreatedOn();
                    if (strlen($current) !== 0) {
                        echo " Created On: " . $current . "\n";
                    } else {
                        echo " Created On: N/A\n";
                    }
                    $current = $file->getDeleteStatus();
                    if (strlen($current) !== 0) {
                        echo " Delete Status: " . $current . "\n";
                    } else {
                        echo " Delete Status: N/A\n";
                    }
                    $current = $file->getFileId();
                    if (strlen($current) !== 0) {
                        echo " File Id: " . $current . "\n";
                    } else {
                        echo " File Id: N/A\n";
                    }
                    $current = $file->getFileName();
                    if (strlen($current) !== 0) {
                        echo " File Name: " . $current . "\n";
                    } else {
                        echo " File Name: N/A\n";
                    }
                    $current = $file->getFolderId();
                    if (strlen($current) !== 0) {
                        echo " Folder Id: " . $current . "\n";
                    } else {
                        echo " Folder Id: N/A\n";
                    }
                    $current = $file->getLastUpdatedOn();
                    if (strlen($current) !== 0) {
                        echo " Last updated on: " . $current . "\n";
                    } else {
                        echo " Last updated on: N/A\n";
                    }
                    $current = $file->getRevision();
                    if (strlen($current) !== 0) {
                        echo " Revision: " . $current . "\n";
                    } else {
                        echo " Revision: N/A\n";
                    }
                }
            }
            $folders = $responseObject->getFolders();
            if (!empty($folders)) {
                echo "\nFolders: \n";
                foreach ($folders as $folder) {
                    echo "\nFolder: \n";
                    $current = $folder->getCreatedOn();
                    if (strlen($current) !== 0) {
                        echo " Created On: " . $current . "\n";
                    } else {
                        echo " Created On: N/A\n";
                    }
                    $current = $folder->getDeletedStatus();
                    if (strlen($current) !== 0) {
                        echo " Deleted Status: " . $current . "\n";
                    } else {
                        echo " Deleted Status: N/A\n";
                    }
                    $current = $folder->getFolderId();
                    if (strlen($current) !== 0) {
                        echo " Folder Id: " . $current . "\n";
                    } else {
                        echo " Folder Id: N/A\n";
                    }
                    $current = $folder->getFolderType();
                    if (strlen($current) !== 0) {
                        echo " Folder Type: " . $current . "\n";
                    } else {
                        echo " Folder Type: N/A\n";
                    }
                    $current = $folder->getLastUpdatedOn();
                    if (strlen($current) !== 0) {
                        echo " Last updated on: " . $current . "\n";
                    } else {
                        echo " Last updated on: N/A\n";
                    }
                    $current = $folder->getRevision();
                    if (strlen($current) !== 0) {
                        echo " Revision: " . $current . "\n";
                    } else {
                        echo " Revision: N/A\n";
                    }
                    $current = $folder->getShareInvitationPending();
                    if (strlen($current) !== 0) {
                        echo " Share Invitation Pending: " . $current . "\n";
                    } else {
                        echo " Share Invitation Pending: N/A\n";
                    }
                    $current = $folder->getSize();
                    if (strlen($current) !== 0) {
                        echo " Size: " . $current . "\n";
                    } else {
                        echo " Size: N/A\n";
                    }
                    $permissions = $folder->getPermissions();
                    if (!empty($permissions)) {
                        echo "Folder Permissions: \n";
                        foreach ($permissions as $permission) {
                            echo "Permission: \n";
                            $current = $permission->getWsPermissionName();
                            if (strlen($current) !== 0) {
                                echo " Permission Name: " . $current . "\n";
                            } else {
                                echo " Permission Name: N/A\n";
                            }
                        }
                    }
                }
            }
        }
    }
    echo "\n----------------------------------------------------------------------------------------------------\n";
}
Esempio n. 2
0
 public function file_info($file_id = null)
 {
     $obj = new \StorageAPIs(\Session::get('ysi.sHost'), \Session::get('ysi.sApp'), \Session::get('ysi.sTr'));
     $obj->setAuthToken(\Session::get('ysi.sToken'));
     $file = $obj->getFileInfo($file_id);
     $current = $file->getErrorStatus();
     if (!empty($current)) {
         $out = array('errorcode' => $current->getCode(), 'errormessage' => $current->getMessage());
     } else {
         $out['data']['revision'] = $file->getRevision();
         $out['data']['id'] = $file->getId();
         $out['data']['clickable_download_url'] = $file->getClickableDownloadUrl();
         $out['data']['created_on'] = $file->getCreatedOn();
         $out['data']['download_url'] = $file->getDownloadUrl();
         $out['data']['name'] = $file->getName();
         $out['data']['owned_by_storage'] = $file->getOwnedByStorage();
         $out['data']['parent_id'] = $file->getParentId();
         $out['data']['size'] = $file->getSize();
     }
     return $out;
 }