public function processValues($values)
 {
     $values = parent::processValues($values);
     if (isset($values['mailing_list_id'])) {
         $ml_id = $values['mailing_list_id'];
         if ($ml_id) {
             if (strpos($ml_id, 'c') === 0) {
                 $ml_id = substr($ml_id, 1);
                 $source_target_list = MailingListTable::getInstance()->findById($ml_id, true);
                 $copy_target_list = MailingListTable::getInstance()->copy($source_target_list, $this->getObject()->getCampaign(), $source_target_list->getName() . ' copy ' . gmdate('Y-m-d H:i'));
                 if ($copy_target_list) {
                     $user = $this->getOption(self::USER, null);
                     /* @var $user sfGuardUser */
                     $tr = new TargetListRights();
                     $tr->setMailingListId($copy_target_list->getId());
                     $tr->setUserId($user->getId());
                     $tr->setActive(1);
                     $tr->save();
                     $this->getObject()->setMailingList($copy_target_list);
                     $values['mailing_list_id'] = $copy_target_list->getId();
                 } else {
                     throw new Exception('target list copy error');
                 }
             } else {
                 $this->getObject()->setMailingList(MailingListTable::getInstance()->findById($ml_id, true));
             }
         } else {
             $ml = new MailingList();
             $ml->setCampaignId($this->getObject()->getCampaignId());
             $ml->setStatus(MailingListTable::STATUS_DRAFT);
             $ml->setName($this->getObject()->getName() . ' Target-List ' . gmdate('Y-m-d H:i'));
             $this->getObject()->setMailingList($ml);
         }
     }
     if ($this->getObject()->isGeoKind()) {
         $target_choices = $target_choices = $this->getObject()->getMailingList()->getTargetChoices();
         $set = array();
         foreach (array($this->getValue('target_selector_1'), $this->getValue('target_selector_2')) as $ts) {
             if ($ts && array_key_exists($ts, $target_choices)) {
                 $set[] = $ts;
             }
         }
         $values['email_targets'] = json_encode($set);
     }
     return $values;
 }
 public function processValues($values)
 {
     $values = parent::processValues($values);
     if ($this->getObject()->isEmailKind()) {
         if ($this->getObject()->getKind() == Petition::KIND_OLD_EMAIL_ACTION || $this->getObject()->getKind() == Petition::KIND_EMAIL_ACTION) {
             $email_targets = array();
             for ($i = 1; $i <= 3; $i++) {
                 $name = $this->getValue("email_target_name_{$i}");
                 $email = $this->getValue("email_target_email_{$i}");
                 if (!empty($email)) {
                     $email_targets[$email] = empty($name) ? '' : $name;
                 }
             }
             $values['email_targets'] = json_encode($email_targets);
         }
     }
     return $values;
 }