예제 #1
0
 /**
  * save the posted form data.
  *
  */
 function save()
 {
     $mainframe = Jfactory::getApplication();
     $model = $this->getModel('redform');
     $result = $model->apisaveform();
     $referer = JRequest::getVar('referer');
     if (!$result) {
         if (!JRequest::getBool('ALREADY_ENTERED')) {
             $msg = JText::_('COM_REDFORM_Sorry_there_was_a_problem_with_your_submission') . ': ' . $model->getError();
         }
         $this->setRedirect($referer, $msg, 'error');
         $this->redirect();
     }
     if ($url = $model->hasActivePayment($result->submit_key)) {
         $url = 'index.php?option=com_redform&controller=payment&task=select&key=' . $result->submit_key;
         $this->setRedirect($url);
         $this->redirect();
     }
     if ($url = $model->getRedirect()) {
         $this->setRedirect($url);
         $this->redirect();
     } else {
         echo $model->getNotificationText();
     }
 }
예제 #2
0
파일: vote.php 프로젝트: q0821/esportshop
 function save(&$element, $forceBackend = false)
 {
     $app = Jfactory::getApplication();
     if ($app->isAdmin() || $forceBackend) {
         return $this->saveBackend($element);
     }
     return $this->saveFrontend($element);
 }
예제 #3
0
 function makeDefault()
 {
     $mainframe = Jfactory::getApplication();
     /* Load the view object */
     $view = $this->getView('shoppergroup', 'html');
     $model = VmModel::getModel('shoppergroup');
     $msgtype = '';
     $cids = JRequest::getVar('virtuemart_shoppergroup_id', array());
     if ($model->makeDefault((int) $cids[0])) {
         $msg = JText::_('COM_VIRTUEMART_SET_TO_DEFAULT_SUCCESSFULLY');
     } else {
         $msg = '';
         // 			$msg = JText::_('COM_VIRTUEMART_SET_TO_DEFAULT_ERROR');
         $msgtype = 'error';
     }
     $mainframe->redirect('index.php?option=com_virtuemart&view=shoppergroup', $msg, $msgtype);
 }
예제 #4
0
 /**
  * Clone a product
  *
  * @author Max Milbers
  */
 public function createClone()
 {
     $mainframe = Jfactory::getApplication();
     /* Load the view object */
     $view = $this->getView('custom', 'html');
     $model = tmsModel::getModel('custom');
     $msgtype = '';
     $cids = vRequest::getInt($this->_cidName, vRequest::getInt('tsmart_custom_id'));
     foreach ($cids as $custom_id) {
         if ($model->createClone($custom_id)) {
             $msg = tsmText::_('com_tsmart_CUSTOM_CLONED_SUCCESSFULLY');
         } else {
             $msg = tsmText::_('com_tsmart_CUSTOM_NOT_CLONED_SUCCESSFULLY') . ' : ' . $custom_id;
             $msgtype = 'error';
         }
     }
     $mainframe->redirect('index.php?option=com_tsmart&view=custom', $msg, $msgtype);
 }
예제 #5
0
 /**
  * Clone a shipment
  *
  * @author Valérie Isaksen
  */
 public function CloneShipment()
 {
     $mainframe = Jfactory::getApplication();
     /* Load the view object */
     $view = $this->getView('shipmentmethod', 'html');
     $model = VmModel::getModel('shipmentmethod');
     $msgtype = '';
     $cids = vRequest::getVar($this->_cidName, vRequest::getInt('virtuemart_shipment_id'));
     foreach ($cids as $cid) {
         if ($model->createClone($cid)) {
             $msg = vmText::_('COM_VIRTUEMART_SHIPMENT_CLONED_SUCCESSFULLY');
         } else {
             $msg = vmText::_('COM_VIRTUEMART_SHIPMENT_NOT_CLONED_SUCCESSFULLY');
             $msgtype = 'error';
         }
     }
     $mainframe->redirect('index.php?option=com_virtuemart&view=shipmentmethod', $msg, $msgtype);
 }
예제 #6
0
 /**
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Initiilise variables
     $app = Jfactory::getApplication('administrator');
     //load the filter state
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setstate('filter.search', $search);
     $accessId = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', null, 'int');
     $this->setstate('filter.access', $accessId);
     $published = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_published', '', 'string');
     $this->setstate('filter.state', $published);
     $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '');
     $this->setstate('filter.category_id', $categoryId);
     //Load the parameters
     $params = JComponentHelper::getParams('com_battle');
     $this->setState('params', $params);
     //List state information
     //	parent::populateState ('a.name','asc');
 }
예제 #7
0
 /**
  * Clone a product
  *
  * @author RolandD, Max Milbers
  */
 public function createClone()
 {
     $mainframe = Jfactory::getApplication();
     /* Load the view object */
     $view = $this->getView('custom', 'html');
     $model = VmModel::getModel('custom');
     $msgtype = '';
     $cids = JRequest::getVar($this->_cidName, JRequest::getVar('virtuemart_custom_id', array(), '', 'ARRAY'), '', 'ARRAY');
     jimport('joomla.utilities.arrayhelper');
     JArrayHelper::toInteger($cids);
     foreach ($cids as $custom_id) {
         if ($model->createClone($custom_id)) {
             $msg = JText::_('COM_VIRTUEMART_CUSTOM_CLONED_SUCCESSFULLY');
         } else {
             $msg = JText::_('COM_VIRTUEMART_CUSTOM_NOT_CLONED_SUCCESSFULLY') . ' : ' . $custom_id;
             $msgtype = 'error';
         }
     }
     $mainframe->redirect('index.php?option=com_virtuemart&view=custom', $msg, $msgtype);
 }
예제 #8
0
 /**
  * Clone a payment
  *
  * @author Valérie Isaksen
  */
 public function ClonePayment()
 {
     $mainframe = Jfactory::getApplication();
     /* Load the view object */
     $view = $this->getView('paymentmethod', 'html');
     $model = tmsModel::getModel('paymentmethod');
     $msgtype = '';
     $cids = vRequest::getInt($this->_cidName, vRequest::getInt('tsmart_payment_id'));
     if (!is_array($cids)) {
         $cids = array($cids);
     }
     foreach ($cids as $cid) {
         if ($model->createClone($cid)) {
             $msg = tsmText::_('com_tsmart_PAYMENT_CLONED_SUCCESSFULLY');
         } else {
             $msg = tsmText::_('com_tsmart_PAYMENT_NOT_CLONED_SUCCESSFULLY');
             $msgtype = 'error';
         }
     }
     $mainframe->redirect('index.php?option=com_tsmart&view=paymentmethod', $msg, $msgtype);
 }
예제 #9
0
 /**
  * Clone a payment
  *
  * @author Valérie Isaksen
  */
 public function ClonePayment()
 {
     $mainframe = Jfactory::getApplication();
     /* Load the view object */
     $view = $this->getView('paymentmethod', 'html');
     $model = VmModel::getModel('paymentmethod');
     $msgtype = '';
     //$cids = vRequest::getInt('virtuemart_product_id',0);
     $cids = vRequest::getVar($this->_cidName, vRequest::getVar('virtuemart_payment_id'));
     //jimport( 'joomla.utilities.arrayhelper' );
     JArrayHelper::toInteger($cids);
     foreach ($cids as $cid) {
         if ($model->createClone($cid)) {
             $msg = vmText::_('COM_VIRTUEMART_PAYMENT_CLONED_SUCCESSFULLY');
         } else {
             $msg = vmText::_('COM_VIRTUEMART_PAYMENT_NOT_CLONED_SUCCESSFULLY');
             $msgtype = 'error';
         }
     }
     $mainframe->redirect('index.php?option=com_virtuemart&view=paymentmethod', $msg, $msgtype);
 }
예제 #10
0
 /**
  * Creates the output for the registration view
  *
  * @since 1.5
  */
 function display($tpl = null)
 {
     $mainframe =& Jfactory::getApplication();
     $document =& JFactory::getDocument();
     $user =& JFactory::getUser();
     $dispatcher =& JDispatcher::getInstance();
     $config = redEVENTHelper::config();
     $acl = UserAcl::getInstance();
     $event = $this->get('SessionDetails');
     if ($this->getLayout() == 'confirmed') {
         $message = $event->confirmation_message;
         $document->setTitle($event->title . ' - ' . JText::_('COM_REDEVENT_REGISTRATION_CONFIRMED_PAGE_TITLE'));
     } else {
         if ($this->getLayout() == 'review') {
             $message = $event->review_message;
             $document->setTitle($event->title . ' - ' . JText::_('COM_REDEVENT_REGISTRATION_REVIEW_PAGE_TITLE'));
         } else {
             if ($this->getLayout() == 'edit') {
                 return $this->_displayEdit($tpl);
             } else {
                 if ($this->getLayout() == 'cancel') {
                     return $this->_displayCancel($tpl);
                 } else {
                     echo 'layout not defined';
                     return;
                 }
             }
         }
     }
     /* This loads the tags replacer */
     JView::loadHelper('tags');
     /* Start the tag replacer */
     $tags = new redEVENT_tags();
     $tags->setXref(JRequest::getInt('xref'));
     $message = $tags->ReplaceTags($message);
     $this->assignRef('tags', $tags);
     $this->assignRef('message', $message);
     $this->assignRef('event', $event);
     parent::display($tpl);
 }
