Index: fb_app.info =================================================================== --- fb_app.info (revision 1.1) +++ fb_app.info (6.x working copy) @@ -1,4 +1,8 @@ name = Facebook Application description = Create one or more facebook applications. package = Facebook -dependencies = fb +dependencies[] = fb +core = 6.x + +version = "6.x-1.x-dev" + Index: fb_app.install =================================================================== --- fb_app.install (revision 1.3) +++ fb_app.install (6.x working copy) @@ -6,60 +6,63 @@ */ // TODO: some of these tables should be created by othe module install files. -Function fb_app_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query(" -CREATE TABLE IF NOT EXISTS {fb_app} ( -nid int(11) unsigned NOT NULL, -label varchar(128) NOT NULL, -apikey varchar(128) NOT NULL, -id varchar(128) NOT NULL, -secret varchar(128) NOT NULL, -canvas varchar(128) NOT NULL, -require_login int(4) NOT NULL, -create_account int(4) NOT NULL, -unique_account int(4) NOT NULL, -rid int(10) unsigned NOT NULL, -data longtext, -PRIMARY KEY (nid), -UNIQUE KEY (apikey) -) /*!40100 DEFAULT CHARACTER SET UTF8 */; -"); - db_query(" -CREATE TABLE IF NOT EXISTS {fb_app_block} ( -nid int(11) unsigned NOT NULL, -delta varchar(32) NOT NULL, -format int(11) DEFAULT 0, -body longtext NOT NULL, -PRIMARY KEY (nid, delta) -) /*!40100 DEFAULT CHARACTER SET UTF8 */; -"); - - // This table schema has to match the cache_filter table. - db_query(" -CREATE TABLE {fb_cache_filter} ( -cid varchar(255) NOT NULL default '', -data longblob, -expire int NOT NULL default '0', -created int NOT NULL default '0', -headers text, -PRIMARY KEY (cid), -INDEX expire (expire) -) /*!40100 DEFAULT CHARACTER SET UTF8 */; +/** + * hook_install() + */ +function fb_app_install() { + // Create tables. + drupal_install_schema('fb_app'); + + drupal_set_message(t('Facebook Application module installed. Please grant yourself permissions and then browse to Create Content => Facebook Application to get started.', array('!perm' => url('admin/user/permissions'), '!create' => url('node/add/fb-app')))); +} -"); +/** + * hook_uninstall() + */ +function fb_app_uninstall() { + // Remove tables. + drupal_uninstall_schema('fb_app'); +} - } - - drupal_set_message(t('Facebook Application module installed. Please grant yourself permissions and then browse to Create Content => Facebook Application to get started.', array('!perm' => url('admin/user/access'), '!create' => url('node/add/fb-app')))); - + +function fb_app_schema() { + $schema['fb_app'] = array( + 'description' => 'Main FB_APP table', + 'fields' => array( + 'nid' => array('type' => 'int', 'length' => 11, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'label' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'apikey' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'id' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'secret' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'canvas' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'require_login' => array('type' => 'int', 'length' => 4, 'not null' => TRUE, ), + 'create_account' => array('type' => 'int', 'length' => 4, 'not null' => TRUE, ), + 'unique_account' => array('type' => 'int', 'length' => 4, 'not null' => TRUE, ), + 'rid' => array('type' => 'int', 'length' => 10, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'data' => array('type' => 'text', 'size' => 'big', ), + ), + 'unique keys' => array( + 'apikey' => array('apikey'), + ), + 'primary key' => array('nid'), + ); + $schema['fb_app_block'] = array( + 'fields' => array( + 'nid' => array('type' => 'int', 'length' => 11, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'delta' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, ), + 'format' => array('type' => 'int', 'length' => 11, 'default' => 0, ), + 'body' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE, ), + ), + 'primary key' => array('nid', 'delta'), + ); + $schema['fb_cache_filter'] = drupal_get_schema_unprocessed('system', 'cache'); + + return $schema; } -function fb_app_update_1() { +function fb_app_update_6100() { // Add id field - $ret[] = update_sql('ALTER TABLE {fb_app} ADD id varchar(128) NOT NULL'); - return $ret; -} -?> \ No newline at end of file + $ret = array(); + db_add_field($ret, 'fb_app', 'id', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, )); + return $ret; +} \ No newline at end of file Index: fb_app.module =================================================================== --- fb_app.module (revision 1.10) +++ fb_app.module (6.x working copy) @@ -34,7 +34,7 @@ } else { if (function_exists('fb_settings')) { - // See settings.inc + // See fb_settings.inc if ($nid = fb_settings(FB_SETTINGS_APP_NID)) { // Here if we're in iframe, using our /fb_canvas/nid/ path convention. $fb_app = db_fetch_object(db_query("SELECT * FROM {fb_app} fb INNER JOIN {node} n ON n.nid=fb.nid WHERE fb.nid=%d and status=1", @@ -84,7 +84,7 @@ ); } -function fb_app_access($op, $node) { +function fb_app_access($op, $node, $account) { if (user_access('administer fb apps')) return TRUE; if ($op == 'create' && user_access('create fb apps')) @@ -231,11 +231,26 @@ return $node; } + +function fb_app_theme() { + return array( + 'fb_app' => array( + 'arguments' => array('data' => NULL), + ), + 'dl' => array( + 'arguments' => array('items' => NULL), + ), + 'fb_app_user_info' => array( + 'arguments' => array('fb_app' => NULL, 'info' => NULL), + ), + ); +} + function theme_fb_app($data) { return theme('dl', array(t('Label') => $data->label, t('API Key') => $data->apikey, t('Secret') => $data->secret, - t('About page') => $data->id ? url("http://www.facebook.com/apps/application.php", "id=$data->id") : t('N/A'), + t('About page') => $data->id ? url("http://www.facebook.com/apps/application.php", array('query' => "id=$data->id")) : t('N/A'), // TODO: edit and logout URLs )); @@ -275,9 +290,9 @@ _fb_app_blocks_update($node); - watchdog('fb_app', t('Created Facebook Application %label. Created role %role.', + watchdog('fb_app', 'Created Facebook Application %label. Created role %role.', array('%label' => $fb_app->label, - '%role' => $role_name)), + '%role' => $role_name), WATCHDOG_NOTICE, l($node->title, 'node/'.$node->nid)); @@ -412,7 +427,7 @@ function theme_fb_app_user_info($fb_app, $info) { $output .= '

'; - $fb_link = l($info['name'], 'http://www.facebook.com/profile.php', NULL, 'id='.$info['uid']); + $fb_link = l($info['name'], 'http://www.facebook.com/profile.php', array('query' => 'id='. $info['uid'])); if ($info['is_app_user']) $output .= '

' . t('!fb_link uses %title', array('!fb_link' => $fb_link, @@ -444,4 +459,3 @@ return $values; } -?> \ No newline at end of file