|
1
|
|
|
<?php |
|
2
|
|
|
// ------------------------------------------------------------------------- |
|
3
|
|
|
|
|
4
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
5
|
|
|
use XoopsModules\Pedigree\{ |
|
6
|
|
|
Utility |
|
7
|
|
|
}; |
|
8
|
|
|
|
|
9
|
|
|
//require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
|
10
|
|
|
require_once __DIR__ . '/header.php'; |
|
11
|
|
|
$moduleDirName = basename(__DIR__); |
|
12
|
|
|
xoops_loadLanguage('main', $moduleDirName); |
|
13
|
|
|
// Include any common code for this module. |
|
14
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
|
15
|
|
|
|
|
16
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_delete.tpl'; |
|
17
|
|
|
|
|
18
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
|
19
|
|
|
|
|
20
|
|
|
//get module configuration |
|
21
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
22
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
23
|
|
|
$module = $moduleHandler->getByDirname($moduleDirName); |
|
24
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
|
25
|
|
|
$configHandler = xoops_getHandler('config'); |
|
26
|
|
|
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
27
|
|
|
|
|
28
|
|
|
//check for access |
|
29
|
|
|
$xoopsModule = XoopsModule::getByDirname($moduleDirName); |
|
30
|
|
|
if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
|
31
|
|
|
redirect_header('<script>javascript:history.go(-1)</script>', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
global $xoopsTpl; |
|
35
|
|
|
global $xoopsDB; |
|
36
|
|
|
global $xoopsModuleConfig; |
|
37
|
|
|
|
|
38
|
|
|
$id = Request::getInt('id', 0, 'GET'); |
|
39
|
|
|
//query (find values for this dog (and format them)) |
|
40
|
|
|
$sql = 'SELECT lastname, firstname, user FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE id=' . $id; |
|
41
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
|
42
|
|
|
|
|
43
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
44
|
|
|
//ID |
|
45
|
|
|
$id = $row['id']; |
|
46
|
|
|
//name |
|
47
|
|
|
$pname = htmlentities(stripslashes($row['lastname']) . ', ' . stripslashes($row['firstname']), ENT_QUOTES); |
|
48
|
|
|
$namelink = '<a href="owner.php?ownid=' . $row['id'] . '">' . stripslashes($row['lastname']) . ', ' . stripslashes($row['firstname']) . '</a>'; |
|
49
|
|
|
//user who entered the info |
|
50
|
|
|
$dbuser = $row['user']; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
//create form |
|
54
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
55
|
|
|
$form = new \XoopsThemeForm($pname, 'deletedata', 'deletebreederpage.php', 'post', true); |
|
56
|
|
|
//hidden value current record owner |
|
57
|
|
|
$form->addElement(new \XoopsFormHidden('dbuser', $dbuser)); |
|
58
|
|
|
//hidden value dog ID |
|
59
|
|
|
$form->addElement(new \XoopsFormHidden('dogid', $_GET['id'])); |
|
60
|
|
|
$form->addElement(new \XoopsFormHidden('curname', $pname)); |
|
61
|
|
|
$form->addElement(new \XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); |
|
62
|
|
|
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_DELE_SURE, _MA_PEDIGREE_DELE_CONF_OWN . '<b>' . $pname . '</b>?')); |
|
63
|
|
|
$breeder = Utility::breederof($_GET['id'], 1); |
|
64
|
|
|
if ('' != $breeder) { |
|
65
|
|
|
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_DELE_WARN, strtr(_MA_PEDIGREE_DELE_WARN_BREEDER, ['[animalTypes]' => $helper->getConfig('animalTypes')]) . '<br><br>' . $breeder)); |
|
66
|
|
|
} |
|
67
|
|
|
$owner = Utility::breederof($_GET['id'], 0); |
|
68
|
|
|
if ('' != $owner) { |
|
69
|
|
|
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_DELE_WARN, strtr(_MA_PEDIGREE_DELE_WARN_OWNER, ['[animalTypes]' => $helper->getConfig('animalTypes')]) . '<br><br>' . $owner)); |
|
70
|
|
|
} |
|
71
|
|
|
$form->addElement(new \XoopsFormButton('', 'button_id', _DELETE, 'submit')); |
|
72
|
|
|
//add data (form) to smarty template |
|
73
|
|
|
$xoopsTpl->assign('form', $form->render()); |
|
74
|
|
|
|
|
75
|
|
|
//footer |
|
76
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
77
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: