Sms_carrier.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 sms_carrier
  18. */
  19. defined('GNUSOCIAL') || die();
  20. class Sms_carrier extends Managed_DataObject
  21. {
  22. ###START_AUTOCODE
  23. /* the code below is auto generated do not remove the above tag */
  24. public $__table = 'sms_carrier'; // table name
  25. public $id; // int(4) primary_key not_null
  26. public $name; // varchar(64) unique_key
  27. public $email_pattern; // varchar(191) not_null not 255 because utf8mb4 takes more space
  28. public $created; // datetime()
  29. public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
  30. /* the code above is auto generated do not remove the tag below */
  31. ###END_AUTOCODE
  32. public function toEmailAddress($sms)
  33. {
  34. return sprintf($this->email_pattern, $sms);
  35. }
  36. public static function schemaDef()
  37. {
  38. return array(
  39. 'fields' => array(
  40. 'id' => array('type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'),
  41. 'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'),
  42. 'email_pattern' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'),
  43. 'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
  44. 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
  45. ),
  46. 'primary key' => array('id'),
  47. 'unique keys' => array(
  48. 'sms_carrier_name_key' => array('name'),
  49. ),
  50. );
  51. }
  52. }