コード例 #1
0
ファイル: post24.php プロジェクト: jflash/moodulid25
 function getOrderShipmentHtml($virtuemart_order_id)
 {
     $db = JFactory::getDBO();
     $q = 'SELECT * FROM `' . $this->_tablename . '` ' . 'WHERE `virtuemart_order_id` = ' . $virtuemart_order_id;
     $db->setQuery($q);
     if (!($method = $db->loadObject())) {
         vmWarn(500, $q . " " . $db->getErrorMsg());
         return '';
     }
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance();
     $tax = ShopFunctions::getTaxByID($method->tax_id);
     $taxDisplay = is_array($tax) ? $tax['calc_value'] . ' ' . $tax['calc_value_mathop'] : $method->tax_id;
     $taxDisplay = $taxDisplay == -1 ? JText::_('COM_VIRTUEMART_PRODUCT_TAX_NONE') : $taxDisplay;
     //geting selected parcel
     $parcels = $this->_quote();
     $title = $parcels[$method->selected_parcel]['title'];
     $html = '<table class="adminlist">' . "\n";
     $html .= $this->getHtmlHeaderBE();
     $html .= $this->getHtmlRowBE('POST24_SM', 'Omniva');
     $html .= $this->getHtmlRowBE('POST24_SELECTED_PARCEL', $title);
     $html .= $this->getHtmlRowBE('POST24_TOPHONE', $method->phone);
     $html .= '</table>' . "\n";
     return $html;
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: cuongnd/etravelservice
 function display($tpl = null)
 {
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $this->SetViewTitle();
     $model = tmsModel::getModel();
     $this->state = $model->getItem();
     $this->tsmart_country_id = vRequest::getInt('tsmart_country_id', $this->state->tsmart_country_id);
     $isNew = count($this->state) < 1;
     if (empty($countryId) && $isNew) {
         vmWarn('Country id is 0');
         return false;
     }
     $country = tmsModel::getModel('country');
     $country->setId($this->tsmart_country_id);
     $this->country_name = $country->getData()->country_name;
     $layoutName = vRequest::getCmd('layout', 'default');
     if ($layoutName == 'edit') {
         $zoneModel = tmsModel::getModel('Worldzones');
         $this->worldZones = $zoneModel->getWorldZonesSelectList();
         $this->addStandardEditViewCommands();
     } else {
         //get list country
         require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php';
         $list_country = tsmcountries::get_countries();
         $this->assignRef('list_country', $list_country);
         //end get list country
         $this->addStandardDefaultViewCommandsEditInline();
         $this->addStandardDefaultViewLists($model);
         $this->items = $model->getItemList();
         $this->pagination = $model->getPagination();
     }
     parent::display($tpl);
 }
コード例 #3
0
 function display($tpl = null)
 {
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $this->SetViewTitle();
     $model = VmModel::getModel();
     $this->state = $model->getSingleState();
     $this->virtuemart_country_id = vRequest::getInt('virtuemart_country_id', $this->state->virtuemart_country_id);
     $isNew = count($this->state) < 1;
     if (empty($countryId) && $isNew) {
         vmWarn('Country id is 0');
         return false;
     }
     $country = VmModel::getModel('country');
     $country->setId($this->virtuemart_country_id);
     $this->country_name = $country->getData()->country_name;
     $layoutName = vRequest::getCmd('layout', 'default');
     if ($layoutName == 'edit') {
         $zoneModel = VmModel::getModel('Worldzones');
         $this->worldZones = $zoneModel->getWorldZonesSelectList();
         $this->addStandardEditViewCommands();
     } else {
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model);
         $this->states = $model->getStates($this->virtuemart_country_id);
         $this->pagination = $model->getPagination();
     }
     parent::display($tpl);
 }
コード例 #4
0
ファイル: view.html.php プロジェクト: kosmosby/medicine-prof
	function display($tpl = null) {

		// Load the helper(s)


		if (!class_exists('VmHTML'))
			require(VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php');

		$this->SetViewTitle();


		$model = VmModel::getModel();

//		$stateId = vRequest::getVar('virtuemart_state_id');
//		$model->setId($stateId);
		$state = $model->getSingleState();

		$countryId = vRequest::getInt('virtuemart_country_id', 0);
		if(empty($countryId)) $countryId = $state->virtuemart_country_id;
		$this->assignRef('virtuemart_country_id',	$countryId);

        $isNew = (count($state) < 1);

		if(empty($countryId) && $isNew){
			vmWarn('Country id is 0');
			return false;
		}

		$country = VmModel::getModel('country');
		$country->setId($countryId);
		$this->assignRef('country_name', $country->getData()->country_name);


		$layoutName = vRequest::getCmd('layout', 'default');
		if ($layoutName == 'edit') {


			$this->assignRef('state', $state);

			$zoneModel = VmModel::getModel('Worldzones');
			$wzsList = $zoneModel->getWorldZonesSelectList();
			$this->assignRef('worldZones', $wzsList);

			$this->addStandardEditViewCommands();

		} else {

			$this->addStandardDefaultViewCommands();
			$this->addStandardDefaultViewLists($model);

			$states = $model->getStates($countryId);
			$this->assignRef('states',	$states);

			$pagination = $model->getPagination();
			$this->assignRef('pagination', $pagination);

		}

		parent::display($tpl);
	}
コード例 #5
0
 function remove($ids)
 {
     if (!vmAccess::manager('paymentsetting')) {
         vmWarn('Insufficient permissions to remove paymentsetting');
         return false;
     }
     return parent::remove($ids);
 }
コード例 #6
0
ファイル: general.php プロジェクト: cuongnd/etravelservice
 function remove($ids)
 {
     if (!vmAccess::manager('general')) {
         vmWarn('Insufficient permissions to remove general');
         return false;
     }
     return parent::remove($ids);
 }
コード例 #7
0
 function store(&$data)
 {
     if (!vmAccess::manager('manufacturercategories')) {
         vmWarn('Insufficient permissions to store manufacturer category');
         return false;
     }
     return parent::store($data);
 }
コード例 #8
0
ファイル: userinfos.php プロジェクト: juanmcortez/Lectorum
 /**
  * Validates the user info record fields.
  *
  * @author RickG, RolandD, Max Milbers
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 public function check()
 {
     if ($this->address_type == 'BT' or $this->address_type == 'ST') {
         if ($this->address_type == 'ST' and empty($this->address_type_name)) {
             $this->address_type_name = 'Delivery Address ' . rand(1, 9);
             vmWarn('Table userinfos check failed: address_type ' . $this->address_type . ' without name, autogenerated ' . $this->address_type_name, 'check failed: ST has no name, autogenerated ' . $this->address_type_name);
             //return false;
         }
     } else {
         vmError('Table userinfos check failed: Unknown address_type ' . $this->address_type, 'check failed: Unknown address_type ');
         vmdebug('Table userinfos check failed: Unknown address_type ' . $this->address_type . ' virtuemart_user_id ' . $this->virtuemart_user_id . ' name ' . $this->name);
         return false;
     }
     if (!empty($this->virtuemart_userinfo_id)) {
         $this->virtuemart_userinfo_id = (int) $this->virtuemart_userinfo_id;
         if (!class_exists('Permissions')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
         }
         if (!Permissions::getInstance()->check("admin")) {
             $q = "SELECT virtuemart_user_id\n\t\t\t\t\t\t\t\t\t\tFROM #__virtuemart_userinfos\n\t\t\t\t\t\t\t\t\t\tWHERE virtuemart_userinfo_id = " . $this->virtuemart_userinfo_id;
             $this->_db->setQuery($q);
             $total = $this->_db->loadResultArray();
             if (count($total) > 0) {
                 $userId = JFactory::getUser()->id;
                 if ($total[0] != $userId) {
                     vmError('Hacking attempt uid check, you got logged');
                     echo 'Hacking attempt uid check, you got logged';
                     return false;
                 }
             }
         }
         //return parent::check();
     } else {
         if (empty($this->address_type)) {
             $this->address_type = 'BT';
         }
         /* Check if a record exists */
         $q = "SELECT virtuemart_userinfo_id\n\t\t\tFROM #__virtuemart_userinfos\n\t\t\tWHERE virtuemart_user_id = " . $this->virtuemart_user_id . "\n\t\t\tAND address_type = " . $this->_db->Quote($this->address_type);
         if ($this->address_type != 'BT') {
             $q .= " AND address_type_name = " . $this->_db->Quote($this->address_type_name);
         }
         $this->_db->setQuery($q);
         $total = $this->_db->loadResultArray();
         if (count($total) > 0) {
             $this->virtuemart_userinfo_id = (int) $total[0];
         } else {
             $this->virtuemart_userinfo_id = 0;
             //md5(uniqid($this->virtuemart_user_id));
         }
     }
     if (empty($this->virtuemart_user_id)) {
         $user = JFactory::getUser();
         if (!empty($user->id)) {
             $this->virtuemart_user_id = $user->id;
         }
     }
     return parent::check();
 }
