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__).'/record.class.php'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* |
29
|
|
|
* @property string $name |
30
|
|
|
* @property string $quantity_unit |
31
|
|
|
* @property int $recover |
32
|
|
|
* @property int $sortkey |
33
|
|
|
*/ |
34
|
|
|
class absences_Rgroup extends absences_Record implements absences_RightSort |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
public function __construct($id) |
39
|
|
|
{ |
40
|
|
|
$this->id = $id; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Table row as an array |
46
|
|
|
* @return array |
47
|
|
|
*/ |
48
|
|
|
public function getRow() |
49
|
|
|
{ |
50
|
|
|
if (null === $this->row) |
51
|
|
|
{ |
52
|
|
|
global $babDB; |
53
|
|
|
$res = $babDB->db_query('SELECT * FROM absences_rgroup WHERE id='.$babDB->quote($this->id)); |
54
|
|
|
$this->setRow($babDB->db_fetch_assoc($res)); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $this->row; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Method used with bab_Sort |
63
|
|
|
*/ |
64
|
|
|
public function getSortKey() |
65
|
|
|
{ |
66
|
|
|
return $this->sortkey; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function setSortKey($i) |
70
|
|
|
{ |
71
|
|
|
global $babDB; |
72
|
|
|
$babDB->db_query('UPDATE absences_rgroup SET sortkey='.$babDB->quote($i).' WHERE id='.$babDB->quote($this->id)); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getSortLabel() |
76
|
|
|
{ |
77
|
|
|
return $this->name; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
public function getIconClassName() |
82
|
|
|
{ |
83
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
84
|
|
|
return Func_Icons::ACTIONS_ARROW_RIGHT_DOUBLE; |
85
|
|
|
} |
86
|
|
|
} |
Let’s take a look at an example:
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
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: