]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
utility functions for Confirm_address
authorEvan Prodromou <evan@status.net>
Sun, 17 Apr 2011 21:46:32 +0000 (17:46 -0400)
committerEvan Prodromou <evan@status.net>
Sun, 17 Apr 2011 21:46:32 +0000 (17:46 -0400)
classes/Confirm_address.php

index ed3875d223c0ff5935979861a4adc5951e919040..4b9bec64c63c4bbf5e37162766f905fed0a9c5c2 100644 (file)
@@ -28,4 +28,36 @@ class Confirm_address extends Memcached_DataObject
 
     function sequenceKey()
     { return array(false, false); }
+
+    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;
+    }
 }