User_openid.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Table Definition for user_openid
  4. */
  5. if (!defined('STATUSNET')) {
  6. exit(1);
  7. }
  8. class User_openid extends Managed_DataObject
  9. {
  10. ###START_AUTOCODE
  11. /* the code below is auto generated do not remove the above tag */
  12. public $__table = 'user_openid'; // table name
  13. public $canonical; // varchar(191) primary_key not_null
  14. public $display; // varchar(191) unique_key not_null
  15. public $user_id; // int(4) not_null
  16. public $created; // datetime() not_null
  17. public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
  18. /* the code above is auto generated do not remove the tag below */
  19. ###END_AUTOCODE
  20. public static function schemaDef()
  21. {
  22. return array(
  23. 'fields' => array(
  24. 'canonical' => array('type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'OpenID canonical string'),
  25. 'display' => array('type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'OpenID display string'),
  26. 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'User ID for OpenID owner'),
  27. 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
  28. 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
  29. ),
  30. 'primary key' => array('canonical'),
  31. 'unique keys' => array(
  32. 'user_openid_display_key' => array('display'),
  33. ),
  34. 'indexes' => array(
  35. 'user_openid_user_id_idx' => array('user_id'),
  36. ),
  37. 'foreign keys' => array(
  38. 'user_openid_user_id_fkey' => array('user', array('user_id' => 'id')),
  39. ),
  40. );
  41. }
  42. public function getID()
  43. {
  44. if (!isset($this->user_id)) {
  45. throw new Exception('No ID set.');
  46. } elseif (empty($this->user_id)) {
  47. throw new Exception('Empty ID for object! (not inserted yet?).');
  48. }
  49. return intval($this->user_id);
  50. }
  51. static function hasOpenID($user_id)
  52. {
  53. $oid = new User_openid();
  54. $oid->user_id = $user_id;
  55. $cnt = $oid->find();
  56. return ($cnt > 0);
  57. }
  58. }