Пример #1
0
 /**
  * Method to validate the form data.
  * Each field error is stored in session and can be retrieved with getFieldError().
  * Once getFieldError() is called, the error is deleted from the session.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     if (!isset($data['project_id'])) {
         $data['project_id'] = TrackslibHelperTools::getCurrentProjectId();
     }
     return parent::validate($form, $data, $group);
 }
Пример #2
0
 /**
  * Method to validate the form data.
  * Each field error is stored in session and can be retrieved with getFieldError().
  * Once getFieldError() is called, the error is deleted from the session.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     $validData = parent::validate($form, $data, $group);
     $validData = $this->getPicture($validData, $data, 'picture');
     $validData = $this->getPicture($validData, $data, 'picture_small');
     $validData = $this->getPicture($validData, $data, 'vehicle_picture');
     return $validData;
 }
Пример #3
0
 /**
  * Get the associated JTable
  *
  * @param   string  $name    Table name
  * @param   string  $prefix  Table prefix
  * @param   array   $config  Configuration array
  *
  * @return  JTable
  */
 public function getTable($name = 'Object', $prefix = '', $config = array())
 {
     $class = get_class($this);
     if (empty($prefix)) {
         $prefix = strstr($class, 'Model', true) . 'Table';
     }
     return parent::getTable($name, $prefix, $config);
 }
Пример #4
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success, False on error.
  *
  * @since   12.2
  */
 public function save($data)
 {
     if (isset($data['channel_params']) && is_array($data['channel_params'])) {
         $registry = new JRegistry();
         $registry->loadArray($data['channel_params']);
         $data['channel_params'] = (string) $registry;
     }
     return parent::save($data);
 }
Пример #5
0
 /**
  * Method to validate the form data.
  * Each field error is stored in session and can be retrieved with getFieldError().
  * Once getFieldError() is called, the error is deleted from the session.
  *
  * @param   JForm   $form   The form to validate against.
  * @param   array   $data   The data to validate.
  * @param   string  $group  The name of the field group to validate.
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     $validData = parent::validate($form, $data, $group);
     if (!JFactory::getUser()->authorise('core.edit', 'com_tracks')) {
         $validData['user_id'] = JFactory::getUser()->get('id');
     } elseif (isset($data['assign_me'])) {
         $validData['user_id'] = JFactory::getUser()->get('id');
     }
     $validData = $this->getPicture($validData, $data, 'picture');
     $validData = $this->getPicture($validData, $data, 'picture_small');
     return $validData;
 }
Пример #6
0
 /**
  * Method to get all extensions that are using redCORE
  *
  * @return  array  Array of extensions
  */
 public static function getExtensionsRedcore()
 {
     if (empty($loadedRedcoreExtensions)) {
         /** @var RedcoreModelConfig $model */
         $model = RModelAdmin::getAdminInstance('Config', array(), 'com_redcore');
         self::$loadedRedcoreExtensions = RComponentHelper::getRedcoreComponents();
         foreach (self::$loadedRedcoreExtensions as $componentKey => $componentName) {
             self::$loadedRedcoreExtensions[$componentKey] = $model->getComponent($componentName);
         }
     }
     return self::$loadedRedcoreExtensions;
 }
Пример #7
0
 /**
  * Constructor.
  *
  * @param   array  $config  An optional associative array of configuration settings.
  *
  * @see     JModelLegacy
  */
 public function __construct($config = array())
 {
     if (!empty($config["tableName"])) {
         $this->tableName = $config["tableName"];
         $this->name = $config["tableName"];
     }
     if (!empty($config["context"])) {
         $this->context = strtolower($config["context"]);
     }
     $this->modelConfig = $config;
     parent::__construct($config);
 }
Пример #8
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed    Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $item = parent::getItem($pk);
     if (!$item->event_id) {
         // Get the prid of the record from the request.
         $id = JFactory::getApplication()->input->getInt('event_id');
         if (!$id) {
             throw new RuntimeException('event_id id is required');
         }
         $item->event_id = $id;
     }
     return $item;
 }
