Subversion Repositories wimsdev

Rev

Rev 17871 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23 reyssat 1
# Variable calculations should be done in this file.
2
# It is read and interpreted by wims for all valid calls to the module.
2368 bpr 3
!read adm/class/classlang names.phtml
13046 bpr 4
!! number of lines in a record of a sheet
15763 guerimand 5
!set sheetrecordlimit=11
13046 bpr 6
 
17333 guerimand 7
scnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
8
!if $job=cleantechvar
9
  !bound sheet between 1 and $scnt default $empty
10
  !if $sheet!=$empty
11
    !readproc proc/checktechvar.proc clean
12
  !endif
13
  job=$empty
14
!endif
15
 
10339 bpr 16
!if $job!=$empty and $job notwordof text modify
12701 bpr 17
  job1=$job
18
  !!for the icon and the title
10339 bpr 19
  !if $job=getsource
20
    job1=sheetsource
21
  !endif
22
  !if $job=prep_putsource
23
    job1=putsource
24
  !endif
10512 bpr 25
  !default name_$(job1)=$(wims_name_$job1)
26
  wims_ariane=!append line sheetadmin,1,cmd=resume to $wims_ariane
27
  !if $(name_$(job1))!=$empty or
28
    wims_ariane=!append line "$(name_$(job1))",8, to $wims_ariane
29
  !endif
10339 bpr 30
!else
31
  !set wims_ariane=!append line sheetadmin,8 to $wims_ariane
32
!endif
33
!set wims_ariane_self=no
34
 
9670 guerimand 35
!if $sheet>$scnt
12312 bpr 36
  wims_infoshow=yes
37
  !setdef wims_infoshow=$wims_infoshow in wimshome/sessions/$wims_session/var.stat
9670 guerimand 38
!endif
9655 guerimand 39
!if $cmd=resume
12312 bpr 40
  !bound infoshow within yes,no default $wims_infoshow
41
  wims_infoshow=$infoshow
42
  !setdef wims_infoshow=$wims_infoshow in wimshome/sessions/$wims_session/var.stat
9655 guerimand 43
!endif
44
 
11965 guerimand 45
tmp=!defof MAX_SHEETS\
11967 guerimand 46
MAX_REQUIRE\
47
DF_SEVERITY\
48
MIN_WEIGHT\
16729 guerimand 49
MAX_WEIGHT\
50
MAX_EXOS in wimshome/public_html/bases/sys/define.conf
51
!distribute line $tmp into max_sheets,require_limit,df_severity,min_weight,max_weight,max_exos
23 reyssat 52
title_limit=80
53
desc_limit=4000
54
etitle_limit=100
55
edesc_limit=400
12316 bpr 56
 
8255 bpr 57
require_limit=$[$require_limit/10]
10305 guerimand 58
wims_prefix=class user tmp n sharing sharable techvar
23 reyssat 59
srcname=wimshome/$wims_sesdir/home_sheet.src
60
wims_helper=chapter=3
61
 
1533 guerimand 62
!readproc tabletheme
23 reyssat 63
!if $wims_user!=supervisor
12312 bpr 64
  error=not_supervisor
65
  !exit
23 reyssat 66
!endif
1980 guerimand 67
!if $job=chseries
12312 bpr 68
  !changeto chseries.proc
1980 guerimand 69
!endif
11633 bpr 70
!readproc adm/levelname.phtml
1980 guerimand 71
!readproc adm/search_engine/names.$lang
72
!readproc adm/search_engine/mklist_form.proc
23 reyssat 73
 
74
today=!char 1 to 8 of $wims_now
75
thisyear=!char 1 to 4 of $today
76
 
7290 bpr 77
!if $class_expiration=$empty
12312 bpr 78
  !defread wimshome/log/classes/$wims_class/.def
79
  !if $wims_superclass!=$empty
80
    class_expiration=!defof class_expiration in wimshome/log/classes/$wims_superclass/.def
81
  !endif
23 reyssat 82
!endif
1533 guerimand 83
 
23 reyssat 84
!if $class_expiration=$empty
12312 bpr 85
  error=bad_class
86
  !exit
23 reyssat 87
!endif
88
 
89
sharers=
90
sharing1=!defof sharable_sheet in wimshome/log/classes/$wims_class/neighbors
91
!for c in $sharing1
12312 bpr 92
  d=!defof sharing_sheet in wimshome/log/classes/$c/neighbors
93
  !if $d issametext $wims_class
94
    sharers=!append item $c to $sharers
95
  !endif
23 reyssat 96
!next c
11967 guerimand 97
 
12089 guerimand 98
!if $save!=$empty
12312 bpr 99
  jquery_defined=!defof jquery_defined in themes/$wims_theme/header.phtml
17311 guerimand 100
  expmon=!char 6 to 7 of $expdate
101
  expday=!char 9 to 10 of $expdate
102
  expyear=!char 1 to 4 of $expdate
12312 bpr 103
  !if $expday>=1 and $expday<=31 and $expmon>=1 and $expmon<=12 \
14335 bpr 104
      and $expyear>=$thisyear and $expyear<=$thisyear+1 \
105
      and $expyear$expmon$expday>$today \
106
      and $expyear$expmon$expday<=$class_expiration \
107
      and N notin $expmon$expday$expyear
12312 bpr 108
    expiration=$expyear$expmon$expday
109
    expdate=$expiration
110
  !else
111
    !if $expyear$expmon$expday>$class_expiration
112
      !readproc adm/date.phtml $class_expiration
113
      error=toolate
114
    !else
115
      expiration=$class_expiration
116
      expdate=$expiration
117
    !endif
118
  !endif
23 reyssat 119
!endif
12089 guerimand 120
 
8255 bpr 121
!if $sheet>$max_sheets
12312 bpr 122
  error=bad_maxsheet
123
  !exit
3062 bpr 124
!endif
125
 
126
!if $sheet<1
12312 bpr 127
  error=bad_sheet
128
  !exit
23 reyssat 129
!endif
130
# menu preparation
131
!if $job!=$empty and $job iswordof \
14335 bpr 132
    prep_activate prep_erase prep_expire prep_putsource prep_modify
12312 bpr 133
  data=!record $sheet of wimshome/log/classes/$wims_class/sheets/.sheets
15763 guerimand 134
  !distribute lines $data into active,expire,title,desc,bla,comment,attribut,exodescshow,formal_hidden_condition,indivtechvar
12387 bpr 135
  !if $modif!=$empty
136
    exo=!record $modif of wimshome/log/classes/$wims_class/sheets/.sheet$sheet
137
    !distribute lines $exo into D_,p_
138
    !read getparm $p_ exotrymax
139
  !endif
12312 bpr 140
  error=$job
7801 bpr 141
  !if $expire < $today
142
    test_expire=$expire,$today
143
  !endif
15859 guerimand 144
  !if $indivtechvar!=$empty and ($job=prep_modify or $job=prep_activate)
15763 guerimand 145
    !readproc adm/vfilter/listvarfilter.proc
146
    nb=!positionof item $indivtechvar in $tv_listcode
147
    !if $nb!=$empty
148
      don=!line $nb of $tv_listtechvar
149
      !distribute item $don into name,classid,number
150
      don=!record $number of wimshome/log/classes/$classid/.techvar
151
      listval=!line 2 of $don
15910 guerimand 152
      nbtechvalue=!itemcnt $listval
15763 guerimand 153
    !else
154
      !reset indivtechvar
155
    !endif
156
  !endif
15859 guerimand 157
  !if $job=prep_activate
17333 guerimand 158
    nb=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sheet
159
    !if $nb>$max_exos
160
      error=toomanyexo
161
      !reset job
162
      !exit
163
    !endif
164
    !read adm/sheet/checkdepindiv
165
    !if $sheet isitemof $sheet_dependancy and $sheet isitemof $sheet_indivtechvar
166
      error=depindiv
167
      !reset job
168
      !exit
169
    !endif
170
    !readproc proc/checktechvar.proc
171
    !if $listvalues!=$empty
172
      error=techvardiscord $listvalues
173
      !reset job
174
    !endif
15859 guerimand 175
  !endif
12312 bpr 176
  !exit
23 reyssat 177
!endif
178
scnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
179
!if $job=erase and $sheet<=$scnt and $sheet>=1
12312 bpr 180
  test=
181
  !for s=$sheet to $scnt
182
    l=!record $s of wimshome/log/classes/$wims_class/sheets/.sheets
183
    l=!line 1 of $l
184
    !if $l>0
17527 bpr 185
      test=notclean
12312 bpr 186
    !endif
187
  !next s
188
  !if $test=$empty
189
    update_field=0
190
    !read proc/update.docindex
191
    !read update.sheet
23 reyssat 192
  !endif
16728 guerimand 193
  !read adm/sheet/writeweights
12312 bpr 194
  !restart module=home
23 reyssat 195
!endif
196
 
9679 guerimand 197
!if $job=duplicate
12312 bpr 198
  !changeto $job.proc
9679 guerimand 199
!endif
200
 
23 reyssat 201
!if $job=expire
12312 bpr 202
  !distribute item 1,2 into update_field,update_content
203
  !read update.sheet
204
  job=
23 reyssat 205
!endif
206
 
207
!if $job=hide
12312 bpr 208
  !distribute item 1,3 into update_field,update_content
209
  !read update.sheet
210
  job=
23 reyssat 211
!endif
212
 
8093 bpr 213
!if $job=reactivate
12312 bpr 214
  !distribute item 1,1 into update_field,update_content
215
  !read update.sheet
216
  job=
23 reyssat 217
!endif
218
 
219
!if $job=deactivate
12312 bpr 220
  !read var.proc.deactivate
23 reyssat 221
!else
12312 bpr 222
  confirmed=!replace word share by $ in $confirmed
223
  confirmed=!singlespace $confirmed
23 reyssat 224
!endif
225
 
226
activetest=!record $sheet of wimshome/log/classes/$wims_class/sheets/.sheets
227
a_=!line 1 of $activetest
228
a_=!trim $a_
229
expp=!line 2 of $activetest
230
!default expiration=$expp
7801 bpr 231
 
232
!if $expiration>$class_expiration or $test_expire!=$empty
12312 bpr 233
  expiration=$class_expiration
23 reyssat 234
!endif
7801 bpr 235
 
23 reyssat 236
ecnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sheet
15767 guerimand 237
wims_listexo=!values v for v=1 to $ecnt
238
!setdef wims_listexo=$wims_listexo in wimshome/sessions/$wims_session/var.stat
1513 guerimand 239
activetest=!replace line number 3 by $ecnt in $activetest
23 reyssat 240
 
241
!if $job=putsource and $a_=0
12312 bpr 242
  source=!trim $source
243
  !writefile $srcname $source
244
  putcnt=!recordcnt $srcname
245
  !for i=1 to $putcnt
246
    s_=!record $i of $srcname
247
    n_=!linecnt $s_
248
    bad_source=$i
13046 bpr 249
    !if $n_>=5 and $n_<=$sheetrecordlimit
12312 bpr 250
      !distribute lines $s_ into di,pa,re,we,ti,de
251
      !for k in re,we,di,pa,ti,de
252
        $k=!trim $($k)
253
        w$k=!wordcnt $($k)
254
      !next k
255
      !if NaN isin $[$re]$[$we] or $[$wre*$wwe*$wdi]!=1 or $wpa>1 or $ti=$empty or\
14335 bpr 256
          .. isin $di or $re<0 or $we<0 or ($re>0 and $we=0)
12312 bpr 257
         error=bad_source
17206 guerimand 258
         ssource=$source
12312 bpr 259
        !exit
260
      !endif
261
      ti=!char 1 to $etitle_limit of $ti
262
      de=!char 1 to $edesc_limit of $de
263
      source_$i=$s_
264
      last=$i
265
    !else
13046 bpr 266
      # last record may be empty
12312 bpr 267
      !if $i!=$putcnt
268
        error=bad_source
17206 guerimand 269
        ssource=$source
12312 bpr 270
        !exit
271
      !endif
272
    !endif
273
  !next i
274
  !for i=1 to $last
275
    !appendfile wimshome/log/classes/$wims_class/sheets/.sheet$sheet :$(source_$i)
276
  !next i
17206 guerimand 277
  !reset ssource
23 reyssat 278
!endif
279
 
280
!if $activetest!=$empty
12312 bpr 281
  sheet_exist=yes
282
  !default expiration=!line 2 of $activetest
283
  activetest=!line 1 of $activetest
284
  exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sheet
23 reyssat 285
!else
12312 bpr 286
  sheet_exist=no
287
  activetest=-1
288
  exocnt=0
289
  !default expiration=$class_expiration
23 reyssat 290
!endif
291
 
292
!if $job=getsource and $sheet_exist=yes
13640 obado 293
  !writefile $srcname
12312 bpr 294
  !for i=1 to $exocnt
295
    l=!record $i of wimshome/log/classes/$wims_class/sheets/.sheet$sheet
13640 obado 296
    # replace eventual html entities so it will not insert \n in textarea
297
    l=!replace internal &#13;&#10; by $ $ in $l
12312 bpr 298
    !appendfile $srcname $$:$l
299
  !next i
13640 obado 300
  !appendfile $srcname
12312 bpr 301
  !exit
23 reyssat 302
!endif
303
 
10062 guerimand 304
!readproc adm/vfilter/listvarfilter.proc
23 reyssat 305
!if $allow=yes
12312 bpr 306
  !if $tv_listname=$empty
307
    !bound allowtype within all,none,select default all
308
  !else
309
    !bound allowtype within all,none,select,techvar default all
310
  !endif
12994 guerimand 311
  !read adm/scorerestriction get
12312 bpr 312
  IPlist=$_output
313
  IPlist=!translate ,;\
23 reyssat 314
* to $    $ in $IPlist
12312 bpr 315
  IPlist=!trim $IPlist
316
  !if $allowtype=select and $IPlist=$empty and $save!=$empty
317
    allowtype=all
318
  !endif
319
  !if $allowtype=all
320
    allow_parm=
321
  !endif
322
  !if $allowtype=none
323
    allow_parm=none
324
  !endif
325
  !if $allowtype=select
326
    allow_parm=$IPlist
327
  !endif
10305 guerimand 328
 
12312 bpr 329
  !if $allowtype=techvar
330
    !readproc adm/vfilter/shexselect.proc $sheet
331
  !endif
10305 guerimand 332
!endif
11810 guerimand 333
 
11967 guerimand 334
!! --------------- get/save severity parameters
335
rec=!record 0 of wimshome/log/classes/$wims_class/sheets/.severity
336
!if $save!=$empty
12312 bpr 337
  !distribute word $df_severity into t1,t2,t3
338
  !bound weight between $min_weight and $max_weight default $t1
339
  !bound formulaA between integer 0 and 6 default $t2
340
  !bound formulaB between integer 0 and 2 default $t3
341
  nb=!linecnt $rec
13059 guerimand 342
  !! define maxscore default =10 (not general variable maybe we should ?)
343
  !if $nb=0
13060 bpr 344
    rec=10
13059 guerimand 345
  !endif
12312 bpr 346
  new=$weight $formulaA $formulaB
13058 guerimand 347
  !if $sheet>$nb-1
12312 bpr 348
    !for k=$nb+1 to $sheet+1
14335 bpr 349
      rec=!append line $df_severity to $rec
13058 guerimand 350
    !next k
12312 bpr 351
  !endif
352
  rec=!replace line number $[$sheet+1] by $new in $rec
353
  !writefile wimshome/log/classes/$wims_class/sheets/.severity $rec
11967 guerimand 354
!endif
355
rec=!line $[$sheet+1] of $rec
356
!distribute word $rec into s_weight,s_formulaA,s_formulaB
357
!default weight=$s_weight
358
!default formulaA=$s_formulaA
359
!default formulaB=$s_formulaB
360
 
10062 guerimand 361
!! ---- save modification of allow parameters
10305 guerimand 362
!if $save!=$empty
10062 guerimand 363
  !if $sharers!=$empty and $allowshare=1
16798 guerimand 364
    !if $allowtype=techvar
16801 guerimand 365
      !readproc adm/vfilter/validtechvar.proc $allowtechvar\
16798 guerimand 366
$sharers
367
      !if $output=1
368
        setclass=!items2words $wims_class,$sharers
369
      !else
370
        error=badallowshare
371
        allowshare=0
372
        setclass=$wims_class
373
      !endif
16801 guerimand 374
    !else
375
      setclass=!items2words $wims_class,$sharers
16798 guerimand 376
    !endif
10062 guerimand 377
  !else
12312 bpr 378
    setclass=$wims_class
10062 guerimand 379
  !endif
380
  !if $allow_parm=$empty
12312 bpr 381
    !sh for c in $setclass; do rm -f $wims_home/log/classes/$$c/.$sheet; done
10062 guerimand 382
  !else
16777 guerimand 383
    setclass=!words2items $setclass
12312 bpr 384
    !for c in $setclass
385
      !writefile wimshome/log/classes/$c/.$sheet $allow_parm
386
    !next c
10062 guerimand 387
  !endif
388
  wims_class_log=sheet $sheet allow $allowtype $allowshare by $wims_realuser
10305 guerimand 389
!endif
10062 guerimand 390
!! ---- end of saving
23 reyssat 391
 
10062 guerimand 392
!if $allow=$empty or $save!=$empty
393
!! --- read saving configuration for allow parameters initial time and after saving
12312 bpr 394
  !readproc adm/vfilter/shexread.proc $sheet
11810 guerimand 395
!! to distribute IPlist content into variable
12312 bpr 396
  !read adm/scorerestriction put\
11810 guerimand 397
$IPlist
10062 guerimand 398
!endif
10244 guerimand 399
old_allowtype=$allowtype
400
old_allowtechvar=$allowtechvar
10062 guerimand 401
!reset allow,save
402
!! --- end of reading
23 reyssat 403
 
404
expmon=!char 5,6 of $expiration
405
expday=!char 7,8 of $expiration
406
expyear=!char 1,2,3,4 of $expiration
407
 
408
!if $job!=text
13640 obado 409
  # remove \n from textareas
12312 bpr 410
  mod_desc=!replace internal $\
13640 obado 411
$ by $ $ in $mod_desc
12312 bpr 412
  mod_comment=!replace internal $\
13640 obado 413
$ by $ $ in $mod_comment
12312 bpr 414
  !if $title_save$desc_save=$empty
415
    rec=!record $sheet of wimshome/log/classes/$wims_class/sheets/.sheets
17333 guerimand 416
    !distribute lines $rec into a,bidon,title_save,desc_save,prpage_save,\
15763 guerimand 417
      comment_save,attribut_save,exodescshow_save,formal_hidden_condition_save,\
418
      indivtechvar_save
17333 guerimand 419
      !if $indivtechvar_save notitemof $tv_listlocalcode
420
        !if $a=0
421
          !readproc proc/checktechvar.proc
422
          !if $listvalues!=$empty
423
            error=techvardiscord $listvalues
424
            display=1
425
          !endif
426
        !endif
427
      !endif
12312 bpr 428
  !endif
429
  title=$title_save
430
  desc=$desc_save
431
  prpage=$prpage_save
432
  comment=$comment_save
13825 bpr 433
  exodescshow=$exodescshow_save
14441 guerimand 434
  !readproc adm/vfilter/convertformat.proc human\
435
$formal_hidden_condition_save
17327 guerimand 436
  !if $output_error!=$empty
437
    error=hiddenbadtechvar
438
    display=1
439
  !endif
14441 guerimand 440
  hidden_condition=$output_convertformat
15763 guerimand 441
  indivtechvar=$indivtechvar_save
23 reyssat 442
!else
12312 bpr 443
  !if $title=$empty
444
    error=no_title
445
    !exit
446
  !endif
12801 obado 447
  title=!singlespace $title
448
  title=!char 1 to $title_limit of $title
449
  title=!replace internal : by &#58; in $title
450
 
12312 bpr 451
  desc=!replace internal $\
13640 obado 452
$ by $ $ in $desc
12801 obado 453
  desc=!singlespace $desc
454
  desc=!char 1 to $desc_limit of $desc
455
  desc=!replace internal : by &#58; in $desc
456
 
12312 bpr 457
  comment=!replace internal $\
13640 obado 458
$ by $ $ in $comment
12312 bpr 459
  comment=!singlespace $comment
12801 obado 460
 
16919 guerimand 461
  !! --- manage of personalized presentation of sheet page
462
  !if $prpage isitemof no,yes or $prpage=$empty
463
    !bound prpage within yes,no default no
464
  !else
465
    !! old gestion of prpage with doc link
466
    !! deprecated but keep for background compatibility
467
    prpage=!word 1 of $prpage
468
    prpage=!char 1 to 100 of $prpage
469
    !if .. isin $prpage or / notin $prpage
470
      prpage=no
12312 bpr 471
    !endif
16919 guerimand 472
    !if $prpage!=no
473
      test=!fileexists wimshome/log/classes/$wims_class/doc/$prpage.def
474
      !if $test!=yes
475
        prpage=no
476
      !endif
477
    !endif
12312 bpr 478
  !endif
16919 guerimand 479
 
14441 guerimand 480
  !if $hidden_condition!=$empty
481
    !readproc adm/vfilter/convertformat.proc formal\
482
$hidden_condition
483
    formal_hidden_condition=$output_convertformat
16195 guerimand 484
    !if $output_error!=$empty
485
      error=badtechvarname $output_error
486
    !endif
487
    !readproc adm/vfilter/convertformat.proc human\
488
$formal_hidden_condition
489
    hidden_condition=$output_convertformat
14441 guerimand 490
  !else
491
    formal_hidden_condition=$empty
492
  !endif
15763 guerimand 493
  !! indivtechvar is not modifiable when sheet is activated.
494
  !if $activetest>0
495
    rec=!record $sheet of wimshome/log/classes/$wims_class/sheets/.sheets
496
    indivtechvar=!item 10 of $rec
497
  !endif
15860 guerimand 498
  !bound indivtechvar within $empty,$tv_listlocalcode default $empty
12312 bpr 499
  !if $sheet_exist=yes
500
    !distribute lines 2\
23 reyssat 501
$expiration into update_field,update_content
12312 bpr 502
    !read update.sheet
12801 obado 503
 
12312 bpr 504
    !distribute lines 3\
23 reyssat 505
$title into update_field,update_content
12312 bpr 506
    !read update.sheet
12801 obado 507
 
12312 bpr 508
    !distribute lines 4\
23 reyssat 509
$desc into update_field,update_content
12312 bpr 510
    !read update.sheet
12801 obado 511
 
12312 bpr 512
    !distribute lines 5\
23 reyssat 513
$prpage into update_field,update_content
12312 bpr 514
    !read update.sheet
12801 obado 515
 
12312 bpr 516
    !distribute lines 6\
1969 guerimand 517
$comment into update_field,update_content
12312 bpr 518
    !read update.sheet
13825 bpr 519
 
520
    !distribute lines 7\
521
$attribut into update_field,update_content
522
    !read update.sheet
14646 bpr 523
 
13825 bpr 524
    !distribute lines 8\
525
$exodescshow into update_field,update_content
526
    !read update.sheet
14646 bpr 527
 
14441 guerimand 528
    !distribute lines 9\
529
$formal_hidden_condition into update_field,update_content
530
    !read update.sheet
531
 
15763 guerimand 532
    !if $activetest=0
533
      !distribute lines 10\
534
$indivtechvar into update_field,update_content
535
    !read update.sheet
536
 
537
    !endif
538
 
12312 bpr 539
  !else
540
    !appendfile wimshome/log/classes/$wims_class/sheets/.sheets :0\
23 reyssat 541
$expiration\
542
$title\
543
$desc\
1969 guerimand 544
$prpage\
13825 bpr 545
$comment\
546
$attribut\
14441 guerimand 547
$exodescshow\
15763 guerimand 548
$formal_hidden_condition\
15859 guerimand 549
$empty
550
    indivtechvar=$empty
12312 bpr 551
    sheet_exist=yes
552
    activetest=0
553
    sheet=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
554
    !writefile wimshome/log/classes/$wims_class/sheets/.sheet$sheet
14242 obado 555
    message=$name_createok
12312 bpr 556
  !endif
557
  title_save=$title
558
  desc_save=$desc
559
  prpage_save=$prpage
560
  comment_save=$comment
13825 bpr 561
  attribut_save=$attribut
562
  exodescshow_save=$exodescshow
14441 guerimand 563
  formal_hidden_condition_save=$formal_hidden_condition
15763 guerimand 564
  indivtechvar_save=$indivtechvar
23 reyssat 565
!endif
566
 
16919 guerimand 567
!if $job=prpage and $prpage_save=yes
568
  test=!fileexists wimshome/sessions/$wims_session/user-deposit
569
  !if $test=yes
17881 bpr 570
    msg2wims_primitives=!defof msgprim in wimshome/public_html/scripts/primitives/allmsgprim
17871 bpr 571
    !sh rm -f $wims_home/$wims_sesdir/sheet$(sheet).def;\
16919 guerimand 572
          $wims_home/bin/msg2wims $wims_home/$wims_sesdir/user-deposit $wims_home/$wims_sesdir/sheet$(sheet).def;\
573
          if [ -e $wims_home/$wims_sesdir/sheet$(sheet).def ]; then\
574
            mv $wims_home/$wims_sesdir/sheet$(sheet).def $wims_home/log/classes/$wims_class/sheets/sheet$(sheet).def;\
575
            mv $wims_home/$wims_sesdir/user-deposit $wims_home/log/classes/$wims_class/sheets/sheet$(sheet).src;\
576
          else\
577
            rm -f $wims_home/$wims_sesdir/user-deposit;\
578
          fi;
579
  !endif
580
!endif
581
 
23 reyssat 582
!if $job=activate and $[$activetest]=0
15859 guerimand 583
  !read adm/sheet/checkdepindiv
584
  !if $sheet isitemof $sheet_dependancy and $sheet isitemof $sheet_indivtechvar
585
    error=depindiv
586
    !reset job
587
    !exit
588
  !endif
15857 guerimand 589
  !read adm/sheet/writeweights
12312 bpr 590
  !if $test_expire!=$empty
591
    !distribute items 2,$expiration into update_field,update_content
7801 bpr 592
    !read update.sheet
593
    !reset test_expire
12312 bpr 594
  !endif
595
  !distribute item 1,1 into update_field,update_content
596
  !read update.sheet
597
  activetest=1
598
  wims_class_log=activate sheet $sheet by $wims_realuser
23 reyssat 599
!endif
600
 
13208 obado 601
!! only delete or move items when sheet has not been activated
602
!if $activetest=0
603
  # delete an item
604
  !if $job=delete and $delete>0 and $delete<=$exocnt
14105 guerimand 605
    !read adm/sheet/sheetexam.shift sheet,$sheet,,$delete
13208 obado 606
    delete=
607
    exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sheet
608
  !endif
23 reyssat 609
 
14104 guerimand 610
  # move to specific position
14113 guerimand 611
  !if $job=moveto and $movetarget>=1 and $movetarget<=$[$exocnt+1] and $movesource!=$movetarget and $movesource>=1 and $movesource<=$exocnt
14105 guerimand 612
    !read adm/sheet/sheetexam.shift sheet,$sheet,$movetarget,$movesource
14104 guerimand 613
  !endif
614
 
15763 guerimand 615
  # change individualisation of sheet with a technical variable
15860 guerimand 616
  !if $job=indiv and $indivtechvar!=0 and $indivtechvar!=$empty
15763 guerimand 617
    !read indiv.proc
618
  !endif
16022 bpr 619
 
13432 bpr 620
!endif
621
 
23 reyssat 622
# modify an item
623
!if $job=modify and $modif>0 and $modif<=$exocnt
12312 bpr 624
  !if $activetest=0
625
    exo=!record $modif of wimshome/log/classes/$wims_class/sheets/.sheet$sheet
626
    !distribute lines $exo into D_,p_
13315 bpr 627
    ####
12312 bpr 628
    iniparm=$p_
12387 bpr 629
    !read getparm $iniparm exo random qnum exotrymax
12312 bpr 630
    exocnt_=!itemcnt $get_exo
13315 bpr 631
    #### common with addmodule
12387 bpr 632
    iniparm2=!replace internal & by $\
633
$ in $iniparm
634
    iniparm2_cnt=!linecnt $iniparm2
635
    new_iniparm=
636
    equal==
12312 bpr 637
    !if $get_random=0
638
      !for i=1 to $get_qnum
16037 bpr 639
        update_order=!append item $(update_ex$i) to $update_order
12312 bpr 640
      !next
641
      get_exo=$(get_exo[$update_order])
642
      !for v in $get_exo
13760 bpr 643
        new_iniparm=!append line exo=$v to $new_iniparm
12312 bpr 644
      !next
645
      !for u=1 to $iniparm2_cnt
646
        l=!line $u of $iniparm2
647
        !if exo$equal notin $l
13760 bpr 648
          new_iniparm=!append line $l to $new_iniparm
12312 bpr 649
        !endif
650
      !next
13760 bpr 651
      new_iniparm=!replace internal $\
652
$ by & in $new_iniparm
12312 bpr 653
      new_iniparm=!nospace $new_iniparm
654
      p_=$new_iniparm
7354 bpr 655
    !endif
12387 bpr 656
    !if $get_exotrymax!=$mod_exotrymax
657
      tmp=!nospace $mod_exotrymax
658
      !if exotrymax isin $p_
13315 bpr 659
        !if $tmp!=$empty
660
          p_=!replace internal exotrymax=$get_exotrymax by exotrymax=$tmp in $p_
661
        !else
662
          p_=!replace internal exotrymax=$get_exotrymax by in $p_
663
        !endif
12400 bpr 664
      !else
12387 bpr 665
        !if $tmp!=$empty
12400 bpr 666
          p_=$p_&exotrymax=$tmp
12387 bpr 667
          !reset mod_exotrymax
668
        !endif
669
      !endif
670
      p_=!nospace $p_
12400 bpr 671
      p_=!replace internal && by & in $p_
12387 bpr 672
      !reset tmp
673
    !endif
674
 
13315 bpr 675
    #####
15910 guerimand 676
    mod_indiv=!listintersection $mod_indiv and $listval
677
    !bound mod_weight between $min_weight and $max_weight default 1
12312 bpr 678
    !bound mod_require between 0 and $[10*$require_limit] default 0
15910 guerimand 679
    !if $mod_indiv!=$empty
16022 bpr 680
      nbvalue=!itemcnt $listval
15910 guerimand 681
      !distribute item $max_weight,$[10*$require_limit],$min_weight,0 into limitM_weight,limitM_require,limitm_weight,limitm_require
682
      !for type in weight,require
683
        tmp=$(mod_$type)
684
        !for k=1 to $nbvalue
685
          !bound $type$k between $(limitm_$type) and $(limitM_$type) default $tmp
686
          !if $($type$k)!=$tmp
687
            mod_$type=$(mod_$type);$(listval[$k]),$($type$k)
688
          !endif
689
        !next k
16022 bpr 690
      !next type
15910 guerimand 691
    !endif
12312 bpr 692
    mod_title=!singlespace $mod_title
693
    mod_desc=!singlespace $mod_desc
694
    mod_comment=!singlespace $mod_comment
695
    mod_title=!char 1 to $etitle_limit of $mod_title
696
    mod_desc=!char 1 to $edesc_limit of $mod_desc
697
    mod_comment=!char 1 to $edesc_limit of $mod_comment
4528 bpr 698
  !endif
12312 bpr 699
  !if $mod_feedback notsametext $empty
14646 bpr 700
    !reset mod_feedback_tmp
701
    tmpcnt=!itemcnt $(mod_feedback[;1])
702
    !for t_=1 to $tmpcnt
703
      mod_feedback_=$(mod_feedback[$t_;])
704
      mod_feedback_lim=$(mod_feedback_[2])
705
      mod_feedback_lim2=$(mod_feedback_[3])
706
      !bound mod_feedback_lim between 0 and 11 default 10
707
      !bound mod_feedback_lim2 between 0  and $mod_feedback_lim default 0
708
      mod_feedback_=!nospace $(mod_feedback_[1])
709
      mod_feedback_test=!replace = by _ in $mod_feedback_
710
      !if cmd_new notin $mod_feedback_test
711
        mod_feedback_=!nospace $mod_feedback_&cmd=new
712
      !endif
713
      !if adm/doc isin $mod_feedback_ and job_read notin $mod_feedback_test
714
        mod_feedback_=$mod_feedback_&job=read
715
      !endif
716
      mod_feedback_tmp=!append line $mod_feedback_,$mod_feedback_lim,$mod_feedback_lim2 to $mod_feedback_tmp
717
    !next
718
    mod_feedback=!lines2rows $mod_feedback_tmp
4528 bpr 719
  !endif
7290 bpr 720
 
12312 bpr 721
  exo=$modif
722
  !if $activetest=0
723
    update_content=$D_\
23 reyssat 724
$p_\
725
$mod_require\
726
$mod_weight\
727
$mod_title\
728
$mod_desc\
1969 guerimand 729
$mod_dep\
4528 bpr 730
$mod_comment\
12316 bpr 731
$mod_feedback\
15763 guerimand 732
$mod_attribut\
733
$mod_indiv
12312 bpr 734
    update_field=0
735
    !read adm/class/update.exo
4864 bpr 736
 !else
12312 bpr 737
    !distribute lines 5\
7290 bpr 738
$mod_title into update_field,update_content
12312 bpr 739
    !read adm/class/update.exo
740
    !distribute lines 6\
7290 bpr 741
$mod_desc into update_field,update_content
12312 bpr 742
    !read adm/class/update.exo
743
    !distribute lines 8\
7290 bpr 744
$mod_comment into update_field,update_content
12312 bpr 745
    !read adm/class/update.exo
746
    !distribute lines 9\
7290 bpr 747
$mod_feedback into update_field,update_content
12312 bpr 748
    !read adm/class/update.exo
12316 bpr 749
    !distribute lines 10\
750
$mod_attribut into update_field,update_content
751
    !read adm/class/update.exo
12312 bpr 752
  !endif
7290 bpr 753
 
12316 bpr 754
  !distribute items $ into mod_title,mod_desc,mod_weight,mod_require,mod_dep,\
15763 guerimand 755
    mod_comment,mod_feedback,mod_attribut,mod_indiv
23 reyssat 756
!endif
757
 
758
!if $[$activetest]=0
12312 bpr 759
  erasable=yes
760
  scnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
761
  !for s=$sheet+1 to $scnt
762
    l=!record $s of wimshome/log/classes/$wims_class/sheets/.sheets
763
    l=!line 1 of $l
764
    !if $l>0
765
      erasable=no
766
    !endif
767
  !next s
23 reyssat 768
!endif
769
 
3245 guerimand 770
!if $back=1 and $error=$empty
12312 bpr 771
  !restart module=home
7020 bpr 772
!endif