@@ -6,30 +6,19 @@ use IMATHUZH\Qfq\Core\Database\Database;
useIMATHUZH\Qfq\Core\Helper\HelperFile;
useIMATHUZH\Qfq\Core\Helper\SqlQuery;
// TODO: test saving of FormElement <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// TODO: implement FORM_DELETE in QuickFormQuery.php
// TODO: Form speichern. siehe zettlr note.
// FORM_DELETE: export Form/FormElement
// FORM_REST:
// FORM_LOAD:
// FORM_SAVE: export Form/FormElement
// FORM_UPDATE: (export Form/FormElement) NO, ask carsten
// FORM_DRAG_AND_DROP: export Form/FormElement
// TODO: test deleteing of Form and FormElement <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// TODO: ensure that form file is imported if Form is loaded via Rest API
// TODO: gibt es UPDATE/INSERT/DELETE statements die an Form/FormElement arbeiten koennen, die nicht nur durch doForm aufgerufen werden?
// TODO: Dies sollte schon erfuellt sein, testen: bevor ein form/formelement im form editor gespeichert wird, soll es vom file geladen werden (Save.php). Falls das file importiert wurde, gibt es eine fehlermeldung.
// TODO: anfrage nach dirty, form file ueberpruefen (importieren)
// TODO: Testen: Dies sollte schon erfuellt sein, testen: bevor ein form/formelement im form editor gespeichert wird, soll es vom file geladen werden (Save.php). Falls das file importiert wurde, gibt es eine fehlermeldung.
// TODO: Testen: anfrage nach dirty, form file ueberpruefen (importieren)
// TODO: Testen: Dirty tabelle ist aussergewoehnlich voll. werden die records nicht abgeraeumt wegen formAsFile?
// TODO: ausporbieren was passiert wenn ich in Form-Editor auf speicher druecke nachdem ich in einem anderen tab das geanderte form file in die DB lade.
// TODO: Testen: ausporbieren was passiert wenn ich in Form-Editor auf speicher druecke nachdem ich in einem anderen tab das geanderte form file in die DB lade.
// TODO: form list Report: when form list report is loaded, load new form files into DB and delete removed forms from DB
// TODO: Carsten Fragen: Form backups erstellen vor dem delete?
// TODO: Maybe: solve reference by ID after file change Problem (might not be a big deal since it only happens on git pull)
// Problem: FormEditor and form list might reference a form by an old id. In that case everything has to be reloaded. That's annoying.
// Variant 1: reference form by name in edit and delete button, not by id (only solver part of the problem)
// Variant 2: track old form ids and relay to new form automatically. Track old form ids in new Form column "oldIds"
// TODO: DONT DO: add column import-modification-date to Form and FormElement and set them to the same as modification date in both exportForm and importForm. compare the two modification dates in the beginning. If the actual modification is after importModification and fileStats are the same in file and in form, then exportForm.
// TODO: DONT DO: what to do if importModificationDate and fileStats have changed? > 1) export Form to new form file named <formName>mergeConflict_timestamp 2) importForm form file, overwrite DB
// TODO: Carsten Fragen: Form backups erstellen vor deleteFormFile und exportForm?
// TODO: Maybe: solve reference by ID after file change Problem (might not be a big deal since it only happens on git pull)
// Problem: FormEditor and form list might reference a form by an old id. In that case everything has to be reloaded. That's annoying.
// Variant 1: reference form by name in edit and delete button, not by id (only solver part of the problem)
// Variant 2: track old form ids and relay to new form automatically. Track old form ids in new Form column "oldIds"
// TODO: DON'T DO
// TODO: DONT DO: add column import-modification-date to Form and FormElement and set them to the same as modification date in both exportForm and importForm. compare the two modification dates in the beginning. If the actual modification is after importModification and fileStats are the same in file and in form, then exportForm.
// TODO: DONT DO: what to do if importModificationDate and fileStats have changed? > 1) export Form to new form file named <formName>mergeConflict_timestamp 2) importForm form file, overwrite DB
///////////////// JUST A TEST, DELETE ME! //////////////
$formFromDb=$database->sql("SELECT `$F_NAME` FROM `$TABLE_NAME_FORM` AS f WHERE `f`.`$F_ID`=? AND `f`.`deleted`='no'",ROW_EXPECT_1,
[$recordId],"Form with id '$recordId' not found. ".self::errorHintFormImport());
return$formFromDb[F_NAME];
caseTABLE_NAME_FORM_ELEMENT:
$F_NAME=F_NAME;
$TABLE_NAME_FORM_ELEMENT=TABLE_NAME_FORM_ELEMENT;
$TABLE_NAME_FORM=TABLE_NAME_FORM;
$F_ID=F_ID;
$FE_FORM_ID=FE_FORM_ID;
$FE_ID=FE_ID;
$formFromDb=$database->sql("SELECT `f`.`$F_NAME` FROM `$TABLE_NAME_FORM` AS f INNER JOIN `$TABLE_NAME_FORM_ELEMENT` AS fe ON f.`$F_ID`=fe.`$FE_FORM_ID` WHERE `fe`.`$FE_ID`=?",ROW_EXPECT_1,
[$recordId],"Form element with id '$recordId' not found. ".self::errorHintFormImport());
return$formFromDb[F_NAME];
default:
returnfalse;
}
}
...
...
@@ -434,45 +398,6 @@ class FormAsFile
$database->sql("DELETE FROM `$TABLE_NAME_FORM_ELEMENT` WHERE `$FE_FORM_ID`=?",ROW_REGULAR,[$formId]);
$formFromDb=$database->sql("SELECT `f`.`$F_NAME` FROM `$TABLE_NAME_FORM` AS f INNER JOIN `$TABLE_NAME_FORM_ELEMENT` AS fe ON f.`$F_ID`=fe.`$FE_FORM_ID` WHERE `fe`.`$FE_ID`=?",ROW_EXPECT_1,
[$formElementId],"Form element with id '$formElementId' not found. ".self::errorHintFormImport());
ERROR_MESSAGE_TO_DEVELOPER=>"Reading/Writing Form file failed: Form name '$formName' not valid. Name may only consist of alphanumeric characters and _ . -"]),