function flag_views_bookmark_update_5102 in Flag 6
Same name and namespace in other branches
- 5 includes/flag.views_bookmark.inc \flag_views_bookmark_update_5102()
- 6.2 includes/flag.views_bookmark.inc \flag_views_bookmark_update_5102()
Handle issues http://drupal.org/node/218766 and http://drupal.org/node/219146
File
- includes/
flag.views_bookmark.inc, line 299 - Upgrade code to migrate from Views bookmark to Flag module.
Code
function flag_views_bookmark_update_5102() {
// Because of a certain FAPI trait, when the admin didn't selected any
// roles on the bookmark configuration form it's as if he selected the
// 'anonymous role'. We clear this bogus selection.
//
// (Note: update_sql() doesn't support %placeholders, so we embed the value
// directly.)
$ret[] = update_sql("UPDATE {views_bookmarks} SET roles = '' WHERE roles = '" . DRUPAL_ANONYMOUS_RID . "'");
// We're now making the 'roles' field a required one. If no roles were
// previously selected, we assign this bookmark to all authenticated users.
$ret[] = update_sql("UPDATE {views_bookmarks} SET roles = '" . DRUPAL_AUTHENTICATED_RID . "' WHERE roles = ''");
return $ret;
}