rewriting some queries on notifications package to avoid using subqueries when checking permissions.
getting right name of query by adding the right path of file where query is used.