function location_fax_locationapi in Location 5.3
Same name and namespace in other branches
- 5 contrib/location_fax/location_fax.module \location_fax_locationapi()
- 6.3 contrib/location_fax/location_fax.module \location_fax_locationapi()
- 7.5 contrib/location_fax/location_fax.module \location_fax_locationapi()
- 7.3 contrib/location_fax/location_fax.module \location_fax_locationapi()
- 7.4 contrib/location_fax/location_fax.module \location_fax_locationapi()
Implementation of hook_locationapi().
File
- contrib/
location_fax/ location_fax.module, line 11 - Add fax number fields to Location address.
Code
function location_fax_locationapi(&$location, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'fields':
return array(
'fax' => t('Fax number'),
);
case 'defaults':
return array(
'fax' => array(
'default' => '',
'collect' => 0,
'weight' => 30,
),
);
case 'field_expand':
if ($a3 == 'fax') {
return array(
'#type' => 'textfield',
'#title' => t('Fax number'),
'#size' => 31,
'#maxlength' => 31,
'#description' => NULL,
'#required' => $a4 == 2,
'#default_value' => $location,
);
}
break;
case 'save':
db_query('DELETE FROM {location_fax} WHERE lid = %d', $location['lid']);
if (!empty($location['fax'])) {
db_query("INSERT INTO {location_fax} (lid, fax) VALUES (%d, '%s')", $location['lid'], $location['fax']);
}
break;
case 'load':
$fields = array(
'fax' => '',
);
if ($row = db_fetch_object(db_query('SELECT fax FROM {location_fax} WHERE lid = %d', $location['lid']))) {
$fields['fax'] = $row->fax;
}
return $fields;
case 'delete':
db_query('DELETE FROM {location_fax} WHERE lid = %d', $location['lid']);
break;
}
}