diff --git a/ChangeLog b/ChangeLog index 603be0b5..e1c41c85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23890,3 +23890,6 @@ * Added a 'wmctrl' dependency to the 'rivendell' RPM package. 2022-12-30 Fred Gleason * Added a 'wmctrl' dependency to the 'rivendell' DEB package. +2022-12-30 Fred Gleason + * Fixed a bug in rdadmin(1) that made it impossible to set the + name of newly created host variables. diff --git a/rdadmin/edit_hostvar.cpp b/rdadmin/edit_hostvar.cpp index d60ec467..ed2d158b 100644 --- a/rdadmin/edit_hostvar.cpp +++ b/rdadmin/edit_hostvar.cpp @@ -2,7 +2,7 @@ // // Edit a Rivendell Host Variable // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -18,6 +18,7 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // +#include #include #include @@ -42,7 +43,6 @@ EditHostvar::EditHostvar(QWidget *parent) // edit_name_edit=new QLineEdit(this); edit_name_edit->setGeometry(125,11,120,19); - edit_name_edit->setReadOnly(true); QLabel *label=new QLabel(tr("Variable Name:"),this); label->setGeometry(10,11,110,19); label->setFont(labelFont()); @@ -133,7 +133,24 @@ int EditHostvar::exec(int id) void EditHostvar::okData() { - QString sql=QString("update `HOSTVARS` set ")+ + QString sql; + RDSqlQuery *q=NULL; + + sql=QString("select ")+ + "`ID` "+ // 00 + "from `HOSTVARS` where "+ + "`STATION_NAME`='"+RDEscapeString(rda->station()->name())+"' && "+ + "`NAME`='"+RDEscapeString(edit_name_edit->text())+"' && "+ + QString::asprintf("`ID`!=%d",edit_id); + q=new RDSqlQuery(sql); + if(q->first()) { + QMessageBox::warning(this,"RDAdmin - "+tr("Error"), + tr("The variable name is already in use!")); + delete q; + return; + } + + sql=QString("update `HOSTVARS` set ")+ "`NAME`='"+RDEscapeString(edit_name_edit->text())+"',"+ "`VARVALUE`='"+RDEscapeString(edit_varvalue_edit->text())+"',"+ "`REMARK`='"+RDEscapeString(edit_remark_edit->text())+"' "+