Commit d82f37d9 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge branch 'develop' of https://stash.z-hub.io/scm/zp/z-push into...

Merge branch 'develop' of https://stash.z-hub.io/scm/zp/z-push into bugfix/ZP-1319-caldav-empty-description
parents 94f7f4dc 1bf2fc99
...@@ -628,6 +628,12 @@ class BackendCalDAV extends BackendDiff { ...@@ -628,6 +628,12 @@ class BackendCalDAV extends BackendDiff {
} }
break; break;
case "X-MICROSOFT-CDO-ALLDAYEVENT":
if ($property->Value() == "TRUE") {
$message->alldayevent = "1";
}
break;
case "DURATION": case "DURATION":
if (!isset($message->endtime)) { if (!isset($message->endtime)) {
$start = date_create("@" . $message->starttime); $start = date_create("@" . $message->starttime);
...@@ -982,14 +988,6 @@ class BackendCalDAV extends BackendDiff { ...@@ -982,14 +988,6 @@ class BackendCalDAV extends BackendDiff {
if (isset($data->subject)) { if (isset($data->subject)) {
$vevent->AddProperty("SUMMARY", $data->subject); $vevent->AddProperty("SUMMARY", $data->subject);
} }
if (isset($data->organizeremail)) {
if (isset($data->organizername)) {
$vevent->AddProperty("ORGANIZER", sprintf("MAILTO:%s", $data->organizeremail), array("CN" => $data->organizername));
}
else {
$vevent->AddProperty("ORGANIZER", sprintf("MAILTO:%s", $data->organizeremail));
}
}
if (isset($data->location)) { if (isset($data->location)) {
$vevent->AddProperty("LOCATION", $data->location); $vevent->AddProperty("LOCATION", $data->location);
} }
...@@ -1003,6 +1001,9 @@ class BackendCalDAV extends BackendDiff { ...@@ -1003,6 +1001,9 @@ class BackendCalDAV extends BackendDiff {
$vevent->AddProperty("X-MICROSOFT-CDO-ALLDAYEVENT", "FALSE"); $vevent->AddProperty("X-MICROSOFT-CDO-ALLDAYEVENT", "FALSE");
} }
} }
else {
$vevent->AddProperty("X-MICROSOFT-CDO-ALLDAYEVENT", "TRUE");
}
if (isset($data->recurrence)) { if (isset($data->recurrence)) {
$vevent->AddProperty("RRULE", $this->_GenerateRecurrence($data->recurrence)); $vevent->AddProperty("RRULE", $this->_GenerateRecurrence($data->recurrence));
} }
...@@ -1046,33 +1047,32 @@ class BackendCalDAV extends BackendDiff { ...@@ -1046,33 +1047,32 @@ class BackendCalDAV extends BackendDiff {
$rtfparser->parse(); $rtfparser->parse();
$vevent->AddProperty("DESCRIPTION", $rtfparser->out); $vevent->AddProperty("DESCRIPTION", $rtfparser->out);
} }
$is_meeting = false;
if (isset($data->meetingstatus)) { if (isset($data->meetingstatus)) {
switch ($data->meetingstatus) { switch ($data->meetingstatus) {
case "1": case "1":
$vevent->AddProperty("STATUS", "TENTATIVE"); $vevent->AddProperty("STATUS", "TENTATIVE");
$vevent->AddProperty("X-MICROSOFT-CDO-BUSYSTATUS", "TENTATIVE"); $vevent->AddProperty("X-MICROSOFT-CDO-BUSYSTATUS", "TENTATIVE");
$vevent->AddProperty("X-MICROSOFT-DISALLOW-COUNTER", "FALSE"); $vevent->AddProperty("X-MICROSOFT-DISALLOW-COUNTER", "FALSE");
$is_meeting = true;
break; break;
case "3": case "3":
$vevent->AddProperty("STATUS", "CONFIRMED"); $vevent->AddProperty("STATUS", "CONFIRMED");
$vevent->AddProperty("X-MICROSOFT-CDO-BUSYSTATUS", "CONFIRMED"); $vevent->AddProperty("X-MICROSOFT-CDO-BUSYSTATUS", "CONFIRMED");
$vevent->AddProperty("X-MICROSOFT-DISALLOW-COUNTER", "FALSE"); $vevent->AddProperty("X-MICROSOFT-DISALLOW-COUNTER", "FALSE");
$is_meeting = true;
break; break;
case "5": case "5":
case "7": case "7":
$vevent->AddProperty("STATUS", "CANCELLED"); $vevent->AddProperty("STATUS", "CANCELLED");
$vevent->AddProperty("X-MICROSOFT-CDO-BUSYSTATUS", "CANCELLED"); $vevent->AddProperty("X-MICROSOFT-CDO-BUSYSTATUS", "CANCELLED");
$vevent->AddProperty("X-MICROSOFT-DISALLOW-COUNTER", "TRUE"); $vevent->AddProperty("X-MICROSOFT-DISALLOW-COUNTER", "TRUE");
$is_meeting = true;
break; break;
} }
} }
if (isset($data->attendees) && is_array($data->attendees)) { if (isset($data->attendees) && is_array($data->attendees)) {
//If there are attendees, we need to set ORGANIZER $is_meeting = true;
//Some phones doesn't send the organizeremail, so we gotto get it somewhere else.
//Lets use the login here ($username)
if (!isset($data->organizeremail)) {
$vevent->AddProperty("ORGANIZER", sprintf("MAILTO:%s", $this->originalUsername));
}
foreach ($data->attendees as $att) { foreach ($data->attendees as $att) {
if (isset($att->name)) { if (isset($att->name)) {
$vevent->AddProperty("ATTENDEE", sprintf("MAILTO:%s", $att->email), array("CN" => $att->name)); $vevent->AddProperty("ATTENDEE", sprintf("MAILTO:%s", $att->email), array("CN" => $att->name));
...@@ -1082,6 +1082,19 @@ class BackendCalDAV extends BackendDiff { ...@@ -1082,6 +1082,19 @@ class BackendCalDAV extends BackendDiff {
} }
} }
} }
if ($is_meeting) {
if (isset($data->organizeremail) && isset($data->organizername)) {
$vevent->AddProperty("ORGANIZER", sprintf("MAILTO:%s", $data->organizeremail), array("CN" => $data->organizername));
}
elseif (isset($data->organizeremail)) {
$vevent->AddProperty("ORGANIZER", sprintf("MAILTO:%s", $data->organizeremail));
}
else {
//Some phones doesn't send the organizeremail, so we gotto get it somewhere else.
//Lets use the login here ($username)
$vevent->AddProperty("ORGANIZER", sprintf("MAILTO:%s", $data->originalUsername));
}
}
if (isset($data->body) && strlen($data->body) > 0) { if (isset($data->body) && strlen($data->body) > 0) {
$vevent->AddProperty("DESCRIPTION", $data->body); $vevent->AddProperty("DESCRIPTION", $data->body);
} }
......
...@@ -1081,6 +1081,15 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider { ...@@ -1081,6 +1081,15 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
elseif (in_array('cell', $tel['type'])) { elseif (in_array('cell', $tel['type'])) {
$message->mobilephonenumber = $tel['val'][0]; $message->mobilephonenumber = $tel['val'][0];
} }
elseif (in_array('main', $tel['type'])) {
$message->companymainphone = $tel['val'][0];
}
elseif (in_array('assistant', $tel['type'])) {
$message->assistnamephonenumber = $tel['val'][0];
}
elseif (in_array('text', $tel['type'])) {
$message->mms = $tel['val'][0];
}
elseif (in_array('home', $tel['type'])) { elseif (in_array('home', $tel['type'])) {
if (in_array('fax', $tel['type'])) { if (in_array('fax', $tel['type'])) {
$message->homefaxnumber = $tel['val'][0]; $message->homefaxnumber = $tel['val'][0];
...@@ -1242,8 +1251,12 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider { ...@@ -1242,8 +1251,12 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
'home2phonenumber' => 'TEL;TYPE=HOME,VOICE', 'home2phonenumber' => 'TEL;TYPE=HOME,VOICE',
'homefaxnumber' => 'TEL;TYPE=HOME,FAX', 'homefaxnumber' => 'TEL;TYPE=HOME,FAX',
'mobilephonenumber' => 'TEL;TYPE=CELL', 'mobilephonenumber' => 'TEL;TYPE=CELL',
'carphonenumber' => 'TEL;TYPE=VOICE', 'carphonenumber' => 'TEL;TYPE=CAR',
'pagernumber' => 'TEL;TYPE=PAGER', 'pagernumber' => 'TEL;TYPE=PAGER',
'companymainphone' => 'TEL;TYPE=WORK,MAIN',
'mms' => 'TEL;TYPE=TEXT',
'radiophonenumber' => 'TEL;TYPE=RADIO,VOICE',
'assistnamephonenumber' => 'TEL;TYPE=ASSISTANT,VOICE',
';;businessstreet;businesscity;businessstate;businesspostalcode;businesscountry' => 'ADR;TYPE=WORK', ';;businessstreet;businesscity;businessstate;businesspostalcode;businesscountry' => 'ADR;TYPE=WORK',
';;homestreet;homecity;homestate;homepostalcode;homecountry' => 'ADR;TYPE=HOME', ';;homestreet;homecity;homestate;homepostalcode;homecountry' => 'ADR;TYPE=HOME',
';;otherstreet;othercity;otherstate;otherpostalcode;othercountry' => 'ADR', ';;otherstreet;othercity;otherstate;otherpostalcode;othercountry' => 'ADR',
...@@ -1290,7 +1303,7 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider { ...@@ -1290,7 +1303,7 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
// http://en.wikipedia.org/wiki/VCard // http://en.wikipedia.org/wiki/VCard
// TODO: add support for v4.0 // TODO: add support for v4.0
// not supported: anniversary, assistantname, assistnamephonenumber, children, department, officelocation, radiophonenumber, spouse, rtf // not supported: anniversary, assistantname, children, department, officelocation, spouse, rtf
return $data; return $data;
} }
......
...@@ -60,6 +60,7 @@ class ASDevice extends StateObject { ...@@ -60,6 +60,7 @@ class ASDevice extends StateObject {
'koegabbackendfolderid' => false, 'koegabbackendfolderid' => false,
'koecapabilities' => array(), 'koecapabilities' => array(),
'koelastaccess' => false, 'koelastaccess' => false,
'syncfiltertype' => false,
); );
static private $loadedData; static private $loadedData;
......
...@@ -688,6 +688,30 @@ class DeviceManager { ...@@ -688,6 +688,30 @@ class DeviceManager {
return $this->device->GetSupportedFields($folderid); return $this->device->GetSupportedFields($folderid);
} }
/**
* Returns the maximum filter type for a folder.
* This might be limited globally, per device or per folder.
*
* @param string $folderid
*
* @access public
* @return int
*/
public function GetFilterType($folderid) {
// either globally configured SYNC_FILTERTIME_MAX or ALL (no limit)
$maxAllowed = (defined('SYNC_FILTERTIME_MAX') && SYNC_FILTERTIME_MAX > SYNC_FILTERTYPE_ALL) ? SYNC_FILTERTIME_MAX : SYNC_FILTERTYPE_ALL;
// TODO we could/should check for a specific value for the folder, if it's available
$maxDevice = $this->device->GetSyncFilterType();
// ALL has a value of 0, all limitations have higher integer values, see SYNC_FILTERTYPE_ALL definition
if ($maxDevice !== false && $maxDevice > SYNC_FILTERTYPE_ALL && ($maxAllowed == SYNC_FILTERTYPE_ALL || $maxDevice < $maxAllowed)) {
$maxAllowed = $maxDevice;
}
return $maxAllowed;
}
/** /**
* Removes all linked states of a specific folder. * Removes all linked states of a specific folder.
* During next request the folder is resynchronized. * During next request the folder is resynchronized.
......
...@@ -415,10 +415,11 @@ class Sync extends RequestProcessor { ...@@ -415,10 +415,11 @@ class Sync extends RequestProcessor {
} }
// limit items to be synchronized to the mobiles if configured // limit items to be synchronized to the mobiles if configured
if (defined('SYNC_FILTERTIME_MAX') && SYNC_FILTERTIME_MAX > SYNC_FILTERTYPE_ALL && $maxAllowed = self::$deviceManager->GetFilterType($spa->GetFolderId());
(!$spa->HasFilterType() || $spa->GetFilterType() == SYNC_FILTERTYPE_ALL || $spa->GetFilterType() > SYNC_FILTERTIME_MAX)) { if ($maxAllowed > SYNC_FILTERTYPE_ALL &&
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SYNC_FILTERTIME_MAX defined. Filter set to value: %s", SYNC_FILTERTIME_MAX)); (!$spa->HasFilterType() || $spa->GetFilterType() == SYNC_FILTERTYPE_ALL || $spa->GetFilterType() > $maxAllowed)) {
$spa->SetFilterType(SYNC_FILTERTIME_MAX); ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): FilterType applied globally or specifically, using value: %s", $maxAllowed));
$spa->SetFilterType($maxAllowed);
} }
// unset filtertype for KOE GAB folder // unset filtertype for KOE GAB folder
...@@ -428,7 +429,7 @@ class Sync extends RequestProcessor { ...@@ -428,7 +429,7 @@ class Sync extends RequestProcessor {
} }
if ($currentFilterType != $spa->GetFilterType()) { if ($currentFilterType != $spa->GetFilterType()) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): filter type has changed (old: '%s', new: '%s'), removing folderstat to force Exporter setup", $currentFilterType, $spa->GetFilterType())); ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): FilterType has changed (old: '%s', new: '%s'), removing folderstat to force Exporter setup", $currentFilterType, $spa->GetFilterType()));
$spa->DelFolderStat(); $spa->DelFolderStat();
} }
......
...@@ -319,16 +319,76 @@ class ZPushAdmin { ...@@ -319,16 +319,76 @@ class ZPushAdmin {
return true; return true;
} }
/**
* Sets options for a device.
* First argument is the FilterType.
* This value is superseeded by the globally configured SYNC_FILTERTIME_MAX.
* If set to false the value will not be modified in the device.
*
* @param string $user user of the device
* @param string $devid device id that should be modified
* @param int $filtertype SYNC_FILTERTYPE_1DAY to SYNC_FILTERTYPE_ALL, false to ignore
*
* @access public
* @return boolean
*/
public static function SetDeviceOptions($user, $devid, $filtertype) {
if ($user === false || $devid === false) {
ZLog::Write(LOGLEVEL_ERROR, "ZPushAdmin::SetDeviceOptions(): user and device must be specified");
return false;
}
if ($filtertype !== false && $filtertype < SYNC_FILTERTYPE_ALL || $filtertype > SYNC_FILTERTYPE_INCOMPLETETASKS) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ZPushAdmin::SetDeviceOptions(): specified FilterType '%s' is out of bounds", $filtertype));
return false;
}
// load device data
$device = new ASDevice($devid, ASDevice::UNDEFINED, $user, ASDevice::UNDEFINED);
try {
$device->SetData(ZPush::GetStateMachine()->GetState($devid, IStateMachine::DEVICEDATA), false);
}
catch (StateNotFoundException $e) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ZPushAdmin::SetDeviceOptions(): device '%s' of user '%s' can not be found", $devid, $user));
return false;
}
if ($filtertype !== false) {
if ($filtertype === $device->GetSyncFilterType()) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPushAdmin::SetDeviceOptions(): device '%s' of user '%s' - device FilterType already at '%s'. Terminating.", $devid, $user, $filtertype));
}
else {
$device->SetSyncFilterType($filtertype);
}
}
// save device data
if ($device->IsDataChanged()) {
try {
if ($device->IsNewDevice() || $device->GetData() === false) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ZPushAdmin::SetDeviceOptions(): data of user '%s' not synchronized on device '%s'. Aborting.", $user, $devid));
return false;
}
ZPush::GetStateMachine()->SetState($device->GetData(), $devid, IStateMachine::DEVICEDATA);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPushAdmin::SetDeviceOptions(): device '%s' of user '%s' - device FilterType updated to '%s'", $devid, $user, $filtertype));
}
catch (StateNotFoundException $e) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ZPushAdmin::SetDeviceOptions(): state for device '%s' of user '%s' can not be saved", $devid, $user));
return false;
}
}
return true;
}
/** /**
* Marks a folder of a device of a user for re-synchronization * Marks a folder of a device of a user for re-synchronization.
* *
* @param string $user user of the device * @param string $user user of the device
* @param string $devid device id which should be re-synchronized * @param string $devid device id which should be re-synchronized
* @param mixed $folderid a single folder id or an array of folder ids * @param mixed $folderid a single folder id or an array of folder ids
* *
* @return boolean
* @access public * @access public
* @return boolean
*/ */
static public function ResyncFolder($user, $devid, $folderid) { static public function ResyncFolder($user, $devid, $folderid) {
// load device data // load device data
......
...@@ -108,6 +108,29 @@ class WebserviceDevice { ...@@ -108,6 +108,29 @@ class WebserviceDevice {
return true; return true;
} }
/**
* Sets device options of the Request::GetGETUser().
*
* @param string $deviceId the device id
* @param int $filtertype SYNC_FILTERTYPE_1DAY to SYNC_FILTERTYPE_ALL, false to ignore
*
* @access public
* @return boolean
* @throws SoapFault
*/
public function SetDeviceOptions($deviceId, $filtertype) {
$deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId);
ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceDevice::SetDeviceOptions('%s', '%s'): set FilterType to '%s'", $deviceId, Request::GetGETUser(), Utils::PrintAsString($filtertype)));
if (! ZPushAdmin::SetDeviceOptions(Request::GetGETUser(), $deviceId, $filtertype)) {
ZPush::GetTopCollector()->AnnounceInformation(ZLog::GetLastMessage(LOGLEVEL_ERROR), true);
throw new SoapFault("ERROR", ZLog::GetLastMessage(LOGLEVEL_ERROR));
}
ZPush::GetTopCollector()->AnnounceInformation(sprintf("FilterType set to '%s' - device id '%s'", Utils::PrintAsString($filtertype), $deviceId), true);
return true;
}
/** /**
* Marks a device of the Request::GetGETUser() for resynchronization. * Marks a device of the Request::GetGETUser() for resynchronization.
* *
......
...@@ -915,6 +915,38 @@ class ZPushAdminCLI { ...@@ -915,6 +915,38 @@ class ZPushAdminCLI {
echo "ActiveSync version:\t".($device->GetASVersion() ? $device->GetASVersion() : "unknown") ."\n"; echo "ActiveSync version:\t".($device->GetASVersion() ? $device->GetASVersion() : "unknown") ."\n";
echo "First sync:\t\t". strftime("%Y-%m-%d %H:%M", $device->GetFirstSyncTime()) ."\n"; echo "First sync:\t\t". strftime("%Y-%m-%d %H:%M", $device->GetFirstSyncTime()) ."\n";
echo "Last sync:\t\t". ($device->GetLastSyncTime() ? strftime("%Y-%m-%d %H:%M", $device->GetLastSyncTime()) : "never")."\n"; echo "Last sync:\t\t". ($device->GetLastSyncTime() ? strftime("%Y-%m-%d %H:%M", $device->GetLastSyncTime()) : "never")."\n";
$filterType = (defined('SYNC_FILTERTIME_MAX') && SYNC_FILTERTIME_MAX > SYNC_FILTERTYPE_ALL) ? SYNC_FILTERTIME_MAX : SYNC_FILTERTYPE_ALL;
$maxDevice = $device->GetSyncFilterType();
if ($maxDevice !== false && $maxDevice > SYNC_FILTERTYPE_ALL && ($filterType == SYNC_FILTERTYPE_ALL || $maxDevice < $filterType)) {
$filterType = $maxDevice;
}
switch($filterType) {
case SYNC_FILTERTYPE_1DAY:
$filterTypeString = "1 day back";
break;
case SYNC_FILTERTYPE_3DAYS:
$filterTypeString = "3 days back";
break;
case SYNC_FILTERTYPE_1WEEK:
$filterTypeString = "1 week back";
break;
case SYNC_FILTERTYPE_2WEEKS:
$filterTypeString = "2 weeks back";
break;
case SYNC_FILTERTYPE_1MONTH:
$filterTypeString = "1 month back";
break;
case SYNC_FILTERTYPE_3MONTHS:
$filterTypeString = "3 months back";
break;
case SYNC_FILTERTYPE_6MONTHS:
$filterTypeString = "6 months back";
break;
default:
$filterTypeString = "unlimited";
}
echo "Sync Period:\t\t". $filterTypeString . " (".$filterType.")\n";
echo "Total folders:\t\t". count($folders). "\n"; echo "Total folders:\t\t". count($folders). "\n";
echo "Short folder Ids:\t". ($device->HasFolderIdMapping() ? "Yes":"No") ."\n"; echo "Short folder Ids:\t". ($device->HasFolderIdMapping() ? "Yes":"No") ."\n";
echo "Synchronized folders:\t". $synchedFolders; echo "Synchronized folders:\t". $synchedFolders;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment