Subversion Repositories wimsdev

Rev

Rev 13254 | Rev 13299 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13012 bpr 1
!set wims_ariane_self=no
2
 
2368 bpr 3
!read adm/class/classlang names.phtml
23 reyssat 4
wims_form_method=post
5
wims_prefix=class user tmp n sharing sharable
6
wims_helper=chapter=3
5002 bpr 7
!default class=$wims_class
13254 guerimand 8
!if $class=$empty
13256 guerimand 9
 error=noclass
10
 !exit
13254 guerimand 11
!endif
13012 bpr 12
!set wims_ariane=!append line "$(module_title_$lang)",8,\
13
to $wims_ariane
10366 bpr 14
## output auth_method_list, idp_method_list, auth_method, idp_method
5110 bpr 15
!read adm/class/initclass $class,auth
9475 bpr 16
!set regvars_cnt=!itemcnt $regvars_class
5111 bpr 17
!!! test pour une nouvelle inscription dans une classe d'un groupement
5135 bpr 18
!if $auth_method isitemof $auth_method_list and $user_auth=$empty and $wims_user!=supervisor
5111 bpr 19
  !if $wims_external_auth!=$empty
13064 bpr 20
    m_test=!lookup $wims_external_auth in wimshome/log/classes/$wims_superclass/.userlist_external
21
    !if $m_test=$wims_user
22
      user_auth=$wims_external_auth
23
    !else
24
      m_test=!defof user_supervisable in wimshome/log/classes/$wims_superclass/.users/$wims_realuser
25
      !if $m_test=yes
5111 bpr 26
        m_test=!lookup $wims_external_auth in wimshome/log/classes/$wims_superclass/.teacherlist_external
27
        !if $m_test=$wims_realuser
28
          user_auth=$wims_external_auth
5117 bpr 29
        !endif
13064 bpr 30
      !endif
31
    !endif
5111 bpr 32
  !endif
33
!endif
5294 bpr 34
 
5122 bpr 35
!! inscription by the supervisor
36
!if $auth_method isitemof $auth_method_list and $wims_user=supervisor
12955 bpr 37
  !reset login_bak
5122 bpr 38
!endif
5111 bpr 39
 
5004 bpr 40
#####################################
41
## need to set user_external_auth
42
#####################################
5002 bpr 43
 
5013 bpr 44
!if $auth_method isitemof $auth_method_list
12955 bpr 45
  !! in case of auth_method=cas, is it right that we have $user_auth=$empty here ??
46
  !!
47
  !! !! I think these lines were wrong: not needed and breaking reguser
48
  !! !! by supervisor
49
  !!  !if $idp_method=php
50
  !!    !default user_auth=$wims_user
51
  !!  !endif
5004 bpr 52
  !set auth_user=$user_auth
5028 bpr 53
  !if $type=authsupervisor
12955 bpr 54
    !!! FIXME ???? is it useful
5028 bpr 55
    !set auth_user=$user_auth
56
    !set wims_user=supervisor
57
  !endif
12955 bpr 58
  ## define wims login
5064 bpr 59
  !reset login_method
8030 bpr 60
  !if $idp_method=ldap
12955 bpr 61
    !!define login_method
8030 bpr 62
    !read adm/class/initldap
5064 bpr 63
  !endif
5135 bpr 64
  !if $wims_user=supervisor and $auth_method isitemof $auth_method_list and $auth_user=$empty
5100 bpr 65
    !if $search!=$empty
66
      !goto begin
67
    !endif
5097 bpr 68
    !exit
69
  !endif
5064 bpr 70
  !read adm/class/hashlogin $auth_user,$class,$login_method
5121 bpr 71
  !if $error!=$empty
72
    !exit
73
  !endif
5004 bpr 74
  !default pass=!randint 10000,100000
75
  !default pass2=$pass
76
  !default login_bak=$login,$pass
5097 bpr 77
  !if $wims_user=supervisor
78
    passverify=ok
79
    !goto step3
80
  !endif
5004 bpr 81
!endif
5100 bpr 82
:begin
23 reyssat 83
!read tabletheme
10367 bpr 84
 
23 reyssat 85
!if $site_total=$empty
12955 bpr 86
  !read adm/class/stat
87
  site_total=$usercnt
88
  !default site_total=0
89
  site_dispo=$[$wims_user_limit-$site_total]
90
  !if NaN isin $site_dispo
91
    error=internal_total
92
    !exit
93
  !endif
94
  !if $site_dispo<1
95
    error=site_complete
96
    !exit
97
  !endif
23 reyssat 98
!endif
99
 
13256 guerimand 100
!if $subclass=yes
101
!! and $class!=$empty (no more needed )
12955 bpr 102
  ctype=!defof class_type in wimshome/log/classes/$class/.def
103
  classlist=
104
  !if $ctype=2
105
    classcnt=!recordcnt wimshome/log/classes/$class/.subclasses
106
    !for i=1 to $classcnt
107
      l=!record $i of wimshome/log/classes/$class/.subclasses
108
      classlist=!append item $(l[1]) to $classlist
109
    !next i
110
  !endif
111
  !if $ctype=4
112
    classlist=!record 0 of wimshome/log/classes/$class/classes
113
    classlist=!column 1 of $classlist
114
    classlist=!nonempty items $classlist
115
    classlist=!makelist $class/xx for xx in $classlist
116
  !endif
117
  !if $classlist!=$empty
118
    classcnt=!itemcnt $classlist
119
    institution_name=!defof class_institution in wimshome/log/classes/$class/.def
120
    !reset class, subclass
121
    !exit
122
  !endif
23 reyssat 123
!endif
13256 guerimand 124
!if $subclass!=yes and $wims_user=supervisor 
125
!! and $class!=$empty (no more needed)
12955 bpr 126
  ctype=!defof class_typename in wimshome/log/classes/$class/.def
127
  !if $ctype=course
128
    ctest=!sh readlink $wims_home/log/classes/$class/.userlist
129
    cl=!defof n_part in wimshome/log/classes/$class/neighbors
130
    ctype=!defof class_typename in wimshome/log/classes/$cl/.def
131
    !if $ctest=../.userlist and $ctype=class
132
      class=$cl
133
      classpass=!defof class_password in wimshome/log/classes/$cl/.def
134
      fromcourse=yes
135
    !endif
23 reyssat 136
  !endif
137
!endif
138
 
13256 guerimand 139
<<<<<<< .mine
140
||||||| .r13254
13254 guerimand 141
!! non used now (dangerous to activate : give access of email of all supervisor of the server)
142
!!if $class=$empty
143
!!  classcnt=!recordcnt wimshome/log/classes/.index
144
!!  !bound classcnt between integer 0 and 500
145
!!  classe=
146
!!  classlist=
147
!!  ctype=0
148
!!  !for i=1 to $classcnt
149
!!    l=!record $i of wimshome/log/classes/.index
150
!!    classlist=!append item $(l[1]) to $classlist
151
!!  !next i
152
!!  !exit
153
!!endif
23 reyssat 154
 
13256 guerimand 155
=======
156
!if $class=$empty
157
  classcnt=!recordcnt wimshome/log/classes/.index
158
  !bound classcnt between integer 0 and 500
159
  classe=
160
  classlist=
161
  ctype=0
162
  !for i=1 to $classcnt
163
    l=!record $i of wimshome/log/classes/.index
164
    classlist=!append item $(l[1]) to $classlist
165
  !next i
166
  !exit
167
!endif
168
 
169
>>>>>>> .r13253
23 reyssat 170
!if $classe=$empty
12955 bpr 171
  !defread wimshome/log/classes/$class/.def
172
  !if $class_defined!=yes
173
    error=no_class
174
    !exit
23 reyssat 175
  !endif
12955 bpr 176
  !if $class_typename iswordof level program or \
177
      $wims_user=supervisor and $class_typename iswordof course
178
    error=bad_classtype
179
    !exit
180
  !endif
181
  !if $class_typename=course
12978 bpr 182
    !!is it a obligatory course ?
12955 bpr 183
    test=!defof class_ocourses in wimshome/log/classes/$class_parent/.def
184
    test=!makelist $class_superclass/x for x in $test
