| | @@ -28,17 +28,427 @@ |
| 28 | 28 | #include "tktsetup.h" |
| 29 | 29 | #include <assert.h> |
| 30 | 30 | |
| 31 | 31 | /* |
| 32 | 32 | ** Main sub-menu for configuring the ticketing system. |
| 33 | | -** WEBPAGE: /tktsetup |
| 33 | +** WEBPAGE: tktsetup |
| 34 | 34 | */ |
| 35 | 35 | void tktsetup_page(void){ |
| 36 | 36 | login_check_credentials(); |
| 37 | 37 | if( !g.okSetup ){ |
| 38 | 38 | login_needed(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | style_header("Ticket Setup"); |
| 42 | | - @ <i>TBD...</i> |
| 42 | + @ <table border="0" cellspacing="20"> |
| 43 | + setup_menu_entry("Table", "tktsetup_tab", |
| 44 | + "Specify the schema of the \"ticket\" table in the database."); |
| 45 | + setup_menu_entry("Common", "tktsetup_com", |
| 46 | + "Common TH1 code run before all ticket processing."); |
| 47 | + setup_menu_entry("New Ticket Page", "tktsetup_newpage", |
| 48 | + "HTML with embedded TH1 code for the \"new ticket\" webpage."); |
| 49 | + setup_menu_entry("View Ticket Page", "tktsetup_viewpage", |
| 50 | + "HTML with embedded TH1 code for the \"view ticket\" webpage."); |
| 51 | + setup_menu_entry("Edit Ticket Page", "tktsetup_editpage", |
| 52 | + "HTML with embedded TH1 code for the \"edit ticket\" webpage."); |
| 53 | + setup_menu_entry("Report Format", "tktsetup_drep", |
| 54 | + "The default ticket report format."); |
| 55 | + @ </table> |
| 56 | + style_footer(); |
| 57 | +} |
| 58 | + |
| 59 | +/* @-comment: ** */ |
| 60 | +static char zDefaultTab[] = |
| 61 | +@ CREATE TABLE ticket( |
| 62 | +@ -- Do not change any column that begins with tkt_ |
| 63 | +@ tkt_id INTEGER PRIMARY KEY, |
| 64 | +@ tkt_uuid TEXT, |
| 65 | +@ tkt_mtime DATE, |
| 66 | +@ -- Add as many field as required below this line |
| 67 | +@ type TEXT, |
| 68 | +@ status TEXT, |
| 69 | +@ subsystem TEXT, |
| 70 | +@ priority TEXT, |
| 71 | +@ severity TEXT, |
| 72 | +@ foundin TEXT, |
| 73 | +@ contact TEXT, |
| 74 | +@ resolution TEXT, |
| 75 | +@ title TEXT, |
| 76 | +@ comment TEXT, |
| 77 | +@ -- Do not alter this UNIQUE clause: |
| 78 | +@ UNIQUE(tkt_uuid, tkt_mtime) |
| 79 | +@ ); |
| 80 | +; |
| 81 | + |
| 82 | +/* |
| 83 | +** Common implementation for the ticket setup editor pages. |
| 84 | +*/ |
| 85 | +static void tktsetup_generic( |
| 86 | + const char *zTitle, /* Page title */ |
| 87 | + const char *zDbField, /* Configuration field being edited */ |
| 88 | + char *zDfltValue, /* Default text value */ |
| 89 | + const char *zDesc, /* Description of this field */ |
| 90 | + int height /* Height of the edit box */ |
| 91 | +){ |
| 92 | + const char *z; |
| 93 | + int isSubmit; |
| 94 | + |
| 95 | + login_check_credentials(); |
| 96 | + if( !g.okSetup ){ |
| 97 | + login_needed(); |
| 98 | + } |
| 99 | + if( P("setup") ){ |
| 100 | + cgi_redirect("tktsetup"); |
| 101 | + } |
| 102 | + isSubmit = P("submit")!=0; |
| 103 | + db_begin_transaction(); |
| 104 | + z = P("x"); |
| 105 | + if( z==0 ){ |
| 106 | + z = db_get(zDbField, zDfltValue); |
| 107 | + } |
| 108 | + style_header("Edit %s", zTitle); |
| 109 | + if( P("clear")!=0 ){ |
| 110 | + db_unset(zDbField, 0); |
| 111 | + z = zDfltValue; |
| 112 | + }else if( isSubmit ){ |
| 113 | + db_set(zDbField, z, 0); |
| 114 | + } |
| 115 | + @ <form action="%s(g.zBaseURL)/%s(g.zPath)" method="POST"> |
| 116 | + @ %s(zDesc) |
| 117 | + @ <textarea name="tab" rows="%d(height)" cols="80">%h(z)</textarea> |
| 118 | + @ <br /> |
| 119 | + @ <input type="submit" name="submit" value="Apply Changes"> |
| 120 | + @ <input type="submit" name="clear" value="Revert To Default"> |
| 121 | + @ <input type="submit" name="setup" value="Ticket Setup Menu"> |
| 122 | + @ </form> |
| 123 | + @ <hr> |
| 124 | + @ <h2>Default %s(zTitle)</h2> |
| 125 | + @ <blockquote><pre> |
| 126 | + @ %h(zDfltValue) |
| 127 | + @ </pre></blockquote> |
| 128 | + db_end_transaction(0); |
| 43 | 129 | style_footer(); |
| 44 | 130 | } |
| 131 | + |
| 132 | +/* |
| 133 | +** WEBPAGE: tktsetup_tab |
| 134 | +*/ |
| 135 | +void tktsetup_tab_page(void){ |
| 136 | + static const char zDesc[] = |
| 137 | + @ <p>Enter a valid CREATE TABLE statement for the "ticket" table. The |
| 138 | + @ table must contain columns named "tkt_id", "tkt_uuid", and "tkt_mtime" |
| 139 | + @ with an unique index on "tkt_uuid" and "tkt_mtime".</p> |
| 140 | + ; |
| 141 | + tktsetup_generic( |
| 142 | + "Ticket Table Schema", |
| 143 | + "ticket-table", |
| 144 | + zDefaultTab, |
| 145 | + zDesc, |
| 146 | + 20 |
| 147 | + ); |
| 148 | +} |
| 149 | + |
| 150 | +static char zDefaultCom[] = |
| 151 | +@ set type_choices { |
| 152 | +@ Code_Defect |
| 153 | +@ Build_Problem |
| 154 | +@ Documentation |
| 155 | +@ Feature_Request |
| 156 | +@ Incident |
| 157 | +@ } |
| 158 | +@ set priority_choices { |
| 159 | +@ Immediate |
| 160 | +@ High |
| 161 | +@ Medium |
| 162 | +@ Low |
| 163 | +@ Zero |
| 164 | +@ } |
| 165 | +@ set severity_choices { |
| 166 | +@ Critical |
| 167 | +@ Severe |
| 168 | +@ Important |
| 169 | +@ Minor |
| 170 | +@ Cosmetic |
| 171 | +@ } |
| 172 | +@ set resolution_choices { |
| 173 | +@ Open |
| 174 | +@ Fixed |
| 175 | +@ Rejected |
| 176 | +@ Unable_To_Reproduce |
| 177 | +@ Works_As_Designed |
| 178 | +@ External_Bug |
| 179 | +@ Not_A_Bug |
| 180 | +@ Duplicate |
| 181 | +@ Overcome_By_Events |
| 182 | +@ Drive_By_Patch |
| 183 | +@ } |
| 184 | +@ set status_choices { |
| 185 | +@ Open |
| 186 | +@ Verified |
| 187 | +@ In_Process |
| 188 | +@ Deferred |
| 189 | +@ Fixed |
| 190 | +@ Tested |
| 191 | +@ Closed |
| 192 | +@ } |
| 193 | +@ set subsystem_choices {one two three} |
| 194 | +; |
| 195 | + |
| 196 | +/* |
| 197 | +** WEBPAGE: tktsetup_com |
| 198 | +*/ |
| 199 | +void tktsetup_com_page(void){ |
| 200 | + static const char zDesc[] = |
| 201 | + @ <p>Enter TH1 script that initializes variables prior to generating |
| 202 | + @ any of the ticket view, edit, or creation pages.</p> |
| 203 | + ; |
| 204 | + tktsetup_generic( |
| 205 | + "Ticket Common Script", |
| 206 | + "ticket-common", |
| 207 | + zDefaultCom, |
| 208 | + zDesc, |
| 209 | + 30 |
| 210 | + ); |
| 211 | +} |
| 212 | + |
| 213 | +static char zDefaultNew[] = |
| 214 | +@ <th1> |
| 215 | +@ if {[info exists submit]} { |
| 216 | +@ set status Open |
| 217 | +@ submit_ticket |
| 218 | +@ } |
| 219 | +@ </th1> |
| 220 | +@ <table cellpadding="5"> |
| 221 | +@ <tr> |
| 222 | +@ <td colspan="2"> |
| 223 | +@ Enter a one-line summary of the problem:<br> |
| 224 | +@ <input type="text" name="title" size="60" value="$<title>"> |
| 225 | +@ </td> |
| 226 | +@ </tr> |
| 227 | +@ |
| 228 | +@ <tr> |
| 229 | +@ <td align="right">Type: |
| 230 | +@ <th1>combobox type $type_choices 1</th1> |
| 231 | +@ </td> |
| 232 | +@ <td>What type of ticket is this?</td> |
| 233 | +@ </tr> |
| 234 | +@ |
| 235 | +@ <tr> |
| 236 | +@ <td align="right">Version: |
| 237 | +@ <input type="text" name="foundin" size="20" value="$<foundin>"> |
| 238 | +@ </td> |
| 239 | +@ <td>In what version or build number do you observe the problem?</td> |
| 240 | +@ </tr> |
| 241 | +@ |
| 242 | +@ <tr> |
| 243 | +@ <td align="right">Severity: |
| 244 | +@ <th1>combobox severity $severity_choices 1</th1> |
| 245 | +@ </td> |
| 246 | +@ <td>How debilitating is the problem? How badly does the problem |
| 247 | +@ effect the operation of the product?</td> |
| 248 | +@ </tr> |
| 249 | +@ |
| 250 | +@ <tr> |
| 251 | +@ <td align="right">EMail: |
| 252 | +@ <input type="text" name="contact" value="$<contact>" size="30"> |
| 253 | +@ </td> |
| 254 | +@ <td>Not publically visible. Used by developers to contact you with |
| 255 | +@ questions.</td> |
| 256 | +@ </tr> |
| 257 | +@ |
| 258 | +@ <tr> |
| 259 | +@ <td colspan="2"> |
| 260 | +@ Enter a detailed description of the problem. |
| 261 | +@ For code defects, be sure to provide details on exactly how |
| 262 | +@ the problem can be reproduced. Provide as much detail as |
| 263 | +@ possible. |
| 264 | +@ <br> |
| 265 | +@ <th1>set nline [linecount $comment 50 10]</th1> |
| 266 | +@ <textarea name="comment" cols="80" rows="$nline" |
| 267 | +@ wrap="virtual" class="wikiedit">$<comment></textarea><br> |
| 268 | +@ <input type="submit" name="preview" value="Preview"> |
| 269 | +@ </tr> |
| 270 | +@ |
| 271 | +@ <th1>enable_output [info exists preview]</th1> |
| 272 | +@ <tr><td colspan="2"> |
| 273 | +@ Description Preview:<br><hr> |
| 274 | +@ <th1>wiki $comment</th1> |
| 275 | +@ <hr> |
| 276 | +@ </td></tr> |
| 277 | +@ <th1>enable_output 1</th1> |
| 278 | +@ |
| 279 | +@ <tr> |
| 280 | +@ <td align="right"> |
| 281 | +@ <input type="submit" name="submit" value="Submit"> |
| 282 | +@ </td> |
| 283 | +@ <td>After filling in the information above, press this button to create |
| 284 | +@ the new ticket</td> |
| 285 | +@ </tr> |
| 286 | +@ </table> |
| 287 | +; |
| 288 | + |
| 289 | +/* |
| 290 | +** WEBPAGE: tktsetup_newpage |
| 291 | +*/ |
| 292 | +void tktsetup_newpage_page(void){ |
| 293 | + static const char zDesc[] = |
| 294 | + @ <p>Enter HTML with embedded TH1 script that will render the "new ticket" |
| 295 | + @ page</p> |
| 296 | + ; |
| 297 | + tktsetup_generic( |
| 298 | + "HTML For New Tickets", |
| 299 | + "ticket-newpage", |
| 300 | + zDefaultNew, |
| 301 | + zDesc, |
| 302 | + 40 |
| 303 | + ); |
| 304 | +} |
| 305 | + |
| 306 | +static char zDefaultView[] = |
| 307 | +@ <table cellpadding="5"> |
| 308 | +@ <tr><td align="right">Title:</td><td> |
| 309 | +@ $<title> |
| 310 | +@ </td></tr> |
| 311 | +@ <tr><td align="right">Status:</td><td> |
| 312 | +@ $<status> |
| 313 | +@ </td></tr> |
| 314 | +@ <tr><td align="right">Type:</td><td> |
| 315 | +@ $<type> |
| 316 | +@ </td></tr> |
| 317 | +@ <tr><td align="right">Severity:</td><td> |
| 318 | +@ $<severity> |
| 319 | +@ </td></tr> |
| 320 | +@ <tr><td align="right">Priority:</td><td> |
| 321 | +@ $<priority> |
| 322 | +@ </td></tr> |
| 323 | +@ <tr><td align="right">Resolution:</td><td> |
| 324 | +@ $<resolution> |
| 325 | +@ </td></tr> |
| 326 | +@ <tr><td align="right">Subsystem:</td><td> |
| 327 | +@ $<subsystem> |
| 328 | +@ </td></tr> |
| 329 | +@ <th1>enable_output [hascap e]</th1> |
| 330 | +@ <tr><td align="right">Contact:</td><td> |
| 331 | +@ $<contact> |
| 332 | +@ </td></tr> |
| 333 | +@ <th1>enable_output 1</th1> |
| 334 | +@ <tr><td align="right">Version Found In:</td><td> |
| 335 | +@ $<foundin> |
| 336 | +@ </td></tr> |
| 337 | +@ <tr><td colspan="2"> |
| 338 | +@ Description And Comments:<br> |
| 339 | +@ <th1>wiki $comment</th1> |
| 340 | +@ </td></tr> |
| 341 | +@ </table> |
| 342 | +; |
| 343 | + |
| 344 | + |
| 345 | +/* |
| 346 | +** WEBPAGE: tktsetup_viewpage |
| 347 | +*/ |
| 348 | +void tktsetup_viewpage_page(void){ |
| 349 | + static const char zDesc[] = |
| 350 | + @ <p>Enter HTML with embedded TH1 script that will render the "view ticket" |
| 351 | + @ page</p> |
| 352 | + ; |
| 353 | + tktsetup_generic( |
| 354 | + "HTML For Viewing Tickets", |
| 355 | + "ticket-viewpage", |
| 356 | + zDefaultView, |
| 357 | + zDesc, |
| 358 | + 40 |
| 359 | + ); |
| 360 | +} |
| 361 | + |
| 362 | +static char zDefaultEdit[] = |
| 363 | +@ <th1> |
| 364 | +@ if {![info exists username]} {set username $login} |
| 365 | +@ if {[info exists submit]} { |
| 366 | +@ if {[info exists cmappnd]} { |
| 367 | +@ if {[string length $cmappnd]>0} { |
| 368 | +@ set ctxt "\n\n<hr><i>[htmlize $login]" |
| 369 | +@ if {$username ne $login} { |
| 370 | +@ set ctxt "$ctxt claiming to be [htmlize $username]" |
| 371 | +@ } |
| 372 | +@ set ctxt "$ctxt added on [date]:</i><br>\n$cmappnd" |
| 373 | +@ append_field comment $ctxt |
| 374 | +@ } |
| 375 | +@ } |
| 376 | +@ submit_ticket |
| 377 | +@ } |
| 378 | +@ </th1> |
| 379 | +@ <table cellpadding="5"> |
| 380 | +@ <tr><td align="right">Title:</td><td> |
| 381 | +@ <input type="text" name="title" value="$<title>" size="60"> |
| 382 | +@ </td></tr> |
| 383 | +@ <tr><td align="right">Status:</td><td> |
| 384 | +@ <th1>combobox status $status_choices 1</th1> |
| 385 | +@ </td></tr> |
| 386 | +@ <tr><td align="right">Type:</td><td> |
| 387 | +@ <th1>combobox type $type_choices 1</th1> |
| 388 | +@ </td></tr> |
| 389 | +@ <tr><td align="right">Severity:</td><td> |
| 390 | +@ <th1>combobox severity $severity_choices 1</th1> |
| 391 | +@ </td></tr> |
| 392 | +@ <tr><td align="right">Priority:</td><td> |
| 393 | +@ <th1>combobox priority $priority_choices 1</th1> |
| 394 | +@ </td></tr> |
| 395 | +@ <tr><td align="right">Resolution:</td><td> |
| 396 | +@ <th1>combobox resolution $resolution_choices 1</th1> |
| 397 | +@ </td></tr> |
| 398 | +@ <tr><td align="right">Subsystem:</td><td> |
| 399 | +@ <th1>combobox subsystem $subsystem_choices 1</th1> |
| 400 | +@ </td></tr> |
| 401 | +@ <th1>enable_output [hascap e]</th1> |
| 402 | +@ <tr><td align="right">Contact:</td><td> |
| 403 | +@ <input type="text" name="contact" size="40" value="$<contact>"> |
| 404 | +@ </td></tr> |
| 405 | +@ <th1>enable_output 1</th1> |
| 406 | +@ <tr><td align="right">Version Found In:</td><td> |
| 407 | +@ <input type="text" name="foundin" size="50" value="$<foundin>"> |
| 408 | +@ </td></tr> |
| 409 | +@ <tr><td colspan="2"> |
| 410 | +@ <th1> |
| 411 | +@ if {![info exists eall]} {set eall 0} |
| 412 | +@ if {[info exists aonlybtn]} {set eall 0} |
| 413 | +@ if {[info exists eallbtn]} {set eall 1} |
| 414 | +@ if {![hascap w]} {set eall 0} |
| 415 | +@ if {![info exists cmappnd]} {set cmappnd {}} |
| 416 | +@ set nline [linecount $comment 15 10] |
| 417 | +@ enable_output $eall |
| 418 | +@ </th1> |
| 419 | +@ Description And Comments:<br> |
| 420 | +@ <textarea name="comment" cols="80" rows="$nline" |
| 421 | +@ wrap="virtual" class="wikiedit">$<comment></textarea><br> |
| 422 | +@ <input type="hidden" name="eall" value="1"> |
| 423 | +@ <input type="submit" name="aonlybtn" value="Append Remark"> |
| 424 | +@ <th1>enable_output [expr {!$eall}]</th1> |
| 425 | +@ Append Remark from |
| 426 | +@ <input type="text" name="username" value="$<username>" size="30">:<br> |
| 427 | +@ <textarea name="cmappnd" cols="80" rows="15" |
| 428 | +@ wrap="virtual" class="wikiedit">$<cmappnd></textarea><br> |
| 429 | +@ <th1>enable_output [expr {[hascap w] && !$eall}]</th1> |
| 430 | +@ <input type="submit" name="eallbtn" value="Edit All"> |
| 431 | +@ <th1>enable_output 1</th1> |
| 432 | +@ </td></tr> |
| 433 | +@ <tr><td align="right"></td><td> |
| 434 | +@ <input type="submit" name="submit" value="Submit Changes"> |
| 435 | +@ </td></tr> |
| 436 | +@ </table> |
| 437 | +; |
| 438 | + |
| 439 | +/* |
| 440 | +** WEBPAGE: tktsetup_editpage |
| 441 | +*/ |
| 442 | +void tktsetup_editpage_page(void){ |
| 443 | + static const char zDesc[] = |
| 444 | + @ <p>Enter HTML with embedded TH1 script that will render the "edit ticket" |
| 445 | + @ page</p> |
| 446 | + ; |
| 447 | + tktsetup_generic( |
| 448 | + "HTML For Editing Tickets", |
| 449 | + "ticket-editpage", |
| 450 | + zDefaultEdit, |
| 451 | + zDesc, |
| 452 | + 40 |
| 453 | + ); |
| 454 | +} |
| 45 | 455 | |