Commit 88093a16 authored by Carsten  Rose's avatar Carsten Rose
Browse files

delete.php: Implemented simple delete by giving table and record ID (by SIP).

save.php: moved constants to Constants.php to reuse them in delete.php. Fixed bug by building error messages.
Sip: extended queryStringToSip() by optional Parameter $scriptName.
AbstractBuilForm: renamed formEditLink() to createFormEditUrl(). Changed createFormEditUrl() to only return the final URL, without HTML tags. Implemented createDeleteUrl().
BuildFormBootstrap, BuildFormTable: rewrote code for using createFormEditLink(). Use of createDeleteUrl().
Constants: defined SIP_TABLE, API_*
QuickFormQuery: reformat Code
parent a5506bbd
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 12/23/15
* Time: 6:16 PM
*/
namespace qfq;
use qfq;
require_once(__DIR__ . '/../qfq/QuickFormQuery.php');
//require_once(__DIR__ . '/../qfq/store/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
/**
* Return JSON encoded answer
*
* status: success|error
* message: <message>
* redirect: client|url|no
* redirect-url: <url>
* field-name:<field name>
* field-message: <message>
*
* Description:
*
* Delete successfull.
* status = 'success'
* message = <message>
* redirect = 'client'
*
* Delete successfull.
* status = 'success'
* message = <message>
* redirect = 'url'
* redirect-url = <URL>
*
* Delete failed: Show message.
* status = 'error'
* message = <message>
* redirect = 'no'
*/
$answer = array();
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_NO;
$answer[API_MESSAGE] = '';
$answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
try {
$qfq = new \qfq\QuickFormQuery(['bodytext' => "debugShowStack=1"]);
$qfq->delete();
$answer[API_MESSAGE] = 'delete: success';
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_CLIENT;
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
} catch (qfq\UserException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (qfq\CodeException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (qfq\DbException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (\Exception $e) {
$answer[API_MESSAGE] = "Generic Exception: " . $e->getMessage();
}
header("Content-Type: application/json");
echo json_encode($answer);
...@@ -12,6 +12,7 @@ use qfq; ...@@ -12,6 +12,7 @@ use qfq;
require_once(__DIR__ . '/../qfq/QuickFormQuery.php'); require_once(__DIR__ . '/../qfq/QuickFormQuery.php');
require_once(__DIR__ . '/../qfq/store/Store.php'); require_once(__DIR__ . '/../qfq/store/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
/** /**
...@@ -46,51 +47,38 @@ require_once(__DIR__ . '/../qfq/store/Store.php'); ...@@ -46,51 +47,38 @@ require_once(__DIR__ . '/../qfq/store/Store.php');
* field-message = <message appearing as tooltip (or similar) near the form element> * field-message = <message appearing as tooltip (or similar) near the form element>
*/ */
const SAVE_STATUS = 'status';
const SAVE_MESSAGE = 'message';
const SAVE_REDIRECT = 'redirect';
const SAVE_REDIRECT_URL = 'redirect-url';
const SAVE_FIELD_NAME = 'field-name';
const SAVE_FIELD_MESSAGE = 'field-message';
const ANSWER_STATUS_SUCCESS = 'success';
const ANSWER_STATUS_ERROR = 'error';
const ANSWER_REDIRECT_CLIENT = 'client';
const ANSWER_REDIRECT_NO = 'no';
const ANSWER_REDIRECT_URL = 'url';
$answer = array(); $answer = array();
$answer[SAVE_STATUS] = 'error'; $answer[API_REDIRECT] = API_ANSWER_REDIRECT_CLIENT;
$answer[SAVE_MESSAGE] = ''; $answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
$answer[SAVE_REDIRECT] = 'client'; $answer[API_MESSAGE] = '';
try { try {
$qfq = new \qfq\QuickFormQuery(['bodytext' => "debugShowStack=1"]); $qfq = new \qfq\QuickFormQuery(['bodytext' => "debugShowStack=1"]);
$qfq->saveForm(); $qfq->saveForm();
$answer[SAVE_REDIRECT] = $qfq->getForwardMode($answer[SAVE_REDIRECT_URL]); $answer[API_REDIRECT] = $qfq->getForwardMode($answer[API_REDIRECT_URL]);
$answer[SAVE_MESSAGE] = 'save: success'; $answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
$answer[SAVE_STATUS] = ANSWER_STATUS_SUCCESS; $answer[API_MESSAGE] = 'save: success';
} catch (qfq\UserException $e) { } catch (qfq\UserException $e) {
$answer[SAVE_MESSAGE] = $e->formatMessage(); $answer[API_MESSAGE] = $e->formatMessage();
$val = Store::getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM); $val = Store::getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM);
if ($val !== false) if ($val !== false)
$answer[SAVE_FIELD_NAME] = $answer[API_FIELD_NAME] = $val;
$val = Store::getVar(SYSTEM_FORM_ELEMENT_MESSAGE, STORE_SYSTEM); $val = Store::getVar(SYSTEM_FORM_ELEMENT_MESSAGE, STORE_SYSTEM);
if ($val !== false) if ($val !== false)
$answer[SAVE_FIELD_MESSAGE] = $val; $answer[API_FIELD_MESSAGE] = $val;
} catch (qfq\CodeException $e) { } catch (qfq\CodeException $e) {
$answer[SAVE_MESSAGE] = $e->formatMessage(); $answer[API_MESSAGE] = $e->formatMessage();
} catch (qfq\DbException $e) { } catch (qfq\DbException $e) {
$answer[SAVE_MESSAGE] = $e->formatMessage(); $answer[API_MESSAGE] = $e->formatMessage();
} catch (\Exception $e) { } catch (\Exception $e) {
$answer[SAVE_MESSAGE] = "Generic Exception: " . $e->getMessage(); $answer[API_MESSAGE] = "Generic Exception: " . $e->getMessage();
} }
header("Content-Type: application/json"); header("Content-Type: application/json");
......
...@@ -96,7 +96,6 @@ abstract class AbstractBuildForm { ...@@ -96,7 +96,6 @@ abstract class AbstractBuildForm {
]; ];
$this->inputCheckPattern = OnArray::inputCheckPatternArray(); $this->inputCheckPattern = OnArray::inputCheckPatternArray();
} }
abstract public function fillWrap(); abstract public function fillWrap();
...@@ -139,9 +138,9 @@ abstract class AbstractBuildForm { ...@@ -139,9 +138,9 @@ abstract class AbstractBuildForm {
* *
* @return string String: <a href="?pageId&sip=....">Edit</a> <small>[sip:..., r:..., urlparam:..., ...]</small> * @return string String: <a href="?pageId&sip=....">Edit</a> <small>[sip:..., r:..., urlparam:..., ...]</small>
*/ */
public function formEditLink() { public function createFormEditUrl() {
if($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) !== 'yes') { if ($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) !== 'yes') {
return ''; return '';
} }
...@@ -156,9 +155,26 @@ abstract class AbstractBuildForm { ...@@ -156,9 +155,26 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance(); $sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip($queryString); $url = $sip->queryStringToSip($queryString);
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP),':', ', ',"'"); return $url;
}
/**
* Create a link (incl. SIP) to delete the current record.
*
* @return string String: "API_DIR/delete.php?sip=...."
*/
public function createDeleteUrl($table, $recordId) {
$queryStringArray = [
SIP_TABLE => $table,
SIP_RECORD_ID => $recordId
];
$queryString = Support::arrayToQueryString($queryStringArray);
return "<p></p><a href='$url'>Edit</a> <small>[$sipParamString]</small></p>"; $sip = $this->store->getSipInstance();
return $sip->queryStringToSip($queryString, RETURN_URL, API_DIR . '/delete.php');
} }
/** /**
...@@ -172,7 +188,10 @@ abstract class AbstractBuildForm { ...@@ -172,7 +188,10 @@ abstract class AbstractBuildForm {
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything $html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
// Logged in BE User will see a FormEdit Link // Logged in BE User will see a FormEdit Link
$html .= $this->formEditLink(); $sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
$formEditUrl = $this->createFormEditUrl();
$html .= "<p><a href='$formEditUrl'>Edit</a> <small>[$sipParamString]</small></p>";
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true); $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
...@@ -247,7 +266,7 @@ abstract class AbstractBuildForm { ...@@ -247,7 +266,7 @@ abstract class AbstractBuildForm {
*/ */
public function getActionUrl() { public function getActionUrl() {
return 'typo3conf/ext/qfq/qfq/api/save.php'; return API_DIR . '/save.php';
} }
/** /**
...@@ -283,8 +302,8 @@ abstract class AbstractBuildForm { ...@@ -283,8 +302,8 @@ abstract class AbstractBuildForm {
// get current data record // get current data record
if ($recordId > 0 && $this->store->getVar('id', STORE_RECORD) === false) { if ($recordId > 0 && $this->store->getVar('id', STORE_RECORD) === false) {
$row = $this->db->sql("SELECT * FROM " . $this->formSpec['tableName'] . " WHERE id = ?", ROW_REGULAR, array($recordId)); $row = $this->db->sql("SELECT * FROM " . $this->formSpec['tableName'] . " WHERE id = ?", ROW_EXPECT_1, array($recordId));
$this->store->setVarArray($row[0], STORE_RECORD); $this->store->setVarArray($row, STORE_RECORD);
} }
// Iterate over all FormElements // Iterate over all FormElements
...@@ -316,7 +335,7 @@ abstract class AbstractBuildForm { ...@@ -316,7 +335,7 @@ abstract class AbstractBuildForm {
$elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack); $elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack);
// debugStack as Tooltip // debugStack as Tooltip
if( $this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) === 'yes' && count($debugStack)>0) { if ($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) === 'yes' && count($debugStack) > 0) {
$elementHtml = Support::appendTooltip($elementHtml, implode("\n", OnArray::htmlentitiesOnArray($debugStack))); $elementHtml = Support::appendTooltip($elementHtml, implode("\n", OnArray::htmlentitiesOnArray($debugStack)));
} }
......
...@@ -90,7 +90,13 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -90,7 +90,13 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @return string * @return string
*/ */
public function head() { public function head() {
$html = $this->formEditLink(); // Logged in BE User will see a FormEdit Link
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
$formEditUrl = $this->createFormEditUrl();
$html = "<p><a href='$formEditUrl'>Edit</a> <small>[$sipParamString]</small></p>";
$deleteUrl = $this->createDeleteUrl($this->formSpec['tableName'], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$html .= "<p><a href='$deleteUrl'>Delete</a>";
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid" $html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
......
...@@ -66,7 +66,15 @@ class BuildFormTable extends AbstractBuildForm { ...@@ -66,7 +66,15 @@ class BuildFormTable extends AbstractBuildForm {
$html = ''; $html = '';
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything $html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
$html .= $this->formEditLink();
// Logged in BE User will see a FormEdit Link
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
$formEditUrl = $this->createFormEditUrl();
$html .= "<p><a href='$formEditUrl'>Edit</a> <small>[$sipParamString]</small></p>";
$deleteUrl = $this->createDeleteUrl($this->formSpec['tableName'], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$html .= "<p><a href='$deleteUrl'>Delete</a>";
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true); $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
$html .= $this->getFormTag(); $html .= $this->getFormTag();
$html .= '<table>'; $html .= '<table>';
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
const CONFIG_INI = "config.ini"; // QFQ configuration file: db access const CONFIG_INI = "config.ini"; // QFQ configuration file: db access
const GFX_INFO = 'typo3conf/ext/qfq/Resources/Public/icons/note.gif';
const API_DIR = 'typo3conf/ext/qfq/qfq/api/';
const QFQ_LOG = 'qfq.log'; const QFQ_LOG = 'qfq.log';
const FORM_LOAD = 'form_load'; const FORM_LOAD = 'form_load';
...@@ -109,6 +112,7 @@ const ERROR_UNNOWN_STORE = 1046; ...@@ -109,6 +112,7 @@ const ERROR_UNNOWN_STORE = 1046;
const ERROR_GET_STORE_ZERO = 1047; const ERROR_GET_STORE_ZERO = 1047;
const ERROR_SET_STORE_ZERO = 1048; const ERROR_SET_STORE_ZERO = 1048;
const ERROR_MISSING_FORMELEMENT = 1049; const ERROR_MISSING_FORMELEMENT = 1049;
const ERROR_INVALID_OR_MISSING_PARAMETER = 1050;
// Store // Store
const ERROR_STORE_VALUE_ALREADY_CODPIED = 1100; const ERROR_STORE_VALUE_ALREADY_CODPIED = 1100;
...@@ -220,6 +224,7 @@ const SYSTEM_FORM_ELEMENT_MESSAGE = 'formElementMessage'; // '<columnname of cur ...@@ -220,6 +224,7 @@ const SYSTEM_FORM_ELEMENT_MESSAGE = 'formElementMessage'; // '<columnname of cur
const SIP_SIP = CLIENT_SIP; // s const SIP_SIP = CLIENT_SIP; // s
const SIP_RECORD_ID = CLIENT_RECORD_ID; // r const SIP_RECORD_ID = CLIENT_RECORD_ID; // r
const SIP_FORM = CLIENT_FORM; const SIP_FORM = CLIENT_FORM;
const SIP_TABLE = 'table'; // delete a record from 'table'
const SIP_URLPARAM = 'urlparam'; const SIP_URLPARAM = 'urlparam';
// FURTHER: all extracted params from 'urlparam // FURTHER: all extracted params from 'urlparam
...@@ -229,4 +234,16 @@ const SIP_URLPARAM = 'urlparam'; ...@@ -229,4 +234,16 @@ const SIP_URLPARAM = 'urlparam';
// FORMELEMENT - copy of all formElements of processed form // FORMELEMENT - copy of all formElements of processed form
//const DEF_FORM_ELEMENT_ID = 'id'; //const DEF_FORM_ELEMENT_ID = 'id';
const GFX_INFO = 'typo3conf/ext/qfq/Resources/Public/icons/note.gif'; // api/save.php, api/delete.php
\ No newline at end of file const API_STATUS = 'status';
const API_MESSAGE = 'message';
const API_REDIRECT = 'redirect';
const API_REDIRECT_URL = 'redirect-url';
const API_FIELD_NAME = 'field-name';
const API_FIELD_MESSAGE = 'field-message';
const API_ANSWER_STATUS_SUCCESS = 'success';
const API_ANSWER_STATUS_ERROR = 'error';
const API_ANSWER_REDIRECT_CLIENT = 'client';
const API_ANSWER_REDIRECT_NO = 'no';
const API_ANSWER_REDIRECT_URL = 'url';
...@@ -107,7 +107,6 @@ class QuickFormQuery { ...@@ -107,7 +107,6 @@ class QuickFormQuery {
if (!isset($t3data['uid'])) if (!isset($t3data['uid']))
$t3data['uid'] = 0; $t3data['uid'] = 0;
$this->t3data = $t3data; $this->t3data = $t3data;
$bodytext = $this->t3data['bodytext']; $bodytext = $this->t3data['bodytext'];
...@@ -119,6 +118,8 @@ class QuickFormQuery { ...@@ -119,6 +118,8 @@ class QuickFormQuery {
} }
/** /**
* Returns the defined forwardMode and set, if necessary, $forwardPage
*
* @param $forwardPage * @param $forwardPage
* @return mixed * @return mixed
*/ */
...@@ -128,6 +129,8 @@ class QuickFormQuery { ...@@ -128,6 +129,8 @@ class QuickFormQuery {
} }
/** /**
* Main entrypoint for display content: form or report
*
* @return string * @return string
*/ */
public function process() { public function process() {
...@@ -140,6 +143,7 @@ class QuickFormQuery { ...@@ -140,6 +143,7 @@ class QuickFormQuery {
/** /**
* Process form (load or save) if a formname is found. * Process form (load or save) if a formname is found.
*
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws UserException * @throws UserException
...@@ -189,8 +193,7 @@ class QuickFormQuery { ...@@ -189,8 +193,7 @@ class QuickFormQuery {
} }
/** /**
* Loads specification of recent form. * Load form. Evaluates form. Load FormElements.
* Evaluates Form and all FormElements.
* *
* Loaded Form is in $this->formSpec * Loaded Form is in $this->formSpec
* Loaded 'action' FormElements are in $this->feSpecAction * Loaded 'action' FormElements are in $this->feSpecAction
...@@ -203,12 +206,15 @@ class QuickFormQuery { ...@@ -203,12 +206,15 @@ class QuickFormQuery {
*/ */
private function loadFormSpecification($mode) { private function loadFormSpecification($mode) {
// formName
if (false === $formName = $this->getFormName()) { if (false === $formName = $this->getFormName()) {
return false; return false;
} }
$this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM); $this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM);
$form = $this->db->sql("SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'", ROW_EXPECT_1, [$formName], 'Form not found or multiple forms with the same name.'); // Load form
$form = $this->db->sql("SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'", ROW_EXPECT_1,
[$formName], 'Form not found or multiple forms with the same name.');
$this->formSpec = $this->eval->parseArray($form); $this->formSpec = $this->eval->parseArray($form);
HelperFormElement::explodeParameter($this->formSpec); HelperFormElement::explodeParameter($this->formSpec);
...@@ -217,18 +223,21 @@ class QuickFormQuery { ...@@ -217,18 +223,21 @@ class QuickFormQuery {
$this->store->setVar(SYSTEM_FORM_ELEMENT, '', STORE_SYSTEM); $this->store->setVar(SYSTEM_FORM_ELEMENT, '', STORE_SYSTEM);
// FE: Action // FE: Action
$this->feSpecAction = $this->eval->parseArray($this->db->sql(SQL_FORM_ELEMENT_ALL_CONTAINER, ROW_REGULAR, ['no', $this->formSpec["id"], 'action'])); $this->feSpecAction = $this->eval->parseArray($this->db->sql(SQL_FORM_ELEMENT_ALL_CONTAINER, ROW_REGULAR,
['no', $this->formSpec["id"], 'action']));
HelperFormElement::explodeParameterInArrayElements($this->feSpecAction); HelperFormElement::explodeParameterInArrayElements($this->feSpecAction);
// FE: Native & Container // FE: Native & Container
// "SELECT *, ? AS 'nestedInFieldSet' FROM FormElement AS fe WHERE fe.formId = ? AND fe.deleted = 'no' AND FIND_IN_SET(fe.class, ? ) AND fe.feIdContainer = ? AND fe.enabled='yes' ORDER BY fe.ord, fe.id"; // "SELECT *, ? AS 'nestedInFieldSet' FROM FormElement AS fe WHERE fe.formId = ? AND fe.deleted = 'no' AND FIND_IN_SET(fe.class, ? ) AND fe.feIdContainer = ? AND fe.enabled='yes' ORDER BY fe.ord, fe.id";
switch ($mode) { switch ($mode) {
case FORM_LOAD: case FORM_LOAD:
$this->feSpecNative = $this->db->sql(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER, ROW_REGULAR, ['no', $this->formSpec["id"], 'native,container', 0]); $this->feSpecNative = $this->db->sql(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER, ROW_REGULAR,
['no', $this->formSpec["id"], 'native,container', 0]);
break; break;
case FORM_SAVE: case FORM_SAVE:
$this->feSpecNative = $this->db->sql(SQL_FORM_ELEMENT_ALL_CONTAINER, ROW_REGULAR, ['no', $this->formSpec["id"], 'native']); $this->feSpecNative = $this->db->sql(SQL_FORM_ELEMENT_ALL_CONTAINER, ROW_REGULAR,
['no', $this->formSpec["id"], 'native']);
break; break;
default: default:
...@@ -240,6 +249,8 @@ class QuickFormQuery { ...@@ -240,6 +249,8 @@ class QuickFormQuery {
} }
/** /**
* Get the formName from STORE_TYPO3 (bodytext), STORE_SIP or by STORE_CLIENT (URL).
*
* @return string|bool Formname (Form.name) or FALSE if no formname found. * @return string|bool Formname (Form.name) or FALSE if no formname found.
* @throws UserException * @throws UserException
* @throws CodeException * @throws CodeException
...@@ -252,6 +263,8 @@ class QuickFormQuery { ...@@ -252,6 +263,8 @@ class QuickFormQuery {
} }
/** /**
* Check if loading of the given form is permit. If not, throw an exception.
*
* @return bool - 'true' if SIP exists, else 'false' * @return bool - 'true' if SIP exists, else 'false'
* @throws CodeException * @throws CodeException
* @throws UserException * @throws UserException
...@@ -262,13 +275,13 @@ class QuickFormQuery { ...@@ -262,13 +275,13 @@ class QuickFormQuery {
$r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_CLIENT); $r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_CLIENT);
// If there is a record_id>0: EDIT else NEW // If there is a record_id>0: EDIT else NEW
$mode = ($r > 0) ? $this->formSpec['permitEdit'] : $this->formSpec['permitNew']; $permitMode = ($r > 0) ? $this->formSpec['permitEdit'] : $this->formSpec['permitNew'];
$feUserLoggedIn = isset($GLOBALS["TSFE"]->fe_user->user["uid"]) && $GLOBALS["TSFE"]->fe_user->user["uid"] > 0; $feUserLoggedIn = isset($GLOBALS["TSFE"]->fe_user->user["uid"]) && $GLOBALS["TSFE"]->fe_user->user["uid"] > 0;
$sipFound = $this->store->getVar(SIP_SIP, STORE_SIP) !== false; $sipFound = $this->store->getVar(SIP_SIP, STORE_SIP) !== false;
switch ($mode) { switch ($permitMode) {
case FORM_PERMISSION_SIP: case FORM_PERMISSION_SIP:
if (!$sipFound) { if (!$sipFound) {
throw new UserException("SIP Parameter needed for this form.", ERROR_SIP_NEEDED_FOR_THIS_FORM); throw new UserException("SIP Parameter needed for this form.", ERROR_SIP_NEEDED_FOR_THIS_FORM);
...@@ -289,7 +302,7 @@ class QuickFormQuery { ...@@ -289,7 +302,7 @@ class QuickFormQuery {
case FORM_PERMISSION_NEVER: case FORM_PERMISSION_NEVER:
throw new UserException("Loading form forbidden.", ERROR_FORM_FORBIDDEN); throw new UserException("Loading form forbidden.", ERROR_FORM_FORBIDDEN);
default: default:
throw new CodeException("Unknown permission mode: '" . $mode . "'", ERROR_FORM_UNKNOWN_PERMISSION_MODE); throw new CodeException("Unknown permission mode: '" . $permitMode . "'", ERROR_FORM_UNKNOWN_PERMISSION_MODE);
} }
// Form Definition valid? // Form Definition valid?
...@@ -301,6 +314,8 @@ class QuickFormQuery { ...@@ -301,6 +314,8 @@ class QuickFormQuery {
} }
/** /**
* Process the SQL Queries from bodytext. Return the output.
*
* @return string * @return string
*/ */
private function doReport() { private function doReport() {
...@@ -313,6 +328,8 @@ class QuickFormQuery { ...@@ -313,6 +328,8 @@ class QuickFormQuery {
} }
/** /**
* Save the current form.
*
* @return string * @return string
*/