302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
}
db_finalize(&q);
db_end_transaction(0);
}
/*
** WEBPAGE: tktview
*/
void tktview_page(void){
char *zScript;
int nScript;
login_check_credentials();
if( !g.okRdTkt ){ login_needed(); return; }
style_header("View Ticket");
ticket_init();
initializeVariablesFromDb();
zScript = (char*)SbS_Fetch(pInterp, "tktview_template", -1, &nScript);
zScript = mprintf("%.*s", nScript, zScript);
SbS_Render(pInterp, zScript);
style_footer();
|
>
>
>
>
>
>
|
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
}
db_finalize(&q);
db_end_transaction(0);
}
/*
** WEBPAGE: tktview
**
** View a ticket.
*/
void tktview_page(void){
char *zScript;
int nScript;
login_check_credentials();
if( !g.okRdTkt ){ login_needed(); return; }
if( g.okWrTkt ){
style_submenu_element("Edit", "Edit The Ticket", "%s/tktedit?name=%T",
g.zTop, PD("name",""));
}
style_header("View Ticket");
ticket_init();
initializeVariablesFromDb();
zScript = (char*)SbS_Fetch(pInterp, "tktview_template", -1, &nScript);
zScript = mprintf("%.*s", nScript, zScript);
SbS_Render(pInterp, zScript);
style_footer();
|
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
return SBS_RETURN;
}
/*
** WEBPAGE: tktnew
** WEBPAGE: debug_tktnew
*/
void tktnew_page(void){
char *zScript;
int nScript;
char *zNewUuid = 0;
login_check_credentials();
|
>
>
>
>
>
>
>
>
|
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
|
return SBS_RETURN;
}
/*
** WEBPAGE: tktnew
** WEBPAGE: debug_tktnew
**
** Enter a new ticket. the tktnew_template script in the ticket
** configuration is used. The /tktnew page is the official ticket
** entry page. The /debug_tktnew page is used for debugging the
** tktnew_template in the ticket configuration. /debug_tktnew works
** just like /tktnew except that it does not really save the new ticket
** when you press submit - it just prints the ticket artifact at the
** top of the screen.
*/
void tktnew_page(void){
char *zScript;
int nScript;
char *zNewUuid = 0;
login_check_credentials();
|
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
cgi_redirect(mprintf("%s/tktview/%s", g.zBaseURL, zNewUuid));
return;
}
@ </form>
style_footer();
}
/*
** WEBPAGE: tktedit
** WEBPAGE: debug_tktedit
*/
void tktedit_page(void){
char *zScript;
int nScript;
int nName;
const char *zName;
int nRec;
|
<
<
>
>
>
>
>
>
>
|
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
|
cgi_redirect(mprintf("%s/tktview/%s", g.zBaseURL, zNewUuid));
return;
}
@ </form>
style_footer();
}
/*
** WEBPAGE: tktedit
** WEBPAGE: debug_tktedit
**
** Edit a ticket. The ticket is identified by the name CGI parameter.
** /tktedit is the official page. The /debug_tktedit page does the same
** thing except that it does not save the ticket change record when you
** press submit - it instead prints the ticket change record at the top
** of the page. The /debug_tktedit page is intended to be used when
** debugging ticket configurations.
*/
void tktedit_page(void){
char *zScript;
int nScript;
int nName;
const char *zName;
int nRec;
|
499
500
501
502
503
504
505
|
if( SbS_Render(pInterp, zScript)==SBS_RETURN && zName ){
cgi_redirect(mprintf("%s/tktview/%s", g.zBaseURL, zName));
return;
}
@ </form>
style_footer();
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
if( SbS_Render(pInterp, zScript)==SBS_RETURN && zName ){
cgi_redirect(mprintf("%s/tktview/%s", g.zBaseURL, zName));
return;
}
@ </form>
style_footer();
}
/*
** Check the ticket configuration in zConfig to see if it appears to
** be well-formed. If everything is OK, return NULL. If something is
** amiss, then return a pointer to a string (obtained from malloc) that
** describes the problem.
*/
char *ticket_config_check(const char *zConfig){
struct Subscript *p;
char *zErr = 0;
const char *z;
int n;
int i;
int rc;
sqlite3 *db;
static const char *azRequired[] = {
"tktnew_template",
"tktview_template",
"tktedit_template",
};
p = SbS_Create();
rc = SbS_Eval(p, zConfig, strlen(zConfig));
if( rc!=SBS_OK ){
zErr = mprintf("%s", SbS_GetErrorMessage(p));
SbS_Destroy(p);
return zErr;
}
for(i=0; i<sizeof(azRequired)/sizeof(azRequired[0]); i++){
z = SbS_Fetch(p, azRequired[i], -1, &n);
if( z==0 ){
zErr = mprintf("missing definition: %s", azRequired[i]);
SbS_Destroy(p);
return zErr;
}
}
z = SbS_Fetch(p, "ticket_sql", -1, &n);
if( z==0 ){
zErr = mprintf("missing definition: ticket_sql");
SbS_Destroy(p);
return zErr;
}
rc = sqlite3_open(":memory:", &db);
if( rc==SQLITE_OK ){
char *zSql = mprintf("%.*s", n, z);
rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
if( rc!=SQLITE_OK ){
sqlite3_close(db);
SbS_Destroy(p);
return zErr;
}
/* TODO: verify that the TICKET table exists and has required fields */
sqlite3_close(db);
}
SbS_Destroy(p);
return 0;
}
|