Esempio n. 1
0
 public function testSerialize()
 {
     $folder = new Folder();
     $folder->setId(3);
     $folder->setName('john');
     $folder->setParentId(4);
     $folder->setUserId('abc');
     $folder->setOpened(true);
     $folder->setDeletedAt(9);
     $this->assertEquals(['id' => 3, 'parentId' => 4, 'name' => 'john', 'userId' => 'abc', 'opened' => true, 'deletedAt' => 9], $folder->jsonSerialize());
 }
Esempio n. 2
0
 /**
  * Get Folder Info
  *
  * @param folderId - required -
  *            The id of the folder.
  * @param includeFiles - optional -
  *            Default = true. If true, the API returns
  *            info about all the files in the specified folder, at this folder level only.
  * @param includeFolders - optional -
  *            Default = true. If true, the API returns info about all
  *            the sub folders, at this folder level only
  * @return The Folder object. If the operation was successful, the object contains the folder info, if not, the object
  * 			contains the error code and message.
  */
 public function getFolderInfo($folderId, $includeFiles = '', $includeFolders = '')
 {
     $parameters = array();
     if ($includeFiles !== '') {
         $parameters['includeFiles'] = $includeFiles;
     }
     if ($includeFolders !== '') {
         $parameters['includeFolders'] = $includeFolders;
     }
     $urld = 'dpi/v1/folder/' . $folderId;
     $this->response = $this->restTransportInstance->sendRequest($urld, $parameters, self::HTTP_GET, $this->authToken);
     $responseBody = simplexml_load_string($this->response);
     $returnObject = new Folder();
     if ($responseBody === false) {
         $errorCode = 'N/A';
         $errorMessage = 'The server has encountered an error, please try again.';
         $errorObject = new ErrorStatus($errorCode, $errorMessage);
         $returnObject->setErrorStatus($errorObject);
     } else {
         $errorStatus = $responseBody->errorStatus;
         if (empty($errorStatus)) {
             $returnObject->setRevision((string) $responseBody->attributes()->revision);
             $returnObject->setId((string) $responseBody->attributes()->id);
             $returnObject->setCreatedOn((string) $responseBody->createdOn);
             $returnObject->setName((string) $responseBody->name);
             $returnObject->setParentId((string) $responseBody->parentid);
             $returnObject->setReadable((string) $responseBody->readable);
             $returnObject->setSize((string) $responseBody->size);
             $returnObject->setType((string) $responseBody->type);
             $returnObject->setUpdatedOn((string) $responseBody->updatedOn);
             $returnObject->setWritable((string) $responseBody->writeable);
             $returnObject->setCurrentUsage((string) $responseBody->currentUsage);
             $returnObject->setStorageQuota((string) $responseBody->storageQuota);
             $fileCount = (string) $responseBody->fileCount;
             $returnObject->setFileCount($fileCount);
             $folderCount = (string) $responseBody->folderCount;
             $returnObject->setFolderCount($folderCount);
             if ($includeFiles) {
                 $filesTag = $responseBody->files;
                 if (!empty($filesTag)) {
                     $allFiles = $responseBody->files->children();
                     $files = array();
                     if (!empty($allFiles)) {
                         foreach ($allFiles as $currentFile) {
                             $file = new File();
                             $file->setRevision((string) $currentFile->attributes()->revision);
                             $file->setId((string) $currentFile->attributes()->id);
                             $file->setCreatedOn((string) $currentFile->createdOn);
                             $file->setName((string) $currentFile->name);
                             $file->setParentId((string) $currentFile->parentid);
                             $file->setSize((string) $currentFile->size);
                             array_push($files, $file);
                         }
                         $returnObject->setFiles($files);
                     }
                 }
             }
             if ($includeFolders) {
                 $foldersTag = $responseBody->folders;
                 if (!empty($foldersTag)) {
                     $allFolders = $responseBody->folders->children();
                     $folders = array();
                     if (!empty($allFolders)) {
                         foreach ($allFolders as $currentFolder) {
                             $folder = new Folder();
                             $folder->setRevision((string) $currentFolder->attributes()->revision);
                             $folder->setId((string) $currentFolder->attributes()->id);
                             $folder->setCreatedOn((string) $currentFolder->createdOn);
                             $folder->setCurrentUsage((string) $currentFolder->currentUsage);
                             $folder->setFileCount((string) $currentFolder->fileCount);
                             $folder->setFolderCount((string) $currentFolder->folderCount);
                             $folder->setName((string) $currentFolder->name);
                             $folder->setParentId((string) $currentFolder->parentid);
                             $folder->setReadable((string) $currentFolder->readable);
                             $folder->setSize((string) $currentFolder->size);
                             $folder->setType((string) $currentFolder->type);
                             $folder->setUpdatedOn((string) $currentFolder->updatedOn);
                             $folder->setWritable((string) $currentFolder->writeable);
                             $folder->setOwnedByUser((string) $currentFolder->ownedByUser);
                             array_push($folders, $folder);
                         }
                         $returnObject->setFolders($folders);
                     }
                 }
             }
         } else {
             $errorCode = (string) $responseBody->errorStatus->code;
             $errorMessage = (string) $responseBody->errorStatus->message;
             $errorObject = new ErrorStatus($errorCode, $errorMessage);
             $returnObject->setErrorStatus($errorObject);
         }
     }
     return $returnObject;
 }
