From what I can gather:
Enterprise assigned to observe planet Nibiru and the natives before it blows up.
Kirk disobeys orders and decides to save the planet but I assume Spock says they cannot reveal themselves to the natives and Kirk goes along with it.
Planet is saved but Enterprise revealed.
Kirk loses command because of breaking the prime directive, disobeying orders & falsifying the logs?