At these points flag_get_flag('follow') is a value and not an object. It occurs in fbss_flag.views_default.inc on lines 22 and 291

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

IceCreamYou’s picture

Component: Miscellaneous » Integrations

Yeah, the Flags submodule needs a lot of work. It hasn't really been updated to the Flag 7.x-2.x API yet. Partially because the Flag 7.x-2.x API is not documented at all.

udvranto’s picture

Subscribing...

udvranto’s picture

The only part I have done is pasted below. Hope others contribute for the rest of the update.

function fbss_flag_flag_default_flags() {
  $flags = array();
  $flags['like'] = array(
    'content_type' => 'facebook_status',
    'title' => t('Like'),
    'global' => FALSE,
    'types' => array(0=>'page'),
    'flag_short' => t('Like'),
    'flag_long' => '',
    'flag_message' => '',
    'unflag_short' => t('Un-like'),
    'unflag_long' => '',
    'unflag_message' => '',
    'unflag_denied_text' => '',
    'show_on_page' => FALSE,
    'link_type' => 'toggle',
    'roles' => array(
      'flag' => array(0 => '2',),
      'unflag' => array (0 => '2',),
    ),
    'show_on_page' => FALSE,
    'show_on_teaser' => FALSE,
    'show_on_form' => FALSE,
    'status' => FALSE,
    'locked' => array('name', 'global', 'types', 'show_on_page', 'show_on_teaser', 'show_on_form', 'status'),
    'module' => 'fbss_flag',
    'api_version' => 2,
  );
  $flags['follow'] = array(
    'content_type' => 'user',
    'title' => t('Follow'),
    'global' => FALSE,
    'types' => array(0=>'-'),
    'flag_short' => t('Follow'),
    'flag_long' => '',
    'flag_message' => t('Following'),
    'unflag_short' => t('Unfollow'),
    'unflag_long' => '',
    'unflag_message' => '',
    'unflag_denied_text' => '',
    'link_type' => 'toggle',
    'roles' => array (
      'flag' => array (0 => '2',),
      'unflag' => array (0 => '2',),
    ),
    'show_on_profile' => true,
    'access_uid' => '',
    'show_on_page' => TRUE,
    'show_on_teaser' => FALSE,
    'show_on_form' => FALSE,
    'status' => FALSE,
    'locked' => array('name', 'global', 'types', 'show_on_teaser', 'show_on_form', 'status'),
    'module' => 'fbss_flag',                                                                                                                                                          138,21        95%
    'api_version' => 2,
  );
  return $flags;
}
IceCreamYou’s picture

eidoscom’s picture

This must be substitute of the original code????

function on code is: "fbss_flag_views_default_views"
function that you provided is: "fbss_flag_flag_default_flags"

Thanks!!!

mathankumarc’s picture

Status: Active » Needs review
FileSize
2.55 KB

Here's the patch for it, modified the flag definitions according to flag api 2.

IceCreamYou’s picture

Status: Needs review » Needs work

Committed the patch in #6 to dev. I haven't tested it but it can't be worse than what's already there (which doesn't work at all).

However, this issue still isn't fixed. There are potential problems everywhere that flag_get_flag() or flag_get_flags() is called:

