Example #1
0
 /**
  * This function is likely never returns
  * but anyway handle result and exceptions
  * @return Am_Paysystem_Result
  */
 function process()
 {
     Am_Di::getInstance()->hook->call(Am_Event::INVOICE_BEFORE_PAYMENT, array('invoice' => $this->invoice, 'controller' => $this->controller));
     $plugin = Am_Di::getInstance()->plugins_payment->loadGet($this->invoice->paysys_id);
     $this->result = new Am_Paysystem_Result();
     $plugin->processInvoice($this->invoice, $this->controller->getRequest(), $this->result);
     if ($this->result->isSuccess() || $this->result->isFailure()) {
         if ($transaction = $this->result->getTransaction()) {
             $transaction->setInvoice($this->invoice);
             $transaction->process();
         }
     }
     if ($this->result->isSuccess()) {
         if (method_exists($this->controller, 'getForm')) {
             $this->controller->getForm()->getSessionContainer()->destroy();
         }
         $url = REL_ROOT_URL . "/thanks?id=" . $this->invoice->getSecureId('THANKS');
         $this->callback($this->onSuccess);
         $this->controller->redirectLocation($url);
         // no return
         // Am_Exception_Redirect only for APPLICATION_ENV = 'testing'
     } elseif ($this->result->isAction()) {
         if (method_exists($this->controller, 'getForm')) {
             $this->controller->getForm()->getSessionContainer()->destroy();
         }
         $this->callback($this->onAction);
         $this->result->getAction()->process($this->controller);
         // no return
         // Am_Exception_Redirect only for APPLICATION_ENV = 'testing'
     } else {
         //  ($result->isFailure()) {
         $this->callback($this->onFailure);
     }
     return $this->result;
 }
Example #2
0
 public function process(Am_Controller $action = null)
 {
     $action->view->url = $this->getURL();
     $action->view->vars = $this->getVars();
     $action->render('payment', '', true);
     throw new Am_Exception_Redirect($this->getURL());
 }
 /**
  * This function is likely never returns
  * but anyway handle result and exceptions
  * @return Am_Paysystem_Result
  */
 function process()
 {
     $err = $this->invoice->validate();
     if ($err) {
         throw new Am_Exception_InputError($err[0]);
     }
     $this->invoice->save();
     $plugin = Am_Di::getInstance()->plugins_payment->loadGet($this->invoice->paysys_id);
     $this->result = new Am_Paysystem_Result();
     $plugin->processInvoice($this->invoice, $this->controller->getRequest(), $this->result);
     if ($this->result->isSuccess() || $this->result->isFailure()) {
         if ($transaction = $this->result->getTransaction()) {
             $transaction->setInvoice($this->invoice);
             $transaction->process();
         }
     }
     if ($this->result->isSuccess()) {
         $url = REL_ROOT_URL . "/thanks?id=" . $this->invoice->getSecureId('THANKS');
         $this->callback($this->onSuccess);
         $this->controller->redirectLocation($url, ___("Invoice processed"), ___("Invoice processed successfully"));
         // no return Am_Exception_Redirect
     } elseif ($this->result->isAction()) {
         $this->callback($this->onAction);
         $this->result->getAction()->process($this->controller);
         // no return Am_Exception_Redirect
     } else {
         //  ($result->isFailure()) {
         $this->callback($this->onFailure);
     }
     return $this->result;
 }
Example #4
0
 public function process(Am_Controller $action = null)
 {
     $action->view->addBasePath($this->_path);
     $action->view->assign($this->getVars());
     $action->renderScript($this->_template);
     throw new Am_Exception_Redirect();
 }
Example #5
0
 public function process(Am_Controller $controller = null)
 {
     if ($controller === null) {
         Am_Controller::redirectLocation($this->getUrl());
     } else {
         $controller->redirectLocation($this->getUrl());
     }
 }
