function cc::get_lists in Constant Contact 6.3
Same name and namespace in other branches
- 6.2 class.cc.php \cc::get_lists()
- 7.3 class.cc.php \cc::get_lists()
* Gets the contact lists for the CC account * The results are pageable * Second argument can be used to show/hide the do-not-mail etc lists * * * @access public
1 call to cc::get_lists()
- cc::get_all_lists in ./
class.cc.php - * Gets all the contact lists for the CC account * If more than one page exists we grab them too * Second argument can be used to show/hide the do-not-mail etc lists * This method also sorts the lists based on the SortOrder field * * *…
File
- ./
class.cc.php, line 372
Class
- cc
- @file
Code
function get_lists($action = 'lists', $exclude = 3) {
$xml = $this
->load_url($action);
if (!$xml) {
return false;
}
$lists = array();
// parse into nicer array
$_lists = isset($xml['feed']['entry']) ? $xml['feed']['entry'] : false;
if (isset($xml['feed']['link']['2_attr']['rel']) && $xml['feed']['link']['2_attr']['rel'] == 'first') {
$this->list_meta_data->first_page = $this
->get_id_from_link($xml['feed']['link']['2_attr']['href']);
$this->list_meta_data->current_page = $this
->get_id_from_link($xml['feed']['link']['3_attr']['href']);
$this->list_meta_data->next_page = '';
}
elseif (isset($xml['feed']['link']['2_attr']['rel']) && $xml['feed']['link']['2_attr']['rel'] == 'next') {
$this->list_meta_data->next_page = $this
->get_id_from_link($xml['feed']['link']['2_attr']['href']);
$this->list_meta_data->current_page = $this
->get_id_from_link($xml['feed']['link']['3_attr']['href']);
$this->list_meta_data->first_page = $this
->get_id_from_link($xml['feed']['link']['4_attr']['href']);
}
else {
$this->list_meta_data->next_page = NULL;
$this->list_meta_data->current_page = NULL;
$this->list_meta_data->first_page = NULL;
}
if (is_array($_lists) && count($_lists) > 3) {
if ($exclude) {
// skip first x amount of lists - remove, do not mail etc
$_lists = array_slice($_lists, $exclude);
}
if (isset($_lists[0]['link_attr']['href'])) {
foreach ($_lists as $k => $v) {
$id = $this
->get_id_from_link($v['link_attr']['href']);
$list = array(
'id' => $id,
'Name' => $v['content']['ContactList']['Name'],
'ShortName' => $v['content']['ContactList']['ShortName'],
);
if (isset($v['content']['ContactList']['OptInDefault'])) {
$list['OptInDefault'] = $v['content']['ContactList']['OptInDefault'];
}
if (isset($v['content']['ContactList']['SortOrder'])) {
$list['SortOrder'] = $v['content']['ContactList']['SortOrder'];
}
$lists[] = $list;
}
}
else {
$id = $this
->get_id_from_link($_lists['link_attr']['href']);
$list = array(
'id' => $id,
'Name' => $_lists['content']['ContactList']['Name'],
'ShortName' => $_lists['content']['ContactList']['ShortName'],
);
if (isset($_lists['content']['ContactList']['OptInDefault'])) {
$list['OptInDefault'] = $_lists['content']['ContactList']['OptInDefault'];
}
if (isset($_lists['content']['ContactList']['SortOrder'])) {
$list['SortOrder'] = $_lists['content']['ContactList']['SortOrder'];
}
$lists[] = $list;
}
}
return $lists;
}