Commit eb4f660c authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #444 in ZP/z-push from bugfix/ZP-1132-koe-store-client-capabilities to develop

* commit 'b000b628':
  ZP-1132 Simply return an emty array if koecapabilities are not set.
  ZP-1132 Store KOE client capabilities in ASDevice.
parents 1aed92b5 b000b628
......@@ -58,6 +58,7 @@ class ASDevice extends StateObject {
'koebuild' => false,
'koebuilddate' => false,
'koegabbackendfolderid' => false,
'koecapabilities' => array(),
);
static private $loadedData;
......
......@@ -150,6 +150,7 @@ class DeviceManager {
$this->device->SetKoeVersion(Request::GetKoeVersion());
$this->device->SetKoeBuild(Request::GetKoeBuild());
$this->device->SetKoeBuildDate(Request::GetKoeBuildDate());
$this->device->SetKoeCapabilities(Request::GetKoeCapabilities());
}
// data to be saved
......@@ -773,6 +774,23 @@ class DeviceManager {
return false;
}
/**
* Indicates if the KOE client supports a feature.
*
* @param string $feature
*
* @access public
* @return boolean
*/
public function HasKoeFeature($feature) {
$capabilities = $this->device->GetKoeCapabilities();
// in a settings request the capabilities might not yet be stored in the device
if (empty($capabilities)) {
$capabilities = Request::GetKoeCapabilities();
}
return in_array($feature, $capabilities);
}
/**
* Adds an Exceptions to the process tracking
*
......
......@@ -80,6 +80,7 @@ class Request {
static private $koeVersion;
static private $koeBuild;
static private $koeBuildDate;
static private $koeCapabilites;
static private $expectedConnectionTimeout;
/**
......@@ -226,6 +227,14 @@ class Request {
self::$koeBuildDate = strtotime(self::filterEvilInput($buildDate, self::ISO8601));
}
if (isset(self::$headers["x-push-plugin-capabilities"])) {
$caps = explode(",", self::$headers["x-push-plugin-capabilities"]);
self::$koeCapabilites = array();
foreach($caps as $cap) {
self::$koeCapabilites[] = strtolower(self::filterEvilInput($cap, self::WORDCHAR_ONLY));
}
}
if (defined('USE_X_FORWARDED_FOR_HEADER') && USE_X_FORWARDED_FOR_HEADER == true && isset(self::$headers["x-forwarded-for"])) {
$forwardedIP = self::filterEvilInput(self::$headers["x-forwarded-for"], self::NUMBERSDOT_ONLY);
if ($forwardedIP) {
......@@ -740,6 +749,19 @@ class Request {
return self::UNKNOWN;
}
/**
* Returns the capabilities of the KOE informed by the capabilities header.
*
* @access public
* @return string
*/
static public function GetKoeCapabilities() {
if (isset(self::$koeCapabilites)) {
return self::$koeCapabilites;
}
return array();
}
/**
* Returns whether it is an Outlook client.
*
......
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