3 * Table Definition for confirm_address
6 class Confirm_address extends Managed_DataObject
8 public $__table = 'confirm_address'; // table name
9 public $code; // varchar(32) primary_key not_null
10 public $user_id; // int(4) not_null
11 public $address; // varchar(191) not_null not 255 because utf8mb4 takes more space
12 public $address_extra; // varchar(191) not_null not 255 because utf8mb4 takes more space
13 public $address_type; // varchar(8) not_null
14 public $claimed; // datetime()
15 public $sent; // datetime()
16 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
18 public static function schemaDef()
22 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'),
23 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who requested confirmation'),
24 'address' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'address (email, xmpp, SMS, etc.)'),
25 'address_extra' => array('type' => 'varchar', 'length' => 191, 'description' => 'carrier ID, for SMS'),
26 'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'),
27 'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'),
28 'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'),
29 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
31 'primary key' => array('code'),
32 'foreign keys' => array(
33 'confirm_address_user_id_fkey' => array('user', array('user_id' => 'id')),
38 static function getAddress($address, $addressType)
40 $ca = new Confirm_address();
42 $ca->address = $address;
43 $ca->address_type = $addressType;
45 if ($ca->find(true)) {
52 static function saveNew($user, $address, $addressType, $extra=null)
54 $ca = new Confirm_address();
57 $ca->user_id = $user->id;
60 $ca->address = $address;
61 $ca->address_type = $addressType;
62 $ca->address_extra = $extra;
63 $ca->code = common_confirmation_code(64);