Subversion Repositories wimsdev

Rev

Rev 20 | Rev 1407 | Go to most recent revision | 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
19
as_t_user=.users .userlist
20
as_t_motd=.motd
21
as_t_sup=supervisor
1322 guerimand 22
as_list=doc,exo,sheet,exam,vote,cdt,livret,forum,user,motd,sup
20 reyssat 23
!if sharing notwordof $wims_prefix
24
 wims_prefix=$wims_prefix n sharing sharable
25
!endif
26
 
27
!if all isitemof $as_l
28
 as_l=$as_list
29
!else
30
 !if exam isitemof $as_l
31
  as_l=!listunion $as_l and sheet
32
 !endif
33
 !if sheet iswordof $as_l
34
  as_l=!listunion $as_l and exo
35
 !endif
36
!endif
37
 
38
L_=
39
!for t in $as_list
40
 !if $t isitemof $as_l
41
  L_=$L_ $(as_t_$t)
42
 !endif
43
!next t
44
!if $L_=$empty
45
 !exit
46
!endif
47
as_n1=!defof n_sup\
48
n_part in wimshome/log/classes/$as_1/neighbors
49
as_n2=!defof n_sup\
50
n_part in wimshome/log/classes/$as_2/neighbors
51
!distribute lines $as_n1 into as_nsup1,as_npart1
52
!distribute lines $as_n2 into as_nsup2,as_npart2
53
as_test=!listcomplement user in $as_l
54
!if ($as_test!=$empty and \
55
	($as_2 notitemof $as_nsup1 or $as_1 notitemof $as_nsup2)) or \
56
    (user isitemof $as_l and \
57
	($as_2 notitemof $as_npart1 or $as_1 notitemof $as_npart2))
58
 error=addshare_noright
59
 !exit
60
!endif
61
 
62
1_=!translate internal / to , in $as_1
63
2_=!translate internal / to , in $as_2
64
1=!itemcnt $1_
65
2=!itemcnt $2_
66
3=$[min($1,$2)]
67
 
68
!for i=1 to $3+1
69
 !if $(1_[$i]) != $(2_[$i])
70
  !break
71
 !endif
72
!next i
73
 
74
1_=!item $i to -1 of $1_
75
!if $i<=$2
76
 4_=!makelist .. for x=$i to $2
77
 1_=$4_,$1_
78
!endif
79
1_=!nonempty items $1_
80
1_=!nospace $1_
81
1_=!translate internal , to / in $1_
82
 
83
!for t in $as_list
84
 !reset sharing_$t
85
!next t
86
!readdef wimshome/log/classes/$as_1/neighbors
87
!for t in $as_l
88
 !if $(sharing_$t) != $empty
89
  error=addshare_conflict
90
  !exit
91
 !endif
92
!next t
93
!for t in $as_list
94
 !reset sharable_$t
95
!next t
96
!readdef wimshome/log/classes/$as_2/neighbors
97
as_already=
98
!for t in $as_l
99
 !if $(sharable_$t) != $empty
100
  error=addshare_conflict
101
  !exit
102
 !endif
103
 !if $(sharing_$t) != $empty
104
  !if $(sharing_$t) = $as_1
105
   as_already=!append item $t to $as_already
106
  !else
107
   error=addshare_conflict
108
   !exit
109
  !endif
110
 !endif
111
!next t
112
!if $as_already!=$empty
113
 as_l=!listcomplement $as_already in $as_l
114
!endif
115
!for t in $as_list
116
 !reset sharable_$t
117
!next t
118
!readdef wimshome/log/classes/$as_1/neighbors
119
as_=
120
!for t in $as_l,all
121
 sharable_$t=!listunion $(sharable_$t) and $as_2
122
 as_=$as_\
123
sharable_$t=$(sharable_$t)
124
!next t
125
!setdef $as_ in wimshome/log/classes/$as_1/neighbors
126
!for t in $as_list
127
 !reset sharing_$t
128
!next t
129
!readdef wimshome/log/classes/$as_2/neighbors
130
as_=
131
!for t in $as_l
132
 as_=$as_\
133
sharing_$t=$as_1
134
!next t
135
sharing_all=!listunion $sharing_all and $as_1
136
as_=$as_\
137
sharing_all=$sharing_all
138
!setdef $as_ in wimshome/log/classes/$as_2/neighbors
139
 
140
as_copy=
141
!if sheet isitemof $as_l
142
 as_copy=$1_/.[0-9]*
143
!endif
144
!if exam isitemof $as_l
145
 as_copy=$as_copy $1_/.E[0-9]*
146
!endif
147
!if $as_copy!=$empty
148
 as_copy=cp -f $as_copy . 2>/dev/null
149
!endif
150
 
151
!sh cd $wims_home/log/classes/$as_2\
152
 rm -Rf $L_\
153
 for f in $L_; do\
154
  ln -s $1_/$$f .\
155
 done\
156
 $as_copy
157