| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Conditional Actions hooks and functions for the terms of service panes.
 
-  */
 
- /**
 
-  * Implements hook_ca_predicate().
 
-  */
 
- function uc_termsofservice_ca_predicate() {
 
-   $predicates['uc_termsofservice_display_pane'] = array(
 
-     '#title' => t('Display pane depending on the product classes'),
 
-     '#class' => 'uc_termsofservice',
 
-     '#trigger' => 'uc_termsofservice_display_pane',
 
-     '#status' => 1,
 
-     '#conditions' => array(
 
-       '#operator' => 'AND',
 
-       '#conditions' => array(
 
-         array(
 
-           '#name' => 'uc_termsofservice_condition_product_class',
 
-           '#title' => t('Check if there are products of the selected product classes.'),
 
-           '#argument_map' => array(
 
-             'cart' => 'cart',
 
-           ),
 
-           '#settings' => array(
 
-             'negate' => FALSE,
 
-             'class' => array('product'),
 
-           ),
 
-         ),
 
-       ),
 
-     ),
 
-     '#actions' => array(),
 
-   );
 
-   return $predicates;
 
- }
 
- /**
 
-  * Implements hook_ca_trigger().
 
-  */
 
- function uc_termsofservice_ca_trigger() {
 
-   $triggers['uc_termsofservice_display_pane'] = array(
 
-     '#title' => t('Display checkout or cart panes'),
 
-     '#category' => t('Checkout'),
 
-     '#arguments' => array(
 
-       'cart' => array('#entity' => 'cart', '#title' => t('Cart')),
 
-     ),
 
-   );
 
-   return $triggers;
 
- }
 
- /**
 
-  * Implements hook_ca_condition().
 
-  */
 
- function uc_termsofservice_ca_condition() {
 
-   $conditions['uc_termsofservice_condition_product_class'] = array(
 
-     '#title' => t('Order has a product of a particular class'),
 
-     '#category' => t('Order: Product'),
 
-     '#callback' => 'uc_termsofservice_condition_product_class',
 
-     '#arguments' => array(
 
-       'cart' => array('#entity' => 'cart', '#title' => t('Cart')),
 
-     ),
 
-   );
 
-   return $conditions;
 
- }
 
- /**
 
-  * Condition Callbacks and Forms.
 
-  */
 
- /**
 
-  * Checks that an order has a product of the selected class.
 
-  *
 
-  * @see uc_termsofservice_condition_product_class_form()
 
-  */
 
- function uc_termsofservice_condition_product_class($cart, $settings) {
 
-   foreach ($cart as $cart_item) {
 
-     if ($cart_item->nid) {
 
-       $type = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $cart_item->nid));
 
-       if (in_array($type, array_values($settings['class']), TRUE)) {
 
-         return TRUE;
 
-       }
 
-     }
 
-   }
 
-   return FALSE;
 
- }
 
- /**
 
-  * @see uc_termsofservice_condition_product_class()
 
-  */
 
- function uc_termsofservice_condition_product_class_form($form_state, $settings = array()) {
 
-   $form['class'] = array(
 
-     '#type' => 'checkboxes',
 
-     '#title' => t('Product class'),
 
-     '#options' => uc_product_type_names(),
 
-     '#default_value' => $settings['class'],
 
-     '#multiple' => TRUE,
 
-   );
 
-   return $form;
 
- }
 
 
  |