Index: flag.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/flag/Attic/flag.install,v retrieving revision 1.1.2.17 diff -u -r1.1.2.17 flag.install --- flag.install 30 Sep 2008 03:09:42 -0000 1.1.2.17 +++ flag.install 10 Oct 2008 08:51:45 -0000 @@ -30,12 +30,6 @@ content_type varchar(32) default '', name varchar(32) default '', title varchar(255) default '', - flag_short varchar(255) default '', - flag_long varchar(255) default '', - flag_message varchar(255) default '', - unflag_short varchar(255) default '', - unflag_long varchar(255) default '', - unflag_message varchar(255) default '', roles varchar(255) default '', global tinyint default 0, options text default NULL, @@ -75,12 +69,6 @@ content_type varchar(32) default '', name varchar(32) default '', title varchar(255) default '', - flag_short varchar(255) default '', - flag_long varchar(255) default '', - flag_message varchar(255) default '', - unflag_short varchar(255) default '', - unflag_long varchar(255) default '', - unflag_message varchar(255) default '', roles varchar(255) default '', global smallint default 0, options text default NULL, @@ -124,15 +112,21 @@ if ($success) { // Insert a starting record. + // Note that UI strings in the following SQL, e.g. "Bookmark this", aren't + // wrapped in t() and that's intentional: they are passed to t() later, + // thus allowing for multilingual sites. $options = array( 'show_on_page' => 1, 'show_on_teaser' => 1, 'show_on_form' => 1, + 'flag_short' => 'Bookmark this', + 'flag_long' => 'Add this post to your bookmarks', + 'flag_message' => 'This post has been added to your bookmarks', + 'unflag_short' => 'Unbookmark this', + 'unflag_long' => 'Remove this post from your bookmarks', + 'unflag_message' => 'This post has been removed from your bookmarks', ); - // Note that UI strings in the following SQL, e.g. "Bookmark this", aren't - // wrapped in t() and that's intentional: they are passed to t() later, - // thus allowing for multilingual sites. - db_query("INSERT INTO {flags} (fid, content_type, name, title, flag_short, flag_long, flag_message, unflag_short, unflag_long, unflag_message, roles, global, options) VALUES (1, 'node', 'bookmarks', 'Bookmarks', 'Bookmark this', 'Add this post to your bookmarks', 'This post has been added to your bookmarks', 'Unbookmark this', 'Remove this post from your bookmarks', 'This post has been removed from your bookmarks', '2', 0, '%s')", serialize($options)); + db_query("INSERT INTO {flags} (fid, content_type, name, title, roles, global, options) VALUES (1, 'node', 'bookmarks', 'Bookmarks', '2', 0, '%s')", serialize($options)); db_query("INSERT INTO {flag_types} (fid, type) VALUES (1, 'story')"); db_query("INSERT INTO {flag_types} (fid, type) VALUES (1, 'forum')"); db_query("INSERT INTO {flag_types} (fid, type) VALUES (1, 'blog')"); @@ -289,6 +283,35 @@ return $ret; } +/** + * Move flag messages and link titles into the options array. + */ +function flag_update_5001() { + $ret = array(); + + if (db_column_exists('flags', 'flag_short')) { + $result = db_query("SELECT * FROM {flags}"); + while ($flag = db_fetch_object($result)) { + $options = unserialize($flag->options); + $options['flag_short'] = $flag->flag_short; + $options['flag_long'] = $flag->flag_long; + $options['flag_message'] = $flag->flag_message; + $options['unflag_short'] = $flag->unflag_short; + $options['unflag_long'] = $flag->unflag_long; + $options['unflag_message'] = $flag->unflag_message; + db_query("UPDATE {flags} SET options = '%s' WHERE fid = %d", serialize($options), $flag->fid); + } + + db_drop_field(&$ret, 'flags', 'flag_short'); + db_drop_field(&$ret, 'flags', 'flag_long'); + db_drop_field(&$ret, 'flags', 'flag_message'); + db_drop_field(&$ret, 'flags', 'unflag_short'); + db_drop_field(&$ret, 'flags', 'unflag_long'); + db_drop_field(&$ret, 'flags', 'unflag_message'); + } + return $ret; +} + // This is a replacement for update_sql(). The latter doesn't support placeholders. function _flag_update_sql($sql) { $args = func_get_args(); Index: flag.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/flag/Attic/flag.inc,v retrieving revision 1.1.4.17 diff -u -r1.1.4.17 flag.inc --- flag.inc 15 Sep 2008 11:25:39 -0000 1.1.4.17 +++ flag.inc 10 Oct 2008 08:51:45 -0000 @@ -102,16 +102,7 @@ // Various non-serialized properties of the flag, corresponding directly to // database columns. - // - // It's a pity they're here. They should be serialized and treated just - // like 'options'. var $title = ''; - var $flag_short = ''; - var $flag_long = ''; - var $flag_message = ''; - var $unflag_short = ''; - var $unflag_long = ''; - var $unflag_message = ''; var $roles = array(DRUPAL_AUTHENTICATED_RID); var $global = FALSE; // The sub-types, e.g. node types, this flag applies to. @@ -172,6 +163,12 @@ */ function default_options() { return array( + 'flag_short' => '', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => '', + 'unflag_long' => '', + 'unflag_message' => '', ); } @@ -650,7 +647,7 @@ * Saves an existing flag to the database. Better use save(). */ function update() { - db_query("UPDATE {flags} SET name = '%s', title = '%s', flag_short = '%s', flag_long = '%s', flag_message = '%s', unflag_short = '%s', unflag_long = '%s', unflag_message = '%s', roles = '%s', global = %d, options = '%s' WHERE fid = %d", $this->name, $this->title, $this->flag_short, $this->flag_long, $this->flag_message, $this->unflag_short, $this->unflag_long, $this->unflag_message, implode(',', $this->roles), $this->global, $this->get_serialized_options(), $this->fid); + db_query("UPDATE {flags} SET name = '%s', title = '%s', roles = '%s', global = %d, options = '%s' WHERE fid = %d", $this->name, $this->title, implode(',', $this->roles), $this->global, $this->get_serialized_options(), $this->fid); db_query("DELETE FROM {flag_types} WHERE fid = %d", $this->fid); foreach ($this->types as $type) { db_query("INSERT INTO {flag_types} (fid, type) VALUES (%d, '%s')", $this->fid, $type); @@ -663,13 +660,13 @@ function insert() { if (function_exists('db_last_insert_id')) { // Drupal 6. We have a 'serial' primary key. - db_query("INSERT INTO {flags} (content_type, name, title, flag_short, flag_long, flag_message, unflag_short, unflag_long, unflag_message, roles, global, options) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s')", $this->content_type, $this->name, $this->title, $this->flag_short, $this->flag_long, $this->flag_message, $this->unflag_short, $this->unflag_long, $this->unflag_message, implode(',', $this->roles), $this->global, $this->get_serialized_options()); + db_query("INSERT INTO {flags} (content_type, name, title, roles, global, options) VALUES ('%s', '%s', '%s', '%s', %d, '%s')", $this->content_type, $this->name, $this->title, implode(',', $this->roles), $this->global, $this->get_serialized_options()); $this->fid = db_last_insert_id('flags', 'fid'); } else { // Drupal 5. We have an 'integer' primary key. $this->fid = db_next_id('{flags}_fid'); - db_query("INSERT INTO {flags} (fid, content_type, name, title, flag_short, flag_long, flag_message, unflag_short, unflag_long, unflag_message, roles, global, options) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s')", $this->fid, $this->content_type, $this->name, $this->title, $this->flag_short, $this->flag_long, $this->flag_message, $this->unflag_short, $this->unflag_long, $this->unflag_message, implode(',', $this->roles), $this->global, $this->get_serialized_options()); + db_query("INSERT INTO {flags} (fid, content_type, name, title, roles, global, options) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $this->fid, $this->content_type, $this->name, $this->title, implode(',', $this->roles), $this->global, $this->get_serialized_options()); } foreach ($this->types as $type) { db_query("INSERT INTO {flag_types} (fid, type) VALUES (%d, '%s')", $this->fid, $type); @@ -733,11 +730,13 @@ */ class flag_node extends flag_flag { function default_options() { - return array( + $options = parent::default_options(); + $options += array( 'show_on_page' => TRUE, 'show_on_teaser' => TRUE, 'show_on_form' => FALSE, ); + return $options; } function options_form(&$form) { @@ -846,9 +845,11 @@ */ class flag_comment extends flag_flag { function default_options() { - return array( + $options = parent::default_options(); + $options += array( 'show_on_comment' => TRUE, ); + return $options; } function options_form(&$form) { @@ -937,9 +938,11 @@ */ class flag_user extends flag_flag { function default_options() { - return array( + $options = parent::default_options(); + $options += array( 'show_on_profile' => TRUE, ); + return $options; } function options_form(&$form) { Index: includes/flag.views_bookmark.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/flag/includes/Attic/flag.views_bookmark.inc,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 flag.views_bookmark.inc --- includes/flag.views_bookmark.inc 2 Oct 2008 00:42:13 -0000 1.1.4.3 +++ includes/flag.views_bookmark.inc 10 Oct 2008 08:51:45 -0000 @@ -83,12 +83,6 @@ $ret[] = update_sql("ALTER TABLE {views_bookmark_nodetypes} CHANGE COLUMN vbid fid smallint unsigned NOT NULL default '0'"); $ret[] = update_sql("ALTER TABLE {views_bookmark_nodetypes} CHANGE COLUMN type type varchar(32) NOT NULL default ''"); $ret[] = update_sql("ALTER TABLE {views_bookmarks} CHANGE COLUMN vbid fid smallint unsigned NOT NULL default '0'"); - $ret[] = update_sql("ALTER TABLE {views_bookmarks} CHANGE COLUMN mark flag_short varchar(255) default ''"); - $ret[] = update_sql("ALTER TABLE {views_bookmarks} CHANGE COLUMN mark_long flag_long varchar(255) default ''"); - $ret[] = update_sql("ALTER TABLE {views_bookmarks} CHANGE COLUMN mark_message flag_message varchar(255) default ''"); - $ret[] = update_sql("ALTER TABLE {views_bookmarks} CHANGE COLUMN unmark unflag_short varchar(255) default ''"); - $ret[] = update_sql("ALTER TABLE {views_bookmarks} CHANGE COLUMN unmark_long unflag_long varchar(255) default ''"); - $ret[] = update_sql("ALTER TABLE {views_bookmarks} CHANGE COLUMN unmark_message unflag_message varchar(255) default ''"); $ret[] = update_sql("ALTER TABLE {views_bookmarks} CHANGE COLUMN global global tinyint default 0"); // Add columns. @@ -99,9 +93,15 @@ $ret[] = update_sql("ALTER TABLE {views_bookmarks} ADD options text default NULL"); // Move options. - $result = db_query("SELECT fid, show_on_form, teaser FROM {views_bookmarks}"); + $result = db_query("SELECT * FROM {views_bookmarks}"); while ($bookmark = db_fetch_object($result)) { $options = array( + 'flag_short' => $bookmark->mark, + 'flag_long' => $bookmark->mark_long, + 'flag_message' => $bookmark->mark_message, + 'unflag_short' => $bookmark->unmark, + 'unflag_long' => $bookmark->unmark_long, + 'unflag_message' => $bookmark->unmark_message, 'show_on_form' => $bookmark->show_on_form, 'show_on_teaser' => $bookmark->teaser, 'show_on_page' => 1, @@ -110,6 +110,12 @@ } // Delete columns. + $ret[] = update_sql("ALTER TABLE {views_bookmarks} DROP COLUMN mark"); + $ret[] = update_sql("ALTER TABLE {views_bookmarks} DROP COLUMN mark_long"); + $ret[] = update_sql("ALTER TABLE {views_bookmarks} DROP COLUMN mark_message"); + $ret[] = update_sql("ALTER TABLE {views_bookmarks} DROP COLUMN unmark"); + $ret[] = update_sql("ALTER TABLE {views_bookmarks} DROP COLUMN unmark_long"); + $ret[] = update_sql("ALTER TABLE {views_bookmarks} DROP COLUMN unmark_message"); $ret[] = update_sql("ALTER TABLE {views_bookmarks} DROP COLUMN show_on_form"); $ret[] = update_sql("ALTER TABLE {views_bookmarks} DROP COLUMN teaser"); @@ -163,6 +169,7 @@ $ret = array(); // Ensure views is available. include_once(drupal_get_path('module', 'views') .'/views.module'); + include_once(drupal_get_path('module', 'flag') .'/flag.inc'); // Load the cache to ensure _views_get_default_views() is available. if (function_exists('views_load_cache')) { views_invalidate_cache();