Subversion Repositories wimsdev

Rev

Rev 13299 | Rev 15290 | 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
13299 bpr 124
!if $subclass!=yes and $wims_user=supervisor
13256 guerimand 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
 
13254 guerimand 139
!! non used now (dangerous to activate : give access of email of all supervisor of the server)
140
!!if $class=$empty
141
!!  classcnt=!recordcnt wimshome/log/classes/.index
142
!!  !bound classcnt between integer 0 and 500
143
!!  classe=
144
!!  classlist=
145
!!  ctype=0
146
!!  !for i=1 to $classcnt
147
!!    l=!record $i of wimshome/log/classes/.index
148
!!    classlist=!append item $(l[1]) to $classlist
149
!!  !next i
150
!!  !exit
151
!!endif
23 reyssat 152
 
153
!if $classe=$empty
12955 bpr 154
  !defread wimshome/log/classes/$class/.def
155
  !if $class_defined!=yes
156
    error=no_class
157
    !exit
23 reyssat 158
  !endif
12955 bpr 159
  !if $class_typename iswordof level program or \
160
      $wims_user=supervisor and $class_typename iswordof course
161
    error=bad_classtype
162
    !exit
163
  !endif
164
  !if $class_typename=course
12978 bpr 165
    !!is it a obligatory course ?
12955 bpr 166
    test=!defof class_ocourses in wimshome/log/classes/$class_parent/.def
167
    test=!makelist $class_superclass/x for x in $test
168
    !if $class isitemof $test
169
      error=bad_classtype
170
      !exit
12978 bpr 171
    !else
172
      !! non obligatory course
173
      !read adm/class/userdef classes,$wims_class,$wims_user
174
      scl=!defof user_participate in $userdef
175
      !if $class notitemof $scl
13064 bpr 176
        tmp=!defof class_type in wimshome/log/classes/$class_parent/.def
177
        !!tmp=3 -> interclasse course
178
        !if $class_parent isin $scl or $tmp=3
12978 bpr 179
          login=$wims_user
13064 bpr 180
          !reset tmp
12978 bpr 181
        !else
182
          error=bad_optioncourse
12984 bpr 183
          !exit
13064 bpr 184
          !reset tmp
12978 bpr 185
        !endif
186
      !else
187
        !exit
188
      !endif
12955 bpr 189
    !endif
190
  !endif
191
  participants=!recordcnt wimshome/log/classes/$class/.userlist
192
  classe=$class_limit\
23 reyssat 193
$participants\
194
$class_password\
195
$class_institution\
196
$class_description\
197
$class_supervisor\
198
$class_email\
199
$class_type
12955 bpr 200
  passverify=
201
  !if $participants>=$class_limit
202
    error=complete
203
    !exit
204
  !endif
23 reyssat 205
!endif
206
!distribute lines $classe into limit,participants,password,institution,description,supervisor,smail,cltype
207
 
208
# class password verification.
8956 bpr 209
classpass_=!defof class_password in wimshome/log/classes/$class/.def
210
!if $classpass_=*
211
  passverify=ok
212
  !goto passclassok
213
!endif
214
 
5084 bpr 215
!if $step=1 or ($step=$empty and ($wims_user=supervisor or $classpass=$password))
12955 bpr 216
  !if ($class=$wims_class and $wims_user=supervisor) or $classpass=$password
217
    superclass=!defof class_superclass in wimshome/log/classes/$class/.def
218
    passverify=ok
219
    search=!translate internal '",\:;$$&@*=+?/|^()[]{} to \
220
 ................................... in $search
221
    search=!word -1 of $search
222
    !if $class!=$superclass and $superclass!=$empty and $wims_user=supervisor \
223
       and $search!=$empty
224
      found=!sh cd $wims_home/log/classes\
225
      comm -23 $superclass/.userlist $class/.userlist | \\
226
      grep -i "$search" | sed 's/^://' | head -100
227
      !!add research on the external_login
228
      !if $auth_method isitemof $auth_method_list
229
          found_external=!sh cd $wims_home/log/classes\
230
           comm -23 $superclass/.userlist_external $class/.userlist_external |\\
14335 bpr 231
          grep -i "$search" | sed 's/:/,/' | head -100
232
        found_external=!column 2 of $found_external
233
       found_external=!item 1 of $found_external
234
        ext_cnt=!itemcnt $found_external
235
        !for tmp=1 to $ext_cnt
236
          found_ext=!sh cd $wims_home/log/classes\
12955 bpr 237
            comm -23 $superclass/.userlist $class/.userlist | \\
14335 bpr 238
          grep -i "$(found_external[$tmp])" | sed 's/^://' | head -100
