00001 #include "siteLimit.h" 00002 00003 class site_pick { 00004 protected: 00005 string selSite; 00006 string siteOptions; 00007 public: 00008 site_pick(cgiScript & script) 00009 { 00010 selSite = currentSite( script.ClientArguments() ); 00011 } 00012 ~site_pick() 00013 { 00014 } 00015 00016 string & getSiteOptions( cgiScript & script, openLogin & login ) 00017 { 00018 string limits; 00019 string value,label; 00020 string sql = "select id, name from metasite.sites "; 00021 limits = siteLimits(login); 00022 if(limits.length()) 00023 { 00024 sql += " where id "; 00025 sql += limits; 00026 } 00027 quickQuery qq; 00028 openRS & rs = qq.getRS(); 00029 siteOptions += "<!--"; 00030 siteOptions += sql; 00031 siteOptions += "-->"; 00032 int count=0; 00033 for(bool o=rs.open(sql);o;o=rs.next()) 00034 { 00035 if( count == 0 ) 00036 { 00037 value = rs.getField(0).format(); 00038 label = rs.getField(1).format(); 00039 } 00040 siteOptions += "<option value=\""; 00041 siteOptions += rs.getField(0).format(); 00042 siteOptions += "\""; 00043 if( selSite == rs.getField(0).format() ) 00044 { 00045 siteOptions += " selected"; 00046 } 00047 siteOptions += ">"; 00048 siteOptions += rs.getField(1).format(); 00049 siteOptions += "</option>\n"; 00050 count++; 00051 } 00052 rs.close(); 00053 if( selSite.length() == 0 ) 00054 { 00055 // set the site cookie to the first site 00056 cgiCookie cookie; 00057 cookie.setPath("/"); 00058 cookie.set( "site_id", value.c_str() ); 00059 } 00060 return siteOptions; 00061 } 00062 }; 00063 00064
1.5.5