BxTasksDb.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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. * Module database queries
  12. */
  13. class BxTasksDb extends BxBaseModTextDb
  14. {
  15. protected $_aSqlMarkers;
  16. public function __construct(&$oConfig)
  17. {
  18. parent::__construct($oConfig);
  19. $this->_aSqlMarkers = [
  20. 'logged_pid' => bx_get_logged_profile_id()
  21. ];
  22. }
  23. public function getContexts($aParams = [])
  24. {
  25. $CNF = &$this->_oConfig->CNF;
  26. $aMethod = ['name' => 'getAll', 'params' => [0 => 'query']];
  27. $sSelectClause = '`tc`.*';
  28. $sJoinClause = $sWhereClause = $sOrderClause = '';
  29. if(!empty($aParams))
  30. switch($aParams['sample']) {
  31. case 'id':
  32. $aMethod['name'] = 'getRow';
  33. $aMethod['params'][1] = [
  34. 'id' => $aParams['id']
  35. ];
  36. $sWhereClause = "AND `tc`.`id` = :id";
  37. break;
  38. }
  39. if(!empty($sOrderClause))
  40. $sOrderClause = "ORDER BY " . $sOrderClause;
  41. $aMethod['params'][0] = "SELECT
  42. " . $sSelectClause . "
  43. FROM `" . $CNF['TABLE_CONTEXTS'] . "` AS `tc` " . $sJoinClause . "
  44. WHERE 1 " . $sWhereClause . " " . $sOrderClause;
  45. return call_user_func_array([$this, $aMethod['name']], $aMethod['params']);
  46. }
  47. public function getLists ($iContextId = 0)
  48. {
  49. $CNF = &$this->_oConfig->CNF;
  50. $sQuery = $this->prepare ("SELECT * FROM `" . $CNF['TABLE_LISTS'] . "` WHERE `context_id` = ?", $iContextId);
  51. return $this->getAll($sQuery);
  52. }
  53. public function getList ($iId = 0)
  54. {
  55. $CNF = &$this->_oConfig->CNF;
  56. $sQuery = $this->prepare ("SELECT * FROM `" . $CNF['TABLE_LISTS'] . "` WHERE `id` = ?", $iId);
  57. return $this->getRow($sQuery);
  58. }
  59. public function deleteList ($iId = 0)
  60. {
  61. $CNF = &$this->_oConfig->CNF;
  62. $sQuery = $this->prepare ("DELETE FROM `" . $CNF['TABLE_LISTS'] . "` WHERE `id` = ?", $iId);
  63. $this->query($sQuery);
  64. $sQuery = $this->prepare ("DELETE FROM `" . $CNF['TABLE_ENTRIES'] . "` WHERE `" . $CNF['FIELD_TASKLIST'] . "` = ?", $iId);
  65. $this->query($sQuery);
  66. }
  67. public function getTasks ($iContextId = 0, $iListId = 0, $aParams = [])
  68. {
  69. $CNF = &$this->_oConfig->CNF;
  70. $aBindings = [];
  71. $sSelectClause = "`te`.*";
  72. $sJoinClause = $sWhereClause = "";
  73. if(($sField = $CNF['FIELD_ALLOW_VIEW_TO']) && $iContextId) {
  74. $aBindings[$sField] = $iContextId;
  75. $sWhereClause .= " AND `te`.`" . $sField . "` = :" . $sField;
  76. }
  77. if(($sField = $CNF['FIELD_TASKLIST']) && $iListId) {
  78. $aBindings[$sField] = $iListId;
  79. $sWhereClause .= " AND `te`.`" . $sField . "` = :" . $sField;
  80. }
  81. if(($iFilter = (int)($aParams['filter'] ?? 0)) && ($aFilter = $this->getFilterById($iFilter))) {
  82. if(($aFltJoin = $aFilter['conditions']['join'] ?? false) && ($sFltJoin = $this->_getSqlJoinFrom($aFltJoin)) != '')
  83. $sJoinClause .= " " . $sFltJoin;
  84. if(($aFltWhere = $aFilter['conditions']['where'] ?? false) && ($sFltWhere = $this->_getSqlWhereFrom($aFltWhere)) != '')
  85. $sWhereClause .= " AND " . $sFltWhere;
  86. }
  87. if(($iProfileId = $aParams['for_profile'] ?? false)) {
  88. $aBindings['profile_id'] = (int)$iProfileId;
  89. $sJoinClause .= " LEFT JOIN `" . $CNF['TABLE_ASSIGNMENTS'] . "` AS `ta` ON `te`.`id`=`ta`.`content`";
  90. $sWhereClause .= " AND (`te`.`" . $CNF['FIELD_AUTHOR'] . "`=:profile_id OR `ta`.`initiator`=:profile_id)";
  91. }
  92. if(($oCf = BxDolContentFilter::getInstance()) && $oCf->isEnabled())
  93. $sWhereClause .= $oCf->getSQLParts('te', $CNF['FIELD_CF']);
  94. if(($aParams['with_stats'] ?? false)) {
  95. $sSelectClause .= $this->prepareAsString(", (SELECT SUM(`value`) FROM `" . $CNF['TABLE_TIME_TRACK'] . "` WHERE `object_id`=`te`.`id` AND `author_id`=?) AS `time`, `tt`.`sum` AS `time_total`", bx_get_logged_profile_id());
  96. $sJoinClause .= " LEFT JOIN `" . $CNF['TABLE_TIME'] . "` AS `tt` ON `te`.`id`=`tt`.`object_id`";
  97. }
  98. return $this->getAll("SELECT DISTINCT " . $sSelectClause . " FROM `" . $CNF['TABLE_ENTRIES'] . "` AS `te`" . $sJoinClause . " WHERE 1" . $sWhereClause, $aBindings);
  99. }
  100. public function getEntriesByDate($sDateFrom, $sDateTo, $aSQLPart = array())
  101. {
  102. // validate input data
  103. if (false === ($oDateFrom = date_create($sDateFrom, new DateTimeZone('UTC'))))
  104. return array();
  105. if (false === ($oDateTo = date_create($sDateTo, new DateTimeZone('UTC'))))
  106. return array();
  107. if ($oDateFrom > $oDateTo)
  108. return array();
  109. // increase start and end date to cover timezones
  110. $oDateFrom = $oDateFrom->sub(new DateInterval("P1D"));
  111. $oDateTo = $oDateTo->add(new DateInterval("P1D"));
  112. // look throught all days in the interval
  113. $oDateIter = clone($oDateFrom);
  114. $aEntries = array();
  115. while ($oDateIter->format('Y-m-d') != $oDateTo->format('Y-m-d')) {
  116. $oDateMin = date_create($oDateIter->format('Y-m-d') . '00:00:00', new DateTimeZone('UTC'));
  117. $oDateMax = date_create($oDateIter->format('Y-m-d') . '23:59:59', new DateTimeZone('UTC'));
  118. // get all events for the specific day
  119. $oDateMonthBegin = date_create($oDateIter->format('Y-m-01'), new DateTimeZone('UTC'));
  120. $iWeekOfMonth = $oDateIter->format('W') - $oDateMonthBegin->format('W') + 1;
  121. $aBindings = array(
  122. 'timestamp_min' => $oDateMin->getTimestamp(),
  123. 'timestamp_max' => $oDateMax->getTimestamp(),
  124. );
  125. $sWhere = isset($aSQLPart['where']) ? $aSQLPart['where'] : '';
  126. $a = $this->getAll("SELECT DISTINCT `bx_tasks_tasks`.`id`, `bx_tasks_tasks`.`title` AS `title`, `bx_tasks_tasks`.`due_date`
  127. FROM `bx_tasks_tasks`
  128. WHERE (`bx_tasks_tasks`.`due_date` >= :timestamp_min AND `bx_tasks_tasks`.`due_date` <= :timestamp_max ) $sWhere
  129. ", $aBindings);
  130. // prepare variables for each event
  131. $sCurrentDay = $oDateIter->format('Y-m-d');
  132. foreach ($a as $k => $r) {
  133. $oDateStart = new DateTime();
  134. $oDateStart->setTimestamp($r['due_date']);
  135. $oDateStart->setTimezone(new DateTimeZone('UTC'));
  136. $oDateEnd = new DateTime();
  137. $oDateEnd->setTimestamp($r['due_date']);
  138. $oDateEnd->setTimezone(new DateTimeZone('UTC'));
  139. $oDuration = $oDateStart->diff($oDateEnd);
  140. $sHoursStart = $oDateStart->format('H:i:s');
  141. $oStart = date_create($sCurrentDay . ' ' . $sHoursStart, new DateTimeZone('UTC'));
  142. $oEnd = $oStart ? clone($oStart) : null;
  143. $oEnd = $oEnd ? $oEnd->add($oDuration) : null;
  144. $a[$k]['start'] = $oStart ? $oStart->format('Y-m-d') : 0;
  145. $a[$k]['start_utc'] = $oStart ? $oStart->getTimestamp() : 0;
  146. $a[$k]['url'] = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->_oConfig->CNF['URI_VIEW_ENTRY'] . '&id=' . $r['id']));
  147. }
  148. // merge with all other events
  149. $aEntries = array_merge($aEntries, $a);
  150. // go to the next day
  151. $oDateIter = $oDateIter->add(new DateInterval("P1D"));
  152. }
  153. return $aEntries;
  154. }
  155. public function expireEntries()
  156. {
  157. $CNF = $this->_oConfig->CNF;
  158. $aResult = $this->getColumn("SELECT `id` FROM `" . $CNF['TABLE_ENTRIES'] . "` WHERE `" . $CNF['FIELD_DUE_DATE'] . "` < UNIX_TIMESTAMP() AND `" . $CNF['FIELD_EXPIRED'] . "` = '0'");
  159. if(empty($aResult) || !is_array($aResult))
  160. return false;
  161. return count($aResult) == (int)$this->query("UPDATE `" . $CNF['TABLE_ENTRIES'] . "` SET `" . $CNF['FIELD_EXPIRED'] . "` = '1' WHERE `id` IN (" . $this->implode_escape($aResult) . ")") ? $aResult : false;
  162. }
  163. public function getContextsIdsByType($sType, $iProfileId)
  164. {
  165. $CNF = $this->_oConfig->CNF;
  166. //--- Add own tasks
  167. $sQuery = '(SELECT `tp`.`id` FROM `' . $CNF['TABLE_ENTRIES'] . '` AS `tt` INNER JOIN `sys_profiles` AS `tp` ON ABS(`tt`.`allow_view_to`)=`tp`.`id` AND `tp`.`type`=:type WHERE `tt`.`author`=:author GROUP BY `tp`.`id`)';
  168. //--- Add assigned tasks
  169. $oAssignments = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION']);
  170. $aSql = $oAssignments->getConnectedContentAsSQLParts('tt', 'id', $iProfileId);
  171. if($aSql && ($sJoin = $aSql['join'] ?? false))
  172. $sQuery .= ' UNION (SELECT `tp`.`id` FROM `' . $CNF['TABLE_ENTRIES'] . '` AS `tt` INNER JOIN `sys_profiles` AS `tp` ON ABS(`tt`.`allow_view_to`)=`tp`.`id` AND `tp`.`type`=:type ' . $sJoin . ' WHERE 1)';
  173. return $this->getColumn($sQuery, [
  174. 'type' => $sType,
  175. 'author' => $iProfileId
  176. ]);
  177. }
  178. public function getFilters($aParams = [])
  179. {
  180. $CNF = &$this->_oConfig->CNF;
  181. $aMethod = ['name' => 'getAll', 'params' => [0 => 'query']];
  182. $sSelectClause = '`tf`.*';
  183. $sJoinClause = $sWhereClause = '';
  184. $sOrderClause = '`tf`.`order` ASC';
  185. if(!empty($aParams))
  186. switch($aParams['sample']) {
  187. case 'id':
  188. $aMethod['name'] = 'getRow';
  189. $aMethod['params'][1] = [
  190. 'id' => $aParams['id']
  191. ];
  192. $sWhereClause = "AND `tf`.`id` = :id";
  193. break;
  194. case 'author':
  195. $aMethod['params'][1] = [
  196. 'author' => $aParams['author']
  197. ];
  198. $sWhereClause = "AND `tf`.`author` = :author";
  199. if(isset($aParams['active']) && $aParams['active'] === true)
  200. $sWhereClause .= " AND `tf`.`active` <> '0'";
  201. break;
  202. case 'active':
  203. $sWhereClause .= " AND `tf`.`active` <> '0'";
  204. break;
  205. }
  206. if(!empty($sOrderClause))
  207. $sOrderClause = "ORDER BY " . $sOrderClause;
  208. $aMethod['params'][0] = "SELECT
  209. " . $sSelectClause . "
  210. FROM `" . $CNF['TABLE_FILTERS'] . "` AS `tf` " . $sJoinClause . "
  211. WHERE 1 " . $sWhereClause . " " . $sOrderClause;
  212. return call_user_func_array([$this, $aMethod['name']], $aMethod['params']);
  213. }
  214. public function getFilterById($iId)
  215. {
  216. $aFilter = $this->getFilters(['sample' => 'id', 'id' => $iId]);
  217. if(!$aFilter || !is_array($aFilter))
  218. return false;
  219. if(($sK = 'conditions') && $aFilter[$sK])
  220. $aFilter[$sK] = json_decode($aFilter[$sK], true);
  221. return $aFilter;
  222. }
  223. public function getTimeTracks($aParams = [])
  224. {
  225. $CNF = &$this->_oConfig->CNF;
  226. $aMethod = ['name' => 'getAll', 'params' => [0 => 'query']];
  227. $sSelectClause = '`ttt`.*';
  228. $sJoinClause = $sWhereClause = $sOrderClause = '';
  229. if(!empty($aParams))
  230. switch($aParams['sample']) {
  231. case 'id':
  232. $aMethod['name'] = 'getRow';
  233. $aMethod['params'][1] = [
  234. 'id' => $aParams['id']
  235. ];
  236. $sWhereClause = "AND `ttt`.`id` = :id";
  237. break;
  238. case 'assignees':
  239. $aMethod['name'] = 'getColumn';
  240. $sSelectClause = 'DISTINCT `ttt`.`author_id`';
  241. break;
  242. }
  243. if(!empty($sOrderClause))
  244. $sOrderClause = "ORDER BY " . $sOrderClause;
  245. $aMethod['params'][0] = "SELECT
  246. " . $sSelectClause . "
  247. FROM `" . $CNF['TABLE_TIME_TRACK'] . "` AS `ttt` " . $sJoinClause . "
  248. WHERE 1 " . $sWhereClause . " " . $sOrderClause;
  249. return call_user_func_array([$this, $aMethod['name']], $aMethod['params']);
  250. }
  251. public function insertTimeTrack($aParamsSet)
  252. {
  253. $CNF = &$this->_oConfig->CNF;
  254. if(empty($aParamsSet))
  255. return false;
  256. return $this->query("INSERT INTO `" . $CNF['TABLE_TIME_TRACK'] . "` SET " . $this->arrayToSQL($aParamsSet)) ? $this->lastId() : false;
  257. }
  258. public function getTimers($aParams = [])
  259. {
  260. $CNF = &$this->_oConfig->CNF;
  261. $aMethod = ['name' => 'getAll', 'params' => [0 => 'query']];
  262. $sSelectClause = '`tt`.*';
  263. $sJoinClause = $sWhereClause = $sOrderClause = '';
  264. if(!empty($aParams))
  265. switch($aParams['sample']) {
  266. case 'id':
  267. $aMethod['name'] = 'getRow';
  268. $aMethod['params'][1] = [
  269. 'id' => $aParams['id']
  270. ];
  271. $sWhereClause = "AND `tt`.`id` = :id";
  272. break;
  273. case 'content_profile_ids':
  274. $aMethod['name'] = 'getRow';
  275. $aMethod['params'][1] = [
  276. 'content_id' => $aParams['content_id'],
  277. 'profile_id' => $aParams['profile_id']
  278. ];
  279. $sWhereClause = "AND `tt`.`content_id` = :content_id AND `tt`.`profile_id` = :profile_id";
  280. break;
  281. case 'profile_id':
  282. $aMethod['params'][1] = [
  283. 'profile_id' => $aParams['profile_id']
  284. ];
  285. $sWhereClause = "AND `tt`.`profile_id` = :profile_id";
  286. if(isset($aParams['active']) && $aParams['active'] === true) {
  287. $aMethod['name'] = 'getRow';
  288. $sWhereClause .= " AND `tt`.`started` <> '0'";
  289. }
  290. break;
  291. }
  292. if(!empty($sOrderClause))
  293. $sOrderClause = "ORDER BY " . $sOrderClause;
  294. $aMethod['params'][0] = "SELECT
  295. " . $sSelectClause . "
  296. FROM `" . $CNF['TABLE_TIMERS'] . "` AS `tt` " . $sJoinClause . "
  297. WHERE 1 " . $sWhereClause . " " . $sOrderClause;
  298. return call_user_func_array([$this, $aMethod['name']], $aMethod['params']);
  299. }
  300. public function isTimerStarted($iObjectId, $iAuthorId)
  301. {
  302. $aTimer = $this->getTimers([
  303. 'sample' => 'content_profile_ids',
  304. 'content_id' => $iObjectId,
  305. 'profile_id' => $iAuthorId
  306. ]);
  307. return ($aTimer['started'] ?? 0) != 0;
  308. }
  309. public function insertTimer($aParamsSet)
  310. {
  311. $CNF = &$this->_oConfig->CNF;
  312. if(empty($aParamsSet))
  313. return false;
  314. return $this->query("INSERT INTO `" . $CNF['TABLE_TIMERS'] . "` SET " . $this->arrayToSQL($aParamsSet)) ? $this->lastId() : false;
  315. }
  316. public function updateTimer($aParamsSet, $aParamsWhere)
  317. {
  318. $CNF = &$this->_oConfig->CNF;
  319. if(empty($aParamsSet) || empty($aParamsWhere))
  320. return false;
  321. return $this->query("UPDATE `" . $CNF['TABLE_TIMERS'] . "` SET " . $this->arrayToSQL($aParamsSet) . " WHERE " . $this->arrayToSQL($aParamsWhere, " AND "));
  322. }
  323. public function deleteTimer($aParamsWhere)
  324. {
  325. $CNF = &$this->_oConfig->CNF;
  326. if(empty($aParamsWhere))
  327. return false;
  328. return $this->query("DELETE FROM `" . $CNF['TABLE_TIMERS'] . "` WHERE " . $this->arrayToSQL($aParamsWhere, " AND "));
  329. }
  330. /**
  331. * Legend:
  332. * grp - group
  333. * cnd - condition
  334. * cnds - conditions
  335. *
  336. * t - table
  337. * f - field
  338. * o - operation
  339. * v - value
  340. * j - joining type (INNER, LEFT)
  341. *
  342. * Addons:
  343. * +a - alias, like ta - table alias
  344. * +j - join, like tj - table join or fj - field join
  345. * +m - main, like tm - table main or fm - field main
  346. */
  347. protected function _getSqlJoinFrom($aCnd)
  348. {
  349. return $this->_getSqlClauseFrom('join', $aCnd);
  350. }
  351. protected function _getSqlJoinFromGroup($aGrp)
  352. {
  353. $sResult = "";
  354. if(empty($aGrp['cnds']) || !is_array($aGrp['cnds']))
  355. return $sResult;
  356. $sOprGrp = " ";
  357. foreach($aGrp['cnds'] as $aCnd)
  358. if(($sResultCnd = $this->_getSqlJoinFromCondition($aCnd)) != '')
  359. $sResult .= $sOprGrp . $sResultCnd;
  360. return trim($sResult, $sOprGrp);
  361. }
  362. protected function _getSqlJoinFromCondition($aCnd)
  363. {
  364. $sResult = "";
  365. if(!$this->_isJoinCondition($aCnd))
  366. return $sResult;
  367. $sFldJ = "`" . ($aCnd['taj'] ?? $aCnd['tj']) . "`.`" . $aCnd['fj'] . "`";
  368. $sFldM = "`" . $aCnd['fm'] . "`";
  369. if(($sTblAlsM = $aCnd['tam'] ?? ($aCnd['tm'] ?? false)))
  370. $sFldM = "`" . $sTblAlsM . "`." . $sFldM;
  371. return $aCnd['j'] . " JOIN `" . $aCnd['tj'] . "`" . (($sTblAlsJ = $aCnd['taj'] ?? false) ? " AS `" . $sTblAlsJ . "`" : "") . " ON (" . $sFldM . " = " . $sFldJ . ")";
  372. }
  373. protected function _getSqlWhereFrom($aCnd)
  374. {
  375. return $this->_getSqlClauseFrom('where', $aCnd);
  376. }
  377. protected function _getSqlWhereFromGroup($aGrp)
  378. {
  379. $sResult = "";
  380. if(!isset($aGrp['o'], $aGrp['cnds']) || empty($aGrp['cnds']) || !is_array($aGrp['cnds']))
  381. return $sResult;
  382. $sOprGrp = " " . $aGrp['o'] . " ";
  383. foreach($aGrp['cnds'] as $aCnd)
  384. if(($sResultCnd = $this->_getSqlWhereFrom($aCnd)) != '')
  385. $sResult .= $sOprGrp . $sResultCnd;
  386. if(($sResult = trim($sResult, $sOprGrp)) != '')
  387. $sResult = "(" . $sResult . ")";
  388. return $sResult;
  389. }
  390. protected function _getSqlWhereFromCondition($aCnd)
  391. {
  392. $sResult = "";
  393. if(!$this->_isWhereCondition($aCnd))
  394. return $sResult;
  395. if(($sMethod = '_getSqlWhereFromCondition' . bx_gen_method_name($aCnd['f'])) && method_exists($this, $sMethod)) {
  396. $mixedResult = $this->$sMethod($aCnd);
  397. if(!$this->_isWhereCondition($mixedResult))
  398. return $mixedResult;
  399. $aCnd = $mixedResult;
  400. }
  401. $sFld = "`" . $aCnd['f'] . "`";
  402. if(($sTbl = $aCnd['t'] ?? ''))
  403. $sFld = "`" . $sTbl . "`." . $sFld;
  404. switch($aCnd['o']) {
  405. case 'IN':
  406. if(empty($aCnd['v']) || !is_array($aCnd['v']))
  407. break;
  408. $sResult .= $sFld . " IN (" . $this->implode_escape($aCnd['v']) . ")";
  409. break;
  410. case 'LIKE':
  411. $sResult .= $sFld . " LIKE " . $this->escape('%' . $aCnd['v'] . '%');
  412. break;
  413. default:
  414. $sResult .= $sFld . " " . $aCnd['o'] . " " . $this->escape($aCnd['v']);
  415. }
  416. return $sResult;
  417. }
  418. protected function _isJoinCondition($mixedCnd)
  419. {
  420. return is_array($mixedCnd) && isset($mixedCnd['j'], $mixedCnd['tj'], $mixedCnd['fj'], $mixedCnd['fm']);
  421. }
  422. protected function _isWhereCondition($mixedCnd)
  423. {
  424. return is_array($mixedCnd) && isset($mixedCnd['f'], $mixedCnd['v'], $mixedCnd['o']);
  425. }
  426. protected function _getSqlClauseFrom($sType, $aCnd)
  427. {
  428. $sMethod = '';
  429. if(($aCnd['grp'] ?? false) === true)
  430. $sMethod = 'Group';
  431. else if(($aCnd['cnd'] ?? false) === true)
  432. $sMethod = 'Condition';
  433. if(!$sMethod || !method_exists($this, ($sMethod = '_getSql' . bx_gen_method_name($sType) . 'From' . $sMethod)))
  434. return '';
  435. $sResult = $this->$sMethod($aCnd);
  436. if($sResult && $this->_aSqlMarkers)
  437. $sResult = bx_replace_markers($sResult, $this->_aSqlMarkers);
  438. return $sResult;
  439. }
  440. }
  441. /** @} */