/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/ActiveSync/Base.php

https://github.com/imr/horde · PHP · 87 lines · 30 code · 5 blank · 52 comment · 0 complexity · c48f3a963c525f52f7b452cded877a09 MD5 · raw file

  1. <?php
  2. /**
  3. * Handles a active sync parameters.
  4. *
  5. * PHP version 5
  6. *
  7. * @category Kolab
  8. * @package Kolab_Storage
  9. * @author Gunnar Wrobel <wrobel@pardus.de>
  10. * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11. * @link http://pear.horde.org/index.php?package=Kolab_Storage
  12. */
  13. /**
  14. * Handles a active sync parameters.
  15. *
  16. * Copyright 2011-2014 Horde LLC (http://www.horde.org/)
  17. *
  18. * See the enclosed file COPYING for license information (LGPL). If you
  19. * did not receive this file, see http://www.horde.org/licenses/lgpl21.
  20. *
  21. * @category Kolab
  22. * @package Kolab_Storage
  23. * @author Gunnar Wrobel <wrobel@pardus.de>
  24. * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
  25. * @link http://pear.horde.org/index.php?package=Kolab_Storage
  26. */
  27. class Horde_Kolab_Storage_List_Query_ActiveSync_Base
  28. extends Horde_Kolab_Storage_List_Query_ActiveSync
  29. {
  30. /** The active sync parameters */
  31. /** @todo Shouldn't this be private data? */
  32. const ANNOTATION_ACTIVE_SYNC = '/priv/vendor/kolab/activesync';
  33. /**
  34. * The driver for accessing the Kolab storage system.
  35. *
  36. * @var Horde_Kolab_Storage_Driver
  37. */
  38. private $_driver;
  39. /**
  40. * Constructor.
  41. *
  42. * @param Horde_Kolab_Storage_Driver $driver The driver to access the backend.
  43. */
  44. public function __construct(Horde_Kolab_Storage_Driver $driver)
  45. {
  46. $this->_driver = $driver;
  47. }
  48. /**
  49. * Returns the active sync settings.
  50. *
  51. * @param string $folder The folder name.
  52. *
  53. * @return array The folder active sync parameters.
  54. */
  55. public function getActiveSync($folder)
  56. {
  57. return json_decode(
  58. base64_decode(
  59. $this->_driver->getAnnotation(
  60. $folder, self::ANNOTATION_ACTIVE_SYNC
  61. )
  62. ),
  63. true
  64. );
  65. }
  66. /**
  67. * Set the active sync settings.
  68. *
  69. * @param string $folder The folder name.
  70. * @param array $data The active sync settings.
  71. *
  72. * @return string The encoded share parameters.
  73. */
  74. public function setActiveSync($folder, array $data)
  75. {
  76. $this->_driver->setAnnotation(
  77. $folder,
  78. self::ANNOTATION_ACTIVE_SYNC,
  79. base64_encode(json_encode($data))
  80. );
  81. }
  82. }