1
0

BxFdbModule.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Feedback Feedback
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxFdbModule extends BxBaseModGeneralModule
  12. {
  13. function __construct(&$aModule)
  14. {
  15. parent::__construct($aModule);
  16. }
  17. public function actionAnswer()
  18. {
  19. $iProfileId = bx_get_logged_profile_id();
  20. if(!$iProfileId)
  21. return echoJson(array('code' => 1, 'msg' => _t('_bx_feedback_err_login_required')));
  22. $iQuestionId = (int)bx_get('question_id');
  23. $iAnswerId = (int)bx_get('answer_id');
  24. if(empty($iQuestionId) || empty($iAnswerId))
  25. return echoJson(array('code' => 2, 'msg' => _t('_bx_feedback_err_wrong_data')));
  26. if(($iAnswerIdOld = $this->_oDb->isAnswer($iQuestionId, $iProfileId)) !== false)
  27. if($this->_oDb->undoAnswer($iAnswerIdOld, $iProfileId))
  28. $this->onDeleteAnswer($iQuestionId, $iAnswerIdOld, $iProfileId);
  29. $sText = bx_process_input(bx_get('text'));
  30. if(!$this->_oDb->doAnswer($iAnswerId, $iProfileId, $sText))
  31. return echoJson(array('code' => 3, 'msg' => _t('_bx_feedback_err_cannot_perform')));
  32. $this->onAddAnswer($iQuestionId, $iAnswerId, $iProfileId, array(
  33. 'text' => $sText
  34. ));
  35. return echoJson(array(
  36. 'code' => 0
  37. ));
  38. }
  39. public function serviceGetInfoAnswer ($iContentId)
  40. {
  41. $aAnswer = $this->_oDb->getAnswers(array('type' => 'id', 'id' => $iContentId));
  42. if(empty($aAnswer) || !is_array($aAnswer))
  43. return array();
  44. return $aAnswer;
  45. }
  46. public function serviceGetBlockQuestion()
  47. {
  48. $iProfileId = bx_get_logged_profile_id();
  49. if(!$iProfileId)
  50. return '';
  51. $aQuestion = $this->_oDb->getQuestions(array('type' => 'actual'));
  52. if(empty($aQuestion) || !is_array($aQuestion))
  53. return '';
  54. $aAnswers = $this->_oDb->getAnswers(array('type' => 'question_id_for_profile', 'question_id' => $aQuestion['id'], 'profile_id' => $iProfileId));
  55. if(empty($aAnswers) || !is_array($aAnswers))
  56. return '';
  57. return $this->_oTemplate->getBlockQuestion($aQuestion, $aAnswers);
  58. }
  59. /**
  60. * Integration methods.
  61. *
  62. * Integration: Timeline.
  63. */
  64. public function serviceGetTimelineData()
  65. {
  66. $sModule = $this->getName();
  67. return array(
  68. 'handlers' => array(
  69. array('group' => $sModule . '_question', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added_question', 'module_name' => $sModule, 'module_method' => 'get_timeline_question', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  70. array('group' => $sModule . '_question', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited_question'),
  71. array('group' => $sModule . '_question', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted_question'),
  72. array('group' => $sModule . '_answer', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added_answer', 'module_name' => $sModule, 'module_method' => 'get_timeline_answer', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  73. array('group' => $sModule . '_answer', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted_answer')
  74. ),
  75. 'alerts' => array(
  76. array('unit' => $sModule, 'action' => 'added_question'),
  77. array('unit' => $sModule, 'action' => 'edited_question'),
  78. array('unit' => $sModule, 'action' => 'deleted_question'),
  79. array('unit' => $sModule, 'action' => 'added_answer'),
  80. array('unit' => $sModule, 'action' => 'deleted_answer'),
  81. )
  82. );
  83. }
  84. public function serviceGetTimelineQuestion($aEvent, $aBrowseParams = array())
  85. {
  86. $aQuestion = $this->_oDb->getQuestions(array('type' => 'id', 'id' => $aEvent['object_id']));
  87. if(empty($aQuestion) || !is_array($aQuestion))
  88. return false;
  89. $CNF = &$this->_oConfig->CNF;
  90. if(($aQuestion[$CNF['FIELD_STATUS_ADMIN']] != 'active'))
  91. return false;
  92. $iUserId = $this->getUserId();
  93. $iAuthorId = (int)$aQuestion[$CNF['FIELD_AUTHOR']];
  94. $iAuthorIdAbs = abs($iAuthorId);
  95. if($iAuthorId < 0 && ((is_numeric($aEvent['owner_id']) && $iAuthorIdAbs == (int)$aEvent['owner_id']) || (is_array($aEvent['owner_id']) && in_array($iAuthorIdAbs, $aEvent['owner_id']))) && $iAuthorIdAbs != $iUserId)
  96. return false;
  97. //--- Title & Description
  98. $sTitle = !empty($aQuestion[$CNF['FIELD_TEXT']]) ? $aQuestion[$CNF['FIELD_TEXT']] : '';
  99. $iOwnerId = $iAuthorIdAbs;
  100. if(isset($aEvent['object_privacy_view']) && (int)$aEvent['object_privacy_view'] < 0)
  101. $iOwnerId = abs($aEvent['object_privacy_view']);
  102. $bCache = true;
  103. $aContent = $this->_getContentForTimelineQuestion($aEvent, $aQuestion, $aBrowseParams);
  104. if(isset($aContent['_cache'])) {
  105. $bCache = (bool)$aContent['_cache'];
  106. unset($aContent['_cache']);
  107. }
  108. return array(
  109. '_cache' => $bCache,
  110. 'owner_id' => $iOwnerId,
  111. 'object_owner_id' => $iOwnerId,
  112. 'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
  113. 'sample' => isset($CNF['T']['txt_sample_question_single_with_article']) ? $CNF['T']['txt_sample_question_single_with_article'] : $CNF['T']['txt_sample_single'],
  114. 'sample_wo_article' => $CNF['T']['txt_sample_question_single'],
  115. 'sample_action' => isset($CNF['T']['txt_sample_question_action']) ? $CNF['T']['txt_sample_question_action'] : '',
  116. 'url' => BX_DOL_URL_ROOT,
  117. 'content' => $aContent, //a string to display or array to parse default template before displaying.
  118. 'allowed_view' => array('module' => $this->getName(), 'method' => 'get_timeline_question_allowed_view'),
  119. 'date' => $aQuestion[$CNF['FIELD_ADDED']],
  120. 'title' => $sTitle, //may be empty.
  121. 'description' => '' //may be empty.
  122. );
  123. }
  124. public function serviceGetTimelineQuestionAllowedView($aEvent)
  125. {
  126. return CHECK_ACTION_RESULT_ALLOWED;
  127. }
  128. public function serviceGetTimelineAnswer($aEvent, $aBrowseParams = array())
  129. {
  130. $CNF = &$this->_oConfig->CNF;
  131. $iOwnerId = (int)$aEvent['owner_id'];
  132. $aAnswer = $this->_oDb->getAnswers(array('type' => 'id_for_profile', 'id' => $aEvent['object_id'], 'profile_id' => $iOwnerId));
  133. if(empty($aAnswer) || !is_array($aAnswer) || ($this->_oConfig->isModeNio() && (int)$aAnswer[$CNF['FIELD_ANS_IMPORTANT']] == 0))
  134. return false;
  135. $aQuestion = $this->_oDb->getQuestions(array('type' => 'id', 'id' => $aAnswer['question_id']));
  136. if(empty($aQuestion) || !is_array($aQuestion))
  137. return false;
  138. if(($aQuestion[$CNF['FIELD_STATUS_ADMIN']] != 'active'))
  139. return false;
  140. //--- Title & Description
  141. $sTitle = !empty($aAnswer[$CNF['FIELD_ANS2USR_TEXT']]) ? $aAnswer[$CNF['FIELD_ANS2USR_TEXT']] : '';
  142. $bCache = true;
  143. $aContent = $this->_getContentForTimelineAnswer($aEvent, $aQuestion, $aAnswer, $aBrowseParams);
  144. if(isset($aContent['_cache'])) {
  145. $bCache = (bool)$aContent['_cache'];
  146. unset($aContent['_cache']);
  147. }
  148. return array(
  149. '_cache' => $bCache,
  150. 'owner_id' => $iOwnerId,
  151. 'object_owner_id' => $iOwnerId,
  152. 'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
  153. 'sample' => isset($CNF['T']['txt_sample_answer_single_with_article']) ? $CNF['T']['txt_sample_answer_single_with_article'] : $CNF['T']['txt_sample_single'],
  154. 'sample_wo_article' => $CNF['T']['txt_sample_answer_single'],
  155. 'sample_action' => isset($CNF['T']['txt_sample_answer_action']) ? $CNF['T']['txt_sample_answer_action'] : '',
  156. 'url' => BX_DOL_URL_ROOT,
  157. 'content' => $aContent, //a string to display or array to parse default template before displaying.
  158. 'allowed_view' => array('module' => $this->getName(), 'method' => 'get_timeline_answer_allowed_view'),
  159. 'date' => $aAnswer[$CNF['FIELD_ADDED']],
  160. 'title' => $sTitle, //may be empty.
  161. 'description' => '' //may be empty.
  162. );
  163. }
  164. public function serviceGetTimelineAnswerAllowedView($aEvent)
  165. {
  166. return CHECK_ACTION_RESULT_ALLOWED;
  167. }
  168. /**
  169. * Integration: Notifications.
  170. */
  171. public function serviceGetNotificationsData()
  172. {
  173. $sModule = $this->getName();
  174. $aResult = array(
  175. 'handlers' => array(
  176. array('group' => $sModule . '_question', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added_question', 'module_name' => $sModule, 'module_method' => 'get_notifications_question', 'module_class' => 'Module', 'module_event_privacy' => ''),
  177. array('group' => $sModule . '_question', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited_question'),
  178. array('group' => $sModule . '_question', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted_question'),
  179. array('group' => $sModule . '_answer', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added_answer_notif', 'module_name' => $sModule, 'module_method' => 'get_notifications_answer', 'module_class' => 'Module', 'module_event_privacy' => ''),
  180. array('group' => $sModule . '_answer', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted_answer_notif'),
  181. ),
  182. 'settings' => array(
  183. array('group' => 'content', 'unit' => $sModule, 'action' => 'added_question', 'types' => array('follow_member')),
  184. array('group' => 'content', 'unit' => $sModule, 'action' => 'added_answer_notif', 'types' => array('follow_member'))
  185. ),
  186. 'alerts' => array(
  187. array('unit' => $sModule, 'action' => 'added_question'),
  188. array('unit' => $sModule, 'action' => 'edited_question'),
  189. array('unit' => $sModule, 'action' => 'deleted_question'),
  190. array('unit' => $sModule, 'action' => 'added_answer_notif'),
  191. array('unit' => $sModule, 'action' => 'deleted_answer_notif')
  192. )
  193. );
  194. return $aResult;
  195. }
  196. public function serviceGetNotificationsQuestion($aEvent)
  197. {
  198. $CNF = &$this->_oConfig->CNF;
  199. $aQuestion = $this->_oDb->getQuestions(array('type' => 'id', 'id' => $aEvent['object_id']));
  200. if(empty($aQuestion) || !is_array($aQuestion) || $aQuestion[$CNF['FIELD_STATUS_ADMIN']] != 'active')
  201. return array();
  202. $sEntryUrl = '{bx_url_root}';
  203. $sEntryCaption = strmaxtextlen($aQuestion[$CNF['FIELD_TEXT']], 20, '...');
  204. return array(
  205. 'entry_sample' => $CNF['T']['txt_sample_question_single'],
  206. 'entry_url' => $sEntryUrl,
  207. 'entry_caption' => $sEntryCaption,
  208. 'entry_author' => $aQuestion[$CNF['FIELD_AUTHOR']]
  209. );
  210. }
  211. public function serviceGetNotificationsAnswer($aEvent)
  212. {
  213. $CNF = &$this->_oConfig->CNF;
  214. $iOwnerId = (int)$aEvent['owner_id'];
  215. $oOwnerProfile = BxDolProfile::getInstance($iOwnerId);
  216. if(!$oOwnerProfile)
  217. return array();
  218. $aQuestion = $this->_oDb->getQuestions(array('type' => 'id', 'id' => $aEvent['object_id']));
  219. if(empty($aQuestion) || !is_array($aQuestion) || $aQuestion[$CNF['FIELD_STATUS_ADMIN']] != 'active')
  220. return array();
  221. $aAnswer = $this->_oDb->getAnswers(array('type' => 'id_for_profile', 'id' => $aEvent['subobject_id'], 'profile_id' => $iOwnerId));
  222. if(empty($aAnswer) || !is_array($aAnswer))
  223. return array();
  224. if($this->_oConfig->isModeNio() && (int)$aAnswer[$CNF['FIELD_ANS_IMPORTANT']] == 0)
  225. return array();
  226. $sEntryUrl = '{bx_url_root}';
  227. $sEntryCaption = strmaxtextlen($aQuestion[$CNF['FIELD_TEXT']], 20, '...');
  228. return array(
  229. 'entry_sample' => $CNF['T']['txt_sample_question_single'],
  230. 'entry_url' => $sEntryUrl,
  231. 'entry_caption' => $sEntryCaption,
  232. 'entry_author' => $aQuestion[$CNF['FIELD_AUTHOR']],
  233. 'subentry_sample' => $CNF['T']['txt_sample_answer_single'],
  234. 'subentry_url' => $oOwnerProfile->getUrl(),
  235. );
  236. }
  237. /**
  238. * Privacy methods.
  239. */
  240. public function serviceCheckAllowedWithContentForProfile($sAction, $iContentId, $iProfileId, $isPerformAction = false)
  241. {
  242. return CHECK_ACTION_RESULT_ALLOWED;
  243. }
  244. /**
  245. * Event handlers.
  246. */
  247. public function onAddQuestion($iId)
  248. {
  249. /**
  250. * @hooks
  251. * @hookdef hook-bx_feedback-added_question 'bx_feedback', 'added_question' - hook on new question added
  252. * - $unit_name - equals `bx_feedback`
  253. * - $action - equals `added_question`
  254. * - $object_id - question_id
  255. * - $sender_id - not used
  256. * @hook @ref hook-bx_feedback-added_question
  257. */
  258. bx_alert($this->getName(), 'added_question', $iId);
  259. }
  260. public function onEditQuestion($iId)
  261. {
  262. /**
  263. * @hooks
  264. * @hookdef hook-bx_feedback-edited_question 'bx_feedback', 'edited_question' - hook on new question edited
  265. * - $unit_name - equals `bx_feedback`
  266. * - $action - equals `edited_question`
  267. * - $object_id - question_id
  268. * - $sender_id - not used
  269. * @hook @ref hook-bx_feedback-edited_question
  270. */
  271. bx_alert($this->getName(), 'edited_question', $iId);
  272. }
  273. public function onDeleteQuestion($aQuestion)
  274. {
  275. $CNF = &$this->_oConfig->CNF;
  276. $oLanguage = BxDolStudioLanguagesUtils::getInstance();
  277. $oLanguage->deleteLanguageString($aQuestion[$CNF['FIELD_TEXT']]);
  278. $aAnswers = $this->_oDb->getAnswers(array('type' => 'question_id', 'question_id' => $aQuestion[$CNF['FIELD_ID']]));
  279. if(!empty($aAnswers) && is_array($aAnswers))
  280. foreach($aAnswers as $aAnswer) {
  281. $oLanguage->deleteLanguageString($aAnswer[$CNF['FIELD_ANS_TITLE']]);
  282. $this->_oDb->deleteAnswer(array('id' => $aAnswer[$CNF['FIELD_ANS_ID']]));
  283. $this->_oDb->deleteAnswer2User(array('answer_id' => $aAnswer[$CNF['FIELD_ANS_ID']]));
  284. }
  285. /**
  286. * @hooks
  287. * @hookdef hook-bx_feedback-deleted_question 'bx_feedback', 'deleted_question' - hook on question deleted
  288. * - $unit_name - equals `bx_feedback`
  289. * - $action - equals `deleted_question`
  290. * - $object_id - question_id
  291. * - $sender_id - not used
  292. * - $extra_params - array of additional params with the following array keys:
  293. * - `question` - [array] all question info
  294. * - `answers` - [array] answers for current question
  295. * @hook @ref hook-bx_feedback-deleted_question
  296. */
  297. bx_alert($this->getName(), 'deleted_question', $aQuestion[$CNF['FIELD_ID']], false, array(
  298. 'question' => $aQuestion,
  299. 'answers' => $aAnswers,
  300. ));
  301. }
  302. public function onAddAnswer($iQuestionId, $iAnswerId, $iProfileId = false, $aParams = array())
  303. {
  304. $CNF = &$this->_oConfig->CNF;
  305. $sModule = $this->getName();
  306. $aAnswer = $this->_oDb->getAnswers(array('type' => 'id', 'id' => $iAnswerId));
  307. /**
  308. * @hooks
  309. * @hookdef hook-bx_feedback-added_answer 'bx_feedback', 'added_answer' - hook on new answer added
  310. * - $unit_name - equals `bx_feedback`
  311. * - $action - equals `added_answer`
  312. * - $object_id - answer id
  313. * - $sender_id - current user profile_id
  314. * - $extra_params - array of additional params with the following array keys:
  315. * - `object_author_id` - [int] current user profile_id
  316. * - `question_id` - [int] question id
  317. * - `important` - [string] answer's important value
  318. * - `data` - [string] answer's content
  319. * - `votes` - [int] count of votes
  320. * @hook @ref hook-bx_feedback-added_answer
  321. */
  322. bx_alert($sModule, 'added_answer', $iAnswerId, $iProfileId, array_merge(array(
  323. 'object_author_id' => $iProfileId,
  324. 'question_id' => $iQuestionId,
  325. 'important' => $aAnswer['important'],
  326. 'data' => $aAnswer['data'],
  327. 'votes' => $aAnswer['votes']
  328. ), $aParams));
  329. /**
  330. * @hooks
  331. * @hookdef hook-bx_feedback-added_answer_notif 'bx_feedback', 'added_answer_notif' - hook on new answer added
  332. * - $unit_name - equals `bx_feedback`
  333. * - $action - equals `added_answer_notif`
  334. * - $object_id - question_id
  335. * - $sender_id - current user profile_id
  336. * - $extra_params - array of additional params with the following array keys:
  337. * - `object_author_id` - [int] current user profile_id
  338. * - `subobject_id` - [int] answer id
  339. * - `important` - [string] answer's important value
  340. * - `data` - [string] answer's content
  341. * - `votes` - [int] count of votes
  342. * @hook @ref hook-bx_feedback-added_answer_notif
  343. */
  344. bx_alert($sModule, 'added_answer_notif', $iQuestionId, $iProfileId, array_merge(array(
  345. 'object_author_id' => $iProfileId,
  346. 'subobject_id' => $iAnswerId,
  347. 'important' => $aAnswer['important'],
  348. 'data' => $aAnswer['data'],
  349. 'votes' => $aAnswer['votes']
  350. ), $aParams));
  351. }
  352. public function onDeleteAnswer($iQuestionId, $iAnswerId, $iProfileId = false, $aParams = array())
  353. {
  354. $CNF = &$this->_oConfig->CNF;
  355. $sModule = $this->getName();
  356. $aAnswer = $this->_oDb->getAnswers(array('type' => 'id', 'id' => $iAnswerId));
  357. /**
  358. * @hooks
  359. * @hookdef hook-bx_feedback-deleted_answer 'bx_feedback', 'deleted_answer' - hook on new answer deleted
  360. * - $unit_name - equals `bx_feedback`
  361. * - $action - equals `deleted_answer`
  362. * - $object_id - answer id
  363. * - $sender_id - current user profile_id
  364. * - $extra_params - array of additional params with the following array keys:
  365. * - `question_id` - [int] question id
  366. * - `important` - [string] answer's important value
  367. * - `data` - [string] answer's content
  368. * - `votes` - [int] count of votes
  369. * @hook @ref hook-bx_feedback-deleted_answer
  370. */
  371. bx_alert($sModule, 'deleted_answer', $iAnswerId, $iProfileId, array_merge(array(
  372. 'question_id' => $iQuestionId,
  373. 'important' => $aAnswer['important'],
  374. 'data' => $aAnswer['data'],
  375. 'votes' => $aAnswer['votes']
  376. ), $aParams));
  377. /**
  378. * @hooks
  379. * @hookdef hook-bx_feedback-deleted_answer_notif 'bx_feedback', 'added_answer_notif' - hook on new answer deleted
  380. * - $unit_name - equals `bx_feedback`
  381. * - $action - equals `added_answer_notif`
  382. * - $object_id - question_id
  383. * - $sender_id - current user profile_id
  384. * - $extra_params - array of additional params with the following array keys:
  385. * - `subobject_id` - [int] answer id
  386. * - `important` - [string] answer's important value
  387. * - `data` - [string] answer's content
  388. * - `votes` - [int] count of votes
  389. * @hook @ref hook-bx_feedback-added_answer_notif
  390. */
  391. bx_alert($sModule, 'deleted_answer_notif', $iQuestionId, $iProfileId, array_merge(array(
  392. 'subobject_id' => $iAnswerId,
  393. 'important' => $aAnswer['important'],
  394. 'data' => $aAnswer['data'],
  395. 'votes' => $aAnswer['votes']
  396. ), $aParams));
  397. }
  398. /**
  399. * Internal methods
  400. */
  401. protected function _getContentForTimelineQuestion($aEvent, $aQuestion, $aBrowseParams = array())
  402. {
  403. $CNF = &$this->_oConfig->CNF;
  404. $sUrl = BX_DOL_URL_ROOT;
  405. //--- Title
  406. $sTitle = strmaxtextlen(_t($aQuestion[$CNF['FIELD_TEXT']]), 20, '...');
  407. return array(
  408. 'sample' => isset($CNF['T']['txt_sample_question_single_with_article']) ? $CNF['T']['txt_sample_question_single_with_article'] : $CNF['T']['txt_sample_question_single'],
  409. 'sample_wo_article' => $CNF['T']['txt_sample_question_single'],
  410. 'sample_action' => isset($CNF['T']['txt_sample_question_action']) ? $CNF['T']['txt_sample_question_action'] : '',
  411. 'url' => $sUrl,
  412. 'title' => $sTitle,
  413. 'text' => '',
  414. 'images' => array(),
  415. 'images_attach' => array(),
  416. 'videos' => array(),
  417. 'videos_attach' => array(),
  418. 'files' => array(),
  419. 'files_attach' => array()
  420. );
  421. }
  422. protected function _getContentForTimelineAnswer($aEvent, $aQuestion, $aAnswer, $aBrowseParams = array())
  423. {
  424. $CNF = &$this->_oConfig->CNF;
  425. $oOwnerProfile = BxDolProfile::getInstance((int)$aEvent['owner_id']);
  426. $sUrl = BX_DOL_URL_ROOT;
  427. if($oOwnerProfile)
  428. $sUrl = $oOwnerProfile->getUrl();
  429. //--- Title
  430. $sTitle = strmaxtextlen(_t($aQuestion[$CNF['FIELD_TEXT']]), 20, '...');
  431. $sTextKey = '_bx_feedback_txt_answer_format' . (empty($aAnswer[$CNF['FIELD_ANS2USR_TEXT']]) ? '_wo_comment' : '');
  432. $sText = _t($sTextKey, _t($aAnswer[$CNF['FIELD_ANS_TITLE']]), $aAnswer[$CNF['FIELD_ANS2USR_TEXT']]);
  433. return array(
  434. 'sample' => isset($CNF['T']['txt_sample_answer_single_with_article']) ? $CNF['T']['txt_sample_answer_single_with_article'] : $CNF['T']['txt_sample_answer_single'],
  435. 'sample_wo_article' => $CNF['T']['txt_sample_answer_single'],
  436. 'sample_action' => isset($CNF['T']['txt_sample_answer_action']) ? $CNF['T']['txt_sample_answer_action'] : '',
  437. 'url' => $sUrl,
  438. 'title' => $sTitle,
  439. 'text' => $sText,
  440. 'images' => array(),
  441. 'images_attach' => array(),
  442. 'videos' => array(),
  443. 'videos_attach' => array(),
  444. 'files' => array(),
  445. 'files_attach' => array()
  446. );
  447. }
  448. }
  449. /** @} */