function paymentreference_load in Payment 7
Load the PID of a Payments available for referencing through an instance.
Parameters
string $entity_type: The entity_type for which the payment should be available.
string $bundle: The bundle of $entity_type for which the payment should be available.
string $field_name: The name of the field on $bundle for which the payment should be available.
integer $uid: The UID of the user for whom the payment should be available.
Return value
integer|false
3 calls to paymentreference_load()
- PaymentreferenceTestQueueWebTestCase::testQueueCRUD in modules/
paymentreference/ tests/ paymentreference_test/ tests/ PaymentreferenceTestQueueWebTestCase.test - PaymentreferenceTestQueueWebTestCase::testQueueFieldImplementation in modules/
paymentreference/ tests/ paymentreference_test/ tests/ PaymentreferenceTestQueueWebTestCase.test - paymentreference_instance_access in modules/
paymentreference/ paymentreference.module - Check if the user has access to add a payment for a field instance.
1 string reference to 'paymentreference_load'
- paymentreference_field_widget_form in modules/
paymentreference/ paymentreference.module - Implements hook_field_widget_form().
File
- modules/
paymentreference/ paymentreference.module, line 347 - Hook implementations and general functions.
Code
function paymentreference_load($entity_type, $bundle, $field_name, $uid) {
$query = db_select('paymentreference', 'pr');
$query
->addJoin('INNER', 'payment', 'p', 'p.pid = pr.pid');
$query
->addJoin('INNER', 'payment_status_item', 'psi', 'p.psiid_last = psi.psiid');
$query
->fields('pr', array(
'pid',
))
->condition('entity_type', $entity_type)
->condition('bundle', $bundle)
->condition('field_name', $field_name)
->condition('status', array_merge(payment_status_info(PAYMENT_STATUS_SUCCESS)
->descendants(), array(
PAYMENT_STATUS_SUCCESS,
)))
->condition('uid', $uid)
->orderBy('pid')
->range(0, 1);
return $query
->execute()
->fetchField();
}