function onAfterRoute()
 {
     $app = JFactory::getApplication();
     // No remember me for admin
     if ($app->isAdmin()) {
         return;
     }
     // Get the full current URI.
     $uri = JURI::getInstance();
     $current = $uri->toString(array('path'));
     $pieces = explode("/", $current);
     $keyword = array_pop($pieces);
     $keywordCat = array_pop($pieces);
     //var_dump($keywordCat);
     if (!isset($keyword) || $keyword == '') {
         return;
     }
     $params = JRequest::get('GET');
     //var_dump($keyword);
     if (strpos($keyword, 'hotels-') === 0) {
         //var_dump("found_region");
         $params = $this->getHotelRegionParams($keyword, $params);
     } else {
         if (strpos($keyword, 'hotel-') === 0) {
             //var_dump("found_hotel");
             $params = $this->getHotelParams($keyword, $params);
         } else {
             if (strpos($keyword, 'hotelarrangement-') === 0) {
                 //var_dump("found_offer");
                 $params = $this->getHotelOfferParams($keyword, $params);
             } else {
                 if (strpos($keywordCat, 'hotelarrangement') === 0) {
                     $params = $this->getHotelCityOffersParams($keyword, $params);
                 } else {
                     if (strpos($keyword, 'type-') === 0) {
                         //var_dump("found_offer");
                         $params = $this->getHotelTypeParams($keyword, $params);
                     } else {
                         if (strpos($keyword, 'theme-') === 0) {
                             //var_dump("found_offer");
                             $params = $this->getHotelThemeParams($keyword, $params);
                         } else {
                             //var_dump($keyword);
                             $params = $this->getVoucherParams($keyword, $params);
                             if (empty($params["voucher"])) {
                                 $params = $this->getHotelCityParams($keyword, $params);
                             }
                         }
                     }
                 }
             }
         }
     }
     //var_dump($params);
     //exit;
     JRequest::set($params, 'get', true);
 }
 /**
  * Proxy the application route() method
  */
 public function route()
 {
     // get the full request URI
     $uri = clone JURI::getInstance();
     $router =& $this->getRouter();
     $result = $router->parse($uri);
     JRequest::set($result, 'get', true);
     parent::route();
 }
Example #3
0
 /**
  * Shows the Admin Tools custom block message
  */
 public function onAfterRoute()
 {
     $session = JFactory::getSession();
     if ($session->get('block', false, 'com_admintools')) {
         // This is an underhanded way to short-circuit Joomla!'s internal router.
         $this->input->set('option', 'com_admintools');
         if (class_exists('JRequest')) {
             JRequest::set(array('option' => 'com_admintools'), 'get', true);
         }
     }
 }
Example #4
0
 /**
  * Parses the route.
  *
  * @param KCommandContext $context Command chain context
  *
  * @return bool
  */
 protected function _actionRoute(KCommandContext $context)
 {
     //route the application
     $url = clone KRequest::url();
     $this->_application->getRouter()->parse($url);
     JRequest::set($url->query, 'get', false);
     // trigger the onAfterRoute events
     $this->_application->triggerEvent('onAfterRoute');
     $url->query = KRequest::get('get', 'raw');
     //globally set ItemId
     global $Itemid;
     $Itemid = KRequest::get('get.Itemid', 'int', 0);
     //set the request
     $this->getRequest()->append($url->query);
     $component = substr($this->_request->option, 4);
     $this->setComponent($component);
 }
Example #5
0
 function search()
 {
     $session =& JFactory::getSession();
     if (JRequest::checkToken()) {
         $params = array('key_search' => JRequest::getVar('key_search', ''), 'Itemid' => JRequest::getInt('Itemid', 0), 'town_id' => JRequest::getInt('town_id', 0), 'area_id' => JRequest::getInt('area_id', 0));
         $session->set('params', $params, 'jea_search');
     } else {
         $app =& JFactory::getApplication();
         $router =& $app->getRouter();
         // force the default to layout on search result
         $router->setVar('layout', 'default');
     }
     $params = $session->get('params', array(), 'jea_search');
     // Bug correction on search pagination
     if ($limit = JRequest::getInt('limit', 0)) {
         $params['limit'] = $limit;
         $session->set('params', $params, 'jea_search');
     }
     JRequest::set($params, 'POST');
     $this->display();
 }
Example #6
0
 /**
  * do the plugin action
  * @param object parameters
  * @param object table model
  * @return string message
  */
 function process(&$params, &$model)
 {
     $ids = JRequest::getVar('ids', array(), 'method', 'array');
     $item = $model->getTable();
     $formModel = $model->getFormModel();
     $origPost = JRequest::get('post', 2);
     JRequest::set(array(), 'post');
     foreach ($ids as $id) {
         $formModel->_rowId = $id;
         $row = $formModel->getData();
         $row['Copy'] = '1';
         $row['fabrik_copy_from_table'] = 1;
         foreach ($row as $key => $val) {
             JRequest::setVar($key, $val, 'post');
         }
         $formModel->setFormData();
         $formModel->_formDataWithTableName = $formModel->_formData;
         $formModel->processToDB();
     }
     JRequest::set(array(), 'post');
     JRequest::set($origPost, 'post', true);
     return true;
 }
Example #7
0
 /**
  * Updates the group
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function update()
 {
     // Check for request forgeries
     FD::checkToken();
     // Only registered members allowed
     FD::requireLogin();
     // Get the current view
     $view = $this->getCurrentView();
     // Get the group
     $id = JRequest::getInt('id');
     $group = FD::group($id);
     $my = FD::user();
     if (!$group->id || !$id) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Only allow user to edit if they have access
     if (!$group->isAdmin() && !$my->isSiteAdmin()) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_NO_ACCESS'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $group);
     }
     // Get post data.
     $post = JRequest::get('POST');
     // Get all published fields apps that are available in the current form to perform validations
     $fieldsModel = FD::model('Fields');
     // Only fetch relevant fields for this user.
     $options = array('group' => SOCIAL_TYPE_GROUP, 'uid' => $group->getCategory()->id, 'data' => true, 'dataId' => $group->id, 'dataType' => SOCIAL_TYPE_GROUP, 'visible' => SOCIAL_PROFILES_VIEW_EDIT);
     $fields = $fieldsModel->getCustomFields($options);
     // Load json library.
     $json = FD::json();
     // Initialize default registry
     $registry = FD::registry();
     // Get disallowed keys so we wont get wrong values.
     $disallowed = array(FD::token(), 'option', 'task', 'controller');
     // Process $_POST vars
     foreach ($post as $key => $value) {
         if (!in_array($key, $disallowed)) {
             if (is_array($value)) {
                 $value = $json->encode($value);
             }
             $registry->set($key, $value);
         }
     }
     // Convert the values into an array.
     $data = $registry->toArray();
     // Perform field validations here. Validation should only trigger apps that are loaded on the form
     // @trigger onRegisterValidate
     $fieldsLib = FD::fields();
     // Get the general field trigger handler
     $handler = $fieldsLib->getHandler();
     // Build arguments to be passed to the field apps.
     $args = array(&$data, &$group);
     // Ensure that there is no errors.
     // @trigger onEditValidate
     $errors = $fieldsLib->trigger('onEditValidate', SOCIAL_FIELDS_GROUP_GROUP, $fields, $args, array($handler, 'validate'));
     // If there are errors, we should be exiting here.
     if (is_array($errors) && count($errors) > 0) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_PROFILE_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         // We need to set the proper vars here so that the es-wrapper contains appropriate class
         JRequest::setVar('view', 'groups', 'POST');
         JRequest::setVar('layout', 'edit', 'POST');
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $view->call('edit', $errors, $data);
     }
     // @trigger onEditBeforeSave
     $errors = $fieldsLib->trigger('onEditBeforeSave', SOCIAL_FIELDS_GROUP_GROUP, $fields, $args, array($handler, 'beforeSave'));
     if (is_array($errors) && count($errors) > 0) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
         // We need to set the proper vars here so that the es-wrapper contains appropriate class
         JRequest::setVar('view', 'groups');
         JRequest::setVar('layout', 'edit');
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $view->call('edit', $errors);
     }
     // Save the group now
     $group->save();
     // @points: groups.update
     // Add points to the user that updated the group
     $my = FD::user();
     $points = FD::points();
     $points->assign('groups.update', 'com_easysocial', $my->id);
     // Reconstruct args
     $args = array(&$data, &$group);
     // @trigger onEditAfterSave
     $fieldsLib->trigger('onEditAfterSave', SOCIAL_FIELDS_GROUP_GROUP, $fields, $args);
     // Bind custom fields for the user.
     $group->bindCustomFields($data);
     // Reconstruct args
     $args = array(&$data, &$group);
     // @trigger onEditAfterSaveFields
     $fieldsLib->trigger('onEditAfterSaveFields', SOCIAL_FIELDS_GROUP_GROUP, $fields, $args);
     // Add stream item to notify the world that this user updated their profile.
     $group->createStream(FD::user()->id, 'update');
     $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_PROFILE_UPDATED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__, $group);
 }
			$ipnval= stripslashes($ipnval);
		}
		if(!eregi("^[_0-9a-z-]{1,30}$", $ipnkey) || !strcasecmp($ipnkey, 'cmd')) {
			// ^ Antidote to potential variable injection and poisoning
			unset($ipnkey);
			unset($ipnval);
		}
		// Eliminate the above
		// Remove empty keys (not values)
		if(@ $ipnkey != '') {
			//unset ($_POST); // Destroy the original ipn post array, sniff...
			$workstring .= '&'.@ $ipnkey.'='.urlencode(@ $ipnval);
		}
		$post_msg .= "key ".$i++.": $ipnkey, value: $ipnval<br />";
	}
	JRequest :: set($_POST, 'post');
	$oseMscConfig= oseRegistry :: call('msc')->getConfig(null, 'obj');
	$paypal_mode = oseObject::getValue($oseMscConfig,'paypal_mode','paypal_express');
	$apiEmail= oseRegistry :: call('member')->getInstance('email');
	$paypal_email= $oseMscConfig->paypal_email;
	$test_mode= $oseMscConfig->paypal_testmode;
	$config= new JConfig();
	$mailfrom= $config->mailfrom;
	$fromname= $config->fromname;
	$process= new oseMscIpnPaypal($paypal_email,$paypal_mode);

	$remote_hostname= gethostbyaddr($_SERVER['REMOTE_ADDR']);
	/*if(oseObject::getValue($oseMscConfig,'paypal_ipvalidate',false))
	{
		// Get the list of IP addresses for www.paypal.com and notify.paypal.com
		$paypal_iplist= gethostbynamel('www.paypal.com');
Example #9
0
 /**
  * Update an event
  *
  * @since   1.3
  * @access  public
  * @param   string
  * @return
  */
 public function update()
 {
     // Check for request forgeries
     FD::checkToken();
     // Ensure that the user is logged in
     FD::requireLogin();
     // Get the event data
     $id = $this->input->get('id', 0, 'int');
     // Load up the event
     $event = FD::event($id);
     if (empty($event) || empty($event->id)) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_INVALID_EVENT_ID'), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__);
     }
     if (!$event->isPublished()) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_EVENT_UNAVAILABLE'), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__);
     }
     $guest = $event->getGuest($this->my->id);
     if (!$this->my->isSiteAdmin() && !$guest->isOwner() && !$event->isAdmin() && (!$event->isGroupEvent() || $event->isGroupEvent() && !$event->getGroup()->isOwner())) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_NOT_ALLOWED_TO_EDIT_EVENT'), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__, $event);
     }
     $post = JRequest::get('POST');
     $json = FD::json();
     $data = array();
     $disallowed = array(FD::token(), 'option', 'task', 'controller');
     foreach ($post as $key => $value) {
         if (in_array($key, $disallowed)) {
             continue;
         }
         if (is_array($value)) {
             $value = $json->encode($value);
         }
         $data[$key] = $value;
     }
     $fieldsModel = FD::model('Fields');
     $fields = FD::model('Fields')->getCustomFields(array('group' => SOCIAL_TYPE_EVENT, 'uid' => $event->getCategory()->id, 'visible' => SOCIAL_EVENT_VIEW_EDIT, 'data' => true, 'dataId' => $event->id, 'dataType' => SOCIAL_TYPE_EVENT));
     $fieldsLib = FD::fields();
     $args = array(&$data, &$event);
     $errors = $fieldsLib->trigger('onEditValidate', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args, array($fieldsLib->getHandler(), 'validate'));
     if (!empty($errors)) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
         JRequest::setVar('view', 'events', 'POST');
         JRequest::setVar('layout', 'edit', 'POST');
         JRequest::set($data, 'POST');
         return $this->view->call('edit', $errors);
     }
     $errors = $fieldsLib->trigger('onEditBeforeSave', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args, array($fieldsLib->getHandler(), 'beforeSave'));
     if (!empty($errors)) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
         JRequest::setVar('view', 'events', 'POST');
         JRequest::setVar('layout', 'edit', 'POST');
         JRequest::set($data, 'POST');
         return $this->view->call('edit', $errors);
     }
     $event->save();
     FD::points()->assign('events.update', 'com_easysocial', $this->my->id);
     $fieldsLib->trigger('onEditAfterSave', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     $event->bindCustomFields($data);
     $fieldsLib->trigger('onEditAfterSaveFields', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     // Only create if applyRecurring is false or event is not a child
     // applyRecurring && parent = true
     // applyRecurring && child = false
     // !applyRecurring && parent = true
     // !applyRecurring && child = true
     if (empty($data['applyRecurring']) || !$event->isRecurringEvent()) {
         $event->createStream('update', $this->my->id, SOCIAL_TYPE_USER);
     }
     $this->view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_UPDATED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS);
     return $this->view->call(__FUNCTION__, $event);
 }
