/**
  * Return a list of group names for this mailing.  Does not work with
  * prior-mailing targets.
  *
  * @return array
  *   Names of groups receiving this mailing
  */
 public function &getGroupNames()
 {
     if (!isset($this->id)) {
         return array();
     }
     $mg = new CRM_Mailing_DAO_MailingGroup();
     $mgtable = CRM_Mailing_DAO_MailingGroup::getTableName();
     $group = CRM_Contact_BAO_Group::getTableName();
     $mg->query("SELECT      {$group}.title as name FROM {$mgtable}\n                    INNER JOIN  {$group} ON {$mgtable}.entity_id = {$group}.id\n                    WHERE       {$mgtable}.mailing_id = {$this->id}\n                        AND     {$mgtable}.entity_table = '{$group}'\n                        AND     {$mgtable}.group_type = 'Include'\n                    ORDER BY    {$group}.name");
     $groups = array();
     while ($mg->fetch()) {
         $groups[] = $mg->name;
     }
     $mg->free();
     return $groups;
 }