function copyMoveExecuteTree($uidFolder, $newUidFolder) { require_once "classes/model/AppDocument.php"; require_once 'classes/model/AppFolder.php'; $appFoder = new AppFolder(); $folderContent = $appFoder->getFolderContent($uidFolder); $folderOrigin = $appFoder->getFolderStructure($uidFolder); if ($newUidFolder == $folderOrigin[$uidFolder]['PARENT'] && $_REQUEST['action'] == 'moveExecute') { return $uidFolder; } $FolderParentUid = trim($newUidFolder); //$form['FOLDER_PARENT_UID']; $FolderName = $folderOrigin[$uidFolder]['NAME']; $newFolderContent = $appFoder->createFolder($FolderName, $FolderParentUid, "new"); $appDocument = new AppDocument(); if ($_REQUEST['action'] == 'moveExecute') { $appFoder->remove($uidFolder, $folderOrigin[$uidFolder]['PARENT']); } $action = $_REQUEST['action']; foreach ($folderContent['documents'] as $keys => $value) { $docInfo = $appDocument->load($value['APP_DOC_UID'], $value['DOC_VERSION']); $docInfo['FOLDER_UID'] = $newFolderContent['folderUID']; $docInfo['APP_DOC_CREATE_DATE'] = date('Y-m-d H:i:s'); $docInfo['APP_DOC_STATUS'] = 'ACTIVE'; if ($action == 'copyExecute') { unset($docInfo['APP_DOC_UID']); $docUid = $appDocument->create($docInfo); } else { $appDocument->update($docInfo); } } return $newFolderContent['folderUID']; }
function copyMoveExecuteTree($uidFolder, $newUidFolder) { require_once ("classes/model/AppDocument.php"); require_once ('classes/model/AppFolder.php'); $appFoder = new AppFolder (); $folderContent = $appFoder->getFolderContent($uidFolder); $folderOrigin = $appFoder->getFolderStructure($uidFolder); if ($newUidFolder == $folderOrigin[$uidFolder]['PARENT'] && $_REQUEST['action'] == 'moveExecute') { return $uidFolder; } $FolderParentUid = trim($newUidFolder);//$form['FOLDER_PARENT_UID']; $FolderName = $folderOrigin[$uidFolder]['NAME']; $newFolderContent = $appFoder->createFolder ($FolderName, $FolderParentUid, "new"); $appDocument = new AppDocument(); if ($_REQUEST['action'] == 'moveExecute') { $appFoder->remove($uidFolder,$folderOrigin[$uidFolder]['PARENT']); } $action = $_REQUEST['action']; foreach ($folderContent['documents'] as $keys => $value) { $docInfo = $appDocument->load($value['APP_DOC_UID'],$value['DOC_VERSION']); $docInfo['FOLDER_UID'] = $newFolderContent['folderUID']; $docInfo['APP_DOC_CREATE_DATE'] = date('Y-m-d H:i:s'); $docInfo['APP_DOC_STATUS'] = 'ACTIVE'; if ($action == 'copyExecute') { $path = PATH_DOCUMENT . G::getPathFromUID($docInfo["APP_UID"]) . PATH_SEP; $arrayInfo = pathinfo($docInfo["APP_DOC_FILENAME"]); $extension = (isset($arrayInfo["extension"])? $arrayInfo["extension"] : ""); $arrayPathFromFile = G::getPathFromFileUID($docInfo["APP_UID"], $docInfo["APP_DOC_UID"]); $originFile = $arrayPathFromFile[0] . PATH_SEP . $arrayPathFromFile[1] . "_" . $docInfo["DOC_VERSION"] . "." . $extension; //Create Document unset($docInfo['APP_DOC_UID']); $docUid = $appDocument->create($docInfo); //Copy file $arrayPathFromFile = G::getPathFromFileUID($docInfo["APP_UID"], $docUid); $newFile = $arrayPathFromFile[0] . PATH_SEP . $arrayPathFromFile[1] . "_" . $docInfo["DOC_VERSION"] . "." . $extension; if(!file_exists($path . $arrayPathFromFile[0])) { mkdir( $path . $arrayPathFromFile[0], 0777, true ); } copy($path . $originFile, $path . $newFile); } else { $appDocument->update($docInfo); } } return $newFolderContent['folderUID']; }
function expandNode() { extract(getExtJSParams()); require_once "classes/model/AppFolder.php"; $oPMFolder = new AppFolder(); $rootFolder = "/"; if ($_POST['node'] == "") { $_POST['node'] = "/"; } if ($_POST['node'] == "root") { $_POST['node'] = "/"; } if (!isset($_POST['sendWhat'])) { $_POST['sendWhat'] = "both"; } if (isset($_POST['renderTree'])) { $limit = 1000000; } $totalItems = 0; $totalFolders = 0; $totalDocuments = 0; if ($_POST['sendWhat'] == "dirs" || $_POST['sendWhat'] == "both") { $folderListObj = $oPMFolder->getFolderList($_POST['node'] != 'root' ? $_POST['node'] == 'NA' ? "" : $_POST['node'] : $rootFolder, $limit, $start); //G::pr($folderListObj); $folderList = $folderListObj['folders']; $totalFolders = $folderListObj['totalFoldersCount']; $totalItems += count($folderList); // G::pr($folderListObj); } if ($_POST['sendWhat'] == "files" || $_POST['sendWhat'] == "both") { $folderContentObj = $oPMFolder->getFolderContent($_POST['node'] != 'root' ? $_POST['node'] == 'NA' ? "" : $_POST['node'] : $rootFolder, array(), NULL, NULL, $limit, $start); //G::pr($folderContentObj); $folderContent = $folderContentObj['documents']; $totalDocuments = $folderContentObj['totalDocumentsCount']; $totalItems += count($folderContent); //G::pr($folderContent); } // G::pr($folderList); //var_dump(isset($folderList)); $processListTree = array(); $tempTree = array(); if (isset($folderList) && sizeof($folderList) > 0) { // print'krlos'; // $tempTree=array(); foreach ($folderList as $key => $obj) { //$tempTree ['all-obj'] = $obj; $tempTree['text'] = $obj['FOLDER_NAME']; $tempTree['id'] = $obj['FOLDER_UID']; $tempTree['folderID'] = $obj['FOLDER_UID']; $tempTree['cls'] = 'folder'; $tempTree['draggable'] = true; $tempTree['name'] = $obj['FOLDER_NAME']; $tempTree['type'] = "Directory"; $tempTree['is_file'] = false; $tempTree['appDocCreateDate'] = $obj['FOLDER_CREATE_DATE']; $tempTree['qtip'] = '<strong>Directory: </strong>' . $obj['FOLDER_NAME'] . '<br /><strong>Create Date:</strong> ' . $obj['FOLDER_CREATE_DATE'] . ''; $tempTree['is_writable'] = true; $tempTree['is_chmodable'] = true; $tempTree['is_readable'] = true; $tempTree['is_deletable'] = true; if (isset($_POST['option']) && $_POST['option'] == "gridDocuments") { $tempTree['icon'] = "/images/documents/extension/folder.png"; } //$tempTree ['leaf'] = true; //$tempTree ['optionType'] = "category"; //$tempTree['allowDrop']=false; //$tempTree ['singleClickExpand'] = false; /* if ($key != "No Category") { $tempTree ['expanded'] = true; } else { //$tempTree ['expanded'] = false; $tempTree ['expanded'] = true; } */ $processListTree[] = $tempTree; $tempTree = array(); } /* if($_POST ['node'] == '/'){ $notInFolderLabel = G::LoadTranslation ( 'ID_NOT_IN_FOLDER' ); $tempTree ['text'] = $notInFolderLabel; $tempTree ['id'] = "NA"; $tempTree ['folderID'] = "NA"; $tempTree ['cls'] = 'folder'; $tempTree ['draggable' ] = true; $tempTree ['name'] = $notInFolderLabel; $tempTree ['type'] = "Directory"; $tempTree ['is_file'] = false; $tempTree ['qtip'] ='<strong>Directory: </strong>'.$notInFolderLabel.'<br /><i>Unfiled Files</i> '; $tempTree ['is_writable'] =true; $tempTree ['is_chmodable'] =true; $tempTree ['is_readable'] =true; $tempTree ['is_deletable'] =true; if((isset($_POST['option']))&&($_POST['option']=="gridDocuments")){ $tempTree ['icon'] = "/images/documents/extension/bz2.png"; }*/ //$tempTree ['leaf'] = true; //$tempTree ['optionType'] = "category"; //$tempTree['allowDrop']=false; //$tempTree ['singleClickExpand'] = false; /* if ($key != "No Category") { $tempTree ['expanded'] = true; } else { //$tempTree ['expanded'] = false; $tempTree ['expanded'] = true; } */ /* $processListTree [] = $tempTree; $tempTree=array(); }*/ } else { if ($_POST['node'] == '/') { // $tempTree=array(); // $processListTree [] = array(); } } if (isset($folderContent)) { foreach ($folderContent as $key => $obj) { $tempTree['text'] = $obj['APP_DOC_FILENAME']; $tempTree['name'] = $obj['APP_DOC_FILENAME']; $mimeInformation = getMime($obj['APP_DOC_FILENAME']); $tempTree['type'] = $mimeInformation['description']; $tempTree['icon'] = $mimeInformation['icon']; if (isset($obj['OUT_DOC_GENERATE'])) { if ($obj['OUT_DOC_GENERATE'] == "BOTH") { $arrayType = array("PDF", "DOC"); } else { $arrayType = array($obj['OUT_DOC_GENERATE']); } foreach ($arrayType as $keyType => $fileType) { $tempTree['text' . $fileType] = $obj['APP_DOC_FILENAME'] . "." . strtolower($fileType); $tempTree['name' . $fileType] = $obj['APP_DOC_FILENAME'] . "." . strtolower($fileType); $mimeInformation = getMime($obj['APP_DOC_FILENAME'] . "." . strtolower($fileType)); $tempTree['type' . $fileType] = $mimeInformation['description']; $tempTree['icon' . $fileType] = $mimeInformation['icon']; } } $tempTree['appdocid'] = $obj['APP_DOC_UID']; $tempTree['id'] = $obj['APP_DOC_UID_VERSION']; $tempTree['cls'] = 'file'; //$tempTree ['draggable'] = true; $tempTree['leaf'] = true; $tempTree['is_file'] = true; //if((isset($_POST['option']))&&($_POST['option']=="gridDocuments")){ //} $tempTree['docVersion'] = $obj['DOC_VERSION']; $tempTree['appUid'] = $obj['APP_UID']; $tempTree['usrUid'] = $obj['USR_UID']; $tempTree['appDocType'] = ucfirst(strtolower($obj['APP_DOC_TYPE'])); $tempTree['appDocCreateDate'] = $obj['APP_DOC_CREATE_DATE']; $tempTree['appDocPlugin'] = $obj['APP_DOC_PLUGIN']; $tempTree['appDocTags'] = $obj['APP_DOC_TAGS']; $tempTree['appDocTitle'] = $obj['APP_DOC_TITLE']; $tempTree['appDocComment'] = $tempTree['qtip'] = $obj['APP_DOC_COMMENT']; $tempTree['appDocFileName'] = $obj['APP_DOC_FILENAME']; if (isset($obj['APP_NUMBER'])) { $tempTree['appLabel'] = sprintf("%s '%s' (%s)", $obj['APP_NUMBER'], $obj['APP_TITLE'], $obj['STATUS']); } else { $tempTree['appLabel'] = "No case related"; } $tempTree['proTitle'] = $obj['PRO_TITLE']; $tempTree['appDocVersionable'] = 0; if (isset($obj['OUT_DOC_VERSIONING'])) { $tempTree['appDocVersionable'] = $obj['OUT_DOC_VERSIONING']; } elseif (isset($obj['INP_DOC_VERSIONING'])) { $tempTree['appDocVersionable'] = $obj['INP_DOC_VERSIONING']; } if (isset($obj['USR_LASTNAME']) && isset($obj['USR_LASTNAME'])) { $tempTree['owner'] = $obj['USR_USERNAME']; $tempTree['owner_firstname'] = $obj['USR_FIRSTNAME']; $tempTree['owner_lastname'] = $obj['USR_LASTNAME']; } else { $tempTree['owner'] = $obj['USR_USERNAME']; $tempTree['owner_firstname'] = ""; $tempTree['owner_lastname'] = ""; } $tempTree['deletelabel'] = $obj['DELETE_LABEL']; if (isset($obj['DOWNLOAD_LABEL']) && $obj['DOWNLOAD_LABEL'] != "") { $labelgen = strtoupper(str_replace(".", "", $obj['DOWNLOAD_LABEL'])); $tempTree['downloadLabel' . $labelgen] = $obj['DOWNLOAD_LABEL']; $tempTree['downloadLink' . $labelgen] = $obj['DOWNLOAD_LINK']; } $tempTree['downloadLabel'] = $obj['DOWNLOAD_LABEL']; $tempTree['downloadLink'] = $obj['DOWNLOAD_LINK']; if (isset($obj['DOWNLOAD_LABEL1']) && $obj['DOWNLOAD_LABEL1'] != "") { $labelgen = strtoupper(str_replace(".", "", $obj['DOWNLOAD_LABEL1'])); $tempTree['downloadLabel' . $labelgen] = $obj['DOWNLOAD_LABEL1']; $tempTree['downloadLink' . $labelgen] = $obj['DOWNLOAD_LINK1']; } $tempTree['downloadLabel1'] = $obj['DOWNLOAD_LABEL1']; $tempTree['downloadLink1'] = $obj['DOWNLOAD_LINK1']; $tempTree['appDocUidVersion'] = $obj['APP_DOC_UID_VERSION']; $tempTree['is_readable'] = true; $tempTree['is_file'] = true; //$tempTree ['optionType'] = "category"; //$tempTree['allowDrop']=false; //$tempTree ['singleClickExpand'] = true; /* if ($key != "No Category") { $tempTree ['expanded'] = true; } else { //$tempTree ['expanded'] = false; $tempTree ['expanded'] = true; } */ if (isset($obj['OUT_DOC_GENERATE'])) { foreach ($arrayType as $keyType => $fileType) { $tempTree['text'] = $tempTree['text' . $fileType]; $tempTree['name'] = $tempTree['name' . $fileType]; $tempTree['type'] = $tempTree['type' . $fileType]; $tempTree['icon'] = $tempTree['icon' . $fileType]; $tempTree['appDocFileName'] = $tempTree['name' . $fileType]; $tempTree['downloadLabel'] = $tempTree['downloadLabel' . $fileType]; $tempTree['downloadLink'] = $tempTree['downloadLink' . $fileType]; $tempTree['id'] = $tempTree['id'] . "_" . $fileType; $processListTree[] = $tempTree; } } else { $processListTree[] = $tempTree; } $tempTree = array(); } } // G::pr($processListTree); if (isset($_POST['option']) && $_POST['option'] == "gridDocuments") { $processListTreeTemp['totalCount'] = $totalFolders + $totalDocuments; //count($processListTree); $processListTreeTemp['msg'] = 'correct reload'; $processListTreeTemp['items'] = $processListTree; $processListTree = $processListTreeTemp; } // G::pr ( $processListTree );die; print G::json_encode($processListTree); }