Small fixes in module.calendar.php
This commit is contained in:
parent
d173d7e226
commit
b9c641dfd0
17
.idea/dictionaries/osboxes.xml
Normal file
17
.idea/dictionaries/osboxes.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="osboxes">
|
||||||
|
<words>
|
||||||
|
<w>caldesc</w>
|
||||||
|
<w>calendarimporter</w>
|
||||||
|
<w>filepath</w>
|
||||||
|
<w>ical</w>
|
||||||
|
<w>importattachment</w>
|
||||||
|
<w>kopano</w>
|
||||||
|
<w>mapi</w>
|
||||||
|
<w>mapisession</w>
|
||||||
|
<w>storeid</w>
|
||||||
|
<w>uids</w>
|
||||||
|
<w>vtimezone</w>
|
||||||
|
</words>
|
||||||
|
</dictionary>
|
||||||
|
</component>
|
@ -2,8 +2,9 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e7c9c2bb-66f1-4e37-904c-d33d8c113bde" name="Default" comment="">
|
<list default="true" id="e7c9c2bb-66f1-4e37-904c-d33d8c113bde" name="Default" comment="">
|
||||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/php/download.php" afterPath="$PROJECT_DIR$/php/download.php" />
|
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/dictionaries/osboxes.xml" />
|
||||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/php/upload.php" afterPath="$PROJECT_DIR$/php/upload.php" />
|
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||||
|
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/php/module.calendar.php" afterPath="$PROJECT_DIR$/php/module.calendar.php" />
|
||||||
</list>
|
</list>
|
||||||
<ignored path="calendarimporter.iws" />
|
<ignored path="calendarimporter.iws" />
|
||||||
<ignored path=".idea/workspace.xml" />
|
<ignored path=".idea/workspace.xml" />
|
||||||
@ -24,30 +25,6 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="FileEditorManager">
|
<component name="FileEditorManager">
|
||||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||||
<file leaf-file-name="module.calendar.php" pinned="false" current-in-tab="false">
|
|
||||||
<entry file="file://$PROJECT_DIR$/php/module.calendar.php">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="300">
|
|
||||||
<caret line="20" column="2" selection-start-line="20" selection-start-column="2" selection-end-line="20" selection-end-column="2" />
|
|
||||||
<folding>
|
|
||||||
<element signature="n#__construct#0;n#CalendarModule#0;n#!!top" expanded="false" />
|
|
||||||
<element signature="n#execute#0;n#CalendarModule#0;n#!!top" expanded="false" />
|
|
||||||
<element signature="n#getDurationStringFromMintues#0;n#CalendarModule#0;n#!!top" expanded="false" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
</file>
|
|
||||||
<file leaf-file-name="upload.php" pinned="false" current-in-tab="true">
|
|
||||||
<entry file="file://$PROJECT_DIR$/php/upload.php">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="75">
|
|
||||||
<caret line="5" column="41" selection-start-line="5" selection-start-column="41" selection-end-line="5" selection-end-column="41" />
|
|
||||||
<folding />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
</file>
|
|
||||||
<file leaf-file-name="helper.php" pinned="false" current-in-tab="false">
|
<file leaf-file-name="helper.php" pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/php/helper.php">
|
<entry file="file://$PROJECT_DIR$/php/helper.php">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
@ -60,6 +37,19 @@
|
|||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
|
<file leaf-file-name="module.calendar.php" pinned="false" current-in-tab="true">
|
||||||
|
<entry file="file://$PROJECT_DIR$/php/module.calendar.php">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="0">
|
||||||
|
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#6#914#0#PHP" expanded="true" />
|
||||||
|
<element signature="e#1004#1022#0#PHP" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
</leaf>
|
</leaf>
|
||||||
</component>
|
</component>
|
||||||
<component name="FileTemplateManagerImpl">
|
<component name="FileTemplateManagerImpl">
|
||||||
@ -99,11 +89,11 @@
|
|||||||
<option value="$PROJECT_DIR$/backend/.htaccess" />
|
<option value="$PROJECT_DIR$/backend/.htaccess" />
|
||||||
<option value="$PROJECT_DIR$/config.php" />
|
<option value="$PROJECT_DIR$/config.php" />
|
||||||
<option value="$PROJECT_DIR$/js/plugin.calendarimporter.js" />
|
<option value="$PROJECT_DIR$/js/plugin.calendarimporter.js" />
|
||||||
<option value="$PROJECT_DIR$/php/module.calendar.php" />
|
|
||||||
<option value="$PROJECT_DIR$/php/Helper.php" />
|
<option value="$PROJECT_DIR$/php/Helper.php" />
|
||||||
<option value="$PROJECT_DIR$/php/helper.php" />
|
<option value="$PROJECT_DIR$/php/helper.php" />
|
||||||
<option value="$PROJECT_DIR$/php/download.php" />
|
<option value="$PROJECT_DIR$/php/download.php" />
|
||||||
<option value="$PROJECT_DIR$/php/upload.php" />
|
<option value="$PROJECT_DIR$/php/upload.php" />
|
||||||
|
<option value="$PROJECT_DIR$/php/module.calendar.php" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@ -267,12 +257,12 @@
|
|||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1477949602474</updated>
|
<updated>1477949602474</updated>
|
||||||
<workItem from="1477949603566" duration="9204000" />
|
<workItem from="1477949603566" duration="9204000" />
|
||||||
<workItem from="1480441197414" duration="7353000" />
|
<workItem from="1480441197414" duration="8737000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TimeTrackingManager">
|
<component name="TimeTrackingManager">
|
||||||
<option name="totallyTimeSpent" value="16557000" />
|
<option name="totallyTimeSpent" value="17941000" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ToolWindowManager">
|
<component name="ToolWindowManager">
|
||||||
<frame x="65" y="24" width="1792" height="999" extended-state="6" />
|
<frame x="65" y="24" width="1792" height="999" extended-state="6" />
|
||||||
@ -549,7 +539,7 @@
|
|||||||
<state relative-caret-position="-9350">
|
<state relative-caret-position="-9350">
|
||||||
<caret line="90" column="87" selection-start-line="90" selection-start-column="87" selection-end-line="90" selection-end-column="87" />
|
<caret line="90" column="87" selection-start-line="90" selection-start-column="87" selection-end-line="90" selection-end-column="87" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="n#!!doc" expanded="true" />
|
<element signature="n#!!doc" expanded="false" />
|
||||||
</folding>
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -629,36 +619,6 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/php/plugin.calendarimporter.php">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="74">
|
|
||||||
<caret line="13" column="25" selection-start-line="13" selection-start-column="22" selection-end-line="13" selection-end-column="25" />
|
|
||||||
<folding />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/php/helper.php">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="690">
|
|
||||||
<caret line="56" column="41" selection-start-line="56" selection-start-column="41" selection-end-line="56" selection-end-column="41" />
|
|
||||||
<folding>
|
|
||||||
<element signature="e#6#905#0#PHP" expanded="true" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/php/module.calendar.php">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="300">
|
|
||||||
<caret line="20" column="2" selection-start-line="20" selection-start-column="2" selection-end-line="20" selection-end-column="2" />
|
|
||||||
<folding>
|
|
||||||
<element signature="n#__construct#0;n#CalendarModule#0;n#!!top" expanded="false" />
|
|
||||||
<element signature="n#execute#0;n#CalendarModule#0;n#!!top" expanded="false" />
|
|
||||||
<element signature="n#getDurationStringFromMintues#0;n#CalendarModule#0;n#!!top" expanded="false" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/php/download.php">
|
<entry file="file://$PROJECT_DIR$/php/download.php">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="0">
|
<state relative-caret-position="0">
|
||||||
@ -677,5 +637,34 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/php/plugin.calendarimporter.php">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="-165">
|
||||||
|
<caret line="13" column="25" selection-start-line="13" selection-start-column="22" selection-end-line="13" selection-end-column="25" />
|
||||||
|
<folding />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/php/helper.php">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="690">
|
||||||
|
<caret line="56" column="41" selection-start-line="56" selection-start-column="41" selection-end-line="56" selection-end-column="41" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#6#905#0#PHP" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/php/module.calendar.php">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="0">
|
||||||
|
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#6#914#0#PHP" expanded="true" />
|
||||||
|
<element signature="e#1004#1022#0#PHP" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -21,20 +21,22 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once('vendor/autoload.php');
|
include_once(__DIR__ . "/vendor/autoload.php");
|
||||||
|
include_once(__DIR__ . "/helper.php");
|
||||||
|
|
||||||
use Sabre\VObject;
|
use Sabre\VObject;
|
||||||
|
use calendarimporter\Helper;
|
||||||
|
|
||||||
class CalendarModule extends Module
|
class CalendarModule extends Module
|
||||||
{
|
{
|
||||||
|
|
||||||
private $DEBUG = false; // enable error_log debugging
|
private $DEBUG = false; // enable error_log debugging
|
||||||
|
|
||||||
private $busystates = null;
|
private $busyStates = null;
|
||||||
|
|
||||||
private $labels = null;
|
private $labels = null;
|
||||||
|
|
||||||
private $attendeetype = null;
|
private $attendeeType = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
@ -49,7 +51,7 @@ class CalendarModule extends Module
|
|||||||
date_default_timezone_set(PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE);
|
date_default_timezone_set(PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE);
|
||||||
|
|
||||||
// init mappings
|
// init mappings
|
||||||
$this->busystates = array(
|
$this->busyStates = array(
|
||||||
"FREE",
|
"FREE",
|
||||||
"TENTATIVE",
|
"TENTATIVE",
|
||||||
"BUSY",
|
"BUSY",
|
||||||
@ -70,7 +72,7 @@ class CalendarModule extends Module
|
|||||||
"PHONE INTERVIEW"
|
"PHONE INTERVIEW"
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->attendeetype = array(
|
$this->attendeeType = array(
|
||||||
"NON-PARTICIPANT", // needed as zarafa starts counting at 1
|
"NON-PARTICIPANT", // needed as zarafa starts counting at 1
|
||||||
"REQ-PARTICIPANT",
|
"REQ-PARTICIPANT",
|
||||||
"OPT-PARTICIPANT",
|
"OPT-PARTICIPANT",
|
||||||
@ -81,6 +83,7 @@ class CalendarModule extends Module
|
|||||||
/**
|
/**
|
||||||
* Executes all the actions in the $data variable.
|
* Executes all the actions in the $data variable.
|
||||||
* Exception part is used for authentication errors also
|
* Exception part is used for authentication errors also
|
||||||
|
*
|
||||||
* @return boolean true on success or false on failure.
|
* @return boolean true on success or false on failure.
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
@ -130,58 +133,44 @@ class CalendarModule extends Module
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a random string with variable length.
|
|
||||||
* @param $length the lenght of the generated string
|
|
||||||
* @return string a random string
|
|
||||||
*/
|
|
||||||
private function randomstring($length = 6)
|
|
||||||
{
|
|
||||||
// $chars - all allowed charakters
|
|
||||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
|
||||||
|
|
||||||
srand((double)microtime() * 1000000);
|
|
||||||
$i = 0;
|
|
||||||
$pass = "";
|
|
||||||
while ($i < $length) {
|
|
||||||
$num = rand() % strlen($chars);
|
|
||||||
$tmp = substr($chars, $num, 1);
|
|
||||||
$pass = $pass . $tmp;
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
return $pass;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a property from the array.
|
* Get a property from the array.
|
||||||
|
*
|
||||||
* @param $props
|
* @param $props
|
||||||
* @param $propname
|
* @param $propName
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getProp($props, $propname)
|
private function getProp($props, $propName)
|
||||||
{
|
{
|
||||||
if (isset($props["props"][$propname])) {
|
if (isset($props["props"][$propName])) {
|
||||||
return $props["props"][$propname];
|
return $props["props"][$propName];
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDurationStringFromMintues($minutes, $pos = false)
|
/**
|
||||||
|
* Get a duration string form given minutes
|
||||||
|
*
|
||||||
|
* @param $minutes
|
||||||
|
* @param bool $pos
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getDurationStringFromMinutes($minutes, $pos = false)
|
||||||
{
|
{
|
||||||
$pos = $pos === true ? "+" : "-";
|
$pos = $pos === true ? "+" : "-";
|
||||||
$str = $pos . "P";
|
$str = $pos . "P";
|
||||||
|
|
||||||
|
|
||||||
// variables for holding values
|
// variables for holding values
|
||||||
$mins = intval($minutes);
|
$min = intval($minutes);
|
||||||
$hours = 0;
|
$hours = 0;
|
||||||
$days = 0;
|
$days = 0;
|
||||||
$weeks = 0;
|
$weeks = 0;
|
||||||
|
|
||||||
// calculations
|
// calculations
|
||||||
if ($mins >= 60) {
|
if ($min >= 60) {
|
||||||
$hours = (int)($mins / 60);
|
$hours = (int)($min / 60);
|
||||||
$mins = $mins % 60;
|
$min = $min % 60;
|
||||||
}
|
}
|
||||||
if ($hours >= 24) {
|
if ($hours >= 24) {
|
||||||
$days = (int)($hours / 24);
|
$days = (int)($hours / 24);
|
||||||
@ -202,8 +191,8 @@ class CalendarModule extends Module
|
|||||||
if ($hours) {
|
if ($hours) {
|
||||||
$str .= "{$hours}H";
|
$str .= "{$hours}H";
|
||||||
}
|
}
|
||||||
if ($mins) {
|
if ($min) {
|
||||||
$str .= "{$mins}M";
|
$str .= "{$min}M";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
@ -211,15 +200,16 @@ class CalendarModule extends Module
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The main export function, creates the ics file for download
|
* The main export function, creates the ics file for download
|
||||||
|
*
|
||||||
* @param $actionType
|
* @param $actionType
|
||||||
* @param $actionData
|
* @param $actionData
|
||||||
*/
|
*/
|
||||||
private function exportCalendar($actionType, $actionData)
|
private function exportCalendar($actionType, $actionData)
|
||||||
{
|
{
|
||||||
// Get store id
|
// Get store id
|
||||||
$storeid = false;
|
$storeId = false;
|
||||||
if (isset($actionData["storeid"])) {
|
if (isset($actionData["storeid"])) {
|
||||||
$storeid = $actionData["storeid"];
|
$storeId = $actionData["storeid"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get records
|
// Get records
|
||||||
@ -239,17 +229,17 @@ class CalendarModule extends Module
|
|||||||
$error_msg = "";
|
$error_msg = "";
|
||||||
|
|
||||||
// write csv
|
// write csv
|
||||||
$token = $this->randomstring(16);
|
$token = Helper::randomstring(16);
|
||||||
$file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics";
|
$file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics";
|
||||||
file_put_contents($file, "");
|
file_put_contents($file, "");
|
||||||
|
|
||||||
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid));
|
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId));
|
||||||
if ($store) {
|
if ($store) {
|
||||||
// load folder first
|
// load folder first
|
||||||
if ($folder !== false) {
|
if ($folder !== false) {
|
||||||
$mapifolder = mapi_msgstore_openentry($store, hex2bin($folder));
|
$mapiFolder = mapi_msgstore_openentry($store, hex2bin($folder));
|
||||||
|
|
||||||
$table = mapi_folder_getcontentstable($mapifolder);
|
$table = mapi_folder_getcontentstable($mapiFolder);
|
||||||
$list = mapi_table_queryallrows($table, array(PR_ENTRYID));
|
$list = mapi_table_queryallrows($table, array(PR_ENTRYID));
|
||||||
|
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
@ -257,12 +247,12 @@ class CalendarModule extends Module
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$vcalendar = new VObject\Component\VCalendar();
|
$vCalendar = new VObject\Component\VCalendar();
|
||||||
|
|
||||||
// Add static stuff to vcalendar
|
// Add static stuff to vCalendar
|
||||||
$vcalendar->add('METHOD', 'PUBLISH');
|
$vCalendar->add('METHOD', 'PUBLISH');
|
||||||
$vcalendar->add('X-WR-CALDESC', 'Exported Zarafa Calendar');
|
$vCalendar->add('X-WR-CALDESC', 'Exported Kopano Calendar');
|
||||||
$vcalendar->add('X-WR-TIMEZONE', date_default_timezone_get());
|
$vCalendar->add('X-WR-TIMEZONE', date_default_timezone_get());
|
||||||
|
|
||||||
// TODO: add VTIMEZONE object to ical.
|
// TODO: add VTIMEZONE object to ical.
|
||||||
|
|
||||||
@ -274,43 +264,43 @@ class CalendarModule extends Module
|
|||||||
$plaintext = true;
|
$plaintext = true;
|
||||||
$messageProps = $GLOBALS['operations']->getMessageProps($store, $message, $properties, $plaintext);
|
$messageProps = $GLOBALS['operations']->getMessageProps($store, $message, $properties, $plaintext);
|
||||||
|
|
||||||
$vevent = $vcalendar->add('VEVENT', [
|
$vEvent = $vCalendar->add('VEVENT', [
|
||||||
'SUMMARY' => $this->getProp($messageProps, "subject"),
|
'SUMMARY' => $this->getProp($messageProps, "subject"),
|
||||||
'DTSTART' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "startdate")),
|
'DTSTART' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "startdate")),
|
||||||
'DTEND' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "duedate")),
|
'DTEND' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "duedate")),
|
||||||
'CREATED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "creation_time")),
|
'CREATED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "creation_time")),
|
||||||
'LAST-MODIFIED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "last_modification_time")),
|
'LAST-MODIFIED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "last_modification_time")),
|
||||||
'PRIORITY' => $this->getProp($messageProps, "importance"),
|
'PRIORITY' => $this->getProp($messageProps, "importance"),
|
||||||
'X-MICROSOFT-CDO-INTENDEDSTATUS' => $this->busystates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid...
|
'X-MICROSOFT-CDO-INTENDEDSTATUS' => $this->busyStates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid...
|
||||||
'X-MICROSOFT-CDO-BUSYSTATUS' => $this->busystates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid...
|
'X-MICROSOFT-CDO-BUSYSTATUS' => $this->busyStates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid...
|
||||||
'X-ZARAFA-LABEL' => $this->labels[intval($this->getProp($messageProps, "label"))],
|
'X-ZARAFA-LABEL' => $this->labels[intval($this->getProp($messageProps, "label"))],
|
||||||
'CLASS' => $this->getProp($messageProps, "private") ? "PRIVATE" : "PUBLIC",
|
'CLASS' => $this->getProp($messageProps, "private") ? "PRIVATE" : "PUBLIC",
|
||||||
'COMMENT' => "eid:" . $records[$index]
|
'COMMENT' => "eid:" . $records[$index]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Add organizer
|
// Add organizer
|
||||||
$vevent->add('ORGANIZER', 'mailto:' . $this->getProp($messageProps, "sender_email_address"));
|
$vEvent->add('ORGANIZER', 'mailto:' . $this->getProp($messageProps, "sender_email_address"));
|
||||||
$vevent->ORGANIZER['CN'] = $this->getProp($messageProps, "sender_name");
|
$vEvent->ORGANIZER['CN'] = $this->getProp($messageProps, "sender_name");
|
||||||
|
|
||||||
// Add Attendees
|
// Add Attendees
|
||||||
if (isset($messageProps["recipients"]) && count($messageProps["recipients"]["item"]) > 0) {
|
if (isset($messageProps["recipients"]) && count($messageProps["recipients"]["item"]) > 0) {
|
||||||
foreach ($messageProps["recipients"]["item"] as $attendee) {
|
foreach ($messageProps["recipients"]["item"] as $attendee) {
|
||||||
$att = $vevent->add('ATTENDEE', "mailto:" . $this->getProp($attendee, "email_address"));
|
$att = $vEvent->add('ATTENDEE', "mailto:" . $this->getProp($attendee, "email_address"));
|
||||||
$att["CN"] = $this->getProp($attendee, "display_name");
|
$att["CN"] = $this->getProp($attendee, "display_name");
|
||||||
$att["ROLE"] = $this->attendeetype[intval($this->getProp($attendee, "recipient_type"))];
|
$att["ROLE"] = $this->attendeeType[intval($this->getProp($attendee, "recipient_type"))];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add alarms
|
// Add alarms
|
||||||
if (!empty($this->getProp($messageProps, "reminder")) && $this->getProp($messageProps, "reminder") == 1) {
|
if (!empty($this->getProp($messageProps, "reminder")) && $this->getProp($messageProps, "reminder") == 1) {
|
||||||
$valarm = $vevent->add('VALARM', [
|
$vAlarm = $vEvent->add('VALARM', [
|
||||||
'ACTION' => 'DISPLAY',
|
'ACTION' => 'DISPLAY',
|
||||||
'DESCRIPTION' => $this->getProp($messageProps, "subject") // reuse the event summary
|
'DESCRIPTION' => $this->getProp($messageProps, "subject") // reuse the event summary
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Add trigger
|
// Add trigger
|
||||||
$durationValue = $this->getDurationStringFromMintues($this->getProp($messageProps, "reminder_minutes"), false);
|
$durationValue = $this->getDurationStringFromMinutes($this->getProp($messageProps, "reminder_minutes"), false);
|
||||||
$valarm->add('TRIGGER', $durationValue); // default trigger type is duration (see 4.8.6.3)
|
$vAlarm->add('TRIGGER', $durationValue); // default trigger type is duration (see 4.8.6.3)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$valarm->add('TRIGGER', date_timestamp_set(new DateTime(), $this->getProp($messageProps, "reminder_time"))); // trigger type "DATE-TIME"
|
$valarm->add('TRIGGER', date_timestamp_set(new DateTime(), $this->getProp($messageProps, "reminder_time"))); // trigger type "DATE-TIME"
|
||||||
@ -320,18 +310,18 @@ class CalendarModule extends Module
|
|||||||
|
|
||||||
// Add location
|
// Add location
|
||||||
if (!empty($this->getProp($messageProps, "location"))) {
|
if (!empty($this->getProp($messageProps, "location"))) {
|
||||||
$vevent->add('LOCATION', $this->getProp($messageProps, "location"));
|
$vEvent->add('LOCATION', $this->getProp($messageProps, "location"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add description
|
// Add description
|
||||||
$body = $this->getProp($messageProps, "isHTML") ? $this->getProp($messageProps, "html_body") : $this->getProp($messageProps, "body");
|
$body = $this->getProp($messageProps, "isHTML") ? $this->getProp($messageProps, "html_body") : $this->getProp($messageProps, "body");
|
||||||
if (!empty($body)) {
|
if (!empty($body)) {
|
||||||
$vevent->add('DESCRIPTION', $body);
|
$vEvent->add('DESCRIPTION', $body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write combined ics file
|
// write combined ics file
|
||||||
file_put_contents($file, file_get_contents($file) . $vcalendar->serialize());
|
file_put_contents($file, file_get_contents($file) . $vCalendar->serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($records) > 0) {
|
if (count($records) > 0) {
|
||||||
@ -356,9 +346,9 @@ class CalendarModule extends Module
|
|||||||
private function importCalendar($actionType, $actionData)
|
private function importCalendar($actionType, $actionData)
|
||||||
{
|
{
|
||||||
// Get uploaded vcf path
|
// Get uploaded vcf path
|
||||||
$icsfile = false;
|
$icsFile = false;
|
||||||
if (isset($actionData["ics_filepath"])) {
|
if (isset($actionData["ics_filepath"])) {
|
||||||
$icsfile = $actionData["ics_filepath"];
|
$icsFile = $actionData["ics_filepath"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get store id
|
// Get store id
|
||||||
@ -368,9 +358,9 @@ class CalendarModule extends Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get folder entryid
|
// Get folder entryid
|
||||||
$folderid = false;
|
$folderId = false;
|
||||||
if (isset($actionData["folderid"])) {
|
if (isset($actionData["folderid"])) {
|
||||||
$folderid = $actionData["folderid"];
|
$folderId = $actionData["folderid"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get uids
|
// Get uids
|
||||||
@ -387,7 +377,7 @@ class CalendarModule extends Module
|
|||||||
$parser = null;
|
$parser = null;
|
||||||
try {
|
try {
|
||||||
$parser = VObject\Reader::read(
|
$parser = VObject\Reader::read(
|
||||||
fopen($icsfile, 'r')
|
fopen($icsFile, 'r')
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$error = true;
|
$error = true;
|
||||||
@ -398,11 +388,11 @@ class CalendarModule extends Module
|
|||||||
if (count($parser->VEVENT) > 0) {
|
if (count($parser->VEVENT) > 0) {
|
||||||
$events = $this->parseCalendarToArray($parser);
|
$events = $this->parseCalendarToArray($parser);
|
||||||
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid));
|
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid));
|
||||||
$folder = mapi_msgstore_openentry($store, hex2bin($folderid));
|
$folder = mapi_msgstore_openentry($store, hex2bin($folderId));
|
||||||
|
|
||||||
$importall = false;
|
$importAll = false;
|
||||||
if (count($uids) == count($events)) {
|
if (count($uids) == count($events)) {
|
||||||
$importall = true;
|
$importAll = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$propValuesMAPI = array();
|
$propValuesMAPI = array();
|
||||||
@ -414,7 +404,7 @@ class CalendarModule extends Module
|
|||||||
|
|
||||||
// iterate through all events and import them :)
|
// iterate through all events and import them :)
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
if (isset($event["startdate"]) && ($importall || in_array($event["internal_fields"]["event_uid"], $uids))) {
|
if (isset($event["startdate"]) && ($importAll || in_array($event["internal_fields"]["event_uid"], $uids))) {
|
||||||
|
|
||||||
$message = mapi_folder_createmessage($folder);
|
$message = mapi_folder_createmessage($folder);
|
||||||
|
|
||||||
@ -469,15 +459,15 @@ class CalendarModule extends Module
|
|||||||
private function getAttachmentPath($actionType, $actionData)
|
private function getAttachmentPath($actionType, $actionData)
|
||||||
{
|
{
|
||||||
// Get store id
|
// Get store id
|
||||||
$storeid = false;
|
$storeId = false;
|
||||||
if (isset($actionData["store"])) {
|
if (isset($actionData["store"])) {
|
||||||
$storeid = $actionData["store"];
|
$storeId = $actionData["store"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get message entryid
|
// Get message entryid
|
||||||
$entryid = false;
|
$entryId = false;
|
||||||
if (isset($actionData["entryid"])) {
|
if (isset($actionData["entryid"])) {
|
||||||
$entryid = $actionData["entryid"];
|
$entryId = $actionData["entryid"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check which type isset
|
// Check which type isset
|
||||||
@ -490,13 +480,13 @@ class CalendarModule extends Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if storeid and entryid isset
|
// Check if storeid and entryid isset
|
||||||
if ($storeid && $entryid) {
|
if ($storeId && $entryId) {
|
||||||
// Open the store
|
// Open the store
|
||||||
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid));
|
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId));
|
||||||
|
|
||||||
if ($store) {
|
if ($store) {
|
||||||
// Open the message
|
// Open the message
|
||||||
$message = mapi_msgstore_openentry($store, hex2bin($entryid));
|
$message = mapi_msgstore_openentry($store, hex2bin($entryId));
|
||||||
|
|
||||||
if ($message) {
|
if ($message) {
|
||||||
$attachment = false;
|
$attachment = false;
|
||||||
@ -506,10 +496,10 @@ class CalendarModule extends Module
|
|||||||
// Loop through the attachNums, message in message in message ...
|
// Loop through the attachNums, message in message in message ...
|
||||||
for ($i = 0; $i < (count($attachNum) - 1); $i++) {
|
for ($i = 0; $i < (count($attachNum) - 1); $i++) {
|
||||||
// Open the attachment
|
// Open the attachment
|
||||||
$tempattach = mapi_message_openattach($message, (int)$attachNum[$i]);
|
$tempAttach = mapi_message_openattach($message, (int)$attachNum[$i]);
|
||||||
if ($tempattach) {
|
if ($tempAttach) {
|
||||||
// Open the object in the attachment
|
// Open the object in the attachment
|
||||||
$message = mapi_attach_openobj($tempattach);
|
$message = mapi_attach_openobj($tempAttach);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,7 +543,7 @@ class CalendarModule extends Module
|
|||||||
$ext_found = false;
|
$ext_found = false;
|
||||||
while (!feof($fh) && !$ext_found) {
|
while (!feof($fh) && !$ext_found) {
|
||||||
$line = fgets($fh);
|
$line = fgets($fh);
|
||||||
preg_match("/(\.[a-z0-9]+)[ \t]+([^ \t\n\r]*)/i", $line, $result);
|
preg_match('/(\.[a-z0-9]+)[ \t]+([^ \t\n\r]*)/i', $line, $result);
|
||||||
if ($extension == $result[1]) {
|
if ($extension == $result[1]) {
|
||||||
$ext_found = true;
|
$ext_found = true;
|
||||||
$contentType = $result[2];
|
$contentType = $result[2];
|
||||||
@ -565,25 +555,26 @@ class CalendarModule extends Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$tmpname = tempnam(TMP_PATH, stripslashes($filename));
|
$tmpName = tempnam(TMP_PATH, stripslashes($filename));
|
||||||
|
|
||||||
// Open a stream to get the attachment data
|
// Open a stream to get the attachment data
|
||||||
$stream = mapi_openpropertytostream($attachment, PR_ATTACH_DATA_BIN);
|
$stream = mapi_openpropertytostream($attachment, PR_ATTACH_DATA_BIN);
|
||||||
$stat = mapi_stream_stat($stream);
|
$stat = mapi_stream_stat($stream);
|
||||||
// File length = $stat["cb"]
|
// File length = $stat["cb"]
|
||||||
|
|
||||||
$fhandle = fopen($tmpname, 'w');
|
$fHandle = fopen($tmpName, 'w');
|
||||||
$buffer = null;
|
$buffer = null;
|
||||||
for ($i = 0; $i < $stat["cb"]; $i += BLOCK_SIZE) {
|
for ($i = 0; $i < $stat["cb"]; $i += BLOCK_SIZE) {
|
||||||
// Write stream
|
// Write stream
|
||||||
$buffer = mapi_stream_read($stream, BLOCK_SIZE);
|
$buffer = mapi_stream_read($stream, BLOCK_SIZE);
|
||||||
fwrite($fhandle, $buffer, strlen($buffer));
|
fwrite($fHandle, $buffer, strlen($buffer));
|
||||||
}
|
}
|
||||||
fclose($fhandle);
|
fclose($fHandle);
|
||||||
|
|
||||||
$response = array();
|
$response = array();
|
||||||
$response['tmpname'] = $tmpname;
|
$response['tmpname'] = $tmpName;
|
||||||
$response['filename'] = $filename;
|
$response['filename'] = $filename;
|
||||||
|
$response['contenttype'] = $contentType;
|
||||||
$response['status'] = true;
|
$response['status'] = true;
|
||||||
$this->addActionData($actionType, $response);
|
$this->addActionData($actionType, $response);
|
||||||
$GLOBALS["bus"]->addData($this->getResponseData());
|
$GLOBALS["bus"]->addData($this->getResponseData());
|
||||||
@ -611,7 +602,7 @@ class CalendarModule extends Module
|
|||||||
private function loadCalendar($actionType, $actionData)
|
private function loadCalendar($actionType, $actionData)
|
||||||
{
|
{
|
||||||
$error = false;
|
$error = false;
|
||||||
$error_msg = "";
|
$errorMsg = "";
|
||||||
|
|
||||||
if (is_readable($actionData["ics_filepath"])) {
|
if (is_readable($actionData["ics_filepath"])) {
|
||||||
$parser = null;
|
$parser = null;
|
||||||
@ -623,11 +614,11 @@ class CalendarModule extends Module
|
|||||||
//error_log(print_r($parser->VTIMEZONE, true));
|
//error_log(print_r($parser->VTIMEZONE, true));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$error = true;
|
$error = true;
|
||||||
$error_msg = $e->getMessage();
|
$errorMsg = $e->getMessage();
|
||||||
}
|
}
|
||||||
if ($error) {
|
if ($error) {
|
||||||
$response['status'] = false;
|
$response['status'] = false;
|
||||||
$response['message'] = $error_msg;
|
$response['message'] = $errorMsg;
|
||||||
} else {
|
} else {
|
||||||
if (count($parser->VEVENT) == 0) {
|
if (count($parser->VEVENT) == 0) {
|
||||||
$response['status'] = false;
|
$response['status'] = false;
|
||||||
@ -681,7 +672,7 @@ class CalendarModule extends Module
|
|||||||
$properties["comment"] = (string)$vEvent->COMMENT;
|
$properties["comment"] = (string)$vEvent->COMMENT;
|
||||||
$properties["timezone"] = (string)$vEvent->DTSTART["TZID"];
|
$properties["timezone"] = (string)$vEvent->DTSTART["TZID"];
|
||||||
$properties["organizer"] = (string)$vEvent->ORGANIZER;
|
$properties["organizer"] = (string)$vEvent->ORGANIZER;
|
||||||
$properties["busystatus"] = array_search((string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'}, $this->busystates); // X-MICROSOFT-CDO-BUSYSTATUS
|
$properties["busystatus"] = array_search((string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'}, $this->busyStates); // X-MICROSOFT-CDO-BUSYSTATUS
|
||||||
$properties["transp"] = (string)$vEvent->TRANSP;
|
$properties["transp"] = (string)$vEvent->TRANSP;
|
||||||
//$properties["trigger"] = (string)$vEvent->COMMENT;
|
//$properties["trigger"] = (string)$vEvent->COMMENT;
|
||||||
$properties["priority"] = (string)$vEvent->PRIORITY;
|
$properties["priority"] = (string)$vEvent->PRIORITY;
|
||||||
|
Loading…
Reference in New Issue
Block a user