Пример #1
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     if (isset($_FILES['vcard']['tmp_name']) && isset($_FILES['vcard']['size']) > 0) {
         $vcard = new vCard();
         $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         SugarApplication::redirect("index.php?action=Importvcard&module={$_REQUEST['module']}");
     }
 }
Пример #2
0
 /**
  * @dataProvider dataProvider
  * @group bug60613
  */
 public function testImportVCard($contents, $module, $allRequiredPresent)
 {
     file_put_contents($this->filename, $contents);
     $vcard = new vCard();
     $beanId = $vcard->importVCard($this->filename, $module);
     if ($allRequiredPresent) {
         $this->createdContacts[] = $beanId;
         $this->assertNotEmpty($beanId);
     } else {
         $this->assertEmpty($beanId);
     }
 }
Пример #3
0
 /**
  * @group bug40629
  */
 public function testImportedVcardAccountLink()
 {
     $filename = dirname(__FILE__) . "/SimpleVCard.vcf";
     $vcard = new vCard();
     $contact_id = $vcard->importVCard($filename, 'Contacts');
     $contact_record = new Contact();
     $contact_record->retrieve($contact_id);
     $this->assertFalse(empty($contact_record->account_id), "Contact should have an account record associated");
     $GLOBALS['db']->query("delete from contacts where id = '{$contact_id}'");
     $vcard = new vCard();
     $lead_id = $vcard->importVCard($filename, 'Leads');
     $lead_record = new Lead();
     $lead_record->retrieve($lead_id);
     $this->assertTrue(empty($lead_record->account_id), "Lead should not have an account record associated");
     $GLOBALS['db']->query("delete from leads where id = '{$lead_id}'");
 }
