1
- /*
1
+ /*
2
2
* Copyright (C) 2000 - 2012 Silverpeas
3
3
*
4
4
* This program is free software: you can redistribute it and/or modify
@@ -36,16 +36,19 @@ function isAUserGroup(object) {
36
36
}
37
37
38
38
function UserProfile ( user ) {
39
-
40
39
var self = this ;
40
+
41
+ var userProfileManagementParams = $ . extend ( { extended : false , async :true } , user ) ;
41
42
var usermgt = new UserProfileManagement ( {
42
- id : user . id
43
+ id : userProfileManagementParams . id ,
44
+ extended : userProfileManagementParams . extended ,
45
+ async : userProfileManagementParams . async
43
46
} ) ;
44
-
47
+
45
48
if ( user != null )
46
49
for ( var prop in user )
47
50
this [ prop ] = user [ prop ] ;
48
-
51
+
49
52
/**
50
53
* Loads the attributes of the profile of this user.
51
54
* Whether a callback is passed as argument, invokes the callback with this user profile once its
@@ -67,7 +70,7 @@ function UserProfile(user) {
67
70
} ) ;
68
71
return self ;
69
72
}
70
-
73
+
71
74
/**
72
75
* Sets this user as having access priviledges in the specified component instance
73
76
* (the unique identifier of the component instance).
@@ -131,7 +134,7 @@ function UserProfile(user) {
131
134
var callback = arguments [ arg ] ;
132
135
if ( usermgt . users == null ) {
133
136
toload = true ;
134
- }
137
+ }
135
138
if ( usermgt . filter . name != name ) {
136
139
usermgt . filter . name = name ;
137
140
toload = true ;
@@ -140,7 +143,7 @@ function UserProfile(user) {
140
143
if ( usermgt . filter . pagination == null || usermgt . filter . pagination . page != page ||
141
144
usermgt . filter . pagination . count != pagesize ) {
142
145
usermgt . filter . pagination = {
143
- page : page ,
146
+ page : page ,
144
147
count : pagesize
145
148
} ;
146
149
toload = true ;
@@ -154,11 +157,11 @@ function UserProfile(user) {
154
157
usermgt . get ( {
155
158
contacts : true
156
159
} , callback ) ;
157
- else
160
+ else
158
161
callback ( usermgt . users ) ;
159
162
return self ;
160
163
}
161
-
164
+
162
165
/**
163
166
* Gets the loaded relationships.
164
167
* Returns null if the relationships were not loaded.
@@ -173,15 +176,15 @@ function UserProfile(user) {
173
176
* It provides additional methods.
174
177
*/
175
178
function UserGroup ( group ) {
176
-
179
+
177
180
var self = this ;
178
181
var subgroupmgt = new UserGroupManagement ( ) ;
179
182
var usermgt = new UserProfileManagement ( ) ;
180
-
183
+
181
184
if ( group != null )
182
185
for ( var prop in group )
183
186
this [ prop ] = group [ prop ] ;
184
-
187
+
185
188
/**
186
189
* Sets this user group as having access priviledges in the specified component instance
187
190
* (the unique identifier of the component instance).
@@ -241,7 +244,7 @@ function UserGroup(group) {
241
244
} ) ;
242
245
return self ;
243
246
}
244
-
247
+
245
248
/**
246
249
* Loads the children (subgroups) of this user group, and calls the specified callback operation
247
250
* by passing it the fetched subgroups.
@@ -259,11 +262,11 @@ function UserGroup(group) {
259
262
name : name ,
260
263
url : self . childrenUri
261
264
} , callback ) ;
262
- } else
265
+ } else
263
266
callback ( subgroupmgt . groups ) ;
264
267
return self ;
265
268
}
266
-
269
+
267
270
/**
268
271
* Loads the nth page of the users that belong to this group (and its subgroups), and calls the
269
272
* specified callback operation by passing it the fetched users.
@@ -292,7 +295,7 @@ function UserGroup(group) {
292
295
if ( usermgt . users == null ) {
293
296
usermgt . filter . group = self . id ;
294
297
toload = true ;
295
- }
298
+ }
296
299
if ( usermgt . filter . name != name ) {
297
300
usermgt . filter . name = name ;
298
301
toload = true ;
@@ -301,7 +304,7 @@ function UserGroup(group) {
301
304
if ( usermgt . filter . pagination == null || usermgt . filter . pagination . page != page ||
302
305
usermgt . filter . pagination . count != pagesize ) {
303
306
usermgt . filter . pagination = {
304
- page : page ,
307
+ page : page ,
305
308
count : pagesize
306
309
} ;
307
310
toload = true ;
@@ -313,19 +316,19 @@ function UserGroup(group) {
313
316
}
314
317
if ( toload )
315
318
usermgt . get ( callback ) ;
316
- else
319
+ else
317
320
callback ( usermgt . users ) ;
318
321
return self ;
319
322
}
320
-
323
+
321
324
/**
322
325
* Gets the loaded subgroups of this user group.
323
326
* Null is returned if the subgroups are not loaded.
324
327
*/
325
328
this . children = function ( ) {
326
329
return subgroupmgt . groups ;
327
330
}
328
-
331
+
329
332
/**
330
333
* Gets the loaded users in this user group.
331
334
* Null is returned if the users are not loaded.
@@ -351,11 +354,12 @@ var rootUserGroup = new UserGroup({
351
354
* You can give some parameters to filter the users on which this object works.
352
355
*/
353
356
function UserProfileManagement ( params ) {
354
-
357
+
355
358
var self = this ;
356
-
359
+
357
360
this . filter = {
358
361
id : null , // the unique identifier of a user to get
362
+ extended : false , // a flag to load user full details
359
363
contacts : false , // the contacts of the refered user. The id must be set to be taken into account
360
364
group : null , // a user group unique identifier
361
365
name : null , // a pattern about a user name (* is a wildcard)
@@ -364,10 +368,10 @@ function UserProfileManagement(params) {
364
368
resource : null , // an identifier of a resource belonging to a component instance (the identifier
365
369
// must be set the resource type following by resource identifier in Silverpeas).
366
370
roles : null , // a string with a comma-separated role names
367
- pagination : null // pagination data in the form of
371
+ pagination : null // pagination data in the form of
368
372
// { page: <number of the page>, count: <count of users to fetch> }
369
373
} ;
370
-
374
+
371
375
/**
372
376
* The filtering parameters about the user profiles to get.
373
377
*/
@@ -376,7 +380,7 @@ function UserProfileManagement(params) {
376
380
for ( var prop in params )
377
381
self . filter [ prop ] = params [ prop ] ;
378
382
}
379
-
383
+
380
384
/**
381
385
* Decorates the user profiles with usefull method to improve the usability.
382
386
*/
@@ -390,12 +394,12 @@ function UserProfileManagement(params) {
390
394
}
391
395
return decoratedUsers ;
392
396
}
393
-
397
+
394
398
setUpFilter ( params ) ;
395
-
399
+
396
400
// the users it manages
397
401
this . users = null ;
398
-
402
+
399
403
/**
400
404
* Gets the user profiles matching the filters (if any) and passes them to the
401
405
* specified callback 'loaded'.
@@ -412,6 +416,10 @@ function UserProfileManagement(params) {
412
416
urlOfUsers += '/' + self . filter . id ;
413
417
if ( self . filter . contacts )
414
418
urlOfUsers += '/contacts' ;
419
+ if ( self . filter . extended ) {
420
+ urlOfUsers += separator + 'extended=' + self . filter . extended ;
421
+ separator = '&' ;
422
+ }
415
423
application = separator + 'application=' ;
416
424
if ( self . filter . component )
417
425
separator = '&' ;
@@ -441,12 +449,13 @@ function UserProfileManagement(params) {
441
449
}
442
450
if ( self . filter . pagination ) {
443
451
urlOfUsers += separator + 'page=' + self . filter . pagination . page + ';' + self . filter . pagination . count ;
444
- }
452
+ }
445
453
$ . ajax ( {
446
454
url : urlOfUsers ,
447
455
type : 'GET' ,
448
456
dataType : 'json' ,
449
457
cache : false ,
458
+ async : params . async ,
450
459
success : function ( users , status , jqXHR ) {
451
460
self . users = decorate ( users ) ;
452
461
self . users . maxlength = jqXHR . getResponseHeader ( 'X-Silverpeas-UserSize' ) ;
@@ -466,9 +475,9 @@ function UserProfileManagement(params) {
466
475
* You can give some parameters to contraints the user groups on which this object should work.
467
476
*/
468
477
function UserGroupManagement ( params ) {
469
-
478
+
470
479
var self = this ;
471
-
480
+
472
481
this . filter = {
473
482
id : null , // the unique identifier of a user group to get.
474
483
url : null , // the URL at which the groups have to be get. If not set, the URL of the root groups
@@ -481,7 +490,7 @@ function UserGroupManagement(params) {
481
490
resource : null // an identifier of a resource belonging to a component instance (the identifier
482
491
// must be set the resource type following by resource identifier in Silverpeas).
483
492
} ;
484
-
493
+
485
494
/**
486
495
* The filtering parameters about the user groups to get.
487
496
*/
@@ -490,7 +499,7 @@ function UserGroupManagement(params) {
490
499
for ( var prop in params )
491
500
self . filter [ prop ] = params [ prop ] ;
492
501
}
493
-
502
+
494
503
/**
495
504
* Decorates the user groups with usefull method to improve the usability:
496
505
* - children(loaded) with loaded a callback called with as argument the loaded groups,
@@ -507,12 +516,12 @@ function UserGroupManagement(params) {
507
516
}
508
517
return decoratedGroups ;
509
518
}
510
-
519
+
511
520
setUpFilter ( params ) ;
512
-
521
+
513
522
// the groups it manages.
514
523
this . groups = null ;
515
-
524
+
516
525
/**
517
526
* Gets the user profiles matching the filters (if any) and passes them to the specified callback
518
527
* 'loaded'.
0 commit comments