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