This patch adds permissions, lets you choose for which node types to enable twitter, and adds the ability to post to a site-wide twitter account in addition to a user's personal twitter account. This patch is for the Drupal 5 version.

Comments

Ian Ward’s picture

StatusFileSize
new5.98 KB

The indentation was messed up on the above patch. Here is a new one.

mlncn’s picture

Status: Needs review » Reviewed & tested by the community

Ian Ward's revised patch in #1 applies cleanly, looks good, and works fine!

Some documentation - this module needs it! - is started here:

http://agaricdesign.com/note/twitter-module-drupal-plus-facebook-plus-ad...

benjamin, Agaric Design Collective

mlncn’s picture

Assigned: Unassigned » mlncn
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new5.85 KB

Actually, further use showed that Ian Ward's patch added the Twitter-this form option to every content type. The attached patch puts in a check to see if it has been enabled for a given content type.

Note: It also makes Twitter to personal checked off by default. This is my preference; ideally I think this should be configurable on a per-content-type basis also. I can reroll the patch without it if anyone objects.

Another thought: should the form not be shown on node edit pages, since the twittering only happens on op 'insert'? Should we keep a record of nodes that were in fact twittered (probably meaning we move away from form_alter for setting up the twitter to more nodeapi)?

mr.j’s picture

StatusFileSize
new8.66 KB

I have added a few things to this patch:

- The twitter user form is now not inserted into the user's profile unless they have permission to post using their personal twitter account (better that people who can't post to twitter don't even see that the feature exists).
- Added tinyurl functionality from the following patch to the sitewide settings (off by default, so no harm): #245453: use tinyurl on urls

Personally I don't like the default setting of 'personal' being checked by default but I can live with it, it's a one-liner to fix.

albertc’s picture

Er... I'm not familiar with module patching. Can somebody add these to the module itself? Thank you!

90macrk’s picture

albertc - I wasn't familiar with patching but found the 'how to' here http://drupal.org/patch/apply simple to follow.

I have the patched the module and it does 95% of what I was hoping. I have configured the sitewide twitter account and that works perfectly but my users still have a 'twitter setup' panel within their 'my account' page. Does anyone know how to hide this panel from view? Any help would be gratefully appreciated.

90macrk’s picture

mr.j - Thank you. That's what I call help - as I was writting my post you were answering my question!

mr.j’s picture

StatusFileSize
new2.64 KB

Here you go albertc - make a backup of your twitter.module then replace it with this one:

mr.j’s picture

StatusFileSize
new2.64 KB
new8.65 KB

I just found a bug that was in this thread's original patch:

if (user_access('broadcast to personal twitter')) {
  $options['personal'] = t('Send to personal twitter');
}
if (user_access('broadcast to personal twitter')) {
  $options['sitewide'] = t('Send to sitewide twitter');
}

As you can see the second if condition should say "sitewide" instead of "personal" in the user_access string.
This prevents users other than the global admin from choosing to post to the sitewide twitter account, even if they have permission.

Here is my patch rerolled with a fix for that bug (also attached full module in case anyone cant patch).

mr.j’s picture

StatusFileSize
new8.75 KB

Another bugfix - added a check that the current logged in user is the same as the user being edited before showing the personal twitter settings form. This is because an admin user with permission to have a personal twitter account would see the twitter account settings when editing another user's profile.

Also made sure the form only appears on the "account settings" tab within the user profile.

And finally also set a weight of 7 on the twitter settings box to push it to the bottom of the form, rather than inserting it at the top before the account settings.

Shai’s picture

Mr. J and all,

This is a fantastic idea/module.

I've had success with patch in #9.

Patch in #10 returns: "patch: **** malformed patch at line 186: case 'insert':"

Please inform whether the following are new feature requests or are possible in current version:

1. Create more than one sitewide Twitter.
2. Integrate with Token module so that there are more choices for the text formatting. One thing that seems critical to me is to prepend the username (ideally linked to user profile) of the person submitting a sitewide twitter so that the author of the twitter is included in the twitter.

