Example #1
0
 protected function processActionUpdateFile($hash, &$fileData, &$package, &$upload, &$error)
 {
     $this->checkRequiredInputParams($_POST, array('targetFileId'));
     $file = false;
     if (!$this->errorCollection->hasErrors()) {
         /** @var File $file */
         $file = File::loadById((int) $_POST['targetFileId'], array('STORAGE'));
         if ($file && isset($_POST['checkBp'])) {
             $workflowParameters = array();
             $search = 'bizproc';
             foreach ($_POST as $idParameter => $valueParameter) {
                 $res = strpos($idParameter, $search);
                 if ($res === 0) {
                     $workflowParameters[$idParameter] = $valueParameter;
                 }
             }
             $autoExecute = intval($_POST['autoExecute']);
             \Bitrix\Disk\BizProcDocument::startAutoBizProc($file->getStorageId(), $file->getId(), $autoExecute, $workflowParameters);
         }
         if (!$file) {
             $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_UPLOAD_ERROR_COULD_NOT_FIND_FILE'), self::ERROR_COULD_NOT_FIND_FILE)));
         } else {
             if (!$file->canUpdate($file->getStorage()->getCurrentUserSecurityContext())) {
                 $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_UPLOAD_ERROR_BAD_RIGHTS2'), self::ERROR_BAD_RIGHTS)));
             } else {
                 if (!$file->uploadVersion($fileData["files"]["default"], $this->getUser()->getId())) {
                     $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_UPLOAD_ERROR_COULD_UPLOAD_VERSION'), self::ERROR_COULD_UPLOAD_VERSION)));
                 }
             }
         }
     }
     $error = implode(" ", (is_object($file) ? $file->getErrors() : array()) + $this->errorCollection->toArray());
     return empty($error);
 }