diff --git a/admin/about.php b/admin/about.php index e58b7b9..6082e23 100644 --- a/admin/about.php +++ b/admin/about.php @@ -14,7 +14,7 @@ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package * @since - * @author XOOPS Development Team + * @author XOOPS Development Team */ require __DIR__ . '/admin_header.php'; diff --git a/admin/admin_footer.php b/admin/admin_footer.php index 5ba8ac5..c90968a 100644 --- a/admin/admin_footer.php +++ b/admin/admin_footer.php @@ -14,16 +14,11 @@ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package * @since - * @author XOOPS Development Team + * @author XOOPS Development Team */ -$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32); +$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32); -echo "
\n" - ."
\n" - ." XOOPS\n" - ."
\n" - .' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" - .'
'; +echo "
\n" . "
\n" . " XOOPS\n" . "
\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . '
'; xoops_cp_footer(); diff --git a/admin/admin_header.php b/admin/admin_header.php index 89855ca..647cbf0 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -14,7 +14,7 @@ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package * @since - * @author XOOPS Development Team + * @author XOOPS Development Team */ $path = dirname(dirname(dirname(__DIR__))); diff --git a/admin/borrow.php b/admin/borrow.php index 80add78..e832870 100644 --- a/admin/borrow.php +++ b/admin/borrow.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -31,10 +32,9 @@ require_once __DIR__ . '/admin_header.php'; xoops_cp_header(); //It recovered the value of argument op in URL$ -$op = Request::getString('op', 'list'); -$order = Request::getString('order', 'desc'); -$sort = Request::getString('sort', ''); - +$op = Request::getString('op', 'list'); +$order = Request::getString('order', 'desc'); +$sort = Request::getString('sort', ''); $adminObject->displayNavigation(basename(__FILE__)); /** @var Permission $permHelper */ @@ -45,7 +45,7 @@ default: $adminObject->addItemButton(AM_EQUIPMENT_ADD_BORROW, 'borrow.php?op=new', 'add'); echo $adminObject->displayButton('left'); - $start = Request::getInt('start', 0); + $start = Request::getInt('start', 0); $borrowPaginationLimit = $GLOBALS['xoopsModuleConfig']['userpager']; $criteria = new CriteriaCompo(); @@ -53,7 +53,7 @@ $criteria->setOrder('ASC'); $criteria->setLimit($borrowPaginationLimit); $criteria->setStart($start); - $borrowTempRows = $borrowHandler->getCount(); + $borrowTempRows = $borrowHandler->getCount(); $borrowTempArray = $borrowHandler->getAll($criteria);/* // // @@ -66,106 +66,95 @@ if ($borrowTempRows > $borrowPaginationLimit) { require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; - $pagenav = new XoopsPageNav($borrowTempRows, $borrowPaginationLimit, $start, 'start', - 'op=list' . '&sort=' . $sort . '&order=' . $order - . ''); + $pagenav = new XoopsPageNav($borrowTempRows, $borrowPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); } $GLOBALS['xoopsTpl']->assign('borrowRows', $borrowTempRows); - $borrowArray = array(); - -// $fields = explode('|', id:smallint:5:unsigned:NOT NULL::primary:ID|borrower:varchar:10::NOT NULL::primary:Customer|amount:int:10:unsigned:NOT NULL:::Amount); -// $fieldsCount = count($fields); + $borrowArray = array(); -$criteria = new CriteriaCompo(); + // $fields = explode('|', id:smallint:5:unsigned:NOT NULL::primary:ID|borrower:varchar:10::NOT NULL::primary:Customer|amount:int:10:unsigned:NOT NULL:::Amount); + // $fieldsCount = count($fields); -//$criteria->setOrder('DESC'); -$criteria->setSort($sort); -$criteria->setOrder($order); -$criteria->setLimit($borrowPaginationLimit); -$criteria->setStart($start); + $criteria = new CriteriaCompo(); + //$criteria->setOrder('DESC'); + $criteria->setSort($sort); + $criteria->setOrder($order); + $criteria->setLimit($borrowPaginationLimit); + $criteria->setStart($start); -$borrowCount = $borrowHandler->getCount($criteria); -$borrowTempArray = $borrowHandler->getAll($criteria); + $borrowCount = $borrowHandler->getCount($criteria); + $borrowTempArray = $borrowHandler->getAll($criteria); -// for ($i = 0; $i < $fieldsCount; ++$i) { - if ($borrowCount > 0) { - foreach (array_keys($borrowTempArray) as $i) { + // for ($i = 0; $i < $fieldsCount; ++$i) { + if ($borrowCount > 0) { + foreach (array_keys($borrowTempArray) as $i) { -// $field = explode(':', $fields[$i]); + // $field = explode(':', $fields[$i]); -$selectorid = EquipmentUtility::selectSorting(AM_EQUIPMENT_BORROW_ID, 'id'); - $GLOBALS['xoopsTpl']->assign('selectorid', $selectorid); - $borrowArray['id'] = $borrowTempArray[$i]->getVar('id'); + $selectorid = EquipmentUtility::selectSorting(AM_EQUIPMENT_BORROW_ID, 'id'); + $GLOBALS['xoopsTpl']->assign('selectorid', $selectorid); + $borrowArray['id'] = $borrowTempArray[$i]->getVar('id'); - $selectorborrower = EquipmentUtility::selectSorting(AM_EQUIPMENT_BORROW_BORROWER, 'borrower'); - $GLOBALS['xoopsTpl']->assign('selectorborrower', $selectorborrower); - $borrowArray['borrower'] = $borrowTempArray[$i]->getVar('borrower'); + $selectorborrower = EquipmentUtility::selectSorting(AM_EQUIPMENT_BORROW_BORROWER, 'borrower'); + $GLOBALS['xoopsTpl']->assign('selectorborrower', $selectorborrower); + $borrowArray['borrower'] = $borrowTempArray[$i]->getVar('borrower'); - $selectoramount = EquipmentUtility::selectSorting(AM_EQUIPMENT_BORROW_AMOUNT, 'amount'); - $GLOBALS['xoopsTpl']->assign('selectoramount', $selectoramount); - $borrowArray['amount'] = $borrowTempArray[$i]->getVar('amount'); - $borrowArray['edit_delete'] = - "" . _EDIT . " + $selectoramount = EquipmentUtility::selectSorting(AM_EQUIPMENT_BORROW_AMOUNT, 'amount'); + $GLOBALS['xoopsTpl']->assign('selectoramount', $selectoramount); + $borrowArray['amount'] = $borrowTempArray[$i]->getVar('amount'); + $borrowArray['edit_delete'] = "" . _EDIT . " " . _DELETE . " - " . _CLONE . ""; - - - $GLOBALS['xoopsTpl']->append_by_ref('borrowArrays', $borrowArray); - unset($borrowArray); - } - unset($borrowTempArray); - // Display Navigation - if ($borrowCount > $borrowPaginationLimit) { - require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; - $pagenav = new XoopsPageNav($borrowCount, $borrowPaginationLimit, $start, 'start', - 'op=list' . '&sort=' . $sort . '&order=' . $order - . ''); - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); - } + " . _CLONE . ""; + $GLOBALS['xoopsTpl']->append_by_ref('borrowArrays', $borrowArray); + unset($borrowArray); + } + unset($borrowTempArray); + // Display Navigation + if ($borrowCount > $borrowPaginationLimit) { + require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; + $pagenav = new XoopsPageNav($borrowCount, $borrowPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); + } -// echo " + // echo " -// "._EDIT." -// "._DELETE." -// "; + // "._EDIT." + // "._DELETE." + // "; -// echo ""; + // echo ""; -// } + // } -// echo "

"; + // echo "

"; -// } else { + // } else { -// echo " + // echo "
-// + // - // -// "; -// echo "
".AM_EQUIPMENT_FORM_ACTION."XXX
There are noXXX borrow


"; + // ".AM_EQUIPMENT_FORM_ACTION."XXX + // There are noXXX borrow"; + // echo "