shai
content2zero

Shai’s picture

Gang,

By tomorrow I should have a patch that allows one to put in !user to return the user name and !userurl to return the users profile url in the text format field.

It's working on my site, just have some cleaning up and patch rolling to do.

No progress on making it possible for more than one sitewide twitter. Kind of begs the question, could Twitter account settings be turned into a CCK field type?

The patch won't have any of the improvement in #10 because that patch wouldn't apply properly for me.

Shai

Shai’s picture

StatusFileSize
new9.38 KB

My starting place for editing was with the patch in #9 applied. The new patch is against the current dev version.

Seems like someone with committing privileges (Benjamin?), should make a new commit because patches are much harder to read when they are many, many changes included.

I've corrected some little typos and also changed some language, like changing "Text format" to "Text content." When I think "format" I think of italics etc. The content tokens are what are applied there.

Look forward to any feedback. There are now four tokens supported, the original two plus: !user and !userurl. !user returns the user name and !userurl returns the users profile page url.

Shai

arrpa’s picture

I applied this patch and in my user profile still twitter setting appear everywhere. plus there is no option for user to select if he wants to use site wide twitter.
But I do see sitewide twitter settings in site configurations where I can setup the sitewide twitter.

And one more thing, Whenever I set twitter settings for admin user and post a content it goes to twitter, But when I set the twitter settings for an authenticated user, it doesnt goto twitter. I am guessing this is something to do with some permission. Since I am pretty much new to drupal, I looked around permissions and stuffs. Still cant see anywhere I can fix this.

Any help, much appriciated.

Shai’s picture

Aarpa, specifically which patch did you apply to what. List the patch by the comment # that it was posted in.

Shai

arrpa’s picture

I was running the version without any patch. And then I applied #13. Somehow its not working. So can you post the last twitter.module file.

Shai’s picture

arrpa,

Okay, here is the dev version patched with #13. The file upload wasn't working here so I pasted it here:

http://privatepaste.com/80jcdZB6AT

Let me know if it works.

Shai

FYI p.s. I edited this page on September 18, 2008 and replaced the privatepaste URL with a new one since the old one expired. It's the same code. I set it this time not to expire, though I hope this issue to be resolved soon :)

arrpa’s picture

I tried this patch.
but for somereason there is no menu where I could enter the sidewide Twitter settings. So I cant seem to test this.

arrpa’s picture

StatusFileSize
new8.38 KB

attached is the twitter.module files that I am having right now. Its without any fixes. Hope this might be of any help, in figuring out whats wrong.

mlncn’s picture

I do not have commit privileges, but would respectfully ask for them, or, better, that Shai get co-maintainership. I understand a lot of work has gone into the Drupal 6 version of the Twitter module but there are clearly some small fixes worth making separately to the D5 branch.

benjamin, Agaric Design Collective

Shai’s picture

@arrpa,

I believe your problem is in not knowing how to set it up properly. So I'm going to write pretty explicit instructions here and then hope you can go back and try it again with #13 applied:

In order to set up site wide Twitter, I believe you need to be set up as user/1, in other words, logged in under the first account that was set up when the site was created. Once logged in as user/1, you go to:

/admin/settings/twitter

You set permissions at:

/admin/user/access

There you can give different roles ability to send a Twitter message that includes the title field and/or the node's URL or any node type that is enabled for Twitter (with my patch you can also optionally include the user's "name" field and profile url). You enable node types for Twitter sending at:

/admin/content/types/story (where "story" is the name of a specific content type). Look at the bottom of the form for "enable Twitter broadcasting."

When a user is creating a node of a Twitter-enabled node type, there is a collapsible field set toward the bottom of the form containing two check boxes: broadcast to personal Twitter, broadcast to sitewide Twitter. Checking one or both of those boxes will cause a Twitter to be sent to the personal twitter account set up on the user's user page and/or to the sitewide account set up by user/1. Check boxes only occur if the user is in a role that has permission to send to at least one of the two types: personal or sitewide Twitter.

