Merge pull request #2504 from luisfernandosl/BUG-13546

BUG 13546 "Creacion de una nueva plantilla sin..." SOLVED
This commit is contained in:
julceslauhub
2014-07-17 16:00:27 -04:00
2 changed files with 55 additions and 17 deletions

View File

@@ -695,6 +695,21 @@ try {
//$json = new Services_JSON(); //$json = new Services_JSON();
$sOutput = Bootstrap::json_encode($response); $sOutput = Bootstrap::json_encode($response);
break; break;
case "verifyNameFile":
$response = array();
$status = "OK";
$filename = $_POST["filename"];
$pathDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST["pro_uid"] . PATH_SEP;
if (file_exists($pathDirectory . PATH_SEP . $filename)) {
$status = "ERROR";
}
$response["status"] = $status;
echo Bootstrap::json_encode($response);
break;
} }
if (isset($sOutput)) { if (isset($sOutput)) {
die($sOutput); die($sOutput);

View File

@@ -152,9 +152,24 @@ function showCreateEmptyOptions(e, MAIN_DIRECTORY){
} }
function saveEmptyFile(){ function saveEmptyFile(){
var fileName = getField('emptyfilename').value + ".html"; var fileName = getField("emptyfilename").value.trim();
if(fileName != "") {
fileName = fileName + ".html";
fileName = fileName.trim(); fileName = fileName.trim();
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({ var oRPC = new leimnud.module.rpc.xmlhttp({
url : 'processes_Ajax', url : 'processes_Ajax',
args: 'action=saveFile&filename='+fileName+'&pro_uid='+CURRENT_PRO_UID+'&MAIN_DIRECTORY='+CURRENT_MAIN_DIRECTORY+'&fcontent=' args: 'action=saveFile&filename='+fileName+'&pro_uid='+CURRENT_PRO_UID+'&MAIN_DIRECTORY='+CURRENT_MAIN_DIRECTORY+'&fcontent='
@@ -171,6 +186,14 @@ function saveEmptyFile(){
editFile(CURRENT_PRO_UID, fileName) editFile(CURRENT_PRO_UID, fileName)
}.extend(this); }.extend(this);
oRPC.make(); oRPC.make();
} else {
new leimnud.module.app.alert().make({label: _("ID_EXISTS_FILES")});
}
}.extend(this);
rpcAjax.make();
} else {
new leimnud.module.app.alert().make({label: _("ID_FILENAME_REQUIRED")});
}
} }
function xReaload(){ function xReaload(){