Exemple #1
0
 public function render(Am_View $view, $user = null)
 {
     $html = $this->html;
     if (strpos($html, '%user.') !== false) {
         $t = new Am_SimpleTemplate();
         if ($user) {
             $t->assign('user', $user);
         }
         $t->assignStdVars();
         $html = $t->render($html);
     }
     if ($this->use_layout) {
         $view->content = '<div class="am-content-page">' . $html . '</div>';
         $view->title = $this->title;
         $view->meta_title = $this->meta_title ? $this->meta_title : $this->title;
         if ($this->meta_keywords) {
             $view->headMeta()->setName('keywords', $this->meta_keywords);
         }
         if ($this->meta_description) {
             $view->headMeta()->setName('description', $this->meta_description);
         }
         return $view->render($this->tpl ? $this->tpl : 'layout.phtml');
     } else {
         return $html;
     }
 }
Exemple #2
0
 public function __toString()
 {
     try {
         $t = new Am_View();
         $t->form = $this;
         return $t->render('admin/_form.phtml');
     } catch (Exception $e) {
         user_error('Exception catched: ' . get_class($e) . ':' . $e->getMessage(), E_USER_ERROR);
     }
 }
Exemple #3
0
 function renderInvoiceCommissions(Invoice $invoice, Am_View $view)
 {
     $query = new Am_Query($this->getDi()->affCommissionTable);
     $query->leftJoin('?_invoice', 'i', 'i.invoice_id=t.invoice_id')->leftJoin('?_user', 'a', 't.aff_id=a.user_id')->leftJoin('?_product', 'p', 't.product_id=p.product_id')->addField('CONCAT(a.login, \' (\', a.name_f, \' \', a.name_l,\') #\', a.user_id)', 'aff_name')->addField('p.title', 'product_title')->addWhere('t.invoice_id=?', $invoice->pk())->leftJoin('?_aff_payout_detail', 'apd', 't.payout_detail_id=apd.payout_detail_id')->leftJoin('?_aff_payout', 'ap', 'ap.payout_id=apd.payout_id')->addField('ap.date', 'payout_date')->addField('ap.payout_id')->addField('apd.is_paid')->setOrder('commission_id', 'desc');
     $items = $query->selectAllRecords();
     $view->comm_items = $items;
     $view->invoice = $invoice;
     $view->has_tiers = $this->getDi()->affCommissionRuleTable->getMaxTier();
     return $view->render('blocks/admin-user-invoice-details.phtml');
 }
Exemple #4
0
 function renderForm($addHidden)
 {
     $this->initPossibleConditions();
     $t = new Am_View();
     $renderer = HTML_QuickForm2_Renderer::factory('array');
     if (!$this->form) {
         $this->createForm(array());
     }
     $this->form->render($renderer);
     $t->assign('form', $renderer->toArray());
     $t->assign('description', $this->getDescription(true));
     $t->assign('serialized', $this->serialize());
     $t->assign('hidden', $addHidden);
     $t->assign('loadSearchOptions', Am_Controller::renderOptions($this->getLoadOptions(), $this->saved_search_id));
     return $t->render($this->template);
 }
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     $invoice = $this->getDi()->invoiceTable->findBySecureId($request->getFiltered('id'), $this->getId());
     if (!$invoice) {
         throw new Am_Exception_InputError(___("Sorry, seems you have used wrong link"));
     }
     $view = new Am_View();
     $html = $this->getConfig('html', 'SITE OWNER DID NOT PROVIDE INSTRUCTIONS FOR OFFLINE PAYMENT YET');
     $tpl = new Am_SimpleTemplate();
     $tpl->invoice = $invoice;
     $tpl->user = $this->getDi()->userTable->load($invoice->user_id);
     $tpl->invoice_id = $invoice->invoice_id;
     $tpl->cancel_url = REL_ROOT_URL . '/cancel?id=' . $invoice->getSecureId('CANCEL');
     $view->content = $tpl->render($html);
     $view->title = $this->getTitle();
     $response->setBody($view->render("layout.phtml"));
 }
Exemple #6
0
 protected function getInlineStyle($id, $offset = 10)
 {
     $spriteOffset = Am_View::getSpriteOffset($id);
     if ($spriteOffset === false) {
         return '';
     }
     $realOffset = $offset - $spriteOffset;
     return sprintf(' style="background-position: %spx center;" ', $realOffset);
 }
