39 return 'Form Integrity Test';
52 return 'A test to check the integrity of forms';
66 public static function test(&$messages, &$errors)
70 $form_assetids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetIds(
'form', FALSE);
71 foreach ($form_assetids as $assetid) {
72 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
76 $questions = $asset->getAllQuestions();
77 foreach ($questions as $question_id => $question_details) {
78 $question = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($question_id,
'', TRUE);
79 if (is_null($question)) {
82 $errors[] =
'Question #'.$question_id.
' on Form #'.$assetid.
' is invalid';
84 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($question);
90 if (strtolower($asset->type()) !==
'form_ecommerce') {
91 $submission_folder = $asset->getSubmissionsFolder();
92 if (is_null($submission_folder)) {
95 $errors[] =
'Submission Folder does not exist for Form #'.$assetid;
97 $submissions_found = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($submission_folder->id,
'form_submission', FALSE);
98 foreach ($submissions_found as $sub_id => $sub_type_code) {
99 $sub = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sub_id,
'', TRUE);
103 $errors[] =
'Submission #'.$sub_id.
' under Form #'.$assetid.
' and could not be loaded';
105 $sub_complete = $sub->attr(
'complete');
106 if (!$sub_complete) {
109 $errors[] =
'Submission #'.$sub_id.
' under Form #'.$assetid.
' and not completed';
111 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($sub, TRUE);
114 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($submission_folder, TRUE);
119 $actions = $asset->attr(
'actions');
120 foreach ($actions as $action) {
121 $action_type = $action[
'type_code'];
122 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($action_type);
124 if (!$action[
'active'] && !call_user_func(Array($action_type,
'isValid'), $asset, $action[
'settings'])) {
127 $errors[] =
'Form #'.$assetid.
' has an invalid form action ('.$action_type.
')';
132 if ($invalid) $count++;
134 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset, TRUE);
138 $messages[] =
'There are '.$count.
' forms found on the system with problems';