コード例 #9
0
ファイル: userinfos.php プロジェクト: lenard112/cms
 /**
  * Validates the user info record fields.
  *
  * @author RickG, RolandD, Max Milbers
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 public function check()
 {
     if ($this->address_type == 'BT' or $this->address_type == 'ST') {
         if ($this->address_type == 'ST' and empty($this->address_type_name)) {
             $this->address_type_name = 'Delivery Address ' . rand(1, 9);
             vmWarn('Table userinfos check failed: address_type ' . $this->address_type . ' without name, autogenerated ' . $this->address_type_name, 'check failed: ST has no name, autogenerated ' . $this->address_type_name);
         }
     } else {
         vmError('Table userinfos check failed: Unknown address_type ' . $this->address_type, 'check failed: Unknown address_type ');
         vmdebug('Table userinfos check failed: Unknown address_type ' . $this->address_type . ' virtuemart_user_id ' . $this->virtuemart_user_id . ' name ' . $this->name);
         return false;
     }
     if (!empty($this->virtuemart_userinfo_id)) {
         $this->virtuemart_userinfo_id = (int) $this->virtuemart_userinfo_id;
         $user = JFactory::getUser();
         if (!$user->authorise('core.admin', 'com_virtuemart')) {
             $q = "SELECT virtuemart_user_id\n\t\t\t\t\t\t\t\t\t\tFROM #__virtuemart_userinfos\n\t\t\t\t\t\t\t\t\t\tWHERE virtuemart_userinfo_id = " . $this->virtuemart_userinfo_id;
             $this->_db->setQuery($q);
             $total = $this->_db->loadColumn();
             if (count($total) > 0) {
                 $userId = JFactory::getUser()->id;
                 if ($total[0] != $userId) {
                     vmError('Hacking attempt uid check, you got logged');
                     echo 'Hacking attempt uid check, you got logged';
                     return false;
                 }
             }
         }
         //return parent::check();
     } else {
         if (empty($this->address_type)) {
             $this->address_type = 'BT';
         }
         /* Check if a record exists */
         $q = "SELECT virtuemart_userinfo_id\n\t\t\tFROM #__virtuemart_userinfos\n\t\t\tWHERE virtuemart_user_id = " . $this->virtuemart_user_id . "\n\t\t\tAND address_type = " . $this->_db->Quote($this->address_type);
         if ($this->address_type != 'BT') {
             $q .= " AND address_type_name = " . $this->_db->Quote($this->address_type_name);
         }
         $this->_db->setQuery($q);
         $total = $this->_db->loadColumn();
         if (count($total) > 0) {
             $this->virtuemart_userinfo_id = (int) $total[0];
         } else {
             $this->virtuemart_userinfo_id = 0;
             //md5(uniqid($this->virtuemart_user_id));
         }
     }
     if (empty($this->virtuemart_user_id)) {
         $user = JFactory::getUser();
         if (!empty($user->id)) {
             $this->virtuemart_user_id = $user->id;
         }
     }
     return parent::check();
 }
コード例 #10
0
ファイル: maksekeskus.php プロジェクト: jflash/moodulid25
 function plgVmOnShowOrderBEPayment($virtuemart_order_id, $virtuemart_payment_id)
 {
     if (!$this->selectedThisByMethodId($virtuemart_payment_id)) {
         return null;
         // Another method was selected, do nothing
     }
     $db = JFactory::getDBO();
     $q = 'SELECT * FROM `' . $this->_tablename . '` ' . 'WHERE `virtuemart_order_id` = ' . $virtuemart_order_id;
     $db->setQuery($q);
     if (!($paymentTable = $db->loadObject())) {
         vmWarn(500, $q . " " . $db->getErrorMsg());
         return '';
     }
     $this->getPaymentCurrency($paymentTable);
     $html = '<table class="adminlist">' . "\n";
     $html .= $this->getHtmlHeaderBE();
     $html .= $this->getHtmlRowBE('MAKSEKESKUS_PAYMENT_NAME', $paymentTable->payment_name);
     $html .= '</table>' . "\n";
     return $html;
 }
コード例 #11
0
ファイル: inventory.php プロジェクト: cuongnd/etravelservice
    /**
     * Select the products to list on the product list page
     * @author Max Milbers
     */
    public function getInventory()
    {
        if (!vmAccess::manager('inventory')) {
            vmWarn('Insufficient permissions to remove shipmentmethod');
            return false;
        }
        $select = ' `#__tsmart_products`.`tsmart_product_id`,
     				`#__tsmart_products`.`product_parent_id`,
     				`product_name`,
     				`product_sku`,
     				`product_in_stock`,
     				`product_weight`,
     				`published`,
     				`product_price`';
        $joinedTables = 'FROM `#__tsmart_products`
			LEFT JOIN `#__tsmart_product_prices`
			ON `#__tsmart_products`.`tsmart_product_id` = `#__tsmart_product_prices`.`tsmart_product_id`
			LEFT JOIN `#__tsmart_shoppergroups`
			ON `#__tsmart_product_prices`.`tsmart_shoppergroup_id` = `#__tsmart_shoppergroups`.`tsmart_shoppergroup_id`';
        return $this->_data = $this->exeSortSearchListQuery(0, $select, $joinedTables, $this->getInventoryFilter(), '', $this->_getOrdering());
    }
コード例 #12
0
ファイル: klarna.php プロジェクト: joselapria/virtuemart
 function checkCountryCondition($method, $country_code, $cart)
 {
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $active_country = "klarna_active_" . strtolower($country_code);
     if (!isset($method->{$active_country}) or !$method->{$active_country}) {
         return false;
     }
     if (empty($country_code)) {
         $msg = JText::_('VMPAYMENT_KLARNA_GET_SWEDISH_ADDRESS');
         $country_code = "swe";
         vmWarn($msg);
         //return false;
     }
     // convert price in euro
     //$euro_currency_id = ShopFunctions::getCurrencyByName( 'EUR');
     $price = KlarnaHandler::convertPrice($cart->pricesUnformatted['salesPrice'], 'EUR');
     if (strtolower($country_code) == 'nld' && $price > 250) {
         // We can't show our payment options for Dutch customers
         // if price exceeds 250 euro. Will be replaced with ILT in
         // the future.
         return false;
     }
     // Get the country settings
     if (!class_exists('KlarnaHandler')) {
         require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnahandler.php';
     }
     $cData = KlarnaHandler::getCountryData($method, $country_code);
     if ($cData['eid'] == '' || $cData['eid'] == 0) {
         return false;
     }
     return $cData;
 }
コード例 #13
0
ファイル: router.php プロジェクト: Roma48/abazherka_old
 private function setMenuItemId()
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu('site');
     $component = JComponentHelper::getComponent('com_virtuemart');
     $items = $menus->getItems('componentid', $component->id);
     if (empty($items)) {
         VmConfig::loadJLang('com_virtuemart', true);
         vmWarn(JText::_('COM_VIRTUEMART_ASSIGN_VM_TO_MENU'));
     } else {
         // Search  Virtuemart itemID in joomla menu
         foreach ($items as $item) {
             $view = $item->query['view'];
             if ($view == 'virtuemart') {
                 $this->menu['virtuemart'] = $item->id;
             }
             $dbKey = $this->dbview[$view];
             if (isset($item->query['virtuemart_' . $dbKey . '_id'])) {
                 $this->menu['virtuemart_' . $dbKey . '_id'][$item->query['virtuemart_' . $dbKey . '_id']] = $item->id;
             } else {
                 $this->menu[$view] = $item->id;
             }
         }
     }
     // init unsetted views  to defaut front view or nothing(prevent duplicates routes)
     if (!isset($this->menu['virtuemart'][0])) {
         $this->menu['virtuemart'][0] = null;
     }
     if (!isset($this->menu['manufacturer'])) {
         $this->menu['manufacturer'] = $this->menu['virtuemart'][0];
     }
 }
コード例 #14
0
 /**
  * Create the table for this plugin if it does not yet exist.
  * This functions checks if the called plugin is active one.
  * When yes it is calling the standard method to create the tables
  *
  */
 public function plgVmOnStoreInstallPaymentPluginTable($jplugin_id)
 {
     if ($jplugin_id != $this->_jid) {
         return FALSE;
     }
     $this->_currentMethod = $this->getPluginMethod(vRequest::getInt('virtuemart_paymentmethod_id'));
     if ($this->_currentMethod->published) {
         $required_parameters = array('merchant_id', 'shared_secret', 'subaccount');
         foreach ($required_parameters as $required_parameter) {
             if (empty($this->_currentMethod->{$required_parameter})) {
                 $text = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PARAMETER_REQUIRED', vmText::_('VMPAYMENT_REALEX_HPP_API_' . $required_parameter), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id);
                 vmWarn($text);
             }
         }
     }
     $this->createPayerRefTable();
     $this->createPmtRefTable();
     return $this->onStoreInstallPluginTable($jplugin_id);
 }
コード例 #15
0
ファイル: paypal.php プロジェクト: sergy444/joomla
	/**
	 * @param $jplugin_id
	 * @return bool|mixed
	 */
	function plgVmOnStoreInstallPaymentPluginTable($jplugin_id) {
		if ($jplugin_id != $this->_jid) {
			return FALSE;
		}
		$this->_currentMethod = $this->getPluginMethod(JRequest::getInt('virtuemart_paymentmethod_id'));
		if ($this->_currentMethod->published) {

			$sandbox = "";
			if ($this->_currentMethod->sandbox ) {
				$sandbox = 'SANDBOX_';
				$sandbox_param = 'sandbox_';
			}


			if ($this->_currentMethod->paypalproduct == 'std') {
				if ($this->_currentMethod->sandbox  ) {
					$param = 'sandbox_merchant_email';
				} else {
					$param = 'paypal_merchant_email';
				}
				if (empty ($this->_currentMethod->$param)) {
					$text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'MERCHANT'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id);
					vmWarn($text);
				}
			}
			if ($this->_currentMethod->paypalproduct == 'exp' OR $this->_currentMethod->paypalproduct == 'hosted' OR $this->_currentMethod->paypalproduct == 'api') {
				$param = $sandbox_param . 'api_login_id';
				if (empty ($this->_currentMethod->$param)) {
					$text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'USERNAME'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id);
					vmWarn($text);
				}
				$param = $sandbox_param . 'api_password';
				if (empty ($this->_currentMethod->$param)) {
					$text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'PASSWORD'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id);
					vmWarn($text);
				}

				if ($this->_currentMethod->authentication == 'signature') {
					$param = $sandbox_param . 'api_signature';
					if (empty ($this->_currentMethod->$param)) {
						$text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'SIGNATURE'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id);
						vmWarn($text);
					}
				} else {
					$param = $sandbox_param . 'api_certificate';
					if (empty ($this->_currentMethod->$param)) {
						$text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'CERTIFICATE'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id);
						vmWarn($text);
					}
				}
			}
			if ($this->_currentMethod->paypalproduct == 'hosted') {
				$param = $sandbox_param . 'payflow_partner';
				if (empty ($this->_currentMethod->$param)) {
					$text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'PAYFLOW_PARTNER'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id);
					vmWarn($text);
				}
			}
			if ($this->_currentMethod->paypalproduct == 'exp' AND empty ($this->_currentMethod->expected_maxamount)) {
				$text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_EXPECTEDMAXAMOUNT'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id);
				vmWarn($text);
			}
			
		}

		return $this->onStoreInstallPluginTable($jplugin_id);
	}
