alecpl
2010-09-30 ce92ba767a9557daf7f18be94882dd7e6f4591fb
program/steps/addressbook/copy.inc
@@ -37,28 +37,30 @@
    $ids = array();
    foreach ($arr_cids as $cid) {
      $plugin = $RCMAIL->plugins->exec_hook('contact_create', array(
        'record' => $CONTACTS->get_record($cid, true),
        'source' => $target,
        'group' => $target_group,
      ));
      $a_record = $plugin['record'];
      $a_record = $CONTACTS->get_record($cid, true);
      if (!$plugin['abort']) {
        // check if contact exists, if so, we'll need it's ID
        $result = $TARGET->search('email', $a_record['email'], true, true);
      // check if contact exists, if so, we'll need it's ID
      $result = $TARGET->search('email', $a_record['email'], true, true);
        // insert contact record
        if (!$result->count) {
      // insert contact record
      if (!$result->count) {
        $plugin = $RCMAIL->plugins->exec_hook('contact_create', array(
          'record' => $a_record, 'source' => $target, 'group' => $target_group));
        if (!$plugin['abort']) {
          if ($insert_id = $TARGET->insert($a_record, false)) {
            $ids[] = $insert_id;
            $success++;
          }
        }
        else {
          $record = $result->first();
          $ids[] = $record['ID'];
        else if ($plugin['result']) {
          $ids = array_merge($ids, $plugin['result']);
          $success++;
        }
      }
      else {
        $record = $result->first();
        $ids[] = $record['ID'];
      }
    }
@@ -79,6 +81,8 @@
        if (($cnt = $TARGET->add_to_group($target_group, $plugin['ids'])) && $cnt > $success)
          $success = $cnt;
      }
      else if ($plugin['result'])
        $success = $plugin['result'];
    }
  }