Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
10372 bpr 1
!!! variables used (to check) : replacelist , up_xx for xx in replacelist and in firstname, lastname
2
!!! regvars_cnt  techvarlist and ???
3
 
20 reyssat 4
uu=$wims_read_parm
5
!if user notwordof $wims_prefix
12555 bpr 6
  wims_prefix=$wims_prefix user class
20 reyssat 7
!endif
8
!default up_class=$wims_class
9
class_type=!defof class_type in wimshome/log/classes/$up_class/.def
16820 bpr 10
authidp=!defof class_authidp in wimshome/log/classes/$up_class/.def
20 reyssat 11
!default class_type=0
12
!read adm/class/authchars
13
l=!text select $char_login in $uu
14
t=!char 1 of $uu
15
n=!charcnt $l
18479 czzmrn 16
!set wims_exec_error=$wims_exec_error\
17
(adduser) class_type=$class_type
13295 bpr 18
!if $class_type isin 012
12934 guerimand 19
!! and $wims_superclass=$empty notneeded 20180612 FG ?
12555 bpr 20
  regvarlist=!makelist regprop x for x=1 to $regvars_cnt
21
  regvarlist=!nospace $regvarlist
22
  replacelist=!append item $regvarlist to $replacelist
10381 guerimand 23
!else
12555 bpr 24
  regvarlist=$empty
10381 guerimand 25
!endif
10367 bpr 26
 
20 reyssat 27
!if $l!=$uu or $t isin $char_punct or $n<$login_min or $n>$login_max
12555 bpr 28
  !exit
20 reyssat 29
!endif
30
uu=!translate internal . to @ in $uu
5097 bpr 31
login_wims=$uu
20 reyssat 32
 
12076 guerimand 33
!reset user_lastname,user_firstname,user_password,user_email,user_comments,user_photourl,\
16615 guerimand 34
    user_exists,user_participate,user_supervise,user_supervisable,user_external_auth,user_mkclass,\
35
    user_forcechpwd
10367 bpr 36
!for j in $regvarlist
12555 bpr 37
  !if $(user_$j)!=$empty
38
    !reset user_$j
39
  !endif
10381 guerimand 40
!next j
20 reyssat 41
!read adm/class/userdef classes,$up_class,$uu
16465 guerimand 42
!sh mkdir -p $Userfolder
20 reyssat 43
!defread $userdef
44
 
45
!if $class_type isin 24 and $user_exists=yes and \
14336 bpr 46
  (($user_supervisable!=yes and $up_supervisable=yes) or \
47
   ($user_supervisable=yes and $up_supervisable!=yes and supervisable \
48
   isitemof $replacelist))
12555 bpr 49
  bad=!append item $uu to $bad
50
  !exit
20 reyssat 51
!endif
52
 
53
!if $class_type isin 13
5374 bpr 54
  !if $class_Supervisor=$wims_realuser
12072 guerimand 55
    !if $class_type=1 and $user_supervisable=yes
56
      replacelist=!listcomplement supervisable in $replacelist
57
    !else
58
      replacelist=!listcomplement participate,supervisable in $replacelist
59
    !endif
5374 bpr 60
  !else
61
    replacelist=!listcomplement supervise,participate,supervisable in $replacelist
62
  !endif
12069 guerimand 63
 
12555 bpr 64
  !! only real supervisor of class (mean : creator) can modify teacher account (very important protection)
18479 czzmrn 65
  !! why? verificare r12069
12555 bpr 66
  !if $wims_user=supervisor and yes isin $user_supervisable $up_supervisable and $class_Supervisor!=$wims_realuser
67
    bad=!append item $uu to $bad
18479 czzmrn 68
!set wims_exec_error=$wims_exec_error\
69
bad=$bad
12555 bpr 70
    !exit
71
  !endif
12072 guerimand 72
 
12976 bpr 73
  !! creator of class cannot loose manage access
12555 bpr 74
  !if $class_Supervisor=$uu and $wims_class notin $up_supervise
12070 guerimand 75
    up_supervise=!append item $wims_class to $up_supervise
12555 bpr 76
  !endif
12070 guerimand 77
 
12555 bpr 78
  !if $adduser_replace iswordof none nopass and $user_password!=$empty
79
    !if $wims_user iswordof supervisor $uu
80
      !default up_password=$user_password
81
    !endif
15324 bpr 82
    !! both can be already crypten
12555 bpr 83
    p1=!word 1 of $user_password
84
    p1=!passcrypt $p1
85
    p2=!word 1 of $up_password
15324 bpr 86
    pass_check=!passcheck $p2 and $p1
12555 bpr 87
    p2=!passcrypt $p2
15324 bpr 88
    !if $p1!=$p2 and $pass_check!=yes
12555 bpr 89
      bad=!append item $uu to $bad
90
      !exit
91
    !endif
20 reyssat 92
  !endif
93
!endif
94
 
16518 guerimand 95
!if $wims_mail_hidden=yes and $wims_user=supervisor and $user_supervisable!=yes
96
 replacelist=!listcomplement email in $replacelist
97
!endif
98
 
4568 bpr 99
!if $user_exists= and email notitemof $replacelist
12555 bpr 100
  replacelist=!append item email to $replacelist
3714 bpr 101
!endif
1644 bpr 102
 
20 reyssat 103
up_exists=yes
104
!default up_supervisable=$user_supervisable
105
replace_=
106
!if $adduser_replace=none
12555 bpr 107
  !goto next
20 reyssat 108
!endif
5124 bpr 109
!!!
12076 guerimand 110
!for n in lastname,firstname,email,regnum,comments,exists,supervise,supervisable,participate,photourl,\
10372 bpr 111
  external_auth,agreecgu,$regvarlist,$techvarlist
10381 guerimand 112
  !if $n isitemof $replacelist,lastname,firstname,exists,supervisable,agreecgu,external_auth
7795 bpr 113
    l_=!singlespace $(up_$n)
12555 bpr 114
    !if $n=comments
14336 bpr 115
      !readproc adm/class/mkcomment name
116
      !let vname=$n$scriptout
13295 bpr 117
    !else
14336 bpr 118
      !let vname=$n
7795 bpr 119
    !endif
13295 bpr 120
    !if ($(up_$n)!=$empty or $n=photourl) and $(up_$n)!=$(user_$vname)
121
      l_=!singlespace $(up_$n)
122
      !if $l_ issametext
123
        l_=
124
      !endif
125
      !if $n iswordof participate supervise
126
        l_=!words2items $l_
127
        l__=
128
        !for a_ in $l_
129
          part_=!text select 1234567890/ in $a_
130
          part_test=!replace internal / by , in $part_
131
          !if $(part_test[1])=$wims_class or $(part_test[1])=$wims_superclass
132
            l__=!append item $part_ to $l__
133
          !endif
134
        !next a_
135
        !if $n iswordof participate
136
          !if $user_supervisable!=yes
137
            l_=!listuniq $l__,$(user_$n)
138
          !endif
139
        !else
140
          l_=!listuniq $l__
12555 bpr 141
        !endif
13295 bpr 142
      !else
143
        !if techvar isin $n
144
          !!!FIXME add a test for validity or add the value to the possible values
12555 bpr 145
        !endif
13295 bpr 146
        !!FIXME one can do l_=!detag $l ???
147
        !if $n isitemof $regvarlist
148
          l_=!detag $l_
149
        !endif
150
        l_=!replace , by &#44; in $l_
151
        l_=!replace < by &lt; in $l_
152
        l_=!translate internal "#*!$$ to $.....$ in $l_
12555 bpr 153
      !endif
13295 bpr 154
      !if $n isitemof comments,photourl,$regvarlist
155
        l_=!char 1 to 5000 of $l_
1640 bpr 156
      !else
13295 bpr 157
        !if $n iswordof participate supervise
158
          l_=!char 1 to 500 of $l_
159
        !else
160
          l_=!char 1 to 100 of $l_
161
        !endif
1640 bpr 162
      !endif
13295 bpr 163
      replace_=!append line !set user_$(vname)=$l_ to $replace_
7795 bpr 164
    !endif
20 reyssat 165
  !endif
166
!next n
7403 bpr 167
 
20 reyssat 168
!if $user_exists!=yes and \
14336 bpr 169
  ($up_password=$empty or $up_lastname=$empty or $up_firstname=$empty)
13295 bpr 170
  bad=!append item $uu to $bad
12555 bpr 171
  !exit
20 reyssat 172
!endif
173
 
174
:next
12944 czzmrn 175
!! verification of user_participate and sharing (needed for teachers in order to register as student)
12976 bpr 176
!if $class_type isin 13 and $up_class notitemof $user_participate
177
  typename=!defof class_typename in wimshome/log/classes/$up_class/.def
12555 bpr 178
  !if $typename != $empty and $typename notwordof class course
179
    bad=!append item $uu to $bad
180
    !exit
20 reyssat 181
  !endif
12555 bpr 182
  !if $typename issametext course
183
    typename=!defof class_typename in wimshome/log/classes/$wims_class/.def
184
    !if $wims_class!=$empty and $typename issametext course and \
14336 bpr 185
        $wims_class=$up_class and $wims_user=supervisor
12555 bpr 186
      au_1=!translate internal / to , in $wims_class
187
      au_1=!translate internal , to / in $(au_1[1..-2])
188
      au_1=!nospace $au_1
189
      up_class=$au_1
190
      typename=!defof class_typename in wimshome/log/classes/$au_1/.def
191
    !endif
13211 bpr 192
    !!case of program occurs in case of an intercourse
193
    !if $wims_class=$empty or $typename notwordof class program or \
14336 bpr 194
        ../$wims_superclass/ notin ../$up_class
12555 bpr 195
      !exit
196
    !endif
197
    user_class=!replace internal ../$wims_superclass/ by in ../$wims_class
198
    user_course=!replace internal ../$wims_superclass/ by in ../$up_class
199
    au_test=!defof user_class in wimshome/log/classes/$up_class/.users/$uu
200
    !if $au_test!=$empty
201
      au_test=$wims_superclass/$au_test
202
      user_courses=!getdef user_courses in wimshome/log/classes/$au_test/.users/$uu
203
      user_courses=!listcomplement $user_course in $user_courses
204
      !setdef !set user_courses=$user_courses in wimshome/log/classes/$au_test/.users/$uu
205
    !endif
206
    !setdef !set user_class=$user_class in wimshome/log/classes/$up_class/.users/$uu
207
    user_courses=!getdef user_courses in wimshome/log/classes/$wims_class/.users/$uu
208
    user_courses=!listunion $user_courses and $user_course
209
    !setdef !set user_courses=$user_courses in wimshome/log/classes/$wims_class/.users/$uu
210
    change=!listunion $change and $uu
211
  !else
212
    !!if participate isitemof $replace_list
213
    !!change up_participate here
214
    up_participate=!listunion $user_participate and $up_class
215
    shclass=!defof sharing_user in wimshome/log/classes/$up_class/neighbors
216
    !default shclass=$up_class
217
    sharing=!defof sharable_user in wimshome/log/classes/$shclass/neighbors
218
    sharing=!append item $shclass to $sharing
219
    sharing=!listcomplement $up_participate in $sharing
220
    !if $sharing!=$empty
221
      !for sh in $sharing
222
        test=!defof class_superclass in wimshome/log/classes/$sh/.def
223
        !if $test!=$empty and $test=$wims_superclass
224
          up_participate=!append item $sh to $up_participate
225
        !endif
226
      !next sh
227
    !endif
228
    !if $user_exists=yes
229
      !setdef !set user_participate=$up_participate in $userdef
230
      change=!listunion $change and $uu
231
    !else
15676 obado 232
      replace_=!append line !set user_participate=$up_participate to $replace_
20 reyssat 233
    !endif
12555 bpr 234
  !endif
20 reyssat 235
!endif
236
 
237
!if $adduser_replace=none
12555 bpr 238
  !exit
20 reyssat 239
!endif
240
 
241
!if $up_password!=$empty and $up_password!=$user_password
12555 bpr 242
  c=!char 1 of $up_password
243
  !if $c=* and $wims_priv_cryptpass=allow
244
    p=!text select */$char_passwd in $up_password
245
  !else
246
    p=!text select $char_passwd in $up_password
247
  !endif
248
  n=!charcnt $p
249
  !if $p!=$up_password or $n<$passwd_min or $n>$passwd_max
250
    bad=!append item $uu to $bad
251
    !exit
252
  !endif
253
  up_password=!passcrypt $up_password
254
  replace_=!append line !set user_password=$up_password to $replace_
16820 bpr 255
  !if $wims_user!=$empty and $uu!=$wims_user and $(authidp[1;])=$empty
16617 guerimand 256
    up_forcechpwd=yes
257
  !else
258
    up_forcechpwd=no
259
  !endif
260
  replace_=!append line !set user_forcechpwd=$up_forcechpwd to $replace_
20 reyssat 261
!endif
262
 
263
!if $up_vars!=$empty
264
  up_vars=!nonempty lines $up_vars
265
  up_vars=!replace internal ! by &#33; in $up_vars
157 bpr 266
  up_vars=!rows2lines $up_vars
10022 guerimand 267
  up_vars=!replace internal = by , in $up_vars
268
  !if $tv_varfilterreaden!=yes
12555 bpr 269
    !readproc adm/vfilter/listvarfilter.proc
10022 guerimand 270
  !endif
20 reyssat 271
  n=!linecnt $up_vars
272
  !for i=1 to $n
12555 bpr 273
    llll=!line $i of $up_vars
274
    llll=!trim $llll
275
    !distribute item $llll into nv_,vv_
276
    !if $nv_ isitemof $tv_listname
14336 bpr 277
      po_=!positionof item $nv_ in $tv_listname
12555 bpr 278
      !if $po_ isitemof $tv_listlocal
14336 bpr 279
        p_=!line $po_ of $tv_listtechvar
280
        val_=!record $(p_[3]) of wimshome/log/classes/$(p_[2])/.techvar
281
        val_=!line 2 of $val_
282
        t_=!item $po_ of $tv_listcode
283
        !bound vv_ within $val_,$empty default $empty
284
        replace_=!append line !set user_techvar_$(t_)=$vv_ to $replace_
285
      !endif
12555 bpr 286
    !endif
20 reyssat 287
  !next i
288
!endif
10384 bpr 289
!!FIXME even if there is no change in user_techvar, it is changed
290
!! and add to the list of users.
12056 guerimand 291
 
16250 guerimand 292
!if $class_type=2 and $user_mkclass!=$up_mkclass and $user_supervisable=yes
293
  !bound up_mkclass within yes,no default yes
294
  replace_=!append line !set user_mkclass=$up_mkclass to $replace_
295
!endif
296
 
297
 
20 reyssat 298
!if $replace_=$empty
12555 bpr 299
  !exit
20 reyssat 300
!endif
301
 
302
change=!listunion $change and $uu
303
 
304
!setdef $replace_ in $userdef
305
 
306
!if $up_class=$wims_class
12555 bpr 307
  wims_class_log=User info $uu
20 reyssat 308
!endif