コード例 #16
0
 /**
  * @author Max Milbers
  * @param unknown_type $tablename
  * @param unknown_type $fields
  * @param unknown_type $command
  */
 public function alterColumns($tablename, $fields, $reCreatePrimary)
 {
     $after = ' FIRST';
     $dropped = 0;
     $altered = 0;
     $added = 0;
     $this->_app = JFactory::getApplication();
     $demandFieldNames = array();
     foreach ($fields as $i => $line) {
         $demandFieldNames[] = $i;
     }
     $query = 'SHOW FULL COLUMNS  FROM `' . $tablename . '` ';
     //$q = 'SHOW CREATE TABLE '.$this->_tbl;
     $this->_db->setQuery($query);
     $fullColumns = $this->_db->loadObjectList();
     $columns = $this->_db->loadColumn(0);
     //vmdebug('alterColumns',$fullColumns);
     //Attention user_infos is not in here, because it an contain customised fields. #__virtuemart_order_userinfos #__virtuemart_userinfos
     //This is currently not working as intended, because the config is not deleted before, it is better to create an extra command for this, when we need it later
     $upDelCols = (int) VmConfig::get('updelcols', 0);
     if ($upDelCols == 1 and !($tablename == $this->_prefix . 'virtuemart_userfields' or $tablename == $this->_prefix . 'virtuemart_userinfos' or $tablename == $this->_prefix . 'virtuemart_order_userinfos')) {
         foreach ($columns as $fieldname) {
             if (!in_array($fieldname, $demandFieldNames)) {
                 $query = 'ALTER TABLE `' . $tablename . '` DROP COLUMN `' . $fieldname . '` ';
                 $action = 'DROP';
                 $dropped++;
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->_app->enqueueMessage('alterTable ' . $action . ' ' . $tablename . '.' . $fieldname . ' :' . $this->_db->getErrorMsg());
                 }
             }
         }
     }
     foreach ($fields as $fieldname => $alterCommand) {
         if (microtime(true) - $this->starttime >= $this->maxScriptTime) {
             vmWarn('alterColumns alterKey not finished, please rise execution time and update tables again');
             return false;
         }
         $query = '';
         $action = '';
         if (empty($alterCommand)) {
             vmdebug('empty alter command ' . $fieldname);
             continue;
         }
         // we remove the auto_increment, to be free to set the primary key
         if (strpos($alterCommand, 'AUTO_INCREMENT') !== false and $reCreatePrimary) {
             $alterCommand = str_replace('AUTO_INCREMENT', '', $alterCommand);
         }
         if (in_array($fieldname, $columns)) {
             $key = array_search($fieldname, $columns);
             $oldColumn = $this->reCreateColumnByTableAttributes($fullColumns[$key]);
             //Attention, we give for a primary the auto_increment back, so we cant decide if a key is used as primary,
             //but has no auto increment, so wie alter it anytime
             if (strpos($alterCommand, 'AUTO_INCREMENT') !== false and $reCreatePrimary) {
                 $query = 'ALTER TABLE `' . $tablename . '` CHANGE COLUMN `' . $fieldname . '` `' . $fieldname . '` ' . $alterCommand;
                 $action = 'CHANGE';
                 $altered++;
                 // 					vmdebug('$fieldname just auto '.$fieldname,$alterCommand,$oldColumn);
             } else {
                 // 					while (strpos($oldColumn,'  ')){
                 // 						str_replace('  ', ' ', $oldColumn);
                 // 					}
                 while (strpos($alterCommand, '  ')) {
                     $alterCommand = str_replace('  ', ' ', trim($alterCommand));
                 }
                 // 					str_replace('  ', ' ', $alterCommand);
                 // 					$compare = strcasecmp( $oldColumn, $alterCommand);
                 // 					$compare = strcasecmp( $oldColumn, $alterCommand);
                 // 					if (!empty($compare)) {
                 $oldColumn = strtoupper($oldColumn);
                 $alterCommand = strtoupper(trim($alterCommand));
                 //	vmdebug('reCreateColumnByTableAttributes ',$fullColumns[$key]);
                 if ($oldColumn != $alterCommand) {
                     $query = 'ALTER TABLE `' . $tablename . '` CHANGE COLUMN `' . $fieldname . '` `' . $fieldname . '` ' . $alterCommand . $after;
                     $action = 'CHANGE';
                     $altered++;
                     vmdebug($tablename . ' Alter field ' . $fieldname . ' oldcolumn ', $oldColumn, $alterCommand);
                     // 						vmdebug('Alter field new column ',$fullColumns[$key]);
                     // 						vmdebug('Alter field new column '.$this->reCreateColumnByTableAttributes($fullColumns[$key])); //,$fullColumns[$key]);
                 }
             }
         } else {
             $query = 'ALTER TABLE `' . $tablename . '` ADD ' . $fieldname . ' ' . $alterCommand . ' ' . $after;
             $action = 'ADD';
             $added++;
             // 				vmdebug('$fieldname '.$fieldname);
         }
         if (!empty($query)) {
             $this->_db->setQuery($query);
             $err = $this->_db->getErrorMsg();
             if (!$this->_db->execute() or !empty($err)) {
                 vmError('alterTable ' . $action . ' ' . $tablename . '.' . $fieldname . ' : ' . $err);
             } else {
                 vmInfo('alterTable ' . $action . ' ' . $tablename . '.' . $fieldname . ' : ' . $query);
             }
         }
         $after = ' AFTER `' . $fieldname . '`';
     }
     if ($dropped != 0 or $altered != 0 or $added != 0) {
         $this->_app->enqueueMessage('Table updated: Tablename ' . $tablename . ' dropped: ' . $dropped . ' altered: ' . $altered . ' added: ' . $added);
         $err = $this->_db->getErrorMsg();
         if (!empty($err)) {
             vmError('Tableupdater updating table ' . $tablename . ' throws error ' . $err);
         }
     }
     return true;
 }
コード例 #17
0
ファイル: currencydisplay.php プロジェクト: lenard112/cms
 /**
 *
 * Gives back the format of the currency, gets $style if none is set, with the currency Id, when nothing is found it tries the vendorId.
 * When no param is set, you get the format of the mainvendor
 *
 * @author Max Milbers
 * @param int 		$currencyId Id of the currency
 * @param int 		$vendorId Id of the vendor
 * @param string 	$style The vendor_currency_display_code
 *   FORMAT:
 1: id,
 2: CurrencySymbol,
 3: NumberOfDecimalsAfterDecimalSymbol,
 4: DecimalSymbol,
 5: Thousands separator
 6: Currency symbol position with Positive values :
 7: Currency symbol position with Negative values :
 
 EXAMPLE: ||&euro;|2|,||1|8
 * @return string
 */
 public static function getInstance($currencyId = 0, $vendorId = 0)
 {
     // 		if(empty(self::$_instance) || empty(self::$_instance->_currency_id) || ($currencyId!=self::$_instance->_currency_id && !empty($currencyId)) ){
     if (empty(self::$_instance) || (!empty($currencyId) and $currencyId != self::$_instance->_currency_id)) {
         self::$_instance = new CurrencyDisplay($vendorId);
         if (empty($currencyId)) {
             if (self::$_instance->_app->isSite()) {
                 self::$_instance->_currency_id = self::$_instance->_app->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', vRequest::getInt('virtuemart_currency_id', 0));
             }
             if (empty(self::$_instance->_currency_id)) {
                 self::$_instance->_currency_id = self::$_instance->_vendorCurrency;
             }
         } else {
             self::$_instance->_currency_id = $currencyId;
         }
         $vendorM = VmModel::getModel('currency');
         $style = $vendorM->getData((int) self::$_instance->_currency_id);
         if (!empty($style)) {
             self::$_instance->setCurrencyDisplayToStyleStr($style);
         } else {
             $uri = JFactory::getURI();
             VmConfig::loadJLang('com_virtuemart');
             if (empty(self::$_instance->_currency_id)) {
                 $link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=user&task=editshop';
                 vmWarn(vmText::sprintf('COM_VIRTUEMART_CONF_WARN_NO_CURRENCY_DEFINED', '<a href="' . $link . '">' . $link . '</a>'));
             } else {
                 if (vRequest::getCmd('view') != 'currency') {
                     $link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=currency&task=edit&cid[]=' . self::$_instance->_currency_id;
                     vmWarn(vmText::sprintf('COM_VIRTUEMART_CONF_WARN_NO_FORMAT_DEFINED', '<a href="' . $link . '">' . $link . '</a>'));
                 }
             }
             //				self::$_instance->setCurrencyDisplayToStyleStr($currencyId);
             //would be nice to automatically unpublish the product/currency or so
         }
     }
     self::$_instance->setPriceArray();
     return self::$_instance;
 }
