| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: userreference.rules.inc,v 1.1.2.2 2008/10/06 15:02:03 karens Exp $ 3 4 /** 5 * @file 6 * Provides additional rules support for userreference fields. 7 */ 8 9 /** 10 * Implementation of hook_rules_action_info() 11 */ 12 function userreference_rules_action_info() { 13 $info = array(); 14 $info['userreference_rules_action_load'] = array( 15 'label' => t('Load a referenced user'), 16 'arguments' => array( 17 'node' => array( 18 'type' => 'node', 19 'label' => t('Content containing the user reference field'), 20 ), 21 ), 22 'new variables' => array( 23 'referenced_user' => array( 24 'type' => 'user', 25 'label' => t('Referenced user'), 26 ), 27 ), 28 'module' => 'CCK', 29 'help' => t('Note that if the field has multiple values, only the first user will be loaded.'), 30 ); 31 return $info; 32 } 33 34 function userreference_rules_action_load($node, $settings) { 35 $uid = $node->{$settings['field']}[0]['uid']; 36 if (isset($uid)) { 37 $user = user_load(array('uid' => $uid)); 38 return array('referenced_user' => $user); 39 } 40 } 41 42 function userreference_rules_action_load_form($settings, &$form) { 43 $settings += array('field' => ''); 44 $options = content_rules_get_field_names_by_type('userreference'); 45 $form['settings']['field'] = array( 46 '#type' => 'select', 47 '#title' => t('Field'), 48 '#default_value' => $settings['field'], 49 '#options' => $options, 50 '#required' => TRUE, 51 '#disabled' => empty($options), 52 '#description' => empty($options) ? t('There are no userreference fields defined.') : '', 53 ); 54 } 55 56 /** 57 * Helps upgrading from the workflow-ng action. 58 * "workflow_ng_action_load_referenced_user" to the equivalent rules action. 59 */ 60 function workflow_ng_action_load_referenced_user_upgrade(&$element) { 61 $element['#name'] = 'userreference_rules_action_load'; 62 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |