Example #1
0
                    $errors_found = TRUE;
                }
            }
        }
        if (!$errors_found) {
            $HTTP_VARS['silc_id'] = fetch_s_item_listing_conf_id($HTTP_VARS['s_item_type_group'], $HTTP_VARS['s_item_type']);
            if (is_not_empty_array($column_conf_rs)) {
                // if no parent item_listing_conf record, we must create one now
                if (!is_numeric($HTTP_VARS['silc_id'])) {
                    $HTTP_VARS['silc_id'] = insert_s_item_listing_conf($HTTP_VARS['s_item_type_group'], $HTTP_VARS['s_item_type']);
                }
                // delete all column conf and insert new set
                insert_new_column_conf_set($HTTP_VARS['silc_id'], $column_conf_rs);
            } else {
                if (is_numeric($HTTP_VARS['silc_id'])) {
                    delete_s_item_listing_column_conf($HTTP_VARS['silc_id']);
                    //delete parent too
                    delete_s_item_listing_conf($HTTP_VARS['silc_id']);
                }
            }
        }
        $HTTP_VARS['op'] = 'edit';
    } else {
        //if(is_exists_s_item_listing_conf($HTTP_VARS['silc_id']))
        // error no item found!
        $HTTP_VARS['op'] = '';
    }
}
// in edit mode, either its a new entry, in which case s_item_type_group / s_item_type is chosen, or its
// an existing item, in which case the silc_id will be provided.
if ($HTTP_VARS['op'] == 'edit') {
Example #2
0
/**
   WARNING: Will not perform any data validations
*/
function insert_new_column_conf_set($silc_id, $column_conf_rs)
{
    if (db_query("LOCK TABLES s_item_listing_column_conf WRITE, s_item_listing_conf WRITE")) {
        if (delete_s_item_listing_column_conf($silc_id)) {
            while (list(, $column_conf_r) = each($column_conf_rs)) {
                // there is not a whole lot we can do if this fails, so keep going
                insert_s_item_listing_column_conf($silc_id, $column_conf_r['column_no'], $column_conf_r['column_type'], $column_conf_r['s_field_type'], $column_conf_r['s_attribute_type'], $column_conf_r['override_prompt'], $column_conf_r['printable_support_ind'], $column_conf_r['orderby_support_ind'], $column_conf_r['orderby_datatype'], $column_conf_r['orderby_default_ind'], $column_conf_r['orderby_sort_order'], TRUE);
                //assumes validation already performed
            }
            db_query("UNLOCK TABLES");
            return TRUE;
        } else {
            db_query("UNLOCK TABLES");
            return FALSE;
        }
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error());
        return FALSE;
    }
}