18 require_once SQ_PACKAGES_PATH.
'/cms/form/form_action/form_action.inc';
19 require_once SQ_PACKAGES_PATH.
'/trim/lib/trim_common.inc';
44 parent::__construct();
56 self::_fillDefaults($settings);
57 $record_type = array_get_index($settings,
'record_type',
'document');
58 $additional_fields = array_get_index($settings,
'additional_fields',
'');
61 <p
class=
"sq-backend-section-subheading">Connection Details</p>
63 <div
id=
"<?php echo $prefix ?>_connector_div" style=
"padding: 0.5em 0px 2em 30px;">
64 <table
class=
"sq-backend-table" style=
"width:auto">
66 <td width=
"100"><p>WSDL</p></td>
67 <td><p><?php text_box($prefix.
'_wsdl', array_get_index($settings,
'wsdl',
''), 120); ?></p></td>
70 <td><?php echo translate(
'username'); ?></td>
71 <td><p><?php text_box($prefix.
'_username', array_get_index($settings,
'username',
''), 35); ?><br />
75 <td><?php echo translate(
'password'); ?></td>
76 <td><p><?php password_box($prefix.
'_password', array_get_index($settings,
'password',
''), 35); ?></p></td>
79 <td colspan=
"2"><?php echo translate(
'use_proxy_connector'); ?></td>
84 <div
id=
"<?php echo $prefix ?>_connector_div" style=
"padding: 0.5em 0px 2em 30px;">
85 <table
class=
"sq-backend-table" style=
"width:auto">
87 <td><p>TRIM Connector
Asset</p></td>
88 <td><p><?php asset_finder($prefix.
'_connector', $settings[
'connector_assetid'], Array(
'trim_connector'=>
'D')); ?><br/>
89 Note: If a TRIM connector is selected, the settings in the
'Connection Setup' section (above) have no effect. <br />TRIM Connector allows the TRIM settings to be reused on other TRIM assets..</p></td>
94 <p
class=
"sq-backend-section-subheading">Create Record Settings</p>
96 <div
id=
"<?php echo $prefix ?>_record_type_selection" style=
"padding: 0.5em 0px 2em 30px;">
97 <table style=
"width:auto;padding-left: 30px;">
99 <td><strong><?php echo translate(
'record_type');?></strong><br /><br /></td>
103 'document' =>
'Document',
105 combo_box($prefix.
'_record_type', $options, FALSE, $record_type);
111 <td><span style=
"padding-top:10px;"><strong><?php echo translate(
'creator_username');?></strong></span></td>
114 text_box($prefix.
'_creator_username', array_get_index($settings,
'creator_username',
''), 35,
'', FALSE, ((
boolean) array_get_index($settings,
'session_creator_username', FALSE)) ?
' disabled=true' :
'');
116 <br />Use current logged in Matrix
User
118 check_box($prefix.
'_session_creator_username',
'1', (
boolean) array_get_index($settings,
'session_creator_username', FALSE),
'
120 document.getElementById(\''.$prefix.
'_creator_username\').disabled = true;
122 document.getElementById(\''.$prefix.
'_creator_username\').disabled = false;
124 ',
' style="padding-top:2px;"');
134 <div
id=
"<?php echo $prefix ?>_mandatory_fields" style=
"padding: 0.5em 0px 2em 30px;">
136 <p
class=
"sq-backend-section-subheading">Mandatory Fields Mapping</p>
138 <div
id=
"<?php echo $prefix ?>_mandatory_fields" style=
"padding: 0.5em 0px 2em 30px;">
139 <table style=
"width:auto;padding-left: 30px;">
141 $required_fields = self::getRecordTypeFields($record_type);
142 foreach ($required_fields as $field_name) {
145 <td
class=
"sq-backend-table-cell" style=
"width:180px;padding-left:15px;"><strong><?php echo ucwords(str_replace(
'_',
' ', $field_name)); ?></strong></td>
146 <td
class=
"sq-backend-table-cell">
149 if ($field_name ==
'security_level') {
150 combo_box($prefix.
'_'.$record_type.
'_security_level', $security_levels, FALSE, isset($settings[$record_type.
'_security_level']) ? $settings[$record_type.
'_security_level'] :
'Unrestricted');
152 text_box($prefix.
'_'.$record_type.
'_'.$field_name, array_get_index($settings, $record_type.
'_'.$field_name,
''), 53);
162 <p
class=
"sq-backend-section-subheading">Additional Fields Mapping</p>
166 if (!empty($additional_fields)) {
167 require_once SQ_PACKAGES_PATH.
'/trim/lib/trim_common.inc';
170 <div
id=
"<?php echo $prefix ?>_mandatory_fields" style=
"padding: 0.5em 0px 2em 30px;">
171 <table style=
"width:auto;padding-left: 30px;">
173 <td><?php echo translate(
'field_name') ?></td>
174 <td><?php echo translate(
'field_value') ?></td>
175 <td><?php echo translate(
'delete_question'); ?></td>
178 foreach ($additional_fields as $field_name => $field_value) {
181 <td
class=
"sq-backend-table-cell" style=
"width:180px;padding-left:15px;"><strong><?php echo $record_properties[$field_name]; ?></strong></td>
182 <td
class=
"sq-backend-table-cell" style=
"width:165px;padding-left:5px;">
184 text_area($prefix.
'_addtional_field_value_edit['.$field_name.
']', $field_value, 50, 3);
187 <td
class=
"sq-backend-table-cell">
189 check_box($prefix.
'_addtional_field_remove[]', $field_name, FALSE);
200 require_once SQ_PACKAGES_PATH.
'/trim/lib/trim_common.inc';
201 $record_properties[
''] =
'None';
203 ksort($record_properties);
206 <div
id=
"<?php echo $prefix ?>_mandatory_fields" style=
"padding: 0.5em 0px 2em 30px;">
207 <table style=
"width:auto;padding-left: 30px;">
209 <td>New Field Name</td>
210 <td>New Field Value</td>
213 <td
class=
"sq-backend-table-cell"><strong><?php
214 combo_box($prefix.
'_addtional_field_name', $record_properties, FALSE,
'None');
216 <td
class=
"sq-backend-table-cell">
218 text_area($prefix.
'_addtional_field_value',
'', 50, 3);
240 $settings[
'connector_assetid'] = $_POST[$prefix.
'_connector'][
'assetid'];
241 $settings[
'record_type'] = $_POST[$prefix.
'_record_type'];
242 $required_fields = self::getRecordTypeFields($settings[
'record_type']);
244 $new_wsdl = array_get_index($_POST, $prefix.
'_wsdl',
'');
245 $new_username = array_get_index($_POST, $prefix.
'_username',
'');
246 $new_password = array_get_index($_POST, $prefix.
'_password',
'');
247 $creator_username = array_get_index($_POST, $prefix.
'_creator_username', NULL);
248 $session_creator_username = array_get_index($_POST, $prefix.
'_session_creator_username', FALSE);
250 if (!is_null($new_wsdl)) {
251 $settings[
'wsdl'] = $new_wsdl;
253 if (!is_null($new_username)) {
254 $settings[
'username'] = $new_username;
256 if (!is_null($new_password)) {
257 $settings[
'password'] = $new_password;
259 if (!is_null($creator_username)) {
260 $settings[
'creator_username'] = $creator_username;
262 if (!is_null($session_creator_username)) {
263 $settings[
'session_creator_username'] = $session_creator_username;
266 foreach ($required_fields as $field_name) {
267 if (isset($_POST[$prefix.
'_'.$settings[
'record_type'].
'_'.$field_name])) {
268 $settings[$settings[
'record_type'].
'_'.$field_name] = $_POST[$prefix.
'_'.$settings[
'record_type'].
'_'.$field_name];
272 if (isset($_POST[$prefix.
'_addtional_field_remove'])) {
273 $remove_field_names = $_POST[$prefix.
'_addtional_field_remove'];
274 foreach ($remove_field_names as $remove_field_name) {
275 if (isset($settings[
'additional_fields'][$remove_field_name])) {
276 unset($settings[
'additional_fields'][$remove_field_name]);
280 if (isset($_POST[$prefix.
'_addtional_field_name']) && !empty($_POST[$prefix.
'_addtional_field_name'])) {
281 $settings[
'additional_fields'][$_POST[$prefix.
'_addtional_field_name']] = $_POST[$prefix.
'_addtional_field_value'];
284 if (isset($_POST[$prefix.
'_addtional_field_value_edit']) && !empty($_POST[$prefix.
'_addtional_field_value_edit'])) {
285 $editing_list = $_POST[$prefix.
'_addtional_field_value_edit'];
286 foreach ($editing_list as $field_name => $field_value) {
287 if (isset($settings[
'additional_fields'][$field_name]) && $settings[
'additional_fields'][$field_name] != $field_value) {
288 $settings[
'additional_fields'][$field_name] = $field_value;
307 self::_fillDefaults($settings);
309 ?><table
class=
"no-borders">
316 <td
class=
"sq-backend-table-cell" style=
"vertical-align: top"><p><strong>Data Source:</strong></p></td>
317 <td
class=
"sq-backend-table-cell" style=
"vertical-align: top"><p><?php
318 if (!empty($settings[
'connector_assetid'])) {
319 echo get_asset_tag_line($settings[
'connector_assetid']);
321 ?><span
class=
"sq-backend-warning">No connection details specified.</span><?php
326 <td
class=
"sq-backend-table-cell" style=
"vertical-align: top"><p><strong>Create Record Type</strong></p></td>
327 <td
class=
"sq-backend-table-cell" style=
"vertical-align: top"><p><?php
328 if (!empty($settings[
'record_type'])) {
329 echo ellipsisize(preg_replace(
'/\\n/',
' ', htmlspecialchars(ucwords($settings[
'record_type']))), 512);
331 ?><span
class=
"sq-backend-warning">No record
type selected.</span><?php
353 $required_fields = self::getRecordTypeFields($settings[
'record_type']);
354 $additional_fields = array_get_index($settings,
'additional_fields', Array());
356 $new_record_info[
'record_type'] = array_get_index($settings,
'record_type',
'');
358 foreach ($required_fields as $field_name) {
359 if (isset($settings[$settings[
'record_type'].
'_'.$field_name])) {
360 $new_record_info[$field_name] = $settings[$settings[
'record_type'].
'_'.$field_name];
364 $field_content = $settings[$settings[
'record_type'].
'_'.$field_name];
365 self::getKeywordReplacementsForForm($field_name, $field_content, $new_record_info, $form);
369 foreach ($additional_fields as $field_name => $field_content) {
370 self::getKeywordReplacementsForForm($field_name, $field_content, $additional_fields, $form);
374 if ($settings[
'session_creator_username']) {
375 if (!empty($GLOBALS[
'SQ_SYSTEM']->user)) {
376 $username = $GLOBALS[
'SQ_SYSTEM']->user->attr(
'username');
378 }
else if (!empty($settings[
'creator_username'])) {
379 $username = $settings[
'creator_username'];
382 $new_record_info[
'additional_fields'] = $additional_fields;
384 $connection = Array();
385 if (!empty($settings[
'connector_assetid'])) {
386 $trim_connector = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($settings[
'connector_assetid']);
387 $connection[
'wsdl'] = $trim_connector->attr(
'wsdl');
388 $connection[
'authentication'] = Array (
389 'login' => $trim_connector->attr(
'username'),
390 'password' => $trim_connector->attr(
'password'),
395 $proxy = $trim_connector->getProxy();
396 $connection[
'authentication'] = array_merge($connection[
'authentication'], $proxy);
398 $connection[
'wsdl'] = $settings[
'wsdl'];
399 $connection[
'authentication'] = Array (
400 'login' => $settings[
'username'],
401 'password' => $settings[
'password'],
423 $found = preg_match_all(
'/%(response_(\\d+_)?q\\d+(_raw)?)%/U', $field_content, $set_matches, PREG_SET_ORDER);
424 $matches = array_merge($matches, $set_matches);
425 $found = preg_match_all(
'/%(question_name_(\\d+_)?q\\d+(_raw)?)%/U', $field_content, $set_matches, PREG_SET_ORDER);
426 $matches = array_merge($matches, $set_matches);
427 $found = preg_match_all(
'/%(form_submission_.*)%/U', $field_content, $set_matches, PREG_SET_ORDER);
428 $matches = array_merge($matches, $set_matches);
430 foreach ($matches as $match) {
431 if (empty($match))
continue;
434 $field_content = preg_replace(
'/%'.$match[1].
'%/U', $form->_getThankYouKeywordReplacement($match[1]), $field_content, 1, $count);
435 $replacement[$field_name] = $field_content;
436 }
while ($count > 0);
449 self::_fillDefaults($settings);
452 if (empty($settings[
'connector_assetid'])) {
457 if (empty($settings[
'record_type'])) {
462 if (!empty($settings[
'record_type'])) {
463 $required_fields = self::getRecordTypeFields($settings[
'record_type']);
465 foreach ($required_fields as $field_name) {
466 if (empty($settings[$settings[
'record_type'].
'_'.$field_name])) {
472 if (empty($settings[
'connector_assetid']) && empty($settings[
'wsdl']) && empty($settings[
'username'])) {
476 if (!$settings[
'session_creator_username'] && empty($settings[
'creator_username'])) {
492 private static function _fillDefaults(&$settings) {
493 if (!isset($settings[
'record_type'])) {
494 $settings[
'record_type'] =
'document';
497 if (!isset($settings[
'connector_assetid'])) {
498 $settings[
'connector_assetid'] = 0;
504 private static function getRecordTypeFields($name)
506 $func_name =
'get'.$name.
'TypeFields';
507 $fields = self::$func_name();
513 private static function getBoxTypeFields()
515 $field_list = Array (
522 private static function getDocumentTypeFields()
524 $field_list = Array (
525 'record_title',
'parent_record_number',
'security_level',
532 private static function getFileTypeFields()
534 $field_list = Array (