Fossil SCM
If versionable settings are present, disallow editing of the corresponding fields in the /setup_settings page.
Commit
3cba68a83ee996655f5b1ff8dc2399a835927410
Parent
10d8abcd0c20aca…
2 files changed
+1
-1
+9
-6
M
src/db.c
+1
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1681,11 +1681,11 @@ | ||
| 1681 | 1681 | ** Logic for reading potentially versioned settings from |
| 1682 | 1682 | ** .fossil-settings/<name> , and emits warnings if necessary. |
| 1683 | 1683 | ** Returns the non-versioned value without modification if there is no |
| 1684 | 1684 | ** versioned value. |
| 1685 | 1685 | */ |
| 1686 | -static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ | |
| 1686 | +char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ | |
| 1687 | 1687 | char *zVersionedSetting = 0; |
| 1688 | 1688 | int noWarn = 0; |
| 1689 | 1689 | struct _cacheEntry { |
| 1690 | 1690 | struct _cacheEntry *next; |
| 1691 | 1691 | const char *zName, *zValue; |
| 1692 | 1692 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1681,11 +1681,11 @@ | |
| 1681 | ** Logic for reading potentially versioned settings from |
| 1682 | ** .fossil-settings/<name> , and emits warnings if necessary. |
| 1683 | ** Returns the non-versioned value without modification if there is no |
| 1684 | ** versioned value. |
| 1685 | */ |
| 1686 | static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ |
| 1687 | char *zVersionedSetting = 0; |
| 1688 | int noWarn = 0; |
| 1689 | struct _cacheEntry { |
| 1690 | struct _cacheEntry *next; |
| 1691 | const char *zName, *zValue; |
| 1692 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1681,11 +1681,11 @@ | |
| 1681 | ** Logic for reading potentially versioned settings from |
| 1682 | ** .fossil-settings/<name> , and emits warnings if necessary. |
| 1683 | ** Returns the non-versioned value without modification if there is no |
| 1684 | ** versioned value. |
| 1685 | */ |
| 1686 | char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ |
| 1687 | char *zVersionedSetting = 0; |
| 1688 | int noWarn = 0; |
| 1689 | struct _cacheEntry { |
| 1690 | struct _cacheEntry *next; |
| 1691 | const char *zName, *zValue; |
| 1692 |
+9
-6
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -773,11 +773,11 @@ | ||
| 773 | 773 | int dfltVal, /* Default value if VAR table entry does not exist */ |
| 774 | 774 | int disabled /* 1 if disabled */ |
| 775 | 775 | ){ |
| 776 | 776 | const char *zQ = P(zQParm); |
| 777 | 777 | int iVal = db_get_boolean(zVar, dfltVal); |
| 778 | - if( zQ==0 && P("submit") ){ | |
| 778 | + if( zQ==0 && !disabled && P("submit") ){ | |
| 779 | 779 | zQ = "off"; |
| 780 | 780 | } |
| 781 | 781 | if( zQ ){ |
| 782 | 782 | int iQ = fossil_strcmp(zQ,"on")==0 || atoi(zQ); |
| 783 | 783 | if( iQ!=iVal ){ |
| @@ -833,11 +833,11 @@ | ||
| 833 | 833 | const char *zDflt, /* Default value if VAR table entry does not exist */ |
| 834 | 834 | int disabled /* 1 if the textarea should not be editable */ |
| 835 | 835 | ){ |
| 836 | 836 | const char *z = db_get(zVar, (char*)zDflt); |
| 837 | 837 | const char *zQ = P(zQP); |
| 838 | - if( zQ && fossil_strcmp(zQ,z)!=0 ){ | |
| 838 | + if( zQ && !disabled && fossil_strcmp(zQ,z)!=0){ | |
| 839 | 839 | login_verify_csrf_secret(); |
| 840 | 840 | db_set(zVar, zQ, 0); |
| 841 | 841 | z = zQ; |
| 842 | 842 | } |
| 843 | 843 | if( rows>0 && cols>0 ){ |
| @@ -1209,14 +1209,15 @@ | ||
| 1209 | 1209 | @ the meaning of each setting.</p><hr /> |
| 1210 | 1210 | @ <form action="%s(g.zTop)/setup_settings" method="post"><div> |
| 1211 | 1211 | @ <table border="0"><tr><td valign="top"> |
| 1212 | 1212 | login_insert_csrf_secret(); |
| 1213 | 1213 | for(pSet=ctrlSettings; pSet->name!=0; pSet++){ |
| 1214 | + int hasVersionableValue = db_get_do_versionable(pSet->name, NULL)!=0; | |
| 1214 | 1215 | if( pSet->width==0 ){ |
| 1215 | 1216 | onoff_attribute(pSet->name, pSet->name, |
| 1216 | 1217 | pSet->var!=0 ? pSet->var : pSet->name, |
| 1217 | - is_truth(pSet->def), 0); | |
| 1218 | + is_truth(pSet->def), hasVersionableValue); | |
| 1218 | 1219 | if( pSet->versionable ){ |
| 1219 | 1220 | @ (v)<br /> |
| 1220 | 1221 | } else { |
| 1221 | 1222 | @ <br /> |
| 1222 | 1223 | } |
| @@ -1231,24 +1232,26 @@ | ||
| 1231 | 1232 | @ <br /> |
| 1232 | 1233 | } |
| 1233 | 1234 | } |
| 1234 | 1235 | @ </td><td style="width:50px;"></td><td valign="top"> |
| 1235 | 1236 | for(pSet=ctrlSettings; pSet->name!=0; pSet++){ |
| 1237 | + int hasVersionableValue = db_get_do_versionable(pSet->name, NULL)!=0; | |
| 1236 | 1238 | if( pSet->width!=0 && pSet->versionable){ |
| 1237 | 1239 | @<b>%s(pSet->name)</b> (v)<br /> |
| 1238 | 1240 | textarea_attribute("", /*rows*/ 3, /*cols*/ 20, pSet->name, |
| 1239 | 1241 | pSet->var!=0 ? pSet->var : pSet->name, |
| 1240 | - (char*)pSet->def, 0); | |
| 1242 | + (char*)pSet->def, hasVersionableValue); | |
| 1241 | 1243 | @<br /> |
| 1242 | 1244 | } |
| 1243 | 1245 | } |
| 1244 | 1246 | @ </td></tr></table> |
| 1245 | 1247 | @ <p><input type="submit" name="submit" value="Apply Changes" /></p> |
| 1246 | 1248 | @ </div></form> |
| 1247 | 1249 | @ <p>Settings marked with (v) are 'versionable' and will be overridden |
| 1248 | - @ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>.</p> | |
| 1249 | - @ <hr /><p> | |
| 1250 | + @ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>. | |
| 1251 | + @ If such a file is present, the corresponding field above is not | |
| 1252 | + @ editable.</p><hr /><p> | |
| 1250 | 1253 | @ These settings work in the same way, as the <kbd>set</kbd> |
| 1251 | 1254 | @ commandline:<br /> |
| 1252 | 1255 | @ </p><pre>%s(zHelp_setting_cmd)</pre> |
| 1253 | 1256 | db_end_transaction(0); |
| 1254 | 1257 | style_footer(); |
| 1255 | 1258 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -773,11 +773,11 @@ | |
| 773 | int dfltVal, /* Default value if VAR table entry does not exist */ |
| 774 | int disabled /* 1 if disabled */ |
| 775 | ){ |
| 776 | const char *zQ = P(zQParm); |
| 777 | int iVal = db_get_boolean(zVar, dfltVal); |
| 778 | if( zQ==0 && P("submit") ){ |
| 779 | zQ = "off"; |
| 780 | } |
| 781 | if( zQ ){ |
| 782 | int iQ = fossil_strcmp(zQ,"on")==0 || atoi(zQ); |
| 783 | if( iQ!=iVal ){ |
| @@ -833,11 +833,11 @@ | |
| 833 | const char *zDflt, /* Default value if VAR table entry does not exist */ |
| 834 | int disabled /* 1 if the textarea should not be editable */ |
| 835 | ){ |
| 836 | const char *z = db_get(zVar, (char*)zDflt); |
| 837 | const char *zQ = P(zQP); |
| 838 | if( zQ && fossil_strcmp(zQ,z)!=0 ){ |
| 839 | login_verify_csrf_secret(); |
| 840 | db_set(zVar, zQ, 0); |
| 841 | z = zQ; |
| 842 | } |
| 843 | if( rows>0 && cols>0 ){ |
| @@ -1209,14 +1209,15 @@ | |
| 1209 | @ the meaning of each setting.</p><hr /> |
| 1210 | @ <form action="%s(g.zTop)/setup_settings" method="post"><div> |
| 1211 | @ <table border="0"><tr><td valign="top"> |
| 1212 | login_insert_csrf_secret(); |
| 1213 | for(pSet=ctrlSettings; pSet->name!=0; pSet++){ |
| 1214 | if( pSet->width==0 ){ |
| 1215 | onoff_attribute(pSet->name, pSet->name, |
| 1216 | pSet->var!=0 ? pSet->var : pSet->name, |
| 1217 | is_truth(pSet->def), 0); |
| 1218 | if( pSet->versionable ){ |
| 1219 | @ (v)<br /> |
| 1220 | } else { |
| 1221 | @ <br /> |
| 1222 | } |
| @@ -1231,24 +1232,26 @@ | |
| 1231 | @ <br /> |
| 1232 | } |
| 1233 | } |
| 1234 | @ </td><td style="width:50px;"></td><td valign="top"> |
| 1235 | for(pSet=ctrlSettings; pSet->name!=0; pSet++){ |
| 1236 | if( pSet->width!=0 && pSet->versionable){ |
| 1237 | @<b>%s(pSet->name)</b> (v)<br /> |
| 1238 | textarea_attribute("", /*rows*/ 3, /*cols*/ 20, pSet->name, |
| 1239 | pSet->var!=0 ? pSet->var : pSet->name, |
| 1240 | (char*)pSet->def, 0); |
| 1241 | @<br /> |
| 1242 | } |
| 1243 | } |
| 1244 | @ </td></tr></table> |
| 1245 | @ <p><input type="submit" name="submit" value="Apply Changes" /></p> |
| 1246 | @ </div></form> |
| 1247 | @ <p>Settings marked with (v) are 'versionable' and will be overridden |
| 1248 | @ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>.</p> |
| 1249 | @ <hr /><p> |
| 1250 | @ These settings work in the same way, as the <kbd>set</kbd> |
| 1251 | @ commandline:<br /> |
| 1252 | @ </p><pre>%s(zHelp_setting_cmd)</pre> |
| 1253 | db_end_transaction(0); |
| 1254 | style_footer(); |
| 1255 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -773,11 +773,11 @@ | |
| 773 | int dfltVal, /* Default value if VAR table entry does not exist */ |
| 774 | int disabled /* 1 if disabled */ |
| 775 | ){ |
| 776 | const char *zQ = P(zQParm); |
| 777 | int iVal = db_get_boolean(zVar, dfltVal); |
| 778 | if( zQ==0 && !disabled && P("submit") ){ |
| 779 | zQ = "off"; |
| 780 | } |
| 781 | if( zQ ){ |
| 782 | int iQ = fossil_strcmp(zQ,"on")==0 || atoi(zQ); |
| 783 | if( iQ!=iVal ){ |
| @@ -833,11 +833,11 @@ | |
| 833 | const char *zDflt, /* Default value if VAR table entry does not exist */ |
| 834 | int disabled /* 1 if the textarea should not be editable */ |
| 835 | ){ |
| 836 | const char *z = db_get(zVar, (char*)zDflt); |
| 837 | const char *zQ = P(zQP); |
| 838 | if( zQ && !disabled && fossil_strcmp(zQ,z)!=0){ |
| 839 | login_verify_csrf_secret(); |
| 840 | db_set(zVar, zQ, 0); |
| 841 | z = zQ; |
| 842 | } |
| 843 | if( rows>0 && cols>0 ){ |
| @@ -1209,14 +1209,15 @@ | |
| 1209 | @ the meaning of each setting.</p><hr /> |
| 1210 | @ <form action="%s(g.zTop)/setup_settings" method="post"><div> |
| 1211 | @ <table border="0"><tr><td valign="top"> |
| 1212 | login_insert_csrf_secret(); |
| 1213 | for(pSet=ctrlSettings; pSet->name!=0; pSet++){ |
| 1214 | int hasVersionableValue = db_get_do_versionable(pSet->name, NULL)!=0; |
| 1215 | if( pSet->width==0 ){ |
| 1216 | onoff_attribute(pSet->name, pSet->name, |
| 1217 | pSet->var!=0 ? pSet->var : pSet->name, |
| 1218 | is_truth(pSet->def), hasVersionableValue); |
| 1219 | if( pSet->versionable ){ |
| 1220 | @ (v)<br /> |
| 1221 | } else { |
| 1222 | @ <br /> |
| 1223 | } |
| @@ -1231,24 +1232,26 @@ | |
| 1232 | @ <br /> |
| 1233 | } |
| 1234 | } |
| 1235 | @ </td><td style="width:50px;"></td><td valign="top"> |
| 1236 | for(pSet=ctrlSettings; pSet->name!=0; pSet++){ |
| 1237 | int hasVersionableValue = db_get_do_versionable(pSet->name, NULL)!=0; |
| 1238 | if( pSet->width!=0 && pSet->versionable){ |
| 1239 | @<b>%s(pSet->name)</b> (v)<br /> |
| 1240 | textarea_attribute("", /*rows*/ 3, /*cols*/ 20, pSet->name, |
| 1241 | pSet->var!=0 ? pSet->var : pSet->name, |
| 1242 | (char*)pSet->def, hasVersionableValue); |
| 1243 | @<br /> |
| 1244 | } |
| 1245 | } |
| 1246 | @ </td></tr></table> |
| 1247 | @ <p><input type="submit" name="submit" value="Apply Changes" /></p> |
| 1248 | @ </div></form> |
| 1249 | @ <p>Settings marked with (v) are 'versionable' and will be overridden |
| 1250 | @ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>. |
| 1251 | @ If such a file is present, the corresponding field above is not |
| 1252 | @ editable.</p><hr /><p> |
| 1253 | @ These settings work in the same way, as the <kbd>set</kbd> |
| 1254 | @ commandline:<br /> |
| 1255 | @ </p><pre>%s(zHelp_setting_cmd)</pre> |
| 1256 | db_end_transaction(0); |
| 1257 | style_footer(); |
| 1258 |