Fossil SCM

If versionable settings are present, disallow editing of the corresponding fields in the /setup_settings page.

jan.nijtmans 2013-05-07 08:17 trunk
Commit 3cba68a83ee996655f5b1ff8dc2399a835927410
2 files changed +1 -1 +9 -6
+1 -1
--- src/db.c
+++ src/db.c
@@ -1681,11 +1681,11 @@
16811681
** Logic for reading potentially versioned settings from
16821682
** .fossil-settings/<name> , and emits warnings if necessary.
16831683
** Returns the non-versioned value without modification if there is no
16841684
** versioned value.
16851685
*/
1686
-static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){
1686
+char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){
16871687
char *zVersionedSetting = 0;
16881688
int noWarn = 0;
16891689
struct _cacheEntry {
16901690
struct _cacheEntry *next;
16911691
const char *zName, *zValue;
16921692
--- 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 @@
773773
int dfltVal, /* Default value if VAR table entry does not exist */
774774
int disabled /* 1 if disabled */
775775
){
776776
const char *zQ = P(zQParm);
777777
int iVal = db_get_boolean(zVar, dfltVal);
778
- if( zQ==0 && P("submit") ){
778
+ if( zQ==0 && !disabled && P("submit") ){
779779
zQ = "off";
780780
}
781781
if( zQ ){
782782
int iQ = fossil_strcmp(zQ,"on")==0 || atoi(zQ);
783783
if( iQ!=iVal ){
@@ -833,11 +833,11 @@
833833
const char *zDflt, /* Default value if VAR table entry does not exist */
834834
int disabled /* 1 if the textarea should not be editable */
835835
){
836836
const char *z = db_get(zVar, (char*)zDflt);
837837
const char *zQ = P(zQP);
838
- if( zQ && fossil_strcmp(zQ,z)!=0 ){
838
+ if( zQ && !disabled && fossil_strcmp(zQ,z)!=0){
839839
login_verify_csrf_secret();
840840
db_set(zVar, zQ, 0);
841841
z = zQ;
842842
}
843843
if( rows>0 && cols>0 ){
@@ -1209,14 +1209,15 @@
12091209
@ the meaning of each setting.</p><hr />
12101210
@ <form action="%s(g.zTop)/setup_settings" method="post"><div>
12111211
@ <table border="0"><tr><td valign="top">
12121212
login_insert_csrf_secret();
12131213
for(pSet=ctrlSettings; pSet->name!=0; pSet++){
1214
+ int hasVersionableValue = db_get_do_versionable(pSet->name, NULL)!=0;
12141215
if( pSet->width==0 ){
12151216
onoff_attribute(pSet->name, pSet->name,
12161217
pSet->var!=0 ? pSet->var : pSet->name,
1217
- is_truth(pSet->def), 0);
1218
+ is_truth(pSet->def), hasVersionableValue);
12181219
if( pSet->versionable ){
12191220
@ (v)<br />
12201221
} else {
12211222
@ <br />
12221223
}
@@ -1231,24 +1232,26 @@
12311232
@ <br />
12321233
}
12331234
}
12341235
@ </td><td style="width:50px;"></td><td valign="top">
12351236
for(pSet=ctrlSettings; pSet->name!=0; pSet++){
1237
+ int hasVersionableValue = db_get_do_versionable(pSet->name, NULL)!=0;
12361238
if( pSet->width!=0 && pSet->versionable){
12371239
@<b>%s(pSet->name)</b> (v)<br />
12381240
textarea_attribute("", /*rows*/ 3, /*cols*/ 20, pSet->name,
12391241
pSet->var!=0 ? pSet->var : pSet->name,
1240
- (char*)pSet->def, 0);
1242
+ (char*)pSet->def, hasVersionableValue);
12411243
@<br />
12421244
}
12431245
}
12441246
@ </td></tr></table>
12451247
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
12461248
@ </div></form>
12471249
@ <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>
12501253
@ These settings work in the same way, as the <kbd>set</kbd>
12511254
@ commandline:<br />
12521255
@ </p><pre>%s(zHelp_setting_cmd)</pre>
12531256
db_end_transaction(0);
12541257
style_footer();
12551258
--- 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

Keyboard Shortcuts

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