if (!$C->isUsed()) { $C->Delete(); } else { $content .= "Category has related products, can't delete."; } $view = 'catlist'; break; case 'delete_img': $img_id = (int) $_REQUEST['img_id']; Product::DeleteImage($img_id); $view = 'editproduct'; break; case 'saveproduct': $P = new Product($_POST['id']); if (!$P->Save($_POST)) { $content .= PAYPAL_errMsg($P->PrintErrors()); $view = 'editproduct'; } break; case 'savecat': USES_paypal_class_category(); $C = new Category($_POST['cat_id']); if (!$C->Save($_POST)) { $content .= PAYPAL_popupMsg($LANG_PP['invalid_form']); $view = 'editcat'; } else { $view = 'catlist'; } break; case 'saveopt': USES_paypal_class_attribute();
/** * Creates the edit form. * * @param integer $id Attributeal ID, current record used if zero * @return string HTML for edit form */ function Edit() { global $_TABLES, $_CONF, $_PP_CONF, $LANG_PP; // If there are no products defined, return a formatted error message // instead of the form. if (DB_count($_TABLES['paypal.products']) == 0) { return PAYPAL_errMsg($LANG_PP['todo_noproducts']); } $T = new Template(PAYPAL_PI_PATH . '/templates'); $T->set_file(array('attrform' => 'attribute_form.thtml')); $id = $this->attr_id; // If we have a nonzero category ID, then we edit the existing record. // Otherwise, we're creating a new item. Also set the $not and $items // values to be used in the parent category selection accordingly. if ($id > 0) { $retval = COM_startBlock($LANG_PP['edit'] . ': ' . $this->attr_value); $T->set_var('attr_id', $id); } else { $retval = COM_startBlock($LANG_PP['new_option']); $T->set_var('attr_id', ''); } $T->set_var(array('action_url' => PAYPAL_ADMIN_URL, 'pi_url' => PAYPAL_URL, 'doc_url' => PAYPAL_getDocURL('attribute_form.html', $_CONF['language']), 'attr_value' => $this->attr_value, 'attr_price' => $this->attr_price, 'product_select' => COM_optionList($_TABLES['paypal.products'], 'id,name', $this->item_id), 'option_group_select' => COM_optionList($_TABLES['paypal.prod_attr'], 'DISTINCT attr_name,attr_name', $this->attr_name, 1), 'orderby' => $this->orderby, 'ena_chk' => $this->enabled == 1 ? ' checked="checked"' : '')); $retval .= $T->parse('output', 'attrform'); $retval .= COM_endBlock(); return $retval; }
} } } else { $content .= SEC_loginRequiredForm(); $view = 'none'; } break; case 'savebillto': case 'saveshipto': $addr_type = substr($action, 4); // get 'billto' or 'shipto' USES_paypal_class_userinfo(); USES_paypal_class_workflow(); $status = ppUserInfo::isValidAddress($_POST); if ($status != '') { $content .= PAYPAL_errMsg($status, $LANG_PP['invalid_form']); $view = $addr_type; break; } $U = new ppUserInfo(); if ($U->uid > 1) { $addr_id = $U->SaveAddress($_POST, $addr_type); if ($addr_id[0] < 0) { if (!empty($addr_id[1])) { $content .= PAYPAL_errorMessage($addr_id[1], 'alert', $LANG_PP['missing_fields']); } $view = $addr_type; break; } else { $_POST['useaddress'] = $addr_id[0]; }