$ cd submodules
$ grep -rn "flag_get_flag" .
./fbss_comments/fbss_comments.module:294:    foreach (flag_get_flags() as $name
=> $info) {
./fbss_flag/fbss_flag.module:16:  foreach (flag_get_flags('statuses') as $flag)
{
./fbss_flag/fbss_flag.module:29:  foreach (flag_get_flags('statuses') as $flag)
{
./fbss_flag/fbss_flag.module:67:  $flag = flag_get_flag('like');
./fbss_flag/views/facebook_status_views_handler_argument_flagged_user.inc:14:
 $flag = array_shift(flag_get_flags($content_type));
./fbss_flag/views/facebook_status_views_handler_argument_flagged_user.inc:24:
 $flags = flag_get_flags('user');
./fbss_flag/views/facebook_status_views_handler_filter_flagged_user.inc:14:    $
flag = array_shift(flag_get_flags($content_type));
./fbss_flag/views/facebook_status_views_handler_filter_flagged_user.inc:24:    $
flags = flag_get_flags('user');
./fbss_flag/views/fbss_flag.views_default.inc:22:  $view->disabled = !flag_get_f
lag('follow')->status; // Line modified from default
./fbss_flag/views/fbss_flag.views_default.inc:285:      'statuses_flag_type' =>
flag_get_flag('follow')->fid, // Line modified from default
./fbss_services/fbss_services.extended.inc:81:  if (module_exists('flag') && $fo
llow = flag_get_flag('follow')) {
./fbss_services/fbss_services.extended.inc:329:    if ($flag = flag_get_flag($fl
ag_name)) {
./fbss_services/fbss_services.extended.inc:395:    if ($flag = flag_get_flag($fl
ag_name)) {
./fbss_services/fbss_services.extended.inc:421:  if (module_exists('flag') && $f
lag = flag_get_flag($flag_name)) {
mathankumarc’s picture

Here is the patch for fbss_comments flag integration.

I think the major problem here is flag integration with views, other areas seems to be fine.

mathankumarc’s picture

Oops! previous patch has lot of white spaces.

Here is the clean patch.

IceCreamYou’s picture

Committed #9 to dev, thanks!

Leaving at "needs work" because the problem mentioned in #7 still exists.

mathankumarc’s picture

Status: Needs work » Needs review
FileSize
1.54 KB

I don't see any issues with flag integration, after changing the flag definitions as per flag api 2(i.e after applying the patch in #2 and #9).

I didn't looked into services integration, since its not ported. I'm sure that flag_get_flag() and flag_get_flags() functions are working fine. However its needs some very little cleanup, added a patch for it.

I think flag integration is stable now. Isaac please share your thoughts on this.

IceCreamYou’s picture

Status: Needs review » Needs work

2 of the locations noted in #7 are still a problem:

  • fbss_flag.module line 68, $flag->status no longer exists
  • fbss_flag.views_default.inc line 22, $flag->status no longer exists

I am not exactly sure what happened to $flag->status so I'm not 100% sure what to do about this. Probably it is just not possible to disable a flag any more so flags are either enabled or nonexistent, in which case it should be enough to just check whether the flag object exists.

+++ b/submodules/fbss_comments/fbss_comments.module
@@ -291,10 +291,8 @@ function theme_fbss_comments_item($variables) {
-    foreach (flag_get_flags() as $name => $info) {
-      if ($info->content_type == 'fbss_comment') {
-        $output .= '<li class="fbss-comments-flag-'. check_plain($name) .'-link">' . flag_create_link($name, $comment->cid) . '</li>';
-      }
+    foreach (flag_get_flags('fbss_comment') as $name => $info) {
+      $output .= '<li class="fbss-comments-flag-'. check_plain($name) .'-link">' . flag_create_link($name, $comment->cid) . '</li>';
     }

Why did you make this change? We should only be adding fbss_comment flags to status comments, so it looks like that if() statement is required. The only change that probably should be made there is the string concatenation style (there should be a space before and after the concatenation operator . ).

mathankumarc’s picture

Why did you make this change? We should only be adding fbss_comment flags to status comments, so it looks like that if() statement is required

flag_get_flags() will return the all the flags(i.e it will return all the content type's flags), however flag_get_flags('fbss_comment') will return the flags which are associated to fbss_comments content type only. So there no need of condition here.

Will look into the $flag->status.

IceCreamYou’s picture

Ah, I overlooked that.

mathankumarc’s picture

$flag->status is exists, here is the dump data which I got for the following snippet

echo "<pre>";print_r(flag_get_flag('like'));exit;

fbss_flag Object
(
    [fid] => 5
    [content_type] => statuses
    [name] => like
    [title] => Like
    [global] => 0
    [types] => Array
        (
            [0] => page
        )

    [flag_short] => Like
    [flag_long] => 
    [flag_message] => 
    [unflag_short] => Un-like
    [unflag_long] => 
    [unflag_message] => 
    [unflag_denied_text] => 
    [link_type] => toggle
    [roles] => Array
        (
            [flag] => Array
                (
                    [0] => 2
                )

            [unflag] => Array
                (
                    [0] => 2
                )

        )

    [module] => fbss_flag
    [locked] => Array
        (
            [name] => name
            [global] => global
            [types] => types
            [show_on_teaser] => show_on_teaser
            [show_on_form] => show_on_form
            [status] => status
        )

    [show_on_teaser] => 
    [show_on_form] => 
    [status] => 1
)
IceCreamYou’s picture

Status: Needs work » Reviewed & tested by the community

Once again I stand corrected. The patch in #11 is RTBC and that should resolve this issue.

mathankumarc’s picture

Status: Reviewed & tested by the community » Fixed
udvranto’s picture

Will there be any port for 6.x?

IceCreamYou’s picture

The equivalent issue for D6 is #682244: Flag 2.x -- I guess the changes would be pretty similar to what was committed in this issue, except that Flag 1.x still needs to be supported. But yes there should be a backport.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Gaurav.Singh’s picture

Issue summary: View changes
FileSize
109.43 KB

It needs work. I am not able to add like flag from my views, it requires user.nid..but statuses have sid.. Issue in adding flag to views

Please help me out with this issue. I t is allowing to add follow but not like.

As soon I add like flag it gives me this error

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS users_, statuses.sid AS statuses_sid, entity_id AS entity_id FROM statuses s' at line 1

Please find image for the same

Thanks

Gaurav.Singh’s picture

Issue tags: +like flag not working
ugintl’s picture

Gaurav use flag 2. It does not work with flag 3

Gaurav.Singh’s picture

I can not downgrade Flag module..as I am already using that on my website.. Please provide any alternative in statuses module..??