예제 #1
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     if ($field = JRequest::getVar('field')) {
         if (strpos($field, 'plugin') !== false) {
             if (JVM_VERSION === 1) {
                 $table = '#__plugins';
                 //$ext_id = 'id';
             } else {
                 $table = '#__extensions';
                 //$ext_id = 'extension_id';
             }
             $field = substr($field, 6);
             $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `element` = "' . $field . '"';
             $db->setQuery($q);
             $this->plugin = $db->loadObject();
             $this->loadHelper('parameterparser');
             $parameters = new vmParameters($this->plugin, $this->plugin->element, 'plugin', 'vmuserfield');
             $lang = JFactory::getLanguage();
             $filename = 'plg_vmuserfield_' . $this->plugin->element;
             $lang->load($filename, JPATH_ADMINISTRATOR);
             echo $parameters->render();
             //echo '<input type="hidden" value="'.$this->plugin->element.'" name="custom_value">';
             jExit();
         }
     }
     jExit();
 }
예제 #2
0
 function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $document->setMimeEncoding('application/json');
     if ($virtuemart_media_id = vRequest::getInt('virtuemart_media_id')) {
         //JResponse::setHeader( 'Content-Disposition', 'attachment; filename="media'.$virtuemart_media_id.'.json"' );
         $model = VmModel::getModel('Media');
         $image = $model->createMediaByIds($virtuemart_media_id);
         // 			echo '<pre>'.print_r($image,1).'</pre>';
         $this->json = $image[0];
         //echo json_encode($this->json);
         if (isset($this->json->file_url)) {
             $this->json->file_root = JURI::root(true) . '/';
             $this->json->msg = 'OK';
             echo @json_encode($this->json);
         } else {
             $this->json->msg = '<b>' . vmText::_('COM_VIRTUEMART_NO_IMAGE_SET') . '</b>';
             echo @json_encode($this->json);
         }
     } else {
         if (!class_exists('VmMediaHandler')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'mediahandler.php';
         }
         $start = vRequest::getInt('start', 0);
         $type = vRequest::getCmd('mediatype', 0);
         $list = VmMediaHandler::displayImages($type, $start);
         echo @json_encode($list);
     }
     jExit();
 }
예제 #3
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     if ($field = JRequest::getVar('field')) {
         if (strpos($field, 'plugin') !== false) {
             if (JVM_VERSION === 1) {
                 $table = '#__plugins';
                 //$ext_id = 'id';
             } else {
                 $table = '#__extensions';
                 //$ext_id = 'extension_id';
             }
             $field = substr($field, 6);
             $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `element` = "' . $field . '"';
             $db->setQuery($q);
             $this->plugin = $db->loadObject();
             if (!class_exists('vmParameters')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php';
             }
             $parameters = new vmParameters($this->plugin, $this->plugin->element, 'plugin', 'vmuserfield');
             $lang = JFactory::getLanguage();
             $filename = 'plg_vmuserfield_' . $this->plugin->element;
             if (VmConfig::get('enableEnglish', 1)) {
                 $lang->load($filename, JPATH_ADMINISTRATOR, 'en-GB', true);
             }
             $lang->load($filename, JPATH_ADMINISTRATOR, $lang->getDefault(), true);
             $lang->load($filename, JPATH_ADMINISTRATOR, null, true);
             echo $parameters->render();
             //echo '<input type="hidden" value="'.$this->plugin->element.'" name="custom_value">';
             jExit();
         }
     }
     jExit();
 }
