protected function initTmpRecord() { $tmpId = CoreServices::get('request')->getFromRequest('_tmpId'); if (!empty($tmpId)) { $this->tmpRecord = $this->tmpRecordDAO->getRecordById($tmpId); if (empty($this->tmpRecord['id'])) { CoreServices2::getDB()->transactionCommit(); CoreUtils::redirect($this->getListPageAddress()); } } else { $this->tmpRecord = $this->tmpRecordDAO->getRecordTemplate(); $this->tmpRecord['recordType'] = $this->getRecordType(); $this->tmpRecord['_tmpRecordCreateTime'] = CoreUtils::getDateTime(); $this->tmpRecord['_tmpRecordSessionId'] = CoreServices2::getRequest()->getSessionId(); $this->tmpRecordDAO->save($this->tmpRecord); } }
protected function getBaseRecord() { $recordType = $this->form->getField('recordType')->getValue(); $tmpId = $this->form->getField('_tmpId')->getValue(); if (!empty($tmpId)) { $dao = new TmpRecordDAO(); $record = $dao->getRecordById($tmpId); if (empty($record['id']) || $record['recordType'] != $recordType) { return null; } return $record; } else { $daoClass = strtoupper(substr($recordType, 0, 1)) . substr($recordType, 1) . 'DAO'; $dao = new $daoClass(); $id = $this->form->getField('id')->getValue(); $record = $dao->getRecordById($id); if (empty($record['id']) || !$this->isValidBaseRecord($recordType, $record)) { return null; } return $record; } }