239
          !if $found_e notlineof $found
12955 bpr 240
            found=!append line $found_e to $found
241
          !endif
6307 bpr 242
        !next
12955 bpr 243
      !endif
244
      foundcnt=!linecnt $found
245
      !exit
23 reyssat 246
    !endif
12955 bpr 247
    !if $superclass!=$empty and ../$superclass/ isin ../$wims_class/ \
248
        and $wims_user!=supervisor
249
      !read adm/class/userdef classes,$wims_class,$wims_user
250
      scl=!defof user_participate in $userdef
251
      cl2=!defof user_class in wimshome/log/classes/$class/.users/$wims_user
252
      !if $class notitemof $scl and $cl2=$empty
253
        adduser_replace=none
254
        up_class=$class
255
        !read adm/class/adduser $wims_user
256
        adduser_replace=
257
        !readdef $userdef
258
        login=$wims_user
259
        wims_otherclass=!append item $class $wims_user to $wims_otherclass
260
        mses=!translate internal _ to $ $ in $wims_sesdir
261
        mses=!word 1 of $mses
13182 bpr 262
        user_participate=!listuniq $user_participate,$class
13211 bpr 263
        ct=!defof class_typename in wimshome/log/classes/$class/.def
264
        !if $ct=course
265
          !! for case of intercourse in particular inscription from portal
266
          ctp=!defof class_parent in wimshome/log/classes/$class/.def
267
          ctt=!defof class_typename in wimshome/log/classes/$ctp/.def
268
          !if $ctt=program
269
            ctp_=!replace internal $wims_class/ by in $ctp
270
            !!ctt_=!replace internal $wims_class/ by in $class
271
            !!setdef !set user_class=$ctt_ in wimshome/log/classes/$ctp/.users/$login
272
            !setdef !set user_class=$ctp_ in wimshome/log/classes/$class/.users/$login
273
          !endif
274
        !endif
13182 bpr 275
        !setdef !set user_participate=$user_participate in $userdef
12955 bpr 276
        !setdef wims_participate=$user_participate in wimshome/$mses/var.stat
13182 bpr 277
        !setdef wims_otherclass=$wims_otherclass,$class in wimshome/$mses/var.stat
278
        !appendfile wimshome/log/classes/$wims_class/.log $date $httpd_REMOTE_ADDR	User $login added
12955 bpr 279
        wims_module_log=Addclass $class by $wims_class/$wims_user
280
        !read adm/class/mkuserlist $class
281
        !read adm/class/stat
282
        date=!translate : to . in $wims_now
283
        !appendfile wimshome/log/classes/$class/.log $date $httpd_REMOTE_ADDR	User $login added: $lastn, $firstn
284
      !endif
285
      step=3
286
      !exit
287
    !endif
288
  !else
289
    error=bad_classpass
23 reyssat 290
  !endif
12955 bpr 291
  !exit
23 reyssat 292
!endif
293
 
8956 bpr 294
:passclassok
23 reyssat 295
!if $step=2
12955 bpr 296
  !read adm/class/authchars
297
  n=!charcnt $login
298
  !if $n<$login_min or $n>$login_max
299
    error=login_size
300
    !exit
23 reyssat 301
  !endif
12955 bpr 302
  ltest=!text select .$char_login in $login
303
  !if $login!=$ltest
304
    error=bad_login
305
    !exit
306
  !endif
307
  Login=!translate internal . to @ in $login
308
  user_exists=
309
  !read adm/class/userdef classes,$class,$Login
310
  test_exists=!defof user_exists in $userdef
311
  lower_Login=!lower $Login
312
  !if $wims_user=supervisor and $Login!=$empty and $lower_Login!=supervisor and $test_exists=yes
313
    !readdef $userdef
314
    pass=$user_password
315
    ptest=$pass
316
    !goto existing
317
  !endif
318
  !for i in lastn,firstn
319
    $i=!replace , by &#44; in $($i)
320
    $i=!translate internal !$$<" to $    $ in $($i)
321
    $i=!trim $($i)
322
    $i=!singlespace $($i)
323
    $i=!char 1 to 40 of $($i)
324
  !next i
325
  !if $lastn=$empty or $firstn=$empty
326
    error=no_real
327
    !exit
328
  !endif
329
  email=!translate internal "<>',|!$$ to $         $ in $email
330
  email=!word -1 of $email
331
  email=!char 1 to 60 of $email
332
  !if $email!=$empty and (@ notin $email or . notin $email)
333
    email=
334
  !endif
335
  n=!charcnt $pass
336
  !if $n<$login_min or $n>$login_max
337
    error=pass_size
