'?', 'use_name'=>'Unknown', 'use_admin'=>0, 'use_usertype'=>'user', 'g_theme'=>'classic', 'use_login'=>$p_user); $a=pg_fetch_array($Ret,0); return $a; } /*! * \brief Give the mod_id from modeledef * * * \param $p_cn database connection (repository) * \param $p_modname template name * \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']; } /*!\brief purpose return the result of a sql statment * in a array * \param $p_cn database connection * \param $p_sql sql query */ function GetArray($p_cn,$p_sql) { echo_debug('postgres.php',__LINE__,"GetArray"); $r=ExecSql($p_cn,$p_sql); if ( ($Max= pg_NumRows($r)) == 0 ) return null; $array=pg_fetch_all($r); echo_debug('postgres.php',__LINE__,var_export($array,true)); return $array; } /*! save_upload_document * \brief Save a "piece justificative" * * \param $cn database connection * \param $seq jr_grpt_id * \return $oid of the lob file * */ function save_upload_document ($cn,$seq) { $new_name=tempnam('/tmp','pj'); echo_debug('postgres.php',__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('postgres.php',__LINE__,"cannot upload document"); Rollback($cn); return; } echo_debug('postgres.php',__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; } } return $oid; } ?>