Esempio n. 1
0
        }
        fn_update_sitemap_links($link_data, $section_id);
        $suffix = ".manage";
    }
    return array(CONTROLLER_STATUS_OK, "sitemap{$suffix}");
}
// -------------------------------------- GET requests -------------------------------
// Collect section methods data
if ($mode == 'update') {
    if (empty($section_id)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    $params = array('section_id' => $section_id);
    $sections = fn_get_sitemap_sections($params);
    if (empty($sections)) {
        return array(CONTROLLER_STATUS_DENIED);
    }
    Registry::get('view')->assign('section', reset($sections));
    $links = fn_get_sitemap_links($section_id);
    Registry::get('view')->assign('links', $links);
    // Show all section methods
} elseif ($mode == 'manage') {
    $sections = fn_get_sitemap_sections();
    Registry::get('view')->assign('sitemap_sections', $sections);
} elseif ($mode == 'delete_section') {
    if (!empty($section_id)) {
        fn_delete_sitemap_sections((array) $section_id);
    }
    return array(CONTROLLER_STATUS_REDIRECT, "sitemap.manage");
}
/** /Body **/
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;
}
Esempio n. 3
0
// Collect section methods data
if ($mode == 'update') {
    if (empty($_REQUEST['section_id'])) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    $section = db_get_row("SELECT s.*, c.object as section FROM ?:sitemap_sections as s LEFT JOIN ?:common_descriptions as c ON c.object_id = s.section_id AND object_holder = ?s AND lang_code = ?s WHERE s.section_id = ?i", 'affiliate_plans', DESCR_SL, $_REQUEST['section_id']);
    $view->assign('section', $section);
    $links = db_get_array("SELECT link_id, link_href, section_id, status, position, link_type, description, object as link FROM ?:sitemap_links LEFT JOIN ?:common_descriptions ON ?:common_descriptions.object_id = ?:sitemap_links.link_id AND ?:common_descriptions.object_holder = 'sitemap_links' AND ?:common_descriptions.lang_code = ?s WHERE section_id = ?i ORDER BY position, link", DESCR_SL, $section_id);
    $view->assign('links', $links);
    fn_add_breadcrumb(fn_get_lang_var('sitemap'), "sitemap.manage");
    // Show all section methods
} elseif ($mode == 'manage') {
    $view->assign('sitemap_sections', db_get_array("SELECT *, object as section FROM ?:sitemap_sections LEFT JOIN ?:common_descriptions ON ?:common_descriptions.object_id = ?:sitemap_sections.section_id AND ?:common_descriptions.object_holder = 'sitemap_sections' AND ?:common_descriptions.lang_code = ?s ORDER BY position, section", DESCR_SL));
} elseif ($mode == 'delete_sitemap_section') {
    if (!empty($_REQUEST['section_id'])) {
        fn_delete_sitemap_sections((array) $_REQUEST['section_id']);
    }
    return array(CONTROLLER_STATUS_REDIRECT, "sitemap.manage");
} elseif ($mode == 'delete_link') {
    if (!empty($_REQUEST['link_id'])) {
        fn_delete_sitemap_links((array) $_REQUEST['link_id']);
    }
    return array(CONTROLLER_STATUS_REDIRECT, "sitemap.update?section_id={$section_id}");
}
/** /Body **/
function fn_delete_sitemap_links($link_ids)
{
    db_query("DELETE FROM ?:sitemap_links WHERE link_id IN (?n)", $link_ids);
    db_query("DELETE FROM ?:common_descriptions WHERE object_holder = 'sitemap_links' AND object_id IN (?n)", $link_ids);
}
function fn_delete_sitemap_sections($section_ids)