public function CampaignMonitor::updateList in Campaign Monitor 7
Update remote list information.
The options array should have the fields "Title", "UnsubscribePage", "ConfirmedOptIn" and "ConfirmationSuccessPage". If you do not wish to set these use an empty string.
Parameters
string $list_id: The Campaign Monitor list ID.
array $options: (optional) An array of options with information to update.
Return value
bool TRUE on success, FALSE otherwise.
File
- lib/
campaignmonitor.class.inc, line 575 - Implementation of the CampaignMonitor class.
Class
- CampaignMonitor
- Implementation of the CampaignMonitor class.
Code
public function updateList($list_id, array $options = []) {
// Make sure that list is loaded.
if (!$this
->getListDetails($list_id)) {
$this
->addError(WATCHDOG_ERROR, t('Could not retrieve update list information for @listID.', [
'@listID' => $list_id,
]));
return FALSE;
}
// Get list object and update the list.
if ($obj = $this
->createListObj($list_id)) {
// @todo: check that the options are correct.
$result = $obj
->update($options);
if ($result
->was_successful()) {
// Update local list cache.
$this->lists[$list_id]['name'] = $options['Title'];
$this->lists[$list_id]['details']['UnsubscribePage'] = $options['UnsubscribePage'];
$this->lists[$list_id]['details']['ConfirmedOptIn'] = $options['ConfirmedOptIn'];
$this->lists[$list_id]['details']['ConfirmationSuccessPage'] = $options['ConfirmationSuccessPage'];
// Update the cache.
cache_set('campaignmonitor_lists', $this->lists, 'cache');
return TRUE;
}
else {
$this
->addError(WATCHDOG_ERROR, $result->response->Message, $result->http_status_code);
}
}
return FALSE;
}