Example #1
0
 private function _importMenu()
 {
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     db_query("DELETE FROM ?:menus");
     $top_menu_id = Menu::update(array('lang_code' => DEFAULT_LANGUAGE, 'name' => 'Top menu', 'status' => 'A'));
     db_query("UPDATE ?:static_data SET param_5 = ?i WHERE section = 'A'", $top_menu_id);
     $quick_menu_id = Menu::update(array('lang_code' => DEFAULT_LANGUAGE, 'name' => 'Quick menu', 'status' => 'A'));
     db_query("UPDATE ?:static_data SET param_5 = ?i WHERE section = 'N'", $quick_menu_id);
     db_query("UPDATE ?:static_data SET section = 'A' WHERE section = 'N'");
     $blocks = db_get_array("SELECT ?:bm_blocks_content.block_id, content FROM ?:bm_blocks_content " . "LEFT JOIN ?:bm_blocks ON ?:bm_blocks.block_id = ?:bm_blocks_content.block_id " . "WHERE type = 'menu'");
     foreach ($blocks as $block) {
         $content = unserialize($block['content']);
         if (isset($content['menu'])) {
             $content['menu'] = $quick_menu_id;
             db_query("UPDATE ?:bm_blocks_content SET content = ?s WHERE block_id = ?i", serialize($content), $block['block_id']);
         }
     }
 }
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;
}
Example #3
0
/**
 * Gets list of menu items for block menu
 *
 * @param mixed $value Default value of current block content item
 * @param array $block Block params
 * @param array $block_scheme Scheme of block
 * @return array List of menu items
 */
function fn_get_menu_items($value, $block, $block_scheme)
{
    $menu_items = array();
    if (!empty($block['content']['menu']) && Menu::getStatus($block['content']['menu']) == 'A') {
        $params = array('section' => 'A', 'get_params' => true, 'icon_name' => '', 'multi_level' => true, 'use_localization' => true, 'status' => 'A', 'generate_levels' => true, 'request' => array('menu_id' => $block['content']['menu']));
        $menu_items = fn_top_menu_form(fn_get_static_data($params));
        fn_dropdown_appearance_cut_second_third_levels($menu_items, 'subitems', $block['properties']);
    }
    return $menu_items;
}
Example #4
0
            $_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);
}