private function prepare(array $campaign_array, $add = false) { $defaults = array('id' => NULL, 'name' => NULL, 'subject' => NULL, 'from_name' => NULL, 'from_email' => NULL, 'reply_to_email' => NULL, 'template_type' => NULL, 'created_date' => NULL, 'modified_date' => NULL, 'last_run_date' => NULL, 'next_run_date' => NULL, 'status' => NULL, 'is_permission_reminder_enabled' => NULL, 'permission_reminder_text' => NULL, 'is_view_as_webpage_enabled' => NULL, 'view_as_web_page_text' => NULL, 'view_as_web_page_link_text' => NULL, 'greeting_salutations' => NULL, 'greeting_name' => NULL, 'greeting_string' => NULL, 'message_footer' => NULL, 'tracking_summary' => NULL, 'email_content' => NULL, 'email_content_format' => NULL, 'style_sheet' => NULL, 'text_content' => NULL, 'sent_to_contact_lists' => array(), 'click_through_details' => array()); $Campaign = wp_parse_args($campaign_array, $defaults); if (array_key_exists("message_footer", $Campaign)) { $Campaign['message_footer'] = MessageFooter::create($this->prepareMessageFooter($Campaign['message_footer'])); } $Campaign['greeting_name'] = strtoupper($Campaign['greeting_name']); if (!in_array($Campaign['greeting_name'], array('FIRST_NAME', 'LAST_NAME', 'FIRST_AND_LAST_NAME', 'NONE'))) { $Campaign['greeting_name'] = 'NONE'; } return $Campaign; }
/** * Factory method to create a Campaign object from an array * @param array $props - associative array of initial properties to set * @return Campaign */ public static function create(array $props) { $campaign = new Campaign(); $campaign->id = parent::getValue($props, "id"); $campaign->name = parent::getValue($props, "name"); $campaign->subject = parent::getValue($props, "subject"); $campaign->from_name = parent::getValue($props, "from_name"); $campaign->from_email = parent::getValue($props, "from_email"); $campaign->reply_to_email = parent::getValue($props, "reply_to_email"); $campaign->template_type = parent::getValue($props, "template_type"); $campaign->created_date = parent::getValue($props, "created_date"); $campaign->modified_date = parent::getValue($props, "modified_date"); $campaign->last_run_date = parent::getValue($props, "last_run_date"); $campaign->next_run_date = parent::getValue($props, "next_run_date"); $campaign->status = parent::getValue($props, "status"); $campaign->is_permission_reminder_enabled = parent::getValue($props, "is_permission_reminder_enabled"); $campaign->permission_reminder_text = parent::getValue($props, "permission_reminder_text"); $campaign->is_view_as_webpage_enabled = parent::getValue($props, "is_view_as_webpage_enabled"); $campaign->view_as_web_page_text = parent::getValue($props, "view_as_web_page_text"); $campaign->view_as_web_page_link_text = parent::getValue($props, "view_as_web_page_link_text"); $campaign->greeting_salutations = parent::getValue($props, "greeting_salutations"); $campaign->greeting_name = parent::getValue($props, "greeting_name"); $campaign->greeting_string = parent::getValue($props, "greeting_string"); if (array_key_exists("message_footer", $props)) { $campaign->message_footer = MessageFooter::create($props['message_footer']); } if (array_key_exists("tracking_summary", $props)) { $campaign->tracking_summary = TrackingSummary::create($props['tracking_summary']); } $campaign->email_content = parent::getValue($props, "email_content"); $campaign->email_content_format = parent::getValue($props, "email_content_format"); $campaign->style_sheet = parent::getValue($props, "style_sheet"); $campaign->text_content = parent::getValue($props, "text_content"); if (array_key_exists('sent_to_contact_lists', $props)) { foreach ($props['sent_to_contact_lists'] as $sent_to_contact_list) { $campaign->sent_to_contact_lists[] = ContactList::create($sent_to_contact_list); } } if (array_key_exists('click_through_details', $props)) { foreach ($props['click_through_details'] as $click_through_details) { $campaign->click_through_details[] = ClickThroughDetails::create($click_through_details); } } return $campaign; }