'?', 'use_name'=>'Unknown', 'use_admin'=>0, 'use_usertype'=>'user', 'g_theme'=>'classic', 'use_login'=>$p_user); $a=pg_fetch_array($Ret,0); return $a; } /* function GetModeleId * Purpose : Give the mod_id from modeledef * * parm : * - p_cn database connection (repository) * - p_modname template name * gen : * - none * return: * template id or 0 if not found */ function GetModeleId($p_cn,$p_modname) { $Res=ExecSql($p_cn,"select mod_id from modeledef where mod_name='$p_modname'"); if (pg_NumRows($Res) == 0) return 0; $name=pg_fetch_array($Res,0); return $name['mod_id']; } /* function GetArray * purpose return the result of a sql statment * in a array * param : $p_cn database connection * $p_sql sql query */ function GetArray($p_cn,$p_sql) { echo_debug(__FILE__,__LINE__,"GetArray"); $r=ExecSql($p_cn,$p_sql); if ( ($Max= pg_NumRows($r)) == 0 ) return null; $array=pg_fetch_all($r); echo_debug(__FILE__,__LINE__,var_export($array,true)); return $array; } /* function save_upload_document * Save a picture of a rest_id * parameters * - $cn database connection * - $file array (from $_FILES) * - $name ( name of the input) */ function save_upload_document ($cn,$seq) { $new_name=tempnam('/tmp','pj'); echo_debug(__FILE__,__LINE__,"new name=".$new_name); if ( strlen ($_FILES['pj']['tmp_name']) != 0 ) { if (move_uploaded_file($_FILES['pj']['tmp_name'], $new_name)) { // echo "Image saved"; $oid= pg_lo_import($cn,$new_name); if ( $oid == false ) { echo_error(__FILE__,__LINE__,"cannot upload document"); Rollback($cn); return; } echo_debug(__FILE__,__LINE__,"Loading document"); // Remove old document $ret=ExecSql($cn,"select jr_pj from jrn where jr_grpt_id=$seq"); if (pg_num_rows($ret) != 0) { $r=pg_fetch_array($ret,0); $old_oid=$r['jr_pj']; if (strlen($old_oid) != 0) pg_lo_unlink($cn,$old_oid); } // Load new document ExecSql($cn,"update jrn set jr_pj=".$oid.", jr_pj_name='".$_FILES['pj']['name']."', ". "jr_pj_type='".$_FILES['pj']['type']."' where jr_grpt_id=$seq"); } else { echo "

Error

"; Rollback($cn); exit; } } } ?>