You are here

function commerce_file_license_line_item_update_status 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_status()
commerce_file_license_order_update_status in includes/commerce_file.entities.inc
Update the status of licenses for files in an order

File

includes/commerce_file.entities.inc, line 1142
Handles file licenses and file license logs

Code

function commerce_file_license_line_item_update_status($line_item, $order = NULL, $updated_status = 'pending') {

  // 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_status($updated_status)
      ->save();
  }
}