} $smarty->assign('list_id', $list_id); $smarty->assign('list', $list); // subscribers tabs $total_items = count($subscribers = cw_call('cw\\news\\get_subscribers', array($list_id))); if (!empty($total_items)) { $navigation = cw_core_get_navigation($target, $total_items, $page); $navigation['script'] = "index.php?target={$target}&js_tab=subscriptions&list_id=" . $list_id; $smarty->assign('navigation', $navigation); $subscribers = array_slice($subscribers, $navigation['first_page'], $navigation['objects_per_page']); } $smarty->assign('subscribers', $subscribers); // messages tab $message = cw_query_first("\n\t\t\tSELECT * FROM {$tables['newsletter']} WHERE list_id = '{$list_id}' AND show_as_news = 2 LIMIT 1\n\t\t"); if (!$message) { $message = cw_vertical_response_get_message($list_id, 0); if (isset($message['news_id'])) { cw_array2insert('newsletter', array('news_id' => $message['news_id'], 'list_id' => $list_id, 'send_date' => cw_core_get_time(), 'updated_date' => cw_core_get_time(), 'created_date' => cw_core_get_time(), 'subject' => $message['subject'], 'body' => $message['body'], 'allow_html' => 1, 'show_as_news' => 2)); } } if ($message) { $message['products1'] = cw_query("\n\t\t\t\tSELECT product_id as id, product as name FROM {$tables['newsletter_products']}\n\t\t\t\tWHERE list_id = '{$list_id}' AND product_num = 1\n\t\t\t"); $message['products2'] = cw_query("\n\t\t\t\tSELECT product_id as id, product as name FROM {$tables['newsletter_products']}\n\t\t\t\tWHERE list_id = '{$list_id}' AND product_num = 2\n\t\t\t"); $smarty->assign('message', $message); $smarty->assign('messageid', $message['news_id']); } $smarty->assign('main', 'management'); } else { $smarty->assign('main', 'details'); } } else {
/** * edit message * * @param $list_id * @param $message_id * @param $content * @param $subject * @return bool */ function cw_vertical_response_edit_message($list_id, $message_id, $content, $subject) { global $config; $vertical_response_email = trim($config[vertical_response_addon_name]['vertical_response_email']); $vertical_response_password = trim($config[vertical_response_addon_name]['vertical_response_password']); $mid = $message_id; try { $vr = new SoapClient(vertical_response_wsdl, array('connection_timeout' => 5)); $sid = $vr->login(array('username' => "{$vertical_response_email}", 'password' => "{$vertical_response_password}", 'session_duration_minutes' => vertical_response_ses_time)); // check if email exist on VR $data = cw_vertical_response_get_message($list_id, $message_id); if (!isset($data['news_id'])) { $mid = 0; } if ($mid) { // edit message $vr->updateEmailContents(array('session_id' => $sid, 'email_id' => $mid, 'freeform_html' => $content, 'freeform_text' => trim($config['Company']['company_name']) . " message")); } else { // create a message $message = array('name' => "Email #" . cw_core_get_time(), 'email_type' => "canvas", 'from_label' => $config['Company']['company_name'], 'reply_to_email' => $config['Company']['site_administrator'], 'freeform_html' => $content, 'freeform_text' => trim($config['Company']['company_name']) . " message", 'subject' => $subject . " (#" . cw_core_get_time() . ")", 'hosted_email' => true); $mid = $vr->createEmail(array('session_id' => $sid, 'email' => $message)); // attaches the list you made above to the campaign you just created $vr->setCampaignLists(array('session_id' => $sid, 'campaign_id' => $mid, 'list_ids' => array($list_id))); } } catch (SoapFault $exception) { // exit ('fault: "' . $exception->faultcode . '" - ' . $exception->faultstring . "\n"); return false; } return $mid; }