1: <?php
2: /**
3: * This code is licensed under AGPLv3 license or Afterlogic Software License
4: * if commercial version of the product was purchased.
5: * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files.
6: */
7:
8: namespace Aurora\Modules\DavContacts;
9:
10: /**
11: * Adds ability to work with Dav Contacts.
12: *
13: * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
14: * @license https://afterlogic.com/products/common-licensing Afterlogic Software License
15: * @copyright Copyright (c) 2023, Afterlogic Corp.
16: *
17: * @property Settings $oModuleSettings
18: *
19: * @package Modules
20: */
21: class Module extends \Aurora\System\Module\AbstractModule
22: {
23: protected $aRequireModules = [
24: 'Contacts'
25: ];
26:
27: protected $_oldGroup = null;
28:
29: protected $__LOCK_AFTER_CREATE_CONTACT_SUBSCRIBE__ = false;
30: protected $__LOCK_AFTER_UPDATE_CONTACT_SUBSCRIBE__ = false;
31:
32: /**
33: * @return Module
34: */
35: public static function getInstance()
36: {
37: return parent::getInstance();
38: }
39:
40: /**
41: * @return Module
42: */
43: public static function Decorator()
44: {
45: return parent::Decorator();
46: }
47:
48: /**
49: * @return Settings
50: */
51: public function getModuleSettings()
52: {
53: return $this->oModuleSettings;
54: }
55:
56: public function init()
57: {
58: $this->subscribeEvent('MobileSync::GetInfo', array($this, 'onGetMobileSyncInfo'));
59: }
60:
61: public function onGetMobileSyncInfo($aArgs, &$mResult)
62: {
63: $oDavModule = \Aurora\Modules\Dav\Module::Decorator();
64:
65: $sDavServer = $oDavModule->GetServerUrl();
66: $aAddressBooks = \Aurora\Modules\Contacts\Module::Decorator()->GetStorages();
67:
68: $mResult['Dav']['Contacts'] = array();
69: if (is_array($aAddressBooks) && count($aAddressBooks) > 0) {
70: foreach ($aAddressBooks as $oBook) {
71: $mResult['Dav']['Contacts'][] = array(
72: 'Name' => isset($oBook['DisplayName']) ? $oBook['DisplayName'] : '',
73: 'Url' => isset($oBook['Url']) ? rtrim($sDavServer . $oBook['Url'], '/') . '/' : ''
74: );
75: }
76: }
77: }
78: }
79: