Invitation.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Table Definition for invitation
  18. */
  19. defined('GNUSOCIAL') || die();
  20. class Invitation extends Managed_DataObject
  21. {
  22. ###START_AUTOCODE
  23. /* the code below is auto generated do not remove the above tag */
  24. public $__table = 'invitation'; // table name
  25. public $code; // varchar(32) primary_key not_null
  26. public $user_id; // int(4) not_null
  27. public $address; // varchar(191) multiple_key not_null not 255 because utf8mb4 takes more space
  28. public $address_type; // varchar(8) multiple_key not_null
  29. public $registered_user_id; // int(4) not_null
  30. public $created; // datetime()
  31. /* the code above is auto generated do not remove the tag below */
  32. ###END_AUTOCODE
  33. public function convert($user)
  34. {
  35. $orig = clone($this);
  36. $this->registered_user_id = $user->id;
  37. return $this->update($orig);
  38. }
  39. public static function schemaDef()
  40. {
  41. return array(
  42. 'fields' => array(
  43. 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'random code for an invitation'),
  44. 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'who sent the invitation'),
  45. 'address' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'invitation sent to'),
  46. 'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'),
  47. 'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
  48. 'registered_user_id' => array('type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'),
  49. ),
  50. 'primary key' => array('code'),
  51. 'foreign keys' => array(
  52. 'invitation_user_id_fkey' => array('user', array('user_id' => 'id')),
  53. 'invitation_registered_user_id_fkey' => array('user', array('registered_user_id' => 'id')),
  54. ),
  55. 'indexes' => array(
  56. 'invitation_address_address_type_idx' => array('address', 'address_type'),
  57. 'invitation_user_id_idx' => array('user_id'),
  58. 'invitation_registered_user_id_idx' => array('registered_user_id'),
  59. ),
  60. );
  61. }
  62. }