Return the currently set vacation message details.
public filters_getVacation ( ) : array | boolean | ||
Résultat | array | boolean | The vacation rule properties or false if interface unavailable. |
/** * Return settings from the backend for a SETTINGS request. * * @param array $settings An array of settings to return. Currently * supported: * - oof: The out of office message information. * @todo * - userinformation: UserInformation requests. * - emailaddresses: User's From email addresses. * - primarysmtpaddress: (@deprecated) The SMTP address used for the * default account. Only supported in EAS >= 14.1 * using accounts. * - status: EAS status code. * - accounts: Array with each entry containing emailaddresses, fullname * for additional identities. The primary address should be the * first in the emailaddresses array. * * @param stdClass $device The device to obtain settings for. * * @return array The requested settings. * @todo H6: return information keyed by the common names given in wbxml * schema for the settings command (use constants). */ public function getSettings(array $settings, $device) { $res = array(); foreach ($settings as $key => $setting) { switch ($key) { case 'oof': 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'] ? Horde_ActiveSync_Request_Settings::OOF_STATE_DISABLED : Horde_ActiveSync_Request_Settings::OOF_STATE_ENABLED, 'oofmsgs' => array()); $res['oof']['oofmsgs'][] = array('appliesto' => Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOINTERNAL, 'replymessage' => $vacation['reason'], 'enabled' => !$vacation['disabled'], 'bodytype' => $setting['bodytype'], 'subject' => $vacation['subject']); break; case 'userinformation': $identities = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($GLOBALS['registry']->getAuth()); $default_email = $identities->getValue('from_addr'); $email_addresses = array($default_email); $accounts = array(); if ($this->_version >= Horde_ActiveSync::VERSION_FOURTEENONE) { // @TODO Do clients actually support multiple accounts? // Can't find one that does. For now, only return the // default identity. $ident = $identities->get(); $emails = !empty($ident['alias_addr']) ? $ident['alias_addr'] : array(); $emails[] = $ident['from_addr']; $accounts[] = array('fullname' => $ident['fullname'], 'emailaddresses' => array_reverse($emails)); } $res['userinformation'] = array('emailaddresses' => $email_addresses, 'primarysmtpaddress' => $default_email, 'status' => Horde_ActiveSync_Request_Settings::STATUS_SUCCESS, 'accounts' => $accounts); } } return $res; }
/** * Return settings from the backend for a SETTINGS request. * * @param array $settings An array of settings to return. Currently * supported: * - oof: The out of office message information. * @todo * - userinformation: UserInformation requests. * - emailaddresses: User's From email addresses. * - primarysmtpaddress: (@deprecated) The SMTP address used for the * default account. Only supported in EAS >= 14.1 * using accounts. * - status: EAS status code. * - accounts: Array with each entry containing emailaddresses, fullname * for additional identities. The primary address should be the * first in the emailaddresses array. * * @param stdClass $device The device to obtain settings for. * * @return array The requested settings. * @todo H6: return information keyed by the common names given in wbxml * schema for the settings command (use constants) and return * as a Horde_ActiveSync_Message_Oof object. */ public function getSettings(array $settings, $device) { global $injector, $prefs, $registry; $res = array(); foreach ($settings as $key => $setting) { switch ($key) { case 'oof': 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'] ? Horde_ActiveSync_Request_Settings::OOF_STATE_DISABLED : Horde_ActiveSync_Request_Settings::OOF_STATE_ENABLED, 'oofmsgs' => array()); // If we have start/end it's a timebased vacation in EAS-speak. if (!empty($vacation['end']) && !$vacation['disabled']) { $res['oof']['oofstate'] = Horde_ActiveSync_Request_Settings::OOF_STATE_TIMEBASED; $res['oof']['starttime'] = new Horde_Date($vacation['start']); $res['oof']['endtime'] = new Horde_Date($vacation['end']); } // Horde's filter API doesn't support internal/external so // always send as internal since that's what most clients // fall back to as well. $res['oof']['oofmsgs'][] = array('appliesto' => Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOINTERNAL, 'replymessage' => $vacation['reason'], 'enabled' => !$vacation['disabled'], 'bodytype' => $setting['bodytype'], 'subject' => $vacation['subject']); break; case 'userinformation': $identities = $injector->getInstance('Horde_Core_Factory_Identity')->create($registry->getAuth()); $as_ident = $prefs->getValue('activesync_identity'); if ($as_ident != 'horde') { $identities->setDefault($prefs->getValue('activesync_identity')); } else { $as_ident = $identities->getDefault(); } $default_email = $identities->getValue('from_addr'); $email_addresses = array($default_email); $accounts = array(); if ($this->_version >= Horde_ActiveSync::VERSION_FOURTEENONE) { $identity = $identities->get(); $emails = !empty($identity['alias_addr']) ? $identity['alias_addr'] : array(); $emails[] = $identity['from_addr']; $accounts[] = array('fullname' => $identity['fullname'], 'emailaddresses' => array_reverse($emails), 'accountname' => $identity['id']); foreach ($identities as $id => $identity) { if ($id != $as_ident) { $emails = !empty($identity['alias_addr']) ? $identity['alias_addr'] : array(); $emails[] = $identity['from_addr']; $accounts[] = array('fullname' => $identity['fullname'], 'emailaddresses' => array_reverse($emails), 'accountname' => $identity['id'], 'id' => $id); } } } $res['userinformation'] = array('emailaddresses' => $email_addresses, 'primarysmtpaddress' => $default_email, 'status' => Horde_ActiveSync_Request_Settings::STATUS_SUCCESS, 'accounts' => $accounts); } } return $res; }