function cc::get_lists in Constant Contact 6.2
Same name and namespace in other branches
- 6.3 class.cc.php \cc::get_lists()
- 7.3 class.cc.php \cc::get_lists()
* Gets all 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
File
- ./
class.cc.php, line 263
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']);
}
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;
}