1
|
|
|
<?php |
2
|
|
|
/************************************************************************ |
3
|
|
|
* OVIDENTIA http://www.ovidentia.org * |
4
|
|
|
************************************************************************ |
5
|
|
|
* Copyright (c) 2003 by CANTICO ( http://www.cantico.fr ) * |
6
|
|
|
* * |
7
|
|
|
* This file is part of Ovidentia. * |
8
|
|
|
* * |
9
|
|
|
* Ovidentia is free software; you can redistribute it and/or modify * |
10
|
|
|
* it under the terms of the GNU General Public License as published by * |
11
|
|
|
* the Free Software Foundation; either version 2, or (at your option) * |
12
|
|
|
* any later version. * |
13
|
|
|
* * |
14
|
|
|
* This program is distributed in the hope that it will be useful, but * |
15
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
17
|
|
|
* See the GNU General Public License for more details. * |
18
|
|
|
* * |
19
|
|
|
* You should have received a copy of the GNU General Public License * |
20
|
|
|
* along with this program; if not, write to the Free Software * |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,* |
22
|
|
|
* USA. * |
23
|
|
|
************************************************************************/ |
24
|
|
|
|
25
|
|
|
bab_Widgets()->includePhpClass('Widget_Form'); |
26
|
|
|
|
27
|
|
|
require_once dirname(__FILE__).'/right.class.php'; |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
class absences_SyncServerEditor extends Widget_Form |
31
|
|
|
{ |
32
|
|
|
private $I; |
33
|
|
|
|
34
|
|
|
public function __construct() |
35
|
|
|
{ |
36
|
|
|
$W = bab_Widgets(); |
37
|
|
|
|
38
|
|
|
parent::__construct(null, $W->VBoxLayout()->setVerticalSpacing(1,'em')); |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
$this->setName('sync_server'); |
42
|
|
|
$this->addClass('widget-bordered'); |
43
|
|
|
$this->addClass('BabLoginMenuBackground'); |
44
|
|
|
$this->addClass('widget-centered'); |
45
|
|
|
$this->colon(); |
46
|
|
|
|
47
|
|
|
$this->setCanvasOptions($this->Options()->width(70,'em')); |
|
|
|
|
48
|
|
|
|
49
|
|
|
$this->I = new absences_RightIterator; |
50
|
|
|
$this->I->kind = array(absences_Right::REGULAR, absences_Right::CET); |
|
|
|
|
51
|
|
|
|
52
|
|
|
$this->addFields(); |
53
|
|
|
$this->loadFormValues(); |
54
|
|
|
|
55
|
|
|
$this->addButtons(); |
56
|
|
|
$this->setSelfPageHiddenFields(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
|
61
|
|
|
protected function addFields() |
62
|
|
|
{ |
63
|
|
|
$W = bab_Widgets(); |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
$this->addItem($W->Label(absences_translate('Shared rights'))); |
67
|
|
|
|
68
|
|
|
$frame = $W->Frame()->setName('right'); |
69
|
|
|
$this->addItem($frame); |
70
|
|
|
|
71
|
|
|
foreach($this->I as $right) |
72
|
|
|
{ |
73
|
|
|
$frame->addItem($this->shareRight($right)); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
protected function shareRight(absences_Right $right) |
80
|
|
|
{ |
81
|
|
|
$W = bab_Widgets(); |
82
|
|
|
return $W->LabelledWidget($right->description, $W->CheckBox())->setName($right->id); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
protected function loadFormValues() |
87
|
|
|
{ |
88
|
|
|
$values = array('right' => array()); |
89
|
|
|
|
90
|
|
|
foreach($this->I as $right) |
91
|
|
|
{ |
92
|
|
|
/*@var $right absences_Right */ |
93
|
|
|
if (absences_Right::SYNC_SERVER === $right->getSyncStatus()) |
94
|
|
|
{ |
95
|
|
|
$values['right'][$right->id] = 1; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
$this->setValues($values, array('sync_server')); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
|
103
|
|
View Code Duplication |
protected function addButtons() |
|
|
|
|
104
|
|
|
{ |
105
|
|
|
$W = bab_Widgets(); |
106
|
|
|
|
107
|
|
|
$button = $W->FlowItems( |
108
|
|
|
$W->SubmitButton()->setName('save')->setLabel(absences_translate('Save')) |
109
|
|
|
)->setSpacing(1,'em'); |
110
|
|
|
|
111
|
|
|
$this->addItem($button); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
|
117
|
|
|
|
118
|
|
|
|
119
|
|
|
|
120
|
|
|
|
121
|
|
|
|
122
|
|
|
|
123
|
|
|
|
124
|
|
|
|
125
|
|
|
|
126
|
|
|
|
127
|
|
|
|
128
|
|
|
|
129
|
|
|
|
130
|
|
|
|
131
|
|
|
|
132
|
|
|
class absences_SyncClientEditor extends Widget_Form |
133
|
|
|
{ |
134
|
|
|
private $I; |
135
|
|
|
|
136
|
|
|
public function __construct() |
137
|
|
|
{ |
138
|
|
|
$W = bab_Widgets(); |
139
|
|
|
|
140
|
|
|
parent::__construct(null, $W->VBoxLayout()->setVerticalSpacing(1,'em')); |
141
|
|
|
|
142
|
|
|
|
143
|
|
|
$this->setName('sync_client'); |
144
|
|
|
$this->addClass('widget-bordered'); |
145
|
|
|
$this->addClass('BabLoginMenuBackground'); |
146
|
|
|
$this->addClass('widget-centered'); |
147
|
|
|
$this->colon(); |
148
|
|
|
|
149
|
|
|
$this->setCanvasOptions($this->Options()->width(70,'em')); |
|
|
|
|
150
|
|
|
|
151
|
|
|
$this->addFields(); |
152
|
|
|
$this->loadFormValues(); |
153
|
|
|
|
154
|
|
|
$this->addButtons(); |
155
|
|
|
$this->setSelfPageHiddenFields(); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @throws Exception |
161
|
|
|
*/ |
162
|
|
|
protected function addFields() |
163
|
|
|
{ |
164
|
|
|
$W = bab_Widgets(); |
165
|
|
|
|
166
|
|
|
|
167
|
|
|
$this->addItem($W->Label(sprintf(absences_translate('Shared rights from %s'), absences_getVacationOption('sync_url')))); |
168
|
|
|
|
169
|
|
|
$frame = $W->Frame()->setName('right'); |
170
|
|
|
$this->addItem($frame); |
171
|
|
|
|
172
|
|
|
require_once dirname(__FILE__).'/client.class.php'; |
173
|
|
|
|
174
|
|
|
$client = new absences_client; |
175
|
|
|
|
176
|
|
|
$rights = $client->getCachedData(); |
177
|
|
|
|
178
|
|
|
if (!$rights) |
|
|
|
|
179
|
|
|
{ |
180
|
|
|
$frame->addItem($W->Label(absences_translate('No rights found'))); |
181
|
|
|
return; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
foreach($rights as $arr) |
185
|
|
|
{ |
186
|
|
|
|
187
|
|
|
$right = new absences_Right(''); |
188
|
|
|
$right->setRow($arr['absences_rights']); |
189
|
|
|
$frame->addItem($this->useRight($right)); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
|
193
|
|
|
$this->addItem($W->Label(absences_translate('The checked rights will be autmatically updated every hours'))); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
|
197
|
|
|
protected function useRight(absences_Right $right) |
198
|
|
|
{ |
199
|
|
|
$W = bab_Widgets(); |
200
|
|
|
|
201
|
|
|
if (!isset($right->description)) |
202
|
|
|
{ |
203
|
|
|
return null; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
return $W->LabelledWidget($right->description, $W->CheckBox())->setName($right->uuid); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
|
210
|
|
|
protected function loadFormValues() |
211
|
|
|
{ |
212
|
|
|
$values = array('right' => array()); |
213
|
|
|
|
214
|
|
|
$I = new absences_RightIterator(); |
215
|
|
|
$I->archived = null; |
216
|
|
|
$I->sync_status = array(absences_Right::SYNC_CLIENT, absences_Right::SYNC_CLIENT_END, absences_Right::SYNC_CLIENT_ERROR); |
|
|
|
|
217
|
|
|
|
218
|
|
|
|
219
|
|
|
foreach($I as $right) |
220
|
|
|
{ |
221
|
|
|
$values['right'][$right->uuid] = 1; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
$this->setValues($values, array('sync_client')); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
|
228
|
|
View Code Duplication |
protected function addButtons() |
|
|
|
|
229
|
|
|
{ |
230
|
|
|
$W = bab_Widgets(); |
231
|
|
|
|
232
|
|
|
$button = $W->FlowItems( |
233
|
|
|
$W->SubmitButton()->setName('save')->setLabel(absences_translate('Save')) |
234
|
|
|
)->setSpacing(1,'em'); |
235
|
|
|
|
236
|
|
|
$this->addItem($button); |
237
|
|
|
} |
238
|
|
|
} |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.