From: <be...@us...> - 2015-02-18 18:43:52
|
Revision: 13000 http://sourceforge.net/p/xoops/svn/13000 Author: beckmi Date: 2015-02-18 18:43:38 +0000 (Wed, 18 Feb 2015) Log Message: ----------- 1 31_ALPHA6_zyspec Modified Paths: -------------- XoopsModules/pedigree/branches/zyspec/pedigree/add_breeder.php XoopsModules/pedigree/branches/zyspec/pedigree/add_dog.php XoopsModules/pedigree/branches/zyspec/pedigree/add_litter.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/about.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/admin_footer.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/admin_header.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/config.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/index.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/main.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/owner.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/pedigree.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/pedigree_config.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/pedigree_temp.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/pedigree_trash.php XoopsModules/pedigree/branches/zyspec/pedigree/admin/permissions.php XoopsModules/pedigree/branches/zyspec/pedigree/advanced.php XoopsModules/pedigree/branches/zyspec/pedigree/blocks/menu_block.php XoopsModules/pedigree/branches/zyspec/pedigree/book.php XoopsModules/pedigree/branches/zyspec/pedigree/breeder.php XoopsModules/pedigree/branches/zyspec/pedigree/class/breadcrumb.php XoopsModules/pedigree/branches/zyspec/pedigree/class/fields.php XoopsModules/pedigree/branches/zyspec/pedigree/class/owner.php XoopsModules/pedigree/branches/zyspec/pedigree/class/pedigree.php XoopsModules/pedigree/branches/zyspec/pedigree/class/pedigreeUtilities.php XoopsModules/pedigree/branches/zyspec/pedigree/class/temp.php XoopsModules/pedigree/branches/zyspec/pedigree/class/trash.php XoopsModules/pedigree/branches/zyspec/pedigree/class/tree.php XoopsModules/pedigree/branches/zyspec/pedigree/coi.php XoopsModules/pedigree/branches/zyspec/pedigree/comment_delete.php XoopsModules/pedigree/branches/zyspec/pedigree/comment_edit.php XoopsModules/pedigree/branches/zyspec/pedigree/comment_new.php XoopsModules/pedigree/branches/zyspec/pedigree/comment_post.php XoopsModules/pedigree/branches/zyspec/pedigree/comment_reply.php XoopsModules/pedigree/branches/zyspec/pedigree/convert.php XoopsModules/pedigree/branches/zyspec/pedigree/delete.php XoopsModules/pedigree/branches/zyspec/pedigree/deletebreeder.php XoopsModules/pedigree/branches/zyspec/pedigree/deletebreederpage.php XoopsModules/pedigree/branches/zyspec/pedigree/deletepage.php XoopsModules/pedigree/branches/zyspec/pedigree/docs/changelog.txt XoopsModules/pedigree/branches/zyspec/pedigree/dog.php XoopsModules/pedigree/branches/zyspec/pedigree/edit.php XoopsModules/pedigree/branches/zyspec/pedigree/footer.php XoopsModules/pedigree/branches/zyspec/pedigree/header.php XoopsModules/pedigree/branches/zyspec/pedigree/imagemanager.php XoopsModules/pedigree/branches/zyspec/pedigree/include/class_field.php XoopsModules/pedigree/branches/zyspec/pedigree/include/common.php XoopsModules/pedigree/branches/zyspec/pedigree/include/config.php XoopsModules/pedigree/branches/zyspec/pedigree/include/functions.php XoopsModules/pedigree/branches/zyspec/pedigree/include/install_function.php XoopsModules/pedigree/branches/zyspec/pedigree/include/notification.inc.php XoopsModules/pedigree/branches/zyspec/pedigree/include/update_function.php XoopsModules/pedigree/branches/zyspec/pedigree/include/waiting.plugin.php XoopsModules/pedigree/branches/zyspec/pedigree/index.php XoopsModules/pedigree/branches/zyspec/pedigree/language/english/main.php XoopsModules/pedigree/branches/zyspec/pedigree/latest.php XoopsModules/pedigree/branches/zyspec/pedigree/members.php XoopsModules/pedigree/branches/zyspec/pedigree/menu_block.php XoopsModules/pedigree/branches/zyspec/pedigree/mpedigree.php XoopsModules/pedigree/branches/zyspec/pedigree/notification_update.php XoopsModules/pedigree/branches/zyspec/pedigree/owner.php XoopsModules/pedigree/branches/zyspec/pedigree/pedigree.php XoopsModules/pedigree/branches/zyspec/pedigree/print.php XoopsModules/pedigree/branches/zyspec/pedigree/result.php XoopsModules/pedigree/branches/zyspec/pedigree/seldog.php XoopsModules/pedigree/branches/zyspec/pedigree/templates/pedigree_result.tpl XoopsModules/pedigree/branches/zyspec/pedigree/templates/pedigree_sel.tpl XoopsModules/pedigree/branches/zyspec/pedigree/tools.php XoopsModules/pedigree/branches/zyspec/pedigree/topstud.php XoopsModules/pedigree/branches/zyspec/pedigree/update.php XoopsModules/pedigree/branches/zyspec/pedigree/updateowner.php XoopsModules/pedigree/branches/zyspec/pedigree/updatepage.php XoopsModules/pedigree/branches/zyspec/pedigree/virtual.php XoopsModules/pedigree/branches/zyspec/pedigree/welcome.php XoopsModules/pedigree/branches/zyspec/pedigree/xoops_version.php Added Paths: ----------- XoopsModules/pedigree/branches/zyspec/pedigree/class/animal.php XoopsModules/pedigree/branches/zyspec/pedigree/class/htmlinput.abstract.php XoopsModules/pedigree/branches/zyspec/pedigree/class/radiobutton.php XoopsModules/pedigree/branches/zyspec/pedigree/class/selectbox.php Modified: XoopsModules/pedigree/branches/zyspec/pedigree/add_breeder.php =================================================================== --- XoopsModules/pedigree/branches/zyspec/pedigree/add_breeder.php 2015-02-18 18:40:33 UTC (rev 12999) +++ XoopsModules/pedigree/branches/zyspec/pedigree/add_breeder.php 2015-02-18 18:43:38 UTC (rev 13000) @@ -1,88 +1,104 @@ <?php -// ------------------------------------------------------------------------- +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ +/** + * pedigree module for XOOPS + * + * @todo: move hard coded language strings to language files + * + * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package pedigree + * @author XOOPS Module Dev Team + * @version $Id: $ + */ + require_once dirname(dirname(__DIR__)) . '/mainfile.php'; -/* -if (file_exists(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php")) { - require_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php"; -} else { - include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/english/main.php"; -} -*/ - xoops_loadLanguage('main', basename(dirname(__DIR__))); // Include any common code for this module. -require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php"); +xoops_load('XoopsRequest'); +require_once $GLOBALS['xoops']->path("/modules/" . $xoopsModule->dirname() . "/include/functions.php"); $xoopsOption['template_main'] = "pedigree_adddog.tpl"; -include XOOPS_ROOT_PATH . '/header.php'; -$xoopsTpl->assign('page_title', "Pedigree database - Add owner/breeder"); +include $GLOBALS['xoops']->path('/header.php'); +//@todo: move hard coded language string to language file +$GLOBALS['xoopsTpl']->assign('page_title', "Pedigree database - Add owner/breeder"); //check for access -$xoopsModule =& XoopsModule::getByDirname("pedigree"); -if (empty($xoopsUser)) { +if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof XoopsUser)) { redirect_header("index.php", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } -$f = isset($_GET['f']) ? $_GET['f'] : ''; -if ($f == "check") { - check(); -} +$op = XoopsRequest::getCmd('op', '', 'POST'); +if ('check' == $op) { + // check XoopsSecurityToken + if (!$GLOBALS["xoopsSecurity"]->check()) { + redirect_header("index.php", 3, implode(",", $GLOBALS["xoopsSecurity"]->getErrors())); + } -function check() -{ - global $xoopsTpl, $xoopsUser, $xoopsDB, $xoopsModuleConfig; - //check for access - $xoopsModule =& XoopsModule::getByDirname("pedigree"); - if (empty($xoopsUser)) { - redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); - exit(); - } + $achternaam = XoopsRequest::getString('achternaam', '', 'POST'); + $voornaam = XoopsRequest::getString('voornaam', '', 'POST'); + $email = XoopsRequest::getString('email', '', 'POST'); + $website = XoopsRequest::getString('website', '', 'POST'); + $user = XoopsRequest::getString('user', '', 'POST'); + + $ownerHandler =& xoops_getmodulehandler('owner', 'pedigree'); + $ownerObj = $ownerHandler->create(); + $ownerObj->setVar('firstname', $achternaam); + $ownerObj->setVar('lastname', $voornaam); + $ownerObj->setVar('emailadres', $email); + $ownerObj->setVar('website', $website); + $ownerObj->setVar('user', $user); + $ownerHandler->insert($ownerObj); +/* $achternaam = $_POST['achternaam']; $voornaam = $_POST['voornaam']; $email = $_POST['email']; $website = $_POST['website']; $user = $_POST['user']; //insert into owner - $query = "INSERT INTO " . $xoopsDB->prefix("pedigree_owner") . " VALUES ('','" . $voornaam . "','" . $achternaam . "','','','','','','" . $email . "','" . $website . "','" . $user . "')"; - $xoopsDB->query($query); - redirect_header("index.php", 1, "The data has been stored."); -} + $query = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix("pedigree_owner") . " VALUES ('','" . $voornaam . "','" . $achternaam . "','','','','','','" . $email . "','" . $website . "','" . $user . "')"; + $GLOBALS['xoopsDB']->query($query); +*/ + //@todo: move hard coded language string to language file + redirect_header("index.php", 3, "The data has been stored."); +} else { + //create form + include $GLOBALS['xoops']->path("/class/xoopsformloader.php"); + $form = new XoopsThemeForm(_MA_PEDIGREE_ADD_OWNER, 'breedername', 'add_breeder.php', 'POST'); + $form->addElement(new XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); + $form->addElement(new XoopsFormHidden('op', 'check')); + $form->addElement(new XoopsFormHidden('user', $GLOBALS['xoopsUser']->getVar("uid"))); + //lastname + $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_LNAME . "</b>", 'achternaam', 50, 255, '')); -global $xoopsTpl, $xoopsUser, $xoopsDB; -//check for access -$xoopsModule =& XoopsModule::getByDirname("pedigree"); -if (empty($xoopsUser)) { - redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); - exit(); -} -//create form -include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; -$form = new XoopsThemeForm(_MA_PEDIGREE_ADD_OWNER, 'breedername', 'add_breeder.php?f=check', 'POST'); -$form->addElement(new XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); -$form->addElement(new XoopsFormHidden('user', $xoopsUser->getVar("uid"))); -//lastname -$form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_LNAME . "</b>", 'achternaam', $size = 50, $maxsize = 255, $value = '')); + //firstname + $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_FNAME . "</b>", 'voornaam', 50, 255, '')); -//firstname -$form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_FNAME . "</b>", 'voornaam', $size = 50, $maxsize = 255, $value = '')); + //email + $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_EMAIL . "</b>", 'email', 50, 255, '')); -//email -$form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_EMAIL . "</b>", 'email', $size = 50, $maxsize = 255, $value = '')); + //website + $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_WEB . "</b>", 'website', 50, 255, '')); + $form->addElement(new XoopsFormLabel("<b>" . _MA_PEDIGREE_EXPLAIN . "</b>", _MA_PEDIGREE_FLD_OWN_WEB_EX)); -//website -$form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_WEB . "</b>", 'website', $size = 50, $maxsize = 255, $value = '')); -$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, _MA_PEDIGREE_FLD_OWN_WEB_EX)); + //submit button + $form->addElement(new XoopsFormButton('', 'button_id', _MA_PEDIGREE_ADD_OWNER, 'submit')); -//submit button -$form->addElement(new XoopsFormButton('', 'button_id', _MA_PEDIGREE_ADD_OWNER, 'submit')); + //add data (form) to smarty template + $GLOBALS['xoopsTpl']->assign("form", $form->render()); -//add data (form) to smarty template -$xoopsTpl->assign("form", $form->render()); - -//footer -include XOOPS_ROOT_PATH . "/footer.php"; + //footer + include $GLOBALS['xoops']->path("/footer.php"); +} Modified: XoopsModules/pedigree/branches/zyspec/pedigree/add_dog.php =================================================================== --- XoopsModules/pedigree/branches/zyspec/pedigree/add_dog.php 2015-02-18 18:40:33 UTC (rev 12999) +++ XoopsModules/pedigree/branches/zyspec/pedigree/add_dog.php 2015-02-18 18:43:38 UTC (rev 13000) @@ -1,7 +1,25 @@ <?php -// ------------------------------------------------------------------------- +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ +/** + * animal module for xoops + * + * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package pedigree + * @author XOOPS Module Dev Team + * @version $Id: $ + */ + require_once dirname(dirname(__DIR__)) . '/mainfile.php'; +xoops_load('animal', 'pedigree'); /* if (file_exists(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php")) { @@ -12,24 +30,46 @@ */ xoops_loadLanguage('main', basename(dirname(__DIR__))); +xoops_load('XoopsRequest'); // Include any common code for this module. -require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php"); -require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/class_field.php"); +require_once $GLOBALS['xoops']->path("/modules/" . $xoopsModule->dirname() . "/include/functions.php"); +require_once $GLOBALS['xoops']->path("/modules/" . $xoopsModule->dirname() . "/include/class_field.php"); $xoopsOption['template_main'] = "pedigree_adddog.tpl"; -include XOOPS_ROOT_PATH . '/header.php'; -$xoopsTpl->assign('page_title', "Pedigree database - Update details"); +include $GLOBALS['xoops']->path('/header.php'); +/* @todo: move hard coded language string to language files */ +$GLOBALS['xoopsTpl']->assign('page_title', "Pedigree database - Update details"); //check for access -$xoopsModule =& XoopsModule::getByDirname("pedigree"); -if (empty($xoopsUser)) { +$GLOBALS['xoopsModule'] =& XoopsModule::getByDirname("pedigree"); +if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof XoopsUser)) { redirect_header("index.php", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } //create function variable from url +$f = XoopsRequest::getString('f', 'add', 'GET'); +switch ($f) { + case "add": + $f = ''; + adddog(); + break; + case "checkname": + checkname(); + break; + case "sire": + sire(); + break; + case "dam": + dam(); + break; + case "check": + check(); + break; +} +/* if (isset($_GET['f'])) { $f = $_GET['f']; } else { @@ -48,11 +88,10 @@ if ($f == "check") { check(); } +*/ function adddog() { - global $xoopsTpl, $xoopsUser, $xoopsDB; - //get module configuration $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname("pedigree"); @@ -60,23 +99,23 @@ $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); //check for access - if (empty($xoopsUser)) { + if (empty($GLOBALS['xoopsUser'])) { redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } - if ($xoopsUser->getVar("uid") == 0) { + if ($GLOBALS['xoopsUser']->getVar("uid") == 0) { redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } //create form - include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; + include $GLOBALS['xoops']->path("/class/xoopsformloader.php"); $form = new XoopsThemeForm(strtr(_MA_PEDIGREE_ADD_DOG, array('[animalType]' => $moduleConfig['animalType'])), 'dogname', 'add_dog.php?f=checkname', 'POST'); $form->addElement(new XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); //create random value $random = (rand() % 10000); $form->addElement(new XoopsFormHidden('random', $random)); //find userid - $form->addElement(new XoopsFormHidden('user', $xoopsUser->getVar("uid"))); + $form->addElement(new XoopsFormHidden('user', $GLOBALS['xoopsUser']->getVar("uid"))); //name $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_NAME . "</b>", 'NAAM', $size = 50, $maxsize = 255, $value = '')); @@ -87,15 +126,11 @@ $form->addElement(new XoopsFormButton('', 'button_id', strtr(_MA_PEDIGREE_ADD_DATA, array('[animalType]' => $moduleConfig['animalType'])), 'submit')); //add data (form) to smarty template - $xoopsTpl->assign("form", $form->render()); + $GLOBALS['xoopsTpl']->assign("form", $form->render()); } function checkname() - { - //configure global variables - global $xoopsTpl, $xoopsDB, $xoopsUser; - //get module configuration $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname("pedigree"); @@ -104,29 +139,43 @@ $name = $_POST['NAAM']; //query - $queryString = "SELECT * from " . $xoopsDB->prefix("pedigree_tree") . " WHERE NAAM LIKE'%" . $name . "%' ORDER BY NAAM"; - $result = $xoopsDB->query($queryString); - $numresults = $xoopsDB->getRowsNum($result); + $pTreeHandler =& xoops_getmodulehandler('tree', 'pedigree'); + $criteria = new CriteriaCompo(); + $criteria->add(new Criteria('NAAM', "%{$name}%", 'LIKE')); + $treeObjs = $pTreeHandler->getALL($criteria); + $numObjs = (is_array($treeObjs) && !empty($treeObjs)) ? count($treeObjs) : 0; +/* + $queryString = "SELECT * FROM " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE NAAM LIKE'%{$name}%' ORDER BY NAAM"; + $result = $GLOBALS['xoopsDB']->query($queryString); + $numresults = $GLOBALS['xoopsDB']->getRowsNum($result); if ($numresults >= 1 && !(isset($_GET['r']))) { +*/ + include $GLOBALS['xoops']->path("/class/xoopsformloader.php"); + if ($numObjs >= 1 && !(isset($_GET['r']))) { //create form - include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; $form = new XoopsThemeForm(strtr(_MA_PEDIGREE_ADD_DOG, array('[animalType]' => $moduleConfig['animalType'])), 'dogname', 'add_dog.php?f=checkname&r=1', 'POST'); //other elements $form->addElement(new XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); - $form->addElement(new XoopsFormHidden('NAAM', $_POST['NAAM'])); - $form->addElement(new XoopsFormHidden('user', $xoopsUser->getVar("uid"))); - while ($row = $xoopsDB->fetchArray($result)) { + $naam = XoopsRequest::getString('NAAM', '', 'POST'); + $form->addElement(new XoopsFormHidden('NAAM', $naam)); +// $form->addElement(new XoopsFormHidden('NAAM', $_POST['NAAM'])); + $form->addElement(new XoopsFormHidden('user', $GLOBALS['xoopsUser']->getVar("uid"))); + foreach($treeObjs as $treeObj) { + $form->addElement(new XoopsFormLabel("<b>" . _MA_PEDIGREE_FLD_NAME . "</b>", "<a href=\"dog.php?id=" . $treeObj->getVar('ID') . "\">" . $treeObj->getVar('NAAM', 's') . "</a>")); + } +/* + while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) { //name $form->addElement(new XoopsFormLabel("<b>" . _MA_PEDIGREE_FLD_NAME . "</b>", "<a href=\"dog.php?id=" . $row['ID'] . "\">" . stripslashes($row['NAAM']) . "</a>")); } +*/ $form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, strtr(_MA_PEDIGREE_ADD_KNOWN, array('[animalTypes]' => $moduleConfig['animalTypes'])))); //submit button $form->addElement(new XoopsFormButton('', 'button_id', strtr(_MA_PEDIGREE_ADD_KNOWNOK, array('[animalType]' => $moduleConfig['animalType'])), 'submit')); //add data (form) to smarty template - $xoopsTpl->assign("form", $form->render()); + $GLOBALS['xoopsTpl']->assign("form", $form->render()); } else { //create form - include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; $form = new XoopsThemeForm(strtr(_MA_PEDIGREE_ADD_DOG, array('[animalType]' => $moduleConfig['animalType'])), 'dogname', 'add_dog.php?f=sire', 'POST'); //added to handle upload $form->setExtra("enctype='multipart/form-data'"); @@ -146,13 +195,13 @@ array('0' => strtr(_MA_PEDIGREE_FLD_MALE, array('[male]' => $moduleConfig['male'])), '1' => strtr(_MA_PEDIGREE_FLD_FEMA, array('[female]' => $moduleConfig['female']))) ); $form->addElement($gender_radio); - if ($moduleConfig['ownerbreeder'] == '1') { + if (1 == $moduleConfig['ownerbreeder']) { //breeder $breeder_select = new XoopsFormSelect("<b>" . _MA_PEDIGREE_FLD_BREE . "</b>", $name = "id_breeder", $value = '0', $size = 1, $multiple = false); - $queryfok = "SELECT ID, lastname, firstname from " . $xoopsDB->prefix("pedigree_owner") . " ORDER BY lastname"; - $resfok = $xoopsDB->query($queryfok); + $queryfok = "SELECT ID, lastname, firstname from " . $GLOBALS['xoopsDB']->prefix("pedigree_owner") . " ORDER BY lastname"; + $resfok = $GLOBALS['xoopsDB']->query($queryfok); $breeder_select->addOption('0', $name = _MA_PEDIGREE_UNKNOWN, $disabled = false); - while ($rowfok = $xoopsDB->fetchArray($resfok)) { + while ($rowfok = $GLOBALS['xoopsDB']->fetchArray($resfok)) { $breeder_select->addOption($rowfok['ID'], $name = $rowfok['lastname'] . ", " . $rowfok['firstname'], $disabled = false); } $form->addElement($breeder_select); @@ -160,10 +209,10 @@ //owner $owner_select = new XoopsFormSelect("<b>" . _MA_PEDIGREE_FLD_OWNE . "</b>", $name = "id_owner", $value = '0', $size = 1, $multiple = false); - $queryfok = "SELECT ID, lastname, firstname from " . $xoopsDB->prefix("pedigree_owner") . " ORDER BY lastname"; - $resfok = $xoopsDB->query($queryfok); + $queryfok = "SELECT ID, lastname, firstname from " . $GLOBALS['xoopsDB']->prefix("pedigree_owner") . " ORDER BY lastname"; + $resfok = $GLOBALS['xoopsDB']->query($queryfok); $owner_select->addOption('0', $name = _MA_PEDIGREE_UNKNOWN, $disabled = false); - while ($rowfok = $xoopsDB->fetchArray($resfok)) { + while ($rowfok = $GLOBALS['xoopsDB']->fetchArray($resfok)) { $owner_select->addOption($rowfok['ID'], $name = $rowfok['lastname'] . ", " . $rowfok['firstname'], $disabled = false); } $form->addElement($owner_select); @@ -176,15 +225,15 @@ $form->addElement($img_box); //create animal object - $animal = new Animal(); + $animal = new PedigreeAnimal(); //test to find out how many user fields there are.. - $fields = $animal->numoffields(); + $fields = $animal->numOfFields(); for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); - if ($userfield->active() && !$userfield->isLocked()) { + if ($userfield->isActive() && !$userfield->isLocked()) { $newentry = $fieldobject->newField(); $form->addElement($newentry); } @@ -195,14 +244,12 @@ $form->addElement(new XoopsFormButton('', 'button_id', strtr(_MA_PEDIGREE_ADD_SIRE, array('[father]' => $moduleConfig['father'])), 'submit')); //add data (form) to smarty template - $xoopsTpl->assign("form", $form->render()); + $GLOBALS['xoopsTpl']->assign("form", $form->render()); } } function sire() { - global $xoopsTpl, $xoopsUser, $xoopsDB; - //get module configuration $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname("pedigree"); @@ -211,7 +258,7 @@ $empty = array(); // an empty array //check for access - if (empty($xoopsUser)) { + if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof XoopsUser)) { redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } @@ -248,16 +295,16 @@ redirect_header("add_dog.php", 1, _MA_PEDIGREE_ADD_NAMEPLZ); } //create animal object - $animal = new Animal(); + $animal = new PedigreeAnimal(); //test to find out how many user fields there are.. - $fields = $animal->numoffields(); + $fields = $animal->numOfFields(); sort($fields); //sort by ID not by order $usersql = ""; for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); - if ($userfield->active()) { + if ($userfield->isActive()) { //check if _FILES variable exists for user picturefield $currentfield = 'user' . $fields[$i]; $picturefield = $_FILES[$currentfield]['name']; @@ -281,10 +328,10 @@ //insert into pedigree_temp $query - = "INSERT INTO " . $xoopsDB->prefix("pedigree_temp") . " VALUES ('" . $random . "','" . unhtmlentities($name) . "','" . $id_owner . "','" . $id_breeder . "','" . $user . "','" . $roft + = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix("pedigree_temp") . " VALUES ('" . $random . "','" . unhtmlentities($name) . "','" . $id_owner . "','" . $id_breeder . "','" . $user . "','" . $roft . "','','','" . $foto . "', ''" . $usersql . ")"; //echo $query; die(); - $xoopsDB->query($query); + $GLOBALS['xoopsDB']->query($query); redirect_header("add_dog.php?f=sire&random=" . $random . "&st=" . $st . "&r=1&l=a", 1, strtr(_MA_PEDIGREE_ADD_SIREPLZ, array('[father]' => $moduleConfig['father']))); } //find letter on which to start else set to 'a' @@ -294,14 +341,14 @@ $l = "a"; } //assign sire to template - $xoopsTpl->assign("sire", "1"); + $GLOBALS['xoopsTpl']->assign("sire", "1"); //create list of males dog to select from $perp = $moduleConfig['perpage']; //count total number of dogs - $numdog = "SELECT count(ID) from " . $xoopsDB->prefix("pedigree_tree") . " WHERE roft='0' and NAAM LIKE '" . $l . "%'"; - $numres = $xoopsDB->query($numdog); + $numdog = "SELECT count(ID) from " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE roft='0' and NAAM LIKE '" . $l . "%'"; + $numres = $GLOBALS['xoopsDB']->query($numdog); //total number of dogs the query will find - list($numresults) = $xoopsDB->fetchRow($numres); + list($numresults) = $GLOBALS['xoopsDB']->fetchRow($numres); //total number of pages $numpages = (floor($numresults / $perp)) + 1; if (($numpages * $perp) == ($numresults + $perp)) { @@ -349,22 +396,22 @@ } //query - $queryString = "SELECT * from " . $xoopsDB->prefix("pedigree_tree") . " WHERE roft = '0' and NAAM like '" . $l . "%'ORDER BY NAAM LIMIT " . $st . ", " . $perp; - $result = $xoopsDB->query($queryString); + $queryString = "SELECT * from " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE roft = '0' and NAAM like '" . $l . "%'ORDER BY NAAM LIMIT " . $st . ", " . $perp; + $result = $GLOBALS['xoopsDB']->query($queryString); - $animal = new Animal(); + $animal = new PedigreeAnimal(); //test to find out how many user fields there are... - $fields = $animal->numoffields(); + $fields = $animal->numOfFields(); $numofcolumns = 1; $columns[] = array('columnname' => "Name"); for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); //create empty string $lookupvalues = ""; - if ($userfield->active() && $userfield->inlist()) { - if ($userfield->haslookup()) { + if ($userfield->isActive() && $userfield->inList()) { + if ($userfield->hasLookup()) { $lookupvalues = $userfield->lookup($fields[$i]); //debug information //print_r($lookupvalues); @@ -388,7 +435,7 @@ 'usercolumns' => $empty ); - while ($row = $xoopsDB->fetchArray($result)) { + while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) { //create picture information if ($row['foto'] != '') { $camera = " <img src=\"assets/images/camera.png\">"; @@ -430,20 +477,17 @@ //add data to smarty template //assign dog - $xoopsTpl->assign("dogs", $dogs); - $xoopsTpl->assign("columns", $columns); - $xoopsTpl->assign("numofcolumns", $numofcolumns); - $xoopsTpl->assign("tsarray", sorttable($numofcolumns)); - //assign links - $xoopsTpl->assign("nummatch", strtr(_MA_PEDIGREE_ADD_SELSIRE, array('[father]' => $moduleConfig['father']))); - $xoopsTpl->assign("pages", $pages); - + $GLOBALS['xoopsTpl']->assign(array("dogs" => $dogs, + "columns" => $columns, + "numofcolumns" => $numofcolumns, + "tsarray" => sorttable($numofcolumns), + "nummatch" => strtr(_MA_PEDIGREE_ADD_SELSIRE, array('[father]' => $moduleConfig['father'])), + "pages" => $pages) + ); } function dam() { - global $xoopsTpl, $xoopsUser, $xoopsDB; - //get module configuration $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname("pedigree"); @@ -453,7 +497,7 @@ //check for access $xoopsModule =& XoopsModule::getByDirname("pedigree"); - if (empty($xoopsUser)) { + if (empty($GLOBALS['xoopsUser'])) { redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } @@ -478,18 +522,18 @@ //make the redirect if (!isset($_GET['r'])) { //insert into pedigree_temp - $query = "UPDATE " . $xoopsDB->prefix("pedigree_temp") . " SET father =" . $_GET['selsire'] . " WHERE ID=" . $random; - $xoopsDB->queryf($query); + $query = "UPDATE " . $GLOBALS['xoopsDB']->prefix("pedigree_temp") . " SET father =" . $_GET['selsire'] . " WHERE ID=" . $random; + $GLOBALS['xoopsDB']->queryf($query); redirect_header("add_dog.php?f=dam&random=" . $random . "&st=" . $st . "&r=1&l=a", 1, strtr(_MA_PEDIGREE_ADD_SIREOK, array('[mother]' => $moduleConfig['mother']))); } - $xoopsTpl->assign("sire", "1"); + $GLOBALS['xoopsTpl']->assign("sire", "1"); //create list of males dog to select from $perp = $moduleConfig['perpage']; //count total number of dogs - $numdog = "SELECT count(ID) from " . $xoopsDB->prefix("pedigree_tree") . " WHERE roft='1' and NAAM LIKE '" . $l . "%'"; - $numres = $xoopsDB->query($numdog); - list($numresults) = $xoopsDB->fetchRow($numres); + $numdog = "SELECT count(ID) from " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE roft='1' and NAAM LIKE '" . $l . "%'"; + $numres = $GLOBALS['xoopsDB']->query($numdog); + list($numresults) = $GLOBALS['xoopsDB']->fetchRow($numres); $numpages = (floor($numresults / $perp)) + 1; if (($numpages * $perp) == ($numresults + $perp)) { $numpages = $numpages - 1; @@ -534,22 +578,22 @@ } //query - $queryString = "SELECT * from " . $xoopsDB->prefix("pedigree_tree") . " WHERE roft = '1' and NAAM LIKE '" . $l . "%' ORDER BY NAAM LIMIT " . $st . ", " . $perp; - $result = $xoopsDB->query($queryString); + $queryString = "SELECT * from " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE roft = '1' and NAAM LIKE '" . $l . "%' ORDER BY NAAM LIMIT " . $st . ", " . $perp; + $result = $GLOBALS['xoopsDB']->query($queryString); - $animal = new Animal(); + $animal = new PedigreeAnimal(); //test to find out how many user fields there are... - $fields = $animal->numoffields(); + $fields = $animal->numOfFields(); $numofcolumns = 1; $columns[] = array('columnname' => "Name"); for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); //create empty string $lookupvalues = ""; - if ($userfield->active() && $userfield->inlist()) { - if ($userfield->haslookup()) { + if ($userfield->isActive() && $userfield->inList()) { + if ($userfield->hasLookup()) { $lookupvalues = $userfield->lookup($fields[$i]); //debug information //print_r($lookupvalues); @@ -573,7 +617,7 @@ 'usercolumns' => $empty ); - while ($row = $xoopsDB->fetchArray($result)) { + while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) { //create picture information if ($row['foto'] != '') { $camera = " <img src=\"assets/images/camera.png\">"; @@ -585,48 +629,47 @@ unset($columnvalue); //fill array for ($i = 1; $i < ($numofcolumns); ++$i) { - $x = $columns[$i]['columnnumber']; + $x = 'user' . $columns[$i]['columnnumber']; if (is_array($columns[$i]['lookupval'])) { foreach ($columns[$i]['lookupval'] as $key => $keyvalue) { - if ($key == $row['user' . $x]) { + if ($key == $row[$x]) { $value = $keyvalue['value']; } } - //debug information - ///echo $columns[$i]['columnname']."is an array !"; + /** @internal{debug information } + echo $columns[$i]['columnname']."is an array !"; + */ } //format value - cant use object because of query count - elseif (substr($row['user' . $x], 0, 7) == 'http://') { - $value = "<a href=\"" . $row['user' . $x] . "\">" . $row['user' . $x] . "</a>"; + elseif (substr($row[$x], 0, 7) == 'http://') { + $value = "<a href='{$row[$x]}'>{$row[$x]}</a>"; } else { - $value = $row['user' . $x]; + $value = $row[$x]; } $columnvalue[] = array('value' => $value); } - $dogs[] = array( - 'id' => $row['ID'], - 'name' => $name, - 'gender' => '<img src="assets/images/female.gif">', - 'link' => "<a href=\"add_dog.php?f=check&random=" . $random . "&seldam=" . $row['ID'] . "\">" . $name . "</a>", - 'colour' => "", - 'number' => "", - 'usercolumns' => $columnvalue + $dogs[] = array('id' => $row['ID'], + 'name' => $name, + 'gender' => '<img src="assets/images/female.gif">', + 'link' => "<a href='add_dog.php?f=check&random=" . $random . "&seldam={$row['ID']}'>{$name}</a>", + 'colour' => "", + 'number' => "", + 'usercolumns' => $columnvalue ); } //add data to smarty template //assign dog - $xoopsTpl->assign("dogs", $dogs); - $xoopsTpl->assign("columns", $columns); - $xoopsTpl->assign("numofcolumns", $numofcolumns); - $xoopsTpl->assign("tsarray", sorttable($numofcolumns)); - $xoopsTpl->assign("nummatch", strtr(_MA_PEDIGREE_ADD_SELDAM, array('[mother]' => $moduleConfig['mother']))); - $xoopsTpl->assign("pages", $pages); + $GLOBALS['xoopsTpl']->assign(array("dogs" => $dogsm, + "columns" => $columns, + "numofcolumns" => $numofcolumns, + "tsarray" => sorttable($numofcolumns), + "nummatch" => strtr(_MA_PEDIGREE_ADD_SELDAM, array('[mother]' => $moduleConfig['mother'])), + "pages" => $pages) + ); } function check() { - global $xoopsTpl, $xoopsUser, $xoopsDB; - //get module configuration $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname("pedigree"); @@ -635,32 +678,34 @@ //check for access $xoopsModule =& XoopsModule::getByDirname("pedigree"); - if (empty($xoopsUser)) { + if (empty($GLOBALS['xoopsUser'])) { redirect_header("index.php", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } + $random = (empty($random)) ? XoopsRequest::getInt('random', 0) : $random; +/* if (empty($random)) { $random = $_POST['random']; } if (isset($_GET['random'])) { $random = $_GET['random']; } - +*/ //query - $queryString = "SELECT * from " . $xoopsDB->prefix("pedigree_temp") . " WHERE ID = " . $random; - $result = $xoopsDB->query($queryString); - while ($row = $xoopsDB->fetchArray($result)) { + $queryString = "SELECT * from " . $GLOBALS['xoopsDB']->prefix("pedigree_temp") . " WHERE ID = " . $random; + $result = $GLOBALS['xoopsDB']->query($queryString); + while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) { //create animal object - $animal = new Animal(); + $animal = new PedigreeAnimal(); //test to find out how many user fields there are.. - $fields = $animal->numoffields(); + $fields = $animal->numOfFields(); sort($fields); $usersql = ""; for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); - if ($userfield->active()) { + if ($userfield->isActive()) { $usersql .= ",'" . addslashes($row['user' . $fields[$i]]) . "'"; } else { $usersql .= ",'" . $fieldobject->defaultvalue . "'"; @@ -669,15 +714,14 @@ } //insert into pedigree $query - = "INSERT INTO " . $xoopsDB->prefix("pedigree_tree") . " VALUES ('','" . addslashes($row['NAAM']) . "','" . $row['id_owner'] . "','" . $row['id_breeder'] . "','" . $row['user'] . "','" + = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " VALUES ('','" . addslashes($row['NAAM']) . "','" . $row['id_owner'] . "','" . $row['id_breeder'] . "','" . $row['user'] . "','" . $row['roft'] . "','" . $_GET['seldam'] . "','" . $row['father'] . "','" . addslashes($row['foto']) . "',''" . $usersql . ")"; mysql_query($query); //echo $query; die(); } - $sqlquery = "DELETE from " . $xoopsDB->prefix("pedigree_temp") . " where ID='" . $random . "'"; - $xoopsDB->queryf($sqlquery); + $sqlquery = "DELETE from " . $GLOBALS['xoopsDB']->prefix("pedigree_temp") . " where ID='{$random}'"; + $GLOBALS['xoopsDB']->queryf($sqlquery); redirect_header("latest.php", 1, strtr(_MA_PEDIGREE_ADD_OK, array('[animalType]' => $moduleConfig['animalType']))); } -//footer -include XOOPS_ROOT_PATH . "/footer.php"; +include $GLOBALS['xoops']->path("/footer.php"); Modified: XoopsModules/pedigree/branches/zyspec/pedigree/add_litter.php =================================================================== --- XoopsModules/pedigree/branches/zyspec/pedigree/add_litter.php 2015-02-18 18:40:33 UTC (rev 12999) +++ XoopsModules/pedigree/branches/zyspec/pedigree/add_litter.php 2015-02-18 18:43:38 UTC (rev 13000) @@ -1,38 +1,51 @@ <?php -// ------------------------------------------------------------------------- +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ +/** + * animal module for xoops + * + * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package pedigree + * @subpackage class + * @author XOOPS Module Dev Team + * @version $Id: $ + */ + require_once dirname(dirname(__DIR__)) . '/mainfile.php'; -/* -if (file_exists(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php")) { - require_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php"; -} else { - include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/english/main.php"; -} -*/ +xoops_loadLanguage('main', 'pedigree'); +xoops_load('XoopsRequest'); +xoops_load('animal', 'pedigree'); -xoops_loadLanguage('main', basename(dirname(__DIR__))); - // Include any common code for this module. -require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php"); -require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/class_field.php"); +require_once $GLOBALS['xoops']->path("/modules/" . $GLOBALS['xoopsModule']->dirname() . "/include/functions.php"); +require_once $GLOBALS['xoops']->path("/modules/" . $GLOBALS['xoopsModule']->dirname() . "/include/class_field.php"); $xoopsOption['template_main'] = "pedigree_addlitter.tpl"; -include XOOPS_ROOT_PATH . '/header.php'; -$xoopsTpl->assign('page_title', "Pedigree database - add a litter"); +include $GLOBALS['xoops']->path('/header.php'); +/* @todo: move hard coded language string to language files */ +$GLOBALS['xoopsTpl']->assign('page_title', "Pedigree database - add a litter"); //check for access $xoopsModule =& XoopsModule::getByDirname("pedigree"); -if (empty($xoopsUser)) { +if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof XoopsUser)) { redirect_header("index.php", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } //get module configuration -$module_handler =& xoops_gethandler('module'); -$module =& $module_handler->getByDirname("pedigree"); +//$module_handler =& xoops_gethandler('module'); +//$module =& $module_handler->getByDirname("pedigree"); $config_handler =& xoops_gethandler('config'); -$moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); +$moduleConfig =& $config_handler->getConfigsByCat(0, $xoopsModule->getVar('mid')); if (!isset($_GET['f'])) { addlitter(); @@ -51,27 +64,28 @@ function addlitter() { - global $xoopsTpl, $xoopsUser, $xoopsDB, $xoopsOption; + global $xoopsOption, $moduleConfig; +/* //get module configuration $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname("pedigree"); $config_handler =& xoops_gethandler('config'); $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); - +*/ //create xoopsform - include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; + include $GLOBALS['xoops']->path("/class/xoopsformloader.php"); $searchform = new XoopsThemeForm(strtr(_MA_PEDIGREE_ADD_LITTER, array('[litter]' => $moduleConfig['litter'])), "searchform", "add_litter.php?f=sire", "post"); $searchform->addElement(new XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); //create random value $random = (rand() % 10000); $searchform->addElement(new XoopsFormHidden('random', $random)); //find userid - $searchform->addElement(new XoopsFormHidden('userid', $xoopsUser->getVar("uid"))); + $searchform->addElement(new XoopsFormHidden('userid', $GLOBALS['xoopsUser']->getVar("uid"))); //create animal object - $animal = new Animal(); + $animal = new PedigreeAnimal(); //test to find out how many user fields there are... - $fields = $animal->numoffields(); + $fields = $animal->numOfFields(); //create form contents for ($count = 1; $count < 11; ++$count) { @@ -87,10 +101,10 @@ $searchform->addElement($gender_radio[$count]); //add userfields for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); - if ($userfield->active() && $userfield->getSetting("Litter") == "1" && !$userfield->isLocked()) { + if ($userfield->isActive() && $userfield->getSetting("Litter") == "1" && !$userfield->isLocked()) { $newentry[$count][$i] = $fieldobject->newField($count); $searchform->addElement($newentry[$count][$i]); } @@ -102,10 +116,10 @@ $searchform->addElement(new XoopsFormLabel(_MA_PEDIGREE_ADD_DATA, _MA_PEDIGREE_DATA_INFO . $moduleConfig['litter'] . ".</h2>")); //add userfields that are not shown in the litter for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); - if ($userfield->active() && $userfield->generallitter() && !$userfield->isLocked()) { + if ($userfield->isActive() && $userfield->generalLitter() && !$userfield->isLocked()) { //add the "-" character to the beginning of the fieldname !!! $newentry[$i] = $fieldobject->newField("-"); $searchform->addElement($newentry[$i]); @@ -113,13 +127,14 @@ } //add the breeder to the list for the entire litter //no need to add the owner here because they will be different for each animal in the litter. - if ($moduleConfig['ownerbreeder'] == '1') { + /* @todo: move hard coded language string to language files */ + if (1 == $moduleConfig['ownerbreeder']) { //breeder $breeder = new XoopsFormSelect(_MA_PEDIGREE_FLD_BREE, 'id_breeder', $value = '', $size = 1, $multiple = false); - $queryfok = "SELECT ID, firstname, lastname from " . $xoopsDB->prefix("pedigree_owner") . " order by `lastname`"; - $resfok = $xoopsDB->query($queryfok); + $queryfok = "SELECT ID, firstname, lastname from " . $GLOBALS['xoopsDB']->prefix("pedigree_owner") . " order by `lastname`"; + $resfok = $GLOBALS['xoopsDB']->query($queryfok); $breeder->addOption(0, $name = 'Unknown', $disabled = false); - while ($rowfok = $xoopsDB->fetchArray($resfok)) { + while ($rowfok = $GLOBALS['xoopsDB']->fetchArray($resfok)) { $breeder->addOption($rowfok['ID'], $name = $rowfok['lastname'] . ", " . $rowfok['firstname'], $disabled = false); } $searchform->addElement($breeder); @@ -128,13 +143,12 @@ //submit button $searchform->addElement(new XoopsFormButton('', 'submit', strtr(_MA_PEDIGREE_ADD_SIRE, array('[father]' => $moduleConfig['father'])), 'submit')); //send to template - $searchform->assign($xoopsTpl); + $searchform->assign($GLOBALS['xoopsTpl']); } function sire() { - global $xoopsTpl, $xoopsUser, $xoopsDB; //debug option ! //print_r($_POST); die(); //get module configuration @@ -143,12 +157,15 @@ $config_handler =& xoops_gethandler('config'); $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); +/* DONE AT BEGINNING OF FILE //check for access $xoopsModule =& XoopsModule::getByDirname("pedigree"); - if (empty($xoopsUser)) { + if (empty($GLOBALS['xoopsUser'])) { redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); exit(); } +*/ + /* @todo: need to filter '_GET' and '_POST' data */ $userid = $_POST['userid']; if (empty($random)) { $random = $_POST['random']; @@ -164,8 +181,8 @@ } $userfields = ""; for ($count = 1; $count < 11; ++$count) { - $namelitter = "name" . $count; - $roftlitter = "roft" . $count; + $namelitter = "name{$count}"; + $roftlitter = "roft{$count}"; //check for an empty name if ($_POST[$namelitter] !== "") { $name .= ":" . $_POST[$namelitter]; @@ -185,13 +202,13 @@ //make the redirect if (!isset($_GET['r'])) { //create animal object - $animal = new Animal(); + $animal = new PedigreeAnimal(); //test to find out how many user fields there are.. - $fields = $animal->numoffields(); + $fields = $animal->numOfFields(); sort($fields); $usersql = ""; for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); $defvalue = $fieldobject->defaultvalue; @@ -204,7 +221,7 @@ //echo $count.'user'.$fields[$i]."=".$_POST[$count.'user'.$fields[$i]]."<br />"; $withinfield .= ":" . $_POST[$count . 'user' . $fields[$i]]; } else { - if ($userfield->active() && $userfield->generallitter() && !$userfield->isLocked()) { + if ($userfield->isActive() && $userfield->generalLitter() && !$userfield->isLocked()) { //use $_POST value if this is a general litter field $withinfield .= ":" . $_POST['-user' . $fields[$i]]; } else { @@ -219,9 +236,9 @@ $user{$fields[$i]} = $withinfield; } //insert into pedigree_temp - $query = "INSERT INTO " . $xoopsDB->prefix("pedigree_temp") . " VALUES ('" . $random . "','" . unhtmlentities($name) . "','0','" . $id_breeder . "','" . $userid . "','" . $roft . "','','','', ''"; + $query = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix("pedigree_temp") . " VALUES ('" . $random . "','" . unhtmlentities($name) . "','0','" . $id_breeder . "','" . $userid . "','" . $roft . "','','','', ''"; for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); //do we only need to create a query for active fields ? @@ -230,7 +247,7 @@ $query .= ")"; //debug options //echo $query."<br />"; die(); - $xoopsDB->query($query); + $GLOBALS['xoopsDB']->query($query); redirect_header("add_litter.php?f=sire&random=" . $random . "&st=" . $st . "&r=1&l=a", 1, strtr(_MA_PEDIGREE_ADD_SIREPLZ, array('[father]' => $moduleConfig['father']))); } //find letter on which to start else set to 'a' @@ -240,14 +257,14 @@ $l = "a"; } //assign 'sire' to the template - $xoopsTpl->assign("sire", "1"); + $GLOBALS['xoopsTpl']->assign("sire", "1"); //create list of males dog to select from $perp = $moduleConfig['perpage']; //count total number of dogs - $numdog = "SELECT ID from " . $xoopsDB->prefix("pedigree_tree") . " WHERE roft='0' and NAAM LIKE '" . $l . "%'"; - $numres = $xoopsDB->query($numdog); + $numdog = "SELECT ID from " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE roft='0' and NAAM LIKE '" . $l . "%'"; + $numres = $GLOBALS['xoopsDB']->query($numdog); //total number of dogs the query will find - $numresults = $xoopsDB->getRowsNum($numres); + $numresults = $GLOBALS['xoopsDB']->getRowsNum($numres); //total number of pages $numpages = (floor($numresults / $perp)) + 1; if (($numpages * $perp) == ($numresults + $perp)) { @@ -294,22 +311,22 @@ } } //query - $queryString = "SELECT * from " . $xoopsDB->prefix("pedigree_tree") . " WHERE roft = '0' and NAAM LIKE '" . $l . "%' ORDER BY NAAM LIMIT " . $st . ", " . $perp; - $result = $xoopsDB->query($queryString); + $queryString = "SELECT * from " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE roft = '0' and NAAM LIKE '" . $l . "%' ORDER BY NAAM LIMIT " . $st . ", " . $perp; + $result = $GLOBALS['xoopsDB']->query($queryString); - $animal = new Animal(); + $animal = new PedigreeAnimal(); //test to find out how many user fields there are... - $fields = $animal->numoffields(); + $fields = $animal->numOfFields(); $numofcolumns = 1; $columns[] = array('columnname' => "Name"); for ($i = 0; $i < count($fields); ++$i) { - $userfield = new Field($fields[$i], $animal->getconfig()); + $userfield = new Field($fields[$i], $animal->getConfig()); $fieldType = $userfield->getSetting("FieldType"); $fieldobject = new $fieldType($userfield, $animal); //create empty string $lookupvalues = ""; - if ($userfield->active() && $userfield->inlist()) { - if ($userfield->haslookup()) { + if ($userfield->isActive() && $userfield->inList()) { + if ($userfield->hasLookup()) { $lookupvalues = $userfield->lookup($fields[$i]); //debug information //print_r($lookupvalues); @@ -333,7 +350,7 @@ 'usercolumns' => $empty ); - while ($row = $xoopsDB->fetchArray($result)) { + while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) { //create picture information if ($row['foto'] != '') { $camera = " <img src=\"assets/images/camera.png\">"; @@ -375,30 +392,31 @@ //add data to smarty template //assign dog - $xoopsTpl->assign("dogs", $dogs); - $xoopsTpl->assign("columns", $columns); - $xoopsTpl->assign("numofcolumns", $numofcolumns); - $xoopsTpl->assign("tsarray", sorttable($numofcolumns)); - $xoopsTpl->assign("nummatch", strtr(_MA_PEDIGREE_ADD_SELSIRE, array('[father]' => $moduleConfig['father']))); - $xoopsTpl->assign("pages", $pages); + $GLOBALS['xoopsTpl']->assign(array("dogs" => $dogs, + "columns" => $columns, + "numofcolumns" => $numofcolumns, + "tsarray" => sorttable($numofcolumns), + "nummatch" => strtr(_MA_PEDIGREE_ADD_SELSIRE, array('[father]' => $moduleConfig['father'])), + "pages" => $pages) + ); } function dam() { - global $xoopsTpl, $xoopsUser, $xoopsDB; - //get module configuration $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname("pedigree"); $config_handler =& xoops_gethandler('config'); $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); - +/* if (empty($random)) { $random = $_POST['random']; } if (isset($_GET['random'])) { $random = $_GET['random']; } +*/ + $random = empty($random) ? XoopsRequest::getInt('random', 0) : $random; if (empty($st)) { $st = 0; } @@ -408,8 +426,8 @@ //make the redirect if (!isset($_GET['r'])) { //insert into pedigree_temp - $query = "UPDATE " . $xoopsDB->prefix("pedigree_temp") . " SET father =" . $_GET['selsire'] . " WHERE ID=" . $random; - $xoopsDB->queryf($query); + $query = "UPDATE " . $GLOBALS['xoopsDB']->prefix("pedigree_temp") . " SET father =" . $_GET['selsire'] . " WHERE ID=" . $random; + $GLOBALS['xoopsDB']->queryf($query); redirect_header("add_litter.php?f=dam&random=" . $random . "&st=" . $st . "&r=1", 1, strtr(_MA_PEDIGREE_ADD_SIREOK, array('[mother]' => $moduleConfig['mother']))); } //find letter on which to start else set to 'a' @@ -419,14 +437,14 @@ $l = "a"; } //assign sire to the template - $xoopsTpl->assign("sire", "1"); + $GLOBALS['xoopsTpl']->assign("sire", "1"); //create list of males dog to select from $perp = $moduleConfig['perpage']; //count total number of dogs - $numdog = "SELECT ID from " . $xoopsDB->prefix("pedigree_tree") . " WHERE roft='1' and NAAM LIKE '" . $l . "%'"; - $numres = $xoopsDB->query($numdog); + $numdog = "SELECT ID from " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE roft='1' and NAAM LIKE '" . $l . "%'"; + $numres = $GLOBALS['xoopsDB']->query($numdog); //total number of dogs the query will find - $numresults = $xoopsDB->getRowsNum($numres); + $numresults = $GLOBALS['xoopsDB']->getRowsNum($numres); //total number of pages $numpages = (floor($numresults / $perp)) + 1; if (($numpages * $perp) == ($numresults + $perp)) { @@ -473,22 +491,22 @@ } } //query - $queryString = "SELECT * from " . $xoopsDB->prefix("pedigree_tree") . " WHERE roft = '1' and NAAM LIKE '" . $l . "%' ORDER BY NAAM LIMIT " . $st . ", " . $perp; - $result = $xoopsDB->query($queryString); + $queryString = "SELECT * from " . $GLOBALS['xoopsDB']->prefix("pedigree_tree") . " WHERE roft = '1' and NAAM LIKE '" . $l . "%' ORDER BY NAAM LIMIT " . $st . ", " . $pe... [truncated message content] |