1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits of |
4
|
|
|
supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit |
6
|
|
|
authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, but |
9
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: Pedigree |
15
|
|
|
* |
16
|
|
|
* @package XoopsModules\Pedigree |
17
|
|
|
* @copyright Copyright (c) 2001-2019 {@link https://xoops.org XOOPS Project} |
18
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
19
|
|
|
* @author XOOPS Module Development Team |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
use Xmf\Request; |
23
|
|
|
use XoopsModules\Pedigree; |
24
|
|
|
use XoopsModules\Pedigree\Constants; |
25
|
|
|
|
26
|
|
|
require_once __DIR__ . '/header.php'; |
27
|
|
|
|
28
|
|
|
/** @var XoopsModules\Pedigree\Helper $helper */ |
29
|
|
|
$helper->loadLanguage('main'); |
30
|
|
|
|
31
|
|
|
//check for access - only allow registered users |
32
|
|
|
if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
33
|
|
|
redirect_header('javascript:history.go(-1)', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_delete.tpl'; |
37
|
|
|
require XOOPS_ROOT_PATH . '/header.php'; |
38
|
|
|
|
39
|
|
|
$id = Request::getInt('id', 0, 'GET'); |
40
|
|
|
if (empty($id)) { |
41
|
|
|
//re-route user if we didn't get a valid id |
42
|
|
|
$helper->redirect('', Constants::REDIRECT_DELAY_MEDIUM, _MA_PEDIGREE_INVALID_ID); |
43
|
|
|
} |
44
|
|
|
//query - find values for this animal |
45
|
|
|
$treeHandler = $helper->getHandler('Tree'); |
46
|
|
|
$treeObj = $treeHandler->get($id); |
47
|
|
|
|
48
|
|
|
if ($treeObj instanceof Pedigree\Tree && !$treeObj->isNew()) { |
49
|
|
|
$pname = $treeObj->getVar('pname', 's'); |
50
|
|
|
//$namelink = "<a href=\"" . $helper->url("dog.php?id={$id}") . "\">{$pname}</a>"; |
51
|
|
|
|
52
|
|
|
//Create form |
53
|
|
|
require XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
54
|
|
|
$form = new \XoopsThemeForm($pname, 'deletedata', 'deletepage.php', 'post'); |
|
|
|
|
55
|
|
|
//hidden value current record owner |
56
|
|
|
$form->addElement(new \XoopsFormHidden('dbuser', $treeObj->getVar('user'))); |
57
|
|
|
//hidden value dog ID |
58
|
|
|
$form->addElement(new \XoopsFormHidden('dogid', $id)); |
59
|
|
|
$form->addElement(new \XoopsFormHidden('curname', $pname)); |
60
|
|
|
$form->addElement(new \XoopsFormHiddenToken('XOOPS_TOKEN_REQUEST', Constants::TOKEN_TIMEOUT)); |
61
|
|
|
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_DELE_SURE, _MA_PEDIGREE_DEL_MSG . $helper->getConfig('animalType') . " : <span style=\"font-weight: bold;\">{$pname}</span>?")); |
62
|
|
|
//@todo move pups() function to Tree class method |
63
|
|
|
$pups = pups($id, (int)$treeObj->getVar('roft')); |
64
|
|
|
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_DELE_WARN, _MA_PEDIGREE_ALL . $helper->getConfig('children') . _MA_PEDIGREE_ALL_ORPH . $pups)); |
65
|
|
|
$form->addElement(new \XoopsFormButton('', 'button_id', _DELETE, 'submit')); |
66
|
|
|
//add data (form) to smarty template |
67
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
68
|
|
|
} else { |
69
|
|
|
//redirect because this animal wasn't found |
70
|
|
|
$helper->redirect('', Constants::REDIRECT_DELAY_MEDIUM, _MA_PEDIGREE_INVALID_ID); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
//footer |
74
|
|
|
require XOOPS_ROOT_PATH . '/footer.php'; |
75
|
|
|
|