18 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
41 $this->static_screens = Array(
44 'force_unlock' => FALSE,
45 'lock_type' =>
'none',
64 $am = $GLOBALS[
'SQ_SYSTEM']->am;
65 $admin_access = $asset->writeAccess(
'attributes');
66 $prefix = $asset->getPrefix();
67 $questions = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'decision_tree_question', FALSE);
70 <table
class=
"sq-backend-table">
72 <td
class=
"sq-backend-table-header">
73 <?php echo translate(
'question'); ?>
75 <td
class=
"sq-backend-table-header">
76 <?php echo translate(
'type'); ?>
81 foreach ($questions as $q_link) {
82 $assetid = $q_link[
'minorid'];
83 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
84 if (is_null($q))
continue;
87 <td
class=
"sq-backend-table-cell">
88 <?php echo get_asset_tag_line($assetid,
'details'); ?>
90 <td
class=
"sq-backend-table-cell">
92 $q_type = str_replace(
'Decision_Tree_Question_Type',
'', get_class($q));
93 $q_type = str_replace(
'_',
' ', $q_type);
94 $q_type = trim(ucwords($q_type));
141 if (!$asset->writeAccess(
'links'))
return FALSE;
143 $am = $GLOBALS[
'SQ_SYSTEM']->am;
144 $question_types = $am->getTypeDescendants(
'decision_tree_question');
145 $questions = Array(
'' =>
'-- Choose Type --');
147 foreach ($question_types as $question) {
148 $q = str_replace(
'decision_tree_question_type',
'', $question);
149 $q = str_replace(
'_',
' ', $q);
150 $q = trim(ucwords($q));
151 $questions[$question] = $q;
154 combo_box($prefix.
'question_type', $questions, FALSE,
'');
157 text_box($prefix.
'question_name',
'',
'25');
175 if (!$asset->writeAccess(
'links'))
return FALSE;
177 $type = (isset($_POST[$prefix.
'question_type'])) ? $_POST[$prefix.
'question_type'] :
'';
178 $name = (isset($_POST[$prefix.
'question_name'])) ? $_POST[$prefix.
'question_name'] :
'';
180 if ($type && $name) {
181 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
182 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
184 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type);
185 $type = ucwords($type);
186 $new_asset =
new $type;
187 $new_asset->setAttrValue(
'name', $name);
191 'link_type' => SQ_LINK_TYPE_2,
193 'sort_order' => NULL,
194 'is_dependant' => TRUE,
195 'is_exclusive' => FALSE,
198 if(!$new_asset->create($link)) {
199 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
200 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
205 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
206 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
227 $dependant_parent = $GLOBALS[
'SQ_SYSTEM']->am->getDependantParents($asset->id,
'', FALSE, FALSE);
228 if (empty($dependant_parent[0])) {
229 echo
"<p>Locking for this asset is controlled by its parent Decision Tree Page.</p>";
233 $parent_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($dependant_parent[0]);
235 $locks = $GLOBALS[
'SQ_SYSTEM']->am->getLockInfo($parent_asset->id,
'attributes', TRUE);
236 $lock = $locks[
'attributes'];
238 $full_write_access = $parent_asset->writeAccess(
'');
239 $acquire_lock_access = $parent_asset->canLiveEdit(
'attributes');
242 if ($full_write_access && $acquire_lock_access) {
243 echo
'<p class="sq-backend-unlocked">The "Attributes" lock to the Decision Tree Page is not currently held.</p>';
245 echo
'You do not have access to edit "'.$parent_asset->name.
'".';
250 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'userid']);
251 $editing = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'source_assetid']);
253 if (SQ_ROLLBACK_VIEW) {
254 $now = strtotime($_SESSION[
'sq_rollback_view'][
'rollback_time']);
259 if (is_null($lock[
'expires'])) {
260 $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.';
262 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
263 $expires_in = easy_time_total(($lock[
'expires'] - $now), TRUE);
264 if (!$expires_in) $expires_in =
'1 second';
265 $expires_in =
'The lock is due to expire in '.$expires_in;
269 <p
class=
"sq-backend-locked-by-<?php echo ($GLOBALS['SQ_SYSTEM']->currentUser($user)) ? 'user' : 'someone-else'; ?>">
270 The
"Attributes" lock to the Decision Tree Question 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/>
271 <?php echo $expires_in; ?>
278 <p>Locking
for this asset is controlled by its parent Decision Tree
Page<?php
279 ?>. Click to access
this asset: <?php $href = $parent_asset->getBackendHref(
'details'); ?><a href=
"<?php echo $href ?>"><?php echo $parent_asset->name ?></a></p><?php