Commit 2fbe6110 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Merge remote-tracking branch 'origin/crose_work' into raos_work

parents 326d11ed 4941e655
......@@ -109,38 +109,48 @@ Upload
-----------------
* The upload UI consist of three elements
* 1) A <div> tag with a) an optional filename of an earlier uploaded file and b) a trash Button.
* 1) A <div> tag with a) an optional filename of an earlier uploaded file and b) a trash button.
* 2) The 'browse' button (<input type='file' name='<feName>'>). This element will not be send by post.
* 3) A HTML hidden element with name=<feName> containing the <sipUpload>.
* A new uniq SIP (sipUpload) will be created for every upload formElement. These 'sipUpload' will be assigned to the upload browse button and to the upload delete button.
* The individual sipUpload is necessary to correctly handle multiple simultaenously forms when using r=0. Also, through this uniq id it's easy to distinguish between asynchron uploaded files.
* A new uniq SIP (sipUpload) will be created for every upload formElement. These 'sipUpload' will be assigned to the upload
browse button and to the upload delete button.
* The individual sipUpload is necessary to correctly handle multiple simultaenously forms when using r=0. Also, through
this uniq id it's easy to distinguish between asynchron uploaded files.
* The SIP on ther server contains the individual '_FILES' information submitted during the upload.
* Via the hidden element <feName> 'save()', access to the form individual upload status informations is given.
Upload to server, before 'save'
...............................
* If a user open's a file for upload via the browse button, that file is immediately transmitted to the server. The user will see a turning wheel until the upload finished.
* If a user open's a file for upload via the browse button, that file is immediately transmitted to the server. The user
will see a turning wheel until the upload finished.
* After successfull upload the 'Browse' button disappears and the filename, plus the delete button, will be displayed (client logic).
* The uploaded file will be checked: maxsize, mime type, check script.
* The uploaded file is still temporary. It has been renamed from $_SESSION['X'][<uploadSip>][FILES_TMP_NAME] to $_SESSION['X'][<uploadSip>][FILES_TMP_NAME].cached
* The upload action will be saved in the user session.
* $_SESSION['X'][<uploadSip>][FILES_TMP_NAME|FILES_NAME|FILES_ERROR|FILE_SIZE]
* The uploaded file is still temporary. It has been renamed from '[STORE_EXTRA][<uploadSip>][FILES_TMP_NAME]' to
'[STORE_EXTRA][<uploadSip>][FILES_TMP_NAME].cached'.
* The upload action will be saved in the user session:
[STORE_EXTRA][<uploadSip>][FILES_TMP_NAME]
[STORE_EXTRA][<uploadSip>][FILES_NAME]
[STORE_EXTRA][<uploadSip>][FILES_ERROR]
[STORE_EXTRA][<uploadSip>][FILE_SIZE]
* Clicks the user on delete button:
* In the usersession a flagDelete will be set: $_SESSION['X'][<uploadSip>]['flagDelete']='1'
* In the usersession a flagDelete will be set:
[STORE_EXTRA][<uploadSip>][FILES_FLAG_DELETE]='1'
* An optional previous upload file (still not saved on the final place) will be deleted.
* An optional existing variable $_SESSION['X'][<uploadSip>][FILES_TMP_NAME] will be deleted. The 'flagDelete' must not be change - it's later needed to detect to delete earlier uploaded files.
* An optional existing variable [STORE_EXTRA][<uploadSip>][FILES_TMP_NAME] will be deleted. The 'flagDelete' must not
be change - it's later needed to detect to delete earlier uploaded files.
Form save
.........
* Step 1: insert /update the record.
* Step 1: insert / update the record.
* Step 2: process all 'uploads'.
* Get every uniq sipUpload to every upload formElement. Get the corresponding temporary uploaded filename.
* If $_SESSION['X'][<uploadSip>]['flagDelete']='1' is set, delete prefious uploaded file.
* Calculate <destination>
* mv <file>.cached <destination>
* clientvalue[<feName>] = <destination>
* delete $_SESSION['X'][<uploadSip>]
* Step 3: update record with final `FileDestination'
* Get every uniq uploadSip (=[STORE_CLIENT][<feName>]) of every upload formElement. Get the corresponding temporary uploaded filename.
* If [STORE_EXTRA][<uploadSip>][FILES_FLAG_DELETE]='1' is set, delete previous uploaded file.
* If [STORE_EXTRA][<uploadSip>][FILES_TMP_NAME]!='': indicates that there is an upload.
* Calculate <fileDestination>
* mv <file>.cached <fileDestination>
* clientvalue[<feName>] = <fileDestination>
* delete [STORE_EXTRA][<uploadSip>]
* Step 3: update record with final <fileDestination>
Formelement type: DATE / DATETIME / TIME
----------------------------------------
......
......@@ -342,6 +342,9 @@ abstract class AbstractBuildForm {
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false, $storeUse = STORE_USE_DEFAULT, $mode = FORM_LOAD) {
$html = '';
$flagOutput = false;
// The following 'FormElement.parameter' will never be used during load (fe.type='upload').
$skip = [FE_SQL_UPDATE, FE_SQL_INSERT, FE_SQL_DELETE, FE_SQL_AFTER, FE_SQL_BEFORE, F_FE_PARAMETER];
// get current data record
if ($recordId > 0 && $this->store->getVar('id', STORE_RECORD) === false) {
......@@ -368,8 +371,15 @@ abstract class AbstractBuildForm {
// Preparation for Log, Debug
$this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($fe), STORE_SYSTEM);
// for Upload FormElements, it's necessary to precalculate an optional given 'slaveId'.
if ($fe[FE_TYPE] === FE_TYPE_UPLOAD) {
Support::setIfNotSet($fe, FE_SLAVE_ID);
$slaveId = Support::falseEmptyToZero($this->evaluate->parse($fe[FE_SLAVE_ID]));
$this->store->setVar(VAR_SLAVE_ID, $slaveId, STORE_VAR);
}
// evaluate current FormElement
$formElement = $this->evaluate->parseArray($fe, $debugStack);
$formElement = $this->evaluate->parseArray($fe, $skip, $debugStack);
// Some Defaults
$formElement = Support::setFeDefaults($formElement);
......
......@@ -233,7 +233,7 @@ const STORE_EMPTY = "E"; // value: '', might helpfull if variable is not defined
const STORE_SYSTEM = "Y"; // various system values like db connection credentials
const STORE_EXTRA = 'X'; // Persistent Store: contains arrays! Not Usefull for user. Used by system.
const STORE_USE_DEFAULT = "FSRD";
const STORE_USE_DEFAULT = "FSRVD";
//
// Store: Definitions / Members
//
......@@ -251,7 +251,6 @@ const CLIENT_UPLOAD_FE_NAME = 'name';
const CLIENT_SIP_FOR_FORM = '_sipForForm';
const CLIENT_FE_NAME = '_feName';
const CLIENT_UPLOAD_FILENAME = '_filename';
// ALL $_SERVER variables: http://php.net/manual/en/reserved.variables.server.php
// The following exist and might be the most used ones.
......@@ -352,7 +351,12 @@ const SIP_URLPARAM = 'urlparam';
const SIP_MAKE_URLPARAM_UNIQ = '_makeUrlParamUniq'; // SIPs for 'new records' needs to be uniq per TAB! Therefore add a uniq parameter
// FURTHER: all extracted params from 'urlparam
const ACTION_KEYWORD_SLAVE_ID = 'slaveId';
const VAR_RANDOM = 'random';
const VAR_FILE_DESTINATION = 'fileDestination';
const VAR_SLAVE_ID = ACTION_KEYWORD_SLAVE_ID;
const VAR_FILENAME = 'filename'; // Original filename of an uploaded file.
//const RECORD_ID_NEW = -1;
......@@ -513,6 +517,8 @@ const FE_EXPECT_RECORDS = 'expectRecords'; // Action: expected number of rows of
const FE_MESSAGE_FAIL = 'messageFail'; // Action: Message to display, if FE_SQL_VALIDATE fails.
const FE_REQUIRED_LIST = 'requiredList'; // Optional list of FormElements which have to be non empty to make this 'action'-FormElement active.
const FE_SLAVE_ID = 'slaveId'; // Action; Value or Query to compute id of slave record.
const FE_SQL_AFTER = 'sqlAfter'; // Action: Always fired
const FE_SQL_BEFORE = 'sqlBefore'; // Action: Always fired
const FE_SQL_UPDATE = 'sqlUpdate'; // Action: Update Statement for slave record
const FE_SQL_INSERT = 'sqlInsert'; // Action: Insert Statement to create slave record.
const FE_SQL_DELETE = 'sqlDelete'; // Action: Delete Statement to delete unused slave record.
......@@ -535,6 +541,7 @@ const FE_RETYPE_SOURCE_NAME = '_retypeSourceName'; // QFQ internal reference to
const RETYPE_FE_NAME_EXTENSION = 'RETYPE';
// FormElement Types
const FE_TYPE_UPLOAD = 'upload';
const FE_TYPE_EXTRA = 'extra';
const FE_TYPE_SENDMAIL = 'sendMail';
const FE_TYPE_BEFORE_LOAD = 'beforeLoad';
......@@ -548,8 +555,6 @@ const FE_TYPE_AFTER_INSERT = 'afterInsert';
const FE_TYPE_AFTER_UPDATE = 'afterUpdate';
const FE_TYPE_AFTER_DELETE = 'afterDelete';
const ACTION_KEYWORD_SLAVE_ID = 'slaveId';
// SUPPORT
const PARAM_T3_ALL = 't3 all';
const PARAM_T3_NO_ID = "t3 no id";
......@@ -575,6 +580,12 @@ const QUERY_TYPE_CONTROL = 'type: set';
const FORMAT_DATE_INTERNATIONAL = 'yyyy-mm-dd';
const FORMAT_DATE_GERMAN = 'dd.mm.yyyy';
// Upload
const UPLOAD_MODE_UNCHANGED = 'unchanged';
const UPLOAD_MODE_NEW = 'new';
const UPLOAD_MODE_DELETEOLD = 'deleteOld';
const UPLOAD_MODE_DELETEOLD_NEW = 'deleteOld+new';
// $_FILES
const FILES_NAME = 'name';
const FILES_TMP_NAME = 'tmp_name';
......
......@@ -49,14 +49,23 @@ class Evaluate {
* Evaluate a whole array or a array of arrays.
*
* @param $tokenArray
* @param array $skip Optional Array with keynames, which will not be evaluated.
* @param array $debugStack
* @return mixed
* @throws UserFormException
*/
public function parseArray($tokenArray, &$debugStack = array()) {
public function parseArray($tokenArray, array $skip = array(), &$debugStack = array()) {
$arr = array();
foreach ($tokenArray as $key => $value) {
if (array_search($key, $skip) !== false) {
$arr[$key] = $value;
continue;
}
if (is_array($value)) {
$arr[] = $this->parseArray($value);
$arr[] = $this->parseArray($value, $skip);
} else {
$arr[$key] = $this->parse($value, 0, $debugStack);
}
......@@ -67,6 +76,7 @@ class Evaluate {
/**
* Recursive evaluation of 'line'. Constant string, Variables or SQL Query or all of them. All queries will be fired.
* In case of an 'INSERT' statement, return the last_insert_id().
*
* Token to replace have to be enclosed by '{{' and '}}'
*
......@@ -136,13 +146,15 @@ class Evaluate {
$posFirstClose = strpos($result, $this->endDelimiter);
}
$result = Support::decryptDoubleCurlyBraces($result);
if ($flagTokenReplaced === true) {
$debugLocal[] = $debugIndent . "FINAL: " . is_array($result) ? "array(" . count($result) . ")" : "$result";
$debugStack = $debugLocal;
}
return Support::decryptDoubleCurlyBraces($result);
return $result;
}
/**
......
......@@ -111,6 +111,7 @@ class File {
}
$statusUpload[FILES_TMP_NAME] = '';
}
$statusUpload[FILES_FLAG_DELETE] = '1';
$this->store->setVar($sipUpload, $statusUpload, STORE_EXTRA);
}
......
......@@ -304,6 +304,7 @@ class QuickFormQuery {
// If an old record exist: load it. Necessary to delete uploaded files which should be overwritten.
$this->fillStoreWithRecord($this->formSpec[F_TABLE_NAME], $recordId, STORE_RECORD);
// SAVE
$save = new Save($this->formSpec, $this->feSpecAction, $this->feSpecNative);
$rc = $save->process();
......
......@@ -48,6 +48,7 @@ class Save {
/**
* Starts save process. On succcess, returns forwardmode/page.
*
* @return int
* @throws CodeException
* @throws DbException
* @throws UserFormException
......@@ -187,8 +188,9 @@ class Save {
if (count($values) === 0)
return 0; // nothing to write, 0 rows affected
if ($recordId === 0)
if ($recordId === 0) {
throw new CodeException('RecordId=0 - this is not possible for update.', ERROR_RECORDID_0_FORBIDDEN);
}
// $paramList = str_repeat('?, ', count($values));
// $paramList = substr($paramList, 0, strlen($paramList) - 2);
......@@ -226,17 +228,27 @@ class Save {
continue;
}
$formElement = HelperFormElement::initUploadFormElement($formElement);
// Preparation for Log, Debug
$this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($formElement), STORE_SYSTEM);
$column = $formElement['name'];
$pathFileName = $this->doUpload($formElement, $formValues[$column], $sip);
// Only update (save) the new pathFileName to the primaryRecord if the corresponding column exist.
if ($pathFileName !== false && isset($primaryRecord[$column])) {
$newValues[$column] = $pathFileName;
$pathFileName = $this->doUpload($formElement, $formValues[$column], $sip, $modeUpload);
// Upload Type: Simple or Advanced
if (isset($primaryRecord[$column])) {
// 'Simple Upload': no special action needed, just process the current (maybe modifired) value.
if ($pathFileName !== false) {
$newValues[$column] = $pathFileName;
}
} else {
// 'Advanced Upload'
$this->doUploadSlave($formElement, $modeUpload);
}
}
// Only used in 'Simple Upload'
if (count($newValues) > 0) {
$this->updateRecord($this->formSpec[F_TABLE_NAME], $newValues, $recordId);
}
......@@ -248,14 +260,18 @@ class Save {
*
* Check also: doc/CODING.md
*
* @param $formElement
* @param $sipUpload
* @return string|false New filename or false on error
* @param array $formElement FormElement 'upload'
* @param string $sipUpload SIP
* @param Sip $sip
* @param string $modeUpload UPLOAD_MODE_UNCHANGED | UPLOAD_MODE_NEW | UPLOAD_MODE_DELETEOLD | UPLOAD_MODE_DELETEOLD_NEW
* @return false|string New pathFilename or false on error
* @throws CodeException
* @throws UserFormException
* @internal param $recordId
*/
private function doUpload($formElement, $sipUpload, Sip $sip) {
private function doUpload($formElement, $sipUpload, Sip $sip, &$modeUpload) {
$flagDelete = false;
$modeUpload = UPLOAD_MODE_UNCHANGED;
// Status information about upload file
$statusUpload = $this->store->getVar($sipUpload, STORE_EXTRA);
......@@ -279,6 +295,14 @@ class Save {
throw new UserFormException('Unlink file failed: ' . $oldFile, ERROR_IO_UNLINK);
}
}
$flagDelete = ($oldFile != '');
}
// Set $modeUpload
if (isset($statusUpload[FILES_TMP_NAME]) && $statusUpload[FILES_TMP_NAME] != '') {
$modeUpload = $flagDelete ? UPLOAD_MODE_DELETEOLD_NEW : UPLOAD_MODE_NEW;
} else {
$modeUpload = $flagDelete ? UPLOAD_MODE_DELETEOLD : UPLOAD_MODE_UNCHANGED;
}
$pathFileName = $this->copyUploadFile($formElement, $statusUpload);
......@@ -289,7 +313,6 @@ class Save {
$this->store->setVar($sipUpload, array(), STORE_EXTRA);
return $pathFileName;
}
/**
......@@ -313,11 +336,14 @@ class Save {
if (isset($formElement[FE_FILE_DESTINATION])) {
// Provide variable '_filename'. Might be substituted in $formElement[FE_PATH_FILE_NAME].
// Provide variable 'filename'. Might be substituted in $formElement[FE_PATH_FILE_NAME].
$origFilename = Sanitize::safeFilename($statusUpload[FILES_NAME]);
$this->store->setVar(CLIENT_UPLOAD_FILENAME, $origFilename, STORE_FORM);
$this->store->setVar(VAR_FILENAME, $origFilename, STORE_VAR);
$pathFileName = $this->evaluate->parse($formElement[FE_FILE_DESTINATION]);
// Saved in store for later use during 'Advanced Upload'-post processing
$this->store->setVar(VAR_FILE_DESTINATION, $pathFileName, STORE_VAR);
}
if ($pathFileName === '') {
......@@ -344,6 +370,70 @@ class Save {
return $pathFileName;
}
/**
* Create/update or delete the slave record.
*
* @param array $fe
* @param bool $flagNewUpload
* @return int
* @throws CodeException
* @throws UserFormException
*/
private function doUploadSlave(array $fe, $modeUpload) {
$sql = '';
$flagUpdateSlaveId = false;
$flagSlaveDeleted = false;
// Get the slaveId
$slaveId = Support::falseEmptyToZero($this->evaluate->parse($fe[FE_SLAVE_ID]));
// Store the slaveId: it's used and replaced in the update statement.
$this->store->setVar(VAR_SLAVE_ID, $slaveId, STORE_VAR, true);
$mode = ($slaveId == '0') ? 'I' : 'U'; // I=Insert, U=Update
$mode .= ($modeUpload == UPLOAD_MODE_NEW || $modeUpload == UPLOAD_MODE_DELETEOLD_NEW) ? 'N' : ''; // N=New File, '' if no new file.
$mode .= ($modeUpload == UPLOAD_MODE_DELETEOLD) ? 'D' : ''; // Delete slave record only if there is no new and not 'unchanged'.
switch ($mode) {
case 'IN':
$sql = $fe[FE_SQL_INSERT];
$flagUpdateSlaveId = true;
break;
case 'UN':
$sql = $fe[FE_SQL_UPDATE];
break;
case 'I':
case 'U':
$sql = ''; // no old file and no new file.
break;
case 'UD':
$sql = $fe[FE_SQL_DELETE];
$flagSlaveDeleted = true;
break;
default:
throw new CodeException('Unknown mode: ' . $mode, ERROR_UNKNOWN_MODE);
}
// If given: fire a sqlBefore query
$this->evaluate->parse($fe[FE_SQL_BEFORE]);
$rc = $this->evaluate->parse($sql);
// Check if the slave record has been deleted: if yes, set slaveId=0
if ($flagSlaveDeleted && $rc > 0) {
$rc = 0;
$flagUpdateSlaveId = true;
}
if ($flagUpdateSlaveId) {
// Store the slaveId: it's used and replaced in the update statement.
$this->store->setVar(VAR_SLAVE_ID, $rc, STORE_VAR, true);
$slaveId = $rc;
}
// If given: fire a sqlAfter query
$this->evaluate->parse($fe[FE_SQL_AFTER]);
return $slaveId;
}
/**
* Get the complete FormElement for $name
*
......
......@@ -72,7 +72,7 @@ class FormAction {
// Iterate over all Action FormElements
foreach ($feSpecAction as $fe) {
$fe = $this->initActionFormElement($fe);
$fe = HelperFormElement::initActionFormElement($fe);
// Only process FE elements of types listed in $feTypeList. Skip all other
if (false === Support::findInSet($fe[FE_TYPE], $feTypeList)) {
......@@ -112,25 +112,6 @@ class FormAction {
return $flagModified;
}
/**
* Set all necessary keys - subsequent 'isset()' are not necessary anymore.
*
* @param array $fe
* @return array
*/
private function initActionFormElement(array $fe) {
$list = [FE_TYPE, FE_SLAVE_ID, FE_SQL_VALIDATE, FE_SQL_INSERT, FE_SQL_UPDATE, FE_SQL_DELETE, FE_EXPECT_RECORDS,
FE_REQUIRED_LIST, FE_MESSAGE_FAIL, FE_SENDMAIL_TO, FE_SENDMAIL_CC, FE_SENDMAIL_BCC, FE_SENDMAIL_FROM, FE_SENDMAIL_SUBJECT, FE_SENDMAIL_REPLY_TO,
FE_SENDMAIL_FLAG_AUTO_SUBMIT, FE_SENDMAIL_GR_ID, FE_SENDMAIL_X_ID];
foreach ($list as $key) {
Support::setIfNotSet($fe, $key);
}
return $fe;
}
/**
* Copy the current primary record to STORE_RECORD
*
......@@ -266,13 +247,16 @@ class FormAction {
}
// Store the slaveId: it's used and replaced in the update statement.
$this->store->setVar(ACTION_KEYWORD_SLAVE_ID, $slaveId, STORE_VAR, true);
$this->store->setVar(VAR_SLAVE_ID, $slaveId, STORE_VAR, true);
// If given: fire a sqlBefore query
$this->evaluate->parse($fe[FE_SQL_BEFORE]);
// Fire slave query
if ($slaveId == 0) {
$slaveId = $this->evaluate->parse($fe[FE_SQL_INSERT]);
// Store the slaveId: it's used and replaced in the update statement.
$this->store->setVar(ACTION_KEYWORD_SLAVE_ID, $slaveId, STORE_VAR, true);
// Store the slaveId: might be used later
$this->store->setVar(VAR_SLAVE_ID, $slaveId, STORE_VAR, true);
} else {
$this->evaluate->parse($fe[FE_SQL_UPDATE]);
}
......@@ -286,164 +270,30 @@ class FormAction {
// If given: fire a delete query
$this->evaluate->parse($fe[FE_SQL_DELETE]);
// If given: fire a sqlAfter query
$this->evaluate->parse($fe[FE_SQL_AFTER]);
return $slaveId;
}
/**
* Set all necessary keys - subsequent 'isset()' are not necessary anymore.
*
* @param array $fe
* @return array
*/
private function initActionFormElement(array $fe) {
$list = [FE_TYPE, FE_SLAVE_ID, FE_SQL_VALIDATE, FE_SQL_BEFORE, FE_SQL_INSERT, FE_SQL_UPDATE, FE_SQL_DELETE,
FE_SQL_AFTER, FE_EXPECT_RECORDS, FE_REQUIRED_LIST, FE_MESSAGE_FAIL, FE_SENDMAIL_TO, FE_SENDMAIL_CC,
FE_SENDMAIL_BCC, FE_SENDMAIL_FROM, FE_SENDMAIL_SUBJECT, FE_SENDMAIL_REPLY_TO, FE_SENDMAIL_FLAG_AUTO_SUBMIT,
FE_SENDMAIL_GR_ID, FE_SENDMAIL_X_ID];
foreach ($list as $key) {
Support::setIfNotSet($fe, $key);
}
return $fe;
}
}
//
///********************************************************
// * doAddNUpdate
// * RC: TRUE ok
// * FALSE,$err bei Fehler
// *********************************************************/
//function doAddNUpdate($formId, $masterId, $tableName, &$err) {
// global $FeId;
//
// if ($this->DebugLevel > 3) t3lib_div::debug("doAddNUpdate");
//
// // Selektiere alle 'addNupdate'-DS des aktuellen Formulars
// $sql = "SELECT * FROM form_element WHERE form_id=" . $formId . " AND typ='addNupdate' AND active='Yes' ORDER BY ord";
// if ($this->DebugLevel > 3) t3lib_div::debug($sql);
// if (!($formDs = mysql(MATH_DB_NAME, $sql))) return ($this->buildMySQLErrMsg($err, $sql, __FILE__, __LINE__));
//
// // Falls nix zu tun ist (kein DS vorhanden), gleich zurueck.
// if (mysql_num_rows($formDs) == 0) return (TRUE);
//
// // Durchlaufe alle 'addNupdate' DS
// while ($formularDs = mysql_fetch_array($formDs, MYSQL_ASSOC)) {
//
// $FeId = $formularDs['id']; // Just for logging
//
// if ($this->DebugLevel > 3) t3lib_div::debug($formularDs);
//
// // Lese den zuvor gespeicherten Master DS
// // Der Master DS sollte nach jedem AddNUpdate neu gelesen werden, evtl. wurde etwas eingetragen
//
// $masterDs = $this->doQuerySingle("SELECT * FROM " . $tableName . " WHERE id=" . $masterId, $err);
// if ($err) return (FALSE);
//
// // Check ob addNUpadte ueberhaupt ausgefuehrt werden soll: Ist 'param' gesetzt ?
// // JA: dann auswerten ob die in 'param' aufgefuehrten Formularfelder gefuellt sind
// // Wenn nein, naechsten addNUpdate DS bearbeiten
// // NEIN: normal weiter machen
// if ($formularDs["param"]) {
// $arr = explode(",", $formularDs["param"]);
// $t = TRUE;
// foreach ($arr as $elem) {
// if ($GLOBALS[HTTP_POST_VARS][FRM . $elem]) {
// $t = FALSE;
// break; //foreach
// }
// }
// if ($t) {
// if ($this->DebugLevel > 3) t3lib_div::debug("doAddNUpdate() nicht ausfuehren, da param gesetzt ist und angegebene Felder leer sind.");
// continue; //while
// }
// }
//
// # Falls in 'value' ein select Statement angegeben ist, dieses ausführen.
// # Es sollte 0 oder 1 DS gefunden werden.
// # Die Spalte 'id' muss vorhanden sein und diese die slaveID angeben.
// if ($formularDs["value"]) {
// $sql = $this->substituteAssoc($formularDs["value"], $masterDs);
// $slaveDs = $this->doQuerySingle($sql, $err, EMPTY_IS_OK);
// $slaveId = $slaveDs["id"];
// } else {
//
// // Name des aktuellen addNupdate Formularelementes, kann gleichzeitig eine ID im masterDs auf eine slaveDS sein
// // Ist so eine ID>0 muss ein Update durchgefuehrt werden, sonst ein insert.
// // Bsp: Formular 'publikation_mit_upload_new' - zur aktuellen Publikation wird ein Notiz DS mit dem Dateinamen der Publikation angelegt.
// if ($masterDs[$formularDs["name"]])
// $slaveId = $masterDs[$formularDs["name"]];
// else
// $slaveId = $GLOBALS[HTTP_POST_VARS][FRM . $formularDs["name"]]; // einige spezielle doAddNUpdate benutzen temporaere Variablen (z.B. Formular publikation_mit_upload: my_pid
// }
//
// if ($slaveId > 0) {
//
// // if($GLOBALS[HTTP_POST_VARS][FRM."id".$post]>0) { // Es existiert ein zugehoeriger DS (=Slave)
//
// // Check ob ein Update Statement existiert
// if (!$formularDs["sql_update"])
// continue;
//
// // Ersetze Variablen in dem SQL update Statement.
// $sql = $this->substituteAssoc($formularDs["sql_update"], $masterDs);
//
// if ($this->DebugLevel > 0) echo("doAddNUpdate(update):" . $sql . "<BR>");
//
// // Fuehre das Update auf den Slave DS aus.
// if ($this->DebugLevel > 3) t3lib_div::debug($sql);
// if (!($res = $this->doSQL(MATH_DB_NAME, $sql . " "))) return ($this->buildMySQLErrMsg($err, $sql . " ", __FILE__, __LINE__, $formularDs));
//
// } else { // Es existiert noch kein zugehoeriger DS (=Slave)
//
// // Check ob ein Insert Statement existiert
// if (!$formularDs["sqlq"])
// continue;
//
// // Ersetze Variablen in dem SQL insert Statement.
// $sql = $this->substituteAssoc($formularDs["sqlq"], $masterDs);
//
// // Fuehre das Update auf den Slave DS aus.
// if ($this->DebugLevel > 1) t3lib_div::debug($sql);
// if (!($res = $this->doSQL(MATH_DB_NAME, $sql))) {
// $this->buildMySQLErrMsg($err, $sql, __FILE__, __LINE__);
// return (FALSE);
// }
//
// // Bestimme den Tabellennamen der im Slave SQL Statement benutzt wird
// $arr = explode(" ", $sql); //
// if ("insert" == mb_strtolower(mb_substr(ltrim($sql), 0, 6))) {
//
// if (mysql_affected_rows() > 0) {
// // Lade gerade geschriebenen Record
// $slaveTableName = mb_strtolower($arr[1]) == "into" ? $arr[2] : $arr[1]; // sql: "insert into <table> ..... der dritte Parameter ist der Tabellenname
//
// // Lese die Id des neu angelegten DS
// $slaveId = mysql_insert_id();
//
// // Bei einigen Tabellen gibt es keine Spalte 'id' - darum die gesuchte Spalte ueber die Definition von auto_increment bestimmen. I.d.R. 'id'
// // Bsp: einfuegen von fe_usern in die T3 Tabelle 'fe_users'
// $sql = "show fields from $slaveTableName where Extra like 'auto_increment'";
// if (!($tmp = $this->doQuerySingle($sql, $err))) {
// $this->buildMySQLErrMsg($err, $sql, __FILE__, __LINE__);
// return (FALSE);
// }
// $colNameId = $tmp["Field"];