18 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
75 if ($asset->attr(
'submitted') ==
'---------- --:--:--') {
76 echo translate(
'cms_not_submitted');
78 echo date(
'd M Y H:i:s', strtotime($asset->attr(
'submitted')));
96 $wa = $asset->writeAccess(
'attributes');
97 $is_editable_q = FALSE;
99 $answers = $asset->attr(
'attributes');
100 if (empty($answers[
'answers']))
return ($wa && $is_editable_q);
102 reset($answers[
'answers']);
103 $form_id = key($GLOBALS[
'SQ_SYSTEM']->am->getParents(key($answers[
'answers']),
'form', FALSE));
104 $form = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($form_id);
105 $sections = $form->getSections();
106 for (reset($sections); $section = current($sections); next($sections)) {
107 $section_questions[$section->id] = Array();
109 $section_questions[$form_id] = Array();
110 foreach ($answers[
'answers'] as $q_id => $details) {
111 $section_id = strtok($q_id,
':');
112 $details[
'printed'] = FALSE;
113 $section_questions[$section_id][$q_id] = $details;
115 foreach ($form->attr(
'sort_order') as $q_id) {
116 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($q_id);
117 if ($q->isEditable() && !$is_editable_q) {
118 $is_editable_q = TRUE;
120 if (isset($section_questions[$form_id][$q_id])) {
121 if (is_string($section_questions[$form_id][$q_id][
'answer'])) {
122 $q->setValue(html_entity_decode($section_questions[$form_id][$q_id][
'answer']));
124 $q->setValue($section_questions[$form_id][$q_id][
'answer']);
127 $note = $q->isEditable() ? $q->getVal(
'note') :
'<i>'.translate(
'cms_form_submission_cannot_edit_question_type').
'</i>';
128 $o->openField($q->getVal(
'title'),
'', $note);
131 $q->setValue(array_get_index($section_questions[$form_id][$q_id],
'answer',
''));
132 $q->setExtraData(array_get_index($section_questions[$form_id][$q_id],
'extra_data', Array()));
134 $q_summary = $q->getSummary();
135 $filepath = $q->getExtraData(
'filesystem_path');
139 if ((SQ_IN_BACKEND || SQ_IN_LIMBO) && (!empty($filepath) && (!isset($filepath[
'existing_file_assetid']) && !isset($filepath[
'new_file_assetid'])) ) ) {
140 $q_summary .=
' [ <a href="./?a='.$asset->id.
'&q='.$q->id.
'">'.
'Click to download'.
'</a> ]';
141 }
else if ((SQ_IN_BACKEND || SQ_IN_LIMBO) && (!empty($filepath) && (isset($filepath[
'existing_file_assetid']) || isset($filepath[
'new_file_assetid']) ) ) ) {
142 $uploade_file_id = array_key_exists(
'existing_file_assetid', $filepath) ? $filepath[
'existing_file_assetid'] : $filepath[
'new_file_assetid'];
143 $q_summary .=
' [ <a href="./?a='.$uploade_file_id.
'" target="_blank" >'.
'Click to download'.
'</a> ]';
146 $q_summary = htmlentities($q->getSummary(), ENT_NOQUOTES, SQ_CONF_DEFAULT_CHARACTER_SET).
' ';
148 echo ($q->isEditable() && $wa) ? $q->getHtmlField() : $q_summary;
150 $section_questions[$form_id][$q_id][
'printed'] = TRUE;
153 foreach ($section_questions[$form_id] as $q_id => $q_details) {
154 if (!$q_details[
'printed']) {
155 $note =
'<i>'.translate(
'cms_form_submission_question_deleted_cannot_be_edited').
'</i>';
156 $o->openField($answers[
'summary'][$q_id][
'name'],
'', $note);
157 echo $q_details[
'answer'];
162 unset($section_questions[$form_id]);
163 foreach ($section_questions as $section_id => $section_qs) {
164 $section_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($section_id);
165 if (!empty($section_info)) {
166 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($section_id);
167 $o->openSection(translate(
'cms_form_submission_answers_for_section',$section->name));
168 foreach ($section->attr(
'sort_order') as $q_id) {
169 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($q_id);
170 if ($q->isEditable() && !$is_editable_q) {
171 $is_editable_q = TRUE;
174 if (isset($section_questions[$section_id][$q_id])) {
175 $q->setValue(array_get_index($section_questions[$section_id][$q_id],
'answer',
''));
176 $q->setExtraData(array_get_index($section_questions[$section_id][$q_id],
'extra_data', Array()));
179 $note = $q->isEditable() ? $q->getVal(
'note') :
'<i>'.translate(
'cms_form_submission_cannot_edit_question_type').
'</i>';
181 $o->openField($q->getVal(
'title'),
'', $note);
182 if ($q->isEditable() && $wa) {
183 echo $q->getHtmlField();
184 $is_editable_q = TRUE;
186 $summary = $q->getSummary();
189 $filepath = $q->getExtraData(
'filesystem_path');
193 if ((SQ_IN_BACKEND || SQ_IN_LIMBO) && (!empty($filepath) && (!isset($filepath[
'existing_file_assetid']) && !isset($filepath[
'new_file_assetid'])) ) ) {
194 $summary .=
' [ <a href="./?a='.$asset->id.
'&q='.$q->id.
'">'.
'Click to download'.
'</a> ]';
195 }
else if ((SQ_IN_BACKEND || SQ_IN_LIMBO) && (!empty($filepath) && (isset($filepath[
'existing_file_assetid']) || isset($filepath[
'new_file_assetid']) ) ) ) {
196 $uploade_file_id = array_key_exists(
'existing_file_assetid', $filepath) ? $filepath[
'existing_file_assetid'] : $filepath[
'new_file_assetid'];
197 $summary .=
' [ <a href="./?a='.$uploade_file_id.
'" target="_blank" >'.
'Click to download'.
'</a> ]';
201 $summary .=
' ';
204 $section_questions[$section_id][$q_id][
'printed'] = TRUE;
208 $o->openSection(translate(
'cms_form_submission_answers_for_deleted_section'));
211 foreach ($section_questions[$section_id] as $q_id => $q_details) {
213 if (!$q_details[
'printed']) {
214 $note =
'<i>'.translate(
'cms_form_submission_question_deleted_cannot_be_edited').
'</i>';
215 $o->openField($answers[
'summary'][$q_id][
'name'],
'', $note);
216 echo $q_details[
'answer'];
223 return $wa && $is_editable_q;
240 $attributes = $asset->attr(
'attributes');
241 $wa = $asset->writeAccess(
'attributes');
243 if (empty($attributes[
'answers']) || !$wa)
return FALSE;
245 $form_id = key($GLOBALS[
'SQ_SYSTEM']->am->getParents(key($attributes[
'answers']),
'form', FALSE));
246 $form = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($form_id);
247 $this->_tmp[
'question_errors'] = Array();
248 $unanswered_questions = $form->getAllQuestionAssets();
250 foreach ($attributes[
'answers'] as $q_id => $details) {
251 $question_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($q_id);
252 if (!is_null($question_asset)) {
253 if (!$question_asset->isEditable())
continue;
254 $question_asset->populate();
255 if (($question_asset->getValue() != $details[
'answer']) && (!$question_asset->hasValidValue())) {
256 $this->_tmp[
'question_errors'] = array_merge($this->_tmp[
'question_errors'], $question_asset->failed_rules);
258 $value = $question_asset->getValue();
259 $attributes[
'answers'][$q_id][
'answer'] = $value;
260 $attributes[
'summary'][$q_id][
'answer'] = $question_asset->getSummary();
261 $attributes[
'summary'][$q_id][
'name'] = $question_asset->getVal(
'title');
263 unset($unanswered_questions[$q_id]);
265 $section_id = strtok($q_id,
':');
266 $details[
'printed'] = FALSE;
267 $section_questions[$section_id][$q_id] = $details;
270 foreach ($unanswered_questions as $unanswered_question) {
271 $question_asset =& $unanswered_question;
272 if (!$question_asset->isEditable())
continue;
273 $question_asset->setAttrValue(
'is_required', FALSE);
274 $question_asset->populate();
275 if (!$question_asset->hasValidValue()) {
276 $this->_tmp[
'question_errors'] = array_merge($this->_tmp[
'question_errors'], $question_asset->failed_rules);
278 $value = $question_asset->getValue();
279 $attributes[
'answers'][$question_asset->id][
'answer'] = $value;
280 $attributes[
'summary'][$question_asset->id][
'answer'] = $question_asset->getSummary();
281 $attributes[
'summary'][$question_asset->id][
'name'] = $question_asset->getVal(
'title');
283 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($question_asset);
285 if (empty($this->_tmp[
'question_errors'])) {
286 $asset->setAttrValue(
'attributes', $attributes);
290 <div style=
"color: red">
291 <strong><?php echo translate(
'cms_form_submission_error_during_processing'); ?></strong>
294 foreach ($this->_tmp[
'question_errors'] as $msg) {
296 <li><?php echo $msg; ?></li>