From 224d82793c769c06d1e4f39c19cd5f2e9cf519b0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 20 Nov 2009 02:50:43 -0800 Subject: Revert "Added 'login' command that gives you a link that can be used to login to the website" This reverts commit b9d40f723bce8e01ddcbbb989bd7035b92cd9af8. Conflicts: actions/login.php classes/statusnet.ini db/08to09.sql db/08to09_pg.sql db/statusnet_pg.sql lib/command.php lib/commandinterpreter.php --- classes/Login_token.php | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 classes/Login_token.php (limited to 'classes') diff --git a/classes/Login_token.php b/classes/Login_token.php deleted file mode 100644 index bd6381f90..000000000 --- a/classes/Login_token.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } - -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; - -class Login_token extends Memcached_DataObject -{ - ###START_AUTOCODE - /* the code below is auto generated do not remove the above tag */ - - public $__table = 'login_token'; // table name - public $user_id; // int(4) primary_key not_null - public $token; // char(32) not_null - public $created; // datetime() not_null - public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP - - /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Login_token',$k,$v); } - - /* the code above is auto generated do not remove the tag below */ - ###END_AUTOCODE -} -- cgit v1.2.3-54-g00ecf From c0190af9821a402497a0ddf8238955d4cceefd48 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 25 Nov 2009 19:22:09 +0000 Subject: Remove annoying log msg --- classes/Avatar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/Avatar.php b/classes/Avatar.php index cc7a6b647..8d6424e8b 100644 --- a/classes/Avatar.php +++ b/classes/Avatar.php @@ -81,7 +81,7 @@ class Avatar extends Memcached_DataObject if (empty($server)) { $server = common_config('site', 'server'); } - common_debug('path = ' . $path); + // XXX: protocol return 'http://'.$server.$path.$filename; -- cgit v1.2.3-54-g00ecf From b771a8bb2124d4e48df2e3d3d3078c4de1da3483 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 25 Nov 2009 22:10:55 +0000 Subject: Fix regression in remote subscription; added hasRole() shadow method on Remote_profile. DB_DataObject hides errors by silently returning null for any non-existent method call, making it harder to tell what the heck's going on... the rights check for blocked remote users returned null for the check for subscribe rights, thus eval'ing to false. We now log a note in this circumstance, which would have cut about 3 hours off of the debug time. --- classes/Remote_profile.php | 10 ++++++++++ lib/oauthstore.php | 1 + 2 files changed, 11 insertions(+) (limited to 'classes') diff --git a/classes/Remote_profile.php b/classes/Remote_profile.php index 9f7bfeadc..0a1676a6a 100644 --- a/classes/Remote_profile.php +++ b/classes/Remote_profile.php @@ -43,4 +43,14 @@ class Remote_profile extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + function hasRight($right) + { + $profile = Profile::staticGet($this->id); + if ($profile) { + return $profile->hasright($right); + } else { + throw new Exception("Missing profile"); + } + } } diff --git a/lib/oauthstore.php b/lib/oauthstore.php index b04bcbb8b..e34bf8a5e 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -463,6 +463,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore $subscriber = $this->_getAnyProfile($subscriber_uri); if (!$subscriber->hasRight(Right::SUBSCRIBE)) { + common_log(LOG_INFO, __METHOD__ . ": remote subscriber banned ($subscriber_uri subbing to $subscribed_user_uri)"); return _('You have been banned from subscribing.'); } -- cgit v1.2.3-54-g00ecf From 2b6cf0d8b6b276eeccb623ec7886effd75423aeb Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 25 Nov 2009 13:38:59 -0800 Subject: Revert "Allow plugin DB_DataObject classes to not have to use the .ini file by overriding keys(), table(), and sequenceKey() for them" This reverts commit a373d07ae00b878f47970f2e4a7d86c6ec3a65cf. Conflicts: classes/statusnet.ini lib/schema.php plugins/Authentication/AuthenticationPlugin.php plugins/OpenID/OpenIDPlugin.php plugins/UserFlag/UserFlagPlugin.php --- classes/Plugin_DataObject.php | 195 ------------------------ lib/schema.php | 20 --- plugins/Authentication/AuthenticationPlugin.php | 13 +- plugins/Authentication/User_username.php | 22 +-- plugins/OpenID/OpenIDPlugin.php | 20 ++- plugins/OpenID/User_openid.php | 22 +-- plugins/OpenID/User_openid_trustroot.php | 20 +-- plugins/UserFlag/UserFlagPlugin.php | 11 +- plugins/UserFlag/User_flag_profile.php | 21 +-- 9 files changed, 47 insertions(+), 297 deletions(-) delete mode 100644 classes/Plugin_DataObject.php (limited to 'classes') diff --git a/classes/Plugin_DataObject.php b/classes/Plugin_DataObject.php deleted file mode 100644 index d5cecf0f7..000000000 --- a/classes/Plugin_DataObject.php +++ /dev/null @@ -1,195 +0,0 @@ -. - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } - -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; - -abstract class Plugin_DataObject extends Memcached_DataObject -{ - function table() { - static $table = null; - if($table == null) { - $table = array(); - $DB = $this->getDatabaseConnection(); - $dbtype = $DB->phptype; - $tableDef = $this->tableDef(); - foreach($tableDef->columns as $columnDef){ - switch(strtoupper($columnDef->type)) { - /*shamelessly copied from DB_DataObject_Generator*/ - case 'INT': - case 'INT2': // postgres - case 'INT4': // postgres - case 'INT8': // postgres - case 'SERIAL4': // postgres - case 'SERIAL8': // postgres - case 'INTEGER': - case 'TINYINT': - case 'SMALLINT': - case 'MEDIUMINT': - case 'BIGINT': - $type = DB_DATAOBJECT_INT; - if ($columnDef->size == 1) { - $type += DB_DATAOBJECT_BOOL; - } - break; - - case 'REAL': - case 'DOUBLE': - case 'DOUBLE PRECISION': // double precision (firebird) - case 'FLOAT': - case 'FLOAT4': // real (postgres) - case 'FLOAT8': // double precision (postgres) - case 'DECIMAL': - case 'MONEY': // mssql and maybe others - case 'NUMERIC': - case 'NUMBER': // oci8 - $type = DB_DATAOBJECT_INT; // should really by FLOAT!!! / MONEY... - break; - - case 'YEAR': - $type = DB_DATAOBJECT_INT; - break; - - case 'BIT': - case 'BOOL': - case 'BOOLEAN': - - $type = DB_DATAOBJECT_BOOL; - // postgres needs to quote '0' - if ($dbtype == 'pgsql') { - $type += DB_DATAOBJECT_STR; - } - break; - - case 'STRING': - case 'CHAR': - case 'VARCHAR': - case 'VARCHAR2': - case 'TINYTEXT': - - case 'ENUM': - case 'SET': // not really but oh well - - case 'POINT': // mysql geometry stuff - not really string - but will do.. - - case 'TIMESTAMPTZ': // postgres - case 'BPCHAR': // postgres - case 'INTERVAL': // postgres (eg. '12 days') - - case 'CIDR': // postgres IP net spec - case 'INET': // postgres IP - case 'MACADDR': // postgress network Mac address. - - case 'INTEGER[]': // postgres type - case 'BOOLEAN[]': // postgres type - - $type = DB_DATAOBJECT_STR; - break; - - case 'TEXT': - case 'MEDIUMTEXT': - case 'LONGTEXT': - - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT; - break; - - - case 'DATE': - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE; - break; - - case 'TIME': - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_TIME; - break; - - - case 'DATETIME': - - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME; - break; - - case 'TIMESTAMP': // do other databases use this??? - - $type = ($dbtype == 'mysql') ? - DB_DATAOBJECT_MYSQLTIMESTAMP : - DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME; - break; - - - case 'BLOB': /// these should really be ignored!!!??? - case 'TINYBLOB': - case 'MEDIUMBLOB': - case 'LONGBLOB': - - case 'CLOB': // oracle character lob support - - case 'BYTEA': // postgres blob support.. - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_BLOB; - break; - - default: - throw new Exception("Cannot handle datatype: $columnDef->type"); - } - if(! $columnDef->nullable) { - $type+=DB_DATAOBJECT_NOTNULL; - } - $table[$columnDef->name]=$type; - } - } - return $table; - } - - function keys() { - static $keys = null; - if($keys == null) { - $keys = array(); - $tableDef = $this->tableDef(); - foreach($tableDef->columns as $columnDef){ - if($columnDef->key != null){ - $keys[] = $columnDef->name; - } - } - } - return $keys; - } - - function sequenceKey() { - static $sequenceKey = null; - if($sequenceKey == null) { - $sequenceKey = array(false,false); - $tableDef = $this->tableDef(); - foreach($tableDef->columns as $columnDef){ - if($columnDef->key == 'PRI' && $columnDef->auto_increment){ - $sequenceKey=array($columnDef->name,true); - } - } - } - return $sequenceKey; - } - - /** - * Get the TableDef object that represents the table backing this class - * Ideally, this function would a static function, but PHP doesn't allow - * abstract static functions - * @return TableDef TableDef instance - */ - abstract function tableDef(); -} - diff --git a/lib/schema.php b/lib/schema.php index 11e2b6f60..df7cb65f5 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -372,26 +372,6 @@ class Schema return true; } - /** - * Ensures that the table that backs a given - * Plugin_DataObject class exists. - * - * If the table does not yet exist, it will - * create the table. If it does exist, it will - * alter the table to match the column definitions. - * - * @param Plugin_DataObject $dataObjectClass - * - * @return boolean success flag - */ - - public function ensureDataObject($dataObjectClass) - { - $obj = new $dataObjectClass(); - $tableDef = $obj->tableDef(); - return $this->ensureTable($tableDef->name,$tableDef->columns); - } - /** * Ensures that a table exists with the given * name and the given column definitions. diff --git a/plugins/Authentication/AuthenticationPlugin.php b/plugins/Authentication/AuthenticationPlugin.php index cd1de1149..a76848b04 100644 --- a/plugins/Authentication/AuthenticationPlugin.php +++ b/plugins/Authentication/AuthenticationPlugin.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * Superclass for plugins that do authentication + * Superclass for plugins that do authentication and/or authorization * * PHP version 5 * @@ -204,7 +204,16 @@ abstract class AuthenticationPlugin extends Plugin function onCheckSchema() { $schema = Schema::get(); - $schema->ensureDataObject('User_username'); + $schema->ensureTable('user_username', + array(new ColumnDef('provider_name', 'varchar', + '255', false, 'PRI'), + new ColumnDef('username', 'varchar', + '255', false, 'PRI'), + new ColumnDef('user_id', 'integer', + null, false), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); return true; } diff --git a/plugins/Authentication/User_username.php b/plugins/Authentication/User_username.php index 6826f2681..f30f60d83 100644 --- a/plugins/Authentication/User_username.php +++ b/plugins/Authentication/User_username.php @@ -2,9 +2,9 @@ /** * Table Definition for user_username */ -require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_username extends Plugin_DataObject +class User_username extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,22 +43,4 @@ class User_username extends Plugin_DataObject return false; } } - - /** - * Get the TableDef object that represents the table backing this class - * @return TableDef TableDef instance - */ - function tableDef() - { - return new TableDef($this->__table, - array(new ColumnDef('provider_name', 'varchar', - '255', false, 'PRI'), - new ColumnDef('username', 'varchar', - '255', false, 'PRI'), - new ColumnDef('user_id', 'integer', - null, false), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); - } } diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index 6dd8a3f5a..9b0a4cd45 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -281,8 +281,24 @@ class OpenIDPlugin extends Plugin function onCheckSchema() { $schema = Schema::get(); - $schema->ensureDataObject('User_openid'); - $schema->ensureDataObject('User_openid_trustroot'); + $schema->ensureTable('user_openid', + array(new ColumnDef('canonical', 'varchar', + '255', false, 'PRI'), + new ColumnDef('display', 'varchar', + '255', false), + new ColumnDef('user_id', 'integer', + null, false, 'MUL'), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); + $schema->ensureTable('user_openid_trustroot', + array(new ColumnDef('trustroot', 'varchar', + '255', false, 'PRI'), + new ColumnDef('user_id', 'integer', + null, false, 'PRI'), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); return true; } diff --git a/plugins/OpenID/User_openid.php b/plugins/OpenID/User_openid.php index c3624118e..338e0f6e9 100644 --- a/plugins/OpenID/User_openid.php +++ b/plugins/OpenID/User_openid.php @@ -2,9 +2,9 @@ /** * Table Definition for user_openid */ -require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_openid extends Plugin_DataObject +class User_openid extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -33,22 +33,4 @@ class User_openid extends Plugin_DataObject return ($cnt > 0); } - - /** - * Get the TableDef object that represents the table backing this class - * @return TableDef TableDef instance - */ - function tableDef() - { - return new TableDef($this->__table, - array(new ColumnDef('canonical', 'varchar', - '255', false, 'PRI'), - new ColumnDef('display', 'varchar', - '255', false), - new ColumnDef('user_id', 'integer', - null, false, 'MUL'), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); - } } diff --git a/plugins/OpenID/User_openid_trustroot.php b/plugins/OpenID/User_openid_trustroot.php index b208dddfd..4654b72df 100644 --- a/plugins/OpenID/User_openid_trustroot.php +++ b/plugins/OpenID/User_openid_trustroot.php @@ -2,9 +2,9 @@ /** * Table Definition for user_openid_trustroot */ -require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_openid_trustroot extends Plugin_DataObject +class User_openid_trustroot extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -26,20 +26,4 @@ class User_openid_trustroot extends Plugin_DataObject { return Memcached_DataObject::pkeyGet('User_openid_trustroot', $kv); } - - /** - * Get the TableDef object that represents the table backing this class - * @return TableDef TableDef instance - */ - function tableDef() - { - return new TableDef($this->__table, - array(new ColumnDef('trustroot', 'varchar', - '255', false, 'PRI'), - new ColumnDef('user_id', 'integer', - null, false, 'PRI'), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); - } } diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php index 97b999a2f..1f1f19957 100644 --- a/plugins/UserFlag/UserFlagPlugin.php +++ b/plugins/UserFlag/UserFlagPlugin.php @@ -48,7 +48,16 @@ class UserFlagPlugin extends Plugin $schema = Schema::get(); // For storing user-submitted flags on profiles - $schema->ensureDataObject('User_flag_profile'); + + $schema->ensureTable('user_flag_profile', + array(new ColumnDef('profile_id', 'integer', null, + false, 'PRI'), + new ColumnDef('user_id', 'integer', null, + false, 'PRI'), + new ColumnDef('created', 'datetime', null, + false, 'MUL'), + new ColumnDef('cleared', 'datetime', null, + true, 'MUL'))); return true; } diff --git a/plugins/UserFlag/User_flag_profile.php b/plugins/UserFlag/User_flag_profile.php index 2fb27912d..30bd4ae68 100644 --- a/plugins/UserFlag/User_flag_profile.php +++ b/plugins/UserFlag/User_flag_profile.php @@ -21,9 +21,9 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; +require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; -class User_flag_profile extends Plugin_DataObject +class User_flag_profile extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -65,21 +65,4 @@ class User_flag_profile extends Plugin_DataObject return !empty($ufp); } - - /** - * Get the TableDef object that represents the table backing this class - * @return TableDef TableDef instance - */ - function tableDef() - { - return new TableDef($this->__table, - array(new ColumnDef('profile_id', 'integer', null, - false, 'PRI'), - new ColumnDef('user_id', 'integer', null, - false, 'PRI'), - new ColumnDef('created', 'datetime', null, - false, 'MUL'), - new ColumnDef('cleared', 'datetime', null, - true, 'MUL'))); - } } -- cgit v1.2.3-54-g00ecf From 54ad3b21d73fd08054bf0a65aa1cb9c13585de31 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 25 Nov 2009 23:26:04 +0000 Subject: Remove relationship: user_openid.user_id -> user.id. I don't think this is used. And if we need it, the OpenID plugin should do it. --- classes/statusnet.links.ini | 3 --- 1 file changed, 3 deletions(-) (limited to 'classes') diff --git a/classes/statusnet.links.ini b/classes/statusnet.links.ini index 95c63f3c0..7f233e676 100644 --- a/classes/statusnet.links.ini +++ b/classes/statusnet.links.ini @@ -22,9 +22,6 @@ consumer_key = consumer:consumer_key [nonce] consumer_key,token = token:consumer_key,token -[user_openid] -user_id = user:id - [confirm_address] user_id = user:id -- cgit v1.2.3-54-g00ecf From 261ee0264adfb40a0821e45de5f80f81a278a03c Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 26 Nov 2009 18:49:18 +0000 Subject: Add OpenID ini info back into statusnet.ini as a stopgap until we can get plugins to load ini info properly on status.net --- classes/statusnet.ini | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/statusnet.ini b/classes/statusnet.ini index b2509dac5..f12707ba1 100644 --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -1,4 +1,3 @@ - [avatar] profile_id = 129 original = 17 @@ -542,4 +541,25 @@ created = 142 modified = 384 [user_group__keys] -id = N \ No newline at end of file +id = N + +[user_openid] +canonical = 130 +display = 130 +user_id = 129 +created = 142 +modified = 384 + +[user_openid__keys] +canonical = K +display = U + +[user_openid_trustroot] +trustroot = 130 +user_id = 129 +created = 142 +modified = 384 + +[user_openid__keys] +trustroot = K +user_id = K \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 2ba67e9b6284043d39656d0476605bc8235edfd2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 27 Nov 2009 14:20:57 -0800 Subject: Log database errors when saving notice_inbox entries --- classes/Notice.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index ebb5022b9..3126cc064 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -964,7 +964,10 @@ class Notice extends Memcached_DataObject } if ($cnt >= MAX_BOXCARS) { $inbox = new Notice_inbox(); - $inbox->query($qry); + $result = $inbox->query($qry); + if (PEAR::isError($result)) { + common_log_db_error($inbox, $qry); + } $qry = $qryhdr; $cnt = 0; } @@ -972,7 +975,10 @@ class Notice extends Memcached_DataObject if ($cnt > 0) { $inbox = new Notice_inbox(); - $inbox->query($qry); + $result = $inbox->query($qry); + if (PEAR::isError($result)) { + common_log_db_error($inbox, $qry); + } } return; -- cgit v1.2.3-54-g00ecf From 496547699847761b0dfcc0d51182e28298428db4 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 27 Nov 2009 14:52:58 -0800 Subject: Fix regression in group posting: bug introduced in commit 1319002e1519fafb0e82fbfd2d2723abdb3112e7. Need to use actual profile object rather than an id on a variable that doesn't exist when checking blocks :D --- classes/Notice.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index 3126cc064..661072156 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -922,13 +922,14 @@ class Notice extends Memcached_DataObject } $groups = $this->saveGroups(); + $profile = $this->getProfile(); foreach ($groups as $group) { $users = $group->getUserMembers(); foreach ($users as $id) { if (!array_key_exists($id, $ni)) { $user = User::staticGet('id', $id); - if (!$user->hasBlocked($notice->profile_id)) { + if (!$user->hasBlocked($profile)) { $ni[$id] = NOTICE_INBOX_SOURCE_GROUP; } } -- cgit v1.2.3-54-g00ecf