BxTasksModule.php 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  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. * @defgroup Tasks Tasks
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. /**
  11. * Task states
  12. */
  13. define('BX_TASKS_STATE_BACBLOG', 1);
  14. define('BX_TASKS_STATE_TODO', 2);
  15. define('BX_TASKS_STATE_IN_PROGRESS', 3);
  16. define('BX_TASKS_STATE_IN_REVIEW', 4);
  17. define('BX_TASKS_STATE_CANCELLED', 5);
  18. define('BX_TASKS_STATE_DUPLICATE', 6);
  19. define('BX_TASKS_STATE_DONE', 7);
  20. class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
  21. {
  22. function __construct(&$aModule)
  23. {
  24. parent::__construct($aModule);
  25. $CNF = &$this->_oConfig->CNF;
  26. $this->_aSearchableNamesExcept = array_merge($this->_aSearchableNamesExcept, array(
  27. $CNF['FIELD_PUBLISHED'],
  28. $CNF['FIELD_ALLOW_COMMENTS']
  29. ));
  30. }
  31. /**
  32. * Action methods
  33. */
  34. /**
  35. * Get possible recipients for start conversation form
  36. */
  37. public function actionAjaxGetInitialMembers($iContextPid)
  38. {
  39. $sTerm = bx_get('term');
  40. $sModule = $this->_oConfig->getName();
  41. $a = bx_srv('system', 'profiles_search', [$sTerm, [
  42. 'module' => $sModule,
  43. 'search_params' => ['name' => $sModule . '_initial_members', 'context_pid' => $iContextPid]
  44. ]], 'TemplServiceProfiles');
  45. header('Content-Type:text/javascript; charset=utf-8');
  46. echo(json_encode($a));
  47. }
  48. public function actionSetCompleted($iContentId, $iCompleted)
  49. {
  50. if(!$this->isAllowManage($iContentId) || !$this->complete($iContentId, $iCompleted))
  51. return echoJson(['code' => 1]);
  52. return echoJson(['code' => 0, 'reload' => 1]);
  53. }
  54. public function actionApplyFilter($iContextId, $iFilterId)
  55. {
  56. $CNF = &$this->_oConfig->CNF;
  57. $sCookieKey = $CNF['COOKIE_SETTING_KEY'];
  58. $aFilters = [];
  59. if(isset($_COOKIE[$sCookieKey]))
  60. $aFilters = json_decode($_COOKIE[$sCookieKey], true);
  61. if(($iFilterId = (int)$iFilterId) != 0)
  62. $aFilters[$iContextId] = $iFilterId;
  63. else
  64. unset($aFilters[$iContextId]);
  65. bx_setcookie($sCookieKey, json_encode($aFilters), time() + 60 * 60 * 24 * 365);
  66. return echoJson([
  67. 'content' => $this->_oTemplate->getEntries($iContextId, ['filter' => $iFilterId]),
  68. 'eval' => $this->_oConfig->getJsObject('tasks') . '.onApplyFilter(oData)'
  69. ]);
  70. }
  71. public function actionProcessContextForm($iContextId)
  72. {
  73. $_iContextId = abs($iContextId);
  74. if(!$this->isAllowManageByContext($_iContextId))
  75. return;
  76. $CNF = &$this->_oConfig->CNF;
  77. $aContext = $this->_oDb->getContexts(['sample' => 'id', 'id' => $_iContextId]);
  78. $bContext = !empty($aContext) && is_array($aContext);
  79. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_CONTEXT'], $CNF['OBJECT_FORM_CONTEXT_DISPLAY_EDIT']);
  80. $oForm->setAction(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'process_context_form/' . $iContextId . '/');
  81. $oForm->initChecker($aContext);
  82. if($oForm->isSubmittedAndValid()) {
  83. if(!$bContext)
  84. $oForm->insert(['id' => $_iContextId]);
  85. else
  86. $oForm->update($_iContextId);
  87. echoJson([
  88. 'eval' => $this->_oConfig->getJsObject('tasks') . '.hidePopup(oData, ' . $iContextId . ')',
  89. ]);
  90. }
  91. else {
  92. $sContent = $this->_oTemplate->parseHtmlByName('popup_form.html', [
  93. 'form_id' => $oForm->getId(),
  94. 'form' => $oForm->getCode(true)
  95. ]);
  96. if($oForm->isSubmitted())
  97. return echoJson([
  98. 'form' => $sContent,
  99. 'form_id' => $oForm->getId()
  100. ]);
  101. echo $sContent;
  102. }
  103. }
  104. public function actionProcessTaskListForm($iContextId, $iId)
  105. {
  106. if (!$this->isAllowAdd(abs($iContextId)))
  107. return;
  108. $CNF = &$this->_oConfig->CNF;
  109. $oForm = null;
  110. $sPopupTitle = "";
  111. $aContentInfo = array();
  112. if ($iId == 0){
  113. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_LIST_ENTRY'], $CNF['OBJECT_FORM_LIST_ENTRY_DISPLAY_ADD']);
  114. $sPopupTitle = _t('_bx_tasks_form_list_entry_display_add');
  115. }
  116. else {
  117. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_LIST_ENTRY'], $CNF['OBJECT_FORM_LIST_ENTRY_DISPLAY_EDIT']);
  118. $aContentInfo = $this->_oDb->getList($iId);
  119. $sPopupTitle = _t('_bx_tasks_form_list_entry_display_edit');
  120. }
  121. $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'process_task_list_form/' . $iContextId . '/' . $iId . '/';
  122. if (!$oForm)
  123. return '';
  124. $oForm->initChecker($aContentInfo, array());
  125. if($oForm->isSubmittedAndValid()) {
  126. if ($iId == 0){
  127. $aValsToAdd['context_id'] = $iContextId;
  128. $iId = $oForm->insert($aValsToAdd);
  129. }
  130. else {
  131. $iId = $oForm->update($iId);
  132. }
  133. return echoJson(array(
  134. 'eval' => $this->_oConfig->getJsObject('tasks') . '.reloadData(oData, ' . $iContextId . ')',
  135. ));
  136. }
  137. else {
  138. $sContent = $this->_oTemplate->parseHtmlByName('popup_form.html', array(
  139. 'form_id' => $oForm->getId(),
  140. 'form' => $oForm->getCode(true)
  141. ));
  142. if (!$oForm->isSubmitted()) {
  143. echo $sContent;
  144. return;
  145. }
  146. return echoJson(array('form' => $sContent, 'form_id' => $oForm->getId()));
  147. }
  148. }
  149. public function actionDeleteTaskList($iId, $iContextId)
  150. {
  151. if (!$this->isAllowManageByContext($iContextId))
  152. return;
  153. $CNF = &$this->_oConfig->CNF;
  154. $aTasks = $this->_oDb->getTasks($iContextId, $iId);
  155. $this->_oDb->deleteList($iId);
  156. if (!empty($aTasks) && ($oConn = BxDolConnection::getObjectInstance($this->_oConfig->CNF['OBJECT_CONNECTION']))) {
  157. foreach ($aTasks as &$aTask)
  158. $oConn->onDeleteContent($aTask[$CNF['FIELD_ID']]);
  159. }
  160. echoJson(array(
  161. 'context_id' => $iContextId,
  162. ));
  163. }
  164. public function actionProcessTaskForm($iContextId, $iListId)
  165. {
  166. $_iContextId = abs($iContextId);
  167. if(!$this->isAllowAdd($_iContextId))
  168. return echoJson([]);
  169. $CNF = &$this->_oConfig->CNF;
  170. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);
  171. if(!$oForm)
  172. return echoJson([]);
  173. $oForm->setAction(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'process_task_form/' . $iContextId . '/' . $iListId . '/');
  174. $oForm->setContextId($_iContextId);
  175. $oForm->initChecker();
  176. if($oForm->isSubmittedAndValid()) {
  177. $iContentId = $oForm->insert([$CNF['FIELD_ALLOW_VIEW_TO'] => $iContextId, $CNF['FIELD_TASKLIST'] => $iListId]);
  178. if($iContentId)
  179. $this->onPublished($iContentId);
  180. return echoJson([
  181. 'eval' => $this->_oConfig->getJsObject('tasks') . '.reloadData(oData, ' . $iContextId . ')',
  182. ]);
  183. }
  184. else {
  185. $sContent = $this->_oTemplate->parseHtmlByName('popup_form.html', [
  186. 'form_id' => $oForm->getId(),
  187. 'form' => $oForm->getCode(true)
  188. ]);
  189. if($oForm->isSubmitted())
  190. return echoJson(['form' => $sContent, 'form_id' => $oForm->getId()]);
  191. echo $sContent;
  192. }
  193. }
  194. public function actionProcessTaskFormEditProperty($iContentId, $sProperty)
  195. {
  196. $CNF = &$this->_oConfig->CNF;
  197. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  198. if(!$this->isAllowAdd(abs($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']])))
  199. return '';
  200. $sForm = '';
  201. if(($sKey = 'OBJECT_FORM_ENTRY_DISPLAY_EDIT_' . strtoupper($sProperty)) && !empty($CNF[$sKey]))
  202. $sForm = $CNF[$sKey];
  203. else
  204. return '';
  205. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sForm);
  206. $oForm->setId($sForm);
  207. $oForm->setName($sForm);
  208. $oForm->setAction(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'process_task_form_edit_property/' . $iContentId . '/' . $sProperty . '/');
  209. if(!$oForm)
  210. return '';
  211. $oForm->initChecker($aContentInfo);
  212. if($oForm->isSubmittedAndValid()) {
  213. if(!$oForm->update($iContentId))
  214. return echoJson(['msg' => _t('_bx_tasks_txt_err_cannot_perform_action')]);
  215. if(($sMethod = '_onEdit' . bx_gen_method_name($sProperty)) && method_exists($this, $sMethod))
  216. $this->$sMethod($aContentInfo, $oForm);
  217. else
  218. $this->_onEditProperty($aContentInfo, $sProperty, $oForm);
  219. return echoJson([
  220. 'eval' => $this->_oConfig->getJsObject('tasks') . '.reload(oData)',
  221. ]);
  222. }
  223. else {
  224. $sContent = $this->_oTemplate->parseHtmlByName('popup_form.html', [
  225. 'form_id' => $oForm->getId(),
  226. 'form' => $oForm->getCode(true)
  227. ]);
  228. if (!$oForm->isSubmitted()) {
  229. echo $sContent;
  230. return;
  231. }
  232. return echoJson(['form' => $sContent, 'form_id' => $oForm->getId()]);
  233. }
  234. }
  235. public function actionCalendarData()
  236. {
  237. // check permissions
  238. $aSQLPart = array();
  239. $iContextId = (int)bx_get('context_id');
  240. if(!$this->isAllowView($iContextId))
  241. return;
  242. $oPrivacy = BxDolPrivacy::getObjectInstance($this->_oConfig->CNF['OBJECT_PRIVACY_VIEW']);
  243. if($iContextId) {
  244. $aSQLPart = $oPrivacy ? $oPrivacy->getContentByGroupAsSQLPart(- $iContextId) : array();
  245. }
  246. // get entries
  247. $aEntries = $this->_oDb->getEntriesByDate(bx_get('start'), bx_get('end'), bx_get('event'), $aSQLPart);
  248. header('Content-Type: application/json; charset=utf-8');
  249. echo json_encode($aEntries);
  250. }
  251. public function actionProcessTimer($sAction, $iContentId, $iProfileId)
  252. {
  253. if(!$this->_iProfileId || $this->_iProfileId != $iProfileId)
  254. return echoJson(['msg' => _t('_sys_txt_access_denied')]);
  255. $aResult = $this->serviceProcessTimer($sAction, $iContentId, $iProfileId);
  256. if($aResult['code'] == 0)
  257. $aResult = array_merge($aResult, [
  258. 'content_id' => $iContentId,
  259. 'profile_id' => $iProfileId,
  260. 'content' => $this->_oTemplate->getTimer($iContentId, $iProfileId),
  261. 'eval' => $this->_oConfig->getJsObject('timer') . '.onPerformAction' . bx_gen_method_name($sAction) . '(oData)'
  262. ]);
  263. return echoJson($aResult);
  264. }
  265. public function serviceGetSafeServices()
  266. {
  267. return array_merge(parent::serviceGetSafeServices(), [
  268. 'ProcessTimer' => '',
  269. ]);
  270. }
  271. public function serviceProcessTimer($sAction, $iContentId, $iProfileId)
  272. {
  273. $CNF = &$this->_oConfig->CNF;
  274. $aResult = ['code' => 1, 'msg' => _t('_sys_txt_error_occured')];
  275. $iNow = time();
  276. switch($sAction) {
  277. case 'start':
  278. $this->stopTimerByAuthor($iProfileId);
  279. $iTimer = false;
  280. $aTimer = $this->getTimer($iContentId, $iProfileId);
  281. if($aTimer && is_array($aTimer)) {
  282. if($this->updateTimerById($aTimer['id'], ['started' => $iNow]))
  283. $iTimer = $aTimer['id'];
  284. }
  285. else
  286. $iTimer = $this->_oDb->insertTimer(['content_id' => $iContentId, 'profile_id' => $iProfileId, 'started' => $iNow]);
  287. if($iTimer !== false)
  288. $aResult = ['code' => 0, 'id' => $iTimer];
  289. break;
  290. case 'stop':
  291. if($this->stopTimerByAuthor($iProfileId))
  292. $aResult = ['code' => 0];
  293. break;
  294. case 'resume':
  295. $this->stopTimerByAuthor($iProfileId);
  296. $aTimer = $this->getTimer($iContentId, $iProfileId);
  297. if($aTimer && is_array($aTimer) && $this->updateTimerById($aTimer['id'], ['started' => $iNow]))
  298. $aResult = ['code' => 0];
  299. break;
  300. case 'reload':
  301. $aTimer = $this->getTimer($iContentId, $iProfileId);
  302. $aResult = [
  303. 'code' => 0,
  304. 'started' => $aTimer && ($aTimer['started'] ?? 0) != 0
  305. ];
  306. break;
  307. case 'log':
  308. $aTimer = $this->getTimer($iContentId, $iProfileId);
  309. if(!$aTimer || !is_array($aTimer) || !$aTimer['duration'])
  310. break;
  311. list($iH, $iM) = $this->_oConfig->timeI2A($aTimer['duration'], true);
  312. $iNow = time();
  313. $iTrackId = $this->_oDb->insertTimeTrack([
  314. 'object_id' => $iContentId,
  315. 'author_id' => $iProfileId,
  316. 'author_nip' => $iProfileId == $this->_iProfileId ? bx_get_ip_hash(getVisitorIP()) : 0,
  317. 'value' => $this->_oConfig->timeA2I([(int)$iH, (int)$iM + 1]),
  318. 'value_date' => $iNow,
  319. 'date' => $iNow
  320. ]);
  321. if(!$iTrackId)
  322. break;
  323. $oTime = BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS_TIME'], $iContentId);
  324. if(!$oTime || !$oTime->isEnabled())
  325. break;
  326. if(!$oTime->putReport($iContentId, $iProfileId, $iTrackId))
  327. break;
  328. $this->_oDb->deleteTimer([
  329. 'content_id' => $iContentId,
  330. 'profile_id' => $iProfileId
  331. ]);
  332. $aResult = ['code' => 0];
  333. break;
  334. case 'clear':
  335. if($this->_oDb->deleteTimer(['content_id' => $iContentId, 'profile_id' => $iProfileId]) !== false)
  336. $aResult = ['code' => 0];
  337. break;
  338. }
  339. return $aResult;
  340. }
  341. public function serviceManageTools($sType = 'common')
  342. {
  343. $CNF = &$this->_oConfig->CNF;
  344. $mixedResults = '';
  345. if(!($mixedResults = parent::serviceManageTools($sType)))
  346. return $mixedResults;
  347. return array_merge(parent::serviceManageTools($sType), [
  348. 'menu' => BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_MANAGE_TOOLS_SUBMENU'])
  349. ]);
  350. }
  351. public function serviceGetBlockMenuBrowse()
  352. {
  353. return $this->_oTemplate->getBlockMenuBrowse();
  354. }
  355. public function serviceGetBlockMenuContext($iProfileId)
  356. {
  357. $CNF = &$this->_oConfig->CNF;
  358. if(!$this->isAllowView($iProfileId))
  359. return '';
  360. $oMenu = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SUBMENU_VIEW_CONTEXT']);
  361. if(!$oMenu)
  362. return '';
  363. $oMenu->addMarkers(['profile_id' => $iProfileId]);
  364. return $oMenu->getCode();
  365. }
  366. public function serviceGetBlockManageTime($sType = 'common', $iContextPid = 0)
  367. {
  368. $CNF = &$this->_oConfig->CNF;
  369. $bContextPid = !empty($iContextPid);
  370. $sGrid = $CNF['OBJECT_GRID_TIME_' . ($bContextPid ? 'CONTEXT_' : '') . strtoupper($sType)];
  371. $oGrid = BxDolGrid::getObjectInstance($sGrid);
  372. if(!$oGrid)
  373. return $this->_bIsApi ? [] : '';
  374. if($bContextPid)
  375. $oGrid->setContextPid($iContextPid);
  376. if($this->_bIsApi)
  377. return [
  378. bx_api_get_block('grid', $oGrid->getCodeAPI())
  379. ];
  380. list($aCssCalendar, $aJsCalendar) = BxBaseFormView::getCssJsCalendar();
  381. $this->_oTemplate->addCss(array_merge($aCssCalendar, ['manage_tools.css', 'time.css']));
  382. $this->_oTemplate->addJs(array_merge($aJsCalendar, ['modules/base/text/js/|manage_tools.js', 'time.js']));
  383. $this->_oTemplate->addJsTranslation(['_sys_grid_search']);
  384. $aResult = [
  385. 'content' => $this->_oTemplate->getJsCode('time', [
  386. 'sObjNameGrid' => $sGrid
  387. ]) . $oGrid->getCode()
  388. ];
  389. if(!$bContextPid)
  390. $aResult['menu'] = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_MANAGE_TOOLS_SUBMENU']);
  391. return $aResult;
  392. }
  393. public function serviceGetBlockTimers()
  394. {
  395. $CNF = &$this->_oConfig->CNF;
  396. return [
  397. 'content' => $this->_oTemplate->getBlockTimers($this->_iProfileId),
  398. 'menu' => BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_MANAGE_TOOLS_SUBMENU'])
  399. ];
  400. }
  401. /**
  402. * Data for Timeline module
  403. */
  404. public function serviceGetTimelineData()
  405. {
  406. $sModule = $this->_aModule['name'];
  407. return array(
  408. 'handlers' => array(
  409. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added', 'module_name' => $sModule, 'module_method' => 'get_timeline_post', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  410. array('group' => $sModule . '_completed', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'completed', 'module_name' => $sModule, 'module_method' => 'get_timeline_completed', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  411. array('group' => $sModule . '_reopened', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'reopened', 'module_name' => $sModule, 'module_method' => 'get_timeline_reopened', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  412. array('group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited'),
  413. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted'),
  414. ),
  415. 'alerts' => array(
  416. array('unit' => $sModule, 'action' => 'added'),
  417. array('unit' => $sModule, 'action' => 'completed'),
  418. array('unit' => $sModule, 'action' => 'reopened'),
  419. array('unit' => $sModule, 'action' => 'edited'),
  420. array('unit' => $sModule, 'action' => 'deleted'),
  421. )
  422. );
  423. }
  424. /**
  425. * Entry task for Timeline module
  426. */
  427. public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
  428. {
  429. $CNF = &$this->_oConfig->CNF;
  430. $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
  431. if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
  432. return $aResult;
  433. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  434. if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
  435. $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
  436. return $aResult;
  437. }
  438. public function serviceGetTimelineCompleted($aEvent, $aBrowseParams = array())
  439. {
  440. $CNF = &$this->_oConfig->CNF;
  441. $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
  442. if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
  443. return $aResult;
  444. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  445. if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
  446. $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
  447. $aResult['sample_action'] = $aResult['content']['sample_action'] = _t('_bx_tasks_txt_action_completed');
  448. return $aResult;
  449. }
  450. public function serviceGetTimelineReopened($aEvent, $aBrowseParams = array())
  451. {
  452. $CNF = &$this->_oConfig->CNF;
  453. $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
  454. if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
  455. return $aResult;
  456. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  457. if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
  458. $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
  459. $aResult['sample_action'] = $aResult['content']['sample_action'] = _t('_bx_tasks_txt_action_reopened');
  460. return $aResult;
  461. }
  462. public function serviceGetNotificationsData()
  463. {
  464. $sModule = $this->_aModule['name'];
  465. $sEventPrivacy = $sModule . '_allow_view_event_to';
  466. if(BxDolPrivacy::getObjectInstance($sEventPrivacy) === false)
  467. $sEventPrivacy = '';
  468. $aResult = parent::serviceGetNotificationsData();
  469. $aResult['handlers'] = array_merge($aResult['handlers'], array(
  470. array('group' => $sModule . '_completed', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'completed', 'module_name' => $sModule, 'module_method' => 'get_notifications_completed', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  471. array('group' => $sModule . '_reopened', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'reopened', 'module_name' => $sModule, 'module_method' => 'get_notifications_reopened', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  472. array('group' => $sModule . '_expired', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'expired', 'module_name' => $sModule, 'module_method' => 'get_notifications_expired', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  473. array('group' => $sModule . '_assign', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'assigned', 'module_name' => $sModule, 'module_method' => 'get_notifications_assigned', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  474. array('group' => $sModule . '_assign', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'unassigned'),
  475. ));
  476. $aResult['settings'] = array_merge($aResult['settings'], array(
  477. array('group' => 'content', 'unit' => $sModule, 'action' => 'completed', 'types' => array('personal', 'follow_member', 'follow_context')),
  478. array('group' => 'content', 'unit' => $sModule, 'action' => 'reopened', 'types' => array('personal', 'follow_member', 'follow_context')),
  479. array('group' => 'content', 'unit' => $sModule, 'action' => 'expired', 'types' => array('personal')),
  480. array('group' => 'content', 'unit' => $sModule, 'action' => 'assigned', 'types' => array('personal')),
  481. ));
  482. $aResult['alerts'] = array_merge($aResult['alerts'], array(
  483. array('unit' => $sModule, 'action' => 'completed'),
  484. array('unit' => $sModule, 'action' => 'reopened'),
  485. array('unit' => $sModule, 'action' => 'expired'),
  486. array('unit' => $sModule, 'action' => 'assigned'),
  487. array('unit' => $sModule, 'action' => 'unassigned'),
  488. ));
  489. return $aResult;
  490. }
  491. public function serviceGetNotificationsCompleted($aEvent)
  492. {
  493. return $this->_serviceGetNotificationsByAction($aEvent, 'completed');
  494. }
  495. public function serviceGetNotificationsReopened($aEvent)
  496. {
  497. return $this->_serviceGetNotificationsByAction($aEvent, 'reopened');
  498. }
  499. public function serviceGetNotificationsExpired($aEvent)
  500. {
  501. return $this->_serviceGetNotificationsByAction($aEvent, 'expired');
  502. }
  503. public function serviceGetNotificationsAssigned($aEvent)
  504. {
  505. return $this->_serviceGetNotificationsByAction($aEvent, 'assigned');
  506. }
  507. protected function _serviceGetNotificationsByAction($aEvent, $sAction)
  508. {
  509. $CNF = &$this->_oConfig->CNF;
  510. $aResult = parent::serviceGetNotificationsPost($aEvent);
  511. if(empty($aResult) || !is_array($aResult))
  512. return $aResult;
  513. $aResult['entry_author'] = $aEvent['object_owner_id'];
  514. $aResult['entry_author_name'] = '';
  515. if(($oAuthor = BxDolProfile::getInstance($aResult['entry_author'])) !== false)
  516. $aResult['entry_author_name'] = $oAuthor->getDisplayName();
  517. $sLangKey = '_bx_tasks_txt_notification_' . $sAction;
  518. if((int)$aEvent['object_privacy_view'] < 0)
  519. $sLangKey .= '_in_context';
  520. $aResult['lang_key'] = _t($sLangKey);
  521. return $aResult;
  522. }
  523. public function serviceCheckAllowedManageInContext($iContextPid)
  524. {
  525. if(!$this->isAllowManageByContext($iContextPid))
  526. return false;
  527. return true;
  528. }
  529. public function serviceCheckAllowedManage($iContentId)
  530. {
  531. if(!$this->isAllowManage($iContentId))
  532. return false;
  533. return true;
  534. }
  535. public function serviceCheckAllowedComplete($iContentId)
  536. {
  537. if(!$this->serviceCheckAllowedManage($iContentId))
  538. return false;
  539. return !$this->isCompleted($iContentId);
  540. }
  541. public function serviceCheckAllowedUncomplete($iContentId)
  542. {
  543. if(!$this->serviceCheckAllowedManage($iContentId))
  544. return false;
  545. return $this->isCompleted($iContentId);
  546. }
  547. public function serviceIsCompleted($iContentId)
  548. {
  549. return $this->isCompleted($iContentId);
  550. }
  551. public function serviceIsUncompleted($iContentId)
  552. {
  553. return !$this->isCompleted($iContentId);
  554. }
  555. public function serviceIsAllowBadges($iContentId)
  556. {
  557. if (!$this->isAllowManage($iContentId))
  558. return false;
  559. if (!$this->serviceIsBadgesAvaliable())
  560. return false;
  561. return true;
  562. }
  563. public function serviceEntityAssignments($iContentId = 0, $bAsArray = false)
  564. {
  565. if(!$iContentId)
  566. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  567. if(!$iContentId)
  568. return false;
  569. $CNF = &$this->_oConfig->CNF;
  570. $aProfiles = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION'])->getConnectedInitiators($iContentId);
  571. if($bAsArray)
  572. return $aProfiles;
  573. return $this->_oTemplate->entryAssignments($aProfiles);
  574. }
  575. public function serviceEntityTimer($iContentId = 0)
  576. {
  577. if(!$iContentId)
  578. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  579. if(!$iContentId)
  580. return false;
  581. return $this->_oTemplate->entryTimer($iContentId, $this->_iProfileId);
  582. }
  583. public function serviceCheckAllowedCommentsTask($iContentId, $sObjectComments)
  584. {
  585. $CNF = &$this->_oConfig->CNF;
  586. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  587. if($aContentInfo[$CNF['FIELD_ALLOW_COMMENTS']] == 0)
  588. return false;
  589. return parent::serviceCheckAllowedCommentsTask($iContentId, $sObjectComments);
  590. }
  591. public function serviceCheckAllowedCommentsView($iContentId, $sObjectComments)
  592. {
  593. $CNF = &$this->_oConfig->CNF;
  594. //negative id used in comments for reports
  595. if($iContentId < 0)
  596. return CHECK_ACTION_RESULT_ALLOWED;
  597. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  598. if($aContentInfo[$CNF['FIELD_ALLOW_COMMENTS']] == 0)
  599. return false;
  600. return parent::serviceCheckAllowedCommentsView($iContentId, $sObjectComments);
  601. }
  602. /**
  603. * @page service Service Calls
  604. * @section bx_tasks Tasks
  605. * @subsection bx_tasks-page_blocks Page Blocks
  606. * @subsubsection bx_tasks-calendar calendar
  607. *
  608. * @code bx_srv('bx_tasks', 'calendar', [...]); @endcode
  609. *
  610. * Shows tasks calendar baced on die date
  611. *
  612. * @param $aData additional data to point which events to show, leave empty to show all events, specify event's ID in 'event' array key to show calendar for one event only, specify context's ID in 'context_id' array key to show calendar for one context events only. If only one event is specified then it will show calendar only if it's repeating event.
  613. * @param $sTemplate template to use to show calendar, or leave empty for default template, possible options: calendar.html, calendar_compact.html
  614. * @return HTML string with calendar to display on the site, all necessary CSS and JS files are automatically added to the HEAD section of the site HTML. On error empty string is returned.
  615. *
  616. * @see BxTasksModule::serviceCalendar
  617. */
  618. /**
  619. * @ref bx_tasks-calendar "calendar"
  620. */
  621. public function serviceCalendar($aData = array(), $sTemplate = 'calendar.html')
  622. {
  623. if (!$this->isAllowView($aData['context_id']))
  624. return;
  625. $o = new BxTemplCalendar(array(
  626. 'eventSources' => array (
  627. bx_append_url_params(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'calendar_data', $aData),
  628. ),
  629. ), $this->_oTemplate);
  630. return $o->display($sTemplate);
  631. }
  632. public function serviceGetCalendarEntries($iProfileId)
  633. {
  634. $CNF = &$this->_oConfig->CNF;
  635. $oConn = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION']);
  636. $aData = $oConn->getConnectedInitiators($iProfileId);
  637. $aData2 = array(0);
  638. foreach($aData as $iProfileId2) {
  639. $oProfile = BxDolProfile::getInstance($iProfileId2);
  640. array_push($aData2, $oProfile->getContentId());
  641. }
  642. $aSQLPart['where'] = " AND " . $CNF['TABLE_ENTRIES'] . ".`" . $CNF['FIELD_ID'] . "` IN(" . implode(',', $aData2) . ")";
  643. return $this->_oDb->getEntriesByDate(bx_get('start'), bx_get('end'), null, $aSQLPart);
  644. }
  645. public function serviceBrowseHome($aParams = [])
  646. {
  647. $iContextPid = bx_process_input(bx_get('context_pid'), BX_DATA_INT);
  648. if(!$iContextPid)
  649. return MsgBox(_t('_Empty'));
  650. $sContent = $this->serviceBrowseTasks(-$iContextPid);
  651. if($sContent && ($oProfile = BxDolProfile::getInstance($iContextPid)) !== false)
  652. return [
  653. 'title' => bx_replace_markers(_t('_bx_tasks_page_block_title_entries_in_context'), [
  654. 'display_name' => $oProfile->getDisplayName(),
  655. 'profile_link' => $oProfile->getUrl()
  656. ]),
  657. 'content' => $sContent
  658. ];
  659. return $sContent;
  660. }
  661. public function serviceBrowseContext($iProfileId = 0, $aParams = [])
  662. {
  663. if(!$iProfileId)
  664. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  665. if(!$iProfileId)
  666. return '';
  667. return $this->serviceBrowseTasks (-$iProfileId, $aParams);
  668. }
  669. public function serviceBrowseTasks($iContextId = 0, $aParams = [])
  670. {
  671. if(!$this->isAllowView(abs($iContextId)))
  672. return '';
  673. return $this->_oTemplate->getEntriesList($iContextId, $aParams);
  674. }
  675. /**
  676. * Common methods
  677. */
  678. public function getModuleTitle($sName)
  679. {
  680. $sResult = $sName;
  681. if(($_sTitle = '_' . $sName) && ($sTitle = _t($_sTitle)) && strcmp($_sTitle, $sTitle) != 0)
  682. $sResult = $sTitle;
  683. else if(($aModule = $this->_oModule->_oDb->getModuleByName($sName)) && is_array($aModule))
  684. $sResult = $aModule['title'] ?? _t('_undefined');
  685. return $sResult;
  686. }
  687. public function getAssignees()
  688. {
  689. $aResults = [];
  690. if(($oProfile = BxDolProfile::getInstance()) !== false && ($aIds = $this->_oDb->getTimeTracks(['sample' => 'assignees'])))
  691. foreach($aIds as $iId)
  692. $aResults[] = ['key' => $iId, 'value' => $oProfile->getDisplayName($iId)];
  693. return $aResults;
  694. }
  695. public function getContexts()
  696. {
  697. $aContexts = [];
  698. $aModules = bx_srv('system', 'get_modules_by_type', ['context', ['name_as_key' => true]]);
  699. foreach($aModules as $sModule => $aModule)
  700. $aContexts[$sModule] = ($_sTitle = '_' . $sModule) && ($sTitle = _t($_sTitle)) && strcmp($_sTitle, $sTitle) != 0 ? $sTitle : $aModule['title'];
  701. return $aContexts;
  702. }
  703. public function getContextMembers($iContextPid)
  704. {
  705. $aMembers = [];
  706. if(($oContext = BxDolProfile::getInstance($iContextPid)) !== false) {
  707. $aPids = bx_srv($oContext->getModule(), 'fans', [$oContext->getContentId(), true]);
  708. foreach($aPids as $iPid)
  709. $aMembers[$iPid] = $oContext->getDisplayName($iPid);
  710. }
  711. return $aMembers;
  712. }
  713. public function getContextEntries($iContextPid)
  714. {
  715. $CNF = &$this->_oConfig->CNF;
  716. $aEntries = [];
  717. if(($aTasks = $this->_oDb->getTasks(-$iContextPid)) && is_array($aTasks))
  718. foreach($aTasks as $aTask)
  719. $aEntries[$aTask[$CNF['FIELD_ID']]] = $aTask[$CNF['FIELD_TITLE']];
  720. return $aEntries;
  721. }
  722. public function getTimer($iContentId, $iProfileId)
  723. {
  724. return $this->_oDb->getTimers(['sample' => 'content_profile_ids', 'content_id' => $iContentId, 'profile_id' => $iProfileId]);
  725. }
  726. public function getTimersByAuthor($iProfileId, $bActive = false)
  727. {
  728. return $this->_oDb->getTimers(['sample' => 'profile_id', 'profile_id' => $iProfileId, 'active' => $bActive]);
  729. }
  730. public function stopTimerByAuthor($iProfileId)
  731. {
  732. $aTimer = $this->getTimersByAuthor($iProfileId, true);
  733. if(!$aTimer || !is_array($aTimer))
  734. return false;
  735. return $this->updateTimerById($aTimer['id'], [
  736. 'started' => 0,
  737. 'duration' => $aTimer['duration'] + (time() - $aTimer['started']),
  738. ]);
  739. }
  740. public function updateTimerById($iId, $aSet)
  741. {
  742. return $this->_oDb->updateTimer($aSet, ['id' => (int)$iId]) !== false;
  743. }
  744. public function onExpired($iContentId)
  745. {
  746. $CNF = &$this->_oConfig->CNF;
  747. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  748. if(!$aContentInfo)
  749. return;
  750. $oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION']);
  751. if($oConnection) {
  752. $aProfileIds = $oConnection->getConnectedContent($iContentId);
  753. if(!empty($aProfileIds) && is_array($aProfileIds))
  754. foreach($aProfileIds as $iProfileId){
  755. /**
  756. * @hooks
  757. * @hookdef hook-bx_tasks-expired 'bx_tasks', 'expired' - hook on task unassigned to profile
  758. * - $unit_name - equals `bx_tasks`
  759. * - $action - equals `expired`
  760. * - $object_id - task id
  761. * - $sender_id - not used
  762. * - $extra_params - array of additional params with the following array keys:
  763. * - `object_author_id` - [int] profile_id for task's author
  764. * - `privacy_view` - [string] privacy view value
  765. * @hook @ref hook-bx_tasks-expired
  766. */
  767. bx_alert($this->getName(), 'expired', $iContentId, false, array(
  768. 'object_author_id' => $iProfileId,
  769. 'privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]
  770. ));
  771. }
  772. }
  773. }
  774. public function isAllowView($iContextId)
  775. {
  776. if(!($oContext = BxDolProfile::getInstance($iContextId)) || $oContext->checkAllowedProfileView($iContextId) !== CHECK_ACTION_RESULT_ALLOWED)
  777. return false;
  778. return true;
  779. }
  780. public function isAllowAdd($iContextId)
  781. {
  782. if(!($oContext = BxDolProfile::getInstance($iContextId)) || $oContext->checkAllowedPostInProfile($iContextId) !== CHECK_ACTION_RESULT_ALLOWED)
  783. return false;
  784. return true;
  785. }
  786. public function isAllowManageByContext($iContextId)
  787. {
  788. if(isAdmin())
  789. return true;
  790. $oProfileContext = BxDolProfile::getInstance($iContextId);
  791. if(BxDolService::call($oProfileContext->getModule(), 'is_admin', array($iContextId)))
  792. return true;
  793. return false;
  794. }
  795. public function isAllowManage($mixedContent)
  796. {
  797. $CNF = &$this->_oConfig->CNF;
  798. $aContentInfo = !is_array($mixedContent) ? $this->_oDb->getContentInfoById((int)$mixedContent) : $mixedContent;
  799. if($this->checkAllowedEdit($aContentInfo) === CHECK_ACTION_RESULT_ALLOWED)
  800. return true;
  801. if($this->isAllowManageByContext(abs($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']])))
  802. return true;
  803. if(($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION'])) !== false) {
  804. $iLoggedId = bx_get_logged_profile_id();
  805. $aProfileIds = $oConnection->getConnectedInitiators($aContentInfo[$CNF['FIELD_ID']]);
  806. if(!empty($aProfileIds) && is_array($aProfileIds) && in_array($iLoggedId, $aProfileIds))
  807. return true;
  808. }
  809. return false;
  810. }
  811. /**
  812. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  813. */
  814. public function checkAllowedManage ($aDataEntry, $isPerformAction = false)
  815. {
  816. return $this->isAllowManage($aDataEntry) ? CHECK_ACTION_RESULT_ALLOWED : _t('_sys_txt_access_denied');
  817. }
  818. public function isCompleted($iContentId)
  819. {
  820. $CNF = &$this->_oConfig->CNF;
  821. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  822. return (bool)$aContentInfo[$CNF['FIELD_COMPLETED']];
  823. }
  824. public function complete($iContentId, $iCompleted)
  825. {
  826. $CNF = &$this->_oConfig->CNF;
  827. $iCompleted = (int)$iCompleted;
  828. $this->_oDb->updateEntriesBy([$CNF['FIELD_COMPLETED'] => $iCompleted], [$CNF['FIELD_ID'] => (int)$iContentId]);
  829. $sModule = $this->getName();
  830. $sAction = !$iCompleted ? 'reopened' : 'completed';
  831. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  832. $iContentAuthor = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
  833. /**
  834. * @hooks
  835. * @hookdef hook-bx_tasks-completed 'bx_tasks', 'completed' - hook on task unassigned to profile
  836. * - $unit_name - equals `bx_tasks`
  837. * - $action - can be `completed` or `reopened`
  838. * - $object_id - task id
  839. * - $sender_id - not used
  840. * - $extra_params - array of additional params with the following array keys:
  841. * - `object_author_id` - [int] profile_id for task's author
  842. * - `privacy_view` - [string] privacy view value
  843. * @hook @ref hook-bx_tasks-completed
  844. */
  845. bx_alert($sModule, $sAction, $iContentId, false, array(
  846. 'object_author_id' => $iContentAuthor,
  847. 'privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]
  848. ));
  849. if(($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION'])) !== false) {
  850. $aProfileIds = $oConnection->getConnectedContent($iContentId);
  851. if(!empty($aProfileIds) && is_array($aProfileIds))
  852. foreach($aProfileIds as $iProfileId) {
  853. if($iProfileId == $iContentAuthor)
  854. continue;
  855. bx_alert($sModule, $sAction, $iContentId, false, array(
  856. 'object_author_id' => $iProfileId,
  857. 'privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]
  858. ));
  859. }
  860. }
  861. $this->logActivity($iContentId, ['key' => '_bx_tasks_txt_msg_' . ($iCompleted ? '' : 'un') . 'completed']);
  862. return true;
  863. }
  864. public function logActivity($iContentId, $aMessage)
  865. {
  866. $CNF = &$this->_oConfig->CNF;
  867. $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId);
  868. if(!$oCmts || !$oCmts->isEnabled())
  869. return false;
  870. if(($oAuthor = BxDolProfile::getInstance()) !== false)
  871. $aMessage['markers'] = array_merge($aMessage['markers'] ?? [], [
  872. 'author_link' => $oAuthor->getUrl(),
  873. 'author_name' => $oAuthor->getDisplayName(),
  874. ]);
  875. return $oCmts->addAuto($aMessage);
  876. }
  877. /**
  878. * Internal methods
  879. */
  880. protected function _onEditProperty($aContentInfo, $sProperty, &$oForm)
  881. {
  882. $CNF = &$this->_oConfig->CNF;
  883. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  884. $mixedValue = $oForm->getCleanValue($CNF['FIELD_' . strtoupper($sProperty)]);
  885. if(($sMethod = 'get' . bx_gen_method_name($sProperty) . 'Title') && method_exists($this->_oConfig, $sMethod))
  886. $mixedValue = $this->_oConfig->$sMethod($mixedValue);
  887. $this->logActivity($iContentId, ['key' => '_bx_tasks_txt_msg_edit_' . $sProperty, 'markers' => ['value' => $mixedValue]]);
  888. }
  889. protected function _onEditState($aContentInfo, &$oForm)
  890. {
  891. $CNF = &$this->_oConfig->CNF;
  892. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  893. $iState = $oForm->getCleanValue($CNF['FIELD_STATE']);
  894. $this->logActivity($iContentId, ['key' => '_bx_tasks_txt_msg_edit_state', 'markers' => ['value' => $this->_oConfig->getStateTitle($iState)]]);
  895. $iCompleted = (int)$this->_oConfig->isCompleted($iState);
  896. if($iCompleted != (int)$this->_oConfig->isCompleted($aContentInfo[$CNF['FIELD_STATE']]))
  897. $this->complete($iContentId, $iCompleted);
  898. }
  899. }
  900. /** @} */