18 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
43 $this->static_screens = Array(
46 'force_unlock' => FALSE,
47 'lock_type' =>
'none',
66 if ($asset->getRuleCount() == 0) {
68 echo translate(
'core_form_no_rules_set');
73 $rule_codes = $asset->getAllowedRules();
74 $type_codes = Array();
75 $write_access = $asset->writeAccess(
'attributes');
77 foreach ($rule_codes as $rule_code) {
78 $type_codes[] =
'form_question_rule_type_'.$rule_code;
81 $desc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_codes,
'description');
83 $rules = $asset->getRules();
85 for (reset($rules); NULL !== ($k = key($rules)); next($rules)) {
88 $type_code =
'form_question_rule_type_'.$rule[
'rule_code'];
89 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
90 $rule_asset =
new $type_code();
91 $edit_fns = $rule_asset->getEditFns();
93 $o->openSection($desc[$type_code]);
94 $edit_fns->paintRule($rule_asset, $o, $prefix.
'_rule_'.$k, $rule, $write_access, $this);
97 $o->openField(translate(
'core_form_custom_error_text'));
98 text_box($prefix.
'_rule_'.$k.
'[custom_text]', array_get_index($rule,
'custom_text',
''), 30);
101 $o->openField(translate(
'delete_question'));
102 check_box($prefix.
'_rule_'.$k.
'[delete]');
105 $o->openField(translate(
'core_form_custom_error_text'));
106 $custom_text = array_get_index($rule,
'custom_text',
'');
107 if (empty($custom_text)) {
108 ?><i><?php echo translate(
'core_form_no_custom_error_text_set') ?></i><?php
110 echo $rule[
'custom_text'];
118 return $write_access;
135 if ($asset->getRuleCount() == 0)
return FALSE;
137 if (!$asset->writeAccess(
'attributes'))
return FALSE;
139 $rule_codes = $asset->getAllowedRules();
140 $type_codes = Array();
142 foreach ($rule_codes as $rule_code) {
143 $type_codes[] =
'form_question_rule_type_'.$rule_code;
146 $desc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_codes,
'description');
148 $rules = $asset->getRules();
151 foreach (array_keys($rules) as $k) {
152 $rule_prefix = $prefix.
'_rule_'.$k;
153 if (!isset($_POST[$rule_prefix]))
continue;
154 if (array_get_index($_POST[$rule_prefix],
'delete', 0)) {
160 for (reset($rules); NULL !== ($k = key($rules)); next($rules)) {
162 $rule_prefix = $prefix.
'_rule_'.$k;
164 $type_code =
'form_question_rule_type_'.$rule[
'rule_code'];
165 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
166 $rule_asset =
new $type_code();
167 $edit_fns = $rule_asset->getEditFns();
169 $edit_fns->processRule($rule_asset, $o, $prefix.
'_rule_'.$k, $rule);
172 if (isset($_POST[$rule_prefix][
'custom_text'])) {
173 $rule[
'custom_text'] = $_POST[$rule_prefix][
'custom_text'];
177 $asset->setAttrValue(
'rules', $rules);
178 return $asset->saveAttributes();
197 if (!$asset->writeAccess(
'attributes'))
return FALSE;
199 $rule_codes = $asset->getAllowedRules();
200 $type_codes = Array();
202 foreach ($rule_codes as $rule_code) {
203 $type_code =
'form_question_rule_type_'.$rule_code;
204 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
205 $val_rule = eval(
'return '.$type_code.
'::isValidationRule();');
206 if ($val_rule) $type_codes[] = $type_code;
209 $desc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_codes,
'description');
210 combo_box(
'rule', array_merge(Array(
' ' =>
'------ '.translate(
'please_select').
' ------'), $desc), FALSE,
'');
229 $type_code = $_POST[
'rule'];
230 $rule_code = substr($type_code,strlen(
'form_question_rule_type_'));
231 if (!trim($rule_code))
return FALSE;
233 $rules = $asset->getRules();
234 $rules[] = Array(
'rule_code' => $rule_code);
236 $asset->setAttrValue(
'rules', $rules);
237 return $asset->saveAttributes();
256 $section_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($asset->_formid);
258 $locks = $GLOBALS[
'SQ_SYSTEM']->am->getLockInfo($section_asset->id,
'attributes', TRUE);
259 $lock = $locks[
'attributes'];
261 $full_write_access = $section_asset->writeAccess(
'');
262 $acquire_lock_access = $section_asset->canLiveEdit(
'attributes');
265 if ($full_write_access && $acquire_lock_access) {
266 echo
'<p class="sq-backend-unlocked">The "Attributes" lock to the '.(($section_asset instanceof
Form_Section) ?
'Form Section' :
'Form').
' is not currently held.</p>';
268 echo
'You do not have access to edit "'.$section_asset->name.
'".';
273 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'userid']);
274 $editing = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'source_assetid']);
276 if (SQ_ROLLBACK_VIEW) {
277 $now = strtotime($_SESSION[
'sq_rollback_view'][
'rollback_time']);
282 if (is_null($lock[
'expires'])) {
283 $expires_in =
'The lock is being held indefinitely and will not expire. The lock must be released manually or be forceably acquired by a System Administrator.';
285 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
286 $expires_in = easy_time_total(($lock[
'expires'] - $now), TRUE);
287 if (!$expires_in) $expires_in =
'1 second';
288 $expires_in =
'The lock is due to expire in '.$expires_in;
292 <p
class=
"sq-backend-locked-by-<?php echo ($GLOBALS['SQ_SYSTEM']->currentUser($user)) ? 'user' : 'someone-else'; ?>">
293 The
"Attributes" lock to the <?php echo ($section_asset instanceof Form_Section) ? 'Form Section' : 'Form' ?> is held by user
"<?php echo htmlspecialchars($user->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET); ?>" at
"<?php echo htmlspecialchars($editing->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET); ?>".<br/>
294 <?php echo $expires_in; ?>
301 <p>Locking
for this asset is controlled by its parent form<?php
305 ?>. Click to access
this asset: <?php $href = $section_asset->getBackendHref(!($section_asset instanceof
Form) ?
'details' :
'contents'); ?><a href=
"<?php echo $href ?>"><?php echo $section_asset->_getName() ?></a></p><?php