1
0

BxBaseModConnectDb.php 3.3 KB

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