function commerce_file_license_line_item_update_state in Commerce File 7
Update the state of licenses for files on a line item
Parameters
$line_item: A line item object
1 call to commerce_file_license_line_item_update_state()
- commerce_file_license_order_update_state in includes/
commerce_file.entities.inc - Update the state of licenses for files in an order
File
- includes/
commerce_file.entities.inc, line 1092 - Handles file licenses and file license logs
Code
function commerce_file_license_line_item_update_state($line_item, $order = NULL, $updated_state = 'denied') {
// exit if we issued this already
if (empty($line_item->line_item_id)) {
return;
}
// get the line item owner
$account = commerce_file_line_item_owner($line_item, $order);
if (empty($account)) {
return;
}
// get existing licenses for this line item and account
$existing_licenses = commerce_file_license_load_by_property(array(), array(
$line_item->line_item_id,
), $account);
// deny all licenses for this line item and account
foreach ($existing_licenses as $license) {
$license
->set_state($updated_state)
->save();
}
}