function brilliant_gallery_checklist_save in Brilliant Gallery 7.2
Same name and namespace in other branches
- 5.4 brilliant_gallery.module \brilliant_gallery_checklist_save()
- 5.3 brilliant_gallery.module \brilliant_gallery_checklist_save()
- 6.4 brilliant_gallery.module \brilliant_gallery_checklist_save()
- 6 brilliant_gallery.module \brilliant_gallery_checklist_save()
- 6.2 brilliant_gallery.module \brilliant_gallery_checklist_save()
- 6.3 brilliant_gallery.module \brilliant_gallery_checklist_save()
- 7 brilliant_gallery.module \brilliant_gallery_checklist_save()
Function to save/update the state of a checkbox when toggled
File
- ./
OLD_brilliant_gallery.module, line 88
Code
function brilliant_gallery_checklist_save($nid, $qid, $state) {
global $user;
$GLOBALS['devel_shutdown'] = FALSE;
if (preg_match("/^user-/", $qid) == 1) {
$uid = $user->uid;
}
else {
$uid = 0;
}
// TODO Please convert this statement to the D7 database API syntax.
$existing = db_query("select count(state) from {brilliant_gallery_checklist} " . "where nid=:nid and user=:uid and qid=:qid", array(
':nid' => $nid,
':uid' => $uid,
':qid' => $qid,
))
->fetchField();
if ($existing == 0) {
// TODO Please convert this statement to the D7 database API syntax.
db_query("insert into {brilliant_gallery_checklist} (nid,user,qid,state) " . "values (:nid,:uid,:qid,:state)", array(
':nid' => $nid,
':uid' => $uid,
':qid' => $qid,
':state' => $state,
));
}
else {
// TODO Please convert this statement to the D7 database API syntax.
$current = db_query("select state from {brilliant_gallery_checklist} " . " where nid=:nid and user=:uid and qid=:qid", array(
':nid' => $nid,
':uid' => $uid,
':qid' => $qid,
))
->fetchField();
if ($current != $state) {
// TODO Please convert this statement to the D7 database API syntax.
db_query("update {brilliant_gallery_checklist} " . "set state=:state where nid=:nid and user=:uid and qid=:qid", array(
':state' => $state,
':nid' => $nid,
':uid' => $uid,
':qid' => $qid,
));
}
}
print drupal_json_encode("1");
exit;
}