Exemple #7
0
 protected function getInlineStyle($id, $offset = 10)
 {
     $spriteOffset = Am_View::getSpriteOffset($id);
     if ($spriteOffset !== false) {
         $realOffset = $offset - $spriteOffset;
         return sprintf(' style="background-position: %spx center;" ', $realOffset);
     } elseif ($src = $this->view->_scriptImg('icons/' . $id . '.png')) {
         return sprintf(' style="background-position: %spx center; background-image:url(\'%s\')" ', $offset, $src);
     } else {
         return false;
     }
 }
 function initElements()
 {
     $this->addElement('text', 'site_title', array('size' => 40), array('help-id' => '#Site Title'))->setLabel(___('Site Title'));
     $this->addElement('static', null, null, array('help-id' => '#Root Url and License Key'))->setContent('<div><a href="' . Am_Controller::escape(REL_ROOT_URL) . '/admin-license" target="_top">' . ___('change') . '</a></div>')->setLabel(___('Root Url and License Keys'));
     $this->addText('flowplayer_license')->setLabel(___("FlowPlayer License Key\nyou may get your key in %smembers area%s", '<a href="http://www.amember.com/amember/member?flowplayer_key=1">', '</a>'))->addRule('regex', ___('Value must be alphanumeric'), '/^[a-zA-Z0-9]*$/');
     $this->addElement('select', 'theme', null, array('help-id' => '#User Pages Theme'))->setLabel(___('User Pages Theme'))->loadOptions(Am_View::getThemes('user'));
     $this->addElement('select', 'admin_theme')->setLabel(___('Admin Pages Theme'))->loadOptions(Am_View::getThemes('admin'));
     /*
              if (!extension_loaded("curl")){
                  $el = $this->addElement('text', 'curl')
                      ->setLabel(___('cURL executable file location', "you need it only if you are using payment processors<br />
                      like Authorize.Net or PayFlow Pro<br />
                      usually valid path is /usr/bin/curl or /usr/local/bin/curl"));
                  $el->default = '/usr/bin/curl';
                  $el->addRule('callback2', 'error', array($this, 'validateCurl'));
              }
     */
     $fs = $this->addElement('fieldset', '##02')->setLabel(___('Signup Form Configuration'));
     //         $this->addElement('advcheckbox', 'generate_login')
     //             ->setLabel(___('Generate Login', 'should aMember generate username for customer?'));
     $this->setDefault('login_min_length', 5);
     $this->setDefault('login_max_length', 16);
     $loginLen = $fs->addGroup()->setLabel(___('Username length'));
     $loginLen->addInteger('login_min_length')->setLabel('min');
     $loginLen->addInteger('login_max_length')->setLabel('max');
     $fs->addElement('advcheckbox', 'login_disallow_spaces')->setLabel(___('Do not allow spaces in username'));
     $fs->addElement('advcheckbox', 'login_dont_lowercase')->setLabel(___("Do not lowercase username\n" . "by default, aMember automatically lowercases entered username\n" . "here you can disable this function"));
     //         $fs->addElement('advcheckbox', 'generate_pass')
     //             ->setLabel(___('Generate Password', 'should aMember generate password for customer?'));
     //
     $this->setDefault('pass_min_length', 6);
     $this->setDefault('pass_max_length', 25);
     $passLen = $fs->addGroup()->setLabel(___('Password Length'));
     $passLen->addInteger('pass_min_length')->setLabel('min');
     $passLen->addInteger('pass_max_length')->setLabel('max');
     $fs = $this->addElement('fieldset', '##03')->setLabel(___('Miscellaneous'));
     $this->setDefault('admin.records-on-page', 10);
     $fs->addElement('text', 'admin.records-on-page')->setLabel(___('Records per page (for grids)'));
     $this->setDefault('currency', 'USD');
     $currency = $fs->addElement('select', 'currency', array('size' => 1))->setLabel(___("Base Currency\n" . "base currency to be used for reports and affiliate commission.\n" . "It could not be changed if there are any invoices in database"))->loadOptions(Am_Currency::getFullList());
     if (Am_Di::getInstance()->db->selectCell("SELECT COUNT(*) FROM ?_invoice")) {
         $currency->toggleFrozen(true);
     }
 }
Exemple #9
0
 /**
  * Redirect customer to new url
  * @param $targetTop useful when doing a redirect in AJAX generated html
  */
 function redirectHtml($url, $text = '', $title = 'Redirecting...', $targetTop = false, $proccessed = null, $total = null)
 {
     $this->view->assign('title', $title);
     $this->view->assign('text', $text);
     $this->view->assign('url', $url);
     if (!is_null($total)) {
         $width = 100 * $proccessed / $total;
         $this->view->width = min(100, round($width));
         $this->view->showProgressBar = true;
         $this->view->total = $total;
         $this->view->proccessed = $proccessed;
     }
     if ($targetTop) {
         $this->view->assign('target', '_top');
     }
     if (ob_get_level()) {
         ob_end_clean();
     }
     $this->getResponse()->setBody($this->view->render(defined('AM_ADMIN') ? 'admin/redirect.phtml' : 'redirect.phtml'));
     throw new Am_Exception_Redirect($url);
     // exit gracefully
 }
