function pay_node_form_load in Pay 6
Same name and namespace in other branches
- 7 modules/pay_node/pay_node.module \pay_node_form_load()
A load helper for pay_forms that are attached to a node.
6 calls to pay_node_form_load()
- pay_node_admin_node_form_alter in modules/
pay_node/ includes/ pay_node.admin.inc - A form_alter helper for node creation forms.
- pay_node_handler_field_pay_form_link::render in modules/
pay_node/ includes/ views/ pay_node_handler_field_pay_form_link.inc - pay_node_nodeapi in modules/
pay_node/ pay_node.module - Implementation of hook_nodeapi().
- pay_node_pay_form in modules/
pay_node/ pay_node.module - A callback for node/x/pay which presents a payment form.
- pay_node_pay_form_access in modules/
pay_node/ pay_node.module - An access callback for payment forms.
File
- modules/
pay_node/ pay_node.module, line 201
Code
function pay_node_form_load($node) {
// Allow this to work if we only get a nid.
if (is_scalar($node)) {
$node = node_load($node);
}
// Don't continue if pay_node settings aren't enabled for this node type.
if (!variable_get('pay_node_enabled_' . $node->type, FALSE)) {
return;
}
// Determine the pay_form handler for this type, and verify that it's enabled.
if (!($handler = variable_get('pay_node_form_' . $node->type, NULL))) {
return;
}
if (!array_key_exists($handler, array_filter(variable_get('pay_node_forms', array())))) {
return;
}
// The linking method (create, select, etc.)
$method = variable_get('pay_node_method_' . $node->type, '');
// Load the pay_form that is associated with this node, if one exists.
if ($node->nid) {
if ($pfid = db_result(db_query("SELECT pfid FROM {pay_form_node} n\n INNER JOIN {pay_form} f USING ( pfid )\n WHERE f.handler = '%s'\n AND n.nid = %d\n AND method = '%s'", $handler, $node->nid, $method))) {
if ($pay_form = pay_form_load($pfid)) {
// Hard-code the payment form's URL.
$pay_form
->set_menu_path('node/' . $node->nid . '/pay');
}
}
elseif ($method == 'select') {
return;
}
}
// Rely on defaults.
if (!isset($pay_form)) {
// The node is linked to a form. Use the default value.
if ($method = 'select') {
if ($pfid = variable_get('pay_node_view_default_select_' . $node->type, '')) {
$pay_form = pay_form_load($pfid);
}
}
elseif ($method = 'create') {
$pay_form = pay_form_load($handler);
}
}
return $pay_form;
}