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(191) primary_key not_null not 255 because utf8mb4 takes more space
14 public $consumer_secret; // varchar(191) not_null not 255 because utf8mb4 takes more space
15 public $seed; // char(32) not_null
16 public $created; // datetime not_null
17 public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
19 /* the code above is auto generated do not remove the tag below */
22 public static function schemaDef()
25 'description' => 'OAuth consumer record',
27 'consumer_key' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'unique identifier, root URL'),
28 'consumer_secret' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'secret value'),
29 'seed' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'seed for new tokens by this consumer'),
31 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
32 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
34 'primary key' => array('consumer_key'),
38 static function generateNew()
40 $cons = new Consumer();
41 $rand = common_random_hexstr(16);
44 $cons->consumer_key = md5(time() + $rand);
45 $cons->consumer_secret = md5(md5(time() + time() + $rand));
46 $cons->created = common_sql_now();
52 * Delete a Consumer and related tokens and nonces
54 * XXX: Should this happen in an OAuthDataStore instead?
57 function delete($useWhere=false)
59 // XXX: Is there any reason NOT to do this kind of cleanup?
61 $this->_deleteTokens();
62 $this->_deleteNonces();
64 return parent::delete($useWhere);
67 function _deleteTokens()
70 $token->consumer_key = $this->consumer_key;
74 function _deleteNonces()
77 $nonce->consumer_key = $this->consumer_key;