function _keyword_table in Glossify 6.3
Same name and namespace in other branches
- 6 glossify.module \_keyword_table()
Helper function that performs operations on the Glossify keyword-table and returns the new, old or removed values, depending on the operation.
3 calls to _keyword_table()
- glossify_nodeapi in ./
glossify.module - Implementation of hook_nodeapi().
- _fetch_affected_keywords in ./
glossify.module - Helper function that fetches and returns an array of all new and old keywords of a node, depending on the method. It also provides for an easy way to update the keywords of a given method/configuration combination.
- _update_keywords_for_methods in ./
glossify.module - Helper function that updates the keyword-tables according to the new/old methods.
File
- ./
glossify.module, line 735
Code
function _keyword_table($operation, $nid, $method, $configuration = 'global', $language = '', $term = '', $alternate = '') {
//dpm(array($operation, $nid, $method, $configuration, $language, $term, $alternate));
switch ($operation) {
case 'insert':
$gnid = db_result(db_query("SELECT nid FROM {glossify} WHERE term = '%s' AND language = '%s' AND method = '%s' AND configuration = '%s'", $term, $language, $method, $configuration));
$new_terms = array();
if (!$gnid) {
db_query("INSERT INTO {glossify} (nid, term, language, method, alternate, configuration) VALUES (%d, '%s', '%s', '%s', '%s', '%s')", $nid, $term, $language, $method, $alternate, $configuration);
$new_terms[$term] = $term;
}
else {
$node = node_load($gnid);
drupal_set_message(t("The keyword: '%term' for the %method-method under configuration %config was already assigned to point to <a href=\"/node/{$node->nid}\">%title</a>", array(
'%term' => $term,
'%title' => $node->title,
'%method' => $method,
'%config' => $configuration,
)), 'warning');
}
return $new_terms;
break;
case 'update':
$old_term = db_result(db_query("SELECT term FROM {glossify} WHERE nid = %d AND method = '%s'", $nid, 'title'));
db_query("UPDATE {glossify} SET term = '%s', language = '%s', method = '%s' WHERE nid = %d AND method = '%s' AND configuration = '%s'", $term, $language, $method, $nid, 'title', $configuration);
return array(
$old_term => $old_term,
);
break;
case 'delete':
$old_terms = array();
if (!empty($term)) {
$old_terms[$term] = $term;
db_query("DELETE FROM {glossify} WHERE nid = %d AND method = '%s' AND language = '%s' AND term = '%s' AND configuration = '%s'", $nid, $method, $language, $term, $configuration);
}
else {
$q = db_query("SELECT term FROM {glossify} WHERE nid = %d AND method = '%s' AND configuration = '%s' ORDER BY term", $nid, $method, $configuration);
while ($r = db_fetch_array($q)) {
$old_terms[$r['term']] = $r['term'];
}
db_query("DELETE FROM {glossify} WHERE nid = %d AND method = '%s' AND configuration = '%s'", $nid, $method, $configuration);
}
return $old_terms;
break;
}
return TRUE;
}