예제 #11
0
 public function calculateCostprice($productId, $data)
 {
     $this->_revert = true;
     //vmdebug('calculationh.php calculateCostprice ',$data);
     //vmSetStartTime('calculateCostprice');
     if (empty($data['product_currency'])) {
         $this->_db->setQuery('SELECT * FROM #__virtuemart_product_prices  WHERE `virtuemart_product_id`="' . $productId . '" ');
         $row = $this->_db->loadAssoc();
         if ($row) {
             if (!empty($row['product_price'])) {
                 // 				$costPrice = $row['product_price'];
                 $this->productCurrency = $row['product_currency'];
                 // 				$this->override = $row['override'];
                 // 				$this->product_override_price = $row['product_override_price'];
                 $this->product_tax_id = $row['product_tax_id'];
                 $this->product_discount_id = $row['product_discount_id'];
             } else {
                 $app = Jfactory::getApplication();
                 $app->enqueueMessage('cost Price empty, if child, everything okey, this is just a dev note');
                 return false;
             }
         }
     } else {
         $this->productCurrency = $data['product_currency'];
         $this->product_tax_id = $data['product_tax_id'];
         $this->product_discount_id = $data['product_discount_id'];
     }
     $this->_db->setQuery('SELECT `virtuemart_vendor_id` FROM #__virtuemart_products  WHERE `virtuemart_product_id`="' . $productId . '" ');
     $single = $this->_db->loadResult();
     $this->productVendorId = $single;
     if (empty($this->productVendorId)) {
         $this->productVendorId = 1;
     }
     $this->_db->setQuery('SELECT `virtuemart_category_id` FROM #__virtuemart_product_categories  WHERE `virtuemart_product_id`="' . $productId . '" ');
     $this->_cats = $this->_db->loadResultArray();
     // 		vmTime('getProductPrices no object given query time','getProductCalcs');
     if (VmConfig::get('multix', 'none') != 'none' and empty($this->vendorCurrency)) {
         $this->_db->setQuery('SELECT `vendor_currency` FROM #__virtuemart_vendors  WHERE `virtuemart_vendor_id`="' . $this->productVendorId . '" ');
         $single = $this->_db->loadResult();
         $this->vendorCurrency = $single;
     }
     if (!empty($amount)) {
         $this->_amount = $amount;
     }
     //$this->setCountryState($this->_cart);
     $this->rules['Marge'] = $this->gatherEffectingRulesForProductPrice('Marge', $this->product_marge_id);
     $this->rules['Tax'] = $this->gatherEffectingRulesForProductPrice('Tax', $this->product_tax_id);
     $this->rules['VatTax'] = $this->gatherEffectingRulesForProductPrice('VatTax', $this->product_tax_id);
     $this->rules['DBTax'] = $this->gatherEffectingRulesForProductPrice('DBTax', $this->product_discount_id);
     $this->rules['DATax'] = $this->gatherEffectingRulesForProductPrice('DATax', $this->product_discount_id);
     $salesPrice = $data['salesPrice'];
     $withoutVatTax = $this->roundInternal($this->executeCalculation($this->rules['VatTax'], $salesPrice));
     $withoutVatTax = !empty($withoutVatTax) ? $withoutVatTax : $salesPrice;
     vmdebug('calculateCostprice', $salesPrice, $withoutVatTax, $data);
     $withDiscount = $this->roundInternal($this->executeCalculation($this->rules['DATax'], $withoutVatTax));
     $withDiscount = !empty($withDiscount) ? $withDiscount : $withoutVatTax;
     // 		vmdebug('Entered final price '.$salesPrice.' discount '.$withDiscount);
     $withTax = $this->roundInternal($this->executeCalculation($this->rules['Tax'], $withDiscount));
     $withTax = !empty($withTax) ? $withTax : $withDiscount;
     $basePriceP = $this->roundInternal($this->executeCalculation($this->rules['DBTax'], $withTax));
     $basePriceP = !empty($basePriceP) ? $basePriceP : $withTax;
     $basePrice = $this->roundInternal($this->executeCalculation($this->rules['Marge'], $basePriceP));
     $basePrice = !empty($basePrice) ? $basePrice : $basePriceP;
     $productCurrency = CurrencyDisplay::getInstance();
     $costprice = $productCurrency->convertCurrencyTo($this->productCurrency, $basePrice, false);
     // 		$productCurrency = CurrencyDisplay::getInstance();
     $this->_revert = false;
     //vmdebug('calculateCostprice',$salesPrice,$costprice, $data);
     return $costprice;
 }
예제 #12
0
 public static function getInstance(&$query = null)
 {
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     if (isset($query['langswitch'])) {
         if ($query['langswitch'] != VMLANG) {
             $instanceKey = $query['langswitch'];
         }
         unset($query['langswitch']);
     } else {
         $instanceKey = VMLANG;
     }
     if (!array_key_exists($instanceKey, self::$_instances)) {
         self::$_instances[$instanceKey] = new vmrouterHelper($instanceKey, $query);
         if (self::$limit === null) {
             $mainframe = Jfactory::getApplication();
             $view = 'virtuemart';
             if (isset($query['view'])) {
                 $view = $query['view'];
             }
             self::$limit = $mainframe->getUserStateFromRequest('com_virtuemart.' . $view . '.limit', VmConfig::get('list_limit', 20), 'int');
             // 				self::$limit= $mainframe->getUserStateFromRequest('global.list.limit', 'limit', VmConfig::get('list_limit', 20), 'int');
         }
     }
     return self::$_instances[$instanceKey];
 }
예제 #13
0
 /**
  * return array of filters for where part of sql query
  *
  * @return array
  */
 function getFilter()
 {
     if (empty($this->_filter)) {
         // Get the paramaters of the active menu item
         $mainframe =& Jfactory::getApplication();
         $params =& $mainframe->getParams();
         $post = JRequest::get('request');
         $filter_continent = $this->getState('filter_continent');
         $filter_country = $this->getState('filter_country');
         $filter_state = $this->getState('filter_state');
         $filter_city = $this->getState('filter_city');
         $filter_venue = $this->getState('filter_venue');
         $filter_date_from = $this->getState('filter_date_from');
         $filter_date_to = $this->getState('filter_date_to');
         $filter_venuecategory = $this->getState('filter_venuecategory');
         $filter_category = $this->getState('filter_category');
         $filter_event = $this->getState('filter_event');
         $customs = $this->getState('filtercustom');
         $filter = $this->getState('filter');
         $filter_type = $this->getState('filter_type');
         $where = array();
         if ($filter) {
             // clean filter variables
             $filter = JString::strtolower($filter);
             $filter = $this->_db->Quote('%' . $this->_db->getEscaped($filter, true) . '%', false);
             $filter_type = JString::strtolower($filter_type);
             switch ($filter_type) {
                 case 'title':
                     $where[] = ' LOWER( a.title ) LIKE ' . $filter;
                     break;
                 case 'venue':
                     $where[] = ' LOWER( l.venue ) LIKE ' . $filter;
                     break;
                 case 'city':
                     $where[] = ' LOWER( l.city ) LIKE ' . $filter;
                     break;
             }
         }
         // filter date
         if (strtotime($filter_date_from)) {
             $date = $this->_db->Quote(strftime('%F', strtotime($filter_date_from)));
             $where[] = " CASE WHEN (x.enddates) THEN {$date} <= x.enddates ELSE {$date} <= x.dates END ";
         }
         if (strtotime($filter_date_to)) {
             $date = $this->_db->Quote(strftime('%F', strtotime($filter_date_to)));
             $where[] = " {$date} >= x.dates ";
         }
         if ($filter_venue) {
             $where[] = ' l.id = ' . $this->_db->Quote($filter_venue);
         } else {
             if (!is_null($filter_city) && $filter_city != "0") {
                 $where[] = ' l.city = ' . $this->_db->Quote($filter_city);
             } else {
                 if (!is_null($filter_state) && $filter_state != "0") {
                     $where[] = ' l.state = ' . $this->_db->Quote($filter_state);
                 } else {
                     if (!is_null($filter_country) && $filter_country != "0") {
                         $where[] = ' l.country = ' . $this->_db->Quote($filter_country);
                     } else {
                         if (!is_null($filter_continent) && $filter_continent != "0") {
                             $where[] = ' c.continent = ' . $this->_db->Quote($filter_continent);
                         }
                     }
                 }
             }
         }
         // filter category
         if ($filter_category) {
             $category = $this->getCategory((int) $filter_category);
             if ($category) {
                 $where[] = '(c.id = ' . $this->_db->Quote($category->id) . ' OR (c.lft > ' . $this->_db->Quote($category->lft) . ' AND c.rgt < ' . $this->_db->Quote($category->rgt) . '))';
             }
         }
         // filter venue category
         if ($filter_venuecategory) {
             $category = $this->getVenueCategory((int) $filter_venuecategory);
             if ($category) {
                 $where[] = '(vc.id = ' . $this->_db->Quote($category->id) . ' OR (vc.lft > ' . $this->_db->Quote($category->lft) . ' AND vc.rgt < ' . $this->_db->Quote($category->rgt) . '))';
             }
         }
         if ($filter_event) {
             $where[] = ' a.id = ' . $this->_db->Quote($filter_event);
         }
         //custom fields
         foreach ((array) $customs as $key => $custom) {
             if ($custom != '') {
                 if (is_array($custom)) {
                     $custom = implode("/n", $custom);
                 }
                 $where[] = ' custom' . $key . ' LIKE ' . $this->_db->Quote('%' . $custom . '%');
             }
         }
         $this->_filter = $where;
     }
     return $this->_filter;
 }