185
    !if $class isitemof $test
186
      error=bad_classtype
187
      !exit
12978 bpr 188
    !else
189
      !! non obligatory course
190
      !read adm/class/userdef classes,$wims_class,$wims_user
191
      scl=!defof user_participate in $userdef
192
      !if $class notitemof $scl
13064 bpr 193
        tmp=!defof class_type in wimshome/log/classes/$class_parent/.def
194
        !!tmp=3 -> interclasse course
195
        !if $class_parent isin $scl or $tmp=3
12978 bpr 196
          login=$wims_user
13064 bpr 197
          !reset tmp
12978 bpr 198
        !else
199
          error=bad_optioncourse
12984 bpr 200
          !exit
13064 bpr 201
          !reset tmp
12978 bpr 202
        !endif
203
      !else
204
        !exit
205
      !endif
12955 bpr 206
    !endif
207
  !endif
208
  participants=!recordcnt wimshome/log/classes/$class/.userlist
209
  classe=$class_limit\
23 reyssat 210
$participants\
211
$class_password\
212
$class_institution\
213
$class_description\
214
$class_supervisor\
215
$class_email\
216
$class_type
12955 bpr 217
  passverify=
218
  !if $participants>=$class_limit
219
    error=complete
220
    !exit
221
  !endif
23 reyssat 222
!endif
223
!distribute lines $classe into limit,participants,password,institution,description,supervisor,smail,cltype
224
 
225
# class password verification.
8956 bpr 226
classpass_=!defof class_password in wimshome/log/classes/$class/.def
227
!if $classpass_=*
228
  passverify=ok
229
  !goto passclassok
230
!endif
231
 
5084 bpr 232
!if $step=1 or ($step=$empty and ($wims_user=supervisor or $classpass=$password))
12955 bpr 233
  !if ($class=$wims_class and $wims_user=supervisor) or $classpass=$password
234
    superclass=!defof class_superclass in wimshome/log/classes/$class/.def
235
    passverify=ok
236
    search=!translate internal '",\:;$$&@*=+?/|^()[]{} to \
237
 ................................... in $search
238
    search=!word -1 of $search
239
    !if $class!=$superclass and $superclass!=$empty and $wims_user=supervisor \
240
       and $search!=$empty
241
      found=!sh cd $wims_home/log/classes\
242
      comm -23 $superclass/.userlist $class/.userlist | \\
243
      grep -i "$search" | sed 's/^://' | head -100
244
      !!add research on the external_login
245
      !if $auth_method isitemof $auth_method_list
246
          found_external=!sh cd $wims_home/log/classes\
247
           comm -23 $superclass/.userlist_external $class/.userlist_external |\\
248
	        grep -i "$search" | sed 's/:/,/' | head -100
249
	      found_external=!column 2 of $found_external
250
	     found_external=!item 1 of $found_external
251
	      ext_cnt=!itemcnt $found_external
252
	      !for tmp=1 to $ext_cnt
253
	        found_ext=!sh cd $wims_home/log/classes\
254
            comm -23 $superclass/.userlist $class/.userlist | \\
255
	        grep -i "$(found_external[$tmp])" | sed 's/^://' | head -100
256
	        !if $found_e notlineof $found
257
            found=!append line $found_e to $found
258
          !endif
6307 bpr 259
        !next
12955 bpr 260
      !endif
261
      foundcnt=!linecnt $found
262
      !exit
23 reyssat 263
    !endif
12955 bpr 264
    !if $superclass!=$empty and ../$superclass/ isin ../$wims_class/ \
265
        and $wims_user!=supervisor
266
      !read adm/class/userdef classes,$wims_class,$wims_user
267
      scl=!defof user_participate in $userdef
268
      cl2=!defof user_class in wimshome/log/classes/$class/.users/$wims_user
269
      !if $class notitemof $scl and $cl2=$empty
270
        adduser_replace=none
271
        up_class=$class
272
        !read adm/class/adduser $wims_user
273
        adduser_replace=
274
        !readdef $userdef
275
        login=$wims_user
276
        wims_otherclass=!append item $class $wims_user to $wims_otherclass
277
        mses=!translate internal _ to $ $ in $wims_sesdir
278
        mses=!word 1 of $mses
13182 bpr 279
        user_participate=!listuniq $user_participate,$class
13211 bpr 280
        ct=!defof class_typename in wimshome/log/classes/$class/.def
281
        !if $ct=course
282
          !! for case of intercourse in particular inscription from portal
283
          ctp=!defof class_parent in wimshome/log/classes/$class/.def
284
          ctt=!defof class_typename in wimshome/log/classes/$ctp/.def
285
          !if $ctt=program
286
            ctp_=!replace internal $wims_class/ by in $ctp
287
            !!ctt_=!replace internal $wims_class/ by in $class
288
            !!setdef !set user_class=$ctt_ in wimshome/log/classes/$ctp/.users/$login
289
            !setdef !set user_class=$ctp_ in wimshome/log/classes/$class/.users/$login
290
          !endif
291
        !endif
13182 bpr 292
        !setdef !set user_participate=$user_participate in $userdef
12955 bpr 293
        !setdef wims_participate=$user_participate in wimshome/$mses/var.stat
13182 bpr 294
        !setdef wims_otherclass=$wims_otherclass,$class in wimshome/$mses/var.stat
295
        !appendfile wimshome/log/classes/$wims_class/.log $date $httpd_REMOTE_ADDR	User $login added
12955 bpr 296
        wims_module_log=Addclass $class by $wims_class/$wims_user
297
        !read adm/class/mkuserlist $class
298
        !read adm/class/stat
299
        date=!translate : to . in $wims_now
300
        !appendfile wimshome/log/classes/$class/.log $date $httpd_REMOTE_ADDR	User $login added: $lastn, $firstn
301
      !endif
302
      step=3
303
      !exit
304
    !endif
305
  !else
306
    error=bad_classpass
23 reyssat 307
  !endif
12955 bpr 308
  !exit
23 reyssat 309
!endif
310
 
8956 bpr 311
:passclassok
23 reyssat 312
!if $step=2
12955 bpr 313
  !read adm/class/authchars
314
  n=!charcnt $login
315
  !if $n<$login_min or $n>$login_max
316
    error=login_size
317
    !exit
23 reyssat 318
  !endif
12955 bpr 319
  ltest=!text select .$char_login in $login
320
  !if $login!=$ltest
321
    error=bad_login
322
    !exit
323
  !endif
324
  Login=!translate internal . to @ in $login
325
  user_exists=
326
  !read adm/class/userdef classes,$class,$Login
327
  test_exists=!defof user_exists in $userdef
328
  lower_Login=!lower $Login
329
  !if $wims_user=supervisor and $Login!=$empty and $lower_Login!=supervisor and $test_exists=yes
330
    !readdef $userdef
331
    pass=$user_password
332
    ptest=$pass
333
    !goto existing
334
  !endif
335
  !for i in lastn,firstn
336
    $i=!replace , by &#44; in $($i)
337
    $i=!translate internal !$$<" to $    $ in $($i)
338
    $i=!trim $($i)
339
    $i=!singlespace $($i)
340
    $i=!char 1 to 40 of $($i)
341
  !next i
342
  !if $lastn=$empty or $firstn=$empty
343
    error=no_real
344
    !exit
345
  !endif
346
  email=!translate internal "<>',|!$$ to $         $ in $email
347
  email=!word -1 of $email
348
  email=!char 1 to 60 of $email
349
  !if $email!=$empty and (@ notin $email or . notin $email)
350
    email=
351
  !endif
352
  n=!charcnt $pass
353
  !if $n<$login_min or $n>$login_max
354
    error=pass_size
355
    !exit
356
  !endif
357
  ltest=!text select $char_passwd in $pass
358
  !if $pass!=$ltest
359
    error=bad_pass
360
    !exit
361
  !endif
362
  !read adm/class/userdef classes,$class,$Login
363
  userdef2=!replace users/ by users/. in $userdef
364
  :existing
365
  work=!filelist $wims_home/log/classes/$class/{score,noscore}/$Login
366
  work=!trim $work
367
  exist1=!defof user_exists in $userdef
