Skip to content

Commit

Permalink
feat: enable advanced validation
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jun 22, 2022
1 parent 7dba5f2 commit 6a24d7b
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public static function canView() {
public function canViewItem() {
global $DB;

// if (Plugin::isPluginActive('advform')) {
// $advFormAnswer = new PluginAdvformFormanswer();
// $advFormAnswer->getFromDB($this->getID());
// return $advFormAnswer->canViewItem();
// }
if (Plugin::isPluginActive('advform')) {
$advFormAnswer = new PluginAdvformFormanswer();
$advFormAnswer->getFromDB($this->getID());
return $advFormAnswer->canViewItem();
}

$currentUser = Session::getLoginUserID();

Expand Down Expand Up @@ -454,9 +454,11 @@ static function showForForm(PluginFormcreatorForm $form, $params = []) {
* Can the current user validate the form ?
*/
public function canValidate(): bool {
// if (Plugin::isPluginActive('advform')) {
// return PluginAdvformFormAnswer::canValidate($this);
// }
if (Plugin::isPluginActive('advform')) {
$formAnswer = new PluginAdvformFormAnswer();
$formAnswer->getFromDB($this->getID());
return $formAnswer->canValidate($this);
}

if (!PluginFormcreatorCommon::canValidate()) {
return false;
Expand Down Expand Up @@ -665,7 +667,9 @@ public function showForm($ID, $options = []) {
}

if (Plugin::isPluginActive('advform')) {
PluginAdvformFormanswerValidation::showValidationStatuses($this);
$formAnswer = PluginFormcreatorCommon::getFormAnswer();
$formAnswer->getFromDB($this->getID());
PluginAdvformFormanswerValidation::showValidationStatuses($formAnswer);
}
$options['canedit'] = true;
$options['candel'] = false;
Expand Down Expand Up @@ -936,7 +940,8 @@ public function getForm(int $formId = null): ?PluginFormcreatorForm {
}

$formFk = PluginFormcreatorForm::getForeignKeyField();
$form = PluginFormcreatorForm::getById($formId ?? $this->fields[$formFk]);
$form = PluginFormcreatorCommon::getForm();
$form->getFromDB($formId ?? $this->fields[$formFk]);
if ($form === false) {
return null;
}
Expand Down Expand Up @@ -1545,10 +1550,6 @@ private function updateIssue() {
public static function getMyLastAnswersAsRequester($limit = 5) {
global $DB;

if (Plugin::isPluginActive('advform')) {
return PluginAdvformFormAnswer::getMyLastAnswersAsRequester($limit);
}

$formAnswerTable = self::getTable();
$formTable = PluginFormcreatorForm::getTable();
$request = [
Expand Down

0 comments on commit 6a24d7b

Please sign in to comment.