BxBaseModConnectDb.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 BaseConnect Base classes for OAuth connect modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModConnectDb extends BxBaseModGeneralDb
  12. {
  13. protected $sTablePrefix;
  14. function __construct(&$oConfig)
  15. {
  16. parent::__construct($oConfig);
  17. $this -> sTablePrefix = $oConfig -> getDbPrefix();
  18. }
  19. /**
  20. * Check remote profile id
  21. *
  22. * @param $iRemoteId integer
  23. * @return local profile id
  24. */
  25. function getProfileId($iRemoteId)
  26. {
  27. $iRemoteId = (int) $iRemoteId;
  28. $sQuery = $this->prepare ("SELECT `local_profile` FROM `{$this -> sTablePrefix}accounts` WHERE `remote_profile` = ? LIMIT 1", $iRemoteId);
  29. return $this -> getOne($sQuery);
  30. }
  31. /**
  32. * Save new remote ID
  33. *
  34. * @param $iProfileId integer
  35. * @param $iRemoteId integer
  36. * @return bool
  37. */
  38. function saveRemoteId($iProfileId, $iRemoteId)
  39. {
  40. $iRemoteId = (int) $iRemoteId;
  41. $iProfileId = (int) $iProfileId;
  42. $sQuery = $this->prepare ("REPLACE INTO `{$this -> sTablePrefix}accounts` SET `local_profile` = ?, `remote_profile` = ?", $iProfileId, $iRemoteId);
  43. return $this -> query($sQuery);
  44. }
  45. /**
  46. * Delete remote account
  47. *
  48. * @param $iProfileId integer
  49. * @return void
  50. */
  51. function deleteRemoteAccount($iProfileId)
  52. {
  53. $iProfileId = (int) $iProfileId;
  54. $sQuery = $this->prepare ("DELETE FROM `{$this -> sTablePrefix}accounts` WHERE `local_profile` = ?", $iProfileId);
  55. return $this -> query($sQuery);
  56. }
  57. /**
  58. * Make as friends
  59. *
  60. * @param $iMemberId integer
  61. * @param $iProfileId intger
  62. * @return void
  63. */
  64. function makeFriend($iMemberId, $iProfileId)
  65. {
  66. // TODO:
  67. return null;
  68. }
  69. /**
  70. * Create new profile;
  71. *
  72. * @param : (array) $aProfileFields - `Profiles` table's fields;
  73. * @return : (integer) - profile's Id;
  74. */
  75. function createProfile(&$aProfileFields)
  76. {
  77. // TODO:
  78. return null;
  79. }
  80. /**
  81. * Function will update profile's status;
  82. *
  83. * @param : $iProfileId (integer) - profile's Id;
  84. * @param : $sStatus (string) - profile's status;
  85. * @return : void;
  86. */
  87. function updateProfileStatus($iProfileId, $sStatus)
  88. {
  89. // TODO:
  90. return null;
  91. }
  92. /**
  93. * Function will check field name in 'Profiles` table;
  94. *
  95. * @param $sFieldName string
  96. * @return : (boolean);
  97. */
  98. function isFieldExist($sFieldName)
  99. {
  100. // TODO:
  101. return null;
  102. }
  103. /**
  104. * Check existing email
  105. *
  106. * @param $sEmail string
  107. * @return boolean
  108. */
  109. function isEmailExisting($sEmail)
  110. {
  111. // TODO:
  112. return null;
  113. }
  114. }
  115. /** @} */