1 | <?php |
||
2 | // ------------------------------------------------------------------------- |
||
3 | |||
4 | use Xmf\Request; |
||
5 | use XoopsModules\Pedigree; |
||
6 | |||
7 | //require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
8 | require_once __DIR__ . '/header.php'; |
||
9 | $moduleDirName = basename(__DIR__); |
||
10 | xoops_loadLanguage('main', $moduleDirName); |
||
11 | // Include any common code for this module. |
||
12 | require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
||
13 | |||
14 | // Get all HTTP post or get parameters into global variables that are prefixed with "param_" |
||
15 | //import_request_variables("gp", "param_"); |
||
16 | extract($_GET, EXTR_PREFIX_ALL, 'param'); |
||
17 | extract($_POST, EXTR_PREFIX_ALL, 'param'); |
||
18 | |||
19 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_dog.tpl'; |
||
20 | include XOOPS_ROOT_PATH . '/header.php'; |
||
21 | |||
22 | global $xoopsUser, $xoopsTpl, $xoopsDB, $xoopsModuleConfig, $xoopsModule; |
||
23 | global $numofcolumns, $numMatch, $pages, $columns, $dogs; |
||
24 | |||
25 | $pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); |
||
26 | |||
27 | xoops_load('XoopsUserUtility'); |
||
28 | |||
29 | //get module configuration |
||
30 | /** @var XoopsModuleHandler $moduleHandler */ |
||
31 | $moduleHandler = xoops_getHandler('module'); |
||
32 | $module = $moduleHandler->getByDirname($moduleDirName); |
||
33 | $configHandler = xoops_getHandler('config'); |
||
34 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
35 | |||
36 | $myts = \MyTextSanitizer::getInstance(); |
||
37 | |||
38 | if (isset($_GET['id'])) { |
||
39 | $id = Request::getInt('id', 0, 'GET'); |
||
40 | } else { |
||
41 | echo 'No dog has been selected'; |
||
42 | die(); |
||
43 | } |
||
44 | |||
45 | if (isset($_GET['delpicture']) && 'true' === $_GET['delpicture']) { |
||
46 | $delpicsql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " SET foto = '' WHERE id = '" . $id . "'"; |
||
47 | $GLOBALS['xoopsDB']->query($delpicsql); |
||
48 | } |
||
49 | //query |
||
50 | $queryString = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE id=' . $id; |
||
51 | $result = $GLOBALS['xoopsDB']->query($queryString); |
||
52 | |||
53 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
54 | //name |
||
55 | $naam = stripslashes($row['naam']); |
||
56 | $xoopsTpl->assign('xoops_pagetitle', $naam . ' -- detailed information'); |
||
57 | //owner |
||
58 | if ('0' != $row['id_owner']) { |
||
59 | $queryeig = 'SELECT id, lastname, firstname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE id=' . $row['id_owner']; |
||
60 | $reseig = $GLOBALS['xoopsDB']->query($queryeig); |
||
61 | while (false !== ($roweig = $GLOBALS['xoopsDB']->fetchArray($reseig))) { |
||
62 | $eig = '<a href="owner.php?ownid=' . $roweig['id'] . '">' . $roweig['firstname'] . ' ' . $roweig['lastname'] . '</a>'; |
||
63 | } |
||
64 | } else { |
||
65 | $eig = '<a href="update.php?id=' . $row['id'] . '&fld=ow">' . _MA_PEDIGREE_UNKNOWN . '</a>'; |
||
66 | } |
||
67 | //breeder |
||
68 | if ('0' != $row['id_breeder']) { |
||
69 | $queryfok = 'SELECT id, lastname, firstname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE id=' . $row['id_breeder']; |
||
70 | $resfok = $GLOBALS['xoopsDB']->query($queryfok); |
||
71 | while (false !== ($rowfok = $GLOBALS['xoopsDB']->fetchArray($resfok))) { |
||
72 | $fok = '<a href="owner.php?ownid=' . $rowfok['id'] . '">' . $rowfok['firstname'] . ' ' . $rowfok['lastname'] . '</a>'; |
||
73 | } |
||
74 | } else { |
||
75 | $fok = '<a href="update.php?id=' . $row['id'] . '&fld=br">' . _MA_PEDIGREE_UNKNOWN . '</a>'; |
||
76 | } |
||
77 | //gender |
||
78 | if (0 == $row['roft']) { |
||
79 | $gender = '<img src="assets/images/male.gif"> ' . strtr(_MA_PEDIGREE_FLD_MALE, ['[male]' => $moduleConfig['male']]); |
||
80 | } else { |
||
81 | $gender = '<img src="assets/images/female.gif"> ' . strtr(_MA_PEDIGREE_FLD_FEMA, ['[female]' => $moduleConfig['female']]); |
||
82 | } |
||
83 | //Sire |
||
84 | if (0 != $row['father']) { |
||
85 | $querysire = 'SELECT naam FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE id=' . $row['father']; |
||
86 | $ressire = $GLOBALS['xoopsDB']->query($querysire); |
||
87 | while (false !== ($rowsire = $GLOBALS['xoopsDB']->fetchArray($ressire))) { |
||
88 | $sire = '<img src="assets/images/male.gif"><a href="dog.php?id=' . $row['father'] . '">' . stripslashes($rowsire['naam']) . '</a>'; |
||
89 | } |
||
90 | } else { |
||
91 | $sire = '<img src="assets/images/male.gif"><a href="seldog.php?curval=' . $row['id'] . '&gend=0&letter=A">' . _MA_PEDIGREE_UNKNOWN . '</a>'; |
||
92 | } |
||
93 | //Dam |
||
94 | if (0 != $row['mother']) { |
||
95 | $querydam = 'SELECT naam FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE id=' . $row['mother']; |
||
96 | $resdam = $GLOBALS['xoopsDB']->query($querydam); |
||
97 | while (false !== ($rowdam = $GLOBALS['xoopsDB']->fetchArray($resdam))) { |
||
98 | $dam = '<img src="assets/images/female.gif"><a href="dog.php?id=' . $row['mother'] . '">' . stripslashes($rowdam['naam']) . '</a>'; |
||
99 | } |
||
100 | } else { |
||
101 | $dam = '<img src="assets/images/female.gif"><a href="seldog.php?curval=' . $row['id'] . '&gend=1&letter=A">' . _MA_PEDIGREE_UNKNOWN . '</a>'; |
||
102 | } |
||
103 | //picture |
||
104 | if ('' != $row['foto']) { |
||
105 | $picture = '<img src=' . PEDIGREE_UPLOAD_URL . '/images/thumbnails/' . $row['foto'] . '_400.jpeg>'; |
||
0 ignored issues
–
show
|
|||
106 | } else { |
||
107 | $picture = '<a href="update.php?id=' . $row['id'] . '&fld=pc">' . _MA_PEDIGREE_UNKNOWN . '</a>'; |
||
108 | } |
||
109 | //inbred precentage |
||
110 | if ('' == $row['coi']) { |
||
111 | if (0 != $row['father'] && 0 != $row['mother']) { |
||
112 | $inbred = '<a href="coi.php?s=' . $row['father'] . '&d=' . $row['mother'] . '&dogid=' . $row['id'] . '&detail=1">' . strtr(_MA_PEDIGREE_COI_WAIT, ['[animalType]' => $moduleConfig['animalType']]) . '</a>'; |
||
113 | } else { |
||
114 | $inbred = _MA_PEDIGREE_COI_MORE; |
||
115 | } |
||
116 | } else { |
||
117 | $inbred = '<a href="coi.php?s=' . $row['father'] . '&d=' . $row['mother'] . '&dogid=' . $row['id'] . '&detail=1" title="' . strtr(_MA_PEDIGREE_COI_WAIT, ['[animalType]' => $moduleConfig['animalType']]) . '">' . $row['coi'] . ' %</a>'; |
||
118 | } |
||
119 | //brothers and sisters |
||
120 | $bas = Pedigree\Utility::bas($id, $row['father'], $row['mother']); |
||
0 ignored issues
–
show
Are you sure the assignment to
$bas is correct as XoopsModules\Pedigree\Ut...ther'], $row['mother']) targeting XoopsModules\Pedigree\Utility::bas() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
121 | //pups |
||
122 | if ('1' == $moduleConfig['pups']) { |
||
123 | $pups = Pedigree\Utility::pups($id, $row['roft']); |
||
0 ignored issues
–
show
Are you sure the assignment to
$pups is correct as XoopsModules\Pedigree\Ut...pups($id, $row['roft']) targeting XoopsModules\Pedigree\Utility::pups() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
124 | } |
||
125 | //check for edit rights |
||
126 | $access = 0; |
||
127 | $xoopsModule = XoopsModule::getByDirname($moduleDirName); |
||
128 | if (!empty($xoopsUser)) { |
||
129 | if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
||
130 | $access = 1; |
||
131 | } |
||
132 | if ($row['user'] == $xoopsUser->getVar('uid')) { |
||
133 | $access = 1; |
||
134 | } |
||
135 | } |
||
136 | |||
137 | //name |
||
138 | $items[] = [ |
||
139 | 'header' => _MA_PEDIGREE_FLD_NAME, |
||
140 | 'data' => '<a href="pedigree.php?pedid=' . $row['id'] . '">' . $naam . '</a> (click to view pedigree)', |
||
141 | 'edit' => '<a href="update.php?id=' . $row['id'] . "&fld=nm\"><img src=' " . $pathIcon16 . "/edit.png' border='0' alt=_EDIT title=_EDIT></a>" |
||
142 | ]; |
||
143 | if ('1' == $moduleConfig['ownerbreeder']) { |
||
144 | //owner |
||
145 | $items[] = [ |
||
146 | 'header' => _MA_PEDIGREE_FLD_OWNE, |
||
147 | 'data' => $eig, |
||
148 | 'edit' => '<a href="update.php?id=' . $row['id'] . "&fld=ow\"><img src=' " . $pathIcon16 . "/edit.png' border='0' alt=_EDIT title=_EDIT></a>" |
||
149 | ]; |
||
150 | //breeder |
||
151 | $items[] = [ |
||
152 | 'header' => _MA_PEDIGREE_FLD_BREE, |
||
153 | 'data' => $fok, |
||
154 | 'edit' => '<a href="update.php?id=' . $row['id'] . "&fld=br\"><img src=' " . $pathIcon16 . "/edit.png' border='0' alt=_EDIT title=_EDIT></a>" |
||
155 | ]; |
||
156 | } |
||
157 | //gender |
||
158 | $items[] = [ |
||
159 | 'header' => _MA_PEDIGREE_FLD_GEND, |
||
160 | 'data' => $gender, |
||
161 | 'edit' => '<a href="update.php?id=' . $row['id'] . "&fld=sx\"><img src=' " . $pathIcon16 . "/edit.png' border='0' alt=_EDIT title=_EDIT></a>" |
||
162 | ]; |
||
163 | //sire |
||
164 | $items[] = [ |
||
165 | 'header' => strtr(_MA_PEDIGREE_FLD_FATH, ['[father]' => $moduleConfig['father']]), |
||
166 | 'data' => $sire, |
||
167 | 'edit' => '<a href="seldog.php?curval=' . $row['id'] . "&gend=0&letter=A\"><img src=' " . $pathIcon16 . "/edit.png' border='0' alt=_EDIT title=_EDIT></a>" |
||
168 | ]; |
||
169 | //dam |
||
170 | $items[] = [ |
||
171 | 'header' => strtr(_MA_PEDIGREE_FLD_MOTH, ['[mother]' => $moduleConfig['mother']]), |
||
172 | 'data' => $dam, |
||
173 | 'edit' => '<a href="seldog.php?curval=' . $row['id'] . "&gend=1&letter=A\"><img src=' " . $pathIcon16 . "/edit.png' border='0' alt=_EDIT title=_EDIT></a>" |
||
174 | ]; |
||
175 | //picture |
||
176 | $items[] = [ |
||
177 | 'header' => _MA_PEDIGREE_FLD_PICT, |
||
178 | 'data' => $picture, |
||
179 | 'edit' => '<a href="update.php?id=' . $row['id'] . "&fld=pc\"><img src=' " . $pathIcon16 . "/edit.png' border='0' alt=_EDIT title=_EDIT></a><a href=\"dog.php?id=" . $row['id'] . "&delpicture=true\"><img src=' " . $pathIcon16 . "/delete.png' border='0' alt=_DELETE title=_DELETE></a>" |
||
180 | ]; |
||
181 | |||
182 | //userdefined fields |
||
183 | |||
184 | $a = Request::getInt('id', 1, 'GET'); |
||
185 | $animal = new Pedigree\Animal($a); |
||
186 | |||
187 | //test to find out how many user fields there are.. |
||
188 | $fields = $animal->getNumOfFields(); |
||
189 | //create userfields and populate them |
||
190 | foreach ($fields as $i => $iValue) { |
||
191 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||
192 | if ($userField->isActive()) { |
||
193 | $fieldType = $userField->getSetting('FieldType'); |
||
194 | $fieldObject = new $fieldType($userField, $animal); |
||
195 | if ($userField->isLocked()) { |
||
196 | $items[] = [ |
||
197 | 'header' => $userField->getSetting('FieldName'), |
||
198 | 'data' => $fieldObject->showValue(), |
||
199 | 'edit' => '' |
||
200 | ]; |
||
201 | } else { |
||
202 | $items[] = [ |
||
203 | 'header' => $userField->getSetting('FieldName'), |
||
204 | 'data' => $fieldObject->showValue(), |
||
205 | 'edit' => '<a href="update.php?id=' . $row['id'] . '&fld=' . $iValue . "\"><img src=' " . $pathIcon16 . "/edit.png' border='0' alt=_EDIT title=_EDIT></a>" |
||
206 | ]; |
||
207 | } |
||
208 | } |
||
209 | unset($fieldObject, $userField); |
||
210 | } |
||
211 | |||
212 | if ('1' == $moduleConfig['proversion']) { |
||
213 | //inbred percentage |
||
214 | $items[] = [ |
||
215 | 'header' => _MA_PEDIGREE_FLD_INBR, |
||
216 | 'data' => $inbred, |
||
217 | 'edit' => '' |
||
218 | ]; |
||
219 | } |
||
220 | if ('1' == $moduleConfig['pups']) { |
||
221 | //pups |
||
222 | if ('0' == $numMatch) { |
||
223 | $pups = ''; |
||
224 | } else { |
||
225 | $pups = 'pups'; |
||
226 | } |
||
227 | $items[] = [ |
||
228 | 'header' => $moduleConfig['children'], |
||
229 | 'data' => $pups, |
||
230 | 'edit' => '' |
||
231 | ]; |
||
232 | } |
||
233 | if ('1' == $moduleConfig['brothers']) { |
||
234 | //bas (brothers and sisters) |
||
235 | if ('0' == $nummatch1) { |
||
236 | $bas = ''; |
||
237 | } else { |
||
238 | $bas = 'bas'; |
||
239 | } |
||
240 | $items[] = [ |
||
241 | 'header' => _MA_PEDIGREE_FLD_BAS, |
||
242 | 'data' => $bas, |
||
243 | 'edit' => '' |
||
244 | ]; |
||
245 | } |
||
246 | //database user |
||
247 | if ('1' == $moduleConfig['proversion']) { |
||
248 | $items[] = [ |
||
249 | 'header' => _MA_PEDIGREE_FLD_DBUS, |
||
250 | 'data' => \XoopsUserUtility::getUnameFromId($row['user']), |
||
251 | 'edit' => '' |
||
252 | ]; |
||
253 | } |
||
254 | //inbred pedigree |
||
255 | if ('1' == $moduleConfig['proversion']) { |
||
256 | $items[] = [ |
||
257 | 'header' => 'Inbred Pedigree', |
||
258 | 'data' => '<a href="mpedigree.php?pedid=' . $row['id'] . '">Inbreeding pedigree</a>', |
||
259 | 'edit' => '' |
||
260 | ]; |
||
261 | } |
||
262 | $id = $row['id']; |
||
263 | } |
||
264 | |||
265 | //add data to smarty template |
||
266 | //assign dog |
||
267 | //pups |
||
268 | $xoopsTpl->assign('dogs', $dogs); |
||
269 | $xoopsTpl->assign('columns', $columns); |
||
270 | $xoopsTpl->assign('numofcolumns', $numofcolumns); |
||
271 | $xoopsTpl->assign('nummatch', $numMatch . ' Animals found.'); |
||
272 | |||
273 | //bas |
||
274 | $xoopsTpl->assign('dogs1', $dogs1); |
||
275 | $xoopsTpl->assign('columns1', $columns1); |
||
276 | $xoopsTpl->assign('numofcolumns1', $numofcolumns1); |
||
277 | $xoopsTpl->assign('nummatch1', $nummatch1 . ' Animals found.'); |
||
278 | |||
279 | //both pups and bas |
||
280 | $xoopsTpl->assign('width', 100 / $numofcolumns); |
||
281 | $xoopsTpl->assign('tsarray', Pedigree\Utility::sortTable($numofcolumns)); |
||
282 | |||
283 | $xoopsTpl->assign('access', $access); |
||
284 | $xoopsTpl->assign('items', $items); |
||
285 | $xoopsTpl->assign('name', $naam); |
||
286 | $xoopsTpl->assign('id', $id); |
||
287 | $xoopsTpl->assign('sdvins', _MA_PEDIGREE_SDVINS); |
||
288 | $xoopsTpl->assign('vpo', _MA_PEDIGREE_VPO); |
||
289 | $xoopsTpl->assign('vpo2', _MA_PEDIGREE_VPO2); |
||
290 | $xoopsTpl->assign('sii', _MA_PEDIGREE_SII); |
||
291 | $xoopsTpl->assign('sip', _MA_PEDIGREE_SIP); |
||
292 | $xoopsTpl->assign('id', $id); |
||
293 | $xoopsTpl->assign('delete', _DELETE); |
||
294 | |||
295 | //comments and footer |
||
296 | include XOOPS_ROOT_PATH . '/include/comment_view.php'; |
||
297 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
298 |