Skip to content

Commit

Permalink
Fix errors when the filter api is unavailable.
Browse files Browse the repository at this point in the history
Bug: 12757
  • Loading branch information
mrubinsk committed Oct 11, 2013
1 parent 2b2e53c commit 2d27b93
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 41 deletions.
78 changes: 41 additions & 37 deletions framework/ActiveSync/lib/Horde/ActiveSync/Request/Settings.php
Expand Up @@ -72,6 +72,7 @@ class Horde_ActiveSync_Request_Settings extends Horde_ActiveSync_Request_Base

const STATUS_SUCCESS = 1;
const STATUS_ERROR = 2;
const STATUS_UNAVAILABLE = 4;

const OOF_STATE_ENABLED = 1;
const OOF_STATE_DISABLED = 0;
Expand Down Expand Up @@ -253,7 +254,7 @@ protected function _handle()
$this->_encoder->startTag(self::SETTINGS_OOF);
$this->_encoder->startTag(self::SETTINGS_STATUS);
if (!isset($result['set']['oof'])) {
$this->_encoder->content(0);
$this->_encoder->content(self::OOF_STATE_DISABLED);
} else {
$this->_encoder->content($result['set']['oof']);
}
Expand Down Expand Up @@ -303,46 +304,49 @@ protected function _handle()
if (isset($request['get']['oof'])) {
$this->_encoder->startTag(self::SETTINGS_OOF);
$this->_encoder->startTag(self::SETTINGS_STATUS);
$this->_encoder->content(1);
$this->_encoder->content($result['get']['oof']['status']);
$this->_encoder->endTag(); // end self::SETTINGS_STATUS

$this->_encoder->startTag(self::SETTINGS_GET);
$this->_encoder->startTag(self::SETTINGS_OOFSTATE);
$this->_encoder->content($result['get']['oof']['oofstate']);
$this->_encoder->endTag(); // end self::SETTINGS_OOFSTATE
// This we maybe need later on (OOFSTATE=2). It shows that OOF
// Messages could be send depending on Time being set in here.
// Unfortunately cannot proof it working on my device.
if ($result['get']['oof']['oofstate'] == 2) {
$this->_encoder->startTag(self::SETTINGS_STARTTIME);
$this->_encoder->content(gmdate('Y-m-d\TH:i:s.000', $result['get']['oof']['starttime']));
$this->_encoder->endTag(); // end self::SETTINGS_STARTTIME
$this->_encoder->startTag(self::SETTINGS_ENDTIME);
$this->_encoder->content(gmdate('Y-m-d\TH:i:s.000', $result['get']['oof']['endtime']));
$this->_encoder->endTag(); // end self::SETTINGS_ENDTIME
}
foreach($result['get']['oof']['oofmsgs'] as $oofentry) {
$this->_encoder->startTag(self::SETTINGS_OOFMESSAGE);
$this->_encoder->startTag($oofentry['appliesto'],false,true);
$this->_encoder->startTag(self::SETTINGS_ENABLED);
$this->_encoder->content($oofentry['enabled']);
$this->_encoder->endTag(); // end self::SETTINGS_ENABLED
$this->_encoder->startTag(self::SETTINGS_REPLYMESSAGE);
$this->_encoder->content($oofentry['replymessage']);
$this->_encoder->endTag(); // end self::SETTINGS_REPLYMESSAGE
$this->_encoder->startTag(self::SETTINGS_BODYTYPE);
switch (strtolower($oofentry['bodytype'])) {
case 'text':
$this->_encoder->content('Text');
break;
case 'HTML':
$this->_encoder->content('HTML');
if ($result['get']['oof']['status'] == self::STATUS_SUCCESS) {
$this->_encoder->startTag(self::SETTINGS_GET);
$this->_encoder->startTag(self::SETTINGS_OOFSTATE);
$this->_encoder->content($result['get']['oof']['oofstate']);
$this->_encoder->endTag(); // end self::SETTINGS_OOFSTATE
// This we maybe need later on (OOFSTATE=2). It shows that OOF
// Messages could be send depending on Time being set in here.
// Unfortunately cannot proof it working on my device.
if ($result['get']['oof']['oofstate'] == 2) {
$this->_encoder->startTag(self::SETTINGS_STARTTIME);
$this->_encoder->content(gmdate('Y-m-d\TH:i:s.000', $result['get']['oof']['starttime']));
$this->_encoder->endTag(); // end self::SETTINGS_STARTTIME
$this->_encoder->startTag(self::SETTINGS_ENDTIME);
$this->_encoder->content(gmdate('Y-m-d\TH:i:s.000', $result['get']['oof']['endtime']));
$this->_encoder->endTag(); // end self::SETTINGS_ENDTIME
}
foreach($result['get']['oof']['oofmsgs'] as $oofentry) {
$this->_encoder->startTag(self::SETTINGS_OOFMESSAGE);
$this->_encoder->startTag($oofentry['appliesto'],false,true);
$this->_encoder->startTag(self::SETTINGS_ENABLED);
$this->_encoder->content($oofentry['enabled']);
$this->_encoder->endTag(); // end self::SETTINGS_ENABLED
$this->_encoder->startTag(self::SETTINGS_REPLYMESSAGE);
$this->_encoder->content($oofentry['replymessage']);
$this->_encoder->endTag(); // end self::SETTINGS_REPLYMESSAGE
$this->_encoder->startTag(self::SETTINGS_BODYTYPE);
switch (strtolower($oofentry['bodytype'])) {
case 'text':
$this->_encoder->content('Text');
break;
case 'HTML':
$this->_encoder->content('HTML');
}
$this->_encoder->endTag(); // end self::SETTINGS_BODYTYPE
$this->_encoder->endTag(); // end self::SETTINGS_OOFMESSAGE
}
$this->_encoder->endTag(); // end self::SETTINGS_BODYTYPE
$this->_encoder->endTag(); // end self::SETTINGS_OOFMESSAGE
$this->_encoder->endTag(); // end self::SETTINGS_GET
$this->_encoder->endTag(); // end self::SETTINGS_OOF
}
$this->_encoder->endTag(); // end self::SETTINGS_GET
$this->_encoder->endTag(); // end self::SETTINGS_OOF

}

$this->_encoder->endTag(); // end self::SETTINGS_SETTINGS
Expand Down
2 changes: 2 additions & 0 deletions framework/ActiveSync/package.xml
Expand Up @@ -21,6 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mjr] Return proper status codes when OOF is unavailable (Bug #12757).
* [mjr] Fix fatal crash when conflict is detected (Thomas Jarosch &lt;thomas.jarosch@intra2net.com&gt;, Bug #12755)
</notes>
<contents>
Expand Down Expand Up @@ -1763,6 +1764,7 @@
<date>2013-10-07</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mjr] Return proper status codes when OOF is unavailable (Bug #12757).
* [mjr] Fix fatal crash when conflict is detected (Thomas Jarosch &lt;thomas.jarosch@intra2net.com&gt;, Bug #12755)
</notes>
</release>
Expand Down
14 changes: 12 additions & 2 deletions framework/Core/lib/Horde/Core/ActiveSync/Connector.php
Expand Up @@ -647,20 +647,30 @@ public function horde_hasInterface($api)
/**
* Return the currently set vacation message details.
*
* @return array The vacation rule properties.
* @return array|boolean The vacation rule properties or false if
* interface unavailable.
*/
public function filters_getVacation()
{
return $this->_registry->filter->getVacation();
if ($this->horde_hasInterface('filter')) {
return $this->_registry->filter->getVacation();
} else {
return false;
}
}

/**
* Set vacation message properties.
*
* @param array $setting The vacation details.
*
* @throws Horde_Exception
*/
public function filters_setVacation(array $setting)
{
if (!$this->horde_hasInterface('filter')) {
throw new Horde_Exception('Filter interface unavailable.');
}
if ($setting['oofstate'] == Horde_ActiveSync_Request_Settings::OOF_STATE_ENABLED) {
// Only support a single message, the APPLIESTOINTERNAL message.
foreach ($setting['oofmsgs'] as $msg) {
Expand Down
4 changes: 3 additions & 1 deletion framework/Core/lib/Horde/Core/ActiveSync/Driver.php
Expand Up @@ -1807,7 +1807,9 @@ public function getSettings(array $settings, $device)
foreach ($settings as $key => $setting) {
switch ($key) {
case 'oof':
$vacation = $this->_connector->filters_getVacation();
if (!$vacation = $this->_connector->filters_getVacation()) {
return array('oof' => array('status' => Horde_ActiveSync_Request_Settings::STATUS_UNAVAILABLE));
}
$res['oof'] = array(
'status' => Horde_ActiveSync_Request_Settings::STATUS_SUCCESS,
'oofstate' => ($vacation['disabled']
Expand Down
4 changes: 3 additions & 1 deletion framework/Core/package.xml
Expand Up @@ -39,6 +39,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mjr] Do not assume that the filter API is available (Bug #12757).
* [mms] Add ability to load javascript via a HordeCore AJAX response (Request #10971).
* [mms] Add ability to expire CSS cache based on file modification time.
* [mms] Allow disabling VFS via the configuration interface.
Expand Down Expand Up @@ -1216,7 +1217,7 @@
<package>
<name>Horde_ActiveSync</name>
<channel>pear.horde.org</channel>
<min>2.8.0</min>
<min>2.8.4</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
Expand Down Expand Up @@ -3178,6 +3179,7 @@
<date>2013-10-08</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mjr] Do not assume that the filter API is available (Bug #12757).
* [mms] Add ability to load javascript via a HordeCore AJAX response (Request #10971).
* [mms] Add ability to expire CSS cache based on file modification time.
* [mms] Allow disabling VFS via the configuration interface.
Expand Down

0 comments on commit 2d27b93

Please sign in to comment.