Esempio n. 3
0
 /**
  * Maps a Folder object contained in a recordset to an object representation
  *
  * @param $rs Recordset filled with the object data
  * @return objeto Mapped Folder object
  */
 function &mapOne($rs)
 {
     if ($rs == null) {
         return null;
     }
     $object = new Folder();
     $object->setId($rs->fields["ID"]);
     $object->setLongDescription($rs->fields["longDescription"]);
     $object->setParentId($rs->fields["parentID"]);
     $object->setPosition($rs->fields["position"]);
     $object->setShortDescription($rs->fields["shortDescription"]);
     $object->setTitle($rs->fields["title"]);
     return $object;
 }
 /**
  * Updates a new folder
  */
 function updateFolder()
 {
     $controllerData =& $this->collectControlerData();
     $folderId = $controllerData["folderIdHidden"];
     $title = $controllerData["titleText"];
     $parentId = $controllerData["parentIdHidden"];
     $position = $controllerData["positionText"];
     $shortDescription = $controllerData["shortDescriptionText"];
     $longDescription = $controllerData["longDescriptionTextarea"];
     $classesIdArray = $controllerData["classesIdSelect"];
     if ($title == null || $title == "") {
         $this->addErrorMessage("title");
     }
     if ($shortDescription == null || $shortDescription == "") {
         $this->addErrorMessage("shortdescription");
     }
     if ($longDescription == null || $longDescription == "") {
         $this->addErrorMessage("longdescription");
     }
     if (count($classesIdArray) <= 0) {
         $this->addErrorMessage("classes");
     }
     if (count($this->controllerMessageArray) > 0) {
         $this->displayUpdateFolderView("addFolder.tpl.php");
         return;
     }
     $folder = new Folder();
     $folder->setId($folderId);
     $folder->setTitle($title);
     $folder->setParentId($parentId);
     $folder->setPosition($position);
     $folder->setShortDescription($shortDescription);
     $folder->setLongDescription($longDescription);
     $folderClassesArray = array();
     foreach ($classesIdArray as $classId) {
         $folderClass = new FolderClass();
         $folderClass->setClassID($classId);
         $folderClass->setPosition(1);
         $folderClass->setIsDefault(0);
         array_push($folderClassesArray, $folderClass);
     }
     $folder->setFolderClasses($folderClassesArray);
     $folderService = new FolderService();
     $folderService->update($folder);
     $this->redirectToReferer();
 }