absences_AgentCardFrame::getPlanning()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 9.4285
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
require_once dirname(__FILE__).'/base.ui.php';
26
bab_Widgets()->includePhpClass('Widget_Form');
27
28
29
class absences_AgentCardFrame extends absences_CardFrame
30
{
31
	protected $agent;
32
	
33
	public function __construct(absences_Agent $agent, $layout = null)
34
	{
35
		parent::__construct(null, $layout);
36
		
37
		$this->agent = $agent;
38
		
39
		$this->loadPage();
40
	}
41
	
42
	protected function initClasses()
43
	{
44
		$this->addClass('absences-agent-cardframe');
45
		$this->addClass(Func_Icons::ICON_LEFT_16);
46
	}
47
	
48
	protected function loadPage()
49
	{
50
		$this->initClasses();
51
		
52
		$W = bab_Widgets();
53
		$cols = $W->HBoxItems(
54
			$col1 = $W->VBoxLayout(), // photo
55
			$W->Items(
56
				$W->Title($this->agent->getName(),3),
57
				$W->HBoxItems(
58
					$col2 = $W->VBoxLayout()->setVerticalSpacing(.2,'em'), 	// nom, regime, fonction, service
59
					$col3 = $W->VBoxLayout()->setVerticalSpacing(.2,'em')	// positions dans l'organigramme / responsable hierarchique
60
				)->setHorizontalSpacing(3,'em')
61
			)
62
		)->setHorizontalSpacing(1,'em');
63
		
64
		$this->addItem($cols);
65
		
66
		if ($photo = $this->getPhoto())
67
		{
68
			$col1->addItem($photo);
69
		}
70
		
71
		
72
		if ($nickname = $this->getNickname())
73
		{
74
			$col2->addItem($nickname);
75
		}
76
		
77
		if ($disabled = $this->getDisabled())
78
		{
79
			$col2->addItem($disabled);
80
		}
81
		
82
		if ($email = $this->getEmail())
83
		{
84
			$col2->addItem($email);
85
		}
86
		
87
		if ($btel = $this->getDirField('btel'))
88
		{
89
			$col2->addItem($btel);
90
		}
91
		
92
		$this->addPersonnelInfos($col2);
93
		
94
		
95
		if ($direntry = $this->getDirEntry())
96
		{
97
			$col3->addItem($direntry);
98
		}
99
		
100
		if ($planning = $this->getPlanning())
101
		{
102
			$col3->addItem($planning);
103
		}
104
		
105
		/*
106
		if ($workinghours = $this->getWorkingHours())
107
		{
108
			$col3->addItem($workinghours);
109
		}
110
		*/
111
		
112
		$superior = absences_Agent::getCurrentUser()->isSuperiorOf($this->agent);
113
		
114
		
115
		if (absences_Agent::getCurrentUser()->isManager())
116
		{
117 View Code Duplication
            if ('rights' !== bab_rp('idx'))
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...
118
            {
119
		        $col3->addItem($W->Link($W->Icon(absences_translate('Rights'), Func_Icons::APPS_VACATIONS), 
120
		            absences_addon()->getUrl().'vacadm&idx=rights&idu='.$this->agent->getIdUser())->setOpenMode(Widget_Link::OPEN_POPUP)
121
		        );
122
            }
123
		    $col3->addItem($W->Link($W->Icon(absences_translate('Export'), Func_Icons::MIMETYPES_OFFICE_SPREADSHEET), absences_addon()->getUrl().'vacadm&idx=export&id_user='.$this->agent->getIdUser()));
124
		
125
		} 
126
		else if ($superior && absences_getVacationOption('chart_superiors_set_rights'))
127
		{
128
		    $entity = $this->agent->getMainEntity();
129
		    $col3->addItem($W->Link($W->Icon(absences_translate('Rights'), Func_Icons::APPS_VACATIONS), 
130
		        absences_addon()->getUrl().'vacchart&idx=rights&idu='.$this->agent->getIdUser().'&ide='.$entity['id'].'&popup=1')->setOpenMode(Widget_Link::OPEN_POPUP)
131
		    );
132
		} 
133 View Code Duplication
		else if ($superior)
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...
134
		{
135
		    $col3->addItem($W->Link($W->Icon(absences_translate('Balance'), Func_Icons::APPS_VACATIONS),
136
		            absences_addon()->getUrl().'vacuser&idx=viewrights&id_user='.$this->agent->getIdUser().'&popup=1')->setOpenMode(Widget_Link::OPEN_POPUP)
137
		    );
138
		}
139
		
140
		
141
		
142
		if ($superior = $this->agent->getSuperior())
143
		{
144
			//TRANSLATORS: Supervisor in organizational chart
145
			$col2->addItem($this->titledLabel(absences_translate('Supervisor'), $superior['name'][0]));
146
		}
147
		
148
		
149
		if ($organization = $this->agent->getOrganization())
150
		{
151
		    $col2->addItem($this->titledLabel(absences_translate('Organization'), $organization->name));
152
		}
153
		
154
		
155
		if ($entity = $this->agent->getMainEntity())
156
		{
157
			if (absences_Agent::getCurrentUser()->canViewEntityPlanning($entity['id']))
158
			{
159
			
160
				$col2->addItem(
161
					$W->FlowItems(
162
						$W->Label(absences_translate('Position'))->addClass('widget-strong')->colon(),
163
						$W->Items(
164
								$W->Label($entity['name']), 
165
								$W->Label(' ('),
166
								$W->Link(absences_translate('planning'), absences_addon()->getUrl().'planning&idx=entity_cal&popup=1&ide='.$entity['id'])->setOpenMode(Widget_Link::OPEN_POPUP),
167
								$W->Label(')')
168
						)
169
					)->addClass('widget-small')->setSpacing(.2,'em', .3,'em')
170
				);
171
			
172
			
173
			} else {
174
				
175
				$col2->addItem($this->titledLabel(absences_translate('Position'), $entity['name']));
176
			}
177
			
178
			
179
			//TRANSLATORS: Main role in organizational chart entity
180
			$col2->addItem($this->titledLabel(absences_translate('Role'), $entity['role_name']));
181
		}
182
		
183
		
184
		if (!$superior && !$entity)
185
		{
186
			// no organizational chart, replace with directory fields
187
			
188
			if ($departmentnumber = $this->getDirField('departmentnumber'))
189
			{
190
				$col2->addItem($departmentnumber);
191
			}
192
		}
193
194
	}
195
	
196
	
197
	/**
198
	 * 
199
	 */
200
	protected function addPersonnelInfos($col2)
201
	{
202
		if ($approbation = $this->agent->getApprobation())
203
		{
204
			$col2->addItem($this->titledLabel(absences_translate('Approbation'), $approbation['name'].sprintf(' (%s)', $approbation['type'])));
205
		}
206
		
207
		$collection = $this->agent->getCollection();
208
		if (isset($collection) && $collection->getRow())
209
		{
210
			$col2->addItem($this->titledLabel(absences_translate('Collection'), $collection->name));
211
		}
212
	}
213
	
214
	
215
	
216
	protected function getPhoto()
217
	{
218
		if ($photo = $this->agent->getPhoto())
219
		{
220
			$W = bab_Widgets();
221
			return $W->Image($photo, $this->agent->getName());
222
		}
223
		
224
		return null;
225
	}
226
	
227
	/**
228
	 * 
229
	 * @param string $fieldname
230
	 */
231
	protected function getDirField($fieldname)
232
	{
233
		$direntry = $this->agent->getDirEntry();
234
		
235
		if (!isset($direntry[$fieldname]))
236
		{
237
			return null;
238
		}
239
		
240
		if (empty($direntry[$fieldname]['value']))
241
		{
242
			return null;
243
		}
244
		
245
		return $this->titledLabel(
246
			$direntry[$fieldname]['name'], 
247
			$direntry[$fieldname]['value']
248
		);
249
	}
250
	
251
252
	protected function getNickname()
253
	{
254
		return $this->titledLabel(
255
				absences_translate('Login ID'),
256
				bab_getUserNickname($this->agent->id_user)
257
		);
258
	}
259
	
260
	
261
	
262
	protected function getDisabled()
263
	{
264
		require_once $GLOBALS['babInstallPath'].'utilit/userinfosincl.php';
265
		
266
		if (bab_userInfos::isValid($this->agent->getIdUser()))
267
		{
268
			return null;
269
		}
270
		
271
		bab_functionality::includeOriginal('Icons');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class bab_functionality as the method includeOriginal() does only exist in the following sub-classes of bab_functionality: Func_Archive, Func_Archive_Zip, Func_Archive_Zip_ZipArchive, Func_Archive_Zip_Zlib, Func_CalendarBackend, Func_CalendarBackend_Ovi, Func_ContextActions, Func_ContextActions_Article, Func_ContextActions_ArticleTopic, Func_Home, Func_Home_Ovidentia, Func_Icons, Func_Icons_Default, Func_Ovml, Func_Ovml_Container, Func_Ovml_Container_Addon, Func_Ovml_Container_Article, Func_Ovml_Container_ArticleCategories, Func_Ovml_Container_ArticleCategory, Func_Ovml_Container_ArticleCategoryNext, Func_Ovml_Container_ArticleCategoryPrevious, Func_Ovml_Container_ArticleFiles, Func_Ovml_Container_ArticleNext, Func_Ovml_Container_ArticlePrevious, Func_Ovml_Container_ArticleTopic, Func_Ovml_Container_ArticleTopicNext, Func_Ovml_Container_ArticleTopicPrevious, Func_Ovml_Container_ArticleTopics, Func_Ovml_Container_Articles, Func_Ovml_Container_ArticlesHomePages, Func_Ovml_Container_CalendarCategories, Func_Ovml_Container_CalendarEventDomains, Func_Ovml_Container_CalendarEvents, Func_Ovml_Container_CalendarGroupEvents, Func_Ovml_Container_CalendarResourceEvents, Func_Ovml_Container_CalendarUserEvents, Func_Ovml_Container_Calendars, Func_Ovml_Container_DbDirectories, Func_Ovml_Container_DbDirectory, Func_Ovml_Container_DbDirectoryAcl, Func_Ovml_Container_DbDirectoryEntry, Func_Ovml_Container_DbDirectoryEntryFields, Func_Ovml_Container_DbDirectoryFields, Func_Ovml_Container_DbDirectoryMemberFields, Func_Ovml_Container_DbDirectoryMembers, Func_Ovml_Container_Delegation, Func_Ovml_Container_DelegationAdministrators, Func_Ovml_Container_DelegationItems, Func_Ovml_Container_DelegationManaged, Func_Ovml_Container_Delegations, Func_Ovml_Container_DelegationsCategories, Func_Ovml_Container_DelegationsCategory, Func_Ovml_Container_DelegationsManaged, Func_Ovml_Container_Faq, Func_Ovml_Container_FaqNext, Func_Ovml_Container_FaqPrevious, Func_Ovml_Container_FaqQuestion, Func_Ovml_Container_FaqQuestionNext, Func_Ovml_Container_FaqQuestionPrevious, Func_Ovml_Container_FaqQuestions, Func_Ovml_Container_FaqSubCategories, Func_Ovml_Container_FaqSubCategory, Func_Ovml_Container_Faqs, Func_Ovml_Container_File, Func_Ovml_Container_FileFields, Func_Ovml_Container_FileNext, Func_Ovml_Container_FilePrevious, Func_Ovml_Container_Files, Func_Ovml_Container_Folder, Func_Ovml_Container_FolderNext, Func_Ovml_Container_FolderPrevious, Func_Ovml_Container_Folders, Func_Ovml_Container_Forum, Func_Ovml_Container_ForumNext, Func_Ovml_Container_ForumPrevious, Func_Ovml_Container_Forums, Func_Ovml_Container_IfEqual, Func_Ovml_Container_IfGreaterThan, Func_Ovml_Container_IfGreaterThanOrEqual, Func_Ovml_Container_IfIsSet, Func_Ovml_Container_IfLessThan, Func_Ovml_Container_IfLessThanOrEqual, Func_Ovml_Container_IfNotEqual, Func_Ovml_Container_IfNotIsSet, Func_Ovml_Container_IfUserMemberOfGroups, Func_Ovml_Container_Multipages, Func_Ovml_Container_ObjectsInfo, Func_Ovml_Container_OrgPathToEntity, Func_Ovml_Container_OrgUserEntities, Func_Ovml_Container_OvmlArray, Func_Ovml_Container_OvmlArrayFields, Func_Ovml_Container_OvmlSoap, Func_Ovml_Container_ParentsArticleCategory, Func_Ovml_Container_Post, Func_Ovml_Container_PostFiles, Func_Ovml_Container_RecentArticles, Func_Ovml_Container_RecentComments, Func_Ovml_Container_RecentFaqQuestions, Func_Ovml_Container_RecentFiles, Func_Ovml_Container_RecentPosts, Func_Ovml_Container_RecentThreads, Func_Ovml_Container_SitemapCustomNode, Func_Ovml_Container_SitemapEntries, Func_Ovml_Container_SitemapEntry, Func_Ovml_Container_SitemapPath, Func_Ovml_Container_Soap, Func_Ovml_Container_SubFolders, Func_Ovml_Container_Tags, Func_Ovml_Container_Thread, Func_Ovml_Container_TmProjects, Func_Ovml_Container_TmSpaces, Func_Ovml_Container_TmTaskFields, Func_Ovml_Container_TmTasks, Func_Ovml_Container_WaitingArticles, Func_Ovml_Container_WaitingComments, Func_Ovml_Container_WaitingFiles, Func_Ovml_Container_WaitingPosts, Func_Ovml_Function, Func_Ovml_Function_AOAddition, Func_Ovml_Function_AODivision, Func_Ovml_Function_AOModulus, Func_Ovml_Function_AOMultiplication, Func_Ovml_Function_AOSubtraction, Func_Ovml_Function_AddStyleSheet, Func_Ovml_Function_Addon, Func_Ovml_Function_Ajax, Func_Ovml_Function_ArticleTree, Func_Ovml_Function_CurrentNode, Func_Ovml_Function_FileTree, Func_Ovml_Function_Get, Func_Ovml_Function_GetCookie, Func_Ovml_Function_GetCsrfProtectToken, Func_Ovml_Function_GetCurrentAdmGroup, Func_Ovml_Function_GetLanguage, Func_Ovml_Function_GetPageTitle, Func_Ovml_Function_GetPath, Func_Ovml_Function_GetSelectedSkinPath, Func_Ovml_Function_GetSessionVar, Func_Ovml_Function_GetVar, Func_Ovml_Function_Header, Func_Ovml_Function_IfNotIsSet, Func_Ovml_Function_Include, Func_Ovml_Function_NextArticle, Func_Ovml_Function_Post, Func_Ovml_Function_PreviousArticle, Func_Ovml_Function_PreviousOrNextArticle, Func_Ovml_Function_PutArray, Func_Ovml_Function_PutSoapArray, Func_Ovml_Function_PutVar, Func_Ovml_Function_Recurse, Func_Ovml_Function_Request, Func_Ovml_Function_SetCookie, Func_Ovml_Function_SetSessionVar, Func_Ovml_Function_SitemapCustomNodeId, Func_Ovml_Function_SitemapMenu, Func_Ovml_Function_SitemapPosition, Func_Ovml_Function_SitemapUrl, Func_Ovml_Function_Translate, Func_Ovml_Function_UrlContent, Func_Ovml_Function_WebStat, Func_PortalAuthentication, Func_PortalAuthentication_AuthOvidentia, Func_PwdComplexity, Func_PwdComplexity_DefaultPortal, Func_SearchUi, Func_SitemapDynamicNode, Func_SitemapDynamicNode_Topic, Func_UserEditor, Func_WorkingHours, Func_WorkingHours_Ovidentia, Ovml_Container_Sitemap, bab_ArithmeticOperator, bab_Ovml_Container_Operator, bab_rgp. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
272
		$W = bab_Widgets();
273
		return $W->Icon(absences_translate('This account is disabled'), Func_Icons::STATUS_DIALOG_WARNING);
274
	}
275
	
276
	
277
	/**
278
	 *
279
	 *
280
	 */
281
	protected function getEmail()
282
	{
283
		$W = bab_Widgets();
284
		$direntry = $this->agent->getDirEntry();
285
	
286
		if (!isset($direntry['email']))
287
		{
288
			return null;
289
		}
290
	
291
		if (empty($direntry['email']['value']))
292
		{
293
			return null;
294
		}
295
		
296
		return $W->FlowItems(
297
				$W->Label($direntry['email']['name'])->addClass('widget-strong')->colon(),
298
				$W->Link($direntry['email']['value'], 'mailto:'.$direntry['email']['value'])
299
		)->addClass('widget-small')->setSpacing(.2,'em', .3,'em');
300
	}
301
	
302
	
303
304
	
305
	
306
	
307
	protected function getDirEntry()
308
	{
309
		$W = bab_Widgets();
310
		$link = bab_getUserDirEntryLink($this->agent->id_user, BAB_DIR_ENTRY_ID_USER);
0 ignored issues
show
Documentation introduced by
$this->agent->id_user is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
311
	
312
		if (!$link)
313
		{
314
			return null;
315
		}
316
	
317
		return $W->Link($W->Icon(absences_translate('View directory entry'), Func_Icons::OBJECTS_CONTACT), $link)->setOpenMode(Widget_Link::OPEN_POPUP);
318
	}
319
	
320
	
321
	
322
	
323
	protected function getPlanning()
324
	{
325
		$W = bab_Widgets();
326
		
327
		$addon = bab_getAddonInfosInstance('absences');
328
		
329
		return $W->Link($W->Icon(absences_translate('View planning'), Func_Icons::APPS_CALENDAR), $addon->getUrl().'planning&idx=cal&popup=1&idu='.$this->agent->id_user)->setOpenMode(Widget_Link::OPEN_POPUP);
330
	}
331
	
332
	
333
	
334
	protected function getWorkingHours()
335
	{
336
		$W = bab_Widgets();
337
		
338
		$func = bab_functionality::get('WorkingHours');
339
		
340
		if (false === $func)
341
		{
342
			return null;
343
		}
344
		
345
		$url = $func->getUserSettingsPopupUrl($this->agent->getIdUser());
346
		
347
		if (null === $url)
348
		{
349
			return null;
350
		}
351
		
352
		return $W->Link($W->Icon(absences_translate('Working hours'), Func_Icons::APPS_CALENDAR), $url)->setOpenMode(Widget_Link::OPEN_POPUP);
353
	}
354
}
355
356
357
358
class absences_AgentFullFrame extends absences_AgentCardFrame
359
{
360
	/**
361
	 *
362
	 */
363
	protected function addPersonnelInfos($col2)
364
	{
365
		// do not display personnel info because exists in edit form
366
		// show link to directory entry instead 
367
	}
368
	
369
	
370
	protected function initClasses()
371
	{
372
		$this->addClass('absences-agent-fullframe');
373
		$this->addClass(Func_Icons::ICON_LEFT_16);
374
	}
375
376
}
377
378
379
380
381
382
383
384
class absences_AgentMovementList extends absences_Paginate 
385
{
386
	const MAX = 20;
387
	
388
	public $altbg = true;
389
	
390
	public $t_date;
391
	public $date;
392
	
393
	public $t_author;
394
	public $author;
395
	
396
	public $t_message;
397
	public $message;
398
	
399
	public $t_comment;
400
	public $comment;
401
	
402
	private $res;
403
	
404
	public function __construct(absences_Agent $agent)
405
	{
406
		$this->t_date = absences_translate('Date');
407
		$this->t_author = absences_translate('Author');
408
		$this->t_request = absences_translate('Object');
0 ignored issues
show
Bug introduced by
The property t_request 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...
409
		$this->t_message = absences_translate('Message');
410
		$this->t_comment = absences_translate('Regularization or approval comment by the author');
411
		
412
		
413
		$this->res = $agent->getMovementIterator();
414
		$this->res->rewind();
415
		
416
		$this->paginate($this->res->count(), self::MAX);
417
		$this->res->seek($this->pos);
418
		
419
		bab_functionality::includeOriginal('Icons');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class bab_functionality as the method includeOriginal() does only exist in the following sub-classes of bab_functionality: Func_Archive, Func_Archive_Zip, Func_Archive_Zip_ZipArchive, Func_Archive_Zip_Zlib, Func_CalendarBackend, Func_CalendarBackend_Ovi, Func_ContextActions, Func_ContextActions_Article, Func_ContextActions_ArticleTopic, Func_Home, Func_Home_Ovidentia, Func_Icons, Func_Icons_Default, Func_Ovml, Func_Ovml_Container, Func_Ovml_Container_Addon, Func_Ovml_Container_Article, Func_Ovml_Container_ArticleCategories, Func_Ovml_Container_ArticleCategory, Func_Ovml_Container_ArticleCategoryNext, Func_Ovml_Container_ArticleCategoryPrevious, Func_Ovml_Container_ArticleFiles, Func_Ovml_Container_ArticleNext, Func_Ovml_Container_ArticlePrevious, Func_Ovml_Container_ArticleTopic, Func_Ovml_Container_ArticleTopicNext, Func_Ovml_Container_ArticleTopicPrevious, Func_Ovml_Container_ArticleTopics, Func_Ovml_Container_Articles, Func_Ovml_Container_ArticlesHomePages, Func_Ovml_Container_CalendarCategories, Func_Ovml_Container_CalendarEventDomains, Func_Ovml_Container_CalendarEvents, Func_Ovml_Container_CalendarGroupEvents, Func_Ovml_Container_CalendarResourceEvents, Func_Ovml_Container_CalendarUserEvents, Func_Ovml_Container_Calendars, Func_Ovml_Container_DbDirectories, Func_Ovml_Container_DbDirectory, Func_Ovml_Container_DbDirectoryAcl, Func_Ovml_Container_DbDirectoryEntry, Func_Ovml_Container_DbDirectoryEntryFields, Func_Ovml_Container_DbDirectoryFields, Func_Ovml_Container_DbDirectoryMemberFields, Func_Ovml_Container_DbDirectoryMembers, Func_Ovml_Container_Delegation, Func_Ovml_Container_DelegationAdministrators, Func_Ovml_Container_DelegationItems, Func_Ovml_Container_DelegationManaged, Func_Ovml_Container_Delegations, Func_Ovml_Container_DelegationsCategories, Func_Ovml_Container_DelegationsCategory, Func_Ovml_Container_DelegationsManaged, Func_Ovml_Container_Faq, Func_Ovml_Container_FaqNext, Func_Ovml_Container_FaqPrevious, Func_Ovml_Container_FaqQuestion, Func_Ovml_Container_FaqQuestionNext, Func_Ovml_Container_FaqQuestionPrevious, Func_Ovml_Container_FaqQuestions, Func_Ovml_Container_FaqSubCategories, Func_Ovml_Container_FaqSubCategory, Func_Ovml_Container_Faqs, Func_Ovml_Container_File, Func_Ovml_Container_FileFields, Func_Ovml_Container_FileNext, Func_Ovml_Container_FilePrevious, Func_Ovml_Container_Files, Func_Ovml_Container_Folder, Func_Ovml_Container_FolderNext, Func_Ovml_Container_FolderPrevious, Func_Ovml_Container_Folders, Func_Ovml_Container_Forum, Func_Ovml_Container_ForumNext, Func_Ovml_Container_ForumPrevious, Func_Ovml_Container_Forums, Func_Ovml_Container_IfEqual, Func_Ovml_Container_IfGreaterThan, Func_Ovml_Container_IfGreaterThanOrEqual, Func_Ovml_Container_IfIsSet, Func_Ovml_Container_IfLessThan, Func_Ovml_Container_IfLessThanOrEqual, Func_Ovml_Container_IfNotEqual, Func_Ovml_Container_IfNotIsSet, Func_Ovml_Container_IfUserMemberOfGroups, Func_Ovml_Container_Multipages, Func_Ovml_Container_ObjectsInfo, Func_Ovml_Container_OrgPathToEntity, Func_Ovml_Container_OrgUserEntities, Func_Ovml_Container_OvmlArray, Func_Ovml_Container_OvmlArrayFields, Func_Ovml_Container_OvmlSoap, Func_Ovml_Container_ParentsArticleCategory, Func_Ovml_Container_Post, Func_Ovml_Container_PostFiles, Func_Ovml_Container_RecentArticles, Func_Ovml_Container_RecentComments, Func_Ovml_Container_RecentFaqQuestions, Func_Ovml_Container_RecentFiles, Func_Ovml_Container_RecentPosts, Func_Ovml_Container_RecentThreads, Func_Ovml_Container_SitemapCustomNode, Func_Ovml_Container_SitemapEntries, Func_Ovml_Container_SitemapEntry, Func_Ovml_Container_SitemapPath, Func_Ovml_Container_Soap, Func_Ovml_Container_SubFolders, Func_Ovml_Container_Tags, Func_Ovml_Container_Thread, Func_Ovml_Container_TmProjects, Func_Ovml_Container_TmSpaces, Func_Ovml_Container_TmTaskFields, Func_Ovml_Container_TmTasks, Func_Ovml_Container_WaitingArticles, Func_Ovml_Container_WaitingComments, Func_Ovml_Container_WaitingFiles, Func_Ovml_Container_WaitingPosts, Func_Ovml_Function, Func_Ovml_Function_AOAddition, Func_Ovml_Function_AODivision, Func_Ovml_Function_AOModulus, Func_Ovml_Function_AOMultiplication, Func_Ovml_Function_AOSubtraction, Func_Ovml_Function_AddStyleSheet, Func_Ovml_Function_Addon, Func_Ovml_Function_Ajax, Func_Ovml_Function_ArticleTree, Func_Ovml_Function_CurrentNode, Func_Ovml_Function_FileTree, Func_Ovml_Function_Get, Func_Ovml_Function_GetCookie, Func_Ovml_Function_GetCsrfProtectToken, Func_Ovml_Function_GetCurrentAdmGroup, Func_Ovml_Function_GetLanguage, Func_Ovml_Function_GetPageTitle, Func_Ovml_Function_GetPath, Func_Ovml_Function_GetSelectedSkinPath, Func_Ovml_Function_GetSessionVar, Func_Ovml_Function_GetVar, Func_Ovml_Function_Header, Func_Ovml_Function_IfNotIsSet, Func_Ovml_Function_Include, Func_Ovml_Function_NextArticle, Func_Ovml_Function_Post, Func_Ovml_Function_PreviousArticle, Func_Ovml_Function_PreviousOrNextArticle, Func_Ovml_Function_PutArray, Func_Ovml_Function_PutSoapArray, Func_Ovml_Function_PutVar, Func_Ovml_Function_Recurse, Func_Ovml_Function_Request, Func_Ovml_Function_SetCookie, Func_Ovml_Function_SetSessionVar, Func_Ovml_Function_SitemapCustomNodeId, Func_Ovml_Function_SitemapMenu, Func_Ovml_Function_SitemapPosition, Func_Ovml_Function_SitemapUrl, Func_Ovml_Function_Translate, Func_Ovml_Function_UrlContent, Func_Ovml_Function_WebStat, Func_PortalAuthentication, Func_PortalAuthentication_AuthOvidentia, Func_PwdComplexity, Func_PwdComplexity_DefaultPortal, Func_SearchUi, Func_SitemapDynamicNode, Func_SitemapDynamicNode_Topic, Func_UserEditor, Func_WorkingHours, Func_WorkingHours_Ovidentia, Ovml_Container_Sitemap, bab_ArithmeticOperator, bab_Ovml_Container_Operator, bab_rgp. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
420
	}
421
	
422 View Code Duplication
	public function getnext()
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...
423
	{
424
		if (($this->res->key() - $this->pos) >= self::MAX)
425
		{
426
			return false;
427
		}
428
		
429
		if ($this->res->valid())
430
		{
431
			$W = bab_Widgets();
432
			$movement = $this->res->current();
433
			/*@var $movement absences_Movement */
434
			
435
			$this->altbg = !$this->altbg;
436
		
437
			$this->author = bab_toHtml(bab_getUserName($movement->id_author));
438
			$this->date = bab_toHtml(bab_shortDate(bab_mktime($movement->createdOn)));
439
			if ($request = $movement->getRequest())
440
			{
441
				$this->request = $request->getManagerFrame()->addClass(Func_Icons::ICON_LEFT_16)->display($W->HtmlCanvas());
0 ignored issues
show
Bug introduced by
The property request does not seem to exist. Did you mean t_request?

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...
442
			} else {
443
				$this->request = '';
0 ignored issues
show
Bug introduced by
The property request does not seem to exist. Did you mean t_request?

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...
444
			}
445
			$this->message = bab_toHtml($movement->message);
446
			$this->comment = bab_toHtml($movement->comment);
447
			
448
			$this->res->next();
449
			return true;
450
		}
451
		
452
		return false;
453
	}
454
	
455 View Code Duplication
	public function getHtml()
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...
456
	{
457
		$babBody = bab_getInstance('babBody');
458
		
459
		if ($this->res->count() === 0)
460
		{
461
			$babBody->addError(absences_translate('There are no records yet for this user'));
462
			return '';
463
		}
464
		
465
		return bab_printTemplate($this, absences_addon()->getRelativePath()."agent.html", "movement");
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

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...
466
	}
467
}
468
469
470
471
472
473
474
475
476
477
478
479
480
class absences_AgentRightsList
481
{
482
	public $nametxt;
483
	public $urlname;
484
	public $url;
485
	public $descriptiontxt;
486
	public $description;
487
	public $consumedtxt;
488
	public $consumed;
489
	public $fullname;
490
	public $titletxt;
491
492
	public $arr = array();
493
	public $babDB;
494
	private $res;
495
496
	public $iduser;
497
	public $idcoll;
498
	public $bview;
499
500
	public $updatetxt;
501
	public $invalidentry;
502
	public $invalidentry1;
503
	public $invalidentry2;
504
505
	public function __construct($id)
506
	{
507
		global $babDB;
508
		$this->iduser = $id;
509
		$this->idu = $id;
0 ignored issues
show
Bug introduced by
The property idu 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...
510
		$this->ide = bab_rp('ide');
0 ignored issues
show
Bug introduced by
The property ide 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...
511
		$this->updatetxt = absences_translate("Update");
512
		$this->desctxt = absences_translate("Description");
0 ignored issues
show
Bug introduced by
The property desctxt 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...
513
		$this->typetxt = absences_translate("Type");
0 ignored issues
show
Bug introduced by
The property typetxt 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...
514
		$this->consumedtxt = absences_translate("Consumed");
515
		$this->waitingtxt = absences_translate("Waiting");
0 ignored issues
show
Bug introduced by
The property waitingtxt 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...
516
		$this->datebtxt = absences_translate("Begin date");
0 ignored issues
show
Bug introduced by
The property datebtxt 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...
517
		$this->dateetxt = absences_translate("End date");
0 ignored issues
show
Bug introduced by
The property dateetxt 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...
518
		$this->quantitytxt = absences_translate("Rights");
0 ignored issues
show
Bug introduced by
The property quantitytxt 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...
519
		$this->balancetxt = absences_translate("Balance");
0 ignored issues
show
Bug introduced by
The property balancetxt 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...
520
		$this->previsionaltxt = absences_translate("Previsional");
0 ignored issues
show
Bug introduced by
The property previsionaltxt 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...
521
		$this->previsionalbalancetxt = absences_translate("Previ. Bal.");
0 ignored issues
show
Bug introduced by
The property previsionalbalancetxt does not seem to exist. Did you mean balancetxt?

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...
522
		$this->datetxt = absences_translate("Entry date");
0 ignored issues
show
Bug introduced by
The property datetxt does not seem to exist. Did you mean updatetxt?

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...
523
		$this->invalidentry = bab_toHtml(absences_translate("Invalid entry!  Only numbers are accepted or . !"), BAB_HTML_JS);
524
		$this->invalidentry1 = absences_translate("Invalid entry");
525
		$this->invalidentry2 = absences_translate("Days must be multiple of 0.5");
526
		$this->t_comment = absences_translate("Comment on quantities modification for user history:");
0 ignored issues
show
Bug introduced by
The property t_comment 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...
527
		$GLOBALS['babBody']->title = absences_translate("Vacation rights of:").' '.bab_getUserName($id);
528
529
		$infos = bab_getUserInfos($id);
530
		$this->currentUserLastname = $infos['sn'];
0 ignored issues
show
Bug introduced by
The property currentUserLastname 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...
531
		$this->currentUserFirstname = $infos['givenname'];
0 ignored issues
show
Bug introduced by
The property currentUserFirstname 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...
532
533
		$this->tg = bab_rp('tg');
0 ignored issues
show
Bug introduced by
The property tg 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...
534
535
		require_once dirname(__FILE__).'/agent.class.php';
536
		require_once dirname(__FILE__).'/agent.ui.php';
537
		$agent = absences_Agent::getFromIdUser($id);
538
		$cardframe = new absences_AgentCardFrame($agent);
539
		$this->header = $cardframe->display(bab_Widgets()->HtmlCanvas());
0 ignored issues
show
Bug introduced by
The property header 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...
540
541
		$this->res = $agent->getAgentRightManagerIterator();
542
		$this->res->rewind();
543
		
544
		$collectionName = absences_translate('Unknown');
545
		if ($collection = $agent->getCollection()) {
546
		    if ($collection->getRow()) {
547
		         $collectionName = $collection->name;
548
		    }
549
		}
550
551
		$this->not_in_collection = sprintf(absences_translate('This right is not in collection %s'), $collectionName);
0 ignored issues
show
Bug introduced by
The property not_in_collection 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...
552
553
		$this->agentRight = (absences_Agent::getCurrentUser()->isManager() && !bab_rp('ide'));
0 ignored issues
show
Bug introduced by
The property agentRight 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...
554
	}
555
556
	public function getnextright(&$ignore)
0 ignored issues
show
Unused Code introduced by
The parameter $ignore is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
557
	{
558
		static $y = '';
559
		static $label = '';
560
561
		if( $this->res->valid())
562
		{
563
564
			$agentRight = $this->res->current();
565
			/*@var $agentRight absences_AgentRight */
566
			$right = $agentRight->getRight();
567
568
			$right->monthlyQuantityUpdate();
569
			
570
			$type = $right->getType();
571
572
			$this->res->next();
573
574
575
			$this->idright = $right->id;
0 ignored issues
show
Bug introduced by
The property idright 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...
576
			$this->description = bab_toHtml($right->description);
577
			$this->type = bab_toHtml($type->name);
0 ignored issues
show
Bug introduced by
The property type 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...
578
			$this->color = bab_toHtml($type->color);
0 ignored issues
show
Bug introduced by
The property color 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...
579
			$this->quantity = absences_editQuantity($agentRight->getQuantity(), $right->quantity_unit);
0 ignored issues
show
Bug introduced by
The property quantity does not seem to exist. Did you mean quantitytxt?

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...
580
			
581
			$this->unit = bab_toHtml($right->getUnitLabel());
0 ignored issues
show
Bug introduced by
The property unit 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...
582
			
583
			$this->dynamic_quantity = null;
0 ignored issues
show
Bug introduced by
The property dynamic_quantity 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...
584
			$dyn = $agentRight->getDynamicQuantity();
585 View Code Duplication
			if (abs($dyn) > 0.01) {
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...
586
			    $this->dynamic_quantity = bab_toHtml(
587
			        sprintf(
588
			            absences_translate(
589
			                'The quantity include %s because of the balance modification according to the consumed amount rule',
590
			                'The quantity include %s because of the balance modification according to the consumed amount rule',
591
			                $dyn
592
			            ),
593
			            absences_quantity($dyn, $right->quantity_unit)
594
	               )
595
	            );
596
			}
597
			
598
			
599
			$this->increment_quantity = null;
0 ignored issues
show
Bug introduced by
The property increment_quantity 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...
600
			$dyn = $agentRight->getIncrementQuantity();
601 View Code Duplication
			if (abs($dyn) > 0.01) {
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...
602
			    $this->increment_quantity = bab_toHtml(
603
			            sprintf(
604
			                    absences_translate(
605
			                        'The quantity include %s because of the monthly modifications',
606
			                        'The quantity include %s because of the monthly modifications',
607
			                        $dyn
608
			                    ),
609
			                    absences_quantity($dyn, $right->quantity_unit)
610
			            )
611
			    );
612
			}
613
			
614
			$this->disp_quantity = absences_quantity($agentRight->getQuantity(), $right->quantity_unit);
0 ignored issues
show
Bug introduced by
The property disp_quantity 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...
615
616
			if ($message = $agentRight->getQuantityAlert())
617
			{
618
				$this->alert = bab_toHtml($message);
0 ignored issues
show
Bug introduced by
The property alert 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...
619
			} else {
620
				$this->alert = null;
621
			}
622
623
624
			if ($right->getYear() !== $y)
625
			{
626
				$this->year = null === $right->getYear() ? absences_translate('No theoretical period') : $right->getYear();
0 ignored issues
show
Bug introduced by
The property year 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...
627
			} else {
628
				$this->year = '';
629
			}
630
			$y = $right->getYear();
631
632
			$rgrouplabel = $right->getRgroupLabel();
633
			$this->rgroup = $rgrouplabel !== $label && !empty($rgrouplabel) ? $rgrouplabel : '';
0 ignored issues
show
Bug introduced by
The property rgroup 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...
634
			$label = $rgrouplabel;
635
636
			$this->in_rgroup = null !== $right->getRgroup();
0 ignored issues
show
Bug introduced by
The property in_rgroup does not seem to exist. Did you mean rgroup?

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...
637
638
			$this->dateb = bab_shortDate(bab_mktime($right->date_begin), false);
0 ignored issues
show
Bug introduced by
The property dateb 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...
639
			$this->datee = bab_shortDate(bab_mktime($right->date_end), false);
0 ignored issues
show
Bug introduced by
The property datee 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...
640
641
			$this->consumed = absences_quantity($agentRight->getConfirmedQuantity(), $right->quantity_unit);
642
			$this->waiting = absences_quantity($agentRight->getWaitingQuantity(), $right->quantity_unit);
0 ignored issues
show
Bug introduced by
The property waiting does not seem to exist. Did you mean waitingtxt?

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...
643
			$this->previsional = absences_quantity($agentRight->getPrevisionalQuantity(), $right->quantity_unit);
0 ignored issues
show
Bug introduced by
The property previsional does not seem to exist. Did you mean previsionaltxt?

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...
644
645
			$balance = $agentRight->getQuantity()-$agentRight->getWaitingQuantity()-$agentRight->getConfirmedQuantity();
646
			$this->balance = absences_quantity($balance, $right->quantity_unit);
0 ignored issues
show
Bug introduced by
The property balance does not seem to exist. Did you mean balancetxt?

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...
647
			$this->previsional_balance = absences_quantity($balance - $agentRight->getPrevisionalQuantity(), $right->quantity_unit);
0 ignored issues
show
Bug introduced by
The property previsional_balance 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...
648
649
			$this->readonly = ($right->getKind() === absences_Right::FIXED);
0 ignored issues
show
Bug introduced by
The property readonly 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...
650
			$this->agent_right_url = bab_toHtml(absences_addon()->getUrl().'vacadm&idx=agentright&ar='.$agentRight->id);
0 ignored issues
show
Bug introduced by
The property agent_right_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...
651
			$this->in_collection = $agentRight->isRightInAgentCollection();
0 ignored issues
show
Bug introduced by
The property in_collection does not seem to exist. Did you mean not_in_collection?

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...
652
653
			return true;
654
		}
655
		else
656
			return false;
657
658
	}
659
660
661
662
663
664
	/**
665
	 * get previous or next user in manager list
666
	 * @param	string	$sign
667
	 * @param	string	$sqlOrderType
668
	 * @return 	int|false
669
	 */
670
	private function getUserInManagerList($sign, $sqlOrderType) {
671
672
673
		global $babDB;
674
675
676
		$ide = bab_rp('ide');
677
678
		// delegation administration list
679
		if ($ide && absences_isAccessibleEntityAsSuperior($ide)) {
680
681
682
			$users = bab_OCGetCollaborators($ide);
683
			$superior = bab_OCGetSuperior($ide);
684
685
			if (((int)$superior['id_user']) !== (int)$GLOBALS['BAB_SESS_USERID'] && false === absences_isAccessibleEntityAsCoManager($ide)) {
686
				$users[] = $superior;
687
			}
688
689
690
			$ordering = array();
691
			foreach($users as $key => $user) {
692
				$ordering[$key] = $user['lastname'].' '.$user['firstname'];
693
			}
694
695
			bab_sort::natcasesort($ordering);
696
697
698
			$previous = false;
699
			$next = false;
700
701
			$next_prev_index = array();
702
703
			foreach($ordering as $key => $dummy) {
704
705
				if (false !== $previous) {
706
					$next_prev_index[$previous]['next'] = $users[$key]['id_user'];
707
				}
708
709
				$next_prev_index[$users[$key]['id_user']] = array(
710
						'previous' => $previous,
711
						'next' => $next
712
				);
713
714
				$previous = $users[$key]['id_user'];
715
			}
716
717
			reset($ordering);
718
			$firstuser = $users[key($ordering)]['id_user'];
719
			next($ordering);
720
			$seconduser = $users[key($ordering)]['id_user'];
721
722
			$next_prev_index[$firstuser]['next'] = $seconduser;
723
724
725
726
			switch($sign) {
727
				case '<':
728
					return $next_prev_index[$this->iduser]['previous'];
729
730
				case '>':
731
					return $next_prev_index[$this->iduser]['next'];
732
			}
733
734
735
			return false;
736
		}
737
738
739
740
741
742
743
		// manager list
744
745
		$acclevel = absences_vacationsAccess();
746
		if( true === $acclevel['manager'])
747
		{
748
749
			$res = $babDB->db_query('
750
					SELECT
751
					p.id_user
752
					FROM
753
					'.ABSENCES_PERSONNEL_TBL.' p, '.BAB_USERS_TBL.' u
754
755
					WHERE
756
					u.id = p.id_user
757
					AND (u.lastname '.$sign.' '.$babDB->quote($this->currentUserLastname).'
758
					OR (u.lastname = '.$babDB->quote($this->currentUserLastname).'
759
					AND u.firstname '.$sign.' '.$babDB->quote($this->currentUserFirstname).')
760
			)
761
762
					ORDER BY u.lastname '.$sqlOrderType.', u.firstname '.$sqlOrderType.'
763
764
					LIMIT 0,2
765
					');
766
767
768
769
			if ($arr = $babDB->db_fetch_assoc($res)) {
770
				return (int) $arr['id_user'];
771
			}
772
773
		}
774
775
776
777
778
779
		return false;
780
	}
781
782
783
784
785 View Code Duplication
	public function previoususer() {
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...
786
787
		static $i = 0;
788
789
		if (0 === $i) {
790
791
			$id_user = $this->getUserInManagerList('<','DESC');
792
			if (!$id_user) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $id_user of type integer|false is loosely compared to false; this is ambiguous if the integer can be zero. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
793
				return false;
794
			}
795
796
			$this->previous = bab_toHtml(bab_getUserName($id_user));
0 ignored issues
show
Bug introduced by
The property previous 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...
797
798
			require_once $GLOBALS['babInstallPath'] . 'utilit/urlincl.php';
799
			$url = bab_url::request_gp();
800
801
			if (bab_rp('idu')) {
802
				$url = bab_url::mod($url, 'idu', $id_user);
803
			}
804
805
			if (bab_rp('id_user')) {
806
				$url = bab_url::mod($url, 'id_user', $id_user);
807
			}
808
809
			$this->previousurl = bab_toHtml($url);
0 ignored issues
show
Bug introduced by
The property previousurl does not seem to exist. Did you mean previous?

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...
810
811
812
			$i++;
813
			return true;
814
		}
815
816
		return false;
817
	}
818
819 View Code Duplication
	public function nextuser() {
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...
820
821
		static $i = 0;
822
823
		if (0 === $i) {
824
825
			$id_user = $this->getUserInManagerList('>','ASC');
826
			if (!$id_user) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $id_user of type integer|false is loosely compared to false; this is ambiguous if the integer can be zero. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
827
				return false;
828
			}
829
830
			$this->next = bab_toHtml(bab_getUserName($id_user));
0 ignored issues
show
Bug introduced by
The property next 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...
831
832
			require_once $GLOBALS['babInstallPath'] . 'utilit/urlincl.php';
833
			$url = bab_url::request_gp();
834
			if (bab_rp('idu')) {
835
				$url = bab_url::mod($url, 'idu', $id_user);
836
			}
837
838
			if (bab_rp('id_user')) {
839
				$url = bab_url::mod($url, 'id_user', $id_user);
840
			}
841
			$this->nexturl = bab_toHtml($url);
0 ignored issues
show
Bug introduced by
The property nexturl 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...
842
843
844
			$i++;
845
			return true;
846
		}
847
848
		return false;
849
	}