"; -//------------------------------------------- + //------------------------------------------- - echo $GLOBALS['xoopsTpl']->fetch( - XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/equipment_admin_borrow.tpl' - ); - } + echo $GLOBALS['xoopsTpl']->fetch(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/equipment_admin_borrow.tpl'); + } - - break; + break; case 'new': $adminObject->addItemButton(AM_EQUIPMENT_BORROW_LIST, 'borrow.php', 'list'); echo $adminObject->displayButton('left'); $borrowObject = $borrowHandler->create(); - $form = $borrowObject->getForm(); + $form = $borrowObject->getForm(); $form->display(); break; @@ -178,7 +167,7 @@ } else { $borrowObject = $borrowHandler->create(); } -// Form save fields + // Form save fields $borrowObject->setVar('borrower', Request::getVar('borrower', '')); $borrowObject->setVar('amount', Request::getVar('amount', '')); if ($borrowHandler->insert($borrowObject)) { @@ -188,16 +177,16 @@ echo $borrowObject->getHtmlErrors(); $form = $borrowObject->getForm(); $form->display(); - break; + break; case 'edit': $adminObject->addItemButton(AM_EQUIPMENT_ADD_BORROW, 'borrow.php?op=new', 'add'); $adminObject->addItemButton(AM_EQUIPMENT_BORROW_LIST, 'borrow.php', 'list'); echo $adminObject->displayButton('left'); $borrowObject = $borrowHandler->get(Request::getString('id', '')); - $form = $borrowObject->getForm(); + $form = $borrowObject->getForm(); $form->display(); - break; + break; case 'delete': $borrowObject = $borrowHandler->get(Request::getString('id', '')); @@ -213,7 +202,7 @@ } else { xoops_confirm(array('ok' => 1, 'id' => Request::getString('id', ''), 'op' => 'delete'), Request::getCmd('REQUEST_URI', '', 'SERVER'), sprintf(AM_EQUIPMENT_FORMSUREDEL, $borrowObject->getVar('borrower'))); } - break; + break; case 'clone': @@ -225,6 +214,6 @@ redirect_header('borrow.php', 3, AM_EQUIPMENT_CLONED_FAILED); } - break; + break; } require_once __DIR__ . '/admin_footer.php'; diff --git a/admin/desc.php b/admin/desc.php index 579e4a8..bb7ad44 100644 --- a/admin/desc.php +++ b/admin/desc.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -31,10 +32,9 @@ require_once __DIR__ . '/admin_header.php'; xoops_cp_header(); //It recovered the value of argument op in URL$ -$op = Request::getString('op', 'list'); -$order = Request::getString('order', 'desc'); -$sort = Request::getString('sort', ''); - +$op = Request::getString('op', 'list'); +$order = Request::getString('order', 'desc'); +$sort = Request::getString('sort', ''); $adminObject->displayNavigation(basename(__FILE__)); /** @var Permission $permHelper */ @@ -45,7 +45,7 @@ default: $adminObject->addItemButton(AM_EQUIPMENT_ADD_DESC, 'desc.php?op=new', 'add'); echo $adminObject->displayButton('left'); - $start = Request::getInt('start', 0); + $start = Request::getInt('start', 0); $descPaginationLimit = $GLOBALS['xoopsModuleConfig']['userpager']; $criteria = new CriteriaCompo(); @@ -53,7 +53,7 @@ $criteria->setOrder('ASC'); $criteria->setLimit($descPaginationLimit); $criteria->setStart($start); - $descTempRows = $descHandler->getCount(); + $descTempRows = $descHandler->getCount(); $descTempArray = $descHandler->getAll($criteria);/* // // @@ -66,118 +66,107 @@ if ($descTempRows > $descPaginationLimit) { require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; - $pagenav = new XoopsPageNav($descTempRows, $descPaginationLimit, $start, 'start', - 'op=list' . '&sort=' . $sort . '&order=' . $order - . ''); + $pagenav = new XoopsPageNav($descTempRows, $descPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); } $GLOBALS['xoopsTpl']->assign('descRows', $descTempRows); - $descArray = array(); - -// $fields = explode('|', id:smallint:5:unsigned:NOT NULL::primary:ID|owner:varchar:10::NOT NULL::index:Owner|name:varchar:30::NOT NULL::index:Name|amount:int:10:unsigned:NOT NULL:::Amount|total:int:10:unsigned:NOT NULL:::Total|image_b64:mediumtext:0::NOT NULL:::Image); -// $fieldsCount = count($fields); + $descArray = array(); -$criteria = new CriteriaCompo(); + // $fields = explode('|', id:smallint:5:unsigned:NOT NULL::primary:ID|owner:varchar:10::NOT NULL::index:Owner|name:varchar:30::NOT NULL::index:Name|amount:int:10:unsigned:NOT NULL:::Amount|total:int:10:unsigned:NOT NULL:::Total|image_b64:mediumtext:0::NOT NULL:::Image); + // $fieldsCount = count($fields); -//$criteria->setOrder('DESC'); -$criteria->setSort($sort); -$criteria->setOrder($order); -$criteria->setLimit($descPaginationLimit); -$criteria->setStart($start); + $criteria = new CriteriaCompo(); + //$criteria->setOrder('DESC'); + $criteria->setSort($sort); + $criteria->setOrder($order); + $criteria->setLimit($descPaginationLimit); + $criteria->setStart($start); -$descCount = $descHandler->getCount($criteria); -$descTempArray = $descHandler->getAll($criteria); + $descCount = $descHandler->getCount($criteria); + $descTempArray = $descHandler->getAll($criteria); -// for ($i = 0; $i < $fieldsCount; ++$i) { - if ($descCount > 0) { - foreach (array_keys($descTempArray) as $i) { + // for ($i = 0; $i < $fieldsCount; ++$i) { + if ($descCount > 0) { + foreach (array_keys($descTempArray) as $i) { -// $field = explode(':', $fields[$i]); + // $field = explode(':', $fields[$i]); -$selectorid = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_ID, 'id'); - $GLOBALS['xoopsTpl']->assign('selectorid', $selectorid); - $descArray['id'] = $descTempArray[$i]->getVar('id'); + $selectorid = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_ID, 'id'); + $GLOBALS['xoopsTpl']->assign('selectorid', $selectorid); + $descArray['id'] = $descTempArray[$i]->getVar('id'); - $selectorowner = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_OWNER, 'owner'); - $GLOBALS['xoopsTpl']->assign('selectorowner', $selectorowner); - $descArray['owner'] = $descTempArray[$i]->getVar('owner'); + $selectorowner = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_OWNER, 'owner'); + $GLOBALS['xoopsTpl']->assign('selectorowner', $selectorowner); + $descArray['owner'] = $descTempArray[$i]->getVar('owner'); - $selectorname = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_NAME, 'name'); - $GLOBALS['xoopsTpl']->assign('selectorname', $selectorname); - $descArray['name'] = $descTempArray[$i]->getVar('name'); + $selectorname = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_NAME, 'name'); + $GLOBALS['xoopsTpl']->assign('selectorname', $selectorname); + $descArray['name'] = $descTempArray[$i]->getVar('name'); - $selectoramount = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_AMOUNT, 'amount'); - $GLOBALS['xoopsTpl']->assign('selectoramount', $selectoramount); - $descArray['amount'] = $descTempArray[$i]->getVar('amount'); + $selectoramount = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_AMOUNT, 'amount'); + $GLOBALS['xoopsTpl']->assign('selectoramount', $selectoramount); + $descArray['amount'] = $descTempArray[$i]->getVar('amount'); - $selectortotal = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_TOTAL, 'total'); - $GLOBALS['xoopsTpl']->assign('selectortotal', $selectortotal); - $descArray['total'] = $descTempArray[$i]->getVar('total'); + $selectortotal = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_TOTAL, 'total'); + $GLOBALS['xoopsTpl']->assign('selectortotal', $selectortotal); + $descArray['total'] = $descTempArray[$i]->getVar('total'); - $selectorimage_b64 = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_IMAGE_B64, 'image_b64'); - $GLOBALS['xoopsTpl']->assign('selectorimage_b64', $selectorimage_b64); - $descArray['image_b64'] = $descTempArray[$i]->getVar('image_b64'); - $descArray['edit_delete'] = - "" . _EDIT . " + $selectorimage_b64 = EquipmentUtility::selectSorting(AM_EQUIPMENT_DESC_IMAGE_B64, 'image_b64'); + $GLOBALS['xoopsTpl']->assign('selectorimage_b64', $selectorimage_b64); + $descArray['image_b64'] = $descTempArray[$i]->getVar('image_b64'); + $descArray['edit_delete'] = "" . _EDIT . " " . _DELETE . " - " . _CLONE . ""; - - - $GLOBALS['xoopsTpl']->append_by_ref('descArrays', $descArray); - unset($descArray); - } - unset($descTempArray); - // Display Navigation - if ($descCount > $descPaginationLimit) { - require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; - $pagenav = new XoopsPageNav($descCount, $descPaginationLimit, $start, 'start', - 'op=list' . '&sort=' . $sort . '&order=' . $order - . ''); - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); - } + " . _CLONE . ""; + $GLOBALS['xoopsTpl']->append_by_ref('descArrays', $descArray); + unset($descArray); + } + unset($descTempArray); + // Display Navigation + if ($descCount > $descPaginationLimit) { + require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; + $pagenav = new XoopsPageNav($descCount, $descPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); + } -// echo " + // echo " -// "._EDIT." -// "._DELETE." -// "; + // "._EDIT." + // "._DELETE." + // "; -// echo ""; + // echo ""; -// } + // } -// echo "