Example #6
0
 protected function _initSetupForm(Am_Form_Setup $form)
 {
     $url = 'https://auth.aweber.com/1.0/oauth/authorize_app/' . self::APP_ID;
     $el = $form->addTextarea('auth', array('cols' => 80, 'rows' => 4))->setLabel("aWeber App Authorization Code\n" . "get it on <a target='_blank' href='{$url}'>aWeber Website</a>");
     $el->addRule('regex', 'Invalid value', '/^[a-zA-Z0-9]+\\|[a-zA-Z0-9]+\\|[a-zA-Z0-9]+\\|[a-zA-Z0-9]+\\|[a-zA-Z0-9]+\\|\\s*$/');
     if ($this->getConfig('auth') && !$this->getConfig('access.access_token')) {
         if (!empty($_GET['oauth_token'])) {
             $api = $this->getApi();
             $api->user->tokenSecret = $_COOKIE['requestTokenSecret'];
             $api->user->requestToken = $_GET['oauth_token'];
             $api->user->verifier = $_GET['oauth_verifier'];
             list($accessToken, $accessTokenSecret) = $api->getAccessToken();
             $this->getDi()->config->saveValue('newsletter.aweber.access', array('access_token' => $accessToken, 'access_secret' => $accessTokenSecret));
             Am_Controller::redirectLocation(REL_ROOT_URL . "/admin-setup/aweber");
             return;
         } else {
             $api = $this->getApi();
             $callbackUrl = Am_Controller::getFullUrl();
             try {
                 list($requestToken, $requestTokenSecret) = $api->getRequestToken($callbackUrl);
                 Am_Controller::setCookie('requestTokenSecret', $requestTokenSecret);
                 $form->addStatic()->setLabel('Access Tokens')->setContent(sprintf('Access tokens are empty or expired, %sclick this link%s to update', '<a href="' . Am_Controller::escape($api->getAuthorizeUrl()) . '">', '</a>'));
             } catch (Exception $e) {
                 $this->getDi()->errorLogTable->logException($e);
                 $form->addStatic()->setLabel('Access Tokens')->setContent('Plugin configuration error. Got an error from API: ' . $e->getMessage());
             }
         }
     }
     $fields = $this->getDi()->userTable->getFields(true);
     unset($fields['email']);
     unset($fields['name_f']);
     unset($fields['name_l']);
     $ff = $form->addMagicSelect('fields')->setLabel("Pass additional fields to AWeber\nfields must be configured in AWeber with exactly same titles\nelse API calls will fail and users will not be added\n\nBy default the plugin passes \"email\" and \"name\"\nfields to Aweber, so usually you do not need to select \nthat fields to send as additional fields.\n");
     $ff->loadOptions(array_combine($fields, $fields));
 }
 public function preDispatch()
 {
     parent::preDispatch();
     if ($this->getDi()->auth->getUserId()) {
         $this->_redirect('member');
     }
 }
Example #8
0
 function infoTabEcheckAction()
 {
     require_once APPLICATION_PATH . '/default/controllers/AdminUsersController.php';
     $this->setActiveMenu('users-browse');
     $user_id = $this->_request->getInt('user_id');
     if (!$user_id) {
         throw Am_Exception_InputError("Empty [user_id] passsed");
     }
     $echeck = $this->getDi()->echeckRecordTable->findFirstByUserId($user_id);
     $this->view->echeck = $echeck;
     $this->view->addUrl = $this->getUrl(null, null, null, 'user_id', $this->getInt('user_id'), array('add' => 1));
     if ($echeck || $this->_request->getInt('add') || $this->_request->get('_save_')) {
         $form = $this->createEcheckAdminForm((bool) $echeck);
         if ($form) {
             if ($form->isSubmitted() && $form->validate()) {
                 if (!$echeck) {
                     $echeck = $this->getDi()->echeckRecordTable->createRecord();
                 }
                 $form->toEcheckRecord($echeck);
                 $echeck->user_id = $user_id;
                 $echeck->save();
                 Am_Controller::redirectLocation($this->_request->getRequestUri());
             } elseif ($echeck) {
                 $arr = $echeck->toArray();
                 unset($arr['echeck_ban']);
                 $form->addDataSource(new HTML_QuickForm2_DataSource_Array($arr));
             }
             $this->view->form = $form;
             $this->view->form->setAction($this->_request->getRequestUri());
         }
     }
     $this->view->display('admin/echeck/info-tab.phtml');
     // ????
 }