コード例 #18
0
ファイル: user.php プロジェクト: cuongnd/etravelservice
 /**
  * Bind the post data to the JUser object and the VM tables, then saves it
  * It is used to register new users
  * This function can also change already registered users, this is important when a registered user changes his email within the checkout.
  *
  * @author Max Milbers
  * @author Oscar van Eijk
  * @return boolean True is the save was successful, false otherwise.
  */
 public function store(&$data)
 {
     $message = '';
     vRequest::vmCheckToken('Invalid Token, while trying to save user');
     if (empty($data)) {
         vmError('Developer notice, no data to store for user');
         return false;
     }
     //To find out, if we have to register a new user, we take a look on the id of the usermodel object.
     //The constructor sets automatically the right id.
     $new = false;
     if (empty($this->_id) or $this->_id < 1) {
         $new = true;
         $user = new JUser();
         //thealmega http://forum.tsmart.net/index.php?topic=99755.msg393758#msg393758
     } else {
         $cUser = JFactory::getUser();
         if (!vmAccess::manager('user.edit') and $cUser->id != $this->_id) {
             vmWarn('Insufficient permission');
             return false;
         }
         $user = JFactory::getUser($this->_id);
     }
     $gid = $user->get('gid');
     // Save original gid
     // Preformat and control user datas by plugin
     JPluginHelper::importPlugin('vmuserfield');
     $dispatcher = JDispatcher::getInstance();
     $valid = true;
     $dispatcher->trigger('plgVmOnBeforeUserfieldDataSave', array(&$valid, $this->_id, &$data, $user));
     // $valid must be false if plugin detect an error
     if (!$valid) {
         return false;
     }
     // Before I used this "if($cart && !$new)"
     // This construction is necessary, because this function is used to register a new JUser, so we need all the JUser data in $data.
     // On the other hand this function is also used just for updating JUser data, like the email for the BT address. In this case the
     // name, username, password and so on is already stored in the JUser and dont need to be entered again.
     if (empty($data['email'])) {
         $email = $user->get('email');
         if (!empty($email)) {
             $data['email'] = $email;
         }
     } else {
         $data['email'] = vRequest::getEmail('email', '');
     }
     //$data['email'] = str_replace(array('\'','"',',','%','*','/','\\','?','^','`','{','}','|','~'),array(''),$data['email']);
     //This is important, when a user changes his email address from the cart,
     //that means using view user layout edit_address (which is called from the cart)
     $user->set('email', $data['email']);
     if (empty($data['name'])) {
         $name = $user->get('name');
         if (!empty($name)) {
             $data['name'] = $name;
         }
     } else {
         $data['name'] = vRequest::getWord('name', '');
     }
     $data['name'] = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $data['name']);
     if (empty($data['username'])) {
         $username = $user->get('username');
         if (!empty($username)) {
             $data['username'] = $username;
         } else {
             $data['username'] = vRequest::getWord('username', '');
         }
     }
     if (empty($data['password'])) {
         $data['password'] = vRequest::getCmd('password', '');
         if ($data['password'] != vRequest::get('password')) {
             vmError('Password contained invalid character combination.');
             return false;
         }
     }
     if (empty($data['password2'])) {
         $data['password2'] = vRequest::getCmd('password2');
         if ($data['password2'] != vRequest::get('password2')) {
             vmError('Password2 contained invalid character combination.');
             return false;
         }
     }
     if (!$new and empty($data['password2'])) {
         unset($data['password']);
         unset($data['password2']);
     }
     if (!vmAccess::manager('core')) {
         $whiteDataToBind = array();
         if (isset($data['name'])) {
             $whiteDataToBind['name'] = $data['name'];
         }
         if (isset($data['username'])) {
             $whiteDataToBind['username'] = $data['username'];
         }
         if (isset($data['email'])) {
             $whiteDataToBind['email'] = $data['email'];
         }
         if (isset($data['language'])) {
             $whiteDataToBind['language'] = $data['language'];
         }
         if (isset($data['editor'])) {
             $whiteDataToBind['editor'] = $data['editor'];
         }
         if (isset($data['password'])) {
             $whiteDataToBind['password'] = $data['password'];
         }
         if (isset($data['password2'])) {
             $whiteDataToBind['password2'] = $data['password2'];
         }
         unset($data['isRoot']);
     } else {
         $whiteDataToBind = $data;
     }
     // Bind Joomla userdata
     if (!$user->bind($whiteDataToBind)) {
         vmdebug('Couldnt bind data to joomla user');
         //array('user'=>$user,'password'=>$data['password'],'message'=>$message,'newId'=>$newId,'success'=>false);
     }
     if ($new) {
         // If user registration is not allowed, show 403 not authorized.
         // But it is possible for admins and storeadmins to save
         $usersConfig = JComponentHelper::getParams('com_users');
         $cUser = JFactory::getUser();
         if ($usersConfig->get('allowUserRegistration') == '0' and !vmAccess::manager('user')) {
             tsmConfig::loadJLang('com_tsmart');
             vmError(tsmText::_('com_tsmart_ACCESS_FORBIDDEN'));
             return;
         }
         // Initialize new usertype setting
         $newUsertype = $usersConfig->get('new_usertype');
         if (!$newUsertype) {
             $newUsertype = 2;
         }
         // Set some initial user values
         $user->set('usertype', $newUsertype);
         $user->groups[] = $newUsertype;
         $date = JFactory::getDate();
         $user->set('registerDate', $date->toSQL());
         // If user activation is turned on, we need to set the activation information
         $useractivation = $usersConfig->get('useractivation');
         $doUserActivation = false;
         if ($useractivation == '1' or $useractivation == '2') {
             $doUserActivation = true;
         }
         if ($doUserActivation) {
             jimport('joomla.user.helper');
             $user->set('activation', vRequest::getHash(JUserHelper::genRandomPassword()));
             $user->set('block', '1');
             //$user->set('lastvisitDate', '0000-00-00 00:00:00');
         }
     }
     $option = vRequest::getCmd('option');
     // If an exising superadmin gets a new group, make sure enough admins are left...
     if (!$new && $user->get('gid') != $gid && $gid == __SUPER_ADMIN_GID) {
         if ($this->getSuperAdminCount() <= 1) {
             vmError(tsmText::_('com_tsmart_USER_ERR_ONLYSUPERADMIN'));
             return false;
         }
     }
     if (isset($data['language'])) {
         $user->setParam('language', $data['language']);
     }
     // Save the JUser object
     if (!$user->save()) {
         $msg = tsmText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $user->getError());
         vmError($msg, $msg);
         return false;
     } else {
         $data['name'] = $user->get('name');
         $data['username'] = $user->get('username');
         $data['email'] = $user->get('email');
         $data['language'] = $user->get('language');
         $data['editor'] = $user->get('editor');
     }
     $newId = $user->get('id');
     $data['tsmart_user_id'] = $newId;
     //We need this in that case, because data is bound to table later
     $this->setUserId($newId);
     //Save the VM user stuff
     if (!$this->saveUserData($data) || !self::storeAddress($data)) {
         vmError('com_tsmart_NOT_ABLE_TO_SAVE_USER_DATA');
         // 			vmError(vmText::_('com_tsmart_NOT_ABLE_TO_SAVE_USERINFO_DATA'));
     } else {
         if ($new) {
             $user->userInfo = $data;
             $password = '';
             if ($usersConfig->get('sendpassword', 1)) {
                 $password = $user->password_clear;
             }
             $this->sendRegistrationEmail($user, $password, $doUserActivation);
             if ($doUserActivation) {
                 vmInfo('com_tsmart_REG_COMPLETE_ACTIVATE');
             } else {
                 vmInfo('com_tsmart_REG_COMPLETE');
                 $user->set('activation', '');
                 $user->set('block', '0');
                 $user->set('guest', '0');
             }
         } else {
             vmInfo('com_tsmart_USER_DATA_STORED');
         }
     }
     //The extra check for isset vendor_name prevents storing of the vendor if there is no form (edit address cart)
     if ((int) $data['user_is_vendor'] == 1 and isset($data['vendor_currency'])) {
         vmdebug('vendor recognised ' . $data['tsmart_vendor_id']);
         if ($this->storeVendorData($data)) {
             if ($new) {
                 if ($doUserActivation) {
                     vmInfo('com_tsmart_REG_VENDOR_COMPLETE_ACTIVATE');
                 } else {
                     vmInfo('com_tsmart_REG_VENDOR_COMPLETE');
                 }
             } else {
                 vmInfo('com_tsmart_VENDOR_DATA_STORED');
             }
         }
     }
     return array('user' => $user, 'password' => $data['password'], 'message' => $message, 'newId' => $newId, 'success' => true);
 }
