/** * Delete several categories from database * * return boolean Deletion result */ public function deleteSelection($customfields) { $return = 1; foreach ($customfields as $id_loffc_block_item) { $customfield = new LofItem((int) $id_loffc_block_item); $return &= $customfield->delete(); } return $return; }
public function delete() { global $cookie; $res = Db::getInstance()->execute(' DELETE FROM `' . _DB_PREFIX_ . 'loffc_block_shop` WHERE `id_loffc_block` = ' . (int) $this->id); $id_loffc_block = $this->id; $res &= parent::delete(); $return = true; if ($res) { $items = self::getItems($id_loffc_block, $cookie->id_lang); if ($items) { foreach ($items as $i) { $obj = new LofItem($i['id_loffc_block_item']); $return &= $obj->delete(); } } } else { $return &= false; } return $return; }
if (!Validate::isGenericName($val)) { $errors[] = $module->l('the field Title is invalid'); } } if (Tools::getValue('type') == 'link') { if (Tools::getValue('linktype') == 'product' && !Validate::isUnsignedId(Tools::getValue('link_type_product'))) { $errors[] = $module->l('the field Product is invalid'); } } if (Tools::getValue('type') == 'module') { if (!Tools::getValue('module_name') || !Validate::isGenericName(Tools::getValue('module_name')) || !Tools::getValue('hook_name') || !Validate::isGenericName(Tools::getValue('hook_name'))) { $errors[] = $module->l('the field Module is invalid'); } } if (!sizeof($errors)) { $objItem = new LofItem(); $objItem->id_loffc_block_item = Tools::getValue('id_loffc_block_item'); $objItem->id_loffc_block = Tools::getValue('id_loffc_block'); $objItem->type = Tools::getValue('type'); if (Tools::getValue('type') == 'link') { $objItem->linktype = Tools::getValue('linktype'); $objItem->target = Tools::getValue('target'); if (Tools::getValue('linktype') == 'product') { $objItem->link_content = Tools::getValue('link_type_product'); } if (Tools::getValue('linktype') == 'category') { $objItem->link_content = Tools::getValue('link_type_category'); } if (Tools::getValue('linktype') == 'cms') { $objItem->link_content = Tools::getValue('link_type_cms'); }
foreach ($table as $key => $row) { $ids = explode('_', $row); Db::getInstance()->Execute(' UPDATE `' . _DB_PREFIX_ . 'loffc_block_item` SET `position` = ' . (int) $pos . ' WHERE `id_loffc_block_item` = ' . (int) $ids[2] . ' AND `id_loffc_block` = ' . (int) $ids[1]); $pos++; } } } if (isset($_GET['lofajax']) && $_GET['task'] == 'deleteItem') { $json_data = array(); $json_data['result'] = 1; if ($table = Tools::getValue('class_tr')) { $ids = explode('_', $table); if (Validate::isLoadedObject($obj = new LofItem($ids[2]))) { if (!$obj->delete()) { $json_data['result'] = 0; $json_data['error'] = $module->l('can\'t delete'); } } else { $json_data['result'] = 0; $json_data['error'] = $module->l('can\'t create object'); } } die(json_encode($json_data)); } if (isset($_GET['lofajax']) && $_GET['task'] == 'updateBlock') { $json_data = array(); $json_data['result'] = 1; if (Validate::isLoadedObject($obj = new LofBlock(Tools::getValue('id_loffc_block')))) {
/** * Render processing form && process saving data. */ public function getContent() { $html = ""; if (Tools::isSubmit('submit')) { if (!sizeof($this->_postErrors)) { $definedConfigs = array('theme' => '', 'class' => ''); foreach ($definedConfigs as $config => $key) { if (strlen($this->name . '_' . $config) >= 32) { echo $this->name . '_' . $config; } else { Configuration::updateValue($this->name . '_' . $config, Tools::getValue($config), true); } } $html .= '<div class="conf confirm">' . $this->l('Settings updated successful') . '</div>'; } else { foreach ($this->_postErrors as $err) { $html .= '<div class="alert error">' . $err . '</div>'; } } } elseif (isset($_GET['submitDeleteBlock'])) { if (Tools::getValue('id_loffc_block') && Validate::isLoadedObject($obj = new LofBlock(Tools::getValue('id_loffc_block'))) && $obj->delete()) { Tools::redirectAdmin($this->base_config_url . '&lofconf=1'); } else { Tools::redirectAdmin($this->base_config_url . '&lofconf=2'); } } elseif (Tools::isSubmit('submitDeleteData')) { $shops = Tools::getValue('shops'); $items = Db::getInstance()->ExecuteS(' SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_item`'); foreach ($items as $item) { $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'loffc_block_item_shop` WHERE `id_loffc_block_item` = ' . (int) $item['id_loffc_block_item'] . ' AND `id_shop` IN (' . implode(',', $shops) . ')'; Db::getInstance()->execute($sql); $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_item_shop` WHERE `id_loffc_block_item` = ' . (int) $item['id_loffc_block_item']; if (!($result = Db::getInstance()->executes($sql))) { $obj = new LofItem((int) $item['id_loffc_block_item']); $obj->delete(); } } $blocks = Db::getInstance()->ExecuteS(' SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block`'); if ($blocks) { foreach ($blocks as $block) { $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'loffc_block_shop` WHERE `id_loffc_block` = ' . (int) $block['id_loffc_block'] . ' AND `id_shop` IN (' . implode(',', $shops) . ')'; Db::getInstance()->execute($sql); $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'loffc_block_shop` WHERE `id_loffc_block` = ' . (int) $block['id_loffc_block']; if (!($result = Db::getInstance()->executes($sql))) { $obj = new LofBlock((int) $block['id_loffc_block']); $obj->delete(); } } } } $this->_params = new LofFooterCustomParams($this->name, $this->hookAssign); if (Tools::getValue('lofconf') == 1) { $html .= '<div class="conf confirm">' . $this->l('Delete Block successful') . '</div>'; } elseif (Tools::getValue('lofconf') == 2) { $html .= '<div class="alert error">' . $this->l('Delete Block error') . '</div>'; } if (sizeof($this->_postErrors)) { foreach ($this->_postErrors as $err) { $html .= '<div class="alert error">' . $err . '</div>'; } } return $html . $this->_getFormConfig(); }