casting non mandatory types from "", to avoid database query problems.
This commit is contained in:
parent
2e572c652c
commit
007a7ee7ef
3 changed files with 100 additions and 85 deletions
|
@ -12,6 +12,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
->addActionContext('create-list-item', 'json')
|
->addActionContext('create-list-item', 'json')
|
||||||
->addActionContext('edit-list-item', 'json')
|
->addActionContext('edit-list-item', 'json')
|
||||||
->addActionContext('delete-list-item', 'json')
|
->addActionContext('delete-list-item', 'json')
|
||||||
|
->addActionContext('delete-list-items', 'json')
|
||||||
->addActionContext('update-list-item', 'json')
|
->addActionContext('update-list-item', 'json')
|
||||||
->addActionContext('update-file-item', 'json')
|
->addActionContext('update-file-item', 'json')
|
||||||
->addActionContext('create-template', 'json')
|
->addActionContext('create-template', 'json')
|
||||||
|
@ -192,6 +193,14 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
$historyService = new Application_Service_HistoryService();
|
$historyService = new Application_Service_HistoryService();
|
||||||
$historyService->deletePlayedItem($history_id);
|
$historyService->deletePlayedItem($history_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteListItemsAction()
|
||||||
|
{
|
||||||
|
$history_ids = $this->_getParam('ids');
|
||||||
|
|
||||||
|
$historyService = new Application_Service_HistoryService();
|
||||||
|
$historyService->deletePlayedItems($history_ids);
|
||||||
|
}
|
||||||
|
|
||||||
public function updateListItemAction()
|
public function updateListItemAction()
|
||||||
{
|
{
|
||||||
|
|
|
@ -638,6 +638,7 @@ class Application_Service_HistoryService
|
||||||
$metadata = array();
|
$metadata = array();
|
||||||
$fields = $template["fields"];
|
$fields = $template["fields"];
|
||||||
$required = $this->mandatoryItemFields();
|
$required = $this->mandatoryItemFields();
|
||||||
|
$phpCasts = $this->getPhpCasts();
|
||||||
|
|
||||||
for ($i = 0, $len = count($fields); $i < $len; $i++) {
|
for ($i = 0, $len = count($fields); $i < $len; $i++) {
|
||||||
|
|
||||||
|
@ -650,14 +651,14 @@ class Application_Service_HistoryService
|
||||||
}
|
}
|
||||||
|
|
||||||
$isFileMd = $field["isFileMd"];
|
$isFileMd = $field["isFileMd"];
|
||||||
$entry = $templateValues[$prefix.$key];
|
$entry = $phpCasts[$field["type"]]($templateValues[$prefix.$key]);
|
||||||
|
|
||||||
if ($isFileMd && isset($file)) {
|
if ($isFileMd && isset($file)) {
|
||||||
Logging::info("adding metadata associated to a file for {$key}");
|
Logging::info("adding metadata associated to a file for {$key} = {$entry}");
|
||||||
$md[$key] = $entry;
|
$md[$key] = $entry;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logging::info("adding metadata for {$key}");
|
Logging::info("adding metadata for {$key} = {$entry}");
|
||||||
$metadata[$key] = $entry;
|
$metadata[$key] = $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -824,6 +825,25 @@ class Application_Service_HistoryService
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* id is an id in cc_playout_history */
|
||||||
|
public function deletePlayedItems($ids) {
|
||||||
|
|
||||||
|
$this->con->beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$records = CcPlayoutHistoryQuery::create()->findPks($ids, $this->con);
|
||||||
|
$records->delete($this->con);
|
||||||
|
|
||||||
|
$this->con->commit();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$this->con->rollback();
|
||||||
|
Logging::info($e);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------- Following code is for History Templates --------------------------//
|
//---------------- Following code is for History Templates --------------------------//
|
||||||
|
@ -842,6 +862,21 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getPhpCasts() {
|
||||||
|
|
||||||
|
$fields = array(
|
||||||
|
TEMPLATE_DATE => "strval",
|
||||||
|
TEMPLATE_TIME => "strval",
|
||||||
|
TEMPLATE_DATETIME => "strval",
|
||||||
|
TEMPLATE_STRING => "strval",
|
||||||
|
TEMPLATE_BOOLEAN => "intval", //boolval only exists in php 5.5+ wtf?
|
||||||
|
TEMPLATE_INT => "intval",
|
||||||
|
TEMPLATE_FLOAT => "floatval",
|
||||||
|
);
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
private function getSqlTypes() {
|
private function getSqlTypes() {
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,26 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
var sDom = 'l<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>';
|
var sDom = 'l<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>';
|
||||||
|
|
||||||
|
var selectedLogItems = {};
|
||||||
|
|
||||||
|
function getSelectedLogItems() {
|
||||||
|
var items = Object.keys(selectedLogItems);
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addSelectedLogItem(id) {
|
||||||
|
selectedLogItems[id] = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeSelectedLogItem(id) {
|
||||||
|
delete selectedLogItems[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
function emptySelectedLogItems() {
|
||||||
|
selectedLogItems = {};
|
||||||
|
}
|
||||||
|
|
||||||
function getFileName(ext){
|
function getFileName(ext){
|
||||||
var filename = $("#his_date_start").val()+"_"+$("#his_time_start").val()+"m--"+$("#his_date_end").val()+"_"+$("#his_time_end").val()+"m";
|
var filename = $("#his_date_start").val()+"_"+$("#his_time_start").val()+"m--"+$("#his_date_end").val()+"_"+$("#his_time_end").val()+"m";
|
||||||
filename = filename.replace(/:/g,"h");
|
filename = filename.replace(/:/g,"h");
|
||||||
|
@ -249,6 +269,11 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
$historyContentDiv = $("#history_content");
|
$historyContentDiv = $("#history_content");
|
||||||
|
|
||||||
|
function redrawTables() {
|
||||||
|
oTableAgg.fnDraw();
|
||||||
|
oTableItem.fnDraw();
|
||||||
|
}
|
||||||
|
|
||||||
function removeHistoryDialog() {
|
function removeHistoryDialog() {
|
||||||
$hisDialogEl.dialog("destroy");
|
$hisDialogEl.dialog("destroy");
|
||||||
$hisDialogEl.remove();
|
$hisDialogEl.remove();
|
||||||
|
@ -315,54 +340,6 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
$historyContentDiv.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
$historyContentDiv.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||||
$historyContentDiv.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
$historyContentDiv.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||||
|
|
||||||
// 'open' an information row when a row is clicked on
|
|
||||||
//for create/edit/delete
|
|
||||||
function openRow(oTable, tr) {
|
|
||||||
var links = ['url-edit', 'url-delete'],
|
|
||||||
i, len,
|
|
||||||
attr,
|
|
||||||
name,
|
|
||||||
$link,
|
|
||||||
$div;
|
|
||||||
|
|
||||||
$div = $("<div/>");
|
|
||||||
|
|
||||||
for (i = 0, len = links.length; i < len; i++) {
|
|
||||||
|
|
||||||
attr = links[i];
|
|
||||||
|
|
||||||
if (tr.hasAttribute(attr)) {
|
|
||||||
name = attr.split("-")[1];
|
|
||||||
|
|
||||||
$link = $("<a/>", {
|
|
||||||
"href": tr.getAttribute(attr),
|
|
||||||
"text": $.i18n._(name),
|
|
||||||
"class": "his_"+name
|
|
||||||
});
|
|
||||||
|
|
||||||
$div.append($link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oTable.fnIsOpen(tr)) {
|
|
||||||
oTable.fnClose(tr);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
oTable.fnOpen(tr, $div, "his_update");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
$historyContentDiv.on("click", "#history_table_list tr", function(ev) {
|
|
||||||
openRow(oTableItem, this);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$historyContentDiv.on("click", "#history_table_aggregate tr", function(ev) {
|
|
||||||
openRow(oTableAgg, this);
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
$("#his_create").click(function(e) {
|
$("#his_create").click(function(e) {
|
||||||
var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
|
var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
|
||||||
|
|
||||||
|
@ -374,35 +351,6 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
}, "json");
|
}, "json");
|
||||||
});
|
});
|
||||||
|
|
||||||
$historyContentDiv.on("click", "a.his_edit", function(e) {
|
|
||||||
var url = e.target.href;
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
$.get(url, function(json) {
|
|
||||||
|
|
||||||
makeHistoryDialog(json.dialog);
|
|
||||||
|
|
||||||
}, "json");
|
|
||||||
});
|
|
||||||
|
|
||||||
$historyContentDiv.on("click", "a.his_delete", function(e) {
|
|
||||||
var url = e.target.href,
|
|
||||||
doDelete;
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
doDelete = confirm($.i18n._("Delete this history record?"));
|
|
||||||
|
|
||||||
if (doDelete) {
|
|
||||||
$.post(url, function(json) {
|
|
||||||
oTableAgg.fnDraw();
|
|
||||||
oTableItem.fnDraw();
|
|
||||||
|
|
||||||
}, "json");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('body').on("click", ".his_file_cancel, .his_item_cancel", function(e) {
|
$('body').on("click", ".his_file_cancel, .his_item_cancel", function(e) {
|
||||||
removeHistoryDialog();
|
removeHistoryDialog();
|
||||||
|
@ -425,7 +373,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
removeHistoryDialog();
|
removeHistoryDialog();
|
||||||
oTableAgg.fnDraw();
|
redrawTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, "json");
|
}, "json");
|
||||||
|
@ -453,12 +401,26 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
removeHistoryDialog();
|
removeHistoryDialog();
|
||||||
oTableItem.fnDraw();
|
redrawTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, "json");
|
}, "json");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$historyContentDiv.on("click", ".his_checkbox input", function(e) {
|
||||||
|
var checked = e.currentTarget.checked,
|
||||||
|
$tr = $(e.currentTarget).parents("tr"),
|
||||||
|
id = $tr.data("his-id");
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
addSelectedLogItem(id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
removeSelectedLogItem(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$historyContentDiv.find("#his_submit").click(function(ev){
|
$historyContentDiv.find("#his_submit").click(function(ev){
|
||||||
var fn,
|
var fn,
|
||||||
|
@ -470,8 +432,16 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
fn.start = oRange.start;
|
fn.start = oRange.start;
|
||||||
fn.end = oRange.end;
|
fn.end = oRange.end;
|
||||||
|
|
||||||
oTableAgg.fnDraw();
|
redrawTables();
|
||||||
oTableItem.fnDraw();
|
});
|
||||||
|
|
||||||
|
$historyContentDiv.find("#his_trash").click(function(ev){
|
||||||
|
var items = getSelectedLogItems(),
|
||||||
|
url = baseUrl+"playouthistory/delete-list-items";
|
||||||
|
|
||||||
|
$.post(url, {ids: items, format: "json"}, function(){
|
||||||
|
redrawTables();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$historyContentDiv.find("#his-tabs").tabs();
|
$historyContentDiv.find("#his-tabs").tabs();
|
||||||
|
@ -518,6 +488,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
if (c) {
|
if (c) {
|
||||||
$.post(deleteUrl, {format: "json"}, function(json) {
|
$.post(deleteUrl, {format: "json"}, function(json) {
|
||||||
oTableItem.fnDraw();
|
oTableItem.fnDraw();
|
||||||
|
oTableAgg.fnDraw();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue