/* 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 tNSSetNavList(void); void tNSSetMembers(unsigned uNSSet); void ExtProcesstNSSetVars(pentry entries[], int x) { /* register int i; for(i=0;i=9) { ProcesstNSSetVars(entries,x); guMode=2000; tNSSet(LANG_NB_CONFIRMNEW); } else tNSSet("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMNEW)) { if(guPermLevel>=9) { unsigned uContactParentCompany=0; ProcesstNSSetVars(entries,x); GetClientOwner(guLoginClient,&uContactParentCompany); guMode=2000; //Check entries here guMode=0; uNSSet=0; uCreatedBy=guLoginClient; uOwner=uContactParentCompany; uModBy=0;//Never modified uModDate=0;//Never modified NewtNSSet(0); } else tNSSet("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_DELETE)) { ProcesstNSSetVars(entries,x); if(uAllowDel(uOwner,uCreatedBy)) { guMode=2001; tNSSet(LANG_NB_CONFIRMDEL); } else tNSSet("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMDEL)) { ProcesstNSSetVars(entries,x); if(uAllowDel(uOwner,uCreatedBy)) { guMode=5; DeletetNSSet(); } else tNSSet("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_MODIFY)) { ProcesstNSSetVars(entries,x); if(uAllowMod(uOwner,uCreatedBy)) { guMode=2002; tNSSet(LANG_NB_CONFIRMMOD); } else tNSSet("Error: Denied by permissions settings"); } else if(!strcmp(gcCommand,LANG_NB_CONFIRMMOD)) { ProcesstNSSetVars(entries,x); if(uAllowMod(uOwner,uCreatedBy)) { guMode=2002; //Check entries here guMode=0; uModBy=guLoginClient; ModtNSSet(); } else tNSSet("Error: Denied by permissions settings"); } } }//void ExttNSSetCommands(pentry entries[], int x) void ExttNSSetButtons(void) { OpenFieldSet("tNSSet 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
"); tNSSetMembers(uNSSet); tNSSetNavList(); } CloseFieldSet(); }//void ExttNSSetButtons(void) void ExttNSSetAuxTable(void) { }//void ExttNSSetAuxTable(void) void ExttNSSetGetHook(entry gentries[], int x) { register int i; for(i=0;i11)//Root can read access all sprintf(gcQuery,"SELECT %s FROM tNSSet ORDER BY" " uNSSet", VAR_LIST_tNSSet); 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 tNSSet,tClient WHERE tNSSet.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)" " ORDER BY uNSSet", VAR_LIST_tNSSet,uContactParentCompany,uContactParentCompany); }//void ExttNSSetSelect(void) void ExttNSSetSelectRow(void) { unsigned uContactParentCompany=0; GetClientOwner(guLoginClient,&uContactParentCompany); if(guLoginClient==1 && guPermLevel>11)//Root can read access all sprintf(gcQuery,"SELECT %s FROM tNSSet WHERE uNSSet=%u", VAR_LIST_tNSSet,uNSSet); else sprintf(gcQuery,"SELECT %s FROM tNSSet,tClient" " WHERE tNSSet.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)" " AND tNSSet.uNSSet=%u", VAR_LIST_tNSSet ,uContactParentCompany,uContactParentCompany ,uNSSet); }//void ExttNSSetSelectRow(void) void ExttNSSetListSelect(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 tNSSet", VAR_LIST_tNSSet); else sprintf(gcQuery,"SELECT %s FROM tNSSet,tClient" " WHERE tNSSet.uOwner=tClient.uClient" " AND tClient.uOwner IN (SELECT uClient FROM tClient WHERE uOwner=%u OR uClient=%u)", VAR_LIST_tNSSet ,uContactParentCompany ,uContactParentCompany); //Changes here must be reflected below in ExttNSSetListFilter() if(!strcmp(gcFilter,"uNSSet")) { sscanf(gcCommand,"%u",&uNSSet); if(guPermLevel<10) strcat(gcQuery," AND "); else strcat(gcQuery," WHERE "); sprintf(cCat,"tNSSet.uNSSet=%u" " ORDER BY uNSSet", uNSSet); strcat(gcQuery,cCat); } else if(1) { //None NO FILTER strcpy(gcFilter,"None"); strcat(gcQuery," ORDER BY uNSSet"); } }//void ExttNSSetListSelect(void) void ExttNSSetListFilter(void) { //Filter printf("   Filter on "); printf(""); }//void ExttNSSetListFilter(void) void ExttNSSetNavBar(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 ExttNSSetNavBar(void) void tNSSetNavList(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 uNSSet,cLabel FROM tNSSet ORDER BY cLabel"); else sprintf(gcQuery,"SELECT tNSSet.uNSSet," " tNSSet.cLabel" " FROM tNSSet,tClient" " WHERE tNSSet.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("

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

tNSSetNavList
\n"); while((field=mysql_fetch_row(res))) printf("%s
\n", field[0],field[1]); } mysql_free_result(res); }//void tNSSetNavList(void) void tNSSetMembers(unsigned uNSSet) { MYSQL_RES *res; MYSQL_ROW field; if(uNSSet==0) return; sprintf(gcQuery,"SELECT tNS.uNS,tNS.cFQDN,tNSType.cLabel FROM tNSSet,tNS,tNSType WHERE" " tNS.uNSSet=tNSSet.uNSSet AND tNS.uNSType=tNSType.uNSType AND" " tNSSet.uNSSet=%u ORDER BY tNS.cFQDN",uNSSet); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) { printf("tNSSetMembers w/tNSType:
\n"); printf("%s",mysql_error(&gMysql)); return; } res=mysql_store_result(&gMysql); if(mysql_num_rows(res)) { printf("tNSSetMembers w/tNSType:
\n"); while((field=mysql_fetch_row(res))) printf("%s %s
\n", field[0],field[1],field[2]); } mysql_free_result(res); sprintf(gcQuery,"SELECT tNS.uNS,tNS.cFQDN,tServer.cLabel FROM tNSSet,tNS,tServer WHERE" " tNS.uNSSet=tNSSet.uNSSet AND tNS.uServer=tServer.uServer AND" " tNSSet.uNSSet=%u ORDER BY tNS.cFQDN",uNSSet); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) { printf("tNSSetMembers w/tServer:
\n"); printf("%s",mysql_error(&gMysql)); return; } res=mysql_store_result(&gMysql); if(mysql_num_rows(res)) { printf("tNSSetMembers w/tServer:
\n"); while((field=mysql_fetch_row(res))) printf("%s %s
\n", field[0],field[1],field[2]); } mysql_free_result(res); }//void tNSSetMembers(unsigned uNSSet)