Completed
Push — master ( 337770...ba0a0c )
by
unknown
07:39 queued 14s
created

caldav_resources   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 46.88 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 30
loc 64
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 16 16 1
A getnext() 0 19 2
A display() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
//-------------------------------------------------------------------------
3
// OVIDENTIA http://www.ovidentia.org
4
// Ovidentia is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 2, or (at your option)
7
// any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
// See the GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17
// USA.
18
//-------------------------------------------------------------------------
19
/**
20
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
21
 * @copyright Copyright (c) 2008 by CANTICO ({@link http://www.cantico.fr})
22
 */
23
require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
24
require_once dirname(__FILE__) . '/functions.php';
25
26
function caldav_editConfiguration()
27
{
28
	global $babBody;
29
	$W = bab_Widgets();
30
	$page = $W->BabPage();
31
	$page->setTitle(caldav_translate('CalDAV configuration'));
32
33
	/* @var $caldav Func_CalendarBackend_Caldav */
34
	$caldav = bab_functionality::get('CalendarBackend/Caldav');
35
36
	if (!$caldav) {
37
		$babBody->addError(caldav_translate('Unable to instanciate \'CalendarBackend/Caldav\' functionality.'));
38
		$babBody->addError(caldav_translate('Please check that the LibCaldav addon is correctly installed.'));
39
		return;
40
	}
41
42
	$userCalendarUrl = $caldav->getDefaultUserCalendarUrl();
43
	$adminIdentifier =  $caldav->getAdminIdentifier();
44
	$adminPassword = $caldav->getAdminPassword();
45
	$storagebackend = $caldav->getStorageBackend();
46
	$verify_peer = $caldav->getVerifyPeer();
47
	$configbyuser = $caldav->configByUser();
48
49
	$registry = bab_getRegistryInstance();
50
	$registry->changeDirectory('/LibCaldav/');
51
	$default_backend = $registry->getValue('default_backend');
52
	
53
	$deleteOnCancel = $registry->getValue('deleteOnCancel', false);
54
55
56
	$form = $W->Form(null, $W->VBoxLayout()->setVerticalSpacing(1, 'em'));
57
	$options = $form->Options()->width(70,'em');
58
	$form->addClass('BabLoginMenuBackground')
59
		->addClass('widget-centered')
60
		->addClass('widget-bordered')
61
		->setCanvasOptions($options);
62
	$form->setHiddenValue('tg', bab_rp('tg'));
63
	$form->setHiddenValue('idx', 'saveConfiguration');
64
	
65
	$form->addItem(
66
		$W->LabelledWidget(caldav_translate('Use caldav for user events storage and allow users to select caldav'), $W->CheckBox()->setValue($storagebackend), 'storagebackend')
67
	);
68
	
69
	$common = $W->Frame(null, $W->VBoxLayout()->setVerticalSpacing(1,'em'));
70
	
71
	
72
	
73
	$form->addItem(
74
			$W->LabelledWidget(caldav_translate('Users can configure the username and password'), $W->CheckBox()->setValue($configbyuser)->setAssociatedDisplayable($common, array('0')), 'configbyuser')
75
	);
76
	
77
	
78
	$form->addItem($common);
79
	
80
	$desc = caldav_translate('%u will be replaced by the ovidentia login id');
81
	
82
	$common->addItem($W->LabelledWidget(caldav_translate('User calendar url'), $W->LineEdit()->setSize(70)->setValue($userCalendarUrl), 'user_calendar_url', $desc));
83
	$common->addItem($W->LabelledWidget(caldav_translate('Admin identifier'), $W->LineEdit()->setSize(30)->setValue($adminIdentifier), 'admin_identifier'));
84
	$common->addItem($W->LabelledWidget(caldav_translate('Admin password'), $W->LineEdit()->setSize(30)->obfuscate()->setValue($adminPassword), 'admin_password'));
85
	$common->addItem($W->LabelledWidget(caldav_translate('Change calendar backend to caldav for all ovidentia users'), $W->CheckBox(), 'set_caldav'));
86
	$common->addItem($W->LabelledWidget(caldav_translate('Set the caldav backend for the new created users'), $W->CheckBox()->setValue((bool) $default_backend), 'default_backend'));
87
	
88
	
89
	$form->addItem($W->LabelledWidget(caldav_translate('SSL peer verification for HTTPS serveurs'), $W->CheckBox()->setValue((bool) $verify_peer), 'verify_peer'));
90
	
91
	
92
	$form->addItem($W->LabelledWidget(
93
	    caldav_translate('Delete events on cancel'), 
94
	    $W->CheckBox()->setValue($deleteOnCancel), 
95
	    'deleteOnCancel',
96
	    caldav_translate('On SoGo, canceled events are displayed like the others events, use this option to really delete events when canceled by ovidentia.')
97
	));
98
	
99
	$form->addItem($W->SubmitButton()->setLabel(caldav_translate('Save')));
100
	
101
	$page->addItem($form);
102
	
103
	$addon = bab_getAddonInfosInstance('LibCaldav');
104
	
105
	
106
	$page->addItemMenu('configuration', caldav_translate('Configuration'), $addon->getUrl().'configuration');
0 ignored issues
show
Deprecated Code introduced by
The method Widget_BabPage::addItemMenu() has been deprecated with message: Replaced by Widget_Tabs

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
107
	$page->addItemMenu('servers', caldav_translate('Servers'), $addon->getUrl().'configuration&idx=servers');
0 ignored issues
show
Deprecated Code introduced by
The method Widget_BabPage::addItemMenu() has been deprecated with message: Replaced by Widget_Tabs

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
108
	$page->addItemMenu('resources', caldav_translate('Resources'), $addon->getUrl().'configuration&idx=resources');
0 ignored issues
show
Deprecated Code introduced by
The method Widget_BabPage::addItemMenu() has been deprecated with message: Replaced by Widget_Tabs

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
109
	
110
	$page->setCurrentItemMenu('configuration');
0 ignored issues
show
Deprecated Code introduced by
The method Widget_BabPage::setCurrentItemMenu() has been deprecated with message: Replaced by Widget_Tabs

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
111
	
112
	$page->displayHtml();
113
}
114
115
116
117
function caldav_saveConfiguration($configbyuser, $userCalendarUrl, $adminIdentifier, $adminPassword, $storagebackend, $verify_peer, $set_caldav, $default_backend, $deleteOnCancel)
118
{
119
	$babBody = bab_getBody();
120
121
	/* @var $caldav Func_CalendarBackend_Caldav */
122
	$caldav = bab_functionality::get('CalendarBackend/Caldav');
123
124 View Code Duplication
	if (!$caldav) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
125
		$babBody->addError(caldav_translate('Unable to instanciate "CalendarBackend/Caldav" functionality.'));
126
		$babBody->addError(caldav_translate('Please check that the LibCaldav addon is correctly installed.'));
127
		return false;
128
	}
129
	
130
	if ($configbyuser)
131
	{
132
		$userCalendarUrl = '';
133
		$adminIdentifier = '';
134
		$adminPassword = '';
135
	}
136
137
	$caldav->setDefaultUserCalendarUrl($userCalendarUrl);
138
	$caldav->setAdminIdentifier($adminIdentifier);
139
	$caldav->setAdminPassword($adminPassword);
140
	$caldav->setStorageBackend($storagebackend);
141
	$caldav->setVerifyPeer($verify_peer);
142
	
143
	if ($set_caldav)
144
	{
145
		require_once $GLOBALS['babInstallPath'].'utilit/calapi.php';
146
		
147
		if (!function_exists('bab_setPersonnalCalendarBackend'))
148
		{
149
			$babBody->addError(caldav_translate('Ovidentia 9.1.93 is required to set the caldendar backend on all users'));
150
		}
151
		
152
		$arr = bab_getGroupsMembers(BAB_REGISTERED_GROUP);
153
		foreach($arr as $user)
0 ignored issues
show
Bug introduced by
The expression $arr of type array|false is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
154
		{
155
			bab_setPersonnalCalendarBackend($user['id'], $caldav);
156
		}
157
	}
158
	
159
	
160
	$registry = bab_getRegistryInstance();
161
	$registry->changeDirectory('/LibCaldav/');
