function fetch_form_list($uid)
{
    global $form_list;
    global $form_list_size;
    // permissions should be incorporated here
    $sql_str = "SELECT " . "tng_form.form_id, " . "tng_form.form_name " . "FROM " . "tng_form " . "INNER JOIN tng_process_form_permissions ON tng_form.form_id = tng_process_form_permissions.form_id " . "WHERE " . "tng_process_form_permissions.uid = " . $_SESSION['obj_login']->uid . " ";
    $dbconn = new DBConn();
    $dbconn->connect();
    $result = pg_query($dbconn->conn, $sql_str);
    if (!$result) {
        echo "An error occurred while executing the query " . pg_last_error($dbconn->conn);
        $dbconn->disconnect();
    } else {
        // successfuly ran the query
        $form_list_size = pg_num_rows($result);
        // fill the array with the form ids and form names.
        // each element in the form_list array is an array
        // of two elements.
        for ($i = 0; $i < $form_list_size; $i++) {
            $form_list[$i] = array(pg_fetch_result($result, $i, 0), pg_fetch_result($result, $i, 1));
        }
    }
    $dbconn->disconnect();
}
function get_form_id($submission_id)
{
    $sql_str = "SELECT " . "form_id " . "FROM " . "tng_form_submission " . "WHERE form_submission_id = " . $submission_id;
    $dbconn = new DBConn();
    if ($dbconn == NULL) {
        die('Could not create connection object');
    }
    $dbconn->connect();
    $result = pg_query($dbconn->conn, $sql_str);
    if (!$result) {
        echo "An error occurred while executing the query - " . $sql_str . " - " . pg_last_error($dbconn->conn);
        $dbconn->disconnect();
        return false;
    }
    $form_id = pg_fetch_result($result, 0, 0);
    $dbconn->disconnect();
    return $form_id;
}
예제 #3
0
 }
 $feature_defn = OGR_L_GetLayerDefn($src_layer);
 /*---------------------------------------------------------------------------------------*/
 /* this is done to find out the geometry type only - should be moved to its own function */
 $feature = OGR_L_GetNextFeature($src_layer);
 $geometry = OGR_F_GetGeometryRef($feature);
 $geom_type = strtolower(OGR_G_GetGeometryName($geometry));
 // execute sql command using form id to find out spatial table name and attribute table
 // namme
 $sql_str = "SELECT " . "tng_spatial_data.table_name, " . "tng_spatial_attribute_table.attr_table_name " . "FROM " . "tng_form_spatial_data " . "INNER JOIN tng_spatial_data ON tng_form_spatial_data.spatial_table_id = tng_spatial_data.spatial_table_id " . "INNER JOIN tng_spatial_attribute_table on tng_form_spatial_data.spatial_table_id = tng_spatial_attribute_table.spatial_table_id " . "WHERE " . "tng_form_spatial_data.form_id = 1 " . "AND " . "tng_spatial_data.geometry_type = '" . $geom_type . "'";
 $dbconn = new DBConn();
 $dbconn->connect();
 $result = pg_query($dbconn->conn, $sql_str);
 if (!$result) {
     echo "An error occurred while executing the query - class_form.php:47 " . pg_last_error($dbconn->conn);
     $dbconn->disconnect();
 } else {
     $dst_layer_name = pg_fetch_result($result, 0, 0);
     $dst_attr_table_name = pg_fetch_result($result, 0, 1);
     $dbconn->disconnect();
 }
 /* end find geometry type */
 /*---------------------------------------------------------------------------------------*/
 /* get the handle for the destination layer */
 $dst_layer = OGR_DS_GetLayerByName($dst_ds, $dst_layer_name);
 if ($dst_layer == NULL) {
     echo "could not create a handle for " . $dst_layer_name;
     exit;
 }
 echo "<br> dst layer : " . $dst_layer_name . "<br>";
 OGR_L_ResetReading($src_layer);