function JB_get_default_currency()
{
    static $jb_default_currency;
    if (!isset($jb_default_currency)) {
        if (!($jb_default_currency = jb_cache_get('jb_default_currency'))) {
            $sql = "SELECT code from currencies WHERE is_default='Y' ";
            $result = JB_mysql_query($sql) or die(mysql_error());
            $jb_default_currency = mysql_fetch_array($result, MYSQL_ASSOC);
            jb_cache_set('jb_default_currency', $jb_default_currency);
        }
        return $jb_default_currency['code'];
    }
    return $jb_default_currency['code'];
}
function JB_getCatStruct($cat_id, $lang, $f_id)
{
    if (!is_numeric($f_id)) {
        return false;
    }
    if ($cat_id == false) {
        $cat_id = '0';
    }
    if ($cat_struct = jb_cache_get("cat_f" . $f_id . "_c" . $cat_id . "_" . $_SESSION['LANG'])) {
        return $cat_struct;
    }
    # query to get all the nodes that are the
    # children of child id
    $query = "SELECT categories.category_id, categories.category_name, lang, cat_name_translations.category_name AS NAME, obj_count, seo_fname, has_child FROM categories LEFT JOIN cat_name_translations  ON categories.category_id=cat_name_translations.category_id WHERE parent_category_id='" . jb_escape_sql($cat_id) . "' AND (lang='" . jb_escape_sql($lang) . "') and form_id={$f_id} ORDER BY list_order, NAME ";
    $x = 0;
    $result = JB_mysql_query($query) or die($query . mysql_error());
    $i = 0;
    while ($row = mysql_fetch_row($result)) {
        $children = array();
        if ($row[6] == 'Y') {
            $children = JB_getCategoryChildrenStruct($row[0], $lang, $f_id);
        }
        $category_table[$i]['cid'] = $row[0];
        // category id
        $category_table[$i]['cpid'] = $cat_id;
        // parent id
        // $category_table[$i]['t'] = "PARENT"; // type
        $category_table[$i]['n'] = $row[3];
        // name
        $category_table[$i]['oc'] = $row[4];
        // object count
        $category_table[$i]['ch'] = $children;
        // children
        $category_table[$i]['chc'] = sizeof($children);
        // children count
        $category_table[$i]['seo'] = $row[5];
        // seo file name
        $i++;
    }
    jb_cache_set("cat_f" . $f_id . "_c" . $cat_id . "_" . $_SESSION['LANG'], $category_table);
    return $category_table;
}
Exemple #3
0
function JB_get_post_count($type = '')
{
    static $post_stats;
    if (!isset($post_stats)) {
        // perhaps it's in the cache?
        $post_stats = jb_cache_get('post_stats');
    }
    if (isset($post_stats[$type])) {
        return $post_stats[$type];
    } elseif (isset($post_stats['AP'])) {
        return $post_stats['AP'];
    }
    switch ($type) {
        case 'AP':
            $sql = "SELECT val FROM jb_variables  WHERE `key`='POST_COUNT_AP' ";
            break;
        case 'PAP':
            $sql = "SELECT val FROM jb_variables  WHERE `key`='POST_COUNT_PAP' ";
            break;
        case 'NA':
            $sql = "SELECT val FROM jb_variables  WHERE `key`='POST_COUNT_NA' ";
            break;
        case 'WA':
            $sql = "SELECT val FROM jb_variables  WHERE `key`='POST_COUNT_WA' ";
            break;
        case 'EX':
            $sql = "SELECT val FROM jb_variables  WHERE `key`='POST_COUNT_EX' ";
            break;
        case 'SAP':
            $sql = "SELECT val FROM jb_variables  WHERE `key`='POST_COUNT_SAP' ";
            break;
        default:
            $sql = "SELECT val FROM jb_variables  WHERE `key`='POST_COUNT_AP' ";
            break;
    }
    $result = JB_mysql_query($sql);
    if (mysql_num_rows($result) > 0) {
        $row = mysql_fetch_row($result);
        $post_stats[$type] = $row[0];
        jb_cache_set('post_stats', $post_stats);
        // update the cache
        return $post_stats[$type];
    } else {
        return null;
    }
}
function JB_getCodeDescription($field_id, $code)
{
    $field_id = (int) $field_id;
    if ($jb_code_table = jb_cache_get('jb_code_table_fid_' . $field_id . '_lang_' . $_SESSION['LANG'])) {
        if (isset($jb_code_table[$field_id][$code])) {
            return $jb_code_table[$field_id][$code];
            // return the description
        }
    }
    if ($_SESSION['LANG'] != '') {
        $sql = "SELECT `description` FROM `codes_translations` WHERE field_id='" . jb_escape_sql($field_id) . "' AND `code` = '" . jb_escape_sql($code) . "' AND lang='" . jb_escape_sql($_SESSION['LANG']) . "' ";
    } else {
        $sql = "SELECT `description` FROM `codes` WHERE field_id='" . jb_escape_sql($field_id) . "' AND `code` = '" . jb_escape_sql($code) . "'";
    }
    $result = JB_mysql_query($sql) or die($sql . mysql_error());
    if ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        if (strlen($row['description']) > 0) {
            $jb_code_table[$field_id][$code] = $row['description'];
            jb_cache_set('jb_code_table_fid_' . $field_id . '_lang_' . $_SESSION['LANG'], $jb_code_table);
            return $row['description'];
        }
    } else {
        $jb_code_table[$field_id][$code] = ' ';
        jb_cache_set('jb_code_table_fid_' . $field_id . '_lang_' . $_SESSION['LANG'], $jb_code_table);
        return $row['description'];
    }
}
Exemple #5
0
function JB_echo_list_head_data($form_id, $admin)
{
    global $q_string, $column_list, $column_info;
    # HTML output for this function comes from ListMarkup Class
    # include/themes/default/JBListMarkup.php
    # Any HTML customizations should be done there.
    # Please copy this class in to your custom theme directory, and
    # customize form there
    $LM =& JB_get_ListMarkupObject($form_id);
    // load the ListMarkup Class
    $LM->set_admin($admin);
    if ($form_id == 1) {
        global $JobListAttributes;
        $q_string = $JobListAttributes->get_query_string('&');
    }
    $ord = strtolower($_REQUEST['ord']);
    if ($ord == 'asc') {
        $ord = 'desc';
    } elseif ($ord == 'desc') {
        $ord = 'asc';
    } else {
        $ord = 'asc';
    }
    $colspan = 0;
    if (!($cached_list = jb_cache_get('column_info_' . $form_id))) {
        $sql = "SELECT `template_tag`, `truncate_length`, `admin`, `linked`, `is_bold`, `no_wrap`, `clean_format`, `is_sortable`, `admin`, `field_type` FROM form_lists WHERE form_id='" . jb_escape_sql($form_id) . "' ORDER BY sort_order ASC ";
        $result = JB_mysql_query($sql);
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $cached_list[] = $row;
        }
        jb_cache_set('column_info_' . $form_id, $cached_list);
    }
    foreach ($cached_list as $row) {
        $colspan++;
        $column_list[$row['template_tag']] = $row['template_tag'];
        $column_info[$row['template_tag']]['field_type'] = $row['field_type'];
        $column_info[$row['template_tag']]['trunc'] = $row['truncate_length'];
        $column_info[$row['template_tag']]['admin'] = $row['admin'];
        $column_info[$row['template_tag']]['link'] = $row['linked'];
        $column_info[$row['template_tag']]['is_bold'] = $row['is_bold'];
        $column_info[$row['template_tag']]['no_wrap'] = $row['no_wrap'];
        $column_info[$row['template_tag']]['clean'] = $row['clean_format'];
        $column_info[$row['template_tag']]['is_sortable'] = $row['is_sortable'];
        if ($row['admin'] == 'Y' && !$admin) {
            continue;
            // do not render this column if not viewed by Admin.
        }
        $LM->list_head_cell_open($row['template_tag']);
        if ($row['is_sortable'] == 'Y') {
            // show column order by link?
            $field_id = JB_get_template_field_id($row['template_tag'], $form_id);
            if ($form_id == 1) {
                // posts
                // post summary is not sortable..
                if ($field_id == 'summary') {
                    $field_id = JB_get_template_field_id('TITLE', 1);
                    // order by title instead!
                }
            }
            if ($form_id == 4) {
                // employers
                // post count is not sortable.
                if ($field_id == 'posts') {
                    $row['is_sortable'] = 'N';
                }
                // sort name by last name
                if ($field_id == 'Name') {
                    $field_id = JB_get_template_field_id('LNAME', 4);
                    // order by title instead!
                }
                if ($field_id == 'has_profile') {
                    $row['is_sortable'] = 'N';
                }
            }
            if ($form_id == 5) {
                // candidates
                // resume id is not sortable.
                if ($field_id == 'resume_id') {
                    $row['is_sortable'] = 'N';
                }
                // sort name by last name
                if ($field_id == 'Name') {
                    $field_id = JB_get_template_field_id('LNAME', 5);
                    // order by title instead!
                }
            }
            $LM->list_head_open_link($field_id, $ord, $q_string);
            // output the start of the link
        }
        $LM->list_head_cell_label($column_info[$row['template_tag']], $row['template_tag'], $form_id);
        if ($row['is_sortable'] == 'Y') {
            // show column order by link?
            $LM->list_head_close_link();
        }
        $LM->list_head_cell_close();
    }
    $LM->set_column_list($column_list);
    $LM->set_column_info($column_info);
    return $colspan;
}
function JB_form_mselect_field($field_id, $selected, $size, $mode)
{
    $DFM =& JB_get_DynamicFormMarkupObject($mode);
    if (JB_CODE_ORDER_BY == 'BY_NAME') {
        $order_by = 'description';
    } else {
        $order_by = 'code';
    }
    $selected_codes = explode(",", $selected);
    if ($mode == 'view') {
        require_once dirname(__FILE__) . "/code_functions.php";
        foreach ($selected_codes as $code) {
            echo $comma . JB_getCodeDescription($field_id, $code);
            $comma = ', ';
        }
    } else {
        // load in the options and display them
        if (!($codes_list = jb_cache_get('codes_list_fid_' . $field_id . '_ord_' . $order_by . '_lang_' . $_SESSION['LANG']))) {
            if ($_SESSION['LANG'] != '') {
                $sql = "SELECT * FROM `codes_translations` WHERE `field_id`='" . JB_escape_sql($field_id) . "' and lang='" . JB_escape_sql($_SESSION['LANG']) . "' order by '" . JB_escape_sql($order_by) . "'";
            } else {
                $sql = "SELECT * FROM `codes` WHERE `field_id`='" . JB_escape_sql($field_id) . "' order by '" . JB_escape_sql($order_by) . "'";
            }
            $result = JB_mysql_query($sql) or die(mysql_error());
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $codes_list[] = $row;
            }
            jb_cache_set('codes_list_fid_' . $field_id . '_ord_' . $order_by . '_lang_' . $_SESSION['LANG'], $codes_list);
        }
        $DFM->multiple_select_open($field_id, $size);
        foreach ($codes_list as $row) {
            if (in_array($row['code'], $selected_codes)) {
                $checked = " selected ";
            } else {
                $checked = "";
            }
            if ($mode == 'view') {
                //$disabled = " disabled  ";
            } else {
                $disabled = "";
            }
            $DFM->multiple_select_option($row, $checked);
        }
        $DFM->multiple_select_close();
    }
}