3c67642001-08-22Per Hedbor #include <config_interface.h> #include <config.h> #include <roxen.h> //<locale-token project="roxen_config">_</locale-token> #define _(X,Y) _STR_LOCALE("roxen_config",X,Y)
b485f72002-07-02Anders Johansson  #define VERIFY(X) do { \ if( !id->variables["yes.x"] ) \ { \ return \ ("<table><tr><td colspan='2'>\n"+ \ sprintf((string)(X), group)+ \ "</td><tr><td><input type=hidden name=action value='&form.action;' />"\ "<submit-gbutton2 name='yes'>"+_(0,"Yes")+"</submit-gbutton2></td>\n"\
e1fff72016-01-15Henrik Grubbström (Grubba)  "<td align=right><a href='"+Roxen.html_encode_string(id->not_query)+\
b485f72002-07-02Anders Johansson  "?group="+\
e1fff72016-01-15Henrik Grubbström (Grubba)  Roxen.html_encode_string(id->variables->group)+"&amp;&usr.set-wiz-id;'><gbutton> "+\
b485f72002-07-02Anders Johansson  _(0,"No")+" </gbutton></a></td>\n</table>\n"); \ } \ } while(0)
a3b9102002-08-16Anders Johansson #define CU_AUTH id->misc->config_user->auth
108e652001-10-08Per Hedbor string trim_sl( string x ) { while( strlen(x) && x[-1] == '/' ) x = x[..strlen(x)-2]; return x; }
3c67642001-08-22Per Hedbor  string parse( RequestID id ) { mapping c; string res = "<use file='/template'/><tmpl>" "<topmenu base='../' selected='dbs'/>" "<content><cv-split><subtablist width='100%'><st-tabs>" "<insert file='subtabs.pike'/></st-tabs><st-page>"
ad1c712001-09-03Per Hedbor  "<input type=hidden name=group value='&form.group;'/>";
a3b9102002-08-16Anders Johansson  int view_mode; if ( !(CU_AUTH( "Edit Global Variables" )) ) view_mode = 1; if( id->variables->action == "delete" && !view_mode)
b485f72002-07-02Anders Johansson  { mixed tmp = delete_group( id->variables->group, id ); if( stringp( tmp ) ) return res+tmp+"\n</st-page></content></tmpl>"; if( tmp ) return tmp; }
a3b9102002-08-16Anders Johansson  if( id->variables->lname && !view_mode)
108e652001-10-08Per Hedbor  { if( strlen(id->variables->pattern) ) id->variables->pattern = "mysql://"+trim_sl(id->variables->pattern)+"/";
ad1c712001-09-03Per Hedbor  DBManager.create_group( id->variables->group, id->variables->lname, id->variables->comment, id->variables->pattern );
108e652001-10-08Per Hedbor  }
3c67642001-08-22Per Hedbor  c = DBManager.get_group( id->variables->group );
ad1c712001-09-03Per Hedbor 
3c67642001-08-22Per Hedbor 
ad1c712001-09-03Per Hedbor  res += "<blockquote><br /><h2>"+c->lname+"</h2>" ""+c->comment+"<table>";
3c67642001-08-22Per Hedbor 
a3b9102002-08-16Anders Johansson  res += "<tr><td><b>Name:</b></td><td> "+ (view_mode ? Roxen.html_encode_string(c->lname) : "<input size=50 name=lname value='"+ Roxen.html_encode_string(c->lname)+"' />")+ "</td></tr>";
3c67642001-08-22Per Hedbor 
108e652001-10-08Per Hedbor  res += "<tr><td><b>URL:</b> </td><td> "
a3b9102002-08-16Anders Johansson  "mysql://"+ (view_mode ? Roxen.html_encode_string(trim_sl((c->pattern/"://")[-1])) : "<input size=42 name=pattern value='"+
108e652001-10-08Per Hedbor  Roxen.html_encode_string(trim_sl((c->pattern/"://")[-1]))+
a3b9102002-08-16Anders Johansson  "' />")+"</td></tr>";
3c67642001-08-22Per Hedbor 
a3b9102002-08-16Anders Johansson  res += "<tr><td valign=top><b>Comment:</b></td><td valign=top> "+ (view_mode ? Roxen.html_encode_string(c->comment) : "<textarea cols='50' rows=4 name=comment>"+ Roxen.html_encode_string(c->comment)+"</textarea>")+ "</td></tr>";
3c67642001-08-22Per Hedbor 
ad1c712001-09-03Per Hedbor 
a3b9102002-08-16Anders Johansson  res += "<tr><td></td><td align=right>" +(view_mode ? "" : "<cf-save />")+ "</td></tr>";
3c67642001-08-22Per Hedbor  res += "</table>";
ad1c712001-09-03Per Hedbor 
9fa11d2001-08-24Martin Nilsson  res += sprintf("<font size=+1><b>"+_(434,"Databases in the group %s")+
3c67642001-08-22Per Hedbor  "</b></font><br />", c->lname );
b485f72002-07-02Anders Johansson  array groups = DBManager.group_dbs( id->variables->group ); res += "<dl>\n"; if( sizeof(groups) ) foreach( groups, string d ) {
a3b9102002-08-16Anders Johansson  res += "<dt><b>"+
e1fff72016-01-15Henrik Grubbström (Grubba)  (view_mode ? "" : "<a href='browser.pike?db="+d+"&amp;&usr.set-wiz-id;'>")+d+
a3b9102002-08-16Anders Johansson  (view_mode ? "" : "</a>")+ "</b>";
b485f72002-07-02Anders Johansson  if( string cm = DBManager.module_table_info( d, "" )->comment ) res += "<dd>"+cm+"</dd>"; res += "</dt>\n"; } else
e165eb2002-08-16Anders Johansson  res += _(312,"(none)");
b485f72002-07-02Anders Johansson  res += "</dl>\n";
a3b9102002-08-16Anders Johansson  if (!view_mode) { string button; if ( sizeof(DBManager.group_dbs(id->variables->group)) ) button = sprintf("<gbutton textcolor='#BEC2CB'>%s</gbutton>",
e165eb2002-08-16Anders Johansson  _(352, "Delete group"));
a3b9102002-08-16Anders Johansson  else
e1fff72016-01-15Henrik Grubbström (Grubba)  button = sprintf("<a href='%s?group=%s&amp;action=%s&amp;&usr.set-wiz-id;'><gbutton>%s</gbutton></a>",
a3b9102002-08-16Anders Johansson  id->not_query, id->variables->group, "delete",
e165eb2002-08-16Anders Johansson  _(352, "Delete group"));
a3b9102002-08-16Anders Johansson  res += "<br />"+button; }
3c67642001-08-22Per Hedbor  return res + "\n</blockquote></st-page></content></tmpl>"; }
b485f72002-07-02Anders Johansson  mixed delete_group( string group, RequestID id ) { if( sizeof(DBManager.group_dbs( group )) )
e165eb2002-08-16Anders Johansson  return (string)_(353, "You can not delete this group because it is not empty."); string msg = (string)_(354, "Are you sure you want to delete the group %s?");
b485f72002-07-02Anders Johansson  VERIFY(msg); DBManager.delete_group( group ); return Roxen.http_redirect( "/dbs/", id ); }