Example #9
0
 function folderAction()
 {
     $id = $this->_request->getInt('id');
     if (!$id) {
         throw new Am_Exception_InputError("Empty folder#");
     }
     $folder = $this->getDi()->folderTable->load($id);
     if (empty($folder)) {
         throw new Am_Exception_InputError("Folder not found");
     }
     // Check if login cookie exists. If not, user is not logged in and should be redirected to login page.
     $pl = $this->getDi()->plugins_protect->loadGet('new-rewrite');
     // User will be there only if file related to folder doesn't exists.
     // So if main file exists, this means that user is logged in but don't have an access.
     // If main file doesn't exists, redirect user to new-rewrite in order to recreate it.
     // Main file will be created even if user is not active.
     if (is_file($pl->getFilePath($pl->getEscapedCookie()))) {
         $this->view->accessObjectTitle = ___("Folder %s (%s)", $folder->title, $folder->url);
         $this->view->orderUrl = REL_ROOT_URL . '/signup';
         $this->view->display('no-access.phtml');
     } else {
         $url = sprintf("%s/protect/new-rewrite?f=%d&url=%s", REL_ROOT_URL, $id, $this->_request->getParam('url', $folder->getUrl()));
         Am_Controller::redirectLocation($url);
     }
 }
Example #10
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $req = new Am_HttpRequest(sprintf('https://gateway-japa.americanexpress.com/api/rest/version/23/merchant/%s/session', $this->getConfig('merchant')), Am_HttpRequest::METHOD_POST);
     $req->setAuth('merchant.' . $this->getConfig('merchant'), $this->getConfig('password'));
     $req->setBody(Am_Controller::getJson(array('apiOperation' => 'CREATE_PAYMENT_PAGE_SESSION', 'order' => array('id' => $invoice->public_id, 'amount' => $invoice->first_total, 'currency' => $invoice->currency), 'paymentPage' => array('cancelUrl' => $this->getCancelUrl(), 'returnUrl' => $this->getPluginUrl('thanks')))));
     $this->logRequest($req);
     $res = $req->send();
     $this->logResponse($res);
     if ($res->getStatus() != 201) {
         $result->setFailed(sprintf('Incorrect Responce Status From Paysystem [%s]', $res->getStatus()));
         return;
     }
     $msg = Am_Controller::decodeJson($res->getBody());
     if ($msg['result'] == 'ERROR') {
         $result->setFailed($msg['error']['explanation']);
         return;
     }
     $invoice->data()->set(self::DATA_KEY, $msg['successIndicator'])->update();
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->{'merchant'} = $this->getConfig('merchant');
     $a->{'order.description'} = $invoice->getLineDescription();
     $a->{'paymentPage.merchant.name'} = $this->getDi()->config->get('site_title');
     $a->{'session.id'} = $msg['session']['id'];
     $this->logRequest($a);
     $result->setAction($a);
 }
 public function init()
 {
     parent::init();
     set_time_limit(0);
     ignore_user_abort(true);
     @ini_set('memory_limit', '256M');
 }
 public function preDispatch()
 {
     parent::preDispatch();
     if (in_array('cc', $this->getDi()->modules->getEnabled())) {
         throw new Am_Exception_AccessDenied(___('Online backup is disabled if you have CC payment plugins enabled. Use offline backup instead'));
     }
 }
Example #13
0
    function _afterInitSetupForm(Am_Form_Setup $form)
    {
        $url = Am_Controller::escape(REL_ROOT_URL) . '/default/admin-content/p/newsletter/index';
        $text = ___("Once the plugin configuration is finished on this page, do not forget to add\n" . "a record on %saMember CP -> Protect Content -> Newsletters%s page", '<a href="' . $url . '" target="_blank" class="link">', '</a>');
        $form->addProlog(<<<CUT
<div class="warning_box">
    {$text}
</div>
CUT
);
        if ($this->canGetLists()) {
            $lists = array();
            try {
                foreach ($this->getLists() as $k => $v) {
                    $lists[$k] = $v['title'];
                }
            } catch (Exception $e) {
                //just log
                $this->getDi()->errorLogTable->logException($e);
            }
            $gr = $form->addGroup()->setLabel(___('Unsubscribe customer from selected newsletter threads'));
            $gr->addSelect('unsubscribe_after_signup')->loadOptions(array('' => ___('Please Select'), self::UNSUBSCRIBE_AFTER_ADDED => ___('After the user has been added'), self::UNSUBSCRIBE_AFTER_PAID => ___('After first payment has been completed')));
            $gr->addStatic()->setContent('<br><br>');
            $gr->addMagicSelect('unsubscribe_after_signup_lists')->loadOptions($lists);
        }
        parent::_afterInitSetupForm($form);
    }
 public function init()
 {
     parent::init();
     $this->loadCart();
     $this->view->cart = $this->cart;
     $this->getDi()->blocks->add(new Am_Block('cart/right', ___('Search Products'), 'cart-search', $this->getModule(), 'search.phtml', Am_Block::TOP))->add(new Am_Block('cart/right', ___('Your Basket'), 'cart-basket', $this->getModule(), 'basket.phtml', Am_Block::TOP))->add(new Am_Block('cart/right', ___('Authentication'), 'cart-auth', $this->getModule(), 'auth.phtml'));
 }