Пример #9
0
 /**
  * Ajax call to get logs tab content.
  *
  * @return  void
  */
 public function ajaxlogs()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $paymentId = $input->getInt('id');
     if ($paymentId) {
         /** @var RedcoreModelPayment_Logs $logsModel */
         $logsModel = RModelAdmin::getAdminInstance('Payment_Logs', array(), 'com_redcore');
         $state = $logsModel->getState();
         $logsModel->setState('filter.payment_id', $paymentId);
         $app->setUserState('log.payment_id', $paymentId);
         $formName = 'logsForm';
         $pagination = $logsModel->getPagination();
         $pagination->set('formName', $formName);
         echo RLayoutHelper::render('payment.logs', array('state' => $state, 'items' => $logsModel->getItems(), 'pagination' => $pagination, 'filterForm' => $logsModel->getForm(), 'activeFilters' => $logsModel->getActiveFilters(), 'formName' => $formName, 'showToolbar' => true, 'action' => RRoute::_('index.php?option=com_redcore&view=payment&model=payment_logs'), 'return' => base64_encode('index.php?option=com_redcore&view=payment&layout=edit&id=' . $paymentId . '&tab=logs&from_payment=1')));
     }
     $app->close();
 }
Пример #10
0
 /**
  * Display method
  *
  * @param   string  $tpl  The template name
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     $model = $this->getModel();
     $app = JFactory::getApplication();
     $this->contentElementName = RedcoreHelpersTranslation::getCurrentContentElement();
     $this->componentName = $app->input->get->get('component', $model->getState('filter.component', ''));
     $this->activeFilters = $model->getActiveFilters();
     $this->state = $model->getState();
     $this->filterForm = $model->getForm();
     $this->pagination = $model->getPagination();
     if (!empty($this->contentElementName)) {
         $this->translationTable = RedcoreHelpersTranslation::getTranslationTable();
         $this->contentElement = RTranslationHelper::getContentElement($this->translationTable->option, $this->translationTable->xml);
         $this->items = $model->getItems();
         $this->filterForm->removeField('component', 'filter');
     } else {
         /** @var RedcoreModelConfig $modelConfig */
         $modelConfig = RModelAdmin::getAdminInstance('Config', array('ignore_request' => true), 'com_redcore');
         if (!empty($this->componentName)) {
             $this->component = $modelConfig->getComponent($this->componentName);
         }
         $this->contentElements = $modelConfig->loadContentElements($this->componentName);
         $this->missingContentElements = $modelConfig->loadMissingContentElements($this->componentName, $this->contentElements);
         $this->return = base64_encode('index.php?option=com_redcore&view=translations&contentelement=&component=' . $this->componentName);
         $layout = 'manage';
         $this->setLayout($layout);
         $app->input->set('layout', $layout);
         $this->filterForm->removeField('language', 'filter');
         $this->filterForm->removeField('search_translations', 'filter');
         $this->filterForm->removeField('translations_limit', 'list');
         $this->filterForm->removeField('contentelement', 'filter');
     }
     // Check if option is enabled
     if (RBootstrap::getConfig('enable_translations', 0) == 0) {
         JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_REDCORE_CONFIG_TRANSLATIONS_PLUGIN_LABEL_WARNING', '<a href="index.php?option=com_plugins&view=plugins&filter_search=redcore">' . JText::_('COM_REDCORE_CONFIGURE') . '</a>'), 'error');
     }
     parent::display($tpl);
 }
Пример #11
0
 /**
  * Load item object
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed    Object on success, false on failure.
  *
  * @since   1.2
  */
 public function getItem($pk = null)
 {
     $this->paymentName = $this->getState('payment_name', '');
     if ($this->paymentName != '' || $this->getState('process_params', '0') == '1') {
         $item = parent::getItem($pk);
         if ($this->paymentName && (empty($item->payment_name) || $item->payment_name != $this->paymentName)) {
             $db = $this->getDbo();
             $query = $db->getQuery(true)->select('p.params as plugin_params, p.name as plugin_name, p.element, p.enabled, p.extension_id')->select('CONCAT("plg_redpayment_", p.element) as plugin_path_name')->from($db->qn('#__extensions', 'p'))->where($db->qn('p.type') . '= ' . $db->q("plugin"))->where($db->qn('p.folder') . '= ' . $db->q("redpayment"))->where($db->qn('p.element') . '= ' . $db->q($this->paymentName));
             $db->setQuery($query);
             if ($defaultPlugin = $db->loadObject()) {
                 $item->params = $defaultPlugin->plugin_params;
                 $item->payment_name = $this->paymentName;
             }
         } else {
             $this->paymentName = $item->payment_name;
             $item->params = json_encode($item->params);
         }
         $item->folder = 'redpayment';
         $item->element = $this->paymentName;
         return $item;
     }
     return parent::getItem($pk);
 }
Пример #12
0
 /**
  * Get the associated JTable
  *
  * @param   string  $name    Table name
  * @param   string  $prefix  Table prefix
  * @param   array   $config  Configuration array
  *
  * @return  JTable
  */
 public function getTable($name = 'Extension', $prefix = 'JTable', $config = array())
 {
     return parent::getTable($name, $prefix, $config);
 }
