Ould Hamma was sentenced in July to 12 years in prison for organizing the kidnapping of the aid workers and for handing them over to an al-Qaida-linked group in the region , al-Qaida in the Islamic Maghreb .