162
	$registry->setKeyValue('default_backend', (bool) $default_backend);
163
	$registry->setKeyValue('deleteOnCancel', (bool) $deleteOnCancel);
164
	
165
166
	$babBody->babEcho('<div style="border: 1px solid #cca; padding: 1em; margin: 2em; background-color: #eec">' . caldav_translate('Configuration saved.') . '</div>');
167
168
	return true;
169
}
170
171
172
173
174
class caldav_servers
175
{
176
	private $res;
177
178
	public $t_name;
179
	public $t_url;
180
	public $t_add;
181
	public $addurl;
182
	
183
	public $altbg = true;
184
185
186 View Code Duplication
	public function __construct()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
187
	{
188
		global $babDB;
189
		$addon = bab_getAddonInfosInstance('LibCaldav');
190
191
		$this->res = $babDB->db_query("SELECT * FROM libcaldav_servers");
192
193
194
		$this->t_name = caldav_translate('Name');
195
		$this->t_server_url = caldav_translate('Caldav Server Url');
0 ignored issues
show
Bug introduced by
The property t_server_url does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
196
		$this->t_user_calendar_path = caldav_translate('User calendar path');
0 ignored issues
show
Bug introduced by
The property t_user_calendar_path does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
197
		$this->t_add = caldav_translate('Add');
198
		$this->t_use_unique_id = caldav_translate('Use unique ID');
0 ignored issues
show
Bug introduced by
The property t_use_unique_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
199
200
		$this->addurl = $addon->getUrl().'configuration&idx=server';
201
202
	}
203
204
	public function getnext()
205
	{
206
		global $babDB;
207
208
		if ($arr = $babDB->db_fetch_assoc($this->res))
209
		{
210
			$this->altbg = !$this->altbg;
211
			$addon = bab_getAddonInfosInstance('LibCaldav');
212
213
			$this->name = bab_toHtml($arr['name']);
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
214
			$this->server_url 	= bab_toHtml($arr['server_url']);
0 ignored issues
show
Bug introduced by
The property server_url does not seem to exist. Did you mean t_server_url?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
215
			$this->user_calendar_path 	= bab_toHtml($arr['user_calendar_path']);
0 ignored issues
show
Bug introduced by
The property user_calendar_path does not seem to exist. Did you mean t_user_calendar_path?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
216
			$this->use_unique_id = bab_toHtml(caldav_translate($arr['use_unique_id']));
0 ignored issues
show
Bug introduced by
The property use_unique_id does not seem to exist. Did you mean t_use_unique_id?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
217
			$this->editurl = bab_toHtml($addon->getUrl().'configuration&idx=server&server='.$arr['id']);
0 ignored issues
show
Bug introduced by
The property editurl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
218
219
			return true;
220
		}
221
		return false;
222
	}
223
224 View Code Duplication
	public function display()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
225
	{
226
		global $babBody;
227
		$addon = bab_getAddonInfosInstance('LibCaldav');
228
229
		$babBody->setTitle(caldav_translate('Availables servers for users configuration'));
230
		$babBody->babEcho(bab_printTemplate($this, $addon->getTemplatePath() . 'configuration.html', 'servers'));
231
232
		$babBody->addItemMenu('configuration', caldav_translate('Configuration'), $addon->getUrl().'configuration');
233
		$babBody->addItemMenu('servers', caldav_translate('Servers'), $addon->getUrl().'configuration&idx=servers');
234
		$babBody->addItemMenu('resources', caldav_translate('Resources'), $addon->getUrl().'configuration&idx=resources');
235
236
		$babBody->setCurrentItemMenu('servers');
237
	}
238
}
239
240
241
242
243
244
245
246
class caldav_resources
247
{
248
	private $res;
249
	
250
	public $t_name;
251
	public $t_url;
252
	public $t_add;
253
	public $addurl;
254
	
255
	public $altbg = true;
256
	
257
	
258 View Code Duplication
	public function __construct()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
259
	{
260
		global $babDB;
261
		$addon = bab_getAddonInfosInstance('LibCaldav');
262
		
263
		$this->res = $babDB->db_query("SELECT * FROM libcaldav_resources");
264
		
265
		
266
		$this->t_name = caldav_translate('Name');
267
		$this->t_url = caldav_translate('Url');
268
		$this->t_add = caldav_translate('Add');
269
		$this->t_access = caldav_translate('Access');
0 ignored issues
show
Bug introduced by
The property t_access does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
270
		
271
		$this->addurl = $addon->getUrl().'configuration&idx=resource';
272
		
273
	}
274
	
275
	public function getnext()
276
	{
277
		global $babDB;
278
		
279
		if ($arr = $babDB->db_fetch_assoc($this->res))
280
		{
281
			$addon = bab_getAddonInfosInstance('LibCaldav');
282
			
283
			$this->altbg = !$this->altbg;
284
			
285
			$this->name = bab_toHtml($arr['name']);
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
286
			$this->url 	= bab_toHtml($arr['url']);
0 ignored issues
show
Bug introduced by
The property url does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
287
			$this->editurl = bab_toHtml($addon->getUrl().'configuration&idx=resource&resource='.$arr['id']);
0 ignored issues
show
Bug introduced by
The property editurl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
288
			$this->accessurl = bab_toHtml($addon->getUrl().'configuration&idx=resourceaccess&id_resource='.$arr['id']);
0 ignored issues
show
Bug introduced by
The property accessurl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
289
			
290
			return true;
291
		}
292
		return false;
293
	}
294
	
295 View Code Duplication
	public function display()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
296
	{
297
		global $babBody;
298
		$addon = bab_getAddonInfosInstance('LibCaldav');
299
		
300
		$babBody->setTitle(caldav_translate('Resources list'));
301
		$babBody->babEcho(bab_printTemplate($this, $addon->getTemplatePath() . 'configuration.html', 'resources'));
302
		
303
		$babBody->addItemMenu('configuration', caldav_translate('Configuration'), $addon->getUrl().'configuration');
304
		$babBody->addItemMenu('servers', caldav_translate('Servers'), $addon->getUrl().'configuration&idx=servers');
305
		$babBody->addItemMenu('resources', caldav_translate('Resources'), $addon->getUrl().'configuration&idx=resources');
306
		
307
		$babBody->setCurrentItemMenu('resources');
308
	}
309
}
310
311
312
313
class caldav_server_editor
314
{
315
	public function __construct()
316
	{
317
		global $babDB;
318
		
319
		$this->t_name = caldav_translate('Name');
0 ignored issues
show
Bug introduced by
The property t_name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
320
		$this->t_server_url = caldav_translate('Caldav Server Url');
0 ignored issues
show
Bug introduced by
The property t_server_url does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
321
		$this->t_server_url_help = caldav_translate('Example: http://localhost/davical/caldav.php');
0 ignored issues
show
Bug introduced by
The property t_server_url_help does not seem to exist. Did you mean t_server_url?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
322
		$this->t_user_calendar_path = caldav_translate('User calendar path');
0 ignored issues
show
Bug introduced by
The property t_user_calendar_path does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
323
		$this->t_user_calendar_path_help = caldav_translate('%u will be replaced by the login id, example: /%u/home');
0 ignored issues
show
Bug introduced by
The property t_user_calendar_path_help does not seem to exist. Did you mean t_user_calendar_path?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
324
		$this->t_user_calendar_path_help2 = caldav_translate('if the login id contain an email address %n will be replaced by the username before @, otherwise it will be replaced by the full login id, example: /%n/home');
0 ignored issues
show
Bug introduced by
The property t_user_calendar_path_help2 does not seem to exist. Did you mean t_user_calendar_path?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
325
		$this->t_user_calendar_path_help3 = caldav_translate('If a unique id is needed, %c will be replaced by the unique id of the user, example : %c/ will give  https://url.yourservercaldav.com/calendars/%c/');
0 ignored issues
show
Bug introduced by
The property t_user_calendar_path_help3 does not seem to exist. Did you mean t_user_calendar_path?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
326
		$this->t_need_unique_id = caldav_translate('Needs a unique id');
0 ignored issues
show
Bug introduced by
The property t_need_unique_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
327
		$this->t_need_unique_id_help = caldav_translate("It means that the user will have to give his id which is contain in the Url of the calendar, example: https://dav.fruux.com/calendars/XXXXXXXXXXX/XXXXXXXXXXX/");
0 ignored issues
show
Bug introduced by
The property t_need_unique_id_help does not seem to exist. Did you mean t_need_unique_id?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
328
		$this->t_record = caldav_translate('Save');
0 ignored issues
show
Bug introduced by
The property t_record does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
329
		$this->t_delete = caldav_translate('Delete');
0 ignored issues
show
Bug introduced by
The property t_delete does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
330
		$this->t_confirm = caldav_translate('Do you really want to delete this server configuration?');
0 ignored issues
show
Bug introduced by
The property t_confirm does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
331
		
332
		$id = bab_rp('server');
333
		if (!empty($id))
334
		{
335
			$res = $babDB->db_query("SELECT * FROM libcaldav_servers WHERE id=".$babDB->quote($id));
336
			$arr = $babDB->db_fetch_assoc($res);
337
		
338
			if (!$arr)
339
			{
340
				throw new Exception('server not found');
341
			}
342
		
343
			$this->server = bab_toHtml($arr['id']);
0 ignored issues
show
Bug introduced by
The property server does not seem to exist. Did you mean t_server_url?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
344
			$this->name = bab_toHtml($arr['name']);
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
345
			$this->test = bab_toHtml("mdr");
0 ignored issues
show
Bug introduced by
The property test does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
346
			$this->server_url = bab_toHtml($arr['server_url']);
0 ignored issues
show
Bug introduced by
The property server_url does not seem to exist. Did you mean t_server_url?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
347
			$this->user_calendar_path = bab_toHtml($arr['user_calendar_path']);
0 ignored issues
show
Bug introduced by
The property user_calendar_path does not seem to exist. Did you mean t_user_calendar_path?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
348
			$this->use_unique_id = bab_toHtml(" ");
0 ignored issues
show
Bug introduced by
The property use_unique_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
349
			if($arr["use_unique_id"]=="true")
350
			{
351
			    $this->use_unique_id = bab_toHtml("checked");
352
			}
353
		
354
		} else {
355
			$this->server = '';
0 ignored issues
show
Bug introduced by
The property server does not seem to exist. Did you mean t_server_url?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
356
			$this->name = '';
357
			$this->server_url = '';
0 ignored issues
show
Bug introduced by
The property server_url does not seem to exist. Did you mean t_server_url?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
358
			$this->user_calendar_path = '';
0 ignored issues
show
Bug introduced by
The property user_calendar_path does not seem to exist. Did you mean t_user_calendar_path?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
359
			$this->use_unique_id='';
360
		}
361
		
362
	}
363
	
364 View Code Duplication
	public function display()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
365
	{
366
		global $babBody;
367
		$addon = bab_getAddonInfosInstance('LibCaldav');
368
	
369
		$babBody->setTitle(caldav_translate('Edit server'));
370
		$babBody->babEcho(bab_printTemplate($this, $addon->getTemplatePath() . 'configuration.html', 'editserver'));
371
	
372
	}
373
}
374
375
class caldav_resource_editor
376
{
377
	public function __construct()
378
	{
379
		global $babDB;
380
		$addon = bab_getAddonInfosInstance('LibCaldav');
381
	
382
		
383
	
384
	
385
		$this->t_name = caldav_translate('Name');
0 ignored issues
show
Bug introduced by
The property t_name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
386
		$this->t_name_help = caldav_translate('Name of calendar as displayed in the selection list');
0 ignored issues
show
Bug introduced by
The property t_name_help does not seem to exist. Did you mean t_name?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
387
		$this->t_url = caldav_translate('Url');
0 ignored issues
show
Bug introduced by
The property t_url does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
388
		$this->t_url_help = caldav_translate('Full url to the caldav calendar (ex: http://serveur/davical/caldav.php/user/home/)');
0 ignored issues
show
Bug introduced by
The property t_url_help does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
389
		$this->t_nickname = caldav_translate('Nickname');
0 ignored issues
show
Bug introduced by
The property t_nickname does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
390
		$this->t_password = caldav_translate('Password');
0 ignored issues
show
Bug introduced by
The property t_password does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
391
		$this->t_record = caldav_translate('Save');
0 ignored issues
show
Bug introduced by
The property t_record does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
392
		$this->t_delete = caldav_translate('Delete');
0 ignored issues
show
Bug introduced by
The property t_delete does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
393
		$this->t_confirm = caldav_translate('Do you really want to delete this resource?');
0 ignored issues
show
Bug introduced by
The property t_confirm does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
394
	
395
		$this->addurl = $addon->getUrl().'configuration&idx=resource';
0 ignored issues
show
Bug introduced by
The property addurl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
396
		
397
		
398
		$id = bab_rp('resource');
399
		if (!empty($id))
400
		{
401
			$res = $babDB->db_query("SELECT * FROM libcaldav_resources WHERE id=".$babDB->quote($id));
402
			$arr = $babDB->db_fetch_assoc($res);
403
			
404
			if (!$arr)
405
			{
406
				throw new Exception('resource not found');
407
			}
408
			
409
			$this->resource = bab_toHtml($arr['id']);
0 ignored issues
show
Bug introduced by
The property resource does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
410
			$this->name = bab_toHtml($arr['name']);
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
411
			$this->url = bab_toHtml($arr['url']);
0 ignored issues
show
Bug introduced by
The property url does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
412
			$this->nickname = bab_toHtml($arr['nickname']);
0 ignored issues
show
Bug introduced by
The property nickname does not seem to exist. Did you mean t_nickname?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
413
			$this->password = bab_toHtml($arr['password']);
0 ignored issues
show
Bug introduced by
The property password does not seem to exist. Did you mean t_password?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
414
			
415
		} else {
416
			$this->resource = '';
417
			$this->name = '';
418
			$this->url = '';
419
			$this->nickname = '';
0 ignored issues
show
Bug introduced by
The property nickname does not seem to exist. Did you mean t_nickname?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
420
			$this->password = '';
0 ignored issues
show
Bug introduced by
The property password does not seem to exist. Did you mean t_password?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
421
		}
422
		
423
		
424
	
425
	}
426
	
427
	
428 View Code Duplication
	public function display()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
429
	{
430
		$babBody = bab_getBody();
431
		$addon = bab_getAddonInfosInstance('LibCaldav');
432
	
433
		$babBody->setTitle(caldav_translate('Resource'));
434
		$babBody->babEcho(bab_printTemplate($this, $addon->getTemplatePath() . 'configuration.html', 'edit'));
435
436
	}
437
}
438
439
440
441
function caldav_deleteServer()
442
{
443
	require_once $GLOBALS['babInstallPath'].'/utilit/urlincl.php';
444
	global $babDB, $babBody;
445
	$id_server = bab_pp('id_server', null);
446
447
	if (empty($id_server))
448
	{
449
		return;
450
	}
451
	
452
	$registry = bab_getRegistryInstance();
453
	$registry->changeDirectory('/LibCaldav/Users/');
454
	$keys = array();
455
	while ($id_user = $registry->fetchChildDir())
456
	{
457
		$keys[] = $id_user.'server';
458
	}
459
	
460
461
	$res = $registry->getValueEx($keys);
462
	/*@var $res bab_RegistryIterator */
463
	
464
	foreach($res as $arr)
465
	{
466
		if (((int) $id_server) === (int) $arr['value'])
467
		{
468
			$babBody->addError(sprintf(caldav_translate('A user is associated to this server')));
469
			return false;
470
		}
471
	}
472
	
473
		
474
	$babDB->db_query('DELETE FROM libcaldav_servers WHERE id='.$babDB->quote($id_server));
475
	
476
477
	$url = bab_url::get_request('tg');
478
	$url->idx = 'servers';
479
	$url->location();
480
}
481
482
483
484
function caldav_deleteResource()
485
{
486
	require_once $GLOBALS['babInstallPath'].'/utilit/urlincl.php';
487
	global $babDB;
488
	$id_resource = bab_pp('id_resource', null);
489
	
490
	if (!empty($id_resource))
491
	{
492
		$babDB->db_query('DELETE FROM libcaldav_resources WHERE id='.$babDB->quote($id_resource));
493
	}
494
	
495
	$url = bab_url::get_request('tg');
496
	$url->idx = 'resources';
497
	$url->location();
498
}
499
500
501
502
503
504
function caldav_saveServer()
505
{
506
	require_once $GLOBALS['babInstallPath'].'/utilit/urlincl.php';
507
	global $babDB, $babBody;
508
509
	$id_server = bab_pp('id_server', null);
510
	$name = bab_pp('name');
511
	$server_url = bab_pp('server_url');
512
	$user_calendar_path = bab_pp('user_calendar_path');
513
	$use_unique_id = bab_pp('use_unique_id');
514
515
516
	if (empty($name))
517
	{
518
		$babBody->addError(caldav_translate('The name is mandatory'));
519
		return false;
520
	}
521
522
	if (empty($server_url))
523
	{
524
		$babBody->addError(caldav_translate('The server url is mandatory'));
525
		return false;
526
	}
527
	
528
	if (empty($user_calendar_path))
529
	{
530
		$babBody->addError(caldav_translate('The user calendar path is mandatory'));
531
		return false;
532
	}
533
	
534
	if(empty($use_unique_id))
535
	{
536
	    $use_unique_id = "false";
537
	}
538
	;
539
540
541 View Code Duplication
	if (!empty($id_server))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
542
	{
543
		$babDB->db_query('
544
			UPDATE libcaldav_servers SET
545
				name='.$babDB->quote($name).',
546
				server_url='.$babDB->quote($server_url).',
547
				user_calendar_path='.$babDB->quote($user_calendar_path).',
548
                use_unique_id='.$babDB->quote($use_unique_id).' 
549
			WHERE id='.$babDB->quote($id_server)
550
		);
551
552
553
	} else {
554
555
		$babDB->db_query('
556
			INSERT INTO libcaldav_servers
557
				(name, server_url, user_calendar_path,use_unique_id)
558
			VALUES
559
				(
560
				'.$babDB->quote($name).',
561
				'.$babDB->quote($server_url).',
562
				'.$babDB->quote($user_calendar_path).',
563
                '.$babDB->quote($use_unique_id).'    
564
				)'
565
		);
566
567
	}
568
569
570
	$url = bab_url::get_request('tg');
571
	$url->idx = 'servers';
572
	$url->location();
573
}
574
575
576
577
578
function caldav_saveResource()
579
{
580
	require_once $GLOBALS['babInstallPath'].'/utilit/urlincl.php';
581
	global $babDB, $babBody;
582
	
583
	$id_resource = bab_pp('id_resource', null);
584
	$name = bab_pp('name');
585
	$url = bab_pp('url');
586
	$nickname = bab_pp('nickname');
587
	$password = bab_pp('password');
588
589
590
	if (empty($name))
591
	{
592
		$babBody->addError(caldav_translate('The name is mandatory'));
593
		return false;
594
	}
595
	
596
	if (empty($url))
597
	{
598
		$babBody->addError(caldav_translate('The url is mandatory'));
599
		return false;
600
	}
601
	
602
	
603 View Code Duplication
	if (!empty($id_resource))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
604
	{
605
		$babDB->db_query('
606
			UPDATE libcaldav_resources SET 
607
				name='.$babDB->quote($name).',
608
				url='.$babDB->quote($url).',
609
				nickname='.$babDB->quote($nickname).',
610
				password='.$babDB->quote($password).' 
611
			WHERE id='.$babDB->quote($id_resource)
612
		);
613
		
614
		
615
	} else {
616
		
617
		$babDB->db_query('
618
				INSERT INTO libcaldav_resources 
619
					(name, url, nickname, password) 
620
				VALUES 
621
					(
622
						'.$babDB->quote($name).', 
623
						'.$babDB->quote($url).',
624
						'.$babDB->quote($nickname).',
625
						'.$babDB->quote($password).'
626
					)'
627
		);
628
		
629
	}
630
	
631
	
632
	$url = bab_url::get_request('tg');
633
	$url->idx = 'resources';
634
	$url->location();
635
}
636
637
638
if (!bab_isUserAdministrator())
639
{
640
	return;
641
}
642
643
644
$idx = bab_rp('idx');
645
646
switch($idx) {
647
	
648
	case 'saveResource':
649
		if (isset($_POST['delete']))
650
		{
651
			caldav_deleteResource();
652
		}
653
		caldav_saveResource();
654
	
655
	case 'resource':
656
		$resources = new caldav_resource_editor();
657
		$resources->display();
658
		break;
659
	
660
	case 'resources':
661
		$resources = new caldav_resources();
662
		$resources->display();
663
		break;
664
		
665
	case 'resourceaccess':
666
		require_once $GLOBALS['babInstallPath'].'admin/acl.php';
667
		require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
668
		
669
		if (bab_rp('aclview'))
670
		{
671
			maclGroups();
672
			$url = bab_url::get_request('tg');
673
			$url->idx = 'resources';
674
			$url->location();
675
		}
676
		
677
		$macl = new macl(bab_rp('tg'), bab_rp('idx'), bab_rp('id_resource'), 'aclview');
678
		$macl->addtable('libcaldav_resource_groups', caldav_translate('Who can view this resource?'));
679
		$macl->babecho();
680
		break;
681
	
682
683
	case 'saveConfiguration':
684
		caldav_saveConfiguration(
685
			(bool) bab_rp('configbyuser'), 
686
			bab_rp('user_calendar_url'), 
687
			bab_rp('admin_identifier'), 
688
			bab_rp('admin_password'), 
689
			bab_rp('storagebackend'), 
690
			(bool) bab_rp('verify_peer'),
691
			(bool) bab_rp('set_caldav'),
692
			(bool) bab_rp('default_backend'),
693
			(bool) bab_rp('deleteOnCancel')
694
		);
695
		caldav_editConfiguration();
696
		break;
697
		
698
	case 'servers':
699
		$servers = new caldav_servers();
700
		$servers->display();
701
		break;
702
	
703
	case 'saveServer':
704
		if (isset($_POST['delete']))
705
		{
706
			if (!caldav_deleteServer())
707
			{
708
				$servers = new caldav_servers();
709
				$servers->display();
710
			}
711
		} else {
712
			caldav_saveServer();
713
		}
714
		break;
715
		
716
	case 'server':
717
		$server = new caldav_server_editor();
718
		$server->display();
719
		break;
720
721
	default:
722
	case 'configuration':
723
		caldav_editConfiguration();
724
		break;
725
}
726