3 * Table Definition for consumer
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
7 class Consumer extends Managed_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'consumer'; // table name
13 public $consumer_key; // varchar(255) primary_key not_null
14 public $consumer_secret; // varchar(255) not_null
15 public $seed; // char(32) not_null
16 public $created; // datetime not_null
17 public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
20 function staticGet($k,$v=null)
21 { return Memcached_DataObject::staticGet('Consumer',$k,$v); }
23 /* the code above is auto generated do not remove the tag below */
26 public static function schemaDef()
29 'description' => 'OAuth consumer record',
31 'consumer_key' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'unique identifier, root URL'),
32 'consumer_secret' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'secret value'),
33 'seed' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'seed for new tokens by this consumer'),
35 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
36 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
38 'primary key' => array('consumer_key'),
42 static function generateNew()
44 $cons = new Consumer();
45 $rand = common_good_rand(16);
48 $cons->consumer_key = md5(time() + $rand);
49 $cons->consumer_secret = md5(md5(time() + time() + $rand));
50 $cons->created = common_sql_now();
56 * Delete a Consumer and related tokens and nonces
58 * XXX: Should this happen in an OAuthDataStore instead?
63 // XXX: Is there any reason NOT to do this kind of cleanup?
65 $this->_deleteTokens();
66 $this->_deleteNonces();
71 function _deleteTokens()
74 $token->consumer_key = $this->consumer_key;
78 function _deleteNonces()
81 $nonce->consumer_key = $this->consumer_key;