Subversion Repositories wimsdev

Rev

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