| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | $Id$ |
|---|
| 4 | (Built initially by unixservice.com mysqlRAD2) |
|---|
| 5 | PURPOSE |
|---|
| 6 | Non schema-dependent table and application table related functions. |
|---|
| 7 | AUTHOR |
|---|
| 8 | (C) 2001-2007 Gary Wallis. |
|---|
| 9 | |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | //ModuleFunctionProtos() |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | void tTemplateReport(void); |
|---|
| 16 | void tTemplateNavList(void); |
|---|
| 17 | |
|---|
| 18 | void ExtProcesstTemplateVars(pentry entries[], int x) |
|---|
| 19 | { |
|---|
| 20 | /* |
|---|
| 21 | register int i; |
|---|
| 22 | for(i=0;i<x;i++) |
|---|
| 23 | { |
|---|
| 24 | } |
|---|
| 25 | */ |
|---|
| 26 | }//void ExtProcesstTemplateVars(pentry entries[], int x) |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | void ExttTemplateCommands(pentry entries[], int x) |
|---|
| 30 | { |
|---|
| 31 | if(!strcmp(gcFunction,"tTemplateTools")) |
|---|
| 32 | { |
|---|
| 33 | //ModuleFunctionProcess() |
|---|
| 34 | |
|---|
| 35 | if(!strcmp(gcCommand,LANG_NB_NEW)) |
|---|
| 36 | { |
|---|
| 37 | if(guPermLevel>=10) |
|---|
| 38 | { |
|---|
| 39 | ProcesstTemplateVars(entries,x); |
|---|
| 40 | guMode=2000; |
|---|
| 41 | tTemplate(LANG_NB_CONFIRMNEW); |
|---|
| 42 | } |
|---|
| 43 | } |
|---|
| 44 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMNEW)) |
|---|
| 45 | { |
|---|
| 46 | if(guPermLevel>=10) |
|---|
| 47 | { |
|---|
| 48 | ProcesstTemplateVars(entries,x); |
|---|
| 49 | |
|---|
| 50 | guMode=2000; |
|---|
| 51 | //Check entries here |
|---|
| 52 | guMode=0; |
|---|
| 53 | |
|---|
| 54 | uTemplate=0; |
|---|
| 55 | uCreatedBy=guLoginClient; |
|---|
| 56 | uOwner=guCompany; |
|---|
| 57 | uModBy=0;//Never modified |
|---|
| 58 | uModDate=0;//Never modified |
|---|
| 59 | NewtTemplate(0); |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | else if(!strcmp(gcCommand,LANG_NB_DELETE)) |
|---|
| 63 | { |
|---|
| 64 | ProcesstTemplateVars(entries,x); |
|---|
| 65 | if(uOwner) GetClientOwner(uOwner,&guReseller); |
|---|
| 66 | if( (guPermLevel>=10 && uOwner==guLoginClient) |
|---|
| 67 | || (guPermLevel>9 && uOwner!=1 && uOwner!=0) |
|---|
| 68 | || (guPermLevel>7 && guReseller==guLoginClient) ) |
|---|
| 69 | { |
|---|
| 70 | guMode=2001; |
|---|
| 71 | tTemplate(LANG_NB_CONFIRMDEL); |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMDEL)) |
|---|
| 75 | { |
|---|
| 76 | ProcesstTemplateVars(entries,x); |
|---|
| 77 | if(uOwner) GetClientOwner(uOwner,&guReseller); |
|---|
| 78 | if( (guPermLevel>=10 && uOwner==guLoginClient) |
|---|
| 79 | || (guPermLevel>9 && uOwner!=1 && uOwner!=0) |
|---|
| 80 | || (guPermLevel>7 && guReseller==guLoginClient) ) |
|---|
| 81 | { |
|---|
| 82 | guMode=5; |
|---|
| 83 | DeletetTemplate(); |
|---|
| 84 | } |
|---|
| 85 | } |
|---|
| 86 | else if(!strcmp(gcCommand,LANG_NB_MODIFY)) |
|---|
| 87 | { |
|---|
| 88 | ProcesstTemplateVars(entries,x); |
|---|
| 89 | if(uOwner) GetClientOwner(uOwner,&guReseller); |
|---|
| 90 | if( (guPermLevel>=10 && uOwner==guLoginClient) |
|---|
| 91 | || (guPermLevel>9 && uOwner!=1 && uOwner!=0) |
|---|
| 92 | || (guPermLevel>7 && guReseller==guLoginClient) ) |
|---|
| 93 | { |
|---|
| 94 | guMode=2002; |
|---|
| 95 | tTemplate(LANG_NB_CONFIRMMOD); |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMMOD)) |
|---|
| 99 | { |
|---|
| 100 | ProcesstTemplateVars(entries,x); |
|---|
| 101 | if(uOwner) GetClientOwner(uOwner,&guReseller); |
|---|
| 102 | if( (guPermLevel>=10 && uOwner==guLoginClient) |
|---|
| 103 | || (guPermLevel>9 && uOwner!=1 && uOwner!=0) |
|---|
| 104 | || (guPermLevel>7 && guReseller==guLoginClient) ) |
|---|
| 105 | { |
|---|
| 106 | guMode=2002; |
|---|
| 107 | //Check entries here |
|---|
| 108 | guMode=0; |
|---|
| 109 | |
|---|
| 110 | uModBy=guLoginClient; |
|---|
| 111 | ModtTemplate(); |
|---|
| 112 | } |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | }//void ExttTemplateCommands(pentry entries[], int x) |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | void ExttTemplateButtons(void) |
|---|
| 120 | { |
|---|
| 121 | OpenFieldSet("tTemplate Aux Panel",100); |
|---|
| 122 | switch(guMode) |
|---|
| 123 | { |
|---|
| 124 | case 2000: |
|---|
| 125 | printf("<p><u>Enter/mod data</u><br>"); |
|---|
| 126 | printf(LANG_NBB_CONFIRMNEW); |
|---|
| 127 | break; |
|---|
| 128 | |
|---|
| 129 | case 2001: |
|---|
| 130 | printf("<p><u>Think twice</u><br>"); |
|---|
| 131 | printf(LANG_NBB_CONFIRMDEL); |
|---|
| 132 | break; |
|---|
| 133 | |
|---|
| 134 | case 2002: |
|---|
| 135 | printf("<p><u>Review changes</u><br>"); |
|---|
| 136 | printf(LANG_NBB_CONFIRMMOD); |
|---|
| 137 | break; |
|---|
| 138 | |
|---|
| 139 | default: |
|---|
| 140 | printf("<p><u>Table Tips</u><br>"); |
|---|
| 141 | printf("tTemplate stores diverse templates. These may be used for system configuration" |
|---|
| 142 | " files or for unxsVZ interfaces and tools.<br>\n"); |
|---|
| 143 | if(uTemplate) |
|---|
| 144 | tTemplateReport(); |
|---|
| 145 | |
|---|
| 146 | tTemplateNavList(); |
|---|
| 147 | } |
|---|
| 148 | CloseFieldSet(); |
|---|
| 149 | |
|---|
| 150 | }//void ExttTemplateButtons(void) |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | void ExttTemplateAuxTable(void) |
|---|
| 154 | { |
|---|
| 155 | |
|---|
| 156 | }//void ExttTemplateAuxTable(void) |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | void ExttTemplateGetHook(entry gentries[], int x) |
|---|
| 160 | { |
|---|
| 161 | register int i; |
|---|
| 162 | |
|---|
| 163 | for(i=0;i<x;i++) |
|---|
| 164 | { |
|---|
| 165 | if(!strcmp(gentries[i].name,"uTemplate")) |
|---|
| 166 | { |
|---|
| 167 | sscanf(gentries[i].val,"%u",&uTemplate); |
|---|
| 168 | guMode=6; |
|---|
| 169 | } |
|---|
| 170 | } |
|---|
| 171 | tTemplate(""); |
|---|
| 172 | |
|---|
| 173 | }//void ExttTemplateGetHook(entry gentries[], int x) |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | void ExttTemplateSelect(void) |
|---|
| 177 | { |
|---|
| 178 | ExtSelect("tTemplate",VAR_LIST_tTemplate); |
|---|
| 179 | |
|---|
| 180 | }//void ExttTemplateSelect(void) |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | void ExttTemplateSelectRow(void) |
|---|
| 184 | { |
|---|
| 185 | ExtSelectRow("tTemplate",VAR_LIST_tTemplate,uTemplate); |
|---|
| 186 | |
|---|
| 187 | }//void ExttTemplateSelectRow(void) |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | void ExttTemplateListSelect(void) |
|---|
| 191 | { |
|---|
| 192 | char cCat[512]; |
|---|
| 193 | |
|---|
| 194 | ExtListSelect("tTemplate",VAR_LIST_tTemplate); |
|---|
| 195 | |
|---|
| 196 | //Changes here must be reflected below in ExttTemplateListFilter() |
|---|
| 197 | if(!strcmp(gcFilter,"uTemplate")) |
|---|
| 198 | { |
|---|
| 199 | sscanf(gcCommand,"%u",&uTemplate); |
|---|
| 200 | if(guLoginClient==1 && guPermLevel>11) |
|---|
| 201 | strcat(gcQuery," WHERE "); |
|---|
| 202 | else |
|---|
| 203 | strcat(gcQuery," AND "); |
|---|
| 204 | sprintf(cCat,"tTemplate.uTemplate=%u ORDER BY uTemplate",uTemplate); |
|---|
| 205 | strcat(gcQuery,cCat); |
|---|
| 206 | } |
|---|
| 207 | else if(1) |
|---|
| 208 | { |
|---|
| 209 | //None NO FILTER |
|---|
| 210 | strcpy(gcFilter,"None"); |
|---|
| 211 | strcat(gcQuery," ORDER BY uTemplate"); |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | }//void ExttTemplateListSelect(void) |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | void ExttTemplateListFilter(void) |
|---|
| 218 | { |
|---|
| 219 | //Filter |
|---|
| 220 | printf(" Filter on "); |
|---|
| 221 | printf("<select name=gcFilter>"); |
|---|
| 222 | if(strcmp(gcFilter,"uTemplate")) |
|---|
| 223 | printf("<option>uTemplate</option>"); |
|---|
| 224 | else |
|---|
| 225 | printf("<option selected>uTemplate</option>"); |
|---|
| 226 | if(strcmp(gcFilter,"None")) |
|---|
| 227 | printf("<option>None</option>"); |
|---|
| 228 | else |
|---|
| 229 | printf("<option selected>None</option>"); |
|---|
| 230 | printf("</select>"); |
|---|
| 231 | |
|---|
| 232 | }//void ExttTemplateListFilter(void) |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | void ExttTemplateNavBar(void) |
|---|
| 236 | { |
|---|
| 237 | if(uOwner) GetClientOwner(uOwner,&guReseller); |
|---|
| 238 | |
|---|
| 239 | printf(LANG_NBB_SKIPFIRST); |
|---|
| 240 | printf(LANG_NBB_SKIPBACK); |
|---|
| 241 | printf(LANG_NBB_SEARCH); |
|---|
| 242 | |
|---|
| 243 | if(guPermLevel>=10 && !guListMode) |
|---|
| 244 | printf(LANG_NBB_NEW); |
|---|
| 245 | |
|---|
| 246 | if( (guPermLevel>=10 && uOwner==guLoginClient) |
|---|
| 247 | || (guPermLevel>9 && uOwner!=1 && uOwner!=0) |
|---|
| 248 | || (guPermLevel>7 && guReseller==guLoginClient) ) |
|---|
| 249 | printf(LANG_NBB_MODIFY); |
|---|
| 250 | |
|---|
| 251 | if( (guPermLevel>=10 && uOwner==guLoginClient) |
|---|
| 252 | || (guPermLevel>9 && uOwner!=1 && uOwner!=0) |
|---|
| 253 | || (guPermLevel>7 && guReseller==guLoginClient) ) |
|---|
| 254 | printf(LANG_NBB_DELETE); |
|---|
| 255 | |
|---|
| 256 | if(uOwner) |
|---|
| 257 | printf(LANG_NBB_LIST); |
|---|
| 258 | |
|---|
| 259 | printf(LANG_NBB_SKIPNEXT); |
|---|
| 260 | printf(LANG_NBB_SKIPLAST); |
|---|
| 261 | printf(" \n"); |
|---|
| 262 | |
|---|
| 263 | }//void ExttTemplateNavBar(void) |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | void tTemplateNavList(void) |
|---|
| 267 | { |
|---|
| 268 | MYSQL_RES *res; |
|---|
| 269 | MYSQL_ROW field; |
|---|
| 270 | |
|---|
| 271 | ExtSelect("tTemplate","tTemplate.uTemplate,tTemplate.cLabel"); |
|---|
| 272 | |
|---|
| 273 | mysql_query(&gMysql,gcQuery); |
|---|
| 274 | if(mysql_errno(&gMysql)) |
|---|
| 275 | { |
|---|
| 276 | printf("<p><u>tTemplateNavList</u><br>\n"); |
|---|
| 277 | printf("%s",mysql_error(&gMysql)); |
|---|
| 278 | return; |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | res=mysql_store_result(&gMysql); |
|---|
| 282 | if(mysql_num_rows(res)) |
|---|
| 283 | { |
|---|
| 284 | printf("<p><u>tTemplateNavList</u><br>\n"); |
|---|
| 285 | |
|---|
| 286 | while((field=mysql_fetch_row(res))) |
|---|
| 287 | { |
|---|
| 288 | printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=tTemplate\ |
|---|
| 289 | &uTemplate=%s>%s</a><br>\n",field[0],field[1]); |
|---|
| 290 | } |
|---|
| 291 | } |
|---|
| 292 | mysql_free_result(res); |
|---|
| 293 | |
|---|
| 294 | }//void tTemplateNavList(void) |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | void tTemplateReport(void) |
|---|
| 298 | { |
|---|
| 299 | MYSQL_RES *res; |
|---|
| 300 | MYSQL_ROW field; |
|---|
| 301 | |
|---|
| 302 | sprintf(gcQuery,"SELECT tProperty.uKey,tContainer.cLabel FROM tProperty,tContainer" |
|---|
| 303 | " WHERE tProperty.uType=3 AND tProperty.cValue='%s'" |
|---|
| 304 | " AND tProperty.uKey=tContainer.uContainer",cLabel); |
|---|
| 305 | mysql_query(&gMysql,gcQuery); |
|---|
| 306 | if(mysql_errno(&gMysql)) |
|---|
| 307 | { |
|---|
| 308 | printf("<p><u>tTemplateReport</u><br>\n"); |
|---|
| 309 | printf("%s",mysql_error(&gMysql)); |
|---|
| 310 | return; |
|---|
| 311 | } |
|---|
| 312 | res=mysql_store_result(&gMysql); |
|---|
| 313 | if(mysql_num_rows(res)) |
|---|
| 314 | { |
|---|
| 315 | printf("<p><u>tTemplateReport</u><br>\n"); |
|---|
| 316 | |
|---|
| 317 | while((field=mysql_fetch_row(res))) |
|---|
| 318 | { |
|---|
| 319 | printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=tContainer" |
|---|
| 320 | "&uContainer=%s>%s used by %s</a><br>\n",field[0],cLabel,field[1]); |
|---|
| 321 | } |
|---|
| 322 | } |
|---|
| 323 | mysql_free_result(res); |
|---|
| 324 | |
|---|
| 325 | }//void tTemplateReport(void) |
|---|