Example #10
0
 private function setRequestOption($key, $value)
 {
     JRequest::set(array($key => $value), 'GET');
     JRequest::set(array($key => $value), 'POST');
 }
Example #11
0
 /**
  * Short description for 'parse'
  *
  * Long description (if any) ...
  *
  * @param      object &$uri Parameter description (if any) ...
  * @return     array Return description (if any) ...
  */
 function parse(&$uri)
 {
     $vars = array();
     // Get the application
     $app = JFactory::getApplication();
     if ($app->getCfg('force_ssl') == 2 && strtolower($uri->getScheme()) != 'https') {
         //forward to https
         $uri->setScheme('https');
         $app->redirect($uri->toString());
     }
     // Get the path
     $path = $uri->getPath();
     //Remove the suffix
     if ($this->_mode == JROUTER_MODE_SEF) {
         // Get the application
         $app = JFactory::getApplication();
         if ($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/')) {
             if ($suffix = pathinfo($path, PATHINFO_EXTENSION)) {
                 $path = str_replace('.' . $suffix, '', $path);
                 $vars['format'] = $suffix;
             }
         }
     }
     //Remove basepath
     $path = substr_replace($path, '', 0, strlen(JURI::base(true)));
     //Remove prefix
     $path = str_replace('index.php', '', $path);
     //Set the route
     $uri->setPath(trim($path, '/'));
     $vars += parent::parse($uri);
     /* HUBzero Extensions Follow to force registration and email confirmation */
     $juser = JFactory::getUser();
     if (!$juser->get('guest')) {
         $session = JFactory::getSession();
         $registration_incomplete = $session->get('registration.incomplete');
         if ($registration_incomplete) {
             if ($vars['option'] == 'com_user') {
                 if ($vars['view'] == 'logout' || $vars['task'] == 'logout') {
                     return $vars;
                 }
             }
             if ($vars['option'] == 'com_members' && (isset($vars['controller']) && $vars['controller'] == 'register' || isset($vars['view']) && $vars['view'] == 'register')) {
                 return $vars;
             }
             if ($uri->getPath() != 'legal/terms') {
                 $vars = array();
                 /*
                 					$vars['option'] = 'com_members';
                 					$vars['controller'] = 'register';
                 
                 					if ($juser->get('tmp_user'))
                 						$vars['task'] = 'create';
                 					else
                 						$vars['task'] = 'update';
                 
                 					$vars['act'] = '';
                 */
                 $vars['option'] = 'com_members';
                 $vars['id'] = $juser->get("id");
                 $vars['active'] = 'profile';
                 $this->setVars($vars);
                 JRequest::set($vars, 'get', true);
                 // overwrite existing
                 return $vars;
             }
         }
         $xprofile = \Hubzero\User\User::oneOrNew($juser->get('id'));
         if (is_object($xprofile) && $xprofile->get('activation') != 1 && $xprofile->get('activation') != 3) {
             if ($vars['option'] == 'com_user') {
                 if ($vars['view'] == 'logout' || $vars['task'] == 'logout') {
                     return $vars;
                 }
             } else {
                 if ($uri->getPath() == 'legal/terms') {
                     return $vars;
                 } else {
                     if ($vars['option'] == 'com_members' && (isset($vars['controller']) && $vars['controller'] == 'register' || isset($vars['view']) && $vars['view'] == 'register')) {
                         if (!empty($vars['task'])) {
                             if ($vars['task'] == 'unconfirmed' || $vars['task'] == 'change' || $vars['task'] == 'resend' || $vars['task'] == 'confirm') {
                                 return $vars;
                             }
                         }
                     }
                 }
             }
             $vars = array();
             $vars['option'] = 'com_members';
             $vars['controller'] = 'register';
             $vars['task'] = 'unconfirmed';
             $this->setVars($vars);
             JRequest::set($vars, 'get', true);
             // overwrite existing
             return $vars;
         }
     }
     return $vars;
 }
Example #12
0
 /**
  * do the plugin action
  * @param object parameters
  * @param object table model
  * @return string message
  */
 function process(&$params, &$model)
 {
     $ids = JRequest::getVar('ids', array(), 'method', 'array');
     $table =& $model->getTable();
     $formModel =& $model->getForm();
     $origPost = JRequest::get('post', 2);
     JRequest::set(array(), 'post');
     foreach ($ids as $id) {
         $formModel->_rowId = $id;
         $row = $formModel->getData();
         $row['Copy'] = '1';
         $row['fabrik_copy_from_table'] = 1;
         foreach ($row as $key => $val) {
             JRequest::setVar($key, $val, 'post');
         }
         $formModel->setFormData();
         $formModel->_formDataWithTableName = $formModel->_formData;
         //set the repeat group count for processing joined data
         $repeatCounts = array();
         if (array_key_exists('join', $row)) {
             $aPreProcessedJoins =& $model->preProcessJoin();
             foreach ($row['join'] as $joinid => $joinData) {
                 foreach ($aPreProcessedJoins as $aPreProcessedJoin) {
                     $oJoin = $aPreProcessedJoin['join'];
                     if ($oJoin->id == $joinid) {
                         $keys = array_keys($joinData);
                         $repeatCounts[$oJoin->group_id] = count($joinData[$keys[0]]);
                     }
                 }
             }
         }
         JRequest::setVar('fabrik_repeat_group', $repeatCounts, 'post');
         //submit the form.
         $formModel->processToDB();
     }
     JRequest::set(array(), 'post');
     JRequest::set($origPost, 'post', true);
     return true;
 }
