? twitter_d7_beerad.patch ? twitter_d7_beeradb-2-17-10.patch Index: twitter.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.inc,v retrieving revision 1.9.2.6 diff -u -p -r1.9.2.6 twitter.inc --- twitter.inc 16 Feb 2010 00:51:17 -0000 1.9.2.6 +++ twitter.inc 18 Feb 2010 03:49:13 -0000 @@ -27,7 +27,7 @@ function twitter_connect($account) { * Saves a TwitterUser object to {twitter_account} */ function twitter_account_save($twitter_user, $save_auth = FALSE, $account = NULL) { - $values = (array)$twitter_user; + $values = (array) $twitter_user; $values['twitter_uid'] = $values['id']; if ($save_auth) { @@ -38,7 +38,8 @@ function twitter_account_save($twitter_u } $values['uid'] = $account->uid; } - if (db_result(db_query("SELECT 1 FROM {twitter_account} WHERE twitter_uid = %d", $values['id']))) { + + if ((bool) db_query_range("SELECT 1 FROM {twitter_account} WHERE twitter_uid = :tuid", 0, 1, array(':tuid' => $values['id']))->fetchField()) { drupal_write_record('twitter_account', $values, array('twitter_uid')); } else { @@ -49,8 +50,9 @@ function twitter_account_save($twitter_u function twitter_account_load($id) { module_load_include('lib.php', 'twitter'); - $values = db_fetch_array(db_query("SELECT * FROM {twitter_account} WHERE twitter_uid = %d", $id)); + $values = (array) db_query("SELECT * FROM {twitter_account} WHERE twitter_uid = :uid", array(':uid' => $id))->fetch(); $values['id'] = $values['twitter_uid']; + $account = new TwitterUser($values); $account->set_auth($values); $account->uid = $values['uid']; @@ -68,7 +70,7 @@ function twitter_status_save($status) { $status->screen_name = $status->user->screen_name; $status->created_time = strtotime($status->created_at); - if (db_result(db_query("SELECT 1 FROM {twitter} WHERE twitter_id = %d", $status->id))) { + if (db_query("SELECT 1 FROM {twitter} WHERE twitter_id = :twitter_id", array(':twitter_id' => $status->id))->fetchCol()) { drupal_write_record('twitter', $status, array('twitter_id')); } else { @@ -93,7 +95,7 @@ function twitter_set_status($twitter_acc function twitter_fetch_user_timeline($id) { $account = twitter_account_load($id); - $since = db_result(db_query("SELECT MAX(twitter_id) FROM {twitter} WHERE screen_name = '%s'", $account->screen_name)); + $since = db_query("SELECT MAX(twitter_id) FROM {twitter} WHERE screen_name = ':screen_name'", array(':screen_name' => $account->screen_name))->fetchCol(); $twitter = twitter_connect($account); @@ -110,7 +112,7 @@ function twitter_fetch_user_timeline($id if (count($statuses) > 0) { twitter_account_save($statuses[0]->user); } - db_query("UPDATE {twitter_account} SET last_refresh = %d WHERE twitter_uid=%d", time(), $account->id); + db_query("UPDATE {twitter_account} SET last_refresh = :now WHERE twitter_uid = :twitter_uid", array(':now' => REQUEST_TIME, ':twitter_uid' =>$account->id)); } function twitter_user_delete($twitter_uid, $screen_name = NULL) { Index: twitter.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.info,v retrieving revision 1.4 diff -u -p -r1.4 twitter.info --- twitter.info 27 May 2009 19:00:07 -0000 1.4 +++ twitter.info 18 Feb 2010 03:49:13 -0000 @@ -2,4 +2,12 @@ name = Twitter description = Adds integration with the Twitter microblogging service. php = 5.1 -core = 6.x +core = 7.x +files[] = twitter.module +files[] = twitter.install +files[] = twitter.inc +files[] = twitter.lib.php +files[] = twitter.pages.inc +files[] = twitter.views.inc +files[] = twitter.views_default.inc +files[] = twitter_views_field_handlers.inc Index: twitter.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.install,v retrieving revision 1.3.2.4 diff -u -p -r1.3.2.4 twitter.install --- twitter.install 13 Feb 2010 20:32:26 -0000 1.3.2.4 +++ twitter.install 18 Feb 2010 03:49:13 -0000 @@ -6,10 +6,10 @@ */ function twitter_schema() { $schema['twitter'] = array( - 'description' => t("Stores individual Twitter posts."), + 'description' => "Stores individual Twitter posts.", 'fields' => array( 'twitter_id' => array( - 'description' => t("Unique identifier for each {twitter} post."), + 'description' => "Unique identifier for each {twitter} post.", 'type' => 'numeric', 'unsigned' => TRUE, 'precision' => 20, @@ -18,38 +18,38 @@ function twitter_schema() { 'default' => 0 ), 'screen_name' => array( - 'description' => t("Screen Name of the {twitter_account} user."), + 'description' => "Screen Name of the {twitter_account} user.", 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), 'created_at' => array( - 'description' => t("Date and time the {twitter} post was created."), + 'description' => "Date and time the {twitter} post was created.", 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '' ), 'created_time' => array( - 'description' => t("A duplicate of {twitter}.created_at in UNIX timestamp format."), + 'description' => "A duplicate of {twitter}.created_at in UNIX timestamp format.", 'type' => 'int', 'not null' => TRUE ), 'text' => array( - 'description' => t("The text of the {twitter} post."), + 'description' => "The text of the {twitter} post.", 'type' => 'varchar', 'length' => 255, 'not null' => FALSE ), 'source' => array( - 'description' => t("The application that created the {twitter} post."), + 'description' => "The application that created the {twitter} post.", 'type' => 'varchar', 'length' => 255, 'not null' => FALSE ), 'in_reply_to_status_id' => array( - 'description' => t("Unique identifier of a status this {twitter} post was replying to."), + 'description' => "Unique identifier of a status this {twitter} post was replying to.", 'type' => 'numeric', 'unsigned' => TRUE, 'precision' => 20, @@ -57,7 +57,7 @@ function twitter_schema() { 'not null' => FALSE, ), 'in_reply_to_user_id' => array( - 'description' => t("Unique identifier for the {twitter_account} this post was replying to."), + 'description' => "Unique identifier for the {twitter_account} this post was replying to.", 'type' => 'numeric', 'unsigned' => TRUE, 'precision' => 20, @@ -65,13 +65,13 @@ function twitter_schema() { 'not null' => FALSE, ), 'in_reply_to_screen_name' => array( - 'description' => t("Screen name of the {twitter} user this post was replying to."), + 'description' => "Screen name of the {twitter} user this post was replying to.", 'type' => 'varchar', 'length' => 255, 'not null' => FALSE, ), 'truncated' => array( - 'description' => t("Boolean flag indicating whether the {twitter} status was cut off to fit in the 140 character limit."), + 'description' => "Boolean flag indicating whether the {twitter} status was cut off to fit in the 140 character limit.", 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, @@ -83,10 +83,10 @@ function twitter_schema() { ); $schema['twitter_account'] = array( - 'description' => t("Stores information on specific Twitter user accounts."), + 'description' => "Stores information on specific Twitter user accounts.", 'fields' => array( 'twitter_uid' => array( - 'description' => t("The unique identifier of the {twitter_account}."), + 'description' => "The unique identifier of the {twitter_account}.", 'type' => 'numeric', 'unsigned' => TRUE, 'precision' => 20, @@ -94,181 +94,181 @@ function twitter_schema() { 'default' => 0 ), 'uid' => array( - 'description' => t("The {users}.uid of the owner of this account"), + 'description' => "The {users}.uid of the owner of this account", 'type' => 'int', 'unsigned' => TRUE, 'size' => 'big', 'not null' => TRUE, ), 'host' => array( - 'description' => t('The host for this account can be a laconi.ca instance'), + 'description' => 'The host for this account can be a laconi.ca instance', 'type' => 'varchar', 'length' => 255, ), 'screen_name' => array( - 'description' => t("The unique login name of the {twitter_account} user."), + 'description' => "The unique login name of the {twitter_account} user.", 'type' => 'varchar', 'length' => 255 ), 'password' => array( - 'description' => t("The password for the Twitter account."), + 'description' => "The password for the Twitter account.", 'type' => 'varchar', 'length' => 64 ), 'oauth_token' => array( - 'description' => t('The token_key for oauth-based access.'), + 'description' => 'The token_key for oauth-based access.', 'type' => 'varchar', 'length' => 64, ), 'oauth_token_secret' => array( - 'description' => t('The token_secret for oauth-based access.'), + 'description' => 'The token_secret for oauth-based access.', 'type' => 'varchar', 'length' => 64, ), 'name' => array( - 'description' => t("The full name of the {twitter_account} user."), + 'description' => "The full name of the {twitter_account} user.", 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '' ), 'description' => array( - 'description' => t("The description/biography associated with the {twitter_account}."), + 'description' => "The description/biography associated with the {twitter_account}.", 'type' => 'varchar', 'length' => 255 ), 'location' => array( - 'description' => t("The location of the {twitter_account}'s owner."), + 'description' => "The location of the {twitter_account}'s owner.", 'type' => 'varchar', 'length' => 255 ), 'followers_count' => array( - 'description' => t("The number of users following this {twitter_account}."), + 'description' => "The number of users following this {twitter_account}.", 'type' => 'int', 'not null' => TRUE, 'default' => 0 ), 'friends_count' => array( - 'description' => t("The number of users this {twitter_account} is following."), + 'description' => "The number of users this {twitter_account} is following.", 'type' => 'int', 'not null' => TRUE, 'default' => 0 ), 'statuses_count' => array( - 'description' => t("The total number of status updates performed by a user, excluding direct messages sent."), + 'description' => "The total number of status updates performed by a user, excluding direct messages sent.", 'type' => 'int', 'not null' => TRUE, 'default' => 0 ), 'favourites_count' => array( - 'description' => t("The number of statuses a user has marked as favorite."), + 'description' => "The number of statuses a user has marked as favorite.", 'type' => 'int', 'not null' => TRUE, 'default' => 0 ), 'url' => array( - 'description' => t("The url of the {twitter_account}'s home page."), + 'description' => "The url of the {twitter_account}'s home page.", 'type' => 'varchar', 'length' => 255 ), 'profile_image_url' => array( - 'description' => t("The url of the {twitter_account}'s profile image."), + 'description' => "The url of the {twitter_account}'s profile image.", 'type' => 'varchar', 'length' => 255 ), 'protected' => array( - 'description' => t("Boolean flag indicating whether the {twitter_account}'s posts are publicly accessible."), + 'description' => "Boolean flag indicating whether the {twitter_account}'s posts are publicly accessible.", 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0 ), 'profile_background_color' => array( - 'description' => t("hex RGB value for a user's background color"), + 'description' => "hex RGB value for a user's background color", 'type' => 'varchar', 'length' => 6, 'not null' => TRUE, 'default' => '', ), 'profile_text_color' => array( - 'description' => t("hex RGB value for a user's text color"), + 'description' => "hex RGB value for a user's text color", 'type' => 'varchar', 'length' => 6, 'not null' => TRUE, 'default' => '', ), 'profile_link_color' => array( - 'description' => t("hex RGB value for a user's link color"), + 'description' => "hex RGB value for a user's link color", 'type' => 'varchar', 'length' => 6, 'not null' => TRUE, 'default' => '', ), 'profile_sidebar_fill_color' => array( - 'description' => t("hex RGB value for a user's sidebar color"), + 'description' => "hex RGB value for a user's sidebar color", 'type' => 'varchar', 'length' => 6, 'not null' => TRUE, 'default' => '', ), 'profile_sidebar_border_color' => array( - 'description' => t("hex RGB value for a user's border color"), + 'description' => "hex RGB value for a user's border color", 'type' => 'varchar', 'length' => 6, 'not null' => TRUE, 'default' => '', ), 'profile_background_image_url' => array( - 'description' => t("The url of the {twitter_account}'s profile image."), + 'description' => "The url of the {twitter_account}'s profile image.", 'type' => 'varchar', 'length' => 255 ), 'profile_background_tile' => array( - 'description' => t("Boolean indicating if a user's background is tiled."), + 'description' => "Boolean indicating if a user's background is tiled.", 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1 ), 'verified' => array( - 'description' => t("Indicates if a user is verified."), + 'description' => "Indicates if a user is verified.", 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1 ), 'created_at' => array( - 'description' => t("Date and time the {twitter_account} was created."), + 'description' => "Date and time the {twitter_account} was created.", 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '' ), 'created_time' => array( - 'description' => t("A duplicate of {twitter_account}.created_at in UNIX timestamp format."), + 'description' => "A duplicate of {twitter_account}.created_at in UNIX timestamp format.", 'type' => 'int', 'not null' => TRUE ), 'utc_offset' => array( - 'description' => t("A duplicate of {twitter_account}.created_at in UNIX timestamp format."), + 'description' => "A duplicate of {twitter_account}.created_at in UNIX timestamp format.", 'type' => 'int', 'not null' => TRUE ), 'import' => array( - 'description' => t("Boolean flag indicating whether the {twitter_user}'s posts should be pulled in by the site."), + 'description' => "Boolean flag indicating whether the {twitter_user}'s posts should be pulled in by the site.", 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1 ), 'last_refresh' => array( - 'description' => t("A UNIX timestamp marking the date Twitter statuses were last fetched on."), + 'description' => "A UNIX timestamp marking the date Twitter statuses were last fetched on.", 'type' => 'int', 'not null' => TRUE, 'default' => 0, ), 'is_global' => array( - 'description' => t("Boolean flag indicating if this account is available for global use"), + 'description' => "Boolean flag indicating if this account is available for global use", 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, @@ -293,402 +293,6 @@ function twitter_install() { db_query("UPDATE {system} SET weight = 3 WHERE name = 'twitter'"); } -/** - * Previous versions of the Twitter module had no database schema. - * We're safe just running the basic install for update_1. - */ -function twitter_update_6000() { - twitter_install(); -} - -/** - * Adding a handful of additional flags on accounts, and saving more metadata - * when Twitter sends it to us. - */ -function twitter_update_6001() { - $ret = array(); - $attributes = array( - 'description' => t("Boolean flag indicating whether the {twitter_user}'s posts should be pulled in by the site."), - 'unsigned' => TRUE, - 'default' => 1, - 'not null' => TRUE, - ); - db_add_column($ret, 'twitter_user', 'import', 'int', $attributes); - - $attributes = array( - 'description' => t("The location of the {twitter_account}'s owner."), - 'length' => 255 - ); - db_add_column($ret, 'twitter_account', 'location', 'varchar(255)', $attributes); - - $attributes = array( - 'description' => t("The number of users following this {twitter_account}."), - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0 - ); - db_add_column($ret, 'twitter_account', 'followers_count', 'int', $attributes); - - return $ret; -} - -/** - * Set the weight a little heavier to allow Pathauto and other modules to do - * their work on the title, path alias, etc. before the twitter post is sent. - */ -function twitter_update_6002() { - $ret = array(); - $ret[] = update_sql("UPDATE {system} SET weight = 3 WHERE name = 'twitter'"); - return $ret; -} - -/** - * Twitter status IDs are hitting the rollover point for signed ints. Let's - * be sure we're ready. See http://bit.ly/kokvi for details. - */ -function twitter_update_6003() { - $ret = array(); - db_drop_primary_key($ret, 'twitter'); - - db_change_field($ret, 'twitter', 'twitter_id', 'twitter_id', - array('description' => t("Unique identifier for each {twitter} post."), - 'type' => 'int', 'size' => 'big', 'unsigned' => 'true', 'not null' => TRUE), - array('primary key' => array('twitter_id'))); - - return $ret; -} - -/** - * Add NOT NULL constraint and DEFAULT value to the screen_name field of the - * twitter and twitter_user tables per updated schema definition. - * - * See http://drupal.org/node/336048 and http://drupal.org/node/430442 - */ -function twitter_update_6004() { - $ret = array(); - // Have to drop PRIMARY KEY and indexes that use the field being changed. - // twitter - db_drop_index($ret, 'twitter', 'screen_name'); - db_change_field($ret, 'twitter', 'screen_name', 'screen_name', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), array('indexes' => array('screen_name' => array('screen_name')))); - - // twitter_user - db_drop_index($ret, 'twitter_user', 'screen_name'); - db_drop_primary_key($ret, 'twitter_user'); - db_change_field($ret, 'twitter_user', 'screen_name', 'screen_name', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), array('primary key' => array('uid', 'screen_name'), 'indexes' => array('screen_name' => array('screen_name')))); - return $ret; -} - - -/** - * Dear PHP, I hate you so bad. Love, Jeff. - * - * Workaround for drupal_write_record(), which treats a DB bigint as a signed 32 - * bit int on 32 bit PHP builds. We can STORE bigints, and PHP automatically - * converts them to floats in memory while we work with them, but db_placeholders() - * always treats them as %d and casts them back to dumb signed ints. - * - * See http://drupal.org/node/333788 for more info. - * - * Instead we'll set the column type to 'string' which is a little like jumping - * off the Sears Tower because the elevator's broken. But that's life. - */ -function twitter_update_6005() { - $ret = array(); - - // First clear out any borked statuses. - $ret[] = update_sql("DELETE FROM {twitter} WHERE twitter_id = 2147483647"); - - db_drop_primary_key($ret, 'twitter'); - - db_change_field($ret, 'twitter', 'twitter_id', 'twitter_id', - array('description' => t("Unique identifier for each {twitter} post."), - 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), - array('primary key' => array('twitter_id'))); - - return $ret; -} - -/** - * Dear PHP, I'm sorry baby. I know I said a lotta things last night, but I was - * angry. I didn't mean it, you know that. I'll use numbers from now on -- no! - * No, I'll use *decimals*. You'll like that, won't you, PHP? We're cool, right? - * - * Yeah. Yeah, we're cool. - * - * Also, while we're at it we'll add support for some of the additional Twitter - * API data for replies, and convert the twitter_uid field to a numeric type, too. - */ -function twitter_update_6006() { - $ret = array(); - - db_drop_primary_key($ret, 'twitter'); - - db_change_field($ret, 'twitter', 'twitter_id', 'twitter_id', - array( - 'description' => t("Unique identifier for each {twitter} post."), - 'type' => 'numeric', - 'unsigned' => TRUE, - 'precision' => 20, - 'scale' => 0, - 'not null' => TRUE, - 'default' => 0 - ), - array('primary key' => array('twitter_id')) - ); - - db_add_field($ret, 'twitter', 'in_reply_to_status_id', - array( - 'description' => t("Unique identifier of a status this {twitter} post was replying to."), - 'type' => 'numeric', - 'precision' => 20, - 'scale' => 0, - 'unsigned' => TRUE, - 'not null' => FALSE, - ) - ); - - db_add_field($ret, 'twitter', 'in_reply_to_user_id', - array( - 'description' => t("Unique identifier for the {twitter_account} this post was replying to."), - 'type' => 'numeric', - 'precision' => 20, - 'scale' => 0, - 'unsigned' => TRUE, - 'not null' => FALSE, - ) - ); - - db_add_field($ret, 'twitter', 'in_reply_to_screen_name', - array( - 'description' => t("Screen name of the {twitter} user this post was replying to."), - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - ) - ); - - db_add_field($ret, 'twitter', 'truncated', - array( - 'description' => t("Boolean flag indicating whether the {twitter} status was cut off to fit in the 140 character limit."), - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ) - ); - - db_drop_primary_key($ret, 'twitter_account'); - - db_change_field($ret, 'twitter_account', 'twitter_uid', 'twitter_uid', - array( - 'description' => t("The unique identifier of the {twitter_account}."), - 'type' => 'numeric', - 'unsigned' => TRUE, - 'precision' => 20, - 'scale' => 0, - 'not null' => TRUE, - 'default' => 0 - ), - array('primary key' => array('twitter_uid')) - ); - - - return $ret; -} - -/* - * Update the last_refresh column to supply a default value. http://drupal.org/node/301317 - */ -function twitter_update_6007() { - $ret = array(); - db_change_field($ret, 'twitter_account', 'last_refresh', 'last_refresh', - array( - 'description' => t("A UNIX timestamp marking the date Twitter statuses were last fetched on."), - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ) - ); - return $ret; -} - -/** - * Update from 2.x to 3.x - */ -function twitter_update_6300() { - $ret = array(); - - // add additional fields to {twitter_account} - db_add_field($ret, 'twitter_account', 'uid', - array( - 'description' => t("The {users}.uid of the owner of this account"), - 'type' => 'int', - 'unsigned' => TRUE, - 'size' => 'big', - 'not null' => TRUE, - )); - - db_add_field($ret, 'twitter_account', 'host', - array( - 'description' => t('The host for this account can be a laconi.ca instance'), - 'type' => 'varchar', - 'length' => 255, - )); - db_add_field($ret, 'twitter_account', 'password', - array( - 'description' => t("The password for the Twitter account."), - 'type' => 'varchar', - 'length' => 64 - )); - db_add_field($ret, 'twitter_account', 'oauth_token', - array( - 'description' => t('The token_key for oauth-based access.'), - 'type' => 'varchar', - 'length' => 64, - )); - db_add_field($ret, 'twitter_account', 'oauth_token_secret', - array( - 'description' => t('The token_secret for oauth-based access.'), - 'type' => 'varchar', - 'length' => 64, - )); - db_add_field($ret, 'twitter_account', 'friends_count', - array( - 'description' => t("The number of users this {twitter_account} is following."), - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0 - )); - db_add_field($ret, 'twitter_account', 'statuses_count', - array( - 'description' => t("The total number of status updates performed by a user, excluding direct messages sent."), - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0 - )); - db_add_field($ret, 'twitter_account', 'favourites_count', - array( - 'description' => t("The number of statuses a user has marked as favorite."), - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0 - )); - db_add_field($ret, 'twitter_account', 'profile_background_color', - array( - 'description' => t("hex RGB value for a user's background color"), - 'type' => 'varchar', - 'length' => 6, - 'not null' => TRUE, - 'default' => '', - )); - db_add_field($ret, 'twitter_account', 'profile_text_color', - array( - 'description' => t("hex RGB value for a user's text color"), - 'type' => 'varchar', - 'length' => 6, - 'not null' => TRUE, - 'default' => '', - )); - db_add_field($ret, 'twitter_account', 'profile_link_color', - array( - 'description' => t("hex RGB value for a user's link color"), - 'type' => 'varchar', - 'length' => 6, - 'not null' => TRUE, - 'default' => '', - )); - db_add_field($ret, 'twitter_account', 'profile_sidebar_fill_color', - array( - 'description' => t("hex RGB value for a user's sidebar color"), - 'type' => 'varchar', - 'length' => 6, - 'not null' => TRUE, - 'default' => '', - )); - db_add_field($ret, 'twitter_account', 'profile_sidebar_border_color', - array( - 'description' => t("hex RGB value for a user's border color"), - 'type' => 'varchar', - 'length' => 6, - 'not null' => TRUE, - 'default' => '', - )); - db_add_field($ret, 'twitter_account', 'profile_background_image_url', - array( - 'description' => t("The url of the {twitter_account}'s profile image."), - 'type' => 'varchar', - 'length' => 255 - )); - db_add_field($ret, 'twitter_account', 'profile_background_tile', - array( - 'description' => t("Boolean indicating if a user's background is tiled."), - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 1 - )); - db_add_field($ret, 'twitter_account', 'verified', - array( - 'description' => t("Indicates if a user is verified."), - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 1 - )); - db_add_field($ret, 'twitter_account', 'created_at', - array( - 'description' => t("Date and time the {twitter_account} was created."), - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'default' => '' - )); - db_add_field($ret, 'twitter_account', 'created_time', - array( - 'description' => t("A duplicate of {twitter_account}.created_at in UNIX timestamp format."), - 'type' => 'int', - 'not null' => TRUE - )); - db_add_field($ret, 'twitter_account', 'utc_offset', - array( - 'description' => t("A duplicate of {twitter_account}.created_at in UNIX timestamp format."), - 'type' => 'int', - 'not null' => TRUE - )); - db_add_field($ret, 'twitter_account', 'import', - array( - 'description' => t("Boolean flag indicating whether the {twitter_user}'s posts should be pulled in by the site."), - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 1 - )); - db_add_field($ret, 'twitter_account', 'is_global', - array( - 'description' => t("Boolean flag indicating if this account is available for global use"), - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0 - )); - - - if (db_table_exists('twitter_user')) { - $result = db_query("SELECT * FROM {twitter_user} ORDER BY uid DESC"); - while ($row = db_fetch_array($result)) { - db_query("UPDATE {twitter_account} SET uid=%d, password='%s', import=%d WHERE screen_name='%s'", - $row['uid'], $row['password'], $row['import'], $row['screen_name']); - } - - db_drop_table($ret, 'twitter_user'); - } - - drupal_install_modules(array('twitter_post')); - - return $ret; -} - - function twitter_uninstall() { // Remove tables. drupal_uninstall_schema('twitter'); Index: twitter.lib.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.lib.php,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 twitter.lib.php --- twitter.lib.php 14 Feb 2010 04:11:45 -0000 1.1.2.5 +++ twitter.lib.php 18 Feb 2010 03:49:13 -0000 @@ -77,6 +77,7 @@ class Twitter { */ protected function get_statuses($path, $params = array(), $use_auth = FALSE) { $values = $this->call($path, $params, 'GET', $use_auth); + $statuses = array(); foreach ($values as $status) { $statuses[] = new TwitterStatus($status); @@ -211,25 +212,28 @@ class Twitter { * Perform a request */ protected function request($url, $params = array(), $method = 'GET', $use_auth = FALSE) { - $data = ''; + + $options = array( + 'headers' => array(), + 'method' => $method, + ); + if (count($params) > 0) { if ($method == 'GET') { - $url .= '?'. http_build_query($params, '', '&'); + $url .= '?' . http_build_query($params, '', '&'); } else { - $data = http_build_query($params, '', '&'); + $option['data'] = http_build_query($params, '', '&'); } } - $headers = array(); - if ($use_auth) { - $headers['Authorization'] = 'Basic '. base64_encode($this->username .':'. $this->password); - $headers['Content-type'] = 'application/x-www-form-urlencoded'; + $options['headers']['Authorization'] = 'Basic '. base64_encode($this->username .':'. $this->password); + $options['headers']['Content-type'] = 'application/x-www-form-urlencoded'; } - - $response = drupal_http_request($url, $headers, $method, $data); - if (!$response->error) { + + $response = drupal_http_request($url, $options); + if (empty($response->error)) { return $response->data; } else { @@ -475,7 +479,7 @@ class TwitterUser { } $this->utc_offset = $values['utc_offset']; - if ($values['status']) { + if (!empty($values['status'])) { $this->status = new TwitterStatus($values['status']); } } Index: twitter.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.module,v retrieving revision 1.10.2.5 diff -u -p -r1.10.2.5 twitter.module --- twitter.module 25 Jan 2010 05:09:05 -0000 1.10.2.5 +++ twitter.module 18 Feb 2010 03:49:13 -0000 @@ -2,7 +2,7 @@ // $Id: twitter.module,v 1.10.2.5 2010/01/25 05:09:05 walkah Exp $ /** - * Implementation of hook_meu() + * Implementation of hook_menu(). */ function twitter_menu() { $items = array(); @@ -30,7 +30,7 @@ function twitter_menu() { 'type' => MENU_DEFAULT_LOCAL_TASK ); - $items['user/%user_category/edit/twitter'] = array( + $items['user/%user/edit/twitter'] = array( 'title' => 'Twitter accounts', 'page callback' => 'twitter_user_settings', 'page arguments' => array(1), @@ -54,10 +54,34 @@ function twitter_menu() { } /** - * Implementation of hook_perm() + * Implementation of hook_admin_paths(). + */ +function hook_admin_paths() { + $paths = array( + 'admin/settings/twitter/default' => TRUE, + 'admin/settings/twitter' => TRUE, + ); + return $paths; +} + +/** + * Implementation of hook_perm(). */ function twitter_perm() { - return array('add twitter accounts', 'use global twitter account', 'make twitter accounts global'); + return array( + 'add twitter accounts' => array( + 'title' => t('Add twitter accounts'), + 'description' => t('Provide credentials or twitter accounts.'), + ), + 'use global twitter account' => array( + 'title' => t('Use global twitter account'), + 'description' => t('Access and maintain global twitter accounts.'), + ), + 'make twitter accounts global' => array( + 'title' => t('Make twitter accounts global'), + 'description' => t('Administer global twitter accounts.'), + ), + ); } /** @@ -79,7 +103,7 @@ function twitter_user($op, &$edit, &$acc function twitter_theme() { return array( 'twitter_account_list_form' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', ) ); } @@ -121,13 +145,13 @@ function twitter_cron() { $sql = "SELECT twitter_uid FROM {twitter_account} WHERE import = 1 ORDER BY last_refresh ASC"; $results = db_query_range($sql, 0, 20); - while ($account = db_fetch_object($results)) { + foreach ($results as $account) { twitter_fetch_user_timeline($account->twitter_uid); } // Nuke old statuses. if ($age = variable_get('twitter_expire', 0)) { - db_query('DELETE FROM {twitter} WHERE created_time < %d', time() - $age); + db_query('DELETE FROM {twitter} WHERE created_time < :purge_time', array(':purge_time' => REQUEST_TIME - $age)); } } @@ -223,14 +247,14 @@ function twitter_twitter_accounts($accou $twitter_accounts = array(); - $sql = "SELECT twitter_uid FROM {twitter_account} WHERE uid = %d"; + $sql = "SELECT twitter_uid FROM {twitter_account} WHERE uid = :uid"; if (user_access('use global twitter account')) { $sql.= " OR is_global=1"; } - $results = db_query($sql, $account->uid); + $results = db_query($sql, array(':uid' => $account->uid)); - while ($row = db_fetch_array($results)) { - $key = $row['twitter_uid']; + foreach ($results as $row) { + $key = $row->twitter_uid; $twitter_accounts[] = twitter_account_load($key); } return $twitter_accounts; Index: twitter.pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.pages.inc,v retrieving revision 1.4.2.9 diff -u -p -r1.4.2.9 twitter.pages.inc --- twitter.pages.inc 16 Feb 2010 00:51:17 -0000 1.4.2.9 +++ twitter.pages.inc 18 Feb 2010 03:49:13 -0000 @@ -4,7 +4,7 @@ /** * */ -function twitter_admin_form() { +function twitter_admin_form($form, &$form_state) { $form = array(); $form['oauth'] = array( @@ -32,7 +32,7 @@ function twitter_admin_form() { '#title' => t('OAuth Consumer secret'), '#default_value' => variable_get('twitter_consumer_secret', NULL), ); - + $form['import'] = array( '#type' => 'fieldset', '#title' => t('Twitter import'), @@ -66,14 +66,14 @@ function twitter_user_settings($account) // management gets an overhaul. $twitter_accounts = twitter_twitter_accounts($account); if (!empty($twitter_accounts)) { - $output .= drupal_get_form('twitter_account_list_form', $twitter_accounts); + $output .= drupal_render_children(drupal_get_form('twitter_account_list_form', $twitter_accounts)); } - $output .= drupal_get_form('twitter_account_form', $account); + $output .= drupal_render_children(drupal_get_form('twitter_account_form', $account)); return $output; } -function twitter_account_list_form($form_state, $twitter_accounts = array()) { +function twitter_account_list_form($form, &$form_state, $twitter_accounts = array()) { $form['#tree'] = TRUE; $form['accounts'] = array(); @@ -111,7 +111,7 @@ function _twitter_account_list_row($acco $form['image'] = array( '#type' => 'markup', - '#value' => theme('image', $account->profile_image_url, '', '', array(), FALSE), + '#value' => theme('image', array('path' => $account->profile_image_url)), ); $form['visible_name'] = array( @@ -169,7 +169,7 @@ function theme_twitter_account_list_form $rows[] = $row; } - $output = theme('table', $header, $rows); + $output = theme('table', array('header' =>$header, 'rows' => $rows)); $output .= drupal_render($form); return $output; } @@ -221,7 +221,8 @@ function twitter_user_make_global_submit $form_state['redirect'] = 'user/'. $form_state['values']['uid'] .'/edit/twitter'; } -function twitter_account_form($form_state, $account = NULL) { +function twitter_account_form($form, &$form_state, $account = NULL) { + if (empty($account)) { global $user; $account = $user; @@ -269,7 +270,6 @@ function twitter_account_form_validate($ module_load_include('inc', 'twitter'); $verify = FALSE; - $pass = $form_state['values']['password']; $name = $form_state['values']['screen_name']; @@ -289,7 +289,6 @@ function twitter_account_form_validate($ function twitter_account_form_submit($form, &$form_state) { module_load_include('inc', 'twitter'); - if (!empty($form_state['values']['screen_name'])) { $account = $form_state['twitter_account']; $account->set_auth($form_state['values']);