Foreign_user.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Table Definition for foreign_user
  4. */
  5. require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
  6. class Foreign_user extends Managed_DataObject
  7. {
  8. ###START_AUTOCODE
  9. /* the code below is auto generated do not remove the above tag */
  10. public $__table = 'foreign_user'; // table name
  11. public $id; // bigint(8) primary_key not_null
  12. public $service; // int(4) primary_key not_null
  13. public $uri; // varchar(255) unique_key not_null
  14. public $nickname; // varchar(255)
  15. public $created; // datetime() not_null
  16. public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
  17. /* the code above is auto generated do not remove the tag below */
  18. ###END_AUTOCODE
  19. public static function schemaDef()
  20. {
  21. return array(
  22. 'fields' => array(
  23. 'id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'unique numeric key on foreign service'),
  24. 'service' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to service'),
  25. 'uri' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'identifying URI'),
  26. 'nickname' => array('type' => 'varchar', 'length' => 255, 'description' => 'nickname on foreign service'),
  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('id', 'service'),
  31. 'foreign keys' => array(
  32. 'foreign_user_service_fkey' => array('foreign_service', array('service' => 'id')),
  33. ),
  34. 'unique keys' => array(
  35. 'foreign_user_uri_key' => array('uri'),
  36. ),
  37. );
  38. }
  39. static function getForeignUser($id, $service) {
  40. $fuser = new Foreign_user();
  41. $fuser->id = $id;
  42. $fuser->service = $service;
  43. $fuser->limit(1);
  44. $result = $fuser->find(true);
  45. return empty($result) ? null : $fuser;
  46. }
  47. static function getByNickname($nickname, $service)
  48. {
  49. if (empty($nickname) || empty($service)) {
  50. return null;
  51. } else {
  52. $fuser = new Foreign_user();
  53. $fuser->service = $service;
  54. $fuser->nickname = $nickname;
  55. $fuser->limit(1);
  56. $result = $fuser->find(true);
  57. return empty($result) ? null : $fuser;
  58. }
  59. }
  60. }