diff --git a/src/elogd.c b/src/elogd.c
index ee66fbeb..845ad6ea 100755
--- a/src/elogd.c
+++ b/src/elogd.c
@@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG
$Log$
+ Revision 1.351 2004/06/18 20:44:37 midas
+ Implemented deletion of logbooks through web interface
+
Revision 1.350 2004/06/18 19:26:33 midas
Fixed typo
@@ -5316,8 +5319,8 @@ void show_standard_title(char *logbook, char *text, int printable)
pnode = phier; /* start at root of tree */
pnext = NULL;
- if (!printable && getcfg(logbook, "logbook tabs", str)
- && atoi(str) == 1) {
+ if (!printable && (!getcfg(logbook, "logbook tabs", str)
+ || atoi(str) == 1)) {
for (level = 0;; level++) {
rsprintf("
\n");
@@ -7747,6 +7750,14 @@ void show_admin_page(LOGBOOK * lbs, char *top_group)
rsprintf(" %s", str);
}
+ if (is_group("global") && !strieq(top_group, "global")) {
+ if (is_admin_user("global", getparam("unm"))) {
+ rsprintf("\n", loc("Delete this logbook"));
+ rsprintf("\n", loc("Rename this logbook"));
+ rsprintf("\n", loc("Create new logbook"));
+ }
+ }
+
rsprintf(" |
\n\n");
/*---- entry form ----*/
@@ -7904,6 +7915,67 @@ int save_admin_config(char *section, char *buffer, char *error)
/*------------------------------------------------------------------*/
+int delete_logbook(char *logbook, char *error)
+{
+ int fh, i, length;
+ char *buf, *p1, *p2;
+
+ error[0] = 0;
+
+ fh = open(config_file, O_RDWR | O_BINARY, 644);
+ if (fh < 0) {
+ sprintf(error, loc("Cannot open file %s"), config_file);
+ strcat(error, ": ");
+ strcat(error, strerror(errno));
+ return 0;
+ }
+
+ /* read previous contents */
+ length = lseek(fh, 0, SEEK_END);
+ lseek(fh, 0, SEEK_SET);
+ buf = malloc(length + 1);
+ assert(buf);
+ read(fh, buf, length);
+ buf[length] = 0;
+
+ /* find logbook config */
+ p1 = (char *) find_section(buf, logbook);
+ p2 = (char *) find_next_section(p1 + 1);
+
+ if (p2)
+ strlcpy(p1, p2, strlen(p2) + 1);
+ else
+ *p1 = 0;
+
+ lseek(fh, 0, SEEK_SET);
+ i = write(fh, buf, strlen(buf));
+ if (i < (int) strlen(buf)) {
+ sprintf(error, loc("Cannot write to %s"), config_file);
+ strcat(error, ": ");
+ strcat(error, strerror(errno));
+ close(fh);
+ free(buf);
+ return 0;
+ }
+
+#ifdef _MSC_VER
+ chsize(fh, TELL(fh));
+#else
+ ftruncate(fh, TELL(fh));
+#endif
+
+ close(fh);
+ free(buf);
+
+ /* force re-read of config file */
+ check_config();
+ el_index_logbooks(TRUE);
+
+ return 1;
+}
+
+/*------------------------------------------------------------------*/
+
int save_config(char *buffer, char *error)
{
int fh, i;
@@ -8824,6 +8896,63 @@ void show_elog_delete(LOGBOOK * lbs, int message_id)
/*------------------------------------------------------------------*/
+void show_logbook_delete(LOGBOOK * lbs)
+{
+ char str[256];
+
+ /* redirect if confirm = NO */
+ if (getparam("confirm") && *getparam("confirm")
+ && strcmp(getparam("confirm"), loc("No")) == 0) {
+
+ redirect(lbs, "?cmd=Config");
+ return;
+ }
+
+ if (getparam("confirm") && *getparam("confirm")) {
+ if (strcmp(getparam("confirm"), loc("Yes")) == 0) {
+
+ /* delete logbook */
+ str[0] = 0;
+ delete_logbook(lbs->name, str);
+ if (str[0])
+ show_error(str);
+ else
+ redirect(NULL, "../");
+ return;
+ }
+
+ } else {
+
+
+ show_standard_header(lbs, TRUE, "Delete Logbook", "");
+
+ rsprintf("\n");
+ show_bottom_text(lbs);
+ rsprintf("