Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the ability to specify a description for each ticket report format. The user and reportfmt tables are updated with a new jx column containing JSON that describes the new features. (The user.jx table is currently not used but it was convenient to add it at the same time.) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
fcf17b28a902c01bccc41f044381073b |
User & Date: | drh 2022-11-18 19:28:35 |
References
2022-11-20
| ||
01:58 | Do not attempt to render empty description of a report. Also make hyperlinks in a report's submenu more robust. This amends [fcf17b28a902c0]. ... (check-in: 04a01d06 user: george tags: trunk) | |
Context
2022-11-18
| ||
19:30 | Fix a potentially uninitialized variable associated with the resent ticket report changes. ... (check-in: d296ddb2 user: drh tags: trunk) | |
19:28 | Add the ability to specify a description for each ticket report format. The user and reportfmt tables are updated with a new jx column containing JSON that describes the new features. (The user.jx table is currently not used but it was convenient to add it at the same time.) ... (check-in: fcf17b28 user: drh tags: trunk) | |
19:23 | Make sure the reportfmt table contains the jx column before trying to use that column. ... (Leaf check-in: d4332725 user: drh tags: json-meta-data) | |
2022-11-17
| ||
07:45 | Increase the version number to 2.21 to start the next development cycle. ... (check-in: 8dcee008 user: danield tags: trunk) | |
Changes
Changes to src/configure.c.
︙ | ︙ | |||
355 356 357 358 359 360 361 | ** In overview, we have: ** ** NAME CONTENT ** ------- ----------------------------------------------------------- ** /config $MTIME $NAME value $VALUE ** /user $MTIME $LOGIN pw $VALUE cap $VALUE info $VALUE photo $VALUE ** /shun $MTIME $UUID scom $VALUE | | | | | | | | | 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 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | ** In overview, we have: ** ** NAME CONTENT ** ------- ----------------------------------------------------------- ** /config $MTIME $NAME value $VALUE ** /user $MTIME $LOGIN pw $VALUE cap $VALUE info $VALUE photo $VALUE ** /shun $MTIME $UUID scom $VALUE ** /reportfmt $MTIME $TITLE owner $VALUE cols $VALUE sqlcode $VALUE jx $JSON ** /concealed $MTIME $HASH content $VALUE ** /subscriber $SMTIME $SEMAIL suname $V ... */ void configure_receive(const char *zName, Blob *pContent, int groupMask){ int checkMask; /* Masks for which we must first check existance of tables */ checkMask = CONFIGSET_SCRIBER; if( zName[0]=='/' ){ /* The new format */ char *azToken[24]; int nToken = 0; int ii, jj; int thisMask; Blob name, value, sql; static const struct receiveType { const char *zName; /* Configuration key for this table */ const char *zPrimKey; /* Primary key column */ int nField; /* Number of data fields */ const char *azField[6]; /* Names of the data fields */ } aType[] = { { "/config", "name", 1, { "value", 0,0,0,0,0 } }, { "@user", "login", 5, { "pw","cap","info","photo","jx",0} }, { "@shun", "uuid", 1, { "scom", 0,0,0,0,0} }, { "@reportfmt", "title", 4, { "owner","cols","sqlcode","jx",0,0}}, { "@concealed", "hash", 1, { "content", 0,0,0,0,0 } }, { "@subscriber","semail",6, { "suname","sdigest","sdonotcall","ssub","sctime","smip"} }, }; /* Locate the receiveType in aType[ii] */ for(ii=0; ii<count(aType); ii++){ if( fossil_strcmp(&aType[ii].zName[1],&zName[1])==0 ) break; } if( ii>=count(aType) ) return; |
︙ | ︙ | |||
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | } blob_append_sql(&sql,") VALUES(%s,%s", azToken[1] /*safe-for-%s*/, azToken[0]/*safe-for-%s*/); for(jj=2; jj<nToken; jj+=2){ blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/); } db_protect_only(PROTECT_SENSITIVE); db_multi_exec("%s)", blob_sql_text(&sql)); if( db_changes()==0 ){ blob_reset(&sql); blob_append_sql(&sql, "UPDATE \"%w\" SET mtime=%s", &zName[1], azToken[0]/*safe-for-%s*/); for(jj=2; jj<nToken; jj+=2){ blob_append_sql(&sql, ", \"%w\"=%s", azToken[jj], azToken[jj+1]/*safe-for-%s*/); | > > > > > > > > > | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | } blob_append_sql(&sql,") VALUES(%s,%s", azToken[1] /*safe-for-%s*/, azToken[0]/*safe-for-%s*/); for(jj=2; jj<nToken; jj+=2){ blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/); } db_protect_only(PROTECT_SENSITIVE); /* Make sure tables have the "jx" column */ if( strcmp(&zName[1],"user")==0 ){ user_update_user_table(); }else if( strcmp(&zName[1],"reportfmt")==0 ){ report_update_reportfmt_table(); } db_multi_exec("%s)", blob_sql_text(&sql)); if( db_changes()==0 ){ blob_reset(&sql); blob_append_sql(&sql, "UPDATE \"%w\" SET mtime=%s", &zName[1], azToken[0]/*safe-for-%s*/); for(jj=2; jj<nToken; jj+=2){ blob_append_sql(&sql, ", \"%w\"=%s", azToken[jj], azToken[jj+1]/*safe-for-%s*/); |
︙ | ︙ | |||
530 531 532 533 534 535 536 | blob_size(&rec), blob_str(&rec)); nCard++; blob_reset(&rec); } db_finalize(&q); } if( groupMask & CONFIGSET_USER ){ | > | | | > > > > > < > | | > | > | > | > | < > > | > > > > | | > < > | | > | > | > | < > | 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 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | blob_size(&rec), blob_str(&rec)); nCard++; blob_reset(&rec); } db_finalize(&q); } if( groupMask & CONFIGSET_USER ){ if( db_table_has_column("repository","user","jx") ){ db_prepare(&q, "SELECT mtime, quote(login), quote(pw), quote(cap)," " quote(info), quote(photo), quote(jx) FROM user" " WHERE mtime>=%lld", iStart); }else{ db_prepare(&q, "SELECT mtime, quote(login), quote(pw), quote(cap)," " quote(info), quote(photo), 'NULL' FROM user" " WHERE mtime>=%lld", iStart); } while( db_step(&q)==SQLITE_ROW ){ const char *z; blob_appendf(&rec,"%s %s", db_column_text(&q,0), db_column_text(&q,1)); z = db_column_text(&q,2); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," pw %s", z); z = db_column_text(&q,3); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," cap %s", z); z = db_column_text(&q,4); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," info %s", z); z = db_column_text(&q,5); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," photo %s", z); z = db_column_text(&q,6); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," jx %s", z); blob_appendf(pOut, "config /user %d\n%s\n", blob_size(&rec), blob_str(&rec)); nCard++; blob_reset(&rec); } db_finalize(&q); } if( groupMask & CONFIGSET_TKT ){ if( db_table_has_column("repository","reportfmt","jx") ){ db_prepare(&q, "SELECT mtime, quote(title), quote(owner), quote(cols)," " quote(sqlcode), quote(jx) FROM reportfmt" " WHERE mtime>=%lld", iStart); }else{ db_prepare(&q, "SELECT mtime, quote(title), quote(owner), quote(cols)," " quote(sqlcode), 'NULL' FROM reportfmt" " WHERE mtime>=%lld", iStart); } while( db_step(&q)==SQLITE_ROW ){ const char *z; blob_appendf(&rec,"%s %s", db_column_text(&q,0), db_column_text(&q,1)); z = db_column_text(&q,2); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," owner %s", z); z = db_column_text(&q,3); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," cols %s", z); z = db_column_text(&q,4); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," sqlcode %s", z); z = db_column_text(&q,5); if( strcmp(z,"NULL")!=0 ) blob_appendf(&rec," jx %s", z); blob_appendf(pOut, "config /reportfmt %d\n%s\n", blob_size(&rec), blob_str(&rec)); nCard++; blob_reset(&rec); } db_finalize(&q); } |
︙ | ︙ |
Changes to src/event.c.
︙ | ︙ | |||
550 551 552 553 554 555 556 | @ <td valign="top"> @ <input type="text" name="g" size="40" value="%h(zTags)" /> @ </td></tr> @ <tr><th align="right" valign="top">\ @ %z(href("%R/markup_help"))Markup Style</a>:</th> @ <td valign="top"> | | | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | @ <td valign="top"> @ <input type="text" name="g" size="40" value="%h(zTags)" /> @ </td></tr> @ <tr><th align="right" valign="top">\ @ %z(href("%R/markup_help"))Markup Style</a>:</th> @ <td valign="top"> mimetype_option_menu(zMimetype, "mimetype"); @ </td></tr> @ <tr><th align="right" valign="top">Page Content:</th> @ <td valign="top"> @ <textarea name="w" class="technoteedit" cols="80" @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea> @ </td></tr> |
︙ | ︙ |
Changes to src/forum.c.
︙ | ︙ | |||
1057 1058 1059 1060 1061 1062 1063 | const char *zContent ){ if( zTitle ){ @ Title: <input type="input" name="title" value="%h(zTitle)" size="50" @ maxlength="125"><br> } @ %z(href("%R/markup_help"))Markup style</a>: | | | 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 | const char *zContent ){ if( zTitle ){ @ Title: <input type="input" name="title" value="%h(zTitle)" size="50" @ maxlength="125"><br> } @ %z(href("%R/markup_help"))Markup style</a>: mimetype_option_menu(zMimetype, "mimetype"); @ <br><textarea aria-label="Content:" name="content" class="wikiedit" \ @ cols="80" rows="25" wrap="virtual">%h(zContent)</textarea><br> } /* ** WEBPAGE: forumnew ** WEBPAGE: forumedit |
︙ | ︙ |
Changes to src/report.c.
︙ | ︙ | |||
73 74 75 76 77 78 79 | } rn = db_column_int(&q, 0); cnt++; blob_appendf(&ril, "<li>"); if( zTitle[0] == '_' ){ blob_appendf(&ril, "%s", zTitle); } else { | | | | | | 73 74 75 76 77 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 | } rn = db_column_int(&q, 0); cnt++; blob_appendf(&ril, "<li>"); if( zTitle[0] == '_' ){ blob_appendf(&ril, "%s", zTitle); } else { blob_appendf(&ril, "%z%h</a>", href("%R/rptview/%d", rn), zTitle); } blob_appendf(&ril, " "); if( g.perm.Write && zOwner && zOwner[0] ){ blob_appendf(&ril, "(by <i>%h</i>) ", zOwner); } if( g.perm.TktFmt ){ blob_appendf(&ril, "[%zcopy</a>] ", href("%R/rptedit/%d?copy=1", rn)); } if( g.perm.Admin || (g.perm.WrTkt && zOwner && fossil_strcmp(g.zLogin,zOwner)==0) ){ blob_appendf(&ril, "[%zedit</a>]", href("%R/rptedit/%d", rn)); } if( g.perm.TktFmt ){ blob_appendf(&ril, "[%zsql</a>]", href("%R/rptsql/%d", rn)); } if( fossil_strcmp(zTitle, defaultReport)==0 ){ blob_appendf(&ril, " ← default"); } blob_appendf(&ril, "</li>\n"); } db_finalize(&q); |
︙ | ︙ | |||
251 252 253 254 255 256 257 258 259 260 261 262 263 264 | *(char**)pError = mprintf("only SELECT statements are allowed"); rc = SQLITE_DENY; break; } } return rc; } /* ** Activate the ticket report query authorizer. Must be followed by an ** eventual call to report_unrestrict_sql(). */ void report_restrict_sql(char **pzErr){ db_set_authorizer(report_query_authorizer,(void*)pzErr,"Ticket-Report"); | > > > > > > > > > > > > > > | 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 | *(char**)pError = mprintf("only SELECT statements are allowed"); rc = SQLITE_DENY; break; } } return rc; } /* ** Make sure the reportfmt table is up-to-date. It should contain ** the "jx" column (as of version 2.21). If it does not, add it. ** ** The "jx" column is intended to hold a JSON object containing optional ** key-value pairs. */ void report_update_reportfmt_table(void){ if( db_table_has_column("repository","reportfmt","jx")==0 ){ db_multi_exec("ALTER TABLE repository.reportfmt" " ADD COLUMN jx TEXT DEFAULT '{}';"); } } /* ** Activate the ticket report query authorizer. Must be followed by an ** eventual call to report_unrestrict_sql(). */ void report_restrict_sql(char **pzErr){ db_set_authorizer(report_query_authorizer,(void*)pzErr,"Ticket-Report"); |
︙ | ︙ | |||
319 320 321 322 323 324 325 326 327 328 | } if( pStmt ){ sqlite3_finalize(pStmt); } report_unrestrict_sql(); return zErr; } /* ** WEBPAGE: rptsql | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | 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 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | } if( pStmt ){ sqlite3_finalize(pStmt); } report_unrestrict_sql(); return zErr; } /* ** Get a report number from query parameters. This can be done in various ** ways: ** ** (1) (legacy) rn=NNN where NNN is the reportfmt.rn integer primary key. ** ** (2) name=NNN where NNN is the rn. ** ** (3) name=TAG where TAG matches reportfmt.jx->>tag ** ** Regardless of how the report is specified, return the primary key, rn. ** Return 0 if not found. */ static int report_number(void){ int rn; const char *zName; char *zEnd; /* Case (1) */ rn = atoi(PD("rn","0")); if( rn>0 ) return rn; zName = P("name"); if( zName==0 || zName[0]==0 ) return 0; if( fossil_isdigit(zName[0]) && (rn = strtol(zName, &zEnd, 10))>0 && zEnd[0]==0 ){ /* Case 2 */ return rn; } rn = db_int(0, "SELECT rn FROM reportfmt WHERE jx->>'tag'==%Q", zName); return rn; } /* ** WEBPAGE: rptsql ** URL: /rptsql/N ** ** Display the SQL query used to generate a ticket report. The N value ** is either the report number of a report tag. */ void view_see_sql(void){ int rn; const char *zTitle; const char *zSQL; const char *zOwner; const char *zClrKey; Stmt q; login_check_credentials(); if( !g.perm.TktFmt ){ login_needed(g.anon.TktFmt); return; } rn = report_number(); db_prepare(&q, "SELECT title, sqlcode, owner, cols " "FROM reportfmt WHERE rn=%d",rn); style_set_current_feature("report"); style_header("SQL For Report Format Number %d", rn); if( db_step(&q)!=SQLITE_ROW ){ @ <p>Unknown report number: %d(rn)</p> style_finish_page(); |
︙ | ︙ | |||
380 381 382 383 384 385 386 | /* ** WEBPAGE: rptnew ** WEBPAGE: rptedit ** ** Create (/rptnew) or edit (/rptedit) a ticket report format. ** Query parameters: ** | > | > > > > | | | | | > > > | > > > > | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | /* ** WEBPAGE: rptnew ** WEBPAGE: rptedit ** ** Create (/rptnew) or edit (/rptedit) a ticket report format. ** Query parameters: ** ** name=N Ticket report number or tag. ** rn=N Ticket report number (legacy). ** ^^^-- one of the two previous is required. ** t=TITLE Title of the report format ** w=USER Owner of the report format ** s=SQL SQL text used to implement the report ** k=KEY Color key ** d=DESC Optional descriptive text ** m=MIMETYPE Mimetype for DESC ** x=TAG Symbolic name for the report */ void view_edit(void){ int rn; const char *zTitle; /* Title of the report */ const char *z; const char *zOwner; /* Owner of the report */ const char *zClrKey; /* Color key - used to add colors to lines */ char *zSQL; /* The SQL text that gnerates the report */ char *zErr = 0; /* An error message */ const char *zDesc; /* Extra descriptive text about the report */ const char *zMimetype; /* Mimetype for zDesc */ const char *zTag; /* Symbolic name for this report */ int dflt = P("dflt") ? 1 : 0; login_check_credentials(); if( !g.perm.TktFmt ){ login_needed(g.anon.TktFmt); return; } style_set_current_feature("report"); /*view_add_functions(0);*/ rn = report_number(); zTitle = P("t"); zOwner = PD("w",g.zLogin); z = P("s"); zSQL = z ? trim_string(z) : 0; zClrKey = trim_string(PD("k","")); zDesc = trim_string(PD("d","")); zMimetype = P("m"); zTag = P("x"); report_update_reportfmt_table(); if( rn>0 && P("del2") ){ login_verify_csrf_secret(); db_multi_exec("DELETE FROM reportfmt WHERE rn=%d", rn); cgi_redirect("reportlist"); return; }else if( rn>0 && P("del1") ){ zTitle = db_text(0, "SELECT title FROM reportfmt " |
︙ | ︙ | |||
454 455 456 457 458 459 460 461 | && db_exists("SELECT 1 FROM reportfmt WHERE title=%Q and rn<>%d", zTitle, rn) ){ zErr = mprintf("There is already another report named \"%h\"", zTitle); } if( zErr==0 ){ login_verify_csrf_secret(); if( rn>0 ){ | > > > > | | > > | > | | > | | > > > > | > > > > > > > > > > > | > > > > > > > > > > > > > > | 516 517 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 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | && db_exists("SELECT 1 FROM reportfmt WHERE title=%Q and rn<>%d", zTitle, rn) ){ zErr = mprintf("There is already another report named \"%h\"", zTitle); } if( zErr==0 ){ login_verify_csrf_secret(); if( zTag && zTag[0]==0 ) zTag = 0; if( zDesc && zDesc[0]==0 ){ zDesc = 0; zMimetype = 0; } if( zMimetype && zMimetype[0]==0 ){ zDesc = 0; zMimetype = 0; } if( rn>0 ){ db_multi_exec( "UPDATE reportfmt SET title=%Q, sqlcode=%Q," " owner=%Q, cols=%Q, mtime=now(), " " jx=json_patch(jx,json_object('desc',%Q,'descmt',%Q,'tag',%Q))" " WHERE rn=%d", zTitle, zSQL, zOwner, zClrKey, zDesc, zMimetype, zTag, rn); }else{ db_multi_exec( "INSERT INTO reportfmt(title,sqlcode,owner,cols,mtime,jx) " "VALUES(%Q,%Q,%Q,%Q,now()," "json_object('desc',%Q,'descmt',%Q,'tag',%Q))", zTitle, zSQL, zOwner, zClrKey, zDesc, zMimetype, zTag); rn = db_last_insert_rowid(); } if( dflt ){ db_set("ticket-default-report", zTitle, 0); }else{ char *defaultReport = db_get("ticket-default-report", 0); if( fossil_strcmp(zTitle, defaultReport)==0 ){ db_set("ticket-default-report", "", 0); } } cgi_redirect(mprintf("rptview/%d", rn)); return; } }else if( rn==0 ){ zTitle = ""; zSQL = ticket_report_template(); zClrKey = ticket_key_template(); }else{ Stmt q; int hasJx; zDesc = 0; zMimetype = 0; zTag = 0; db_prepare(&q, "SELECT title, sqlcode, owner, cols, json_valid(jx) " "FROM reportfmt WHERE rn=%d",rn); if( db_step(&q)==SQLITE_ROW ){ char *defaultReport = db_get("ticket-default-report", 0); zTitle = db_column_malloc(&q, 0); zSQL = db_column_malloc(&q, 1); zOwner = db_column_malloc(&q, 2); zClrKey = db_column_malloc(&q, 3); dflt = fossil_strcmp(zTitle, defaultReport)==0; hasJx = db_column_int(&q, 4); } db_finalize(&q); if( hasJx ){ db_prepare(&q, "SELECT jx->>'desc', jx->>'descmt', jx->>'tag'" " FROM reportfmt WHERE rn=%d", rn); if( db_step(&q)==SQLITE_ROW ){ zDesc = db_column_malloc(&q, 0); zMimetype = db_column_malloc(&q, 1); zTag = db_column_malloc(&q, 2); } db_finalize(&q); } if( P("copy") ){ rn = 0; zTitle = mprintf("Copy Of %s", zTitle); zOwner = g.zLogin; } } if( zOwner==0 ) zOwner = g.zLogin; style_submenu_element("Cancel", "reportlist"); if( rn>0 ){ style_submenu_element("Delete", "rptedit/%d?del1=1", rn); } style_header("%s", rn>0 ? "Edit Report Format":"Create New Report Format"); if( zErr ){ @ <blockquote class="reportError">%h(zErr)</blockquote> } @ <form action="rptedit" method="post"><div> @ <input type="hidden" name="rn" value="%d(rn)" /> @ <p>Report Title:<br /> @ <input type="text" name="t" value="%h(zTitle)" size="60" /></p> @ <p>Enter a complete SQL query statement against the "TICKET" table:<br /> @ <textarea name="s" rows="20" cols="80">%h(zSQL)</textarea> @ </p> login_insert_csrf_secret(); if( g.perm.Admin ){ @ <p>Report owner: @ <input type="text" name="w" size="20" value="%h(zOwner)" /> @ </p> @ <p>Tag: @ <input type="text" name="x" size="20" value="%h(zTag?zTag:"")" /> @ </p> } else { @ <input type="hidden" name="w" value="%h(zOwner)" /> if( zTag && zTag[0] ){ @ <input type="hidden" name="x" value="%h(zTag)" /> } } @ <p>Enter an optional color key in the following box. (If blank, no @ color key is displayed.) Each line contains the text for a single @ entry in the key. The first token of each line is the background @ color for that line.<br /> @ <textarea name="k" rows="8" cols="50">%h(zClrKey)</textarea> @ </p> @ <p>Optional human-readable description for this report<br /> @ %z(href("%R/markup_help"))Markup style</a>: mimetype_option_menu(zMimetype, "m"); @ <br><textarea aria-label="Description:" name="d" class="wikiedit" \ @ cols="80" rows="15" wrap="virtual">%h(zDesc)</textarea> @ </p> @ <p><label><input type="checkbox" name="dflt" %s(dflt?"checked":"")> \ @ Make this the default report</label></p> if( !g.perm.Admin && fossil_strcmp(zOwner,g.zLogin)!=0 ){ @ <p>This report format is owned by %h(zOwner). You are not allowed @ to change it.</p> @ </form> report_format_hints(); |
︙ | ︙ | |||
751 752 753 754 755 756 757 | pState->wikiFlags = WIKI_NOBADLINKS; pState->zWikiStart = ""; pState->zWikiEnd = ""; if( P("plaintext") ){ pState->wikiFlags |= WIKI_LINKSONLY; pState->zWikiStart = "<pre class='verbatim'>"; pState->zWikiEnd = "</pre>"; | | | | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 | pState->wikiFlags = WIKI_NOBADLINKS; pState->zWikiStart = ""; pState->zWikiEnd = ""; if( P("plaintext") ){ pState->wikiFlags |= WIKI_LINKSONLY; pState->zWikiStart = "<pre class='verbatim'>"; pState->zWikiEnd = "</pre>"; style_submenu_element("Formatted", "%R/rptview/%d", pState->rn); }else{ style_submenu_element("Plaintext", "%R/rptview/%d?plaintext", pState->rn); } }else{ pState->nCol++; } } } |
︙ | ︙ | |||
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | ){ int count = 0; int rn, rc; char *zSql; char *zTitle; char *zOwner; char *zClrKey; int tabs; Stmt q; char *zErr1 = 0; char *zErr2 = 0; | > > | > > | < > | > > > | 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 | ){ int count = 0; int rn, rc; char *zSql; char *zTitle; char *zOwner; char *zClrKey; char *zDesc; char *zMimetype; int tabs; Stmt q; char *zErr1 = 0; char *zErr2 = 0; login_check_credentials(); if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; } report_update_reportfmt_table(); rn = report_number(); tabs = P("tablist")!=0; db_prepare(&q, "SELECT title, sqlcode, owner, cols, rn, jx->>'desc', jx->>'descmt'" " FROM reportfmt WHERE rn=%d", rn); rc = db_step(&q); if( rc!=SQLITE_ROW ){ const char *titleSearch = defaultTitleSearch==0 || trim_string(defaultTitleSearch)[0]==0 ? P("title") : defaultTitleSearch; db_finalize(&q); db_prepare(&q, "SELECT title, sqlcode, owner, cols, rn, jx->>'desc', jx->>'descmt'" " FROM reportfmt WHERE title GLOB %Q", titleSearch); rc = db_step(&q); } if( rc!=SQLITE_ROW ){ db_finalize(&q); if( redirectMissing ) { cgi_redirect("reportlist"); } return; } zTitle = db_column_malloc(&q, 0); zSql = db_column_malloc(&q, 1); zOwner = db_column_malloc(&q, 2); zClrKey = db_column_malloc(&q, 3); rn = db_column_int(&q,4); zDesc = db_column_malloc(&q, 5); zMimetype = db_column_malloc(&q, 6); db_finalize(&q); if( P("order_by") ){ /* ** If the user wants to do a column sort, wrap the query into a sub ** query and then sort the results. This is a whole lot easier than ** trying to insert an ORDER BY into the query itself, especially |
︙ | ︙ | |||
1092 1093 1094 1095 1096 1097 1098 | style_submenu_element("Reports","%R/reportlist?%s",zQS); } else { style_submenu_element("Raw","%R/%s?tablist=1",g.zPath); style_submenu_element("Reports","%R/reportlist"); } if( g.perm.Admin || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){ | | | > > > > > > > | 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | style_submenu_element("Reports","%R/reportlist?%s",zQS); } else { style_submenu_element("Raw","%R/%s?tablist=1",g.zPath); style_submenu_element("Reports","%R/reportlist"); } if( g.perm.Admin || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){ style_submenu_element("Edit", "rptedit/%d", rn); } if( g.perm.TktFmt ){ style_submenu_element("SQL", "rptsql/%d",rn); } if( g.perm.NewTkt ){ style_submenu_element("New Ticket", "%R/tktnew"); } style_header("%s", zTitle); } if( zDesc && zMimetype ){ Blob src; blob_init(&src, zDesc, -1); wiki_render_by_mimetype(&src, zMimetype); blob_reset(&src); @ <p> } output_color_key(zClrKey, 1, "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\""); @ <table border="1" cellpadding="2" cellspacing="0" class="report sortable" @ data-column-types='' data-init-sort='0'> sState.rn = rn; sState.nCount = 0; |
︙ | ︙ |
Changes to src/schema.c.
︙ | ︙ | |||
124 125 126 127 128 129 130 | @ pw TEXT, -- password @ cap TEXT, -- Capabilities of this user @ cookie TEXT, -- WWW login cookie @ ipaddr TEXT, -- IP address for which cookie is valid @ cexpire DATETIME, -- Time when cookie expires @ info TEXT, -- contact information @ mtime DATE, -- last change. seconds since 1970 | | > | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | @ pw TEXT, -- password @ cap TEXT, -- Capabilities of this user @ cookie TEXT, -- WWW login cookie @ ipaddr TEXT, -- IP address for which cookie is valid @ cexpire DATETIME, -- Time when cookie expires @ info TEXT, -- contact information @ mtime DATE, -- last change. seconds since 1970 @ photo BLOB, -- JPEG image of this user @ jx TEXT DEFAULT '{}' -- Extra fields in JSON @ ); @ @ -- The config table holds miscellanous information about the repository. @ -- in the form of name-value pairs. @ -- @ CREATE TABLE config( @ name TEXT PRIMARY KEY NOT NULL, -- Primary name of the entry |
︙ | ︙ | |||
174 175 176 177 178 179 180 | @ -- @ CREATE TABLE reportfmt( @ rn INTEGER PRIMARY KEY, -- Report number @ owner TEXT, -- Owner of this report format (not used) @ title TEXT UNIQUE, -- Title of this report @ mtime DATE, -- Last modified. seconds since 1970 @ cols TEXT, -- A color-key specification | | > | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | @ -- @ CREATE TABLE reportfmt( @ rn INTEGER PRIMARY KEY, -- Report number @ owner TEXT, -- Owner of this report format (not used) @ title TEXT UNIQUE, -- Title of this report @ mtime DATE, -- Last modified. seconds since 1970 @ cols TEXT, -- A color-key specification @ sqlcode TEXT, -- An SQL SELECT statement for this report @ jx TEXT DEFAULT '{}' -- Additional fields encoded as JSON @ ); @ @ -- Some ticket content (such as the originators email address or contact @ -- information) needs to be obscured to protect privacy. This is achieved @ -- by storing an SHA1 hash of the content. For display, the hash is @ -- mapped back into the original text using this table. @ -- |
︙ | ︙ |
Changes to src/user.c.
︙ | ︙ | |||
571 572 573 574 575 576 577 578 579 580 581 582 583 584 | url_parse(0, URL_USE_CONFIG); fossil_print("URL user: %s\n", g.url.user); user_select(); fossil_print("Final g.zLogin: %s\n", g.zLogin); fossil_print("Final g.userUid: %d\n", g.userUid); } /* ** COMMAND: test-hash-passwords ** ** Usage: %fossil test-hash-passwords REPOSITORY ** ** Convert all local password storage to use a SHA1 hash of the password | > > > > > > > > > > > > > > | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | url_parse(0, URL_USE_CONFIG); fossil_print("URL user: %s\n", g.url.user); user_select(); fossil_print("Final g.zLogin: %s\n", g.zLogin); fossil_print("Final g.userUid: %d\n", g.userUid); } /* ** Make sure the USER table is up-to-date. It should contain ** the "JX" column (as of version 2.21). If it does not, add it. ** ** The "JX" column is intended to hold a JSON object containing optional ** key-value pairs. */ void user_update_user_table(void){ if( db_table_has_column("repository","user","jx")==0 ){ db_multi_exec("ALTER TABLE repository.user" " ADD COLUMN jx TEXT DEFAULT '{}';"); } } /* ** COMMAND: test-hash-passwords ** ** Usage: %fossil test-hash-passwords REPOSITORY ** ** Convert all local password storage to use a SHA1 hash of the password |
︙ | ︙ |
Changes to src/wiki.c.
︙ | ︙ | |||
644 645 646 647 648 649 650 | alert_user_contact(login_name()); } return nrid; } /* ** Output a selection box from which the user can select the | | > > > | | | 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | alert_user_contact(login_name()); } return nrid; } /* ** Output a selection box from which the user can select the ** wiki mimetype. Arguments: ** ** zMimetype - The current value of the query parameter ** zParam - The name of the query parameter */ void mimetype_option_menu(const char *zMimetype, const char *zParam){ unsigned i; @ <select name="%s(zParam)" size="1"> for(i=0; i<count(azStyles); i+=3){ if( fossil_strcmp(zMimetype,azStyles[i])==0 ){ @ <option value="%s(azStyles[i])" selected>%s(azStyles[i+1])</option> }else{ @ <option value="%s(azStyles[i])">%s(azStyles[i+1])</option> } } |
︙ | ︙ | |||
1332 1333 1334 1335 1336 1337 1338 | "data-tab-label='Editor' " "class='hidden'" ">"); CX("<div class='" "wikiedit-options flex-container flex-row child-gap-small'>"); CX("<div class='input-with-label'>" "<label>Mime type</label>"); | | | 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 | "data-tab-label='Editor' " "class='hidden'" ">"); CX("<div class='" "wikiedit-options flex-container flex-row child-gap-small'>"); CX("<div class='input-with-label'>" "<label>Mime type</label>"); mimetype_option_menu("text/x-markdown", "mimetype"); CX("</div>"); style_select_list_int("select-font-size", "editor_font_size", "Editor font size", NULL/*tooltip*/, 100, "100%", 100, "125%", 125, "150%", 150, "175%", 175, |
︙ | ︙ | |||
1533 1534 1535 1536 1537 1538 1539 | wiki_standard_submenu(W_ALL_BUT(W_NEW)); @ <p>Rules for wiki page names:</p> well_formed_wiki_name_rules(); form_begin(0, "%R/wikinew"); @ <p>Name of new wiki page: @ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br /> @ %z(href("%R/markup_help"))Markup style</a>: | | | 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 | wiki_standard_submenu(W_ALL_BUT(W_NEW)); @ <p>Rules for wiki page names:</p> well_formed_wiki_name_rules(); form_begin(0, "%R/wikinew"); @ <p>Name of new wiki page: @ <input style="width: 35;" type="text" name="name" value="%h(zName)" /><br /> @ %z(href("%R/markup_help"))Markup style</a>: mimetype_option_menu("text/x-markdown", "mimetype"); @ <br /><input type="submit" value="Create" /> @ </p></form> if( zName[0] ){ @ <p><span class="wikiError"> @ "%h(zName)" is not a valid wiki page name!</span></p> } style_finish_page(); |
︙ | ︙ |