With the help of these instructions, I'd hope you go back to experimenting on a patched version, with either the patch in #13 or #9 applied, preferably #13 -- then report back.

Thanks for your persistence.

Good luck,

Shai

arrpa’s picture

@Shai
I have done exactly the same,
And actually I am trying to get twitter module working on like this.
A row is inserted to DB creating a new node. And I want to trigger twitter module to send out the twits without any other user intrevention. The twitter module I have right now (attached in post #19) works sometimes and doesnt work then. And also I have noticed sometimes when One user creates a node the twit goes from another user's account.
Could someone modify that it keeps looking at node table. and when ever a new node is created it triggers the twitter module. And ofcourse to send out to sitewide twitter and personel twitter.

Thanks

afreytes’s picture

I'm trying out #17.

Settings seem to show and work as appropiate. Will update this when I make a post with the node type I enabled it on.

cglusky’s picture

just fired it up and it seems to work fine for me on blog posts. nice work!

christefano’s picture

#256475 and #275311 have been marked as duplicates of this issue.

Shai’s picture

#24 - cglusky,

Thanks for testing.

Just to keep things clear and on track, could you specifically mention which patch you applied and tested.

Thanks,

Shai

cglusky’s picture

sorry bout that. yes, the patched version linked on #17. sitewide, personal, tinyurls, content type integration, admin etc all seem to work fine.

theunraveler’s picture

StatusFileSize
new407 bytes

I made a patch based on the the code in comment #17 that posts to a twitter account (sitewide or personal) when a node is updated as well, if the check box is checked. With the code from #17, the node would only be posted on the twitter account when it was inserted into the database.

I'm sort of new at fooling with modules, so let me know if I've done something wrong.

Shai’s picture

unravelme1 --

Great.

I'll give this a whirl and report back. Nice idea.

This will give me new energy to keep up my (so far unsuccessful) harassment of walkah and eaton to commit a new dev version on the D5 branch.

Best,

Shai

theunraveler’s picture

Any progress with this? I'd like to see a new release rolled out so that I don't have to use a patched-up unofficial copy of this module on my site. I'd be willing to step up and maintain the module if someone with more experience could help me out.

Shai’s picture

Unravelme!,

I appreciate your interest. This hasn't gotten any response from the project maintainer, unfortunately. I'm going to try writing him a private email today, see if we can get him to budge or allow other people commit priveleges.

Shai

cglusky’s picture

Thanks for keeping on top of this Shai. Any thoughts/testing on the latest #28 patch to include Twetes on node update? I have not applied yet, but can easily do so and test if this is something that we will push for going forward. As a feature it does seem to make sense.

Hopefully if the Fail Whale is reduced to a bad memory this module will get more official lovin'.

R,
Coby

Shai’s picture

I've tested #28 which is a patch on #13 which is a patch on the June - 07 D5 Twitter module dev version. It worked great!

I've posted a twitter.module file, patched with the above two patches, for folks who are new to patching and/or don't want to fuss with applying two patches.

http://privatepaste.com/f8JCIEhRAN

(FYI, I tried attaching it to this post, but Drupal.org wouldn't let me.)

best,

Shai

christefano’s picture

StatusFileSize
new11.31 KB
new8.56 KB

Thanks, Shai! I couldn't keep track of what was a patched version of what and simply gave up.

Here's your version of the module from #33 (rename twitter_220092.txt to twitter.module) as well as a patch.

alan4cast’s picture

All of these comments are awesome and it's making this into a potentially great module! (Which I'm already using on one of my sites).

Is there a way to have another substitution? I really want to send the body (a !body substitution) - or at least the first 140 characters. Or maybe someone knows a way to do the reverse? My new site has a "latest thought" that's already been going out on twitter for several weeks. We want to incorporate that into a block... The easiest way seemed to be to make a new content type ("Twitter Message" or "tweet") and have appropriate members post that each day - with the thought going out to twitter...

The "reverse" would be a post to twitter, which is then followed by the site and made into a node... That just seems harder!

Thanks!

Alan

Shai’s picture

Alan,

What you said is harder is actually much easier, when you combine Twitter's feed capabilities with Drupal aggregation capabilities. Using Drupal core's Aggregator module you should be able to pull in your tweets to a Drupal block in like two minutes to set up. However, that way you can't turn each tweet into a Drupal node which means you miss out on various node goodness like taxonomy and comments and exposure to views. But maybe you just need the content. And you're done.

A more complicated but flexible solution would require the contrib module called, feedapi. Wow, that module is incredibly powerful. Several months ago when I was fooling around with it, it was a bit buggy with a relatively steep learning curve. It's already up to version 1.3 under very active development by a bunch of smart people, so I'd assume they've cleaned up most of the bugs. Still might be a bit hard to learn. With feedapi you can basically take content from any source that puts out a feed and do ANYTHING you want with it on your Drupal site.

I like the idea of using the body text instead of or in addition to the title text. Also is there some jquery widget we can use to count out the 140 characters?

Shai

cglusky’s picture

Alan,
There are a few options for posting:
1) Create a new content type and omit the body and just use the title field. Problem is in D5 you are limited to 128 characters and in D6 it goes to 255? But you could use the !title token.
2) If you are using CCK then you could create a new text area field named something like 'twete' and then do a hook form alter to limit it's size. You would then need to add support for the right token in the twitter.module to get your field sent to twitter - something like (consider this pseudo code please):

