Twitter Module Customization

drupal_developer's picture

I would like to thanks to the creator of this module for this incredible work.
I have observed some things that with which you can make twitter more better.
1) Nodes that are not published should not be posted to twitter. There may be approval process for nodes to get publish right?
2)Twitter passwords are not being encrypted which is not good. There should be someway to encrypt it while saving in db and when posting to twitter it should get decrypted.

rightchoice2c_me on July 03rd 2009

My requirement was that nodes should not get published as they are created, there is an approval process, once the content is approved then it should set the status in twitter. But twitter module set the status in twitter.com once the content is created.
As I am using workflow module for approval process. I set the action is workflow Post to twitter when content is published.
I did that by just adding a workflow in context in this hook twitter_actions_set_status_action in twitter_actions.module file.

global $user;
$variables['%site_name'] = variable_get('site_name', 'Drupal');

switch ($context['hook']) {
case 'nodeapi':
// Because this is not an action of type 'node' the node
// will not be passed as $object, but it will still be available
// in $context.
$node = $context['node'];
break;
case 'workflow':
// Some times the node publish will be assosiated with worklows
// so once the node is published through workflow the status should then be send to twitter
$node = $context['node'];
break;
// The comment hook provides nid, in $context.
case 'comment':
$comment = $context['comment'];
$node = node_load($comment->nid);
case 'user':
// Because this is not an action of type 'user' the user
// object is not passed as $object, but it will still be available
// in $context.
$account = $context['account'];
if (isset($context['node'])) {
$node = $context['node'];
}
elseif ($context['recipient'] == '%author') {
// If we don't have a node, we don't have a node author.
watchdog('error', 'Cannot use %author token in this context.');
return;
}
break;
case 'taxonomy':
$account = $user;
$vocabulary = taxonomy_vocabulary_load($object->vid);
$variables = array_merge($variables, array(
'%term_name' => $object->name,
'%term_description' => $object->description,
'%term_id' => $object->tid,
'%vocabulary_name' => $vocabulary->name,
'%vocabulary_description' => $vocabulary->description,
'%vocabulary_id' => $vocabulary->vid,
)
);
break;
default:
// We are being called directly.
$node = $object;
}

 

Free Web Hosting
v>