Пример #13
0
 /**
  * Load item object
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed    Object on success, false on failure.
  *
  * @since   1.2
  */
 public function getItem($pk = null)
 {
     if (!($item = parent::getItem($pk))) {
         return $item;
     }
     // Get Access token and Authorization codes
     $db = $this->getDbo();
     // There can be multiple access tokens that are not expired yet so we only load last one
     $query = $db->getQuery(true)->select('oat.access_token, oat.expires as access_token_expires')->from($db->qn('#__redcore_oauth_access_tokens', 'oat'))->where('oat.client_id = ' . $db->quote($item->client_id))->order('oat.expires DESC');
     $db->setQuery($query);
     if ($accessToken = $db->loadObject()) {
         $item->access_token = $accessToken->access_token;
         $item->access_token_expires = $accessToken->access_token_expires;
     }
     // There can be multiple authorization codes that are not expired yet so we only load last one
     $query = $db->getQuery(true)->select('oac.authorization_code, oac.expires as authorization_code_expires')->from($db->qn('#__redcore_oauth_authorization_codes', 'oac'))->where('oac.client_id = ' . $db->quote($item->client_id))->order('oac.expires DESC');
     $db->setQuery($query);
     if ($accessToken = $db->loadObject()) {
         $item->authorization_code = $accessToken->authorization_code;
         $item->authorization_code_expires = $accessToken->authorization_code_expires;
     }
     // There can be multiple refresh tokens that are not expired yet so we only load last one
     $query = $db->getQuery(true)->select('ort.refresh_token, ort.expires as refresh_token_expires')->from($db->qn('#__redcore_oauth_refresh_tokens', 'ort'))->where('ort.client_id = ' . $db->quote($item->client_id))->order('ort.expires DESC');
     $db->setQuery($query);
     if ($accessToken = $db->loadObject()) {
         $item->refresh_token = $accessToken->refresh_token;
         $item->refresh_token_expires = $accessToken->refresh_token_expires;
     }
     $item->grant_types = explode(' ', $item->grant_types);
     $item->scope = explode(' ', $item->scope);
     return $item;
 }
Пример #14
0
 /**
  * Get the associated JTable
  *
  * @param   string  $name    Table name
  * @param   string  $prefix  Table prefix
  * @param   array   $config  Configuration array
  *
  * @return  JTable
  */
 public function getTable($name = null, $prefix = '', $config = array())
 {
     $name = !empty($name) ? $name : 'Extension';
     $prefix = !empty($prefix) ? $prefix : 'JTable';
     return parent::getTable($name, $prefix, $config);
 }
Пример #15
0
 /**
  * Check Component Requirements against known application versions and check for installed libraries
  *
  * @param   string  $option   List of requirements to check
  * @param   string  $message  Custom message for display
  *
  * @return  string  Component info Layout
  */
 public static function displayComponentInfo($option, $message = '')
 {
     $option = strtolower($option);
     if (isset(self::$redcoreExtensionManifests[$option])) {
         unset(self::$redcoreExtensionManifests[$option]);
     }
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_redcore/models', 'RedcoreModel');
     /** @var RedcoreModelConfig $modelConfig */
     $modelConfig = RModelAdmin::getAdminInstance('Config', array('ignore_request' => true), 'com_redcore');
     $component = $modelConfig->getComponent($option);
     $loadInstallModules = array('%' . $component->xml->xmlComponentName . '%');
     $loadInstallPlugins = array();
     $loadInstallPlugins[(string) $component->xml->xmlComponentName] = '%' . $component->xml->xmlComponentName . '%';
     if ($component->xml->modules) {
         foreach ($component->xml->modules->module as $module) {
             $loadInstallModules[] = (string) $module['name'];
         }
     }
     if ($component->xml->plugins) {
         foreach ($component->xml->plugins->plugin as $plugin) {
             $loadInstallPlugins[(string) $plugin['group']] = (string) $plugin['name'];
         }
     }
     $modules = $modelConfig->getInstalledExtensions('module', $loadInstallModules);
     $plugins = $modelConfig->getInstalledExtensions('plugin', $loadInstallPlugins, $component->xml->xmlComponentName);
     $requirements = self::checkComponentRequirements($component->xml->requirements);
     return RLayoutHelper::render('component.extensioninfo', array('xml' => $component->xml, 'requirements' => $requirements, 'modules' => $modules, 'plugins' => $plugins, 'message' => $message));
 }
