';
echo html_e('input', array('type' => 'button', 'name' => _('Cancel'), 'value' => _('Cancel'), 'onclick' => 'window.location=\''.util_make_uri(getStringFromServer('PHP_SELF')).'\''));
echo $HTML->closeForm();
} else {
echo db_error();
}
}
/**
* admin_table_postadd() - update the database based on a submitted change
*
* @param string $table the table to act on
* @param string $unit the name of the "units" described by the table's records
*/
function admin_table_postadd($table, $unit) {
global $HTML;
if (!form_key_is_valid(getStringFromRequest('form_key'))) {
exit_form_double_submit('home');
}
$field_list = getStringFromRequest('__fields__');
$fields = explode(",", $field_list);
$values = array(); $v = array ();
$qpa = db_construct_qpa(array(), 'INSERT INTO ' . $table . ' (' . $field_list . ') VALUES (') ;
$i = 1 ;
foreach ($fields as $field) {
$v[] = '$'.$i;
$i++ ;
$values[] = getStringFromPost($field);
}
$qpa = db_construct_qpa($qpa, implode (',', $v).')', $values) ;
if (db_query_qpa($qpa)) {
echo $HTML->feedback(sprintf(_('%s successfully added.'), ucfirst(getUnitLabel($unit))));
} else {
echo $HTML->error_msg(_('Failed.').' '.db_error());
form_release_key(getStringFromRequest('form_key'));
}
}
/**
* admin_table_confirmdelete() - present a form to confirm requested record deletion
*
* @param string $table the table to act on
* @param string $unit the name of the "units" described by the table's records
* @param string $primary_key the primary key of the table
* @param string $id the id of the record to act on
*/
function admin_table_confirmdelete($table, $unit, $primary_key, $id) {
global $HTML;
if ($unit == "processor") {
$result = db_numrows(db_query_params ('SELECT processor_id FROM frs_file WHERE processor_id = $1',
array($id)));
if ($result > 0) {
echo $HTML->warning_msg(sprintf(_('You cannot delete the processor %s since it is currently referenced in a file release.'), db_result(db_query_params ('select name from frs_processor where processor_id = $1',
array($id)), 0, 0)));
return;
}
}
if ($unit == "license") {
$result = db_numrows(db_query_params ('SELECT license FROM groups WHERE license = $1',
array($id)));
if ($result > 0) {
echo $HTML->warning_msg(sprintf(_('You can\'t delete the license %s since it is currently referenced in a project.'), db_result(db_query_params ('select license_name from licenses where license_id = $1',
array($id)), 0, 0)));
return;
}
}
if ($unit == "supported_language") {
$result = db_numrows(db_query_params("SELECT language FROM users WHERE language=$1", array($id)));
if ($result > 0) {
echo $HTML->warning_msg(sprintf(_('You cannot delete the language %s since it is currently referenced in a user profile.'), db_result(db_query_params ('select language from users where language = $1',
array($id)), 0, 0)));
return;
}
}
if ($unit == "theme") {
$result = db_numrows(db_query_params("SELECT theme_id FROM users WHERE theme_id=$1", array($id)));
if ($result > 0) {
echo $HTML->warning_msg(sprintf(_('You cannot delete the theme %s since it is currently referenced in a user profile.'), db_result(db_query_params ('select language from users where language = $1',
array($id)), 0, 0)));
return;
}
}
$result = db_query_params("SELECT * FROM $table WHERE $primary_key=$1", array($id));
if ($result) {
$cols = db_numfields($result);
echo '
';
printf(_('Are you sure you want to delete this %s?'), getUnitLabel($unit));
echo '
';
echo $HTML->openForm(array('name' => 'delete', 'action' => getStringFromServer('PHP_SELF').'?function=delete&id='.$id, 'method' => 'post'));
echo '';
echo html_e('input', array('type' => 'button', 'name' => _('Cancel'), 'value' => _('Cancel'), 'onclick' => 'window.location=\''.util_make_uri(getStringFromServer('PHP_SELF')).'\''));
echo $HTML->closeForm();
} else {
echo $HTML->error_msg(db_error());
}
}
/**
* admin_table_delete() - delete a record from the database after confirmation
*
* @param string $table the table to act on
* @param string $unit the name of the "units" described by the table's records
* @param string $primary_key the primary key of the table
* @param string $id the id of the record to act on
*/
function admin_table_delete($table, $unit, $primary_key, $id) {
global $HTML;
if (db_query_params("DELETE FROM $table WHERE $primary_key=$1", array($id))) {
echo $HTML->feedback(sprintf(_('%s successfully deleted.'), ucfirst(getUnitLabel($unit))));
} else {
echo $HTML->error_msg(db_error());
}
}
/**
* admin_table_edit() - present a form for editing a record in the specified table
*
* @param string $table the table to act on
* @param string $unit the name of the "units" described by the table's records
* @param string $primary_key the primary key of the table
* @param string $id the id of the record to act on
*/
function admin_table_edit($table, $unit, $primary_key, $id) {
global $HTML;
$result = db_query_params("SELECT * FROM $table WHERE $primary_key=$1", array($id));
if ($result) {
$cols = db_numfields($result);
printf(_('Modify the %s below:'), getUnitLabel($unit));
echo $HTML->openForm(array('name' => 'edit' ,'action' => getStringFromServer('PHP_SELF').'?function=postedit&id='.$id, 'method' => 'post'));
echo '