/usr/sbin/kopano-mr-process is in kopano-dagent 8.5.5-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | #!/usr/bin/php
<?php
# -*- Mode: php -*-
/*
* Copyright 2005 - 2015 Zarafa B.V.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
include('mapi/mapi.util.php');
include('mapi/mapidefs.php');
include('mapi/mapicode.php');
include('mapi/mapitags.php');
include('mapi/mapiguid.php');
include('mapi/class.meetingrequest.php');
include('mapi/class.baserecurrence.php');
include('mapi/class.recurrence.php');
include('mapi/class.freebusypublish.php');
define('RECURRENCE_AVAILABILITY_RANGE', 60 * 60 * 24 * 180); // 180 days
$DEBUG = 1;
function parseConfig($configfile)
{
$fp = fopen($configfile, "rt");
if(!$fp)
return false;
$settings = array();
while($line = fgets($fp)) {
if($line[0] == '#')
continue;
$pos = strpos($line, "=");
if($pos) {
$key = trim(substr($line, 0, $pos));
$value = trim(substr($line, $pos+1));
$settings[$key] = $value;
}
}
return $settings;
}
function u2w($s)
{
return $s;
}
if(!function_exists('hex2bin')){
function hex2bin($data)
{
return pack("H*", $data);
}
}
function debugLog($message)
{
global $DEBUG;
if($DEBUG) {
print($message);
}
}
/**
* Auto-process a meeting request, response or cancellation
*/
function autoProcess($session, $store, $entryid)
{
debugLog("Processing item with entryid " . bin2hex($entryid) . "\n");
$message = mapi_msgstore_openentry($store, $entryid);
if(!$message) {
debugLog("Unable to open item with entryid " . bin2hex($entryid) . "\n");
return false;
}
$mr = new Meetingrequest($store, $message, $session);
if($mr->isMeetingRequest()) {
// Check general policy settings
$mr->doAccept(true, false, false);
return true;
} else if($mr->isMeetingRequestResponse()) {
$mr->processMeetingRequestResponse();
return true;
} else if($mr->isMeetingCancellation()) {
$mr->processMeetingCancellation();
return true;
}
}
// Since the username we are getting from the commandline is always in utf8, we have
// to force LC_CTYPE to an UTF-8 language. This makes sure that opening the user's store
// will always open the correct user's store.
forceUTF8(LC_CTYPE);
forceUTF8(LC_MESSAGES);
textdomain("kopano");
if(count($argv) != 4) {
print "Usage: " . $argv[0] . " <username> <path/to/dagent.cfg> <entryid>\n";
print
print "If <entryid> is not specified, all unresponded MRs in the inbox are processed\n";
exit(1);
}
$username = $argv[1];
$config = $argv[2];
$entryid = $argv[3];
$settings = parseConfig($config);
if(!$settings || !isset($settings["server_socket"])) {
$settings["server_socket"] = "default:";
}
if(isset($settings["sslkey_file"]) && isset($settings["sslkey_pass"]))
$session = mapi_logon_zarafa($username, "", $settings["server_socket"], $settings["sslkey_file"], $settings["sslkey_pass"]);
else
$session = mapi_logon_zarafa($username, "", $settings["server_socket"]);
$store = GetDefaultStore($session);
$inbox = mapi_msgstore_getreceivefolder($store);
autoProcess($session, $store, hex2bin($entryid));
$storeprops = mapi_getprops($store, array(PR_MAILBOX_OWNER_ENTRYID));
$fb = new FreeBusyPublish($session, $store, getCalendar($store), $storeprops[PR_MAILBOX_OWNER_ENTRYID]);
$fb->PublishFB(time() - (7 * 24 * 60 * 60), 6 * 30 * 24 * 60 * 60); // publish from one week ago, 6 months ahead
exit(0);
?>
|