403Webshell
Server IP : 46.105.57.169  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : verseaumee ( 152031)
PHP Version : 8.5.7
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/verseaumee/ptitsanes/plugins/user/solidres/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/verseaumee/ptitsanes/plugins/user/solidres/solidres.php
<?php
/*------------------------------------------------------------------------
  Solidres - Hotel booking extension for Joomla
  ------------------------------------------------------------------------
  @Author    Solidres Team
  @Website   http://www.solidres.com
  @Copyright Copyright (C) 2013 - 2016 Solidres. All Rights Reserved.
  @License   GNU General Public License version 3, or later
------------------------------------------------------------------------*/

defined('_JEXEC') or die;

/**
 * Solidres User plugin
 *
 * @package     Solidres
 * @subpackage  Customer
 * @since       0.6.0
 */

use GeoIp2\Database\Reader;
use Joomla\Utilities\ArrayHelper;
use Joomla\Utilities\IpHelper;

JLoader::import('solidres.plugin.plugin');

class plgUserSolidres extends SRPlugin
{

	/**
	 * Application object
	 *
	 * @var    JApplicationCms
	 * @since  3.2
	 */
	protected $app;

	/**
	 * Database object
	 *
	 * @var    JDatabaseDriver
	 * @since  3.2
	 */
	protected $db;

	/**
	 * Remove all sessions for the user name
	 *
	 * Method is called after user data is deleted from the database
	 *
	 * @param   array   $user    Holds the user data
	 * @param   boolean $success True if user was succesfully stored in the database
	 * @param   string  $msg     Message
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	public function onUserAfterDelete($user, $success, $msg)
	{
		if (!$success)
		{
			return false;
		}

		JTable::addIncludePath($this->_getAdminPath() . '/tables');
		$customerTable = JTable::getInstance('Customer', 'SolidresTable');
		$customerTable->load(array('user_id' => $user['id']));

		// Handle relationship with Solidres's Customers
		$query = $this->db->getQuery(true);

		// Take care of Reservation
		$query->update($this->db->quoteName('#__sr_reservations'))
			->set('customer_id = NULL')
			->where('customer_id = ' . $this->db->quote($customerTable->id));
		$this->db->setQuery($query)->execute();

		// Take care of Customer Fields
		$query->clear();
		$query->delete()->from($this->db->quoteName('#__sr_customer_fields'))
			->where('user_id = ' . $this->db->quote($customerTable->id));
		$this->db->setQuery($query)->execute();

		// Take care of relation ship with Reservation Asset
		$query->clear();
		$query->update($this->db->quoteName('#__sr_reservation_assets'))
			->set('partner_id = NULL')
			->where('partner_id = ' . $this->db->quote($customerTable->id));
		$this->db->setQuery($query)->execute();

		// Take care of Customer itself
		$query->clear();
		$query->delete()->from($this->db->quoteName('#__sr_customers'))
			->where('id = ' . $this->db->quote($customerTable->id));
		$this->db->setQuery($query)->execute();

		return true;
	}

	/**
	 * Utility method to act on a user after it has been saved.
	 *
	 * This method sends a registration email to new users created in the backend.
	 *
	 * By default: in the built-in onUserAfterSave, Joomla only send email if the user is registered from backend. We
	 *             need to modify it in order to send email for user who is registerd from front end as well.
	 *
	 * @param   array   $user    Holds the new user data.
	 * @param   boolean $isnew   True if a new user is stored.
	 * @param   boolean $success True if user was succesfully stored in the database.
	 * @param   string  $msg     Message.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	public function onUserAfterSave($user, $isnew, $success, $msg)
	{
		$this->saveUserProfile($user, $isnew, $success);
	}

	public function onReservationAfterSave($data, $table, $isNew, $model)
	{
		// Look like the user is logged in, no need to do anything here
		if (JFactory::getUser()->id)
		{
			return true;
		}

		// User is not logged in and he/she doesn't want to create an account
		if (!isset($data['customer_username']) && !isset($data['customer_password']))
		{
			return true;
		}

		$customerData = array(
			'customer_group_id' => null,
			'user_id'           => null,
			'username'          => $data['customer_username'],
			'password'          => $data['customer_password'],
			'password2'         => $data['customer_password'],
			'email'             => $data['customer_email'],
			'groups'            => array('2'), // Hard coded joomla user group id here, 2 = Registered group
			'firstname'         => $data['customer_firstname'],
			'middlename'        => isset($data['customer_middlename']) ? $data['customer_middlename'] : '',
			'lastname'          => $data['customer_lastname'],
			'vat_number'        => isset($data['customer_vat_number']) ? $data['customer_vat_number'] : '',
			'company'           => $data['customer_company'],
			'phonenumber'       => $data['customer_phonenumber'],
			'mobilephone'       => $data['customer_mobilephone'],
			'address1'          => $data['customer_address1'],
			'address2'          => $data['customer_address2'],
			'city'              => $data['customer_city'],
			'zipcode'           => $data['customer_zipcode'],
			'country_id'        => $data['customer_country_id'],
			'geo_state_id'      => isset($data['customer_geo_state_id']) && !empty($data['customer_geo_state_id']) ? $data['customer_geo_state_id'] : null
		);

		JModelLegacy::addIncludePath($this->_getAdminPath() . '/models', 'SolidresModel');
		$customerModel = JModelLegacy::getInstance('Customer', 'SolidresModel', array('ignore_request' => true));
		$customerModel->save($customerData);
		$recentStoredCustomerId = (int) $customerModel->getState($customerModel->getName() . '.id');

		if ($recentStoredCustomerId > 0)
		{
			$table->customer_id = $recentStoredCustomerId;
			$table->store();

			if (!empty($data['privacyConsent']))
			{
				$this->onActivateUserPrivacyConsent($recentStoredCustomerId);
			}
		}

		return true;
	}

	public function onActivateUserPrivacyConsent($customerId)
	{
		if (JPluginHelper::isEnabled('system', 'privacyconsent'))
		{
			try
			{
				$db    = JFactory::getDbo();
				$query = $db->getQuery(true)
					->select('u.*')
					->from($db->quoteName('#__users', 'u'))
					->join('INNER', $db->quoteName('#__sr_customers', 'c') . ' ON c.user_id = u.id')
					->where('c.id = ' . (int) $customerId);

				if ($userObj = $db->setQuery($query)->loadObject())
				{
					$query->clear()
						->delete($db->quoteName('#__privacy_consents'))
						->where($db->quoteName('user_id') . ' = ' . $userObj->id);
					$db->setQuery($query)
						->execute();
					$ip        = IpHelper::getIp();
					$userAgent = $this->app->input->server->get('HTTP_USER_AGENT', '', 'string');
					$userNote  = (object) [
						'user_id' => $userObj->id,
						'subject' => 'PLG_SYSTEM_PRIVACYCONSENT_SUBJECT',
						'body'    => JText::sprintf('PLG_SYSTEM_PRIVACYCONSENT_BODY', $ip, $userAgent),
						'created' => JFactory::getDate()->toSql(),
					];

					$this->db->insertObject('#__privacy_consents', $userNote);


					$message = [
						'action'      => 'consent',
						'id'          => $userObj->id,
						'title'       => $userObj->name,
						'itemlink'    => 'index.php?option=com_users&task=user.edit&id=' . $userObj->id,
						'userid'      => $userObj->id,
						'username'    => $userObj->username,
						'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $userObj->id,
					];

					JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel');

					/* @var ActionlogsModelActionlog $model */
					$model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel');
					$model->addLog([$message], 'PLG_SYSTEM_PRIVACYCONSENT_CONSENT', 'plg_system_privacyconsent', $userObj->id);
				}
			}
			catch (Exception $e)
			{

			}
		}
	}

	/**
	 * Create a new Joomla user before we create a new Solidres's customer.
	 *
	 * The procedure is different between front end and back end.
	 *
	 * @param $data
	 * @param $table
	 * @param $isNew
	 * @param $response
	 *
	 * @return bool
	 */
	public function onCustomerBeforeSave($data, $table, $isNew, &$response)
	{
		$app                = JFactory::getApplication();
		$isSite             = $app->getName() == 'site';
		$solidresConfig     = JComponentHelper::getParams('com_solidres');
		$customerUserGroups = $solidresConfig->get('customer_user_groups', array(2));
		$userData           = array(
			'id'        => $data['user_id'],
			'username'  => $data['username'],
			'password'  => $data['password'],
			'password2' => $data['password2'],
			'email'     => $data['email'],
		);

		if (isset($data['Solidres_fields']['customer_firstname']))
		{
			$userData['name'] = $data['Solidres_fields']['customer_firstname'];

			if (isset($data['Solidres_fields']['customer_middlename']))
			{
				$userData['name'] .= ' ' . $data['Solidres_fields']['customer_middlename'];
			}

			$userData['name'] .= ' ' . $data['Solidres_fields']['customer_lastname'];
		}
		else
		{
			$userData['name'] = $data['firstname'] . ' ' . $data['middlename'] . ' ' . $data['lastname'];
		}

		if (!$isSite || !$isNew) // Special case for Customer Dashboard profile editing
		{
			$pk         = (!empty($userData['id'])) ? $userData['id'] : 0;
			$joomlaUser = JUser::getInstance($pk);

			if (empty($joomlaUser->groups))
			{
				$userData['groups'] = $customerUserGroups;
			}

			if (!$joomlaUser->bind($userData))
			{
				$table->setError($joomlaUser->getError());

				return false;
			}

			$result = $joomlaUser->save();

			if (!$result)
			{
				$table->setError($joomlaUser->getError());

				return false;
			}

			// Assign the recent insert joomla user id
			$response = $joomlaUser->id;

			return true;
		}
		else // For front end, just use the way Joomla register a user
		{
			$lang = JFactory::getLanguage();
			$lang->load('com_users', JPATH_SITE, null, 1);

			$user               = new JUser;
			$params             = JComponentHelper::getParams('com_users');
			$useractivation     = $params->get('useractivation');
			$sendpassword       = $params->get('sendpassword', 1);
			$config             = JFactory::getConfig();
			$db                 = JFactory::getDbo();
			$query              = $db->getQuery(true);
			$userData['groups'] = $customerUserGroups;

			// Compile the notification mail values.
			$data = $userData;
			// Check if the user needs to activate their account.
			if (($useractivation == 1) || ($useractivation == 2))
			{
				$data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
				$data['block']      = 1;
			}

			// Bind the data.
			if (!$user->bind($data))
			{
				$this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));

				return false;
			}

			// Load the users plugin group.
			JPluginHelper::importPlugin('user');

			// Store the data.
			if (!$user->save())
			{
				$this->setError($user->getError());

				return false;
			}

			// Assign the recent insert joomla user id to response, so that we can store it into customer's table
			$response = $user->id;

			$data['fromname'] = $config->get('fromname');
			$data['mailfrom'] = $config->get('mailfrom');
			$data['sitename'] = $config->get('sitename');
			$data['siteurl']  = JUri::root();

			// Handle account activation/confirmation emails.
			if ($useractivation == 2)
			{
				// Set the link to confirm the user email.
				$uri              = JUri::getInstance();
				$base             = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
				$data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);

				$emailSubject = JText::sprintf(
					'COM_USERS_EMAIL_ACCOUNT_DETAILS',
					$data['name'],
					$data['sitename']
				);

				if ($sendpassword)
				{
					$emailBody = JText::sprintf(
						'COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY',
						$data['name'],
						$data['sitename'],
						$data['activate'],
						$data['siteurl'],
						$data['username'],
						$data['password_clear']
					);
				}
				else
				{
					$emailBody = JText::sprintf(
						'COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY_NOPW',
						$data['name'],
						$data['sitename'],
						$data['activate'],
						$data['siteurl'],
						$data['username']
					);
				}
			}
			elseif ($useractivation == 1)
			{
				// Set the link to activate the user account.
				$uri              = JUri::getInstance();
				$base             = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
				$data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);

				$emailSubject = JText::sprintf(
					'COM_USERS_EMAIL_ACCOUNT_DETAILS',
					$data['name'],
					$data['sitename']
				);

				if ($sendpassword)
				{
					$emailBody = JText::sprintf(
						'COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY',
						$data['name'],
						$data['sitename'],
						$data['activate'],
						$data['siteurl'],
						$data['username'],
						$data['password_clear']
					);
				}
				else
				{
					$emailBody = JText::sprintf(
						'COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY_NOPW',
						$data['name'],
						$data['sitename'],
						$data['activate'],
						$data['siteurl'],
						$data['username']
					);
				}
			}
			else
			{

				$emailSubject = JText::sprintf(
					'COM_USERS_EMAIL_ACCOUNT_DETAILS',
					$data['name'],
					$data['sitename']
				);

				if ($sendpassword)
				{
					$emailBody = JText::sprintf(
						'COM_USERS_EMAIL_REGISTERED_BODY',
						$data['name'],
						$data['sitename'],
						$data['siteurl'],
						$data['username'],
						$data['password_clear']
					);
				}
				else
				{
					$emailBody = JText::sprintf(
						'COM_USERS_EMAIL_REGISTERED_BODY_NOPW',
						$data['name'],
						$data['sitename'],
						$data['siteurl']
					);
				}
			}

			// Send the registration email.
			$return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);

			// Send Notification mail to administrators
			if (($params->get('useractivation') < 2) && ($params->get('mail_to_admin') == 1))
			{
				$emailSubject = JText::sprintf(
					'COM_USERS_EMAIL_ACCOUNT_DETAILS',
					$data['name'],
					$data['sitename']
				);

				$emailBodyAdmin = JText::sprintf(
					'COM_USERS_EMAIL_REGISTERED_NOTIFICATION_TO_ADMIN_BODY',
					$data['name'],
					$data['username'],
					$data['siteurl']
				);

				// Get all admin users
				$query->clear()
					->select($db->quoteName(array('name', 'email', 'sendEmail')))
					->from($db->quoteName('#__users'))
					->where($db->quoteName('sendEmail') . ' = ' . 1);

				$db->setQuery($query);

				try
				{
					$rows = $db->loadObjectList();
				}
				catch (RuntimeException $e)
				{
					$this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);

					return false;
				}

				// Send mail to all superadministrators id
				foreach ($rows as $row)
				{
					$return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBodyAdmin);

					// Check for an error.
					if ($return !== true)
					{
						$this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));

						return false;
					}
				}
			}

			// Check for an error.
			if ($return !== true)
			{
				$this->setError(JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED'));

				// Send a system message to administrators receiving system mails
				$db = JFactory::getDbo();
				$query->clear()
					->select($db->quoteName(array('name', 'email', 'sendEmail', 'id')))
					->from($db->quoteName('#__users'))
					->where($db->quoteName('block') . ' = ' . (int) 0)
					->where($db->quoteName('sendEmail') . ' = ' . (int) 1);
				$db->setQuery($query);

				try
				{
					$sendEmail = $db->loadColumn();
				}
				catch (RuntimeException $e)
				{
					$this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);

					return false;
				}

				if (count($sendEmail) > 0)
				{
					$jdate = new JDate;

					// Build the query to add the messages
					foreach ($sendEmail as $userid)
					{
						$values = array($db->quote($userid), $db->quote($userid), $db->quote($jdate->toSql()), $db->quote(JText::_('COM_USERS_MAIL_SEND_FAILURE_SUBJECT')), $db->quote(JText::sprintf('COM_USERS_MAIL_SEND_FAILURE_BODY', $return, $data['username'])));
						$query->clear()
							->insert($db->quoteName('#__messages'))
							->columns($db->quoteName(array('user_id_from', 'user_id_to', 'date_time', 'subject', 'message')))
							->values(implode(',', $values));
						$db->setQuery($query);

						try
						{
							$db->execute();
						}
						catch (RuntimeException $e)
						{
							$this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);

							return false;
						}
					}
				}

				return false;
			}

			if ($useractivation == 1)
			{
				return "useractivate";
			}
			elseif ($useractivation == 2)
			{
				return "adminactivate";
			}
			else
			{
				return $user->id;
			}
		}
	}

	protected function defines()
	{
		$this->setPluginName('user');
		parent::defines();
	}

	public static function autoLoadCountry()
	{
		$app       = JFactory::getApplication();
		$countryId = $app->getUserState('com_solidres.user.country_id', null);

		if (null === $countryId)
		{
			JLoader::import('maxmind.lib.autoload', SR_PLUGIN_USER_PATH . '/libraries');
			$countryId = 0;

			try
			{
				$reader  = new Reader(SR_PLUGIN_USER_PATH . '/libraries/maxmind/db/GeoLite2-Country.mmdb');
				$detect  = $reader->country($_SERVER['REMOTE_ADDR']);
				$isoCode = strtoupper($detect->country->isoCode);
			}
			catch (Exception $e)
			{
				$isoCode = null;
			}

			if (null !== $isoCode)
			{
				$db    = JFactory::getDbo();
				$query = $db->getQuery(true)
					->select('c.id')
					->from($db->quoteName('#__sr_countries', 'c'))
					->where('c.code_2 = ' . $db->quote($isoCode));
				$db->setQuery($query);
				$countryId = (int) $db->loadResult();
			}

			$app->setUserState('com_solidres.user.country_id', $countryId);
		}

		return $countryId;
	}

	protected function getMenuTypeOptions()
	{
		$viewPath = $this->_getSitePath() . '/views';

		return array(
			'customer' => $viewPath . '/customer/tmpl/default.xml'
		);
	}

	public function onContentPrepareForm(JForm $form, $data)
	{
		if (!($form instanceof JForm))
		{
			$this->_subject->setError('JERROR_NOT_A_FORM');

			return false;
		}

		$name          = $form->getName();
		$edit          = $this->app->input->getWord('layout') === 'edit';
		$allowContexts = array(
			'com_solidres.customer',
			'com_admin.profile',
			'com_users.user',
			'com_users.profile',
			'com_users.registration',
		);

		if (!SRPlugin::isEnabled('customfield')
			|| !in_array($name, $allowContexts)
		)
		{
			return true;
		}

		$language = JFactory::getLanguage();
		$language->load('com_solidres', JPATH_BASE . '/components/com_solidres')
		|| $language->load('com_solidres', JPATH_BASE);
		$id = (int) $form->getValue('id', null, 0);

		if ($id < 1)
		{
			$registry = new Joomla\Registry\Registry($data);
			$id       = (int) $registry->get('id', 0);
		}

		$ignoreFieldsNames = [
			'customer_note',
			'customer_email',
			'customer_email2',
		];

		$source = [];
		$fields = SRCustomFieldHelper::findFields(['context' => 'com_solidres.customer']);

		foreach($fields as $field)
		{
			if ($field->type != 'file')
			{
				$source[] = $field;
			}
		}

		$xml = SRCustomFieldHelper::buildFields($source, 'Solidres_fields', $ignoreFieldsNames);

		if ($form->load($xml->saveXML()))
		{
			foreach ($form->getGroup('Solidres_fields') as $field)
			{
				if ($field->getAttribute('name') == 'file')
				{
					$form->removeField($field->getAttribute('name'), 'Solidres_fields');
				}
			}

			if ($id > 0)
			{
				JTable::addIncludePath(SRPlugin::getAdminPath('user') . '/tables');
				$customerTable = JTable::getInstance('Customer', 'SolidresTable');
				$fieldsData    = array(
					'Solidres_fields' => array(),
				);

				if ($name == 'com_solidres.customer')
				{
					$load = $customerTable->load($id);

					foreach ($form->getFieldset('fields') as $field)
					{
						$form->removeField($field->getAttribute('name'), 'Solidres_fields');
					}
				}
				else
				{
					$load = $customerTable->load(array('user_id' => $id));
				}

				if ($fieldsValues = SRCustomFieldHelper::getValues(array('context' => 'com_solidres.customer.profile.' . $customerTable->user_id)))
				{
					foreach ($fieldsValues as $fieldsValue)
					{
						if ($name = $fieldsValue->field->get('field_name'))
						{
							if ($edit)
							{
								$fieldsData['Solidres_fields'][$name] = isset($fieldsValue->orgValue) ? $fieldsValue->orgValue : $fieldsValue->value;
							}
							else
							{
								$fieldsData['Solidres_fields'][$name] = $fieldsValue->value;
							}
						}
					}
				}

				if ($load)
				{
					foreach ($customerTable->getProperties() as $name => $value)
					{
						if (strpos($name, 'customer') !== 0)
						{
							$name = 'customer_' . $name;
						}

						if (!isset($fieldsData['Solidres_fields'][$name]))
						{
							$fieldsData['Solidres_fields'][$name] = $value;
						}
					}
				}

				$form->bind($fieldsData);
			}
		}

		JFactory::getDocument()->addScriptDeclaration('Solidres.jQuery(document).ready(function($){
			var country = $("#jform_Solidres_fields_customer_country_id");

			if (country.length) {
				var state = $("#jformSolidres_fieldscustomer_geo_state_id");
				var selected = state.val();

				country.on("change", function(){
					var countryId = $(this).val();

					if(countryId == ""){
						state.html("").trigger("liszt:updated");
					}else{
						$.ajax({
							url : "' . JUri::root(true) . '/index.php?option=com_solidres&format=json&task=states.find&id=" + countryId,
							type: "post",
							success : function(html) {
								html = $.trim(html);

								if (html.indexOf("<option") === 0) {
									state.html(html).val(selected).trigger("liszt:updated");
								} else {
									state.html("").trigger("liszt:updated");
								}
							}
						});
					}

				});

				country.trigger("change");
			}
		});');

		return true;
	}

	protected function saveUserProfile($data, $isNew, $result)
	{
		if (!SRPlugin::isEnabled('customfield'))
		{
			return false;
		}

		$arrayData = (array) $data;
		$userId    = ArrayHelper::getValue($arrayData, 'id', 0, 'int');

		if ($result)
		{
			try
			{
				if (empty($arrayData['Solidres_fields']))
				{
					$jform                        = JFactory::getApplication()->input->get('jform', array(), 'array');
					$arrayData['Solidres_fields'] = isset($jform['Solidres_fields']) ? $jform['Solidres_fields'] : array();
				}

				JTable::addIncludePath(__DIR__ . '/administrator/components/com_solidres/tables');
				$customerTable = JTable::getInstance('Customer', 'SolidresTable');

				if (!$customerTable->load(array('user_id' => $userId)))
				{
					$customerTable->set('user_id', $userId);
					$customerTable->set('customer_group_id', null);
					$customerTable->set('customer_code', '');
				}

				$fields = SRCustomFieldHelper::findFields(array('context' => 'com_solidres.customer'));

				if ($fields && !empty($arrayData['Solidres_fields']))
				{
					$dataValue = array();

					foreach ($fields as $field)
					{
						if (isset($arrayData['Solidres_fields'][$field->field_name]))
						{
							$value       = $arrayData['Solidres_fields'][$field->field_name];
							$dataValue[] = array(
								'id'      => 0,
								'context' => 'com_solidres.customer.profile.' . $userId,
								'value'   => $value,
								'storage' => $field
							);

							if (strpos($field->field_name, 'customer_') === 0)
							{
								$name = str_replace('customer_', '', $field->field_name);

								if (property_exists($customerTable, $name))
								{
									if (empty($value) && in_array($name, array('country_id', 'geo_state_id')))
									{
										$value = null;
									}

									$customerTable->set($name, $value);
								}
							}
						}
					}

					if (count($dataValue))
					{
						SRCustomFieldHelper::storeValues($dataValue, $isNew);
					}
				}

				$customerTable->store(true);
			}
			catch (RuntimeException $e)
			{
				$this->_subject->setError($e->getMessage());

				return false;
			}
		}

		return true;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit