- Posts: 36
- Thank you received: 3
OS Property support center
Wrong Group sign up.
- Mark
- Topic Author
- Offline
- Junior Member
-
Less
More
9 years 8 months ago #67436
by Mark
Wrong Group sign up. was created by Mark
I register a company in OS Property. The access level is going to Registered.
Then i sign up a agent. The access level is going to be registered again.
But i set in configuration that agents must be in the group agent and company in the group company. Anybody a idea where to fix that error?
Then i sign up a agent. The access level is going to be registered again.
But i set in configuration that agents must be in the group agent and company in the group company. Anybody a idea where to fix that error?
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 13056
- Thank you received: 1696
9 years 8 months ago #67443
by Mr. Dam
Replied by Mr. Dam on topic Wrong Group sign up.
Hi Mark,
I have solved the issue on your site. To solve the issue, i modified file:
Thanks
Dam
I have solved the issue on your site. To solve the issue, i modified file:
We update PHP function:components > com_osproperty > helpers > helper.php
Code:
registration
/**
* Register Joomla User
* @param $data
*/
public static function registration($data)
{
$mainframe = JFactory::getApplication();
$msg = array();
$language = JFactory::getLanguage();
$current_language = $language->getTag();
$extension = 'com_users';
$base_dir = JPATH_SITE;
$language->load($extension, $base_dir, $current_language);
$params = JComponentHelper::getParams('com_users');
// Initialise the table with JUser.
$user = new JUser;
$new_usertype = $params->get('new_usertype', '2');
$groups = array();
$groups[0] = $new_usertype;
$data['groups'] = $groups;
$useractivation = $params->get('useractivation');
$sendpassword = $params->get('sendpassword', 1);
// Check if the user needs to activate their account.
if (($useractivation == 1) || ($useractivation == 2)) {
jimport('joomla.user.helper');
if (version_compare(JVERSION, '3.0', 'lt')) {
$data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
} else {
$data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
}
$data['block'] = 1;
}
// Bind the data.
if (!$user->bind($data)) {
$mainframe->redirect(JRoute::_('index.php?option=com_osproperty&task=agent_register&Itemid=' . $itemid), JText::sprintf('OS_COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
return false;
}
// Load the users plugin group.
JPluginHelper::importPlugin('user');
// Store the data.
if (!$user->save()) {
$mainframe->redirect(JRoute::_('index.php?option=com_osproperty&task=agent_register&Itemid=' . $itemid), JText::sprintf('OS_COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
return false;
}
$config = JFactory::getConfig();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Compile the notification mail values.
$data = $user->getProperties();
$data['fromname'] = $config->get('fromname');
$data['mailfrom'] = $config->get('mailfrom');
$data['sitename'] = $config->get('sitename');
$data['siteurl'] = JUri::base();
// 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) {
JError::raiseError(500, JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()));
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) {
$msg[] = JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED');
//JError::raiseError( 500, JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()));
return false;
}
}
// Check for an error.
if ($return !== true) {
$msg[] = 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) {
JError::raiseError(500, JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()));
//$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) {
JError::raiseError(500, JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()));
//$this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
return false;
}
}
}
return false;
}
}
// Redirect to the login screen.
if ($useractivation == 2)
{
$msg[] = JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY');
}
elseif ($useractivation == 1)
{
$msg[] = JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE');
}
else
{
$msg[] = JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS');
}
$return = array();
$return[0]->user = $user;
$return[0]->message = $msg;
return $return;
}
Thanks
Dam
Please Log in or Create an account to join the conversation.
Moderators: Mr. Dam, Nguyen Phu Quan
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.