if (!is_object($item)) { myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl, 5); } $item->unsetNew(); $add = false; } else { $item = $h_myshop_cat->create(true); $add = true; } $opRedirect = 'categories'; $item->setVars($_POST); if (isset($_POST['delpicture']) && intval($_POST['delpicture']) == 1) { $item->deletePicture(); } $destname = ''; $res1 = myshop_utils::uploadFile(0, MYSHOP_PICTURES_PATH); if ($res1 === true) { if (myshop_utils::getModuleOption('resize_others')) { myshop_utils::resizePicture(MYSHOP_PICTURES_PATH . DIRECTORY_SEPARATOR . $destname, MYSHOP_PICTURES_PATH . DIRECTORY_SEPARATOR . $destname, myshop_utils::getModuleOption('images_width'), myshop_utils::getModuleOption('images_height'), true); } $item->setVar('cat_imgurl', basename($destname)); } else { if ($res1 !== false) { echo $res1; } } $res = $h_myshop_cat->insert($item); if ($res) { myshop_utils::updateCache(); if ($add) { $notification_handler =& xoops_gethandler('notification');
xoops_cp_header(); $id = isset($_POST['file_id']) ? intval($_POST['file_id']) : 0; if (!empty($id)) { $edit = true; $item = $h_myshop_files->get($id); if (!is_object($item)) { myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl, 5); } $item->unsetNew(); } else { $item = $h_myshop_files->create(true); } $opRedirect = 'files'; $item->setVars($_POST); $destname = ''; $result = myshop_utils::uploadFile(0, MYSHOP_ATTACHED_FILES_PATH); if ($result === true) { $item->setVar('file_filename', basename($destname)); $item->setVar('file_mimetype', myshop_utils::getMimeType(MYSHOP_ATTACHED_FILES_PATH . DIRECTORY_SEPARATOR . $destname)); } else { if ($result !== false) { myshop_utils::redirect(_AM_MYSHOP_SAVE_PB . '<br />' . $result, $baseurl . '?op=' . $opRedirect, 5); } } $res = $h_myshop_files->insert($item); if ($res) { myshop_utils::updateCache(); myshop_utils::redirect(_AM_MYSHOP_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); } else { myshop_utils::redirect(_AM_MYSHOP_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); }
} else { if ($res2 !== false) { echo $res2; } } } else { $indiceAttached = 1; if (xoops_trim($mainPicture) != '') { $thumbName = MYSHOP_THUMBS_PREFIX . $mainPicture; myshop_utils::resizePicture(MYSHOP_PICTURES_PATH . DIRECTORY_SEPARATOR . $mainPicture, MYSHOP_PICTURES_PATH . DIRECTORY_SEPARATOR . $thumbName, myshop_utils::getModuleOption('thumbs_width'), myshop_utils::getModuleOption('thumbs_height'), true); $item->setVar('product_thumb_url', $thumbName); } } // Download $destname = ''; $res3 = myshop_utils::uploadFile($indiceAttached, MYSHOP_ATTACHED_FILES_PATH); if ($res3 === true) { $item->setVar('product_attachment', basename($destname)); } else { if ($res3 !== false) { echo $res3; } } $res = $h_myshop_products->insert($item); if ($res) { $id = $item->getVar('product_id'); // Notifications if ($add == true) { if (intval($item->getVar('product_online')) == 1) { $notification_handler =& xoops_gethandler('notification'); $tags['PRODUCT_NAME'] = $item->getVar('product_title');