예제 #4
0
파일: view.json.php 프로젝트: lenard112/cms
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     if ($field = vRequest::getVar('field')) {
         if (strpos($field, 'plugin') !== false) {
             JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields');
             $table = '#__extensions';
             $field = substr($field, 6);
             $q = 'SELECT `params`,`element`,`type` FROM `' . $table . '` WHERE `element` = "' . $field . '"';
             $db->setQuery($q);
             $this->userField = $db->loadObject();
             //$this->userField->element = substr($this->userField->type, 6);
             if (!class_exists('vmPlugin')) {
                 require JPATH_VM_PLUGINS . DS . 'vmplugin.php';
             }
             vmPlugin::loadJLang('plg_vmuserfield_' . $this->userField->element, 'vmuserfield', $this->userField->element);
             $path = JPATH_ROOT . DS . 'plugins' . DS . 'vmuserfield' . DS . $this->userField->element . DS . $this->userField->element . '.xml';
             // Get the payment XML.
             $formFile = JPath::clean($path);
             if (file_exists($formFile)) {
                 if (!class_exists('VmConfig')) {
                     require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
                 }
                 if (!class_exists('VmTable')) {
                     require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtable.php';
                 }
                 $this->userField->form = JForm::getInstance($this->userField->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
                 $this->userField->params = new stdClass();
                 $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm');
                 /*
                 					$this->userField->params->userfield_params = $this->userField->params;
                 					VmTable::bindParameterable($this->userField->params,'userfield_params',$varsToPush);*/
                 if (empty($this->userField->userfield_params)) {
                     $this->userField->userfield_params = '';
                 }
                 $this->userField->params->userfield_params = $this->userField->userfield_params;
                 VmTable::bindParameterable($this->userField->params, 'userfield_params', $varsToPush);
                 $this->userField->form->bind($this->userField);
             } else {
                 $this->userField->form = false;
                 vmdebug('renderUserfieldPlugin could not find xml for ' . $this->userField->type . ' at ' . $path);
             }
             //vmdebug('renderUserfieldPlugin ',$this->userField->form);
             if ($this->userField->form) {
                 $form = $this->userField->form;
                 ob_start();
                 include JPATH_VM_ADMINISTRATOR . DS . 'fields' . DS . 'formrenderer.php';
                 $body = ob_get_contents();
                 ob_end_clean();
                 echo $body;
             }
         }
     }
     jExit();
 }
예제 #5
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     if ($virtuemart_media_id = vRequest::getInt('virtuemart_media_id')) {
         //$db = JFactory::getDBO();
         $query = 'SELECT `file_url`,`file_title` FROM `#__virtuemart_medias` where `virtuemart_media_id`=' . $virtuemart_media_id;
         $db->setQuery($query);
         $json = $db->loadObject();
         if (isset($json->file_url)) {
             $json->file_url = JURI::root() . $json->file_url;
             $json->msg = 'OK';
             echo json_encode($json);
         } else {
             $json->msg = '<b>' . vmText::_('COM_VIRTUEMART_NO_IMAGE_SET') . '</b>';
             echo json_encode($json);
         }
     } elseif ($custom_jplugin_id = vRequest::getInt('custom_jplugin_id')) {
         $table = '#__extensions';
         $ext_id = 'extension_id';
         $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `' . $ext_id . '` = "' . $custom_jplugin_id . '"';
         $db->setQuery($q);
         $this->jCustom = $db->loadObject();
         $customModel = VmModel::getModel('custom');
         $this->custom = $customModel->getCustom();
         // Get the payment XML.
         $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmcustom' . DS . $this->jCustom->element . DS . $this->jCustom->element . '.xml');
         if (file_exists($formFile)) {
             VmConfig::loadJLang('plg_vmpsplugin', false);
             if (!class_exists('vmPlugin')) {
                 require VMPATH_PLUGINLIBS . DS . 'vmplugin.php';
             }
             $filename = 'plg_vmcustom_' . $this->jCustom->element;
             vmPlugin::loadJLang($filename, 'vmcustom', $this->jCustom->element);
             $this->custom = VmModel::getModel('custom')->getCustom();
             $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm');
             $this->custom->form = JForm::getInstance($this->jCustom->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
             $this->custom->params = new stdClass();
             foreach ($varsToPush as $k => $field) {
                 if (strpos($k, '_') != 0) {
                     $this->custom->params->{$k} = $field[0];
                 }
             }
             $this->custom->form->bind($this->custom->getProperties());
             $form = $this->custom->form;
             include VMPATH_ADMIN . DS . 'fields' . DS . 'formrenderer.php';
             echo '<input type="hidden" value="' . $this->jCustom->element . '" name="custom_value">';
         } else {
             $this->custom->form = null;
             //VmConfig::$echoDebug = 1;
             vmdebug('File does not exist ' . $formFile);
         }
     }
     jExit();
 }
예제 #6
0
 public function __construct()
 {
     parent::__construct();
     $stateModel = tmsModel::getModel('state');
     $states = array();
     //retrieving countries id
     $countries = vRequest::getString('virtuemart_country_id');
     $countries = explode(',', $countries);
     foreach ($countries as $country) {
         $states[$country] = $stateModel->getStates((int) $country, true, true);
     }
     echo json_encode($states);
     jExit();
 }
예제 #7
0
 /**
  * Method to display the view
  *
  * @access	public
  * @author RickG, Max Milbers
  */
 public function __construct()
 {
     parent::__construct();
     $stateModel = VmModel::getModel('state');
     $states = array();
     //retrieving countries id
     $countries = JRequest::getString('virtuemart_country_id');
     $countries = explode(',', $countries);
     foreach ($countries as $country) {
         $states[$country] = $stateModel->getStates(JFilterInput::clean($country, 'INTEGER'), true);
     }
     echo json_encode($states);
     jExit();
 }
예제 #8
0
 public function __construct()
 {
     parent::__construct();
     $stateModel = VmModel::getModel('state');
     $states = array();
     //retrieving countries id
     $countries = vRequest::getString('virtuemart_country_id');
     $countries = explode(',', $countries);
     foreach ($countries as $country) {
         $states[$country] = $stateModel->getStates((int) $country, true, true);
     }
     JResponse::setHeader("Content-type", "application/json");
     JResponse::sendHeaders();
     echo json_encode($states);
     jExit();
 }
예제 #9
0
 /**
  * Method to render the plugin datas
  * this is an entry point to plugin to easy renders json or html
  *
  *
  * @access    public
  */
 function display($cachable = false, $urlparams = false)
 {
     if (!($type = vRequest::getCmd('vmtype', NULL))) {
         $type = vRequest::getCmd('type', 'vmcustom');
     }
     $typeWhiteList = array('vmcustom', 'vmcalculation', 'vmuserfield', 'vmpayment', 'vmshipment');
     if (!in_array($type, $typeWhiteList)) {
         return FALSE;
     }
     $name = vRequest::getCmd('name', 'none');
     $nameBlackList = array('plgVmValidateCouponCode', 'plgVmRemoveCoupon', 'none');
     if (in_array($name, $nameBlackList)) {
         echo 'You got logged';
         return FALSE;
     }
     JPluginHelper::importPlugin($type, $name);
     $dispatcher = JDispatcher::getInstance();
     // if you want only one render simple in the plugin use jExit();
     // or $render is an array of code to echo as html or json Objects!
     $render = NULL;
     $dispatcher->trigger('plgVmOnSelfCallFE', array($type, $name, &$render));
     if ($render) {
         // Get the document object.
         $document = JFactory::getDocument();
         if (vRequest::getCmd('cache') == 'no') {
             JResponse::setHeader('Cache-Control', 'no-cache, must-revalidate');
             JResponse::setHeader('Expires', 'Mon, 6 Jul 2000 10:00:00 GMT');
         }
         $format = vRequest::getCmd('format', 'json');
         if ($format == 'json') {
             $document->setMimeEncoding('application/json');
             // Change the suggested filename.
             JResponse::setHeader('Content-Disposition', 'attachment;filename="' . $type . '.json"');
             JResponse::setHeader("Content-type", "application/json");
             JResponse::sendHeaders();
             echo json_encode($render);
             jExit();
         } else {
             echo $render;
             jExit();
         }
     } else {
     }
 }
