Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
9447 guerimand 1
sjob=$job
16748 bpr 2
!!to avoid sheet of an open class
3
noopenclone=
17181 guerimand 4
!if $ssourcecls=$empty and $step>-2
5
  step=-3
9454 guerimand 6
!endif
17185 guerimand 7
!if $scheckpwd!=1 and $step>-1
8
  step=-2
9
  !exit
10
!endif
17181 guerimand 11
!if $smethodecp=$empty and $step>0
12
  step=-1
13
  !exit
14
!endif
9454 guerimand 15
 
16
!if $wims_class=$empty
12659 bpr 17
  cltype=0
9454 guerimand 18
!else
14335 bpr 19
  !read adm/class/userdef classes,$wims_class,$wims_user
16250 guerimand 20
  supervisable=!defof user_supervisable\
21
user_mkclass in $userdef
22
  !distribute line $supervisable into supervisable,mkclass
23
  !if $wims_supertype!=2 or ($wims_user!=supervisor and $supervisable!=yes) or $wims_class!=$wims_superclass or $mkclass=no
14335 bpr 24
    error=no_subclass
25
    !exit
26
  !endif
9454 guerimand 27
!endif
28
 
29
!if $step=-3
12659 bpr 30
  !! search if exists at less one cloneable class (verifying keywords)
17185 guerimand 31
  !reset scheckpwd
14335 bpr 32
  keyword=!items2words $keyword
33
  keyword=!trim $keyword
34
  kw=!words2items $keyword
35
  kw=!deaccent $kw
36
  kw=!tolower $kw
37
  ccnt=!recordcnt wimshome/log/classes/.index
38
  i=1
39
  debcls=$empty
40
  !while $i<=$ccnt and $debcls=$empty
41
    l=!record $i of wimshome/log/classes/.index
42
    !distribute items $l into code,expire,inst,cl,la,ty
43
    !if $ty!=4
44
      l1=!deaccent $l
45
      l1=!tolower $l1
46
      c1=!text extract 0123456789 in $code
47
      k=yes
48
      !if $kw!=$empty
49
        !for w in $kw
50
          !if $w notin $l1
51
            !let k=no
52
            !break
53
          !endif
54
        !next w
55
      !endif
12659 bpr 56
      !if $k=no and $kw!=$empty and $ty=2
14335 bpr 57
        !! find of keyword in subclasses
58
        sbcnt=!recordcnt wimshome/log/classes/$code/.subclasses
59
        sb=1
60
        !while $sb<=$sbcnt and $k=no
12659 bpr 61
          ksb=yes
62
          l1sb=!record $sb of wimshome/log/classes/$code/.subclasses
14335 bpr 63
          l1sb=!deaccent $l1sb
64
          l1sb=!tolower $l1sb
12659 bpr 65
          !for w in $kw
14335 bpr 66
            !if $w notin $l1sb
67
              ksb=no
68
              !!break
69
            !endif
70
          !next w
71
          !if $ksb=yes
72
            k=yes
12659 bpr 73
          !endif
14335 bpr 74
          !increase sb
12659 bpr 75
        !endwhile
76
      !endif
14335 bpr 77
      !if $k=yes
78
        debcls=$i
79
      !endif
80
    !endif
81
    !increase i
82
  !endwhile
83
  !exit
9454 guerimand 84
!endif
85
 
86
!if $step=-2
17190 guerimand 87
  !if $sourcecls!=file and $sourcecls!=wget
17181 guerimand 88
    !! checking allowed clonage + ask for cloning pwd
89
    sourcecls=!text select /0123456789 in $sourcecls
90
    tmp=!defof class_defined\
9461 guerimand 91
class_allowcloning\
9534 guerimand 92
class_type\
93
class_typename in wimshome/log/classes/$sourcecls/.def
17181 guerimand 94
    testneighbors=!defof sharing_all in wimshome/log/classes/$sourcecls/neighbors
95
    !distribute line $tmp into tmp1,tmp3,tmp6,tmp7
96
    !if yes!=$tmp1
97
      error=classdontexists
14335 bpr 98
      !exit
99
    !endif
17181 guerimand 100
    !if $sourcecls<=9999 and $sourcecls notin $noopenclone
101
      step=-1
102
    !else
103
      !! only single class can be cloned (waiting other improvment)
104
      !! class with sharing can't be cloned.
105
      !if (($tmp6!=1 or $tmp7!=class) and 0!=$tmp6) or $testneighbors!=$empty
106
        error=disallowcloning
107
        !exit
108
      !endif
109
      !if yes!=$tmp3
110
        error=cloningnotallow
111
        !exit
112
      !endif
14335 bpr 113
    !endif
17181 guerimand 114
    ssourcecls=$sourcecls
115
  !else
17190 guerimand 116
    !if $sourcecls=file
117
      !! --- manage to clone a tgz file classe
118
      !if $wims_deposit!=$empty
119
        wims_deposit=!word 1 of $wims_deposit
120
        selection=
121
        gotlist=
122
        !if . notin $wims_deposit or / isin $wims_deposit or .. isin $wims_deposit
123
          error=bad_file
124
          !exit
125
        !endif
126
      !endif
127
      t=!translate . to $ $ in $wims_deposit
128
      format=!word 2 to -1 of $t
129
      format=!translate $ $ to . in $format
130
      !if $format notwordof tgz tar.gz zip
17165 guerimand 131
        error=bad_file
132
        !exit
133
      !endif
17190 guerimand 134
    !else
135
      !! manage of method wget
136
      !read adm/class/authchars
137
      wgetfile=!text select /&=$char_passwd in $wgetfile
138
      t=!translate / to , in $wgetfile
139
      t=!item -1 of $t
140
      t=!translate . to $ $ in $t
141
      format=!word 2 to -1 of $t
142
      format=!translate $ $ to . in $format
143
      !if $format notwordof tgz tar.gz zip
144
        error=bad_file
145
        !exit
146
      !endif
147
      !sh cd $wims_home/sessions/$wims_session;\
17208 guerimand 148
          wget -O user-deposit "$wgetfile" 2> /dev/null;
17190 guerimand 149
      wims_deposit=savecls.tgz
17165 guerimand 150
    !endif
151
    !sh $wims_home/public_html/scripts/adm/decompress.sh
152
    ssourcecls=file
17185 guerimand 153
    scheckpwd=1
17181 guerimand 154
    step=-1
155
  !endif
156
  !exit
157
!endif
158
 
159
!if $step=-1
160
  !!checking pwd or exampleclass
17194 guerimand 161
  !if $ssourcecls=file or $ssourcecls=wget
17185 guerimand 162
    scheckpwd=1
17165 guerimand 163
  !else
164
    !if $ssourcecls>9999
165
      !! check cloningpwd
166
      !! --------------------------------------- attention il faut rajouter la temporisation pour badpwd
167
      pwd=!defof class_cloningpwd in wimshome/log/classes/$ssourcecls/.def
168
      !if $pwd!=$clonepwd
169
        error=badcloningpwd
170
        step=-2
171
        !exit
172
      !endif
173
    !endif
17185 guerimand 174
    scheckpwd=1
12659 bpr 175
  !endif
17185 guerimand 176
  !exit
9461 guerimand 177
!endif
178
 
17165 guerimand 179
!if $ssourcecls=file
180
  source_title=!defof class_institution,class_description in wimshome/sessions/$wims_session/upload/class/.def
181
!else
182
  source_title=!defof class_institution,class_description in wimshome/log/classes/$ssourcecls/.def
183
!endif
9447 guerimand 184
 
185
!if $step=0
12659 bpr 186
  !if $methodecp!=0 and $methodecp!=1
14335 bpr 187
    error=badcpmethod
188
    !exit
12659 bpr 189
  !endif
190
  smethodecp=$methodecp
9447 guerimand 191
!endif
192
 
193
!read proc/newclass.proc
194
 
195
!! ajout des ressources de la classe d'exemple
196
!if $step=3
12659 bpr 197
  !read proc/cloning.proc
198
  !if $wims_class!=$empty
14335 bpr 199
    !restart module=home
12659 bpr 200
  !endif
9454 guerimand 201
!endif