Fossil
Check-in [c3d7df650b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

SHA1 Hash:c3d7df650ba1bf488dad512c3039fec8f4e50205
Date: 2010-03-16 21:33:16
User: drh
Comment:Work toward adding support for attachments. Keep this on an experimental branch until it is actually working.

Tags And Properties
Changes
[hide diffs]

Added src/attach.c

Changes to src/login.c

@@ -476,11 +476,12 @@
       case 's':   g.okSetup = 1;  /* Fall thru into Admin */
       case 'a':   g.okAdmin = g.okRdTkt = g.okWrTkt = g.okZip =
                               g.okRdWiki = g.okWrWiki = g.okNewWiki =
                               g.okApndWiki = g.okHistory = g.okClone =
                               g.okNewTkt = g.okPassword = g.okRdAddr =
-                              g.okTktFmt = 1;  /* Fall thru into Read/Write */
+                              g.okTktFmt = g.okAttach = 1;
+                              /* Fall thru into Read/Write */
       case 'i':   g.okRead = g.okWrite = 1;                     break;
       case 'o':   g.okRead = 1;                                 break;
       case 'z':   g.okZip = 1;                                  break;
 
       case 'd':   g.okDelete = 1;                               break;
@@ -498,10 +499,11 @@
       case 'n':   g.okNewTkt = 1;                               break;
       case 'w':   g.okWrTkt = g.okRdTkt = g.okNewTkt =
                   g.okApndTkt = 1;                              break;
       case 'c':   g.okApndTkt = 1;                              break;
       case 't':   g.okTktFmt = 1;                               break;
+      case 'b':   g.okAttach = 1;                               break;
 
       /* The "u" privileges is a little different.  It recursively
       ** inherits all privileges of the user named "reader" */
       case 'u': {
         if( zUser==0 ){
@@ -534,11 +536,11 @@
   int rc = 1;
   if( nCap<0 ) nCap = strlen(zCap);
   for(i=0; i<nCap && rc && zCap[i]; i++){
     switch( zCap[i] ){
       case 'a':  rc = g.okAdmin;     break;
-      /* case 'b': */
+      case 'b':  rc = g.okAttach;    break;
       case 'c':  rc = g.okApndTkt;   break;
       case 'd':  rc = g.okDelete;    break;
       case 'e':  rc = g.okRdAddr;    break;
       case 'f':  rc = g.okNewWiki;   break;
       case 'g':  rc = g.okClone;     break;

Changes to src/main.c

@@ -130,10 +130,11 @@
   int okWrWiki;           /* k: edit wiki via web */
   int okRdTkt;            /* r: view tickets via web */
   int okNewTkt;           /* n: create new tickets */
   int okApndTkt;          /* c: append to tickets via the web */
   int okWrTkt;            /* w: make changes to tickets via web */
+  int okAttach;           /* b: add attachments */
   int okTktFmt;           /* t: create new ticket report formats */
   int okRdAddr;           /* e: read email addresses or other private data */
   int okZip;              /* z: download zipped artifact via /zip URL */
 
   /* For defense against Cross-site Request Forgery attacks */

Changes to src/main.mk

@@ -13,10 +13,11 @@
 
 
 SRC = \
   $(SRCDIR)/add.c \
   $(SRCDIR)/allrepo.c \
+  $(SRCDIR)/attach.c \
   $(SRCDIR)/bag.c \
   $(SRCDIR)/blob.c \
   $(SRCDIR)/branch.c \
   $(SRCDIR)/browse.c \
   $(SRCDIR)/captcha.c \
@@ -86,10 +87,11 @@
   $(SRCDIR)/zip.c
 
 TRANS_SRC = \
   add_.c \
   allrepo_.c \
+  attach_.c \
   bag_.c \
   blob_.c \
   branch_.c \
   browse_.c \
   captcha_.c \
@@ -159,10 +161,11 @@
   zip_.c
 
 OBJ = \
  $(OBJDIR)/add.o \
  $(OBJDIR)/allrepo.o \
+ $(OBJDIR)/attach.o \
  $(OBJDIR)/bag.o \
  $(OBJDIR)/blob.o \
  $(OBJDIR)/branch.o \
  $(OBJDIR)/browse.o \
  $(OBJDIR)/captcha.o \
@@ -273,16 +276,16 @@
 	# noop
 
 clean:
 	rm -f $(OBJDIR)/*.o *_.c $(APPNAME) VERSION.h
 	rm -f translate makeheaders mkindex page_index.h headers
-	rm -f add.h allrepo.h bag.h blob.h branch.h browse.h captcha.h cgi.h checkin.h checkout.h clearsign.h clone.h comformat.h configure.h construct.h content.h db.h delta.h deltacmd.h descendants.h diff.h diffcmd.h doc.h encode.h file.h finfo.h graph.h http.h http_socket.h http_ssl.h http_transport.h info.h login.h main.h manifest.h md5.h merge.h merge3.h name.h pivot.h pqueue.h printf.h rebuild.h report.h rss.h rstats.h schema.h search.h setup.h sha1.h shun.h skins.h stat.h style.h sync.h tag.h th_main.h timeline.h tkt.h tktsetup.h undo.h update.h url.h user.h verify.h vfile.h wiki.h wikiformat.h winhttp.h xfer.h zip.h
+	rm -f add.h allrepo.h attach.h bag.h blob.h branch.h browse.h captcha.h cgi.h checkin.h checkout.h clearsign.h clone.h comformat.h configure.h construct.h content.h db.h delta.h deltacmd.h descendants.h diff.h diffcmd.h doc.h encode.h file.h finfo.h graph.h http.h http_socket.h http_ssl.h http_transport.h info.h login.h main.h manifest.h md5.h merge.h merge3.h name.h pivot.h pqueue.h printf.h rebuild.h report.h rss.h rstats.h schema.h search.h setup.h sha1.h shun.h skins.h stat.h style.h sync.h tag.h th_main.h timeline.h tkt.h tktsetup.h undo.h update.h url.h user.h verify.h vfile.h wiki.h wikiformat.h winhttp.h xfer.h zip.h
 
 page_index.h: $(TRANS_SRC) mkindex
 	./mkindex $(TRANS_SRC) >$@
 headers:	page_index.h makeheaders VERSION.h
-	./makeheaders  add_.c:add.h allrepo_.c:allrepo.h bag_.c:bag.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h construct_.c:construct.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h file_.c:file.h finfo_.c:finfo.h graph_.c:graph.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h info_.c:info.h login_.c:login.h main_.c:main.h manifest_.c:manifest.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h name_.c:name.h pivot_.c:pivot.h pqueue_.c:pqueue.h printf_.c:printf.h rebuild_.c:rebuild.h report_.c:report.h rss_.c:rss.h rstats_.c:rstats.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h skins_.c:skins.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h update_.c:update.h url_.c:url.h user_.c:user.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winhttp_.c:winhttp.h xfer_.c:xfer.h zip_.c:zip.h $(SRCDIR)/sqlite3.h $(SRCDIR)/th.h VERSION.h
+	./makeheaders  add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h construct_.c:construct.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h file_.c:file.h finfo_.c:finfo.h graph_.c:graph.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h info_.c:info.h login_.c:login.h main_.c:main.h manifest_.c:manifest.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h name_.c:name.h pivot_.c:pivot.h pqueue_.c:pqueue.h printf_.c:printf.h rebuild_.c:rebuild.h report_.c:report.h rss_.c:rss.h rstats_.c:rstats.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h skins_.c:skins.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h update_.c:update.h url_.c:url.h user_.c:user.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winhttp_.c:winhttp.h xfer_.c:xfer.h zip_.c:zip.h $(SRCDIR)/sqlite3.h $(SRCDIR)/th.h VERSION.h
 	touch headers
 headers: Makefile
 Makefile:
 add_.c:	$(SRCDIR)/add.c translate
 	./translate $(SRCDIR)/add.c >add_.c
@@ -296,10 +299,17 @@
 
 $(OBJDIR)/allrepo.o:	allrepo_.c allrepo.h  $(SRCDIR)/config.h
 	$(XTCC) -o $(OBJDIR)/allrepo.o -c allrepo_.c
 
 allrepo.h:	headers
+attach_.c:	$(SRCDIR)/attach.c translate
+	./translate $(SRCDIR)/attach.c >attach_.c
+
+$(OBJDIR)/attach.o:	attach_.c attach.h  $(SRCDIR)/config.h
+	$(XTCC) -o $(OBJDIR)/attach.o -c attach_.c
+
+attach.h:	headers
 bag_.c:	$(SRCDIR)/bag.c translate
 	./translate $(SRCDIR)/bag.c >bag_.c
 
 $(OBJDIR)/bag.o:	bag_.c bag.h  $(SRCDIR)/config.h
 	$(XTCC) -o $(OBJDIR)/bag.o -c bag_.c

Changes to src/makemake.tcl

@@ -7,10 +7,11 @@
 # "translate" and "makeheaders"
 #
 set src {
   add
   allrepo
+  attach
   bag
   blob
   branch
   browse
   captcha

Changes to src/setup.c

@@ -147,10 +147,12 @@
   @ <ol>
   @ <li><p>The permission flags are as follows:</p>
   @ <table>
      @ <tr><td valign="top"><b>a</b></td>
      @   <td><i>Admin:</i> Create and delete users</td></tr>
+     @ <tr><td valign="top"><b>b</b></td>
+     @   <td><i>Attach:</i> Add attachments to wiki or tickets</td></tr>
      @ <tr><td valign="top"><b>c</b></td>
      @   <td><i>Append-Tkt:</i> Append to tickets</td></tr>
      @ <tr><td valign="top"><b>d</b></td>
      @   <td><i>Delete:</i> Delete wiki and tickets</td></tr>
      @ <tr><td valign="top"><b>e</b></td>
@@ -239,11 +241,11 @@
 */
 void user_edit(void){
   const char *zId, *zLogin, *zInfo, *zCap, *zPw;
   char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap;
   char *oak, *oad, *oac, *oaf, *oam, *oah, *oag, *oae;
-  char *oat, *oau, *oav, *oaz;
+  char *oat, *oau, *oav, *oab, *oaz;
   const char *inherit[128];
   int doWrite;
   int uid;
   int higherUser = 0;  /* True if user being edited is SETUP and the */
                        /* user doing the editing is ADMIN.  Disallow editing */
@@ -276,10 +278,11 @@
   doWrite = cgi_all("login","info","pw") && !higherUser;
   if( doWrite ){
     char zCap[50];
     int i = 0;
     int aa = P("aa")!=0;
+    int ab = P("ab")!=0;
     int ad = P("ad")!=0;
     int ae = P("ae")!=0;
     int ai = P("ai")!=0;
     int aj = P("aj")!=0;
     int ak = P("ak")!=0;
@@ -297,10 +300,11 @@
     int at = P("at")!=0;
     int au = P("au")!=0;
     int av = P("av")!=0;
     int az = P("az")!=0;
     if( aa ){ zCap[i++] = 'a'; }
+    if( ab ){ zCap[i++] = 'b'; }
     if( ac ){ zCap[i++] = 'c'; }
     if( ad ){ zCap[i++] = 'd'; }
     if( ae ){ zCap[i++] = 'e'; }
     if( af ){ zCap[i++] = 'f'; }
     if( ah ){ zCap[i++] = 'h'; }
@@ -353,18 +357,19 @@
   */
   zLogin = "";
   zInfo = "";
   zCap = "";
   zPw = "";
-  oaa = oac = oad = oae = oaf = oag = oah = oai = oaj = oak = oam =
+  oaa = oab = oac = oad = oae = oaf = oag = oah = oai = oaj = oak = oam =
         oan = oao = oap = oar = oas = oat = oau = oav = oaw = oaz = "";
   if( uid ){
     zLogin = db_text("", "SELECT login FROM user WHERE uid=%d", uid);
     zInfo = db_text("", "SELECT info FROM user WHERE uid=%d", uid);
     zCap = db_text("", "SELECT cap FROM user WHERE uid=%d", uid);
     zPw = db_text("", "SELECT pw FROM user WHERE uid=%d", uid);
     if( strchr(zCap, 'a') ) oaa = " checked";
+    if( strchr(zCap, 'b') ) oab = " checked";
     if( strchr(zCap, 'c') ) oac = " checked";
     if( strchr(zCap, 'd') ) oad = " checked";
     if( strchr(zCap, 'e') ) oae = " checked";
     if( strchr(zCap, 'f') ) oaf = " checked";
     if( strchr(zCap, 'g') ) oag = " checked";
@@ -467,15 +472,16 @@
   @    <input type="checkbox" name="ag"%s(oag)/>%s(B('g'))Clone<br>
   @    <input type="checkbox" name="aj"%s(oaj)/>%s(B('j'))Read Wiki<br>
   @    <input type="checkbox" name="af"%s(oaf)/>%s(B('f'))New Wiki<br>
   @    <input type="checkbox" name="am"%s(oam)/>%s(B('m'))Append Wiki<br>
   @    <input type="checkbox" name="ak"%s(oak)/>%s(B('k'))Write Wiki<br>
-  @    <input type="checkbox" name="ar"%s(oar)/>%s(B('r'))Read Tkt<br>
-  @    <input type="checkbox" name="an"%s(oan)/>%s(B('n'))New Tkt<br>
-  @    <input type="checkbox" name="ac"%s(oac)/>%s(B('c'))Append Tkt<br>
-  @    <input type="checkbox" name="aw"%s(oaw)/>%s(B('w'))Write Tkt<br>
-  @    <input type="checkbox" name="at"%s(oat)/>%s(B('t'))Tkt Report<br>
+  @    <input type="checkbox" name="ab"%s(oab)/>%s(B('b'))Attachments<br>
+  @    <input type="checkbox" name="ar"%s(oar)/>%s(B('r'))Read Ticket<br>
+  @    <input type="checkbox" name="an"%s(oan)/>%s(B('n'))New Ticket<br>
+  @    <input type="checkbox" name="ac"%s(oac)/>%s(B('c'))Append Ticket<br>
+  @    <input type="checkbox" name="aw"%s(oaw)/>%s(B('w'))Write Ticket<br>
+  @    <input type="checkbox" name="at"%s(oat)/>%s(B('t'))Ticket Report<br>
   @    <input type="checkbox" name="az"%s(oaz)/>%s(B('z'))Download Zip
   @   </td>
   @ </tr>
   @ <tr>
   @   <td align="right">Password:</td>
@@ -564,13 +570,13 @@
   @ </li><p>
   @
   @ <li><p>
   @ The <b>Read Wiki</b>, <b>New Wiki</b>, <b>Append Wiki</b>, and
   @ <b>Write Wiki</b> privileges control access to wiki pages.  The
-  @ <b>Read Tkt</b>, <b>New Tkt</b>, <b>Append Tkt</b>, and
-  @ <b>Write Tkt</b> privileges control access to trouble tickets.
-  @ The <b>Tkt Report</b> privilege allows the user to create or edit
+  @ <b>Read Ticket</b>, <b>New Ticket</b>, <b>Append Ticket</b>, and
+  @ <b>Write Ticket</b> privileges control access to trouble tickets.
+  @ The <b>Ticket Report</b> privilege allows the user to create or edit
   @ ticket report formats.
   @ </p></li>
   @
   @ <li><p>
   @ Users with the <b>Password</b> privilege are allowed to change their
@@ -582,10 +588,15 @@
   @ The <b>EMail</b> privilege allows the display of sensitive information
   @ such as the email address of users and contact information on tickets.
   @ Recommended OFF for "anonymous" and for "nobody" but ON for
   @ "developer".
   @ </p></li>
+  @
+  @ <li><p>
+  @ The <b>Attachment</b> privilege is needed in order to add attachments
+  @ to tickets or wiki.  Write privilege on the ticket or wiki is also
+  @ required.</p></li>
   @
   @ <li><p>
   @ Login is prohibited if the password is an empty string.
   @ </p></li>
   @ </ul>