Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2016, 10:43 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,457
Kyttias is on a distinguished road
Default Friend System Questions

1) I've created a link on my user profiles to display a link to send a friend request. I'd like to prevent it from displaying on the profiles of users you're already friends with? Currently in classes/class_userprofile.php I have something like this:
PHP Code:
    if (($mysidia->user->username != $mysidia->input->get("user")) && ($mysidia->user->usergroup->gid 5)){
      
$member = new Member($mysidia->input->get("user"));
      
$friendrequest "<a href='../../friends/request/{$member->uid}'>Send Friend Request</a>";      
    } 
2) What exactly happens when you remove from your friend list? I was unable to refriend a user I had accidentally removed because the database kept the status as 'confirmed'. It wouldn't allow me to send a request again because the entry was never removed. I had to set it back to 'pending' manually and then have the other user go into their account settings and reapprove the request. How can I go about making refriending someone possible? Perhaps just remove the original entry from adopts_friend_requests while the friend is removed?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 01-05-2016 at 10:45 PM.
Reply With Quote
  #2  
Old 01-06-2016, 01:13 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 334,206
Hall of Famer is on a distinguished road
Default

1. For this you will need to add an if check to the location that renders 'send a friend request' link on user profile page. Look for file classes/class_userprofile.php at around line 184-185, and you will find this:

PHP Code:
      $document->add(new Image("templates/icons/fr.gif""Send a Friend Request"));
      
$document->add(new Link("friends/request/{$member->uid}""Send {$mysidia->input->get("user")} a Friend Request"TRUE)); 
What you can do is to add an if check to this block of code, and to add friend request image/link to document only if the user is not a friend with you yet.


2. I honestly never tested the edge case when you attempt to add a friend back after you break friendship. So I think there is a chance that you cannot add him/her back since the friend request stays in database, you cannot send duplicate friend requests. If this happens, and it is not the desired behavior for you, you can simply remove the friend request from database once you remove a friend.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 01-06-2016, 03:08 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,457
Kyttias is on a distinguished road
Default

1) Yes. The question was how do I write the check itself? I already have the contents how I want them. I just don't quite understand how I would need to form that.

2) Hmm... Where? (In the friend class's remove function?) Also not the most familiar with calls to the database to remove entries. Only one of the friends will have been the one to initiate the request.... hmm.

Thanks anyway, HoF!
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #4  
Old 01-07-2016, 08:17 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 334,206
Hall of Famer is on a distinguished road
Default

1. You will need to check if the user is on your friendlist, and only show the 'send a friend request' image and link when the user is not a friend of yours yet. The below steps demonstrates how to check this:

PHP Code:
$friendlist = new Friendlist($mysidia->user); //create your own friendlist object.
$friend = new Friend(new Member($mysidia->input->get("user")), $friendlist); //create a friend object.
if(!$friend->isfriend){ //only show if the user is a friend of yours. 
    
$document->add(new Image("templates/icons/fr.gif""Send a Friend Request"));
    
$document->add(new Link("friends/request/{$member->uid}""Send {$mysidia->input->get("user")} a Friend Request"TRUE));     

Note the above code may need some tweaks, as if you are viewing the page as a guest you may get get a glitch. You can test it and lemme know how it goes.

2. Yeah, you can add one line to the friend class' remove method, to delete the row from table prefix_friend_requests. The code should look like this below:

PHP Code:
$mysidia->db->delete("friend_requests""(fromuser='{$mysidia->user->username}' AND touser='{$this->username}') OR (touser='{$mysidia->user->username}' AND fromuser='{$this->username}')"); 
This above code should delete a row with friend request between you and your old friend that you dont want to maintain friendship anymore. After the friend request is deleted, you should be able to send friend request to this user again without any problems.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #5  
Old 01-07-2016, 04:12 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,457
Kyttias is on a distinguished road
Default

Thanks!!
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:10 PM.

Currently Active Users: 9755 (0 members and 9755 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636