当前位置: 首页>>代码示例>>PHP>>正文


PHP vmWarn函数代码示例

本文整理汇总了PHP中vmWarn函数的典型用法代码示例。如果您正苦于以下问题:PHP vmWarn函数的具体用法?PHP vmWarn怎么用?PHP vmWarn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了vmWarn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getOrderShipmentHtml

 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;
 }
开发者ID:jflash,项目名称:moodulid25,代码行数:27,代码来源:post24.php

示例2: display

 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);
 }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:35,代码来源:view.html.php

示例3: display

 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);
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:30,代码来源:view.html.php

示例4: display

	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);
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:60,代码来源:view.html.php

示例5: remove

 function remove($ids)
 {
     if (!vmAccess::manager('paymentsetting')) {
         vmWarn('Insufficient permissions to remove paymentsetting');
         return false;
     }
     return parent::remove($ids);
 }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:8,代码来源:paymentsetting.php

示例6: store

 function store(&$data)
 {
     if (!vmAccess::manager('manufacturercategories')) {
         vmWarn('Insufficient permissions to store manufacturer category');
         return false;
     }
     return parent::store($data);
 }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:8,代码来源:manufacturercategories.php

示例7: check

 /**
  * 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();
 }
开发者ID:juanmcortez,项目名称:Lectorum,代码行数:64,代码来源:userinfos.php

示例8: check

 /**
  * 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();
 }
开发者ID:lenard112,项目名称:cms,代码行数:61,代码来源:userinfos.php

示例9: plgVmOnShowOrderBEPayment

 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;
 }
开发者ID:jflash,项目名称:moodulid25,代码行数:20,代码来源:maksekeskus.php

示例10: getInventory

    /**
     * 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());
    }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:25,代码来源:inventory.php

示例11: checkCountryCondition

 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;
 }
开发者ID:joselapria,项目名称:virtuemart,代码行数:34,代码来源:klarna.php

示例12: setMenuItemId

 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];
     }
 }
开发者ID:Roma48,项目名称:abazherka_old,代码行数:32,代码来源:router.php

示例13: plgVmOnStoreInstallPaymentPluginTable

 /**
  * 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);
 }
开发者ID:virtuemart-fr,项目名称:virtuemart-fr,代码行数:25,代码来源:realex_hpp_api.php

示例14: plgVmOnStoreInstallPaymentPluginTable

	/**
	 * @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);
	}
开发者ID:sergy444,项目名称:joomla,代码行数:71,代码来源:paypal.php

示例15: alterColumns

 /**
  * @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);
//.........这里部分代码省略.........
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:101,代码来源:tableupdater.php


注:本文中的vmWarn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。