Fossil

Check-in [45591e21]
Login

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

Overview
Comment:Futher improvements to the user capability summary display.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | forum-v2
Files: files | file ages | folders
SHA3-256:45591e211154bc58cfa46838fdfab883d2289b441d6ca240ed6c4cf5d320fffa
User & Date: drh 2018-07-30 21:39:45
Context
2018-07-30
23:29
Improved login screen with a "Create A New Account" button. check-in: 14335899 user: drh tags: forum-v2
21:39
Futher improvements to the user capability summary display. check-in: 45591e21 user: drh tags: forum-v2
21:17
Improved CSS for the user capability summary. check-in: ba232e26 user: drh tags: forum-v2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/capabilities.c.

   280    280   ** against the various user categories.
   281    281   */
   282    282   void capability_summary(void){
   283    283     Stmt q;
   284    284     db_prepare(&q,
   285    285       "WITH t(id,seq) AS (VALUES('nobody',1),('anonymous',2),('reader',3),"
   286    286                          "('developer',4))"
   287         -    " SELECT id, fullcap(user.cap),seq FROM t LEFT JOIN user ON t.id=user.login"
          287  +    " SELECT id, fullcap(user.cap),seq,1"
          288  +    "   FROM t LEFT JOIN user ON t.id=user.login"
          289  +    " UNION ALL"
          290  +    " SELECT 'New User Default', fullcap(%Q), 10, 1"
   288    291       " UNION ALL"
   289         -    " SELECT 'Regular Users', fullcap(capunion(cap)), 5 FROM user"
          292  +    " SELECT 'Regular User', fullcap(capunion(cap)), 20, count(*) FROM user"
   290    293       " WHERE cap NOT GLOB '*[as]*'"
   291    294       " UNION ALL"
   292         -    " SELECT 'Admins', fullcap(capunion(cap)), 6 FROM user"
          295  +    " SELECT 'Adminstator', fullcap(capunion(cap)), 30, count(*) FROM user"
   293    296       " WHERE cap GLOB '*[as]*'"
   294         -    " ORDER BY 3 ASC"
          297  +    " ORDER BY 3 ASC",
          298  +    db_get("default-perms","")
   295    299     );
   296    300     @ <table id='capabilitySummary' cellpadding="0" cellspacing="0" border="1">
   297    301     @ <tr><th>&nbsp;<th>Code<th>Forum<th>Tickets<th>Wiki\
   298    302     @ <th>Unversioned Content</th></tr>
   299    303     while( db_step(&q)==SQLITE_ROW ){
   300    304       const char *zId = db_column_text(&q, 0);
   301    305       const char *zCap = db_column_text(&q, 1);
          306  +    int n = db_column_int(&q, 3);
   302    307       int eType;
   303    308       static const char *azType[] = { "off", "read", "write" };
   304    309       static const char *azClass[] = { "capsumOff", "capsumRead", "capsumWrite" };
   305    310   
          311  +    if( n==0 ) continue;
          312  +
   306    313       /* Code */
   307         -    @ <tr><th align="right">%h(zId)</th>
          314  +    if( db_column_int(&q,2)<10 ){
          315  +      @ <tr><th align="right"><tt>"%h(zId)"</tt></th>
          316  +    }else if( n>1 ){
          317  +      @ <tr><th align="right">%d(n) %h(zId)s</th>
          318  +    }else{
          319  +      @ <tr><th align="right">%h(zId)</th>
          320  +    }
   308    321       if( sqlite3_strglob("*[asi]*",zCap)==0 ){
   309    322         eType = 2;
   310    323       }else if( sqlite3_strglob("*[oz]*",zCap)==0 ){
   311    324         eType = 1;
   312    325       }else{
   313    326         eType = 0;
   314    327       }
................................................................................
   343    356         eType = 0;
   344    357       }
   345    358       @ <td class="%s(azClass[eType])">%s(azType[eType])</td>
   346    359   
   347    360       /* Unversioned */
   348    361       if( sqlite3_strglob("*y*",zCap)==0 ){
   349    362         eType = 2;
   350         -    }else if( sqlite3_strglob("*o*",zCap)==0 ){
          363  +    }else if( sqlite3_strglob("*[ioas]*",zCap)==0 ){
   351    364         eType = 1;
   352    365       }else{
   353    366         eType = 0;
   354    367       }
   355    368       @ <td class="%s(azClass[eType])">%s(azType[eType])</td>
   356    369   
   357    370     }
   358    371     db_finalize(&q);
   359    372     @ </table>
   360    373   }