t('Phone number')); case 'defaults': return array( 'phone' => array('default' => '', 'collect' => 0, 'weight' => 25), ); case 'field_expand': if ($a3 == 'phone') { return array( '#type' => 'textfield', '#title' => t('Phone number'), '#size' => 31, '#maxlength' => 31, '#description' => NULL, '#required' => ($a4 == 2), '#default_value' => $location, ); } break; case 'save': db_query('DELETE FROM {location_phone} WHERE lid = %d', $location['lid']); if (!empty($location['phone'])) { db_query("INSERT INTO {location_phone} (lid, phone) VALUES (%d, '%s')", $location['lid'], $location['phone']); } break; case 'load': $fields = array('phone' => ''); if ($row = db_fetch_object(db_query('SELECT phone FROM {location_phone} WHERE lid = %d', $location['lid']))) { $fields['phone'] = $row->phone; } return $fields; case 'delete': db_query('DELETE FROM {location_phone} WHERE lid = %d', $location['lid']); break; } } function location_phone_views_tables() { $tables['location_phone'] = array( 'name' => 'location_phone', 'join' => array( 'left' => array( 'table' => 'location', 'field' => 'lid', ), 'right' => array( 'field' => 'lid', ), ), 'fields' => array( 'phone' => array( 'name' => t('Location: Phone'), 'sortable' => TRUE, ), ), 'filters' => array( 'has_phone' => array( 'field' => 'phone', 'name' => t('Location: Has phone'), 'operator' => array('IS NOT' => t('Has phone'), 'IS' => t('No phone')), 'handler' => 'views_handler_filter_null', ), ), ); return $tables; } /** * Implementation of hook_token_list(). */ function location_phone_token_list($type = 'all') { if ($type == 'node' || $type == 'user' || $type == 'all') { $tokens['location']['location-phone_N'] = t('Location Phone number (If there are multiple locations per node, N is the iteration, starting with 0)'); return $tokens; } }