Subversion Repositories wimsdev

Rev

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