[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] sync/inc/class.bo_outlook_import.inc.php, 1.1
From: |
nomail |
Subject: |
[Phpgroupware-cvs] sync/inc/class.bo_outlook_import.inc.php, 1.1 |
Date: |
Tue, 13 Jul 2004 20:24:30 +0200 |
Update of /sync/inc
Added Files:
Branch:
class.bo_outlook_import.inc.php
date: 2004/07/13 18:24:30; author: mkaemmerer; state: Exp;
Log Message:
- update
=====================================================================
<?php
/**
* vCard import and synchronizsation (oneway outlook to phpGW) plugin
*
* @author Markus Kämmerer <address@hidden>
* @copyright Copyright (C) 2004 Free Software Foundation http://www.fsf.org/
* @license http://www.fsf.org/licenses/gpl.html GNU General Public License
* @package sync
* @subpackage so
* @version $Id: class.bo_outlook_import.inc.php,v 1.1 2004/07/13 18:24:30
mkaemmerer Exp $
*/
/**
* @package sync
*/
class bo_outlook_import
{
var $public_functions = array
(
'sync' => true
);
/**
* Synchronize exchange accounts with phpgroupware addressbook
*
*
*/
function sync($directory, $category)
{
define('SOURCE', 'outlook_vcard');
echo "<h4>Outlook Adress Import</h4><br>";
$this->ipcManager =&
CreateObject('phpgwapi.ipc_manager');
$this->ipc_sync =& $this->ipcManager->getIPC('sync');
if (empty($this->ipc_sync)) {
echo "Error: Sync module not installed or activated";
exit;
}
$this->so = CreateObject('sync.so_sync');
// authenticate to sync module, the user and session
switching will be prevented
// trough sync internal code
$deviceid =
$this->ipc_sync->authenticate($GLOBALS['phpgw_info']['user']['account_lid'],
$GLOBALS['phpgw_info']['user']['passwd'],
'intern_phpgwapi_outlook_sync');
if ($deviceid == -1)
{
echo "Error: could not found valid internal device for sync, setup sync
module again<br>";
exit;
}
$deviceid = $deviceid['result'];
echo "Device ID gefunden: ". $deviceid . "<br>";
// this default channel is created during the sync module setup process
// get this channel now
$channelid = $this->ipc_sync->authorize($deviceid['result'], SOURCE);
if ($channelid == -1)
{
echo "Error: could not find valid sync channel, setup sync module
again<br>";
exit;
}
echo "found channel_id: $channelid<br>";
echo "Verzeichnis: ".$directory."<br><br>";
// collect
$folder = dir($directory);
while ($filename = $folder->read())
{
if (ereg(".*\.vcd", $filename))
{
echo "Datei '".$filename."' gefunden<br>";
$handle = fopen($directory.'\\'.$filename, "r");
$fsize = filesize($directory.'\\'.$filename);
if ($fsize > 0)
{
$data = fread($handle, 65536);
fclose($handle);
ereg('(.*)\.vcd', $filename, $regs);
$guid = $regs[1];
echo "Importiere Adresse: $guid<br>";
$ipcManager =&
CreateObject('phpgwapi.ipc_manager');
$ipc =&
$ipcManager->getIPC('addressbook');
if (!isset($ipc) or ($ipc == false))
{
error_log("Sync Module: Error: There is
no source called '$source'. Can not synchronize");
return -1;
}
$data = $ipc->ConvertData($data, 'text/vcard',
'3.0', 'x-phpgroupware/addressbook-appl-data-array', '');
$data['categories'] = $category;
$this->ipc_sync->setSyncItem($deviceid, SOURCE, $guid,
'x-phpgroupware/addressbook-appl-data-array', $data);
}
}
}
$folder->close;
echo "Fertig";
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] sync/inc/class.bo_outlook_import.inc.php, 1.1,
nomail <=