예제 #10
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     if ($virtuemart_media_id = JRequest::getInt('virtuemart_media_id')) {
         //$db = JFactory::getDBO();
         $query = 'SELECT `file_url`,`file_title` FROM `#__virtuemart_medias` where `virtuemart_media_id`=' . $virtuemart_media_id;
         $db->setQuery($query);
         $json = $db->loadObject();
         if (isset($json->file_url)) {
             $json->file_url = JURI::root() . $json->file_url;
             $json->msg = 'OK';
             echo json_encode($json);
         } else {
             $json->msg = '<b>' . JText::_('COM_VIRTUEMART_NO_IMAGE_SET') . '</b>';
             echo json_encode($json);
         }
     } elseif ($custom_jplugin_id = JRequest::getInt('custom_jplugin_id')) {
         if (JVM_VERSION === 1) {
             $table = '#__plugins';
             $ext_id = 'id';
         } else {
             $table = '#__extensions';
             $ext_id = 'extension_id';
         }
         $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `' . $ext_id . '` = "' . $custom_jplugin_id . '"';
         $db->setQuery($q);
         $this->plugin = $db->loadObject();
         if (!class_exists('vmParameters')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php';
         }
         $parameters = new vmParameters($this->plugin->params, $this->plugin->element, 'plugin', 'vmcustom');
         if (!class_exists('vmPlugin')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'plugins' . DS . 'vmplugin.php';
         }
         $filename = 'plg_vmcustom_' . $this->plugin->element;
         vmPlugin::loadJLang($filename, 'vmcustom', $this->plugin->element);
         echo $parameters->render();
         echo '<input type="hidden" value="' . $this->plugin->element . '" name="custom_value">';
         jExit();
     }
     jExit();
 }
예제 #11
0
 function saveJS()
 {
     $data = JRequest::get('get');
     JRequest::setVar($data['token'], '1', 'post');
     JRequest::checkToken() or jexit('Invalid Token save');
     $model = VmModel::getModel($this->_cname);
     $id = $model->store($data);
     $errors = $model->getErrors();
     if (empty($errors)) {
         $msg = JText::sprintf('COM_VIRTUEMART_STRING_SAVED', $this->mainLangKey);
         $type = 'save';
     } else {
         $type = 'error';
     }
     foreach ($errors as $error) {
         $msg = $error . '<br />';
     }
     $json['msg'] = $msg;
     if ($id) {
         $json['product_id'] = $id;
         $json['ok'] = 1;
     } else {
         $json['ok'] = 0;
     }
     echo json_encode($json);
     jExit();
 }
예제 #12
0
파일: product.php 프로젝트: lenard112/cms
 function saveJS()
 {
     vRequest::vmCheckToken();
     $model = VmModel::getModel($this->_cname);
     $data = vRequest::getRequest();
     $id = $model->store($data);
     $errors = $model->getErrors();
     if (empty($errors)) {
         $msg = vmText::sprintf('COM_VIRTUEMART_STRING_SAVED', $this->mainLangKey);
         $type = 'message';
     } else {
         $type = 'error';
     }
     foreach ($errors as $error) {
         $msg = $error . '<br />';
     }
     $json['msg'] = $msg;
     if ($id) {
         $json['product_id'] = $id;
         $json['ok'] = 1;
     } else {
         $json['ok'] = 0;
     }
     echo json_encode($json);
     jExit();
 }
예제 #13
0
 /**
  * Add the product to the cart, with JS
  *
  * @author Max Milbers
  * @access public
  */
 public function addJS()
 {
     //maybe we should use $mainframe->close(); or jexit();instead of die;
     /* Load the cart helper */
     //require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
     $this->json = null;
     $cart = VirtueMartCart::getCart(false);
     if ($cart) {
         // Get a continue link */
         $virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
         if ($virtuemart_category_id) {
             $categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id;
         } else {
             $categoryLink = '';
         }
         $continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink);
         $virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
         $errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED');
         if ($cart->add($virtuemart_product_ids, $errorMsg)) {
             $this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
             $this->json->msg .= '<a class="showcart floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart") . '">' . JText::_('COM_VIRTUEMART_CART_SHOW_MODAL') . '</a>';
             if ($errorMsg) {
                 $this->json->msg .= '<div>' . $errorMsg . '</div>';
             }
             $this->json->stat = '1';
         } else {
             // $this->json->msg = '<p>' . $cart->getError() . '</p>';
             $this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
             $this->json->msg .= '<div>' . $errorMsg . '</div>';
             $this->json->stat = '2';
         }
     } else {
         $this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart') . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
         $this->json->msg .= '<p>' . JText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
         $this->json->stat = '0';
     }
     echo json_encode($this->json);
     jExit();
 }
