Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
VBO integration would be a nice feature for Auto Expire.I have not done vbo integration before, but I think it should be doable. I have no time available at the moment to dig into it myself, but if you start writing a patch, I'll be happy to review it and get it committed.
Hmm, i'll see, dont know if my knowledge is good enough for this. Maybe i will have to pay someone. But VBO integration should be something very useful for this modul.
p.s.
Is it possible that nodes are etended before time limit is over? Currently button Extend limit in table view of nodes (admin view i made) only shows if node is extended and it would be useful if it could be extended whenever, not waiting the time limit to pass. Is this doable?
As far as I can see, integration with vbo is done by implementing hook_node_operations (http://api.drupal.org/api/function/hook_node_operations/6) and making sure that it executes the right functions. Please don't feel obliged to post only perfect and complete patches; I invite you to give it a go and share your work-in-progress if you get stuck. Of course you can also pay someone to do it; obviously I would appreciate if that work would also be shared with the community.
Re. your ps:
The extend link in a view is available after a user has been warned that his node is about to expire. You could allow users to extend earlier by increasing the warn period. It is possible to break that link between warn period and the possibility to extend, but that would require some re-writing. If it's important to you, please open a separate issue for it.
Well i am trying, currently i did manage to get function to show in actions but it doesnt work. maybe i am calling wrong stuff or its not the right way to do it.
so i am calling _auto_expire_expiry_submit, as this seems like function to call but its not working. I am not so good with drupal and knowing how it works, so maybe its missing some arguments here altough if i compare to other example there is no argument passing of the nodes which are req. to change like
'label' => t('Demote the selected posts'),
'callback' => 'node_operations_demote',
so i guess i really dont know what is wrong here, any ideas?
When you look at http://api.drupal.org/api/function/node_node_operations/6 you'll see that there are callback arguments.
The tricky thing is that _auto_expire_expiry_submit is a form submit function, so it expects $form and $form_state as arguments. To keep code clean and readable, I think you should:
- separate the code that extends a node from the form submit handler, into it's own function (ie. auto_expire_extend($nid))
- create a mass update function (ie. auto_expire_mass_update) similar to node_mass_update (http://api.drupal.org/api/function/node_mass_update/6)
This way, both _auto_expire_expiry_submit() and auto_expire_mass_update() could call auto_expire_extend() to take care of the actual extension of a node.
I tried to figure out all this layers of abstraction in creating operations but didnt figure it out, tried to make some prints to see whate going on but nothing is outputed, i am just not good dev. in drupal so i made Execute arbitary PHP script that works.
$node=$object;
$expire= "SELECT expire FROM auto_expire WHERE nid = '$node->nid'";
$days = variable_get(AUTO_EXPIRE_NODE_TYPE . $node->type .'_d', AUTO_EXPIRE_DAYS);
$newexpire = max(time(), $expire) + $days * 24 * 60 * 60;
db_query('UPDATE {auto_expire} SET expire = %d, extended = extended + 1, warned = 0 WHERE nid = %d', $newexpire, $node->nid);
db_query('UPDATE {node} SET status = 1 WHERE nid = %d', $node->nid);
node_save($node);
also i removed part where you cannot extend node whenever you like, so cometing lines in view... .inc helps me solve this
class views_handler_field_auto_expire_link_extend extends views_handler_field_node_link {
function construct() {
parent::construct();
}
function render($values) {
$nid = $values->{$this->aliases['nid']};
// check if user has rights to extend
if (_auto_expire_can_user_extend($nid)) {
// check if node is 'extendable' at this moment
// $expire = _auto_expire_get_expire($nid);
// $code = AUTO_EXPIRE_NODE_TYPE . $node->type;
// $warn = variable_get($code . '_w', AUTO_EXPIRE_WARN);
// if (time() > $expire - ($warn * 24 * 60 * 60)) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('extend');
return l($text, "node/$nid/expiry", array('query' => drupal_get_destination()));
// }
}
return;
Don't worry, I'll write the action at the weekend (or before if I get time). ...I'm assuming that only one is required for extending a batch of nodes? ...And for the 6.x-1.0-rc1 release not HEAD?
Pobster, I know you have been working hard on improving this module and I appreciate that. I will reply once I have found the time to have a good look at your code. Sorry if that is not within your expected time frame.
No, no - you're misunderstanding what I mean. I'm not referring to the patch in the other issue queue here, I was merely asking for guidance on what is actually required to fulfil the request in this issue with regards what Actions are actually required... I thought in 4 days that **someone** might reply... Especially as someone posted a bounty on this 'feature' when I was offering to code it for free...
...I don't care about the other patch, it's up to you whether you use it or not - it brings no extra functionality to the module.
Comments
Comment #1
marcvangendVBO integration would be a nice feature for Auto Expire.I have not done vbo integration before, but I think it should be doable. I have no time available at the moment to dig into it myself, but if you start writing a patch, I'll be happy to review it and get it committed.
Comment #2
Marko B commentedHmm, i'll see, dont know if my knowledge is good enough for this. Maybe i will have to pay someone. But VBO integration should be something very useful for this modul.
p.s.
Is it possible that nodes are etended before time limit is over? Currently button Extend limit in table view of nodes (admin view i made) only shows if node is extended and it would be useful if it could be extended whenever, not waiting the time limit to pass. Is this doable?
Comment #3
marcvangendAs far as I can see, integration with vbo is done by implementing hook_node_operations (http://api.drupal.org/api/function/hook_node_operations/6) and making sure that it executes the right functions. Please don't feel obliged to post only perfect and complete patches; I invite you to give it a go and share your work-in-progress if you get stuck. Of course you can also pay someone to do it; obviously I would appreciate if that work would also be shared with the community.
Re. your ps:
The extend link in a view is available after a user has been warned that his node is about to expire. You could allow users to extend earlier by increasing the warn period. It is possible to break that link between warn period and the possibility to extend, but that would require some re-writing. If it's important to you, please open a separate issue for it.
Comment #4
Marko B commentedWell i am trying, currently i did manage to get function to show in actions but it doesnt work. maybe i am calling wrong stuff or its not the right way to do it.
so i am calling _auto_expire_expiry_submit, as this seems like function to call but its not working. I am not so good with drupal and knowing how it works, so maybe its missing some arguments here altough if i compare to other example there is no argument passing of the nodes which are req. to change like
'label' => t('Demote the selected posts'),
'callback' => 'node_operations_demote',
so i guess i really dont know what is wrong here, any ideas?
Comment #5
marcvangendWhen you look at http://api.drupal.org/api/function/node_node_operations/6 you'll see that there are callback arguments.
The tricky thing is that _auto_expire_expiry_submit is a form submit function, so it expects $form and $form_state as arguments. To keep code clean and readable, I think you should:
- separate the code that extends a node from the form submit handler, into it's own function (ie. auto_expire_extend($nid))
- create a mass update function (ie. auto_expire_mass_update) similar to node_mass_update (http://api.drupal.org/api/function/node_mass_update/6)
This way, both _auto_expire_expiry_submit() and auto_expire_mass_update() could call auto_expire_extend() to take care of the actual extension of a node.
Comment #6
Marko B commentedStill didnt solve this, thinking of using execute arbitary php script, but there is nothing about node expiry in node object, hmm
Comment #7
Marko B commentedI tried to figure out all this layers of abstraction in creating operations but didnt figure it out, tried to make some prints to see whate going on but nothing is outputed, i am just not good dev. in drupal so i made Execute arbitary PHP script that works.
$node=$object;$expire= "SELECT expire FROM auto_expire WHERE nid = '$node->nid'";
$days = variable_get(AUTO_EXPIRE_NODE_TYPE . $node->type .'_d', AUTO_EXPIRE_DAYS);
$newexpire = max(time(), $expire) + $days * 24 * 60 * 60;
db_query('UPDATE {auto_expire} SET expire = %d, extended = extended + 1, warned = 0 WHERE nid = %d', $newexpire, $node->nid);
db_query('UPDATE {node} SET status = 1 WHERE nid = %d', $node->nid);
node_save($node);
also i removed part where you cannot extend node whenever you like, so cometing lines in view... .inc helps me solve this
class views_handler_field_auto_expire_link_extend extends views_handler_field_node_link {function construct() {
parent::construct();
}
function render($values) {
$nid = $values->{$this->aliases['nid']};
// check if user has rights to extend
if (_auto_expire_can_user_extend($nid)) {
// check if node is 'extendable' at this moment
// $expire = _auto_expire_get_expire($nid);
// $code = AUTO_EXPIRE_NODE_TYPE . $node->type;
// $warn = variable_get($code . '_w', AUTO_EXPIRE_WARN);
// if (time() > $expire - ($warn * 24 * 60 * 60)) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('extend');
return l($text, "node/$nid/expiry", array('query' => drupal_get_destination()));
// }
}
return;
}
}
Comment #8
pobster commentedDon't worry, I'll write the action at the weekend (or before if I get time). ...I'm assuming that only one is required for extending a batch of nodes? ...And for the 6.x-1.0-rc1 release not HEAD?
Pobster
Comment #9
pobster commentedAs no-one replied (in 4 days...) I didn't bother. Whatever...
Pobster
Comment #10
marcvangendPobster, I know you have been working hard on improving this module and I appreciate that. I will reply once I have found the time to have a good look at your code. Sorry if that is not within your expected time frame.
Comment #11
pobster commentedNo, no - you're misunderstanding what I mean. I'm not referring to the patch in the other issue queue here, I was merely asking for guidance on what is actually required to fulfil the request in this issue with regards what Actions are actually required... I thought in 4 days that **someone** might reply... Especially as someone posted a bounty on this 'feature' when I was offering to code it for free...
...I don't care about the other patch, it's up to you whether you use it or not - it brings no extra functionality to the module.
Pobster
Comment #12
marcvangendOK, I see, I figured that your clean-up work in the other issue was meant as a foundation to write this patch here, but obviously I misunderstood.
Comment #13
Marko B commentedI dont know if action will be made for this or not, just to say that my stuff works and its useable :-)