@staticmethod
def getInstalls(db, user):
    """
        Return a list of extension installs in effect for the specified user

        If 'user' is None, all universal extension installs are listed.

        Each install is returned as a tuple containing four elements, the
        extension id, the version id, the version SHA-1 and a boolean which is
        true if the install is universal.  For a LIVE version, the version id
        and the version SHA-1 are None.

        The list of installs is ordered by precedence; most significant install
        first, least significant install last.
        """
    cursor = db.cursor()
    cursor.execute(
        """SELECT extensioninstalls.id, extensioninstalls.extension,
                                 extensionversions.id, extensionversions.sha1,
                                 extensioninstalls.uid IS NULL
                            FROM extensioninstalls
                 LEFT OUTER JOIN extensionversions ON (extensionversions.id=extensioninstalls.version)
                           WHERE uid=%s OR uid IS NULL
                        ORDER BY uid NULLS FIRST"""
        , (user.id if user else None,))
    install_per_extension = {}
    for install_id, extension_id, version_id, version_sha1, is_universal in cursor:
        install_per_extension[extension_id
            ] = install_id, version_id, version_sha1, is_universal
    installs = [(install_id, extension_id, version_id, version_sha1,
        is_universal) for extension_id, (install_id, version_id,
        version_sha1, is_universal) in install_per_extension.items()]
    installs.sort(reverse=True)
    return [(extension_id, version_id, version_sha1, is_universal) for _,
        extension_id, version_id, version_sha1, is_universal in installs]
