Roxen.git / server / config_interface / sites / add_module.pike

version» Context lines:

Roxen.git/server/config_interface/sites/add_module.pike:1:   #include <config_interface.h>   #include <module.h>   #include <module_constants.h>   #include <roxen.h>    + int no_reload() + { +  if( sizeof( already_added ) ) +  return 1; // Reloading this script now would destroy state. + } +    //<locale-token project="roxen_config">LOCALE</locale-token>   #define LOCALE(X,Y) _STR_LOCALE("roxen_config",X,Y)      // Class is the name of the directory.   array(string) class_description( string d, RequestID id )   {    string name, doc;    while(!(< "", "/" >)[d] && !file_stat( d+"/INFO" ))    d = dirname(d);    if((< "", "/" >)[d])
Roxen.git/server/config_interface/sites/add_module.pike:56:   }      // To redirect to when done with module addition   string site_url( RequestID id, string site )   {    return "/sites/site.html/"+site+"/";   }      string page_base( RequestID id, string content )   { -  return sprintf( "<use file='/standard/template' />\n" +  return sprintf( "<use file='/template' />\n"    "<tmpl title=' %s'>" -  "<topmenu base='&cf.num-dotdots;' selected='sites'/>\n" +  "<topmenu base='/' selected='sites'/>\n"    "<content><cv-split>"    "<subtablist width='100%%'>"    "<st-tabs></st-tabs>"    "<st-page>"    "<if not='1' variable='form.initial'>"    "<gbutton href='add_module.pike?config=&form.config:http;"    "&reload_module_list=yes' > %s </gbutton> "    "<gbutton href='site.html/&form.config;'> %s </gbutton>"    "<p>\n</if>%s\n</p>\n"    "</st-page></subtablist></td></tr></table>"
Roxen.git/server/config_interface/sites/add_module.pike:321:   }      array(int|string) class_visible_normal( string c, string d, RequestID id )   {    int x;    string header = ("<tr><td colspan='2'><table width='100%' "    "cellspacing='0' border='0' cellpadding='3' "    "bgcolor='&usr.content-titlebg;'><tr><td>");       if( id->variables->unfolded == c ) { -  header+=("<a name="+Roxen.http_encode_string(c)+ -  "></a><gbutton dim='1'> "+LOCALE(267, "View")+" </gbutton>"); +  header+=("<gbutton " +  "href='add_module.pike?config=&form.config;" +  "#"+Roxen.http_encode_string(c)+"' > "+ +  LOCALE(0, "Hide")+" </gbutton>");    x=1;    }    else    header+=("<gbutton "    "href='add_module.pike?config=&form.config;"    "&unfolded="+Roxen.http_encode_string(c)+    "#"+Roxen.http_encode_string(c)+"' > "+    LOCALE(267, "View")+" </gbutton>");       header+=("</td><td width='100%'>"
Roxen.git/server/config_interface/sites/add_module.pike:524:    if( (int)what )    return (string)((array(int))(what/","-({""})));    return what;   }               array initial_form( RequestID id, Configuration conf, array modules )   { -  id->variables->initial = 1; +  id->variables->initial = "1"; +  id->real_variables->initial = ({ "1" }); +     string res = "";    int num; -  +     foreach( modules, string mod )    {    ModuleInfo mi = roxen.find_module( (mod/"!")[0] );    RoxenModule moo = conf->find_module( replace(mod,"!","#") );    foreach( indices(moo->query()), string v )    {    if( moo->getvar( v )->get_flags() & VAR_INITIAL )    {    num++;    res += "<tr><td colspan='3'><h2>"
Roxen.git/server/config_interface/sites/add_module.pike:551:    <tr><td width='50'></td><td width=20%><b>&_.name;</b></td><td><eval>&_.form:none;</eval></td></tr>    <tr><td></td><td colspan=2>&_.doc:none;<p>&_.type_hint;</td></tr>   </emit>";    break;    }    }    }    return ({res,num});   }    + mapping already_added = ([]); +    mixed do_it_pass_2( array modules, Configuration conf,    RequestID id )   {    id->misc->do_not_goto = 1;    foreach( modules, string mod )    { -  +  if( already_added[mod] ) +  mod = already_added[ mod ];    if( !has_value(mod, "!") || !conf->find_module( replace(mod,"!","#") ) )    {    RoxenModule mm = conf->enable_module( mod,0,0,1 );    if( !mm || !conf->otomod[mm] )    {    report_error("Failed to enable "+mod+"\n" ); -  // This will (hopefully) show the event log, with the message -  // above at the top. +     return Roxen.http_redirect( site_url(id,conf->name), id );    }    conf->call_low_start_callbacks( mm,    roxen.find_module( (mod/"!")[0] ),    conf->modules[ mod ] ); -  modules = replace( modules, mod, mod+"!"+(conf->otomod[mm]/"#")[-1] ); +  modules = replace( modules, mod, +  (already_added[mod]=(mod/"!")[0]+"!"+ +  (conf->otomod[mm]/"#")[-1]) );    }    remove_call_out( roxen.really_save_it );    }       [string cf_form, int num] = initial_form( id, conf, modules );    if( !num || id->variables["ok.x"] )    {    // set initial variables from form variables...    if( num ) Roxen.parse_rxml( cf_form, id );    foreach( modules, string mod )    conf->call_start_callbacks( conf->find_module( replace(mod,"!","#") ),    roxen.find_module( (mod/"!")[0] ),    conf->modules[ mod ] ); -  +  already_added = ([ ]);    conf->save( ); // save it all in one go    return Roxen.http_redirect( site_url(id,conf->name)+modules[-1]+"/" , id);    }    return page_base(id,"<table>"+    map( modules, lambda( string q ) {    return "<input type='hidden' "    "name='module_to_add' "    "value='"+q+"' />";    } )*"\n"    +"<input type='hidden' name='config' "
Roxen.git/server/config_interface/sites/add_module.pike:606:      mixed do_it( RequestID id )   {    if( id->variables->encoded )    id->variables->config = decode_site_name( id->variables->config );       Configuration conf = roxen.find_configuration( id->variables->config );       if( !conf->inited )    conf->enable_all_modules(); +     array modules = (id->variables->module_to_add/"\0")-({""});    if( !sizeof( modules ) )    return Roxen.http_redirect( site_url(id,conf->name ), id );    return do_it_pass_2( modules, conf, id );   }      mixed parse( RequestID id )   {    if( !config_perm( "Add Module" ) )    return LOCALE(226, "Permission denied");