public static function GetBackend($sName) { if (!isset(self::$aBackends[$sName])) { $oBackend = null; switch ($sName) { case 'auth': $oBackend = \afterlogic\DAV\Auth\Backend::getInstance(); break; case 'principal': $oBackend = new \afterlogic\DAV\Principal\Backend\PDO(); break; case 'caldav': $oBackend = new \afterlogic\DAV\CalDAV\Backend\PDO(); break; case 'carddav': $oBackend = new \afterlogic\DAV\CardDAV\Backend\PDO(); break; case 'carddav-owncloud': $oBackend = new \afterlogic\DAV\CardDAV\Backend\OwnCloudPDO(); break; case 'lock': $oBackend = new \afterlogic\DAV\Locks\Backend\PDO(); break; case 'reminders': $oBackend = new \afterlogic\DAV\Reminders\Backend\PDO(); break; } if (isset($oBackend)) { self::$aBackends[$sName] = $oBackend; } } return self::$aBackends[$sName]; }
public function getAccount() { if ($this->oAccount == null) { $sUser = \afterlogic\DAV\Auth\Backend::getInstance()->getCurrentUser(); $this->oAccount = \afterlogic\DAV\Utils::GetAccountByLogin($sUser); } return $this->oAccount; }
public function initPath() { $username = \afterlogic\DAV\Auth\Backend::getInstance()->getCurrentUser(); if ($this->rootPath === null) { $this->rootPath = $this->path . '/' . $username; if (!file_exists($this->rootPath)) { mkdir($this->rootPath, 0777, true); } } $this->path = $this->rootPath; }
/** * @param CAccount $oAccount */ public function Init($oAccount) { $bResult = false; if ($oAccount) { if (!$this->initialized) { \afterlogic\DAV\Auth\Backend::getInstance()->setCurrentUser($oAccount->Email); \afterlogic\DAV\Utils::CheckPrincipals($oAccount->Email); $this->initialized = true; } $bResult = true; } return $bResult; }
public function initPath() { if ($this->rootPath === null) { $sUserName = \afterlogic\DAV\Auth\Backend::getInstance()->getCurrentUser(); if (isset($sUserName)) { $oAccount = \afterlogic\DAV\Utils::GetAccountByLogin($sUserName); if ($oAccount) { $this->rootPath = $this->path . '/' . $oAccount->IdTenant; if (!file_exists($this->rootPath)) { mkdir($this->rootPath, 0777, true); } } } } $this->path = $this->rootPath; }
/** * Validates a username and password * * This method should return true or false depending on if login * succeeded. * * @return bool */ protected function validateUserPass($sUserName, $sPassword) { $mResult = false; if (class_exists('CApi') && \CApi::IsValid()) { /* @var $oApiCapabilityManager \CApiCapabilityManager */ $oApiCapabilityManager = \CApi::GetSystemManager('capability'); if ($oApiCapabilityManager) { $mResult = \Afterlogic\DAV\Auth\Backend::Login($sUserName, $sPassword); $bIsOutlookSyncClient = \Afterlogic\DAV\Utils::ValidateClient('outlooksync'); $bIsMobileSync = false; $bIsOutlookSync = false; $bIsDemo = false; // if ($mResult !== false) { // $iIdUser = isset($mResult['id']) ? $mResult['id'] : 0; // return true; /* $bIsMobileSync = $oApiCapabilityManager->isMobileSyncSupported($iIdUser); $bIsOutlookSync = $oApiCapabilityManager->isOutlookSyncSupported($iIdUser); \CApi::Plugin()->RunHook( 'plugin-is-demo-account', array(&$oAccount, &$bIsDemo) ); * */ // } /* if (($oAccount && $oAccount->IncomingMailPassword === $sPassword && (($bIsMobileSync && !$bIsOutlookSyncClient) || ($bIsOutlookSync && $bIsOutlookSyncClient))) || $bIsDemo || $sUserName === \CApi::ExecuteMethod('Dav::GetPublicUser')) { return true; } * */ } } return $mResult; }
/** * @param CAccount $oAccount */ public function InitByAccount($oAccount) { $bResult = false; if ($oAccount && (!$this->Account || $this->Account->Email !== $oAccount->Email)) { $this->Account = $oAccount; $this->aAddressBooksCache = array(); $this->aContactItemsCache = array(); $this->aGroupItemsCache = array(); $this->ContactsCache = array(); $this->GroupsCache = array(); \afterlogic\DAV\Auth\Backend::getInstance()->setCurrentUser($oAccount->Email); \afterlogic\DAV\Utils::CheckPrincipals($oAccount->Email); $aPrincipalProperties = \afterlogic\DAV\Backend::Principal()->getPrincipalByPath(\afterlogic\DAV\Constants::PRINCIPALS_PREFIX . '/' . $oAccount->Email); if ($aPrincipalProperties) { if (isset($aPrincipalProperties['uri'])) { $this->Principal = $aPrincipalProperties['uri']; } } } if ($this->Account) { $bResult = true; } return $bResult; }
public static function getCurrentAccount() { return self::getUsersManager()->getAccountByEmail(\afterlogic\DAV\Auth\Backend::getInstance()->getCurrentUser()); }