function certificate_update_node_mappings in Certificate 8.3
Same name and namespace in other branches
- 6.2 certificate.module \certificate_update_node_mappings()
- 6 certificate.module \certificate_update_node_mappings()
- 7.3 certificate.module \certificate_update_node_mappings()
- 7.2 certificate.module \certificate_update_node_mappings()
- 3.x certificate.module \certificate_update_node_mappings()
Submit handler to update mappings.
4 calls to certificate_update_node_mappings()
- CertificateTestCase::testCertificateMapping in ./
certificate.test - Test that the user receives the correct certificate.
- CertificateTestCase::testCertificateTemplates in ./
certificate.test - Test the token replacement inside of certificates.
- certificate_node_update in ./
certificate.module - Implementation of hook_node_update().
- certificate_settings_form_submit in ./
certificate.admin.inc - Save the certificate mappings. For global mappings, we use node ID zero to store it in the database.
File
- ./
certificate.module, line 303 - Certificate module.
Code
function certificate_update_node_mappings($nid, array $node_settings = NULL) {
if (is_array($node_settings)) {
foreach ($node_settings as $mapper => $values) {
foreach ($values as $match => $cert_nid) {
if ($cert_nid) {
$record = array(
'nid' => $nid,
'mapper' => $mapper,
'type' => $match,
'template' => $cert_nid,
);
db_merge('certificate_node')
->fields($record)
->key(array(
'nid' => $nid,
'mapper' => $mapper,
'type' => $match,
))
->execute();
}
else {
// No certificate has been set.
// Delete any prior setting.
db_delete('certificate_node')
->condition('nid', $nid)
->condition('mapper', $mapper)
->condition('type', $match)
->execute();
}
}
}
}
}