Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Progress toward getting ticketing working. We can enter a new ticket and display it. Cannot yet edit a ticket. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
fb358ca492904507ebfc504c40b0a6e4 |
| User & Date: | drh 2007-11-24 19:33:46.000 |
Context
|
2007-11-24
| ||
| 21:28 | Progress toward ticket editing. This is an incremental check-in. check-in: d913179b82 user: drh tags: trunk | |
| 19:33 | Progress toward getting ticketing working. We can enter a new ticket and display it. Cannot yet edit a ticket. check-in: fb358ca492 user: drh tags: trunk | |
| 14:06 | Documentation updates. check-in: 6680679c2e user: drh tags: trunk | |
Changes
Changes to src/cgi.c.
| ︙ | ︙ | |||
724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue));
return zValue;
}
}
CGIDEBUG(("no-match [%s]\n", zName));
return zDefault;
}
/*
** Print CGI debugging messages.
*/
void cgi_debug(const char *zFormat, ...){
va_list ap;
if( g.fDebug ){
| > > > > > > > > > > > > | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue));
return zValue;
}
}
CGIDEBUG(("no-match [%s]\n", zName));
return zDefault;
}
/*
** Return the name of the i-th CGI parameter. Return NULL if there
** are fewer than i registered CGI parmaeters.
*/
const char *cgi_parameter_name(int i){
if( i>=0 && i<nUsedQP ){
return aParamQP[i].zName;
}else{
return 0;
}
}
/*
** Print CGI debugging messages.
*/
void cgi_debug(const char *zFormat, ...){
va_list ap;
if( g.fDebug ){
|
| ︙ | ︙ |
Changes to src/db.c.
| ︙ | ︙ | |||
318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
}
double db_column_double(Stmt *pStmt, int N){
return sqlite3_column_double(pStmt->pStmt, N);
}
const char *db_column_text(Stmt *pStmt, int N){
return (char*)sqlite3_column_text(pStmt->pStmt, N);
}
char *db_column_malloc(Stmt *pStmt, int N){
return mprintf("%s", db_column_text(pStmt, N));
}
void db_column_blob(Stmt *pStmt, int N, Blob *pBlob){
blob_append(pBlob, sqlite3_column_blob(pStmt->pStmt, N),
sqlite3_column_bytes(pStmt->pStmt, N));
}
| > > > > > > | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
}
double db_column_double(Stmt *pStmt, int N){
return sqlite3_column_double(pStmt->pStmt, N);
}
const char *db_column_text(Stmt *pStmt, int N){
return (char*)sqlite3_column_text(pStmt->pStmt, N);
}
const char *db_column_name(Stmt *pStmt, int N){
return (char*)sqlite3_column_name(pStmt->pStmt, N);
}
int db_column_count(Stmt *pStmt){
return (char*)sqlite3_column_count(pStmt->pStmt);
}
char *db_column_malloc(Stmt *pStmt, int N){
return mprintf("%s", db_column_text(pStmt, N));
}
void db_column_blob(Stmt *pStmt, int N, Blob *pBlob){
blob_append(pBlob, sqlite3_column_blob(pStmt->pStmt, N),
sqlite3_column_bytes(pStmt->pStmt, N));
}
|
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
857 858 859 860 861 862 863 864 865 866 867 868 |
m.rDate, rid, m.zUser, zComment,
TAG_BGCOLOR, rid,
TAG_BGCOLOR, rid,
TAG_USER, rid,
TAG_COMMENT, rid
);
free(zComment);
}
db_end_transaction(0);
manifest_clear(&m);
return 1;
}
| > > > > > > > > > > > > > > > > | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
m.rDate, rid, m.zUser, zComment,
TAG_BGCOLOR, rid,
TAG_BGCOLOR, rid,
TAG_USER, rid,
TAG_COMMENT, rid
);
free(zComment);
}
if( m.type==CFTYPE_TICKET ){
char *zTag;
char *zComment;
ticket_insert(&m, 1, 1);
zTag = mprintf("tkt-%s", m.zTicketUuid);
tag_insert(zTag, 1, 0, rid, m.rDate, rid);
free(zTag);
zComment = mprintf("Changes to ticket [%.10s]", m.zTicketUuid);
db_multi_exec(
"INSERT INTO event(type,mtime,objid,user,comment)"
"VALUES('t',%.17g,%d,%Q,%Q)",
m.rDate, rid, m.zUser, zComment
);
free(zComment);
}
db_end_transaction(0);
manifest_clear(&m);
return 1;
}
|
Changes to src/rebuild.c.
| ︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
" WHERE type='table'"
" AND name NOT IN ('blob','delta','rcvfrom','user','config','shun')");
if( zTable==0 ) break;
db_multi_exec("DROP TABLE %Q", zTable);
free(zTable);
}
db_multi_exec(zRepositorySchema2);
db_multi_exec("INSERT INTO unclustered SELECT rid FROM blob");
db_multi_exec(
"DELETE FROM unclustered"
" WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
);
db_multi_exec(
| > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
" WHERE type='table'"
" AND name NOT IN ('blob','delta','rcvfrom','user','config','shun')");
if( zTable==0 ) break;
db_multi_exec("DROP TABLE %Q", zTable);
free(zTable);
}
db_multi_exec(zRepositorySchema2);
ticket_create_table(0);
db_multi_exec("INSERT INTO unclustered SELECT rid FROM blob");
db_multi_exec(
"DELETE FROM unclustered"
" WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
);
db_multi_exec(
|
| ︙ | ︙ |
Changes to src/subscript.c.
| ︙ | ︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include "subscript.h" #include <assert.h> #if INTERFACE typedef struct Subscript Subscript; #define SBS_OK 0 #define SBS_ERROR 1 #endif /* ** Configuration constants */ #define SBSCONFIG_NHASH 41 /* Size of the hash table */ #define SBSCONFIG_NSTACK 10 /* Maximum stack depth */ | > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include "subscript.h" #include <assert.h> #if INTERFACE typedef struct Subscript Subscript; #define SBS_OK 0 #define SBS_ERROR 1 #define SBS_RETURN 2 #define SBS_BREAK 3 #endif /* ** Configuration constants */ #define SBSCONFIG_NHASH 41 /* Size of the hash table */ #define SBSCONFIG_NSTACK 10 /* Maximum stack depth */ |
| ︙ | ︙ | |||
341 342 343 344 345 346 347 | free(p); } /* ** Set the error message for an interpreter. Verb implementations ** use this routine when they encounter an error. */ | | | > > > > > > > | > | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
free(p);
}
/*
** Set the error message for an interpreter. Verb implementations
** use this routine when they encounter an error.
*/
void SbS_SetErrorMessage(struct Subscript *p, const char *zErr, ...){
int nErr;
char *zMsg;
va_list ap;
va_start(ap, zErr);
zMsg = vmprintf(zErr, ap);
va_end(ap);
nErr = strlen(zMsg);
if( nErr>sizeof(p->zErrMsg)-1 ){
nErr = sizeof(p->zErrMsg)-1;
}
memcpy(p->zErrMsg, zMsg, nErr);
p->zErrMsg[nErr] = 0;
free(zMsg);
}
/*
** Return a pointer to the current error message for the
** interpreter.
*/
const char *SbS_GetErrorMessage(struct Subscript *p){
|
| ︙ | ︙ | |||
526 527 528 529 530 531 532 533 534 535 536 |
** The returned string is not necessarily (probably not) zero-terminated.
** The string may be deallocated the next time anything is done to
** the interpreter. Make a copy if you need it to persist.
*/
const char *SbS_Fetch(
struct Subscript *p, /* The interpreter we are interrogating */
const char *zKey, /* Name of the variable. Case sensitive */
int *pLength /* Write the length here */
){
const SbSValue *pVal;
| > | | 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
** The returned string is not necessarily (probably not) zero-terminated.
** The string may be deallocated the next time anything is done to
** the interpreter. Make a copy if you need it to persist.
*/
const char *SbS_Fetch(
struct Subscript *p, /* The interpreter we are interrogating */
const char *zKey, /* Name of the variable. Case sensitive */
int nKey, /* Length of the key */
int *pLength /* Write the length here */
){
const SbSValue *pVal;
pVal = sbs_fetch(&p->symTab, zKey, nKey);
if( pVal==0 || (pVal->flags & SBSVAL_STR)==0 ){
*pLength = 0;
return 0;
}else{
*pLength = pVal->u.str.size;
return pVal->u.str.z;
}
|
| ︙ | ︙ | |||
705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
*/
static int enableOutputCmd(struct Subscript *p, void *pNotUsed){
if( SbS_RequireStack(p, 1, "enable_output") ) return 1;
enableOutput = SbS_StackValueInt(p, 0)!=0;
SbS_Pop(p, 1);
return 0;
}
/*
** Subscript command: STRING puts
** Subscript command: STRING html
**
** Output STRING as HTML (html) or unchanged (puts).
** Pop it from the stack.
| > > > > > > > > > > > > > > > | 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 |
*/
static int enableOutputCmd(struct Subscript *p, void *pNotUsed){
if( SbS_RequireStack(p, 1, "enable_output") ) return 1;
enableOutput = SbS_StackValueInt(p, 0)!=0;
SbS_Pop(p, 1);
return 0;
}
/*
** Send text to the appropriate output: Either to the console
** or to the CGI reply buffer.
*/
static void sendText(const char *z, int n){
if( enableOutput && n ){
if( n<0 ) n = strlen(z);
if( g.cgiPanic ){
cgi_append_content(z, n);
}else{
fwrite(z, 1, n, stdout);
}
}
}
/*
** Subscript command: STRING puts
** Subscript command: STRING html
**
** Output STRING as HTML (html) or unchanged (puts).
** Pop it from the stack.
|
| ︙ | ︙ | |||
726 727 728 729 730 731 732 |
z = SbS_StackValue(p, 0, &size);
if( pConvert ){
zOut = htmlize(z, size);
size = strlen(zOut);
}else{
zOut = (char*)z;
}
| > > > > > > > > | > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | < | > > > > | > > | 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
z = SbS_StackValue(p, 0, &size);
if( pConvert ){
zOut = htmlize(z, size);
size = strlen(zOut);
}else{
zOut = (char*)z;
}
sendText(zOut, size);
if( pConvert ){
free(zOut);
}
}
SbS_Pop(p, 1);
return 0;
}
/*
** Subscript command: STRING wiki
**
** Render the input string as wiki.
*/
static int wikiCmd(struct Subscript *p, void *pConvert){
int size;
const char *z;
if( SbS_RequireStack(p, 1, "wiki") ) return 1;
if( enableOutput ){
Blob src;
z = SbS_StackValue(p, 0, &size);
blob_init(&src, z, size);
wiki_convert(&src, 0, WIKI_INLINE);
blob_reset(&src);
}
SbS_Pop(p, 1);
return 0;
}
/*
** Subscript command: NAME TEXT-LIST NUMLINES combobox
**
** Generate an HTML combobox. NAME is both the name of the
** CGI parameter and the name of a variable that contains the
** currently selected value. TEXT-LIST is a list of possible
** values for the combobox. NUMLINES is 1 for a true combobox.
** If NUMLINES is greater than one then the display is a listbox
** with the number of lines given.
*/
static int comboboxCmd(struct Subscript *p, void *NotUsed){
if( SbS_RequireStack(p, 3, "combobox") ) return 1;
if( enableOutput ){
int height;
Blob list, elem;
char *zName, *zList;
int nName, nList, nValue;
const char *zValue;
char *z, *zH;
height = SbS_StackValueInt(p, 0);
zList = (char*)SbS_StackValue(p, 1, &nList);
blob_init(&list, zList, nList);
zName = (char*)SbS_StackValue(p, 2, &nName);
zValue = SbS_Fetch(p, zName, nName, &nValue);
z = mprintf("<select name=\"%.*h\" size=\"%d\">", nName, zName, height);
sendText(z, -1);
free(z);
while( blob_token(&list, &elem) ){
zH = mprintf("%.*h", blob_size(&elem), blob_buffer(&elem));
if( zValue && blob_size(&elem)==nValue
&& memcmp(zValue, blob_buffer(&elem), nValue)==0 ){
z = mprintf("<option value=\"%s\" selected>%s</option>", zH, zH);
}else{
z = mprintf("<option value=\"%s\">%s</option>", zH, zH);
}
free(zH);
sendText(z, -1);
free(z);
}
sendText("</select>", -1);
blob_reset(&list);
}
SbS_Pop(p, 3);
return 0;
}
/*
** A table of built-in commands
*/
static const struct {
const char *zCmd;
int (*xCmd)(Subscript*,void*);
void *pArg;
} aBuiltin[] = {
{ "add", bopCmd, (void*)SBSOP_AND },
{ "and", bopCmd, (void*)SBSOP_AND },
{ "combobox", comboboxCmd, 0, },
{ "div", bopCmd, (void*)SBSOP_DIV },
{ "enable_output", enableOutputCmd, 0 },
{ "exists", existsCmd, 0, },
{ "get", getCmd, 0, },
{ "hascap", hascapCmd, 0 },
{ "html", putsCmd, (void*)1 },
{ "linecount", linecntCmd, 0 },
{ "max", bopCmd, (void*)SBSOP_MAX },
{ "min", bopCmd, (void*)SBSOP_MIN },
{ "mul", bopCmd, (void*)SBSOP_MUL },
{ "not", notCmd, 0 },
{ "or", bopCmd, (void*)SBSOP_OR },
{ "puts", putsCmd, 0 },
{ "set", setCmd, 0 },
{ "sub", bopCmd, (void*)SBSOP_SUB },
{ "wiki", wikiCmd, 0, },
};
/*
** Compare a zero-terminated string zPattern against
** an unterminated string zStr of length nStr.
**
|
| ︙ | ︙ | |||
858 859 860 861 862 863 864 865 866 867 868 869 870 871 |
break;
}else if( c>0 ){
upr = i-1;
}else{
lwr = i+1;
}
}
}else if( pVal->flags & SBSVAL_VERB ){
rc = pVal->u.verb.xVerb(p, pVal->u.verb.pArg);
}else if( pVal->flags & SBSVAL_EXEC ){
rc = SbS_Eval(p, pVal->u.str.z, pVal->u.str.size);
}else{
rc = SbS_Push(p, pVal->u.str.z, pVal->u.str.size, 0);
}
| > > > | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
break;
}else if( c>0 ){
upr = i-1;
}else{
lwr = i+1;
}
}
if( upr<lwr ){
SbS_SetErrorMessage(p, "unknown verb: %.*s", n, zScript);
}
}else if( pVal->flags & SBSVAL_VERB ){
rc = pVal->u.verb.xVerb(p, pVal->u.verb.pArg);
}else if( pVal->flags & SBSVAL_EXEC ){
rc = SbS_Eval(p, pVal->u.str.z, pVal->u.str.size);
}else{
rc = SbS_Push(p, pVal->u.str.z, pVal->u.str.size, 0);
}
|
| ︙ | ︙ | |||
885 886 887 888 889 890 891 |
** stdout or into CGI.
*/
int SbS_Render(struct Subscript *p, const char *z){
int i = 0;
int rc = SBS_OK;
while( z[i] ){
if( z[i]=='[' ){
| < < | < < < < < | > > | | | | < | 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 |
** stdout or into CGI.
*/
int SbS_Render(struct Subscript *p, const char *z){
int i = 0;
int rc = SBS_OK;
while( z[i] ){
if( z[i]=='[' ){
sendText(z, i);
z += i+1;
for(i=0; z[i] && z[i]!=']'; i++){}
rc = SbS_Eval(p, z, i);
if( rc!=SBS_OK ) break;
if( z[i] ) i++;
z += i;
i = 0;
}else{
i++;
}
}
if( rc==SBS_ERROR ){
sendText("<hr><p><font color=\"red\"><b>ERROR: ", -1);
sendText(SbS_GetErrorMessage(p), -1);
sendText("</b></font></p>", -1);
}else{
sendText(z, i);
}
return rc;
}
/*
** COMMAND: test-subscript
*/
void test_subscript(void){
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** This file contains code used render and control ticket entry ** and display pages. */ | < | | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This file contains code used render and control ticket entry
** and display pages.
*/
#include "config.h"
#include "tkt.h"
#include <assert.h>
/*
** The list of database user-defined fields in the TICKET table.
** The real table also contains some addition fields for internal
** used. The internal-use fields begin with "tkt_".
*/
static int nField = 0;
static char **azField = 0;
/*
** A subscript interpreter used for processing Tickets.
*/
static struct Subscript *pInterp = 0;
/*
** Compare two entries in azField for sorting purposes
*/
static int nameCmpr(const void *a, const void *b){
return strcmp(*(char**)a, *(char**)b);
}
/*
** Obtain a list of all fields of the TICKET table. Put them
** in sorted order.
*/
static void getAllTicketFields(void){
|
| ︙ | ︙ | |||
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
static int isTicketField(const char *zField){
int i;
for(i=0; i<nField; i++){
if( strcmp(azField[i], zField)==0 ) return 1;
}
return 0;
}
/*
** Update an entry of the TICKET table according to the information
** in the control file given in p. Attempt to create the appropriate
** TICKET table entry if createFlag is true. If createFlag is false,
** that means we already know the entry exists and so we can save the
** work of trying to create it.
*/
void ticket_insert(Manifest *p, int createFlag, int checkTime){
Blob sql;
Stmt q;
int i;
if( createFlag ){
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > | > > > > > > > > > > > | | | | | | | | | | > | | > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 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 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
static int isTicketField(const char *zField){
int i;
for(i=0; i<nField; i++){
if( strcmp(azField[i], zField)==0 ) return 1;
}
return 0;
}
/*
** Query the database for all TICKET fields for the specific
** ticket whose name is given by the "name" CGI parameter.
** Load the values for all fields into the interpreter.
*/
static void initializeVariablesFromDb(void){
const char *zName;
Stmt q;
int i, n;
zName = PD("name","");
db_prepare(&q, "SELECT * FROM ticket WHERE tkt_uuid GLOB '%q*'", zName);
if( db_step(&q)==SQLITE_ROW ){
n = db_column_count(&q);
for(i=0; i<n; i++){
const char *zVal = db_column_text(&q, i);
if( zVal==0 ) zVal = "";
SbS_Store(pInterp, db_column_name(&q,i), zVal, 1);
}
}else{
db_finalize(&q);
db_prepare(&q, "PRAGMA table_info(ticket)");
while( db_step(&q)==SQLITE_ROW ){
const char *zField = db_column_text(&q, 1);
SbS_Store(pInterp, zField, "", 0);
}
}
db_finalize(&q);
}
/*
** Transfer all CGI parameters to variables in the interpreter.
*/
static void initializeVariablesFromCGI(void){
int i;
const char *z;
for(i=0; (z = cgi_parameter_name(i))!=0; i++){
SbS_Store(pInterp, z, P(z), 0);
}
}
/*
** Rebuild all tickets named in the _pending_ticket table.
**
** This routine is called just prior to commit after new
** out-of-sequence ticket changes have been added.
*/
static int ticket_rebuild_at_commit(void){
Stmt q;
db_multi_exec(
"DELETE FROM ticket WHERE tkt_uuid IN _pending_ticket"
);
db_prepare(&q, "SELECT uuid FROM _pending_ticket");
while( db_step(&q)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q, 0);
ticket_rebuild_entry(zUuid);
}
db_multi_exec(
"DELETE FROM _pending_ticket"
);
return 0;
}
/*
** Update an entry of the TICKET table according to the information
** in the control file given in p. Attempt to create the appropriate
** TICKET table entry if createFlag is true. If createFlag is false,
** that means we already know the entry exists and so we can save the
** work of trying to create it.
*/
void ticket_insert(Manifest *p, int createFlag, int checkTime){
Blob sql;
Stmt q;
int i;
const char *zSep;
getAllTicketFields();
if( createFlag ){
db_multi_exec("INSERT OR IGNORE INTO ticket(tkt_uuid, tkt_mtime) "
"VALUES(%Q, 0)", p->zTicketUuid);
}
blob_zero(&sql);
blob_appendf(&sql, "UPDATE ticket SET tkt_mtime=:mtime");
zSep = "SET";
for(i=0; i<p->nField; i++){
const char *zName = p->aField[i].zName;
if( zName[0]=='+' ){
zName++;
if( !isTicketField(zName) ) continue;
blob_appendf(&sql,", %s=%s || %Q", zName, zName, p->aField[i].zValue);
}else{
if( !isTicketField(zName) ) continue;
blob_appendf(&sql,", %s=%Q", zName, p->aField[i].zValue);
}
}
blob_appendf(&sql, " WHERE tkt_uuid='%s' AND tkt_mtime<:mtime",
p->zTicketUuid);
db_prepare(&q, "%s", blob_str(&sql));
db_bind_double(&q, ":mtime", p->rDate);
db_step(&q);
db_finalize(&q);
if( checkTime && db_changes()==0 ){
static int isInit = 0;
if( !isInit ){
db_multi_exec("CREATE TEMP TABLE _pending_ticket(uuid TEXT UNIQUE)");
db_commit_hook(ticket_rebuild_at_commit, 1);
isInit = 1;
}
db_multi_exec("INSERT OR IGNORE INTO _pending_ticket"
"VALUES(%Q)", p->zTicketUuid);
}
blob_reset(&sql);
}
/*
** Rebuild an entire entry in the TICKET table
*/
void ticket_rebuild_entry(const char *zTktUuid){
char *zTag = mprintf("tkt-%s", zTktUuid);
int tagid = tag_findid(zTag, 1);
Stmt q;
Manifest manifest;
Blob content;
int createFlag = 1;
db_multi_exec(
"DELETE FROM ticket WHERE tkt_uuid=%Q", zTktUuid
);
db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid);
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
content_get(rid, &content);
manifest_parse(&manifest, &content);
ticket_insert(&manifest, createFlag, 0);
manifest_clear(&manifest);
createFlag = 0;
}
db_finalize(&q);
}
/*
** Create the subscript interpreter and load the ticket configuration.
*/
void ticket_init(void){
char *zConfig;
if( pInterp ) return;
pInterp = SbS_Create();
zConfig = db_text((char*)zDefaultTicketConfig,
"SELECT value FROM config WHERE name='ticket-configuration'");
SbS_Eval(pInterp, zConfig, -1);
}
/*
** Recreate the ticket table.
*/
void ticket_create_table(int separateConnection){
char *zSql;
int nSql;
db_multi_exec("DROP TABLE IF EXISTS ticket;");
ticket_init();
zSql = (char*)SbS_Fetch(pInterp, "ticket_sql", -1, &nSql);
if( zSql==0 ){
fossil_panic("no ticket_sql defined by ticket configuration");
}
if( separateConnection ){
zSql = mprintf("%.*s", nSql, zSql);
db_init_database(g.zRepositoryName, zSql, 0);
free(zSql);
}else{
db_multi_exec("%.*s", nSql, zSql);
}
}
/*
** Repopulate the ticket table
*/
void ticket_rebuild(void){
Stmt q;
db_begin_transaction();
db_prepare(&q,"SELECT tagname FROM tag WHERE tagname GLOB 'tkt-*'");
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
int len;
zName += 4;
len = strlen(zName);
if( len<20 || !validate16(zName, len) ) continue;
ticket_rebuild_entry(zName);
}
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();
}
/*
** Subscript command: LABEL submit_new_ticket
**
** If the variable named LABEL exists, then submit a new ticket
** based on the values of other defined variables.
*/
static int submitNewCmd(struct Subscript *p, void *pNotify){
const char *zLabel;
int nLabel, size;
if( SbS_RequireStack(p, 1, "submit_new_ticket") ) return 1;
zLabel = SbS_StackValue(p, 0, &nLabel);
if( SbS_Fetch(p, zLabel, nLabel, &size)!=0 ){
char *zDate, *zUuid;
int i;
int rid;
Blob tktchng, cksum;
(*(int*)pNotify) = 1;
blob_zero(&tktchng);
zDate = db_text(0, "SELECT datetime('now')");
zDate[10] = 'T';
blob_appendf(&tktchng, "D %s\n", zDate);
free(zDate);
for(i=0; i<nField; i++){
const char *zValue;
int nValue;
zValue = SbS_Fetch(p, azField[i], -1, &nValue);
if( zValue ){
while( nValue>0 && isspace(zValue[nValue-1]) ){ nValue--; }
blob_appendf(&tktchng, "J %s %z\n",
azField[i], fossilize(zValue,nValue));
}
}
zUuid = db_text(0, "SELECT lower(hex(randomblob(20)))");
blob_appendf(&tktchng, "K %s\n", zUuid);
(*(char**)pNotify) = zUuid;
blob_appendf(&tktchng, "U %F\n", g.zLogin ? g.zLogin : "");
md5sum_blob(&tktchng, &cksum);
blob_appendf(&tktchng, "Z %b\n", &cksum);
#if 0
@ <hr><pre>
@ %h(blob_str(&tktchng))
@ </pre><hr>
blob_zero(&tktchng)
SbS_Pop(p, 1);
return SBS_OK;
#endif
rid = content_put(&tktchng, 0, 0);
if( rid==0 ){
fossil_panic("trouble committing ticket: %s", g.zErrMsg);
}
manifest_crosslink(rid, &tktchng);
return SBS_RETURN;
}
SbS_Pop(p, 1);
return SBS_OK;
}
/*
** WEBPAGE: tktnew
*/
void tktnew_page(void){
char *zScript;
int nScript;
char *zNewUuid = 0;
login_check_credentials();
if( !g.okNewTkt ){ login_needed(); return; }
style_header("New Ticket");
ticket_init();
getAllTicketFields();
initializeVariablesFromCGI();
@ <form method="POST" action="%s(g.zBaseURL)/tktnew">
zScript = (char*)SbS_Fetch(pInterp, "tktnew_template", -1, &nScript);
zScript = mprintf("%.*s", nScript, zScript);
SbS_AddVerb(pInterp, "submit_new_ticket", submitNewCmd, (void*)&zNewUuid);
if( SbS_Render(pInterp, zScript)==SBS_RETURN && zNewUuid ){
cgi_redirect(mprintf("%s/tktview/%s", g.zBaseURL, zNewUuid));
return;
}
@ </form>
style_footer();
}
|
Deleted src/tktconf.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/tktconfig.c.
| ︙ | ︙ | |||
101 102 103 104 105 106 107 |
@ # Every ticket configuration *must* define a set of columns for the
@ # "ticket" table of the database. These column names will also be
@ # used as CGI parameter names, so to avoid problems it is best that
@ # the names be all lower-case alphabetic characters. The names must
@ # be unique and must not begin with "tkt_".
@ #
@ {
| < < < < < < < < < < | < > > | > > > > > > > > | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
@ # Every ticket configuration *must* define a set of columns for the
@ # "ticket" table of the database. These column names will also be
@ # used as CGI parameter names, so to avoid problems it is best that
@ # the names be all lower-case alphabetic characters. The names must
@ # be unique and must not begin with "tkt_".
@ #
@ {
@ CREATE TABLE ticket(
@ -- Do not change any column that begins with tkt_
@ tkt_id INTEGER PRIMARY KEY,
@ tkt_uuid TEXT,
@ tkt_mtime DATE,
@ -- Add as many field as required below this line
@ type TEXT,
@ status TEXT,
@ subsystem TEXT,
@ priority TEXT,
@ severity TEXT,
@ foundin TEXT,
@ contact TEXT,
@ title TEXT,
@ comment TEXT,
@ -- Do not alter this UNIQUE clause:
@ UNIQUE(tkt_uuid, tkt_mtime)
@ );
@ -- Add indices as desired
@ } /ticket_sql set
@
@ ############################################################################
@ # You can define additional variables here. These variables will be
@ # accessible to the page templates when they run.
@ #
@ {
@ Code_Defect
@ Build_Problem
@ Documentation
@ Feature_Request
@ Incident
@ } /type_choices set
@ {Immediate High Medium Low Zero} /priority_choices set
@ {Critical Severe Important Minor Cosmetic} /severity_choices set
@ {
@ Open
@ Fixed
@ Rejected
@ Unable_To_Reproduce
@ Works_As_Designed
|
| ︙ | ︙ | |||
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
@ Verified
@ In_Process
@ Deferred
@ Fixed
@ Tested
@ Closed
@ } /status_choices set
@
@ ##########################################################################
@ # The "tktnew_template" variable is set to text which is a template for
@ # the HTML of the "New Ticket" page. Within this template, text contained
@ # within [...] is subscript. That subscript runs when the page is
@ # rendered.
@ #
@ {
@ <!-- load database field names not found in CGI with an empty string -->
@ <!-- start a form -->
@ [{Open} /status set /submit submit_new_ticket]
@ <table cellpadding="5">
@ <tr>
| > | | | | | > > > > > > > > | > | < | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
@ Verified
@ In_Process
@ Deferred
@ Fixed
@ Tested
@ Closed
@ } /status_choices set
@ {} /subsystem_choices set
@
@ ##########################################################################
@ # The "tktnew_template" variable is set to text which is a template for
@ # the HTML of the "New Ticket" page. Within this template, text contained
@ # within [...] is subscript. That subscript runs when the page is
@ # rendered.
@ #
@ {
@ <!-- load database field names not found in CGI with an empty string -->
@ <!-- start a form -->
@ [{Open} /status set /submit submit_new_ticket]
@ <table cellpadding="5">
@ <tr>
@ <td colspan="2">
@ Enter a one-line summary of the problem:<br>
@ <input type="text" name="title" size="60" value="[{} /title get html]">
@ </td>
@ </tr>
@
@ <tr>
@ <td align="right">Type:
@ [/type type_choices 1 combobox]
@ </td>
@ <td>What type of ticket is this?</td>
@ </tr>
@
@ <tr>
@ <td align="right">Version:
@ <input type="text" name="foundin" size="20" value="[{} /foundin get html]">
@ </td>
@ <td>In what version or build number do you observer the problem?</td>
@ </tr>
@
@ <tr>
@ <td align="right">Severity:
@ [/severity severity_choices 1 combobox]
@ </td>
@ <td>How debilitating is the problem? How badly does the problem
@ effect the operation of the product?</td>
@ </tr>
@
@ <tr>
@ <td align="right">EMail:
@ [/severity severity_choices 1 combobox]
@ </td>
@ <td>Not publically visible. Used by developers to contact you with
@ questions.</td>
@ </tr>
@
@ <tr>
@ <td colspan="2">
@ Enter a detailed description of the problem.
@ For code defects, be sure to provide details on exactly how
@ the problem can be reproduced. Provide as much detail as
@ possible.
@ <br>
@ <textarea name="comment" cols="80"
@ rows="[{} /comment linecount 50 max 10 min]"
@ wrap="virtual" class="wikiedit">[{} /comment get html]</textarea><br>
@ <input type="submit" name="preview" value="Preview">
@ </tr>
@
@ [/preview exists enable_output]
@ <tr><td colspan="2">
@ Description Preview:<br><hr>
@ [{} /comment get wiki]
@ <hr>
@ </td></tr>
@ [1 enable_output]
@
@ <tr>
@ <td align="right">
@ <input type="submit" name="submit" value="Submit">
|
| ︙ | ︙ | |||
244 245 246 247 248 249 250 | @ /cmappnd /comment append_remark] @ [/submit submit_ticket_change] @ <table cellpadding="5"> @ <tr><td align="right">Title:</td><td> @ <input type="text" name="title" value="[title html] size=60"> @ </td></tr> @ <tr><td align="right">Status:</td><td> | | | | | | | | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | @ /cmappnd /comment append_remark] @ [/submit submit_ticket_change] @ <table cellpadding="5"> @ <tr><td align="right">Title:</td><td> @ <input type="text" name="title" value="[title html] size=60"> @ </td></tr> @ <tr><td align="right">Status:</td><td> @ [/status status_choices 1 combobox] @ </td></tr> @ <tr><td align="right">Type:</td><td> @ [/type type_choices 1 combobox] @ </td></tr> @ <tr><td align="right">Severity:</td><td> @ [/severity severity_choices 1 combobox] @ </td></tr> @ <tr><td align="right">Priority:</td><td> @ [/priority priority_choices 1 combobox] @ </td></tr> @ <tr><td align="right">Resolution:</td><td> @ [/resolution resolution_choices 1 combobox] @ </td></tr> @ <tr><td align="right">Subsystem:</td><td> @ [/subsystem subsystem_choices 1 combobox] @ </td></tr> @ [/e hascap enable_output] @ <tr><td align="right">Contact:</td><td> @ <input type="text" name="contact" size="40" value="[contact html]"> @ </td></tr> @ [1 enable_output] @ <tr><td align="right">Version Found In:</td><td> |
| ︙ | ︙ | |||
301 302 303 304 305 306 307 |
@
@ ##########################################################################
@ # The template for the "view ticket" page
@ {
@ <!-- load database fields automatically loaded into variables -->
@ <table cellpadding="5">
@ <tr><td align="right">Title:</td><td>
| | | | | | | | | | | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
@
@ ##########################################################################
@ # The template for the "view ticket" page
@ {
@ <!-- load database fields automatically loaded into variables -->
@ <table cellpadding="5">
@ <tr><td align="right">Title:</td><td>
@ [title html]
@ </td></tr>
@ <tr><td align="right">Status:</td><td>
@ [status html]
@ </td></tr>
@ <tr><td align="right">Type:</td><td>
@ [type html]
@ </td></tr>
@ <tr><td align="right">Severity:</td><td>
@ [severity html]
@ </td></tr>
@ <tr><td align="right">Priority:</td><td>
@ [priority html]
@ </td></tr>
@ <tr><td align="right">Resolution:</td><td>
@ [priority html]
@ </td></tr>
@ <tr><td align="right">Subsystem:</td><td>
@ [subsystem html]
@ </td></tr>
@ [{e} hascap enable_output]
@ <tr><td align="right">Contact:</td><td>
@ [contact html]
@ </td></tr>
@ [1 enable_output]
@ <tr><td align="right">Version Found In:</td><td>
@ [foundin html]
@ </td></tr>
@ <tr><td colspan="2">
@ Description And Comments:<br>
@ [comment wiki]
@ </td></tr>
@ </table>
@ } /tktview_template set
;
|