/**
  * Gets a single addressbook group from the database.
  * Optionally populates it with member contacts.
  * @global moodle_database $DB Moodle database manager
  * @param int $addressbookId Addressbook group is in
  * @param int $groupId ID of group to fetch
  * @param boolean $includeContactsInGroup True to include contacts
  * @return MoodletxtAddressbookGroup
  * @throws InvalidArgumentException
  * @version 2012092401
  * @since 2012091201
  */
 public function getAddressbookGroupById($addressbookId, $groupId, $includeContactsInGroup = false)
 {
     global $DB;
     $groupRecord = $DB->get_record('block_moodletxt_ab_group', array('id' => $groupId, 'addressbook' => $addressbookId));
     if ($groupRecord == null) {
         throw new InvalidArgumentException('The group you specified does not exist within this addressbook.');
     } else {
         $group = new MoodletxtAddressbookGroup($groupRecord->name, (int) $groupRecord->addressbook, (int) $groupRecord->id);
         if ($includeContactsInGroup) {
             $group->setContacts($this->getAddressbookContactsInGroup($group->getId()));
         }
         return $group;
     }
 }