function farm_inventory_enabled in farmOS 7
Check whether or not inventory management is enabled on an asset.
Parameters
FarmAsset $asset: The asset to check.
Return value
bool Returns TRUE or FALSE.
3 calls to farm_inventory_enabled()
- farm_inventory_entity_view_alter in modules/
farm/ farm_inventory/ farm_inventory.module - Implements hook_entity_view_alter().
- farm_inventory_form_farm_asset_form_alter in modules/
farm/ farm_inventory/ farm_inventory.module - Implements hook_form_FORM_ID_alter().
- farm_inventory_set in modules/
farm/ farm_inventory/ farm_inventory.module - Create a log for adjusting asset inventory.
File
- modules/
farm/ farm_inventory/ farm_inventory.module, line 346
Code
function farm_inventory_enabled(FarmAsset $asset) {
// If the asset type is not set, bail.
if (empty($asset->type)) {
return FALSE;
}
// Check the database to see if inventory management is enabled.
$result = db_query('SELECT enabled FROM {farm_inventory_asset_type} WHERE type = :type', array(
':type' => $asset->type,
))
->fetchField();
// Return TRUE or FALSE.
if (!empty($result)) {
return TRUE;
}
return FALSE;
}