Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plg_user_profile] Misc fixes #20412

Merged
merged 5 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 22 additions & 16 deletions plugins/user/profile/field/tos.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function getLabel()
JHtml::_('behavior.modal');

// Build the class for the label.
$class = !empty($this->description) ? 'hasTooltip' : '';
$class = !empty($this->description) ? 'hasPopover' : '';
$class = $class . ' required';
$class = !empty($this->labelClass) ? $class . ' ' . $this->labelClass : $class;

Expand All @@ -69,16 +69,17 @@ protected function getLabel()
// If a description is specified, use it to build a tooltip.
if (!empty($this->description))
{
$label .= ' title="'
. htmlspecialchars(
trim($text, ':') . '<br />' . ($this->translateDescription ? JText::_($this->description) : $this->description),
ENT_COMPAT, 'UTF-8'
) . '"';
$label .= ' title="' . htmlspecialchars(trim($text, ':'), ENT_COMPAT, 'UTF-8') . '"';
$label .= ' data-content="' . htmlspecialchars(
$this->translateDescription ? JText::_($this->description) : $this->description,
ENT_COMPAT,
'UTF-8'
) . '"';
}

$tosarticle = $this->element['article'] > 0 ? (int) $this->element['article'] : 0;
$tosArticle = $this->element['article'] > 0 ? (int) $this->element['article'] : 0;

if ($tosarticle)
if ($tosArticle)
{
JLoader::register('ContentHelperRoute', JPATH_BASE . '/components/com_content/helpers/route.php');

Expand All @@ -90,27 +91,32 @@ protected function getLabel()
$query = $db->getQuery(true);
$query->select('id, alias, catid, language')
->from('#__content')
->where('id = ' . $tosarticle);
->where('id = ' . $tosArticle);
$db->setQuery($query);
$article = $db->loadObject();

if (JLanguageAssociations::isEnabled())
{
$tosassociated = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $tosarticle);
$tosAssociated = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $tosArticle);
}

$current_lang = JFactory::getLanguage()->getTag();
$currentLang = JFactory::getLanguage()->getTag();

if (isset($tosassociated) && $current_lang !== $article->language && array_key_exists($current_lang, $tosassociated))
if (isset($tosAssociated) && $currentLang !== $article->language && array_key_exists($currentLang, $tosAssociated))
{
$url = ContentHelperRoute::getArticleRoute($tosassociated[$current_lang]->id, $tosassociated[$current_lang]->catid);
$link = JHtml::_('link', JRoute::_($url . '&tmpl=component&lang=' . $tosassociated[$current_lang]->language), $text, $attribs);
$url = ContentHelperRoute::getArticleRoute(
$tosAssociated[$currentLang]->id,
$tosAssociated[$currentLang]->catid,
$tosAssociated[$currentLang]->language
);

$link = JHtml::_('link', JRoute::_($url . '&tmpl=component'), $text, $attribs);
}
else
{
$slug = $article->alias ? ($article->id . ':' . $article->alias) : $article->id;
$url = ContentHelperRoute::getArticleRoute($slug, $article->catid);
$link = JHtml::_('link', JRoute::_($url . '&tmpl=component&lang=' . $article->language), $text, $attribs);
$url = ContentHelperRoute::getArticleRoute($slug, $article->catid, $article->language);
$link = JHtml::_('link', JRoute::_($url . '&tmpl=component'), $text, $attribs);
}
}
else
Expand Down
14 changes: 7 additions & 7 deletions plugins/user/profile/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,19 @@ public function onContentPrepareForm($form, $data)
$form->setFieldAttribute('tos', 'description', 'PLG_USER_PROFILE_FIELD_TOS_DESC_SITE', 'profile');
}

$tosarticle = $this->params->get('register_tos_article');
$tosenabled = $this->params->get('register-require_tos', 0);
$tosArticle = $this->params->get('register_tos_article');
$tosEnabled = $this->params->get('register-require_tos', 0);

// We need to be in the registration form and field needs to be enabled
if ($name !== 'com_users.registration' || !$tosenabled)
if ($name !== 'com_users.registration' || !$tosEnabled)
{
// We only want the TOS in the registration form
$form->removeField('tos', 'profile');
}
else
{
// Push the TOS article ID into the TOS field.
$form->setFieldAttribute('tos', 'article', $tosarticle, 'profile');
$form->setFieldAttribute('tos', 'article', $tosArticle, 'profile');
}