"; + // echo "

"; -// } else { + // } else { -// echo " + // echo "
-// + // - // -// "; -// echo "
".AM_EQUIPMENT_FORM_ACTION."XXX
There are noXXX desc


"; + // ".AM_EQUIPMENT_FORM_ACTION."XXX + // There are noXXX desc"; + // echo "

"; -//------------------------------------------- + //------------------------------------------- - echo $GLOBALS['xoopsTpl']->fetch( - XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/equipment_admin_desc.tpl' - ); - } + echo $GLOBALS['xoopsTpl']->fetch(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/equipment_admin_desc.tpl'); + } - - break; + break; case 'new': $adminObject->addItemButton(AM_EQUIPMENT_DESC_LIST, 'desc.php', 'list'); echo $adminObject->displayButton('left'); $descObject = $descHandler->create(); - $form = $descObject->getForm(); + $form = $descObject->getForm(); $form->display(); break; @@ -190,21 +179,20 @@ } else { $descObject = $descHandler->create(); } -// Form save fields + // Form save fields $descObject->setVar('owner', Request::getVar('owner', '')); $descObject->setVar('name', Request::getVar('name', '')); $descObject->setVar('amount', Request::getVar('amount', '')); $descObject->setVar('total', Request::getVar('total', '')); - require_once XOOPS_ROOT_PATH.'/class/uploader.php'; - $uploadDir = XOOPS_UPLOAD_PATH.'/equipment/images/'; - $uploader = new XoopsMediaUploader($uploadDir, xoops_getModuleOption('mimetypes', 'equipment'), - xoops_getModuleOption('maxsize', 'equipment'), null, null); + require_once XOOPS_ROOT_PATH . '/class/uploader.php'; + $uploadDir = XOOPS_UPLOAD_PATH . '/equipment/images/'; + $uploader = new XoopsMediaUploader($uploadDir, xoops_getModuleOption('mimetypes', 'equipment'), xoops_getModuleOption('maxsize', 'equipment'), null, null); if ($uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0])) { - + //$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '' , $_FILES['attachedfile']['name']); //$imgName = str_replace(' ', '', $_POST['']).'.'.$extension; - + $uploader->setPrefix('image_b64_'); $uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0]); if (!$uploader->upload()) { @@ -216,14 +204,14 @@ } else { $descObject->setVar('image_b64', Request::getVar('image_b64', '')); } - - //Permissions -//=============================================================== - $mid = $GLOBALS['xoopsModule']->mid(); - /** @var XoopsGroupPermHandler $gpermHandler */ - $gpermHandler = xoops_getHandler('groupperm'); - $id = Request::getInt('id', 0); + //Permissions + //=============================================================== + + $mid = $GLOBALS['xoopsModule']->mid(); + /** @var XoopsGroupPermHandler $gpermHandler */ + $gpermHandler = xoops_getHandler('groupperm'); + $id = Request::getInt('id', 0); /** * @param $myArray @@ -233,110 +221,108 @@ * @param $permissionName * @param $mid */ - function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid) - { - $permissionArray = $myArray; - if ($id > 0) { - $sql = 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name` = '" . $permissionName - . "' AND `gperm_itemid`= $id;"; - $GLOBALS['xoopsDB']->query($sql); - } - //admin - $gperm = $gpermHandler->create(); - $gperm->setVar('gperm_groupid', XOOPS_GROUP_ADMIN); - $gperm->setVar('gperm_name', $permissionName); - $gperm->setVar('gperm_modid', $mid); - $gperm->setVar('gperm_itemid', $id); - $gpermHandler->insert($gperm); - unset($gperm); - //non-Admin groups - if (is_array($permissionArray)) { - foreach ($permissionArray as $key => $cat_groupperm) { - if ($cat_groupperm > 0) { - $gperm = $gpermHandler->create(); - $gperm->setVar('gperm_groupid', $cat_groupperm); - $gperm->setVar('gperm_name', $permissionName); - $gperm->setVar('gperm_modid', $mid); - $gperm->setVar('gperm_itemid', $id); - $gpermHandler->insert($gperm); - unset($gperm); - } - } - } elseif ($permissionArray > 0) { - $gperm = $gpermHandler->create(); - $gperm->setVar('gperm_groupid', $permissionArray); - $gperm->setVar('gperm_name', $permissionName); - $gperm->setVar('gperm_modid', $mid); - $gperm->setVar('gperm_itemid', $id); - $gpermHandler->insert($gperm); - unset($gperm); - } - } - - //setPermissions for View items - $permissionGroup = 'groupsRead'; - $permissionName = 'equipment_view'; - $permissionArray = Request::getArray($permissionGroup, ''); - $permissionArray[] = XOOPS_GROUP_ADMIN; - //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid); - $permHelper->savePermissionForItem($permissionName, $id, $permissionArray); - - - //setPermissions for Submit items - $permissionGroup = 'groupsSubmit'; - $permissionName = 'equipment_submit'; - $permissionArray = Request::getArray($permissionGroup, ''); - $permissionArray[] = XOOPS_GROUP_ADMIN; - //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid); - $permHelper->savePermissionForItem($permissionName, $id, $permissionArray); - - //setPermissions for Approve items - $permissionGroup = 'groupsModeration'; - $permissionName = 'equipment_approve'; - $permissionArray = Request::getArray($permissionGroup, ''); - $permissionArray[] = XOOPS_GROUP_ADMIN; - //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid); - $permHelper->savePermissionForItem($permissionName, $id, $permissionArray); - -/* - //Form equipment_view - $arr_equipment_view = Request::getArray('cat_gperms_read'); + function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid) + { + $permissionArray = $myArray; if ($id > 0) { - $sql - = - 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name`='equipment_view' AND `gperm_itemid`=$id;"; + $sql = 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name` = '" . $permissionName . "' AND `gperm_itemid`= $id;"; $GLOBALS['xoopsDB']->query($sql); } //admin $gperm = $gpermHandler->create(); $gperm->setVar('gperm_groupid', XOOPS_GROUP_ADMIN); - $gperm->setVar('gperm_name', 'equipment_view'); + $gperm->setVar('gperm_name', $permissionName); $gperm->setVar('gperm_modid', $mid); $gperm->setVar('gperm_itemid', $id); $gpermHandler->insert($gperm); unset($gperm); - if (is_array($arr_equipment_view)) { - foreach ($arr_equipment_view as $key => $cat_groupperm) { - $gperm = $gpermHandler->create(); - $gperm->setVar('gperm_groupid', $cat_groupperm); - $gperm->setVar('gperm_name', 'equipment_view'); - $gperm->setVar('gperm_modid', $mid); - $gperm->setVar('gperm_itemid', $id); - $gpermHandler->insert($gperm); - unset($gperm); + //non-Admin groups + if (is_array($permissionArray)) { + foreach ($permissionArray as $key => $cat_groupperm) { + if ($cat_groupperm > 0) { + $gperm = $gpermHandler->create(); + $gperm->setVar('gperm_groupid', $cat_groupperm); + $gperm->setVar('gperm_name', $permissionName); + $gperm->setVar('gperm_modid', $mid); + $gperm->setVar('gperm_itemid', $id); + $gpermHandler->insert($gperm); + unset($gperm); + } } - } else { + } elseif ($permissionArray > 0) { $gperm = $gpermHandler->create(); - $gperm->setVar('gperm_groupid', $arr_equipment_view); - $gperm->setVar('gperm_name', 'equipment_view'); + $gperm->setVar('gperm_groupid', $permissionArray); + $gperm->setVar('gperm_name', $permissionName); $gperm->setVar('gperm_modid', $mid); $gperm->setVar('gperm_itemid', $id); $gpermHandler->insert($gperm); unset($gperm); } -*/ + } + + //setPermissions for View items + $permissionGroup = 'groupsRead'; + $permissionName = 'equipment_view'; + $permissionArray = Request::getArray($permissionGroup, ''); + $permissionArray[] = XOOPS_GROUP_ADMIN; + //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid); + $permHelper->savePermissionForItem($permissionName, $id, $permissionArray); + + //setPermissions for Submit items + $permissionGroup = 'groupsSubmit'; + $permissionName = 'equipment_submit'; + $permissionArray = Request::getArray($permissionGroup, ''); + $permissionArray[] = XOOPS_GROUP_ADMIN; + //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid); + $permHelper->savePermissionForItem($permissionName, $id, $permissionArray); + + //setPermissions for Approve items + $permissionGroup = 'groupsModeration'; + $permissionName = 'equipment_approve'; + $permissionArray = Request::getArray($permissionGroup, ''); + $permissionArray[] = XOOPS_GROUP_ADMIN; + //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid); + $permHelper->savePermissionForItem($permissionName, $id, $permissionArray); + + /* + //Form equipment_view + $arr_equipment_view = Request::getArray('cat_gperms_read'); + if ($id > 0) { + $sql + = + 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name`='equipment_view' AND `gperm_itemid`=$id;"; + $GLOBALS['xoopsDB']->query($sql); + } + //admin + $gperm = $gpermHandler->create(); + $gperm->setVar('gperm_groupid', XOOPS_GROUP_ADMIN); + $gperm->setVar('gperm_name', 'equipment_view'); + $gperm->setVar('gperm_modid', $mid); + $gperm->setVar('gperm_itemid', $id); + $gpermHandler->insert($gperm); + unset($gperm); + if (is_array($arr_equipment_view)) { + foreach ($arr_equipment_view as $key => $cat_groupperm) { + $gperm = $gpermHandler->create(); + $gperm->setVar('gperm_groupid', $cat_groupperm); + $gperm->setVar('gperm_name', 'equipment_view'); + $gperm->setVar('gperm_modid', $mid); + $gperm->setVar('gperm_itemid', $id); + $gpermHandler->insert($gperm); + unset($gperm); + } + } else { + $gperm = $gpermHandler->create(); + $gperm->setVar('gperm_groupid', $arr_equipment_view); + $gperm->setVar('gperm_name', 'equipment_view'); + $gperm->setVar('gperm_modid', $mid); + $gperm->setVar('gperm_itemid', $id); + $gpermHandler->insert($gperm); + unset($gperm); + } + */ -//=============================================================== + //=============================================================== if ($descHandler->insert($descObject)) { redirect_header('desc.php?op=list', 2, AM_EQUIPMENT_FORMOK); @@ -345,16 +331,16 @@ function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permiss echo $descObject->getHtmlErrors(); $form = $descObject->getForm(); $form->display(); - break; + break; case 'edit': $adminObject->addItemButton(AM_EQUIPMENT_ADD_DESC, 'desc.php?op=new', 'add'); $adminObject->addItemButton(AM_EQUIPMENT_DESC_LIST, 'desc.php', 'list'); echo $adminObject->displayButton('left'); $descObject = $descHandler->get(Request::getString('id', '')); - $form = $descObject->getForm(); + $form = $descObject->getForm(); $form->display(); - break; + break; case 'delete': $descObject = $descHandler->get(Request::getString('id', '')); @@ -370,7 +356,7 @@ function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permiss } else { xoops_confirm(array('ok' => 1, 'id' => Request::getString('id', ''), 'op' => 'delete'), Request::getCmd('REQUEST_URI', '', 'SERVER'), sprintf(AM_EQUIPMENT_FORMSUREDEL, $descObject->getVar('id'))); } - break; + break; case 'clone': @@ -382,6 +368,6 @@ function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permiss redirect_header('desc.php', 3, AM_EQUIPMENT_CLONED_FAILED); } - break; + break; } require_once __DIR__ . '/admin_footer.php'; diff --git a/admin/index.php b/admin/index.php index 8f9e2dc..b56258d 100644 --- a/admin/index.php +++ b/admin/index.php @@ -14,7 +14,7 @@ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package * @since - * @author XOOPS Development Team + * @author XOOPS Development Team */ require_once __DIR__ . '/admin_header.php'; diff --git a/admin/menu.php b/admin/menu.php index 38e7b41..bfdccf8 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -1,6 +1,6 @@ loadLanguage('modinfo'); $moduleHelper->loadLanguage('main'); - $adminmenu = [ [ 'title' => _MI_EQUIPMENT_MENU0, @@ -53,13 +52,13 @@ ], [ 'title' => MI_EQUIPMENT_ADMENU6, - 'link' => 'admin/borrow.php', + 'link' => 'admin/borrow.php', 'desc' => MI_EQUIPMENT_ADMENU6_DESC, 'icon' => $pathIcon32 . '/user-icon.png' ], [ 'title' => MI_EQUIPMENT_ADMENU7, - 'link' => 'admin/permissions.php', + 'link' => 'admin/permissions.php', 'desc' => MI_EQUIPMENT_ADMENU7_DESC, 'icon' => $pathIcon32 . '/permissions.png' ], diff --git a/admin/permissions.php b/admin/permissions.php index 27cfbf2..f18e93d 100644 --- a/admin/permissions.php +++ b/admin/permissions.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -20,14 +21,15 @@ * @link https://xoops.org/ * @since 1.0.0 */ + use Xmf\Module\Admin; use Xmf\Request; require_once __DIR__ . '/admin_header.php'; xoops_cp_header(); -require_once XOOPS_ROOT_PATH.'/class/xoopsform/grouppermform.php'; +require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; if ('' != Request::getString('submit', '')) { - redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['xoopsModule']->dirname().'/admin/permissions.php', 1, AM_EQUIPMENT_PERMISSIONS__GPERMUPDATED); + redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->dirname() . '/admin/permissions.php', 1, AM_EQUIPMENT_PERMISSIONS__GPERMUPDATED); } // Check admin have access to this page /*$group = $GLOBALS['xoopsUser']->getGroups (); @@ -37,9 +39,9 @@ }*/ $adminObject->displayNavigation(basename(__FILE__)); -$permission = Request::getInt('permission', 1, 'POST'); -$selected = array('', '', '', ''); -$selected[$permission-1] = ' selected'; +$permission = Request::getInt('permission', 1, 'POST'); +$selected = array('', '', '', ''); +$selected[$permission - 1] = ' selected'; echo "
@@ -47,10 +49,10 @@ @@ -60,27 +62,29 @@ $module_id = $GLOBALS['xoopsModule']->getVar('mid'); switch ($permission) { case 1: - $formTitle = AM_EQUIPMENT_PERMISSIONS_GLOBAL; - $permName = 'equipment_ac'; - $permDesc = AM_EQUIPMENT_PERMISSIONS_GLOBAL_DESC; - $globalPerms = array( '4' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_4, - '8' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_8, - '16' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_16 ); + $formTitle = AM_EQUIPMENT_PERMISSIONS_GLOBAL; + $permName = 'equipment_ac'; + $permDesc = AM_EQUIPMENT_PERMISSIONS_GLOBAL_DESC; + $globalPerms = array( + '4' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_4, + '8' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_8, + '16' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_16 + ); break; case 2: $formTitle = AM_EQUIPMENT_PERMISSIONS_APPROVE; - $permName = 'equipment_approve'; - $permDesc = AM_EQUIPMENT_PERMISSIONS_APPROVE_DESC; + $permName = 'equipment_approve'; + $permDesc = AM_EQUIPMENT_PERMISSIONS_APPROVE_DESC; break; case 3: $formTitle = AM_EQUIPMENT_PERMISSIONS_SUBMIT; - $permName = 'equipment_submit'; - $permDesc = AM_EQUIPMENT_PERMISSIONS_SUBMIT_DESC; + $permName = 'equipment_submit'; + $permDesc = AM_EQUIPMENT_PERMISSIONS_SUBMIT_DESC; break; case 4: $formTitle = AM_EQUIPMENT_PERMISSIONS_VIEW; - $permName = 'equipment_view'; - $permDesc = AM_EQUIPMENT_PERMISSIONS_VIEW_DESC; + $permName = 'equipment_view'; + $permDesc = AM_EQUIPMENT_PERMISSIONS_VIEW_DESC; break; } @@ -96,7 +100,7 @@ $criteria->setSort('id'); $criteria->setOrder('ASC'); $desc_count = $descHandler->getCount($criteria); - $descArray = $descHandler->getObjects($criteria); + $descArray = $descHandler->getObjects($criteria); unset($criteria); foreach (array_keys($descArray) as $i) { $permform->addItem($descArray[$i]->getVar('id'), $descArray[$i]->getVar('id')); diff --git a/blocks/borrow.php b/blocks/borrow.php index 16b5ea2..4b86fe7 100644 --- a/blocks/borrow.php +++ b/blocks/borrow.php @@ -33,14 +33,14 @@ function showEquipmentBorrow($options) $moduleDirName = basename(dirname(__DIR__)); //$myts = MyTextSanitizer::getInstance(); - $block = array(); - $blockType = $options[0]; + $block = array(); + $blockType = $options[0]; $borrowCount = $options[1]; //$titleLenght = $options[2]; /** @var XoopsObjectHandler $borrowHandler */ $borrowHandler = xoops_getModuleHandler('borrow', $moduleDirName); - $criteria = new CriteriaCompo(); + $criteria = new CriteriaCompo(); array_shift($options); array_shift($options); array_shift($options); @@ -58,6 +58,7 @@ function showEquipmentBorrow($options) return $block; } + /** * @param $options * @@ -69,13 +70,13 @@ function editEquipmentBorrow($options) $moduleDirName = basename(dirname(__DIR__)); $form = MB_EQUIPMENT_DISPLAY; - $form .= ""; - $form .= " 
"; - $form .= MB_EQUIPMENT_TITLELENGTH." :

"; - + $form .= ""; + $form .= " 
"; + $form .= MB_EQUIPMENT_TITLELENGTH . " :

"; + /** @var XoopsObjectHandler $'. borrow . 'Handler */ $borrowHandler = xoops_getModuleHandler('borrow', $moduleDirName); - $criteria = new CriteriaCompo(); + $criteria = new CriteriaCompo(); array_shift($options); array_shift($options); array_shift($options); @@ -83,11 +84,11 @@ function editEquipmentBorrow($options) $criteria->setSort('id'); $criteria->setOrder('ASC'); $borrowArray = $borrowHandler->getAll($criteria); - $form .= MB_EQUIPMENT_CATTODISPLAY."
"; + $form .= "'; foreach (array_keys($borrowArray) as $i) { - $id = $borrowArray[$i]->getVar('id'); - $form .= "'; + $id = $borrowArray[$i]->getVar('id'); + $form .= "'; } $form .= ''; diff --git a/blocks/desc.php b/blocks/desc.php index 24f9429..df12df8 100644 --- a/blocks/desc.php +++ b/blocks/desc.php @@ -33,14 +33,14 @@ function showEquipmentDesc($options) $moduleDirName = basename(dirname(__DIR__)); //$myts = MyTextSanitizer::getInstance(); - $block = array(); + $block = array(); $blockType = $options[0]; $descCount = $options[1]; //$titleLenght = $options[2]; /** @var XoopsObjectHandler $descHandler */ $descHandler = xoops_getModuleHandler('desc', $moduleDirName); - $criteria = new CriteriaCompo(); + $criteria = new CriteriaCompo(); array_shift($options); array_shift($options); array_shift($options); @@ -54,11 +54,12 @@ function showEquipmentDesc($options) $descArray = $descHandler->getAll($criteria); foreach (array_keys($descArray) as $i) { $block[$i]['owner'] = $descArray[$i]->getVar('owner'); - $block[$i]['name'] = $descArray[$i]->getVar('name'); + $block[$i]['name'] = $descArray[$i]->getVar('name'); } return $block; } + /** * @param $options * @@ -70,13 +71,13 @@ function editEquipmentDesc($options) $moduleDirName = basename(dirname(__DIR__)); $form = MB_EQUIPMENT_DISPLAY; - $form .= ""; - $form .= " 
"; - $form .= MB_EQUIPMENT_TITLELENGTH." :

"; - + $form .= ""; + $form .= " 
"; + $form .= MB_EQUIPMENT_TITLELENGTH . " :

"; + /** @var XoopsObjectHandler $'. desc . 'Handler */ $descHandler = xoops_getModuleHandler('desc', $moduleDirName); - $criteria = new CriteriaCompo(); + $criteria = new CriteriaCompo(); array_shift($options); array_shift($options); array_shift($options); @@ -84,11 +85,11 @@ function editEquipmentDesc($options) $criteria->setSort('id'); $criteria->setOrder('ASC'); $descArray = $descHandler->getAll($criteria); - $form .= MB_EQUIPMENT_CATTODISPLAY."
"; + $form .= "'; foreach (array_keys($descArray) as $i) { - $id = $descArray[$i]->getVar('id'); - $form .= "'; + $id = $descArray[$i]->getVar('id'); + $form .= "'; } $form .= ''; diff --git a/class/borrow.php b/class/borrow.php index 9166d5d..951e243 100644 --- a/class/borrow.php +++ b/class/borrow.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -20,13 +21,13 @@ * @link https://xoops.org/ * @since 1.0.0 */ + use Xmf\Module\Helper\Permission; $moduleDirName = basename(dirname(__DIR__)); $permHelper = new Permission($moduleDirName); - /** * Class EquipmentBorrow */ @@ -56,15 +57,17 @@ public function getForm() require_once XOOPS_ROOT_PATH . '/modules/equipment/class/form/borrow.php'; $form = new EquipmentBorrowForm($this); + return $form; } - - /** + + /** * @return array|null */ public function getGroupsRead() { global $permHelper; + //return $this->publisher->getHandler('permission')->getGrantedGroupsById('borrow_read', id); return $permHelper->getGroupsForItem('sbcolumns_read', $this->getVar('id')); } @@ -75,8 +78,9 @@ public function getGroupsRead() public function getGroupsSubmit() { global $permHelper; -// return $this->publisher->getHandler('permission')->getGrantedGroupsById('borrow_submit', id); - return $permHelper->getGroupsForItem('sbcolumns_submit', $this->getVar('id')); + + // return $this->publisher->getHandler('permission')->getGrantedGroupsById('borrow_submit', id); + return $permHelper->getGroupsForItem('sbcolumns_submit', $this->getVar('id')); } /** @@ -85,14 +89,15 @@ public function getGroupsSubmit() public function getGroupsModeration() { global $permHelper; -// return $this->publisher->getHandler('permission')->getGrantedGroupsById('borrow_moderation', id); + + // return $this->publisher->getHandler('permission')->getGrantedGroupsById('borrow_moderation', id); return $permHelper->getGroupsForItem('sbcolumns_moderation', $this->getVar('id')); } } - /** - * Class EquipmentBorrowHandler - */ +/** + * Class EquipmentBorrowHandler + */ class EquipmentBorrowHandler extends XoopsPersistableObjectHandler { /** diff --git a/class/constants.php b/class/constants.php index 80b0591..3e5144a 100644 --- a/class/constants.php +++ b/class/constants.php @@ -32,7 +32,6 @@ * work correctly if trying to upgrade if these values have been changed. * **/ - interface EquipmentConstants { } diff --git a/class/desc.php b/class/desc.php index 6a052fd..590d0e3 100644 --- a/class/desc.php +++ b/class/desc.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -20,13 +21,13 @@ * @link https://xoops.org/ * @since 1.0.0 */ + use Xmf\Module\Helper\Permission; $moduleDirName = basename(dirname(__DIR__)); $permHelper = new Permission($moduleDirName); - /** * Class EquipmentDesc */ @@ -59,15 +60,17 @@ public function getForm() require_once XOOPS_ROOT_PATH . '/modules/equipment/class/form/desc.php'; $form = new EquipmentDescForm($this); + return $form; } - - /** + + /** * @return array|null */ public function getGroupsRead() { global $permHelper; + //return $this->publisher->getHandler('permission')->getGrantedGroupsById('desc_read', id); return $permHelper->getGroupsForItem('sbcolumns_read', $this->getVar('id')); } @@ -78,8 +81,9 @@ public function getGroupsRead() public function getGroupsSubmit() { global $permHelper; -// return $this->publisher->getHandler('permission')->getGrantedGroupsById('desc_submit', id); - return $permHelper->getGroupsForItem('sbcolumns_submit', $this->getVar('id')); + + // return $this->publisher->getHandler('permission')->getGrantedGroupsById('desc_submit', id); + return $permHelper->getGroupsForItem('sbcolumns_submit', $this->getVar('id')); } /** @@ -88,14 +92,15 @@ public function getGroupsSubmit() public function getGroupsModeration() { global $permHelper; -// return $this->publisher->getHandler('permission')->getGrantedGroupsById('desc_moderation', id); + + // return $this->publisher->getHandler('permission')->getGrantedGroupsById('desc_moderation', id); return $permHelper->getGroupsForItem('sbcolumns_moderation', $this->getVar('id')); } } - /** - * Class EquipmentDescHandler - */ +/** + * Class EquipmentDescHandler + */ class EquipmentDescHandler extends XoopsPersistableObjectHandler { /** diff --git a/class/form/borrow.php b/class/form/borrow.php index ebafebf..925664d 100644 --- a/class/form/borrow.php +++ b/class/form/borrow.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -20,7 +21,7 @@ * @link https://xoops.org/ * @since 1.0.0 */ - + use Xmf\Request; use Xmf\Module\Helper; use Xmf\Module\Helper\Permission; @@ -28,16 +29,18 @@ require_once __DIR__ . '/../../include/config.php'; $moduleDirName = basename(dirname(dirname(__DIR__))); -$moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName); -$permHelper = new Permission($moduleDirName); +$moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName); +$permHelper = new Permission($moduleDirName); xoops_load('XoopsFormLoader'); + /** * Class EquipmentBorrowForm */ class EquipmentBorrowForm extends XoopsThemeForm { public $targetObject; + /** * Constructor * @@ -51,23 +54,20 @@ public function __construct($target) $title = $this->targetObject->isNew() ? sprintf(AM_EQUIPMENT_BORROW_ADD) : sprintf(AM_EQUIPMENT_BORROW_EDIT); parent::__construct($title, 'form', xoops_getenv('PHP_SELF'), 'post', true); $this->setExtra('enctype="multipart/form-data"'); - - //include ID field, it's needed so the module knows if it is a new form or an edited form - $hidden = new XoopsFormHidden('id', $this->targetObject->getVar('id')); $this->addElement($hidden); unset($hidden); - -// Id - $this->addElement(new XoopsFormLabel(AM_EQUIPMENT_BORROW_ID, $this->targetObject->getVar('id'), 'id')); - // Borrower + + // Id + $this->addElement(new XoopsFormLabel(AM_EQUIPMENT_BORROW_ID, $this->targetObject->getVar('id'), 'id')); + // Borrower $this->addElement(new XoopsFormText(AM_EQUIPMENT_BORROW_BORROWER, 'borrower', 50, 255, $this->targetObject->getVar('borrower')), false); // Amount $this->addElement(new XoopsFormText(AM_EQUIPMENT_BORROW_AMOUNT, 'amount', 50, 255, $this->targetObject->getVar('amount')), false); - + $this->addElement(new XoopsFormHidden('op', 'save')); $this->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); } diff --git a/class/form/desc.php b/class/form/desc.php index 83bbcbb..8f4b103 100644 --- a/class/form/desc.php +++ b/class/form/desc.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -20,7 +21,7 @@ * @link https://xoops.org/ * @since 1.0.0 */ - + use Xmf\Request; use Xmf\Module\Helper; use Xmf\Module\Helper\Permission; @@ -28,16 +29,18 @@ require_once __DIR__ . '/../../include/config.php'; $moduleDirName = basename(dirname(dirname(__DIR__))); -$moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName); -$permHelper = new Permission($moduleDirName); +$moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName); +$permHelper = new Permission($moduleDirName); xoops_load('XoopsFormLoader'); + /** * Class EquipmentDescForm */ class EquipmentDescForm extends XoopsThemeForm { public $targetObject; + /** * Constructor * @@ -51,19 +54,16 @@ public function __construct($target) $title = $this->targetObject->isNew() ? sprintf(AM_EQUIPMENT_DESC_ADD) : sprintf(AM_EQUIPMENT_DESC_EDIT); parent::__construct($title, 'form', xoops_getenv('PHP_SELF'), 'post', true); $this->setExtra('enctype="multipart/form-data"'); - - //include ID field, it's needed so the module knows if it is a new form or an edited form - $hidden = new XoopsFormHidden('id', $this->targetObject->getVar('id')); $this->addElement($hidden); unset($hidden); - -// Id - $this->addElement(new XoopsFormLabel(AM_EQUIPMENT_DESC_ID, $this->targetObject->getVar('id'), 'id')); - // Owner + + // Id + $this->addElement(new XoopsFormLabel(AM_EQUIPMENT_DESC_ID, $this->targetObject->getVar('id'), 'id')); + // Owner $this->addElement(new XoopsFormText(AM_EQUIPMENT_DESC_OWNER, 'owner', 50, 255, $this->targetObject->getVar('owner')), false); // Name $this->addElement(new XoopsFormText(AM_EQUIPMENT_DESC_NAME, 'name', 50, 255, $this->targetObject->getVar('name')), false); @@ -74,37 +74,37 @@ public function __construct($target) // Image_b64 $image_b64 = $this->targetObject->getVar('image_b64') ?: 'blank.png'; - $uploadDir = '/uploads/equipment/images/'; - $imgtray = new XoopsFormElementTray(AM_EQUIPMENT_DESC_IMAGE_B64, '
'); - $imgpath = sprintf(AM_EQUIPMENT_FORMIMAGE_PATH, $uploadDir); + $uploadDir = '/uploads/equipment/images/'; + $imgtray = new XoopsFormElementTray(AM_EQUIPMENT_DESC_IMAGE_B64, '
'); + $imgpath = sprintf(AM_EQUIPMENT_FORMIMAGE_PATH, $uploadDir); $imageselect = new XoopsFormSelect($imgpath, 'image_b64', $image_b64); - $imageArray = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadDir); + $imageArray = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadDir); foreach ($imageArray as $image) { $imageselect->addOption("$image", $image); } - $imageselect->setExtra("onchange='showImgSelected(\"image_image_b64\", \"image_b64\", \"".$uploadDir.'", "", "'.XOOPS_URL."\")'"); + $imageselect->setExtra("onchange='showImgSelected(\"image_image_b64\", \"image_b64\", \"" . $uploadDir . '", "", "' . XOOPS_URL . "\")'"); $imgtray->addElement($imageselect); - $imgtray->addElement(new XoopsFormLabel('', "
")); + $imgtray->addElement(new XoopsFormLabel('', "
")); $fileseltray = new XoopsFormElementTray('', '
'); $fileseltray->addElement(new XoopsFormFile(AM_EQUIPMENT_FORMUPLOAD, 'image_b64', xoops_getModuleOption('maxsize'))); $fileseltray->addElement(new XoopsFormLabel('')); $imgtray->addElement($fileseltray); $this->addElement($imgtray); - + //permissions /** @var XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); - $groupList = $memberHandler->getGroupList(); + $memberHandler = xoops_getHandler('member'); + $groupList = $memberHandler->getGroupList(); /** @var XoopsGroupPermHandler $gpermHandler */ $gpermHandler = xoops_getHandler('groupperm'); - $fullList = array_keys($groupList); + $fullList = array_keys($groupList); -//======================================================================== + //======================================================================== - $mid = $GLOBALS['xoopsModule']->mid(); + $mid = $GLOBALS['xoopsModule']->mid(); $groupIdAdmin = 0; $groupNameAdmin = ''; - + // create admin checkbox foreach ($groupList as $groupId => $groupName) { if ($groupId == XOOPS_GROUP_ADMIN) { @@ -119,17 +119,17 @@ public function __construct($target) // ******************************************************** // permission view items - $cat_gperms_read = $gpermHandler->getGroupIds('equipment_view', $this->targetObject->getVar('id'), $mid); + $cat_gperms_read = $gpermHandler->getGroupIds('equipment_view', $this->targetObject->getVar('id'), $mid); $arr_cat_gperms_read = $this->targetObject->isNew() ? '0' : $cat_gperms_read; $permsTray = new XoopsFormElementTray(AM_EQUIPMENT_PERMISSIONS_VIEW, ''); - + $selectAllReadCheckbox = new XoopsFormCheckBox('', 'adminbox1', 1); $selectAllReadCheckbox->addOption('allbox', _AM_SYSTEM_ALL); $selectAllReadCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox1\" , \"groupsRead[]\");' "); $selectAllReadCheckbox->setClass('xo-checkall'); $permsTray->addElement($selectAllReadCheckbox); - + // checkbox webmaster $permsTray->addElement($selectPermAdmin, false); // checkboxes other groups @@ -151,13 +151,13 @@ public function __construct($target) $arr_cat_gperms_create = $this->targetObject->isNew() ? '0' : $cat_gperms_create; $permsTray = new XoopsFormElementTray(AM_EQUIPMENT_PERMISSIONS_SUBMIT, ''); - + $selectAllSubmitCheckbox = new XoopsFormCheckBox('', 'adminbox2', 1); $selectAllSubmitCheckbox->addOption('allbox', _AM_SYSTEM_ALL); $selectAllSubmitCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox2\" , \"groupsSubmit[]\");' "); $selectAllSubmitCheckbox->setClass('xo-checkall'); $permsTray->addElement($selectAllSubmitCheckbox); - + // checkbox webmaster $permsTray->addElement($selectPermAdmin, false); // checkboxes other groups @@ -178,13 +178,13 @@ public function __construct($target) $arr_cat_gperms_admin = $this->targetObject->isNew() ? '0' : $cat_gperms_admin; $permsTray = new XoopsFormElementTray(AM_EQUIPMENT_PERMISSIONS_APPROVE, ''); - + $selectAllModerateCheckbox = new XoopsFormCheckBox('', 'adminbox3', 1); $selectAllModerateCheckbox->addOption('allbox', _AM_SYSTEM_ALL); $selectAllModerateCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox3\" , \"groupsModeration[]\");' "); $selectAllModerateCheckbox->setClass('xo-checkall'); $permsTray->addElement($selectAllModerateCheckbox); - + // checkbox webmaster $permsTray->addElement($selectPermAdmin, false); // checkboxes other groups @@ -199,7 +199,7 @@ public function __construct($target) $this->addElement($permsTray, false); unset($permsTray, $selectPerm); -//========================================================================= + //========================================================================= $this->addElement(new XoopsFormHidden('op', 'save')); $this->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); } diff --git a/class/utility.php b/class/utility.php index 45f2359..bd048f2 100644 --- a/class/utility.php +++ b/class/utility.php @@ -186,7 +186,8 @@ public static function createFolder($folder) } file_put_contents($folder . '/index.html', ''); } - } catch (Exception $e) { + } + catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), '', '
'; } } diff --git a/header.php b/header.php index b7c59c2..7efbb0a 100644 --- a/header.php +++ b/header.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -26,21 +27,19 @@ //require_once dirname(dirname(__DIR__)) . '/mainfile.php'; - $path = (dirname(dirname(__DIR__))); require_once $path . '/include/cp_header.php'; require_once XOOPS_ROOT_PATH . '/header.php'; - $moduleDirName = basename(__DIR__); +$moduleDirName = basename(__DIR__); $moduleHelper = Helper::getHelper($moduleDirName); -$modulePath = XOOPS_ROOT_PATH. '/modules/'.$moduleDirName; +$modulePath = XOOPS_ROOT_PATH . '/modules/' . $moduleDirName; require_once __DIR__ . '/include/config.php'; require_once __DIR__ . '/class/utility.php'; - -$myts = MyTextSanitizer::getInstance(); +$myts = MyTextSanitizer::getInstance(); $stylesheet = "modules/{$moduleDirName}/assets/css/style.css"; if (file_exists($GLOBALS['xoops']->path($stylesheet))) { $GLOBALS['xoTheme']->addStylesheet($GLOBALS['xoops']->url("www/{$stylesheet}")); diff --git a/include/config.php b/include/config.php index bfd0550..cffc6af 100644 --- a/include/config.php +++ b/include/config.php @@ -26,16 +26,16 @@ $pathIcon32 = Xmf\Module\Admin::menuIconPath(''); $moduleDirName = basename(dirname(__DIR__)); -$capsDirName = strtoupper($moduleDirName); +$capsDirName = strtoupper($moduleDirName); //if (!defined($moduleDirName . '_DIRNAME')) { if (@!defined('MD_' . constant($capsDirName . '_DIRNAME'))) { define('MD_' . $capsDirName . '_DIRNAME', $moduleDirName); define('MD_' . $capsDirName . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant('MD_' . $capsDirName . '_DIRNAME')); define('MD_' . $capsDirName . '_URL', XOOPS_URL . '/modules/' . constant('MD_' . $capsDirName . '_DIRNAME')); - // define('MD_' . $capsDirName . '_ADMIN', constant('MD_' . $capsDirName . '_URL') . '/admin/index.php'); + // define('MD_' . $capsDirName . '_ADMIN', constant('MD_' . $capsDirName . '_URL') . '/admin/index.php'); define('MD_' . $capsDirName . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . constant('MD_' . $capsDirName . '_DIRNAME')); - //define('MD_' . $capsDirName . '_AUTHOR_LOGOIMG', constant($capsDirName . '_URL') . '/assets/images/logoModule.png'); + //define('MD_' . $capsDirName . '_AUTHOR_LOGOIMG', constant($capsDirName . '_URL') . '/assets/images/logoModule.png'); define($capsDirName . '_AUTHOR_LOGOIMG', $pathIcon32 . '/xoopsmicrobutton.gif'); } @@ -43,7 +43,7 @@ //$img_dir = $GLOBALS['xoopsModuleConfig']['uploadDir']; -define($capsDirName . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' .$moduleDirName); // WITHOUT Trailing slash +define($capsDirName . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash //define("XXXXXX_UPLOAD_PATH", $img_dir); // WITHOUT Trailing slash define($capsDirName . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash @@ -51,9 +51,7 @@ //$copyright = " // {$mod_a_w_name}"; $copyright = " - XOOPS Project"; - - + XOOPS Project"; //constant($cloned_lang . '_CATEGORY_NOTIFY') /* @@ -78,13 +76,13 @@ //Configurator return array( - 'name' => 'Module Configurator', - 'uploadFolders' => array( + 'name' => 'Module Configurator', + 'uploadFolders' => array( constant($capsDirName . '_UPLOAD_PATH'), constant($capsDirName . '_UPLOAD_PATH') . '/images', constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails' ), - 'copyBlankFiles' => array( + 'copyBlankFiles' => array( constant($capsDirName . '_UPLOAD_PATH'), constant($capsDirName . '_UPLOAD_PATH') . '/images', constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails' @@ -100,7 +98,7 @@ '/include/update_functions.php', '/include/install_functions.php' ), - 'oldFolders' => array( + 'oldFolders' => array( '/images', '/css', '/js', diff --git a/include/notification.inc.php b/include/notification.inc.php index 06762e0..be74b82 100644 --- a/include/notification.inc.php +++ b/include/notification.inc.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -33,14 +34,14 @@ function equipment_notify_iteminfo($category, $item_id) { $moduleDirName = basename(dirname(__DIR__)); - + if (empty($GLOBALS['xoopsModule']) || $GLOBALS['xoopsModule']->getVar('dirname') !== 'equipment') { /** @var XoopsModuleHandler $moduleHandler */ $moduleHandler = xoops_getHandler('module'); - $module = $moduleHandler->getByDirname('equipment'); + $module = $moduleHandler->getByDirname('equipment'); /** @var XoopsConfigHandler \$modConfigHandler */ $configHandler = xoops_getHandler('config'); - $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); + $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); } else { $module = $GLOBALS['xoopsModule']; $config = $GLOBALS['xoopsModuleConfig']; @@ -50,31 +51,32 @@ function equipment_notify_iteminfo($category, $item_id) if ('global' === $category) { $item['name'] = ''; - $item['url'] = ''; + $item['url'] = ''; return $item; } if ('category' === $category) { // Assume we have a valid category id - $sql = 'SELECT _title FROM ' . $GLOBALS['xoopsDB']->prefix('equipment_cat') . ' WHERE _cid = '.$item_id; - $result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check + $sql = 'SELECT _title FROM ' . $GLOBALS['xoopsDB']->prefix('equipment_cat') . ' WHERE _cid = ' . $item_id; + $result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check $resultArrayay = $GLOBALS['xoopsDB']->fetchArray($result); - $item['name'] = $resultArrayay['_title']; - $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/cat_view.php?_cid=' . $item_id; + $item['name'] = $resultArrayay['_title']; + $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/cat_view.php?_cid=' . $item_id; return $item; } if ('' == $category) { // Assume we have a valid link id - $sql = 'SELECT _cid, _title FROM '.$GLOBALS['xoopsDB']->prefix('equipment_borrow') . ' WHERE _lid = ' . $item_id; - $result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check + $sql = 'SELECT _cid, _title FROM ' . $GLOBALS['xoopsDB']->prefix('equipment_borrow') . ' WHERE _lid = ' . $item_id; + $result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check $resultArrayay = $GLOBALS['xoopsDB']->fetchArray($result); - $item['name'] = $resultArrayay['title']; - $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/equipment_visit.php?_cid=' . $resultArrayay['_cid'] . '&_lid=' . $item_id; + $item['name'] = $resultArrayay['title']; + $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/equipment_visit.php?_cid=' . $resultArrayay['_cid'] . '&_lid=' . $item_id; return $item; } + return null; } diff --git a/include/oninstall.php b/include/oninstall.php index 963876e..91070ab 100644 --- a/include/oninstall.php +++ b/include/oninstall.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -20,6 +21,7 @@ * @link https://xoops.org/ * @since 1.0.0 */ + use Xmf\Language; /** @@ -48,8 +50,10 @@ function xoops_module_pre_install_equipment(XoopsModule $module) foreach ($mod_tables as $table) { $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); } + return true; } + /** * * Performs tasks required during installation of the module @@ -64,13 +68,13 @@ function xoops_module_install_equipment(XoopsModule $module) $moduleDirName = basename(dirname(__DIR__)); xoops_loadLanguage('admin', $moduleDirName); xoops_loadLanguage('modinfo', $moduleDirName); - $configurator = include __DIR__ . '/config.php'; + $configurator = include __DIR__ . '/config.php'; $classUtility = ucfirst($moduleDirName) . 'Utility'; if (!class_exists($classUtility)) { xoops_load('utility', $moduleDirName); } global $xoopsModule; - // default Permission Settings + // default Permission Settings $moduleId = $xoopsModule->getVar('mid'); //$moduleName = $xoopsModule->getVar('name'); //$moduleDirName = $xoopsModule->getVar('dirname'); @@ -82,7 +86,7 @@ function xoops_module_install_equipment(XoopsModule $module) $gpermHandler->addRight('equipment_view', 1, XOOPS_GROUP_ADMIN, $moduleId); $gpermHandler->addRight('equipment_view', 1, XOOPS_GROUP_USERS, $moduleId); $gpermHandler->addRight('equipment_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); - + // --- CREATE FOLDERS --------------- if (count($configurator['uploadFolders']) > 0) { // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { @@ -98,5 +102,6 @@ function xoops_module_install_equipment(XoopsModule $module) $classUtility::copyFile($file, $dest); } } + return true; } diff --git a/include/onupdate.php b/include/onupdate.php index 488cd4f..2a25087 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -9,6 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * Module: Equipment * @@ -21,13 +22,10 @@ * @since 1.0.0 */ - - use Xmf\Language; if ((!defined('XOOPS_ROOT_PATH')) || !$GLOBALS['xoopsUser'] instanceof XoopsUser - || !$GLOBALS['xoopsUser']->IsAdmin() -) { + || !$GLOBALS['xoopsUser']->IsAdmin()) { exit('Restricted access' . PHP_EOL); } @@ -43,7 +41,6 @@ function tableExists($tablename) return ($GLOBALS['xoopsDB']->getRowsNum($result) > 0); } - /** * * Prepares system prior to attempting to install module @@ -84,7 +81,7 @@ function xoops_module_update_equipment(XoopsModule $module, $previousVersion = n { // global $xoopsDB; $moduleDirName = basename(dirname(__DIR__)); - $capsDirName = strtoupper($moduleDirName); + $capsDirName = strtoupper($moduleDirName); if ($previousVersion < 240) { $configurator = include __DIR__ . '/config.php'; @@ -93,7 +90,6 @@ function xoops_module_update_equipment(XoopsModule $module, $previousVersion = n xoops_load('utility', $moduleDirName); } - //delete old HTML templates if (count($configurator['templateFolders']) > 0) { foreach ($configurator['templateFolders'] as $folder) { @@ -112,7 +108,6 @@ function xoops_module_update_equipment(XoopsModule $module, $previousVersion = n } } - // --- DELETE OLD FILES --------------- if (count($configurator['oldFiles']) > 0) { // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { @@ -131,7 +126,7 @@ function xoops_module_update_equipment(XoopsModule $module, $previousVersion = n foreach (array_keys($configurator['oldFolders']) as $i) { $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator['oldFolders'][$i]); /** @var XoopsObjectHandler $folderHandler */ - $folderHandler = XoopsFile::getHandler('folder', $tempFolder); + $folderHandler = XoopsFile::getHandler('folder', $tempFolder); $folderHandler->delete($tempFolder); } } @@ -154,10 +149,9 @@ function xoops_module_update_equipment(XoopsModule $module, $previousVersion = n } //delete .html entries from the tpl table - $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', - 'n') - . "' AND `tpl_file` LIKE '%.html%'"; + $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; $GLOBALS['xoopsDB']->queryF($sql); } + return true; } diff --git a/include/search.inc.php b/include/search.inc.php index a0d86fc..ec8d94a 100644 --- a/include/search.inc.php +++ b/include/search.inc.php @@ -20,36 +20,36 @@ * @link https://xoops.org/ * @since 1.0.0 */ - /** +/** * equipment_search * * @return array|bool */ function equipment_search($queryarray, $andor, $limit, $offset, $userid) { - $sql = 'SELECT id, borrower FROM '.$GLOBALS['xoopsDB']->prefix('equipment_borrow').' WHERE _online = 1'; + $sql = 'SELECT id, borrower FROM ' . $GLOBALS['xoopsDB']->prefix('equipment_borrow') . ' WHERE _online = 1'; if ($userid !== 0) { - $sql .= ' AND _submitter='.(int)$userid; + $sql .= ' AND _submitter=' . (int)$userid; } if (is_array($queryarray) && $count = count($queryarray)) { - $sql .= ' AND ((borrower LIKE '%$queryarray[0]%')'; + $sql .= ' AND ((borrower LIKE ' % $queryarray[0] % ')'; - for ($i=1;$i<$count;++$i) { + for ($i = 1; $i < $count; ++$i) { $sql .= " $andor "; - $sql .= '(borrower LIKE '%$queryarray[0]%')'; + $sql .= '(borrower LIKE ' % $queryarray[0] % ')'; } $sql .= ')'; } - $sql .= ' ORDER BY id DESC'; + $sql .= ' ORDER BY id DESC'; $result = $GLOBALS['xoopsDB']->query($sql, $limit, $offset); - $ret = array(); - $i = 0; + $ret = array(); + $i = 0; while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { $ret[$i]['image'] = 'assets/images/icons/32/_search.png'; - $ret[$i]['link'] = 'borrow.php?id='.$myrow['id']; + $ret[$i]['link'] = 'borrow.php?id=' . $myrow['id']; $ret[$i]['title'] = $myrow['borrower']; ++$i; } diff --git a/index.php b/index.php index 89af9ed..2f5faef 100644 --- a/index.php +++ b/index.php @@ -6,12 +6,11 @@ require_once __DIR__ . '/include/config.php'; /** @var EquipmentDescHandler $descHandler */ -$json_data = $descHandler->getDataJson(); +$json_data = $descHandler->getDataJson(); $xoopsTpl->assign('json_data', $json_data); - /** @var EquipmentBorrowHandler $borrowHandler */ -$borrow_data = $borrowHandler->getDataJson(); +$borrow_data = $borrowHandler->getDataJson(); $xoopsTpl->assign('borrow_data', $borrow_data); include_once XOOPS_ROOT_PATH . '/footer.php'; diff --git a/language/english/main.php b/language/english/main.php index 4945ae3..abb9143 100644 --- a/language/english/main.php +++ b/language/english/main.php @@ -1,6 +1,5 @@ '1.01', 'module_status' => 'Beta 1', 'release_date' => '2017/07/05', @@ -29,7 +29,7 @@ 'config' => [], // ------------------- Install/Update ------------------- 'onInstall' => 'include/oninstall.php', -// 'onUpdate' => 'include/onupdate.php', + // 'onUpdate' => 'include/onupdate.php', // 'onUninstall' => 'include/onuninstall.php', // ------------------- Mysql ----------------------------- 'sqlfile' => ['mysql' => 'sql/mysql.sql'], @@ -40,8 +40,6 @@ ], ]; - - // ------------------- Help files ------------------- // $modversion['helpsection'] = array( ['name' => _MI_EQUIPMENT_OVERVIEW, 'link' => 'page=help'],