phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] sync/inc/class.outlook_import.inc.php, 1.1


From: nomail
Subject: [Phpgroupware-cvs] sync/inc/class.outlook_import.inc.php, 1.1
Date: Mon, 12 Jul 2004 23:13:12 +0200

Update of /sync/inc
Added Files:
        Branch: 
          class.outlook_import.inc.php

date: 2004/07/12 21:13:12;  author: mkaemmerer;  state: Exp;

Log Message:
- added outlook import
=====================================================================
<?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.outlook_import.inc.php,v 1.1 2004/07/12 21:13:12 
mkaemmerer Exp $ 
  */

 /**
  * @package  sync
  */
  class outlook_import
        {

                var $public_functions = array
                (
                        'sync'   => true
                );

        /**
                * Synchronize exchange accounts with phpgroupware addressbook
                *
                */
                function sync()
                {
                        define('VCARD_DIR', 'c:\a');
                        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: ".VCARD_DIR."<br><br>";
                        // collect  
      $folder = dir(VCARD_DIR); 
      while ($filename = $folder->read())
      {
        if (ereg(".*\.vcd", $filename))
        {
          echo "Datei '".$filename."' gefunden<br>";
          $handle = fopen(VCARD_DIR.'\\'.$filename, "r");
          $data = fread($handle, 65536);
          fclose($handle);
          ereg('(.*)\.vcd', $filename, $regs);
          $guid = $regs[1];

          echo "Importiere Adresse: $guid<br>";
          
                                        $this->ipc_sync->setSyncItem($deviceid, 
SOURCE, $guid, 'text/vcard', base64_encode($data));
        }
      }
      $folder->close;
      
      echo "Fertig";
                }
        }
?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]