function bueditor_editor_add in BUEditor 5
Insert/update an editor.
1 call to bueditor_editor_add()
- bueditor_form_editor_submit in ./
bueditor.module - Editor form submitted.
File
- ./
bueditor.module, line 317
Code
function bueditor_editor_add($editor) {
$sets = array();
$vals = array();
$eid = $editor['eid'];
unset($editor['eid']);
foreach ($editor as $key => $val) {
$sets[] = $key . "='%s'";
$vals[] = $val;
}
if (is_numeric($eid)) {
//bueditor with an ID. update
$vals[] = $eid;
db_query("UPDATE {bueditor_editors} SET " . implode(', ', $sets) . " WHERE eid = %d", $vals);
}
else {
if ($editor['name']) {
//bueditor with no real ID. insert
$eid = db_next_id('{bueditor_editors}_eid');
$vals[] = $eid;
db_query("INSERT INTO {bueditor_editors} (" . implode(', ', array_keys($editor)) . ", eid) VALUES(" . str_repeat("'%s', ", count($vals) - 1) . "%d)", $vals);
drupal_set_message(t('New editor has been added.'));
}
}
return $eid;
}