~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to zarafa/php/liste_email.php

  • Committer: Fabien Pinckaers
  • Date: 2009-02-06 10:25:35 UTC
  • mfrom: (3547.1.3 trunk-extra-addons)
  • Revision ID: fp@tinyerp.com-20090206102535-1eykxxd9d8uwb8cv
Adding Sednacom Zarafa Module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
session_start();
 
3
 
 
4
/*
 
5
Zarafa interface (PHP)
 
6
(c) 2008 Sednacom
 
7
Authors: gael@sednacom.fr
 
8
 
 
9
This program is free software; you can redistribute it and/or modify
 
10
it under the terms of the GNU General Public License as published by
 
11
the Free Software Foundation; either version 2 of the License, or
 
12
(at your option) any later version.
 
13
 
 
14
This program is distributed in the hope that it will be useful,
 
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
GNU General Public License for more details.
 
18
 
 
19
You should have received a copy of the GNU General Public License
 
20
along with this program; if not, write to the Free Software
 
21
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
22
 
 
23
*/
 
24
 
 
25
 // Include the files
 
26
define('BASE_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . "/");
 
27
 
 
28
set_include_path(BASE_PATH."server/" . PATH_SEPARATOR . BASE_PATH."server/PEAR/" .  PATH_SEPARATOR .BASE_PATH. PATH_SEPARATOR ."/usr/share/php/");
 
29
 
 
30
require("config.php");
 
31
require("mapi/mapi.util.php");
 
32
require("mapi/mapiguid.php");
 
33
require("mapi/mapidefs.php");
 
34
require("mapi/mapitags.php");
 
35
require("server/util.php");
 
36
require("server/core/class.conversion.php");
 
37
require("server/core/class.mapisession.php");
 
38
require("server/core/class.settings.php");
 
39
require("server/core/class.xmlparser.php");
 
40
require("server/core/class.bus.php");
 
41
require("server/core/class.xmlbuilder.php");
 
42
require("server/core/class.operations.php");
 
43
require("server/modules/class.module.php");
 
44
require("server/modules/class.listmodule.php");
 
45
require("server/modules/class.itemmodule.php");
 
46
require("server/core/class.properties.php");
 
47
require("server/modules/class.maillistmodule.php");
 
48
 
 
49
    //////////////////////////////////
 
50
    /// get username and password
 
51
    //////////////////////////////////
 
52
    $username = $_POST['user'];
 
53
    $password = $_POST['password'];
 
54
    $server = 'http://localhost:236/zarafa';
 
55
 
 
56
 
 
57
    ////////////////////////////////
 
58
    //connect to the zarafa server
 
59
    ///////////////////////////////
 
60
    $GLOBALS["mapisession"] = new MAPISession();
 
61
    $sess = $GLOBALS["mapisession"]->logon($username, $password, $server);
 
62
    $session = mapi_logon_zarafa($username, $password, $server);
 
63
    $bus = new Bus(); // Create global bus object
 
64
    $GLOBALS["bus"] = $bus; // Make bus global
 
65
    $GLOBALS["settings"] = new Settings();
 
66
    $storelist = $GLOBALS["mapisession"]->getAllMessageStores();
 
67
    $id = "webmail4";     //define an id
 
68
    $GLOBALS["operations"] = new Operations();
 
69
    $datas = $GLOBALS["operations"]->getHierarchyList(array(PR_IPM_INBOX));
 
70
    $store_idhex = $datas[store][0][attributes][id];
 
71
    $entryidhex = $datas[store][0][defaultfolders][inbox];
 
72
    $entryid = hex2bin($entryidhex);
 
73
 
 
74
    $data = array(
 
75
        0 => array(
 
76
            "attributes" => array(
 
77
                "type" => "list"),
 
78
                "store" => $store_idhex,
 
79
                "entryid" => $entryidhex,
 
80
                "columns" => array(
 
81
                    "column" => array(
 
82
                        0 => '')
 
83
                        ),
 
84
                    "restriction" => array(
 
85
                        "start" =>""),
 
86
                    "data_retrieval" => "normal"));
 
87
 
 
88
 
 
89
    $GLOBALS["properties"] = new Properties();
 
90
    $email_obj = new MailListModule($id, $data);
 
91
    $stores = mapi_getmsgstorestable($session);
 
92
    $storeslist = mapi_table_queryallrows($stores);
 
93
 
 
94
    $store = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]);
 
95
    $email_obj->messageList($store, $entryid, $data[0]);
 
96
    $result = $GLOBALS["bus"]->getData();
 
97
    $result = $result[module][0][action][0][item];
 
98
 
 
99
    $res="";
 
100
    foreach($result as $email)
 
101
        {
 
102
        $res .= "email start\n";
 
103
        $res .= "zid:".$email[entryid][_content]."\n";
 
104
        $res .= "subject:".$email[subject]."\n";
 
105
        $res .= "from:".$email[sender_email_address]."\n";
 
106
        $res .= "to:".$email[display_to]."\n";
 
107
        $res .= "delivery:".$email[message_delivery_time][_content]."\n";
 
108
        $res .= "email end\n";
 
109
        }
 
110
    print $res;
 
111
?>