/* FILE $Id$ (Built initially by unixservice.com mysqlRAD2) PURPOSE Non schema-dependent table and application table related functions. AUTHOR (C) 2001-2008 Gary Wallis and Hugo Urquiza. */ //ModuleFunctionProtos() void tServerNavList(void); void tServerContextInfo(void); void ExtProcesstServerVars(pentry entries[], int x) { /* register int i; for(i=0;i=9) { ProcesstServerVars(entries,x); guMode=2000; tServer(LANG_NB_CONFIRMNEW); } else tServer("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMNEW)) { if(guPermLevel>=9) { unsigned uContactParentCompany=0; ProcesstServerVars(entries,x); GetClientOwner(guLoginClient,&uContactParentCompany); guMode=2000; //Check entries here guMode=0; uServer=0; uCreatedBy=guLoginClient; uOwner=uContactParentCompany; uModBy=0;//Never modified uModDate=0;//Never modified NewtServer(0); } else tServer("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_DELETE)) { ProcesstServerVars(entries,x); if(uAllowDel(uOwner,uCreatedBy)) { guMode=2001; tServer(LANG_NB_CONFIRMDEL); } else tServer("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMDEL)) { ProcesstServerVars(entries,x); if(uAllowDel(uOwner,uCreatedBy)) { guMode=5; DeletetServer(); } else tServer("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_MODIFY)) { ProcesstServerVars(entries,x); if(uAllowMod(uOwner,uCreatedBy)) { guMode=2002; tServer(LANG_NB_CONFIRMMOD); } else tServer("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMMOD)) { ProcesstServerVars(entries,x); if(uAllowMod(uOwner,uCreatedBy)) { guMode=2002; //Check entries here guMode=0; uModBy=guLoginClient; ModtServer(); } else tServer("Error: Denied by permissions settings"); } } }//void ExttServerCommands(pentry entries[], int x) void ExttServerButtons(void) { OpenFieldSet("tServer Aux Panel",100); switch(guMode) { case 2000: printf("

Enter/mod data
"); printf(LANG_NBB_CONFIRMNEW); break; case 2001: printf("

Think twice
"); printf(LANG_NBB_CONFIRMDEL); break; case 2002: printf("

Review changes
"); printf(LANG_NBB_CONFIRMMOD); break; default: printf("Table Tips
"); printf("

Record Context Info
"); tServerContextInfo(); tServerNavList(); } CloseFieldSet(); }//void ExttServerButtons(void) void ExttServerAuxTable(void) { }//void ExttServerAuxTable(void) void ExttServerGetHook(entry gentries[], int x) { register int i; for(i=0;i11)//Root can read access all sprintf(gcQuery,"SELECT %s FROM tServer ORDER BY" " uServer", VAR_LIST_tServer); else //If you own it, the company you work for owns the company that owns it, //you created it, or your company owns it you can at least read access it //select tTemplateSet.cLabel from tTemplateSet,tClient where tTemplateSet.uOwner=tClient.uClient and tClient.uOwner in (select uClient from tClient where uOwner=81 or uClient=51); sprintf(gcQuery,"SELECT %s FROM tServer,tClient WHERE tServer.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)" " ORDER BY uServer", VAR_LIST_tServer,uContactParentCompany,uContactParentCompany); }//void ExttServerSelect(void) void ExttServerSelectRow(void) { unsigned uContactParentCompany=0; GetClientOwner(guLoginClient,&uContactParentCompany); if(guLoginClient==1 && guPermLevel>11)//Root can read access all sprintf(gcQuery,"SELECT %s FROM tServer WHERE uServer=%u", VAR_LIST_tServer,uServer); else sprintf(gcQuery,"SELECT %s FROM tServer,tClient" " WHERE tServer.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)" " AND tServer.uServer=%u", VAR_LIST_tServer ,uContactParentCompany,uContactParentCompany ,uServer); }//void ExttServerSelectRow(void) void ExttServerListSelect(void) { char cCat[512]; unsigned uContactParentCompany=0; GetClientOwner(guLoginClient,&uContactParentCompany); if(guLoginClient==1 && guPermLevel>11)//Root can read access all sprintf(gcQuery,"SELECT %s FROM tServer", VAR_LIST_tServer); else sprintf(gcQuery,"SELECT %s FROM tServer,tClient" " WHERE tServer.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)", VAR_LIST_tServer ,uContactParentCompany ,uContactParentCompany); //Changes here must be reflected below in ExttServerListFilter() if(!strcmp(gcFilter,"uServer")) { sscanf(gcCommand,"%u",&uServer); if(guPermLevel<10) strcat(gcQuery," AND "); else strcat(gcQuery," WHERE "); sprintf(cCat,"tServer.uServer=%u" " ORDER BY uServer", uServer); strcat(gcQuery,cCat); } else if(1) { //None NO FILTER strcpy(gcFilter,"None"); strcat(gcQuery," ORDER BY uServer"); } }//void ExttServerListSelect(void) void ExttServerListFilter(void) { //Filter printf("   Filter on "); printf(""); }//void ExttServerListFilter(void) void ExttServerNavBar(void) { printf(LANG_NBB_SKIPFIRST); printf(LANG_NBB_SKIPBACK); printf(LANG_NBB_SEARCH); if(guPermLevel>=7 && !guListMode) printf(LANG_NBB_NEW); if(uAllowMod(uOwner,uCreatedBy)) printf(LANG_NBB_MODIFY); if(uAllowDel(uOwner,uCreatedBy)) printf(LANG_NBB_DELETE); if(uOwner) printf(LANG_NBB_LIST); printf(LANG_NBB_SKIPNEXT); printf(LANG_NBB_SKIPLAST); printf("   \n"); }//void ExttServerNavBar(void) void tServerNavList(void) { MYSQL_RES *res; MYSQL_ROW field; unsigned uContactParentCompany=0; GetClientOwner(guLoginClient,&uContactParentCompany); GetClientOwner(uContactParentCompany,&guReseller);//Get owner of your owner... if(guReseller==1) guReseller=0;//...except Root companies if(guLoginClient==1 && guPermLevel>11)//Root can read access all sprintf(gcQuery,"SELECT uServer,cLabel FROM tServer ORDER BY cLabel"); else sprintf(gcQuery,"SELECT tServer.uServer," " tServer.cLabel" " FROM tServer,tClient" " WHERE tServer.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)", uContactParentCompany ,uContactParentCompany); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) { printf("

tServerNavList
\n"); printf("%s",mysql_error(&gMysql)); return; } res=mysql_store_result(&gMysql); if(mysql_num_rows(res)) { printf("

tServerNavList
\n"); while((field=mysql_fetch_row(res))) printf("%s
\n", field[0],field[1]); } mysql_free_result(res); }//void tServerNavList(void) void tServerContextInfo(void) { MYSQL_RES *res; MYSQL_ROW field; if(!uServer) return; sprintf(gcQuery,"SELECT COUNT(tZone.uZone) FROM tNSSet,tNS,tZone WHERE" " tZone.uNSSet=tNSSet.uNSSet AND tNSSet.uNSSet=tNS.uNSSet AND" " tNS.uServer=%u",uServer); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) { printf("tServerContextInfo:
\n"); printf("%s",mysql_error(&gMysql)); return; } res=mysql_store_result(&gMysql); if((field=mysql_fetch_row(res))) { printf("tServerContextInfo:
\n"); printf("%s zones are assigned to NS sets that have NS associated with this server.",field[0]); } mysql_free_result(res); }//void tServerContextInfo(void)