Issues (1940)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

programs/vacadma.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
include_once dirname(__FILE__).'/functions.php';
26
include_once dirname(__FILE__).'/utilit/vacincl.php';
27
include_once dirname(__FILE__).'/utilit/vacfixedincl.php';
28
require_once dirname(__FILE__).'/utilit/right.class.php';
29
include_once dirname(__FILE__).'/utilit/agent.class.php';
30
31
32
33
function listVacationRigths($idtype, $idcoll, $rgroup, $dateb, $datee, $active, $pos, $archived, $recovery)
34
{
35
	global $babBody;
36
	require_once dirname(__FILE__).'/utilit/rightlist.ui.php';
37
38
	if ($recovery) {
39
		$babBody->setTitle(absences_translate("Recovery rights"));
40
	}	
41
	else if ($archived) {
42
		$babBody->setTitle(absences_translate("Archived vacations rights"));
43
	} else {
44
		$babBody->setTitle(absences_translate("Vacations rights"));
45
	}
46
		
47
	$babBody->babecho(absences_rightListMenu());
48
	
49
	$name = bab_rp('name');
50
51
	$temp = new absences_RightList($idtype, $idcoll, $rgroup, $dateb, $datee, $active, $pos, $archived, $recovery, $name);
52
	$babBody->babecho(	bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadma.html", "vrightslist"));
53
	return $temp->count;
54
55
}
56
57
58
59
function absences_choseBeneficiariesMethod($id)
60
{
61
	bab_functionality::includeOriginal('Icons');
62
	$W = bab_Widgets();
63
	
64
	$page = $W->BabPage();
65
	$page->setTitle(absences_translate('Vacation right beneficiaries'));
66
	$right = new absences_Right($id);
67
	$frame = $W->Frame(null, $W->VBoxLayout()->setVerticalSpacing(1,'em'));
68
	$page->addItem($frame);
69
	$frame->addClass('widget-bordered');
70
	$frame->addClass('BabLoginMenuBackground');
71
	$frame->addClass('widget-centered');
72
	$frame->setCanvasOptions($frame->Options()->width(60,'em'));
73
	
74
	$frame->addItem($W->Title($right->description, 4));
75
	
76
	$I = $right->getAgentRightIterator();
77
	
78
	if (0 === $I->count())
79
	{
80
		$frame->addItem($W->Label(absences_translate('This right has no beneficiaries, please use collections or personnel members to add beneficiaries to the vacation right')));
81
	}
82
	
83
	$buttons = $W->FlowLayout()->setSpacing(2,'em');
84
	$frame->addItem($buttons);
85
	
86
	$buttons->addItem(
87
		$W->Link(
88
			$W->Button()->addItem($W->Icon(absences_translate('By collections'), Func_Icons::ACTIONS_USER_GROUP_PROPERTIES)),
89
			absences_addon()->getUrl().'vacadma&idx=lvrc&idvr='.$id
90
		)
91
	);
92
	
93
	$buttons->addItem(
94
			$W->Link(
95
					$W->Button()->addItem($W->Icon(absences_translate('By users'), Func_Icons::ACTIONS_USER_PROPERTIES)),
96
					absences_addon()->getUrl().'vacadma&idx=lvrp&idvr='.$id
97
			)
98
	);
99
	
100
	
101
	$page->displayHtml();
102
}
103
104
105
106
107
function absences_addModifyVacationRight($id = false, $from = false)
108
{
109
	
110
	require_once dirname(__FILE__).'/utilit/right.ui.php';
111
	require_once dirname(__FILE__).'/utilit/right.act.php';
112
	
113
	
114
	if (isset($_POST['right']))
115
	{
116
		if ( isset($_POST['right']['cancel']) )
117
		{
118
			absences_RightAct::redirect();
119
		}
120
		
121
		
122
		if( isset($_POST['right']['save'] ))
123
		{
124
			absences_RightAct::save();
125
		}
126
		
127
		if( isset($_POST['right']['delete']))
128
		{
129
			deleteVacationRight($_POST['right']['id']);
130
		}
131
		
132
		
133
	}
134
	
135
	$W = bab_Widgets();
136
	
137
	$page = $W->BabPage();
138
	$right = null;
139
	
140
	if ($id)
141
	{
142
		$right = new absences_Right($id);
143
		$page->setTitle(absences_translate('Edit vacation right'));
144
		$editor = new absences_RightEditor($right);
145
	} else {
146
	    
147
	    if ($from) {
148
	        $right = new absences_Right($from);
149
	    }
150
	    
151
		$page->setTitle(absences_translate('Create vacation right'));
152
		$editor = new absences_CreateRightEditor($right);
153
	}
154
	
155
	
156
	$page->addItem($editor);
157
	
158
	
159
	$page->displayHtml();
160
}
161
162
163
164
165
166
167
function absences_fixedRightUpdate($id)
168
{
169
	
170
	$W = bab_Widgets();
171
	
172
	$page = $W->BabPage();
173
	
174
	$right = new absences_Right($id);
175
	
176
	
177
	if (!$right->getRow())
178
	{
179
		throw new Exception(absences_translate('The vacation right does not exists'));
180
	}
181
	
182
	if (absences_Right::FIXED !== $right->getKind())
183
	{
184
		throw new Exception(absences_translate('The vacation right is not fixed'));
185
	}
186
	
187
	
188
	$page->setTitle(sprintf(absences_translate('Update requests for the fixed vacation right "%s"'), $right->description));
189
	
190
	$nextbutton = $W->Button()->addItem($W->Label(absences_translate('Next')));
191
	
192
	$page->addItem(
193
		$W->Frame()
194
		->setCanvasOptions($page->Options()->width(70,'em'))
195
		->addClass('widget-bordered')
196
		->addClass('BabLoginMenuBackground')
197
		->addClass('widget-centered')
198
		->addItem(
199
			$W->ProgressBar()
200
				->setTitle(absences_translate('Process beneficiaries list'))
201
				->setProgressAction($W->Action()->fromRequest()->setParameter('idx', 'fixedud_progress'))
202
				->setCompletedAction($W->Action()->fromRequest()->setParameter('idx', 'lrig'), $nextbutton)
203
		)
204
		->addItem($nextbutton)
205
	);
206
	
207
	
208
	$page->displayHtml();
209
}
210
211
212
213
214
function absences_fixedRightUpdateProgress($id)
215
{
216
	require_once dirname(__FILE__).'/utilit/right.ui.php';
217
	require_once dirname(__FILE__).'/utilit/right.act.php';
218
	
219
	$W = bab_Widgets();
220
	
221
	$right = new absences_Right($id);
222
	
223
	if (absences_Right::FIXED !== $right->getKind())
224
	{
225
		throw new Exception(absences_translate('The vacation right is not fixed'));
226
	}
227
	
228
	$progress = $W->ProgressBar();
229
	
230
	absences_RightAct::updateFixed($right, $progress);
231
	die();
232
}
233
234
235
236 View Code Duplication
function absences_beneficiariesUpdateProgress($id)
237
{
238
	require_once dirname(__FILE__).'/utilit/right.ui.php';
239
	require_once dirname(__FILE__).'/utilit/right.act.php';
240
	
241
	$W = bab_Widgets();
242
	
243
	$right = new absences_Right($id);
244
	
245
	$progress = $W->ProgressBar();
246
	
247
	absences_RightAct::updateCollectionsBeneficiaries($right, $progress, (array) bab_gp('collection', array()));
248
	die();
249
}
250
251
252
253
254
255
/**
256
 * 
257
 * @param int $id_right
258
 * @param string $next_idx
259
 */
260
function absences_userRightReport($id_right, $next_idx)
261
{
262
	require_once dirname(__FILE__).'/utilit/collection.class.php';
263
	$W = bab_Widgets();
264
265
	$page = $W->BabPage();
266
267
	$right = new absences_Right($id_right);
268
	
269
	if (!$right->getRow())
270
	{
271
		throw new Exception(absences_translate('The vacation right does not exists'));
272
	}
273
274
275
276
	$page->setTitle(sprintf(absences_translate('Error report for right "%s"'), $right->description));
277
	
278
	
279
	$frame = $W->Frame(null, $W->VBoxLayout()->setVerticalSpacing(1.5,'em'))
280
		->setCanvasOptions($page->Options()->width(70,'em'))
281
		->addClass('widget-bordered')
282
		->addClass('BabLoginMenuBackground')
283
		->addClass('widget-centered');
284
	
285
	$page->addItem($frame);
286
	
287
288
	// si aucun probleme a signaler, diriger le gestionnaire vers la page droit/regime
289
	
290
	
291
	$I = $right->getAgentRightIterator();
292
	$display = false;
293
	
294
	foreach($I as $agentRight)
295
	{
296
		/*@var $agentRight absences_AgentRight */
297
		$errors = $agentRight->getErrors();
298
		
299
		if (empty($errors))
300
		{
301
			continue;
302
		}
303
		
304
		$display = true;
305
		
306
		$messageLayout = $W->VBoxLayout();
307
		$user = $W->Section($agentRight->getAgent()->getName(), $messageLayout);
308
		$frame->addItem($user);
309
		
310
		foreach($errors as $error)
311
		{
312
			$messageLayout->addItem($W->Label($error));
313
		}
314
	}
315
	
316
	require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
317
	$url = bab_url::get_request('tg', 'pos');
318
	$url->idx = $next_idx;
319
	$url->idvr = $id_right;
320
	
321
	
322
	if  (!$display)
323
	{
324
		global $babBody;
325
		/* @var $babBody babBody */
326
		
327
		// reporter les messages a la page suivante
328
		foreach($babBody->messages as $m)
329
		{
330
			$babBody->addNextPageMessage($m);
331
		}
332
		
333
		$url->location();
334
	}
335
	
336
	
337
	$frame->addItem($W->Link($W->Button()->addItem($W->Label(absences_translate('Continue'))), $url->toString()));
338
	
339
340
	$page->displayHtml();
341
}
342
343
344
345
346
347
348
349
350
351
352
/**
353
 * 
354
 * @param int $id_group
355
 * @param bool $tree
356
 * 
357
 * @return array
358
 */
359
function absences_getUsersFromGroup($id_group, $tree)
360
{
361
	$groups = array($id_group);
362
	
363
	if ($tree)
364
	{
365
		$arr = bab_getGroups($id_group, true);
366
		$groups = array_merge($groups, $arr['id']);
367
	}
368
	
369
	$members = bab_getGroupsMembers($groups);
370
	$users = array();
371
	foreach($members as $arr)
372
	{
373
		$users[] = (int) $arr['id'];
374
	}
375
	
376
	return $users;
377
}
378
379
380
381
function absences_addVacationRightPersonnel($id)
382
{
383
	$W = bab_Widgets();
384
	require_once dirname(__FILE__).'/utilit/agent.class.php';
385
	require_once dirname(__FILE__).'/utilit/right.ui.php';
386
	require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
387
	global $babDB;
388
	
389
	$page = $W->BabPage();
390
	
391
	if (isset($_POST['right']))
392
	{	
393
	
394
		if( isset($_POST['right']['save'] ))
395
		{
396
			$id_right = (int) $_POST['right']['id'];
397
			$id_group = (int) $_POST['right']['group'];
398
			$tree = (bool) $_POST['right']['tree'];
399
			$users = absences_getUsersFromGroup($id_group, $tree);
400
			$right = new absences_Right($id_right);
401
			
402
			// croiser avec les membres du personnel
403
			
404
			$res = $babDB->db_query('SELECT * FROM absences_personnel WHERE id_user IN('.$babDB->quote($users).')');
405
			while ($arr = $babDB->db_fetch_assoc($res))
406
			{
407
				$agent = new absences_Agent;
408
				$agent->setRow($arr);
409 View Code Duplication
				if ($agent->addRight($right))
410
				{
411
					try {
412
						$agent->addFixedEntry($right);
413
					} 
414
					catch(absences_EntryException $e)
415
					{
416
						$page->addError($agent->getName().' : '.$e->getMessage());
417
						$agent->removeRight($right);
418
					}
419
				}
420
			}
421
		}
422
		
423 View Code Duplication
		if (!$page->containErrors())
424
		{
425
			$url = bab_url::get_request('tg', 'idvr');
426
			$url->idx = 'lvrp';
427
			$url->location();
428
		}
429
	}
430
	
431
	
432
	
433
	
434
	
435
	
436
	$right = new absences_Right($id);
437
	
438
	
439
	if (!$right->getRow())
440
	{
441
		throw new Exception(absences_translate('The vacation right does not exists'));
442
	}
443
	
444
	$page->setTitle(sprintf(absences_translate('Add personnel members to the right %s'), $right->description));
445
	
446
447
	$editor = new absences_RightAddPersonnelEditor($right);
448
	$page->addItem($editor);
449
	
450
	
451
	$page->displayHtml();
452
}
453
454
455
456
457
458
459
460
461
462
463
464 View Code Duplication
function listVacationRightPersonnel($idvr)
465
{
466
    require_once dirname(__FILE__).'/utilit/beneficiarieslist.ui.php';
467
    
468
	$list = new absences_BeneficiariesList($idvr, (array) bab_rp('filter', array()));
469
	
470
	$addon = bab_getAddonInfosInstance('absences');
471
472
	$babBody = bab_getInstance('babBody');
473
	$babBody->addStyleSheet($addon->getStylePath().'vacation.css');
474
	$babBody->babecho(bab_printTemplate($list,  absences_addon()->getRelativePath()."vacadma.html", "vrpersonnellist"));
475
}
476
	
477
	
478
	
479
	
480
	
481
	
482
	
483
	
484
function listVacationRightCollection($idvr)
485
{
486
	
487
	class temp
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type temp has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L38-118) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
488
	{
489
490
		public $altbg = true;
491
		public $name;
492
		public $description;
493
		public $idvr;
494
495
		public function __construct($idvr)
496
		{
497
			require_once dirname(__FILE__).'/utilit/collection.class.php';
498
			require_once dirname(__FILE__).'/utilit/collection_right.class.php';
499
			require_once dirname(__FILE__).'/utilit/right.class.php';
500
501
			$babBody = bab_getInstance('babBody');
502
503
			$this->allname = absences_translate("All");
504
			$this->uncheckall = absences_translate("Uncheck all");
505
			$this->checkall = absences_translate("Check all");
506
			$this->modify = absences_translate("Modify");
507
			$this->t_name = absences_translate("Name");
508
			$this->t_description = absences_translate("Description");
509
			$this->t_linked = absences_translate("Linked");
510
			$this->t_unlinked = absences_translate("Unlinked");
511
			$this->t_edit = absences_translate("Edit");
512
513
			global $babDB;
514
			$this->idvr = (int) $idvr;
515
516
			
517
			$this->right = new absences_Right($idvr);
518
519
			$babBody->setTitle(sprintf(absences_translate("Collections associated to the right %s"), $this->right->description));
520
			$type = $this->right->getType();
521
			
522
			if ($type->id)
523
			{
524
				$this->right_type = bab_toHtml($type->name);
525
			} else {
526
				$this->right_type = '';
527
			}
528
529
			$req = "select *
530
				from
531
					absences_collections 
532
				order by name";
533
			
534
			
535
			$this->res = $babDB->db_query($req);
536
		}
537
538
		public function getnext()
539
		{
540
			global $babDB;
541
			if($arr = $babDB->db_fetch_array($this->res))
542
			{
543
544
				
545
				$this->altbg = !$this->altbg;
546
547
				// create the agent and the agent_right objects
548
549
				$collection = new absences_Collection();
550
				$collection->setRow($arr);
551
552
553
				$this->selected = "";
554
555
				$res2 = $babDB->db_query("select * from absences_coll_rights where id_coll='".$babDB->db_escape_string($collection->id)."' AND id_right ='".$babDB->db_escape_string($this->idvr)."'");
556
				if( $res2 && $babDB->db_num_rows($res2) > 0 )
557
				{
558
					$this->selected = "checked";
559
				}
560
				
561
562
				$this->id_collection = bab_toHtml($collection->id);
563
				$this->name = bab_toHtml($collection->name);
564
				$this->description = bab_toHtml($collection->description);
565
566
				return true;
567
			}
568
			else
569
				return false;
570
571
		}
572
573
		
574
		
575
		
576
		public function displaySaveProgress()
577
		{
578
			$W = bab_Widgets();
579
			
580
			$page = $W->BabPage();
581
582
			
583
			$page->setTitle(sprintf(absences_translate('Update users associated to vacation right "%s"'), $this->right->description));
584
			
585
			$nextbutton = $W->Button()->addItem($W->Label(absences_translate('Next')));
586
			
587
			$checked_collections = bab_pp('collection', array());
588
			
589
			$page->addItem(
590
					$W->Frame()
591
					->setCanvasOptions($page->Options()->width(70,'em'))
592
					->addClass('widget-bordered')
593
					->addClass('BabLoginMenuBackground')
594
					->addClass('widget-centered')
595
					->addItem(
596
							$W->ProgressBar()
597
							->setProgress(0)
598
							->setTitle(absences_translate('Process beneficiaries list'))
599
							->setProgressAction($W->Action()->fromRequest()->setParameter('idx', 'lvrc_progress')->setParameter('collection', $checked_collections))
600
							->setCompletedAction($W->Action()->fromRequest()->setParameter('idx', 'lvrc'), $nextbutton)
601
					)
602
					->addItem($nextbutton)
603
			);
604
			
605
			
606
			$page->displayHtml();
607
		}
608
	}
609
	
610
611
	$temp = new temp($idvr);
612
	
613
	
614
	if (!empty($_POST))
615
	{
616
		// $temp->save();
617
		$temp->displaySaveProgress();
618
		return;
619
	}
620
	
621
622
	$babBody = bab_getInstance('babBody');
623
	$babBody->babecho(bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadma.html", "vrcollectionlist"));
624
}
625
	
626
	
627
	
628
	
629
630
function viewVacationRightPersonnel($idvr)
631
{
632
	require_once dirname(__FILE__).'/utilit/right.ui.php';
633
	
634
	
635
	
636
	$W = bab_Widgets();
637
	
638
	$page = $W->BabPage();
639
	$right = null;
640
	
641
	
642
	$right = new absences_Right($idvr);
643
	$page->setTitle(absences_translate('View vacation right'));
644
645
	$fullframe = new absences_RightFullFrame($right);
646
	$page->addItem($fullframe);
647
	
648
	
649
	$page->displayHtml();
650
}
651
652
653
654
function rgrouplist() {
655
656
	global $babBody;
657
	class temp
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type temp has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L38-118) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
658
		{
659
		var $altbg = true;
660
661
		function temp()
662
			{
663
			$this->t_name = absences_translate('Name');
664
			$this->t_edit = absences_translate('Edit');
665
			$this->t_rights = absences_translate('Rights');
666
			global $babDB;
667
			$this->res = $babDB->db_query("SELECT * FROM ".ABSENCES_RGROUPS_TBL."");
668
			}
669
670
		function getnext()
671
			{
672
			global $babDB;
673
			if ($arr = $babDB->db_fetch_assoc($this->res)) {
674
				$this->altbg		= !$this->altbg;
675
				$this->name			= bab_toHtml($arr['name']);
676
				$this->id_rgroup	= bab_toHtml($arr['id']);
677
678
679
				$this->rgroup = $babDB->db_query("SELECT description FROM ".ABSENCES_RIGHTS_TBL." WHERE id_rgroup=".$babDB->quote($arr['id']));
680
				return true;
681
			}
682
			return false;
683
		}
684
685
		function getnextright() {
686
			global $babDB;
687
			
688
			static $i = 0;
689
			
690
			if ($i === 10) {
691
			    $this->description = bab_toHtml(
692
		            sprintf(
693
		                absences_translate('And %d more vacation rights...'),
694
		                $babDB->db_num_rows($this->rgroup)
695
		            )
696
		        );
697
			    
698
			    $i++;
699
			    return true;
700
			}
701
			
702
			if ($i > 10) {
703
			    return false;
704
			}
705
			
706
			
707
			
708
			if ($arr = $babDB->db_fetch_assoc($this->rgroup)) {
709
				$this->description = bab_toHtml($arr['description']);
710
				$i++;
711
				
712
				
713
				return true;
714
			}
715
			
716
			$i = 0;
717
			return false;
718
		}
719
720
	}
721
722
	$temp = new temp();
723
	$babBody->babecho(bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadma.html", "rgrouplist"));
724
}
725
726
727
728
function rgroupmod() {
729
730
	global $babBody;
731
	class temp
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type temp has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L38-118) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
732
	{
733
		function temp()
734
		{
735
			$this->t_name = absences_translate('Name');
736
			$this->t_recover = absences_translate('Use this right group to store the created recovery rights');
737
			$this->t_quantity_unit = absences_translate('Allowed quantity unit');
738
			$this->t_days = absences_translate('Days');
739
			$this->t_hours = absences_translate('Hours');
740
			$this->t_record = absences_translate('Record');
741
			$this->t_delete = absences_translate('Delete');
742
			global $babDB;
743
			$this->id_rgroup = bab_rp('id_rgroup');
744
			if ($this->id_rgroup) {
745
				$res = $babDB->db_query("SELECT * FROM ".ABSENCES_RGROUPS_TBL." WHERE id=".$babDB->quote($this->id_rgroup));
746
				$arr = $babDB->db_fetch_assoc($res);
747
				$this->name = bab_toHtml($arr['name']);
748
				$this->recover = $arr['recover'];
749
				$this->quantity_unit = bab_toHtml($arr['quantity_unit']);
750
			} else {
751
				$this->name = '';
752
				$this->recover = 0;
753
				$this->quantity_unit = 'D';
754
			}
755
		}
756
	}
757
758
	$temp = new temp();
759
	$babBody->babecho(bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadma.html", "rgroupmod"));
760
}
761
762
763
764
765
function modifyVacationRightPersonnel($idvr, $userids, $nuserids)
766
{
767
	
768
	global $babDB;
769
	require_once dirname(__FILE__).'/utilit/right.class.php';
770
	require_once dirname(__FILE__).'/utilit/agent.class.php';
771
	
772
	$babBody = bab_getInstance('babBody');
773
	/*@var $babBody babBody */
774
	$count = sizeof($userids);
775
	
776
	$right = new absences_Right($idvr);
777
778
	if (!$right->getRow())
779
	{
780
		throw new Exception('This vacation right does not exists');
781
	}
782
783
	for( $i = 0; $i < sizeof($nuserids); $i++)
784
	{
785
	    bab_setTimeLimit(10);
786
	    
787
		if( $nuserids[$i] != "" && ( $count == 0 || !in_array($nuserids[$i], $userids)))
788
		{
789
			$agent = absences_Agent::getFromIdUser($nuserids[$i]);
790
			if ($agent->removeRight($right))
791
			{
792
				$agent->removeFixedEntry($right);
793
			}
794
		}
795
	}
796
	
797
	bab_setTimeLimit(60);
798
	
799
800
	for( $i = 0; $i < $count; $i++)
801
	{
802
		if( !in_array($userids[$i], $nuserids) )
803
		{
804
		    bab_setTimeLimit(10);
805
			$agent = absences_Agent::getFromIdUser($userids[$i]);
806 View Code Duplication
			if ($agent->addRight($right))
807
			{
808
				try {
809
					$agent->addFixedEntry($right);
810
				} catch(absences_EntryException $e)
811
				{
812
					$babBody->addError($agent->getName().' : '.$e->getMessage());
813
					$agent->removeRight($right);
814
				}
815
			}
816
		}
817
	}
818
	
819
	bab_setTimeLimit(60);
820
	
821
	if (0 === count($babBody->errors))
822
	{
823
		$babBody->addNextPageMessage(sprintf(absences_translate('The checked personal members were associated with "%s"'), $right->description));
824
		return true;
825
	}
826
	
827
	return false;
828
}
829
830
831
function deleteVacationRightConf($idvr) {
832
833
	global $babBody;
834
	class temp
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type temp has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L38-118) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
835
		{
836
		var $yes;
837
		var $no;
838
		var $invalidentry1;
839
		var $tpsel;
840
		var $colsel;
841
842
		function temp($idvr)
843
			{
844
			$this->idvr = $idvr;
845
			$this->t_alert = absences_translate("Some vacation requests are linked to this right, if you delete the right, the vacation requests will be deleted with it");
846
847
			$this->t_request = absences_translate("Last request with this right");
848
			$this->t_confirm = absences_translate("Confirm");
849
850
			global $babDB;
851
			$this->res = $babDB->db_query(
852
				"SELECT
853
					UNIX_TIMESTAMP(e.date_begin) date_begin
854
				FROM
855
					".ABSENCES_ENTRIES_ELEM_TBL." ee,
856
					".ABSENCES_ENTRIES_TBL." e
857
				WHERE
858
					ee.id_right=".$babDB->quote($idvr)."
859
					AND e.id = ee.id_entry
860
861
				ORDER BY e.date_begin DESC"
862
				);
863
864
			$arr = $babDB->db_fetch_assoc($this->res);
865
			$nb_requests = $babDB->db_num_rows($this->res);
866
			$this->request = bab_toHtml(absences_longDate($arr['date_begin']));
867
			if (1 == $nb_requests) {
868
				$this->t_nb_requests = bab_toHtml(absences_translate("one request will be deleted"));
869
			} else {
870
				$this->t_nb_requests = bab_toHtml(sprintf(absences_translate("%d requests will be deleted"),$nb_requests));
871
			}
872
		}
873
	}
874
875
	$temp = new temp($idvr);
876
	$babBody->babecho(bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadma.html", "rightsdelete"));
877
	$babBody->title = absences_translate("Delete vacation right");
878
	$babBody->addItemMenu("delvr", absences_translate("Delete"), absences_addon()->getUrl()."vacadma&idx=delvr");
879
}
880
881
882
883
884
885
/**
886
 * 
887
 */
888
function rightcopy() {
889
890
	global $babBody;
891
	require_once dirname(__FILE__).'/utilit/rightincl.php';
892
893
	if (isset($_POST['copy_rights'])) {
894
		$temp = new absences_RightCopyStep2();
895
		$babBody->babecho(bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadma.html", "rightcopy2"));
896
897
	} else {
898
		$temp = new absences_RightCopyStep1();
899
		$babBody->babecho(bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadma.html", "rightcopy"));
900
	}
901
}
902
903
904
905
906
/**
907
 * Delete vacation right and request associated to the vacation right
908
 * @param int $idvr
909
 * @return bool
910
 */
911
function deleteVacationRight($idvr)
912
{
913
	global $babBody, $babDB;
914
	list($total) = $babDB->db_fetch_row($babDB->db_query("select count(id) as total from ".ABSENCES_ENTRIES_ELEM_TBL." where id_right=".$babDB->quote($idvr)));
915
	if( $total == 0 )
916
	{
917
		$babDB->db_query("DELETE FROM ".ABSENCES_RIGHTS_TBL." WHERE id=".$babDB->quote($idvr));
918
		$babDB->db_query("DELETE FROM ".ABSENCES_USERS_RIGHTS_TBL." WHERE id_right=".$babDB->quote($idvr));
919
		$babDB->db_query("DELETE FROM ".ABSENCES_RIGHTS_RULES_TBL." WHERE id_right=".$babDB->quote($idvr));
920
		$babDB->db_query("UPDATE absences_movement SET id_right='0' WHERE id_right=".$babDB->quote($idvr));
921
922
		$res = $babDB->db_query("SELECT id_entry FROM ".ABSENCES_ENTRIES_ELEM_TBL." WHERE id_right=".$babDB->quote($idvr));
923
		while ($arr = $babDB->db_fetch_assoc($res)) {
924
			absences_delete_request($arr['id_entry']);
925
		}
926
		
927
		require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
928
		$url = bab_url::get_request('tg');
929
		$url->idx = 'lrig';
930
		$url->location();
931
	}
932
933
	$babBody->addError(absences_translate('The vacation right cannot be deleted because of existing associated requests'));
934
	return false;
935
}
936
937
938
function modRgroup() {
939
940
	global $babDB, $babBody;
941
942
	$name = bab_pp('name');
943
	if (empty($name)) {
944
		$babBody->addError(absences_translate('The name is mandatory'));
945
		return false;
946
	}	
947
		
948
	global $babDB;
949
	$id = bab_pp('id_rgroup');
950
	$recover = bab_pp('recover', 0);
951
	$quantity_unit = bab_pp('quantity_unit', 'D');
952
	
953
	if (empty($id)) {
954
		$babDB->db_query("INSERT INTO absences_rgroup (name, recover, quantity_unit) VALUES (".$babDB->quote($name).", ".$babDB->quote($recover).", ".$babDB->quote($quantity_unit).")");
955
		$id = $babDB->db_insert_id();
956
	} else {
957
		
958
		if ($recover)
959
		{
960
			$res = $babDB->db_query('SELECT g.id FROM absences_rgroup g, absences_rights r 
961
					WHERE r.id_rgroup=g.id AND g.id='.$babDB->quote($id).' AND r.kind<>'.$babDB->quote(absences_Right::RECOVERY));
962
			
963
			if ($babDB->db_num_rows($res) > 0)
964
			{
965
				$babBody->addError(absences_translate('This right group already contains rights of a different kind than recovery'));
966
				return false;
967
			}
968
		}
969
		
970
		
971
		
972
		$babDB->db_query("UPDATE absences_rgroup SET 
973
			name=".$babDB->quote($name).", 
974
			recover=".$babDB->quote($recover).",  
975
			quantity_unit=".$babDB->quote($quantity_unit)." 
976
		WHERE id=".$babDB->quote($id));
977
	}
978
	
979
	if ($recover)
980
	{
981
		$babDB->db_query("UPDATE absences_rgroup SET recover='0' WHERE id<>".$babDB->quote($id));
982
	}
983
	
984
	return true;
985
}
986
987
988
function deleteRgroup() {
989
	global $babDB;
990
	$id = bab_rp('id_rgroup');
991
	if (!empty($id)) {
992
		$babDB->db_query("DELETE FROM ".ABSENCES_RGROUPS_TBL." WHERE id=".$babDB->quote($id));
993
	}
994
}
995
996
997
998
999 View Code Duplication
function absences_rightMovements($id_right)
1000
{
1001
    require_once dirname(__FILE__).'/utilit/right.class.php';
1002
    require_once dirname(__FILE__).'/utilit/right.ui.php';
1003
1004
    $babBody = bab_getInstance('babBody');
1005
    $right = new absences_Right($id_right);
1006
    $W = bab_Widgets();
1007
1008
    $card = new absences_RightCardFrame($right);
1009
1010
    $card->addClass('widget-bordered');
1011
    $card->addClass('BabLoginMenuBackground');
1012
1013
    $list = new absences_RightMovementList($right);
1014
1015
    $babBody->setTitle(absences_translate('Right history'));
1016
1017
    $babBody->babEcho($card->display($W->HtmlCanvas()));
1018
    $babBody->babEcho($list->getHtml());
1019
}
1020
1021
1022
1023
1024
/* main */
1025
bab_requireCredential();
1026
$agent = absences_Agent::getCurrentUser();
1027
if( !$agent->isManager())
1028
	{
1029
	$babBody->msgerror = absences_translate("Access denied");
1030
	return;
1031
	}
1032
	
1033
$idx = bab_rp('idx', "lrig");
1034
1035
1036
if( isset($_POST['action']) )
1037
	{
1038
	switch ($_POST['action'])
1039
		{
1040
1041
		case 'rgroupmod':
1042
			if (isset($_POST['rgroup_delete'])) {
1043
				deleteRgroup();
1044
1045
			} else if (!modRgroup()) {
1046
				$idx = 'rgroupmod';
1047
			}
1048
			break;
1049
1050
		}
1051
1052
	}
1053
1054
	
1055
	
1056
if ($agent->isInPersonnel())
1057
{
1058
	$babBody->addItemMenu("vacuser", absences_translate("Vacations"), absences_addon()->getUrl()."vacuser");
1059
}
1060
$babBody->addItemMenu("menu", absences_translate("Management"), absences_addon()->getUrl()."vacadm&idx=menu");
1061
1062
1063
1064
switch($idx)
1065
	{
1066
1067
1068
1069
	case "delvru":
1070
		$userids = bab_rp('userids', array());
1071
		if (modifyVacationRightPersonnel(bab_rp('idvr'), $userids, bab_rp('nuserids', array())))
1072
		{
1073
			
1074
			require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
1075
			$url = bab_url::get_request('tg', 'pos');
1076
			$url->idx = 'user_right_report';
1077
			$url->id_right = bab_rp('idvr');
1078
			$url->nextidx = 'lvrp';
1079
			$url->location();
1080
		}
1081
		
1082
		$idx = 'lvrp';
1083
		// no break
1084
		
1085 View Code Duplication
	case "lvrp":
1086
		listVacationRightPersonnel(bab_rp('idvr'));
1087
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1088
		$babBody->addItemMenu("lvrc", absences_translate("Collections beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrc&idvr=".bab_rp('idvr'));
1089
		$babBody->addItemMenu("lvrp", absences_translate("Users beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrp&idvr=".bab_rp('idvr'));
1090
		break;
1091
		
1092 View Code Duplication
	case 'lvrp_add':
1093
		absences_addVacationRightPersonnel(bab_rp('idvr'));
1094
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1095
		$babBody->addItemMenu("lvrp", absences_translate("Users beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrp&idvr=".bab_rp('idvr'));
1096
		$babBody->addItemMenu("lvrp_add", absences_translate("Grant by group"), absences_addon()->getUrl()."vacadma&idx=lvrp_add&idvr=".bab_rp('idvr'));
1097
		break;
1098
		
1099 View Code Duplication
	case "lvrc":
1100
	
1101
		listVacationRightCollection(bab_rp('idvr'));
1102
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1103
		$babBody->addItemMenu("lvrc", absences_translate("Collections beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrc&idvr=".bab_rp('idvr'));
1104
		$babBody->addItemMenu("lvrp", absences_translate("Users beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrp&idvr=".bab_rp('idvr'));
1105
		break;
1106
		
1107
	case 'lvrc_progress':
1108
		absences_beneficiariesUpdateProgress(bab_rp('idvr'));
1109
		break;
1110
		
1111 View Code Duplication
	case "viewvr":
1112
	    viewVacationRightPersonnel(bab_rp('idvr'));
1113
	    $babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1114
	    $babBody->addItemMenu("viewvr", absences_translate("Vacation right"), absences_addon()->getUrl()."vacadma&idx=viewvr&idvr=".bab_rp('idvr'));
1115
	    $babBody->addItemMenu("modvr", absences_translate("Edit"), absences_addon()->getUrl()."vacadma&idx=modvr&idvr=".bab_rp('idvr'));
1116
	    $babBody->addItemMenu("movement", absences_translate("History"), absences_addon()->getUrl()."vacadma&idx=movement&idvr=".bab_rp('idvr'));
1117
	    break;
1118
		
1119 View Code Duplication
	case 'movement':
1120
	    $babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1121
	    $babBody->addItemMenu("viewvr", absences_translate("Vacation right"), absences_addon()->getUrl()."vacadma&idx=viewvr&idvr=".bab_rp('idvr'));
1122
		$babBody->addItemMenu("modvr", absences_translate("Modify"), absences_addon()->getUrl()."vacadma&idx=modvr&idvr=".bab_rp('idvr'));
1123
		$babBody->addItemMenu("movement", absences_translate("History"), absences_addon()->getUrl()."vacadma&idx=movement&idvr=".bab_rp('idvr'));
1124
	    absences_rightMovements(bab_rp('idvr'));
1125
	    break;
1126
1127 View Code Duplication
	case "modvr":
1128
		absences_addModifyVacationRight(bab_rp('idvr'));
1129
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1130
		$babBody->addItemMenu("viewvr", absences_translate("Vacation right"), absences_addon()->getUrl()."vacadma&idx=viewvr&idvr=".bab_rp('idvr'));
1131
		$babBody->addItemMenu("modvr", absences_translate("Modify"), absences_addon()->getUrl()."vacadma&idx=modvr&idvr=".bab_rp('idvr'));
1132
		$babBody->addItemMenu("movement", absences_translate("History"), absences_addon()->getUrl()."vacadma&idx=movement&idvr=".bab_rp('idvr'));
1133
		break;
1134
1135 View Code Duplication
	case "addvr":
1136
		absences_addModifyVacationRight(false, bab_rp('from'));
1137
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1138
		$babBody->addItemMenu("addvr", absences_translate("Add"), absences_addon()->getUrl()."vacadma&idx=addvr");
1139
		break;
1140
		
1141
	case 'nobenef';
1142
		absences_choseBeneficiariesMethod(bab_rp('idvr'));
1143
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1144
		$babBody->addItemMenu("nobenef", absences_translate("Beneficiaries"), absences_addon()->getUrl()."vacadma&idx=nobenef");
1145
		break;
1146
		
1147
	case 'fixedud':
1148
		// fixed vacation right requests progress bar
1149
		absences_fixedRightUpdate(bab_rp('idvr'));
1150
		$babBody->addItemMenu("fixedud", absences_translate("Update"), absences_addon()->getUrl()."vacadma&idx=fixedud");
1151
		break;
1152
		
1153
	case 'fixedud_progress':
1154
		absences_fixedRightUpdateProgress(bab_rp('idvr'));
1155
		break;
1156
		
1157 View Code Duplication
	case 'user_right_report':
1158
		// user-right links report
1159
		absences_userRightReport(bab_rp('id_right'), bab_rp('nextidx'));
1160
		$babBody->addItemMenu("user_right_report", absences_translate("Update"), absences_addon()->getUrl()."vacadma&idx=user_right_update");
1161
		break;
1162
	
1163
1164 View Code Duplication
	case 'rgroup':
1165
		$babBody->title = absences_translate("Rights groups");
1166
		$babBody->addItemMenu("rgroup", absences_translate("Rights groups"), absences_addon()->getUrl()."vacadma&idx=rgroup");
1167
		$babBody->addItemMenu("rgroupmod", absences_translate("Add"), absences_addon()->getUrl()."vacadma&idx=rgroupmod");
1168
		rgrouplist();
1169
		break;
1170
1171 View Code Duplication
	case 'rgroupmod':
1172
		$babBody->title = absences_translate("Right group");
1173
		$babBody->addItemMenu("rgroup", absences_translate("Rights groups"), absences_addon()->getUrl()."vacadma&idx=rgroup");
1174
		$babBody->addItemMenu("rgroupmod", absences_translate("Edit"), absences_addon()->getUrl()."vacadma&idx=rgroupmod");
1175
		rgroupmod();
1176
		break;
1177
1178
1179 View Code Duplication
	case 'copy':
1180
		$babBody->title = absences_translate("Rights renewal by years");
1181
		$babBody->addItemMenu('copy', absences_translate("Rights renewal"), absences_addon()->getUrl()."vacadma&idx=rgroupmod");
1182
		rightcopy();
1183
		break;
1184
1185
	case "lrig":
1186
	case 'recovery':
1187
	case 'archives':
1188
	default:
1189
		$datee			= bab_rp('datee');
1190
		$dateb			= bab_rp('dateb');
1191
		$idtype			= bab_rp('idtype');
1192
		$idcoll			= bab_rp('idcoll');
1193
		$rgroup			= bab_rp('rgroup');
1194
		$pos			= bab_rp('pos',0);
1195
		$active			= bab_rp('active','');
1196
		$archived		= bab_rp('archived', 0);
1197
		$recovery		= bab_rp('recovery', 0);
1198
1199
		listVacationRigths($idtype, $idcoll, $rgroup, $dateb, $datee, $active, $pos, $archived, $recovery);
1200
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1201
		$babBody->addItemMenu("recovery", absences_translate("Recovery rights"), absences_addon()->getUrl()."vacadma&idx=recovery&recovery=1");
1202
		$babBody->addItemMenu("archives", absences_translate("Archives"), absences_addon()->getUrl()."vacadma&idx=archives&archived=1");
1203
		break;
1204
	}
1205
$babBody->setCurrentItemMenu($idx);
1206
bab_siteMap::setPosition('absences','User');
1207
1208