فهرست منبع

Ticket #4971 - Build-in API support: Attached polls in Timeline.

AntonLV 1 سال پیش
والد
کامیت
1a81a1bdfc

+ 2 - 0
modules/base/general/classes/BxBaseModGeneralConfig.php

@@ -46,6 +46,8 @@ class BxBaseModGeneralConfig extends BxDolModuleConfig
             'TABLE_POLLS_ANSWERS_VOTES_TRACK' => $aModule['db_prefix'] . 'polls_answers_votes_track',
             
             // database fields
+            'FIELD_POLL' => 'polls',
+
             'FIELD_POLL_ID' => 'id',
             'FIELD_POLL_AUTHOR_ID' => 'author_id',
             'FIELD_POLL_CONTENT_ID' => 'content_id',

+ 3 - 2
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -678,9 +678,10 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
 
     public function getCleanValue($sName)
     {
-        $mixedValue = parent::getCleanValue($sName);
+        $CNF = &$this->_oModule->_oConfig->CNF;
 
-        if($this->_bIsApi && !empty($mixedValue) && isset($this->aInputs[$sName]['type']) && in_array($this->aInputs[$sName]['type'], ['polls']))
+        $mixedValue = parent::getCleanValue($sName);
+        if($this->_bIsApi && !empty($mixedValue) && in_array($sName, [$CNF['FIELD_POLL']]))
             $mixedValue = explode(',', $mixedValue);
 
         return $mixedValue;

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralFormPoll.php

@@ -213,7 +213,7 @@ class BxBaseModGeneralFormPollCheckerHelper extends BxDolFormCheckerHelper
 {
     static public function checkAvailAnswers ($s)
     {
-        return !self::_isEmptyArray($s) && count($s) >= 2;
+        return bx_is_api() ? self::checkAvail($s) : !self::_isEmptyArray($s) && count($s) >= 2;
     }
 }
 

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -398,7 +398,7 @@ class BxBaseModGeneralModule extends BxDolModule
             if((int)$aResult['code'] == 0) {
                 return [
                     'id' => $aResult['id'],
-                    'item' => 'TODO: return newly created poll'
+                    'item' => $aResult['item']
                 ];
             }
             else