Kunena 6.3.0 released

The Kunena team has announce the arrival of Kunena 6.3.0 [K 6.3.0] in stable which is now available for download as a native Joomla extension for J! 4.4.x/5.0.x/5.1.x. This version addresses most of the issues that were discovered in K 6.2 and issues discovered during the last development stages of K 6.3

Question [SOLVED] How to add security to the Birthdate for guests?

More
12 years 10 months ago - 12 years 10 months ago #11 by sozzled
I'm looking at the question

Cordel wrote:

In Kunena, when a user fills out his birthdate, it shows on the summary profile next to, or on top of his post depending on your configuration. I need this to not show for guest users.

In this case it makes no sense to modify the file ../administrator/components/com_kunena/libraries/user.php but, rather, you should modify the files that display these details. This would be ../components/com_kunena/template/view/profile.horizontal.php and ../components/com_kunena/template/view/profile.vertical.php. That gives you a place to start looking.

You need to add a test to line that reads
Code:
<?php echo $this->profile->profileIcon('birthdate'); ?>
Last edit: 12 years 10 months ago by sozzled.

Please Log in or Create an account to join the conversation.

More
12 years 10 months ago #12 by Cordel
Thanks Migus that helps.

But I really need this to be in the backend, otherwise I'd have to many themes to modify which is why I'm looking at administrator/components/com_kunena/libraries/user.php as it would carry through all themes.
Allot of these folks downed themes and modified them so would be allot of work.... though maybe I can get payed good ;)

Please Log in or Create an account to join the conversation.

More
12 years 10 months ago - 12 years 10 months ago #13 by Cordel
sozzled
It calls to the file that I listed that produces that Link.. already ahead of you. Thats why I listed it.
Smart enough to find it but ignorant enough that I can't figure out how to deal with it. :pinch:

Ideally it would be nice to pull from the option in Kunena config in the admin panel under the security tab "Allow Guests to see User Profiles" but any hack at this point would suffice. So I might just go ahead and start editing themes. I just thought if I was going to try, try to do it right and give it back.
Last edit: 12 years 10 months ago by Cordel.

Please Log in or Create an account to join the conversation.

More
12 years 10 months ago #14 by sozzled
The PHP function to check if a user has logged-in or not (i.e. a "guest") is one of the following:

!KunenaFactory::getUser()->exists()

or

!JoomlaFactory::getUser()->id

I hope that helps.

Please Log in or Create an account to join the conversation.

More
12 years 10 months ago #15 by migus

Cordel wrote: But I really need this to be in the backend

If you talk about self-made enhancement of Kunena backend - it's all the same only hack solution. Suppose it is good point for us to make feature request for next releases...

Altai Mountains - is a fairy tale!

Please Log in or Create an account to join the conversation.

More
12 years 10 months ago - 12 years 10 months ago #16 by Cordel
BINGO!
Thank you sozzled. So I'll add this query into the function to create or not create the icons into the themes. Thats almost perfect! Then I'll query the database to check for the option of whether or not the config shows profiles to guests is true or not and put it together to make it appropriate!

As far a feature requests go, it would be to add this so that if option not to show profile to guests is true, then creation of birthdate Icon should be suppressed. And add to it the option to strip the Year off birthdays would be nice in the admin panel.

I'll see if I can figure a good way to word it and put in a feature request. I'll post the patch here of what I have done soon as I have it working on the test server.

Sozzled, is there an API listing somewhere I missed in the Kunena Wiki? How did you manage to find the Kunena function if I may ask so I don't have to ask on the forum dumb questions.

Cheers!
Last edit: 12 years 10 months ago by Cordel.

Please Log in or Create an account to join the conversation.

More
12 years 10 months ago #17 by sozzled

Cordel wrote: How did you manage to find the Kunena function if I may ask ...

I asked the developers. ;)
The following user(s) said Thank You: Cordel

Please Log in or Create an account to join the conversation.

  • C0n
  • C0n's Avatar
  • Offline
  • Premium Member
  • Only the strongest will survive
More
12 years 10 months ago #18 by C0n

migus wrote: Hi Cordel,
I have a custom solution for this issue in:
...home.../components/com_kunena/template/default(or yours)/view/profile.vertical.php
simply use if ( $this->my->id ) statement:

