Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.8 kB
2
Indexable
Never
function file_hide( $p_file_id, $p_table = 'bug', $f_future, $t_bug_id, $t_project_id ) {

    $t_diskfile = file_get_field( $p_file_id, 'diskfile' );
    $t_folder = file_get_field( $p_file_id, 'folder' );

    if ($f_future && file_exists($t_folder . $t_diskfile))
    {
        $query = "INSERT INTO mantis_bug_file_table_hidden_project
				( project_id, content)
			  VALUES
				( " . db_param() . ", " . db_param() .  " )";
        db_query_bound( $query, Array(
            $t_project_id,
            md5_file($t_folder . $t_diskfile)));

        $query = "DELETE FROM mantis_bug_file_table_hidden_ticket WHERE
				file_id = " . db_param() ;
        db_query_bound( $query, Array($p_file_id));
    }
    elseif (!$f_future)
    {
        $query = "INSERT INTO mantis_bug_file_table_hidden_ticket(ticket_id, file_id) VALUES(" . db_param() . "," . db_param() . ")";
        db_query_bound( $query, Array( $t_bug_id, $p_file_id ) );
    }
    return true;
}

function file_show( $p_file_id, $p_table = 'bug', $f_future, $t_project_id ) {

    $t_diskfile = file_get_field( $p_file_id, 'diskfile' );
    $t_folder = file_get_field( $p_file_id, 'folder' );

    if ($f_future && file_exists($t_folder . $t_diskfile))
    {
        $query = "DELETE FROM mantis_bug_file_table_hidden_project
				WHERE project_id = " . db_param() . " AND content =  " . db_param();
        db_query_bound( $query, Array(
            $t_project_id,
            md5(file_get_contents($t_folder . $t_diskfile))
        ) );
    }else if(!$f_future)
    {
        $query = "DELETE FROM mantis_bug_file_table_hidden_ticket WHERE
				file_id = " . db_param() ;
        db_query_bound( $query, Array($p_file_id));
    }
    return true;
}