18 require_once dirname(__FILE__).
'/../form/form_edit_fns.inc';
19 require_once SQ_FUDGE_PATH.
'/datetime_field/datetime_field.inc';
20 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
21 require_once SQ_FUDGE_PATH.
'/db_extras/db_extras.inc';
65 'min' =>
'2003-01-01 00:00:00',
66 'max' => ts_iso8601(time()),
68 'show' => Array(
'y',
'm',
'd'),
77 $parameters[
'print_format'] =
'j M Y';
79 $from_value = isset($_POST[$prefix.
'_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_fromvalue'][
'm'],$_POST[$prefix.
'_fromvalue'][
'd'],$_POST[$prefix.
'_fromvalue'][
'y'])) : date(
'Y-m-d',time()-7*86400).
' --:--:--';
80 $to_value = isset($_POST[$prefix.
'_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_tovalue'][
'm'],$_POST[$prefix.
'_tovalue'][
'd'],$_POST[$prefix.
'_tovalue'][
'y'])) : date(
'Y-m-d').
' --:--:--';
82 $from =
new Datetime_Field($prefix.
'_from', $from_value, $parameters);
83 $to =
new Datetime_Field($prefix.
'_to', $to_value, $parameters);
86 echo
' '.translate(
'to').
' ';
106 $num_per_page = array_get_index($_REQUEST, $prefix.
'_per_page', 50);
107 if ($num_per_page < 1) $num_per_page = 50;
109 text_box($prefix.
'_per_page', $num_per_page, 3);
126 $write_access = $asset->writeAccess(
'links');
127 $expand_list = isset($_POST[$prefix.
'_expand']) ? $_POST[$prefix.
'_expand'] : Array();
131 $num_per_page = array_get_index($_REQUEST, $prefix.
'_per_page', 50);
132 if ($num_per_page < 1) $num_per_page = 50;
134 $from_value = isset($_POST[$prefix.
'_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_fromvalue'][
'm'],$_POST[$prefix.
'_fromvalue'][
'd'],$_POST[$prefix.
'_fromvalue'][
'y'])) : date(
'Y-m-d',time()-7*86400).
' --:--:--';
135 $to_value = isset($_POST[$prefix.
'_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_tovalue'][
'm'],$_POST[$prefix.
'_tovalue'][
'd'],$_POST[$prefix.
'_tovalue'][
'y'])) : date(
'Y-m-d').
' --:--:--';
137 $from_value = iso8601_date_component($from_value).
' 00:00:00';
138 $to_value = iso8601_date_component($to_value).
' 23:59:59';
142 $from_ts = mktime(0,0,0,$from_value[1],$from_value[2],$from_value[0]);
143 $to_ts = mktime(23,59,59,$to_value[1],$to_value[2],$to_value[0]);
146 a.assetid, a.created_userid, v.custom_val AS submitted
148 ('.SQ_TABLE_RUNNING_PREFIX.
'ast a
149 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_typ_inhd i ON a.type_code = i.type_code)
150 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_lnk l ON l.minorid = a.assetid
151 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_attr_val v ON v.assetid = a.assetid
152 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_attr n ON n.attrid = v.attrid';
157 ('.SQ_TABLE_RUNNING_PREFIX.
'ast a
158 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_typ_inhd i ON a.type_code = i.type_code)
159 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_lnk l ON l.minorid = a.assetid
160 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_attr_val v ON v.assetid = a.assetid
161 JOIN '.SQ_TABLE_RUNNING_PREFIX.
'ast_attr n ON n.attrid = v.attrid';
163 $sub_folder = $asset->getSubmissionsFolder();
166 $where =
'l.majorid IN (:assetid, :subfolder_assetid)
167 AND i.inhd_type_code = :inhd_type_code
168 AND n.name = :name AND v.contextid = :context';
170 $where .=
' AND TO_CHAR(DBMS_LOB.SUBSTR(v.custom_val, 30, 1)) > :from_date AND TO_CHAR(DBMS_LOB.SUBSTR(v.custom_val, 30, 1)) < :to_date';
171 $order =
' ORDER BY TO_CHAR(DBMS_LOB.SUBSTR(v.custom_val, 30, 1)) DESC';
173 $where .=
' AND v.custom_val BETWEEN :from_date AND :to_date';
174 $order =
' ORDER BY v.custom_val DESC';
177 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'a');
178 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'i');
179 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'n');
180 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'v');
181 $where = $GLOBALS[
'SQ_SYSTEM']->constructRollbackWhereClause($where,
'l');
195 }
catch (Exception $e) {
196 throw new Exception(
'Unable to get the number of assets due to database error: '.$e->getMessage());
199 $num_pages = ceil($asset_count / $num_per_page);
200 $page_num = array_get_index($_POST, $prefix.
'_submissions_page', 1);
201 $page_num = max($page_num, 1);
202 $page_num = min($page_num, $num_pages);
204 $submission_offset = ($page_num - 1) * $num_per_page;
206 $sql = $sql.$where.$order;
207 require_once SQ_FUDGE_PATH.
'/db_extras/db_extras.inc';
208 $sql = db_extras_modify_limit_clause($sql,
MatrixDAL::getDbType(), $num_per_page, $submission_offset);
210 if ($asset_count == 0) {
211 ?><p><i><?php echo translate(
'cms_form_no_submissions_during_period') ?></i></p><?php
213 if ($num_pages == 1) {
214 $page_tag = translate(
'page_number', $page_num, $num_pages);
216 $page_tag = translate(
'page_number_with_pager', $page_num, $num_pages, $prefix.
'_submissions_page');
218 $asset_count_tag = translate(
'item_range', ($page_num - 1) * $num_per_page + 1, min($asset_count, $page_num * $num_per_page), $asset_count, strtolower(translate(
'submissions')));
221 'first' =>
'<<',
222 'previous' =>
'<',
225 'last' =>
'>>',
229 $links[
'first'] =
'<a title="'.translate(
'pagination_go_to_first').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_submissions_page\', 1)">'.$links[
'first'].
'</a>';
230 $links[
'previous'] =
'<a title="'.translate(
'pagination_go_to_previous').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_submissions_page\', '.($page_num - 1).
')">'.$links[
'previous'].
'</a>';
232 $links[
'first'] =
'<span title="'.translate(
'pagination_cannot_go_further_back').
'." style="color: #333">'.$links[
'first'].
'</span>';
233 $links[
'previous'] =
'<span title="'.translate(
'pagination_cannot_go_further_back').
'." style="color: #333">'.$links[
'previous'].
'</span>';
236 if ($page_num < $num_pages) {
237 $links[
'last'] =
'<a title="'.translate(
'pagination_go_to_last').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_submissions_page\', '.$num_pages.
')">'.$links[
'last'].
'</a>';
238 $links[
'next'] =
'<a title="'.translate(
'pagination_go_to_next').
'" style="text-decoration: none; color: #fff" href="#" onClick="return sq_pager_jump(\''.$prefix.
'_submissions_page\', '.($page_num + 1).
')">'.$links[
'next'].
'</a>';
240 $links[
'last'] =
'<span title="'.translate(
'pagination_cannot_go_further_forward').
'." style="color: #333">'.$links[
'last'].
'</span>';
241 $links[
'next'] =
'<span title="'.translate(
'pagination_cannot_go_further_forward').
'." style="color: #333">'.$links[
'next'].
'</span>';
244 hidden_field($prefix.
'_submissions_page', $page_num); ?>
246 <style type=
"text/css">
250 .sq-form-sub table.sq-backend-table {
252 margin: 0 8px 8px 8px;
254 .sq-form-sub table.sq-backend-table th {
256 text-decoration: italic;
258 table.sq-backend-table tr td.sq-form-sub-header {
259 background-color: #666;
264 <script type=
"text/javascript"><!--
265 function sq_set_check_all(form, prefix, value) {
266 set_els = form.elements[prefix];
268 if (set_els.length) {
269 for (k = 0; k < set_els.length; k++) {
270 set_els[k].checked = value;
273 set_els.checked = value;
277 function sq_test_check_all(form, prefix, set_el) {
278 test_els = form.elements[prefix];
279 set_el = form.elements[set_el];
281 if (test_els.length) {
283 for (k = 0; k < test_els.length; k++) {
284 if (!test_els[k].checked) {
290 test = test_els.checked;
293 set_el.checked = test;
296 <table
class=
"sq-backend-table">
298 <td
class=
"sq-backend-table-header-header" colspan=
"2"><?php echo implode(
' ', $links) ?></td>
299 <td
class=
"sq-backend-table-header-header" colspan=
"<?php echo ($write_access === TRUE) ? 4 : 3 ?>" style=
"text-align: right; font-weight: normal"><?php echo $asset_count_tag; ?></span></td>
302 <td
class=
"sq-form-sub-header" colspan=
"2"><b><?php
303 hidden_field($prefix.
'_submission_offset', $submission_offset);
304 if ($submission_offset > 0) {
305 ?><a title=
"<?php echo translate('cms_form_submissions_go_to_first') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_submission_offset', '0'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
307 ?><span title=
"<?php echo translate('cms_form_cannot_go_further_back') ?>" style=
"color: #333"><?php
312 if ($submission_offset > 0) {
317 ?> <?php
318 if ($submission_offset > 0) {
319 ?><a title=
"<?php echo translate('cms_form_submissions_go_to_previous') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_submission_offset', '<?php echo $submission_offset - $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
321 ?><span title=
"<?php echo translate('cms_form_cannot_go_further_back') ?>" style=
"color: #333"><?php
326 if ($submission_offset > 0) {
332 <?php echo translate(
'page_number', round(($submission_offset + $num_per_page) / $num_per_page), ceil($asset_count / $num_per_page)); ?>
334 if (($submission_offset + $num_per_page) < $asset_count) {
335 ?><a title=
"<?php echo translate('cms_form_submissions_go_to_next') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_submission_offset', '<?php echo $submission_offset + $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
337 ?><span title=
"<?php echo translate('cms_form_cannot_go_further_forward') ?>" style=
"color: #333"><?php
342 if (($submission_offset + $num_per_page) < $asset_count) {
347 ?> <?php
348 if (($submission_offset + $num_per_page) < $asset_count) {
349 ?><a title=
"<?php echo translate('cms_form_submissions_go_to_last') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_submission_offset', '<?php echo ($num_pages - 1) * $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
351 ?><span title=
"<?php echo translate('cms_form_cannot_go_further_forward') ?>" style=
"color: #333"><?php
356 if (($submission_offset + $num_per_page) < $asset_count) {
363 <td
class=
"sq-form-sub-header" colspan=
"4" align=
"right"><?php echo translate(
'cms_form_submissions_during_period', $submission_offset + 1, min($asset_count, $submission_offset + $num_per_page), $asset_count) ?>
368 <?php echo translate(
'asset_id') ?>
371 <?php echo translate(
'submission_time') ?>
374 <?php echo translate(
'user') ?>
377 <input type=
"checkbox" name=
"<?php echo $prefix ?>_expand_all" value=
"" onclick=
"sq_set_check_all(this.form, '<?php echo $prefix ?>_expand[]', this.checked);"> <?php echo translate(
'expand_question') ?>
383 <input type=
"checkbox" name=
"<?php echo $prefix ?>_delete_all" value=
"" onclick=
"sq_set_check_all(this.form, '<?php echo $prefix ?>_delete[]', this.checked);"> <?php echo translate(
'delete_question') ?>
402 }
catch (Exception $e) {
403 throw new Exception(
'Unable to get submission list due to database error: '.$e->getMessage());
406 foreach ($result as $asset_info) {
407 $assetid = $asset_info[
'assetid'];
410 $sub_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
411 $sub_user = $asset_info[
'created_userid'];
412 $sub_time = date(
'd M Y H:i:s', strtotime($asset_info[
'submitted']));
413 $sub_expanded = array_search($assetid, $expand_list) !== FALSE;
416 if ($num_subs > $num_per_page)
break;
419 echo ($sub_expanded) ?
' class="alt"' :
'';
422 <?php echo $assetid ?>
425 <?php echo $sub_time ?>
430 if (!empty($sub_user)) {
431 $sub_user_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sub_user);
432 if (!empty($sub_user_asset)) {
433 echo get_asset_tag_line($sub_user);
438 ?><i><?php echo translate(
'cms_form_no_logged_in_user'); ?></i><?php
443 <input type=
"checkbox" name=
"<?php echo $prefix ?>_expand[]" value=
"<?php echo $assetid ?>" <?php
if ($sub_expanded) echo
' checked="checked"'; ?> onclick=
"sq_test_check_all(this.form, '<?php echo $prefix ?>_expand[]', '<?php echo $prefix ?>_expand_all');">
449 <input type=
"checkbox" name=
"<?php echo $prefix ?>_delete[]" value=
"<?php echo $assetid ?>" onclick=
"sq_test_check_all(this.form, '<?php echo $prefix ?>_delete[]', '<?php echo $prefix ?>_delete_all');">
454 <td>[ <a href=
"<?php echo $sub_asset->getBackendHref(); ?>"><?php echo translate(
'edit') ?></a> ]</td>
461 <td colspan=
"6" class=
"sq-form-sub">
462 <table
class=
"sq-backend-table">
466 $elements = $sub_asset->getSummary();
467 if (count($elements) % 2 != 0) {
468 $elements[] = Array(
'name' =>
'',
'answer' =>
'');
470 foreach ($elements as $element) {
473 <th width=
"10%"><?php echo $element[
'name'];
if (!empty($element[
'name'])) echo
':'; ?></th>
474 <td width=
"40%"><?php echo $element[
'answer']; ?></td>
476 if (($i < count($elements)) && ($i % 2 == 0)) {
493 <script type=
"text/javascript"><!--
494 sq_test_check_all(document.main_form,
'<?php echo $prefix ?>_expand[]',
'<?php echo $prefix ?>_expand_all');
517 $delete_list = isset($_POST[$prefix.
'_delete']) ? $_POST[$prefix.
'_delete'] : Array();
518 if (empty($delete_list))
return FALSE;
520 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
521 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
524 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'links')) {
525 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
526 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
530 foreach ($delete_list as $delete_assetid) {
532 if (!assert_valid_assetid($delete_assetid,
'', FALSE, FALSE)) {
533 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
534 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
539 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($delete_assetid,
'links')) {
540 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
541 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
544 $submissions_folder = $asset->getSubmissionsFolder();
545 $submission_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($submissions_folder->id, $delete_assetid, SQ_LINK_TYPE_3);
546 if (!$submission_link) {
547 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
548 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
551 if (!$submissions_folder->deleteLink($submission_link[
'linkid'])) {
552 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
553 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
559 if (!$GLOBALS[
'SQ_SYSTEM']->am->releaseLock($delete_assetid,
'links')) {
560 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
561 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
567 if (!$GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'links')) {
568 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
569 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
573 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
574 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
594 'min' =>
'2003-01-01 00:00:00',
595 'max' => ts_iso8601(time()),
596 'allow_circa' =>
'0',
597 'show' => Array(
'y',
'm',
'd'),
606 $parameters[
'print_format'] =
'j M Y';
608 $from_value = isset($_POST[$prefix.
'_export_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_fromvalue'][
'm'],$_POST[$prefix.
'_export_fromvalue'][
'd'],$_POST[$prefix.
'_export_fromvalue'][
'y'])) : date(
'Y-m-d', time()-7*86400).
' --:--:--';
609 $to_value = isset($_POST[$prefix.
'_export_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_tovalue'][
'm'],$_POST[$prefix.
'_export_tovalue'][
'd'],$_POST[$prefix.
'_export_tovalue'][
'y'])) : date(
'Y-m-d').
' --:--:--';
611 $from =
new Datetime_Field($prefix.
'_export_from', $from_value, $parameters);
612 $to =
new Datetime_Field($prefix.
'_export_to', $to_value, $parameters);
615 echo
' '.translate(
'to').
' ';
634 '' =>
'------- '.translate(
'please_select').
' -------',
635 'csv' => translate(
'cms_form_download_csv'),
636 'csv_nhr' => translate(
'cms_form_download_csv_nhr'),
637 'xml' => translate(
'cms_form_download_xml'),
640 echo combo_box($prefix.
'_export_format', $options, FALSE,
'');
641 echo hidden_field($prefix.
'_export_switch',
'0');
643 $delimiter_text = isset($_POST[$prefix.
'_delimiter']) ? $_POST[$prefix.
'_delimiter'] :
',';
644 echo
' Delimiter ';
645 echo text_box($prefix.
'_delimiter',$delimiter_text,1,1,TRUE);
671 echo normal_button($prefix.
'_export', translate(
'download_file'),
'this.form.'.$prefix.
'_export_switch.value = 1; this.form.submit(); SQ_FORM_SUBMITTED = false; this.form.'.$prefix.
'_export_switch.value = 0; return true;');
691 $export_button_pressed = array_get_index($_POST, $prefix.
'_export_switch');
692 if (is_null($export_button_pressed))
return TRUE;
694 $export_type = array_get_index($_POST, $prefix.
'_export_format',
'');
695 $export_delimiter = array_get_index($_POST, $prefix.
'_delimiter',
'');
697 switch ($export_type) {
734 $from_value = isset($_POST[$prefix.
'_export_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_fromvalue'][
'm'],$_POST[$prefix.
'_export_fromvalue'][
'd'],$_POST[$prefix.
'_export_fromvalue'][
'y'])) :
'---------- --:--:--';
735 $to_value = isset($_POST[$prefix.
'_export_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_tovalue'][
'm'],$_POST[$prefix.
'_export_tovalue'][
'd'],$_POST[$prefix.
'_export_tovalue'][
'y'])) :
'---------- --:--:--';
737 $from_value = explode(
'-',iso8601_date_component($from_value));
738 $to_value = explode(
'-',iso8601_date_component($to_value));
742 $from_ts = mktime(0,0,0,$from_value[1],$from_value[2],$from_value[0]);
743 $to_ts = mktime(23,59,59,$to_value[1],$to_value[2],$to_value[0]);
746 $csv->setFilename(
'submission_log.csv');
747 $csv->setDeliminator($delimiter);
750 if (!$header_row) $csv->setFieldHeaders($header_row);
771 $headers = Array(
'__time__' => translate(
'submission_time'),
'__user__' => translate(
'cms_form_user_submitting'),
'__ipaddress__' => translate(
'cms_form_ipaddress_submitting'));
772 $sub_folder = $form->getSubmissionsFolder();
773 $assetids = Array($form->id, $sub_folder->id);
774 $from_time = ts_iso8601($from_time);
775 $to_time = ts_iso8601($to_time);
779 'assetids' => $assetids,
780 'from_time' => $from_time,
781 'to_time' => $to_time,
782 'name' =>
'submitted',
783 'context' => $GLOBALS[
'SQ_SYSTEM']->getContextId(),
786 }
catch (Exception $e) {
787 throw new Exception(
"Unable to get submission log due to database error: ".$e->getMessage());
790 foreach ($result as $asset_info) {
791 $assetid = $asset_info[
'assetid'];
792 $type_code = $asset_info[
'type_code'];
794 $create_time = strtotime($asset_info[
'submitted']);
796 $sub_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type_code);
797 if (!$sub_asset->attr(
'complete'))
continue;
800 $ipaddress = $sub_asset->getIP();
803 $summary = $sub_asset->getSummary();
804 $logs[$assetid] = Array(
805 '__time__' => date(
'Y-m-d H:i:s', $create_time),
806 '__user__' => $asset_info[
'created_userid'],
807 '__ipaddress__' => $ipaddress,
809 if (empty($summary)) $summary = Array();
810 foreach ($summary as $id => $element) {
811 if (!isset($headers[$id])) {
812 $headers[$id] = $element[
'name'];
815 $logs[$assetid][$id] = html_entity_decode($element[
'answer'], ENT_NOQUOTES, SQ_CONF_DEFAULT_CHARACTER_SET) ;
817 $logs[$assetid][
'__assetid__'] = $assetid;
820 if (!isset($headers[
'__assetid__'])) {
821 $headers[
'__assetid__'] = translate(
'assetid');
825 require_once SQ_FUDGE_PATH.
'/csv/csv.inc';
827 $csv->setFieldHeaders($headers);
828 $csv->setValues($logs);
851 header(
'Content-Type: application/xml');
854 header(
'Content-Disposition: attachment; filename=submission_log.xml;');
857 $from_value = isset($_POST[$prefix.
'_export_fromvalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_fromvalue'][
'm'],$_POST[$prefix.
'_export_fromvalue'][
'd'],$_POST[$prefix.
'_export_fromvalue'][
'y'])) :
'---------- --:--:--';
858 $to_value = isset($_POST[$prefix.
'_export_tovalue']) ? ts_iso8601(mktime(0,0,0,$_POST[$prefix.
'_export_tovalue'][
'm'],$_POST[$prefix.
'_export_tovalue'][
'd'],$_POST[$prefix.
'_export_tovalue'][
'y'])) :
'---------- --:--:--';
860 $from_value = explode(
'-', iso8601_date_component($from_value));
861 $to_value = explode(
'-', iso8601_date_component($to_value));
865 $from_ts = mktime(0, 0, 0, $from_value[1], $from_value[2], $from_value[0]);
866 $to_ts = mktime(23, 59, 59, $to_value[1], $to_value[2], $to_value[0]);
867 $from_time = ts_iso8601($from_ts);
868 $to_time = ts_iso8601($to_ts);
869 $sub_folder = $asset->getSubmissionsFolder();
870 $assetids = Array($asset->id, $sub_folder->id);
874 'assetids' => $assetids,
875 'from_time' => $from_time,
876 'to_time' => $to_time,
877 'name' =>
'submitted',
878 'context' => $GLOBALS[
'SQ_SYSTEM']->getContextId(),
881 }
catch (Exception $e) {
882 throw new Exception(
"Unable to get submission log due to database error: ".$e->getMessage());
885 echo
"<submissions>\n";
886 foreach ($result as $asset_info) {
887 $assetid = $asset_info[
'assetid'];
888 $type_code = $asset_info[
'type_code'];
890 $sub_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type_code);
891 if (!$sub_asset->attr(
'complete'))
continue;
893 if (trim($sub_asset->attr(
'xml')) ==
'')
continue;
894 echo
"\t".$sub_asset->attr(
'xml').
"\n";
896 echo
'</submissions>';
917 $job_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'cron_job_send_submission_log', TRUE,
'minor');
919 if (!empty($job_links)) {
921 <table
class=
"sq-backend-table">
923 <td
class=
"sq-backend-table-header"><?php echo translate(
'name'); ?></td>
924 <td
class=
"sq-backend-table-header"><?php echo translate(
'when'); ?></td>
925 <td align=
"center" class=
"sq-backend-table-header" style=
"text-align: center;"><?php echo translate(
'delete'); ?> ?</td>
926 <td align=
"center" class=
"sq-backend-table-header" style=
"text-align: center;"></td>
929 for ($k = 0; $k < count($job_links); $k++) {
930 $job = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($job_links[$k][
'majorid'],
'cron_job_send_submission_log');
933 <td
class=
"sq-backend-table-cell">
934 <?php echo $job->displayName(); ?>
936 <td
class=
"sq-backend-table-cell">
937 <?php echo $job->readableWhen(); ?>
939 <td align=
"center" class=
"sq-backend-table-cell">
941 if ($write_access && $job->canDelete()) {
942 check_box($prefix.
'_remove_job[]', $job->id);
944 check_box($prefix.
'_remove_job[]', $job->id, FALSE,
'',
'disabled');
948 <td>[ <a href=
"<?php echo $job->getBackendHref(); ?>"><?php echo translate(
'edit') ?></a> ]</td>
957 echo
"<i>".translate(
'cron_job_send_submission_log_no_jobs').
"</i><br/><br/>";
962 label(translate(
'cron_job_send_submission_log_add_new_job'), $prefix.
'_new_job');
964 text_box($prefix.
'_new_job_name',
'', 25);
965 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'cron_job_send_submission_log');
967 $edit_fns = $cron_job->getEditFns();
969 $edit_fns->paintScheduleInterface($null_asset, $o, $prefix);
972 return $write_access;
992 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
993 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'cron_job_send_submission_log');
996 if (isset($_POST[$prefix.
'_remove_job'])) {
1000 if ($GLOBALS[
'SQ_SYSTEM']->am->acquireLock($cron_mgr->id,
'links')) {
1001 for ($i = 0; $i < count($jobs); $i++) {
1002 if (in_array($jobs[$i]->
id, $_POST[$prefix.
'_remove_job'])) {
1003 $cron_mgr->removeJob($jobs[$i]);
1006 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($cron_mgr->id,
'links');
1008 trigger_localised_error(
'SYS0232', E_USER_NOTICE);
1016 $new_job_name = isset($_POST[$prefix.
'_new_job_name']) ? trim($_POST[$prefix.
'_new_job_name']) :
'';
1017 if (!empty($new_job_name)) {
1019 $default_time =
'TI='.time().
',7,86400';
1021 $new_job->setAttrValue(
'display_name', $new_job_name);
1022 $new_job->setAttrValue(
'type',
'repeating');
1023 $new_job->setAttrValue(
'long', TRUE);
1024 $edit_fns = $new_job->getEditFns();
1025 if (!$edit_fns->processScheduleInterface($new_job, $o, $prefix)) {
1029 if ($new_job->setAssetToUpdate($asset)) {
1030 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1031 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1032 if ($cron_mgr->addJob($new_job, $GLOBALS[
'SQ_SYSTEM']->user)) {
1033 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1035 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1037 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1040 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($cron_mgr);
1044 return $write_access;
1062 if (isset($bind_vars[
'assetids']) && empty($bind_vars[
'assetids'])) {
1068 $sql =
"SELECT a.assetid, a.type_code, v.custom_val AS submitted, a.created_userid
1070 INNER JOIN sq_ast_typ_inhd t ON a.type_code=t.type_code
1071 INNER JOIN sq_ast_lnk l ON l.minorid=a.assetid
1072 INNER JOIN sq_ast_attr_val v ON v.assetid=a.assetid
1073 INNER JOIN sq_ast_attr n ON n.attrid=v.attrid";
1075 $assetids = array_get_index($bind_vars,
'assetids', Array());
1076 if (!empty($assetids)) {
1077 foreach ($assetids as $index => $assetid) {
1080 $where .=
" l.majorid IN (".implode(
',', $assetids).
") AND";
1082 $where .=
" t.inhd_type_code='form_submission'
1083 AND n.name=:name AND v.contextid=:context
1084 AND TO_CHAR(DBMS_LOB.SUBSTR(v.custom_val, 30, 1)) > :from_time
1085 AND TO_CHAR(DBMS_LOB.SUBSTR(v.custom_val, 30, 1)) < :to_time";
1095 }
catch (Exception $e) {
1097 throw new Exception(
"Unable to get submission log due to database error: ".$e->getMessage());
1115 $children = Array();
1117 $kids =& $tree_root->children;
1119 for (reset($kids); NULL !== ($k = key($kids)); next($kids)) {
1120 $this_child =& $kids[$k];
1121 $child_id = $this_child->getAttribute(
'id');
1122 $child_name = $this_child->getAttribute(
'name');
1123 switch ($this_child->name) {
1128 $child_value = $this_child->content;
1132 $child_value = date(
'd M Y H:i:s', iso8601_ts($this_child->content));
1133 $circa = $this_child->getAttribute(
'circa');
1134 if ($circa) $child_value =
'circa '.$child_value;
1138 $select_options =& $this_child->children;
1139 $child_value = Array();
1141 for (reset($select_options); NULL !== ($k = key($select_options)); next($select_options)) {
1142 $this_option =& $select_options[$k];
1143 $child_value[] = $this_option->content;
1145 $child_value = implode(
', ', $child_value);
1149 if ($this_child->name !=
'section') {
1150 $children[] = Array(
'id' => $child_id,
'name' => $child_name,
'content' => $child_value);
1174 $write_access = $asset->writeAccess(
'attributes');
1176 $assetid = $asset->attr(
'receipt_field');
1177 if ($write_access) {
1178 asset_finder($prefix.
'_rec_field', $assetid, Array(
'form_question_type_email_address' =>
'I'));
1180 if (!empty($assetid)) {
1181 echo get_asset_tag_line($assetid);
1183 echo
'<em>'.translate(
'none').
'</em>';
1187 return $write_access;
1204 if (!isset($_POST[$prefix.
'_rec_field']))
return FALSE;
1205 $assetid = $_POST[$prefix.
'_rec_field'][
'assetid'];
1210 if ($assetid == $asset->attr(
'receipt_field')) {
1213 if (!$asset->setAttrValue(
'receipt_field', $assetid)) {
1237 $write_access = $asset->writeAccess(
'attributes');
1239 $assetid = $asset->attr(
'staf_field');
1240 if ($write_access) {
1241 asset_finder($prefix.
'_staf_field', $assetid, Array(
'form_question_type_text' =>
'D'));
1243 if (!empty($assetid)) {
1244 echo get_asset_tag_line($assetid);
1246 echo
'<em>'.translate(
'none').
'</em>';
1250 return $write_access;
1267 if (!isset($_POST[$prefix.
'_staf_field'])) {
1270 $assetid = $_POST[$prefix.
'_staf_field'][
'assetid'];
1275 if ($assetid == $asset->attr(
'staf_field')) {
1278 if (!$asset->setAttrValue(
'staf_field', $assetid)) {
1302 if (!$asset->writeAccess(
'attributes'))
return FALSE;
1303 check_box($prefix.
'_new_se_rule',
'1', FALSE);
1323 if (!isset($_REQUEST[$prefix.
'_new_se_rule'])) {
1326 $all_se = $asset->attr(
'selective_emails');
1329 if (empty($all_se)) {
1332 $new_id = max(array_keys($all_se)) + 1;
1336 $all_se[$new_id] = Array(
1340 'send' =>
'recipient',
1345 $_REQUEST[$prefix.
'_se_active_ruleid'] = $new_id;
1347 $_POST[$prefix.
'_require'] =
'all';
1348 $_POST[$prefix.
'_send'] =
'recipient';
1349 $_POST[$prefix.
'_address'] =
'';
1351 if (!$asset->setAttrValue(
'selective_emails', $all_se)) {
1355 return $asset->saveAttributes();
1372 $admin_access = $asset->adminAccess(
'attributes');
1374 $am = $GLOBALS[
'SQ_SYSTEM']->am;
1376 $ruleid = isset($_REQUEST[$prefix.
'_se_active_ruleid']) ? $_REQUEST[$prefix.
'_se_active_ruleid'] : -1;
1378 if (isset($_REQUEST[$prefix.
'_se_active_ruleid'])) {
1379 $o->addHiddenField($prefix.
'_se_active_ruleid', $_REQUEST[$prefix.
'_se_active_ruleid']);
1382 $all_se = $asset->attr(
'selective_emails');
1384 if (empty($all_se)) {
1385 echo translate(
'cms_form_no_selective_email_rules');
1390 <table
class=
"sq-backend-table">
1393 if ($admin_access) {
1394 ?><td align=
"center" width=
"30" class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'edit') ?></td><?php
1396 ?><td
class=
"sq-backend-table-header">
1397 <?php echo translate(
'rule') ?>
1399 <td align=
"center" width=
"50" class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'valid_question') ?></td>
1401 if ($admin_access) {
1402 ?><td align=
"center" width=
"70" class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'delete_question') ?></td>
1408 for (reset($all_se); NULL !== ($k = key($all_se)); next($all_se)) {
1409 $info =& $all_se[$k];
1410 $rule_prefix = $prefix.
'_r'.$k;
1413 <tr<?php
if ($ruleid == $k) echo
' class="alt"'; ?>>
1415 if ($admin_access) {
1417 <td valign=
"top" align=
"center" width=
"30" class=
"sq-backend-table-cell"><a href=
"<?php echo $o->getCurrentLocation(); ?>&<?php echo $prefix?>_se_active_ruleid=<?php echo $k ?>"><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/icons/edit_mode.png" width=
"15" height=
"15" border=
"0" /></a></td>
1421 <td valign=
"top" class=
"sq-backend-table-cell">
1423 if (empty($info[
'rules'])) {
1425 <span><?php echo translate(
'cms_form_rule_no_parts') ?></span><br/>
1429 $rules =& $info[
'rules'];
1431 $rule_logic = ($info[
'require'] ==
'all') ? strtoupper(translate(
'and')) : strtoupper(translate(
'or'));
1432 $descriptions = Array();
1436 for (reset($rules); NULL !== ($rule_key = key($rules)); next($rules)) {
1437 $rule =& $rules[$rule_key];
1438 $type_code =
'form_question_rule_type_'.$rule[
'name'];
1439 $q_asset = $am->getAsset($rule[
'assetid']);
1448 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
1449 $rule_asset =
new $type_code();
1450 $descriptions[] = $rule_asset->ruleDescription($q_asset, $rule);
1456 echo translate(
'cms_form_se_rule_deleted_questions');
1458 echo implode(
'<br/><b>'.$rule_logic.
'</b>', $descriptions);
1465 if ($info[
'send'] ==
'staf') {
1466 echo translate(
'cms_form_staf');
1467 }
else if ($info[
'send'] ==
'recipient') {
1468 echo translate(
'cms_form_recipient');
1469 }
else if ($info[
'send'] ==
'receipt') {
1470 echo translate(
'cms_form_receipt');
1472 echo translate(
'cms_form_unknown_email_type');
1476 echo
'</b> email to <b>';
1477 if (empty($info[
'address'])) {
1479 echo translate(
'cms_form_no_email_address');
1481 echo $info[
'address'];
1486 <td valign=
"top" align=
"center" width=
"70" class=
"sq-backend-table-cell"><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $valid ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" /></td>
1488 if ($admin_access) {
1489 ?><td valign=
"top" align=
"center" width=
"50" class=
"sq-backend-table-cell"><?php check_box($prefix.
'_deletes[]', $k); ?></td><?php
1516 if (!isset($_POST[$prefix.
'_deletes']))
return TRUE;
1518 $all_se = $asset->attr(
'selective_emails');
1519 $delete_ruleids = $_POST[$prefix.
'_deletes'];
1522 foreach ($delete_ruleids as $ruleid) {
1523 unset($all_se[$ruleid]);
1524 if (isset($_REQUEST[$prefix.
'_se_active_ruleid'])) {
1525 if ($ruleid == $_REQUEST[$prefix.
'_se_active_ruleid']) {
1526 unset($_REQUEST[$prefix.
'_se_active_ruleid']);
1531 $asset->setAttrValue(
'selective_emails', $all_se);
1533 return $asset->saveAttributes();
1550 if (!$asset->writeAccess(
'attributes'))
return FALSE;
1552 if (isset($_REQUEST[$prefix.
'_se_active_ruleid'])) {
1553 $current_assetid = isset($_POST[$prefix.
'_se_new_qid'][
'assetid']) ? $_POST[$prefix.
'_se_new_qid'][
'assetid'] : 0;
1554 asset_finder($prefix.
'_se_new_qid', $current_assetid, Array(
'form_question' =>
'D'));
1592 if (!$asset->adminAccess(
'attributes'))
return FALSE;
1593 if (!isset($_REQUEST[$prefix.
'_se_active_ruleid'])) {
1598 if (isset($_POST[$prefix.
'_se_new_qid']) && $_POST[$prefix.
'_se_new_qid'][
'assetid'] == 0) {
1599 unset($_POST[$prefix.
'_se_new_qid'][
'assetid']);
1602 if (!isset($_POST[$prefix.
'_se_new_qid'][
'assetid'])) {
1603 echo translate(
'cms_form_select_question_before_part');
1606 $active_question = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($_POST[$prefix.
'_se_new_qid'][
'assetid']);
1608 $rule_codes = $active_question->getAllowedRules();
1609 $type_codes = Array();
1610 foreach ($rule_codes as $rule_code) {
1611 $type_code =
'form_question_rule_type_'.$rule_code;
1612 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
1613 $se_rule = eval(
'return '.$type_code.
'::isSelectiveEmailRule();');
1614 if ($se_rule) $type_codes[] = $type_code;
1617 $desc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_codes,
'description');
1618 combo_box($prefix.
'_new_rule', array_merge(Array(
' ' =>
'------ '.translate(
'please_select').
' ------'), $desc), FALSE,
'');
1638 if (!$asset->adminAccess(
'attributes'))
return FALSE;
1641 if (!isset($_REQUEST[$prefix.
'_se_active_ruleid']) ||
1642 !isset($_REQUEST[$prefix.
'_new_rule']) || empty($_POST[$prefix.
'_se_new_qid'][
'assetid'])) {
1646 $ruleid = $_REQUEST[$prefix.
'_se_active_ruleid'];
1647 $qid = $_POST[$prefix.
'_se_new_qid'][
'assetid'];
1648 $active_question = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($qid);
1650 $type_code = $_POST[$prefix.
'_new_rule'];
1651 $rule_code = substr($type_code,24);
1652 if (!trim($rule_code))
return FALSE;
1654 $all_se = $asset->attr(
'selective_emails');
1656 $rules =& $all_se[$ruleid][
'rules'];
1658 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
1659 $operators = array_keys(eval(
'return '.$type_code.
'::getOperators();'));
1663 'name' => $rule_code,
1664 'operator' => $operators[0],
1666 'comparison_question_id' => 0,
1670 $asset->setAttrValue(
'selective_emails', $all_se);
1671 return $asset->saveAttributes();
1689 if (!$asset->writeAccess(
'attributes')) {
1690 $o->openField(
'Note');
1691 echo translate(
'cms_form_unlock_to_select_se_rule');
1696 if (!isset($_REQUEST[$prefix.
'_se_active_ruleid'])) {
1697 $o->openField(
'Note');
1698 echo translate(
'cms_form_select_to_edit_se_rule');
1703 $ruleid = $_REQUEST[$prefix.
'_se_active_ruleid'];
1705 $write_access = $asset->writeAccess(
'attributes');
1707 $am = $GLOBALS[
'SQ_SYSTEM']->am;
1708 $all_se = $asset->attr(
'selective_emails');
1709 $rules = $all_se[$ruleid][
'rules'];
1712 if (empty($rules)) {
1713 $o->openField(
'Note');
1714 echo translate(
'cms_form_se_rule_empty');
1719 for (reset($rules); NULL !== ($k = key($rules)); next($rules)) {
1720 $rule =& $rules[$k];
1722 $type_code =
'form_question_rule_type_'.$rule[
'name'];
1723 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
1724 $rule_asset =
new $type_code();
1725 $edit_fns = $rule_asset->getEditFns();
1727 if (!isset($descs[$type_code])) {
1728 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(Array($type_code),
'description');
1729 $descs[$type_code] = $asset_info[$type_code];
1732 $o->openSection($descs[$type_code]);
1734 $o->openField(translate(
'applies_to'));
1735 $q_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($rule[
'assetid']);
1737 echo get_asset_tag_line($q_asset->id);
1739 echo
'<i class="sq-backend-warning">'.translate(
'cms_form_deleted_question_cannot_edit', $rule[
'assetid']).
'</i>';
1744 $edit_fns->paintRule($rule_asset, $o, $prefix.
'_rule_'.$k, $rule, $write_access, $q_asset);
1747 if ($write_access) {
1748 $o->openField(
'Delete ?');
1749 check_box($prefix.
'_rule_'.$k.
'[delete]');
1757 return $write_access;
1774 $all_se = $asset->attr(
'selective_emails');
1775 if (!isset($_REQUEST[$prefix.
'_se_active_ruleid'])) {
1779 $ruleid = $_REQUEST[$prefix.
'_se_active_ruleid'];
1780 if (!isset($all_se[$ruleid]))
return FALSE;
1782 $rules =& $all_se[$ruleid][
'rules'];
1784 $prefix = $asset->getPrefix();
1787 if (empty($rules)) $rules = Array();
1788 foreach (array_keys($rules) as $k) {
1789 $rule_prefix = $prefix.
'_rule_'.$k;
1790 if (!isset($_POST[$rule_prefix]))
continue;
1792 if (array_get_index($_POST[$rule_prefix],
'delete', 0)) {
1798 for (reset($rules); NULL !== ($k = key($rules)); next($rules)) {
1799 $rule =& $rules[$k];
1801 $type_code =
'form_question_rule_type_'.$rule[
'name'];
1802 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
1803 $rule_asset =
new $type_code();
1804 $edit_fns = $rule_asset->getEditFns();
1806 $edit_fns->processRule($rule_asset, $o, $prefix.
'_rule_'.$k, $rule);
1809 $asset->setAttrValue(
'selective_emails', $all_se);
1810 return $asset->saveAttributes();
1829 if (!$asset->adminAccess(
'attributes'))
return FALSE;
1830 if (!isset($_REQUEST[$prefix.
'_se_active_ruleid'])) {
1834 $ruleid = $_REQUEST[$prefix.
'_se_active_ruleid'];
1835 $all_se = $asset->attr(
'selective_emails');
1839 combo_box($prefix.
'_require', Array(
'all' =>
'ALL',
'any' =>
'ANY'), FALSE, Array($all_se[$ruleid][
'require']));
1840 $require_box = ob_get_contents();
1844 combo_box($prefix.
'_send', Array(
'recipient' =>
'Recipient E-mail',
'receipt' =>
'Receipt',
'staf' =>
'Send To A Friend E-mail'), FALSE, Array($all_se[$ruleid][
'send']));
1845 $email_type_box = ob_get_contents();
1850 text_area($prefix.
'_address', $all_se[$ruleid][
'address'], 30, 5);
1851 $address_box = ob_get_contents();
1854 echo translate(
'cms_form_match_email_line', $require_box, $email_type_box, $address_box);
1874 if (!$asset->adminAccess(
'attributes'))
return FALSE;
1875 if (!isset($_REQUEST[$prefix.
'_se_active_ruleid']) || !isset($_POST[$prefix.
'_address'])) {
1879 $ruleid = $_REQUEST[$prefix.
'_se_active_ruleid'];
1880 $all_se = $asset->attr(
'selective_emails');
1882 $all_se[$ruleid][
'require'] = $_POST[$prefix.
'_require'];
1883 $all_se[$ruleid][
'send'] = $_POST[$prefix.
'_send'];
1884 $all_se[$ruleid][
'address'] = $_POST[$prefix.
'_address'];
1886 $asset->setAttrValue(
'selective_emails', $all_se);
1887 return $asset->saveAttributes();
1905 <p>In addition to the simple formatting options shown underneath each email, you can use the same keyword replacements as is available
for the Thank You bodycopy. Click here
for a <a href=
"#" onClick=
"javascript: var win = window.open('<?php echo sq_web_path('data')?>/asset_types/form/popups/thank_you_keywords.php?assetid=<?php echo $asset->id ?>', 'keywords', 'toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,width=580,height=520')">list of keywords available
for use in emails</a>.<br/></p>
1942 return $asset->writeAccess(
'attributes');
1961 $write_access = $asset->
writeAccess(
'attributes');
1962 $actions = $asset->
attr(
'actions');
1965 if ($write_access) {
1966 $selected_action = array_get_index($_REQUEST, $prefix.
'_new_selected_action', NULL);
1967 if (!is_numeric($selected_action)) {
1968 $selected_action = array_get_index($_POST, $prefix.
'_selected_action', NULL);
1971 $selected_action = NULL;
1976 hidden_field($prefix.
'_new_selected_action',
'');
1978 if (!empty($actions)) {
1979 ?><table
class=
"sq-backend-table">
1981 <col width=
"60" align=
"center" />
1984 <col width=
"60" align=
"center" />
1985 <col width=
"60" align=
"center" />
1988 <th><p>Edit</p></th>
1989 <th><p>Action Name / Type</p></th>
1990 <th><p>Summary</p></th>
1991 <th><p>Valid ?</p></th>
1992 <th><p>Active ?</p></th>
1993 <th><p>Delete ?</p></th>
1994 </thead><tbody><?php
1996 foreach ($actions as $key => $action) {
1997 $is_selected_action = (!is_null($selected_action) && ((string)$selected_action === (
string)$key));
1999 if ($is_selected_action) {
2000 echo
' class="alt"';
2003 $action_type = $action[
'type_code'];
2004 $settings = $action[
'settings'];
2005 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($action_type,
'name');
2007 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($action_type);
2009 if ($write_access && !$is_selected_action) {
2010 ?><td
class=
"sq-backend-table-cell"><p><a href=
"#" onclick=
"document.getElementById('<?php echo $prefix ?>_new_selected_action').value = <?php echo $key ?>; document.main_form.submit(); return false;"><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/icons/edit_mode.png" width=
"15" height=
"15" border=
"0" /></a></p></td><?php
2012 ?><td
class=
"sq-backend-table-cell"> </td><?php
2014 ?><td
class=
"sq-backend-table-cell"><p><strong><?php echo $action[
'name'] ?></strong><br/>(<?php echo $type_name ?>)</p></td><?php
2015 ?><td
class=
"sq-backend-table-cell"><?php echo call_user_func(Array($action_type,
'paintSummary'), $asset, $settings, $o, $prefix) ?></td><?php
2016 ?><td
class=
"sq-backend-table-cell"><p><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo call_user_func(Array($action_type, 'isValid'), $asset, $settings) ? 'tick' : 'cross' ?>.gif" width=
"15" height=
"15" border=
"0" /></p></td><?php
2017 if ($write_access) {
2018 ?><td
class=
"sq-backend-table-cell"><p><?php check_box($prefix.
'_rules[active]['.$key.
']',
'1', $action[
'active']) ?></p></td><?php
2019 ?><td
class=
"sq-backend-table-cell"><p><?php check_box($prefix.
'_rules[delete]['.$key.
']',
'1', FALSE) ?></p></td><?php
2021 ?><td
class=
"sq-backend-table-cell"><p><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $action['active'] ? 'tick' : 'cross' ?>.gif" width=
"15" height=
"15" border=
"0" /></p></td><?php
2022 ?><td
class=
"sq-backend-table-cell"> </td><?php
2026 ?></tbody></table><?php
2028 ?><p>There are no actions currently defined
for this form.</p><?php
2032 $o->
sectionNote(
'Only actions that are <strong>valid</strong> and <strong>active</strong> will be executed when a form is submitted. An action can be activated or deactivated with the <strong>Active ?</strong> check box.');
2034 return $write_access;
2050 $write_access = $asset->
writeAccess(
'attributes');
2055 $edit_action = array_get_index($_REQUEST, $prefix.
'_new_selected_action', NULL);
2056 if (!empty($edit_action)) {
2057 return $write_access;
2060 if ($write_access) {
2061 $actions = $asset->
attr(
'actions');
2063 $rule_changes = array_get_index($_POST, $prefix.
'_rules', Array());
2065 if(!empty($actions)) {
2066 foreach ($actions as $key => $action) {
2067 if (!isset($rule_changes[
'active'][$key])) {
2068 $rule_changes[
'active'][$key] = Array();
2072 if (!isset($rule_changes[
'active'])) {
2073 $rule_changes[
'active'] = Array();
2077 if (!isset($rule_changes[
'delete'])) {
2078 $rule_changes[
'delete'] = Array();
2081 foreach ($rule_changes[
'active'] as $key => $value) {
2082 $actions[$key][
'active'] = (boolean)$value;
2084 foreach ($rule_changes[
'delete'] as $key => $value) {
2085 unset($actions[$key]);
2092 return $write_access;
2108 $write_access = $asset->
writeAccess(
'attributes');
2110 $types = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants(
'form_action');
2111 $names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($types,
'name');
2114 if ($write_access) {
2116 check_box($prefix.
'_new',
'1', FALSE,
'this.form.'.$prefix.
'_new_type.disabled = !this.checked; return true;');
2117 ?><label
for=
"<?php echo $prefix ?>_new">Create a
new action of type:</label> <?php
2118 $names = Array(
'' =>
'Select action type...') + $names;
2119 combo_box($prefix.
'_new_type', $names, FALSE,
'', 0,
'disabled="disabled"');
2122 ?><p>This screen must be locked before you can create a
new action.</p><?php
2128 $o->
sectionNote(
'If you create a new action, the new action will be displayed immediately for you to edit. If you already have an action open to edit, the changes to that action will be saved when you commit before the new action is created.');
2130 return $write_access;
2146 $write_access = $asset->
writeAccess(
'attributes');
2148 if ($write_access) {
2150 $new_action = (int)array_get_index($_POST, $prefix.
'_new',
'0');
2156 $action_type = array_get_index($_POST, $prefix.
'_new_type',
'');
2157 if (!empty($action_type)) {
2158 if ($GLOBALS[
'SQ_SYSTEM']->am->installed($action_type)) {
2160 $type_parents = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAncestors($action_type);
2161 if (in_array(
'form_action', $type_parents)) {
2163 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($action_type,
'name');
2164 $actions = $asset->
attr(
'actions');
2166 if (!empty($actions)) {
2167 $new_key = max(array_keys($actions)) + 1;
2172 $actions[$new_key] = Array(
2174 'type_code' => $action_type,
2181 $_POST[$prefix.
'_new_selected_action'] = $new_key;
2185 trigger_error(
'Cannot create new action; asset type "'.$action_type.
'" is not a form action', E_USER_WARNING);
2189 trigger_error(
'Cannot create new action; "'.$action_type.
'" is not a valid asset type', E_USER_WARNING);
2197 return $write_access;
2213 $write_access = $asset->
writeAccess(
'attributes');
2214 $selected_action = array_get_index($_REQUEST, $prefix.
'_new_selected_action', NULL);
2215 if (!is_numeric($selected_action)) {
2216 $selected_action = array_get_index($_POST, $prefix.
'_selected_action', NULL);
2219 if ($write_access) {
2220 if (!is_null($selected_action)) {
2221 $actions = $asset->
attr(
'actions');
2225 if (!isset($actions[$selected_action])) {
2227 ?><p>No action is currently selected
for editing. To edit an action, please select from the
"Existing Actions" list above.</p><?php
2232 $action = $actions[$selected_action];
2234 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($action[
'type_code'],
'name');
2238 text_box($prefix.
'_selected_name', $action[
'name'], 30);
2239 $o->
note(
'An optional name to identify this particular action. If cleared, the action\'s type ("'.$type_name.
'" in this case) will be used, numerically indexed if necessary.');
2244 hidden_field($prefix.
'_selected_action', $selected_action);
2245 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($action[
'type_code']);
2246 call_user_func(Array($action[
'type_code'],
'paintInlineInterface'), $asset, $action[
'settings'], $o, $prefix);
2252 ?><p>No action is currently selected
for editing. To edit an action, please select from the
"Existing Actions" list above.</p><?php
2258 ?><p>This screen must be locked before you can edit an action.</p><?php
2262 return $write_access;
2278 $write_access = $asset->
writeAccess(
'attributes');
2279 $actions = $asset->
attr(
'actions');
2284 $edit_action = array_get_index($_REQUEST, $prefix.
'_new_selected_action', NULL);
2285 if (is_numeric($edit_action)) {
2291 $selected_action = array_get_index($_POST, $prefix.
'_selected_action', NULL);
2292 if (!isset($actions[$selected_action])) {
2296 if ($write_access) {
2297 if (!is_null($selected_action)) {
2298 $new_name = array_get_index($_POST, $prefix.
'_selected_name', NULL);
2299 $action = $actions[$selected_action];
2301 $new_name = array_get_index($_POST, $prefix.
'_selected_name', NULL);
2302 if ($new_name != $action[
'name']) {
2303 if (empty($new_name)) {
2304 $new_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($action[
'type_code'],
'name');
2309 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($action[
'type_code']);
2310 $settings = $action[
'settings'];
2314 $result = call_user_func_array(Array($action[
'type_code'],
'processInlineInterface'), Array($asset, &$settings, $o, $prefix));
2316 $actions[$selected_action][
'settings'] = $settings;
2325 return ($result && $write_access);
2344 $actions = $asset->
attr(
'actions');
2352 foreach ($actions as $action) {
2353 if ($action[
'name'] == $name) {
2358 $name = $base_name.
' '.$i;