Пример #1
0
function fetch_review_rating($item_id = NULL)
{
    if ($item_id) {
        $query = "SELECT r.rating FROM review r ";
        if (get_opendb_config_var('item_review', 'include_other_title_reviews') === TRUE) {
            $item_r = fetch_item_r($item_id);
            $query .= ", item i " . "WHERE r.item_id = i.id AND (i.id = {$item_id} OR i.title = '" . addslashes($item_r['title']) . "')";
            if (get_opendb_config_var('item_review', 'other_title_reviews_restrict_to_item_type_group') !== FALSE) {
                // first of all we need to get the groups this item belongs to, then we need
                // to get the list of all other s_item_type's that are in those groups.
                $item_type_group_r = fetch_item_type_groups_for_item_type_r($item_r['s_item_type']);
                if (is_array($item_type_group_r)) {
                    $item_type_r = fetch_item_types_for_group_r($item_type_group_r[0]);
                    // only use first one.
                    if (is_array($item_type_r)) {
                        $query .= " AND i.s_item_type IN (" . format_sql_in_clause($item_type_r) . ")";
                    }
                }
            }
        } else {
            $query .= "WHERE r.item_id = {$item_id}";
        }
    } else {
        $query = "SELECT rating FROM review";
    }
    $result = db_query($query);
    if ($result && db_num_rows($result) > 0) {
        // Initialise.
        $total = 0;
        $number = 0;
        while ($review_r = db_fetch_assoc($result)) {
            $total = $total + $review_r['rating'];
            $number++;
        }
        db_free_result($result);
        if ($number == 0) {
            return 0;
        } else {
            return $total / $number;
        }
    }
    //else
    return FALSE;
}
Пример #2
0
        $errors[] = array(error => get_opendb_lang_var('prompt_must_be_specified', 'prompt', get_opendb_lang_var('review')));
    }
    if (get_opendb_config_var('item_review', 'rating_compulsory') == TRUE && strlen($HTTP_VARS['rating']) == 0) {
        $errors[] = array(error => get_opendb_lang_var('prompt_must_be_specified', 'prompt', get_opendb_lang_var('rating')));
    }
    if (is_array($errors)) {
        return FALSE;
    } else {
        return TRUE;
    }
}
if (is_site_enabled()) {
    if (is_opendb_valid_session()) {
        if (is_user_granted_permission(PERM_USER_REVIEWER)) {
            if (is_numeric($HTTP_VARS['item_id']) && ($HTTP_VARS['op'] == 'insert' || $HTTP_VARS['op'] == 'add')) {
                $item_r = fetch_item_r($HTTP_VARS['item_id']);
            } else {
                if (is_numeric($HTTP_VARS['sequence_number']) && ($HTTP_VARS['op'] == 'update' || $HTTP_VARS['op'] == 'delete' || $HTTP_VARS['op'] == 'edit')) {
                    $review_r = fetch_review_r($HTTP_VARS['sequence_number']);
                    // Copy reference only.
                    $item_r = $review_r;
                }
            }
            if (is_not_empty_array($item_r)) {
                $titleMaskCfg = new TitleMask('item_display');
                $item_r['title'] = $titleMaskCfg->expand_item_title($item_r);
                $page_title = get_opendb_lang_var('review_title', 'display_title', $item_r['title']);
                echo _theme_header($page_title);
                echo "<h2>" . $page_title . " " . get_item_image($item_r['s_item_type']) . "</h2>\n";
                if ($HTTP_VARS['op'] == 'insert') {
                    $HTTP_VARS['comment'] = filter_input_field('htmlarea(55,10)', $HTTP_VARS['comment']);
Пример #3
0
function fetch_child_item_r($item_id)
{
    return fetch_item_r($item_id);
}
Пример #4
0
function perform_delete_relation_process(&$item_r, &$status_type_r, &$HTTP_VARS, &$footer_links_r)
{
    global $PHP_SELF;
    global $titleMaskCfg;
    $parent_item_r = fetch_item_r($HTTP_VARS['parent_item_id']);
    do_op_title($parent_item_r, $status_type_r, 'delete_related');
    $errors = null;
    $return_val = handle_item_relation_delete($item_r, $status_type_r, $HTTP_VARS, $errors);
    if ($return_val === "__CONFIRM__") {
        echo get_op_confirm_form($PHP_SELF, get_opendb_lang_var('confirm_delete_relation_title', 'display_title', $titleMaskCfg->expand_item_title($parent_item_r)), $HTTP_VARS);
    } else {
        if ($return_val == "__ABORTED__") {
            echo "<p class=\"success\">" . get_opendb_lang_var('item_relation_not_deleted') . "</p>";
            $footer_links_r[] = array(url => "item_input.php?op=edit&item_id=" . $item_r['item_id'] . "&instance_no=" . $item_r['instance_no'], text => get_opendb_lang_var('back_to_item'));
        } else {
            if ($return_val === FALSE) {
                echo format_error_block($errors);
                $footer_links_r[] = array(url => "item_input.php?op=edit&item_id=" . $item_r['item_id'] . "&instance_no=" . $item_r['instance_no'], text => get_opendb_lang_var('back_to_item'));
            } else {
                echo "<p class=\"success\">" . get_opendb_lang_var('item_relation_deleted') . "</p>";
                $footer_links_r[] = array(url => "item_input.php?op=edit&item_id=" . $item_r['item_id'] . "&instance_no=" . $item_r['instance_no'], text => get_opendb_lang_var('back_to_item'));
            }
        }
    }
}