Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
20 reyssat 1
!! Add sharing between two classes.
2
!! Calling parameters: 2 lines.
3
!! Line 1: initiating class, destination class
4
!! Line 2: list of resources to share.
5
 
6
as_1=!translate internal , to $ $ in $wims_read_parm
7
!distribute lines $as_1 into as_1,as_l
8
!distribute words $as_1 into as_1,as_2
9
as_l=!words2items $as_l
10
 
11
as_t_exo=src def Exindex Extitles
12
as_t_sheet=sheets
13
as_t_exam=exams
14
as_t_doc=doc
15
as_t_vote=vote
16
as_t_cdt=cdt
1322 guerimand 17
as_t_livret=livret
20 reyssat 18
as_t_forum=forum
5392 bpr 19
as_t_user=.users .userlist .userlist_external
20 reyssat 20
as_t_motd=.motd
21
as_t_sup=supervisor
1407 bpr 22
as_t_seq=seq
12115 guerimand 23
as_t_userphoto=photoboard
12895 guerimand 24
as_t_tool=tool
16708 guerimand 25
as_t_freework=freeworks
26
as_list=doc,exo,sheet,exam,vote,cdt,livret,forum,user,motd,sup,livret,seq,userphoto,tool,freework
20 reyssat 27
!if sharing notwordof $wims_prefix
12555 bpr 28
  wims_prefix=$wims_prefix n sharing sharable
20 reyssat 29
!endif
30
 
31
!if all isitemof $as_l
12555 bpr 32
  as_l=$as_list
20 reyssat 33
!else
12555 bpr 34
  !if exam isitemof $as_l
35
    as_l=!listunion $as_l and sheet
36
  !endif
37
  !if sheet iswordof $as_l
38
    as_l=!listunion $as_l and exo
39
  !endif
20 reyssat 40
!endif
41
 
42
L_=
43
!for t in $as_list
12555 bpr 44
  !if $t isitemof $as_l
45
    L_=$L_ $(as_t_$t)
46
  !endif
20 reyssat 47
!next t
48
!if $L_=$empty
12555 bpr 49
  !exit
20 reyssat 50
!endif
51
as_n1=!defof n_sup\
52
n_part in wimshome/log/classes/$as_1/neighbors
53
as_n2=!defof n_sup\
54
n_part in wimshome/log/classes/$as_2/neighbors
55
!distribute lines $as_n1 into as_nsup1,as_npart1
56
!distribute lines $as_n2 into as_nsup2,as_npart2
57
as_test=!listcomplement user in $as_l
58
!if ($as_test!=$empty and \
14336 bpr 59
    ($as_2 notitemof $as_nsup1 or $as_1 notitemof $as_nsup2)) or \
20 reyssat 60
    (user isitemof $as_l and \
14336 bpr 61
    ($as_2 notitemof $as_npart1 or $as_1 notitemof $as_npart2))
12555 bpr 62
  error=addshare_noright
63
  !exit
20 reyssat 64
!endif
65
 
66
1_=!translate internal / to , in $as_1
67
2_=!translate internal / to , in $as_2
68
1=!itemcnt $1_
69
2=!itemcnt $2_
70
3=$[min($1,$2)]
71
 
72
!for i=1 to $3+1
12555 bpr 73
  !if $(1_[$i]) != $(2_[$i])
74
    !break
75
  !endif
20 reyssat 76
!next i
77
 
78
1_=!item $i to -1 of $1_
79
!if $i<=$2
12555 bpr 80
  4_=!makelist .. for x=$i to $2
81
  1_=$4_,$1_
20 reyssat 82
!endif
83
1_=!nonempty items $1_
84
1_=!nospace $1_
85
1_=!translate internal , to / in $1_
86
 
87
!for t in $as_list
12555 bpr 88
  !reset sharing_$t
20 reyssat 89
!next t
90
!readdef wimshome/log/classes/$as_1/neighbors
91
!for t in $as_l
12555 bpr 92
  !if $(sharing_$t) != $empty
93
    error=addshare_conflict
94
    !exit
95
  !endif
20 reyssat 96
!next t
97
!for t in $as_list
12555 bpr 98
  !reset sharable_$t
20 reyssat 99
!next t
100
!readdef wimshome/log/classes/$as_2/neighbors
101
as_already=
102
!for t in $as_l
12555 bpr 103
  !if $(sharable_$t) != $empty
104
    error=addshare_conflict
105
    !exit
20 reyssat 106
  !endif
12555 bpr 107
  !if $(sharing_$t) != $empty
108
    !if $(sharing_$t) = $as_1
109
      as_already=!append item $t to $as_already
110
    !else
111
      error=addshare_conflict
112
      !exit
113
    !endif
114
  !endif
20 reyssat 115
!next t
116
!if $as_already!=$empty
12555 bpr 117
  as_l=!listcomplement $as_already in $as_l
20 reyssat 118
!endif
119
!for t in $as_list
12555 bpr 120
  !reset sharable_$t
20 reyssat 121
!next t
122
!readdef wimshome/log/classes/$as_1/neighbors
123
as_=
124
!for t in $as_l,all
12555 bpr 125
  sharable_$t=!listunion $(sharable_$t) and $as_2
126
  as_=$as_\
20 reyssat 127
sharable_$t=$(sharable_$t)
128
!next t
129
!setdef $as_ in wimshome/log/classes/$as_1/neighbors
130
!for t in $as_list
12555 bpr 131
  !reset sharing_$t
20 reyssat 132
!next t
133
!readdef wimshome/log/classes/$as_2/neighbors
134
as_=
135
!for t in $as_l
12555 bpr 136
  as_=$as_\
20 reyssat 137
sharing_$t=$as_1
138
!next t
139
sharing_all=!listunion $sharing_all and $as_1
140
as_=$as_\
141
sharing_all=$sharing_all
142
!setdef $as_ in wimshome/log/classes/$as_2/neighbors
143
 
144
as_copy=
145
!if sheet isitemof $as_l
12555 bpr 146
  as_copy=$1_/.[0-9]*
20 reyssat 147
!endif
148
!if exam isitemof $as_l
12555 bpr 149
  as_copy=$as_copy $1_/.E[0-9]*
20 reyssat 150
!endif
151
!if $as_copy!=$empty
12555 bpr 152
  as_copy=cp -f $as_copy . 2>/dev/null
20 reyssat 153
!endif
5392 bpr 154
!if user isitemof $as_l
155
  as_touch=touch $1_/.userlist_external
156
!endif
20 reyssat 157
 
158
!sh cd $wims_home/log/classes/$as_2\
159
 rm -Rf $L_\
5392 bpr 160
 $as_touch\
20 reyssat 161
 for f in $L_; do\
162
  ln -s $1_/$$f .\
163
 done\
164
 $as_copy