예제 #14
0
 /**
  * Paste the table  in json format
  *
  */
 public function paste()
 {
     // TODO Test user ?
     $json = array();
     $json['fields'] = 'error';
     $json['msg'] = 'Invalid Token';
     $json['structure'] = 'empty';
     if (!vRequest::vmCheckToken(-1)) {
         echo json_encode($json);
         jexit();
     }
     $lang = vRequest::getvar('lg');
     $langs = VmConfig::get('active_languages', array());
     $language = JFactory::getLanguage();
     if (!in_array($lang, $langs)) {
         $json['msg'] = 'Invalid language ! ' . $lang;
         $json['langs'] = $langs;
         echo json_encode($json);
         jexit();
     }
     $lang = strtolower($lang);
     // Remove tag if defaut or
     // if ($language->getDefault() == $lang ) $dblang ='';
     $dblang = strtr($lang, '-', '_');
     VmConfig::$vmlang = $dblang;
     $id = vRequest::getInt('id', 0);
     $viewKey = vRequest::getCmd('editView');
     // TODO temp trick for vendor
     if ($viewKey == 'vendor') {
         $id = 1;
     }
     $tables = array('category' => 'categories', 'product' => 'products', 'manufacturer' => 'manufacturers', 'manufacturercategories' => 'manufacturercategories', 'vendor' => 'vendors', 'paymentmethod' => 'paymentmethods', 'shipmentmethod' => 'shipmentmethods');
     if (!array_key_exists($viewKey, $tables)) {
         $json['msg'] = "Invalid view " . $viewKey;
         echo json_encode($json);
         jExit();
     }
     $tableName = '#__virtuemart_' . $tables[$viewKey] . '_' . $dblang;
     $db = JFactory::getDBO();
     $q = 'select * FROM `' . $tableName . '` where `virtuemart_' . $viewKey . '_id` =' . $id;
     $db->setQuery($q);
     $m = VmModel::getModel('coupon');
     $table = $m->getTable($tables[$viewKey]);
     $table->load($id);
     $json['fields'] = $table->loadFieldValues();
     //if ($json['fields'] = $db->loadAssoc()) {
     if ($table->getLoaded()) {
         $json['structure'] = 'filled';
         $json['msg'] = vmText::_('COM_VIRTUEMART_SELECTED_LANG') . ':' . $lang;
     } else {
         $json['structure'] = 'empty';
         $db->setQuery('SHOW COLUMNS FROM ' . $tableName);
         $tableDescribe = $db->loadAssocList();
         array_shift($tableDescribe);
         $fields = array();
         foreach ($tableDescribe as $key => $val) {
             $fields[$val['Field']] = $val['Field'];
         }
         $json['fields'] = $fields;
         $json['msg'] = vmText::sprintf('COM_VIRTUEMART_LANG_IS_EMPTY', $lang, vmText::_('COM_VIRTUEMART_' . strtoupper($viewKey)));
     }
     echo json_encode($json);
     jExit();
 }
예제 #15
0
 * This file is executed during install/upgrade and uninstall
 *
 * @author Patrick Kohl, Max Milbers, Valérie Isaksen
 * @package VirtueMart
 */
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
//Update Tables
if (!class_exists('tsmConfig')) {
    if (file_exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php')) {
        require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
    } else {
        jExit('Install the tsmart Core first ');
    }
}
if (!method_exists('vRequest', 'vmSpecialChars')) {
    jExit('Install the tsmart Core first ');
}
$max_execution_time = ini_get('max_execution_time');
if ((int) $max_execution_time < 120) {
    @ini_set('max_execution_time', '120');
}
$memory_limit = (int) substr(ini_get('memory_limit'), 0, -1);
if ($memory_limit < 128) {
    @ini_set('memory_limit', '128M');
}
// hack to prevent defining these twice in 1.6 installation
if (!defined('_VM_AIO_SCRIPT_INCLUDED')) {
    define('_VM_AIO_SCRIPT_INCLUDED', TRUE);
    class com_virtuemart_allinoneInstallerScript
    {
        public function preflight()
예제 #16
0
 public function keepalive()
 {
     jExit();
 }
예제 #17
0
 * This file is executed during install/upgrade and uninstall
 *
 * @author Patrick Kohl, Max Milbers, Valérie Isaksen
 * @package VirtueMart
 */
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
//Update Tables
if (!class_exists('VmConfig')) {
    if (file_exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php')) {
        require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
    } else {
        jExit('Install the virtuemart Core first ');
    }
}
if (!method_exists('vRequest', 'vmSpecialChars')) {
    jExit('Install the virtuemart Core first ');
}
$max_execution_time = ini_get('max_execution_time');
if ((int) $max_execution_time < 120) {
    @ini_set('max_execution_time', '120');
}
$memory_limit = (int) substr(ini_get('memory_limit'), 0, -1);
if ($memory_limit < 128) {
    @ini_set('memory_limit', '128M');
}
// hack to prevent defining these twice in 1.6 installation
if (!defined('_VM_AIO_SCRIPT_INCLUDED')) {
    define('_VM_AIO_SCRIPT_INCLUDED', TRUE);
    class com_virtuemart_allinoneInstallerScript
    {
        public function preflight()
예제 #18
0
	function plgVmOnSelfCallFE ($type, $name, &$render) {
		if ($name != $this->_name || $type != 'vmpayment') {
			return FALSE;
		}
		$action = vRequest::getCmd('action');
		$virtuemart_paymentmethod_id = vRequest::getInt('virtuemart_paymentmethod_id');
		//Load the method
		if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}

		if (!class_exists('VirtueMartCart')) {
			require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
		}
		switch ($action) {

			case 'updateCartWithAmazonAddress':
				//$client = $this->getOffAmazonPaymentsService_Client();
				//$this->setOrderReferenceDetails()
				$return = $this->updateCartWithAmazonAddress();
				$json = array();
				$json['reload'] = $return['error'];
				$json['error_msg'] = '';
				if (isset($return['error_msg'])) {
					$json['error_msg'] = $this->rendererErrorMessage($return['error_msg']);
				}


				JResponse::setHeader('Cache-Control', 'no-cache, must-revalidate');
				JResponse::setHeader('Expires', 'Mon, 6 Jul 2000 10:00:00 GMT');
				// Set the MIME type for JSON output.
				$document = JFactory::getDocument();
				$document->setMimeEncoding('application/json');
				JResponse::setHeader('Content-Disposition', 'attachment;filename="amazon.json"', TRUE);
				JResponse::sendHeaders();

				echo json_encode($json);
				jExit();
				//JFactory::getApplication()->close();
				break;


			case 'leaveAmazonCheckout':
				$this->leaveAmazonCheckout();
				$json = array();
				JResponse::setHeader('Cache-Control', 'no-cache, must-revalidate');
				JResponse::setHeader('Expires', 'Mon, 6 Jul 2000 10:00:00 GMT');
				// Set the MIME type for JSON output.
				$document = JFactory::getDocument();
				$document->setMimeEncoding('application/json');
				JResponse::setHeader('Content-Disposition', 'attachment;filename="amazon.json"', TRUE);
				JResponse::sendHeaders();

				echo json_encode($json);
				jExit();
				break;

			case 'resetAmazonReferenceId':
				$this->clearAmazonSession();
				break;
			case 'onInvalidPaymentNewAuthorization':
				$this->onInvalidPaymentNewAuthorization();
				break;
			default:
				$this->amazonError(vmText::_('VMPAYMENT_AMAZON_INVALID_NOTIFICATION_TASK'));
				return;
		}

	}
예제 #19
0
 /**
  * Add the product to the cart, with JS
  * @access public
  */
 public function addJS()
 {
     $this->json = new stdClass();
     $cart = VirtueMartCart::getCart(false);
     if ($cart) {
         $view = $this->getView('cart', 'json');
         $virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
         $categoryLink = '';
         if ($virtuemart_category_id) {
             $categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id;
         }
         $continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink);
         $virtuemart_product_ids = vRequest::getInt('virtuemart_product_id');
         $view = $this->getView('cart', 'json');
         $errorMsg = 0;
         $products = $cart->add($virtuemart_product_ids, $errorMsg);
         $view->setLayout('padded');
         $this->json->stat = '1';
         if (!$products or count($products) == 0) {
             $view->setLayout('perror');
             $this->json->stat = '2';
         }
         $view->assignRef('products', $products);
         $view->assignRef('errorMsg', $errorMsg);
         ob_start();
         $view->display();
         $this->json->msg = ob_get_clean();
     } else {
         $this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart', FALSE) . '" >' . vmText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
         $this->json->msg .= '<p>' . vmText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
         $this->json->stat = '0';
     }
     echo json_encode($this->json);
     jExit();
 }
예제 #20
0
파일: cart.php 프로젝트: sergy444/joomla
 /**
  * Add the product to the cart, with JS
  *
  * @author Max Milbers
  * @access public
  */
 public function addJS()
 {
     $this->json = new stdClass();
     $cart = VirtueMartCart::getCart(false);
     if ($cart) {
         $virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
         $view = $this->getView('cart', 'json');
         $errorMsg = 0;
         //JText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED');
         $products = $cart->add($virtuemart_product_ids, $errorMsg);
         if ($products) {
             if (is_array($products) and isset($products[0])) {
                 $view->assignRef('product', $products[0]);
             }
             $view->setLayout('padded');
             $this->json->stat = '1';
         } else {
             $view->setLayout('perror');
             $this->json->stat = '2';
             $tmp = false;
             $view->assignRef('product', $tmp);
         }
         $view->assignRef('products', $products);
         $view->assignRef('errorMsg', $errorMsg);
         ob_start();
         $view->display();
         $this->json->msg = ob_get_clean();
     } else {
         $this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart', FALSE) . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
         $this->json->msg .= '<p>' . JText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
         $this->json->stat = '0';
     }
     echo json_encode($this->json);
     jExit();
 }
예제 #21
0
파일: contact.php 프로젝트: joebushi/joomla
 /**
  * Method to cancel an edit
  *
  * Checks the item in, sets item ID in the session to null, and then redirects to the list page.
  */
 function cancel()
 {
     JRequest::checkToken() or jExit(JText::_('JInvalid_Token'));
     // Initialise variables.
     $app =& JFactory::getApplication();
     // Get the previous  id (if any) and the current  id.
     $previousId = (int) $app->getUserState('com_contact.edit.contact.id');
     // Get the  item model.
     $model =& $this->getModel();
     // If rows ids do not match, checkin previous row.
     if (!$model->checkin($previousId)) {
         // Attempt to check-in the current contact
         // Check-in failed, go back to the  item and display a notice.
         $message = JText::sprintf('JError_Checkin_failed', $model->getError());
         return false;
     }
     // Clear the  item edit information from the session.
     $app->setUserState('com_contact.edit.contact.id', null);
     $app->setUserState('com_contact.edit.contact.data', null);
     // Redirect to the list screen.
     $this->setRedirect(JRoute::_('index.php?option=com_contact&view=contacts', false));
 }
예제 #22
0
 function saveJS()
 {
     vRequest::vmCheckToken();
     $model = tmsModel::getModel($this->_cname);
     $data = vRequest::getRequest();
     $id = $model->store($data);
     $msg = 'failed';
     if (!empty($id)) {
         $msg = tsmText::sprintf('com_tsmart_STRING_SAVED', $this->mainLangKey);
         $type = 'message';
     } else {
         $type = 'error';
     }
     $json['msg'] = $msg;
     if ($id) {
         $json['product_id'] = $id;
         $json['ok'] = 1;
     } else {
         $json['ok'] = 0;
     }
     echo vmJsApi::safe_json_encode($json);
     jExit();
 }
예제 #23
0
 /**
  * Checks for the data that is needed to process the order
  *
  * @author Valérie Isaksen
  *
  */
 public function checkoutJS()
 {
     $json = new stdClass();
     $cart = VirtueMartCart::getCart();
     $cart->getFilterCustomerComment();
     $cart->tosAccepted = JRequest::getInt('tosAccepted', $cart->tosAccepted);
     $task = JRequest::getString('task');
     $setShipment = "";
     $setPayment = "";
     $checkout = "";
     $view = $this->getView('cart', 'html');
     $update = vRequest::getString('update', false);
     $cart->_inConfirm = false;
     if ($update and is_array($update) or $task == 'update') {
         reset($update);
         $key = key($update);
         $quantity = vRequest::getInt('quantity');
         $cart->updateProductCart(key($update), $quantity[$key]);
         //$this->display();
     } else {
         if (isset($_POST['setcoupon']) or $task == 'setcoupon') {
             $this->setcoupon();
         } else {
             if (isset($_POST['setshipment']) or $task == 'setshipment') {
                 $this->setshipment();
             } else {
                 if (isset($_POST['setpayment']) or $task == 'setpayment') {
                     $this->setpayment();
                 } else {
                     if (VmConfig::get('oncheckout_opc', 1) && JRequest::getInt('virtuemart_shipmentmethod_id', false) && $cart->virtuemart_shipmentmethod_id != JRequest::getInt('virtuemart_shipmentmethod_id')) {
                         $setShipment = $this->setshipment(false);
                     }
                     if (VmConfig::get('oncheckout_opc', 1) && JRequest::getInt('virtuemart_paymentmethod_id', false) && $cart->virtuemart_paymentmethod_id != JRequest::getInt('virtuemart_paymentmethod_id')) {
                         $setPayment = $this->setpayment(false);
                     }
                     if ($cart && !VmConfig::get('use_as_catalog', 0)) {
                         $checkout = $cart->checkout(false);
                     }
                 }
             }
         }
     }
     ob_start();
     $view->display();
     $json->msg = ob_get_clean();
     echo json_encode($json);
     jExit();
 }
예제 #24
0
 public function keepalive()
 {
     //echo 'alive';
     jExit();
 }
 /**
  * Paste the table  in json format
  *
  */
 public function paste()
 {
     // TODO Test user ?
     $json = array();
     $json['fields'] = 'error';
     $json['msg'] = 'Invalid Token';
     $json['structure'] = 'empty';
     if (!JSession::checkToken('get')) {
         echo json_encode($json);
         jexit();
     }
     $lang = JRequest::getvar('lg');
     $langs = VmConfig::get('active_languages', array());
     $language = JFactory::getLanguage();
     if (!in_array($lang, $langs)) {
         $json['msg'] = 'Invalid language ! ' . $lang;
         $json['langs'] = $langs;
         echo json_encode($json);
         jexit();
     }
     $lang = strtolower($lang);
     // Remove tag if defaut or
     // if ($language->getDefault() == $lang ) $dblang ='';
     $dblang = strtr($lang, '-', '_');
     $id = JRequest::getInt('id', 0);
     $viewKey = JRequest::getWord('editView');
     // we have here 2 access user & vendor give same results
     if ($viewKey == 'user') {
         $viewKey = 'vendor';
     }
     // Not needed , vendor is checked in constructor
     //if ($viewKey == 'vendor') $id = 1 ;
     $tables = array('category' => 'categories', 'product' => 'products', 'manufacturer' => 'manufacturers', 'manufacturercategories' => 'manufacturercategories', 'vendor' => 'vendors', 'paymentmethod' => 'paymentmethods', 'shipmentmethod' => 'shipmentmethods');
     if (!isset($tables[$viewKey])) {
         $json['msg'] = "Invalid view " . $viewKey;
         echo json_encode($json);
         jExit();
     }
     $tableName = '#__virtuemart_' . $tables[$viewKey] . '_' . $dblang;
     $db = JFactory::getDBO();
     $q = 'select * FROM `' . $tableName . '` where `virtuemart_' . $viewKey . '_id` =' . $id;
     $db->setQuery($q);
     if ($json['fields'] = $db->loadAssoc()) {
         $json['structure'] = 'filled';
         $json['msg'] = jText::_('COM_VIRTUEMART_SELECTED_LANG') . ':' . $lang;
     } else {
         $json['structure'] = 'empty';
         $db->setQuery('SHOW COLUMNS FROM ' . $tableName);
         $tableDescribe = $db->loadAssocList();
         array_shift($tableDescribe);
         $fields = array();
         foreach ($tableDescribe as $key => $val) {
             $fields[$val['Field']] = $val['Field'];
         }
         $json['fields'] = $fields;
         $json['msg'] = JText::sprintf('COM_VIRTUEMART_LANG_IS_EMPTY', $lang, jText::_('COM_VIRTUEMART_' . strtoupper($viewKey)));
     }
     echo json_encode($json);
     jExit();
 }