| 
									
										
										
										
											2008-06-20 01:15:36 -04:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2008-06-22 11:50:28 -04:00
										 |  |  |  * Table Definition for confirm_address | 
					
						
							| 
									
										
										
										
											2008-06-20 01:15:36 -04:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-09-26 12:18:24 -04:00
										 |  |  | require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; | 
					
						
							| 
									
										
										
										
											2008-06-20 01:15:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-22 17:52:02 -04:00
										 |  |  | class Confirm_address extends Managed_DataObject  | 
					
						
							| 
									
										
										
										
											2008-06-20 01:15:36 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     ###START_AUTOCODE
 | 
					
						
							|  |  |  |     /* the code below is auto generated do not remove the above tag */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-22 11:50:28 -04:00
										 |  |  |     public $__table = 'confirm_address';                 // table name
 | 
					
						
							| 
									
										
										
										
											2008-06-20 01:15:36 -04:00
										 |  |  |     public $code;                            // varchar(32)  primary_key not_null
 | 
					
						
							|  |  |  |     public $user_id;                         // int(4)   not_null
 | 
					
						
							| 
									
										
										
										
											2015-02-12 18:18:55 +01:00
										 |  |  |     public $address;                         // varchar(191)   not_null   not 255 because utf8mb4 takes more space
 | 
					
						
							|  |  |  |     public $address_extra;                   // varchar(191)   not_null   not 255 because utf8mb4 takes more space
 | 
					
						
							| 
									
										
										
										
											2008-06-22 12:16:07 -04:00
										 |  |  |     public $address_type;                    // varchar(8)   not_null
 | 
					
						
							| 
									
										
										
										
											2008-07-15 15:55:13 -04:00
										 |  |  |     public $claimed;                         // datetime()  
 | 
					
						
							|  |  |  |     public $sent;                            // datetime()  
 | 
					
						
							| 
									
										
										
										
											2008-06-20 01:15:36 -04:00
										 |  |  |     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* the code above is auto generated do not remove the tag below */ | 
					
						
							|  |  |  |     ###END_AUTOCODE
 | 
					
						
							| 
									
										
										
										
											2008-07-09 18:46:30 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-22 17:52:02 -04:00
										 |  |  |     public static function schemaDef() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return array( | 
					
						
							|  |  |  |             'fields' => array( | 
					
						
							|  |  |  |                 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'good random code'), | 
					
						
							|  |  |  |                 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who requested confirmation'), | 
					
						
							| 
									
										
										
										
											2015-02-12 18:18:55 +01:00
										 |  |  |                 'address' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'address (email, xmpp, SMS, etc.)'), | 
					
						
							|  |  |  |                 'address_extra' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'carrier ID, for SMS'), | 
					
						
							| 
									
										
										
										
											2011-08-22 17:52:02 -04:00
										 |  |  |                 'address_type' => array('type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'), | 
					
						
							|  |  |  |                 'claimed' => array('type' => 'datetime', 'description' => 'date this was claimed for queueing'), | 
					
						
							|  |  |  |                 'sent' => array('type' => 'datetime', 'description' => 'date this was sent for queueing'), | 
					
						
							|  |  |  |                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |             'primary key' => array('code'), | 
					
						
							|  |  |  |             'foreign keys' => array( | 
					
						
							|  |  |  |                 'confirm_address_user_id_fkey' => array('user', array('user_id' => 'id')), | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-17 17:46:32 -04:00
										 |  |  |     static function getAddress($address, $addressType) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $ca = new Confirm_address(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $ca->address      = $address; | 
					
						
							|  |  |  |         $ca->address_type = $addressType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ($ca->find(true)) { | 
					
						
							|  |  |  |             return $ca; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static function saveNew($user, $address, $addressType, $extra=null) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $ca = new Confirm_address(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!empty($user)) { | 
					
						
							|  |  |  |             $ca->user_id = $user->id; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $ca->address       = $address; | 
					
						
							|  |  |  |         $ca->address_type  = $addressType; | 
					
						
							|  |  |  |         $ca->address_extra = $extra; | 
					
						
							|  |  |  |         $ca->code          = common_confirmation_code(64); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $ca->insert(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $ca; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-06-20 01:15:36 -04:00
										 |  |  | } |