850
851
}
852
853
854
855
856
857
858
859
860
861
862
class absences_PersonalOptionsEditor extends Widget_Form
863
{
864
865
	public function __construct()
866
	{
867
		$W = bab_Widgets();
868
869
		parent::__construct(null, $W->VBoxLayout()->setVerticalSpacing(1,'em'));
870
871
872
		$this->setName('options');
873
		$this->addClass('widget-bordered');
874
		$this->addClass('BabLoginMenuBackground');
875
		$this->addClass('widget-centered');
876
		$this->colon();
877
878
		$this->setCanvasOptions($this->Options()->width(70,'em'));
0 ignored issues
show
Bug introduced by
It seems like $this->Options()->width(70, 'em') targeting Widget_CanvasOptions::width() can also be of type double; however, Widget_Item::setCanvasOptions() does only seem to accept object<Widget_CanvasOptions>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
879
880
		$this->addFields();
881
		$this->loadFormValues();
882
883
		$this->addButtons();
884
		$this->setSelfPageHiddenFields();
885
	}
886
887
888
889 View Code Duplication
	protected function addFields()
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...
890
	{
891
		$W = bab_Widgets();
892
893
894
		$this->addItem($W->LabelledWidget(
895
				absences_translate('Email to notify when a vacation request is accepted (other than me)'),
896
				$W->TextEdit()->setColumns(80)->setLines(2),
897
				'emails',
898
				absences_translate('Comma separated values')
899
		));
900
901
		
902
	}
903
904
905
906
907
908
	protected function loadFormValues()
909
	{
910
		global $babDB;
911
912
		
913
		$values = array();
914
		$agent = absences_Agent::getCurrentUser();
915
		
916
		$values['emails'] = $agent->emails;
917
918
		$this->setValues($values, array('options'));
919
	}
920
921
922 View Code Duplication
	protected function addButtons()
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...
923
	{
924
		$W = bab_Widgets();
925
926
		$button = $W->FlowItems(
927
				$W->SubmitButton()->setName('save')->setLabel(absences_translate('Save'))
928
		)->setSpacing(1,'em');
929
930
		$this->addItem($button);
931
	}
932
}
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
class absences_AgentEdit
954
{
955
    public $usertext;
956
    public $grouptext;
957
    public $userval;
958
    public $userid;
959
    public $groupval;
960
    public $groupid;
961
    public $collection;
962
    public $idcollection;
963
    public $collname;
964
    public $appschema;
965
    public $idsapp;
966
    public $saname;
967
    public $selected;
968
    public $add;
969
    public $bdel;
970
    public $delete;
971
    public $groupsbrowurl;
972
    public $usersbrowurl;
973
974
    public $orand;
975
    public $reset;
976
    
977
    
978
    /**
979
     * @var bool
980
     */
981
    public $changeorganization = true;
982
983
    /**
984
     * @var int
985
     */
986
    private $id_organization;
987
    
988
    /**
989
     * @var absences_OrganizationIterator
990
     */
991
    private $organizations;
992
    
993
    
994
    /**
995
     * @var array
996
     */
997
    private $wsprofiles;
998
    
999
    /**
1000
     * @var ORM_Iterator
1001
     */
1002
    private $profiles;
1003
    
1004
    
1005
    /**
1006
     * @var int
1007
     */
1008
    private $loop_selectedProfile = 0;
1009
    
1010
    
1011
    public $canuseprofiles = false;
1012
1013
1014
    public function __construct($idp)
1015
    {
1016
        require_once dirname(__FILE__).'/organization.class.php';
1017
        
1018
        $this->usertext = absences_translate("User");
1019
        $this->collection = absences_translate("Collection:");
1020
        $this->appschema = absences_translate("Approbation schema for vacation requests:");
1021
        $this->t_id_sa_cet = absences_translate("Approbation schema for deposit into the time savings account:");
0 ignored issues
show
Bug introduced by
The property t_id_sa_cet 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...
1022
        $this->t_id_sa_recover = absences_translate("Approbation schema for declaration of worked days entitling recovery:");
0 ignored issues
show
Bug introduced by
The property t_id_sa_recover 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...
1023
        $this->t_use_vr = absences_translate("Use schema for vacation requests");
0 ignored issues
show
Bug introduced by
The property t_use_vr 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...
1024
        $this->t_list_request = absences_translate("List absence requests");
0 ignored issues
show
Bug introduced by
The property t_list_request 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...
1025
        $this->t_create_request = absences_translate("Create a vacation request");
0 ignored issues
show
Bug introduced by
The property t_create_request 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...
1026
        $this->t_emails = absences_translate('Email to notify when a vacation request is accepted, comma separated');
0 ignored issues
show
Bug introduced by
The property t_emails 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...
1027
        $this->t_organization = absences_translate('Organization:');
0 ignored issues
show
Bug introduced by
The property t_organization 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...
1028
        $this->t_workschedule = absences_translate('Work schedule profile');
0 ignored issues
show
Bug introduced by
The property t_workschedule 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...
1029
        $this->t_from = absences_translate('From');
0 ignored issues
show
Bug introduced by
The property t_from 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...
1030
        $this->t_to = absences_translate('To');
0 ignored issues
show
Bug introduced by
The property t_to 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...
1031
1032
        $this->listrequesturl = bab_toHtml(absences_addon()->getUrl()."vacadmb&idx=lreq&userid=".urlencode($idp));
0 ignored issues
show
Bug introduced by
The property listrequesturl 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...
1033
        $this->createrequesturl = bab_toHtml(absences_addon()->getUrl()."vacuser&idx=period&rfrom=1&id_user=".urlencode($idp));
0 ignored issues
show
Bug introduced by
The property createrequesturl 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...
1034
1035
        $this->delete = absences_translate("Delete");
1036
        $this->usersbrowurl = absences_addon()->getUrl()."vacadm&idx=browu&cb=";
1037
        $this->tg = bab_rp('tg');
0 ignored issues
show
Bug introduced by
The property tg 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...
1038
        $this->ide = isset($_REQUEST['ide']) ? $_REQUEST['ide'] : false;
0 ignored issues
show
Bug introduced by
The property ide 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...
1039
1040
        global $babDB;
1041
        $W = bab_Widgets();
1042
        $this->idp = $idp;
0 ignored issues
show
Bug introduced by
The property idp 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...
1043
         
1044
        $userpicker = $W->UserPicker()->setName('userid');
1045
        bab_functionality::includeOriginal('Icons');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class bab_functionality as the method includeOriginal() does only exist in the following sub-classes of bab_functionality: Func_Archive, Func_Archive_Zip, Func_Archive_Zip_ZipArchive, Func_Archive_Zip_Zlib, Func_CalendarBackend, Func_CalendarBackend_Ovi, Func_ContextActions, Func_ContextActions_Article, Func_ContextActions_ArticleTopic, Func_Home, Func_Home_Ovidentia, Func_Icons, Func_Icons_Default, Func_Ovml, Func_Ovml_Container, Func_Ovml_Container_Addon, Func_Ovml_Container_Article, Func_Ovml_Container_ArticleCategories, Func_Ovml_Container_ArticleCategory, Func_Ovml_Container_ArticleCategoryNext, Func_Ovml_Container_ArticleCategoryPrevious, Func_Ovml_Container_ArticleFiles, Func_Ovml_Container_ArticleNext, Func_Ovml_Container_ArticlePrevious, Func_Ovml_Container_ArticleTopic, Func_Ovml_Container_ArticleTopicNext, Func_Ovml_Container_ArticleTopicPrevious, Func_Ovml_Container_ArticleTopics, Func_Ovml_Container_Articles, Func_Ovml_Container_ArticlesHomePages, Func_Ovml_Container_CalendarCategories, Func_Ovml_Container_CalendarEventDomains, Func_Ovml_Container_CalendarEvents, Func_Ovml_Container_CalendarGroupEvents, Func_Ovml_Container_CalendarResourceEvents, Func_Ovml_Container_CalendarUserEvents, Func_Ovml_Container_Calendars, Func_Ovml_Container_DbDirectories, Func_Ovml_Container_DbDirectory, Func_Ovml_Container_DbDirectoryAcl, Func_Ovml_Container_DbDirectoryEntry, Func_Ovml_Container_DbDirectoryEntryFields, Func_Ovml_Container_DbDirectoryFields, Func_Ovml_Container_DbDirectoryMemberFields, Func_Ovml_Container_DbDirectoryMembers, Func_Ovml_Container_Delegation, Func_Ovml_Container_DelegationAdministrators, Func_Ovml_Container_DelegationItems, Func_Ovml_Container_DelegationManaged, Func_Ovml_Container_Delegations, Func_Ovml_Container_DelegationsCategories, Func_Ovml_Container_DelegationsCategory, Func_Ovml_Container_DelegationsManaged, Func_Ovml_Container_Faq, Func_Ovml_Container_FaqNext, Func_Ovml_Container_FaqPrevious, Func_Ovml_Container_FaqQuestion, Func_Ovml_Container_FaqQuestionNext, Func_Ovml_Container_FaqQuestionPrevious, Func_Ovml_Container_FaqQuestions, Func_Ovml_Container_FaqSubCategories, Func_Ovml_Container_FaqSubCategory, Func_Ovml_Container_Faqs, Func_Ovml_Container_File, Func_Ovml_Container_FileFields, Func_Ovml_Container_FileNext, Func_Ovml_Container_FilePrevious, Func_Ovml_Container_Files, Func_Ovml_Container_Folder, Func_Ovml_Container_FolderNext, Func_Ovml_Container_FolderPrevious, Func_Ovml_Container_Folders, Func_Ovml_Container_Forum, Func_Ovml_Container_ForumNext, Func_Ovml_Container_ForumPrevious, Func_Ovml_Container_Forums, Func_Ovml_Container_IfEqual, Func_Ovml_Container_IfGreaterThan, Func_Ovml_Container_IfGreaterThanOrEqual, Func_Ovml_Container_IfIsSet, Func_Ovml_Container_IfLessThan, Func_Ovml_Container_IfLessThanOrEqual, Func_Ovml_Container_IfNotEqual, Func_Ovml_Container_IfNotIsSet, Func_Ovml_Container_IfUserMemberOfGroups, Func_Ovml_Container_Multipages, Func_Ovml_Container_ObjectsInfo, Func_Ovml_Container_OrgPathToEntity, Func_Ovml_Container_OrgUserEntities, Func_Ovml_Container_OvmlArray, Func_Ovml_Container_OvmlArrayFields, Func_Ovml_Container_OvmlSoap, Func_Ovml_Container_ParentsArticleCategory, Func_Ovml_Container_Post, Func_Ovml_Container_PostFiles, Func_Ovml_Container_RecentArticles, Func_Ovml_Container_RecentComments, Func_Ovml_Container_RecentFaqQuestions, Func_Ovml_Container_RecentFiles, Func_Ovml_Container_RecentPosts, Func_Ovml_Container_RecentThreads, Func_Ovml_Container_SitemapCustomNode, Func_Ovml_Container_SitemapEntries, Func_Ovml_Container_SitemapEntry, Func_Ovml_Container_SitemapPath, Func_Ovml_Container_Soap, Func_Ovml_Container_SubFolders, Func_Ovml_Container_Tags, Func_Ovml_Container_Thread, Func_Ovml_Container_TmProjects, Func_Ovml_Container_TmSpaces, Func_Ovml_Container_TmTaskFields, Func_Ovml_Container_TmTasks, Func_Ovml_Container_WaitingArticles, Func_Ovml_Container_WaitingComments, Func_Ovml_Container_WaitingFiles, Func_Ovml_Container_WaitingPosts, Func_Ovml_Function, Func_Ovml_Function_AOAddition, Func_Ovml_Function_AODivision, Func_Ovml_Function_AOModulus, Func_Ovml_Function_AOMultiplication, Func_Ovml_Function_AOSubtraction, Func_Ovml_Function_AddStyleSheet, Func_Ovml_Function_Addon, Func_Ovml_Function_Ajax, Func_Ovml_Function_ArticleTree, Func_Ovml_Function_CurrentNode, Func_Ovml_Function_FileTree, Func_Ovml_Function_Get, Func_Ovml_Function_GetCookie, Func_Ovml_Function_GetCsrfProtectToken, Func_Ovml_Function_GetCurrentAdmGroup, Func_Ovml_Function_GetLanguage, Func_Ovml_Function_GetPageTitle, Func_Ovml_Function_GetPath, Func_Ovml_Function_GetSelectedSkinPath, Func_Ovml_Function_GetSessionVar, Func_Ovml_Function_GetVar, Func_Ovml_Function_Header, Func_Ovml_Function_IfNotIsSet, Func_Ovml_Function_Include, Func_Ovml_Function_NextArticle, Func_Ovml_Function_Post, Func_Ovml_Function_PreviousArticle, Func_Ovml_Function_PreviousOrNextArticle, Func_Ovml_Function_PutArray, Func_Ovml_Function_PutSoapArray, Func_Ovml_Function_PutVar, Func_Ovml_Function_Recurse, Func_Ovml_Function_Request, Func_Ovml_Function_SetCookie, Func_Ovml_Function_SetSessionVar, Func_Ovml_Function_SitemapCustomNodeId, Func_Ovml_Function_SitemapMenu, Func_Ovml_Function_SitemapPosition, Func_Ovml_Function_SitemapUrl, Func_Ovml_Function_Translate, Func_Ovml_Function_UrlContent, Func_Ovml_Function_WebStat, Func_PortalAuthentication, Func_PortalAuthentication_AuthOvidentia, Func_PwdComplexity, Func_PwdComplexity_DefaultPortal, Func_SearchUi, Func_SitemapDynamicNode, Func_SitemapDynamicNode_Topic, Func_UserEditor, Func_WorkingHours, Func_WorkingHours_Ovidentia, Ovml_Container_Sitemap, bab_ArithmeticOperator, bab_Ovml_Container_Operator, bab_rgp. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
1046
        $this->userpicker = $W->Frame()->addClass(Func_Icons::ICON_LEFT_16)->addItem($userpicker)->display($W->HtmlCanvas());
0 ignored issues
show
Bug introduced by
The property userpicker 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...
1047
         
1048
1049
        list($n) = $babDB->db_fetch_array($babDB->db_query("SELECT COUNT(*) FROM ".ABSENCES_ENTRIES_TBL." WHERE id_user='".$babDB->db_escape_string($this->idp)."' AND status=''"));
1050
1051
        if ($n > 0) {
1052
            $waiting = absences_translate(
1053
                'Modification are disabled, the user have %d waiting request' ,
1054
                'Modification are disabled, the user have %d waiting requests',
1055
                $n);
1056
            $this->waiting = sprintf($waiting, $n);
0 ignored issues
show
Bug introduced by
The property waiting 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...
1057
        }
1058
1059
        if (isset($_POST['action']) && $_POST['action'] == 'changeuser')
1060
        {
1061
            $this->userid = $_POST['userid'];
1062
            $this->idsa = $_POST['idsa'];
0 ignored issues
show
Bug introduced by
The property idsa 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...
1063
            $this->id_sa_cet = $_POST['id_sa_cet'];
0 ignored issues
show
Bug introduced by
The property id_sa_cet does not seem to exist. Did you mean t_id_sa_cet?

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...
1064
            $this->id_sa_recover = $_POST['id_sa_recover'];
0 ignored issues
show
Bug introduced by
The property id_sa_recover does not seem to exist. Did you mean t_id_sa_recover?

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...
1065
            $this->idcol = $_POST['idcol'];
0 ignored issues
show
Bug introduced by
The property idcol 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...
1066
            $this->idp = $_POST['idp'];
1067
            $this->id_organization = bab_pp('id_organization');
1068
        }
1069
1070
        if( !empty($this->idp))
1071
        {
1072
            require_once dirname(__FILE__).'/agent.class.php';
1073
            require_once dirname(__FILE__).'/agent.ui.php';
1074
            $this->add = absences_translate("Modify");
1075
            $agent = absences_Agent::getFromIdUser($this->idp);
1076
1077
            if (!$agent->exists())
1078
            {
1079
                // T7680 apres suppression d'une fiche d'annuaire
1080
                $url = bab_url::get_request('tg');
1081
                $url->idx = 'lper';
1082
                $url->location();
1083
            }
1084
1085
            $this->userid = $agent->getIdUser();
1086
1087
1088
            $frame = new absences_AgentFullFrame($agent);
1089
1090
            $this->userval = $frame->display($W->HtmlCanvas());
1091
            $this->idcol = $agent->id_coll;
1092
            $this->idsa = $agent->id_sa;
1093
            $this->id_sa_cet = $agent->id_sa_cet;
0 ignored issues
show
Bug introduced by
The property id_sa_cet does not seem to exist. Did you mean t_id_sa_cet?

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...
1094
            $this->id_sa_recover = $agent->id_sa_recover;
0 ignored issues
show
Bug introduced by
The property id_sa_recover does not seem to exist. Did you mean t_id_sa_recover?

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...
1095
            $this->emails = bab_toHtml($agent->emails);
0 ignored issues
show
Bug introduced by
The property emails does not seem to exist. Did you mean t_emails?

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...
1096
            $this->id_organization = $agent->id_organization;
1097
        }
1098
        else
1099
        {
1100
            $this->add = absences_translate("Add");
1101
            $this->idcol = '';
1102
            $this->idsa = '';
1103
            $this->id_sa_cet = '';
0 ignored issues
show
Bug introduced by
The property id_sa_cet does not seem to exist. Did you mean t_id_sa_cet?

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...
1104
            $this->id_sa_recover = '';
0 ignored issues
show
Bug introduced by
The property id_sa_recover does not seem to exist. Did you mean t_id_sa_recover?

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...
1105
            $this->userval = '';
1106
            $this->userid = '';
1107
            $this->emails = '';
0 ignored issues
show
Bug introduced by
The property emails does not seem to exist. Did you mean t_emails?

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...
1108
            $this->id_organization = 0;
1109
        }
1110
1111
        $this->groupval = "";
1112
        $this->groupid = "";
1113
1114
        $this->sares = bab_WFGetApprobationsList();
0 ignored issues
show
Bug introduced by
The property sares 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...
1115
1116
1117
        $this->colres = $babDB->db_query("select * from ".ABSENCES_COLLECTIONS_TBL." order by name asc");
0 ignored issues
show
Bug introduced by
The property colres 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...
1118
        $this->countcol = $babDB->db_num_rows($this->colres);
0 ignored issues
show
Bug introduced by
The property countcol 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...
1119
         
1120
        $this->organizations = new absences_OrganizationIterator();
1121
        $this->organizations->rewind();
1122
        
1123
        $this->changeorganization = !(bool) absences_getVacationOption('organization_sync');
1124
        
1125
        $defaultWh = bab_functionality::get('WorkingHours');
1126
        
1127
        if ($workschedules = bab_functionality::get('WorkingHours/Workschedules')) {
1128
            /*@var $workschedules Func_WorkingHours_Workschedules */
1129
            $this->wsprofiles = $workschedules->getProfiles($this->idp);
1130
            
1131
            if (count($this->wsprofiles) > 0 && $workschedules instanceof $defaultWh) {
1132
                $this->canuseprofiles = true;
1133
            }
1134
            
1135
            
1136
            $this->profiles = $workschedules->getUserProfiles($this->idp);
1137
            $this->profiles->rewind();
1138
        }
1139
    }
1140
1141
1142
    public function getnextorganization()
1143
    {
1144
        if ($this->organizations->valid()) {
1145
            $organization = $this->organizations->current();
1146
            $this->organizations->next();
1147
            
1148
            $this->value = bab_toHtml($organization->id);
0 ignored issues
show
Bug introduced by
The property value 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...
1149
            $this->name = bab_toHtml($organization->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...
1150
            $this->selected = ($this->id_organization == $organization->id);
1151
            
1152
            return true;
1153
        }
1154
    }
1155
1156
    public function getnextsa()
1157
    {
1158
1159
        if( list(,$arr) = each($this->sares) )
1160
        {
1161
            $this->saname = $arr['name'];
1162
            $this->idsapp = $arr['id'];
1163
            $this->selected = ( $this->idsa == $this->idsapp ) ? "selected" : '';
1164
            $this->selected_cet = ( $this->id_sa_cet == $this->idsapp ) ? "selected" : '';
0 ignored issues
show
Bug introduced by
The property selected_cet does not seem to exist. Did you mean selected?

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...
Bug introduced by
The property id_sa_cet does not seem to exist. Did you mean t_id_sa_cet?

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...
1165
            $this->selected_recover = ( $this->id_sa_recover == $this->idsapp ) ? "selected" : '';
0 ignored issues
show
Bug introduced by
The property selected_recover does not seem to exist. Did you mean selected?

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...
Bug introduced by
The property id_sa_recover does not seem to exist. Did you mean t_id_sa_recover?

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...
1166
1167
            return true;
1168
        }
1169
        reset($this->sares);
1170
        return false;
1171
1172
    }
1173
1174 View Code Duplication
    public function getnextcol()
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...
1175
    {
1176
        static $j= 0;
1177
        if( $j < $this->countcol )
1178
        {
1179
            global $babDB;
1180
            $arr = $babDB->db_fetch_array($this->colres);
1181
            $this->collname = $arr['name'];
1182
            $this->idcollection = $arr['id'];
1183
            if( $this->idcol == $this->idcollection )
1184
                $this->selected = "selected";
1185
            else
1186
                $this->selected = "";
1187
            $j++;
1188
            return true;
1189
        }
1190
        else
1191
            return false;
1192
    }
1193
1194
    
1195
    public function getnextwsprofile()
1196
    {
1197
        if (list($id, $name) = each($this->wsprofiles)) {
1198
            $this->id = bab_toHtml($id);
0 ignored issues
show
Bug introduced by
The property 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...
1199
            $this->name = bab_toHtml($name);
1200
            $this->selected = ($this->loop_selectedProfile === $id);
1201
            
1202
            return true;
1203
        }
1204
        
1205
        reset($this->wsprofiles);
1206
        return false;
1207
    }
1208
    
1209
    
1210
    public function getnextprofile()
1211
    {
1212
        static $firstRow = null;
1213
        
1214
        if (!isset($firstRow) && 0 === $this->profiles->count()) {
1215
            $firstRow = true;
1216
            $this->profileRow();
1217
            return true;
1218
        }
1219
        
1220
        
1221
        if ($this->profiles->valid()) {
1222
            $userProfile = $this->profiles->current();
1223
            $this->profileRow($userProfile);
1224
            
1225
            
1226
            $this->profiles->next();
1227
            return true;
1228
        }
1229
        
1230
        return false;
1231
    }
1232
    
1233
    
1234
    private function profileRow(workschedules_UserProfile $userProfile = null)
1235
    {
1236
        $W = bab_Widgets();
1237
        $canvas = $W->HtmlCanvas();
1238
        
1239
        $this->userProfileId = '0';
0 ignored issues
show
Bug introduced by
The property userProfileId 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...
1240
        
1241
        $from = $W->DatePicker()->setName(array('profiles', 'from', ''));
1242
        $to = $W->DatePicker()->setName(array('profiles', 'to', ''));
1243
        
1244
        if (isset($userProfile)) {
1245
            $this->userProfileId = $userProfile->id;
1246
            $this->loop_selectedProfile = (int) $userProfile->profile->id;
1247
            
1248
            $from->setValue($userProfile->from);
1249
            $to->setValue($userProfile->to);
1250
        }
1251
        
1252
        $this->datepicker_from = $from->display($canvas);
0 ignored issues
show
Bug introduced by
The property datepicker_from 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...
1253
        $this->datepicker_to = $to->display($canvas);
0 ignored issues
show
Bug introduced by
The property datepicker_to 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...
1254
        
1255
        $this->userProfileId = isset($userProfile) ? $userProfile->id : '0';
1256
    }
1257
    
1258
1259
    public function printhtml()
1260
    {
1261
        $babBody = bab_getBody();
1262
        
1263
        $babBody->addJavascriptFile(absences_addon()->getTemplatePath().'workschedules.js', true);
1264
        
1265
        $babBody->addStyleSheet(absences_addon()->getStylePath().'vacation.css');
1266
        $babBody->babecho(bab_printTemplate($this, absences_addon()->getRelativePath()."vacadm.html", "personnelcreate"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

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...
1267
    }
1268
}
1269
1270
1271
1272