コード例 #19
0
ファイル: vmplugin.php プロジェクト: cuongnd/etravelservice
 /**
  *  Note: We have 2 subfolders for versions > J15 for 3rd parties developers, to avoid 2 installers
  *	Note: from Version 2.12: it is possible to have the tmpl folder directly in $pluginName folder
  * @author Max Milbers, Valérie Isaksen
  */
 private function _getLayoutPath($pluginName, $group, $layout = 'default')
 {
     $layoutPath = $templatePathWithGroup = $defaultPathWithGroup = '';
     jimport('joomla.filesystem.file');
     // First search in the new system
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     $vmStyle = VmTemplate::loadVmTemplateStyle();
     $template = $vmStyle['template'];
     $templatePath = VMPATH_ROOT . DS . 'templates' . DS . $template . DS . 'html' . DS . $group . DS . $pluginName . DS . $layout . '.php';
     $defaultPath = VMPATH_ROOT . DS . 'plugins' . DS . $group . DS . $pluginName . DS . 'tmpl' . DS . $layout . '.php';
     $defaultPathWithGroup = VMPATH_ROOT . DS . 'plugins' . DS . $group . DS . $pluginName . DS . $pluginName . DS . 'tmpl' . DS . $layout . '.php';
     if (JFile::exists($templatePath)) {
         $layoutPath = $templatePath;
     } elseif (JFile::exists($defaultPath)) {
         $layoutPath = $defaultPath;
     } elseif (JFile::exists($defaultPathWithGroup)) {
         $layoutPath = $defaultPathWithGroup;
     }
     if (empty($layoutPath)) {
         $warn = 'The layout: ' . $layout . ' does not exist in:';
         $warn .= '<br />' . $templatePath . '<br />' . $defaultPath;
         if (!empty($defaultPathWithGroup)) {
             $warn .= '<br />' . $defaultPathWithGroup . '<br />';
         }
         vmWarn($warn);
         return false;
     }
     return $layoutPath;
 }
コード例 #20
0
ファイル: category.php プロジェクト: sam-akopyan/hamradio
 public function getCategoryRecurse($virtuemart_category_id, $catMenuId, $idsArr = true)
 {
     static $resId = array();
     if ($idsArr and !is_array($idsArr)) {
         $idsArr = array();
         $this->categoryRecursed = 0;
     } else {
         if ($this->categoryRecursed > 10) {
             vmWarn('Stopped getCategoryRecurse after 10 rekursions');
             return false;
         }
     }
     $hash = $virtuemart_category_id . 'c' . $catMenuId;
     if (isset($resId[$hash])) {
         $ids = $resId[$hash];
     } else {
         $db = JFactory::getDBO();
         $q = "SELECT `category_child_id` AS `child`, `category_parent_id` AS `parent`\n\t\t\t\tFROM  #__virtuemart_category_categories AS `xref`\n\t\t\t\tWHERE `xref`.`category_child_id`= " . (int) $virtuemart_category_id;
         $db->setQuery($q);
         $ids = $resId[$hash] = $db->loadObject();
     }
     if (isset($ids->child)) {
         $idsArr[] = $ids->child;
         if ($ids->parent != 0 and $catMenuId != $virtuemart_category_id and $catMenuId != $ids->parent) {
             $this->categoryRecursed++;
             $idsArr = $this->getCategoryRecurse($ids->parent, $catMenuId, $idsArr);
         }
     }
     return $idsArr;
 }
コード例 #21
0
ファイル: mediahandler.php プロジェクト: sam-akopyan/hamradio
 /**
  * Deletes a file
  *
  * @param string $url relative Url, gets adjusted to path
  */
 function deleteFile($url)
 {
     if (!vmAccess::manager('media.delete')) {
         vmWarn('Insufficient permissions to delete the media');
         return false;
     }
     if (!class_exists('JFile')) {
         require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
     }
     $file_path = VMPATH_ROOT . DS . str_replace('/', DS, $url);
     $app = JFactory::getApplication();
     $msg_path = '';
     if (vmAccess::manager('core')) {
         $msg_path = $file_path;
     }
     if ($res = JFile::delete($file_path)) {
         $app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_FILE_DELETE_OK', $msg_path));
     } else {
         $app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_FILE_DELETE_ERR', $res . ' ' . $msg_path));
     }
     return;
 }
コード例 #22
0
 /**
  *
  * @author Valerie Isaksen
  * @author Max Milbers
  * @param int $virtuemart_order_id
  * @return string pluginName from the plugin table
  */
 private function getOrderMethodNamebyOrderId($virtuemart_order_id)
 {
     $db = JFactory::getDBO();
     $q = 'SELECT * FROM `' . $this->_tablename . '` ' . 'WHERE `virtuemart_order_id` = ' . $virtuemart_order_id;
     $db->setQuery($q);
     $err = $db->getErrorMsg();
     if (!($pluginInfo = $db->loadObject())) {
         vmdebug('Attention, ' . $this->_tablename . ' has not any entry for order_id = ' . $virtuemart_order_id);
         if (!empty($err)) {
             vmWarn('Attention, ' . $this->_tablename . ' has not any entry for order_id = ' . $virtuemart_order_id . ' err = ' . $err);
         }
         return NULL;
     }
     $idName = $this->_psType . '_name';
     return $pluginInfo->{$idName};
 }
コード例 #23
0
    /**
     * Display for the cart
     *
     * @author Patrick Kohl
     * @param obj $product product object
     * @return html code
     */
    public function getProductCustomsFieldCart($product)
    {
        // group by virtuemart_custom_id
        $query = 'SELECT C.`virtuemart_custom_id`, `custom_title`, `show_title`, C.`custom_value`,`custom_field_desc` ,`custom_tip`,`field_type`,field.`virtuemart_customfield_id`,`is_hidden`
				FROM `#__virtuemart_customs` AS C
				LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
				Where `virtuemart_product_id` =' . (int) $product->virtuemart_product_id . ' and `field_type` != "G" and `field_type` != "R" and `field_type` != "Z"';
        $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id ORDER BY field.`ordering`';
        $this->_db->setQuery($query);
        $groups = $this->_db->loadObjectList();
        $err = $this->_db->getErrorMsg();
        if (!empty($err)) {
            vmWarn('getProductCustomsFieldCart ' . $err);
        } else {
            if (empty($groups)) {
                return array();
            }
        }
        JLoader::register('VmHTML', JPATH_VM_ADMINISTRATOR . 'helpers/html.php');
        $row = 0;
        JLoader::register('CurrencyDisplay', JPATH_VM_ADMINISTRATOR . '/helpers/currencydisplay.php');
        $currency = CurrencyDisplay::getInstance();
        JLoader::register('calculationHelper', JPATH_VM_ADMINISTRATOR . '/helpers/calculationh.php');
        $calculator = calculationHelper::getInstance();
        $calculator->_product = $product;
        $calculator->_cats = $product->categories;
        $calculator->product_tax_id = isset($product->product_tax_id) ? $product->product_tax_id : 0;
        $calculator->product_discount_id = isset($product->product_discount_id) ? $product->product_discount_id : 0;
        $calculator->productCurrency = isset($product->product_currency) ? $product->product_currency : $calculator->productCurrency;
        JLoader::register('vmCustomPlugin', JPATH_VM_PLUGINS . '/vmcustomplugin.php');
        //$free = JText::_ ('COM_VIRTUEMART_CART_PRICE_FREE');
        // render select list
        foreach ($groups as $group) {
            //				$query='SELECT  field.`virtuemart_customfield_id` as value ,concat(field.`custom_value`," :bu ", field.`custom_price`) AS text
            $query = 'SELECT field.`virtuemart_product_id`, `custom_params`,`custom_element`, field.`virtuemart_custom_id`,
							field.`virtuemart_customfield_id`,field.`custom_value`, field.`custom_price`, field.`custom_param`
					FROM `#__virtuemart_customs` AS C
					LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
					Where `virtuemart_product_id` =' . (int) $product->virtuemart_product_id;
            $query .= ' and is_cart_attribute = 1 and C.`virtuemart_custom_id`=' . (int) $group->virtuemart_custom_id;
            // We want the field to be ordered as the user defined
            $query .= ' ORDER BY field.`ordering`';
            $this->_db->setQuery($query);
            $options = $this->_db->loadObjectList();
            //vmdebug('getProductCustomsFieldCart options',$options);
            $group->options = array();
            foreach ($options as $option) {
                $group->options[$option->virtuemart_customfield_id] = $option;
            }
            if ($group->field_type == 'V') {
                $default = current($group->options);
                foreach ($group->options as $productCustom) {
                    $price = self::_getCustomPrice($productCustom->custom_price, $currency, $calculator);
                    $productCustom->text = $productCustom->custom_value . ' ' . $price;
                }
                $group->display = VmHTML::select('customPrice[' . $row . '][' . $group->virtuemart_custom_id . ']', $group->options, $default->custom_value, '', 'virtuemart_customfield_id', 'text', FALSE, false);
            } else {
                if ($group->field_type == 'G') {
                    $group->display .= '';
                    // no direct display done by plugin;
                } else {
                    if ($group->field_type == 'E') {
                        $group->display = '';
                        JLoader::register('vmCustomPlugin', JPATH_VM_PLUGINS . '/vmcustomplugin.php');
                        foreach ($group->options as $k => $productCustom) {
                            $price = self::_getCustomPrice($productCustom->custom_price, $currency, $calculator);
                            $productCustom->text = $productCustom->custom_value . ' ' . $price;
                            $productCustom->virtuemart_customfield_id = $k;
                            //legacy, it will be removed 2.2
                            $productCustom->value = $productCustom->virtuemart_customfield_id;
                            JPluginHelper::importPlugin('vmcustom');
                            $dispatcher = JDispatcher::getInstance();
                            $fieldsToShow = $dispatcher->trigger('plgVmOnDisplayProductVariantFE', array($productCustom, &$row, &$group));
                            //	$group->display .= '<input type="hidden" value="' . $k . '" name="customPrice[' . $row . '][' . $group->virtuemart_custom_id . ']" /> ';
                            $group->display .= '<input type="hidden" value="' . $productCustom->virtuemart_customfield_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_custom_id . ']" /> ';
                            if (!empty($currency->_priceConfig['variantModification'][0]) and $price !== '') {
                                $group->display .= '<div class="price-plugin">' . JText::_('COM_VIRTUEMART_CART_PRICE') . '<span class="price-plugin">' . $price . '</span></div>';
                            }
                            $row++;
                        }
                        $row--;
                    } else {
                        if ($group->field_type == 'U') {
                            foreach ($group->options as $productCustom) {
                                $price = self::_getCustomPrice($productCustom->custom_price, $currency, $calculator);
                                $productCustom->text = $productCustom->custom_value . ' ' . $price;
                                $group->display .= '<input type="text" value="' . JText::_($productCustom->custom_value) . '" name="customPrice[' . $row . '][' . $group->virtuemart_custom_id . '][' . $productCustom->value . ']" /> ';
                                if (!empty($currency->_priceConfig['variantModification'][0]) and $price !== '') {
                                    $group->display .= '<div class="price-plugin">' . JText::_('COM_VIRTUEMART_CART_PRICE') . '<span class="price-plugin">' . $price . '</span></div>';
                                }
                            }
                        } else {
                            if ($group->field_type == 'A') {
                                $group->display = '';
                                foreach ($group->options as $productCustom) {
                                    /*	if ((float)$productCustom->custom_price) {
                                    				$price = $currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($productCustom->custom_price));
                                    			}
                                    			else {
                                    				$price = ($productCustom->custom_price === '') ? '' : $free;
                                    			}*/
                                    $productCustom->field_type = $group->field_type;
                                    $productCustom->is_cart = 1;
                                    $group->display .= $this->displayProductCustomfieldFE($product, $productCustom, $row);
                                    $checked = '';
                                }
                            } else {
                                $group->display = '';
                                $checked = 'checked="checked"';
                                foreach ($group->options as $productCustom) {
                                    //vmdebug('getProductCustomsFieldCart',$productCustom);
                                    $price = self::_getCustomPrice($productCustom->custom_price, $currency, $calculator);
                                    $productCustom->field_type = $group->field_type;
                                    $productCustom->is_cart = 1;
                                    //	$group->display .= '<input id="' . $productCustom->virtuemart_custom_id . '" ' . $checked . ' type="radio" value="' .
                                    //		$productCustom->virtuemart_custom_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_customfield_id . ']" /><label
                                    //		for="' . $productCustom->virtuemart_custom_id . '">' . $this->displayProductCustomfieldFE ($productCustom, $row) . ' ' . $price . '</label>';
                                    //MarkerVarMods
                                    $group->display .= '<input id="' . $productCustom->virtuemart_custom_id . $row . '" ' . $checked . ' type="radio" value="' . $productCustom->virtuemart_customfield_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_custom_id . ']" /><label
										for="' . $productCustom->virtuemart_custom_id . '" class="other-customfield">' . $this->displayProductCustomfieldFE($product, $productCustom, $row) . ' ' . $price . '</label>';
                                    $checked = '';
                                }
                            }
                        }
                    }
                }
            }
            $row++;
        }
        return $groups;
    }
