BxBaseModProfileDb.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseProfile Base classes for profile modules
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxBaseModGeneralDb');
  12. /*
  13. * Profile based module database queries
  14. */
  15. class BxBaseModProfileDb extends BxBaseModGeneralDb
  16. {
  17. public function __construct(&$oConfig)
  18. {
  19. parent::__construct($oConfig);
  20. }
  21. public function getContentInfoById ($iContentId)
  22. {
  23. $sQuery = $this->prepare ("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = 'bx_persons') WHERE `c`.`id` = ?", $iContentId);
  24. return $this->getRow($sQuery);
  25. }
  26. public function updateContentPictureById($iContentId, $iProfileId, $iPictureId, $sFieldPicture)
  27. {
  28. $sQuery = $this->prepare ("UPDATE `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` SET `" . $sFieldPicture . "` = ? WHERE `id` = ? AND `author` = ?", $iPictureId, $iContentId, $iProfileId);
  29. return $this->res($sQuery);
  30. }
  31. public function searchByTerm($sTerm, $iLimit)
  32. {
  33. $sQuery = $this->prepare("SELECT `c`.`id` AS `content_id`, `p`.`account_id`, `p`.`id` AS `profile_id`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = 'bx_persons') WHERE `p`.`status` = ? AND `c`.`fullname` LIKE ? ORDER BY `added` DESC LIMIT ?", BX_PROFILE_STATUS_ACTIVE, '%' . $sTerm . '%', (int)$iLimit);
  34. return $this->getAll($sQuery);
  35. }
  36. }
  37. /** @} */