Пример #16
0
 /**
  * Generate Payment Log depending on the status
  *
  * @param   array  $paymentLog           Data for payment log storage
  * @param   bool   $updatePaymentStatus  Update Payment Status
  *
  * @return bool
  */
 public static function saveNewPaymentLog($paymentLog, $updatePaymentStatus = true)
 {
     if (empty($paymentLog['payment_id'])) {
         return false;
     }
     // Forcing default set of statuses
     $paymentLog['status'] = RApiPaymentStatus::getStatus($paymentLog['status']);
     // Currency should not be numeric
     if (!empty($paymentLog['currency']) && is_numeric($paymentLog['currency'])) {
         $paymentLog['currency'] = RHelperCurrency::getIsoCode($paymentLog['currency']);
     }
     /** @var RedcoreModelPayment_Log $logModel */
     $logModel = RModelAdmin::getAdminInstance('Payment_Log', array(), 'com_redcore');
     if ($logModel->save($paymentLog)) {
         if ($updatePaymentStatus) {
             self::updatePaymentStatus($paymentLog['payment_id']);
         }
     }
     return true;
 }
Пример #17
0
 /**
  * Method to get a form object.
  *
  * @param   array    $data      Data for the form.
  * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
  *
  * @return  mixed  A JForm object on success, false on failure
  */
 public function getForm($data = array(), $loadData = true)
 {
     $form = parent::getForm($data, $loadData);
     if ($form) {
         // Load dynamic form for operations
         $form->load(str_replace('"operation"', '"create"', $this->loadFormOperationXml()));
         $form->load(str_replace('"operation"', '"read-list"', $this->loadFormOperationXml()));
         $form->load(str_replace('"operation"', '"read-item"', $this->loadFormOperationXml()));
         $form->load(str_replace('"operation"', '"update"', $this->loadFormOperationXml()));
         $form->load(str_replace('"operation"', '"delete"', $this->loadFormOperationXml()));
         if (!empty($data)) {
             foreach ($data as $operationName => $operation) {
                 if (substr($operationName, 0, strlen('task-')) === 'task-') {
                     $form->load(str_replace('"operation"', '"' . $operationName . '"', $this->loadFormOperationXml()));
                 }
             }
         }
         if (!empty($this->xmlFile) && ($tasks = $this->xmlFile->xpath('//operations/task'))) {
             $tasks = $tasks[0];
             foreach ($tasks as $taskName => $task) {
                 $form->load(str_replace('"operation"', '"task-' . $taskName . '"', $this->loadFormOperationXml()));
             }
         }
         $form->bind($this->formData);
     }
     return $form;
 }
Пример #18
0
<?php

/**
 * @package     Redcore.Admin
 * @subpackage  Templates
 *
 * @copyright   Copyright (C) 2008 - 2015 redCOMPONENT.com. All rights reserved.
 * @license     GNU General Public License version 2 or later, see LICENSE.
 */
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
JHtml::_('rdropdown.init');
JHtml::_('rbootstrap.tooltip');
JHtml::_('rjquery.chosen', 'select');
// Check for request forgeries.
JPluginHelper::importPlugin('redpayment');
$app = JFactory::getApplication();
$input = $app->input;
$paymentName = $input->getString('payment_name');
$paymentConfigurationId = $input->getInt('payment_id', 0);
$randomId = rand(1, 10000);
$data = array('payment_name' => $paymentName, 'extension_name' => 'com_redcore', 'owner_name' => '', 'order_name' => 'Order ' . $randomId, 'order_id' => 'test' . $randomId, 'client_email' => '*****@*****.**', 'amount_original' => '10', 'amount_order_tax' => '2', 'order_tax_details' => '20% tax', 'amount_shipping' => '1', 'shipping_details' => '1 shipping', 'customer_note' => 'Testing', 'currency' => 'USD', 'sandbox' => true, 'url_cancel' => JUri::root() . 'administrator/index.php?option=com_redcore&view=payments', 'url_accept' => JUri::root() . 'administrator/index.php?option=com_redcore&view=payments');
if (!empty($paymentConfigurationId)) {
    $model = RModelAdmin::getAdminInstance('Payment_Configuration', array(), 'com_redcore');
    if ($item = $model->getItem($paymentConfigurationId)) {
        $data['extension_name'] = $item->extension_name;
        $data['owner_name'] = $item->owner_name;
    }
}
echo RApiPaymentHelper::displayPayment($paymentName, $data['extension_name'], $data['owner_name'], $data);