Пример #4
0
 /**
  * Build and export data with VCard format
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function VCardBuild()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     require_once JAWS_PATH . 'gadgets/Addressbook/vCard.php';
     $model = $this->gadget->model->load('AddressBook');
     $agModel = $this->gadget->model->load('AddressBookGroup');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $ids = jaws()->request->fetch('adr:array');
     $link = $this->gadget->urlMap('AddressBook', array(), true);
     if (empty($ids)) {
         Jaws_Header::Location($link);
         return false;
     }
     $addressItems = $model->GetAddresses($ids, $user);
     if (Jaws_Error::IsError($addressItems) || empty($addressItems)) {
         return Jaws_HTTPError::Get(404);
     }
     $result = '';
     $nVCard = array('LastName', 'FirstName', 'AdditionalNames', 'Prefixes', 'Suffixes');
     foreach ($addressItems as $addressItem) {
         $vCard = new vCard();
         $names = explode(';', $addressItem['name']);
         foreach ($names as $key => $name) {
             $vCard->n($name, $nVCard[$key]);
         }
         $vCard->fn($names[3] . (trim($names[3]) == '' ? '' : ' ') . $names[1] . (trim($names[1]) == '' ? '' : ' ') . $names[0]);
         $vCard->nickname($addressItem['nickname']);
         $vCard->title($addressItem['title']);
         $adrGroups = $agModel->GetGroupNames($addressItem['address_id'], $user);
         $vCard->categories(implode(',', $adrGroups));
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_home'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_work'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_other'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_home'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_work'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_other'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_home'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_work'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_other'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'url', $addressItem['url'], null, '\\n');
         $vCard->note($addressItem['notes']);
         $result = $result . $vCard;
     }
     header("Content-Disposition: attachment; filename=\"" . 'address.vcf' . "\"");
     header("Content-type: application/csv");
     header("Content-Length: " . strlen($result));
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Connection: close");
     echo $result;
     exit;
 }
Пример #5
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $redirect = "index.php?action=Importvcard&module={$_REQUEST['module']}";
     if (!empty($_FILES['vcard']) && $_FILES['vcard']['error'] == 0) {
         $vcard = new vCard();
         $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         if (empty($record)) {
             SugarApplication::redirect($redirect . '&error=vcardErrorRequired');
         }
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         switch ($_FILES['vcard']['error']) {
             case UPLOAD_ERR_FORM_SIZE:
                 $redirect .= "&error=vcardErrorFilesize";
                 break;
             default:
                 $redirect .= "&error=vcardErrorDefault";
                 $GLOBALS['log']->error('Upload error code: ' . $_FILES['vcard']['error'] . '. Please refer to the error codes http://php.net/manual/en/features.file-upload.errors.php');
                 break;
         }
         SugarApplication::redirect($redirect);
     }
 }
Пример #6
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $redirect = "index.php?action=Importvcard&module={$_REQUEST['module']}";
     if (!empty($_FILES['vcard']) && is_uploaded_file($_FILES['vcard']['tmp_name']) && $_FILES['vcard']['error'] == 0) {
         $vcard = new vCard();
         try {
             $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         } catch (Exception $e) {
             SugarApplication::redirect($redirect . '&error=vcardErrorRequired');
         }
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         switch ($_FILES['vcard']['error']) {
             case UPLOAD_ERR_FORM_SIZE:
                 $redirect .= "&error=vcardErrorFilesize";
                 break;
             default:
                 $redirect .= "&error=vcardErrorDefault";
                 $GLOBALS['log']->info('Upload error code: ' . $_FILES['vcard']['error'] . '.');
                 break;
         }
         SugarApplication::redirect($redirect);
     }
 }
Пример #7
0
$qry->Begin();
$etag = md5($request->raw_post);
$params = array(':user_no' => $dest->GetProperty('user_no'), ':dav_name' => $dest->bound_from(), ':etag' => $etag, ':dav_data' => $request->raw_post, ':session_user' => $session->user_no);
if ($dest->Exists()) {
    $sql = 'UPDATE caldav_data SET caldav_data=:dav_data, dav_etag=:etag, logged_user=:session_user,
          modified=current_timestamp, user_no=:user_no, caldav_type=\'VCARD\' WHERE dav_name=:dav_name';
    $response_code = 200;
    $qry->QDo($sql, $params);
    $qry->QDo("SELECT dav_id FROM caldav_data WHERE dav_name = :dav_name ", array(':dav_name' => $params[':dav_name']));
} else {
    $sql = 'INSERT INTO caldav_data ( user_no, dav_name, dav_etag, caldav_data, caldav_type, logged_user, created, modified, collection_id )
          VALUES( :user_no, :dav_name, :etag, :dav_data, \'VCARD\', :session_user, current_timestamp, current_timestamp, :collection_id )';
    $params[':collection_id'] = $collection_id;
    $response_code = 201;
    $qry->QDo($sql, $params);
    $qry->QDo("SELECT currval('dav_id_seq') AS dav_id");
}
$row = $qry->Fetch();
require_once 'vcard.php';
$vcard = new vCard($request->raw_post);
$vcard->Write($row->dav_id, $dest->Exists());
$qry->QDo("SELECT write_sync_change( {$collection_id}, {$response_code}, :dav_name)", array(':dav_name' => $dest->bound_from()));
if (!$qry->Commit()) {
    $qry->Rollback();
    $request->DoResponse(500, "A database error occurred");
}
header('ETag: "' . $etag . '"');
if ($response_code == 200) {
    $response_code = 204;
}
$request->DoResponse($response_code);
Пример #8
0
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/vcard.class.php';
$id = GETPOST('id', 'int');
// Security check
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
$contact = new Contact($db);
$result = $contact->fetch($id);
$physicalperson = 1;
$company = new Societe($db);
if ($contact->socid) {
    $result = $company->fetch($contact->socid);
    //print "ee";
}
// We create VCard
$v = new vCard();
$v->setProdId('Dolibarr ' . DOL_VERSION);
$v->setUid('DOLIBARR-CONTACTID-' . $contact->id);
$v->setName($contact->lastname, $contact->firstname, "", "", "");
$v->setFormattedName($contact->getFullName($langs));
// By default, all informations are for work (except phone_perso and phone_mobile)
$v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE");
$v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE");
$v->setPhoneNumber($contact->fax, "WORK;FAX");
$v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, $contact->country_code ? $contact->country_id : '', "WORK;POSTAL");
$v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, $contact->country_code ? $contact->country_id : '', "WORK");
$v->setEmail($contact->email, 'internet,pref');
$v->setNote($contact->note);
$v->setTitle($contact->poste);
// Data from linked company
if ($company->id) {
Пример #9
0
<?php

require_once 'vCard.php';
$vCard = new vCard();
$vCard->n('John', 'FirstName');
$vCard->n('Doe', 'LastName');
$vCard->tel('555-1111');
$vCard->tel('555-1234', 'Work');
$vCard->adr('', 'POBox');
$vCard->adr('', 'ExtendedAddress');
$vCard->adr('42 Plantation St.', 'StreetAddress');
$vCard->adr('Baytown', 'Locality');
$vCard->adr('LA', 'Region');
$vCard->adr('30314', 'PostalCode');
$vCard->adr('USA', 'Country');
//$vCard = new vCard('Example3.0.vcf');
echo '<pre>' . $vCard . '</pre>';
Пример #10
0
 * 02110-1301 USA.
 *
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
require_once 'include/vCard.php';
if (isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '') {
    $current_language = $_SESSION['authenticated_user_language'];
} else {
    $current_language = $sugar_config['default_language'];
}
//set module and application string arrays based upon selected language
$app_strings = return_application_language($current_language);
$app_list_strings = return_app_list_strings_language($current_language);
$vcard = new vCard();
$module = 'Contacts';
if (isset($_REQUEST['module'])) {
    $module = clean_string($_REQUEST['module']);
}
$vcard->loadContact($_REQUEST['contact_id'], $module);
$vcard->saveVCard();
Пример #11
0
 public function testSetORG()
 {
     $vcard = new vCard();
     $vcard->setORG('foo', 'bar');
     $this->assertEquals('foo;bar', $vcard->getProperty('ORG'));
 }
Пример #12
0
 /**
  * Generate vcard for the current user
  **/
 function generateVcard()
 {
     include_once GLPI_ROOT . "/lib/vcardclass/classes-vcard.php";
     // build the Vcard
     $vcard = new vCard();
     if (!empty($this->fields["realname"]) || !empty($this->fields["firstname"])) {
         $vcard->setName($this->fields["realname"], $this->fields["firstname"], "", "");
     } else {
         $vcard->setName($this->fields["name"], "", "", "");
     }
     $vcard->setPhoneNumber($this->fields["phone"], "PREF;WORK;VOICE");
     $vcard->setPhoneNumber($this->fields["phone2"], "HOME;VOICE");
     $vcard->setPhoneNumber($this->fields["mobile"], "WORK;CELL");
     $vcard->setEmail($this->getDefaultEmail());
     $vcard->setNote($this->fields["comment"]);
     // send the  VCard
     $output = $vcard->getVCard();
     $filename = $vcard->getFileName();
     // "xxx xxx.vcf"
     @Header("Content-Disposition: attachment; filename=\"{$filename}\"");
     @Header("Content-Length: " . Toolbox::strlen($output));
     @Header("Connection: close");
     @Header("content-type: text/x-vcard; charset=UTF-8");
     echo $output;
 }