Example #15
0
 public function init()
 {
     parent::init();
     $this->loadCart();
     $this->view->cart = $this->cart;
     $cc = $this->getCategoryCode();
     $this->view->cc = $cc;
     $cats = explode(',', $this->getRequest()->getCookie('am-cart-cats', ''));
     if (!in_array($cc, $cats)) {
         $cats[] = $cc;
         $this->setCookie('am-cart-cats', implode(',', $cats));
     }
     $this->hiddenCatCodes = $cats;
     $this->view->productCategoryOptions = array(null => ___('-- Select Category --')) + $this->getDi()->productCategoryTable->getUserSelectOptions(array(ProductCategoryTable::EXCLUDE_EMPTY => true, ProductCategoryTable::COUNT => true, ProductCategoryTable::EXCLUDE_HIDDEN => true, ProductCategoryTable::INCLUDE_HIDDEN => $this->getHiddenCatCodes(), ProductCategoryTable::ROOT => $this->getModule()->getConfig('category_id', null)));
     if (!$this->getModule()->getConfig('layout_no_category')) {
         $this->getDi()->blocks->add(new Am_Block('cart/right', ___('Category'), 'cart-category', $this->getModule(), 'category.phtml', Am_Block::TOP));
     }
     if (!$this->getModule()->getConfig('layout_no_search')) {
         $this->getDi()->blocks->add(new Am_Block('cart/right', ___('Search Products'), 'cart-search', $this->getModule(), 'search.phtml', Am_Block::TOP));
     }
     if (!$this->getModule()->getConfig('layout_no_basket')) {
         $this->getDi()->blocks->add(new Am_Block('cart/right', ___('Your Basket'), 'cart-basket', $this->getModule(), 'basket.phtml', Am_Block::TOP));
     }
     if (!$this->getModule()->getConfig('layout_no_auth')) {
         $this->getDi()->blocks->add(new Am_Block('cart/right', ___('Authentication'), 'cart-auth', $this->getModule(), 'auth.phtml'));
     }
 }
Example #16
0
 public function init()
 {
     $this->strategy = $this->getDi()->helpdeskStrategy;
     $type = defined('AM_ADMIN') ? 'admin' : 'user';
     $this->getView()->headLink()->appendStylesheet($this->getView()->_scriptCss('helpdesk-' . $type . '.css'));
     parent::init();
 }
Example #17
0
 protected function getWrapper($obj, $grid)
 {
     $id = $this->action->getIdForRecord($obj);
     list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id));
     $start = sprintf("<span class='live-edit' id='%s' livetemplate='%s' liveurl='%s' livedata='%s' placeholder='%s'>", $grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id), $grid->escape($this->getInputTemplate()), $url, Am_Controller::getJson($params), $grid->escape($this->action->getPlaceholder()));
     $stop = '</span>';
     return array($start, $stop);
 }
Example #18
0
 protected function getContent($obj, Am_Grid_Editable $grid)
 {
     $id = $this->action->getIdForRecord($obj);
     $val = $obj->{$this->field->getFieldName()};
     list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id));
     $content = sprintf('<input name="%s" class="live-checkbox" data-url="%s" data-id="%d" data-params="%s" data-value="%s" data-empty_value="%s" type="checkbox" %s/>', Am_Controller::escape($grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id)), Am_Controller::escape($url), $id, Am_Controller::escape(Am_Controller::getJson($params)), Am_Controller::escape($this->action->getValue()), Am_Controller::escape($this->action->getEmptyValue()), $val == $this->action->getValue() ? 'checked ' : '');
     return $content;
 }
 public function renderInputs()
 {
     $gridId = $this->grid->getId();
     $options = array_merge(array('' => ''), Am_Currency::getSupportedCurrencies());
     array_remove_value($options, Am_Currency::getDefault());
     $filter = $this->getParam('filter');
     return sprintf("<select name='{$gridId}_filter[currency]'>\n%s\n</select>\n", Am_Controller::renderOptions($options, @$filter['currency']));
 }