// not tested - pseudo code 
!twete = $node = > field_twete;

3) We could do a string manipulation to limit the body to the first 140 characters and add support for the !body token, but you get into running filters which looks to be a bit tricky. Something like (again not tested, making this up as i go along quality code):

// not tested pseudo code //
$body = check_markup($body, FILTER_HTML_STRIP, False);
$body = substr($body, 0, 139);

See some more info with a (possibly dated) code snippet here: http://drupal.org/node/68180

Near the bottom of the twitter.module file you will see the array that builds the twetes from the supported tokens.

And for bringing twetes in for display I think FeedAPI might have you covered, but that will depend on what you are trying to follow.

We are going OT here (and have been for a bit I think), but it would help if you put the first part in a separate feature request. The second part about receiving twetes is out of scope for this module.

R,
Coby

cglusky’s picture

Looks like Shai beat me to the reply - what he said. And I could have probably just patched the darn thing by the time I finished my ode to twitter module.

christefano’s picture

Also is there some jquery widget we can use to count out the 140 characters?

Maxlength is designed for this and has a counter showing remaining characters, but it appears to be limited to the node's body field.

This thread is exploding in a lot of different directions. Can we stay on topic and open new issues for separate feature requests?

coltrane’s picture

Marked #339931: Module need permissions as a duplicate of this issue.

hankpalan.com’s picture

I'm running the latest dev for the 6.x version. Are the problems and fixes mentioned in this issue applied to the 6.x version?

Why do I still have a Twitter link on a user account page if I haven't given permission for that user to add a twitter account?

mckeen_greg’s picture

I can confirm with #41 that these changes have not been committed to the D6 Version. I was about to come and post a "Feature request" issue, when I noticed this. It would be great if all of these changes were committed to D6 as the module sorely needs this functionality. Per content basis, non-twitter access users not seeing twitter settings, Off by default, only on node/edit. All of this could also be configurable by admin in twitter-settings.

Im no coder, so I cant help there Im afraid.

mrfelton’s picture

As with #42, I was just about to post a feature request for some permission control. I really want twitter functionality for my site, but there is no way I can use this module if it is going to giver every user their personal twitter tab.

michaek’s picture

Status: Needs review » Closed (won't fix)