Пример #13
0
 /**
  * @group default
  * @depends testQuestFNNo
  */
 public function testQuestUndefinedNo()
 {
     $fragments = ['vcard' => '{{output,?x-undefined}}', 'output' => 'Output'];
     $template = new Template($fragments);
     $vcard = new vCard();
     $this->assertEmpty($vcard->__get('x-undefined'));
     // precondition
     $output = $template->output($vcard);
     $this->assertEmpty($output);
 }
Пример #14
0
<?php

require_once 'vCard.php';
$vCard = new vCard();
/*$vCard -> n('John', 'FirstName');
	$vCard -> n('Doe', 'LastName');
	$vCard -> tel('555-1111');
	$vCard -> tel('555-1234', 'Work');
	$vCard -> adr('', 'home');
	$vCard -> adr('', 'POBox');
	$vCard -> adr('', 'ExtendedAddress');
	$vCard -> adr('42 Plantation St.', 'StreetAddress');
	$vCard -> adr('Baytown', 'Locality');
	$vCard -> adr('LA', 'Region');
	$vCard -> adr('30314', 'PostalCode');
	$vCard -> adr('USA', 'Country');

	$vCard -> adr('', 'work');
	$vCard -> adr('', 'POBox');
	$vCard -> adr('', 'ExtendedAddress');
	$vCard -> adr('42 Plantation St.', 'StreetAddress');
	$vCard -> adr('Baytown', 'Locality');
	$vCard -> adr('LA', 'Region');
	$vCard -> adr('30314', 'PostalCode');
	$vCard -> adr('USA', 'Country');*/
$vCard->X_qq('USA', 'Work');
//$vCard = new vCard('Example3.0.vcf');
echo $vCard;
Пример #15
0
 function vcard_action($group = null)
 {
     // Set constants for export
     $charset = 'utf-8';
     $filename = _('Kontakte');
     // Set layout
     $this->set_layout(null);
     // If we got an array of user
     if (Request::submitted('user')) {
         $user = User::findManyByUsername(Request::getArray('user'));
     }
     // If we got a group
     if ($group) {
         $user = User::findMany(Statusgruppen::find($group)->members->pluck('user_id'));
     }
     // Fallback to all contacts if we got nothing
     if (!$user) {
         $user = User::findCurrent()->contacts;
     }
     header("Content-type: text/x-vCard;charset=" . $charset);
     //application/octet-stream MIME
     header("Content-disposition: attachment; filename=" . $filename . ".vcf");
     header("Pragma: private");
     $this->vCard = vCard::export($user);
 }
Пример #16
0

$contact = new Contact($db);
$result=$contact->fetch($_GET["id"]);

$physicalperson=1;

$company = new Societe($db);
if ($contact->socid)
{
	$result=$company->fetch($contact->socid);
	//print "ee";
}

// We create VCard
$v = new vCard();
$v->setProdId('Dolibarr '.DOL_VERSION);

$v->setUid('DOLIBARR-CONTACTID-'.$contact->id);
$v->setName($contact->name, $contact->firstname, "", "", "");
$v->setFormattedName($contact->getFullName($langs));

// By default, all informations are for work (except phone_perso and phone_mobile)
$v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE");
$v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE");
$v->setPhoneNumber($contact->fax, "WORK;FAX");

$v->setAddress("", "", $contact->address, $contact->ville, "", $contact->cp, ($contact->pays_code?$contact->pays:''), "WORK;POSTAL");
$v->setLabel("", "", $contact->address, $contact->ville, "", $contact->cp, ($contact->pays_code?$contact->pays:''), "WORK");
$v->setEmail($contact->email,'internet,pref');
$v->setNote($contact->note);
Пример #17
0
/**
* This function will import a whole calendar
* @param string $ics_content the ics file to import
* @param int $user_no the user wich will receive this ics file
* @param string $path the $path where it will be store such as /user_foo/home/
* @param boolean $caldav_context Whether we are responding via CalDAV or interactively
*
* Any VEVENTs with the same UID will be concatenated together
*/
function import_addressbook_collection($vcard_content, $user_no, $path, $caldav_context, $appending = false)
{
    global $c, $session;
    // We hack this into an enclosing component because vComponent only expects a single root component
    $addressbook = new vComponent("BEGIN:ADDRESSES\r\n" . $vcard_content . "\r\nEND:ADDRESSES\r\n");
    require_once 'vcard.php';
    $sql = 'SELECT * FROM collection WHERE dav_name = :dav_name';
    $qry = new AwlQuery($sql, array(':dav_name' => $path));
    if (!$qry->Exec('PUT', __LINE__, __FILE__)) {
        rollback_on_error($caldav_context, $user_no, $path);
    }
    if (!$qry->rows() == 1) {
        dbg_error_log('ERROR', ' PUT: Collection does not exist at "%s" for user %d', $path, $user_no);
        rollback_on_error($caldav_context, $user_no, $path);
    }
    $collection = $qry->Fetch();
    if (!(isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import)) {
        $qry->Begin();
    }
    $base_params = array(':collection_id' => $collection->collection_id, ':session_user' => $session->user_no, ':caldav_type' => 'VCARD');
    if (!$appending) {
        if (!$qry->QDo('DELETE FROM caldav_data WHERE collection_id = :collection_id', $base_params)) {
            rollback_on_error($caldav_context, $user_no, $collection->collection_id);
        }
    }
    $dav_data_insert = <<<EOSQL
INSERT INTO caldav_data ( user_no, dav_name, dav_etag, caldav_data, caldav_type, logged_user, created, modified, collection_id )
    VALUES( :user_no, :dav_name, :etag, :dav_data, :caldav_type, :session_user, :created, :modified, :collection_id )
EOSQL;
    $resources = $addressbook->GetComponents();
    foreach ($resources as $k => $resource) {
        if (isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import) {
            $qry->Begin();
        }
        $vcard = new vCard($resource->Render());
        $uid = $vcard->GetPValue('UID');
        if (empty($uid)) {
            $uid = uuid();
            $vcard->AddProperty('UID', $uid);
        }
        $last_modified = $vcard->GetPValue('REV');
        if (empty($last_modified)) {
            $last_modified = gmdate('Ymd\\THis\\Z');
            $vcard->AddProperty('REV', $last_modified);
        }
        $created = $vcard->GetPValue('X-CREATED');
        if (empty($last_modified)) {
            $created = gmdate('Ymd\\THis\\Z');
            $vcard->AddProperty('X-CREATED', $created);
        }
        $rendered_card = $vcard->Render();
        $dav_data_params = $base_params;
        $dav_data_params[':user_no'] = $user_no;
        // We don't allow any of &?\/@%+: in the UID to appear in the path, but anything else is fair game.
        $dav_data_params[':dav_name'] = sprintf('%s%s.ics', $path, preg_replace('{[&?\\/@%+:]}', '', $uid));
        $dav_data_params[':etag'] = md5($rendered_card);
        $dav_data_params[':dav_data'] = $rendered_card;
        $dav_data_params[':modified'] = $last_modified;
        $dav_data_params[':created'] = $created;
        if (isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import) {
            $qry->Begin();
        }
        if (!$qry->QDo($dav_data_insert, $dav_data_params)) {
            rollback_on_error($caldav_context, $user_no, $path);
        }
        $qry->QDo('SELECT dav_id FROM caldav_data WHERE dav_name = :dav_name ', array(':dav_name' => $dav_data_params[':dav_name']));
        if ($qry->rows() == 1 && ($row = $qry->Fetch())) {
            $dav_id = $row->dav_id;
        }
        $vcard->Write($row->dav_id, false);
        if (isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import) {
            $qry->Commit();
        }
    }
    if (!(isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import)) {
        if (!$qry->Commit()) {
            rollback_on_error($caldav_context, $user_no, $path);
        }
    }
}
Пример #18
0
} else {
    $is_guest = false;
}
if (isset($memberdata[$_GET['id']])) {
    $is_member = true;
}
($code = $plugins->load('profile_start')) ? eval($code) : null;
$breadcrumb->Add($lang->phrase('members'), 'members.php' . SID2URL_1);
$breadcrumb->Add($lang->phrase('profile_title'), 'profile.php?id=' . $_GET['id'] . $url_ext . SID2URL_x);
if ($_GET['action'] == "vcard" && $is_member && $config['vcard_dl'] == 1 && (!$my->vlogin && $config['vcard_dl_guests'] == 1 || $my->vlogin)) {
    require "classes/class.vCard.inc.php";
    ($code = $plugins->load('profile_vcard_start')) ? eval($code) : null;
    $result = $db->query("\n\tSELECT id, name, mail, hp, birthday, location, fullname, groups \n\tFROM {$db->pre}user \n\tWHERE id = '{$_GET['id']}'\n\t", __LINE__, __FILE__);
    $row = $gpc->prepare($db->fetch_object($result));
    $row->level = $slog->getStatus($row->groups, ', ');
    $vCard = new vCard('', '');
    $vCard->setNickname($row->name);
    $vCard->setEMail($row->mail);
    $vCard->setNote($lang->phrase('vcard_note'));
    if (!empty($row->fullname)) {
        $names = explode(' ', $row->fullname);
        $anz = count($names);
        $middle = '';
        foreach ($names as $middlename) {
            if ($middlename != $names[0] && $middlename != $names[$anz - 1]) {
                $middle .= $middlename;
            }
        }
        $vCard->setFirstName($names[0]);
        $vCard->setMiddleName($middle);
        $vCard->setLastName($names[$anz - 1]);
Пример #19
0
 /**
  * Retrieves the generated vcard for a record
  *
  * @param $api  ServiceBase The API class of the request, used in cases where the API changes how the fields are pulled from the args array.
  * @param $args array The arguments array passed in from the API
  *
  * @return String
  */
 protected function getVcardForRecord($api, $args)
 {
     $bean = $this->loadBean($api, $args);
     if (!$bean->ACLAccess('view')) {
         throw new SugarApiExceptionNotAuthorized('No access to view records for module: ' . $args['module']);
     }
     $vcard = new vCard();
     if (isset($args['module'])) {
         $module = clean_string($args['module']);
     } else {
         $module = 'Contacts';
     }
     $vcard->loadContact($args['record'], $module);
     return $vcard->saveVCardApi($api);
 }
Пример #20
0
Header("Content-Type: text/x-vCard; name=$filename");

echo $output;
?>
*/
$user_id = $_REQUEST['user_id'];
$user_id = mysql_real_escape_string($user_id);
$query = "\tSELECT\n\t\t\t\t\tuser.homenr,\n\t\t\t\t\tuser.mobilnr,\n\t\t\t\t\tuser.scoutname,\n\t\t\t\t\tuser.firstname,\n\t\t\t\t\tuser.surname,\n\t\t\t\t\tuser.birthday,\n\t\t\t\t\tuser.street,\n\t\t\t\t\tuser.zipcode,\n\t\t\t\t\tuser.city,\n\t\t\t\t\tuser.mail\n\t\t\t\tFROM\n\t\t\t\t\tuser,\n\t\t\t\t\tuser as my_user,\n\t\t\t\t\tuser_camp,\n\t\t\t\t\tuser_camp as my_user_camp\n\t\t\t\tWHERE\n\t\t\t\t\tuser.id = {$user_id} AND\n\t\t\t\t\tmy_user.id = {$_user->id} AND\n\t\t\t\t\tmy_user.id = my_user_camp.user_id AND\n\t\t\t\t\tuser.id = user_camp.user_id AND\n\t\t\t\t\tuser_camp.camp_id = my_user_camp.camp_id";
$result = mysql_query($query);
if (mysql_num_rows($result) < 1) {
    die("no result");
}
$user_data = mysql_fetch_assoc($result);
$birthday = new c_date();
$birthday->setDay2000($user_data[birthday]);
$v = new vCard();
$v->setPhoneNumber($user_data[homenr], "PREF;HOME;VOICE");
$v->setPhoneNumber($user_data[mobilnr], "PREF;CELL;VOICE");
$v->setName($user_data[surname], $user_data[firstname], $user_data[scoutname], "");
$v->setBirthday($birthday->getString("Y-m-d"));
$v->setAddress("", "", $user_data[street], $user_data[city], "", $user_data[zipcode], "");
$v->setEmail($user_data[mail]);
$v->setNote("Automatisch generiert auf Basis der Daten von eCamp");
$output = $v->getVCard();
$filename = $v->getFileName();
Header("Content-Disposition: attachment; filename={$filename}");
Header("Content-Length: " . strlen($output));
Header("Connection: close");
Header("Content-Type: text/x-vCard; name={$filename}");
echo $output;
die;
Пример #21
0
 /**
  * Generate the Vcard for the current Contact
  *
  *@return Nothing (display)
  **/
 function generateVcard()
 {
     include GLPI_ROOT . "/lib/vcardclass/classes-vcard.php";
     if (!$this->can($this->fields['id'], READ)) {
         return false;
     }
     // build the Vcard
     $vcard = new vCard();
     $vcard->setName($this->fields["name"], $this->fields["firstname"], "", "");
     $vcard->setPhoneNumber($this->fields["phone"], "PREF;WORK;VOICE");
     $vcard->setPhoneNumber($this->fields["phone2"], "HOME;VOICE");
     $vcard->setPhoneNumber($this->fields["mobile"], "WORK;CELL");
     $addr = $this->GetAddress();
     if (is_array($addr)) {
         $vcard->setAddress($addr["name"], "", $addr["address"], $addr["town"], $addr["state"], $addr["postcode"], $addr["country"], "WORK;POSTAL");
     }
     $vcard->setEmail($this->fields["email"]);
     $vcard->setNote($this->fields["comment"]);
     $vcard->setURL($this->GetWebsite(), "WORK");
     // send the  VCard
     $output = $vcard->getVCard();
     $filename = $vcard->getFileName();
     // "xxx xxx.vcf"
     @Header("Content-Disposition: attachment; filename=\"{$filename}\"");
     @Header("Content-Length: " . Toolbox::strlen($output));
     @Header("Connection: close");
     @Header("content-type: text/x-vcard; charset=UTF-8");
     echo $output;
 }
Пример #22
0
<?php

#Application name: PhpCollab
#Status page: 0
#Path by root: ../users/exportuser.php
$export = "true";
$checkSession = "false";
include_once '../includes/library.php';
include "../includes/vcard.class.php";
$tmpquery = "WHERE mem.id = '{$id}'";
$userDetail = new request();
$userDetail->openMembers($tmpquery);
$v = new vCard();
$v->setPhoneNumber($userDetail->mem_phone_work[0]);
$v->setName($userDetail->mem_name[0]);
$v->setTitle($userDetail->mem_title[0]);
$v->setOrganization($userDetail->mem_org_name[0]);
$v->setEmail($userDetail->mem_email_work[0]);
$v->setPhoneNumber($userDetail->mem_phone_work[0], "WORK;VOICE");
$v->setPhoneNumber($userDetail->mem_phone_home[0], "HOME;VOICE");
$v->setPhoneNumber($userDetail->mem_mobile[0], "CELL;VOICE");
$v->setPhoneNumber($userDetail->mem_fax[0], "WORK;FAX");
$output = $v->getVCard();
$filename = $v->getFileName();
Header("Content-Disposition: attachment; filename={$filename}");
Header("Content-Length: " . strlen($output));
Header("Connection: close");
Header("Content-Type: text/x-vCard; name={$filename}");
echo $output;
 function display()
 {
     $vcard = new vCard();
     $vcard->loadContact($this->bean->id, $this->bean->object_name);
     $vcard->saveVCard();
 }
Пример #24
0
 function create_vcard($user)
 {
     global $config, $conn;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     require_once $config['basepath'] . '/include/class/vcard/vcard.inc.php';
     $v = new vCard();
     $first = $this->get_user_first_name($user);
     $last = $this->get_user_last_name($user);
     $v->setName($last, $first);
     $sql = 'SELECT userdb_emailaddress FROM ' . $config['lang_table_prefix'] . 'userdb WHERE userdb_id=' . $user;
     $recordSet = $conn->Execute($sql);
     if ($recordSet === false) {
         $misc->log_error($sql);
     }
     $email = $recordSet->fields['userdb_emailaddress'];
     $v->setEmail($email);
     $sql = $sql = "SELECT userdbelements_field_name,userdbelements_field_value FROM " . $config['lang_table_prefix'] . "userdbelements WHERE userdb_id=" . $user;
     $recordSet = $conn->Execute($sql);
     if ($recordSet === false) {
         $misc->log_error($sql);
     }
     while (!$recordSet->EOF) {
         if ($recordSet->fields['userdbelements_field_name'] == $config['vcard_phone']) {
             $phone = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setPhoneNumber($phone, "HOME;VOICE");
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_fax']) {
             $fax = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setPhoneNumber($fax, "HOME;FAX");
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_mobile']) {
             $mobile = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setPhoneNumber($mobile, "HOME;CELL");
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_notes']) {
             $notes = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setNote($notes);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_url']) {
             $url = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setURL($url, "HOME");
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_address']) {
             $address = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_city']) {
             $city = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_state']) {
             $state = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_zip']) {
             $zip = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_country']) {
             $country = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         }
         $v->setAddress("", "", $address, $city, $state, $zip, $country, "HOME;POSTAL");
         $recordSet->MoveNext();
     }
     $output = $v->getVCard();
     echo $output;
     $filename = $v->getFileName();
     Header("Content-Disposition: attachment; filename={$filename}");
     Header("Content-Length: " . strlen($output));
     Header("Connection: close");
     Header("Content-Type: text/x-vCard; name={$filename}");
 }
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
/*********************************************************************************
 * Description:  
 ********************************************************************************/
if (isset($_FILES['vcard']['tmp_name']) && isset($_FILES['vcard']['size']) > 0) {
    require_once 'include/vCard.php';
    $vcard = new vCard();
    $record = $vcard->importVCard($_FILES['vcard']['tmp_name']);
    header("Location: index.php?action=DetailView&module=Contacts&record={$record}");
    exit;
} else {
    echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_IMPORT_VCARD'], true);
    global $theme;
    $error_msg = '';
    global $app_strings;
    global $app_list_strings;
    global $current_language;
    $mod_strings = return_module_language($current_language, 'Contacts');
    $xtpl = new XTemplate('modules/Contacts/ImportVCard.html');
    $xtpl->assign("MOD", $mod_strings);
    $xtpl->assign("APP", $app_strings);
    $xtpl->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
Пример #26
0
 /**
  * @group default
  * @depends testOutputEmptyVCard
  */
 public function testOutputWithOneN()
 {
     $name = ['GivenName' => 'Luna', 'AdditionalNames' => 'Charlotte', 'FamilyName' => 'Begtrup', 'Prefixes' => 'Ms.', 'Suffixes' => 'PhD'];
     $fn = 'Ms. Luna C. Begtrup, PhD';
     $fnEsc = VCard::escape($fn);
     $vcard = new vCard();
     $vcard->push(VCard::builder('fn')->setValue($fn)->build())->push(VCard::builder('n')->setValue($name)->build());
     $output = $vcard->output();
     $expected = ['N:' . $name['FamilyName'] . ';' . $name['GivenName'] . ';' . $name['AdditionalNames'] . ';' . $name['Prefixes'] . ';' . $name['Suffixes'], 'FN:' . $fnEsc, 'UID:' . VCard::escape($vcard->getUID())];
     sort($expected);
     $lines = $this->checkAndRemoveSkeleton($output);
     $this->assertEquals($expected, $lines);
 }
Пример #27
0
*/
ob_start();
print_organizations($top_content_parent_id, $content, 0, '', array(), $toc_html);
//Exoprt Forum:
print_resources_forum();
$organizations_str = ob_get_contents();
ob_end_clean();
// end of modified by Cindy Qi Li on Jan 12, 2010
/* append the Organizations and Resources to the imsmanifest */
$imsmanifest_xml .= str_replace(array('{ORGANIZATIONS}', '{GLOSSARY}', '{RESOURCES}', '{TEST_ITEMS}', '{COURSE_TITLE}'), array($organizations_str, $glossary_manifest_xml, $resources, $test_xml_items, $ims_course_title), $ims_template_xml['final']);
// generate the vcard for the instructor/author
$usersDAO = new UsersDAO();
$row = $usersDAO->getUserByID($instructor_id);
//$sql = "SELECT first_name, last_name, email, website, login, phone FROM ".TABLE_PREFIX."members WHERE member_id=$instructor_id";
//$result = mysql_query($sql, $db);
$vcard = new vCard();
if (isset($row)) {
    $vcard->setName($row['last_name'], $row['first_name'], $row['login']);
    $vcard->setEmail($row['email']);
    $vcard->setNote('Originated from an AContent at ' . TR_BASE_HREF . '. See ATutor.ca for additional information.');
    $vcard->setURL($row['website']);
    $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml);
} else {
    $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml);
}
/* save the imsmanifest.xml file */
$zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml');
/* Commented by Cindy Qi Li on Jan 12, 2010
// AContent does not have glossary and forums (discussion tools)
if ($glossary_xml) {
	$zipfile->create_dir('resources/GlossaryItem/');
Пример #28
0
 function CarteIndividu($individu)
 {
     $v = new vCard();
     $acl = Zend_Registry::get('acl');
     $ind = Zend_Registry::get('user');
     if ($acl->isAllowed($ind, $individu, 'fiche')) {
         $v->setName($individu->nom, $individu->prenom);
         if ($individu->naissance) {
             $v->setBirthday($individu->naissance);
         }
         $t0 = explode("\n", $individu->adresse);
         $t0 = array_pad($t0, 3, '');
         list($adresse, $ville, $pays) = $t0;
         if (preg_match("`(\\d{5}) (.*)`", $ville, $res)) {
             $v->setAddress("", "", $adresse, $res[2], "", $res[1], $pays);
         }
         $v->setPhoneNumber($individu->fixe, "HOME");
         $v->setPhoneNumber($individu->portable, "CELL");
         if ($photo = $individu->getCheminImage()) {
             $v->setPhoto('jpeg', file_get_contents($photo));
         }
         $v->setEmail($individu->adelec);
         $v->setURL($this->view->urlIndividu($individu, 'fiche', 'individus', true, true));
     } else {
         $v->setName($individu->getName());
         $v->setBirthday(substr($individu->naissance, 0, 4));
     }
     array_push($this->view->vcards, $v);
 }
Пример #29
0
 function testVCard2()
 {
     $vCard = new vCard();
     $vCard->setOrganization('Testing, Inc.');
     $vCard->setName('Smith', 'John', 'J.', 'Mr.', 'Jr.');
     $vCard->setEmail('*****@*****.**');
     $vCard->setPhoneNumber('612-555-3000', 'CELL');
     $vCard->setTitle('Senior Tester');
     $vCard->setAddress('555 Testing Dr', 'Suite 100', 'Testertown', 'TN', '12345', '', 'USA', '', 'HOME');
     $vCard->setNote('Test note.');
     $vCard->setURL('http://www.slashdot.org');
     $output = trim($vCard->getVCard());
     $outputLines = explode("\n", $output);
     $outputLines = array_map('trim', $outputLines);
     $this->assertIdentical($outputLines[0], 'BEGIN:VCARD');
     $this->assertIdentical($outputLines[1], 'VERSION:2.1');
     $this->assertIdentical($outputLines[2], 'ORG;ENCODING=QUOTED-PRINTABLE:Testing, Inc.');
     $this->assertIdentical($outputLines[3], 'N:Smith;John;J.;Mr.;Jr.');
     $this->assertIdentical($outputLines[4], 'FN:Mr. John J. Smith Jr.');
     $this->assertIdentical($outputLines[5], 'EMAIL;INTERNET:test@testerson.org');
     $this->assertIdentical($outputLines[6], 'TEL;CELL:612-555-3000');
     $this->assertIdentical($outputLines[7], 'TITLE;ENCODING=QUOTED-PRINTABLE:Senior Tester');
     $this->assertIdentical($outputLines[8], 'ADR;HOME;ENCODING=QUOTED-PRINTABLE:;Suite 100;555 Testing Dr;Testertown;TN;12345;USA');
     $this->assertIdentical($outputLines[9], 'ORG;ENCODING=QUOTED-PRINTABLE:Test note.');
     $this->assertIdentical($outputLines[10], 'URL:http://www.slashdot.org');
     /* Test revision timestamp. */
     $this->assertPatternIn('/^REV:\\d{8}T\\d{6}$/', $outputLines[11]);
     $currentREVNumeric = date('YmdHis');
     $vCardREVNumeric = preg_replace('/REV:|T/', '', $outputLines[11]);
     $this->assertTrue($vCardREVNumeric >= $currentREVNumeric - 5 && $vCardREVNumeric <= $currentREVNumeric + 5, 'REV is within +/-5 seconds of current timestamp');
     $this->assertIdentical($outputLines[12], 'MAILER:CATS');
     $this->assertIdentical($outputLines[13], 'END:VCARD');
     $this->assertIdentical($vCard->getFilename(), 'John Smith.vcf');
 }
Пример #30
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $vcard = new vCard();
     $vcard->loadContact($this->bean->id, $this->module);
     $vcard->saveVCard();
 }