Skip to content
Snippets Groups Projects
Commit 00ec7e39 authored by Ryan Szrama's avatar Ryan Szrama
Browse files

Committing files missed during a Git export to CVS.

parent 0324d316
No related branches found
No related tags found
No related merge requests found
......@@ -13,68 +13,67 @@
* Implements hook_rules_event_info().
*/
function commerce_line_item_rules_event_info() {
$items = array(
'commerce_line_item_insert' => array(
'label' => t('After saving a new line item'),
'group' => t('Commerce'),
'variables' => commerce_line_item_rules_variables(t('Created line item')),
'access callback' => 'commerce_line_item_rules_access',
),
'commerce_line_item_update' => array(
'label' => t('After updating an existing line item'),
'group' => t('Commerce'),
'variables' => commerce_line_item_rules_variables(t('Updated line item'), TRUE),
'access callback' => 'commerce_line_item_rules_access',
),
'commerce_line_item_presave_insert' => array(
'label' => t('Before saving a new line item'),
'group' => t('Commerce'),
'variables' => commerce_line_item_rules_variables(t('Saved line item'), TRUE),
'access callback' => 'commerce_line_item_rules_access',
),
'commerce_line_item_presave_update' => array(
'label' => t('Before saving an updated line item'),
'group' => t('Commerce'),
'variables' => commerce_line_item_rules_variables(t('Saved line item'), TRUE),
'access callback' => 'commerce_line_item_rules_access',
),
'commerce_line_item_delete' => array(
'label' => t('After deleting a line item'),
'group' => t('Commerce'),
'variables' => commerce_line_item_rules_variables(t('Deleted line item')),
'access callback' => 'commerce_line_item_rules_access',
),
);
$events = array();
// Specify that on presave the line item is saved anyway.
$items['commerce_line_item_presave_insert']['variables']['line_item']['skip save'] = TRUE;
$items['commerce_line_item_presave_update']['variables']['line_item']['skip save'] = TRUE;
$events['commerce_line_item_presave'] = array(
'label' => t('Before saving a line item'),
'group' => t('Commerce Line Item'),
'variables' => commerce_line_item_rules_event_variables(t('Line item'), TRUE, TRUE),
'access callback' => 'commerce_line_item_rules_access',
);
$events['commerce_line_item_insert'] = array(
'label' => t('After saving a new line item'),
'group' => t('Commerce Line Item'),
'variables' => commerce_line_item_rules_event_variables(t('Created line item'), TRUE),
'access callback' => 'commerce_line_item_rules_access',
);
$events['commerce_line_item_update'] = array(
'label' => t('After updating an existing line item'),
'group' => t('Commerce Line Item'),
'variables' => commerce_line_item_rules_event_variables(t('Updated line item'), TRUE),
'access callback' => 'commerce_line_item_rules_access',
);
$events['commerce_line_item_delete'] = array(
'label' => t('After deleting a line item'),
'group' => t('Commerce Line Item'),
'variables' => commerce_line_item_rules_event_variables(t('Deleted line item')),
'access callback' => 'commerce_line_item_rules_access',
);
return $items;
return $events;
}
/**
* Returns some parameter suitable for using it with a node
* Returns a variables array for line item events.
*
* @param $label
* The label for the primary line item variable.
* @param $unchanged
* Boolean indicating whether or not to include the unchanged line item.
* @param $skip_save
* Boolean indicating whether or not the primary line item variable should
* skip saving after event execution.
*/
function commerce_line_item_rules_variables($label, $update = FALSE) {
$args = array(
function commerce_line_item_rules_event_variables($label, $unchanged = FALSE, $skip_save = FALSE) {
$variables = array(
'line_item' => array(
'type' => 'commerce_line_item',
'label' => $label,
'skip save' => $skip_save,
),
);
if ($update) {
$args += array(
'line_item_unchanged' => array(
'type' => 'commerce_line_item',
'label' => t('Unchanged line item'),
'handler' => 'rules_events_entity_unchanged',
),
// Include the unchanged line item if specified.
if ($unchanged) {
$variables['line_item_unchanged'] = array(
'type' => 'commerce_line_item',
'label' => t('Unchanged line item'),
'skip save' => TRUE,
'handler' => 'rules_events_entity_unchanged',
);
}
return $args;
return $variables;
}
/**
......
......@@ -53,15 +53,12 @@ class CommerceLineItemEntityController extends DrupalDefaultEntityController {
'currency_code' => $line_item->unit_price[LANGUAGE_NONE][0]['currency_code'],
);
// Give modules the opportunity to prepare field data for saving, first
// through the Field API and then through $op specific hooks.
// Give modules the opportunity to prepare field data for saving.
field_attach_presave('commerce_line_item', $line_item);
rules_invoke_all('commerce_line_item_presave', $line_item);
// If this is a new line item...
if (empty($line_item->line_item_id)) {
// Give modules the opportunity to prepare field data for inserting.
rules_invoke_all('commerce_line_item_presave_insert', $line_item);
// Set the creation timestamp.
$line_item->created = REQUEST_TIME;
......@@ -72,9 +69,6 @@ class CommerceLineItemEntityController extends DrupalDefaultEntityController {
$op = 'insert';
}
else {
// Give modules the opportunity to prepare field data for updating.
rules_invoke_all('commerce_line_item_presave_update', $line_item);
// Save the updated line item and fields.
drupal_write_record('commerce_line_item', $line_item, 'line_item_id');
field_attach_update('commerce_line_item', $line_item);
......
......@@ -13,61 +13,66 @@
* Implements hook_rules_event_info().
*/
function commerce_order_rules_event_info() {
$items = array(
'commerce_order_insert' => array(
'label' => t('After saving a new order'),
'group' => t('Commerce'),
'variables' => commerce_order_rules_variables(t('Created order')),
'access callback' => 'commerce_order_rules_access',
),
'commerce_order_update' => array(
'label' => t('After updating an existing order'),
'group' => t('Commerce'),
'variables' => commerce_order_rules_variables(t('Updated order'), TRUE),
'access callback' => 'commerce_order_rules_access',
),
'commerce_order_presave' => array(
'label' => t('Before saving an order'),
'group' => t('Commerce'),
'variables' => commerce_order_rules_variables(t('Saved order'), TRUE),
'access callback' => 'commerce_order_rules_access',
),
'commerce_order_delete' => array(
'label' => t('After deleting an order'),
'group' => t('Commerce'),
'variables' => commerce_order_rules_variables(t('Deleted order')),
'access callback' => 'commerce_order_rules_access',
),
);
$events = array();
// Specify that on presave the order is saved anyway.
$items['commerce_order_presave']['variables']['order']['skip save'] = TRUE;
$events['commerce_order_presave'] = array(
'label' => t('Before saving an order'),
'group' => t('Commerce Order'),
'variables' => commerce_order_rules_event_variables(t('Order'), TRUE, TRUE),
'access callback' => 'commerce_order_rules_access',
);
$events['commerce_order_insert'] = array(
'label' => t('After saving a new order'),
'group' => t('Commerce Order'),
'variables' => commerce_order_rules_event_variables(t('Created order'), TRUE),
'access callback' => 'commerce_order_rules_access',
);
$events['commerce_order_update'] = array(
'label' => t('After updating an existing order'),
'group' => t('Commerce Order'),
'variables' => commerce_order_rules_event_variables(t('Updated order'), TRUE),
'access callback' => 'commerce_order_rules_access',
);
$events['commerce_order_delete'] = array(
'label' => t('After deleting an order'),
'group' => t('Commerce Order'),
'variables' => commerce_order_rules_event_variables(t('Deleted order')),
'access callback' => 'commerce_order_rules_access',
);
return $items;
return $events;
}
/**
* Returns some parameter suitable for using it with a node
* Returns a variables array for order events.
*
* @param $label
* The label for the primary order variable.
* @param $unchanged
* Boolean indicating whether or not to include the unchanged order.
* @param $skip_save
* Boolean indicating whether or not the primary order variable should skip
* saving after event execution.
*/
function commerce_order_rules_variables($label, $update = FALSE) {
$args = array(
function commerce_order_rules_event_variables($label, $unchanged = FALSE, $skip_save = FALSE) {
$variables = array(
'order' => array(
'type' => 'commerce_order',
'label' => $label,
'skip save' => $skip_save,
),
);
if ($update) {
$args += array(
'order_unchanged' => array(
'type' => 'commerce_order',
'label' => t('Unchanged order'),
'handler' => 'rules_events_entity_unchanged',
),
if ($unchanged) {
$variables['order_unchanged'] = array(
'type' => 'commerce_order',
'label' => t('Unchanged order'),
'skip save' => TRUE,
'handler' => 'rules_events_entity_unchanged',
);
}
return $args;
return $variables;
}
/**
......
......@@ -123,6 +123,8 @@ class CommerceOrderEntityController extends DrupalDefaultEntityController {
$op = 'insert';
}
else {
// Invoke presave to let modules react before the save.
rules_invoke_all('commerce_order_presave', $order);
// Save the updated order.
drupal_write_record('commerce_order', $order, 'order_id');
......
......@@ -96,7 +96,7 @@ function commerce_order_views_data() {
'title' => t('Order status'),
'help' => t('The workflow status of the order.'),
'field' => array(
'handler' => 'commerce_order_handler_field_order_status',
'handler' => 'commerce_order_handler_field_order_status',
'click sortable' => TRUE,
),
'filter' => array(
......@@ -160,7 +160,7 @@ function commerce_order_views_data() {
'field' => array(
'title' => t('Delete link'),
'help' => t('Provide a simple link to delete the order.'),
'handler' => 'commerce_order_handler_field_order_link_delete',
'handler' => 'commerce_order_handler_field_order_link_delete',
),
);
......
......@@ -3,7 +3,7 @@
/**
* @file
* Rules integration for payment.
* Rules integration for payments.
*
* @addtogroup rules
* @{
......@@ -13,18 +13,84 @@
* Implements hook_rules_event_info().
*/
function commerce_payment_rules_event_info() {
$items = array(
'commerce_payment_methods' => array(
'label' => t('Select available payment methods for an order'),
'group' => t('Commerce - payment'),
'variables' => commerce_order_rules_variables(t('Order')),
'access callback' => 'commerce_order_rules_access',
$events = array();
$events['commerce_payment_methods'] = array(
'label' => t('Select available payment methods for an order'),
'group' => t('Commerce Payment'),
'variables' => commerce_order_rules_event_variables(t('Order')),
'access callback' => 'commerce_order_rules_access',
);
$events['commerce_payment_transaction_presave'] = array(
'label' => t('Before saving a payment transaction'),
'group' => t('Commerce Payment'),
'variables' => commerce_payment_rules_event_variables(t('Payment transaction'), TRUE, TRUE),
'access callback' => 'commerce_payment_rules_access',
);
$events['commerce_payment_transaction_insert'] = array(
'label' => t('After saving a new payment transaction'),
'group' => t('Commerce Payment'),
'variables' => commerce_payment_rules_event_variables(t('Created payment transaction'), TRUE),
'access callback' => 'commerce_payment_rules_access',
);
$events['commerce_payment_transaction_update'] = array(
'label' => t('After updating an existing payment transaction'),
'group' => t('Commerce Payment'),
'variables' => commerce_payment_rules_event_variables(t('Updated payment transaction'), TRUE),
'access callback' => 'commerce_payment_rules_access',
);
$events['commerce_payment_transaction_delete'] = array(
'label' => t('After deleting a payment transaction'),
'group' => t('Commerce Payment'),
'variables' => commerce_payment_rules_event_variables(t('Deleted payment transaction')),
'access callback' => 'commerce_payment_rules_access',
);
return $events;
}
/**
* Returns a variables array for payment transaction events.
*
* @param $label
* The label for the primary payment transaction variable.
* @param $unchanged
* Boolean indicating whether or not to include the unchanged transaction.
* @param $skip_save
* Boolean indicating whether or not the primary transaction variable should
* skip saving after event execution.
*/
function commerce_payment_rules_event_variables($label, $unchanged = FALSE, $skip_save = FALSE) {
$variables = array(
'payment_transaction' => array(
'type' => 'commerce_payment_transaction',
'label' => $label,
'skip save' => $skip_save,
),
);
return $items;
if ($unchanged) {
$variables['payment_transaction_unchanged'] = array(
'type' => 'commerce_payment_transaction',
'label' => t('Unchanged payment transaction'),
'skip save' => TRUE,
'handler' => 'rules_events_entity_unchanged',
);
}
return $variables;
}
/**
* Rules integration access callback.
*/
function commerce_payment_rules_access($type, $name) {
if ($type == 'event' || $type == 'condition') {
return TRUE;
}
}
/**
* Implements hook_rules_action_info().
*/
......
......@@ -20,13 +20,14 @@ files[] = includes/commerce_product.controller.inc
files[] = includes/views/commerce_product.views.inc
; Views handlers
files[] = includes/views/handlers/commerce_product_handler_argument_product_id.inc
files[] = includes/views/handlers/commerce_product_handler_field_product.inc
files[] = includes/views/handlers/commerce_product_handler_field_product_type.inc
files[] = includes/views/handlers/commerce_product_handler_field_product_link.inc
files[] = includes/views/handlers/commerce_product_handler_field_product_link_delete.inc
files[] = includes/views/handlers/commerce_product_handler_field_product_link_edit.inc
files[] = includes/views/handlers/commerce_product_handler_field_product_operations.inc
files[] = includes/views/handlers/commerce_product_handler_argument_product_id.inc
files[] = includes/views/handlers/commerce_product_handler_filter_product_type.inc
; Simple tests
files[] = tests/commerce_product.test
......@@ -68,6 +68,8 @@ class CommerceProductEntityController extends DrupalDefaultEntityController {
$op = 'insert';
}
else {
// Invoke presave to let modules react before the save.
rules_invoke_all('commerce_product_presave', $product);
// Save the updated product and fields.
drupal_write_record('commerce_product', $product, 'product_id');
field_attach_update('commerce_product', $product);
......
......@@ -66,7 +66,7 @@ function commerce_product_views_data() {
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
'handler' => 'commerce_product_handler_filter_product_type',
),
'sort' => array(
'handler' => 'views_handler_sort',
......
<?php
// $Id$
/**
* Argument handler to display product titles in View using product arguments.
*/
class commerce_product_handler_argument_product_id extends views_handler_argument_numeric {
function title_query() {
$titles = array();
......@@ -7,8 +11,8 @@ class commerce_product_handler_argument_product_id extends views_handler_argumen
->fields('cp', array('title'))
->condition('cp.product_id', $this->value)
->execute();
foreach ($result as $term) {
$titles[] = check_plain($term->title);
foreach ($result as $product) {
$titles[] = check_plain($product->title);
}
return $titles;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment