BxDolCmtsQuery.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. /**
  10. * @see BxDolCmts
  11. */
  12. class BxDolCmtsQuery extends BxDolDb
  13. {
  14. protected $_oMain;
  15. protected $_sTable;
  16. protected $_sTriggerTable;
  17. protected $_sTriggerFieldId;
  18. protected $_sTriggerFieldAuthor;
  19. protected $_sTriggerFieldTitle;
  20. protected $_sTriggerFieldComments;
  21. protected $_sTableFiles;
  22. protected $_sTableFiles2Entries;
  23. protected $_sTableIds;
  24. public function __construct(&$oMain)
  25. {
  26. $this->_oMain = $oMain;
  27. $aSystem = $this->_oMain->getSystemInfo();
  28. $this->_sTable = $aSystem['table'];
  29. $this->_sTriggerTable = $aSystem['trigger_table'];
  30. $this->_sTriggerFieldId = $aSystem['trigger_field_id'];
  31. $this->_sTriggerFieldAuthor = $aSystem['trigger_field_author'];
  32. $this->_sTriggerFieldTitle = $aSystem['trigger_field_title'];
  33. $this->_sTriggerFieldComments = $aSystem['trigger_field_comments'];
  34. $this->_sTableFiles = $aSystem['table_images'];
  35. $this->_sTableFiles2Entries = $aSystem['table_images2entries'];
  36. $this->_sTableIds = $aSystem['table_ids'];
  37. parent::__construct();
  38. }
  39. function getTableName ()
  40. {
  41. return $this->_sTable;
  42. }
  43. function setTableNameFiles($sTable)
  44. {
  45. $this->_sTableFiles = $sTable;
  46. }
  47. function setTableNameFiles2Entries($sTable)
  48. {
  49. $this->_sTableFiles2Entries = $sTable;
  50. }
  51. function getCommentsCountAll ($iId)
  52. {
  53. $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldComments}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ?", $iId);
  54. return (int)$this->getOne($sQuery);
  55. }
  56. function getCommentsCount ($iId, $iCmtVParentId = -1, $iAuthorId = 0, $sFilter = '')
  57. {
  58. $aBindings = array(
  59. 'cmt_object_id' => $iId
  60. );
  61. $sWhereClause = '';
  62. if((int)$iCmtVParentId >= 0) {
  63. $aBindings['cmt_vparent_id'] = $iCmtVParentId;
  64. $sWhereClause .= " AND `{$this->_sTable}`.`cmt_vparent_id` = :cmt_vparent_id";
  65. }
  66. $sJoinClause = '';
  67. switch($sFilter) {
  68. case BX_CMT_FILTER_FRIENDS:
  69. case BX_CMT_FILTER_SUBSCRIPTIONS:
  70. $oConnection = BxDolConnection::getObjectInstance($this->_oMain->getConnectionObject($sFilter));
  71. $aQueryParts = $oConnection->getConnectedContentAsSQLParts($this->_sTable, 'cmt_author_id', $iAuthorId);
  72. $sJoinClause .= ' ' . $aQueryParts['join'];
  73. break;
  74. case BX_CMT_FILTER_OTHERS:
  75. $aBindings['cmt_author_id'] = $iAuthorId;
  76. $sWhereClause .= " AND `{$this->_sTable}`.`cmt_author_id` <> :cmt_author_id";
  77. break;
  78. }
  79. $sQuery = "SELECT COUNT(*) FROM `{$this->_sTable}` $sJoinClause WHERE `{$this->_sTable}`.`cmt_object_id` = :cmt_object_id" . $sWhereClause;
  80. return (int)$this->getOne($sQuery, $aBindings);
  81. }
  82. function getComments ($iId, $iCmtVParentId = 0, $iAuthorId = 0, $sFilter = '', $aOrder = array(), $iStart = 0, $iCount = -1)
  83. {
  84. $aBindings = array(
  85. 'cmt_object_id' => $iId,
  86. 'system_id' => $this->_oMain->getSystemId()
  87. );
  88. $sFields = $sJoin = "";
  89. $sWhereParent = '';
  90. if((int)$iCmtVParentId >= 0) {
  91. $aBindings['cmt_vparent_id'] = $iCmtVParentId;
  92. $sWhereParent = " AND `{$this->_sTable}`.`cmt_vparent_id` = :cmt_vparent_id";
  93. }
  94. if(in_array($sFilter, array(BX_CMT_FILTER_FRIENDS, BX_CMT_FILTER_SUBSCRIPTIONS))) {
  95. $oConnection = BxDolConnection::getObjectInstance($this->_oMain->getConnectionObject($sFilter));
  96. $aQueryParts = $oConnection->getConnectedContentAsSQLParts($this->_sTable, 'cmt_author_id', $iAuthorId);
  97. $sJoin .= ' ' . $aQueryParts['join'];
  98. }
  99. $sOrder = " ORDER BY `{$this->_sTable}`.`cmt_time` ASC";
  100. if(isset($aOrder['by']) && isset($aOrder['way'])) {
  101. $aOrder['way'] = strtoupper(in_array($aOrder['way'], array(BX_CMT_ORDER_WAY_ASC, BX_CMT_ORDER_WAY_DESC)) ? $aOrder['way'] : BX_CMT_ORDER_WAY_ASC);
  102. switch($aOrder['by']) {
  103. case BX_CMT_ORDER_BY_DATE:
  104. $sOrder = " ORDER BY `{$this->_sTable}`.`cmt_time` " . $aOrder['way'];
  105. break;
  106. case BX_CMT_ORDER_BY_POPULAR:
  107. $oVote = $this->_oMain->getVoteObject(0);
  108. $oScore = $this->_oMain->getScoreObject(0);
  109. $aSortFields = array();
  110. if($oVote !== false) {
  111. array_push($aSortFields, '`' . $this->_sTableIds . '`.`votes`');
  112. }
  113. if($oScore !== false) {
  114. array_push($aSortFields, '`' . $this->_sTableIds . '`.`score`');
  115. }
  116. if (count($aSortFields) == 0)
  117. array_push($aSortFields, '`' . $this->_sTable . '`.`id`');
  118. $sOrder = " ORDER BY " . implode($aOrder['way'] . ', ', $aSortFields) . " " . $aOrder['way'];
  119. break;
  120. }
  121. }
  122. $sLimit = $iCount != -1 ? $this->prepareAsString(" LIMIT ?, ?", (int)$iStart, (int)$iCount) : '';
  123. $sQuery = "SELECT
  124. `{$this->_sTable}`.`cmt_id`,
  125. `{$this->_sTable}`.`cmt_parent_id`,
  126. `{$this->_sTable}`.`cmt_vparent_id`,
  127. `{$this->_sTable}`.`cmt_object_id`,
  128. `{$this->_sTable}`.`cmt_author_id`,
  129. `{$this->_sTable}`.`cmt_level`,
  130. `{$this->_sTable}`.`cmt_text`,
  131. `{$this->_sTable}`.`cmt_replies`,
  132. `{$this->_sTable}`.`cmt_time`
  133. $sFields
  134. FROM `{$this->_sTable}`
  135. LEFT JOIN `{$this->_sTableIds}` ON (`{$this->_sTable}`.`cmt_id` = `{$this->_sTableIds}`.`cmt_id` AND `{$this->_sTableIds}`.`system_id` = :system_id)
  136. $sJoin
  137. WHERE `{$this->_sTable}`.`cmt_object_id` = :cmt_object_id" . $sWhereParent . $sOrder . $sLimit;
  138. return $this->getAll($sQuery, $aBindings);
  139. }
  140. function getCommentsBy($aParams = array())
  141. {
  142. $aMethod = array('name' => 'getAll', 'params' => array(0 => 'query', 1 => array()));
  143. $sSelectClause = $sJoinClause = $sWhereClause = $sOrderClause = $sLimitClause = "";
  144. $sSelectClause = "
  145. `{$this->_sTable}`.`cmt_id`,
  146. `{$this->_sTable}`.`cmt_parent_id`,
  147. `{$this->_sTable}`.`cmt_vparent_id`,
  148. `{$this->_sTable}`.`cmt_object_id`,
  149. `{$this->_sTable}`.`cmt_author_id`,
  150. `{$this->_sTable}`.`cmt_level`,
  151. `{$this->_sTable}`.`cmt_text`,
  152. `{$this->_sTable}`.`cmt_replies`,
  153. `{$this->_sTable}`.`cmt_time`";
  154. if(isset($aParams['object_id'])) {
  155. $aMethod['params'][1]['cmt_object_id'] = (int)$aParams['object_id'];
  156. $sWhereClause .= " AND `{$this->_sTable}`.`cmt_object_id` = :cmt_object_id";
  157. }
  158. switch($aParams['type']) {
  159. case 'id':
  160. $aMethod['name'] = 'getRow';
  161. $aMethod['params'][1]['id'] = (int)$aParams['id'];
  162. $sWhereClause .= " AND `{$this->_sTable}`.`cmt_id` = :id";
  163. break;
  164. case 'latest':
  165. if(!empty($aParams['author'])) {
  166. $aMethod['params'][1]['cmt_author_id'] = (int)$aParams['author'];
  167. $sWhereClause .= " AND `{$this->_sTable}`.`cmt_author_id` " . (isset($aParams['others']) && (int)$aParams['others'] == 1 ? "<>" : "=") . " :cmt_author_id";
  168. }
  169. $sOrderClause = "`{$this->_sTable}`.`cmt_time` DESC";
  170. $sLimitClause = "";
  171. if(isset($aParams['per_page']))
  172. $sLimitClause = $this->prepareAsString("?, ?", $aParams['start'], $aParams['per_page']);
  173. break;
  174. case 'object_id':
  175. $aMethod['params'][1]['cmt_object_id'] = (int)$aParams['object_id'];
  176. $sWhereClause .= " AND `{$this->_sTable}`.`cmt_object_id` = :cmt_object_id";
  177. $sOrderClause = "`{$this->_sTable}`.`cmt_time` ASC";
  178. $sLimitClause = "";
  179. if(isset($aParams['per_page']))
  180. $sLimitClause = $this->prepareAsString("?, ?", $aParams['start'], $aParams['per_page']);
  181. break;
  182. case 'search_ids':
  183. $aMethod['name'] = 'getColumn';
  184. $sSelectClause = "`{$this->_sTable}`.`cmt_id`";
  185. if (!empty($aParams['start']) && !empty($aParams['per_page']))
  186. $sLimitClause = $this->prepareAsString("?, ?", $aParams['start'], $aParams['per_page']);
  187. elseif (!empty($aParams['per_page']))
  188. $sLimitClause = $this->prepareAsString("?", $aParams['per_page']);
  189. $sWhereConditions = "1";
  190. foreach($aParams['search_params'] as $sSearchParam => $aSearchParam) {
  191. $sSearchValue = "";
  192. switch ($aSearchParam['operator']) {
  193. case 'like':
  194. $sSearchValue = " LIKE " . $this->escape("%" . $aSearchParam['value'] . "%");
  195. break;
  196. case 'in':
  197. $sSearchValue = " IN (" . $this->implode_escape($aSearchParam['value']) . ")";
  198. break;
  199. case 'and':
  200. $iResult = 0;
  201. if (is_array($aSearchParam['value']))
  202. foreach ($aSearchParam['value'] as $iValue)
  203. $iResult |= pow (2, $iValue - 1);
  204. else
  205. $iResult = (int)$aSearchParam['value'];
  206. $sSearchValue = " & " . $iResult . "";
  207. break;
  208. default:
  209. $sSearchValue = " " . $aSearchParam['operator'] . " :" . $sSearchParam;
  210. $aMethod['params'][1][$sSearchParam] = $aSearchParam['value'];
  211. }
  212. $sWhereConditions .= " AND `{$this->_sTable}`.`" . $sSearchParam . "`" . $sSearchValue;
  213. }
  214. $sWhereClause .= " AND (" . $sWhereConditions . ")";
  215. $sOrderClause .= "`{$this->_sTable}`.`cmt_time` ASC";
  216. break;
  217. case 'all_ids':
  218. $aMethod['name'] = 'getColumn';
  219. $sSelectClause = "`{$this->_sTable}`.`cmt_id`";
  220. $sOrderClause = "`{$this->_sTable}`.`cmt_time` ASC";
  221. break;
  222. }
  223. if(!empty($sOrderClause))
  224. $sOrderClause = 'ORDER BY ' . $sOrderClause;
  225. if(!empty($sLimitClause))
  226. $sLimitClause = 'LIMIT ' . $sLimitClause;
  227. $aMethod['params'][0] = "SELECT " . $sSelectClause . " FROM `{$this->_sTable}` " . $sJoinClause . " WHERE 1 " . $sWhereClause . " " . $sOrderClause . " " . $sLimitClause;
  228. return call_user_func_array(array($this, $aMethod['name']), $aMethod['params']);
  229. }
  230. function getComment ($iId, $iCmtId)
  231. {
  232. $sFields = $sJoin = "";
  233. $oVote = $this->_oMain->getVoteObject($iCmtId);
  234. if($oVote !== false) {
  235. $aSql = $oVote->getSqlParts($this->_sTableIds, 'id');
  236. $sFields .= $aSql['fields'];
  237. $sJoin .= $aSql['join'];
  238. }
  239. $sQuery = $this->prepare("SELECT
  240. `{$this->_sTable}`.`cmt_id`,
  241. `{$this->_sTableIds}`.`id` AS `cmt_unique_id`,
  242. `{$this->_sTable}`.`cmt_parent_id`,
  243. `{$this->_sTable}`.`cmt_vparent_id`,
  244. `{$this->_sTable}`.`cmt_object_id`,
  245. `{$this->_sTable}`.`cmt_author_id`,
  246. `{$this->_sTable}`.`cmt_level`,
  247. `{$this->_sTable}`.`cmt_text`,
  248. `{$this->_sTable}`.`cmt_replies`,
  249. `{$this->_sTable}`.`cmt_time`
  250. $sFields
  251. FROM `{$this->_sTable}`
  252. LEFT JOIN `{$this->_sTableIds}` ON (`{$this->_sTable}`.`cmt_id` = `{$this->_sTableIds}`.`cmt_id` AND `{$this->_sTableIds}`.`system_id` = ?)
  253. $sJoin
  254. WHERE `{$this->_sTable}`.`cmt_object_id` = ? AND `{$this->_sTable}`.`cmt_id` = ?
  255. LIMIT 1", $this->_oMain->getSystemId(), $iId, $iCmtId);
  256. return $this->getRow($sQuery);
  257. }
  258. function getCommentSimple ($iId, $iCmtId)
  259. {
  260. $sQuery = $this->prepare("SELECT * FROM {$this->_sTable} AS `c` WHERE `cmt_object_id` = ? AND `cmt_id` = ? LIMIT 1", $iId, $iCmtId);
  261. return $this->getRow($sQuery);
  262. }
  263. function removeComment ($iId, $iCmtId, $iCmtParentId)
  264. {
  265. $sQuery = $this->prepare("DELETE FROM {$this->_sTable} WHERE `cmt_object_id` = ? AND `cmt_id` = ? LIMIT 1", $iId, $iCmtId);
  266. if (!$this->query($sQuery))
  267. return false;
  268. if($iCmtParentId)
  269. $this->updateRepliesCount($iCmtParentId, -1);
  270. return true;
  271. }
  272. function saveImages($iSystemId, $iCmtId, $iImageId)
  273. {
  274. $sQuery = $this->prepare("INSERT IGNORE INTO `{$this->_sTableFiles2Entries}` SET `system_id`=?, `cmt_id`=?, `image_id`=?", $iSystemId, $iCmtId, $iImageId);
  275. return (int)$this->query($sQuery) > 0;
  276. }
  277. function getFiles($iSystemId, $iCmtId, $iId = false)
  278. {
  279. $aBindings = array(
  280. 'system_id' => $iSystemId
  281. );
  282. $sJoin = "";
  283. $sWhere = " AND `tf2e`.`system_id` = :system_id ";
  284. if($iCmtId !== false) {
  285. $aBindings['cmt_id'] = $iCmtId;
  286. $sWhere .= " AND `tf2e`.`cmt_id` = :cmt_id ";
  287. }
  288. if($iId !== false) {
  289. $aBindings['cmt_object_id'] = $iId;
  290. $sWhere .= " AND `te`.`cmt_object_id` = :cmt_object_id";
  291. $sJoin .= " INNER JOIN `{$this->_sTable}` AS `te` ON (`tf2e`.`cmt_id` = `te`.`cmt_id`) ";
  292. }
  293. $sQuery = "SELECT
  294. `tf2e`.*,
  295. `tf`.`file_name` AS `file_name`,
  296. `tf`.`mime_type` AS `mime_type`,
  297. `tf`.`size` AS `size`
  298. FROM `{$this->_sTableFiles2Entries}` AS `tf2e`
  299. LEFT JOIN `{$this->_sTableFiles}` AS `tf` ON (`tf2e`.`image_id` = `tf`.`id`) " . $sJoin . "
  300. WHERE 1 " . $sWhere;
  301. return $this->getAll($sQuery, $aBindings);
  302. }
  303. function deleteImages($iSystemId, $iCmtId)
  304. {
  305. $aBindings = array(
  306. 'system_id' => $iSystemId
  307. );
  308. $sWhereAddon = "";
  309. if ($iCmtId !== false) {
  310. $aBindings['cmt_id'] = $iCmtId;
  311. $sWhereAddon = " AND `cmt_id` = :cmt_id ";
  312. }
  313. return $this->query("DELETE FROM `{$this->_sTableFiles2Entries}` WHERE `system_id` = :system_id" . $sWhereAddon, $aBindings);
  314. }
  315. function updateRepliesCount($iCmtId, $iCount)
  316. {
  317. $sQuery = $this->prepare("UPDATE `{$this->_sTable}` SET `cmt_replies`=`cmt_replies`+? WHERE `cmt_id`=? LIMIT 1", $iCount, $iCmtId);
  318. return $this->query($sQuery);
  319. }
  320. function deleteAuthorComments ($iAuthorId, &$aFiles = null, &$aCmtIds = null)
  321. {
  322. $aSystem = $this->_oMain->getSystemInfo();
  323. $isDelOccured = 0;
  324. $sQuery = $this->prepare("SELECT `cmt_id`, `cmt_parent_id` FROM {$this->_sTable} WHERE `cmt_author_id` = ? AND `cmt_replies` = 0", $iAuthorId);
  325. $a = $this->getAll ($sQuery);
  326. foreach ($a as $r) {
  327. $sQuery = $this->prepare("DELETE FROM {$this->_sTable} WHERE `cmt_id` = ?", $r['cmt_id']);
  328. $this->query ($sQuery);
  329. $sQuery = $this->prepare("UPDATE {$this->_sTable} SET `cmt_replies` = `cmt_replies` - 1 WHERE `cmt_id` = ?", $r['cmt_parent_id']);
  330. $this->query ($sQuery);
  331. $aFilesMore = $this->convertImagesArray($this->getFiles($aSystem['system_id'], $r['cmt_id']));
  332. $this->deleteImages($aSystem['system_id'], $r['cmt_id']);
  333. if ($aFilesMore && null !== $aFiles)
  334. $aFiles = array_merge($aFiles, $aFilesMore);
  335. if (null !== $aCmtIds)
  336. $aCmtIds[] = $r['cmt_id'];
  337. $isDelOccured = 1;
  338. }
  339. $sQuery = $this->prepare("UPDATE {$this->_sTable} SET `cmt_author_id` = 0 WHERE `cmt_author_id` = ? AND `cmt_replies` != 0", $iAuthorId);
  340. $this->query ($sQuery);
  341. if ($isDelOccured)
  342. $this->query ("OPTIMIZE TABLE {$this->_sTable}");
  343. }
  344. function deleteObjectComments ($iObjectId, &$aFilesReturn = null, &$aCmtIds = null)
  345. {
  346. $aSystem = $this->_oMain->getSystemInfo();
  347. $aFiles = $this->convertImagesArray($this->getFiles($aSystem['system_id'], false, $iObjectId));
  348. if ($aFiles) {
  349. $sQuery = $this->prepare("DELETE FROM {$this->_sTableFiles2Entries} WHERE `system_id` = ? AND `image_id` IN(" . $this->implode_escape($aFiles) . ")", $aSystem['system_id']);
  350. $this->query($sQuery);
  351. }
  352. if (null !== $aCmtIds) {
  353. $sQuery = $this->prepare("SELECT `cmt_id` FROM {$this->_sTable} WHERE `cmt_object_id` = ?", $iObjectId);
  354. $aCmtIds = $this->getColumn ($sQuery);
  355. }
  356. $sQuery = $this->prepare("DELETE FROM {$this->_sTable} WHERE `cmt_object_id` = ?", $iObjectId);
  357. $this->query ($sQuery);
  358. $this->query ("OPTIMIZE TABLE {$this->_sTable}");
  359. if (null !== $aFilesReturn)
  360. $aFilesReturn = $aFiles;
  361. }
  362. function deleteAll ($iSystemId, &$aFiles = null, &$aCmtIds = null)
  363. {
  364. // get files
  365. if (null !== $aFiles)
  366. $aFiles = $this->convertImagesArray($this->getFiles($iSystemId, false));
  367. // delete files
  368. $this->deleteImages($iSystemId, false);
  369. if (null !== $aCmtIds)
  370. $aCmtIds = $this->getColumn ("SELECT `cmt_id` FROM {$this->_sTable}");
  371. // delete comments
  372. $sQuery = $this->prepare("TRUNCATE TABLE {$this->_sTable}");
  373. $this->query ($sQuery);
  374. }
  375. function deleteCmtIds ($iSystemId, $iCmtId)
  376. {
  377. $sQuery = $this->prepare("DELETE FROM {$this->_sTableIds} WHERE `system_id` = ? AND `cmt_id` = ?", $iSystemId, $iCmtId);
  378. return $this->query ($sQuery);
  379. }
  380. function getObjectAuthorId($iId)
  381. {
  382. $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldAuthor}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ? LIMIT 1", $iId);
  383. return $this->getOne($sQuery);
  384. }
  385. function getObjectTitle($iId)
  386. {
  387. $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldTitle}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ? LIMIT 1", $iId);
  388. return $this->getOne($sQuery);
  389. }
  390. function updateTriggerTable($iId, $iCount)
  391. {
  392. $sQuery = $this->prepare("UPDATE `{$this->_sTriggerTable}` SET `{$this->_sTriggerFieldComments}` = ? WHERE `{$this->_sTriggerFieldId}` = ? LIMIT 1", $iCount, $iId);
  393. return $this->query($sQuery);
  394. }
  395. function getUniqId($iSystemId, $iCmtId)
  396. {
  397. $sQuery = $this->prepare("SELECT `id` FROM `{$this->_sTableIds}` WHERE `system_id` = ? AND `cmt_id` = ?", $iSystemId, $iCmtId);
  398. if ($iUniqId = $this->getOne($sQuery))
  399. return $iUniqId;
  400. $sQuery = $this->prepare("INSERT INTO `{$this->_sTableIds}` SET `system_id` = ?, `cmt_id` = ?", $iSystemId, $iCmtId);
  401. if (!$this->query($sQuery))
  402. return false;
  403. return $this->lastId();
  404. }
  405. protected function convertImagesArray($a)
  406. {
  407. if (!$a || !is_array($a))
  408. return array();
  409. $aFiles = array ();
  410. foreach ($a as $aFile)
  411. $aFiles[] = $aFile['image_id'];
  412. return $aFiles;
  413. }
  414. }
  415. /** @} */