/** * Sets up the backend. */ public function __construct() { $oPdo = \CApi::GetPDO(); $dbPrefix = \CApi::GetSettings()->GetConf('Common/DBPrefix'); $this->oApiUsersManager = \CApi::Manager('users'); parent::__construct($oPdo, $dbPrefix . Constants::T_PRINCIPALS, $dbPrefix . Constants::T_GROUPMEMBERS); }
public static function CheckPrincipals($sUserName) { if (trim($sUserName) !== '') { $oPdo = \CApi::GetPDO(); $dbPrefix = \CApi::GetSettingsConf('Common/DBPrefix'); $sPrincipal = \afterlogic\DAV\Constants::PRINCIPALS_PREFIX . '/' . $sUserName; $oStmt = $oPdo->prepare('SELECT id FROM ' . $dbPrefix . Constants::T_PRINCIPALS . ' WHERE uri = ? LIMIT 1'); $oStmt->execute(array($sPrincipal)); if (count($oStmt->fetchAll()) === 0) { $oStmt = $oPdo->prepare('INSERT INTO ' . $dbPrefix . Constants::T_PRINCIPALS . ' (uri,email,displayname) VALUES (?, ?, ?)'); try { $oStmt->execute(array($sPrincipal, $sUserName, '')); } catch (Exception $e) { } } $oStmt = $oPdo->prepare('SELECT principaluri FROM ' . $dbPrefix . Constants::T_CALENDARS . ' WHERE principaluri = ?'); $oStmt->execute(array($sPrincipal)); if (count($oStmt->fetchAll()) === 0) { $oStmt = $oPdo->prepare('INSERT INTO ' . $dbPrefix . Constants::T_CALENDARS . ' (principaluri, displayname, uri, description, components, ctag, calendarcolor) VALUES (?, ?, ?, ?, ?, 1, ?)'); $oAccount = self::GetAccountByLogin($sUserName); $oStmt->execute(array($sPrincipal, \CApi::ClientI18N('CALENDAR/CALENDAR_DEFAULT_NAME', $oAccount), \Sabre\DAV\UUIDUtil::getUUID(), '', 'VEVENT,VTODO', Constants::CALENDAR_DEFAULT_COLOR)); } $oStmt = $oPdo->prepare('SELECT principaluri FROM ' . $dbPrefix . Constants::T_CALENDARS . ' WHERE principaluri = ? and uri = ? LIMIT 1'); $oStmt->execute(array($sPrincipal, Constants::CALENDAR_DEFAULT_NAME)); if (count($oStmt->fetchAll()) !== 0) { $oStmt = $oPdo->prepare('UPDATE ' . $dbPrefix . Constants::T_CALENDARS . ' SET uri = ? WHERE principaluri = ? and uri = ?'); $oStmt->execute(array(\Sabre\DAV\UUIDUtil::getUUID(), $sPrincipal, Constants::CALENDAR_DEFAULT_NAME)); } $oStmt = $oPdo->prepare('SELECT principaluri FROM ' . $dbPrefix . Constants::T_ADDRESSBOOKS . ' WHERE principaluri = ? and uri = ? LIMIT 1'); $oStmt->execute(array($sPrincipal, Constants::ADDRESSBOOK_DEFAULT_NAME)); $bHasDefaultAddressbooks = count($oStmt->fetchAll()) != 0; $oStmt->execute(array($sPrincipal, Constants::ADDRESSBOOK_DEFAULT_NAME_OLD)); $bHasOldDefaultAddressbooks = count($oStmt->fetchAll()) != 0; $oStmt->execute(array($sPrincipal, Constants::ADDRESSBOOK_COLLECTED_NAME)); $bHasCollectedAddressbooks = count($oStmt->fetchAll()) != 0; $stmt1 = $oPdo->prepare('INSERT INTO ' . $dbPrefix . Constants::T_ADDRESSBOOKS . ' (principaluri, displayname, uri, description, ctag) VALUES (?, ?, ?, ?, 1)'); if (!$bHasDefaultAddressbooks) { if ($bHasOldDefaultAddressbooks) { $oStmt = $oPdo->prepare('UPDATE ' . $dbPrefix . Constants::T_ADDRESSBOOKS . ' SET uri = ? WHERE principaluri = ? and uri = ?'); $oStmt->execute(array(Constants::ADDRESSBOOK_DEFAULT_NAME, $sPrincipal, Constants::ADDRESSBOOK_DEFAULT_NAME_OLD)); } else { $stmt1->execute(array($sPrincipal, Constants::ADDRESSBOOK_DEFAULT_DISPLAY_NAME, Constants::ADDRESSBOOK_DEFAULT_NAME, Constants::ADDRESSBOOK_DEFAULT_DISPLAY_NAME)); } } if (!$bHasCollectedAddressbooks) { $stmt1->execute(array($sPrincipal, Constants::ADDRESSBOOK_COLLECTED_DISPLAY_NAME, Constants::ADDRESSBOOK_COLLECTED_NAME, Constants::ADDRESSBOOK_COLLECTED_DISPLAY_NAME)); } } }
/** * Creates the backend object. * * @return void */ public function __construct() { $dBPrefix = \CApi::GetSettings()->GetConf('Common/DBPrefix'); $this->pdo = \CApi::GetPDO(); $this->table = $dBPrefix . Constants::T_REMINDERS; $this->calendarTbl = $dBPrefix . Constants::T_CALENDARS; $this->principalsTbl = $dBPrefix . Constants::T_PRINCIPALS; }
/** * Constructor */ public function __construct() { $oPdo = \CApi::GetPDO(); $dbPrefix = \CApi::GetSettings()->GetConf('Common/DBPrefix'); parent::__construct($oPdo, $dbPrefix.Constants::T_LOCKS); }
/** * Sets up the object */ public function __construct() { parent::__construct(\CApi::GetPDO()); $sDbPrefix = \CApi::GetSettings()->GetConf('Common/DBPrefix'); $this->cardsTableName = $sDbPrefix . Constants::T_CARDS; $this->addressBooksTableName = $sDbPrefix . Constants::T_ADDRESSBOOKS; $this->addressBookChangesTableName = $sDbPrefix . Constants::T_ADDRESSBOOKCHANGES; }
/** * Sets up the object */ public function __construct() { $oPdo = \CApi::GetPDO(); $sDbPrefix = \CApi::GetSettings()->GetConf('Common/DBPrefix'); parent::__construct($oPdo, $sDbPrefix.Constants::T_ADDRESSBOOKS, $sDbPrefix.Constants::T_CARDS); }
/** * Creates the backend */ public function __construct() { $oPdo = \CApi::GetPDO(); $sDbPrefix = \CApi::GetSettings()->GetConf('Common/DBPrefix'); $this->dBPrefix = $sDbPrefix; parent::__construct($oPdo, $sDbPrefix . Constants::T_CALENDARS, $sDbPrefix . Constants::T_CALENDAROBJECTS); $this->calendarSharesTableName = $sDbPrefix . Constants::T_CALENDARSHARES; $this->principalsTableName = $sDbPrefix . Constants::T_PRINCIPALS; $this->notificationsTableName = $sDbPrefix . Constants::T_NOTIFICATIONS; }
/** * Creates the backend */ public function __construct() { parent::__construct(\CApi::GetPDO()); $this->dBPrefix = \CApi::GetSettings()->GetConf('Common/DBPrefix'); $this->calendarTableName = $this->dBPrefix . Constants::T_CALENDARS; $this->calendarChangesTableName = $this->dBPrefix . Constants::T_CALENDARCHANGES; $this->calendarObjectTableName = $this->dBPrefix . Constants::T_CALENDAROBJECTS; $this->calendarSharesTableName = $this->dBPrefix . Constants::T_CALENDARSHARES; $this->schedulingObjectTableName = $this->dBPrefix . Constants::T_SCHEDULINGOBJECTS; $this->calendarSubscriptionsTableName = $this->dBPrefix . Constants::T_CALENDARSUBSCRIPTIONS; }
/** * @param CApiGlobalManager &$oManager */ public function __construct(CApiGlobalManager &$oManager) { parent::__construct('carddav', $oManager); CApi::Inc('common.dav.client'); $this->Dav = null; $this->Settings = CApi::GetSettings(); $this->Pdo = CApi::GetPDO(); $this->User = null; $this->Account = null; $this->Connected = false; $this->aAddressBooksCache = array(); $this->aGroupItemsCache = array(); $this->ContactsCache = array(); $this->GroupsCache = array(); $this->DbPrefix = $this->Settings->GetConf('Common/DBPrefix'); $this->ApiUsersManager = CApi::Manager('users'); $this->ApiDavManager = CApi::Manager('dav'); }
/** * Constructor */ public function __construct() { parent::__construct(\CApi::GetPDO()); $dbPrefix = \CApi::GetSettings()->GetConf('Common/DBPrefix'); $this->tableName = $dbPrefix . Constants::T_LOCKS; }
public function __construct($baseUri = '/') { $this->debugExceptions = false; self::$exposeVersion = false; $this->setBaseUri($baseUri); date_default_timezone_set('GMT'); if (\CApi::GetPDO()) { /* Authentication Plugin */ $this->addPlugin(new \Sabre\DAV\Auth\Plugin(Backends::Auth(), 'SabreDAV')); /* Logs Plugin */ $this->addPlugin(new Logs\Plugin()); /* DAV ACL Plugin */ $aclPlugin = new \Sabre\DAVACL\Plugin(); $aclPlugin->hideNodesFromListings = true; $aclPlugin->defaultUsernamePath = Constants::PRINCIPALS_PREFIX; $mAdminPrincipal = \CApi::GetConf('labs.dav.admin-principal', false); if ($mAdminPrincipal !== false) { $aclPlugin->adminPrincipals = array(Constants::PRINCIPALS_PREFIX . '/' . $mAdminPrincipal); } $this->addPlugin($aclPlugin); $bIsOwncloud = false; /* Directory tree */ $aTree = array($bIsOwncloud ? new CardDAV\AddressBookRoot(Backends::Principal(), Backends::GetBackend('carddav-owncloud')) : new CardDAV\AddressBookRoot(Backends::Principal(), Backends::Carddav()), new CalDAV\CalendarRootNode(Backends::Principal(), Backends::Caldav()), new CardDAV\GAddressBooks('gab', Constants::GLOBAL_CONTACTS)); $this->oApiCapaManager = \CApi::Manager('capability'); /* Files folder */ if ($this->oApiCapaManager->IsFilesSupported()) { $bErrorCreateDir = false; /* Public files folder */ $publicDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT; if (!file_exists($publicDir)) { if (!@mkdir($publicDir)) { $bErrorCreateDir = true; } } $publicDir .= Constants::FILESTORAGE_PATH_CORPORATE; if (!file_exists($publicDir)) { if (!@mkdir($publicDir)) { $bErrorCreateDir = true; } } $personalDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT . Constants::FILESTORAGE_PATH_PERSONAL; if (!file_exists($personalDir)) { if (!@mkdir($personalDir)) { $bErrorCreateDir = true; } } $sharedDir = \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT . Constants::FILESTORAGE_PATH_SHARED; if (!file_exists($sharedDir)) { if (!@mkdir($sharedDir)) { $bErrorCreateDir = true; } } if ($bErrorCreateDir) { throw new \Sabre\DAV\Exception('Can\'t create directory in ' . \CApi::DataPath() . Constants::FILESTORAGE_PATH_ROOT, 500); } $aFilesTree = array(new FS\RootPersonal($personalDir), new FS\RootPublic($publicDir)); if (\CApi::GetConf('labs.files-sharing', false)) { array_push($aFilesTree, new FS\RootShared($sharedDir)); } array_push($aTree, new \Sabre\DAV\SimpleCollection('files', $aFilesTree)); $this->addPlugin(new FS\Plugin()); // Automatically guess (some) contenttypes, based on extesion $this->addPlugin(new \Sabre\DAV\Browser\GuessContentType()); } $oPrincipalColl = new \Sabre\DAVACL\PrincipalCollection(Backends::Principal()); $oPrincipalColl->disableListing = true; array_push($aTree, $oPrincipalColl); /* Initializing server */ parent::__construct($aTree); $this->httpResponse->setHeader("X-Server", Constants::DAV_SERVER_NAME); /* Reminders Plugin */ $this->addPlugin(new Reminders\Plugin(Backends::Reminders())); /* Contacts Plugin */ $this->addPlugin(new Contacts\Plugin()); if ($this->oApiCapaManager->IsMobileSyncSupported()) { /* CalDAV Plugin */ $this->addPlugin(new \Sabre\CalDAV\Plugin()); /* CardDAV Plugin */ $this->addPlugin(new \Sabre\CardDAV\Plugin()); /* ICS Export Plugin */ $this->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); /* VCF Export Plugin */ $this->addPlugin(new \Sabre\CardDAV\VCFExportPlugin()); } /* Calendar Sharing Plugin */ $this->addPlugin(new \Sabre\CalDAV\SharingPlugin()); /* HTML Frontend Plugin */ if (\CApi::GetConf('labs.dav.use-browser-plugin', false) !== false) { $this->addPlugin(new \Sabre\DAV\Browser\Plugin(false, false)); } /* Locks Plugin */ // $this->addPlugin(new \Sabre\DAV\Locks\Plugin(new \Sabre\DAV\Locks\Backend\File(\CApi::DataPath() . '/locks.dat'))); $this->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'), 90); } }
<?php /* * Copyright 2004-2015, AfterLogic Corp. * Licensed under AGPLv3 license or AfterLogic license * if commercial version of the product was purchased. * See the LICENSE file for a full license statement. */ // remove the following line for real use //exit('remove this line'); require_once dirname(__FILE__) . '/../libraries/afterlogic/api.php'; /* Get WebMail Settings */ $oSettings =& \CApi::GetSettings(); $sDbPrefix = $oSettings->GetConf('Common/DBPrefix'); /* Database */ $oPdo = \CApi::GetPDO(); $sCalendarSharesTableName = $sDbPrefix . \afterlogic\DAV\Constants::T_CALENDARSHARES; $stmt1 = $oPdo->prepare("SELECT * FROM " . $sDbPrefix . "adav_delegates"); $stmt1->execute(); while ($aRow1 = $stmt1->fetch(\PDO::FETCH_ASSOC)) { $stmt2 = $oPdo->prepare("SELECT * FROM " . $sCalendarSharesTableName . " WHERE calendarid = ? and member = ?"); $stmt2->execute(array($aRow1['calendarid'], $aRow1['principalid'])); if (count($stmt2->fetchAll()) === 0) { $stmt3 = $oPdo->prepare("INSERT INTO " . $sCalendarSharesTableName . "(calendarid, member, readonly) VALUES (?, ?, ?)"); $stmt3->execute(array($aRow1['calendarid'], $aRow1['principalid'], (int) $aRow1['mode'] === \ECalendarPermission::Read)); } }
public function __construct($baseUri = '/') { $this->debugExceptions = true; self::$exposeVersion = false; $this->setBaseUri($baseUri); date_default_timezone_set('GMT'); if (\CApi::GetPDO()) { /* Authentication Plugin */ $this->addPlugin(new \Afterlogic\DAV\Auth\Plugin(Backend::Auth(), 'SabreDAV')); /* Logs Plugin */ // $this->addPlugin(new Logs\Plugin()); /* DAV ACL Plugin */ $aclPlugin = new \Sabre\DAVACL\Plugin(); $aclPlugin->hideNodesFromListings = true; $aclPlugin->defaultUsernamePath = Constants::PRINCIPALS_PREFIX; $mAdminPrincipal = \CApi::GetConf('labs.dav.admin-principal', false); $aclPlugin->adminPrincipals = $mAdminPrincipal !== false ? array(Constants::PRINCIPALS_PREFIX . '/' . $mAdminPrincipal) : array(); $this->addPlugin($aclPlugin); $bIsOwncloud = false; /* Directory tree */ $aTree = array($bIsOwncloud ? new CardDAV\AddressBookRoot(Backend::Principal(), Backend::getBackend('carddav-owncloud')) : new CardDAV\AddressBookRoot(Backend::Principal(), Backend::Carddav()), new CalDAV\CalendarRoot(Backend::Principal(), Backend::Caldav()), new CardDAV\GAB\AddressBooks('gab', Constants::GLOBAL_CONTACTS)); $this->oApiCapaManager = \CApi::GetSystemManager('capability'); /* Files folder */ if ($this->oApiCapaManager->isFilesSupported()) { array_push($aTree, new \Afterlogic\DAV\FS\FilesRoot()); $this->addPlugin(new FS\Plugin()); // Automatically guess (some) contenttypes, based on extesion $this->addPlugin(new \Sabre\DAV\Browser\GuessContentType()); } $oPrincipalColl = new \Sabre\DAVACL\PrincipalCollection(Backend::Principal()); // $oPrincipalColl->disableListing = true; array_push($aTree, $oPrincipalColl); /* Initializing server */ parent::__construct($aTree); $this->httpResponse->setHeader("X-Server", Constants::DAV_SERVER_NAME); /* Reminders Plugin */ $this->addPlugin(new Reminders\Plugin(Backend::Reminders())); $this->addPlugin(new \Sabre\CalDAV\Schedule\Plugin()); $this->addPlugin(new \Sabre\CalDAV\Schedule\IMipPlugin('*****@*****.**')); /* Contacts Plugin */ $this->addPlugin(new Contacts\Plugin()); // if ($this->oApiCapaManager->isMobileSyncSupported()) { /* CalDAV Plugin */ $this->addPlugin(new \Sabre\CalDAV\Plugin()); /* CardDAV Plugin */ $this->addPlugin(new \Sabre\CardDAV\Plugin()); /* ICS Export Plugin */ $this->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); /* VCF Export Plugin */ $this->addPlugin(new \Sabre\CardDAV\VCFExportPlugin()); // } /* Calendar Sharing Plugin */ $this->addPlugin(new \Sabre\CalDAV\SharingPlugin()); /* DAV Sync Plugin */ $this->addPlugin(new \Sabre\DAV\Sync\Plugin()); /* HTML Frontend Plugin */ if (\CApi::GetConf('labs.dav.use-browser-plugin', false) !== false) { $this->addPlugin(new \Sabre\DAV\Browser\Plugin()); } /* Locks Plugin */ // $this->addPlugin(new \Sabre\DAV\Locks\Plugin()); $this->on('beforeGetProperties', array($this, 'beforeGetProperties'), 90); } }