Fossil SCM

Futher improvements to the user capability summary display.

drh 2018-07-30 21:39 forum-v2
Commit 45591e211154bc58cfa46838fdfab883d2289b441d6ca240ed6c4cf5d320fffa
1 file changed +19 -6
--- src/capabilities.c
+++ src/capabilities.c
@@ -282,31 +282,44 @@
282282
void capability_summary(void){
283283
Stmt q;
284284
db_prepare(&q,
285285
"WITH t(id,seq) AS (VALUES('nobody',1),('anonymous',2),('reader',3),"
286286
"('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"
288291
" UNION ALL"
289
- " SELECT 'Regular Users', fullcap(capunion(cap)), 5 FROM user"
292
+ " SELECT 'Regular User', fullcap(capunion(cap)), 20, count(*) FROM user"
290293
" WHERE cap NOT GLOB '*[as]*'"
291294
" UNION ALL"
292
- " SELECT 'Admins', fullcap(capunion(cap)), 6 FROM user"
295
+ " SELECT 'Adminstator', fullcap(capunion(cap)), 30, count(*) FROM user"
293296
" WHERE cap GLOB '*[as]*'"
294
- " ORDER BY 3 ASC"
297
+ " ORDER BY 3 ASC",
298
+ db_get("default-perms","")
295299
);
296300
@ <table id='capabilitySummary' cellpadding="0" cellspacing="0" border="1">
297301
@ <tr><th>&nbsp;<th>Code<th>Forum<th>Tickets<th>Wiki\
298302
@ <th>Unversioned Content</th></tr>
299303
while( db_step(&q)==SQLITE_ROW ){
300304
const char *zId = db_column_text(&q, 0);
301305
const char *zCap = db_column_text(&q, 1);
306
+ int n = db_column_int(&q, 3);
302307
int eType;
303308
static const char *azType[] = { "off", "read", "write" };
304309
static const char *azClass[] = { "capsumOff", "capsumRead", "capsumWrite" };
305310
311
+ if( n==0 ) continue;
312
+
306313
/* 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
+ }
308321
if( sqlite3_strglob("*[asi]*",zCap)==0 ){
309322
eType = 2;
310323
}else if( sqlite3_strglob("*[oz]*",zCap)==0 ){
311324
eType = 1;
312325
}else{
@@ -345,11 +358,11 @@
345358
@ <td class="%s(azClass[eType])">%s(azType[eType])</td>
346359
347360
/* Unversioned */
348361
if( sqlite3_strglob("*y*",zCap)==0 ){
349362
eType = 2;
350
- }else if( sqlite3_strglob("*o*",zCap)==0 ){
363
+ }else if( sqlite3_strglob("*[ioas]*",zCap)==0 ){
351364
eType = 1;
352365
}else{
353366
eType = 0;
354367
}
355368
@ <td class="%s(azClass[eType])">%s(azType[eType])</td>
356369
--- src/capabilities.c
+++ src/capabilities.c
@@ -282,31 +282,44 @@
282 void capability_summary(void){
283 Stmt q;
284 db_prepare(&q,
285 "WITH t(id,seq) AS (VALUES('nobody',1),('anonymous',2),('reader',3),"
286 "('developer',4))"
287 " SELECT id, fullcap(user.cap),seq FROM t LEFT JOIN user ON t.id=user.login"
 
 
 
288 " UNION ALL"
289 " SELECT 'Regular Users', fullcap(capunion(cap)), 5 FROM user"
290 " WHERE cap NOT GLOB '*[as]*'"
291 " UNION ALL"
292 " SELECT 'Admins', fullcap(capunion(cap)), 6 FROM user"
293 " WHERE cap GLOB '*[as]*'"
294 " ORDER BY 3 ASC"
 
295 );
296 @ <table id='capabilitySummary' cellpadding="0" cellspacing="0" border="1">
297 @ <tr><th>&nbsp;<th>Code<th>Forum<th>Tickets<th>Wiki\
298 @ <th>Unversioned Content</th></tr>
299 while( db_step(&q)==SQLITE_ROW ){
300 const char *zId = db_column_text(&q, 0);
301 const char *zCap = db_column_text(&q, 1);
 
302 int eType;
303 static const char *azType[] = { "off", "read", "write" };
304 static const char *azClass[] = { "capsumOff", "capsumRead", "capsumWrite" };
305
 
 
306 /* Code */
307 @ <tr><th align="right">%h(zId)</th>
 
 
 
 
 
 
308 if( sqlite3_strglob("*[asi]*",zCap)==0 ){
309 eType = 2;
310 }else if( sqlite3_strglob("*[oz]*",zCap)==0 ){
311 eType = 1;
312 }else{
@@ -345,11 +358,11 @@
345 @ <td class="%s(azClass[eType])">%s(azType[eType])</td>
346
347 /* Unversioned */
348 if( sqlite3_strglob("*y*",zCap)==0 ){
349 eType = 2;
350 }else if( sqlite3_strglob("*o*",zCap)==0 ){
351 eType = 1;
352 }else{
353 eType = 0;
354 }
355 @ <td class="%s(azClass[eType])">%s(azType[eType])</td>
356
--- src/capabilities.c
+++ src/capabilities.c
@@ -282,31 +282,44 @@
282 void capability_summary(void){
283 Stmt q;
284 db_prepare(&q,
285 "WITH t(id,seq) AS (VALUES('nobody',1),('anonymous',2),('reader',3),"
286 "('developer',4))"
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"
291 " UNION ALL"
292 " SELECT 'Regular User', fullcap(capunion(cap)), 20, count(*) FROM user"
293 " WHERE cap NOT GLOB '*[as]*'"
294 " UNION ALL"
295 " SELECT 'Adminstator', fullcap(capunion(cap)), 30, count(*) FROM user"
296 " WHERE cap GLOB '*[as]*'"
297 " ORDER BY 3 ASC",
298 db_get("default-perms","")
299 );
300 @ <table id='capabilitySummary' cellpadding="0" cellspacing="0" border="1">
301 @ <tr><th>&nbsp;<th>Code<th>Forum<th>Tickets<th>Wiki\
302 @ <th>Unversioned Content</th></tr>
303 while( db_step(&q)==SQLITE_ROW ){
304 const char *zId = db_column_text(&q, 0);
305 const char *zCap = db_column_text(&q, 1);
306 int n = db_column_int(&q, 3);
307 int eType;
308 static const char *azType[] = { "off", "read", "write" };
309 static const char *azClass[] = { "capsumOff", "capsumRead", "capsumWrite" };
310
311 if( n==0 ) continue;
312
313 /* Code */
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 }
321 if( sqlite3_strglob("*[asi]*",zCap)==0 ){
322 eType = 2;
323 }else if( sqlite3_strglob("*[oz]*",zCap)==0 ){
324 eType = 1;
325 }else{
@@ -345,11 +358,11 @@
358 @ <td class="%s(azClass[eType])">%s(azType[eType])</td>
359
360 /* Unversioned */
361 if( sqlite3_strglob("*y*",zCap)==0 ){
362 eType = 2;
363 }else if( sqlite3_strglob("*[ioas]*",zCap)==0 ){
364 eType = 1;
365 }else{
366 eType = 0;
367 }
368 @ <td class="%s(azClass[eType])">%s(azType[eType])</td>
369

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button