Code:
<li class="kpost-smallicons"> <?php echo $this->profile->profileIcon('website'); ?> <?php echo $this->profile->profileIcon('gender'); ?> <?php if ( $this->my->id ) : ?> <?php echo $this->profile->profileIcon('birthdate'); ?> <?php echo $this->profile->profileIcon('location'); ?> <?php echo $this->profile->profileIcon('private'); ?> <?php echo $this->profile->profileIcon('email'); ?> <?php endif ?> </li>
Good luck :cheer:


It is a good fix on the issue in the time being hopefully in the future it will become a feature were you can choose the privacy status of your birthdate.

Please Log in or Create an account to join the conversation.

More
12 years 10 months ago - 12 years 10 months ago #19 by Cordel
Thank you every one for your input!
Here is what I came up with:

administrator/components/com_kunena/libraries/user.php
Code:
public function profileIcon($name) { $kunena_config = KunenaFactory::getConfig (); //Added This line and next $isRegistered = KunenaFactory::getUser()->exists(); switch ($name) { case 'gender' : switch ($this->gender) { case 1 : $gender = 'male'; break; case 2 : $gender = 'female'; break; default : $gender = 'unknown'; } $title = JText::_ ( 'COM_KUNENA_MYPROFILE_GENDER' ) . ': ' . JText::_ ( 'COM_KUNENA_MYPROFILE_GENDER_' . $gender ); return '<span class="kicon-profile kicon-profile-gender-' . $gender . '" title="' . $title . '"></span>'; break; case 'birthdate' : if ($this->birthdate && ($isRegistered || $kunena_config->pubprofile != 0)) { //Added member condition so not public unless profile is set to public in Kunena config jimport('joomla.utilities.date'); $date = new JDate ( $this->birthdate, 0 ); if ($date->toFormat('%Y')<1902) break; return '<span class="kicon-profile kicon-profile-birthdate" title="' . JText::_ ( 'COM_KUNENA_MYPROFILE_BIRTHDATE' ) . ': ' . CKunenaTimeformat::showDate ( $this->birthdate, 'date', 'utc', 0 ) . '"></span>'; } break; case 'location' : if ($this->location) return '<span class="kicon-profile kicon-profile-location" title="' . JText::_ ( 'COM_KUNENA_MYPROFILE_LOCATION' ) . ': ' . kunena_htmlspecialchars ( $this->location ) . '"></span>'; break; case 'website' : $url = 'http://' . $this->websiteurl; if (! $this->websitename) $websitename = $this->websiteurl; else $websitename = $this->websitename; if ($this->websiteurl) return '<a href="' . kunena_htmlspecialchars ( $url ) . '" target="_blank"><span class="kicon-profile kicon-profile-website" title="' . JText::_ ( 'COM_KUNENA_MYPROFILE_WEBSITE' ) . ': ' . kunena_htmlspecialchars ( $websitename ) . '"></span></a>'; break; case 'private' : $pms = KunenaFactory::getPrivateMessaging (); return $pms->showIcon ( $this->userid ); break; case 'email' : // TODO: show email return; // '<span class="email" title="'. JText::_('COM_KUNENA_MYPROFILE_EMAIL').'"></span>'; break; case 'profile' : if (! $this->userid) return; return CKunenaLink::GetProfileLink ( $this->userid, '<span class="profile" title="' . JText::_ ( 'COM_KUNENA_VIEW_PROFILE' ) . '"></span>' ); break; } }
This is the entire function. Right after the function call you can see I added a call to get from the database Kunea config and to populate a variable for user status.
Code:
public function profileIcon($name) { $kunena_config = KunenaFactory::getConfig (); //Added This line and next $isRegistered = KunenaFactory::getUser()->exists();
Then added the condition:
Code:
case 'birthdate' : if ($this->birthdate && ($isRegistered || $kunena_config->pubprofile != 0)) { //Added member condition so not public unless profile is public in Kunena config.

I also added the same code to social Icons in case someone wants to make a custom template to include these on the summery profile beside or on top of posts in the attached file.

Thank you all and maybe this helps someone ;)
Attachments:
Last edit: 12 years 10 months ago by Cordel. Reason: Opp's don't upload file as php but txt

Please Log in or Create an account to join the conversation.

Time to create page: 0.555 seconds