Fossil SCM

New admin-only page /setup_uinfo that shows combined information from the USER and SUBSCRIBER tables about a single user. Give a hyperlink to this page when a timeline delivered to an admin says "by user".

drh 2024-08-23 19:54 trunk
Commit 24eb1822483412f7ca640998a4d200f57d20498cfaf27232303c1f2be41098b3
2 files changed +93 +6 -1
--- src/setupuser.c
+++ src/setupuser.c
@@ -939,5 +939,98 @@
939939
@ but less than a <span class="usertype">developer</span>.
940940
@ </p></li>
941941
@ </ul>
942942
style_finish_page();
943943
}
944
+
945
+/*
946
+** WEBPAGE: setup_uinfo
947
+**
948
+** Detailed information about a user account, available to administrators
949
+** only.
950
+**
951
+** u=UID
952
+** l=LOGIN
953
+*/
954
+void setup_uinfo_page(void){
955
+ Stmt q;
956
+ Blob sql;
957
+ const char *zLogin;
958
+ int uid;
959
+
960
+ /* Must have ADMIN privileges to access this page
961
+ */
962
+ login_check_credentials();
963
+ if( !g.perm.Admin ){ login_needed(0); return; }
964
+ style_set_current_feature("setup");
965
+ zLogin = P("l");
966
+ uid = atoi(PD("u","0"));
967
+ if( zLogin==0 && uid==0 ){
968
+ uid = db_int(1,"SELECT uid FROM user");
969
+ }
970
+ blob_init(&sql, 0, 0);
971
+ blob_append_sql(&sql,
972
+ "SELECT "
973
+ /* 0 */ "uid,"
974
+ /* 1 */ "login,"
975
+ /* 2 */ "cap,"
976
+ /* 3 */ "cookie,"
977
+ /* 4 */ "datetime(cexpire),"
978
+ /* 5 */ "info,"
979
+ /* 6 */ "datetime(user.mtime,'unixepoch'),"
980
+ );
981
+ if( db_table_exists("repository","subscriber") ){
982
+ blob_append_sql(&sql,
983
+ /* 7 */ "subscriberId,"
984
+ /* 8 */ "semail,"
985
+ /* 9 */ "sverified,"
986
+ /* 10 */ "date(lastContact+2440587.5)"
987
+ " FROM user LEFT JOIN subscriber ON suname=login"
988
+ );
989
+ }else{
990
+ blob_append_sql(&sql,
991
+ /* 7 */ "NULL,"
992
+ /* 8 */ "NULL,"
993
+ /* 9 */ "NULL,"
994
+ /* 10 */ "NULL"
995
+ " FROM user"
996
+ );
997
+ }
998
+ if( zLogin!=0 ){
999
+ blob_append_sql(&sql, " WHERE login=%Q", zLogin);
1000
+ }else{
1001
+ blob_append_sql(&sql, " WHERE uid=%d", uid);
1002
+ }
1003
+ db_prepare(&q, "%s", blob_sql_text(&sql));
1004
+ blob_zero(&sql);
1005
+ if( db_step(&q)!=SQLITE_ROW ){
1006
+ style_header("No Such User");
1007
+ if( zLogin ){
1008
+ @ <p>Cannot find any information on user %h(zLogin).
1009
+ }else{
1010
+ @ <p>Cannot find any information on userid %d(uid).
1011
+ }
1012
+ style_finish_page();
1013
+ db_finalize(&q);
1014
+ return;
1015
+ }
1016
+ style_header("User %h", db_column_text(&q,1));
1017
+ @ <table class="label-value">
1018
+ @ <tr><th>uid:</th><td>%d(db_column_int(&q,0))
1019
+ @ (<a href="%R/setup_uedit?uid=%d(db_column_int(&q,0))">edit</a>)</td></tr>
1020
+ @ <tr><th>login:</th><td>%h(db_column_text(&q,1))</td></tr>
1021
+ @ <tr><th>capabilities:</th><td>%h(db_column_text(&q,2))</th></tr>
1022
+ @ <tr><th valign="top">info:</th>
1023
+ @ <td valign="top"><span style='white-space:pre-line;'>\
1024
+ @ %h(db_column_text(&q,5))</span></td></tr>
1025
+ @ <tr><th>user.mtime:</th><td>%h(db_column_text(&q,6))</td></tr>
1026
+ if( db_column_type(&q,7)!=SQLITE_NULL ){
1027
+ @ <tr><th>subscriberId:</th><td>%d(db_column_int(&q,7))
1028
+ @ (<a href="%R/alerts?sid=%d(db_column_int(&q,7))">edit</a>)</td></tr>
1029
+ @ <tr><th>semail:</th><td>%h(db_column_text(&q,8))</td></tr>
1030
+ @ <tr><th>verified:</th><td>%s(db_column_int(&q,9)?"yes":"no")</td></th>
1031
+ @ <tr><th>lastContact:</th><td>%h(db_column_text(&q,10))</td></tr>
1032
+ }
1033
+ @ </table>
1034
+ db_finalize(&q);
1035
+ style_finish_page();
1036
+}
9441037
--- src/setupuser.c
+++ src/setupuser.c
@@ -939,5 +939,98 @@
939 @ but less than a <span class="usertype">developer</span>.
940 @ </p></li>
941 @ </ul>
942 style_finish_page();
943 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
944
--- src/setupuser.c
+++ src/setupuser.c
@@ -939,5 +939,98 @@
939 @ but less than a <span class="usertype">developer</span>.
940 @ </p></li>
941 @ </ul>
942 style_finish_page();
943 }
944
945 /*
946 ** WEBPAGE: setup_uinfo
947 **
948 ** Detailed information about a user account, available to administrators
949 ** only.
950 **
951 ** u=UID
952 ** l=LOGIN
953 */
954 void setup_uinfo_page(void){
955 Stmt q;
956 Blob sql;
957 const char *zLogin;
958 int uid;
959
960 /* Must have ADMIN privileges to access this page
961 */
962 login_check_credentials();
963 if( !g.perm.Admin ){ login_needed(0); return; }
964 style_set_current_feature("setup");
965 zLogin = P("l");
966 uid = atoi(PD("u","0"));
967 if( zLogin==0 && uid==0 ){
968 uid = db_int(1,"SELECT uid FROM user");
969 }
970 blob_init(&sql, 0, 0);
971 blob_append_sql(&sql,
972 "SELECT "
973 /* 0 */ "uid,"
974 /* 1 */ "login,"
975 /* 2 */ "cap,"
976 /* 3 */ "cookie,"
977 /* 4 */ "datetime(cexpire),"
978 /* 5 */ "info,"
979 /* 6 */ "datetime(user.mtime,'unixepoch'),"
980 );
981 if( db_table_exists("repository","subscriber") ){
982 blob_append_sql(&sql,
983 /* 7 */ "subscriberId,"
984 /* 8 */ "semail,"
985 /* 9 */ "sverified,"
986 /* 10 */ "date(lastContact+2440587.5)"
987 " FROM user LEFT JOIN subscriber ON suname=login"
988 );
989 }else{
990 blob_append_sql(&sql,
991 /* 7 */ "NULL,"
992 /* 8 */ "NULL,"
993 /* 9 */ "NULL,"
994 /* 10 */ "NULL"
995 " FROM user"
996 );
997 }
998 if( zLogin!=0 ){
999 blob_append_sql(&sql, " WHERE login=%Q", zLogin);
1000 }else{
1001 blob_append_sql(&sql, " WHERE uid=%d", uid);
1002 }
1003 db_prepare(&q, "%s", blob_sql_text(&sql));
1004 blob_zero(&sql);
1005 if( db_step(&q)!=SQLITE_ROW ){
1006 style_header("No Such User");
1007 if( zLogin ){
1008 @ <p>Cannot find any information on user %h(zLogin).
1009 }else{
1010 @ <p>Cannot find any information on userid %d(uid).
1011 }
1012 style_finish_page();
1013 db_finalize(&q);
1014 return;
1015 }
1016 style_header("User %h", db_column_text(&q,1));
1017 @ <table class="label-value">
1018 @ <tr><th>uid:</th><td>%d(db_column_int(&q,0))
1019 @ (<a href="%R/setup_uedit?uid=%d(db_column_int(&q,0))">edit</a>)</td></tr>
1020 @ <tr><th>login:</th><td>%h(db_column_text(&q,1))</td></tr>
1021 @ <tr><th>capabilities:</th><td>%h(db_column_text(&q,2))</th></tr>
1022 @ <tr><th valign="top">info:</th>
1023 @ <td valign="top"><span style='white-space:pre-line;'>\
1024 @ %h(db_column_text(&q,5))</span></td></tr>
1025 @ <tr><th>user.mtime:</th><td>%h(db_column_text(&q,6))</td></tr>
1026 if( db_column_type(&q,7)!=SQLITE_NULL ){
1027 @ <tr><th>subscriberId:</th><td>%d(db_column_int(&q,7))
1028 @ (<a href="%R/alerts?sid=%d(db_column_int(&q,7))">edit</a>)</td></tr>
1029 @ <tr><th>semail:</th><td>%h(db_column_text(&q,8))</td></tr>
1030 @ <tr><th>verified:</th><td>%s(db_column_int(&q,9)?"yes":"no")</td></th>
1031 @ <tr><th>lastContact:</th><td>%h(db_column_text(&q,10))</td></tr>
1032 }
1033 @ </table>
1034 db_finalize(&q);
1035 style_finish_page();
1036 }
1037
+6 -1
--- src/timeline.c
+++ src/timeline.c
@@ -2913,11 +2913,16 @@
29132913
if( cpOnly && showCherrypicks ){
29142914
blob_appendf(&desc, " that participate in a cherrypick merge");
29152915
tmFlags |= TIMELINE_CHPICK|TIMELINE_DISJOINT;
29162916
}
29172917
if( zUser ){
2918
- blob_appendf(&desc, " by user %h", zUser);
2918
+ if( g.perm.Admin ){
2919
+ blob_appendf(&desc, " by user <a href='%R/setup_uinfo?l=%h'>%h</a>",
2920
+ zUser, zUser);
2921
+ }else{
2922
+ blob_appendf(&desc, " by user %h", zUser);
2923
+ }
29192924
tmFlags |= TIMELINE_XMERGE | TIMELINE_FILLGAPS;
29202925
}
29212926
if( zTagSql ){
29222927
if( matchStyle==MS_EXACT || matchStyle==MS_BRLIST ){
29232928
if( related ){
29242929
--- src/timeline.c
+++ src/timeline.c
@@ -2913,11 +2913,16 @@
2913 if( cpOnly && showCherrypicks ){
2914 blob_appendf(&desc, " that participate in a cherrypick merge");
2915 tmFlags |= TIMELINE_CHPICK|TIMELINE_DISJOINT;
2916 }
2917 if( zUser ){
2918 blob_appendf(&desc, " by user %h", zUser);
 
 
 
 
 
2919 tmFlags |= TIMELINE_XMERGE | TIMELINE_FILLGAPS;
2920 }
2921 if( zTagSql ){
2922 if( matchStyle==MS_EXACT || matchStyle==MS_BRLIST ){
2923 if( related ){
2924
--- src/timeline.c
+++ src/timeline.c
@@ -2913,11 +2913,16 @@
2913 if( cpOnly && showCherrypicks ){
2914 blob_appendf(&desc, " that participate in a cherrypick merge");
2915 tmFlags |= TIMELINE_CHPICK|TIMELINE_DISJOINT;
2916 }
2917 if( zUser ){
2918 if( g.perm.Admin ){
2919 blob_appendf(&desc, " by user <a href='%R/setup_uinfo?l=%h'>%h</a>",
2920 zUser, zUser);
2921 }else{
2922 blob_appendf(&desc, " by user %h", zUser);
2923 }
2924 tmFlags |= TIMELINE_XMERGE | TIMELINE_FILLGAPS;
2925 }
2926 if( zTagSql ){
2927 if( matchStyle==MS_EXACT || matchStyle==MS_BRLIST ){
2928 if( related ){
2929

Keyboard Shortcuts

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