Exemple #10
0
 public function icon($name, $alt = '', $source = 'icon')
 {
     $arr = is_string($alt) ? array('alt' => $alt) : (array) $alt;
     $attrs = "";
     foreach ($arr as $k => $v) {
         $attrs .= $this->view->escape($k) . '="' . $this->view->escape($v) . '" ';
     }
     $spriteOffset = Am_View::getSpriteOffset($name, $source);
     if ($spriteOffset !== false) {
         if (!empty($arr['alt'])) {
             $attrs .= ' title="' . $this->view->escape($arr['alt']) . '"';
         }
         $res = sprintf('<div class="glyph sprite-%s" style="background-position: %spx center;" %s></div>', $source, -1 * $spriteOffset, $attrs);
     } elseif ($src = $this->view->_scriptImg('icons/' . $name . '.png')) {
         $res = sprintf('<img src="%s" ' . $attrs . ' />', $src);
     } else {
         if (!empty($arr['alt'])) {
             $res = $arr['alt'];
         } else {
             $res = null;
         }
     }
     return $res;
 }
Exemple #11
0
 function render($path, Am_View $view)
 {
     $urlPath = $this->request->get('path', 'upload::');
     $list = array();
     foreach ($this->plugins as $pl) {
         $o = new stdclass();
         $o->title = $pl->getTitle();
         $o->link = $this->getUrl($pl->getPath(null));
         $list[$pl->getId()] = $o;
     }
     $view->plugins = $list;
     $view->description = $this->storage->getDescription();
     $view->active_plugin = $this->storage->getId();
     $view->path = $path;
     $view->currentUrl = $this->getUrl($path);
     $items = $actions = array();
     foreach ($this->storage->getItems($path, $actions) as $item) {
         switch (true) {
             case $item instanceof Am_Storage_File:
                 $item->_data_info = $item->info($this->secure);
                 $item->_link = $this->getUrl($this->storage->getPath($item->getPath()));
                 $items[] = $item;
                 break;
             case $item instanceof Am_Storage_Folder:
                 $item->_link = $this->getUrl($this->storage->getPath($item->getPath()));
                 $items[] = $item;
                 break;
         }
     }
     foreach ($actions as $item) {
         switch (true) {
             case $item instanceof Am_Storage_Action_Upload:
                 $item->_link = $this->getUrl($urlPath . '?action=upload');
                 $view->upload = $item;
                 break;
             case $item instanceof Am_Storage_Action_CreateFolder:
                 $item->_link = $this->getUrl($urlPath . '?action=create-folder');
                 $view->createfolder = $item;
                 break;
             case $item instanceof Am_Storage_Action_Refresh:
                 $item->_link = $this->getUrl($urlPath . '?action=refresh');
                 $view->refresh = $item;
                 break;
             case $item instanceof Am_Storage_Action_DeleteFile:
                 $item->_link = $this->getUrl($urlPath . '?action=delete-file&path=__PATH__');
                 $view->deletefile = $item;
                 break;
             default:
                 $actions[] = $item;
         }
     }
     $view->actions = $actions;
     $view->items = $items;
     $output = $view->render('admin/_storage-grid.phtml');
     $this->response->appendBody($output);
 }
Exemple #12
0
 function __exception(Exception $e)
 {
     if ($e instanceof Zend_Controller_Dispatcher_Exception && preg_match('/^Invalid controller specified/', $e->getMessage())) {
         return $this->__exception404(Zend_Controller_Front::getInstance()->getResponse());
     }
     if ($e->getCode() == 404) {
         return $this->__exception404(Zend_Controller_Front::getInstance()->getResponse());
     }
     try {
         static $in_fatal_error;
         //!
         $in_fatal_error++;
         if ($in_fatal_error > 2) {
             echo nl2br("<b>\n\n" . __METHOD__ . " called twice\n\n</b>");
             exit;
         }
         if (!$this->initFinished) {
             $isApiError = false;
         } else {
             $request = Zend_Controller_Front::getInstance()->getRequest();
             $isApiError = preg_match('#^/api/#', $request->getPathInfo()) && !preg_match('#^/api/admin($|/)#', $request->getPathInfo());
         }
         if (!$isApiError && (defined('AM_DEBUG') && AM_DEBUG || APPLICATION_ENV == 'testing')) {
             $display_error = "<pre>" . $e . ':' . $e->getMessage() . "</pre>";
         } else {
             if ($e instanceof Am_Exception) {
                 $display_error = $e->getPublicError();
                 $display_title = $e->getPublicTitle();
             } elseif ($e instanceof Zend_Controller_Dispatcher_Exception) {
                 $display_error = ___("Error 404 - Not Found");
                 header("HTTP/1.0 404 Not Found");
             } else {
                 $display_error = ___('An internal error happened in the script, please contact webmaster for details');
             }
         }
         /// special handling for API errors
         if ($isApiError) {
             $format = $request->getParam('_format', 'json');
             if (!empty($display_title)) {
                 $display_error = $display_title . ':' . $display_error;
             }
             $display_error = trim($display_error, " \t\n\r");
             if ($format == 'xml') {
                 $xml = new SimpleXMLElement('<error />');
                 $xml->ok = 'false';
                 $xml->message = $display_error;
                 echo (string) $xml;
             } else {
                 echo json_encode(array('ok' => false, 'error' => true, 'message' => $display_error));
             }
             exit;
         }
         if (!$this->initFinished) {
             amDie($display_error);
         }
         // fixes http://bt.amember.com/issues/597
         if (($router = Zend_Controller_Front::getInstance()->getRouter()) instanceof Zend_Controller_Router_Rewrite) {
             $router->addDefaultRoutes();
         }
         //
         $t = new Am_View();
         $t->assign('is_html', true);
         // must be already escaped here!
         if (isset($display_title)) {
             $t->assign('title', $display_title);
         }
         $t->assign('error', $display_error);
         $t->assign('admin_email', $this->di->config->get('admin_email'));
         if (defined('AM_DEBUG') && AM_DEBUG) {
             $t->assign('trace', $e->getTraceAsString());
         }
         $t->display("error.phtml");
         // log error
         if (!method_exists($e, 'getLogError') || $e->getLogError()) {
             $this->di->errorLogTable->logException($e);
         }
     } catch (Exception $e) {
         echo $e . " thrown within the exception handler. Message: " . $e->getMessage() . " on line " . $e->getLine();
     }
     exit;
 }
Exemple #13
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     try {
         $invoiceLog = $this->_logDirectAction($request, $response, $invokeArgs);
         $transaction = $this->createTransaction($request, $response, $invokeArgs);
         if (!$transaction) {
             throw new Am_Exception_InputError("Request not handled - createTransaction() returned null");
         }
         $transaction->setInvoiceLog($invoiceLog);
         try {
             $transaction->process();
         } catch (Exception $e) {
             if ($invoiceLog) {
                 $invoiceLog->add($e);
             }
             throw $e;
         }
         if ($invoiceLog) {
             $invoiceLog->setProcessed();
         }
         //show thanks page without redirect
         if ($transaction->isFirst()) {
             $this->displayThanks($request, $response, $invokeArgs, $transaction->getInvoice());
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         $view = new Am_View($this->getDi());
         $view->assign('error', $e->getMessage());
         $view->assign('is_html', false);
         $view->placeholder("head-start")->prepend(sprintf('<base href="%s://%s" />', empty($_SERVER['HTTPS']) ? 'http' : 'https', Am_Controller::escape($_SERVER['HTTP_HOST'])));
         $this->invoice = $transaction->getInvoice();
         $view->placeholder("head-start")->prepend(sprintf('<meta http-equiv="refresh" content="0;url=%s">', $this->getCancelUrl()));
         $view->display('error.phtml');
     }
 }
Exemple #14
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     //if ($request->getActionName() == 'cron') return $this->onHourly();
     if ($request->getActionName() == 'thanks') {
         return $this->thanksAction($request, $response, $invokeArgs);
     }
     $invoice = $this->getDi()->invoiceTable->findBySecureId($request->getFiltered('id'), $this->getId());
     if (!$invoice) {
         throw new Am_Exception_InputError(___("Sorry, seems you have used wrong link"));
     }
     $u = $invoice->getUser();
     $xml = new DOMDocument('1.0', 'utf-8');
     $e = new DOMElement('PesapalDirectOrderInfo');
     $el = $xml->appendChild($e);
     $el->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchemainstance');
     $el->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
     $el->setAttribute('Amount', number_format($invoice->first_total, 2));
     $el->setAttribute('Description', $invoice->getLineDescription());
     $el->setAttribute('Code', '');
     $el->setAttribute('Type', 'MERCHANT');
     $el->setAttribute('PaymentMethod', '');
     $el->setAttribute('Reference', $invoice->public_id);
     $el->setAttribute('FirstName', $u->name_f);
     $el->setAttribute('LastName', $u->name_l);
     $el->setAttribute('Email', $u->email);
     $el->setAttribute('PhoneNumber', $u->phone);
     $el->setAttribute('UserName', $u->email);
     $el->setAttribute('Currency', $invoice->currency);
     $el->setAttribute('xmlns', 'http://www.pesapal.com');
     //post transaction to pesapal
     $consumer = $this->getConsumer();
     $token = $params = NULL;
     $method = $this->getMethod();
     $iframe_src = OAuthRequest::from_consumer_and_token($consumer, $token, "GET", self::URL, $params);
     $iframe_src->set_parameter("oauth_callback", $this->getPluginUrl('thanks'));
     $iframe_src->set_parameter("pesapal_request_data", $s = htmlentities($xml->saveXML()));
     $iframe_src->sign_request($method, $consumer, $token);
     $view = new Am_View();
     $view->addScriptPath(dirname(__FILE__));
     $view->invoice = $invoice;
     $view->iframe_src = $iframe_src;
     $response->setBody($view->render("payment-pesapal-confirm.phtml"));
 }
Exemple #15
0
    protected function displayReuse()
    {
        $result = new Am_Paysystem_Result();
        $tr = new Am_Paysystem_Transaction_Stripe_GetCustomer($this->plugin, $this->invoice, $this->invoice->getUser()->data()->get(Am_Paysystem_Stripe::TOKEN));
        $tr->run($result);
        if (!$result->isSuccess()) {
            throw new Am_Exception_Paysystem("Stored customer profile not found");
        }
        $card = $tr->getInfo();
        if ($card['active_card']['last4']) {
            $card = 'XXXX XXXX XXXX ' . $card['active_card']['last4'];
        } else {
            $last4 = 'XXXX';
            foreach (@(array) $card['cards']['data'] as $c) {
                if (@$c['id'] == @$card['default_card']) {
                    $last4 = $c['last4'];
                }
            }
            $card = 'XXXX XXXX XXXX ' . $last4;
        }
        $text = ___('Click "Continue" to pay this order using stored credit card %s', $card);
        $continue = ___('Continue');
        $cancel = ___('Cancel');
        $action = $this->plugin->getPluginUrl('cc');
        $id = Am_Controller::escape($this->_request->get('id'));
        $action = Am_Controller::escape($action);
        $view = new Am_View();
        $receipt = $view->partial('_receipt.phtml', array('invoice' => $this->invoice));
        $this->view->content .= <<<CUT
<div class='am-reuse-card-confirmation'>
{$receipt}
{$text}
<form method='get' action='{$action}'>
    <input type='hidden' name='id' value='{$id}' />
    <input type='submit' class='tb-btn tb-btn-primary' name='reuse_ok' value='{$continue}' />
    &nbsp;&nbsp;&nbsp;
    <input type='submit' class='tb-btn' name='reuse_cancel' value='{$cancel}' />
</form>
</div>
   
CUT;
        $this->view->display('layout.phtml');
    }
Exemple #16
0
 public function __toString()
 {
     $view = new Am_View();
     $view->form = $this;
     return $view->render('_form.phtml');
 }
Exemple #17
0
 public function renderWidgetSales(Am_View $view, $config = null)
 {
     $intervals = is_null($config) ? array(Am_Interval::PERIOD_TODAY, Am_Interval::PERIOD_THIS_WEEK_FROM_SUN) : (array) $config['interval'];
     $out = '';
     foreach ($intervals as $interval) {
         list($start, $stop) = $this->getDi()->interval->getStartStop($interval);
         $view->start = $start;
         $view->stop = $stop;
         $view->reportTitle = $this->getDi()->interval->getTitle($interval);
         $view->controller = $this;
         $out .= $view->render('admin/widget/sales.phtml');
     }
     return $out;
 }