Example #20
0
 function init()
 {
     if (!class_exists('Am_Form_Brick', false)) {
         class_exists('Am_Form_Brick', true);
         Am_Di::getInstance()->hook->call(Am_Event::LOAD_BRICKS);
     }
     parent::init();
 }
Example #21
0
 function renderTable($kvRows)
 {
     $h = "<table class='logdetail'>\n";
     foreach ($kvRows as $k => $v) {
         $h .= sprintf("<tr><th>%s</th><td>%s</td></tr>\n", Am_Controller::escape($k), Am_Controller::escape($v));
     }
     $h .= "</table>\n";
     return $h;
 }
Example #22
0
 public function renderLink(ResourceAbstract $resource)
 {
     $html = "";
     $url = $resource->getUrl();
     if (!empty($url)) {
         $html = sprintf('<a href="%s" target="_blank">%s</a>', Am_Controller::escape($url), ___('link'));
     }
     return $this->renderTd($html, false);
 }
Example #23
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     $user = $this->getDi()->user;
     $id = $this->getDi()->app->reveal($request->getActionName());
     //actualy it is notification_id
     $notification = $this->getDi()->notificationTable->load($id);
     $this->getDi()->notificationClickTable->log($user, $notification);
     Am_Controller::redirectLocation($notification->url);
 }
Example #24
0
 protected function getWrapper($obj, $grid)
 {
     $id = $this->action->getIdForRecord($obj);
     $val = $obj->{$this->field->getFieldName()};
     list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id));
     $start = sprintf('<span class="live-edit%s" id="%s" livetemplate="%s" liveurl="%s" livedata="%s" placeholder="%s" data-init-callback="%s">', $val ? '' : ' live-edit-placeholder', $grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id), $grid->escape($this->getInputTemplate()), $url, $grid->escape(Am_Controller::getJson($params)), $grid->escape($this->action->getPlaceholder()), $grid->escape($this->action->getInitCallback()));
     $stop = '</span>';
     return array($start, $stop);
 }
Example #25
0
    public function getReadme()
    {
        $ipn = Am_Controller::escape($this->getPluginUrl('ipn'));
        return <<<CUT
You need to enable 'Direct HTTP server-to-server request' on page 'Configuration -> Technical Information -> Transaction Feedback' in your ePDQ account
and set it to
<strong>{$ipn}</strong>
CUT;
    }
Example #26
0
 function init()
 {
     if (!class_exists('Am_Form_Brick', false)) {
         class_exists('Am_Form_Brick', true);
         Am_Di::getInstance()->hook->call(Am_Event::LOAD_BRICKS);
     }
     parent::init();
     $this->msg = ___('We review all affiliates manually, so your affiliate account status is pending. ' . 'You will receive email when your account will be approved. Thank you for your patience.');
 }
 function preDispatch()
 {
     $this->user_id = intval($this->_request->user_id);
     if ($this->_request->getActionName() != 'log') {
         if ($this->user_id <= 0) {
             throw new Am_Exception_InputError("user_id is empty in " . get_class($this));
         }
     }
     return parent::preDispatch();
 }
Example #28
0
 public function preDispatch()
 {
     $db_version = $this->getDi()->store->get('db_version');
     if (empty($db_version)) {
         $this->getDi()->store->set('db_version', AM_VERSION);
     } elseif ($db_version != AM_VERSION) {
         $this->redirectLocation(REL_ROOT_URL . '/admin-upgrade-db');
     }
     parent::preDispatch();
 }
Example #29
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ('reject' == $request->getActionName()) {
         $invoice = $this->getDi()->invoiceTable->findFirstByPublicId($request->get("orderDescription"));
         $url = $this->getRootUrl() . "/cancel?id=" . $invoice->getSecureId('CANCEL');
         return Am_Controller::redirectLocation($url);
     } else {
         return parent::directAction($request, $response, $invokeArgs);
     }
 }
 function initActions()
 {
     $this->actionAdd(new Am_Grid_Action_Upload());
     $this->actionAdd(new Am_Grid_Action_Delete());
     $actionDownload = new Am_Grid_Action_Url('download', 'Download', Am_Controller::makeUrl('admin-upload', 'get', 'default', array('id' => '__ID__')));
     $actionDownload->setTarget('_top');
     $this->actionAdd($actionDownload);
     $this->actionAdd(new Am_Grid_Action_Group_Delete());
     $this->actionAdd(new Am_Grid_Action_LiveEdit('desc'));
 }