3 * Table Definition for confirm_address
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
7 class Confirm_address extends Managed_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'confirm_address'; // table name
13 public $code; // varchar(32) primary_key not_null
14 public $user_id; // int(4) not_null
15 public $address; // varchar(191) not_null not 255 because utf8mb4 takes more space
16 public $address_extra; // varchar(191) not_null not 255 because utf8mb4 takes more space
17 public $address_type; // varchar(8) not_null
18 public $claimed; // datetime()
19 public $sent; // datetime()
20 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
22 /* the code above is auto generated do not remove the tag below */
25 public static function schemaDef()
29 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'),
30 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who requested confirmation'),
31 'address' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'address (email, xmpp, SMS, etc.)'),
32 'address_extra' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'carrier ID, for SMS'),
33 'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'),
34 'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'),
35 'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'),
36 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
38 'primary key' => array('code'),
39 'foreign keys' => array(
40 'confirm_address_user_id_fkey' => array('user', array('user_id' => 'id')),
45 static function getAddress($address, $addressType)
47 $ca = new Confirm_address();
49 $ca->address = $address;
50 $ca->address_type = $addressType;
52 if ($ca->find(true)) {
59 static function saveNew($user, $address, $addressType, $extra=null)
61 $ca = new Confirm_address();
64 $ca->user_id = $user->id;
67 $ca->address = $address;
68 $ca->address_type = $addressType;
69 $ca->address_extra = $extra;
70 $ca->code = common_confirmation_code(64);