18 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
55 'type' =>
'serialise',
58 'is_required' => Array(
63 'cust_required_error' => Array(
72 'parameters' => Array(
73 'allow_empty' => FALSE,
80 'parameters' => Array(
81 'allow_negative' => FALSE,
82 'allow_empty' => TRUE,
83 'range_upper' => 32767,
102 $res = parent::_upgrade($current_version);
104 if (version_compare($current_version,
'0.6',
'<')) {
105 echo(
'UPGRADING FORM QUESTION FROM v < 0.6');
109 if (version_compare($current_version,
'0.3',
'<')) {
111 $fixing_upgrade = FALSE;
114 $fixing_upgrade = TRUE;
118 $form_ids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'form', FALSE, TRUE);
119 $question_assets = Array();
120 foreach ($form_ids as $form_id => $type) {
121 $form = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($form_id, $type);
122 $question_assets += $form->getChildren($form->id,
'form_question', FALSE);
124 $section_ids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'form_section', FALSE, TRUE);
125 foreach ($section_ids as $section_id => $type) {
126 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($section_id, $type);
127 $question_assets += $section->getChildren($section->id,
'form_question', FALSE);
131 $irrelevant_types = Array();
132 foreach ($question_assets as $id => $type) {
133 if (!isset($irrelevant_types[$type])) {
134 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id, $type);
135 if (!isset($q->vars[
'required'])) {
136 $irrelevant_types[$type] = 1;
139 if ((!$fixing_upgrade) || ($q->attr(
'is_required') == FALSE)) {
143 $q->setAttrValue(
'is_required', $q->attr(
'required'));
144 $q->saveAttributes();