@@ -41,6 +41,8 @@ class AJXP_Role implements AjxpGroupPathProvider
41
41
protected $ actions = array ();
42
42
protected $ autoApplies = array ();
43
43
44
+ static $ cypheredPassPrefix = '$pydio_password$ ' ;
45
+
44
46
public function __construct ($ id )
45
47
{
46
48
$ this ->roleId = $ id ;
@@ -146,12 +148,12 @@ public function clearAcls()
146
148
* Send all role informations as an associative array
147
149
* @return array
148
150
*/
149
- public function getDataArray ()
151
+ public function getDataArray ($ blurPasswords = false )
150
152
{
151
153
$ roleData = array ();
152
154
$ roleData ["ACL " ] = $ this ->listAcls ();
153
155
$ roleData ["ACTIONS " ] = $ this ->listActionsStates ();
154
- $ roleData ["PARAMETERS " ] = $ this ->listParameters ();
156
+ $ roleData ["PARAMETERS " ] = $ this ->listParameters (false , $ blurPasswords );
155
157
$ roleData ["APPLIES " ] = $ this ->listAutoApplies ();
156
158
return $ roleData ;
157
159
}
@@ -204,28 +206,54 @@ public function filterParameterValue($pluginId, $parameterName, $repositoryId, $
204
206
if (isSet ($ this ->parameters [AJXP_REPO_SCOPE_ALL ][$ pluginId ][$ parameterName ])) {
205
207
$ v = $ this ->parameters [AJXP_REPO_SCOPE_ALL ][$ pluginId ][$ parameterName ];
206
208
if ($ v === AJXP_VALUE_CLEAR ) return "" ;
207
- else return $ v ;
209
+ else return $ this -> filterCypheredPasswordValue ( $ v ) ;
208
210
}
209
211
if (isSet ($ this ->parameters [$ repositoryId ][$ pluginId ][$ parameterName ])) {
210
212
$ v = $ this ->parameters [$ repositoryId ][$ pluginId ][$ parameterName ];
211
213
if ($ v === AJXP_VALUE_CLEAR ) return "" ;
212
- else return $ v ;
214
+ else return $ this -> filterCypheredPasswordValue ( $ v ) ;
213
215
}
214
216
return $ parameterValue ;
215
217
}
218
+
216
219
/**
220
+ * @param bool $preserveCypheredPasswords
221
+ * @param bool $blurCypheredPasswords
217
222
* @return array Associative array of parameters : array[REPO_ID][PLUGIN_ID][PARAMETER_NAME] = PARAMETER_VALUE
218
223
*/
219
- public function listParameters ()
224
+ public function listParameters ($ preserveCypheredPasswords = false , $ blurCypheredPasswords = false )
220
225
{
221
- return $ this ->parameters ;
226
+ if ($ preserveCypheredPasswords ) return $ this ->parameters ;
227
+
228
+ $ copy = $ this ->parameters ;
229
+ foreach ($ copy as $ repo => &$ plugs ){
230
+ foreach ($ plugs as $ plugName => &$ plugData ){
231
+ foreach ($ plugData as $ paramName => &$ paramValue ){
232
+ $ testValue = $ this ->filterCypheredPasswordValue ($ paramValue );
233
+ if ($ testValue != $ paramValue ){
234
+ if ($ blurCypheredPasswords ) $ paramValue = "__AJXP_VALUE_SET__ " ;
235
+ else $ paramValue = $ testValue ;
236
+ }
237
+ }
238
+ }
239
+ }
240
+ return $ copy ;
222
241
}
223
242
224
243
public function listAutoApplies ()
225
244
{
226
245
return $ this ->autoApplies ;
227
246
}
228
247
248
+ /**
249
+ * @param String $value
250
+ * @return String
251
+ */
252
+ private function filterCypheredPasswordValue ($ value ){
253
+ if (is_string ($ value ) && strpos ($ value , self ::$ cypheredPassPrefix ) === 0 ) return str_replace (self ::$ cypheredPassPrefix , "" , $ value );
254
+ return $ value ;
255
+ }
256
+
229
257
/**
230
258
* @param string $pluginId
231
259
* @param string $actionName
@@ -302,7 +330,7 @@ public function override(AJXP_Role $role)
302
330
$ newRole ->setAcl ($ repoId , $ rightString );
303
331
}
304
332
305
- $ newParams = $ this ->array_merge_recursive2 ($ role ->listParameters (), $ this ->listParameters ());
333
+ $ newParams = $ this ->array_merge_recursive2 ($ role ->listParameters (true ), $ this ->listParameters (true ));
306
334
foreach ($ newParams as $ repoId => $ data ) {
307
335
foreach ($ data as $ pluginId => $ param ) {
308
336
foreach ($ param as $ parameterName => $ parameterValue ) {
0 commit comments