]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Confirm_address.php
Possible hack for tags from private dents in public profile or wrong scope (both...
[quix0rs-gnu-social.git] / classes / Confirm_address.php
index d6d0d77960e64e7c6245c289f8c07a01eaae7c75..97c69872a60d1cb524c357e0a2b1f37a62a09b6f 100644 (file)
@@ -2,9 +2,9 @@
 /**
  * Table Definition for confirm_address
  */
-require_once 'DB/DataObject.php';
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 
-class Confirm_address extends DB_DataObject 
+class Confirm_address extends Managed_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -19,11 +19,58 @@ class Confirm_address extends DB_DataObject
     public $sent;                            // datetime()  
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 
-    /* Static get */
-    function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Confirm_address',$k,$v); }
-
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
-       
-    function sequenceKey() { return array(false, false); }
+
+    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'),
+                'address' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'address (email, xmpp, SMS, etc.)'),
+                'address_extra' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'carrier ID, for SMS'),
+                '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')),
+            ),
+        );
+    }
+
+    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 $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;
+    }
 }