Programmatically activate operations for an existing view
eipie - April 3, 2008 - 19:38
| Project: | Views Bulk Operations (VBO) |
| Version: | 5.x-1.0-beta5 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hi,
I want to ask how I can activate in my update script the operations for an existing view, so that I do not have to click it. I want to program it. Copy the content from the variable table into my update script and then variable_set did not function. So, how can I do this?
eipie

#1
Very good question. The main idea is to set a variable called "views_bulk_operations_prefs_$vid" to an array of strings, each string being the md5() result of the label of the action that we want to include in the view. Two things:
1. $vid is either the actual vid of the view if the latter is stored in the view_view table. If it is a default view, then it's not stored in the view_view table and therefore its vid = NULL. In this case the $vid variable is the view name.
2. Up until VBO Beta 5, the label of the action on which the md5() is applied came from the description field of the action structure. After Beta 5, the label is now the callback function name because this avoids the problem of localizing the description field (as was pointed out by another user).
I realize that's complicated. We never took that issue into consideration. Ideally, the VBO module should expose functions to set and read the selected actions for a given view. Feel free to contribute a patch that adds these functions based on the above logic :-)
#2