368
  exist2=!defof user_exists in $userdef2
369
  stest=!defof class_superclass in wimshome/log/classes/$class/.def
370
  !if $exist1!=$empty and $stest!=$empty
371
    ptest=!defof user_password in $userdef
372
    ctest=!defof user_participate in $userdef
373
    ptest1=!passcrypt $ptest
374
    ptest2=!passcrypt $pass
375
    !if $ptest2 iswordof $ptest1
376
      ctest=!append item $class to $ctest
377
      ctest=!listuniq $ctest
378
      !setdef !set user_participate=$ctest in $userdef
379
      step=3
380
      !goto endreg
381
    !endif
382
  !endif
383
  lower_login=!lower $login
384
  !if $exist1$exist2!=$empty or $work!=$empty or $lower_login iswordof supervisor visitor
385
    error=login_double
386
    !exit
387
  !endif
388
  !bound agreecgu within yes,no,external default no
389
  !if $agreecgu=no and $wims_user!=supervisor
390
    error=no_cgu
391
    !exit
392
  !endif
393
  login_bak=$login,$pass
23 reyssat 394
  !exit
395
!endif
5097 bpr 396
:step3
23 reyssat 397
!if $step=3
12955 bpr 398
  !bound agreecgu within yes,no,external default no
399
  !if $agreecgu=no and $wims_user!=supervisor
400
    error=no_cgu
401
    !exit
402
  !endif
403
  !if $pass!=$pass2 or $login_bak!=$login,$pass
404
    error=pass_error
405
    !exit
406
  !endif
407
  Login=!translate internal . to @ in $login
408
  !read adm/class/userdef classes,$class,$Login
409
  userdef2=!replace internal users/ by users/. in $userdef
410
  !defread $userdef
411
  user_exists=
5023 bpr 412
 
12955 bpr 413
  !defread $userdef2
414
  work=!filelist $wims_home/log/classes/$class/{score,noscore}/$Login
415
  !if $user_exists=yes or $work!=$empty
416
    error=login_double
417
    !exit
9475 bpr 418
  !endif
12955 bpr 419
  !if $idp_method=$empty
420
    up_firstname=$firstn
421
    up_lastname=$lastn
422
    up_email=$email
423
    !if $regvars_cnt>0
424
      !for j=1 to $regvars_cnt
425
        up_regprop$j=!detag $(regprop$j)
426
      !next j
427
    !endif
23 reyssat 428
  !else
12955 bpr 429
    !read adm/class/idp_$idp_method
430
    firstn=$up_firstname
431
    lastn=$up_lastname
432
    email=$up_email
23 reyssat 433
  !endif
12955 bpr 434
  up_password=$pass
435
  up_class=$class
436
  up_agreecgu=$agreecgu
437
  up_external_auth=$auth_user
438
  !if ($cltype iswordof 2 4 and $wims_user=$empty) or\
439
    ($wims_user=supervisor and $utype iswordof 1 3)
440
    up_supervisable=yes
441
  !else
442
    up_supervisable=no
23 reyssat 443
  !endif
12955 bpr 444
  !default Login=$login
445
  !read adm/class/adduser $Login
446
  user_exists=
447
  !defread $userdef
448
  !if $user_exists!=yes
449
    error=insert_fail
450
    !exit
451
  !endif
452
  :endreg
453
  !read adm/class/mkuserlist $class
454
  !if $up_supervisable=yes
455
    superclass=!defof class_superclass in wimshome/log/classes/$class/.def
456
    !if $superclass!=$empty
457
      ctype=!defof class_type in wimshome/log/classes/$superclass/.def
458
    !else
459
      superclass=$class
460
      ctype=$class_type
461
    !endif
462
    !ifval $ctype=4 or $ctype=2
463
      !read adm/gateway/mkteacherlist $superclass
464
    !endif
465
  !endif
466
  wims_module_log=registered $login in $class
467
  date=!translate : to . in $wims_now
468
  !appendfile wimshome/log/classes/$class/.log $date $httpd_REMOTE_ADDR	User $login created: $lastn, $firstn
469
  !read adm/class/stat
470
  !exit
23 reyssat 471
!endif