コード例 #24
0
ファイル: migrator.php プロジェクト: naka211/studiekorrektur
 /**
  * Roughly taken from the forum, a bit rewritten by Max Milbers to use the joomla database
  * Thank you raycarter
  *
  * http://forum.virtuemart.net/index.php?topic=102083.0
  * @author raycarter
  */
 function portVm1Attributes()
 {
     if ($this->_stop || microtime(true) - $this->starttime >= $this->maxScriptTime) {
         return;
     }
     $alreadyKnownIds = $this->getMigrationProgress('attributes');
     $i = 0;
     $prefix = '#_';
     $oldtable = '#__vm_product';
     $db = JFactory::getDbo();
     $db->setQuery("SELECT product_sku, attribute FROM " . $oldtable . " WHERE ( attribute IS NULL or attribute <> '') ");
     $rows = $db->loadObjectList();
     foreach ($rows as $product) {
         $db->setQuery("SELECT virtuemart_product_id FROM " . $prefix . "_virtuemart_products WHERE product_sku=" . $db->Quote($product->product_sku));
         $productid = (int) $db->loadResult();
         if (!in_array($productid, $alreadyKnownIds)) {
             $ignore = vRequest::getVar('prodIdsToIgnore', array());
             if (!is_array($ignore)) {
                 $ignore = array($ignore);
             }
             foreach ($ignore as &$ig) {
                 $ig = (int) $ig;
             }
             $ign = false;
             if (count($ignore) && $productid) {
                 foreach ($ignore as $ig) {
                     if ($ig == $productid) {
                         $ign = true;
                         echo "ignoring product_id =" . $productid . "<br/>";
                         break;
                     }
                 }
             }
             if (!$ign) {
                 $attrStr = explode(";", $product->attribute);
                 foreach ($attrStr as $attributes) {
                     $result = "adding attributes for product_id :" . $productid . "<br/>";
                     $attrData = array();
                     $attrData = explode(",", $attributes);
                     //its the parent, create it,it does not exist before
                     $db->setQuery("SELECT virtuemart_custom_id FROM " . $prefix . "_virtuemart_customs WHERE custom_title =" . $db->Quote($attrData[0]));
                     $parent = $db->loadResult();
                     if ($parent) {
                         $pid = $parent;
                         $result .= "found parent with id=" . $parent . "<br/>";
                     } else {
                         $query = 'INSERT INTO ' . $prefix . '_virtuemart_customs (custom_title,custom_tip,field_type,is_cart_attribute,published) VALUES
     (' . $db->Quote($attrData[0]) . ',"","V","1","1")';
                         $db->setQuery($query);
                         if (!$db->execute()) {
                             die($query);
                         }
                         $pid = $db->insertid();
                         $result .= "<p>inserted parent " . $attrData[0] . "</p>";
                     }
                     foreach ($attrData as $key => $attr) {
                         if ($key != '0') {
                             $priceset = explode("[", $attr);
                             $price = 0;
                             $warning = '';
                             if (count($priceset) > 1) {
                                 $price = substr($priceset[1], 0, -1);
                                 // remove ]
                                 if ('=' == substr($price, 0, 1)) {
                                     // Don't port, set the price to 0
                                     $price = 0;
                                     $warning = 'WARNING: Price for this attribute has been set to 0';
                                 } elseif ("+" == substr($price, 0, 1)) {
                                     $price = substr($price, 1);
                                     // remove the +
                                 }
                             }
                             $cleaned = $priceset[0];
                             //get ordering of the last element and add 1 to it
                             $db->setQuery('SELECT MAX(ordering) from ' . $prefix . '_virtuemart_product_customfields');
                             $ordering = $db->loadResult() + 1;
                             $query = 'INSERT INTO ' . $prefix . '_virtuemart_product_customfields (virtuemart_product_id,virtuemart_custom_id,customfield_value,customfield_price,ordering) VALUES
             (' . $productid . ',' . $pid . ',' . $db->Quote($cleaned) . ',' . $price . ',' . $ordering . ')';
                             $db->setQuery($query);
                             if (!$db->execute()) {
                                 $result .= "query failed for attribute :" . $cleaned . ", query :" . $query . "</br>";
                                 vmWarn('portVm1Attributes ' . $result);
                             }
                             $result .= "inserted attribute for parent :" . $attrData[0] . ", atttribute name :" . $cleaned . ' ' . $warning . "<br/>";
                         }
                     }
                 }
             }
             $alreadyKnownIds[] = $productid;
             $i++;
             if (microtime(true) - $this->starttime >= $this->maxScriptTime) {
                 break;
             }
         } else {
         }
     }
     $this->storeMigrationProgress('attributes', $alreadyKnownIds);
 }
コード例 #25
0
ファイル: orders.php プロジェクト: alesconti/FF_2015
 function createInvoiceNumber($orderDetails, &$invoiceNumber)
 {
     $orderDetails = (array) $orderDetails;
     $db = JFactory::getDBO();
     if (!isset($orderDetails['virtuemart_order_id'])) {
         vmWarn('createInvoiceNumber $orderDetails has no virtuemart_order_id ', $orderDetails);
         vmdebug('createInvoiceNumber $orderDetails has no virtuemart_order_id ', $orderDetails);
     }
     $q = 'SELECT * FROM `#__virtuemart_invoices` WHERE `virtuemart_order_id`= "' . $orderDetails['virtuemart_order_id'] . '" ';
     // AND `order_status` = "'.$orderDetails->order_status.'" ';
     $db->setQuery($q);
     $result = $db->loadAssoc();
     // 		vmdebug('my createInvoiceNumber $q '.$q,$result);
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     if (!$result or empty($result['invoice_number'])) {
         $data['virtuemart_order_id'] = $orderDetails['virtuemart_order_id'];
         $data['order_status'] = $orderDetails['order_status'];
         $data['virtuemart_vendor_id'] = $orderDetails['virtuemart_vendor_id'];
         JPluginHelper::importPlugin('vmshopper');
         JPluginHelper::importPlugin('vmpayment');
         $dispatcher = JDispatcher::getInstance();
         // plugin returns invoice number, 0 if it does not want an invoice number to be created by Vm
         $plg_datas = $dispatcher->trigger('plgVmOnUserInvoice', array($orderDetails, &$data));
         foreach ($plg_datas as $plg_data) {
             // 				$data = array_merge($plg_data,$data);
         }
         if (!isset($data['invoice_number'])) {
             // check the default configuration
             $orderstatusForInvoice = VmConfig::get('inv_os', array());
             if (!is_array($orderstatusForInvoice)) {
                 $orderstatusForInvoice = array($orderstatusForInvoice);
             }
             //for backward compatibility 2.0.8e
             $pdfInvoice = (int) VmConfig::get('pdf_invoice', 0);
             // backwards compatible
             $force_create_invoice = JRequest::getInt('create_invoice', 0);
             // florian : added if pdf invoice are enabled
             if (in_array($orderDetails['order_status'], $orderstatusForInvoice) or $pdfInvoice == 1 or $force_create_invoice == 1) {
                 $q = 'SELECT COUNT(1) FROM `#__virtuemart_invoices` WHERE `virtuemart_vendor_id`= "' . $orderDetails['virtuemart_vendor_id'] . '" ';
                 // AND `order_status` = "'.$orderDetails->order_status.'" ';
                 $db->setQuery($q);
                 $count = $db->loadResult() + 1;
                 if (empty($data['invoice_number'])) {
                     //$variable_fixed=sprintf("%05s",$num_rows);
                     $date = date("Y-m-d");
                     // 					$date = JFactory::getDate()->toMySQL();
                     $data['invoice_number'] = str_replace('-', '', substr($date, 2, 8)) . substr(md5($orderDetails['order_number'] . $orderDetails['order_status']), 0, 3) . '0' . $count;
                 }
             } else {
                 return false;
             }
         }
         $table = $this->getTable('invoices');
         $table->bindChecknStore($data);
         $invoiceNumber = array($table->invoice_number, $table->created_on);
     } elseif (ShopFunctions::InvoiceNumberReserved($result['invoice_number'])) {
         $invoiceNumber = array($result['invoice_number'], $result['created_on']);
         return true;
     } else {
         $invoiceNumber = array($result['invoice_number'], $result['created_on']);
     }
     return true;
 }
