I have always been edified by the availability of our parish priest and his assistant parish priest to celebrate a funeral Mass for the people of our parish who pass away. Even if at times the priests are not able to accompany the burial entourage to the cemetery, the relatives of the faithful departed are always consoled by the Funeral Mass and prayers that our priests piously celebrate in the Church before the actual burial. At times I have seen our parish priest go through this even during hectic holy week schedule or during our fiesta, when obviously there are many other activities requiring his presence. Is he doing this because of some strict obligation or is he just naturally kind? On the other hand, I also remember reading sometime ago that somewhere in Luzon a known Mason was denied ecclesiastical funeral by the Bishop.
What does Canon Law say about this?
What is a Church Funeral?
By a Church funeral¾technically referred to as ecclesiastical funeral rites or collectively just ecclesiastical funeral¾is understood the sacred rites celebrated and suffrages offered by the Church to implore spiritual help in favor of the faithful on the occasion of their death. They are considered not only as private prayers but as liturgical actions of the Church itself (cf. c.837, §1). They correspond to what in the old Code of Canon Law of 1917 was referred to as an ecclesiastical burial¾a term, on the other hand, which was considered too narrow by the framers of the new Code, as it tended to limit its scope to the actual interment.
The new Code of Canon Law establishes the juridic nature of the ecclesiastical funeral¾aside from its obviously theological and pastoral dimensions¾by regulating it in a series of canons (cc.1176-1185). In general terms, the Code establishes its contents in c.1176, §2:
Through ecclesiastical funeral rites the Church asks spiritual assistance for the departed, honors their bodies, and at the same time brings the solace of hope to the living; such rites are to be celebrated according to the norms of liturgical laws.
Thus, they have a threefold aim: 1) to gain spiritual help for the faithful departed, 2) to honor their memory and their mortal remains, and 3) to give the solace of hope to the bereaved living.
On the other hand, the Ritual for Christian Funeral (Cf. Ordo Exequiarum, 15.VIII.1969)¾the main source of the norms of liturgical laws alluded to by c.1176, §2¾goes into the specific details of the ecclesiastical funeral, among which we can mention the following:
1) The principal elements of the funeral rites: Eucharistic celebration, reading of the Word of God, prayers, psalms, final commendation and farewell by the community to one of its members.
2) Three possible places or stations for the celebration of the funeral rites: (1) the house, (2) the church and (3) the final burial place. Thus, depending on the availability of the priest, any one of the three stations can constitute a full funeral rite. In big cities, for example, with the time required to go to the memorial park which are usually in the suburbs, it is quite alright (and in fact usual) for the funeral rite to be limited to the church.
Is There a Right to an Ecclesiastical Funeral?
The Code clearly establishes the right of the faithful to the ecclesiastical funeral rites, as well as the corresponding obligation of the sacred ministers to assure the celebration of the same, in c.1176, §1: The Christian faithful departed are to be given ecclesiastical funeral rites according to the norm of law.
This right and obligation are founded on Christian communion¾i.e., in the participation of the faithful in the life and means of salvation of the Christian community. The Church recognizes the responsibility of delivering these salvific means and thus has instituted the ecclesial funeral rites to help the faithful departed, in the same way that it administers the sacraments and sacramentals to help the living. Thus, Canon Law¾declares an old decree of the former Sacred Congregation of the Council¾strictly commands that ecclesiastical burial be accorded all the baptized, except when they have been expressly deprived of such by the Law. 
Furthermore, the general obligation of the Church to provide the ecclesiastical funeral is specified as one of the special duties of the parish priest by c.530: The following functions are especially entrusted to the pastor… 5°the performing of funerals.
Who have the Right to an Ecclesiastical Funeral?
Can.1176, §1 states the general norm making all those baptized in the Catholic Church subjects of the right to an ecclesiastical funeral: The Christian faithful departed are to be given ecclesiastical funeral rites according to the norms of law.
Can.1183 further expands the scope of the subjects of this right:
¾ §1. As regards funeral rites, catechumens are to be considered member of the Christian faithful. (They are considered baptizati in voto).
¾ §2. The Local Ordinary can permit children to be given ecclesiastical funeral rites if their parents intended to baptize them but they died before their baptism.
¾ §3. In the prudent judgment of the Local Ordinary, ecclesiastical funeral rites can be granted to baptized members of some non-Catholic church or ecclesial community, unless it is evidently contrary to their will and provided their own minister is unavailable.
Can anyone be denied an Ecclesiastical Funeral?
Can.1184 enumerates a series of subjects to be denied ecclesiastical funeral:
¾ §1. Unless they have given some signs of repentance before their death, the following are to be deprived of ecclesiastical funeral rites:
1° notorious apostates, heretics and schismatics;
2° persons who had chosen the cremation of their own bodies for reasons opposed to the Christian faith;
3° other manifests sinners for whom ecclesiastical funeral rites cannot be granted without public scandal to the faithful.
¾ §2. If some doubt should arise, the Local Ordinary is to be consulted; and his judgment is to be followed.
Hence, the following baptized Christians are to be denied ecclesiastical funeral:
1st Notorious apostates (those who publicly renounce adherence to the Catholic Church), heretics (those who publicly renounce adhesion to a specific dogma of the Catholic Church) and schismatics (those who publicly renounce communion with the Church through its visible head who is the Pope). Such persons are in fact publicly expressing a will contrary to an ecclesiastical funeral, and the Church is just respecting such a will.
The logic of this norm becomes even clearer when we keep in mind that apostasy, heresy and schism suppose a pertinacious and notorious will in denying Church doctrine and communion (c.751), and are even typified as canonical crimes (c.1364).
2nd Persons who had chosen the cremation of their own bodies for reasons opposed to the Christian faith¾which would seem to be an altogether rare occurrence nowadays, when people usually choose cremation for reasons that have nothing to do with religious beliefs.
3rd Other manifests sinners¾for the verification of which the Code establishes two concomitant conditions for ecclesiastical funeral to be denied: (1) a manifest or obvious sinful situation, and (2) a clearly foreseen scandal to the faithful should ecclesiastical funeral be granted. If either condition is not verified, therefore, an ecclesiastical funeral should not be denied.
Sometimes, however, the verification of these conditions is not so easy¾either because the objective (manifest) situation of sin may not always coincide with the subjective conscience (guilt) of the subject, or the danger of scandal may be attenuated through adequate instruction of the faithful. Hence, the Code provides that in case of doubt, the Local Ordinary is to be consulted; and his judgment is to be followed.
1) The parish priest is indeed just fulfilling his strict obligation to provide ecclesiastical funeral to his parishioners.
2) In the case of a notorious mason, since membership in a Masonic lodge has been repeatedly condemned by the Catholic Bishops Conference of the Philippines, and in the case of the cited diocese in Nueva Ecija even expressly proscribed by the Local Ordinary¾with the warning precisely of the denial of an ecclesiastical burial¾then the Local Ordinary indeed had the right to judge the case, and deemed it to the interest of the common good of the Christian faithful to deny ecclesiastical funeral to the notorious mason.
 S.C. of the Council, Instruction, 12.I.1924, in AAS 16 (1924), p.189. Cf. CIC 1917, cc.1239 & 1240.