Exemple #18
0
    function initElements()
    {
        $this->addElement('text', 'site_title', array('class' => 'el-wide'), array('help-id' => '#Setup.2FEdit_Site_Title'))->setLabel(___('Site Title'));
        $this->addElement('static', null, null, array('help-id' => '#Root_URL_and_License_Key'))->setContent('<a href="' . Am_Controller::escape(REL_ROOT_URL) . '/admin-license" target="_top" class="link">' . ___('change') . '</a>')->setLabel(___('Root Url and License Keys'));
        $players = array('Flowplayer' => 'Flowplayer');
        if (file_exists(ROOT_DIR . '/application/default/views/public/js/jwplayer/jwplayer.js')) {
            $players['JWPlayer'] = 'JWPlayer';
        }
        $this->addSelect('video_player')->setId('video-player')->setLabel(___('Video Player'))->loadOptions($players)->toggleFrozen(count($players) == 1 ? true : false);
        $this->setDefault('video_player', 'Flowplayer');
        $this->addText('flowplayer_license')->setId('video-player-Flowplayer')->setLabel(___("FlowPlayer License Key\nyou may get your key in %smembers area%s", '<a href="http://www.amember.com/amember/member?flowplayer_key=1" class="link">', '</a>'))->addRule('regex', ___('Value must be alphanumeric'), '/^[a-zA-Z0-9]*$/');
        $this->addText('jwplayer_license')->setId('video-player-JWPlayer')->setLabel(___("JWPlayer License Key"));
        $this->addScript()->setScript(<<<CUT
\$(function(){
    \$('#video-player').change(function(){
        \$('#video-player-Flowplayer').closest('.row').toggle(\$(this).val() == 'Flowplayer');
        \$('#video-player-JWPlayer').closest('.row').toggle(\$(this).val() == 'JWPlayer');
    }).change();
})
CUT
);
        $this->addElement('select', 'theme', null, array('help-id' => '#Setup.2FEdit_User_Pages_Theme'))->setLabel(___('User Pages Theme'))->loadOptions(Am_View::getThemes('user'));
        $this->addElement('select', 'admin_theme', null, array('help-id' => '#Setup.2FEdit_Admin_Pages_Theme'))->setLabel(___('Admin Pages Theme'))->loadOptions(Am_View::getThemes('admin'));
        $tax_plugins = array('global-tax' => ___('Global Tax'), 'regional' => ___('Regional Tax'), 'vat' => ___('EU VAT'), 'vat2015' => ___('EU VAT (New Rules 2015)'), 'gst' => ___('GST (Inclusive Tax)'));
        foreach (Am_Di::getInstance()->plugins_tax->getAvailable() as $plugin) {
            if (!isset($tax_plugins[$plugin])) {
                $tax_plugins[$plugin] = ucwords(str_replace("-", ' ', $plugin));
            }
        }
        $this->addSelect('plugins.tax', array('size' => 1))->setLabel(___('Tax'))->loadOptions(array('' => ___('No Tax')) + $tax_plugins);
        $fs = $this->addElement('fieldset', '##02')->setLabel(___('Signup Form Configuration'));
        //         $this->addElement('advcheckbox', 'generate_login')
        //             ->setLabel(___('Generate Login', 'should aMember generate username for customer?'));
        $this->setDefault('login_min_length', 5);
        $this->setDefault('login_max_length', 16);
        $loginLen = $fs->addGroup(null, null, array('help-id' => '#Setup.2FEdit_Username_Rules'))->setLabel(___('Username Length'));
        $loginLen->addInteger('login_min_length', array('size' => 3))->setLabel('min');
        $loginLen->addStatic('')->setContent(' &mdash; ');
        $loginLen->addInteger('login_max_length', array('size' => 3))->setLabel('max');
        $fs->addElement('advcheckbox', 'login_disallow_spaces', null, array('help-id' => '#Setup.2FEdit_Username_Rules'))->setLabel(___('Do not Allow Spaces in Username'));
        $fs->addElement('advcheckbox', 'login_dont_lowercase', null, array('help-id' => '#Setup.2FEdit_Username_Rules'))->setLabel(___("Do not Lowercase Username\n" . "by default, aMember automatically lowercases entered username\n" . "here you can disable this function"));
        //         $fs->addElement('advcheckbox', 'generate_pass')
        //             ->setLabel(___('Generate Password', 'should aMember generate password for customer?'));
        //
        $this->setDefault('pass_min_length', 6);
        $this->setDefault('pass_max_length', 25);
        $passLen = $fs->addGroup(null, null, array('help-id' => '#Setup.2FEdit_Password_Length'))->setLabel(___('Password Length'));
        $passLen->addInteger('pass_min_length', array('size' => 3))->setLabel('min');
        $passLen->addStatic('')->setContent(' &mdash; ');
        $passLen->addInteger('pass_max_length', array('size' => 3))->setLabel('max');
        $fs->addAdvCheckbox('require_strong_password')->setLabel(___("Require Strong Password\n" . 'password should contain at least 2 capital letters, 2 or more numbers and 2 or more special chars'));
        $fs = $this->addElement('fieldset', '##03')->setLabel(___('Miscellaneous'));
        $this->setDefault('admin.records-on-page', 10);
        $fs->addElement('text', 'admin.records-on-page')->setLabel(___('Records per Page (for grids)'));
        $fs->addAdvCheckbox('disable_rte')->setLabel(___('Disable Visual HTML Editor'));
        $this->setDefault('currency', 'USD');
        $currency = $fs->addElement('select', 'currency', array('size' => 1, 'class' => 'am-combobox'), array('help-id' => '#Set_Up.2FEdit_Base_Currency'))->setLabel(___("Base Currency\n" . "base currency to be used for reports and affiliate commission.\n" . "It could not be changed if there are any invoices in database.\n" . "You can edit exchange rate %shere%s", '<a class="link" href="' . REL_ROOT_URL . '/admin-currency-exchange">', '</a>'))->loadOptions(Am_Currency::getFullList());
        if (Am_Di::getInstance()->db->selectCell("SELECT COUNT(*) FROM ?_invoice")) {
            $currency->toggleFrozen(true);
        }
        $this->addSelect('404_page')->setLabel(___("Page Not Found (404)\n" . "%sthis page will be public and do not require any login/password%s\n" . 'you can create new pages %shere%s', '<strong>', '</strong>', '<a class="link" href="' . REL_ROOT_URL . '/default/admin-content/p/pages/index' . '">', '</a>'))->loadOptions(array('' => ___('Default Not Found Page')) + Am_Di::getInstance()->db->selectCol("SELECT page_id AS ?, title FROM ?_page", DBSIMPLE_ARRAY_KEY));
    }
Exemple #19
0
 function render(Am_View $view, User $user = null)
 {
     $out = $this->is_custom ? $this->content : sprintf('<div class="am-info am-notification">%s %s</div>', $view->escape($this->content), $this->url ? sprintf('<a href="%s"%s>%s</a>', $view->escape(REL_ROOT_URL . '/misc/notification/' . $this->getDi()->app->obfuscate($this->pk())), $this->is_blank ? 'target="_blank"' : '', ___('click here')) : '');
     $t = new Am_SimpleTemplate();
     $t->user = $user;
     return $t->render($out);
 }
Exemple #20
0
 public function expressCheckoutAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     $invoiceLog = $this->_logDirectAction($request, $response, $invokeArgs);
     $token = $request->getFiltered('token');
     if (!$token) {
         throw new Am_Exception_InputError("No required [token] provided, internal error");
     }
     $log = $this->getDi()->invoiceLogRecord;
     $log->title = "";
     $log->paysys_id = $this->getId();
     if ($request->getInt('do')) {
         $invoice = current($this->getDi()->invoiceTable->findByData(self::PAYPAL_EXPRESS_TOKEN, $token));
         if (!$invoice) {
             throw new Am_Exception_InternalError("Could not find invoice by token [{$token}]");
         }
         $invoiceLog->setInvoice($invoice);
         $this->_setInvoice($invoice);
         $log->setInvoice($invoice);
         if ($invoice->first_total > 0) {
             // bill initial amount @todo free trial
             $log->title .= " doExpressCheckout";
             $apireq = new Am_Paysystem_PaypalApiRequest($this);
             $apireq->doExpressCheckout($invoice, $token, $request->getFiltered('PayerID'));
             $vars = $apireq->sendRequest($log);
             $transaction = new Am_Paysystem_Transaction_PayPalExpress_DoExpressCheckout($this, $vars);
             $transaction->setInvoice($invoice);
             $transaction->process();
         }
         if ($invoice->rebill_times) {
             $log->title .= " createRecurringPaymentProfile";
             $apireq = new Am_Paysystem_PaypalApiRequest($this);
             $apireq->createRecurringPaymentProfile($invoice, null, $token, $request->getFiltered('PayerID'));
             $vars = $apireq->sendRequest($log);
             if (!in_array($vars['ACK'], array('Success', 'SuccessWithWarning'))) {
                 $this->logError("Not Success response to CreateRecurringPaymentProfile request", $vars);
             } else {
                 $invoice->data()->set(self::PAYPAL_PROFILE_ID, $vars['PROFILEID'])->update();
                 if ($invoice->first_total <= 0) {
                     $transaction = new Am_Paysystem_Transaction_PayPalExpress_CreateRecurringPaymentProfile($this, $vars);
                     $transaction->setInvoice($invoice);
                     $transaction->process();
                 }
             }
         }
         return Am_Controller::redirectLocation($this->getReturnUrl());
     } else {
         $log->title .= " getExpressCheckoutDetails";
         $apireq = new Am_Paysystem_PaypalApiRequest($this);
         $apireq->getExpressCheckoutDetails($token);
         $vars = $apireq->sendRequest($log);
         $invoiceId = filterId(get_first(@$vars['INVNUM'], @$vars['L_PAYMENTREQUEST_0_INVNUM'], $this->getDi()->session->paypal_invoice_id));
         if (!$invoiceId || !($invoice = $this->getDi()->invoiceTable->findBySecureId($invoiceId, 'paypal'))) {
             throw new Am_Exception_InputError("Could not find invoice related to given payment. Internal error. Your account was not billed, please try again");
         }
         $invoiceLog->setInvoice($invoice);
         $log->setInvoice($invoice);
         $log->update();
         $this->_setInvoice($invoice);
         /* @var $invoice Invoice */
         if ($invoice->isPaid()) {
             return Am_Controller::redirectLocation($this->getReturnUrl());
         }
         $invoice->data()->set(self::PAYPAL_EXPRESS_TOKEN, $token)->update();
         $view = new Am_View();
         $view->invoice = $invoice;
         $view->url = $this->getPluginUrl(self::PAYPAL_EXPRESS_CHECKOUT);
         $view->hidden = array('do' => '1', 'token' => $request->getFiltered('token'), 'PayerID' => $request->getFiltered('PayerID'));
         $view->display("payment-confirm.phtml");
     }
 }
 protected function populateForm()
 {
     $info = $this->getController()->getValue();
     foreach ($info as $k => $v) {
         if ($k[0] == '_') {
             unset($info[$k]);
         }
     }
     if (@$info['table_prefix']) {
         foreach ($info['table'] as &$v) {
             $v = preg_replace('/^' . preg_quote($info['table_prefix']) . '/', '', $v);
         }
     }
     $userFields = array();
     $guessFields = array();
     foreach ($info['field']['user'] as $fn => $a) {
         if (empty($a['field'])) {
             continue;
         }
         $guessFields[] = $fn;
         $expr = $a['field'];
         if ($expr == 'string') {
             $expr = var_export(':' . $a['text'], true);
         } elseif ($expr == 'expr') {
             $expr = '"!' . $a['text'] . '"';
         }
         $userFields[] = "array({$expr}, '{$fn}'),";
     }
     $view = new Am_View();
     $view->assign($info);
     $view->assign('guessFields', $guessFields);
     $view->assign('userFields', $userFields);
     $cnt = "<h2>Plugin Template Generated</h2>";
     $cnt .= "Put the following code to <i>application/default/plugins/protect/{$info['plugin']}.php</i> and start customization";
     $cnt .= "<div style='background-color: #eee; width: 90%; height: 300px; overflow-x: scroll; overflow-y: scroll;'>\n";
     $cnt .= highlight_string($view->render('admin/plugin-template.phtml'), true);
     $cnt .= "</div>";
     $el = $this->form->addStatic(null, array('class' => 'no-label'))->setContent($cnt);
     $gr = $this->form->addGroup(null, array('class' => 'no-label', 'style' => 'text-align:center'));
     $gr->addSubmit($this->getButtonName('back'), array('value' => 'Back'));
     $page = $this;
     while ($p = $page->getController()->previousPage($page)) {
         $page = $p;
     }
     $gr->addSubmit($page->getButtonName('jump'), array('value' => 'Start Over'));
 }
Exemple #22
0
 function renderWidget(Am_View $view, $config = null)
 {
     $view->num = is_null($config) ? 5 : $config['num'];
     return $view->render('admin/helpdesk/widget/messages.phtml');
 }
Exemple #23
0
 function __exception(Exception $e)
 {
     if ($e instanceof Zend_Controller_Dispatcher_Exception && preg_match('/^Invalid controller specified/', $e->getMessage())) {
         return $this->__exception404(Zend_Controller_Front::getInstance()->getResponse());
     }
     if ($e->getCode() == 404) {
         return $this->__exception404(Zend_Controller_Front::getInstance()->getResponse());
     }
     try {
         static $in_fatal_error;
         //!
         $in_fatal_error++;
         if ($in_fatal_error > 2) {
             echo nl2br("<b>\n\n" . __METHOD__ . " called twice\n\n</b>");
             exit;
         }
         if (defined('AM_DEBUG') && AM_DEBUG || APPLICATION_ENV == 'testing') {
             $display_error = "<pre>" . $e . ':' . $e->getMessage() . "</pre>";
         } else {
             if ($e instanceof Am_Exception) {
                 $display_error = $e->getPublicError();
             } elseif ($e instanceof Zend_Controller_Dispatcher_Exception) {
                 $display_error = ___("Error 404 - Not Found");
                 header("HTTP/1.0 404 Not Found");
             } else {
                 $display_error = ___('An internal error happened in the script, please contact webmaster for details');
             }
         }
         $t = new Am_View();
         $t->assign('is_html', true);
         // must be already escaped here!
         $t->assign('error', $display_error);
         $t->assign('admin_email', $this->di->config->get('admin_email'));
         if (defined('AM_DEBUG') && AM_DEBUG) {
             $t->assign('trace', $e->getTraceAsString());
         }
         $t->display("error.phtml");
         // log error
         if (!method_exists($e, 'getLogError') || $e->getLogError()) {
             $this->di->errorLogTable->logException($e);
         }
     } catch (Exception $e) {
         echo $e . " thrown within the exception handler. Message: " . $e->getMessage() . " on line " . $e->getLine();
     }
     exit;
 }
Exemple #24
0
 public function viewAction()
 {
     $ticketIdentity = $this->getParam('ticket');
     $ticket = $this->getDi()->helpdeskTicketTable->load($ticketIdentity);
     if (!$this->strategy->canViewTicket($ticket)) {
         throw new Am_Exception_AccessDenied(___('Access Denied'));
     }
     $grid = new Am_Helpdesk_Grid_Admin($this->getRequest(), $this->getView());
     $grid->getDataSource()->getDataSourceQuery()->addWhere('m.user_id=?d', $ticket->user_id);
     $grid->actionsClear();
     $grid->removeField('m_login');
     $grid->addCallback(Am_Grid_ReadOnly::CB_TR_ATTRIBS, function (&$ret, $record) use($ticket) {
         if ($record->pk() == $ticket->pk()) {
             $ret['class'] = isset($ret['class']) ? $ret['class'] . ' emphase' : 'emphase';
         }
     });
     $grid->isAjax($this->isAjax() && $this->isGridRequest('_grid'));
     if ($grid->isAjax()) {
         echo $grid->run();
         return;
     }
     $category = $ticket->getCategory();
     $t = new Am_View();
     $t->assign('ticket', $ticket);
     $t->assign('category', $category);
     $t->assign('user', $ticket->getUser());
     $t->assign('strategy', $this->strategy);
     $t->assign('historyGrid', $grid->render());
     $content = $t->render($this->strategy->getTemplatePath() . '/ticket.phtml');
     if ($this->isAjax()) {
         header('Content-type: text/html; charset=UTF-8');
         echo $content;
     } else {
         $this->view->assign('content', $content);
         $this->view->display($this->strategy->getTemplatePath() . '/index.phtml');
     }
 }
 private function getReplyForm($ticket_id, $message = null, $type = 'message')
 {
     $content = '';
     $hiddens = '';
     if (!is_null($message) && $type == 'message') {
         $content = explode("\n", $message->content);
         $content = array_map(create_function('$v', 'return \'>\'.$v;'), $content);
         $content = "\n\n" . implode("\n", $content);
     } elseif (!is_null($message) && $type == 'comment') {
         $content = $message->content;
         $hiddens .= sprintf('<input type="hidden" name="message_id" value="%d" />', $message->message_id);
     }
     $t = new Am_View();
     $t->assign('content', $content);
     $t->assign('type', $type);
     $t->assign('hiddens', $hiddens);
     $t->assign('ticket_id', $ticket_id);
     return $t->display($this->strategy->getTemplatePath() . '/_reply-form.phtml');
 }