コード例 #26
0
ファイル: ulozenka.php プロジェクト: aldegtyarev/stelsvelo
 /**
  * @param $virtuemart_order_id
  * @return string
  * @author zasilkovna
  */
 function getOrderShipmentHtml($virtuemart_order_id)
 {
     $db = JFactory::getDBO();
     $q = 'SELECT * FROM `' . $this->_tablename . '` ' . 'WHERE `virtuemart_order_id` = ' . $virtuemart_order_id;
     $db->setQuery($q);
     if (!($shipinfo = $db->loadObject())) {
         vmWarn(500, $q . " " . $db->getErrorMsg());
         return '';
     }
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance();
     $tax = ShopFunctions::getTaxByID($shipinfo->tax_id);
     $taxDisplay = is_array($tax) ? $tax['calc_value'] . ' ' . $tax['calc_value_mathop'] : $shipinfo->tax_id;
     $taxDisplay = $taxDisplay == -1 ? JText::_('COM_VIRTUEMART_PRODUCT_TAX_NONE') : $taxDisplay;
     $html = '<table class="adminlist">' . "\n";
     $html .= $this->getHtmlHeaderBE();
     $html .= $this->getHtmlRowBE('WEIGHT_COUNTRIES_SHIPPING_NAME', $shipinfo->shipment_name);
     $html .= $this->getHtmlRowBE('BRANCH', $shipinfo->branch_name_street);
     $html .= $this->getHtmlRowBE('CURRENCY', $shipinfo->branch_currency);
     $html .= '</table>' . "\n";
     return $html;
 }
コード例 #27
0
ファイル: vmmodel.php プロジェクト: thumbs-up-sign/TuVanDuAn
 /**
  *
  * @author Patrick Kohl
  * @author Max Milbers
  */
 static function getModel($name = false)
 {
     if (!$name) {
         $name = vRequest::getCmd('view', '');
         // 			vmdebug('Get standard model of the view');
     }
     $name = strtolower($name);
     $className = 'VirtueMartModel' . ucfirst($name);
     if (empty(self::$_vmmodels[strtolower($className)])) {
         if (!class_exists($className)) {
             $modelPath = VMPATH_ADMIN . DS . "models" . DS . $name . ".php";
             if (file_exists($modelPath)) {
                 require $modelPath;
             } else {
                 vmWarn('Model ' . $name . ' not found.');
                 echo 'File for Model ' . $name . ' not found.';
                 return false;
             }
         }
         self::$_vmmodels[strtolower($className)] = new $className();
         return self::$_vmmodels[strtolower($className)];
     } else {
         return self::$_vmmodels[strtolower($className)];
     }
 }
コード例 #28
0
ファイル: connection.php プロジェクト: cuongnd/etravelservice
 /**
  * This is a general function to safely open a connection to a server,
  * post data when needed and read the result.
  * Tries using cURL and switches to fopen/fsockopen if cURL is not available
  * @since tsmart 1.1.0
  * @static
  * @param string $url
  * @param string $postData
  * @param array $headers
  * @param resource $fileToSaveData
  * @return mixed
  */
 static function handleCommunication($url, $postData = '', $headers = array(), $fileToSaveData = null)
 {
     $urlParts = parse_url($url);
     if (!isset($urlParts['port'])) {
         $urlParts['port'] = 80;
     }
     if (!isset($urlParts['scheme'])) {
         $urlParts['scheme'] = 'http';
     }
     if (isset($urlParts['query'])) {
         $urlParts['query'] = '?' . $urlParts['query'];
         if (isset($urlParts['path'])) {
             $urlParts['path'] = $urlParts['path'] . $urlParts['query'];
         }
     }
     $vm_proxy_url = tsmConfig::get('conf_VM_PROXY_URL', '');
     // Check proxy
     if (trim($vm_proxy_url) != '') {
         if (!stristr($vm_proxy_url, 'http')) {
             $proxyURL['host'] = $vm_proxy_url;
             $proxyURL['scheme'] = 'http';
         } else {
             $proxyURL = parse_url($vm_proxy_url);
         }
     } else {
         $proxyURL = '';
     }
     if (function_exists("curl_init") && function_exists('curl_exec')) {
         $CR = curl_init();
         curl_setopt($CR, CURLOPT_URL, $url);
         // just to get sure the script doesn't die
         curl_setopt($CR, CURLOPT_TIMEOUT, 30);
         if (!empty($headers)) {
             // Add additional headers if provided
             curl_setopt($CR, CURLOPT_HTTPHEADER, $headers);
         }
         curl_setopt($CR, CURLOPT_FAILONERROR, true);
         if ($postData) {
             curl_setopt($CR, CURLOPT_POSTFIELDS, $postData);
             curl_setopt($CR, CURLOPT_POST, 1);
         }
         if (is_resource($fileToSaveData)) {
             curl_setopt($CR, CURLOPT_FILE, $fileToSaveData);
         } else {
             curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);
         }
         // Do we need to set up the proxy?
         if (!empty($proxyURL)) {
             //		$vmLogger->debug( 'Setting up proxy: '.$proxyURL['host'].':'.VM_PROXY_PORT );
             //curl_setopt($CR, CURLOPT_HTTPPROXYTUNNEL, true);
             curl_setopt($CR, CURLOPT_PROXY, $proxyURL['host']);
             curl_setopt($CR, CURLOPT_PROXYPORT, VM_PROXY_PORT);
             // Check if the proxy needs authentication
             if (trim(@VM_PROXY_USER) != '') {
                 //		    $vmLogger->debug( 'Using proxy authentication!' );
                 curl_setopt($CR, CURLOPT_PROXYUSERPWD, VM_PROXY_USER . ':' . VM_PROXY_PASS);
             }
         }
         if ($urlParts['scheme'] == 'https') {
             // No PEER certificate validation...as we don't have
             // a certificate file for it to authenticate the host www.ups.com against!
             curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
         }
         $result = curl_exec($CR);
         $error = curl_error($CR);
         if (!empty($error) && stristr($error, '502') && !empty($proxyURL)) {
             //		$vmLogger->debug( 'Switching to NTLM authenticaton.');
             curl_setopt($CR, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
             $result = curl_exec($CR);
             $error = curl_error($CR);
         }
         curl_close($CR);
         if (!empty($error)) {
             //JError::raiseError(1, $error );
             return false;
         } else {
             return $result;
         }
     } else {
         if ($postData) {
             if (!empty($proxyURL)) {
                 // If we have something to post we need to write into a socket
                 if ($proxyURL['scheme'] == 'https') {
                     $protocol = 'ssl';
                 } else {
                     $protocol = 'http';
                 }
                 $fp = fsockopen("{$protocol}://" . $proxyURL['host'], VM_PROXY_PORT, $errno, $errstr, $timeout = 30);
             } else {
                 // If we have something to post we need to write into a socket
                 if ($urlParts['scheme'] == 'https') {
                     $protocol = 'ssl';
                 } else {
                     $protocol = $urlParts['scheme'];
                 }
                 $fp = fsockopen("{$protocol}://" . $urlParts['host'], $urlParts['port'], $errno, $errstr, $timeout = 30);
             }
         } else {
             if (!empty($proxyURL)) {
                 // Do a read-only fopen transaction
                 $fp = fopen($proxyURL['scheme'] . '://' . $proxyURL['host'] . ':' . VM_PROXY_PORT, 'rb');
             } else {
                 // Do a read-only fopen transaction
                 $fp = fopen($urlParts['scheme'] . '://' . $urlParts['host'] . ':' . $urlParts['port'] . $urlParts['path'], 'rb');
             }
         }
         if (!$fp) {
             //error tell us
             vmWarn('Possible server error! - ' . $errstr . '(' . $errno . ')\\n');
             return false;
         } else {
             vmdebug('Connection opened to ' . $urlParts['host']);
         }
         if ($postData) {
             //send the server request
             if (!empty($proxyURL)) {
                 fputs($fp, "POST " . $urlParts['host'] . ':' . $urlParts['port'] . $urlParts['path'] . " HTTP/1.0\r\n");
                 fputs($fp, "Host: " . $proxyURL['host'] . "\r\n");
                 if (trim(@VM_PROXY_USER) != '') {
                     fputs($fp, "Proxy-Authorization: Basic " . base64_encode(VM_PROXY_USER . ':' . VM_PROXY_PASS) . "\r\n\r\n");
                 }
             } else {
                 fputs($fp, 'POST ' . $urlParts['path'] . " HTTP/1.0\r\n");
                 fputs($fp, 'Host:' . $urlParts['host'] . "\r\n");
             }
             fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
             fputs($fp, "Content-length: " . strlen($postData) . "\r\n");
             fputs($fp, "Connection: close\r\n\r\n");
             fputs($fp, $postData . "\r\n\r\n");
         } else {
             if (!empty($proxyURL)) {
                 fputs($fp, "GET " . $urlParts['host'] . ':' . $urlParts['port'] . $urlParts['path'] . " HTTP/1.0\r\n");
                 fputs($fp, "Host: " . $proxyURL['host'] . "\r\n");
                 if (trim(@VM_PROXY_USER) != '') {
                     fputs($fp, "Proxy-Authorization: Basic " . base64_encode(VM_PROXY_USER . ':' . VM_PROXY_PASS) . "\r\n\r\n");
                 }
             } else {
                 //				JError::raiseNotice(1, 'Host:'. $urlParts['host'].' path: '. $urlParts['path'] );
                 fputs($fp, 'GET ' . $urlParts['path'] . " HTTP/1.0\r\n");
                 fputs($fp, 'Host:' . $urlParts['host'] . "\r\n");
             }
         }
         // Add additional headers if provided
         foreach ($headers as $header) {
             fputs($fp, $header . "\r\n");
         }
         $data = "";
         while (!feof($fp)) {
             $data .= @fgets($fp, 4096);
         }
         fclose($fp);
         // If didnt get content-length, something is wrong, return false.
         if (trim($data) == '') {
             vmWarn('An error occured while communicating with the server ' . $urlParts['host'] . '. It didn\'t reply (correctly). Please try again later, thank you.');
             return false;
         }
         $result = trim($data);
         if (is_resource($fileToSaveData)) {
             fwrite($fileToSaveData, $result);
             return true;
         } else {
             return $result;
         }
     }
 }
