本文整理汇总了PHP中CApi::Plugin方法的典型用法代码示例。如果您正苦于以下问题:PHP CApi::Plugin方法的具体用法?PHP CApi::Plugin怎么用?PHP CApi::Plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApi
的用法示例。
在下文中一共展示了CApi::Plugin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param CDomain $oDomain
* @return void
*/
public function __construct()
{
parent::__construct(get_class($this), 'IdIdentity');
$this->SetTrimer(array('Email', 'FriendlyName'));
$this->SetDefaults(array('IdIdentity' => 0, 'IdUser' => 0, 'IdAccount' => 0, 'Virtual' => false, 'Default' => false, 'Enabled' => true, 'Email' => '', 'FriendlyName' => '', 'Signature' => '', 'SignatureType' => EAccountSignatureType::Html, 'UseSignature' => false));
CApi::Plugin()->RunHook('api-identity-construct', array(&$this));
}
示例2: getDigestHash
public function getDigestHash($sRealm, $sUserName)
{
if (class_exists('CApi') && \CApi::IsValid()) {
/* @var $oApiCapabilityManager \CApiCapabilityManager */
$oApiCapabilityManager = \CApi::GetSystemManager('capability');
if ($oApiCapabilityManager) {
$oAccount = \Afterlogic\DAV\Utils::GetAccountByLogin($sUserName);
if ($oAccount && $oAccount->IsDisabled) {
return null;
}
$bIsOutlookSyncClient = \Afterlogic\DAV\Utils::ValidateClient('outlooksync');
$bIsMobileSync = false;
$bIsOutlookSync = false;
$bIsDemo = false;
if ($oAccount) {
$bIsMobileSync = $oApiCapabilityManager->isMobileSyncSupported($oAccount);
$bIsOutlookSync = $oApiCapabilityManager->isOutlookSyncSupported($oAccount);
\CApi::Plugin()->RunHook('plugin-is-demo-account', array(&$oAccount, &$bIsDemo));
}
if ($oAccount && ($bIsMobileSync && !$bIsOutlookSyncClient || $bIsOutlookSync && $bIsOutlookSyncClient) || $bIsDemo || $sUserName === \CApi::ExecuteMethod('Dav::GetPublicUser')) {
return md5($sUserName . ':' . $sRealm . ':' . ($bIsDemo ? 'demo' : $oAccount->IncomingMailPassword));
}
}
}
return null;
}
示例3: CommonSocial
public function CommonSocial(ap_Standard_Screen &$oScreen)
{
$oApiCapa = CApi::Manager('capability');
/* @var $oApiCapa CApiCapabilityManager */
if ($oApiCapa && !$this->oAdminPanel->IsOnlyReadAuthType()) {
$oTenant = $this->oModule->GetTenantAdminObject();
if ($oTenant) {
$aConnectors = array();
$oPlugin = \CApi::Plugin()->GetPluginByName('external-services');
if ($oPlugin) {
$aEnableConnectors = $oPlugin->GetEnabledConnectors();
$aSocials = $oTenant->getSocials();
foreach ($aSocials as $sKey => $oSocial) {
if (in_array($sKey, $aEnableConnectors)) {
$oSocial->SupportedScopes = $oPlugin->GetSupportedScopes($sKey);
$oSocial->TranslatedScopes = $oPlugin->GetTranslatedScopes($oSocial->SupportedScopes);
$oSocial->HasApiKey = $oPlugin->HasApiKey($sKey);
$aConnectors[$sKey] = $oSocial;
}
}
}
$oScreen->Data->SetValue('Socials', $aConnectors);
}
}
}
示例4: validateUserPass
/**
* Validates a username and password
*
* This method should return true or false depending on if login
* succeeded.
*
* @return bool
*/
protected function validateUserPass($sUserName, $sPassword)
{
if (class_exists('CApi') && \CApi::IsValid()) {
/* @var $oApiCalendarManager \CApiCalendarManager */
$oApiCalendarManager = \CApi::Manager('calendar');
/* @var $oApiCapabilityManager \CApiCapabilityManager */
$oApiCapabilityManager = \CApi::Manager('capability');
if ($oApiCalendarManager && $oApiCapabilityManager) {
$oAccount = \afterlogic\DAV\Utils::GetAccountByLogin($sUserName);
if ($oAccount && $oAccount->IsDisabled) {
return false;
}
$bIsOutlookSyncClient = \afterlogic\DAV\Utils::ValidateClient('outlooksync');
$bIsMobileSync = false;
$bIsOutlookSync = false;
$bIsDemo = false;
if ($oAccount) {
$bIsMobileSync = $oApiCapabilityManager->IsMobileSyncSupported($oAccount);
$bIsOutlookSync = $oApiCapabilityManager->IsOutlookSyncSupported($oAccount);
\CApi::Plugin()->RunHook('plugin-is-demo-account', array(&$oAccount, &$bIsDemo));
}
if ($oAccount && $oAccount->IncomingMailPassword === $sPassword && ($bIsMobileSync && !$bIsOutlookSyncClient || $bIsOutlookSync && $bIsOutlookSyncClient) || $bIsDemo || $sUserName === $oApiCalendarManager->GetPublicUser()) {
\afterlogic\DAV\Utils::CheckPrincipals($sUserName);
return true;
}
}
}
return false;
}
示例5: __construct
public function __construct()
{
parent::__construct(get_class($this), 'IdGroup');
$this->__USE_TRIM_IN_STRINGS__ = true;
$this->SetDefaults(array('IdGroup' => '', 'IdGroupStr' => '', 'IdUser' => 0, 'Name' => '', 'IsOrganization' => false, 'Email' => '', 'Company' => '', 'Street' => '', 'City' => '', 'State' => '', 'Zip' => '', 'Country' => '', 'Phone' => '', 'Fax' => '', 'Web' => '', 'Events' => array()));
CApi::Plugin()->RunHook('api-group-construct', array(&$this));
}
示例6: __construct
public function __construct()
{
parent::__construct(get_class($this), 'IdContact');
$this->__USE_TRIM_IN_STRINGS__ = true;
$this->SetDefaults(array('IdContact' => '', 'IdContactStr' => '', 'IdUser' => 0, 'IdDomain' => 0, 'IdTenant' => 0, 'GroupsIds' => array(), 'Type' => EContactType::Personal, 'IdTypeLink' => '', 'FullName' => '', 'UseFriendlyName' => true, 'ViewEmail' => '', 'PrimaryEmail' => CApi::GetConf('contacts.default-primary-email', EPrimaryEmailType::Home), 'DateCreated' => time(), 'DateModified' => time(), 'Title' => '', 'FirstName' => '', 'LastName' => '', 'NickName' => '', 'Skype' => '', 'Facebook' => '', 'HomeEmail' => '', 'HomeStreet' => '', 'HomeCity' => '', 'HomeState' => '', 'HomeZip' => '', 'HomeCountry' => '', 'HomePhone' => '', 'HomeFax' => '', 'HomeMobile' => '', 'HomeWeb' => '', 'BusinessEmail' => '', 'BusinessCompany' => '', 'BusinessStreet' => '', 'BusinessCity' => '', 'BusinessState' => '', 'BusinessZip' => '', 'BusinessCountry' => '', 'BusinessJobTitle' => '', 'BusinessDepartment' => '', 'BusinessOffice' => '', 'BusinessPhone' => '', 'BusinessMobile' => '', 'BusinessFax' => '', 'BusinessWeb' => '', 'OtherEmail' => '', 'Notes' => '', 'BirthdayDay' => 0, 'BirthdayMonth' => 0, 'BirthdayYear' => 0, 'ReadOnly' => false, 'Global' => false, 'ItsMe' => false, 'ETag' => '', 'SharedToAll' => false, 'HideInGAB' => false));
$this->__LOCK_DATE_MODIFIED__ = false;
$this->__SKIP_VALIDATE__ = false;
CApi::Plugin()->RunHook('api-contact-construct', array(&$this));
}
示例7: __construct
/**
* @param CDomain $oDomain
* @return void
*/
public function __construct($oDomain)
{
parent::__construct(get_class($this), 'IdAccount');
$this->Domain = $oDomain;
$this->User = new CUser($oDomain);
$this->aExtension = array();
$this->SetTrimer(array('Email', 'FriendlyName', 'IncomingMailServer', 'IncomingMailLogin', 'IncomingMailPassword', 'PreviousMailPassword', 'OutgoingMailServer', 'OutgoingMailLogin'));
$this->SetLower(array('IncomingMailServer', 'OutgoingMailServer'));
$this->SetDefaults(array('IdAccount' => 0, 'IdUser' => 0, 'IdDomain' => $oDomain->IdDomain, 'IdTenant' => $oDomain->IdTenant, 'IsDefaultAccount' => true, 'IsInternal' => $oDomain->IsInternal, 'IsDisabled' => false, 'IsMailingList' => false, 'StorageQuota' => $oDomain->UserQuota, 'StorageUsedSpace' => 0, 'Email' => '', 'FriendlyName' => '', 'IncomingMailProtocol' => $oDomain->IncomingMailProtocol, 'IncomingMailServer' => $oDomain->IncomingMailServer, 'IncomingMailPort' => $oDomain->IncomingMailPort, 'IncomingMailLogin' => '', 'IncomingMailPassword' => '', 'IncomingMailUseSSL' => $oDomain->IncomingMailUseSSL, 'PreviousMailPassword' => '', 'OutgoingMailServer' => $oDomain->OutgoingMailServer, 'OutgoingMailPort' => $oDomain->OutgoingMailPort, 'OutgoingMailLogin' => '', 'OutgoingMailPassword' => '', 'OutgoingMailAuth' => $oDomain->OutgoingMailAuth, 'OutgoingMailUseSSL' => $oDomain->OutgoingMailUseSSL, 'OutgoingSendingMethod' => $oDomain->OutgoingSendingMethod, 'HideInGAB' => false, 'Signature' => '', 'SignatureType' => EAccountSignatureType::Html, 'SignatureOptions' => EAccountSignatureOptions::DontAdd, 'GlobalAddressBook' => $oDomain->GlobalAddressBook, 'AllowCompose' => true, 'AllowReply' => true, 'AllowForward' => true, 'DetectSpecialFoldersWithXList' => $oDomain->DetectSpecialFoldersWithXList, 'CustomFields' => '', 'ForceSaveOnLogin' => false));
CApi::Plugin()->RunHook('api-account-construct', array(&$this));
}
示例8: __construct
/**
* @return void
*/
public function __construct(CDomain $oDomain)
{
parent::__construct(get_class($this), 'IdUser');
$oSettings =& CApi::GetSettings();
$iSaveMail = $oSettings->GetConf('WebMail/SaveMail');
$iSaveMail = ESaveMail::Always !== $iSaveMail ? $oSettings->GetConf('WebMail/SaveMail') : ESaveMail::DefaultOn;
$this->oSubCache = null;
$this->__USE_TRIM_IN_STRINGS__ = true;
$this->SetUpper(array('Capa'));
$this->SetDefaults(array('IdUser' => 0, 'IdSubscription' => 0, 'IdHelpdeskUser' => 0, 'MailsPerPage' => $oDomain->MailsPerPage, 'ContactsPerPage' => $oDomain->ContactsPerPage, 'AutoCheckMailInterval' => $oDomain->AutoCheckMailInterval, 'CreatedTime' => 0, 'LastLogin' => 0, 'LastLoginNow' => 0, 'LoginsCount' => 0, 'DefaultSkin' => $oDomain->DefaultSkin, 'DefaultLanguage' => $oDomain->DefaultLanguage, 'DefaultEditor' => EUserHtmlEditor::Html, 'SaveMail' => $iSaveMail, 'Layout' => $oDomain->Layout, 'DefaultTimeZone' => 0, 'DefaultTimeFormat' => $oDomain->DefaultTimeFormat, 'DefaultDateFormat' => $oDomain->DefaultDateFormat, 'DefaultIncomingCharset' => CApi::GetConf('webmail.default-inc-charset', 'iso-8859-1'), 'Question1' => '', 'Question2' => '', 'Answer1' => '', 'Answer2' => '', 'TwilioNumber' => '', 'TwilioEnable' => true, 'TwilioDefaultNumber' => false, 'SipEnable' => true, 'SipImpi' => '', 'SipPassword' => '', 'Capa' => '', 'ClientTimeZone' => '', 'UseThreads' => $oDomain->UseThreads, 'SaveRepliedMessagesToCurrentFolder' => false, 'DesktopNotifications' => false, 'AllowChangeInputDirection' => false, 'EnableOpenPgp' => false, 'AllowAutosaveInDrafts' => true, 'AutosignOutgoingEmails' => false, 'AllowHelpdeskNotifications' => false, 'CustomFields' => '', 'FilesEnable' => true));
CApi::Plugin()->RunHook('api-user-construct', array(&$this));
}
示例9: getSqlTables
/**
* @staticvar array $aTablesCache
*
* @return array
*/
public static function getSqlTables()
{
static $aTablesCache = null;
if (null !== $aTablesCache) {
return $aTablesCache;
}
$aTables = array();
CDbSchemaHelper::addTablesToArray($aTables, array('a_users', 'awm_accounts', 'awm_settings', 'awm_domains', 'awm_folders', 'awm_folders_tree', 'awm_filters', 'awm_messages', 'awm_messages_body', 'awm_reads', 'awm_columns', 'awm_senders', 'awm_mailaliases', 'awm_mailforwards', 'awm_mailinglists', 'awm_addr_book', 'awm_addr_groups', 'awm_addr_groups_contacts', 'awm_addr_groups_events', 'awm_identities', 'awm_tenants', 'awm_fetchers', 'awm_system_folders', 'awm_channels', 'awm_folders_order', 'awm_min', 'awm_subscriptions', 'awm_folders_order_names', 'awm_social', 'awm_tenant_socials', 'awm_account_quotas', 'awm_domain_quotas', 'awm_tenant_quotas', 'acal_calendars', 'acal_events', 'acal_users_data', 'acal_publications', 'acal_reminders', 'acal_appointments', 'acal_eventrepeats', 'acal_exclusions', 'acal_sharing', 'acal_cron_runs', 'acal_awm_fnbl_runs', 'ahd_users', 'ahd_threads', 'ahd_posts', 'ahd_reads', 'ahd_attachments', 'ahd_online', 'ahd_fetcher', 'adav_addressbooks', 'adav_calendars', 'adav_cache', 'adav_calendarobjects', 'adav_cards', 'adav_locks', 'adav_groupmembers', 'adav_principals', 'adav_reminders', 'adav_calendarshares', 'twofa_accounts'));
CApi::Plugin()->RunHook('api-db-tables', array(&$aTables));
$aTablesCache = $aTables;
return $aTablesCache;
}
示例10: __construct
/**
* @param int $iUserId
* @return void
*/
public function __construct($iUserId)
{
parent::__construct(get_class($this), 'IdCalUser');
$iUserId = (int) $iUserId;
$oDomain = null;
$oSettings =& CApi::GetSettings();
if (0 < $iUserId) {
/* @var $oApiUsersManager CApiUsersManager */
$oApiUsersManager = CApi::Manager('users');
$iDomainId = $oApiUsersManager->GetDefaultAccountDomainId($iUserId);
if (0 < $iDomainId) {
/* @var $oApiDomainsManager CApiDomainsManager */
$oApiDomainsManager = CApi::Manager('domains');
$oDomain = $oApiDomainsManager->GetDomainById($iDomainId);
}
}
$this->SetDefaults(array('IdCalUser' => 0, 'IdUser' => (int) $iUserId, 'ShowWeekEnds' => (bool) ($oDomain ? $oDomain->CalendarShowWeekEnds : $oSettings->GetConf('Calendar/ShowWeekEnds')), 'ShowWorkDay' => (bool) ($oDomain ? $oDomain->CalendarShowWorkDay : $oSettings->GetConf('Calendar/ShowWorkDay')), 'WorkDayStarts' => (int) ($oDomain ? $oDomain->CalendarWorkdayStarts : $oSettings->GetConf('Calendar/WorkdayStarts')), 'WorkDayEnds' => (int) ($oDomain ? $oDomain->CalendarWorkdayEnds : $oSettings->GetConf('Calendar/WorkdayEnds')), 'WeekStartsOn' => (int) ($oDomain ? $oDomain->CalendarWeekStartsOn : $oSettings->GetConf('Calendar/WeekStartsOn')), 'DefaultTab' => (int) ($oDomain ? $oDomain->CalendarDefaultTab : $oSettings->GetConf('Calendar/DefaultTab'))));
CApi::Plugin()->RunHook('api-caluser-construct', array(&$this));
}
示例11: Handle
/**
* @return void
*/
public function Handle()
{
$sVersion = file_get_contents(PSEVEN_APP_ROOT_PATH . 'VERSION');
define('PSEVEN_APP_VERSION', $sVersion);
if (!class_exists('MailSo\\Version')) {
echo 'MailSo';
return '';
} else {
if (!class_exists('\\CApi') || !\CApi::IsValid()) {
echo 'AfterLogic API';
return '';
}
}
$sPathInfo = \trim(\trim($this->oHttp->GetServer('PATH_INFO', '')), ' /');
if (!empty($sPathInfo)) {
if ('dav' === \substr($sPathInfo, 0, 3)) {
$this->oActions->PathInfoDav();
return '';
}
}
/* @var $oApiIntegrator \CApiIntegratorManager */
$oApiIntegrator = \CApi::Manager('integrator');
// ------ Redirect to HTTPS
$oSettings =& \CApi::GetSettings();
$bRedirectToHttps = $oSettings->GetConf('Common/RedirectToHttps');
$bHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== "off" || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == "443";
if ($bRedirectToHttps && !$bHttps) {
header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
// ------
/* @var $oApiCapability \CApiCapabilityManager */
$oApiCapability = \CApi::Manager('capability');
$sResult = '';
$sQuery = \trim(\trim($this->oHttp->GetServer('QUERY_STRING', '')), ' /');
\CApi::Plugin()->RunQueryHandle($sQuery);
$iPos = \strpos($sQuery, '&');
if (0 < $iPos) {
$sQuery = \substr($sQuery, 0, $iPos);
}
$aPaths = explode('/', $sQuery);
if (0 < count($aPaths) && !empty($aPaths[0])) {
$sFirstPart = strtolower($aPaths[0]);
if ('ping' === $sFirstPart) {
@header('Content-Type: text/plain; charset=utf-8');
$sResult = 'Pong';
} else {
if ('pull' === $sFirstPart) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
pclose(popen("start /B git pull", "r"));
} else {
exec("git pull > /dev/null 2>&1 &");
}
\CApi::Location('./');
} else {
if ('ajax' === $sFirstPart) {
@ob_start();
$aResponseItem = null;
$sAction = $this->oHttp->GetPost('Action', null);
try {
\CApi::Log('AJAX: Action: ' . $sAction);
if ('SystemGetAppData' !== $sAction && \CApi::GetConf('labs.webmail.csrftoken-protection', true) && !$this->validateToken()) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidToken);
} else {
if (!empty($sAction)) {
$sMethodName = 'Ajax' . $sAction;
$this->oActions->SetActionParams($this->oHttp->GetPostAsArray());
if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) {
$aResponseItem = call_user_func(array($this->oActions, $sMethodName));
}
if (\CApi::Plugin()->JsonHookExists($sMethodName)) {
$aResponseItem = \CApi::Plugin()->RunJsonHook($this->oActions, $sMethodName, $aResponseItem);
}
}
}
if (!is_array($aResponseItem)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::UnknownError);
}
} catch (\Exception $oException) {
//if ($oException instanceof \ProjectCore\Exceptions\ClientException &&
// \ProjectCore\Notifications::AuthError === $oException->getCode())
//{
// $oApiIntegrator = /* @var $oApiIntegrator \CApiIntegratorManager */ \CApi::Manager('integrator');
// $oApiIntegrator->setLastErrorCode(\ProjectCore\Notifications::AuthError);
// $oApiIntegrator->logoutAccount();
//}
\CApi::LogException($oException);
$sAction = empty($sAction) ? 'Unknown' : $sAction;
$aAdditionalParams = null;
if ($oException instanceof \ProjectCore\Exceptions\ClientException) {
$aAdditionalParams = $oException->GetObjectParams();
}
$aResponseItem = $this->oActions->ExceptionResponse(null, $sAction, $oException, $aAdditionalParams);
}
@header('Content-Type: application/json; charset=utf-8');
\CApi::Plugin()->RunHook('ajax.response-result', array($sAction, &$aResponseItem));
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, \CApi::MailSoLogger());
// \CApi::Log('AJAX: Response: '.$sResult);
//.........这里部分代码省略.........
示例12: getDefaultSocials
/**
* @return array
*/
public function getDefaultSocials()
{
$aResult = array();
$oSettings =& CApi::GetSettings();
$aSocials = $oSettings->GetConf('Socials');
if (isset($aSocials) && is_array($aSocials)) {
$oPlugin = \CApi::Plugin()->GetPluginByName('external-services');
if ($oPlugin) {
$aConnectors = $oPlugin->GetEnabledConnectors();
foreach ($aSocials as $sKey => $aSocial) {
if (in_array(strtolower($sKey), $aConnectors)) {
$oTenantSocial = CTenantSocials::initFromSettings($aSocial);
if ($oTenantSocial !== null) {
$aResult[strtolower($sKey)] = $oTenantSocial;
}
}
}
}
}
return $aResult;
}
示例13: PrepareStorageMap
public function PrepareStorageMap()
{
CApi::Plugin()->RunHook('api-prepare-storage-map', array(&$this->aStorageMap));
}
示例14: Process
public static function Process($mResult)
{
$sExternalServicesRedirect = '';
$sError = '';
$sErrorMessage = '';
if (isset($_COOKIE["external-services-redirect"])) {
$sExternalServicesRedirect = $_COOKIE["external-services-redirect"];
@setcookie('external-services-redirect', null);
}
if ($sExternalServicesRedirect === 'helpdesk') {
self::SetValuesToCookie($mResult);
$sTenantHash = self::GetTenantHashFromCookie();
\CApi::Location($sTenantHash ? './?helpdesk=' . $sTenantHash : './?helpdesk');
} else {
$oApiUsers = \CApi::Manager('users');
$oInviteAccount = null;
if (isset($_COOKIE["external-services-invite-hash"])) {
$oInviteAccount = $oApiUsers->getAccountById($_COOKIE["external-services-invite-hash"], true);
@setcookie('external-services-invite-hash', null);
}
$sEmail = trim($mResult['email']);
if (empty($sEmail) && $oInviteAccount) {
$mResult['email'] = $oInviteAccount->Email;
}
$oApiSocial = \CApi::Manager('social');
$oSocial = new \CSocial();
$oSocial->TypeStr = $mResult['type'];
$oSocial->AccessToken = isset($mResult['access_token']) ? $mResult['access_token'] : '';
$oSocial->RefreshToken = isset($mResult['refresh_token']) ? $mResult['refresh_token'] : '';
$oSocial->IdSocial = $mResult['id'];
$oSocial->Name = $mResult['name'];
$oSocial->Email = $mResult['email'];
if ($sExternalServicesRedirect === 'login') {
self::SetValuesToCookie($mResult);
$oSocialOld = $oApiSocial->getSocialById($oSocial->IdSocial, $oSocial->TypeStr);
if ($oSocialOld) {
if ($oInviteAccount && $oInviteAccount->IdAccount === $oSocialOld->IdAccount || !$oInviteAccount) {
if (!$oSocialOld->Disabled && $oSocialOld->issetScope('auth')) {
$oSocialOld->setScope('auth');
$oSocial->Scopes = $oSocialOld->Scopes;
$oApiSocial->updateSocial($oSocial);
$oInviteAccount = $oApiUsers->getAccountById($oSocialOld->IdAccount);
} else {
$bResult = false;
$sError = '?error=es-002';
if (!empty($mResult['email'])) {
$sError = $sError . '&email=' . $mResult['email'];
} else {
$sError = $sError . '&service=' . $mResult['type'];
}
}
} else {
$oInviteAccount = null;
$bResult = false;
$sError = '?error=es-003';
}
} else {
$oInviteAccount = $oApiUsers->getAccountByEmail($mResult['email']);
if ($oInviteAccount) {
$oSocial->IdAccount = $oInviteAccount->IdAccount;
$oSocial->setScopes($mResult['scopes']);
$oApiSocial->createSocial($oSocial);
} else {
$sError = '?error=es-002';
if (!empty($mResult['email'])) {
$sError = $sError . '&email=' . $mResult['email'];
} else {
$sError = $sError . '&service=' . $mResult['type'];
}
}
}
if ($oInviteAccount) {
$oApiIntegrator = \CApi::Manager('integrator');
$oApiIntegrator->setAccountAsLoggedIn($oInviteAccount, true);
$oApiUsers->updateAccountLastLoginAndCount($oInviteAccount->IdUser);
}
\CApi::Location2('./' . $sError);
} else {
$oInviteAccount = \api_Utils::GetDefaultAccount();
if ($oInviteAccount) {
$bResult = false;
$oSocial->IdAccount = $oInviteAccount->IdAccount;
$oSocialOld = $oApiSocial->getSocialById($oSocial->IdSocial, $oSocial->TypeStr);
if ($oSocialOld) {
if ($oSocialOld->IdAccount === $oSocial->IdAccount) {
if (in_array('null', $mResult['scopes']) || count($mResult['scopes']) === 0) {
$bResult = $oSocial->deleteSocial($oInviteAccount->IdAccount, $oSocial->TypeStr);
} else {
$oSocial->setScopes($mResult['scopes']);
$bResult = $oApiSocial->updateSocial($oSocial);
}
} else {
$bResult = false;
$oPlugin = \CApi::Plugin()->GetPluginByName('external-services');
if ($oPlugin) {
$sErrorMessage = $oPlugin->I18N('PLUGIN_EXTERNAL_SERVICES/INFO_ACCOUNT_ALREADY_ASSIGNED', $oInviteAccount);
}
}
} else {
if (!in_array('null', $mResult['scopes']) && count($mResult['scopes']) > 0) {
//.........这里部分代码省略.........
示例15: sendMessage
/**
* Sends message out.
*
* @param CAccount $oAccount Account object.
* @param \MailSo\Mime\Message $oMessage Message to be sent out.
* @param CFetcher $oFetcher = null. Fetcher object which may override sending settings.
* @param string $sSentFolder = ''. Name of Sent folder.
* @param string $sDraftFolder = ''. Name of Sent folder.
* @param string $sDraftUid = ''. Last UID value of the message saved in Drafts folder.
*
* @return array|bool
*
* @throws CApiInvalidArgumentException
*/
public function sendMessage($oAccount, $oMessage, $oFetcher = null, $sSentFolder = '', $sDraftFolder = '', $sDraftUid = '')
{
if (!$oAccount || !$oMessage) {
throw new CApiInvalidArgumentException();
}
$oImapClient =& $this->_getImapClient($oAccount);
$rMessageStream = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
$iMessageStreamSize = \MailSo\Base\Utils::MultipleStreamWriter($oMessage->ToStream(true), array($rMessageStream), 8192, true, true, true);
$mResult = false;
if (false !== $iMessageStreamSize && is_resource($rMessageStream)) {
$oRcpt = $oMessage->GetRcpt();
if ($oRcpt && 0 < $oRcpt->Count()) {
$sRcptEmail = '';
try {
$iConnectTimeOut = CApi::GetConf('socket.connect-timeout', 5);
$iSocketTimeOut = CApi::GetConf('socket.get-timeout', 5);
$bVerifySsl = !!CApi::GetConf('socket.verify-ssl', false);
CApi::Plugin()->RunHook('webmail-smtp-update-socket-timeouts', array(&$iConnectTimeOut, &$iSocketTimeOut));
$oSmtpClient = \MailSo\Smtp\SmtpClient::NewInstance();
$oSmtpClient->SetTimeOuts($iConnectTimeOut, $iSocketTimeOut);
$oLogger = $oImapClient->Logger();
if ($oLogger) {
$oSmtpClient->SetLogger($oLogger);
}
$iSecure = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT;
if ($oFetcher) {
$iSecure = $oFetcher->OutgoingMailSecurity;
} else {
if ($oAccount->OutgoingMailUseSSL) {
$iSecure = \MailSo\Net\Enumerations\ConnectionSecurityType::SSL;
}
}
$sOutgoingMailLogin = '';
if ($oFetcher) {
$sOutgoingMailLogin = $oFetcher->IncomingMailLogin;
}
if (0 === strlen($sOutgoingMailLogin)) {
$sOutgoingMailLogin = $oAccount->OutgoingMailLogin;
$sOutgoingMailLogin = 0 < strlen($sOutgoingMailLogin) ? $sOutgoingMailLogin : $oAccount->IncomingMailLogin;
}
$sOutgoingMailPassword = '';
if ($oFetcher) {
$sOutgoingMailPassword = $oFetcher->IncomingMailPassword;
}
if (0 === strlen($sOutgoingMailPassword)) {
$sOutgoingMailPassword = $oAccount->OutgoingMailPassword;
$sOutgoingMailPassword = 0 < strlen($sOutgoingMailPassword) ? $sOutgoingMailPassword : $oAccount->IncomingMailPassword;
}
$sEhlo = \MailSo\Smtp\SmtpClient::EhloHelper();
CApi::Plugin()->RunHook('api-smtp-send-ehlo', array($oAccount, &$sEhlo));
if ($oFetcher) {
$oSmtpClient->Connect($oFetcher->OutgoingMailServer, $oFetcher->OutgoingMailPort, $sEhlo, $iSecure, $bVerifySsl);
} else {
$oSmtpClient->Connect($oAccount->OutgoingMailServer, $oAccount->OutgoingMailPort, $sEhlo, $iSecure, $bVerifySsl);
}
if ($oFetcher && $oFetcher->OutgoingMailAuth || !$oFetcher && $oAccount->OutgoingMailAuth) {
$oSmtpClient->Login($sOutgoingMailLogin, $sOutgoingMailPassword);
}
$oSmtpClient->MailFrom($oFetcher ? $oFetcher->Email : $oAccount->Email, (string) $iMessageStreamSize);
$aRcpt =& $oRcpt->GetAsArray();
CApi::Plugin()->RunHook('api-smtp-send-rcpt', array($oAccount, &$aRcpt));
foreach ($aRcpt as $oEmail) {
$sRcptEmail = $oEmail->GetEmail();
$oSmtpClient->Rcpt($sRcptEmail);
}
$oSmtpClient->DataWithStream($rMessageStream);
$oSmtpClient->LogoutAndDisconnect();
} catch (\MailSo\Net\Exceptions\ConnectionException $oException) {
throw new \CApiManagerException(Errs::Mail_AccountConnectToMailServerFailed, $oException);
} catch (\MailSo\Smtp\Exceptions\LoginException $oException) {
throw new \CApiManagerException(Errs::Mail_AccountLoginFailed, $oException);
} catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException) {
throw new \CApiManagerException(Errs::Mail_CannotSendMessage, $oException);
} catch (\MailSo\Smtp\Exceptions\MailboxUnavailableException $oException) {
throw new \CApiManagerException(Errs::Mail_MailboxUnavailable, $oException, array(), array('Mailbox' => $sRcptEmail));
}
if (0 < strlen($sSentFolder)) {
try {
if (!$oMessage->GetBcc()) {
if (is_resource($rMessageStream)) {
rewind($rMessageStream);
}
$oImapClient->MessageAppendStream($sSentFolder, $rMessageStream, $iMessageStreamSize, array(\MailSo\Imap\Enumerations\MessageFlag::SEEN));
} else {
$rAppendMessageStream = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
$iAppendMessageStreamSize = \MailSo\Base\Utils::MultipleStreamWriter($oMessage->ToStream(), array($rAppendMessageStream), 8192, true, true, true);
//.........这里部分代码省略.........