Twitter Tab shouldn't be visible if user has not given his account informations

Starminder - April 29, 2009 - 16:53
Project:Twitter
Version:6.x-2.4
Component:User interface
Category:task
Priority:critical
Assigned:Unassigned
Status:needs review
Description

Module is setup, but there are no fields to enter account information on the Twitter Tab in my user account.

#1

MaffooClock - May 12, 2009 - 16:55

I can confirm this problem. Uninstalled, reinstalled, tried dev version -- nothing changes.

#2

anselmbradford - May 14, 2009 - 10:33

Are you looking at the "Twitter" tab or the "Twitter accounts" sub tab under "Edit"?

The main Twitter Tab is controlled by the tweets View, and will be empty if there are no Twitter status' imported.

#3

funana - May 14, 2009 - 13:44

http://drupal.org/node/448676#comment-1587782 is the way to go.

The fact that the Twitter tab is shown even if the user has not given his Twitter account information is very irritating.
The Twitter Tab should not show up if the user has not given his account informations. Should we open another issue for that?

#4

dddave - May 26, 2009 - 15:45
Title:Twitter Tab on User Account is blank» Twitter Tab shouldn't be visible if user has not given his account informations
Version:6.x-2.3» 6.x-2.4
Component:Code» User interface
Category:bug report» task

Woah, this was irritating and should really be fixed.

#5

heywetried - June 1, 2009 - 17:11
Priority:normal» critical

I hope no one minds that I've bumped this up to critical status. This (fantastic) module is basically useless as long as this bug remains.

I've got a company site with a global twitter account, but only employees can use it (of course). I don't want other site users (clients) looking at an empty Twitter tab on their profile pages wondering what that feature does. I assume that this is not an uncommon application of this module.

I'm still building right now, but I'm thinking of a hack at the theme layer (once I get around to it) to get rid of the tab (since I don't need it on any user's profile page, actually). I'll post it here if it works for me.

#6

Nimo - June 11, 2009 - 12:01

Subscribing.

#7

entr3p - June 12, 2009 - 05:19

Subscribing. It really surprised me when I saw this "bug". It confused me a little as I thought I set up something wrong.

#PS: Also the tab shouldn't be shown if the " Import Twitter statuses" is disabled. It doesn't make sense to disable importing the Twitter statuses and show a blank page.

#8

heywetried - June 17, 2009 - 21:43

I was hoping to be able to get this out at the theme layer, but instead I had to do a very minor hack to the module. In "twitter.views_default.inc" at about line 135, I replaced this:

  $handler = $view->new_display('page', 'Page', 'page');
  $handler->override_option('path', 'user/%/tweets');
  $handler->override_option('menu', array(
    'type' => 'tab',
    'title' => 'Twitter',
    'weight' => '1',
  ));

with this:

// this commented out section added a twitter tab to all user profile pages

//  $handler = $view->new_display('page', 'Page', 'page');
//  $handler->override_option('path', 'user/%/tweets');
//  $handler->override_option('menu', array(
//    'type' => 'tab',
//    'title' => 'Twitter',
//    'weight' => '1',
//  ));

This removes the twitter tab from all profile pages (it actually prevents views from defining the page) without modifying the remaining featureset of the module (at least as far as I use it).

This does the job for my purposes, but I suppose if you wanted to use a less draconian measure, you could put conditionals on the original section of code, restricting the display of the tab and/or creation of the page by uid or role. This might also be where this feature would be patched for a future version of the module (so it could be configured in the admin), but I don't know enough about drupal module programming to make this happen. Anyone care to take it on?

#9

aharown07 - June 22, 2009 - 12:51

Put in your hack but I still see Twitter tabs... some kind of cache flush required?

Edit: yup. Had to do a total cache flush.

#10

gettysburger - June 22, 2009 - 12:40

Subscribing

#11

yelvington - June 23, 2009 - 15:42

+1 for this fix.

We are not planning to dish out Twitter privileges to hundreds of users due to scalability concerns, but we want staffers to be able to use this module. Hiding the Twitter tab is important.

#12

wickwood - July 14, 2009 - 01:24

Subscribing, definitely would like to see this changed.

#13

djudd - July 14, 2009 - 21:25

I don't even plan to allow my staffers to use the module directly. I want it to be used for news updates during live coverage events, like a local high school football game. Yes, we're a community newspaper.

With that in mind, I decided to remove the tab all together in favor of people tweeting from their phones remotely with a change to my template.php file.

function themename_preprocess_page(&$vars) {
  // Remove undesired local task tabs.
  // This first example removes the Users tab from the Search page.
  endless_news_removetab('Twitter', $vars);
}

function themename_removetab($label, &$vars) {
  $tabs = explode("\n", $vars['tabs']);
  $vars['tabs'] = '';

  foreach ($tabs as $tab) {
    if (strpos($tab, '>' . $label . '<') === FALSE) {
      $vars['tabs'] .= $tab . "\n";
    }
  }
}

#14

artha6 - July 29, 2009 - 04:11

Subscribing.

#15

tobias - August 4, 2009 - 06:14

+1 on hiding this tab for folks who are not using twitter.

#16

jez500 - August 6, 2009 - 06:25

Subscribing

#17

garethsprice - August 13, 2009 - 16:03

Simple fix: Site Building > Views > scroll to 'Tweets' > hit 'Disable'

Thought I'd better post this before the next "suggestion" involved hacking core...

#18

dugh - August 25, 2009 - 03:13

Yeah you can disable the twitter view from views (which I did), but this issue is about hiding the tab only if the user hasn't entered any twitter info.

I did a similar hack for the FriendFeed module in drupal 5, but that hack doesn't work in drupal 6 (I'll work on it when I have more time): http://drupal.org/node/277826

It involved loading the user object (user_load) and checking for the existence of the setting (probably not optimal, but it worked at least). You could also just do an SQL query yourself, similar to what the user_load object does, but more lightweight: http://api.drupal.org/api/function/user_load/6

This is a common thing with other views (with tabs/menus) too, so it'd be nice as a general feature (conditional views?).
Or since menus & tabs already dynamically hide based on permissions, perhaps it could be connected to that somehow.

#19

jblyberg - August 28, 2009 - 20:03

Attached is a small patch that will cause the tab to display only if the user has permission to add a personal twitter account. Once patched, you'll have to clear your cache for the change to take effect.

AttachmentSize
user_tabfix.patch 460 bytes

#20

dddave - August 28, 2009 - 20:11
Status:active» needs review

Hope I get the time to try this soon.....

Against which version is this patch?

#21

jblyberg - August 29, 2009 - 03:09

6.x-2.6

#22

dugh - August 29, 2009 - 03:21

I updated my friendfeed patch to work for drupal 6, if you want to adapt it to the twitter module. It hides the menu tab if the user has not entered any friendfeed info in their account.

The key part is the menu 'access callback'. Add that to wherever the twitter menu tab is being created (in the menu hook).

function _friendfeed_user_tab_access($account) {
  return user_access('view friendfeeds') &&
         !empty($account->friendfeed_username) &&
         !empty($account->friendfeed_key);
}

function friendfeed_menu() {
  return array(
    'user/%user/friendfeed' => array(
      'title' => 'FriendFeed',
      'description' => 'View FriendFeed status.',
      'page callback' => 'friendfeed_user_view',
      'page arguments' => array(1),
      'access callback' => '_friendfeed_user_tab_access',
      'access arguments' => array(1),
      'type' => MENU_LOCAL_TASK,
    ),
  );
}

#23

majnoona - October 13, 2009 - 19:53

Subscribing
I'd love to see this fix in the module and not just a patch!
Sounds like many people have the same issue with only wanting to allow a subset of users to have twitter accounts!

#24

frogdog - October 19, 2009 - 17:24

thank you to garethsprice, you saved me a lot of time and trouble... your solution was all i needed for my site.

#25

cheema-elegant - November 18, 2009 - 06:18

Thanks "garethsprice" ..

#26

ktf - November 23, 2009 - 23:39

garethsprice's solution works, but only if you don't actually want your tweets to be displayed somewhere.

Here's how I solved the problem:

1) Go to: admin/build/views/list
2) Edit the "Tweets" view
3) Select "User page"
4) Under "Page settings", change the "Menu" setting to "No menu"

Worked like a charm!

 
 

Drupal is a registered trademark of Dries Buytaert.