/** * Returns a list of principals based on a prefix. * * This prefix will often contain something like 'principals'. You are only * expected to return principals that are in this base path. * * You are expected to return at least a 'uri' for every user, you can * return any additional properties if you wish so. Common properties are: * {DAV:}displayname * {http://sabredav.org/ns}email-address - This is a custom SabreDAV * field that's actualy injected in a number of other properties. If * you have an email address, use this property. * * @param string $prefixPath * @return array */ function getPrincipalsByPrefix($prefixPath) { $principals = []; $aUsers = \CApi::GetModuleDecorator('Core')->GetUserList(0, 0); if (is_array($aUsers)) { foreach ($aUsers as $oUser) { $principals[] = array('id' => $oUser['UUID'], 'uri' => 'principals/' . $oUser['UUID'], '{DAV:}displayname' => $oUser['Name']); } } return $principals; }
protected function getUser($principalUri) { if (null === $this->iUserId) { $oCoreModuleDecorador = \CApi::GetModuleDecorator('Core'); if ($oCoreModuleDecorador) { $oUser = $oCoreModuleDecorador->GetUser(basename($principalUri)); if ($oUser) { $this->iUserId = basename($principalUri); } } } return $this->iUserId; }
/** * 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) { $oDavDecorator = \CApi::GetModuleDecorator('Dav'); if ($oDavDecorator) { $mResult = $oDavDecorator->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 int $iUserId Default value is empty string. * * @return \CUser */ public function getAuthenticatedUserByIdHelper($iUserId = '') { $oCoreDecorator = \CApi::GetModuleDecorator('Core'); $oUser = null; if (0 < $iUserId) { $oUser = $oCoreDecorator->GetUser($iUserId); } elseif ($iUserId === -1) { $oUser = $oCoreDecorator->GetAdminUser(); } return $oUser; }