From c9a90446fa551fb8f78c92f7bbf46d720449ef0e Mon Sep 17 00:00:00 2001 From: Luis Fernando Saisa Lopez Date: Thu, 17 Jul 2014 11:24:44 -0400 Subject: [PATCH 1/2] BUG 13546 "Creacion de una nueva plantilla sin..." SOLVED - Creacion de una nueva plantilla sin nombre. - Problema resuelto, cuando se crea una nueva plantilla y no se coloca nada en la caja de texto, al hacer click en el boton "create" le mostrara un mensaje indicando que introduzca un nombre. Cuando se tiene creado varios plantillas y se quiere crear uno que ya existe, se mostrara un mensaje indicando que el file ya existe. --- .../methods/processes/processes_Ajax.php | 22 +++++++ .../processes/processes_FilesOptions.xml | 57 +++++++++++++------ 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/workflow/engine/methods/processes/processes_Ajax.php b/workflow/engine/methods/processes/processes_Ajax.php index e8bb90191..dec6593ef 100755 --- a/workflow/engine/methods/processes/processes_Ajax.php +++ b/workflow/engine/methods/processes/processes_Ajax.php @@ -695,6 +695,28 @@ try { //$json = new Services_JSON(); $sOutput = Bootstrap::json_encode($response); break; + case "verifyNameFile": + $response = array(); + $status = "OK"; + + $filename = $_POST["filename"]; + $pathDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST["pro_uid"] . PATH_SEP; + + if (is_dir($pathDirectory)) { + $myDirectory = opendir($pathDirectory); + + while ($myFile = readdir($myDirectory)) { + if ($myFile == $filename) { + $status = "ERROR"; + } + } + + closedir($myDirectory); + } + + $response["status"] = $status; + echo Bootstrap::json_encode($response); + break; } if (isset($sOutput)) { die($sOutput); diff --git a/workflow/engine/xmlform/processes/processes_FilesOptions.xml b/workflow/engine/xmlform/processes/processes_FilesOptions.xml index 2ea24df15..a8d6a7247 100755 --- a/workflow/engine/xmlform/processes/processes_FilesOptions.xml +++ b/workflow/engine/xmlform/processes/processes_FilesOptions.xml @@ -152,25 +152,48 @@ function showCreateEmptyOptions(e, MAIN_DIRECTORY){ } function saveEmptyFile(){ - var fileName = getField('emptyfilename').value + ".html"; - fileName = fileName.trim(); + var fileName = getField("emptyfilename").value.trim(); - var oRPC = new leimnud.module.rpc.xmlhttp({ - url : 'processes_Ajax', - args: 'action=saveFile&filename='+fileName+'&pro_uid='+CURRENT_PRO_UID+'&MAIN_DIRECTORY='+CURRENT_MAIN_DIRECTORY+'&fcontent=' - }); + if(fileName != "") { + fileName = fileName + ".html"; + fileName = fileName.trim(); - oRPC.callback = function(rpc){ - showCreateEmptyOptionsPanel.remove(); - /// goToDirectory(CURRENT_PRO_UID, 'mailTemplates', ''); - if(typeof(CURRENT_MAIN_DIRECTORY) != "undefined" ) { - goToDirectory(CURRENT_PRO_UID, CURRENT_MAIN_DIRECTORY, ''); - } else { - goToDirectory(CURRENT_PRO_UID, 'mailTemplates', ''); - } - editFile(CURRENT_PRO_UID, fileName) - }.extend(this); - oRPC.make(); + var rpcAjax = new leimnud.module.rpc.xmlhttp({ + url: "processes_Ajax", + method: "POST", + args: "action=verifyNameFile&filename=" + fileName + "&pro_uid=" + CURRENT_PRO_UID + "&MAIN_DIRECTORY=" + CURRENT_MAIN_DIRECTORY + "&fcontent=" + }); + + rpcAjax.callback = function (rpc) + { + var response = rpc.xmlhttp.responseText.parseJSON(); + var status = response.status; + + if (status == "OK") { + var oRPC = new leimnud.module.rpc.xmlhttp({ + url : 'processes_Ajax', + args: 'action=saveFile&filename='+fileName+'&pro_uid='+CURRENT_PRO_UID+'&MAIN_DIRECTORY='+CURRENT_MAIN_DIRECTORY+'&fcontent=' + }); + + oRPC.callback = function(rpc){ + showCreateEmptyOptionsPanel.remove(); + /// goToDirectory(CURRENT_PRO_UID, 'mailTemplates', ''); + if(typeof(CURRENT_MAIN_DIRECTORY) != "undefined" ) { + goToDirectory(CURRENT_PRO_UID, CURRENT_MAIN_DIRECTORY, ''); + } else { + goToDirectory(CURRENT_PRO_UID, 'mailTemplates', ''); + } + editFile(CURRENT_PRO_UID, fileName) + }.extend(this); + oRPC.make(); + } else { + new leimnud.module.app.alert().make({label: "The file exists."}); + } + }.extend(this); + rpcAjax.make(); + } else { + new leimnud.module.app.alert().make({label: "File name required."}); + } } function xReaload(){ From 2e48193d8c7270cba64c2278053768d876bfff63 Mon Sep 17 00:00:00 2001 From: Luis Fernando Saisa Lopez Date: Thu, 17 Jul 2014 15:05:43 -0400 Subject: [PATCH 2/2] BUG 13546 "Creacion de una nueva plantilla sin..." SOLVED - Creacion de una nueva plantilla sin nombre. - Problema resuelto, cuando se crea una nueva plantilla y no se coloca nada en la caja de texto, al hacer click en el boton "create" le mostrara un mensaje indicando que introduzca un nombre. Cuando se tiene creado varios plantillas y se quiere crear uno que ya existe, se mostrara un mensaje indicando que el file ya existe. --- .../engine/methods/processes/processes_Ajax.php | 13 +++---------- .../xmlform/processes/processes_FilesOptions.xml | 4 ++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/workflow/engine/methods/processes/processes_Ajax.php b/workflow/engine/methods/processes/processes_Ajax.php index dec6593ef..3014d4fed 100755 --- a/workflow/engine/methods/processes/processes_Ajax.php +++ b/workflow/engine/methods/processes/processes_Ajax.php @@ -700,18 +700,11 @@ try { $status = "OK"; $filename = $_POST["filename"]; + $pathDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST["pro_uid"] . PATH_SEP; - if (is_dir($pathDirectory)) { - $myDirectory = opendir($pathDirectory); - - while ($myFile = readdir($myDirectory)) { - if ($myFile == $filename) { - $status = "ERROR"; - } - } - - closedir($myDirectory); + if (file_exists($pathDirectory . PATH_SEP . $filename)) { + $status = "ERROR"; } $response["status"] = $status; diff --git a/workflow/engine/xmlform/processes/processes_FilesOptions.xml b/workflow/engine/xmlform/processes/processes_FilesOptions.xml index a8d6a7247..88efc785b 100755 --- a/workflow/engine/xmlform/processes/processes_FilesOptions.xml +++ b/workflow/engine/xmlform/processes/processes_FilesOptions.xml @@ -187,12 +187,12 @@ function saveEmptyFile(){ }.extend(this); oRPC.make(); } else { - new leimnud.module.app.alert().make({label: "The file exists."}); + new leimnud.module.app.alert().make({label: _("ID_EXISTS_FILES")}); } }.extend(this); rpcAjax.make(); } else { - new leimnud.module.app.alert().make({label: "File name required."}); + new leimnud.module.app.alert().make({label: _("ID_FILENAME_REQUIRED")}); } }