/** * Checks that menu can be modified * * @param int $menu_id Menu identifier * @return bool True if menu can be modified, false otherwise */ function fn_check_menu_owner($menu_id) { $allow = false; if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) { $_menus = Menu::getList(db_quote(" AND ?:menus.menu_id = ?i" . fn_get_company_condition('?:menus.company_id'), $menu_id)); if (count($_menus) > 0) { $allow = true; } } else { $allow = true; } return $allow; }
function fn_delete_company($company_id) { if (empty($company_id)) { return false; } if (fn_allowed_for('MULTIVENDOR')) { // Do not delete vendor if there're any orders associated with this company if (db_get_field("SELECT COUNT(*) FROM ?:orders WHERE company_id = ?i", $company_id)) { fn_set_notification('W', __('warning'), __('unable_delete_vendor_orders_exists'), '', 'company_has_orders'); return false; } } fn_set_hook('delete_company_pre', $company_id); $result = db_query("DELETE FROM ?:companies WHERE company_id = ?i", $company_id); // deleting categories $cat_ids = db_get_fields("SELECT category_id FROM ?:categories WHERE company_id = ?i", $company_id); foreach ($cat_ids as $cat_id) { fn_delete_category($cat_id, false); } // deleting products $product_ids = db_get_fields("SELECT product_id FROM ?:products WHERE company_id = ?i", $company_id); foreach ($product_ids as $product_id) { fn_delete_product($product_id); } // deleting shipping $shipping_ids = db_get_fields("SELECT shipping_id FROM ?:shippings WHERE company_id = ?i", $company_id); foreach ($shipping_ids as $shipping_id) { fn_delete_shipping($shipping_id); } if (fn_allowed_for('ULTIMATE')) { // deleting layouts $layouts = Layout::instance($company_id)->getList(); foreach ($layouts as $layout_id => $layout) { Layout::instance($company_id)->delete($layout_id); } } $blocks = Block::instance($company_id)->getAllUnique(); foreach ($blocks as $block) { Block::instance($company_id)->remove($block['block_id']); } $product_tabs = ProductTabs::instance($company_id)->getList(); foreach ($product_tabs as $product_tab) { ProductTabs::instance($company_id)->delete($product_tab['tab_id'], true); } $_menus = Menu::getList(db_quote(" AND company_id = ?i", $company_id)); foreach ($_menus as $menu) { Menu::delete($menu['menu_id']); } db_query("DELETE FROM ?:company_descriptions WHERE company_id = ?i", $company_id); // deleting product_options $option_ids = db_get_fields("SELECT option_id FROM ?:product_options WHERE company_id = ?i", $company_id); foreach ($option_ids as $option_id) { fn_delete_product_option($option_id); } // deleting company admins and users if (Registry::get('settings.Stores.share_users') != 'Y') { $users_condition = db_quote(' OR company_id = ?i', $company_id); } else { $users_condition = ''; // Unassign users from deleted company db_query('UPDATE ?:users SET company_id = 0 WHERE company_id = ?i', $company_id); } $user_ids = db_get_fields("SELECT user_id FROM ?:users WHERE company_id = ?i AND user_type = ?s ?p", $company_id, 'V', $users_condition); foreach ($user_ids as $user_id) { fn_delete_user($user_id); } // deleting pages $page_ids = db_get_fields("SELECT page_id FROM ?:pages WHERE company_id = ?i", $company_id); foreach ($page_ids as $page_id) { fn_delete_page($page_id); } // deleting promotions $promotion_ids = db_get_fields("SELECT promotion_id FROM ?:promotions WHERE company_id = ?i", $company_id); fn_delete_promotions($promotion_ids); // deleting features $feature_ids = db_get_fields("SELECT feature_id FROM ?:product_features WHERE company_id = ?i", $company_id); foreach ($feature_ids as $feature_id) { fn_delete_feature($feature_id); } // deleting logos $types = fn_get_logo_types(); foreach ($types as $type => $data) { fn_delete_logo($type, $company_id); } $payment_ids = db_get_fields('SELECT payment_id FROM ?:payments WHERE company_id = ?i', $company_id); foreach ($payment_ids as $payment_id) { fn_delete_payment($payment_id); } // Delete sitemap sections and links $params = array('company_id' => $company_id); $section_ids = fn_get_sitemap_sections($params); fn_delete_sitemap_sections(array_keys($section_ids)); fn_set_hook('delete_company', $company_id, $result); return $result; }
$_REQUEST['menu_data']['lang_code'] = DESCR_SL; Menu::update($_REQUEST['menu_data']); } } // // Delete menu // if ($mode == 'delete') { if (!empty($_REQUEST['menu_id'])) { Menu::delete($_REQUEST['menu_id']); } } return array(CONTROLLER_STATUS_OK, 'menus.manage'); } // ---------------------- GET routines --------------------------------------- if ($mode == 'manage') { $menus = Menu::getList('', DESCR_SL); Tygh::$app['view']->assign('menus', $menus); } elseif ($mode == 'update') { $menu_id = isset($_REQUEST['menu_data']['menu_id']) ? $_REQUEST['menu_data']['menu_id'] : 0; if (!empty($_REQUEST['menu_data'])) { $menu_data = $_REQUEST['menu_data']; } else { $menu_data = array(); } // If edit block if ($menu_id > 0 && empty($_REQUEST['menu_data']['content'])) { $menu_data = current(Menu::getList(db_quote(' AND ?:menus.menu_id=?i', $menu_id), DESCR_SL)); } Tygh::$app['view']->assign('menu_data', $menu_data); }