public function _initSetupForm(Am_Form_Setup $form) { parent::_initSetupForm($form); $form->addText('install_url')->setLabel(___('NuevoMailer installation URL')); $form->addText('api_key')->setLabel(___('API Key')); $form->addAdvCheckbox('api_send_email')->setLabel(___('Send opt-in/out emails')); $form->addAdvCheckbox('double_optin')->setLabel(___('Enable double opt-in')); }
function syncLists(Am_Newsletter_Plugin $plugin, array $lists) { $existing = $disabled = array(); foreach ($this->findByPluginId($plugin->getId()) as $r) { if ($r->disabled) { $disabled[$r->plugin_list_id] = $r; } else { $existing[$r->plugin_list_id] = $r; } } // disable exising lists foreach (array_diff_key($existing, $lists, $disabled) as $list) { $list->disable(); // not available on service side anymore? } // foreach (array_diff_key($lists, $existing, $disabled) as $id => $list) { $r = $this->createRecord(array('plugin_id' => $plugin->getId(), 'plugin_list_id' => $id, 'title' => $list['title'])); $r->insert(); } // list is now enabled foreach (array_intersect_key($disabled, $lists) as $list) { $list->enable(); } //sync titles for existing lists foreach (array_intersect_key($existing, $lists) as $list) { if ($list->title != $lists[$list->plugin_list_id]['title']) { $list->updateQuick('title', $lists[$list->plugin_list_id]['title']); } } }
public function sendRequest($api_action, $params, $method = self::METHOD_POST) { $this->setMethod($method); $this->setHeader('Expect', ''); $this->params = $params; if ($this->plugin->getConfig('api_type') == 0) { $this->vars['api_user'] = $this->plugin->getConfig('api_user'); $this->vars['api_pass'] = $this->plugin->getConfig('api_password'); } else { $this->vars['api_key'] = $this->plugin->getConfig('api_key'); } $this->vars['api_action'] = $api_action; $this->vars['api_output'] = 'serialize'; if ($method == self::METHOD_POST) { $this->addPostParameter($this->params); $url = $this->plugin->getConfig('api_url') . '/admin/api.php?' . http_build_query($this->vars, '', '&'); if ($this->plugin->getConfig('debug')) { Am_Di::getInstance()->errorLogTable->log("ACTIVECAMPAIGN POST REQUEST : {$url}" . var_export($this->params, true)); } } else { $url = $this->plugin->getConfig('api_url') . '/admin/api.php?' . http_build_query($this->vars + $this->params, '', '&'); if ($this->plugin->getConfig('debug')) { Am_Di::getInstance()->errorLogTable->log("ACTIVECAMPAIGN GET REQUEST : {$url}"); } } $this->setUrl($url); $ret = parent::send(); if (!in_array($ret->getStatus(), array(200, 404))) { throw new Am_Exception_InternalError("Activecampaign API Error, configured API Key is wrong"); } $arr = unserialize($ret->getBody()); if ($this->plugin->getConfig('debug')) { Am_Di::getInstance()->errorLogTable->log("ACTIVECAMPAIGN RESPONSE : " . var_export($arr, true)); } if (!$arr) { throw new Am_Exception_InternalError("Activecampaign API Error - unknown response [" . $ret->getBody() . "]"); } if ($arr['result_code'] != 1) { Am_Di::getInstance()->errorLogTable->log("Activecampaign API Error - code [" . $arr['result_code'] . "]response [" . $arr['result_message'] . "]"); } unset($arr['result_code'], $arr['result_message'], $arr['result_output']); return $arr; }
public function canGetLists() { if ($this->getConfig('api_key') && $this->getConfig('client_api_id')) { return parent::canGetLists(); } }
public function _initSetupForm(Am_Form_Setup $form) { parent::_initSetupForm($form); }
public function onUserAfterInsert(Am_Event_UserAfterInsert $e) { parent::onUserAfterInsert($e); if ($this->getConfig('ecommerce_tracking') && $this->getDi()->request->getCookie('mc_cid') && $this->getDi()->request->getCookie('mc_eid')) { $user = $e->getUser(); $user->data()->set('mc_cid', $this->getDi()->request->getCookie('mc_cid'))->set('mc_eid', $this->getDi()->request->getCookie('mc_eid'))->update(); } }