public function processSave() { global $cookie; $obj = parent::processSave(); if (!Module::isInstalled('agilemultipleseller')) { return $obj; } if ($this->is_seller) { AgileSellerManager::assignObjectOwner('feature', $obj->id, $cookie->id_employee); } else { AgileSellerManager::assignObjectOwner('feature', $obj->id, Tools::getValue('id_seller')); } return $obj; }
public function init() { parent::init(); ${"GLOBALS"}["tvubeipssbhz"] = "id_product"; $bxgngnjmt = "action"; $this->orderBy = Tools::getValue("agile_orderby"); $this->orderWay = Tools::getValue("agile_orderway"); $cegzdngh = "id_product"; ${$bxgngnjmt} = Tools::getValue("process"); ${$cegzdngh} = Tools::getValue("id_product"); if (isset(${${"GLOBALS"}["xmejvhmbjf"]}) && isset(${${"GLOBALS"}["tvubeipssbhz"]})) { ${"GLOBALS"}["qcujxbitt"] = "action"; $ljdeuuxtnpu = "action"; if (${${"GLOBALS"}["qcujxbitt"]} == "delete") { $this->sellerinfo = new SellerInfo(SellerInfo::getIdByCustomerId($this->context->customer->id), $this->context->language->id); if ($this->sellerinfo->id_seller > 0 and $this->sellerinfo->id_seller == AgileSellerManager::getObjectOwnerID("product", ${${"GLOBALS"}["kswjllrrkq"]})) { ${"GLOBALS"}["jbichwqsqmye"] = "product"; $gmydjry = "product"; ${${"GLOBALS"}["xbssqyr"]} = new Product((int) ${${"GLOBALS"}["kswjllrrkq"]}); $this->beforeDelete(${${"GLOBALS"}["jbichwqsqmye"]}); if (!$product->delete()) { $this->errors[] = Tools::displayError("Error occured during deleting the product."); } $this->afterDelete(${$gmydjry}, $product->id); } else { $this->errors[] = Tools::displayError("You do not have permission to delete this product or the product is not found."); } } else { if (${${"GLOBALS"}["xmejvhmbjf"]} == "inactive" || ${$ljdeuuxtnpu} == "active") { $gvvbmjfbht = "id_product"; ${${"GLOBALS"}["xbssqyr"]} = new Product((int) ${$gvvbmjfbht}); $product->active = !$product->active; $product->update(); $this->sellerinfo = new SellerInfo(SellerInfo::getIdByCustomerId($this->context->customer->id), $this->context->language->id); AgileSellerManager::assignObjectOwner("product", ${${"GLOBALS"}["kswjllrrkq"]}, $this->sellerinfo->id_seller); } } } }
private function assign_entity_owner() { global $cookie; if (!Module::isInstalled('agilemultipleseller')) { return true; } if (isset($_GET['status' . $this->table])) { return true; } $eaccess = AgileSellerManager::get_entity_access($this->table); if ($eaccess['owner_table_type'] == AgileSellerManager::OWNER_TABLE_UNKNOWN) { return true; } include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/agilemultipleseller.php"; global $cookie; if (empty($eaccess['owner_xr_table'])) { $is_seller = $cookie->profile == (int) Configuration::get('AGILE_MS_PROFILE_ID'); if ($is_seller and (Tools::getValue('controller') == 'AdminCarrierWizard' or isset($_GET['submitAdd' . $this->table]) or isset($_POST['submitAdd' . $this->table]) or isset($_POST['submitAdd' . $this->table . 'AndStay']) or isset($_POST['import']) and $_POST['import'] = 1 and isset($_POST['csv']))) { $id_seller = $cookie->id_employee; } elseif (isset($_POST['id_seller'])) { $id_seller = intval($_POST['id_seller']); } else { $id_seller = 0; } AgileSellerManager::assignObjectOwner($this->table, $this->id, $id_seller); } return true; }
public static function createSellerAccount($customer) { $toqkiomv = "customer"; global $cookie; if (!Validate::isLoadedObject(${$toqkiomv})) { return; } require_once dirname(__FILE__) . "/SellerInfo.php"; $sid = AgileSellerManager::getLinkedSellerID($customer->id); if ($sid > 0) { return; } ${${"GLOBALS"}["qkyaztoiww"]} = Address::getFirstCustomerAddressId($customer->id, true); $quvvpsbmm = "address"; ${${"GLOBALS"}["ttgfmxhakl"]} = new Address(intval(${${"GLOBALS"}["qkyaztoiww"]})); if (!Validate::isLoadedObject(${$quvvpsbmm})) { $address->id_country = Configuration::get("PS_COUNTRY_DEFAULT"); } if (Employee::employeeExists($customer->email)) { $ixpzflfvjdl = "emp"; ${"GLOBALS"}["tuwsmwyun"] = "seller_emp"; ${$ixpzflfvjdl} = new Employee(); ${${"GLOBALS"}["tuwsmwyun"]} = $emp->getByEmail($customer->email); } else { $jdiwblvo = "seller_emp"; ${$jdiwblvo} = new Employee(); $seller_emp->firstname = $customer->firstname; $seller_emp->lastname = $customer->lastname; $seller_emp->email = $customer->email; $seller_emp->id_profile = (int) Configuration::get("AGILE_MS_PROFILE_ID"); $seller_emp->active = intval(Configuration::get("AGILE_MS_SELLER_APPROVAL")) == 1 ? 0 : 1; $seller_emp->id_lang = $cookie->id_lang; $seller_emp->passwd = $customer->passwd; $seller_emp->default_tab = Tab::getIdFromClassName("AdminProducts"); $seller_emp->bo_theme = "default"; $seller_emp->optin = 0; $seller_emp->add(); } AgileSellerManager::assignObjectOwner("customer", $customer->id, $seller_emp->id); ${"GLOBALS"}["pienutr"] = "customer"; ${${"GLOBALS"}["atnqtpp"]} = self::createSellerInfo(${${"GLOBALS"}["pienutr"]}, ${${"GLOBALS"}["ttgfmxhakl"]}, ${${"GLOBALS"}["mbnicd"]}); self::sendNewSellerAccountEmail($sellerinfo->id); }
public function processDuplicate() { if (!Module::isInstalled('agilemultipleseller')) { parent::processDuplicate(); } else { if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) { $id_product_old = $product->id; if (empty($product->price) && Shop::getContext() == Shop::CONTEXT_GROUP) { $shops = ShopGroup::getShopsFromGroup(Shop::getContextShopGroupID()); foreach ($shops as $shop) { if ($product->isAssociatedToShop($shop['id_shop'])) { $product_price = new Product($id_product_old, false, null, $shop['id_shop']); $product->price = $product_price->price; } } } unset($product->id); unset($product->id_product); $product->indexed = 0; $product->active = 0; if ($product->add() && Category::duplicateProductCategories($id_product_old, $product->id) && ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false && GroupReduction::duplicateReduction($id_product_old, $product->id) && Product::duplicateAccessories($id_product_old, $product->id) && Product::duplicateFeatures($id_product_old, $product->id) && Product::duplicateSpecificPrices($id_product_old, $product->id) && Pack::duplicate($id_product_old, $product->id) && Product::duplicateCustomizationFields($id_product_old, $product->id) && Product::duplicateTags($id_product_old, $product->id) && Product::duplicateDownload($id_product_old, $product->id)) { if ($product->hasAttributes()) { Product::updateDefaultAttribute($product->id); } AgileSellerManager::assignObjectOwner('product', $product->id, AgileSellerManager::getObjectOwnerID('product', $id_product_old)); if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { $this->errors[] = Tools::displayError('An error occurred while copying images.'); } else { Hook::exec('actionProductAdd', array('product' => $product)); if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) { Search::indexation(false, $product->id); } $this->redirect_after = self::$currentIndex . (Tools::getIsset('id_category') ? '&id_category=' . (int) Tools::getValue('id_category') : '') . '&conf=19&token=' . $this->token; } } else { $this->errors[] = Tools::displayError('An error occurred while creating an object.'); } } } }
private function processSaveProduct() { // die('<pre>' . print_r($_POST, true)); // Address 2 and city /*$_POST['address2_2'] = $_POST['address2_1']; $_POST['city_2'] = $_POST['city_1'];*/ $dateNow = date('ymdhis'); ${"GLOBALS"}["ndtbxrwjprt"] = "limit"; ${"GLOBALS"}["tpztaib"] = "id_default_lang"; if ($this->id_object == 0 and empty($_POST["link_rewrite_" . $this->id_language])) { $_POST["link_rewrite_" . $this->id_language] = $dateNow; } $_POST["link_rewrite_" . 1] = $dateNow; $_POST["link_rewrite_" . 2] = $dateNow; // $_POST["link_rewrite_" . $this->id_language] = Tools::link_rewrite($_POST["name_" . $this->id_language]); if ($this->id_language != 1) { $this->updateProductLangTableToEng(); } else { $this->updateProductLangTableToOther(); } if (empty($_POST['address_1'])) { $_POST['address_1'] = " "; } // die('<pre>' . print_r($_POST, true)); ${${"GLOBALS"}["vqjtbm"]} = intval(Configuration::get("PS_LANG_DEFAULT")); if (${${"GLOBALS"}["tpztaib"]} != $this->id_language) { $rdapymdhyc = "id_default_lang"; if (empty($_POST["link_rewrite_" . ${$rdapymdhyc}])) { $_POST["link_rewrite_" . ${${"GLOBALS"}["vqjtbm"]}] = $_POST["link_rewrite_" . $this->id_language]; } if (empty($_POST["name_" . ${${"GLOBALS"}["vqjtbm"]}])) { $_POST["name_" . ${${"GLOBALS"}["vqjtbm"]}] = $_POST["name_" . $this->id_language]; } } $this->copyFromPost($this->object, $this->table); $this->object->online_only = (int) Tools::getValue("online_only"); $this->object->available_for_order = (int) Tools::getValue("available_for_order"); $this->object->show_price = (int) Tools::getValue("show_price"); if ($this->object->available_for_order) { $this->object->show_price = 1; } ${"GLOBALS"}["jcohmkpwkls"] = "limit"; ${${"GLOBALS"}["pfkeshhubw"]} = (int) Configuration::get("PS_PRODUCT_SHORT_DESC_LIMIT"); if (${${"GLOBALS"}["ndtbxrwjprt"]} <= 0) { ${${"GLOBALS"}["jcohmkpwkls"]} = 800; } if (strlen($this->object->description_short[$this->id_language]) > ${${"GLOBALS"}["pfkeshhubw"]}) { $this->errors[] = Tools::displayError("Short description is too long"); return; } $this->validateRules(); if (count($this->errors) > 0) { return; } if ($this->id_object <= 0) { $this->beforeAdd($this->object); if (method_exists($this->object, "add") && !$this->object->add()) { $this->errors[] = Tools::displayError("An error occurred while creating object.") . " <b>" . $this->table . " (" . Db::getInstance()->getMsgError() . ")</b>"; return; } $qnkriesy = "languages"; AgileSellerManager::assignObjectOwner("product", $this->object->id, $_POST["id_seller"]); $this->afterAdd($this->object); $this->updateAssoShop($this->object->id); StockAvailable::setQuantity($this->object->id, 0, (int) Tools::getValue("quantity")); $this->updateDefaultCategory($this->object->id_category_default, $this->object->id); Hook::exec("actionProductAdd", array("product" => $this->object)); ${${"GLOBALS"}["emgichjdg"]} = Language::getLanguages(false); $this->updateTags(${$qnkriesy}, $this->object); $this->id_object = $this->object->id; $this->object = $this->agileLoadProduct($this->id_object, true); } else { if (method_exists($this->object, "update") && !$this->object->update()) { $this->errors[] = Tools::displayError("An error occurred while updating object.") . " <b>" . $this->table . " (" . Db::getInstance()->getMsgError() . ")</b>"; return; } StockAvailable::setQuantity($this->object->id, 0, (int) Tools::getValue("quantity")); $this->updateDefaultCategory($this->object->id_category_default, $this->object->id); Hook::exec("actionProductUpdate", array("product" => $this->object)); ${${"GLOBALS"}["emgichjdg"]} = Language::getLanguages(false); $this->updateTags(${${"GLOBALS"}["emgichjdg"]}, $this->object); $this->object = $this->agileLoadProduct($this->id_object, true); $this->afterUpdate($this->object); } if ($this->object->id_supplier > 0) { $this->object->addSupplierReference($this->object->id_supplier, 0); } /* die('<pre>' . print_r($this->object, true)); if($this->id_object == 0) Tools::redirect('en');*/ }
public function postProcess() { if (Module::isInstalled('agilemultipleseller') and isset($_POST['assign_all_products']) and intval($_POST['assign_all_products']) == 1 and !$this->is_seller) { AgileSellerManager::assign_all_products_under_category(Tools::getValue('id_category')); $this->confirmations[] = $this->l('You requested has been executed successfully.'); } if (Tools::isSubmit('submitBulkassigntocategory') && !$this->is_seller) { if (isset($_POST[$this->table . 'Box'])) { $categoryids = $_POST[$this->table . 'Box']; foreach ($categoryids as $id) { if (intval($id) <= 0) { continue; } AgileSellerManager::assignObjectOwner('category', $id, Tools::getValue("id_seller")); } } else { $this->errors[] = "No categories was selected to assign."; } return; } parent::postProcess(); }