Check-in [355ee47555]
Not logged in
Overview

SHA1 Hash:355ee475554304a88afe5f11c4ad74a3d12aa9e9
Date: 2009-03-31 16:47:41
User: drh
Comment:Add the new "reader" role, analogous to "developer".
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/login.c from [cfdc7a0c2e] to [f3badebb6b].

@@ -336,10 +336,11 @@
 /*
 ** Set the global capability flags based on a capability string.
 */
 void login_set_capabilities(const char *zCap){
   static char *zDev = 0;
+  static char *zUser = 0;
   int i;
   for(i=0; zCap[i]; i++){
     switch( zCap[i] ){
       case 's':   g.okSetup = 1;  /* Fall thru into Admin */
       case 'a':   g.okAdmin = g.okRdTkt = g.okWrTkt =
@@ -366,10 +367,20 @@
       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;
+
+      /* The "u" privileges is a little different.  It recursively
+      ** inherits all privileges of the user named "reader" */
+      case 'u': {
+        if( zUser==0 ){
+          zUser = db_text("", "SELECT cap FROM user WHERE login='reader'");
+          login_set_capabilities(zUser);
+        }
+        break;
+      }
 
       /* The "v" privileges is a little different.  It recursively
       ** inherits all privileges of the user named "developer" */
       case 'v': {
         if( zDev==0 ){
@@ -411,12 +422,12 @@
       case 'p':  rc = g.okPassword;  break;
       /* case 'q': */
       case 'r':  rc = g.okRdTkt;     break;
       case 's':  rc = g.okSetup;     break;
       case 't':  rc = g.okTktFmt;    break;
-      /* case 'u': */
-      /* case 'v': */
+      /* case 'u': READER    */
+      /* case 'v': DEVELOPER */
       case 'w':  rc = g.okWrTkt;     break;
       /* case 'x': */
       /* case 'y': */
       case 'z':  rc = g.okZip;       break;
       default:   rc = 0;             break;

Modified src/setup.c from [e6e6ffccb4] to [d905d90c04].

@@ -172,10 +172,13 @@
      @   <td><i>Read-Tkt:</i> View tickets</td></tr>
      @ <tr><td valign="top"><b>s</b></td>
      @   <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
      @ <tr><td valign="top"><b>t</b></td>
      @   <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
+     @ <tr><td valign="top"><b>u</b></td>
+     @   <td><i>Developer:</i> Inherit privileges of
+     @   user <tt>reader</tt></td></tr>
      @ <tr><td valign="top"><b>v</b></td>
      @   <td><i>Developer:</i> Inherit privileges of
      @   user <tt>developer</tt></td></tr>
      @ <tr><td valign="top"><b>w</b></td>
      @   <td><i>Write-Tkt:</i> Edit tickets</td></tr>
@@ -228,11 +231,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, *oav, *oaz;
+  char *oat, *oau, *oav, *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 */
@@ -282,10 +285,11 @@
     int af = P("af")!=0;
     int am = P("am")!=0;
     int ah = P("ah")!=0;
     int ag = P("ag")!=0;
     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( ac ){ zCap[i++] = 'c'; }
     if( ad ){ zCap[i++] = 'd'; }
@@ -301,10 +305,11 @@
     if( ao ){ zCap[i++] = 'o'; }
     if( ap ){ zCap[i++] = 'p'; }
     if( ar ){ zCap[i++] = 'r'; }
     if( as ){ zCap[i++] = 's'; }
     if( at ){ zCap[i++] = 't'; }
+    if( au ){ zCap[i++] = 'u'; }
     if( av ){ zCap[i++] = 'v'; }
     if( aw ){ zCap[i++] = 'w'; }
     if( az ){ zCap[i++] = 'z'; }
 
     zCap[i] = 0;
@@ -339,11 +344,11 @@
   zLogin = "";
   zInfo = "";
   zCap = "";
   zPw = "";
   oaa = oac = oad = oae = oaf = oag = oah = oai = oaj = oak = oam =
-        oan = oao = oap = oar = oas = oat = oav = oaw = oaz = "";
+        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);
@@ -362,10 +367,11 @@
     if( strchr(zCap, 'o') ) oao = " checked";
     if( strchr(zCap, 'p') ) oap = " checked";
     if( strchr(zCap, 'r') ) oar = " checked";
     if( strchr(zCap, 's') ) oas = " checked";
     if( strchr(zCap, 't') ) oat = " checked";
+    if( strchr(zCap, 'u') ) oau = " checked";
     if( strchr(zCap, 'v') ) oav = " checked";
     if( strchr(zCap, 'w') ) oaw = " checked";
     if( strchr(zCap, 'z') ) oaz = " checked";
   }
 
@@ -374,10 +380,18 @@
   if( strcmp(zLogin, "developer") ){
     char *z1, *z2;
     z1 = z2 = db_text(0,"SELECT cap FROM user WHERE login='developer'");
     while( z1 && *z1 ){
       inherit[0x7f & *(z1++)] = "<font color=\"red\">&bull;</font>";
+    }
+    free(z2);
+  }
+  if( strcmp(zLogin, "reader") ){
+    char *z1, *z2;
+    z1 = z2 = db_text(0,"SELECT cap FROM user WHERE login='reader'");
+    while( z1 && *z1 ){
+      inherit[0x7f & *(z1++)] = "<font color=\"black\">&bull;</font>";
     }
     free(z2);
   }
   if( strcmp(zLogin, "anonymous") ){
     char *z1, *z2;
@@ -436,10 +450,11 @@
   @    <input type="checkbox" name="ae"%s(oae)>%s(B('e'))Email</input><br>
   @    <input type="checkbox" name="ap"%s(oap)>%s(B('p'))Password</input><br>
   @    <input type="checkbox" name="ai"%s(oai)>%s(B('i'))Check-In</input><br>
   @    <input type="checkbox" name="ao"%s(oao)>%s(B('o'))Check-Out</input><br>
   @    <input type="checkbox" name="ah"%s(oah)>%s(B('h'))History</input><br>
+  @    <input type="checkbox" name="au"%s(oau)>%s(B('u'))Reader</input><br>
   @    <input type="checkbox" name="av"%s(oav)>%s(B('v'))Developer</input><br>
   @    <input type="checkbox" name="ag"%s(oag)>%s(B('g'))Clone</input><br>
   @    <input type="checkbox" name="aj"%s(oaj)>%s(B('j'))Read Wiki</input><br>
   @    <input type="checkbox" name="af"%s(oaf)>%s(B('f'))New Wiki</input><br>
   @    <input type="checkbox" name="am"%s(oam)>%s(B('m'))Append Wiki</input><br>
@@ -501,10 +516,16 @@
   @
   @ <li><p>
   @ The "<font color="red"><big>&bull;</big></font>" mark indicates
   @ the privileges of "developer" that are inherited by all users with
   @ the <b>Developer</b> privilege.
+  @ </p></li>
+  @
+  @ <li><p>
+  @ The "<font color="black"><big>&bull;</big></font>" mark indicates
+  @ the privileges of "reader" that are inherited by all users with
+  @ the <b>Reader</b> privilege.
   @ </p></li>
   @
   @ <li><p>
   @ The <b>Delete</b> privilege give the user the ability to erase
   @ wiki, tickets, and attachments that have been added by anonymous
@@ -590,11 +611,13 @@
   @
   @ <li><p>
   @ The "<b>developer</b>" user is intended as a template for trusted users
   @ with check-in privileges.  When adding new trusted users, simply
   @ select the <b>Developer</b> privilege to cause the new user to inherit
-  @ all privileges of the "developer" user.
+  @ all privileges of the "developer" user.  Similarly, the "<b>reader</b>"
+  @ user is a template for users who are allowed more access than anonymous,
+  @ but less than a developer.
   @ </li></p>
   @ </ul>
   @ </form>
   style_footer();
 }