@@ -49,28 +49,49 @@ public static function getInstance() {
49
49
}
50
50
51
51
public function __construct () {
52
- $ this ->autocreate = OCP \Config::getAppValue ('user_cas ' , 'cas_autocreate ' , true );
53
- $ this ->cas_link_to_ldap_backend = \OCP \Config::getAppValue ('user_cas ' , 'cas_link_to_ldap_backend ' , false );
54
- $ this ->updateUserData = OCP \Config::getAppValue ('user_cas ' , 'cas_update_user_data ' , true );
55
- $ this ->defaultGroup = OCP \Config::getAppValue ('user_cas ' , 'cas_default_group ' , '' );
56
- $ this ->protectedGroups = explode (', ' , str_replace (' ' , '' , OCP \Config::getAppValue ('user_cas ' , 'cas_protected_groups ' , '' )));
57
- $ this ->mailMapping = OCP \Config::getAppValue ('user_cas ' , 'cas_email_mapping ' , '' );
58
- $ this ->displayNameMapping = OCP \Config::getAppValue ('user_cas ' , 'cas_displayName_mapping ' , '' );
59
- $ this ->groupMapping = OCP \Config::getAppValue ('user_cas ' , 'cas_group_mapping ' , '' );
52
+ // copy system settings to app settings when app is initialized for the first time.
53
+ if ( ! self ::getAppValue ('system_defaults_loaded ' , false )) {
54
+ self ::setAppValue ('cas_autocreate ' , self ::getSystemValue ('cas_autocreate ' , true ));
55
+ self ::setAppValue ('cas_force_login ' , self ::getSystemValue ('cas_force_login ' , false ));
56
+ self ::setAppValue ('cas_link_to_ldap_backend ' , self ::getSystemValue ('cas_link_to_ldap_backend ' , false ));
57
+ self ::setAppValue ('cas_update_user_data ' , self ::getSystemValue ('cas_update_user_data ' , true ));
58
+ self ::setAppValue ('cas_default_group ' , self ::getSystemValue ('cas_default_group ' , '' ));
59
+ self ::setAppValue ('cas_protected_groups ' , self ::getSystemValue ('cas_protected_groups ' , '' ));
60
+ self ::setAppValue ('cas_email_mapping ' , self ::getSystemValue ('cas_email_mapping ' , '' ));
61
+ self ::setAppValue ('cas_displayName_mapping ' , self ::getSystemValue ('cas_displayName_mapping ' , '' ));
62
+ self ::setAppValue ('cas_group_mapping ' , self ::getSystemValue ('cas_group_mapping ' , '' ));
63
+ self ::setAppValue ('cas_server_version ' , self ::getSystemValue ('cas_server_version ' , '2.0 ' ));
64
+ self ::setAppValue ('cas_server_hostname ' , self ::getSystemValue ('cas_server_hostname ' , $ _SERVER ['SERVER_NAME ' ]));
65
+ self ::setAppValue ('cas_server_port ' , self ::getSystemValue ('cas_server_port ' , 443 ));
66
+ self ::setAppValue ('cas_server_path ' , self ::getSystemValue ('cas_server_path ' , '/cas ' ));
67
+ self ::setAppValue ('cas_debug_file ' , self ::getSystemValue ('cas_debug_file ' , '' ));
68
+ self ::setAppValue ('cas_cert_path ' , self ::getSystemValue ('cas_cert_path ' , '' ));
69
+ self ::setAppValue ('cas_php_cas_path ' , self ::getSystemValue ('cas_php_cas_path ' , 'CAS.php ' ));
70
+ self ::setAppValue ('cas_service_url ' , self ::getSystemValue ('cas_service_url ' , '' ));
71
+ self ::setAppValue ('system_defaults_loaded ' , true );
72
+ }
73
+ $ this ->autocreate = self ::getAppValue ('cas_autocreate ' , true );
74
+ $ this ->cas_link_to_ldap_backend = self ::getAppValue ('cas_link_to_ldap_backend ' , false );
75
+ $ this ->updateUserData = self ::getAppValue ('cas_update_user_data ' , true );
76
+ $ this ->defaultGroup = self ::getAppValue ('cas_default_group ' , '' );
77
+ $ this ->protectedGroups = explode (', ' , str_replace (' ' , '' , self ::getAppValue ('cas_protected_groups ' , '' )));
78
+ $ this ->mailMapping = self ::getAppValue ('cas_email_mapping ' , '' );
79
+ $ this ->displayNameMapping = self ::getAppValue ('cas_displayName_mapping ' , '' );
80
+ $ this ->groupMapping = self ::getAppValue ('cas_group_mapping ' , '' );
60
81
61
82
self :: initialized_php_cas ();
62
83
}
63
84
64
85
public static function initialized_php_cas () {
65
86
if (!self :: $ _initialized_php_cas ) {
66
- $ casVersion = OCP \Config ::getAppValue (' user_cas ' , 'cas_server_version ' , '2.0 ' );
67
- $ casHostname = OCP \Config ::getAppValue (' user_cas ' , 'cas_server_hostname ' , $ _SERVER ['SERVER_NAME ' ]);
68
- $ casPort = OCP \Config ::getAppValue (' user_cas ' , 'cas_server_port ' , 443 );
69
- $ casPath = OCP \Config ::getAppValue (' user_cas ' , 'cas_server_path ' , '/cas ' );
70
- $ casDebugFile =OCP \Config ::getAppValue (' user_cas ' , 'cas_debug_file ' , '' );
71
- $ casCertPath = OCP \Config ::getAppValue (' user_cas ' , 'cas_cert_path ' , '' );
72
- $ php_cas_path =OCP \Config ::getAppValue (' user_cas ' , 'cas_php_cas_path ' , 'CAS.php ' );
73
- $ cas_service_url = OCP \Config ::getAppValue (' user_cas ' , 'cas_service_url ' , '' );
87
+ $ casVersion = self ::getAppValue ('cas_server_version ' , '2.0 ' );
88
+ $ casHostname = self ::getAppValue ('cas_server_hostname ' , $ _SERVER ['SERVER_NAME ' ]);
89
+ $ casPort = self ::getAppValue ('cas_server_port ' , 443 );
90
+ $ casPath = self ::getAppValue ('cas_server_path ' , '/cas ' );
91
+ $ casDebugFile =self ::getAppValue ('cas_debug_file ' , '' );
92
+ $ casCertPath = self ::getAppValue ('cas_cert_path ' , '' );
93
+ $ php_cas_path =self ::getAppValue ('cas_php_cas_path ' , 'CAS.php ' );
94
+ $ cas_service_url = self ::getAppValue ('cas_service_url ' , '' );
74
95
75
96
if (!class_exists ('phpCAS ' )) {
76
97
if (empty ($ php_cas_path )) $ php_cas_path ='CAS.php ' ;
@@ -156,5 +177,17 @@ public function setDisplayName($uid,$displayName) {
156
177
$ udb ->setDisplayName ($ uid ,$ displayName );
157
178
}
158
179
180
+ protected static function getAppValue ($ id , $ default ) {
181
+ return \OCP \Config::getAppValue ('user_cas ' , $ id , $ default );
182
+ }
183
+
184
+ protected static function setAppValue ($ id , $ value ) {
185
+ return \OCP \Config::setAppValue ('user_cas ' , $ id , $ value );
186
+ }
187
+
188
+ protected static function getSystemValue ($ id , $ default ) {
189
+ return \OCP \Config::getSystemValue ($ id , $ default );
190
+ }
191
+
159
192
}
160
193
0 commit comments