|
|
@@ -29,13 +29,38 @@ class BxBaseVoteServices extends BxDol
|
|
|
if(!$oVote)
|
|
|
return ['code' => BX_DOL_OBJECT_ERR_NOT_AVAILABLE];
|
|
|
|
|
|
+ $sMethod = 'serviceDo' . bx_gen_method_name($oVote->getType());
|
|
|
+ if(method_exists($this, $sMethod))
|
|
|
+ return $this->$sMethod($aParams, $oVote);
|
|
|
+
|
|
|
+ $aResult = $oVote->vote($aParams);
|
|
|
+ if((int)$aResult['code'] != 0)
|
|
|
+ return $aResult;
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'is_voted' => $aResult['voted'],
|
|
|
+ 'is_disabled' => $aResult['disabled'],
|
|
|
+ 'icon' => !empty($aResult['label_emoji']) ? $aResult['label_emoji'] : $aDefaultInfo['emoji'],
|
|
|
+ 'title' => !empty($aResult['label_title']) ? $aResult['label_title'] : '',
|
|
|
+ 'counter' => $oVote->getVote()
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function serviceDoReactions($aParams, &$oVote)
|
|
|
+ {
|
|
|
$aResult = $oVote->vote($aParams);
|
|
|
if((int)$aResult['code'] != 0)
|
|
|
return $aResult;
|
|
|
|
|
|
+ $aDefault = $oVote->getReaction($oVote->getDefault());
|
|
|
+ $aDefaultInfo = $oVote->getReaction($aDefault['name']);
|
|
|
+
|
|
|
return [
|
|
|
+ 'is_voted' => $aResult['voted'],
|
|
|
+ 'is_disabled' => $aResult['disabled'],
|
|
|
'reaction' => $aResult['reaction'],
|
|
|
- 'icon' => !empty($aResult['label_emoji']) ? $aResult['label_emoji'] : '',
|
|
|
+ 'icon' => !empty($aResult['label_emoji']) ? $aResult['label_emoji'] : $aDefaultInfo['emoji'],
|
|
|
+ 'title' => !empty($aResult['label_title']) ? $aResult['label_title'] : '',
|
|
|
'counter' => $oVote->getVote()
|
|
|
];
|
|
|
}
|