예제 #14
0
파일: field.php 프로젝트: q0821/esportshop
    function display($field, $value, $map, $inside, $options = '', $test = false, $allFields = null, $allValues = null)
    {
        if (empty($field->field_options['format'])) {
            $field->field_options['format'] = "%Y-%m-%d";
        }
        $format = $field->field_options['format'];
        $size = $options . empty($field->field_options['size']) ? '' : ' size="' . $field->field_options['size'] . '"';
        if (!HIKASHOP_J30) {
            JHTML::_('behavior.mootools');
        } else {
            JHTML::_('behavior.framework');
        }
        $processing = '';
        $message = '';
        $check = 'false';
        if (HIKASHOP_J30 && !empty($field->field_options['allow'])) {
            switch ($field->field_options['allow']) {
                case 'future':
                    $check = 'today>selectedDate';
                    $message = JText::_('SELECT_DATE_IN_FUTURE', true);
                    $format .= '",' . "\r\n" . 'disableFunc: function(date) { var today=new Date(); today.setHours(0);today.setMinutes(0);today.setSeconds(0);today.setMilliseconds(0); if(date < today) { return true; } return false; }, //';
                    break;
                case 'past':
                    $check = 'today<selectedDate';
                    $message = JText::_('SELECT_DATE_IN_PAST', true);
                    $format .= '",' . "\r\n" . 'disableFunc: function(date) { var today=new Date(); today.setHours(23);today.setMinutes(59);today.setSeconds(59);today.setMilliseconds(99); if(date > today) { return true; } return false; }, //';
                    break;
            }
        }
        if (!empty($check)) {
            $conversion = '';
            if ($field->field_options['format'] != "%Y-%m-%d") {
                $seps = preg_replace('#[a-z0-9%]#iU', '', $field->field_options['format']);
                $seps = str_replace(array('.', '-'), array('\\.', '\\-'), $seps);
                $mConv = false;
                $yP = -1;
                $mP = -1;
                $dP = -1;
                $i = 0;
                foreach (preg_split('#[' . $seps . ']#', $field->field_options['format']) as $d) {
                    switch ($d) {
                        case '%y':
                        case '%Y':
                            if ($yP < 0) {
                                $yP = $i;
                            }
                            break;
                        case '%b':
                        case '%B':
                            $mConv = true;
                        case '%m':
                            if ($mP < 0) {
                                $mP = $i;
                            }
                            break;
                        case '%d':
                        case '%e':
                            if ($dP < 0) {
                                $dP = $i;
                            }
                            break;
                    }
                    $i++;
                }
                $conversion .= '
				var reg = new RegExp("[' . $seps . ']+", "g");
				var elems = d.split(reg);
				';
                if ($mConv) {
                    $conversion .= 'for(var j=0;j<12;++j){if(Calendar._MN[j].substr(0,elems[' . $mP . '].length).toLowerCase()==elems[' . $mP . '].toLowerCase()){elems[' . $mP . ']=(j+1);break;}};
				';
                }
                $conversion .= 'd = elems[' . $yP . '] + "-" + elems[' . $mP . '] + "-" + elems[' . $dP . '];
				';
            }
            $js = 'function ' . $this->prefix . $field->field_namekey . $this->suffix . '_checkDate(nohide)
			{
				var selObj = document.getElementById(\'' . $this->prefix . $field->field_namekey . $this->suffix . '\');
				if( typeof(' . $this->prefix . $field->field_namekey . $this->suffix . '_preCheckDate) == "function" ) {
					try {
						if(!' . $this->prefix . $field->field_namekey . $this->suffix . '_preCheckDate(selObj))
							return false;
					} catch(ex) {}
				}
				if(selObj.value==\'\'){
					return true;
				}
				var d = selObj.value;' . $conversion . '
				var timestamp=Date.parse(d);
				var today=new Date();
				today.setHours(0);today.setMinutes(0);today.setSeconds(0);today.setMilliseconds(0);
				if(isNaN(timestamp)!=false){
					selObj.value=\'\';
					alert(\'' . JText::_('INCORRECT_DATE_FORMAT', true) . '\');
					return false;
				}
				var selectedDate = new Date(timestamp);
				selectedDate.setHours(0);selectedDate.setMinutes(0);selectedDate.setSeconds(0);selectedDate.setMilliseconds(0);

				' . $processing . '
				if(' . $check . '){
					selObj.value=\'\';
					alert(\'' . $message . '\');
				}else{
					if(!nohide) this.hide();
				}
				if( typeof(' . $this->prefix . $field->field_namekey . $this->suffix . '_postCheckDate) == "function" ) {
					try{ ' . $this->prefix . $field->field_namekey . $this->suffix . '_postCheckDate(selObj, selectedDate); } catch(ex){}
				}
			}';
            if (HIKASHOP_PHP5) {
                $document = JFactory::getDocument();
            } else {
                $document =& JFactory::getDocument();
            }
            $document->addScriptDeclaration($js);
            $size .= ' onChange="' . $this->prefix . $field->field_namekey . $this->suffix . '_checkDate(1);"';
        }
        if (HIKASHOP_J25 && !empty($value) && $field->field_options['format'] != "%Y-%m-%d") {
            $seps = preg_replace('#[a-z0-9%]#iU', '', $field->field_options['format']);
            $seps = str_replace(array('.', '-'), array('\\.', '\\-'), $seps);
            $mConv = false;
            $yP = -1;
            $mP = -1;
            $dP = -1;
            $i = 0;
            foreach (preg_split('#[' . $seps . ']#', $field->field_options['format']) as $d) {
                switch ($d) {
                    case '%y':
                    case '%Y':
                        if ($yP < 0) {
                            $yP = $i;
                        }
                        break;
                    case '%b':
                    case '%B':
                        $mConv = true;
                    case '%m':
                        if ($mP < 0) {
                            $mP = $i;
                        }
                        break;
                    case '%d':
                    case '%e':
                        if ($dP < 0) {
                            $dP = $i;
                        }
                        break;
                }
                $i++;
            }
            $elems = preg_split('#[' . $seps . ']#', $value);
            $value = @$elems[$yP] . '-' . @$elems[$mP] . '-' . @$elems[$dP];
            $app = Jfactory::getApplication();
            if ($app->isAdmin()) {
                $app->enqueueMessage('Since Joomla 2.5.24 it is not possible anymore to change the format of dates. If you need a different format, please use the advanced datepicker type of custom field.');
            }
            $format = "%Y-%m-%d";
            $field->field_options['format'] = $format;
        }
        if (HIKASHOP_J25 && !empty($value)) {
            try {
                JHTML::_('date', $value, null, null);
            } catch (Exception $e) {
                $value = '';
            }
        }
        JPluginHelper::importPlugin('hikashop');
        $dispatcher = JDispatcher::getInstance();
        $dispatcher->trigger('onFieldDateDisplay', array($field->field_namekey, $field, &$value, &$map, &$format, &$size));
        return JHTML::_('calendar', $value, $map, $this->prefix . $field->field_namekey . $this->suffix, $format, $size);
    }
예제 #15
0
 /**
  * Returns html code for the specified form fields
  * To modify previously posted data, the reference field must contain either:
  * - submit_key as a string
  * - an array of submitters ids
  *
  * @param   int    $form_id    form id
  * @param   mixed  $reference  submit_key or array of submitters ids
  * @param   int    $multi      number of instance of the form to display
  * @param   array  $options    array of possible options: eventdetails, booking, extrafields
  *
  * @return string
  */
 function getFormFields($form_id, $reference = null, $multi = 1, $options = array())
 {
     $uri = JURI::getInstance();
     $user = JFactory::getUser();
     $document =& JFactory::getDocument();
     $app =& Jfactory::getApplication();
     // was this form already submitted before (and there was an error for example, or editing)
     $answers = $this->getAnswers($reference);
     if ($answers && $reference) {
         $submit_key = $answers[0]->submit_key;
     } else {
         $submit_key = null;
     }
     $model_redform = new RedformModelRedform();
     $model_redform->setFormId($form_id);
     $form = $model_redform->getForm();
     $fields = $model_redform->getFormFields();
     // css
     $document->addStyleSheet(JURI::base() . 'components/com_redform/assets/css/tooltip.css');
     $document->addStyleSheet(JURI::base() . 'components/com_redform/assets/css/redform.css');
     // load jquery for the form javascript
     if (JRequest::getVar('format', 'html') == 'html') {
         JHTML::_('behavior.tooltip');
         jimport('joomla.html.html');
     }
     // custom tooltip
     $toolTipArray = array('className' => 'redformtip' . $form->classname);
     JHTML::_('behavior.tooltip', '.hasTipField', $toolTipArray);
     // currency for javascript
     $js = "var currency = \"" . $form->currency . "\";\n";
     $document->addScriptDeclaration($js);
     self::JsCheck();
     if ($form->show_js_price) {
         self::jsPrice();
     }
     // redmember integration: pull extra fields
     if ($user->get('id') && file_exists(JPATH_ROOT . DS . 'components' . DS . 'com_redmember')) {
         $this->getRedmemberfields($user);
     }
     /* Stuff to find and replace */
     $find = array(' ', '_', '-', '.', '/', '&', ';', ':', '?', '!', ',');
     $replace = '';
     $html = '<div id="redform' . $form->classname . '" class="redform-form">';
     if ($form->showname) {
         $html .= '<div id="formname">' . $form->formname . '</div>';
     }
     // for virtuemart
     if (JRequest::getInt('productid', false)) {
         $productinfo = $this->getProductinfo();
         if (!stristr('http', $productinfo->product_full_image)) {
             $productimage = $uri->root() . '/components/com_virtuemart/shop_image/product/' . $productinfo->product_full_image;
         } else {
             $productimage = $productinfo->product_full_image;
         }
         $html .= '<div id="productimage">' . JHTML::_('image', $productimage, $productinfo->product_name) . '</div>';
         $html .= '<div id="productname">' . $productinfo->product_name . '</div>';
     }
     if ($multi > 1 && $user->id == 0) {
         $html .= '<div id="needlogin">' . JText::_('COM_REDFORM_LOGIN_BEFORE_MULTI_SIGNUP') . '</div>';
         $multi = 1;
     }
     // limit to max 30 sumbissions at the same time...
     if ($multi > 30) {
         $multi = 30;
     }
     if ($multi > 1) {
         if (empty($answers)) {
             // link to add signups
             $html .= '<div id="signupuser"><a href="javascript: AddUser();">' . JText::_('COM_REDFORM_SIGN_UP_USER') . '</a></div>';
         }
         // signups display controls
         $html .= '<div id="signedusers" style="float: right">';
         $html .= '<div><a href="javascript: ShowAllUsers(true);" >' . JText::_('COM_REDFORM_SHOW_ALL_USERS') . '</a></div>' . '<div><a href="javascript: ShowAllUsers(false);" >' . JText::_('COM_REDFORM_HIDE_ALL_USERS') . '</a></div>' . '<ul>' . JText::_('COM_REDFORM_Signed_up') . ':';
         $html .= '<li><a href="javascript: ShowSingleForm(\'div#formfield1\');"># 1</a></li>';
         if ($answers) {
             for ($k = 2; $k < count($answers) + 1; $k++) {
                 $html .= '<li><a href="javascript: ShowSingleForm(\'div#formfield' . $k . '\');"># ' . $k . '</a></li>';
             }
         }
         $html .= '</ul>';
         $html .= '</div>';
     }
     if ($answers) {
         // set multi to number of answers...
         $multi = count($answers);
     }
     /* Loop through here for as many forms there are */
     for ($signup = 1; $signup <= $multi; $signup++) {
         if ($answers && $answers[$signup - 1]->sid) {
             $submitter_id = $answers[$signup - 1]->sid;
             $html .= '<input type="hidden" name="submitter_id' . $signup . '" value="' . $submitter_id . '" />';
         } else {
             $submitter_id = 0;
         }
         /* Make a collapsable box */
         $html .= '<div id="formfield' . $signup . '" class="formbox" style="display: ' . ($signup == 1 ? 'block' : 'none') . ';">';
         if ($multi > 1) {
             $html .= '<fieldset><legend>' . JText::sprintf('COM_REDFORM_FIELDSET_SIGNUP_NB', $signup) . '</legend>';
         }
         if ($form->activatepayment && isset($options['eventdetails']) && $options['eventdetails']->course_price > 0) {
             $html .= '<div class="eventprice" price="' . $options['eventdetails']->course_price . '">' . JText::_('COM_REDFORM_Registration_price') . ': ' . $form->currency . ' ' . $options['eventdetails']->course_price . '</div>';
         }
         if ($form->activatepayment && isset($options['booking']) && $options['booking']->course_price > 0) {
             $html .= '<div class="bookingprice" price="' . $options['booking']->course_price . '">' . JText::_('COM_REDFORM_Registration_price') . ': ' . $form->currency . ' ' . $options['booking']->course_price . '</div>';
         }
         if (isset($options['extrafields']) && count($options['extrafields'])) {
             foreach ($options['extrafields'] as $field) {
                 $html .= '<div class="fieldline' . (isset($field['class']) && !empty($field['class']) ? ' ' . $field['class'] : '') . '">';
                 $html .= '<div class="label">' . $field['label'] . '</div>';
                 $html .= '<div class="field">' . $field['field'] . '</div>';
                 $html .= '</div>';
             }
         }
         foreach ($fields as $key => $field) {
             if (!($app->isAdmin() || $field->published)) {
                 // only display unpublished fields in backend form
                 continue;
             }
             if ($field->fieldtype != 'hidden') {
                 $html .= '<div id="fieldline_' . $field->id . '" class="fieldline type-' . $field->fieldtype . $field->parameters->get('class', '') . '">';
             }
             $values = $model_redform->getFormValues($field->id);
             if ($field->fieldtype == 'info') {
                 if ($values && count($values)) {
                     $html .= '<div class="infofield">' . $values[0]->value . '</div>';
                 }
                 $html .= '</div>';
                 continue;
             }
             $cleanfield = 'field_' . $field->id;
             if ($field->fieldtype == 'hidden') {
                 $element = "";
             } else {
                 $element = "<div class=\"field\">";
             }
             switch ($field->fieldtype) {
                 case 'radio':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= '<div class="fieldoptions">';
                     foreach ($values as $id => $value) {
                         $element .= '<div class="fieldoption">';
                         $element .= "<input class=\"" . $field->parameters->get('class', '') . " ";
                         if ($field->validate) {
                             $element .= "required";
                         }
                         $element .= "\"";
                         if ($field->readonly && !$app->isAdmin()) {
                             $element .= ' readonly="readonly"';
                         }
                         if ($answers) {
                             if (in_array($value->value, explode('~~~', $answers[$signup - 1]->fields->{$cleanfield}))) {
                                 $element .= ' checked="checked"';
                             }
                         } else {
                             if ($user->get($field->redmember_field)) {
                                 $fvalues = explode(',', $user->get($field->redmember_field));
                                 if (in_array($value->value, $fvalues)) {
                                     $element .= ' checked="checked"';
                                 }
                             } else {
                                 if ($field->default) {
                                     $def_vals = explode("\n", $field->default);
                                     foreach ($def_vals as $val) {
                                         if ($value->value == trim($val)) {
                                             $element .= ' checked="checked"';
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                         $element .= ' type="radio" name="field' . $field->id . '.' . $signup . '[radio][]" value="' . $value->id . '" price="' . $value->price . '" />' . $value->label . "\n";
                         $element .= "</div>\n";
                     }
                     $element .= "</div>\n";
                     break;
                 case 'textarea':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= '<textarea class="' . $field->parameters->get('class', '');
                     if ($field->validate) {
                         $element .= ' required';
                     }
                     $element .= '" name="field' . $field->id . '.' . $signup . '[textarea]"';
                     $element .= ' id="field' . $field->id . '" ';
                     $element .= ' cols="' . $field->parameters->get('cols', 25) . '" rows="' . $field->parameters->get('rows', 6) . '"';
                     if ($field->readonly && !$app->isAdmin()) {
                         $element .= ' readonly="readonly"';
                     }
                     $element .= ">";
                     if ($answers) {
                         if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             $element .= $answers[$signup - 1]->fields->{$cleanfield};
                         }
                     } else {
                         if ($user->get($field->redmember_field)) {
                             $element .= $user->get($field->redmember_field);
                         } else {
                             $element .= $field->default;
                         }
                     }
                     $element .= "</textarea>\n";
                     break;
                 case 'wysiwyg':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $content = '';
                     if ($answers) {
                         if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             $element .= $answers[$signup - 1]->fields->{$cleanfield};
                         }
                     } else {
                         if ($user->get($field->redmember_field)) {
                             $content = $user->get($field->redmember_field);
                         } else {
                             $content = $field->default;
                         }
                     }
                     $editor =& JFactory::getEditor();
                     // Cannot have buttons, it triggers an error with tinymce for unregistered users
                     $element .= $editor->display("field" . $field->id . '.' . $signup . "[wysiwyg]", $content, '100%;', '200', '75', '20', false);
                     $element .= "\n";
                     break;
                 case 'email':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= "<div class=\"emailfields\">";
                     $element .= "<div class=\"emailfield\">";
                     $element .= "<input class=\"" . $field->parameters->get('class', '') . " ";
                     if ($field->validate) {
                         $element .= "required";
                     }
                     $element .= "\" type=\"text\" name=\"field" . $field->id . '.' . $signup . "[email][]\"";
                     $element .= ' id="field' . $field->id . '" ';
                     $element .= ' size="' . $field->parameters->get('size', 25) . '"';
                     $element .= ' maxlength="' . $field->parameters->get('maxlength', 250) . '"';
                     if ($field->readonly && !$app->isAdmin()) {
                         $element .= ' readonly="readonly"';
                     }
                     $element .= ' value="';
                     if ($answers) {
                         if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             $element .= $answers[$signup - 1]->fields->{$cleanfield};
                         }
                     } else {
                         if ($user->get($field->redmember_field)) {
                             $element .= $user->get($field->redmember_field);
                         } else {
                             if ($signup == 1 && $user->email) {
                                 $element .= $user->email;
                             } else {
                                 $element .= $field->default;
                             }
                         }
                     }
                     $element .= "\" />\n";
                     $element .= "</div>\n";
                     /* check if there is a mailing list integration */
                     if (strlen($field->listnames) > 0) {
                         $listnames = explode(";", $field->listnames);
                         if (count($listnames)) {
                             if ($field->parameters->get('force_mailing_list', 0)) {
                                 // auto subscribe => use hidden field
                                 foreach ($listnames as $listkey => $listname) {
                                     $element .= '<input type="hidden" name="field' . $field->id . '.' . $signup . '[email][listnames][]" value="' . $listname . '" />';
                                 }
                             } else {
                                 $element .= "<div class=\"newsletterfields\">";
                                 $element .= '<div id="signuptitle">' . JText::_('COM_REDFORM_SIGN_UP_MAILINGLIST') . '</div>';
                                 $element .= "<div class=\"field" . $field->fieldtype . "_listnames\">";
                                 foreach ($listnames as $listkey => $listname) {
                                     $element .= "<div class=\"field_" . $listkey . "\">";
                                     $element .= "<input type=\"checkbox\" name=\"field" . $field->id . '.' . $signup . "[email][listnames][]\" value=\"" . $listname . "\" />" . $listname . '</div>';
                                 }
                                 $element .= "</div>\n";
                                 $element .= "</div>\n";
                             }
                         }
                     }
                     $element .= "</div>\n";
                     break;
                 case 'fullname':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= "<input class=\"" . $field->parameters->get('class', '');
                     if ($field->validate) {
                         $element .= " required";
                     }
                     $element .= "\" type=\"text\" name=\"field" . $field->id . '.' . $signup . "[fullname][]\"";
                     $element .= ' id="field' . $field->id . '" ';
                     $element .= ' size="' . $field->parameters->get('size', 25) . '"';
                     $element .= ' maxlength="' . $field->parameters->get('maxlength', 250) . '"';
                     if ($field->readonly && !$app->isAdmin()) {
                         $element .= ' readonly="readonly"';
                     }
                     $element .= ' value="';
                     if ($answers) {
                         if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             $element .= $answers[$signup - 1]->fields->{$cleanfield};
                         }
                     } else {
                         if ($user->get($field->redmember_field)) {
                             $element .= $user->get($field->redmember_field);
                         } else {
                             if ($signup == 1 && $user->name) {
                                 $element .= $user->name;
                             } else {
                                 $element .= $field->default;
                             }
                         }
                     }
                     $element .= "\" />\n";
                     break;
                 case 'username':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= "<input class=\"" . $field->parameters->get('class', '');
                     if ($field->validate) {
                         $element .= " required";
                     }
                     $element .= "\" type=\"text\" name=\"field" . $field->id . '.' . $signup . "[username][]\"";
                     $element .= ' id="field' . $field->id . '" ';
                     $element .= ' size="' . $field->parameters->get('size', 25) . '"';
                     $element .= ' maxlength="' . $field->parameters->get('maxlength', 250) . '"';
                     if ($field->readonly && !$app->isAdmin()) {
                         $element .= ' readonly="readonly"';
                     }
                     $element .= ' value="';
                     if ($answers) {
                         if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             $element .= $answers[$signup - 1]->fields->{$cleanfield};
                         }
                     } else {
                         if ($user->get($field->redmember_field)) {
                             $element .= $user->get($field->redmember_field);
                         } else {
                             if ($signup == 1 && $user->username) {
                                 $element .= $user->username;
                             } else {
                                 $element .= $field->default;
                             }
                         }
                     }
                     $element .= "\" />\n";
                     break;
                 case 'textfield':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= "<input class=\"" . $field->parameters->get('class', '');
                     if ($field->validate) {
                         $element .= " required";
                     }
                     $element .= "\" type=\"text\" name=\"field" . $field->id . '.' . $signup . "[text][]\"";
                     $element .= ' id="field' . $field->id . '" ';
                     $element .= ' size="' . $field->parameters->get('size', 25) . '"';
                     $element .= ' maxlength="' . $field->parameters->get('maxlength', 250) . '"';
                     if ($field->readonly && !$app->isAdmin()) {
                         $element .= ' readonly="readonly"';
                     }
                     $element .= ' value="';
                     if ($answers) {
                         if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             $element .= $answers[$signup - 1]->fields->{$cleanfield};
                         }
                     } else {
                         if ($user->get($field->redmember_field)) {
                             $element .= $user->get($field->redmember_field);
                         } else {
                             $element .= $field->default;
                         }
                     }
                     $element .= "\" />\n";
                     break;
                 case 'hidden':
                     $label = '';
                     $element .= "<input class=\"" . $field->parameters->get('class', '');
                     if ($field->validate) {
                         $element .= " required";
                     }
                     $element .= "\" type=\"hidden\" name=\"field" . $field->id . '.' . $signup . "[hidden][]\"";
                     $element .= ' id="field' . $field->id . '" ';
                     $element .= ' value="';
                     if ($answers) {
                         if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             $element .= $answers[$signup - 1]->fields->{$cleanfield};
                         }
                     } else {
                         if ($user->get($field->redmember_field)) {
                             $element .= $user->get($field->redmember_field);
                         } else {
                             switch ($field->parameters->get('valuemethod', 'constant')) {
                                 case 'jrequest':
                                     $varname = $field->parameters->get('jrequestvar');
                                     if (!$varname) {
                                         $app->enqueueMessage(JText::_('COM_REDFORM_ERROR_HIDDEN_FIELD_VARNAME_NOT_DEFINED'), 'warning');
                                     } else {
                                         $element .= JRequest::getVar($varname);
                                     }
                                     break;
                                 case 'phpeval':
                                     $code = $field->parameters->get('phpeval');
                                     $element .= eval($code);
                                     break;
                                 case 'constant':
                                 default:
                                     $element .= $field->default;
                             }
                         }
                     }
                     $element .= "\" />\n";
                     break;
                 case 'date':
                     JHTML::_('behavior.calendar');
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     if ($answers) {
                         if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             $val = $answers[$signup - 1]->fields->{$cleanfield};
                         } else {
                             $val = null;
                         }
                     } elseif ($user->get($field->redmember_field)) {
                         // redmember uses unix timestamp
                         $val = strftime($field->parameters->get('dateformat', '%Y-%m-%d'), $user->get($field->redmember_field));
                     } else {
                         if ($field->default && strtotime($field->default)) {
                             $val = strftime($field->parameters->get('dateformat', '%Y-%m-%d'), strtotime($field->default));
                         } else {
                             $val = null;
                         }
                     }
                     if ($val && !strtotime($val)) {
                         $element .= '<span>(invalid: ' . $val . ')</span>';
                         $val = null;
                     }
                     $class = $field->parameters->get('class', '');
                     if ($field->validate) {
                         $class .= " required";
                     }
                     if ($field->readonly && !$app->isAdmin()) {
                         $element .= $val;
                         $element .= '<input class="' . $class . '"';
                         $element .= " type=\"hidden\" name=\"field" . $field->id . '.' . $signup . "[text][]\"";
                         $element .= ' id="field' . $field->id . '" ';
                         $element .= ' size="' . $field->parameters->get('size', strlen($val) + 1) . '"';
                         $element .= ' maxlength="' . $field->parameters->get('maxlength', 25) . '"';
                         $element .= ' readonly="readonly"';
                         $element .= ' value="' . $val . "\" />\n";
                     } else {
                         $attribs = array('class' => $class);
                         $element .= JHTML::_('calendar', $val, 'field' . $field->id . '.' . $signup . '[date]', 'field' . $field->id, $field->parameters->get('dateformat', '%Y-%m-%d'), $attribs);
                     }
                     break;
                 case 'price':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     // if has not null value, it is a fixed price, if not this is a user input price
                     if (count($values) && $values[0]) {
                         $element .= $form->currency . ' ' . $values[0]->value;
                         $element .= '<input type="hidden" class="rfprice" id="field' . $field->id . '" name="field' . $field->id . '.' . $signup . '[price][]" value="' . $values[0]->value . '" />';
                     } else {
                         $element .= '<input class="rfprice ' . $field->parameters->get('class', '') . ($field->validate ? " required" : '') . '"';
                         $element .= ' type="text" name="field' . $field->id . '.' . $signup . '[price][]"';
                         $element .= ' id="field' . $field->id . '" ';
                         $element .= ' size="' . $field->parameters->get('size', 25) . '"';
                         $element .= ' maxlength="' . $field->parameters->get('maxlength', 250) . '"';
                         if ($field->readonly && !$app->isAdmin()) {
                             $element .= ' readonly="readonly"';
                         }
                         $element .= ' value="';
                         if ($answers) {
                             if (isset($answers[$signup - 1]->fields->{$cleanfield})) {
                                 $element .= $answers[$signup - 1]->fields->{$cleanfield};
                             }
                         } else {
                             if ($user->get($field->redmember_field)) {
                                 $element .= $user->get($field->redmember_field);
                             } else {
                                 $element .= $field->default;
                             }
                         }
                         $element .= '"';
                         $element .= '/>';
                     }
                     $element .= "\n";
                     break;
                 case 'checkbox':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= '<div class="fieldoptions">';
                     foreach ($values as $id => $value) {
                         $element .= '<div class="fieldoption">';
                         $element .= "<input class=\"" . $field->parameters->get('class', '') . " ";
                         if ($field->validate) {
                             $element .= "required";
                         }
                         $element .= "\"";
                         if ($field->readonly && !$app->isAdmin()) {
                             $element .= ' readonly="readonly"';
                         }
                         if ($answers && isset($answers[$signup - 1]->fields->{$cleanfield})) {
                             if (in_array($value->value, explode('~~~', $answers[$signup - 1]->fields->{$cleanfield}))) {
                                 $element .= ' checked="checked"';
                             }
                         } else {
                             if ($user->get($field->redmember_field)) {
                                 $fvalues = explode(',', $user->get($field->redmember_field));
                                 if (in_array($value->value, $fvalues)) {
                                     $element .= ' checked="checked"';
                                 }
                             } else {
                                 if ($field->default) {
                                     $def_vals = explode("\n", $field->default);
                                     foreach ($def_vals as $val) {
                                         if ($value->value == trim($val)) {
                                             $element .= ' checked="checked"';
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                         $element .= ' type="checkbox" name="field' . $field->id . '.' . $signup . '[checkbox][]" value="' . $value->value . '" price="' . $value->price . '" /> ' . $value->label . "\n";
                         $element .= "</div>\n";
                     }
                     $element .= "</div>\n";
                     break;
                 case 'select':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= "<select id=\"field" . $field->id . "\" name=\"field" . $field->id . '.' . $signup . "[select][]\" class=\"" . $field->parameters->get('class', '') . ($field->validate ? " required" : '') . "\"";
                     $element .= ">";
                     foreach ($values as $id => $value) {
                         $element .= "<option value=\"" . $value->value . "\"";
                         if ($answers) {
                             if ($answers[$signup - 1]->fields->{$cleanfield} == $value->value) {
                                 $element .= ' selected="selected"';
                             }
                         } else {
                             if ($user->get($field->redmember_field) == $value->value) {
                                 $element .= ' selected="selected"';
                             } else {
                                 if ($field->default) {
                                     $def_vals = explode("\n", $field->default);
                                     foreach ($def_vals as $val) {
                                         if ($value->value == trim($val)) {
                                             $element .= ' selected="selected"';
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                         $element .= ' price="' . $value->price . '" >' . $value->label . "</option>";
                     }
                     $element .= '</select>';
                     $element .= "\n";
                     break;
                 case 'multiselect':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= '<select id="field' . $field->id . '" name="field' . $field->id . '.' . $signup . '[multiselect][]"' . ' multiple="multiple" size="' . $field->parameters->get('size', 5) . '"' . ' class="' . trim($field->parameters->get('class', '') . ($field->validate ? " required" : '')) . '"';
                     $element .= '>';
                     foreach ($values as $id => $value) {
                         $element .= "<option value=\"" . $value->value . "\"";
                         if ($answers) {
                             if (in_array($value->value, explode('~~~', $answers[$signup - 1]->fields->{$cleanfield}))) {
                                 $element .= ' selected="selected"';
                             }
                         } else {
                             if ($user->get($field->redmember_field)) {
                                 $fvalues = explode(',', $user->get($field->redmember_field));
                                 if (in_array($value->value, $fvalues)) {
                                     $element .= ' selected="selected"';
                                 }
                             } else {
                                 if ($field->default) {
                                     $def_vals = explode("\n", $field->default);
                                     foreach ($def_vals as $val) {
                                         if ($value->value == trim($val)) {
                                             $element .= ' selected="selected"';
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                         $element .= ' price="' . $value->price . '" />' . $value->label . "</option>";
                     }
                     $element .= '</select>';
                     $element .= "\n";
                     break;
                 case 'recipients':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     $element .= "<select id=\"field" . $field->id . "\" name=\"field" . $field->id . '.' . $signup . "[recipients][]\"" . ($field->parameters->get('multiple', 1) ? ' multiple="multiple"' : '') . ' size="' . $field->parameters->get('size', 5) . '"' . ' class="' . $field->parameters->get('class', '') . ($field->validate ? " required" : '') . '"';
                     $element .= '>';
                     foreach ($values as $id => $value) {
                         $element .= "<option value=\"" . $value->value . "\"";
                         if ($answers) {
                             if (in_array($value->value, explode('~~~', $answers[$signup - 1]->fields->{$cleanfield}))) {
                                 $element .= ' selected="selected"';
                             }
                         } else {
                             if ($user->get($field->redmember_field)) {
                                 $fvalues = explode(',', $user->get($field->redmember_field));
                                 if (in_array($value->value, $fvalues)) {
                                     $element .= ' selected="selected"';
                                 }
                             } else {
                                 if ($field->default) {
                                     $def_vals = explode("\n", $field->default);
                                     foreach ($def_vals as $val) {
                                         if ($value->value == trim($val)) {
                                             $element .= ' selected="selected"';
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                         $element .= " >" . $value->label . "</option>";
                     }
                     $element .= '</select>';
                     $element .= "\n";
                     break;
                 case 'fileupload':
                     $label = '<div id="field_' . $field->id . '" class="label"><label for="field' . $field->id . '">' . $field->field . '</label></div>';
                     if ($submitter_id == 0) {
                         $attr = array('type="file"');
                         $attr[] = 'id="field' . $field->id . '"';
                         $attr[] = 'name="field' . $field->id . '.' . $signup . '[fileupload][]"';
                         $class = array('fileupload' . $field->parameters->get('class', ''));
                         if ($field->validate) {
                             $class[] = 'required';
                         }
                         $attr[] = 'class="' . implode(' ', $class) . '"';
                         $element .= '<input ' . implode(' ', $attr) . '/>';
                     }
                     $element .= "\n";
                     break;
             }
             if ($field->fieldtype == 'hidden') {
                 $html .= $element;
             } else {
                 $html .= $label . $element;
                 $html .= '</div>';
                 // fieldtype div
                 if ($field->validate || strlen($field->tooltip)) {
                     $html .= '<div class="fieldinfo">';
                     if ($field->validate) {
                         $img = JHTML::image(JURI::root() . 'components/com_redform/assets/images/warning.png', JText::_('COM_REDFORM_Required'));
                         $html .= ' <span class="editlinktip hasTipField" title="' . JText::_('COM_REDFORM_Required') . '" style="text-decoration: none; color: #333;">' . $img . '</span>';
                     }
                     if (strlen($field->tooltip) > 0) {
                         $img = JHTML::image(JURI::root() . 'components/com_redform/assets/images/info.png', JText::_('COM_REDFORM_ToolTip'));
                         $html .= ' <span class="editlinktip hasTipField" title="' . htmlspecialchars($field->field) . '::' . htmlspecialchars($field->tooltip) . '" style="text-decoration: none; color: #333;">' . $img . '</span>';
                     }
                     $html .= '</div>';
                 }
                 $html .= '</div>';
                 // fieldline_ div
             }
         }
         if ($multi > 1) {
             $html .= '</fieldset>';
         }
         if (isset($this->_rwfparams['uid'])) {
             $html .= '<div>' . JText::_('COM_REDFORM_JOOMLA_USER') . ': ' . JHTML::_('list.users', 'uid', $this->_rwfparams['uid'], 1, NULL, 'name', 0) . '</div>';
         }
         $html .= '</div>';
         // formfield div
     }
     //TODO: redcompetition should use redform core directly
     /* Add any redCOMPETITION values */
     $redcompetition = JRequest::getVar('redcompetition', false);
     if ($redcompetition) {
         $html .= '<input type="hidden" name="competition_task" value="' . $redcompetition->task . '" />';
         $html .= '<input type="hidden" name="competition_id" value="' . $redcompetition->competitionid . '" />';
     }
     // Get an unique id just for the submission
     $uniq = uniqid();
     /* Add the captcha, only if initial submit */
     if ($form->captchaactive && empty($submit_key)) {
         JPluginHelper::importPlugin('redform_captcha');
         $captcha = '';
         $dispatcher =& JDispatcher::getInstance();
         $results = $dispatcher->trigger('onGetCaptchaField', array(&$captcha));
         if (count($results)) {
             $html .= '<div class="fieldline">';
             $html .= '<div class="label"><label>' . JText::_('COM_REDFORM_CAPTCHA_LABEL') . '</label></div>';
             $html .= '<div id="redformcaptcha">';
             $html .= $captcha;
             $html .= '</div>';
             $html .= '</div>';
             JFactory::getSession()->set('checkcaptcha' . $uniq, 1);
         }
     }
     if (!empty($submit_key)) {
         // Link to add signups
         $html .= '<input type="hidden" name="submit_key" value="' . $submit_key . '" />';
     }
     $html .= '<input type="hidden" name="curform" value="' . ($answers && count($answers) ? count($answers) : 1) . '" />';
     $html .= '<input type="hidden" name="form_id" value="' . $form_id . '" />';
     $html .= '<input type="hidden" name="multi" value="' . $multi . '" />';
     $html .= '<input type="hidden" name="' . JSession::getFormToken() . '" value="' . $uniq . '" />';
     $html .= '</div>';
     // div #redform
     return $html;
 }
예제 #16
0
 public static function getCurrency(&$cart)
 {
     static $curr = 0;
     if (!empty($curr)) {
         return $curr;
     }
     if (!empty($cart)) {
         $vendorId = $cart->vendorId;
     } else {
         $vendorId = 1;
     }
     $db = JFactory::getDBO();
     $q = 'SELECT `vendor_accepted_currencies`, `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id`=' . $vendorId;
     $db->setQuery($q);
     $vendor_currency = $db->loadAssoc();
     $mainframe = Jfactory::getApplication();
     $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id', $vendor_currency['vendor_currency']));
     $curr = $virtuemart_currency_id;
     return $virtuemart_currency_id;
 }
예제 #17
0
 function display($tpl = null)
 {
     $mainframe = Jfactory::getApplication();
     $option = vRequest::getCmd('option');
     //Load helpers
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     /* Get the review IDs to retrieve (input variable may be cid, cid[] or virtuemart_rating_review_id */
     $cids = vRequest::getInt('cid', vRequest::getVar('virtuemart_rating_review_id', 0));
     if ($cids && !is_array($cids)) {
         $cids = array($cids);
     }
     // Figure out maximum rating scale (default is 5 stars)
     $this->max_rating = VmConfig::get('vm_maximum_rating_scale', 5);
     $model = VmModel::getModel();
     $this->SetViewTitle('REVIEW_RATE');
     /* Get the task */
     $task = vRequest::getCmd('task');
     switch ($task) {
         case 'edit':
             /* Get the data
             				$rating = $model->getRating($cids);
             				$this->addStandardEditViewCommands();
             
             				break;*/
         /* Get the data
         				$rating = $model->getRating($cids);
         				$this->addStandardEditViewCommands();
         
         				break;*/
         case 'listreviews':
             /* Get the data */
             $this->addStandardDefaultViewLists($model);
             $virtuemart_product_id = vRequest::getInt('virtuemart_product_id');
             if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) {
                 $virtuemart_product_id = (int) $virtuemart_product_id[0];
             } else {
                 $virtuemart_product_id = (int) $virtuemart_product_id;
             }
             $this->reviewslist = $model->getReviews($virtuemart_product_id);
             $lists = array();
             $lists['filter_order'] = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', '', 'cmd');
             $lists['filter_order_Dir'] = $mainframe->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
             $this->pagination = $model->getPagination();
             $this->addStandardDefaultViewCommands(false, true);
             break;
         case 'edit_review':
             JToolBarHelper::divider();
             // Get the data
             $this->rating = $model->getReview($cids);
             if (!empty($this->rating)) {
                 $this->SetViewTitle('REVIEW_RATE', $this->rating->product_name . " (" . $this->rating->customer . ")");
                 JToolBarHelper::custom('saveReview', 'save', 'save', vmText::_('COM_VIRTUEMART_SAVE'), false);
                 JToolBarHelper::custom('applyReview', 'apply', 'apply', vmText::_('COM_VIRTUEMART_APPLY'), false);
             } else {
                 $this->SetViewTitle('REVIEW_RATE', 'ERROR');
             }
             JToolBarHelper::custom('cancelEditReview', 'cancel', 'cancel', vmText::_('COM_VIRTUEMART_CANCEL'), false);
             break;
         default:
             $this->addStandardDefaultViewCommands(false, true);
             $this->addStandardDefaultViewLists($model);
             $this->ratingslist = $model->getRatings();
             $this->pagination = $model->getPagination();
             break;
     }
     parent::display($tpl);
 }
예제 #18
0
 /**
  * do the plugin action
  *
  */
 function process(&$data, &$tableModel)
 {
     //jimport('joomla.mail.helper');
     $params =& $this->getParams();
     $app =& Jfactory::getApplication();
     $gcal_url = $params->get('gcal_sync_gcal_url');
     $matches = array();
     // this matches a standard GCal URL, found under the Google "Calender Details" tab, using the XML button.
     // It should match any form, for public or private ...
     // http://www.google.com/calendar/feeds/hugh.messenger%40gmail.com/public/basic
     // http://www.google.com/calendar/feeds/hugh.messenger%40gmail.com/private-3081eca2b0asdfasdf8f106ea6f63343056/basic
     $gcal_url = str_replace('/basic', '/full', $gcal_url);
     $gcal_url = preg_replace('#/private-\\w+/#', '/private/', $gcal_url);
     if (preg_match('#feeds/(.*?)/(\\w+-\\w+|\\w+)/(\\w+)#', $gcal_url, $matches)) {
         // grab the bits of the URL we need for the Zend framework call
         $gcal_user = $matches[1];
         $gcal_visibility = $matches[2];
         $gcal_projection = $matches[3];
         $gcal_email = urldecode($gcal_user);
         // grab the table model and find table name and PK
         $table =& $tableModel->getTable();
         $table_name = $table->db_table_name;
         $primary_key = $table->db_primary_key;
         $primary_key_element_long = FabrikString::safeColNameToArrayKey($table->db_primary_key);
         // for now, we have to read the table ourselves.  We can't rely on the $data passed to us
         // because it can be filtered, and we need to see all records to know if the GCal events
         // already exist in the table
         /*
         $mydata = array();
         $db = JFactory::getDBO();
         $db->setQuery("SELECT * FROM $table_name");
         $mydata[0] = $db->loadObjectList();
         */
         $db = JFactory::getDBO();
         $mydata =& $data;
         // grab all the field names to use
         $gcal_label_element_long = $params->get('gcal_sync_label_element');
         $gcal_label_element = FabrikString::shortColName($gcal_label_element_long);
         $gcal_desc_element_long = $params->get('gcal_sync_desc_element');
         $gcal_desc_element = FabrikString::shortColName($gcal_desc_element_long);
         $gcal_start_date_element_long = $params->get('gcal_sync_startdate_element');
         $gcal_start_date_element = FabrikString::shortColName($gcal_start_date_element_long);
         $gcal_end_date_element_long = $params->get('gcal_sync_enddate_element');
         $gcal_end_date_element = FabrikString::shortColName($gcal_end_date_element_long);
         $gcal_id_element_long = $params->get('gcal_sync_id_element');
         $gcal_id_element = FabrikString::shortColName($gcal_id_element_long);
         $gcal_userid_element_long = $params->get('gcal_sync_userid_element');
         $gcal_userid_element = FabrikString::shortColName($gcal_userid_element_long);
         // sanity check, make sure required elements have been specified
         if (empty($gcal_label_element_long) || empty($gcal_start_date_element_long) || empty($gcal_end_date_element_long) || empty($gcal_id_element_long)) {
             JError::raiseNotice(500, 'missing gcal data');
             return;
         }
         // if they selected a User ID element to use, see if we can find a J! user with matching email to this feed's owner
         $our_userid = 0;
         if ($gcal_userid_element_long) {
             $db->setQuery("SELECT id FROM " . $db->nameQuote('#__users') . " WHERE " . $db->nameQUote('email') . " = " . $db->Quote($gcal_email));
             $our_userid = $db->loadResult();
             // better make sure it's not NULL, in case underlying column is NOT NULL
             if (empty($our_userid)) {
                 $our_userid = 0;
             }
         }
         // include the Zend stuff
         $path = JPATH_SITE . DS . 'libraries';
         set_include_path(get_include_path() . PATH_SEPARATOR . $path);
         $path = get_include_path();
         require_once 'Zend/Loader.php';
         Zend_Loader::loadClass('Zend_Gdata');
         Zend_Loader::loadClass('Zend_Uri_Http');
         // Won't need these loaded until we add sync'ing events back to Google
         //Zend_Loader::loadClass('Zend_Gdata_AuthSub');
         //Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
         Zend_Loader::loadClass('Zend_Gdata_Calendar');
         // see if they want to sync to gcal, and provided a login
         $gcal_sync_upload = $params->get('gcal_sync_upload_events', 'from');
         if ($gcal_sync_upload == 'both' || $gcal_sync_upload == 'to') {
             Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
             $email = $params->get('gcal_sync_login', '');
             $passwd = $params->get('gcal_sync_passwd', '');
             try {
                 $client = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, 'cl');
             } catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
                 echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
                 echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
                 return;
             } catch (Zend_Gdata_App_AuthException $ae) {
                 echo 'Problem authenticating: ' . $ae->exception() . "\n";
                 return;
             }
             $gdataCal = new Zend_Gdata_calendar($client);
         } else {
             $gdataCal = new Zend_Gdata_calendar();
         }
         // set up and execute the call to grab the feed from google
         $query = $gdataCal->newEventQuery();
         $query->setUser($gcal_user);
         $query->setVisibility($gcal_visibility);
         $query->setProjection($gcal_projection);
         $eventFeed = $gdataCal->getCalendarEventFeed($query);
         // build an array of the events from the feed, indexed by the Google ID
         $event_ids = array();
         foreach ($eventFeed as $key => $event) {
             $short_id = $this->_getGcalShortId($event->id->text);
             $gcal_event_ids[$short_id] =& $eventFeed[$key];
         }
         // run through our table data, and build an array of our events indexed by the Google ID
         // (of course not all events may have a Google ID)
         $our_event_ids = array();
         $our_upload_ids = array();
         foreach ($mydata as $gkey => $group) {
             if (is_array($group)) {
                 foreach ($group as $rkey => $row) {
                     if ($row->{$gcal_id_element_long}) {
                         $our_event_ids[$row->{$gcal_id_element_long}] =& $mydata[$gkey][$rkey];
                     } else {
                         $our_upload_ids[] =& $mydata[$gkey][$rkey];
                     }
                 }
             }
         }
         // now go through the google events id's, and process the ones which aren't in our table.
         $our_event_adds = array();
         foreach ($gcal_event_ids as $id => $event) {
             if (!array_key_exists($id, $our_event_ids)) {
                 // we don't have the ID, so add the event to our table
                 $row = array();
                 $row[$gcal_start_date_element_long] = strftime('%Y-%m-%d %H:%M:%S', strtotime($event->when[0]->startTime));
                 if ($gcal_end_date_element_long) {
                     $row[$gcal_end_date_element_long] = strftime('%Y-%m-%d %H:%M:%S', strtotime($event->when[0]->endTime));
                 }
                 $row[$gcal_label_element_long] = $event->title->text;
                 if ($gcal_desc_element_long) {
                     $row[$gcal_desc_element_long] = $event->content->text;
                 }
                 $row[$gcal_id_element_long] = $id;
                 if ($gcal_userid_element_long) {
                     $row[$gcal_userid_element_long] = $our_userid;
                 }
                 $tableModel->storeRow($row, 0);
             }
             $our_event_adds[$id] = $row;
         }
         $app->enqueueMessage(count($our_event_adds) . ' events added ');
         // if upload syncing (from us to gcal) is enabled ...
         if ($gcal_sync_upload == 'both' || $gcal_sync_upload == 'to') {
             // Grab the tzOffset.  Note that gcal want +/-XX (like -06)
             // but J! gives us +/-X (like -6) so we sprintf it to the right format
             $config =& JFactory::getConfig();
             $tzOffset = (int) $config->getValue('config.offset');
             $tzOffset = sprintf('%+03d', $tzOffset);
             // loop thru the array we built earlier of events we have that aren't in gcal
             $uploadCount = 0;
             foreach ($our_upload_ids as $id => $event) {
                 // skip if a userid element is specified, and doesn't match the owner of this gcal
                 if ($gcal_userid_element_long) {
                     if ($event->{$gcal_userid_element_long} != $our_userid) {
                         continue;
                     }
                 }
                 // now start building the gcal event structure
                 $newEvent = $gdataCal->newEventEntry();
                 $newEvent->title = $gdataCal->newTitle($event->{$gcal_label_element_long});
                 if ($gcal_desc_element_long) {
                     $newEvent->content = $gdataCal->newContent($event->{$gcal_desc_element_long});
                 } else {
                     $newEvent->content = $gdataCal->newContent($event->{$gcal_label_element_long});
                 }
                 $when = $gdataCal->newWhen();
                 // grab the start date, apply the tx offset, and format it for gcal
                 $start_date = JFactory::getDate($event->{$gcal_start_date_element_long});
                 $start_date->setOffset($tzOffset);
                 $start_fdate = $start_date->toFormat('%Y-%m-%d %H:%M:%S');
                 $date_array = explode(' ', $start_fdate);
                 $when->startTime = "{$date_array[0]}T{$date_array[1]}.000{$tzOffset}:00";
                 // we have to provide an end date for gcal, so if we don't have one,
                 // default it to start date + 1 hour
                 if (empty($gcal_end_date_element_long) || empty($event->{$gcal_end_date_element_long}) || $event->{$gcal_end_date_element_long} == '0000-00-00 00:00:00') {
                     $startstamp = strtotime($event->{$gcal_start_date_element_long});
                     $endstamp = $startstamp + 60 * 60;
                     $event->{$gcal_end_date_element_long} = strftime('%Y-%m-%d %H:%M:%S', $endstamp);
                 }
                 // grab the end date, apply the tx offset, and format it for gcal
                 $end_date = JFactory::getDate($event->{$gcal_end_date_element_long});
                 $end_date->setOffset($tzOffset);
                 $end_fdate = $end_date->toFormat('%Y-%m-%d %H:%M:%S');
                 $date_array = explode(' ', $end_fdate);
                 $when->endTime = "{$date_array[0]}T{$date_array[1]}.000{$tzOffset}:00";
                 $newEvent->when = array($when);
                 // fire off the insertEvent to gcal, catch any errors
                 try {
                     $retEvent = $gdataCal->insertEvent($newEvent, $gcal_url);
                 } catch (Zend_Gdata_App_HttpException $he) {
                     $errStr = 'Problem adding event: ' . $he->getRawResponseBody() . "\n";
                     continue;
                 }
                 $uploadCount++;
                 // insertEvent worked, so grab the gcal ID from the returned event data,
                 // and update our event record with the short version of the ID
                 $gcal_id = $this->_getGcalShortId($retEvent->id->text);
                 $our_id = $event->__pk_val;
                 $db->setQuery("\n\t\t\t\t\t\tUPDATE {$table_name}\n\t\t\t\t\t\tSET {$gcal_id_element} = " . $db->Quote($gcal_id) . "\n\t\t\t\t\t\tWHERE {$primary_key} = " . (int) $our_id);
                 $db->query();
             }
             $app->enqueueMessage($uploadCount . ' events uploaded to GCal');
         }
     } else {
         JError::raiseNotice(500, 'Incorrect url');
     }
 }
예제 #19
0
 /**
  * @param      $method
  * @param bool $getCurrency
  */
 static function getPaymentCurrency(&$method, $getCurrency = FALSE)
 {
     if (!isset($method->payment_currency) or empty($method->payment_currency) or !$method->payment_currency or $getCurrency) {
         // 	    if (!class_exists('VirtueMartModelVendor')) require(VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php');
         $vendorId = 1;
         //VirtueMartModelVendor::getLoggedVendor();
         $db = JFactory::getDBO();
         $q = 'SELECT   `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id`=' . $vendorId;
         $db->setQuery($q);
         $method->payment_currency = $db->loadResult();
     } elseif (isset($method->payment_currency) and $method->payment_currency == -1) {
         $vendorId = 1;
         $db = JFactory::getDBO();
         // the select list should include the vendor currency which is the currency in which the product prices are displayed by default.
         $q = 'SELECT CONCAT(`vendor_accepted_currencies`, ",",`vendor_currency`) AS all_currencies, `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id`=' . $vendorId;
         $db->setQuery($q);
         $vendor_currency = $db->loadAssoc();
         $mainframe = Jfactory::getApplication();
         $method->payment_currency = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id', $vendor_currency['vendor_currency']));
     }
 }
 public static function getInstance(&$query = null)
 {
     if (empty(self::$_instances)) {
         JLoader::register('VmConfig', JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php');
         VmConfig::loadConfig();
     }
     if (isset($query['langswitch'])) {
         if ($query['langswitch'] != VMLANG) {
             $instanceKey = $query['langswitch'];
         }
         unset($query['langswitch']);
     } else {
         $instanceKey = VMLANG;
     }
     if (!isset(self::$_instances[$instanceKey])) {
         self::$_instances[$instanceKey] = new vmrouterHelper($instanceKey, $query);
         if (self::$limit === null) {
             $mainframe = Jfactory::getApplication();
             $view = 'virtuemart';
             if (isset($query['view'])) {
                 $view = $query['view'];
             }
             self::$limit = $mainframe->getUserStateFromRequest('com_virtuemart.' . $view . '.limit', VmConfig::get('list_limit', 20), 'int');
             // 				self::$limit= $mainframe->getUserStateFromRequest('global.list.limit', 'limit', VmConfig::get('list_limit', 20), 'int');
         }
     }
     return self::$_instances[$instanceKey];
 }
예제 #21
0
 public function CreateOrderHead()
 {
     $mainframe = Jfactory::getApplication();
     if (!vmAccess::manager('orders.create')) {
         vmInfo('Restricted');
         $view = $this->getView('orders', 'html');
         $view->display();
         return false;
     }
     $model = VmModel::getModel();
     $orderid = $model->CreateOrderHead();
     $mainframe->redirect('index.php?option=com_virtuemart&view=orders&task=edit&virtuemart_order_id=' . $orderid);
 }
예제 #22
0
 /**
  * Add a product rating
  * @author Max Milbers
  */
 public function addRating()
 {
     $mainframe = Jfactory::getApplication();
     /* Get the product ID */
     // 		$cids = array();
     $cids = JRequest::getVar($this->_cidName, JRequest::getVar('virtuemart_product_id', array(), '', 'ARRAY'), '', 'ARRAY');
     jimport('joomla.utilities.arrayhelper');
     JArrayHelper::toInteger($cids);
     // 		if (!is_array($cids)) $cids = array($cids);
     $mainframe->redirect('index.php?option=com_virtuemart&view=ratings&task=add&virtuemart_product_id=' . $cids[0]);
 }
예제 #23
0
 function display($tpl = null)
 {
     $mainframe = Jfactory::getApplication();
     $option = JRequest::getWord('option');
     //Load helpers
     $this->loadHelper('html');
     /* Get the review IDs to retrieve (input variable may be cid, cid[] or virtuemart_rating_review_id */
     $cids = JRequest::getVar('cid', 0);
     if (empty($cids)) {
         $cids = JRequest::getVar('virtuemart_rating_review_id', 0);
     }
     if ($cids && !is_array($cids)) {
         $cids = array($cids);
     }
     jimport('joomla.utilities.arrayhelper');
     JArrayHelper::toInteger($cids);
     // Figure out maximum rating scale (default is 5 stars)
     $this->max_rating = VmConfig::get('vm_maximum_rating_scale', 5);
     $this->assignRef('max_rating', $this->max_rating);
     $model = VmModel::getModel();
     $this->SetViewTitle('REVIEW_RATE');
     /* Get the task */
     $task = JRequest::getWord('task');
     switch ($task) {
         case 'listreviews':
             /* Get the data */
             $this->addStandardDefaultViewLists($model);
             $virtuemart_product_id = JRequest::getInt('virtuemart_product_id', 0);
             $reviewslist = $model->getReviews($virtuemart_product_id);
             $lists = array();
             $lists['filter_order'] = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', '', 'cmd');
             $lists['filter_order_Dir'] = $mainframe->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
             $this->assignRef('reviewslist', $reviewslist);
             $pagination = $model->getPagination();
             $this->assignRef('pagination', $pagination);
             $this->addStandardDefaultViewCommands(false, true);
             break;
         case 'edit':
             /* Get the data */
             $rating = $model->getRating($cids);
             $this->addStandardEditViewCommands();
             /* Assign the data */
             $this->assignRef('rating', $rating);
             break;
         case 'edit_review':
             JToolBarHelper::divider();
             /* Get the data */
             $rating = $model->getReview($cids);
             if (!empty($rating)) {
                 $this->SetViewTitle('REVIEW_RATE', $rating->product_name . " (" . $rating->customer . ")");
                 JToolBarHelper::customX('saveReview', 'save', 'save', JText::_('COM_VIRTUEMART_SAVE'), false);
                 JToolBarHelper::customX('applyReview', 'apply', 'apply', JText::_('COM_VIRTUEMART_APPLY'), false);
             } else {
                 $this->SetViewTitle('REVIEW_RATE', 'ERROR');
             }
             JToolBarHelper::customX('cancelEditReview', 'cancel', 'cancel', JText::_('COM_VIRTUEMART_CANCEL'), false);
             /* Assign the data */
             $this->assignRef('rating', $rating);
             break;
         default:
             $this->addStandardDefaultViewCommands(false, true);
             $this->addStandardDefaultViewLists($model);
             $ratingslist = $model->getRatings();
             $this->assignRef('ratingslist', $ratingslist);
             $pagination = $model->getPagination();
             $this->assignRef('pagination', $pagination);
             break;
     }
     parent::display($tpl);
 }
예제 #24
0
 /**
  * Update status for the selected order items
  */
 public function updateOrderItemStatus()
 {
     //vmdebug('updateOrderItemStatus');
     $mainframe = Jfactory::getApplication();
     $model = VmModel::getModel();
     $_items = JRequest::getVar('item_id', 0, '', 'array');
     //JArrayHelper::toInteger($_items);
     $_orderID = JRequest::getInt('virtuemart_order_id', '');
     foreach ($_items as $key => $value) {
         //vmdebug('updateOrderItemStatus VAL  ',$value);
         if (!isset($value['comments'])) {
             $value['comments'] = '';
         }
         $data = (object) $value;
         $data->virtuemart_order_id = $_orderID;
         // 			$model->updateSingleItem((int)$key, $value['order_status'],$value['comments'],$_orderID);
         $model->updateSingleItem((int) $key, $data);
     }
     $mainframe->redirect('index.php?option=com_virtuemart&view=orders&task=edit&virtuemart_order_id=' . $_orderID);
 }
예제 #25
0
파일: product.php 프로젝트: lenard112/cms
 /**
  * Add a product rating
  * @author Max Milbers
  */
 public function addRating()
 {
     $mainframe = Jfactory::getApplication();
     // Get the product ID
     $cids = vRequest::getInt($this->_cidName, vRequest::getInt('virtuemart_product_id'));
     $mainframe->redirect('index.php?option=com_virtuemart&view=ratings&task=add&virtuemart_product_id=' . $cids[0]);
 }
예제 #26
0
* This template structure includes elements from
		beez (overrides)
		rhuk_milkyway (rounded modules)
It is based on the skeleton-template-tableless by Waseem Sadiq of www.bulletprooftemplates.com (collapsible source-ordered layout, styleswitcher etc).
		 
* EMC23 extends our infinite gratitude to the Joomla Community
* Bugs? Please contact us - www.emc23.com
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.tooltip');
include_once "includes/template_config.php";
$url = clone JURI::getInstance();
$user =& JFactory::getUser();
$app = Jfactory::getApplication();
?>



<?php 
echo '<?xml version="1.0" encoding="utf-8"?' . '>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
echo $this->language;
?>
" lang="<?php 
echo $this->language;
?>
" dir="<?php 
예제 #27
0
 public static function getInstance(&$query = null)
 {
     defined('DS') or define('DS', DIRECTORY_SEPARATOR);
     if (!class_exists('VmConfig')) {
         require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     if (!self::$_instance) {
         self::$_instance = new vmrouterHelper($query);
         if (self::$limit === null) {
             $mainframe = Jfactory::getApplication();
             $view = 'virtuemart';
             if (isset($query['view'])) {
                 $view = $query['view'];
             }
             self::$limit = $mainframe->getUserStateFromRequest('com_virtuemart.' . $view . '.limit', VmConfig::get('list_limit', 20), 'int');
         }
     }
     self::$_instance->query = $query;
     return self::$_instance;
 }
예제 #28
0
 /**
  * Initialise the mailer object to start sending mails
  *
  * @copyright
  * @author		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return
  * @since 		3.0
  */
 private function _getMailer()
 {
     $mainframe = Jfactory::getApplication();
     jimport('joomla.mail.helper');
     // Start the mailer object
     $this->mailer = JFactory::getMailer();
     $this->mailer->isHTML(true);
     $this->mailer->From = $mainframe->getCfg('mailfrom');
     $this->mailer->FromName = $mainframe->getCfg('sitename');
     $this->mailer->AddReplyTo(array($mainframe->getCfg('mailfrom'), $mainframe->getCfg('sitename')));
 }
예제 #29
0
 public function CreateOrderHead()
 {
     $mainframe = Jfactory::getApplication();
     $model = VmModel::getModel();
     $orderid = $model->CreateOrderHead();
     $mainframe->redirect('index.php?option=com_virtuemart&view=orders&task=edit&virtuemart_order_id=' . $orderid);
 }
예제 #30
0
*
* www.virtuemart.net
*/


/***********
 *
 * Prices in the orders are saved in the shop currency; these fields are required
 * to show the prices to the user in a later stadium.
  */

if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');

VmConfig::loadConfig();
VmConfig::loadModJLang('mod_virtuemart_currencies', true);
$mainframe = Jfactory::getApplication();
$vendorId = JRequest::getInt('vendorid', 1);
$text_before = $params->get( 'text_before', '');
/* table vm_vendor */
$db = JFactory::getDBO();
// the select list should include the vendor currency which is the currency in which the product prices are displayed by default.
$q  = 'SELECT CONCAT(`vendor_accepted_currencies`, ",",`vendor_currency`) AS all_currencies, `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id`='.$vendorId;
$db->setQuery($q);
$vendor_currency = $db->loadAssoc();


$virtuemart_currency_id = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id',JRequest::getInt('virtuemart_currency_id', $vendor_currency['vendor_currency']) );

//if (!$vendor_currency['vendor_accepted_currencies']) return;
//$currency_codes = explode(',' , $currencies->vendor_accepted_currencies );