338
    !exit
339
  !endif
340
  ltest=!text select $char_passwd in $pass
341
  !if $pass!=$ltest
342
    error=bad_pass
343
    !exit
344
  !endif
345
  !read adm/class/userdef classes,$class,$Login
346
  userdef2=!replace users/ by users/. in $userdef
347
  :existing
348
  work=!filelist $wims_home/log/classes/$class/{score,noscore}/$Login
349
  work=!trim $work
350
  exist1=!defof user_exists in $userdef
351
  exist2=!defof user_exists in $userdef2
352
  stest=!defof class_superclass in wimshome/log/classes/$class/.def
353
  !if $exist1!=$empty and $stest!=$empty
354
    ptest=!defof user_password in $userdef
355
    ctest=!defof user_participate in $userdef
356
    ptest1=!passcrypt $ptest
357
    ptest2=!passcrypt $pass
358
    !if $ptest2 iswordof $ptest1
359
      ctest=!append item $class to $ctest
360
      ctest=!listuniq $ctest
361
      !setdef !set user_participate=$ctest in $userdef
362
      step=3
363
      !goto endreg
364
    !endif
365
  !endif
366
  lower_login=!lower $login
367
  !if $exist1$exist2!=$empty or $work!=$empty or $lower_login iswordof supervisor visitor
368
    error=login_double
369
    !exit
370
  !endif
371
  !bound agreecgu within yes,no,external default no
372
  !if $agreecgu=no and $wims_user!=supervisor
373
    error=no_cgu
374
    !exit
375
  !endif
376
  login_bak=$login,$pass
23 reyssat 377
  !exit
378
!endif
5097 bpr 379
:step3
23 reyssat 380
!if $step=3
12955 bpr 381
  !bound agreecgu within yes,no,external default no
382
  !if $agreecgu=no and $wims_user!=supervisor
383
    error=no_cgu
384
    !exit
385
  !endif
386
  !if $pass!=$pass2 or $login_bak!=$login,$pass
387
    error=pass_error
388
    !exit
389
  !endif
390
  Login=!translate internal . to @ in $login
391
  !read adm/class/userdef classes,$class,$Login
392
  userdef2=!replace internal users/ by users/. in $userdef
393
  !defread $userdef
394
  user_exists=
5023 bpr 395
 
12955 bpr 396
  !defread $userdef2
397
  work=!filelist $wims_home/log/classes/$class/{score,noscore}/$Login
398
  !if $user_exists=yes or $work!=$empty
399
    error=login_double
400
    !exit
9475 bpr 401
  !endif
12955 bpr 402
  !if $idp_method=$empty
403
    up_firstname=$firstn
404
    up_lastname=$lastn
405
    up_email=$email
406
    !if $regvars_cnt>0
407
      !for j=1 to $regvars_cnt
408
        up_regprop$j=!detag $(regprop$j)
409
      !next j
410
    !endif
23 reyssat 411
  !else
12955 bpr 412
    !read adm/class/idp_$idp_method
413
    firstn=$up_firstname
414
    lastn=$up_lastname
415
    email=$up_email
23 reyssat 416
  !endif
12955 bpr 417
  up_password=$pass
418
  up_class=$class
419
  up_agreecgu=$agreecgu
420
  up_external_auth=$auth_user
421
  !if ($cltype iswordof 2 4 and $wims_user=$empty) or\
422
    ($wims_user=supervisor and $utype iswordof 1 3)
423
    up_supervisable=yes
424
  !else
425
    up_supervisable=no
23 reyssat 426
  !endif
12955 bpr 427
  !default Login=$login
428
  !read adm/class/adduser $Login
429
  user_exists=
430
  !defread $userdef
431
  !if $user_exists!=yes
432
    error=insert_fail
433
    !exit
434
  !endif
435
  :endreg
436
  !read adm/class/mkuserlist $class
437
  !if $up_supervisable=yes
438
    superclass=!defof class_superclass in wimshome/log/classes/$class/.def
439
    !if $superclass!=$empty
440
      ctype=!defof class_type in wimshome/log/classes/$superclass/.def
441
    !else
442
      superclass=$class
443
      ctype=$class_type
444
    !endif
445
    !ifval $ctype=4 or $ctype=2
446
      !read adm/gateway/mkteacherlist $superclass
447
    !endif
448
  !endif
449
  wims_module_log=registered $login in $class
450
  date=!translate : to . in $wims_now
451
  !appendfile wimshome/log/classes/$class/.log $date $httpd_REMOTE_ADDR	User $login created: $lastn, $firstn
452
  !read adm/class/stat
453
  !exit
23 reyssat 454
!endif