120 $audience->setAccountId($accountId);
121 $audiencesResult = $audience->getList();
122 if ($audiencesResult->isSuccess())
124 while ($audienceData = $audiencesResult->fetch())
126 $audienceData = $audience->normalizeListRow($audienceData);
127 if ($audienceData[
'ID'])
130 'id' => $audienceData[
'ID'],
131 'isSupportMultiTypeContacts' => $audience->isSupportMultiTypeContacts(),
133 'supportedContactTypes' => $audienceData[
'SUPPORTED_CONTACT_TYPES'],
135 $audienceData[
'NAME']
137 $audienceData[
'NAME'] . (
138 $audienceData[
'COUNT_VALID'] > 0 ?
139 ' (' . $audienceData[
'COUNT_VALID'] .
')'
151 self::$errors = $audiencesResult->getErrorMessages();
176 $providers = static::getServiceProviders($types);
177 foreach ($providers as $type => $provider)
180 $providers[$type][
'URL_AUDIENCE_LIST'] = $audience->getUrlAudienceList();
181 $providers[$type][
'IS_SUPPORT_ACCOUNT'] = $audience->isSupportAccount();
182 $providers[$type][
'IS_SUPPORT_REMOVE_CONTACTS'] = $audience->isSupportRemoveContacts();
184 $providers[$type][
'IS_SUPPORT_MULTI_TYPE_CONTACTS'] = $audience->isSupportMultiTypeContacts();
185 $providers[$type][
'IS_SUPPORT_ADD_AUDIENCE'] = $audience->isSupportAddAudience();
186 $lookalikeAudienceParams = $audience->getLookalikeAudiencesParams();
187 $providers[$type][
'IS_SUPPORT_LOOKALIKE_AUDIENCE'] = !!$lookalikeAudienceParams;
188 $providers[$type][
'LOOKALIKE_AUDIENCE_PARAMS'] = $lookalikeAudienceParams;
202 static $audiences = array();
203 if (!isset($audiences[$config->type]))
205 if ($config->clientId)
207 $service = static::getService();
208 $service->setClientId($config->clientId);
211 $audiences[$config->type] = $audience;
215 $audience = $audiences[$config->type];
218 $audience->setAccountId($config->accountId);
219 static::$isQueueUsed ? $audience->enableQueueMode() : $audience->disableQueueMode();
220 if ($config->autoRemoveDayNumber)
222 $audience->enableQueueAutoRemove($config->autoRemoveDayNumber);
226 $audience->disableQueueAutoRemove();
229 $audienceImportResult = $audience->addContacts(
233 'type' => $config->contactType,
234 'parentId' => $config->parentId
238 self::$errors = $audienceImportResult->getErrorMessages();
239 return $audienceImportResult->isSuccess();
306 $typeList = static::getServiceTypes();
308 $providers = array();
309 foreach ($typeList as $type)
311 if ($types && !in_array($type, $types))
316 $service = static::getService();
317 $authAdapter = $service->getAuthAdapter($type);
318 $account = $service->getAccount($type);
319 $canUserMultiClients = $authAdapter->canUseMultipleClients();
321 $providers[$type] = array(
323 'HAS_AUTH' => $authAdapter->hasAuth(),
324 'AUTH_URL' => $authAdapter->getAuthUrl(),
325 'PROFILE' => $authAdapter->getToken() ? $account->getProfileCached() :
false,
327 if ($canUserMultiClients)
329 $providers[$type][
'CLIENTS'] = static::getClientsProfiles($authAdapter);
330 if (empty($providers[$type][
'CLIENTS']))
332 $providers[$type][
'HAS_AUTH'] =
false;
337 if ($providers[$type][
'HAS_AUTH'] && empty($providers[$type][
'PROFILE']))
339 static::removeAuth($type);
340 if (!$canUserMultiClients)
342 $providers[$type][
'HAS_AUTH'] =
false;
390 if (!static::canUse())
397 $account = static::getService()->getAccount($type);
398 $accountsResult = $account->getList();
399 if ($accountsResult->isSuccess())
401 while ($accountData = $accountsResult->fetch())
403 $accountData = $account->normalizeListRow($accountData);
404 if ($accountData[
'ID'])
407 'id' => $accountData[
'ID'],
408 'name' => $accountData[
'NAME'] ? $accountData[
'NAME'] : $accountData[
'ID']
415 self::$errors = $accountsResult->getErrorMessages();