Example #13
0
 /**
  * Retrieves the stream contents.
  *
  * @since	1.0
  * @access	public
  */
 public function getStream()
 {
     // Check for request forgeries.
     FD::checkToken();
     // In order to access the dashboard apps, user must be logged in.
     FD::requireLogin();
     // set jrequest view
     JRequest::set(array('view' => 'dashboard'));
     $hashtags = array();
     // Get the type of the stream to load.
     $type = $this->input->get('type', '', 'word');
     // Get the stream
     $stream = FD::stream();
     if (!$type) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_INVALID_FEED_TYPE'), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__, $stream, $type);
     }
     // Get feeds from user's friend list.
     if ($type == 'list') {
         // The id of the friend list.
         $id = $this->input->get('id', 0, 'int');
         $list = FD::table('List');
         $list->load($id);
         if (!$id || !$list->id) {
             $this->view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_INVALID_LIST_ID_PROVIDED'), SOCIAL_MSG_ERROR);
             return $this->view->call(__FUNCTION__, $stream, $type);
         }
         // Get list of users from this list.
         $friends = $list->getMembers();
         if ($friends) {
             $stream->get(array('listId' => $id));
         } else {
             $stream->filter = 'list';
         }
     }
     if ($type == 'following') {
         $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'type' => 'follow'));
     }
     // Filter by bookmarks
     if ($type == 'bookmarks') {
         $stream->get(array('guest' => true, 'type' => 'bookmarks'));
     }
     // Filter by sticky
     if ($type == 'sticky') {
         $stream->get(array('userId' => $this->my->id, 'type' => 'sticky'));
     }
     // Filter stream items by event
     if ($type == 'event') {
         $id = $this->input->get('id', 0, 'int');
         $event = FD::event($id);
         // Check if the user is a member of the group
         if (!$event->getGuest()->isGuest() && !$this->my->isSiteAdmin()) {
             $this->view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_EVENTS_NO_PERMISSIONS'), SOCIAL_MSG_ERROR);
             return $this->view->call(__FUNCTION__, $stream, $type);
         }
         //lets get the sticky posts 1st
         $stickies = $stream->getStickies(array('clusterId' => $id, 'clusterType' => SOCIAL_TYPE_EVENT, 'limit' => 0));
         if ($stickies) {
             $stream->stickies = $stickies;
         }
         $stream->get(array('clusterId' => $id, 'clusterType' => SOCIAL_TYPE_EVENT, 'nosticky' => true));
     }
     if ($type == 'group') {
         $id = $this->input->get('id', 0, 'int');
         $group = FD::group($id);
         // Check if the user is a member of the group
         if (!$group->isMember() && !$this->my->isSiteAdmin()) {
             $this->view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_GROUPS_NO_PERMISSIONS'), SOCIAL_MSG_ERROR);
             return $this->view->call(__FUNCTION__, $stream, $type);
         }
         //lets get the sticky posts 1st
         $stickies = $stream->getStickies(array('clusterId' => $id, 'clusterType' => SOCIAL_TYPE_GROUP, 'limit' => 0));
         if ($stickies) {
             $stream->stickies = $stickies;
         }
         $stream->get(array('clusterId' => $id, 'clusterType' => SOCIAL_TYPE_GROUP, 'nosticky' => true));
     }
     // Get feeds from everyone
     if ($type == 'everyone') {
         // $stream->getPublicStream( SOCIAL_STREAM_GUEST_LIMIT, 0 );
         $stream->get(array('guest' => true, 'ignoreUser' => true));
     }
     if ($type == 'appFilter') {
         // we need to use string and not 'word' due to some app name has number. e.g k2
         $appType = $this->input->get('id', '', 'string');
         $stream->get(array('context' => $appType));
         $stream->filter = 'custom';
     }
     // custom filter.
     if ($type == 'custom') {
         // Get the id
         $id = $this->input->get('id', 0, 'int');
         $sfilter = FD::table('StreamFilter');
         $sfilter->load($id);
         if ($sfilter->id) {
             $hashtags = $sfilter->getHashTag();
             $tags = explode(',', $hashtags);
             if ($tags) {
                 $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'tag' => $tags));
             }
         }
         $stream->filter = 'custom';
     }
     // Get feeds from the current user and friends only.
     if ($type == 'me') {
         $stream->get();
     }
     // $nextStartDate = $stream->getNextStartDate();
     // echo $stream->html();exit;
     return $this->view->call(__FUNCTION__, $stream, $type, $hashtags);
 }
Example #14
0
 /**
  * Used whenever an attribute selection is changed,
  * to update the price and/or attribute selectlists
  *
  * @return unknown_type
  */
 function updateAddToCart()
 {
     $response = array();
     $response['msg'] = '';
     $response['error'] = '';
     // get elements from post
     $elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', JRequest::getVar('elements', '', 'post', 'string')));
     // convert elements to array that can be binded
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $helper = TiendaHelperBase::getInstance();
     $values = $helper->elementsToArray($elements);
     // merge current elements with post
     $request_arr = JRequest::get();
     unset($request_arr['elements']);
     JRequest::setVar('elements', null);
     $values = array_merge($values, $request_arr);
     JRequest::set($values, 'POST');
     if (empty($values['product_id'])) {
         $values['product_id'] = JRequest::getInt('product_id', 0);
     }
     // now get the summary
     $this->display_cartbutton = true;
     Tienda::load('TiendaHelperProduct', 'helpers.product');
     $html = TiendaHelperProduct::getCartButton($values['product_id'], 'viewproduct_addtocart', $values);
     $response['msg'] = $html;
     // encode and echo (need to echo to send back to browser)
     echo json_encode($response);
     return;
 }
Example #15
0
function MijopollsParseRoute($segments)
{
    $vars = array();
    //Get the active menu item if there is a menu link to polls view
    $menu =& JSite::getMenu();
    $item =& $menu->getActive();
    // Count route segments
    $count = count($segments);
    //if item is not set, there is no menu linking to this view - poll
    if (!isset($item)) {
        $vars['view'] = 'poll';
        $vars['id'] = $segments[$count - 1];
        return $vars;
    }
    //if there is a menu to polls view ->
    $vars['view'] = 'poll';
    $vars['id'] = $segments[$count - 1];
    if (MijopollsHelper::is30()) {
        JRequest::set($vars, 'get');
    }
    return $vars;
}
Example #16
0
 function onAfterRoute()
 {
     /** @var JSite $app */
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         // don't use MobileJoomla in backend
         return;
     }
     $is_joomla15 = $this->isJoomla15();
     // don't filter RSS and non-html
     /** @var JDocument $document */
     $document = JFactory::getDocument();
     $format = $document->getType();
     $doctype = JRequest::getVar('type', false);
     if ($doctype == 'rss' || $doctype == 'atom' || $format !== 'html' && $format !== 'raw') {
         //reset mobile content-type header
         $headers = JResponse::getHeaders();
         JResponse::clearHeaders();
         foreach ($headers as $header) {
             if (strtolower($header['name']) != 'content-type') {
                 JResponse::setHeader($header['name'], $header['value']);
             }
         }
         return;
     }
     //be last registered onAfterRender event
     $app->registerEvent('onAfterRender', 'plgSystemMobileBot_onAfterRenderLast');
     // Load config
     $MobileJoomla_Settings =& MobileJoomla::getConfig();
     $MobileJoomla_Device =& MobileJoomla::getDevice();
     jimport('joomla.environment.browser');
     $browser = JBrowser::getInstance();
     if (version_compare(JVERSION, '3.0', '<')) {
         $browser->set('_mobile', $MobileJoomla_Device['markup'] !== false);
     } else {
         $refObj = new ReflectionObject($browser);
         $refProp = $refObj->getProperty('mobile');
         $refProp->setAccessible(true);
         $refProp->setValue($browser, $MobileJoomla_Device['markup'] !== false);
     }
     JPluginHelper::importPlugin('mobile');
     $app->triggerEvent('onMobileAfterRoute', array(&$MobileJoomla_Settings, &$MobileJoomla_Device));
     $this->filterExtensions($MobileJoomla_Settings, $MobileJoomla_Device);
     // "Vary" header for proxy
     JResponse::setHeader('Vary', 'User-Agent');
     if ($MobileJoomla_Device['markup'] === false) {
         $pcpage = $MobileJoomla_Settings['pcpage'];
         if ($pcpage && $pcpage !== 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) {
             $app->redirect($pcpage);
         }
         return;
     }
     define('_MJ', 1);
     /** @var MobileJoomla $MobileJoomla */
     $MobileJoomla = MobileJoomla::getInstance();
     if (!$is_joomla15 && isset($app->registeredurlparams)) {
         $registeredurlparams = $app->registeredurlparams;
         $this->setRequestVar('mjurlkey', null);
         unset($registeredurlparams->mjurlkey);
         $app->registeredurlparams = $registeredurlparams;
     }
     $app->triggerEvent('onMobile', array(&$MobileJoomla, &$MobileJoomla_Settings, &$MobileJoomla_Device));
     $template = $MobileJoomla->getParam('template');
     $homepage = $MobileJoomla->getParam('homepage');
     $gzip = $MobileJoomla->getParam('gzip');
     //Set template
     if (!empty($template)) {
         if ($is_joomla15) {
             $app->setUserState('setTemplate', $template);
             $app->setTemplate($template);
         } else {
             $db = JFactory::getDBO();
             $query = "SELECT params FROM #__template_styles WHERE client_id = 0 AND template = " . $db->Quote($template) . " ORDER BY id LIMIT 1";
             $db->setQuery($query);
             $params_data = $db->loadResult();
             if (empty($params_data)) {
                 $params_data = '{}';
             }
             if (version_compare(JVERSION, '1.7', '>=')) {
                 $app->setTemplate($template, $params_data);
             } elseif (version_compare(JVERSION, '1.6', '>=')) {
                 $app->setTemplate($template);
                 $template_obj = $app->getTemplate(true);
                 $template_obj->params->loadJSON($params_data);
             }
         }
     }
     // JHtml overrides
     if (version_compare(JVERSION, '3.0', '<')) {
         jimport('joomla.html.html');
         JHtml::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/override/html');
         if (@is_dir($dir = JPATH_THEMES . '/' . $template . '/override/html')) {
             JHtml::addIncludePath($dir);
         }
     } else {
         // load email.php only (workaround for new J!3 class loader)
         if (@is_file($path = JPATH_THEMES . '/' . $template . '/override/html/email.php')) {
             JLoader::register('JHtmlEmail', $path, true);
         } else {
             JLoader::register('JHtmlEmail', JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/override/html/email.php', true);
         }
     }
     $this->setConfig('gzip', $gzip);
     //Set headers
     JResponse::clearHeaders();
     $document = JFactory::getDocument();
     $document->setMimeEncoding($MobileJoomla->getContentType());
     $MobileJoomla->setHeader();
     // SEO
     $canonical = MobileJoomla::getCanonicalURI();
     if ($canonical) {
         if ($format == 'html') {
             $document->addHeadLink($canonical, 'canonical');
         }
         $document->setMetaData('robots', 'noindex, nofollow');
     }
     if (JRequest::getMethod() == 'POST') {
         return;
     }
     /** @var JMenu $menu */
     $menu = $app->getMenu();
     $router = $app->getRouter();
     $Itemid = version_compare(JVERSION, '3.0', '>=') ? $app->input->getInt('Itemid') : JRequest::getInt('Itemid');
     $item = $menu->getItem($Itemid);
     if (is_object($item)) {
         $current = array_merge($item->query, $_GET, $router->getVars());
     } else {
         $current = array_merge($_GET, $router->getVars());
     }
     if (!isset($current['Itemid'])) {
         $current['Itemid'] = (string) $Itemid;
     }
     unset($current['device']);
     unset($current['lang']);
     unset($current['format']);
     unset($current['no_html']);
     unset($current['language']);
     unset($current['tp']);
     unset($current['template']);
     unset($current['templateStyle']);
     unset($current['start']);
     unset($current['limitstart']);
     unset($current['limit']);
     // fix for sh404sef
     if (isset($current['limitstart']) && $current['limitstart'] == 0) {
         unset($current['limitstart']);
     }
     if (isset($current[session_name()])) {
         unset($current[session_name()]);
     }
     if ($is_joomla15) {
         $default = $menu->getDefault();
     } else {
         $lang = JFactory::getLanguage();
         $default = $menu->getDefault($lang->getTag());
     }
     $home = $default->query;
     $home['Itemid'] = $default->id;
     if (substr($homepage, 0, 10) == 'index.php?') {
         parse_str(substr($homepage, 10), $mj_home);
         if (isset($mj_home['Itemid'])) {
             $mj_home_Itemid = (int) $mj_home['Itemid'];
             if ($is_joomla15) {
                 $menu->setDefault($mj_home_Itemid);
             } else {
                 $menu->setDefault($mj_home_Itemid, '*');
             }
         }
         if ($current == $mj_home) {
             $MobileJoomla->setHome(true);
         }
     }
     if (count($current) == 0 || $current == $home) {
         $MobileJoomla->setHome(true);
         if ($homepage) {
             if (isset($mj_home_Itemid)) {
                 global $Itemid;
                 $Itemid = $mj_home_Itemid;
                 $menu->setActive($Itemid);
                 if (version_compare(JVERSION, '3.2', '>=')) {
                     $menu->authorise($Itemid);
                 } elseif (!$is_joomla15) {
                     $app->authorise($Itemid);
                 } else {
                     $app->authorize($Itemid);
                 }
             }
             $_SERVER['REQUEST_URI'] = JUri::base(true) . '/' . $homepage;
             if (isset($mj_home)) {
                 $_SERVER['QUERY_STRING'] = substr($homepage, 10);
                 foreach ($current as $key => $val) {
                     unset($_REQUEST[$key]);
                     unset($_GET[$key]);
                 }
                 JRequest::set($mj_home, 'get');
             } else {
                 $url = 'http';
                 $url .= isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 's' : '';
                 $url .= '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                 $uri = new JUri($url);
                 $router = $app->getRouter();
                 $result = $router->parse($uri);
                 JRequest::set($result, 'get');
             }
         }
     }
 }
Example #17
0
 /**
  * @param $key
  * @param $value
  */
 private function setRequestOption($key, $value)
 {
     if (class_exists('JRequest')) {
         JRequest::set(array($key => $value), 'GET');
         JRequest::set(array($key => $value), 'POST');
     }
 }
Example #18
0
 /**
  * Stores the user object
  *
  * @since	1.0
  * @access	public
  */
 public function store()
 {
     // Check for request forgeries
     FD::checkToken();
     // Load front end's language file
     FD::language()->loadSite();
     // Get the current task
     $task = $this->getTask();
     // Determine if this is an edited user.
     $id = $this->input->get('id', 0, 'int');
     $id = !$id ? null : $id;
     // Get the posted data
     $post = $this->input->getArray('post');
     // this should come from backend user management page only.
     $autoApproval = isset($post['autoapproval']) ? $post['autoapproval'] : 0;
     // Create an options array for custom fields
     $options = array();
     if (!$id) {
         $user = new SocialUser();
         // Get the profile id
         $profileId = $this->input->get('profileId');
     } else {
         // Here we assume that the user record already exists.
         $user = FD::user($id);
         // Get the profile id from the user
         $profileId = $user->getProfile()->id;
         $options['data'] = true;
         $options['dataId'] = $id;
         $options['dataType'] = SOCIAL_TYPE_USER;
     }
     // Set the profile id
     $options['profile_id'] = $profileId;
     // Set the group
     $options['group'] = SOCIAL_FIELDS_GROUP_USER;
     // Load the profile
     $profile = FD::table('Profile');
     $profile->load($profileId);
     // Set the visibility
     // since this is at backend so we assume admin is editing someone else.
     if (!$id) {
         $options['visible'] = SOCIAL_PROFILES_VIEW_REGISTRATION;
     }
     // Get fields model
     $fieldsModel = ES::model('Fields');
     // Get the custom fields
     $fields = $fieldsModel->getCustomFields($options);
     // Initialize default registry
     $registry = ES::registry();
     // Get disallowed keys so we wont get wrong values.
     $disallowed = array(ES::token(), 'option', 'task', 'controller', 'autoapproval');
     // Process $_POST vars
     foreach ($post as $key => $value) {
         if (!in_array($key, $disallowed)) {
             if (is_array($value)) {
                 $value = json_encode($value);
             }
             $registry->set($key, $value);
         }
     }
     // Test to see if the points has changed.
     $points = $this->input->get('points', 0, 'int');
     // Lets get the difference of the points
     $userPoints = $user->getPoints();
     // If there is a difference, the admin may have altered the user points
     if ($userPoints != $points) {
         // Insert a new points record for this new adjustments.
         if ($points > $userPoints) {
             // If the result points is larger, we always need to subtract and get the balance.
             $totalPoints = $points - $userPoints;
         } else {
             // If the result points is smaller, we always need to subtract.
             $totalPoints = -($userPoints - $points);
         }
         $pointsLib = FD::points();
         $pointsLib->assignCustom($user->id, $totalPoints, JText::_('COM_EASYSOCIAL_POINTS_ADJUSTMENTS'));
         $user->points = $points;
     }
     // Convert the values into an array.
     $data = $registry->toArray();
     // Get the fields lib
     $fieldsLib = FD::fields();
     // Build arguments to be passed to the field apps.
     $args = array(&$data, &$user);
     // @trigger onAdminEditValidate
     $errors = $fieldsLib->trigger('onAdminEditValidate', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // If there are errors, we should be exiting here.
     if (is_array($errors) && count($errors) > 0) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $this->view->call('form', $errors);
     }
     // @trigger onAdminEditBeforeSave
     $errors = $fieldsLib->trigger('onAdminEditBeforeSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     if (is_array($errors) && count($errors) > 0) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $this->view->call('form', $errors);
     }
     // Update the user's gid
     $gid = $this->input->get('gid', array(), 'array');
     $data['gid'] = $gid;
     // Bind the user object with the form data.
     $user->bind($data);
     // Create a new user record if the id don't exist yet.
     if (!$id) {
         $model = ES::model('Users');
         $user = $model->create($data, $user, $profile);
         if (!$user) {
             $this->view->setMessage($model->getError(), SOCIAL_MSG_ERROR);
             // We need to set the data into the post again because onEditValidate might have changed the data structure
             JRequest::set($data, 'post');
             return $this->view->call('form');
         }
         // If admin selected auto approval, automatically approve this user.
         if ($autoApproval) {
             $user->approve(false);
         }
         $message = $autoApproval ? JText::_('COM_EASYSOCIAL_USERS_CREATED_SUCCESSFULLY_AND_APPROVED') : JText::_('COM_EASYSOCIAL_USERS_CREATED_SUCCESSFULLY');
     } else {
         // If this was an edited user, save the user object.
         $user->save();
         $message = JText::_('COM_EASYSOCIAL_USERS_USER_UPDATED_SUCCESSFULLY');
     }
     // Reconstruct args
     $args = array(&$data, &$user);
     // @trigger onEditAfterSave
     $fieldsLib->trigger('onAdminEditAfterSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Bind the custom fields for the user.
     $user->bindCustomFields($data);
     // Reconstruct args
     $args = array(&$data, &$user);
     // @trigger onEditAfterSaveFields
     $fieldsLib->trigger('onAdminEditAfterSaveFields', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Prepare the dispatcher
     FD::apps()->load(SOCIAL_TYPE_USER);
     $dispatcher = FD::dispatcher();
     $args = array(&$user, &$fields, &$data);
     // @trigger: onUserProfileUpdate
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onUserProfileUpdate', $args);
     // Process notifications
     if (isset($post['notifications']) && !empty($post['notifications'])) {
         $systemNotifications = $post['notifications']['system'];
         $emailNotifications = $post['notifications']['email'];
         // Store the notification settings for this user.
         $model = ES::model('Notifications');
         $model->saveNotifications($systemNotifications, $emailNotifications, $user);
     }
     // Process privacy items
     if (isset($post['privacy']) && !empty($post['privacy'])) {
         $resetPrivacy = isset($post['privacyReset']) ? true : false;
         $user->bindPrivacy($post['privacy'], $post['privacyID'], $post['privacyCustom'], $post['privacyOld'], $resetPrivacy);
     }
     $this->view->setMessage($message, SOCIAL_MSG_SUCCESS);
     return $this->view->call(__FUNCTION__, $task, $user);
 }
Example #19
0
 function ajaxfilter()
 {
     require JPATH_COMPONENT_ADMINISTRATOR . DS . 'library' . DS . 'JSON.php';
     $json = JRequest::getVar('json', '');
     $document =& JFactory::getDocument();
     $document->setMimeEncoding('application/json');
     $jsonService = new Services_JSON();
     $post = $jsonService->decode($json);
     JRequest::set((array) $post, 'POST');
     $model =& $this->getModel('Properties');
     $res = $model->getProperties(true);
     $result = array();
     $result['types'][] = array('value' => 0, 'text' => '- ' . Jtext::_('Property type') . ' -');
     $result['towns'][] = array('value' => 0, 'text' => '- ' . Jtext::_('town') . ' -');
     $result['departments'][] = array('value' => 0, 'text' => '- ' . Jtext::_('Department') . ' -');
     $temp = array();
     $temp['types'] = array();
     $temp['towns'] = array();
     $temp['departments'] = array();
     foreach ($res['rows'] as $row) {
         if ($row->type_id && !isset($temp['types'][$row->type_id])) {
             $result['types'][] = array('value' => $row->type_id, 'text' => $row->type);
             $temp['types'][$row->type_id] = true;
         }
         if ($row->town_id && !isset($temp['towns'][$row->town_id])) {
             $result['towns'][] = array('value' => $row->town_id, 'text' => $row->town);
             $temp['towns'][$row->town_id] = true;
         }
         if ($row->department_id && !isset($temp['departments'][$row->department_id])) {
             $result['departments'][] = array('value' => $row->department_id, 'text' => $row->department);
             $temp['departments'][$row->department_id] = true;
         }
     }
     echo $jsonService->encode($result);
 }
Example #20
0
 /**
  * Verifies the fields in a submitted form.
  * Then adds the item to the users cart
  *
  * @return unknown_type
  */
 function addToCart()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     $product_id = JRequest::getInt('product_id');
     $product_qty = JRequest::getInt('product_qty');
     $filter_category = JRequest::getInt('filter_category');
     Tienda::load("TiendaHelperRoute", 'helpers.route');
     $router = new TiendaHelperRoute();
     if (!($itemid = $router->product($product_id, $filter_category, true))) {
         $itemid = $router->category(1, true);
         if (!$itemid) {
             $itemid = JRequest::getInt('Itemid', 0);
         }
     }
     // set the default redirect URL
     $redirect = "index.php?option=com_tienda&view=products&task=view&id={$product_id}&filter_category={$filter_category}&Itemid=" . $itemid;
     $redirect = JRoute::_($redirect, false);
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $helper = TiendaHelperBase::getInstance();
     if (!Tienda::getInstance()->get('shop_enabled', '1')) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_TIENDA_SHOP_DISABLED');
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     // convert elements to array that can be binded
     $values = JRequest::get('post');
     if (isset($values['elements'])) {
         $elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', $values['elements']));
         unset($values['elements']);
         // convert elements to array that can be binded
         $values = array_merge(TiendaHelperBase::elementsToArray($elements), $values);
         JRequest::set($values, 'POST');
     }
     $files = JRequest::get('files');
     $attributes = array();
     foreach ($values as $key => $value) {
         if (substr($key, 0, 10) == 'attribute_') {
             $attributes[] = $value;
         }
     }
     sort($attributes);
     $attributes_csv = implode(',', $attributes);
     // Integrity checks on quantity being added
     if ($product_qty < 0) {
         $product_qty = '1';
     }
     // using a helper file to determine the product's information related to inventory
     $availableQuantity = Tienda::getClass('TiendaHelperProduct', 'helpers.product')->getAvailableQuantity($product_id, $attributes_csv);
     if ($availableQuantity->product_check_inventory && $product_qty > $availableQuantity->quantity) {
         $this->messagetype = 'notice';
         $this->message = JText::_(JText::sprintf("COM_TIENDA_NOT_AVAILABLE_QUANTITY", $availableQuantity->product_name, $product_qty));
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     // do the item's charges recur? does the cart already have a subscription in it?  if so, fail with notice
     $product = JTable::getInstance('Products', 'TiendaTable');
     $product->load(array('product_id' => $product_id), true, false);
     // if product notforsale, fail
     if ($product->product_notforsale) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_TIENDA_PRODUCT_NOT_FOR_SALE');
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     $user = JFactory::getUser();
     $cart_id = $user->id;
     $id_type = "user_id";
     if (empty($user->id)) {
         $session = JFactory::getSession();
         $cart_id = $session->getId();
         $id_type = "session";
     }
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $carthelper = new TiendaHelperCarts();
     $cart_recurs = $carthelper->hasRecurringItem($cart_id, $id_type);
     if ($product->product_recurs && $cart_recurs) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_TIENDA_CART_ALREADY_RECURS');
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     if ($product->product_recurs) {
         $product_qty = '1';
     }
     // create cart object out of item properties
     $item = new JObject();
     $item->user_id = JFactory::getUser()->id;
     $item->product_id = (int) $product_id;
     $item->product_qty = (int) $product_qty;
     $item->product_attributes = $attributes_csv;
     $item->vendor_id = '0';
     // vendors only in enterprise version
     // if ther is another product_url, put it into the cartitem_params, to allow custom redirect
     if (array_key_exists('product_url', $values)) {
         $params = new DSCParameter(trim(@$item->cartitem_params));
         $params->set('product_url', $values['product_url']);
         $item->cartitem_params = trim($params->toString());
     }
     // onAfterCreateItemForAddToCart: plugin can add values to the item before it is being validated /added
     // once the extra field(s) have been set, they will get automatically saved
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger("onAfterCreateItemForAddToCart", array($item, $values, $files));
     foreach ($results as $result) {
         foreach ($result as $key => $value) {
             $item->set($key, $value);
         }
     }
     // does the user/cart match all dependencies?
     $canAddToCart = $carthelper->canAddItem($item, $cart_id, $id_type);
     if (!$canAddToCart) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_TIENDA_CANNOT_ADD_ITEM_TO_CART') . " - " . $carthelper->getError();
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     // no matter what, fire this validation plugin event for plugins that extend the checkout workflow
     $results = array();
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger("onBeforeAddToCart", array(&$item, $values));
     for ($i = 0; $i < count($results); $i++) {
         $result = $results[$i];
         if (!empty($result->error)) {
             $this->messagetype = 'notice';
             $this->message = $result->message;
             $this->setRedirect($redirect, $this->message, $this->messagetype);
             return;
         }
     }
     // if here, add to cart
     // After login, session_id is changed by Joomla, so store this for reference
     $session = JFactory::getSession();
     $session->set('old_sessionid', $session->getId());
     // add the item to the cart
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $cart_helper = new TiendaHelperCarts();
     $cartitem = $cart_helper->addItem($item);
     // fire plugin event
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onAfterAddToCart', array($cartitem, $values));
     // get the 'success' redirect url
     switch (Tienda::getInstance()->get('addtocartaction', 'redirect')) {
         case "checkout":
             // if a base64_encoded url is present as return, use that as the return url
             // otherwise return == the product view page
             $returnUrl = base64_encode($redirect);
             if ($return_url = JRequest::getVar('return', '', 'method', 'base64')) {
                 $return_url = base64_decode($return_url);
                 if (JURI::isInternal($return_url)) {
                     $returnUrl = base64_encode($return_url);
                 }
             }
             // if a base64_encoded url is present as redirect, redirect there,
             // otherwise redirect to the checkout
             $itemid_checkout = $router->findItemid(array('view' => 'checkout'));
             $itemid_opc = $router->findItemid(array('view' => 'opc'));
             $checkout_view = "checkout";
             $itemid = null;
             if ($itemid_opc) {
                 $itemid = $itemid_opc;
                 $checkout_view = "opc";
             } elseif ($itemid_checkout) {
                 $itemid = $itemid_checkout;
             }
             if (!$itemid) {
                 $itemid = JRequest::getInt('Itemid', 0);
             }
             $redirect = JRoute::_("index.php?option=com_tienda&view=" . $checkout_view . "&Itemid=" . $itemid, false);
             if ($redirect_url = JRequest::getVar('redirect', '', 'method', 'base64')) {
                 $redirect_url = base64_decode($redirect_url);
                 if (JURI::isInternal($redirect_url)) {
                     $redirect = $redirect_url;
                 }
             }
             if (strpos($redirect, '?') === false) {
                 $redirect .= "?return=" . $returnUrl;
             } else {
                 $redirect .= "&return=" . $returnUrl;
             }
             break;
         case "0":
         case "none":
             // redirects back to product page
             break;
         case "samepage":
             // redirects back to the page it came from (category, content, etc)
             // Take only the url without the base domain (index.php?option.....)
             if ($return_url = JRequest::getVar('return', '', 'method', 'base64')) {
                 $return_url = base64_decode($return_url);
                 $uri = JURI::getInstance();
                 $uri->parse($return_url);
                 $redirect = $uri->toString(array('path', 'query', 'fragment'));
                 $redirect = JRoute::_($redirect, false);
             }
             break;
         case "lightbox":
         case "redirect":
         default:
             // if a base64_encoded url is present as return, use that as the return url
             // otherwise return == the product view page
             $returnUrl = base64_encode($redirect);
             if ($return_url = JRequest::getVar('return', '', 'method', 'base64')) {
                 $return_url = base64_decode($return_url);
                 if (JURI::isInternal($return_url)) {
                     $returnUrl = base64_encode($return_url);
                 }
             }
             // if a base64_encoded url is present as redirect, redirect there,
             // otherwise redirect to the cart
             $itemid = $router->findItemid(array('view' => 'carts'));
             if (!$itemid) {
                 $itemid = JRequest::getInt('Itemid', 0);
             }
             $redirect = JRoute::_("index.php?option=com_tienda&view=carts&Itemid=" . $itemid, false);
             if ($redirect_url = JRequest::getVar('redirect', '', 'method', 'base64')) {
                 $redirect_url = base64_decode($redirect_url);
                 if (JURI::isInternal($redirect_url)) {
                     $redirect = $redirect_url;
                 }
             }
             //$returnUrl = base64_encode( $redirect );
             //$itemid = $router->findItemid( array('view'=>'checkout') );
             //$redirect = JRoute::_( "index.php?option=com_tienda&view=carts&Itemid=".$itemid, false );
             if (strpos($redirect, '?') === false) {
                 $redirect .= "?return=" . $returnUrl;
             } else {
                 $redirect .= "&return=" . $returnUrl;
             }
             break;
     }
     $this->messagetype = 'message';
     $this->message = JText::_('COM_TIENDA_ITEM_ADDED_TO_YOUR_CART');
     $this->setRedirect($redirect, $this->message, $this->messagetype);
     return;
 }
Example #21
0
 /**
  * Parse the URI
  *
  * @param	object	The URI
  *
  * @return	array
  */
 public function parse(&$uri)
 {
     $vars = array();
     // Get the application
     $app = JApplication::getInstance('site');
     if ($app->getCfg('force_ssl') == 2 && strtolower($uri->getScheme()) != 'https') {
         //forward to https
         $uri->setScheme('https');
         $app->redirect((string) $uri);
     }
     // Get the path
     $path = $uri->getPath();
     // Remove the base URI path.
     $path = substr_replace($path, '', 0, strlen(JURI::base(true)));
     // Check to see if a request to a specific entry point has been made.
     if (preg_match("#.*?\\.php#u", $path, $matches)) {
         // Get the current entry point path relative to the site path.
         $scriptPath = realpath($_SERVER['SCRIPT_FILENAME'] ? $_SERVER['SCRIPT_FILENAME'] : str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']));
         $relativeScriptPath = str_replace('\\', '/', str_replace(JPATH_SITE, '', $scriptPath));
         // If a php file has been found in the request path, check to see if it is a valid file.
         // Also verify that it represents the same file from the server variable for entry script.
         if (file_exists(JPATH_SITE . $matches[0]) && $matches[0] == $relativeScriptPath) {
             // Remove the entry point segments from the request path for proper routing.
             $path = str_replace($matches[0], '', $path);
         }
     }
     // Identify format
     if ($this->_mode == JROUTER_MODE_SEF) {
         if ($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/')) {
             if ($suffix = pathinfo($path, PATHINFO_EXTENSION)) {
                 $vars['format'] = $suffix;
             }
         }
     }
     //Remove prefix
     $path = str_replace('index.php', '', $path);
     //Set the route
     $uri->setPath(trim($path, '/'));
     $vars += parent::parse($uri);
     if (empty($vars['option']) && isset($_POST['option'])) {
         $vars['option'] = JRequest::getCmd('option', '', 'post');
     }
     if (empty($vars['option'])) {
         JError::raiseError(404, JText::_('JGLOBAL_RESOURCE_NOT_FOUND'));
     }
     /* START: HUBzero Extensions Follow to force registration and email confirmation */
     $juser = JFactory::getUser();
     if (!$juser->get('guest')) {
         $session = JFactory::getSession();
         $registration_incomplete = $session->get('registration.incomplete');
         if ($registration_incomplete) {
             if ($vars['option'] == 'com_users') {
                 if ($vars['view'] == 'logout' || $vars['task'] == 'logout') {
                     return $vars;
                 }
             }
             if ($vars['option'] == 'com_members' && (isset($vars['controller']) && $vars['controller'] == 'register' || isset($vars['view']) && $vars['view'] == 'register')) {
                 $session->set('linkaccount', false);
                 return $vars;
             }
             if ($uri->getPath() != 'legal/terms') {
                 $originalVars = $vars;
                 $vars = array();
                 if ($juser->get('tmp_user')) {
                     $vars['option'] = 'com_members';
                     $vars['controller'] = 'register';
                     $vars['task'] = 'create';
                     $vars['act'] = '';
                 } else {
                     if (substr($juser->get('email'), -8) == '@invalid') {
                         // First, allow ticket creation
                         if ($originalVars['option'] == 'com_support' && $originalVars['controller'] == 'tickets' && $originalVars['task'] == 'save') {
                             // Do nothing...allow it to pass through
                             $vars = $originalVars;
                         } elseif ($session->get('linkaccount', true)) {
                             $vars['option'] = 'com_users';
                             $vars['view'] = 'link';
                         } else {
                             $vars['option'] = 'com_members';
                             $vars['controller'] = 'register';
                             $vars['task'] = 'update';
                             $vars['act'] = '';
                         }
                     } else {
                         $o = JRequest::getVar('option', '');
                         $t = JRequest::getVar('task', '');
                         $nh = JRequest::getInt('no_html', 0);
                         //are we trying to use the tag autocompletor when forcing registration update?
                         if ($o == 'com_tags' && $t == 'autocomplete' && $nh) {
                             $vars['option'] = 'com_tags';
                         } else {
                             $vars['option'] = 'com_members';
                             $vars['id'] = $juser->get("id");
                             $vars['active'] = 'profile';
                         }
                     }
                 }
                 $this->setVars($vars);
                 JRequest::set($vars, 'get', true);
                 // overwrite existing
                 return $vars;
             }
         }
         $xprofile = \Hubzero\User\Profile::getInstance($juser->get('id'));
         if (is_object($xprofile) && $xprofile->get('emailConfirmed') != 1 && $xprofile->get('emailConfirmed') != 3) {
             if ($vars['option'] == 'com_users') {
                 if (isset($vars['view']) && $vars['view'] == 'logout' || isset($vars['task']) && $vars['task'] == 'logout') {
                     return $vars;
                 }
             } else {
                 if ($uri->getPath() == 'legal/terms') {
                     return $vars;
                 } else {
                     if ($vars['option'] == 'com_members' && (isset($vars['controller']) && $vars['controller'] == 'register' || isset($vars['view']) && $vars['view'] == 'register')) {
                         if (!empty($vars['task'])) {
                             if ($vars['task'] == 'unconfirmed' || $vars['task'] == 'change' || $vars['task'] == 'resend' || $vars['task'] == 'confirm') {
                                 return $vars;
                             }
                         }
                     } else {
                         if ($vars['option'] == 'com_members' && (isset($vars['task']) && $vars['task'] == 'download') && (isset($vars['active']) && strpos($vars['active'], 'Image:') !== false) && JFactory::getSession()->get('userchangedemail', 0) == 1) {
                             return $vars;
                         }
                     }
                 }
             }
             $vars = array();
             $vars['option'] = 'com_members';
             $vars['controller'] = 'register';
             $vars['task'] = 'unconfirmed';
             $this->setVars($vars);
             JRequest::set($vars, 'get', true);
             // overwrite existing
             return $vars;
         }
         if (!$juser->get('approved')) {
             if ($vars['option'] == 'com_users') {
                 if ($vars['view'] == 'logout' || $vars['task'] == 'logout') {
                     return $vars;
                 }
             } else {
                 if ($uri->getPath() == 'legal/terms') {
                     return $vars;
                 } else {
                     if ($vars['option'] == 'com_support' && $vars['controller'] == 'tickets' && $vars['task'] == 'save') {
                         return $vars;
                     } else {
                         if ($vars['option'] == 'com_support' && $vars['controller'] == 'tickets' && $vars['task'] == 'new') {
                             return $vars;
                         }
                     }
                 }
             }
             $vars = array();
             $vars['option'] = 'com_users';
             $vars['view'] = 'unapproved';
             $this->setVars($vars);
             JRequest::set($vars, 'get', true);
             // overwrite existing
             return $vars;
         }
         $badpassword = $session->get('badpassword', false);
         $expiredpassword = $session->get('expiredpassword', false);
         if ($badpassword || $expiredpassword) {
             if ($vars['option'] == 'com_members' && isset($vars['task']) && $vars['task'] == 'changepassword') {
                 return $vars;
             }
             if ($vars['option'] == 'com_users' && ($vars['view'] == 'logout' || $vars['task'] == 'logout' || JRequest::getWord('task') == 'logout')) {
                 return $vars;
             }
             if ($vars['option'] == 'com_support' && $vars['task'] == 'save') {
                 return $vars;
             }
             if ($uri->getPath() == 'legal/terms') {
                 return $vars;
             }
             // @FIXME: should double check shadowFlag here in case password gets chanegd
             // out of band.
             // @FIXME: should we clear POST and GET data
             $vars = array();
             $vars['option'] = 'com_members';
             $vars['task'] = 'changepassword';
             if ($badpassword) {
                 $vars['message'] = "Your password does not meet current site requirements. Please change your password now.";
             }
             if ($expiredpassword) {
                 $vars['message'] = "Your password has expired. Please change your password now.";
             }
             $this->setVars($vars);
             JRequest::set($vars, 'get', true);
             // overwrite existing
         }
     }
     // Call system plugins for parsing routes
     if ($responses = JDispatcher::getInstance()->trigger('onParseRoute', array($vars))) {
         // We're assuming here that if a plugin returns vars, we'll take them wholesale.
         // This also means that plugins need to be ordered in terms of priority, as we'll
         // return the first response that isn't empty.
         foreach ($responses as $response) {
             if (is_array($response) && !empty($response)) {
                 $this->setVars($response);
                 JRequest::set($response, 'get', true);
                 return $response;
             }
         }
     }
     /* END: HUBzero Extensions Follow to force registration and email confirmation */
     return $vars;
 }
Example #22
0
 public function store()
 {
     FD::checkToken();
     FD::language()->loadSite();
     $my = FD::user();
     $view = $this->getCurrentView();
     $task = $this->getTask();
     $id = JRequest::getInt('id');
     $event = FD::event($id);
     $isNew = empty($event->id);
     $post = JRequest::get('POST');
     $options = array();
     if ($isNew) {
         $event->category_id = JRequest::getInt('category_id');
         $event->creator_uid = $my->id;
         $event->creator_type = SOCIAL_TYPE_USER;
         $event->state = SOCIAL_STATE_PUBLISHED;
         $event->key = md5(FD::date()->toSql() . $my->password . uniqid());
     } else {
         $options['data'] = true;
         $options['dataId'] = $event->id;
         $options['dataType'] = SOCIAL_FIELDS_GROUP_EVENT;
     }
     $options['uid'] = $event->category_id;
     $options['group'] = SOCIAL_FIELDS_GROUP_EVENT;
     $fields = FD::model('fields')->getCustomFields($options);
     $registry = FD::registry();
     $disallowed = array(FD::token(), 'option', 'task', 'controller');
     foreach ($post as $key => $value) {
         if (!in_array($key, $disallowed)) {
             if (is_array($value)) {
                 $value = FD::json()->encode($value);
             }
             $registry->set($key, $value);
         }
     }
     $data = $registry->toArray();
     $fieldsLib = FD::fields();
     $args = array(&$data, &$event);
     $errors = $fieldsLib->trigger('onAdminEditValidate', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     if (!empty($errors)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_FORM_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         JRequest::set($data, 'POST');
         return $view->call('form', $errors);
     }
     $errors = $fieldsLib->trigger('onAdminEditBeforeSave', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     if (!empty($errors)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_EVENTS_FORM_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         JRequest::set($data, 'POST');
         return $view->call('form', $errors);
     }
     $event->bind($data);
     $event->save();
     if ($isNew) {
         $event->createOwner();
     }
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onAdminEditAfterSave', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     $event->bindCustomFields($data);
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onAdminEditAfterSaveFields', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     if ($isNew) {
         $event->createStream('create', $event->creator_uid, $event->creator_type);
     }
     // Jason: We do not want to create "update" stream if the edit occurs at backend?
     /*else {
     
                 // Only create if applyRecurring is false or event is not a child
                 // applyRecurring && parent = true
                 // applyRecurring && child = false
                 // !applyRecurring && parent = true
                 // !applyRecurring && child = true
                 if (empty($data['applyRecurring']) || !$event->isRecurringEvent()) {
                     $event->createStream('update', $my->id, SOCIAL_TYPE_USER);
                 }
             }*/
     $message = JText::_($isNew ? 'COM_EASYSOCIAL_EVENTS_FORM_CREATE_SUCCESS' : 'COM_EASYSOCIAL_EVENTS_FORM_UPDATE_SUCCESS');
     $view->setMessage($message, SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__, $task, $event);
 }
Example #23
0
 /**
  * Retrieves the timeline for the current user that is being viewed.
  *
  * @since	1.0
  * @access	public
  */
 public function getStream()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Get the view.
     $view = $this->getCurrentView();
     // set jrequest view
     JRequest::set(array('view' => 'profile'));
     // Get the current user that is being viewed.
     $id = JRequest::getInt('id', null);
     $user = FD::user($id);
     // @TODO: Check if the viewer can access the user's timeline or not.
     // Retrieve user's stream
     $stream = FD::get('Stream');
     $stream->get(array('userId' => $user->id));
     // Retrieve user's status
     $story = FD::get('Story', SOCIAL_TYPE_USER);
     $story->target = $user->id;
     $stream->story = $story;
     return $view->call(__FUNCTION__, $stream, $story);
 }
Example #24
0
 /**
  * Saves a group
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function store()
 {
     // Check for request forgeries
     FD::checkToken();
     // Load front end's language file
     FD::language()->loadSite();
     // Get the current view
     $view = $this->getCurrentView();
     // Get the current task
     $task = $this->getTask();
     // Determines if this group is being edited.
     $id = $this->input->get('id', 0, 'int');
     // Flag to see if this is new or edit
     $isNew = empty($id);
     // Get the posted data
     $post = $this->input->getArray('post');
     $options = array();
     if ($isNew) {
         // Include group library
         FD::import('admin:/includes/group/group');
         $group = new SocialGroup();
         $categoryId = $this->input->get('category_id', 0, 'int');
     } else {
         $group = FD::group($id);
         $options['data'] = true;
         $options['dataId'] = $group->id;
         $options['dataType'] = SOCIAL_FIELDS_GROUP_GROUP;
         $categoryId = $group->category_id;
     }
     // Set the necessary data
     $options['uid'] = $categoryId;
     $options['group'] = SOCIAL_FIELDS_GROUP_GROUP;
     // Get fields model
     $fieldsModel = FD::model('Fields');
     // Get the custom fields
     $fields = $fieldsModel->getCustomFields($options);
     // Initialize default registry
     $registry = FD::registry();
     // Get disallowed keys so we wont get wrong values.
     $disallowed = array(FD::token(), 'option', 'task', 'controller', 'autoapproval');
     // Process $_POST vars
     foreach ($post as $key => $value) {
         if (!in_array($key, $disallowed)) {
             if (is_array($value)) {
                 $value = json_encode($value);
             }
             $registry->set($key, $value);
         }
     }
     // Convert the values into an array.
     $data = $registry->toArray();
     // Get the fields lib
     $fieldsLib = FD::fields();
     // Build arguments to be passed to the field apps.
     $args = array(&$data, &$group);
     // @trigger onAdminEditValidate
     $errors = $fieldsLib->trigger('onAdminEditValidate', $options['group'], $fields, $args);
     // If there are errors, we should be exiting here.
     if (is_array($errors) && count($errors) > 0) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_FORM_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $view->call('form', $errors);
     }
     // @trigger onAdminEditBeforeSave
     $errors = $fieldsLib->trigger('onAdminEditBeforeSave', $options['group'], $fields, $args);
     // If there are errors, we should be exiting here.
     if (is_array($errors) && count($errors) > 0) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_FORM_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $view->call('form', $errors);
     }
     // Initialise group data for new group
     if ($isNew) {
         // Set the category id for the group
         $group->category_id = $categoryId;
         $group->creator_uid = $this->my->id;
         $group->creator_type = SOCIAL_TYPE_USER;
         $group->state = SOCIAL_STATE_PUBLISHED;
         $group->hits = 0;
         // Generate a unique key for this group which serves as a password
         $group->key = md5(FD::date()->toSql() . $this->my->password . uniqid());
     }
     // Bind the user object with the form data.
     $group->bind($data);
     // Save the group
     $group->save();
     // After the group is created, assign the current user as the node item
     if ($isNew) {
         $group->createOwner($this->my->id);
     }
     // Reconstruct args
     $args = array(&$data, &$group);
     // @trigger onEditAfterSave
     $fieldsLib->trigger('onAdminEditAfterSave', $options['group'], $fields, $args);
     // Bind the custom fields for the group.
     $group->bindCustomFields($data);
     // Reconstruct args
     $args = array(&$data, &$group);
     // @trigger onEditAfterSaveFields
     $fieldsLib->trigger('onAdminEditAfterSaveFields', $options['group'], $fields, $args);
     $message = $id ? JText::_('COM_EASYSOCIAL_GROUPS_FORM_SAVE_UPDATE_SUCCESS') : JText::_('COM_EASYSOCIAL_GROUPS_FORM_CREATE_SUCCESS');
     $view->setMessage($message, SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__, $task, $group);
 }
Example #25
0
	/**
	* Route the application.
	*
	* Routing is the process of examining the request environment to determine which
	* component should receive the request. The component optional parameters
	* are then set in the request object to be processed when the application is being
	* dispatched.
	*
	* @abstract
	* @param	object A JURI object.
	* @access	public
	*/
	function route($uri = null)
 	{
		if(!isset($uri)) {
		    $uri = clone(JURI::getInstance());
		}

	    $result = $this->getRouter()->parse($uri);
		JRequest::set($result, 'get', false );
 	}
 private function decodeFields($option, $task)
 {
     if ($this->params->get('contact') and $option == 'com_contact' and $task == 'contact.submit') {
         $name = $this->_session->get('jform[contact_name]', null, 'easycalccheck');
         $email = $this->_session->get('jform[contact_email]', null, 'easycalccheck');
         $subject = $this->_session->get('jform[contact_subject]', null, 'easycalccheck');
         $text = $this->_session->get('jform[contact_message]', null, 'easycalccheck');
         $jform_array = JRequest::getVar('jform');
         $jform = array();
         $jform['jform']['contact_name'] = JRequest::getString($name);
         $jform['jform']['contact_email'] = JRequest::getString($email);
         $jform['jform']['contact_subject'] = JRequest::getString($subject);
         $jform['jform']['contact_message'] = JRequest::getString($text);
         // Check e-mail copy
         if (isset($jform_array['contact_email_copy'])) {
             $jform['jform']['contact_email_copy'] = '';
         }
         JRequest::set($jform, 'post', true);
         $this->_session->clear('jform[contact_name]', 'easycalccheck');
         $this->_session->clear('jform[contact_email]', 'easycalccheck');
         $this->_session->clear('jform[contact_subject]', 'easycalccheck');
         $this->_session->clear('jform[contact_message]', 'easycalccheck');
     } elseif ($this->params->get('user_reg') and $option == 'com_users' and $task == 'registration.register') {
         $name = $this->_session->get('jform[name]', null, 'easycalccheck');
         $username = $this->_session->get('jform[username]', null, 'easycalccheck');
         $password1 = $this->_session->get('jform[password1]', null, 'easycalccheck');
         $password2 = $this->_session->get('jform[password2]', null, 'easycalccheck');
         $email1 = $this->_session->get('jform[email1]', null, 'easycalccheck');
         $email2 = $this->_session->get('jform[email2]', null, 'easycalccheck');
         $jform = JRequest::get();
         $jform['jform']['name'] = JRequest::getString($name);
         $jform['jform']['username'] = JRequest::getString($username);
         $jform['jform']['password1'] = JRequest::getString($password1);
         $jform['jform']['password2'] = JRequest::getString($password2);
         $jform['jform']['email1'] = JRequest::getString($email1);
         $jform['jform']['email2'] = JRequest::getString($email2);
         JRequest::set($jform, 'post', true);
         $this->_session->clear('jform[name]', 'easycalccheck');
         $this->_session->clear('jform[username]', 'easycalccheck');
         $this->_session->clear('jform[password1]', 'easycalccheck');
         $this->_session->clear('jform[password2]', 'easycalccheck');
         $this->_session->clear('jform[email1]', 'easycalccheck');
         $this->_session->clear('jform[email2]', 'easycalccheck');
     }
 }
 /**
  * Utility Function:
  * Force frontend specific redirestions most notably redirecting the joomla ARTICLE VIEW to the FLEXIcontent ITEM VIEW
  * Some special cases are handled e.g. redirecting the joomla article form to FLEXIcontent item form
  *
  * @access public
  * @return void
  */
 function redirectSiteComContent()
 {
     $app = JFactory::getApplication();
     $option = JRequest::getCMD('option');
     $view = JRequest::getCMD('view');
     $db = JFactory::getDBO();
     // Let's Redirect/Reroute Joomla's article view & form to FLEXIcontent item view & form respectively !!
     // NOTE: we do not redirect/reroute Joomla's category views (blog,list,featured for J2.5 etc),
     //       thus site administrator can still utilize them
     if ($option == 'com_content' && ($view == 'article' || $view == FLEXI_ITEMVIEW || $view == 'form')) {
         // In J2.5, in case of form we need to use a_id instead of id, this will also be set in HTTP Request too and JRouter too
         $id = JRequest::getInt('id');
         $id = $view == 'form' ? JRequest::getInt('a_id') : $id;
         // Get article category id, if it is not already in url
         $catid = JRequest::getInt('catid');
         if (!$catid) {
             $db->setQuery('SELECT catid FROM #__content WHERE id = ' . $id);
             $catid = $db->loadResult();
         }
         $in_limits = $catid >= FLEXI_LFT_CATEGORY && $catid <= FLEXI_RGT_CATEGORY;
         // Allow Joomla article view for non-bound items or for specific content types
         if ($in_limits && $view == 'article') {
             $db->setQuery('SELECT	attribs' . ' FROM #__flexicontent_types AS ty ' . ' JOIN #__flexicontent_items_ext AS ie ON ie.type_id = ty.id ' . ' WHERE ie.item_id = ' . $id);
             $type_params = $db->loadResult();
             if (!$type_params) {
                 $in_limits = false;
             } else {
                 $type_params = new JRegistry($type_params);
                 $in_limits = $type_params->get('allow_jview') == 0;
                 // Allow viewing by article view, if so configured
             }
         }
         if (empty($in_limits)) {
             return;
         }
         if ($this->params->get('redirect_method_fe', 1) == 1) {
             // Set new request variables:
             // NOTE: we only need to set REQUEST variable that must be changed,
             //       but setting any other variables to same value will not hurt
             if ($view == 'article' || $view == FLEXI_ITEMVIEW) {
                 $newRequest = array('option' => $this->extension, 'view' => FLEXI_ITEMVIEW, 'Itemid' => JRequest::getInt('Itemid'), 'lang' => JRequest::getCmd('lang'));
             } else {
                 if ($view == 'form') {
                     $newRequest = array('option' => $this->extension, 'view' => FLEXI_ITEMVIEW, 'task' => 'edit', 'layout' => 'form', 'id' => $id, 'Itemid' => JRequest::getInt('Itemid'), 'lang' => JRequest::getCmd('lang'));
                 } else {
                     // Unknown CASE ?? unreachable ?
                     return;
                 }
             }
             JRequest::set($newRequest, 'get');
             // Set variable also in the router, for best compatibility
             $router = $app->getRouter();
             $router->setVars($newRequest, false);
             //$app->enqueueMessage( "Set com_flexicontent item view instead of com_content article view", 'message');
         } else {
             if ($view == 'form') {
                 $urlItem = 'index.php?option=' . $this->extension . '&view=' . FLEXI_ITEMVIEW . '&id=' . $id . '&task=edit&layout=form';
             } else {
                 // Include the route helper files
                 require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
                 require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'route.php';
                 $itemslug = JRequest::getVar('id');
                 $catslug = JRequest::getVar('catid');
                 // Warning current menu item id must not be passed to the routing functions since it points to com_content, and thus it will break FC SEF URLs
                 $urlItem = $catslug ? FlexicontentHelperRoute::getItemRoute($itemslug, $catslug) : FlexicontentHelperRoute::getItemRoute($itemslug);
                 $urlItem = JRoute::_($urlItem);
             }
             //$app->enqueueMessage( "Redirected to com_flexicontent item view instead of com_content article view", 'message');
             $app->redirect($urlItem);
         }
     }
 }
Example #28
0
 /**
  * Router action
  * 
  * @param KCommandContext $context
  */
 protected function _actionRoute(KCommandContext $context)
 {
     //legacy
     if (KRequest::has('post.option')) {
         KRequest::set('get.option', KRequest::get('post.option', 'cmd'));
     }
     parent::_actionRoute($context);
     $component = $this->getRequest()->get('option');
     $user =& JFactory::getUser();
     if (!$user->authorize('login', 'administrator')) {
         $component = 'com_login';
     }
     if (empty($component)) {
         $component = 'com_cpanel';
     }
     $this->getRequest()->set('option', $component);
     JRequest::set($this->getRequest()->toArray(), 'get');
     $this->setComponent(substr($component, 4));
     $this->dispatch();
 }
 /**
  * Route the application.
  *
  * Routing is the process of examining the request environment to determine which
  * component should receive the request. The component optional parameters
  * are then set in the request object to be processed when the application is being
  * dispatched.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function route()
 {
     // Get the full request URI.
     $uri = clone JURI::getInstance();
     $router = $this->getRouter();
     $result = $router->parse($uri);
     JRequest::set($result, 'get', false);
     // Trigger the onAfterRoute event.
     JPluginHelper::importPlugin('system');
     $this->triggerEvent('onAfterRoute');
 }
Example #30
0
 function search()
 {
     $model =& $this->getModel('search');
     $session =& JFactory::getSession();
     if (JRequest::checkToken()) {
         $facility_search = JRequest::getVar('facility_search', array(), '', 'array');
         $type_search = JRequest::getVar('type_search', array(), '', 'array');
         $params = array('search' => JRequest::getVar('search', '', 'string'), 'filter_country' => JRequest::getInt('country', 0), 'filter_states' => JRequest::getInt('filter_states', 0), 'filter_city' => JRequest::getInt('filter_city', 0), 'filter_star' => JRequest::getVar('filter_star', '', 'string'), 'filter_rate' => JRequest::getVar('filter_rate', '', 'string'), 'filter_price' => JRequest::getVar('filter_price', '', 'string'), 'facility_search' => implode(', ', $facility_search), 'type_search' => implode(', ', $type_search));
         //			JError::raiseWarning( 500, implode(', ', $facility_search));
         $session->set('params', $params, 'hg_search');
     } else {
         // force the default to layout on search result
         JError::raiseWarning(500, $model->getState('filter_country', 0));
     }
     $params = $session->get('params', array(), 'hg_search');
     // Bug correction on search pagination
     if ($limit = $model->getState('limit', 0)) {
         $params['limit'] = $limit;
         $session->set('params', $params, 'hg_search');
     }
     if ($limitstart = $model->getState('limitstart', 0)) {
         $params['limitstart'] = $limitstart;
         $session->set('params', $params, 'hg_search');
     }
     JRequest::set($params, 'POST');
     $this->display();
 }