17 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
43 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
61 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
62 $admin_access = $asset->writeAccess(
'attributes');
63 $prefix = $asset->getPrefix();
67 <script language=
"JavaScript">
68 function sortOrderMoveDown(currentOrder) {
69 if (!document.getElementById) {
70 alert(js_translate(
'brower_does_not_support_getelementbyid'));
74 var form = document.getElementById(
'main_form');
76 if (!document.getElementById(
'<?php echo $prefix ?>_option_text' + (currentOrder + 1)))
return;
79 var currentText = document.getElementById(
'<?php echo $prefix ?>_option_text' + currentOrder);
80 var nextText = document.getElementById(
'<?php echo $prefix ?>_option_text' + (currentOrder + 1));
81 temp = currentText.value;
82 currentText.value = nextText.value;
83 nextText.value = temp;
86 var currentVotes = document.getElementById(
'<?php echo $prefix ?>_option_votes' + currentOrder);
87 var prevVotes = document.getElementById(
'<?php echo $prefix ?>_option_votes' + (currentOrder + 1));
88 temp = currentVotes.innerHTML;
89 currentVotes.innerHTML = prevVotes.innerHTML;
90 prevVotes.innerHTML = temp;
93 temp = form.elements[
'<?php echo $prefix ?>_order[delete][' + (currentOrder+1) +
']'].checked;
94 form.elements[
'<?php echo $prefix ?>_order[delete][' + (currentOrder+1) +
']'].checked = form.elements[
'<?php echo $prefix ?>_order[delete][' + currentOrder +
']'].checked;
95 form.elements[
'<?php echo $prefix ?>_order[delete][' + currentOrder +
']'].checked = temp;
98 temp = form.elements[
'<?php echo $prefix ?>_order[reorder][' + (currentOrder+1) +
']'].value;
99 form.elements[
'<?php echo $prefix ?>_order[reorder][' + (currentOrder+1) +
']'].value = form.elements[
'<?php echo $prefix ?>_order[reorder][' + currentOrder +
']'].value;
100 form.elements[
'<?php echo $prefix ?>_order[reorder][' + currentOrder +
']'].value = temp;
103 function sortOrderMoveUp(currentOrder) {
104 if (!document.getElementById) {
105 alert(js_translate(
'brower_does_not_support_getelementbyid'));
109 var form = document.getElementById(
'main_form');
111 if (currentOrder == 0)
return;
114 var currentText = document.getElementById(
'<?php echo $prefix ?>_option_text' + currentOrder);
115 var prevText = document.getElementById(
'<?php echo $prefix ?>_option_text' + (currentOrder - 1));
116 temp = currentText.value;
117 currentText.value = prevText.value;
118 prevText.value = temp;
121 var currentVotes = document.getElementById(
'<?php echo $prefix ?>_option_votes' + currentOrder);
122 var prevVotes = document.getElementById(
'<?php echo $prefix ?>_option_votes' + (currentOrder - 1));
123 temp = currentVotes.innerHTML;
124 currentVotes.innerHTML = prevVotes.innerHTML;
125 prevVotes.innerHTML = temp;
128 temp = form.elements[
'<?php echo $prefix ?>_order[delete][' + (currentOrder-1) +
']'].checked;
129 form.elements[
'<?php echo $prefix ?>_order[delete][' + (currentOrder-1) +
']'].checked = form.elements[
'<?php echo $prefix ?>_order[delete][' + currentOrder +
']'].checked;
130 form.elements[
'<?php echo $prefix ?>_order[delete][' + currentOrder +
']'].checked = temp;
133 temp = form.elements[
'<?php echo $prefix ?>_order[reorder][' + (currentOrder-1) +
']'].value;
134 form.elements[
'<?php echo $prefix ?>_order[reorder][' + (currentOrder-1) +
']'].value = form.elements[
'<?php echo $prefix ?>_order[reorder][' + currentOrder +
']'].value;
135 form.elements[
'<?php echo $prefix ?>_order[reorder][' + currentOrder +
']'].value = temp;
139 <table
class=
"sq-backend-table">
141 <td
class=
"sq-backend-table-header">
144 <td align=
"center" width=
"100" class=
"sq-backend-table-header" style=
"font-weight: bold;">
152 <td align=
"center" width=
"100" class=
"sq-backend-table-header" style=
"font-weight: bold;">Delete ?</td>
153 <td align=
"center" width=
"100" class=
"sq-backend-table-header" style=
"font-weight: bold;">Move</td>
163 $poll_options = $asset->attr(
'options');
165 if (is_null($poll_options))
return FALSE;
168 foreach ($poll_options as $sort_id => $sort_data) {
172 <td
class=
"sq-backend-table-cell">
175 text_box($prefix.
'_option_text'.$sort_id,$sort_data[
'option_text'], 30);
177 echo $sort_data[
'option_text'];
181 hidden_field($prefix.
'_order[reorder]['.$sort_id.
']', $sort_id);
184 <!-- No. of Votes -->
185 <td align=
"center" width=
"100" class=
"sq-backend-table-cell">
186 <span
id=
"<?php echo $prefix.'_option_votes'.$sort_id; ?>">
188 echo $sort_data[
'votes'];
195 <td align=
"center" width=
"100" class=
"sq-backend-table-cell">
197 check_box($prefix.
'_order[delete]['.$sort_id.
']');
200 <td align=
"center" width=
"100" class=
"sq-backend-table-cell">
203 ?><a href=
"#" onclick=
"sortOrderMoveUp(<?php echo $sort_id ?>); return false;"><script language=
"JavaScript" type=
"text/javascript">sq_print_icon(
"<?php echo sq_web_path('lib').'/web/images/icons/up_arrow.png' ?>",
"16",
"16",
"Move Up");</script></a><?php
206 if ($ii != count($poll_options) -1) {
207 ?><a href=
"#" onclick=
"sortOrderMoveDown(<?php echo $sort_id ?>); return false;"><img src=
"<?php echo sq_web_path('lib').'/web/images/icons/down_arrow.png' ?>" width=
"16" height=
"16" border=
"0"alt=
"Move Down" /></a><?php
239 $prefix = $asset->getPrefix();
240 $options = $asset->attr(
'options');
241 $option_updated = FALSE;
244 if (isset($_POST[$prefix.
'_order'][
'reorder'])) {
245 $reorder_array = $_POST[$prefix.
'_order'][
'reorder'];
247 foreach ($reorder_array as $reorder_index => $reorder_data) {
248 $options[$reorder_data][
'option_text'] = $_POST[$prefix.
'_option_text'.$reorder_index];
249 array_push($newArray, $options[$reorder_data]);
250 $option_updated = TRUE;
252 $options = $newArray;
256 if (isset($_POST[$prefix.
'_order'][
'delete'])) {
257 foreach (array_keys($options) as $option_index ) {
258 if (isset($_POST[$prefix.
'_order'][
'delete'][$option_index])) {
259 if ($_POST[$prefix.
'_order'][
'delete'][$option_index] ==
'1') {
260 $options[$option_index] = NULL;
261 unset($options[$option_index]);
262 $options = array_values($options);
265 $option_updated = TRUE;
269 if ($option_updated) $asset->updateOptions($options);
288 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
289 $admin_access = $asset->writeAccess(
'attributes');
290 $prefix = $asset->getPrefix();
292 combo_box($prefix.
'_no_options', Array(
'',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'10' ), FALSE,
'');
310 $prefix = $asset->getPrefix();
311 $options = $asset->attr(
'options');
313 if (isset($_POST[$prefix.
'_no_options'])) {
314 for ($ii = 0; $ii < $_POST[$prefix.
'_no_options']; $ii++) {
315 $new_option = Array(
'option_text' =>
'Poll Option Text #'.($ii + 1),
'votes' => 0);
316 array_push($options, $new_option);
318 $asset->setAttrValue(
'options', $options);
337 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
338 $admin_access = $asset->writeAccess(
'attributes');
339 $prefix = $asset->getPrefix();
340 $users_array = Array(
'',
'all' =>
'Delete All Users' );
343 $voters = $GLOBALS[
'SQ_SYSTEM']->am->getShadowLinkByAsset($asset->id, NULL, SQ_LINK_NOTICE, NULL,
'major', TRUE);
346 if (empty($voters)) {
347 ?><em><?php echo translate(
'cms_poll_question_no_voting_records_exist'); ?></em><?php
349 foreach ($voters as $voter) {
350 $voter_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($voter[
'minorid']));
351 $users_array[$voter[
'minorid']] = $voter_info[$voter[
'minorid']][
'name'];
354 combo_box($prefix.
'options', $users_array, FALSE,
'');
357 ?><em><?php echo translate(
'cms_poll_question_admin_access_to_delete_user'); ?></em><?php
375 $prefix = $asset->getPrefix();
377 if (!empty($_POST[$prefix.
'options'])) {
378 $other_assetid = ($_POST[$prefix.
'options'] ==
'all') ? NULL : $_POST[$prefix.
'options'];
379 $voter_links = $GLOBALS[
'SQ_SYSTEM']->am->getShadowLinkByAsset($asset->id, $other_assetid, SQ_LINK_NOTICE, NULL,
'major', TRUE);
381 foreach ($voter_links as $voter_link) {
382 $GLOBALS[
'SQ_SYSTEM']->am->deleteShadowAssetLink($voter_link[
'linkid']);