| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Helper class to provide a functor as callback. 4 */ 5 class DataViewsBulkOperationsHelper { 6 var $table_name; 7 function __construct($table_name) { 8 $this->table_name = $table_name; 9 } 10 function load($oid) { 11 $handler = data_get_handler($this->table_name); 12 if (!$handler) return NULL; 13 $table = data_get_table($this->table_name); 14 if (!$table) return NULL; 15 $schema = $table->get('table_schema'); 16 $objects = $handler->load(array($schema['primary key'][0] => $oid)); 17 return (object)$objects[0]; 18 } 19 }; 20 21 /** 22 * Implementation of hook_views_bulk_operations_object_info(). 23 */ 24 function data_vbo_views_bulk_operations_object_info() { 25 $object_info = array(); 26 foreach (data_get_all_tables() as $table_name => $table) { 27 $schema = $table->get('table_schema'); 28 $object_info[$table_name] = array( 29 'type' => 'data', 30 'base_table' => $table_name, 31 'load' => array(new DataViewsBulkOperationsHelper($table_name), 'load'), 32 'oid' => $schema['primary key'][0], // TODO handle more than one PK in VBO 33 'title' => $schema['primary key'][0], // TODO find a more suitable title 34 ); 35 } 36 return $object_info; 37 } 38 39 /** 40 * Implementation of hook_action_info(). 41 */ 42 function data_vbo_action_info() { 43 return array( 44 'data_delete_action' => array( 45 'type' => 'data', 46 'description' => t('Delete data record'), 47 'configurable' => FALSE, 48 'behavior' => array('deletes_node_property'), 49 ), 50 ); 51 } 52 53 function data_delete_action($datum, $context) { 54 if (!isset($context['object_info'])) return; 55 $object_info = $context['object_info']; 56 $handler = data_get_handler($object_info['base_table']); 57 if (!$handler) return; 58 $handler->delete(array($object_info['oid'] => $datum->{$object_info['oid']})); 59 } 60
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |