return false; } if ($_POST['datatype'] == 'date') { $_POST['newvalue'] = strtotime($_POST['newvalue']); } //$db->debug=true; if (may_see_table($db, $USER, $tableinfo->id) && may_write($db, $tableinfo->id, $_post['recordid'], $USER)) { if ($_POST['datatype'] == 'mpulldown') { // $newvalue is a comma separated list with ids of the selected items // remove the last (extra) comma) $_POST['newvalue'] = substr($_POST['newvalue'], 0, -1); $valueArray = explode(',', $_POST['newvalue']); // figure out name of keytable $keytable = get_cell($db, $tableinfo->desname, 'key_table', 'columnname', $_POST['field']); if ($keytable) { update_mpulldown($db, $keytable, $_POST['recordid'], $valueArray); } } else { // if the value is really empty, set to NULL, this is essential for numeric fields if ($_POST['newvalue'] == '') { $result = $db->Execute("UPDATE {$tableinfo->realname} SET {$_POST['field']}=NULL WHERE id={$_POST['recordid']}"); } else { // escape nasty stuff before sending it the database $_POST['newvalue'] = addslashes($_POST['newvalue']); $result = $db->Execute("UPDATE {$tableinfo->realname} SET {$_POST['field']}='{$_POST['newvalue']}' WHERE id={$_POST['recordid']}"); } if ($result) { // The javascript code likes this answer, otherwise it will reload echo "SUCCESS!"; } else { echo "FAILED!";
unset($_POST); // or we won't see the new record unset($_SESSION["{$queryname}"]); } } elseif (isset($submit) && $submit == 'Modify Record') { $modfields = comma_array_SQL_where($db, $tableinfo->desname, "columnname", "modifiable", "Y"); // The pdf plugin wants to modify fields that have been set to modifiable=='N' if (!(check_g_data($db, $_POST, $tableinfo, true) && modify($db, $tableinfo->realname, $modfields, $_POST, $_POST['id'], $USER, $tableinfo->id))) { add_g_form($db, $tableinfo, $_POST, $_POST['id'], $USER, $PHP_SELF, $system_settings); printfooter(); exit; } else { // mpulldown $rd = $db->Execute('SELECT columnname,key_table FROM ' . $tableinfo->desname . " WHERE datatype='mpulldown'"); while ($rd && !$rd->EOF) { update_mpulldown($db, $rd->fields['key_table'], $_POST['id'], $_POST[$rd->fields['columnname']]); $rd->MoveNext(); } // upload files and images $rc = $db->Execute("SELECT id,columnname,datatype,thumb_x_size FROM {$tableinfo->desname} WHERE datatype='file' OR datatype='image'"); while (!$rc->EOF) { if ($_FILES[$rc->fields['columnname']]['name'][0]) { // delete all existing files //delete_column_file ($db,$tableinfo->id,$rc->fields['id'],$_POST['id'],$USER); // store the file uploaded by the user $fileid = upload_files($db, $tableinfo->id, $_POST['id'], $rc->fields['id'], $rc->fields['columnname'], $USER, $system_settings); if ($rc->fields['datatype'] == 'file') { // try to convert it to an html file if ($fileid) { $htmlfileid = process_file($db, $fileid, $system_settings); }