/** * @param string $type * @param $api * @param null $passed * @param array $return * @param null $page * @param bool $return_error Whether to return exception object * * @return array|bool */ function constant_contact_old_api_get_all($type = 'Events', &$api, $passed = null, &$return = array(), $page = null, $return_error = false) { $key = constant_contact_cache_key('all_' . $type, $passed); if (!constant_contact_refresh_cache($type) && ($cached = get_transient($key))) { return $cached; } try { ob_start(); if (!empty($passed)) { $items = $api->{"get{$type}"}($passed, $page); } else { $items = $api->{"get{$type}"}($page); } $error = ob_get_clean(); if ($error) { do_action('ctct_error', 'Get All Events Exception', $error); } // If no results if (empty($items[strtolower($type)])) { return $return; } else { // Otherwise, add items using the startdate time as the key for sorting below foreach ($items[strtolower($type)] as $item) { $allkey = isset($item->startDate) ? strtotime($item->startDate) : null; $return[$allkey] = $item; } // Sort by event date krsort($return); if (!empty($items['nextLink'])) { constant_contact_old_api_get_all($type, $api, $passed, $return, $items['nextLink']); } set_transient($key, $return, apply_filters('constant_contact_cache_age', HOUR_IN_SECONDS * 6)); } } catch (Exception $e) { do_action('ctct_error', 'Get All Events Exception', $e->getMessage()); $return = $return_error ? $e : false; } return $return; }
}); }); </script> <div id="select_eventspot_event" style="display:none;"> <div class="wrap"> <div style="padding:15px 15px 0 15px;"> <a href="http://katz.si/4o" rel="external"><img src="<?php echo plugins_url('images/eventspot-logo.png', EVENTSPOT_FILE); ?> " alt="EventSpot from Constant Contact" /></a> <?php $return = array(); $events = constant_contact_old_api_get_all('Events', CTCT_EventSpot::getInstance()->old_api, null, $return, null, true); if ($events instanceof Exception) { printf(__('<p>There was a problem fetching the Events:</p><pre>%s</pre>', 'ctct'), $events->getMessage()); $events = false; } if (empty($events)) { include EVENTSPOT_FILE_PATH . '/views/promo.php'; } else { include EVENTSPOT_FILE_PATH . '/views/insert-event.php'; } // End empty events ?> </div> </div> </div>
/** * Generate the content for the Events dashboard widget */ function events_dashboard() { $_events = constant_contact_old_api_get_all('Events', $this->old_api); if (!empty($_events) && is_array($_events)) { $draft = $active = array(); foreach ($_events as $k => $v) { if ($v->status === 'ACTIVE') { $active[$v->id] = $v; } elseif ($v->status === 'DRAFT') { $draft[$v->id] = $v; } } if (!empty($active)) { $this->dashboard_make_table(__('Active Events', 'ctct'), $active); } if (!empty($draft)) { $this->dashboard_make_table(__('Draft Events', 'ctct'), $draft); } ?> <p class="textright"> <a class="button" href="<?php echo admin_url('admin.php?page=constant-contact-events'); ?> "><?php _e('View All Events', 'ctct'); ?> </a> </p> <?php } else { ?> <p><?php _e(sprintf("You don't have any events. Did you know that Constant Contact offers %sEvent Marketing%s?", '<a href="http://katz.si/4o" title="Learn more about Constant Contact Event Marketing">', '</a>'), 'constant_contact_api'); ?> </p> <?php } return true; }
" class="button-primary"><?php _e('Return to Events', 'ctct'); ?> <a href="<?php echo add_query_arg('refresh', 'event'); ?> " class="button-secondary alignright" title="<?php _e('Refresh Event data now.', 'ctct'); ?> "><?php _e('Refresh Event', 'ctct'); ?> </a></a> <?php $_registrants = constant_contact_old_api_get_all('Registrants', $this->old_api, $v); $_cancelled = array(); foreach ($_registrants as $k => $reg) { if ($reg->registrationStatus == 'CANCELLED') { $_cancelled[] = $reg; unset($_registrants[$k]); continue; } } // If no registrants, let's get outta here. if (empty($_registrants) && empty($_cancelled)) { return; } ?> <h2><?php _e('Registrants', 'ctct');