Răsfoiți Sursa

Ticket #4148 - Build-in API support: Action repost.

AntonLV 3 ani în urmă
părinte
comite
aa7e4215d1

+ 10 - 8
modules/base/general/classes/BxBaseModGeneralMenuViewActions.php

@@ -408,17 +408,19 @@ class BxBaseModGeneralMenuViewActions extends BxTemplMenuCustom
         if(!empty($CNF['FIELD_STATUS_ADMIN']) && isset($aContentInfo[$CNF['FIELD_STATUS_ADMIN']]) && $aContentInfo[$CNF['FIELD_STATUS_ADMIN']] != $sStatus)
             return '';
 
-        if(!BxDolRequest::serviceExists('bx_timeline', 'get_repost_element_block'))
-            return '';
-
-        if($this->_bIsApi)
-            return $aItem;
-
-        $sResult = BxDolService::call('bx_timeline', 'get_repost_element_block', array(bx_get_logged_profile_id(), $this->_oModule->_oConfig->getName(), $sAction, $iId, array(
+        $aSrvParams = [bx_get_logged_profile_id(), $this->_oModule->_oConfig->getName(), $sAction, $iId, [
             'do' => !empty($aParams['do']) ? $aParams['do'] : 'repost',
             'show_do_repost_as_button' => $this->_bShowAsButton,
             'show_do_repost_text' => $this->_bShowTitle
-        )));
+        ]];
+
+        if($this->_bIsApi && BxDolRequest::serviceExists('bx_timeline', 'get_repost_element_block_api'))
+            return bx_srv('bx_timeline', 'get_repost_element_block_api', $aSrvParams);
+
+        if(!BxDolRequest::serviceExists('bx_timeline', 'get_repost_element_block'))
+            return '';
+
+        $sResult = bx_srv('bx_timeline', 'get_repost_element_block', $aSrvParams);
         if(empty($sResult))
             return '';
 

+ 39 - 0
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -2603,6 +2603,45 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return $this->_oTemplate->getRepostElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams);
     }
 
+    /**
+     * @page service Service Calls
+     * @section bx_timeline Timeline
+     * @subsection bx_timeline-repost Repost
+     * @subsubsection bx_timeline-get_repost_element_block_api get_repost_element_block_api
+     * 
+     * @code bx_srv('bx_timeline', 'get_repost_element_block_api', [...]); @endcode
+     * 
+     * Get repost element for content based modules. 
+     * Note. Response is formated to be used in API calls.
+     * 
+     * @param $iOwnerId integer value with owner profile ID.
+     * @param $sType string value with type (module name). 
+     * @param $sAction string value with action (module action). 
+     * @param $iObjectId integer value with object ID to be reposted. 
+     * @param $aParams (optional) an array with additional params.
+     * @return HTML string with repost element to display on the site, all necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
+     * 
+     * @see BxTimelineModule::serviceGetRepostElementBlockApi
+     */
+    /** 
+     * @ref bx_timeline-get_repost_element_block_api "get_repost_element_block_api"
+     * @api @ref bx_timeline-get_repost_element_block_api "get_repost_element_block_api"
+     */
+    public function serviceGetRepostElementBlockApi($iOwnerId, $sType, $sAction, $iObjectId, $aParams = [])
+    {
+        if(!bx_is_api())
+            return;
+
+        //TODO: Implement the functionality here.
+
+        $sClass = get_class($this);
+        return [
+            'display_type' => 'element',
+            'name' => md5($sClass),
+            'title' => get_class($this)
+        ];
+    }
+
     /**
      * @page service Service Calls
      * @section bx_timeline Timeline