CODE STYLE

- workflow/engine/menus/cases.php
- workflow/engine/methods/appFolder/appFolderAjax.php
This commit is contained in:
Marco Antonio Nina
2012-07-19 17:13:59 -04:00
parent 3e22cd5c25
commit fb83aef89b
2 changed files with 1530 additions and 1505 deletions

View File

@@ -26,14 +26,18 @@ global $RBAC;
global $G_TMP_MENU;
$G_TMP_MENU->AddIdRawOption('FOLDERS', '', G::LoadTranslation('ID_CASES_MENU_FOLDERS'), '', '', 'blockHeader');
$G_TMP_MENU->AddIdRawOption('CASES_START_CASE', 'casesStartPage?action=startCase', G::LoadTranslation('ID_NEW_CASE'), '' );
$G_TMP_MENU->AddIdRawOption('CASES_INBOX', 'casesListExtJs?action=todo', G::LoadTranslation('ID_INBOX'), 'icon-cases-inbox.png' );
$G_TMP_MENU->AddIdRawOption('CASES_DRAFT', 'casesListExtJs?action=draft', G::LoadTranslation('ID_DRAFT'), 'mail-mark-task.png' );
$G_TMP_MENU->AddIdRawOption('CASES_SENT', 'casesListExtJs?action=sent', G::LoadTranslation('ID_SENT'), 'icon-cases-outbox.png');
$G_TMP_MENU->AddIdRawOption('CASES_SELFSERVICE', 'casesListExtJs?action=selfservice',G::LoadTranslation('ID_UNASSIGNED'), 'rotate_cw.png' );
$G_TMP_MENU->AddIdRawOption('CASES_PAUSED', 'casesListExtJs?action=paused', G::LoadTranslation('ID_PAUSED'), 'mail-queue.png' );
//$G_TMP_MENU->AddIdRawOption('CASES_CANCELLED', 'casesListExtJs?action=cancelled', G::LoadTranslation('ID_CANCELLED'), 'edit-clear-list.png' );
//$G_TMP_MENU->AddIdRawOption('CASES_FOLDERS1', '../appFolder/appFolderList', G::LoadTranslation('ID_FOLDERS'), 'folderV2.gif' );
$G_TMP_MENU->AddIdRawOption('CASES_START_CASE', 'casesStartPage?action=startCase',
G::LoadTranslation('ID_NEW_CASE'), '');
$G_TMP_MENU->AddIdRawOption('CASES_INBOX', 'casesListExtJs?action=todo', G::LoadTranslation('ID_INBOX'),
'icon-cases-inbox.png');
$G_TMP_MENU->AddIdRawOption('CASES_DRAFT', 'casesListExtJs?action=draft', G::LoadTranslation('ID_DRAFT'),
'mail-mark-task.png' );
$G_TMP_MENU->AddIdRawOption('CASES_SENT', 'casesListExtJs?action=sent', G::LoadTranslation('ID_SENT'),
'icon-cases-outbox.png');
$G_TMP_MENU->AddIdRawOption('CASES_SELFSERVICE', 'casesListExtJs?action=selfservice',
G::LoadTranslation('ID_UNASSIGNED'),'rotate_cw.png');
$G_TMP_MENU->AddIdRawOption('CASES_PAUSED', 'casesListExtJs?action=paused', G::LoadTranslation('ID_PAUSED'),
'mail-queue.png');
if ($RBAC->userCanAccess('PM_ALLCASES') == 1) {
//$G_TMP_MENU->AddIdRawOption('CASES_GRAL', 'casesListExtJs?action=gral', G::LoadTranslation('ID_GENERAL'));
@@ -42,29 +46,36 @@ if ( $RBAC->userCanAccess('PM_ALLCASES') == 1 ) {
$G_TMP_MENU->AddIdRawOption('SEARCHS', '', G::LoadTranslation('ID_CASES_MENU_SEARCH'), '', '', 'blockHeader');
if ($RBAC->userCanAccess('PM_ALLCASES') == 1) {
$G_TMP_MENU->AddIdRawOption('CASES_SEARCH', 'casesListExtJs?action=search', G::LoadTranslation('ID_ADVANCEDSEARCH'), 'system-search.png' );
$G_TMP_MENU->AddIdRawOption('CASES_SEARCH', 'casesListExtJs?action=search',
G::LoadTranslation('ID_ADVANCEDSEARCH'), 'system-search.png' );
}
$G_TMP_MENU->AddIdRawOption('ADMIN', '', G::LoadTranslation('ID_CASES_MENU_ADMIN'), '', '', 'blockHeader');
if ($RBAC->userCanAccess('PM_SUPERVISOR') == 1) {
//$G_TMP_MENU->AddIdRawOption('CASES_TO_REVISE_NORMAL', 'cases_List?l=to_revise', G::LoadTranslation('ID_TO_REVISE'), 'document-review.png' );
$G_TMP_MENU->AddIdRawOption('CASES_TO_REVISE', 'casesListExtJs?action=to_revise', G::LoadTranslation('ID_TO_REVISE'), 'document-review.png' );
//$G_TMP_MENU->AddIdRawOption('CASES_TO_REVISE_NORMAL', 'cases_List?l=to_revise',
//G::LoadTranslation('ID_TO_REVISE'), 'document-review.png' );
$G_TMP_MENU->AddIdRawOption('CASES_TO_REVISE', 'casesListExtJs?action=to_revise',
G::LoadTranslation('ID_TO_REVISE'), 'document-review.png');
//$G_TMP_MENU->AddIdRawOption('CASES_SCHEDULER','cases_Scheduler_List',G::LoadTranslation('ID_SCHEDULER_LIST'));
//$G_TMP_MENU->AddIdRawOption('CASES_SCHEDULER_LOG','cases_Scheduler_Log',G::LoadTranslation('ID_SCHEDULER_LOG'));
}
if ($RBAC->userCanAccess('PM_REASSIGNCASE') == 1) {
//$G_TMP_MENU->AddIdRawOption('CASES_TO_REASSIGN_NORMAL', 'cases_List?l=to_reassign', G::LoadTranslation('ID_TO_REASSIGN'), 'reassing.png' );
$G_TMP_MENU->AddIdRawOption('CASES_TO_REASSIGN', 'casesListExtJs?action=to_reassign', G::LoadTranslation('ID_TO_REASSIGN'), 'reassing.png' );
//$G_TMP_MENU->AddIdRawOption('CASES_TO_REASSIGN_NORMAL', 'cases_List?l=to_reassign',
//G::LoadTranslation('ID_TO_REASSIGN'), 'reassing.png' );
$G_TMP_MENU->AddIdRawOption('CASES_TO_REASSIGN', 'casesListExtJs?action=to_reassign',
G::LoadTranslation('ID_TO_REASSIGN'), 'reassing.png' );
}
if ($RBAC->userCanAccess('PM_FOLDERS_VIEW') == 1) {
$G_TMP_MENU->AddIdRawOption('CASES_FOLDERS', 'casesStartPage?action=documents', G::LoadTranslation('ID_FOLDERS'), 'folderV2.gif','','blockHeaderNoChild' );
$G_TMP_MENU->AddIdRawOption('CASES_FOLDERS', 'casesStartPage?action=documents', G::LoadTranslation('ID_FOLDERS'),
'folderV2.gif', '', 'blockHeaderNoChild' );
}
//$G_TMP_MENU->AddIdRawOption('CASES_START_PAGE', 'casesStartPage?action=mainDashboard', ucwords(strtolower(G::LoadTranslation('ID_DASHBOARD'))), '' );
//$G_TMP_MENU->AddIdRawOption('CASES_START_PAGE', 'casesStartPage?action=mainDashboard',
//ucwords(strtolower(G::LoadTranslation('ID_DASHBOARD'))),'');
//Load Other registered Dashboards (From plugins)
$oPluginRegistry = & PMPluginRegistry::getSingleton ();
@@ -76,9 +87,9 @@ if(count($dashBoardPages)>0){
$tabName=$tabInfo->sName;
$tabIcon=str_replace("ICON_","",$tabInfo->sIcon);
if ($tabName!= "") {
$G_TMP_MENU->AddIdRawOption($tabIcon, 'casesStartPage?action='.$tabNameSpace.'-'.$tabName, ucwords(strtolower($tabName)), '' );
$G_TMP_MENU->AddIdRawOption($tabIcon, 'casesStartPage?action='.$tabNameSpace.'-'.$tabName,
ucwords(strtolower($tabName)), '');
}
}
}

View File

@@ -24,7 +24,8 @@ $functionName ( $functionParams );
* @param void
* @return true
**/
function delete() {
function delete()
{
include_once ("classes/model/AppDocument.php");
include_once ("classes/model/AppFolder.php");
@@ -55,33 +56,36 @@ $functionName ( $functionParams );
* @param string $opt
* @return true
**/
function deleteDocuments($aDocuments, $opt){
function deleteDocuments($aDocuments, $opt)
{
include_once ("classes/model/AppDocument.php");
$oAppDocument = new AppDocument ();
foreach ($aDocuments as $key => $val) {
if ($opt == 'documents') {
list($sFileUID,$docVersion) = explode('_',$val);
} else {
$sFileUID = $val['sAppDocUid'];
$docVersion = $val['iVersion'];
}
$oAppDocument->remove($sFileUID,$docVersion);
}
return true;
}
/////////////////////////////////////////////
function getExtJSParams() {
$validParams = array('callback' => '', 'dir' => 'DESC', 'sort' => '', 'start' => 0, 'limit' => 25, 'filter' => '', 'search' => '', 'action' => '', 'xaction' => '', 'data' => '', 'status' => '', 'query' => '', 'fields' => "");
function getExtJSParams()
{
$validParams = array('callback' => '', 'dir' => 'DESC', 'sort' => '', 'start' => 0, 'limit' => 25, 'filter' => '',
'search' => '', 'action' => '', 'xaction' => '', 'data' => '', 'status' => '', 'query' => '', 'fields' => "");
$result = array();
foreach ($validParams as $paramName => $paramDefault) {
$result[$paramName] = isset($_REQUEST[$paramName]) ? $_REQUEST[$paramName] : isset($_REQUEST[$paramName]) ? $_REQUEST[$paramName] : $paramDefault;
$result[$paramName] = isset($_REQUEST[$paramName]) ?
$_REQUEST[$paramName] : isset($_REQUEST[$paramName]) ? $_REQUEST[$paramName] : $paramDefault;
}
return $result;
}
function sendJsonResultGeneric($response, $callback) {
function sendJsonResultGeneric($response, $callback)
{
header("Content-Type: application/json");
$finalResponse = G::json_encode($response);
if ($callback != '') {
@@ -91,7 +95,8 @@ function sendJsonResultGeneric($response, $callback) {
}
}
function expandNode(){
function expandNode()
{
extract(getExtJSParams());
require_once ("classes/model/AppFolder.php");
@@ -102,38 +107,33 @@ function expandNode(){
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);
$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")) {
global $RBAC;
$user = ($RBAC->userCanAccess('PM_ALLCASES') == 1)? '' : $_SESSION['USER_LOGGED'];
$folderContentObj = $oPMFolder->getFolderContent ( $_POST ['node'] != 'root' ? $_POST ['node'] == 'NA' ? "" : $_POST ['node'] : $rootFolder, array(), NULL, NULL, $limit, $start, $user);
$folderContentObj = $oPMFolder->getFolderContent ($_POST ['node'] != 'root' ?
$_POST ['node'] == 'NA' ? "" : $_POST ['node'] : $rootFolder, array(), null, null, $limit, $start, $user);
$folderContent=$folderContentObj['documents'];
$totalDocuments=$folderContentObj['totalDocumentsCount'];
$totalItems+=count($folderContent);
@@ -157,7 +157,8 @@ function expandNode(){
$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 ['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;
@@ -181,7 +182,6 @@ function expandNode(){
$processListTree [] = $tempTree;
$tempTree=array();
}
/*if ($_POST ['node'] == '/') {
$notInFolderLabel = G::LoadTranslation ('ID_NOT_IN_FOLDER');
$tempTree ['text'] = $notInFolderLabel;
@@ -215,18 +215,13 @@ function expandNode(){
*/
/*$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'];
@@ -241,7 +236,6 @@ function expandNode(){
} 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);
@@ -251,19 +245,14 @@ function expandNode(){
}
}
$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'];
@@ -286,7 +275,6 @@ function expandNode(){
} 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'];
@@ -295,7 +283,6 @@ function expandNode(){
$tempTree ['owner'] = $obj['USR_USERNAME'];
$tempTree ['owner_firstname'] = "";
$tempTree ['owner_lastname'] = "";
}
$tempTree ['deletelabel'] = $obj['DELETE_LABEL'];
@@ -363,10 +350,12 @@ function expandNode(){
print G::json_encode ($processListTree);
}
function openPMFolder(){
function openPMFolder()
{
$WIDTH_PANEL = 350;
G::LoadClass ('tree');
$folderContent = $oPMFolder->getFolderList ( $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ? "" : $_POST ['folderID'] : $rootFolder );
$folderContent = $oPMFolder->getFolderList ($_POST ['folderID'] != '0' ?
$_POST ['folderID'] == 'NA' ? "" : $_POST ['folderID'] : $rootFolder);
//krumo($folderContent);
if (! is_array ($folderContent)) {
echo $folderContent;
@@ -386,15 +375,16 @@ function openPMFolder(){
$i ++;
//if ($obj->item_type=="F") {
$RowClass = ($i % 2 == 0) ? 'Row1' : 'Row2';
$id_delete = G::LoadTranslation('ID_DELETE');
$id_edit = G::LoadTranslation('ID_EDIT');
$htmlGroup = <<<GHTML
<table cellspacing='0' cellpadding='0' border='1' style='border:0px;' width="100%" class="pagedTable">
<tr id="{$i}" onmouseout="setRowClass(this, '{$RowClass}')" onmouseover="setRowClass(this, 'RowPointer' )" class="{$RowClass}" style="cursor:hand">
<td width='' class='treeNode' style='border:0px;background-color:transparent;'><a href="#" onclick="focusRow(this, 'Selected');openPMFolder('{$obj['FOLDER_UID']}','{$_POST['rootfolder']}');">
<tr id="{$i}" onmouseout="setRowClass(this, '{$RowClass}')" onmouseover="setRowClass(this, 'RowPointer')"
class="{$RowClass}" style="cursor:hand">
<td width='' class='treeNode' style='border:0px;background-color:transparent;'><a href="#"
onclick="focusRow(this, 'Selected');openPMFolder('{$obj['FOLDER_UID']}','{$_POST['rootfolder']}');">
<img src="/images/folderV2.gif" border = "0" valign="middle" />&nbsp;{$obj['FOLDER_NAME']}</a>
<a href="#" onclick="deletePMFolder('{$obj['FOLDER_UID']}','{$_POST['rootfolder']}');">&nbsp; {$id_delete}</a>
</td>
@@ -405,7 +395,6 @@ GHTML;
$ch = & $tree->addChild ($key, $htmlGroup, array ('nodeType' => 'child'));
$ch->point = ' ';
}
$RowClass = ($i % 2 == 0) ? 'Row1' : 'Row2';
$key = 0;
@@ -413,8 +402,10 @@ GHTML;
$notInFolderLabel = G::LoadTranslation ('ID_NOT_IN_FOLDER');
$htmlGroup = <<<GHTML
<table cellspacing='0' cellpadding='0' border='1' style='border:0px;' width="100%" class="pagedTable">
<tr id="{$i}" onclick="focusRow(this, 'Selected');openPMFolder('NA');" onmouseout="setRowClass(this, '{$RowClass}')" onmouseover="setRowClass(this, 'RowPointer' )" class="{$RowClass}">
<td width='' class='treeNode' style='border:0px;background-color:transparent;'><a href="#" onclick=""><img src="/images/folderV2.gif" border = "0" valign="middle" />&nbsp;- {$notInFolderLabel} -</a>&nbsp;</td>
<tr id="{$i}" onclick="focusRow(this, 'Selected');openPMFolder('NA');"
onmouseout="setRowClass(this, '{$RowClass}')" onmouseover="setRowClass(this, 'RowPointer')" class="{$RowClass}">
<td width='' class='treeNode' style='border:0px;background-color:transparent;'><a href="#" onclick="">
<img src="/images/folderV2.gif" border = "0" valign="middle" />&nbsp;- {$notInFolderLabel} -</a>&nbsp;</td>
</tr>
</table>
@@ -429,15 +420,18 @@ GHTML;
}
function getPMFolderContent(){
function getPMFolderContent()
{
$swSearch = false;
if (isset ( $_POST ['folderID'] )) { //Render content of a folder
if (isset ($_POST ['folderID'])) {
//Render content of a folder
$folderID = $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ? "" : $_POST ['folderID'] : $rootFolder;
$folderContent = $oPMFolder->getFolderContent ($folderID);
} else { // Perform a Search
} else {
// Perform a Search
$swSearch = true;
$folderContent = $oPMFolder->getFolderContent ( NULL, array (), $_POST ['searchKeyword'], $_POST ['type'] );
$folderContent = $oPMFolder->getFolderContent (null, array (), $_POST ['searchKeyword'], $_POST ['type']);
}
array_unshift ($folderContent, array ('id' => 'char'));
if (! is_array ($folderContent)) {
@@ -465,18 +459,23 @@ function getPMFolderContent(){
}
if (! $swSearch) {
$G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'appFolder/appFolderDocumentList', $c, array ('folderID' => $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ? "/" : $_POST ['folderID'] : $rootFolder, 'labelFolderAddFile' => $labelFolderAddFile, 'labelFolderAddFolder' => $labelFolderAddFolder ) );
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'appFolder/appFolderDocumentListHeader', '', array (), 'appFolderList?folderID=' . $_POST ['folderID'] );
$G_PUBLISH->AddContent ('propeltable', 'paged-table', 'appFolder/appFolderDocumentList',
$c, array ('folderID' => $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ?
"/" : $_POST ['folderID'] : $rootFolder, 'labelFolderAddFile' => $labelFolderAddFile,
'labelFolderAddFolder' => $labelFolderAddFolder));
$G_PUBLISH->AddContent ('xmlform', 'xmlform', 'appFolder/appFolderDocumentListHeader', '',
array (), 'appFolderList?folderID=' . $_POST ['folderID']);
} else {
$G_PUBLISH->AddContent ('propeltable', 'paged-table', 'appFolder/appFolderDocumentListSearch', $c, array ());
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'appFolder/appFolderDocumentListHeader', '', array (), 'appFolderList?folderID=/' );
$G_PUBLISH->AddContent ('xmlform', 'xmlform', 'appFolder/appFolderDocumentListHeader', '', array (),
'appFolderList?folderID=/');
}
G::RenderPage ('publish', 'raw');
}
function getPMFolderTags(){
function getPMFolderTags()
{
// Default font sizes
$min_font_size = 12;
$max_font_size = 30;
@@ -502,7 +501,9 @@ function getPMFolderTags(){
$href = "#";
//$href="?q="$tag;
$size = $min_font_size + ($count - $minimum_count) * ($max_font_size - $min_font_size) / $spread;
$cloud_tags [] = '<a style="font-size: ' . floor ( $size ) . 'px' . '" class="tag_cloud" href="' . $href . '" onClick="getPMFolderSearchResult(\'' . $tag . '\',\'TAG\')"' . ' title="\'' . $tag . '\' returned a count of ' . $count . '">' . htmlspecialchars ( stripslashes ( $tag ) ) . '</a>';
$cloud_tags [] = '<a style="font-size: ' . floor ($size) . 'px' . '" class="tag_cloud" href="' . $href .
'" onClick="getPMFolderSearchResult(\'' . $tag . '\',\'TAG\')"' . ' title="\'' . $tag .
'\' returned a count of ' . $count . '">' . htmlspecialchars (stripslashes ($tag)) . '</a>';
}
$cloud_html = join ("\n", $cloud_tags) . "\n";
@@ -510,11 +511,10 @@ function getPMFolderTags(){
}
function uploadDocument(){
function uploadDocument()
{
$uploadDocumentComponent=array();
$uploadDocumentComponent["xtype"]= "tabpanel";
$uploadDocumentComponent["stateId"]= "upload_tabpanel";
$uploadDocumentComponent["activeTab"]= "uploadform";
@@ -523,7 +523,8 @@ function uploadDocument(){
$uploadDocumentComponent["stateEvents"]= array("tabchange");
$uploadDocumentComponent["getState"]= "function_getState";
$functionsToReplace['function_getState']="function() { return {
$functionsToReplace['function_getState']="function() {
return {
activeTab:this.items.indexOf(this.getActiveTab())
};
}";
@@ -535,7 +536,6 @@ function uploadDocument(){
$itemA=array();
$itemA["xtype"]= "swfuploadpanel";
$itemA["title"]= "flashupload";
$itemA["height"]= "300";
@@ -576,13 +576,15 @@ function uploadDocument(){
$itemA["labelWidth"]="125";
$itemA["url"]="URL_SCRIPT";
$itemA["title"]=G::LoadTranslation('ID_UPLOAD');
//$itemA["tooltip"]="Max File Size <strong>". ((get_max_file_size() / 1024) / 1024)." MB</strong><br />Max Post Size<strong>". ((get_max_upload_limit() / 1024) / 1024)." MB</strong><br />";
//$itemA["tooltip"]="Max File Size <strong>". ((get_max_file_size() / 1024) / 1024)." MB</strong><br />
//Max Post Size<strong>". ((get_max_upload_limit() / 1024) / 1024)." MB</strong><br />";
$itemA["frame"]=true;
$itemA["items"]=array();
$itemB=array();
$itemB["xtype"]="displayfield";
$itemB["value"]="Max File Size <strong>". ((get_max_file_size() / 1024) / 1024)." MB</strong><br />Max Post Size<strong>". ((get_max_upload_limit() / 1024) / 1024)." MB</strong><br />";
$itemB["value"]="Max File Size <strong>". ((get_max_file_size() / 1024) / 1024)." MB</strong><br />
Max Post Size<strong>". ((get_max_upload_limit() / 1024) / 1024)." MB</strong><br />";
//$itemA["items"][]=$itemB;
for ($i=0; $i<7; $i++) {
@@ -731,7 +733,6 @@ function uploadDocument(){
$finalResponse=G::json_encode($uploadDocumentComponent);
$finalResponse=str_replace("URL_SCRIPT","../appFolder/appFolderAjax.php",$finalResponse);
foreach ($functionsToReplace as $key => $originalFunction) {
$finalResponse=str_replace('"'.$key.'"',$originalFunction,$finalResponse);
}
echo ($finalResponse);
@@ -749,17 +750,22 @@ function uploadDocument(){
$Fields ['appId'] = $_POST ['appId'];
$Fields ['docType'] = $_POST ['docType'];
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'appFolderSaveDocument?UID=' . $_POST ['docID'] . '&appId=' . $_POST ['appId'] . '&docType=' . $_POST ['docType'] );
$G_PUBLISH->AddContent ('xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields,
'appFolderSaveDocument?UID=' . $_POST ['docID'] . '&appId=' . $_POST ['appId'] . '&docType=' .
$_POST ['docType']);
G::RenderPage ('publish', 'raw');
*/
}
function copyAction(){
function copyAction()
{
copyMoveAction("copy");
}
function moveAction(){
function moveAction()
{
copyMoveAction("move");
}
function copyMoveAction($type){
function copyMoveAction($type)
{
require_once ("classes/model/AppFolder.php");
$oPMFolder = new AppFolder ();
@@ -798,8 +804,6 @@ function copyMoveAction($type){
$itemField["allowBlank"]=false;
$copyDialog["items"][]=$itemField;
$copyDialog["buttons"]=array();
$itemButton=array();
@@ -856,29 +860,29 @@ function copyMoveAction($type){
$finalResponse=G::json_encode($copyDialog);
foreach ($functionsToReplace as $key => $originalFunction) {
$finalResponse=str_replace('"'.$key.'"',$originalFunction,$finalResponse);
}
$finalResponse=str_replace("URL_SCRIPT","../appFolder/appFolderAjax.php",$finalResponse);
echo ($finalResponse);
}
function copyExecute(){
function copyExecute()
{
copyMoveExecute("copy");
}
function moveExecute(){
function moveExecute()
{
copyMoveExecute("move");
}
function copyMoveExecute($type){
function copyMoveExecute($type)
{
uploadExternalDocument();
}
function documentVersionHistory(){
function documentVersionHistory()
{
$folderID = $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ? "" : $_POST ['folderID'] : $rootFolder;
$folderContent = $oPMFolder->getFolderContent ($folderID, array ($_POST ['appDocId']));
@@ -898,13 +902,15 @@ function documentVersionHistory(){
$G_PUBLISH = new Publisher ();
require_once ('classes/class.xmlfield_InputPM.php');
$G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'appFolder/appFolderDocumentListHistory', $c, array ('folderID' => $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ? "/" : $_POST ['folderID'] : $rootFolder ) );
$G_PUBLISH->AddContent ('propeltable', 'paged-table', 'appFolder/appFolderDocumentListHistory', $c,
array ('folderID' => $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ?
"/" : $_POST ['folderID'] : $rootFolder));
G::RenderPage ('publish', 'raw');
}
function uploadExternalDocument(){
function uploadExternalDocument()
{
$response['action']=$_POST['action']. " - ".$_POST['option'];
$response['error']="error";
$response['message']="error";
@@ -919,34 +925,38 @@ function uploadExternalDocument(){
$quequeUpload=array();
// upload files & check for errors
for ($i=0; $i<$uploadedInstances; $i++) {
$errors[$i]=NULL;
$errors[$i] = null;
$tmp = $_FILES['uploadedFile']['tmp_name'][$i];
$items[$i] = stripslashes($_FILES['uploadedFile']['name'][$i]);
if($sw_error_exists) $up_err = $_FILES['uploadedFile']['error'][$i];
else $up_err=(file_exists($tmp)?0:4);
if ($sw_error_exists) {
$up_err = $_FILES['uploadedFile']['error'][$i];
} else {
$up_err=(file_exists($tmp)?0:4);
}
if ($items[$i]=="" || $up_err==4) {
$emptyInstances++;
continue;
}
if ($up_err==1 || $up_err==2) {
$errors[$i]='miscfilesize';
$sw_error=true; continue;
$sw_error = true;
continue;
}
if ($up_err==3) {
$errors[$i]='miscfilepart';
$sw_error=true; continue;
$sw_error=true;
continue;
}
if (!@is_uploaded_file($tmp)) {
$errors[$i]='uploadfile';
$sw_error=true; continue;
$sw_error=true;
continue;
}
//The uplaoded files seems to be correct and ready to be uploaded. Add to the Queque
$fileInfo=array("tempName"=>$tmp,"fileName"=>$items[$i]);
$quequeUpload[]=$fileInfo;
}}elseif(isset($_POST['selitems'])){
}
} elseif (isset($_POST['selitems'])) {
$response="";
$response['msg']="correct reload";
$response['success']=true;
@@ -960,7 +970,6 @@ function uploadExternalDocument(){
$docInfo['FOLDER_UID'] = $_POST['new_dir'];
$docInfo['APP_DOC_CREATE_DATE'] = date('Y-m-d H:i:s');
$oAppDocument->update($docInfo);
//G::pr($docInfo);
}
}
@@ -975,7 +984,6 @@ function uploadExternalDocument(){
$folderId=$_POST['dir']==""?"/":$_POST['dir'];
$appId=$_POST['appId'];
$docType=isset($_POST['docType'])?$_GET['docType']:"INPUT";
//save info
require_once ("classes/model/AppDocument.php");
@@ -991,10 +999,8 @@ function uploadExternalDocument(){
$aID=array('INP_DOC_DESTINATION_PATH'=>$folderStructure['PATH']);
}
$oAppDocument = new AppDocument();
//Get the Custom Folder ID (create if necessary)
$oFolder=new AppFolder();
if ($docUid!=-1) {
@@ -1006,11 +1012,12 @@ function uploadExternalDocument(){
$folderId=$folderId;
$fileTags="EXTERNAL";
}
foreach ($quequeUpload as $key => $fileObj) {
switch ($actionType) {
case "R": //replace
$aFields = array('APP_DOC_UID' => $appDocUid,
case "R":
//replace
$aFields = array(
'APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId,
'DOC_VERSION' => $docVersion,
'DEL_INDEX' => 1,
@@ -1018,53 +1025,53 @@ function uploadExternalDocument(){
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $docType,
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ?
$_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => $fileObj['fileName'],
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
'APP_DOC_TAGS' => $fileTags
);
$oAppDocument->update($aFields);
break;
case "NV": //New Version
$aFields = array('APP_DOC_UID' => $appDocUid,
case "NV":
//New Version
$aFields = array(
'APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId,
'DEL_INDEX' => 1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $docType,
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ?
$_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => $fileObj['fileName'],
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
'APP_DOC_TAGS' => $fileTags
);
$oAppDocument->create($aFields);
break;
default: //New
$aFields = array('APP_UID' => $appId,
default:
//New
$aFields = array(
'APP_UID' => $appId,
'DEL_INDEX' => isset($_SESSION['INDEX'])?$_SESSION['INDEX']:1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $docType,
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ?
$_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => $fileObj['fileName'],
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
'APP_DOC_TAGS' => $fileTags
);
$oAppDocument->create($aFields);
break;
}
$sAppDocUid = $oAppDocument->getAppDocUid();
$iDocVersion = $oAppDocument->getDocVersion();
$info = pathinfo($oAppDocument->getAppDocFilename());
@@ -1080,7 +1087,6 @@ function uploadExternalDocument(){
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ($oPluginRegistry->existsTrigger (PM_UPLOAD_DOCUMENT) && class_exists ('uploadDocumentData')) {
$oData['APP_UID'] = $appId;
$documentData = new uploadDocumentData (
$appId,
@@ -1089,35 +1095,33 @@ function uploadExternalDocument(){
$fileObj['fileName'],
$sAppDocUid
);
//$oPluginRegistry->executeTriggers (PM_UPLOAD_DOCUMENT , $documentData);
//unlink ($sPathName . $sFileName);
}
//end plugin
if($sw_error) { // there were errors
if ($sw_error) {
// there were errors
$err_msg="";
for ($i=0; $i<$uploadedInstances; $i++) {
if($errors[$i]==NULL) continue;
if ($errors[$i]==null) {
continue;
}
$err_msg .= $items[$i]." : ".$errors[$i]."\n";
}
$response['error']=$err_msg;
$response['message']=$err_msg;
$response['success']=false;
}
elseif ($emptyInstances==$uploadedInstances) {
} elseif ($emptyInstances==$uploadedInstances) {
$response['error']="You may upload at least one file";
$response['message']="You may upload at least one file";
$response['success']=false;
}
else {
} else {
$response['error']="Upload complete";
$response['message']="Upload complete";
$response['success']=true;
}
}
}
}
print_r(G::json_encode($response));
/*
@@ -1129,17 +1133,23 @@ function uploadExternalDocument(){
$Fields ['appId'] = "00000000000000000000000000000000";
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'appFolderSaveDocument?UID=-1&appId=' . $Fields ['appId'] . "&folderId=" . $_POST ['folderID'] );
$G_PUBLISH->AddContent ('xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields,
'appFolderSaveDocument?UID=-1&appId=' . $Fields ['appId'] . "&folderId=" . $_POST ['folderID']);
G::RenderPage ('publish', 'raw');
*/
}
function newFolder(){
function newFolder()
{
require_once ("classes/model/AppFolder.php");
$oPMFolder = new AppFolder ();
//G::pr($_POST);
if($_POST ['dir']=="") $_POST ['dir']="/";
if($_POST ['dir']=="root") $_POST ['dir']="/";
if ($_POST ['dir']=="") {
$_POST ['dir']="/";
}
if ($_POST ['dir']=="root") {
$_POST ['dir']="/";
}
$folderStructure = $oPMFolder->getFolderStructure ($_POST ['dir']);
//G::pr($folderStructure);
$folderPath = $folderStructure ['PATH'];
@@ -1148,7 +1158,6 @@ function newFolder(){
$formNewFolder=array();
$formNewFolder["xtype"]="form";
$formNewFolder["id"]= "simpleform";
$formNewFolder["labelWidth"]=125;
@@ -1157,8 +1166,6 @@ function newFolder(){
$formNewFolder["frame"]= true;
$formNewFolder["items"]= array();
$field=array();
$field["xtype"]= "label";
$field["fieldLabel"]= "Path";
@@ -1199,10 +1206,8 @@ function newFolder(){
$field["allowBlank"]=false;
$formNewFolder["items"][]= $field;
$formNewFolder["buttons"]= array();
$button = array();
$button["text"] = "Create";
$button["handler"] = 'handlerCreate';
@@ -1261,7 +1266,8 @@ function newFolder(){
*/
}
function appFolderSave(){
function appFolderSave()
{
require_once ("classes/model/AppFolder.php");
$oPMFolder = new AppFolder ();
$form = $_POST['form'];
@@ -1279,21 +1285,21 @@ function appFolderSave(){
$response=array_merge($response,$folderCreateResponse);
print_r(G::json_encode($response));
}
function documentInfo(){
function documentInfo()
{
$oFolder = new AppFolder ();
$Fields = $oPMFolder->getCompleteDocumentInfo ( $_POST ['appId'], $_POST ['appDocId'], $_POST ['docVersion'], $_POST ['docID'], $_POST ['usrUid'] );
$Fields = $oPMFolder->getCompleteDocumentInfo ($_POST ['appId'], $_POST ['appDocId'], $_POST ['docVersion'],
$_POST ['docID'], $_POST ['usrUid']);
$G_PUBLISH = new Publisher ();
$G_PUBLISH->AddContent ('xmlform', 'xmlform', 'appFolder/appFolderDocumentInfo', '', $Fields, '');
G::RenderPage ('publish', 'raw');
}
function documentdelete(){
function documentdelete()
{
include_once ("classes/model/AppDocument.php");
$oAppDocument = new AppDocument ();
$oAppDocument->remove($_POST['sFileUID'],$_POST['docVersion']);
@@ -1303,14 +1309,16 @@ function documentdelete(){
unlink($sPathName.$_POST['sFileUID'].'_1.jpg');*/
}
function deletePMFolder(){
function deletePMFolder()
{
include_once ("classes/model/AppFolder.php");
$oAppFoder = new AppFolder ();
$oAppFoder->remove($_POST['sFileUID'],$_POST['rootfolder']);
}
function getMime($fileName){
function getMime($fileName)
{
$fileName=basename($fileName);
$fileNameA=explode(".",$fileName);
$return['description']=G::LoadTranslation("MIME_DES_FILE");
@@ -1325,15 +1333,19 @@ function getMime($fileName){
return $return;
}
function get_max_file_size() { // get php max_upload_file_size
function get_max_file_size()
{
// get php max_upload_file_size
return calc_php_setting_bytes(ini_get("upload_max_filesize"));
}
function get_max_upload_limit() {
function get_max_upload_limit()
{
return calc_php_setting_bytes(ini_get('post_max_size'));
}
function calc_php_setting_bytes( $value ) {
function calc_php_setting_bytes($value)
{
//if(@eregi("G$",$value)) {
// $value = substr($value,0,-1);
// $value = round($value*1073741824);
@@ -1347,34 +1359,36 @@ function calc_php_setting_bytes( $value ) {
if (@preg_match("/G$/i", $value)) {
$value = substr($value, 0, -1);
$value = round($value * 1073741824);
}
else {
} else {
if (@preg_match("/M$/i", $value)) {
$value = substr($value, 0, -1);
$value = round($value * 1048576);
}
else {
} else {
if (@preg_match("/K$/i", $value)) {
$value = substr($value, 0, -1);
$value = round($value * 1024);
}
}
}
return $value;
}
function get_abs_item($dir, $item) { // get absolute file+path
function get_abs_item($dir, $item)
{
// get absolute file+path
if (is_array($item)) {
// FTP Mode
$abs_item = '/' . get_abs_dir($dir)."/".$item['name'];
if( get_is_dir($item)) $abs_item.='/';
if (get_is_dir($item)) {
$abs_item.='/';
}
return extPathName($abs_item);
}
return extPathName(get_abs_dir($dir)."/".$item);
}
function extPathName($p_path,$p_addtrailingslash = false) {
function extPathName($p_path, $p_addtrailingslash=false)
{
$retval = "";
$isWin = (substr(PHP_OS, 0, 3) == 'WIN');
@@ -1416,6 +1430,6 @@ function extPathName($p_path,$p_addtrailingslash = false) {
$retval = '/'.$retval;
}
}
return $retval;
}