Hallo Martin,
jetzt bin ich mal so frech und setzte Dir die gesamte save-Function überarbeitet wie auch immer hier rein. Ich finde diesen Punkt einfach nicht.
:o
function save() {
if ($this->typoVersion >= 3006000) global $TYPO3_DB;
switch($this->cmd) {
case 'edit':
$theUid = $this->dataArr['uid'];
$origArr = $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $theUid);
// Fetch the original record to check permissions
if ($this->conf['edit'] && ($GLOBALS['TSFE']->loginUser || $this->aCAuth($origArr))) {
// Must be logged in in order to edit (OR be validated by email)
$newFieldList = implode(',', array_intersect(explode(',', $this->fieldList), t3lib_div::trimExplode(',', $this->conf['edit.']['fields'], 1)));
$newFieldList = implode(',', array_unique( array_merge (explode(',', $newFieldList), explode(',', $this->adminFieldList))));
// Do not reset the name if we have no new value
if(!in_array('name', t3lib_div::trimExplode(',', $this->conf[$this->cmdKey.'.']['fields'], 1)) && !in_array('first_name', t3lib_div::trimExplode(',', $this->conf[$this->cmdKey.'.']['fields'], 1)) && !in_array('last_name', t3lib_div::trimExplode(',', $this->conf[$this->cmdKey.'.']['fields'], 1))) {
$newFieldList = implode(',', array_diff(explode(',', $newFieldList), array('name')));
}
if ($this->aCAuth($origArr) || $this->cObj->DBmayFEUserEdit($this->theTable, $origArr, $GLOBALS['TSFE']->fe_user->user, $this->conf['allowedGroups'], $this->conf['fe_userEditSelf'])) {
if ($this->typoVersion >= 3006000) {
$res = $this->cObj->DBgetUpdate($this->theTable, $theUid, $this->parseOutgoingDates($this->dataArr), $newFieldList, true);
} else {
$query = $this->cObj->DBgetUpdate($this->theTable, $theUid, $this->parseOutgoingDates($this->dataArr), $newFieldList);
mysql(TYPO3_db, $query);
echo mysql_error();
}
$this->saved = 1;
// Post-edit processing: call user functions and hooks
$this->currentArr = $this->parseIncomingTimestamps( $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $theUid));
$this->userProcess_alt($this->conf['edit.']['userFunc_afterSave'], $this->conf['edit.']['userFunc_afterSave.'], array('rec' => $this->currentArr, 'origRec' => $origArr));
// <Ries van Twisk added registrationProcess hooks>
// Call all afterSaveEdit hooks after the record has been edited and saved
if (is_array ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['registrationProcess'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['registrationProcess'] as $classRef) {
$hookObj= &t3lib_div::getUserObj($classRef);
if (method_exists($hookObj, 'registrationProcess_afterSaveEdit')) {
$hookObj->registrationProcess_afterSaveEdit($this->currentArr, &$this);
}
}
}
// </Ries van Twisk added registrationProcess hooks>
} else {
$this->error = '###TEMPLATE_NO_PERMISSIONS###';
}
}
break;
default:
if ($this->conf['create']) {
$newFieldList = implode(array_intersect(explode(',', $this->fieldList), t3lib_div::trimExplode(',', $this->conf['create.']['fields'], 1)), ',');
$newFieldList = implode( array_unique( array_merge (explode(',', $newFieldList), explode(',', $this->adminFieldList))), ',');
if ($this->typoVersion >= 3006000) {
$res = $this->cObj->DBgetInsert($this->theTable, $this->thePid, $this->parseOutgoingDates($this->dataArr), $newFieldList, true);
$newId = $TYPO3_DB->sql_insert_id();
} else {
$query = $this->cObj->DBgetInsert($this->theTable, $this->thePid, $this->parseOutgoingDates($this->dataArr), $newFieldList);
mysql(TYPO3_db, $query);
echo mysql_error();
$newId = mysql_insert_id();
}
// Enable users to own them self.
if ($this->theTable == "fe_users" && $this->conf['fe_userOwnSelf']) {
$extraList = '';
$dataArr = array();
if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id']) {
$field = $GLOBALS['TCA'][$this->theTable]['ctrl']['fe_cruser_id'];
$dataArr[$field] = $newId;
$extraList .= ','.$field;
}
if ($GLOBALS['TCA'][$this->theTable]['ctrl']['fe_crgroup_id']) {
$field = $GLOBALS['TCA'][$this->theTable]['ctrl']['fe_crgroup_id'];
list($dataArr[$field]) = explode(',', $this->dataArr['usergroup']);
$dataArr[$field] = intval($dataArr[$field]);
$extraList .= ','.$field;
}
if (count($dataArr)) {
if ($this->typoVersion >= 3006000) {
$res = $this->cObj->DBgetUpdate($this->theTable, $newId, $dataArr, $extraList, true);
} else {
$query = $this->cObj->DBgetUpdate($this->theTable, $newId, $dataArr, $extraList);
mysql(TYPO3_db, $query);
echo mysql_error();
}
}
}
$this->saved = 1;
// Post-create processing: call user functions and hooks
$this->currentArr = $this->parseIncomingTimestamps( $GLOBALS['TSFE']->sys_page->getRawRecord($this->theTable, $newId));
$this->userProcess_alt($this->conf['create.']['userFunc_afterSave'], $this->conf['create.']['userFunc_afterSave.'], array('rec' => $this->currentArr));
// <Ries van Twisk added registrationProcess hooks>
// Call all afterSaveCreate hooks after the record has been created and saved
if (is_array ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['registrationProcess'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['registrationProcess'] as $classRef) {
$hookObj= &t3lib_div::getUserObj($classRef);
if (method_exists($hookObj, 'registrationProcess_afterSaveCreate')) {
$hookObj->registrationProcess_afterSaveCreate($this->currentArr, &$this);
}
}
}
// </Ries van Twisk added registrationProcess hooks>
}
break;
}
}