Beispiel #1
0
    $display['detail'] = dis_vcard_import_form($params['addressbook']);
  } else {
    header('location: '.$GLOBALS['path'].'/contact/contact_index.php');
  }
} elseif ($action == 'save') {
///////////////////////////////////////////////////////////////////////////////
  $addressbooks = OBM_AddressBook::search();
  $contacts = $addressbooks->exportContacts($params['searchpattern']);
  dis_contact_vcard_export_all($contacts);
  exit();
} elseif ($action == 'vcard_insert') {
///////////////////////////////////////////////////////////////////////////////
  if (!empty($params[vcard_tmp])) {
    $addressbook = OBM_AddressBook::get($params['addressbook']);
    if($addressbook->write) {
      $ids = run_query_vcard_insert($params, $addressbook);
    } else {
      header('location: '.$GLOBALS['path'].'/contact/contact_index.php');
    }
    if ($ids !== false) {
      header('location: '.$GLOBALS['path'].'/contact/contact_index.php');
    } else {
      $display['msg'] .= display_err_msg("$l_contact : $l_insert_error");
      $display['detail'] .= dis_vcard_import_form($params['addressbook']);
    }
  } else {
    $display['msg'] .= display_err_msg("$l_contact : $l_insert_error");
    $display['detail'] .= dis_vcard_import_form($params['addressbook']);
  }

} elseif ($action == 'export') {
Beispiel #2
0
 /**
  * Perform the import of the contacts
  */
 function user_contacts_import($vcf_contacts, $user_id)
 {
     include_once 'php/contact/addressbook.php';
     include_once 'php/contact/contact_query.inc';
     $remember_uid = $GLOBALS['obm']['uid'];
     $GLOBALS['obm']['uid'] = $user_id;
     // some kind of sudo $user_id
     $addressbooks = OBM_AddressBook::search();
     $addressBookByName = array();
     foreach ($addressbooks as $addressbook) {
         if ($addressbook->name != 'public_contacts') {
             // I'd better filter this addressbook on search
             if ($addressbook->isDefault || isset($vcf_contacts[$addressbook->name])) {
                 $addressbook->reset();
                 $addressBookByName[$addressbook->name] = $addressbook;
             } else {
                 OBM_AddressBook::delete(array('addressbook_id' => $addressbook->id));
             }
         }
     }
     foreach ($vcf_contacts as $addBookName => $fd) {
         if (isset($addressBookByName[$addBookName])) {
             $addressbook = $addressBookByName[$addBookName];
         } else {
             $addressbook = OBM_AddressBook::create(array('name' => $addBookName));
         }
         if ($fd && $addressbook->write) {
             $ids = run_query_vcard_insert(array('vcard_fd' => $fd), $addressbook);
         }
     }
     $GLOBALS['obm']['uid'] = $remember_uid;
 }