message_die(GENERAL_ERROR, "Couldn't insert new item_type", "", __LINE__, __FILE__, $sql);
             }
             // Update cache
             include_once $phpbb_root_path . 'adr/includes/adr_functions_cache.' . $phpEx;
             adr_update_item_type();
             adr_previous(Adr_item_type_successful_edited, admin_adr_item_type, '');
             break;
         case 'order':
             $move = intval($_GET['move']);
             $item_type_id = intval($_GET['id']);
             $sql = "UPDATE " . ADR_SHOPS_ITEMS_TYPE_TABLE . "\n\t\t\t\t\t\tSET item_type_order = item_type_order + {$move}\n\t\t\t\t\t\tWHERE item_type_id = {$item_type_id}";
             if (!($result = $db->sql_query($sql))) {
                 message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
             }
             adr_renumber_order();
             adr_update_item_type();
             adr_previous(Adr_item_type_successful_edited, admin_adr_item_type, '');
             break;
     }
 } else {
     adr_template_file('admin/config_adr_item_type_list_body.tpl');
     $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TYPE_TABLE . " ORDER BY item_type_category, item_type_order ASC";
     $result = $db->sql_query($sql);
     if (!$result) {
         message_die(GENERAL_ERROR, 'Could not obtain minerals information', "", __LINE__, __FILE__, $sql);
     }
     $item_type = $db->sql_fetchrowset($result);
     for ($i = 0; $i < count($item_type); $i++) {
         $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
         $template->assign_block_vars("items", array("ROW_CLASS" => $row_class, "NAME" => adr_get_lang($item_type[$i]['item_type_lang']), "ID" => $item_type[$i]['item_type_id'], "PRICE" => $item_type[$i]['item_type_base_price'], "U_ITEM_TYPE_UP" => append_sid("admin_adr_item_type.{$phpEx}?mode=order&amp;move=-15&amp;id=" . $item_type[$i]['item_type_id']), "U_ITEM_TYPE_DOWN" => append_sid("admin_adr_item_type.{$phpEx}?mode=order&amp;move=15&amp;id=" . $item_type[$i]['item_type_id']), "U_ITEM_TYPE_EDIT" => append_sid("admin_adr_item_type.{$phpEx}?mode=edit&amp;id=" . $item_type[$i]['item_type_id']), "U_ITEM_TYPE_DELETE" => append_sid("admin_adr_item_type.{$phpEx}?mode=delete&amp;id=" . $item_type[$i]['item_type_id'])));
         if ($item_type[$i]['item_type_category'] != $prev_cat) {
function adr_get_item_type($type, $mode)
{
    global $db, $lang, $phpEx, $userdata, $phpbb_root_path, $board_config;
    $type = intval($type);
    define('IN_ADR_SHOPS', 1);
    include_once $phpbb_root_path . 'adr/includes/adr_constants.' . $phpEx;
    $cache_config = explode('-', $board_config['Adr_use_cache_system']);
    if ($cache_config[5]) {
        // All the following code has been made by Ptirhiik
        @(include $phpbb_root_path . './adr/cache/cache_item_type.' . $phpEx);
        if (!empty($adr_item_type)) {
            while (list($item_type_id, $item_type_data) = @each($adr_item_type)) {
                $items_type[$item_type_id] = $item_type_data;
            }
        } else {
            $sql = "SELECT * FROM  " . ADR_SHOPS_ITEMS_TYPE_TABLE;
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Unable to query item type infos (cache)', '', __LINE__, __FILE__, $sql);
            }
            @(include $phpbb_root_path . './adr/cache/cache_item_type.' . $phpEx);
            if (empty($adr_item_type)) {
                adr_update_item_type();
                include $phpbb_root_path . './adr/cache/cache_item_type.' . $phpEx;
                while (list($item_type_id, $item_type_data) = @each($adr_item_type)) {
                    $items_type[$item_type_id] = $item_type_data;
                }
            }
        }
    } else {
        $sql = "SELECT * FROM  " . ADR_SHOPS_ITEMS_TYPE_TABLE;
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Unable to query item type infos (non-cache)', '', __LINE__, __FILE__, $sql);
        }
        $items_type = $db->sql_fetchrowset($result);
    }
    switch ($mode) {
        case 'list':
            $item_type = '<select name="item_type_use">';
            for ($l = 1; $l < count($items_type); $l++) {
                $selected = $items_type[$l]['item_type_id'] == $type ? 'selected="selected"' : '';
                $item_type .= '<option value = "' . $items_type[$l]['item_type_id'] . '" ' . $selected . '>' . adr_get_lang($items_type[$l]['item_type_lang']) . '</option>';
            }
            $item_type .= '</select>';
            return $item_type;
            break;
        case 'search':
            $item_type = '<select name="item_type_use">';
            for ($l = 0; $l < count($items_type); $l++) {
                $item_type .= '<option value = "' . $items_type[$l]['item_type_id'] . '" >' . adr_get_lang($items_type[$l]['item_type_lang']) . '</option>';
            }
            $item_type .= '</select>';
            return $item_type;
            break;
        case 'simple':
            $item_type = adr_get_lang($items_type[$type]['item_type_lang']);
            return $item_type;
            break;
        case 'price':
            $item_type = $items_type[$type]['item_type_base_price'];
            return $item_type;
            break;
    }
}
Example #3
0
function adr_get_item_type($type, $mode)
{
    global $db, $lang, $phpEx, $userdata, $phpbb_root_path, $board_config;
    $type = intval($type);
    redefine('IN_ADR_SHOPS', 1);
    include_once $phpbb_root_path . 'adr/includes/adr_constants.' . $phpEx;
    // All the following code has been made by Ptirhiik
    @(include $phpbb_root_path . './adr/cache/cache_item_type.' . $phpEx);
    if (!empty($adr_item_type)) {
        while (list($item_type_id, $item_type_data) = @each($adr_item_type)) {
            $items_type[$item_type_id] = $item_type_data;
        }
    } else {
        adr_update_item_type();
        include $phpbb_root_path . './adr/cache/cache_item_type.' . $phpEx;
        while (list($item_type_id, $item_type_data) = @each($adr_item_type)) {
            $items_type[$item_type_id] = $item_type_data;
        }
    }
    switch ($mode) {
        case 'list':
            $item_type = '<select name="item_type_use">';
            for ($l = 1; $l < count($items_type); $l++) {
                $selected = $items_type[$l]['item_type_id'] == $type ? 'selected="selected"' : '';
                $item_type .= '<option value = "' . $items_type[$l]['item_type_id'] . '" ' . $selected . '>' . adr_get_lang($items_type[$l]['item_type_lang']) . '</option>';
            }
            $item_type .= '</select>';
            return $item_type;
            break;
        case 'search':
            $item_type = '<select name="item_type_use">';
            for ($l = 0; $l < count($items_type); $l++) {
                $item_type .= '<option value = "' . $items_type[$l]['item_type_id'] . '" >' . adr_get_lang($items_type[$l]['item_type_lang']) . '</option>';
            }
            $item_type .= '</select>';
            return $item_type;
            break;
        case 'simple':
            $item_type = adr_get_lang($items_type[$type]['item_type_lang']);
            return $item_type;
            break;
        case 'price':
            $item_type = $items_type[$type]['item_type_base_price'];
            return $item_type;
            break;
    }
}