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