Passed
Push — master ( b847d6...d6d54c )
by Michael
09:34 queued 05:00
created

delete.php (1 issue)

Labels
Severity
1
<?php
2
// -------------------------------------------------------------------------
3
4
use XoopsModules\Pedigree;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Pedigree. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are 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.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
5
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
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_delete.tpl';
15
16
include XOOPS_ROOT_PATH . '/header.php';
17
18
//get module configuration
19
/** @var XoopsModuleHandler $moduleHandler */
20
$moduleHandler = xoops_getHandler('module');
21
$module        = $moduleHandler->getByDirname($moduleDirName);
22
$configHandler = xoops_getHandler('config');
23
$moduleConfig  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
24
25
//check for access
26
$xoopsModule = XoopsModule::getByDirname($moduleDirName);
27
if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)) {
28
    redirect_header('javascript:history.go(-1)', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST);
29
}
30
31
global $xoopsTpl;
32
global $xoopsDB;
33
global $xoopsModuleConfig;
34
35
$id = $_GET['id'];
36
//query (find values for this dog (and format them))
37
$queryString = 'SELECT naam, user, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' WHERE id=' . $id;
38
$result      = $GLOBALS['xoopsDB']->query($queryString);
39
40
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
41
    //ID
42
    $id = $row['id'];
43
    //name
44
    $naam     = htmlentities(stripslashes($row['naam']), ENT_QUOTES);
45
    $namelink = '<a href="dog.php?id=' . $row['id'] . '">' . stripslashes($row['naam']) . '</a>';
46
    //user who entered the info
47
    $dbuser = $row['user'];
48
    $roft   = $row['roft'];
49
}
50
51
//create form
52
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
53
$form = new \XoopsThemeForm($naam, 'deletedata', 'deletepage.php', 'post', true);
54
//hidden value current record owner
55
$form->addElement(new \XoopsFormHidden('dbuser', $dbuser));
56
//hidden value dog ID
57
$form->addElement(new \XoopsFormHidden('dogid', $_GET['id']));
58
$form->addElement(new \XoopsFormHidden('curname', $naam));
59
$form->addElement(new \XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360));
60
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_DELE_SURE, _MA_PEDIGREE_DEL_MSG . $moduleConfig['animalType'] . ' : <b>' . $naam . '</b>?'));
61
$pups = pups($_GET['id'], $roft);
62
$form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_DELE_WARN, _MA_PEDIGREE_ALL . $moduleConfig['children'] . _MA_PEDIGREE_ALL_ORPH . $pups));
63
$form->addElement(new \XoopsFormButton('', 'button_id', _DELETE, 'submit'));
64
//add data (form) to smarty template
65
$xoopsTpl->assign('form', $form->render());
66
67
//footer
68
include XOOPS_ROOT_PATH . '/footer.php';
69