foreach ($fields as $field)
Expand Down Expand Up @@ -388,11 +388,11 @@ public function onUserBeforeSave($user, $isnew, $data)
// Check that the tos is checked if required ie only in registration from frontend.
$task = JFactory::getApplication()->input->getCmd('task');
$option = JFactory::getApplication()->input->getCmd('option');
$tosarticle = $this->params->get('register_tos_article');
$tosenabled = ($this->params->get('register-require_tos', 0) == 2);
$tosArticle = $this->params->get('register_tos_article');
$tosEnabled = ($this->params->get('register-require_tos', 0) == 2);

// Check that the tos is checked.
if ($task === 'register' && $tosenabled && $tosarticle && $option === 'com_users' && !$data['profile']['tos'])
if ($task === 'register' && $tosEnabled && $tosArticle && $option === 'com_users' && !$data['profile']['tos'])
{
throw new InvalidArgumentException(JText::_('PLG_USER_PROFILE_FIELD_TOS_DESC_SITE'));
}
Expand Down
46 changes: 46 additions & 0 deletions plugins/user/profile/profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_ADDRESS1_LABEL"
description="PLG_USER_PROFILE_FIELD_ADDRESS1_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -44,6 +46,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_ADDRESS2_LABEL"
description="PLG_USER_PROFILE_FIELD_ADDRESS2_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -55,6 +59,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_CITY_LABEL"
description="PLG_USER_PROFILE_FIELD_CITY_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -66,6 +72,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_REGION_LABEL"
description="PLG_USER_PROFILE_FIELD_REGION_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -77,6 +85,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_COUNTRY_LABEL"
description="PLG_USER_PROFILE_FIELD_COUNTRY_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -88,6 +98,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_POSTAL_CODE_LABEL"
description="PLG_USER_PROFILE_FIELD_POSTAL_CODE_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -99,6 +111,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_PHONE_LABEL"
description="PLG_USER_PROFILE_FIELD_PHONE_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -110,6 +124,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_WEB_SITE_LABEL"
description="PLG_USER_PROFILE_FIELD_WEB_SITE_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -121,6 +137,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_FAVORITE_BOOK_LABEL"
description="PLG_USER_PROFILE_FIELD_FAVORITE_BOOK_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -132,6 +150,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_ABOUT_ME_LABEL"
description="PLG_USER_PROFILE_FIELD_ABOUT_ME_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -144,6 +164,7 @@
label="PLG_USER_PROFILE_FIELD_TOS_LABEL"
description="PLG_USER_PROFILE_FIELD_TOS_DESC"
default="0"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="0">JDISABLED</option>
Expand All @@ -158,13 +179,16 @@
new="true"
edit="true"
clear="true"
filter="integer"
/>

<field
name="register-require_dob"
type="list"
label="PLG_USER_PROFILE_FIELD_DOB_LABEL"
description="PLG_USER_PROFILE_FIELD_DOB_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -189,6 +213,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_ADDRESS1_LABEL"
description="PLG_USER_PROFILE_FIELD_ADDRESS1_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -200,6 +226,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_ADDRESS2_LABEL"
description="PLG_USER_PROFILE_FIELD_ADDRESS2_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -211,6 +239,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_CITY_LABEL"
description="PLG_USER_PROFILE_FIELD_CITY_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -222,6 +252,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_REGION_LABEL"
description="PLG_USER_PROFILE_FIELD_REGION_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -233,6 +265,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_COUNTRY_LABEL"
description="PLG_USER_PROFILE_FIELD_COUNTRY_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -244,6 +278,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_POSTAL_CODE_LABEL"
description="PLG_USER_PROFILE_FIELD_POSTAL_CODE_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -255,6 +291,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_PHONE_LABEL"
description="PLG_USER_PROFILE_FIELD_PHONE_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -266,6 +304,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_WEB_SITE_LABEL"
description="PLG_USER_PROFILE_FIELD_WEB_SITE_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -277,6 +317,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_FAVORITE_BOOK_LABEL"
description="PLG_USER_PROFILE_FIELD_FAVORITE_BOOK_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -288,6 +330,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_ABOUT_ME_LABEL"
description="PLG_USER_PROFILE_FIELD_ABOUT_ME_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand All @@ -299,6 +343,8 @@
type="list"
label="PLG_USER_PROFILE_FIELD_DOB_LABEL"
description="PLG_USER_PROFILE_FIELD_DOB_DESC"
default="1"
filter="integer"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
Expand Down
1 change: 1 addition & 0 deletions plugins/user/profile/profiles/profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
label="PLG_USER_PROFILE_FIELD_TOS_LABEL"
description="PLG_USER_PROFILE_FIELD_TOS_DESC"
default="0"
filter="integer"
>
<option value="1">PLG_USER_PROFILE_OPTION_AGREE</option>
<option value="0">JNO</option>
Expand Down