Added poll management to quick reply/inline edit
authorAlexander Ebert <ebert@woltlab.com>
Fri, 3 Jun 2016 15:12:22 +0000 (17:12 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 3 Jun 2016 15:12:28 +0000 (17:12 +0200)
com.woltlab.wcf/templates/__messageFormPoll.tpl
com.woltlab.wcf/templates/__messageFormPollInline.tpl [new file with mode: 0644]
com.woltlab.wcf/templates/messageFormTabsInline.tpl
wcfsetup/install/files/js/WCF.Poll.js
wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/InlineEditor.js
wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php
wcfsetup/install/files/lib/system/poll/PollManager.class.php
wcfsetup/install/files/style/ui/poll.scss

index 2a911519435f00b1b7ff184d947867e72e1bece6..d2c32596d52b5ab6becb4d10234ef1d97f1a31d7 100644 (file)
@@ -28,7 +28,7 @@
                        <dt>
                                <label>{lang}wcf.poll.options{/lang}</label>
                        </dt>
-                       <dd id="pollOptionContainer" class="sortableListContainer">
+                       <dd id="pollOptionContainer" class="pollOptionContainer sortableListContainer">
                                <ol class="sortableList"></ol>
                                {if $errorField == 'pollOptions'}
                                        <small class="innerError">
diff --git a/com.woltlab.wcf/templates/__messageFormPollInline.tpl b/com.woltlab.wcf/templates/__messageFormPollInline.tpl
new file mode 100644 (file)
index 0000000..b3465b0
--- /dev/null
@@ -0,0 +1,73 @@
+{if $__showPoll|isset && $__showPoll}
+       <script data-relocate="true">
+               //<![CDATA[
+               $(function() {
+                       WCF.Language.addObject({
+                               'wcf.poll.button.addOption': '{lang}wcf.poll.button.addOption{/lang}',
+                               'wcf.poll.button.removeOption': '{lang}wcf.poll.button.removeOption{/lang}'
+                       });
+                       
+                       new WCF.Poll.Management(
+                               'pollOptionContainer_{$wysiwygSelector}',
+                               [ {implode from=$pollOptions item=pollOption}{ optionID: {@$pollOption[optionID]}, optionValue: '{$pollOption[optionValue]|encodeJS}' }{/implode} ],
+                               {@POLL_MAX_OPTIONS},
+                               '{$wysiwygSelector}'
+                       );
+               });
+               //]]>
+       </script>
+       
+       <div class="jsOnly messageTabMenuContent">
+               <dl>
+                       <dt>
+                               <label for="pollQuestion_{$wysiwygSelector}">{lang}wcf.poll.question{/lang}</label>
+                       </dt>
+                       <dd>
+                               <input type="text" name="pollQuestion" id="pollQuestion_{$wysiwygSelector}" value="{$pollQuestion}" class="long" maxlength="255">
+                       </dd>
+                       <dt>
+                               <label>{lang}wcf.poll.options{/lang}</label>
+                       </dt>
+                       <dd id="pollOptionContainer_{$wysiwygSelector}" class="pollOptionContainer sortableListContainer">
+                               <ol class="sortableList"></ol>
+                               <small>{lang}wcf.poll.options.description{/lang}</small>
+                       </dd>
+               </dl>
+               <dl>
+                       <dt>
+                               <label for="pollEndTime_{$wysiwygSelector}">{lang}wcf.poll.endTime{/lang}</label>
+                       </dt>
+                       <dd>
+                               <input type="datetime" name="pollEndTime" id="pollEndTime_{$wysiwygSelector}" value="{if $pollEndTime}{@$pollEndTime|date:'c'}{/if}" class="medium" data-ignore-timezone="true">
+                       </dd>
+               </dl>
+               <dl>
+                       <dt>
+                               <label for="pollMaxVotes_{$wysiwygSelector}">{lang}wcf.poll.maxVotes{/lang}</label>
+                       </dt>
+                       <dd>
+                               <input type="number" name="pollMaxVotes" id="pollMaxVotes_{$wysiwygSelector}" value="{@$pollMaxVotes}" min="1" class="tiny">
+                       </dd>
+               </dl>
+               <dl>
+                       <dt></dt>
+                       <dd>
+                               <label><input type="checkbox" name="pollIsChangeable" value="1"{if $pollIsChangeable} checked{/if}> {lang}wcf.poll.isChangeable{/lang}</label>
+                       </dd>
+                       {if !$pollID && $__wcf->getPollManager()->canStartPublicPoll()}
+                               <dd>
+                                       <label><input type="checkbox" name="pollIsPublic" value="1"{if $pollIsPublic} checked{/if}> {lang}wcf.poll.isPublic{/lang}</label>
+                               </dd>
+                       {/if}
+                       <dd>
+                               <label><input type="checkbox" name="pollResultsRequireVote" value="1"{if $pollResultsRequireVote} checked{/if}> {lang}wcf.poll.resultsRequireVote{/lang}</label>
+                               <small>{lang}wcf.poll.resultsRequireVote.description{/lang}</small>
+                       </dd>
+                       <dd>
+                               <label><input type="checkbox" name="pollSortByVotes" value="1"{if $pollSortByVotes} checked{/if}> {lang}wcf.poll.sortByVotes{/lang}</label>
+                       </dd>
+               </dl>
+               
+               {event name='fields'}
+       </div>
+{/if}
\ No newline at end of file
index a92ac33e26fd446f7fc17499d2f87444b8c10275..3caa6a53f806087eb8834535455cde12e6e390cc 100644 (file)
@@ -1,6 +1,7 @@
 {assign var=smileyCategories value=$__wcf->getSmileyCache()->getVisibleCategories()}
 {if !$permissionCanUseSmilies|isset}{assign var=permissionCanUseSmilies value='user.message.canUseSmilies'}{/if}
 {if !$wysiwygContainerID|isset}{assign var=wysiwygContainerID value='text'}{/if}
+{if !$wysiwygSelector|isset}{assign var=wysiwygSelector value=$wysiwygContainerID}{/if}
 
 {capture assign='__messageFormSettingsInlineContent'}{include file='messageFormSettingsInline'}{/capture}
 {assign var='__messageFormSettingsInlineContent' value=$__messageFormSettingsInlineContent|trim}
@@ -11,6 +12,7 @@
                        {if MODULE_SMILEY && $__wcf->getSession()->getPermission($permissionCanUseSmilies) && $smileyCategories|count}<li data-name="smilies"><a><span class="icon icon16 fa-smile-o"></span> <span>{lang}wcf.message.smilies{/lang}</span></a></li>{/if}
                        {if MODULE_ATTACHMENT && !$attachmentHandler|empty && $attachmentHandler->canUpload()}<li data-name="attachments"><a><span class="icon icon16 fa-paperclip"></span> <span>{lang}wcf.attachment.attachments{/lang}</span></a></li>{/if}
                        {if $__messageFormSettingsInlineContent}<li data-name="settings"><a><span class="icon icon16 fa-cog"></span> <span>{lang}wcf.message.settings{/lang}</span></a></li>{/if}
+                       {if $__showPoll|isset && $__showPoll}<li data-name="poll"><a><span class="icon icon16 fa-bar-chart"></span> <span>{lang}wcf.poll.management{/lang}</span></a></li>{/if}
                        {event name='tabMenuTabs'}
                </ul>
        </nav>
@@ -20,6 +22,8 @@
        
        {if $__messageFormSettingsInlineContent}{@$__messageFormSettingsInlineContent}{/if}
        
+       {include file='__messageFormPollInline'}
+       
        {event name='tabMenuContents'}
 </div>
 
index 4df48bbff0d58ad43a29efcf8b9cfc63b29ea26d..eed02fde8fbbc0a4e8cecc0027e47496c746ef4b 100644 (file)
@@ -28,6 +28,12 @@ WCF.Poll.Management = Class.extend({
         */
        _count: 0,
        
+       /**
+        * editor element id
+        * @var string
+        */
+       _editorId: '',
+       
        /**
         * maximum allowed number of options
         * @var int
@@ -37,11 +43,12 @@ WCF.Poll.Management = Class.extend({
        /**
         * Initializes the WCF.Poll.Management class.
         * 
-        * @param       string          containerID
-        * @param       array<object>   optionList
-        * @param       integer         maxOptions
+        * @param       {string}        containerID
+        * @param       {Object[]}      optionList
+        * @param       {int}           maxOptions
+        * @param       {string}        editorId
         */
-       init: function(containerID, optionList, maxOptions) {
+       init: function(containerID, optionList, maxOptions, editorId) {
                this._count = 0;
                this._maxOptions = maxOptions || -1;
                this._container = $('#' + containerID).children('ol:eq(0)');
@@ -50,11 +57,19 @@ WCF.Poll.Management = Class.extend({
                        return;
                }
                
-               optionList = optionList || [ ];
+               optionList = optionList || [];
                this._createOptionList(optionList);
                
                // bind event listener
-               this._container.parents('form').submit($.proxy(this._submit, this));
+               if (editorId) {
+                       this._editorId = editorId;
+                       
+                       WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'reset_' + editorId, this._reset.bind(this));
+                       WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'submit_' + editorId, this._submit.bind(this));
+               }
+               else {
+                       this._container.parents('form').submit($.proxy(this._submit, this));
+               }
                
                // init sorting
                new WCF.Sortable.List(containerID, '', undefined, {
@@ -152,7 +167,7 @@ WCF.Poll.Management = Class.extend({
                        return false;
                }
                
-               var $listItem = $(event.currentTarget).parents('li');
+               var $listItem = $(event.currentTarget).closest('li', this._container[0]);
                
                this._createOption(undefined, undefined, $listItem);
        },
@@ -163,7 +178,7 @@ WCF.Poll.Management = Class.extend({
         * @param       object          event
         */
        _removeOption: function(event) {
-               $(event.currentTarget).parents('li').remove();
+               $(event.currentTarget).closest('li', this._container[0]).remove();
                
                this._count--;
                this._container.find('span.jsAddOption').addClass('pointer').removeClass('disabled');
@@ -175,31 +190,81 @@ WCF.Poll.Management = Class.extend({
        
        /**
         * Inserts hidden input elements storing the option values.
+        * 
+        * @param       {(Event|Object)}        event
         */
-       _submit: function() {
-               var $options = [ ];
-               this._container.children('li').each(function(index, listItem) {
+       _submit: function(event) {
+               var $options = [];
+               this._container.children('li').each(function (index, listItem) {
                        var $listItem = $(listItem);
                        var $optionValue = $.trim($listItem.find('input').val());
                        
                        // ignore empty values
                        if ($optionValue != '') {
-                               $options.push({
-                                       optionID: $listItem.data('optionID'),
-                                       optionValue: $optionValue
-                               });
+                               $options.push($listItem.data('optionID') + '_' + $optionValue);
                        }
                });
                
-               // create hidden input fields
-               if ($options.length) {
-                       var $formSubmit = this._container.parents('form').find('.formSubmit');
-                       
-                       for (var $i = 0, $length = $options.length; $i < $length; $i++) {
-                               var $option = $options[$i];
-                               $('<input type="hidden" name="pollOptions[' + $i + ']" />').val($option.optionID + '_' + $option.optionValue).appendTo($formSubmit);
+               if (event instanceof Event) {
+                       // create hidden input fields
+                       if ($options.length) {
+                               var $formSubmit = this._container.parents('form').find('.formSubmit');
+                               
+                               for (var $i = 0, $length = $options.length; $i < $length; $i++) {
+                                       $('<input type="hidden" name="pollOptions[' + $i + ']">').val($options[$i]).appendTo($formSubmit);
+                               }
                        }
                }
+               else {
+                       event.poll = { pollOptions: $options };
+                       
+                       // get form input fields
+                       var parentContainer = this._container.parents('.messageTabMenuContent:eq(0)');
+                       parentContainer.find('input').each(function(index, input) {
+                               if (input.name) {
+                                       if (input.type !== 'checkbox' || input.checked) {
+                                               event.poll[input.name] = input.value;
+                                       }
+                               }
+                       });
+               }
+       },
+       
+       /**
+        * Resets the poll option form.
+        * 
+        * @private
+        */
+       _reset: function() {
+               // reset options
+               /** @type Element */
+               var container = this._container[0];
+               while (container.childElementCount > 1) {
+                       container.removeChild(container.children[1]);
+               }
+               
+               elBySel('input', container.children[0]).value = '';
+               
+               // reset input fields and checkboxes
+               var parentContainer = this._container.parents('.messageTabMenuContent:eq(0)');
+               parentContainer.find('input').each(function(index, input) {
+                       if (input.name) {
+                               if (input.type === 'checkbox') {
+                                       input.checked = false;
+                               }
+                               else if (input.type === 'text') {
+                                       input.value = '';
+                               }
+                               else if (input.type === 'number') {
+                                       input.value = input.min;
+                               }
+                       }
+               });
+               
+               // reset date picker
+               require(['WoltLab/WCF/Date/Picker'], (function(UiDatePicker) {
+                       UiDatePicker.clear('pollEndTime_' + this._editorId);
+               }).bind(this));
        }
 });
 
index 9aebd9f9ef75da72191d21e0a66adbc0271f4357..87836c9e5e0748386f10fcf46026b388155369ed 100644 (file)
@@ -2,7 +2,7 @@
  * Date picker with time support.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/Date/Picker
  */
@@ -260,9 +260,9 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                /**
                 * Renders the full picker on init.
                 * 
-                * @param       {integer}       day
-                * @param       {integer}       month
-                * @param       {integer}       year
+                * @param       {int}           day
+                * @param       {int}           month
+                * @param       {int}           year
                 */
                _renderPicker: function(day, month, year) {
                        this._renderGrid(day, month, year);
@@ -283,12 +283,12 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                /**
                 * Updates the date grid.
                 * 
-                * @param       {integer}       day
-                * @param       {integer}       month
-                * @param       {integer}       year
+                * @param       {int}           day
+                * @param       {int}           month
+                * @param       {int}           year
                 */
                _renderGrid: function(day, month, year) {
-                       var cell, hasDay = (day !== undefined), hasMonth = (month !== undefined);
+                       var cell, hasDay = (day !== undefined), hasMonth = (month !== undefined), i;
                        
                        day = ~~day || ~~elData(_dateGrid, 'day');
                        month = ~~month;
@@ -336,7 +336,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                                }
                                
                                var selectable;
-                               for (var i = 0; i < 35; i++) {
+                               for (i = 0; i < 35; i++) {
                                        cell = _dateCells[i];
                                        
                                        cell.textContent = date.getDate();
@@ -368,7 +368,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                                }
                                
                                if (rebuildMonths) {
-                                       for (var i = 0; i < 12; i++) {
+                                       for (i = 0; i < 12; i++) {
                                                var currentMonth = _dateMonth.children[i];
                                                
                                                currentMonth.disabled = (year === _minDate.getFullYear() && currentMonth.value < _minDate.getMonth()) || (year === _maxDate.getFullYear() && currentMonth.value > _maxDate.getMonth());
@@ -388,7 +388,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                        
                        // update active day
                        if (day) {
-                               for (var i = 0; i < 35; i++) {
+                               for (i = 0; i < 35; i++) {
                                        cell = _dateCells[i];
                                        
                                        cell.classList[(!cell.classList.contains('otherMonth') && ~~cell.textContent === day) ? 'add' : 'remove']('active');
@@ -475,8 +475,8 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                        selectWrapper.appendChild(_dateMonth);
                        monthYearContainer.appendChild(selectWrapper);
                        
-                       var months = '', monthNames = Language.get('__monthsShort');
-                       for (var i = 0; i < 12; i++) {
+                       var i, months = '', monthNames = Language.get('__monthsShort');
+                       for (i = 0; i < 12; i++) {
                                months += '<option value="' + i + '">' + monthNames[i] + '</option>';
                        }
                        _dateMonth.innerHTML = months;
@@ -503,7 +503,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                        _dateGrid.appendChild(item);
                        
                        var span, weekdays = Language.get('__daysShort');
-                       for (var i = 0; i < 7; i++) {
+                       for (i = 0; i < 7; i++) {
                                var day = i + _firstDayOfWeek;
                                if (day > 6) day -= 7;
                                
@@ -514,7 +514,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                        
                        // create date grid
                        var callbackClick = this._click.bind(this), cell, row;
-                       for (var i = 0; i < 5; i++) {
+                       for (i = 0; i < 5; i++) {
                                row = elCreate('li');
                                _dateGrid.appendChild(row);
                                
@@ -537,7 +537,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                        var tmp = '';
                        var date = new Date(2000, 0, 1);
                        var timeFormat = Language.get('wcf.date.timeFormat').replace(/:/, '').replace(/[isu]/g, '');
-                       for (var i = 0; i < 24; i++) {
+                       for (i = 0; i < 24; i++) {
                                date.setHours(i);
                                tmp += '<option value="' + i + '">' + DateUtil.format(date, timeFormat) + "</option>";
                        }
@@ -551,8 +551,8 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                        _dateMinute.className = 'minute';
                        _dateMinute.addEventListener('change', this._formatValue.bind(this));
                        
-                       var tmp = '';
-                       for (var i = 0; i < 60; i++) {
+                       tmp = '';
+                       for (i = 0; i < 60; i++) {
                                tmp += '<option value="' + i + '">' + (i < 10 ? '0' + i.toString() : i) + '</option>';
                        }
                        _dateMinute.innerHTML = tmp;
@@ -646,8 +646,8 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                /**
                 * Sets the date of given element.
                 * 
-                * @param       {(Element|string)}      element         input element or id
-                * @param       {Date}                  date            Date object
+                * @param       {(HTMLInputElement|string)}     element         input element or id
+                * @param       {Date}                          date            Date object
                 */
                setDate: function(element, date) {
                        element = this._getElement(element);
@@ -662,7 +662,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                /**
                 * Clears the date value of given element.
                 * 
-                * @param       {(Element|string)}      element         input element or id
+                * @param       {(HTMLInputElement|string)}     element         input element or id
                 */
                clear: function(element) {
                        element = this._getElement(element);
@@ -678,7 +678,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                /**
                 * Reverts the date picker into a normal input field.
                 * 
-                * @param       {(Element|string)}      element         input element or id
+                * @param       {(HTMLInputElement|string)}     element         input element or id
                 */
                destroy: function(element) {
                        element = this._getElement(element);
index 0395356b6ac6dc5dcf3906f9022b57de5c3ea9d5..fcfa8edaabdb5efec10f53ce5e7f621872c463c4 100644 (file)
@@ -416,7 +416,7 @@ define(
                        var id = this._getEditorId();
                        
                        EventHandler.fire('com.woltlab.wcf.redactor2', 'getText_' + id, parameters.data);
-                       EventHandler.fire('com.woltlab.wcf.messageOptionsInline', 'submit_' + id, parameters);
+                       EventHandler.fire('com.woltlab.wcf.redactor2', 'submit_' + id, parameters);
                        
                        Ajax.api(this, {
                                actionName: 'save',
@@ -453,6 +453,22 @@ define(
                                }
                        }
                        
+                       // handle poll
+                       if (typeof data.returnValues.poll === 'string') {
+                               // find current poll
+                               var poll = elBySel('.pollContainer', elementData.messageBody);
+                               if (poll !== null) {
+                                       // poll contain is wrapped inside `.jsInlineEditorHideContent`
+                                       elRemove(poll.parentNode);
+                               }
+                               
+                               var pollContainer = elCreate('div');
+                               pollContainer.className = 'jsInlineEditorHideContent';
+                               DomUtil.setInnerHtml(pollContainer, data.returnValues.poll);
+                               
+                               DomUtil.prepend(pollContainer, elementData.messageBody);
+                       }
+                       
                        this._restoreMessage();
                        
                        this._updateHistory(this._getHash(this._getObjectId(this._activeElement)));
index acb6ec4365a74ea6494903998807b7335be273aa..bf4c9654648802d890d10bb4d7e182645769451d 100644 (file)
@@ -242,12 +242,16 @@ class QuickReplyManager extends SingletonFactory {
                        
                        return [
                                'lastPostTime' => $message->time,
+                               'objectID' => $message->getObjectID(),
                                'template' => WCF::getTPL()->fetch($templateName, $application)
                        ];
                }
                else {
                        // redirect
-                       return ['url' => $object->getRedirectUrl($this->container, $message)];
+                       return [
+                               'objectID' => $message->getObjectID(),
+                               'url' => $object->getRedirectUrl($this->container, $message)
+                       ];
                }
        }
        
index 3117fd55df085bc2ec8e6acfe0c191e30520f168..4b884a0c1c93ba69c845461249c707be76432f87 100644 (file)
@@ -157,27 +157,33 @@ class PollManager extends SingletonFactory {
        
        /**
         * Reads form parameters for polls.
+        * 
+        * @param       array   $postData       optional post data to be used instead of $_POST
         */
-       public function readFormParameters() {
+       public function readFormParameters(array $postData = array()) {
+               if (empty($postData)) {
+                       $postData &= $_POST;
+               }
+               
                // reset poll data and options prior to reading form input
                $this->pollData = $this->pollOptions = [];
                
                // poll data
-               if (isset($_POST['pollEndTime'])) {
-                       $d = \DateTime::createFromFormat('Y-m-d H:i', $_POST['pollEndTime'], WCF::getUser()->getTimeZone());
+               if (isset($postData['pollEndTime'])) {
+                       $d = \DateTime::createFromFormat('Y-m-d H:i', $postData['pollEndTime'], WCF::getUser()->getTimeZone());
                        $this->pollData['endTime'] = ($d !== false) ? $d->getTimestamp() : 0;
                }
                
-               if (isset($_POST['pollMaxVotes'])) $this->pollData['maxVotes'] = max(intval($_POST['pollMaxVotes']), 1); // force a minimum of 1
-               if (isset($_POST['pollQuestion'])) $this->pollData['question'] = StringUtil::trim($_POST['pollQuestion']);
+               if (isset($postData['pollMaxVotes'])) $this->pollData['maxVotes'] = max(intval($postData['pollMaxVotes']), 1); // force a minimum of 1
+               if (isset($postData['pollQuestion'])) $this->pollData['question'] = StringUtil::trim($postData['pollQuestion']);
                
                // boolean values
-               $this->pollData['isChangeable'] = (isset($_POST['pollIsChangeable'])) ? 1 : 0;
-               $this->pollData['resultsRequireVote'] = (isset($_POST['pollResultsRequireVote'])) ? 1 : 0;
-               $this->pollData['sortByVotes'] = (isset($_POST['pollSortByVotes'])) ? 1 : 0;
+               $this->pollData['isChangeable'] = (isset($postData['pollIsChangeable'])) ? 1 : 0;
+               $this->pollData['resultsRequireVote'] = (isset($postData['pollResultsRequireVote'])) ? 1 : 0;
+               $this->pollData['sortByVotes'] = (isset($postData['pollSortByVotes'])) ? 1 : 0;
                
                if ($this->poll === null) {
-                       $this->pollData['isPublic'] = (isset($_POST['pollIsPublic']) && $this->canStartPublicPoll()) ? 1 : 0;
+                       $this->pollData['isPublic'] = (isset($postData['pollIsPublic']) && $this->canStartPublicPoll()) ? 1 : 0;
                }
                else {
                        // visibility cannot be changed after creation
@@ -185,8 +191,8 @@ class PollManager extends SingletonFactory {
                }
                
                // poll options
-               if (isset($_POST['pollOptions']) && is_array($_POST['pollOptions'])) {
-                       foreach ($_POST['pollOptions'] as $showOrder => $value) {
+               if (isset($postData['pollOptions']) && is_array($postData['pollOptions'])) {
+                       foreach ($postData['pollOptions'] as $showOrder => $value) {
                                list($optionID, $optionValue) = explode('_', $value, 2);
                                $this->pollOptions[$showOrder] = [
                                        'optionID' => intval($optionID),
index f983b196a9c58789a346b2b5c106674d861bb321..f7e86b2521e88d318a3b2c80db8c6b5273677801 100644 (file)
@@ -1,5 +1,5 @@
 /* poll create/edit form */
-#pollOptionContainer .pollOptionInput {
+.pollOptionContainer .pollOptionInput {
        align-items: center;
        margin: 5px 0;