コード例 #29
0
    function addStandardEditViewCommandsNoValidate($id = 0, $object = null)
    {
        $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart'));
        if (!class_exists('JToolBarHelper')) {
            require JPATH_ADMINISTRATOR . DS . 'includes' . DS . 'toolbar.php';
        }
        JToolBarHelper::divider();
        if (vmAccess::manager($view . '.edit')) {
            JToolBarHelper::save();
            JToolBarHelper::apply();
        }
        JToolBarHelper::cancel();
        //self::showHelp();
        //self::showACLPref($view);
        if ($view != 'shipmentmethod' and $view != 'paymentmethod' and $view != 'media') {
            $validate = true;
        } else {
            $validate = false;
        }
        $this->addJsJoomlaSubmitButtonNoValidate($validate);
        $editView = vRequest::getCmd('view', vRequest::getCmd('controller', ''));
        $params = JComponentHelper::getParams('com_languages');
        $selectedLangue = $params->get('site', 'en-GB');
        $this->lang = strtolower(strtr($selectedLangue, '-', '_'));
        // Get all the published languages defined in Language manager > Content
        $allLanguages = JLanguageHelper::getLanguages();
        foreach ($allLanguages as $jlang) {
            $languagesByCode[$jlang->lang_code] = $jlang;
        }
        // only add if ID and view not null
        if ($editView and $id and count(tsmConfig::get('active_languages')) > 1) {
            if ($editView == 'user') {
                $editView = 'vendor';
            }
            jimport('joomla.language.helper');
            $this->lang = vRequest::getVar('vmlang', $this->lang);
            // list of languages installed in #__extensions (may be more than the ones in the Language manager > Content if the user did not added them)
            $languages = JLanguageHelper::createLanguageList($selectedLangue, constant('VMPATH_ROOT'), true);
            $activeVmLangs = tsmConfig::get('active_languages');
            $flagCss = "";
            foreach ($languages as $k => &$joomlaLang) {
                if (!in_array($joomlaLang['value'], $activeVmLangs)) {
                    unset($languages[$k]);
                } else {
                    $key = $joomlaLang['value'];
                    if (!isset($languagesByCode[$key])) {
                        $img = substr($key, 0, 2);
                        //We try a fallback
                        vmdebug('com_tsmart_MISSING_FLAG', $img, $joomlaLang['text']);
                    } else {
                        $img = $languagesByCode[$key]->image;
                    }
                    $image_flag = VMPATH_ROOT . "/media/mod_languages/images/" . $img . ".gif";
                    $image_flag_url = JURI::root() . "media/mod_languages/images/" . $img . ".gif";
                    if (!file_exists($image_flag)) {
                        vmerror(tsmText::sprintf('com_tsmart_MISSING_FLAG', $image_flag, $joomlaLang['text']));
                    } else {
                        $flagCss .= "td.flag-" . $key . ",.flag-" . $key . "{background: url( " . $image_flag_url . ") no-repeat 0 0; padding-left:20px !important;}\n";
                    }
                }
            }
            JFactory::getDocument()->addStyleDeclaration($flagCss);
            $this->langList = JHtml::_('select.genericlist', $languages, 'vmlang', 'class="inputbox" style="width:176px;"', 'value', 'text', $selectedLangue, 'vmlang');
            if ($editView == 'product') {
                $productModel = tmsModel::getModel('product');
                $childproducts = $productModel->getProductChilds($id) ? $productModel->getProductChilds($id) : '';
            }
            $token = vRequest::getFormToken();
            $j = '
			jQuery(function($) {
				var oldflag = "";
				$("select#vmlang").chosen().change(function() {
					langCode = $(this).find("option:selected").val();
					flagClass = "flag-"+langCode;
					jQuery.ajax({
						type: "GET",
						cache: false,
        				dataType: "json",
        				url: "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $id . '&editView=' . $editView . '&' . $token . '=1",
    				}).done(
						function(data) {
							var items = [];

							var theForm = document.forms["adminForm"];
							if(typeof theForm.vmlang==="undefined"){
							 	var input = document.createElement("input");
								input.type = "hidden";
								input.name = "vmlang";
								input.value = langCode;
								theForm.appendChild(input);
							} else {
								theForm.vmlang.value = langCode;
							}
							if (data.fields !== "error" ) {
								if (data.structure == "empty") alert(data.msg);
								$.each(data.fields , function(key, val) {
									cible = jQuery("#"+key);
									if (oldflag !== "") cible.parent().removeClass(oldflag)
									var tmce_ver = 0;
									if(typeof window.tinyMCE!=="undefined"){
										var tmce_ver=window.tinyMCE.majorVersion;
									}
									if (tmce_ver>="4") {
										if (cible.parent().addClass(flagClass).children().hasClass("mce_editable") && data.structure !== "empty" ) {
											tinyMCE.get(key).execCommand("mceSetContent", false,val);
											cible.val(val);
										} else if (data.structure !== "empty") cible.val(val);
									} else {
										if (cible.parent().addClass(flagClass).children().hasClass("mce_editable") && data.structure !== "empty" ) {
											tinyMCE.execInstanceCommand(key,"mceSetContent",false,val);
											cible.val(val);
										} else if (data.structure !== "empty") cible.val(val);
									}
									});

							} else alert(data.msg);';
            if ($editView == 'product' && !empty($childproducts)) {
                foreach ($childproducts as $child) {
                    $j .= 'jQuery.ajax({
        						type: "GET",
								cache: false,
        						dataType: "json",
        						url: "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $child->tsmart_product_id . '&editView=' . $editView . '&' . $token . '=1",
    					}).done(
								//	$.getJSON( "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $child->tsmart_product_id . '&editView=' . $editView . '&' . $token . '=1" ,
										function(data) {
											cible = jQuery("#child' . $child->tsmart_product_id . 'product_name");
											if (oldflag !== "") cible.parent().removeClass(oldflag)
											cible.parent().addClass(flagClass);
											cible.val(data.fields.product_name);
											jQuery("#child' . $child->tsmart_product_id . 'slug").val(data.fields["slug"]);
										}
									)
								';
                }
            }
            $j .= 'oldflag = flagClass ;
						}
					)
				});
			})';
            vmJsApi::addJScript('vmlang', $j);
        } else {
            $jlang = JFactory::getLanguage();
            $langs = $jlang->getKnownLanguages();
            $defautName = $selectedLangue;
            $flagImg = $selectedLangue;
            if (isset($languagesByCode[$selectedLangue])) {
                $defautName = $langs[$selectedLangue]['name'];
                $flagImg = JHtml::_('image', 'mod_languages/' . $languagesByCode[$selectedLangue]->image . '.gif', $languagesByCode[$selectedLangue]->title_native, array('title' => $languagesByCode[$selectedLangue]->title_native), true);
            } else {
                vmWarn(tsmText::sprintf('com_tsmart_MISSING_FLAG', $selectedLangue, $selectedLangue));
            }
            $this->langList = '<input name ="vmlang" type="hidden" value="' . $selectedLangue . '" >' . $flagImg . ' <b> ' . $defautName . '</b>';
        }
        if (JFactory::getApplication()->isSite()) {
            $bar = JToolBar::getInstance('toolbar');
            $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0');
        }
    }
コード例 #30
0
ファイル: tableupdater.php プロジェクト: Roma48/abazherka_old
 private function _getMaxItems($name)
 {
     $maxItems = 50;
     $freeRam = ($this->maxMemoryLimit - memory_get_usage(true)) / (1024 * 1024);
     $maxItems = (int) $freeRam * 100;
     if ($maxItems <= 0) {
         $maxItems = 50;
         vmWarn('Your system is low on RAM! Limit set: ' . $this->maxMemoryLimit . ' used ' . memory_get_usage(true) / (1024 * 1024) . ' MB and php.ini ' . ini_get('memory_limit'));
     }
     vmdebug('Migrating ' . $name . ', free ram left ' . $freeRam . ' so limit chunk to ' . $maxItems);
     return $maxItems;
 }