Friend Request v1.0.2

Release Notes

 

'Updated' with Sharky's contribs to fix the emailing (strings and function call).

Steve's Contributions:  I fixed it.  I completed the language elements (albeit
somewhat informally), fixed the functions for testing for relationships, and changed
the view for profiles to adequately display the options for add/cancel/confirm/deny.  Most
importantly, no edits to the core of Elgg need to be done.

  • This completely messed up my site. I had to go back to the previous version.

  • When I click on the notifications link in the email, it just takes me to the main page of the site. Doesn't seem like I have a notifications plugin. Where can I get that or when will this plugin use super notify?

    Thank you and God Bless <><

    Greg

  • Another thought...say something wants to be my friend and they request it. Once I approve them being my friend, can this plugin add them to my friends list automatically? That is how facebook works.

    Thanks again!

  • It appears it already does what I asked. I'm just not for sure since I don't have a notifications plugin...

    Thanks

  • Can somebody tell me wich is the diference between "Friends" and "Friend of" it seems for me that this is like on Twitter "Followers" and "Follow" or I'm wrong? Please help.

    Thanks

  • This plugin works for me, but when you press to see notification ....you get nothing, just the dashboard. Also does not send any confirmation for delete frind, and deny requiest. Hope this bugs willl be fixed later. So far I'm using it.

  • Add: got the super notify and works fine. But what to do now with "Friends of" link?. Because it seems for me that they will have the same content. I'm confused with this, and users asked me, nut I couldn't explain them which is the difference between "Friends" and "Friends of"...need help. Thanks

  • Albert, et al...

    I see the problems...hopefully will get to it in the next day or so!

    Thanks,

    Steve

  • Is this suppose to work with super notify yet? I have the notifications screen now. But, there weren't any notifications about a friend request. I had to go to the user's profile to approve the request.

    Thanks!

  • One more thing. Ex. person X snd request for friendship to Y. When Y accept, then they became friends. But, in the friends activity I've got: 1. X is now friend with Y. 2. X is now friend with X. - for X profile, and 1. Y is now friend with X. 2. Y is now friend with Y - for Y profile. X and X & Y and Y no good.

  • One more thing (suggestion)! May be "Friends of" will be better to use as "Friends of my Friends" and there will be shown all friends of your frinds, from where you can pick a person whom you may know. Like in Facebook.

  • This plugin didn't work for me on a clean 1.2 install. The link sent to verify the relationship would redirect to the dashboard.

    Also the message pop-up and the email sent could use some cleaning up.

    What are the advantages of this plugin over Zacs (besides the fact that Elgg 1.5 will break his plugin)?

  • @Cash,

    Mostly, this one supports my Super Notify plugin for generic internal site notifications.  Will provide useful links (confirm/deny/look at profile).  Zac's plugin is very nice - but adds its own notification to the toolbar.  I'm hoping to have one place for all notifications.

  • It looks like version 1.5 of Elgg will use the messages plugin for internal notifications.

  • I actually like that Zac's plugin adds the extra notify. However I want to try your Plugin, do I need supernotify also? Will it work wit 1.5 or is there a new version for 1.5 coming up?

  • Okay, just tested both, Zac's is broken in 1.5, showing up the notification but approving or denying has no effect.

    Yours won't work without supernotify and it is breaking the "Friends" and "Members" view which won't show the latest wire post anymore.

    Hope there will be a 1.5 Version soon ;)

  • Hi!

    I have tested on ELGG 1.5 and it works correctly, even the site notification. I have a suggestion for you: 'Friends of' and 'friends' options are the same with this plugin, if you wanna see only 'friends'...

    register_elgg_event_handler('pagesetup','system','friendrequest_users_pagesetup',1);

    function friendrequest_users_pagesetup (){
        global $CONFIG;
        if (get_context() == "friends" || get_context() == "collections") {
            unset($CONFIG->submenu['a']);
            add_submenu_item(elgg_echo('friends'),$CONFIG->wwwroot."pg/friends/" . page_owner_entity()->username);
            if ($_SESSION['guid'] == page_owner()) {
                collections_submenu_items();
            }   
        }
    }

    and inside the init function you can add:

    unset($CONFIG->pagehandler['friendsof']);

    in order to deactivate the friendsof page handler.

    Regards!

  • Hi

    By adding this line to mod/friendrequest/action/confirm.php you get river messages when people confirms friendship:

    add_to_river('friends/river/create','friend',$_SESSION['user']->guid,$friend_guid);

    Add it just above this one near the end of file:

    system_message(sprintf(elgg_echo("friends:add:successful"),$friend->name));

    Regards

    slyhne

  • @Miguel: and it didn't break the "Friends" and "Members" view? When I activated it, the latest wire post was not shon there anymore...

  • I figured out how to get the notifications working. Under settings>notifications make sure that both "Email" and "Site" are checked.

    Does anyone know how to make "Site" by default checked so that new users can recieve site notifications?

  • So far so good...

    A couple of small changes i've made.. Changes bold and underlined.

    en.php
    'friends:request:successful' => "Your friend request
    was successfully sent to <b>%s</b> .",

    'friend:newfriendrequest:body' => "%s is requesting to add you as a friend. Please confirm or deny this request by viewing %s's profile.<br /><br />  To view their profile, click here:<br /><br /> %s <br /><br />  To view your notifications, click here<br />&nbsp;%s<br /><br />   Please do not reply to this email.",

    startFunctions.php
    sprintf(elgg_echo("friend:newfriendrequest:body"), $user->name, $user->name, $CONFIG->site->url . "pg/profile/" . $user->username, $CONFIG->site->url . "pg/notifications/") ,

  • Is this possible to add an auto accept option.
    If i need to modify php files, it is not a problem.
    But what need i do ?

    Thanks.

  • Elgg Modification for Auto-Mark as Friend when the user register with InviteCode:

    1.   /engine/lib/users.php,  line 283


    function addFriend($friend_guid) {
            return user_add_friend($this->getGUID(), $friend_guid);
        }

     
    +++++++++ Add Plus +++++++++
    ////////////////////// Friend Request ////////////////////////////////////
        function addFriendRequest($friend_guid) {
            return user_add_friendRequest($this->getGUID(), $friend_guid);
        }
    ////////////////////// Friend Request ////////////////////////////////////

     
    2.    /engine/lib/users.php,  line 730


    function user_add_friend($user_guid, $friend_guid) {
        $user_guid = (int) $user_guid;
        $friend_guid = (int) $friend_guid;
        if ($user_guid == $friend_guid) {
            return false;
        }
        if (!$friend = get_entity($friend_guid)) {
            return false;
        }
        if (!$user = get_entity($user_guid)) {
            return false;
        }
        if ((!($user instanceof ElggUser)) || (!($friend instanceof ElggUser))) {
            return false;
        }
        return add_entity_relationship($user_guid, "friendrequest", $friend_guid);
    }

     
    +++++++++ Add Plus +++++++++
    ////////////////////// Friend Request ////////////////////////////////////
    function user_add_friendRequest($user_guid, $friend_guid) {
        $user_guid = (int) $user_guid;
        $friend_guid = (int) $friend_guid;
        if ($user_guid == $friend_guid) {
            return false;
        }
        if (!$friend = get_entity($friend_guid)) {
            return false;
        }
        if (!$user = get_entity($user_guid)) {
            return false;
        }
        if ((!($user instanceof ElggUser)) || (!($friend instanceof ElggUser))) {
            return false;
        }
        return add_entity_relationship($user_guid, "friend", $friend_guid);
    }
    ////////////////////// Friend Request ////////////////////////////////////

     

    3.    /engine/lib/users.php,  line 1577

    if ($friend_guid) {
            if ($friend_user = get_user($friend_guid)) {
                if ($invitecode == generate_invite_code($friend_user->username)) {
                    $user->addFriend($friend_guid);
                    $friend_user->addFriend($user->guid);

                    // @todo Should this be in addFriend?
                    //add_to_river('friends/river/create', 'friend', $user->getGUID(), $friend_guid);
                    //add_to_river('friends/river/create', 'friend', $friend_guid, $user->getGUID());
                }
            }
        }

     
    +++++++++ Add Plus +++++++++
    ////////////////////// Friend Request ////////////////////////////////////
        // If $friend_guid has been set, by Friend_request
        if ($friendRequest_guid) {
            if ($friend_user = get_user($friendRequest_guid)) {
                if ($invitecode == generate_invite_code($friend_user->username)) {
                    $user->addFriendRequest($friendrequest_guid);
                    $friend_user->addFriendRequest($user->guid);

                    // @todo Should this be in addFriend?
                    add_to_river('friends/river/create', 'friend', $user->getGUID(), $friend_guid);
                    add_to_river('friends/river/create', 'friend', $friend_guid, $user->getGUID());
                }
            }
        }
    ////////////////////// Friend Request ////////////////////////////////////

     4.    /mod/friend_request/actions/approve.php,  line 30, 31


    $user->addFriend($friend->guid);
                $friend->addFriend($user->guid);            //Friends mean reciprical...

    Replace to:

    $user->addFriendRequest($friend->guid);
                $friend->addFriendRequest($user->guid);            //Friends mean reciprical...

    THE END :)

  • hi

    thanks for the great plugin, does it work with your super_notify plugin yet?

    thanks again

     

    stumpy?

  • ooops

    sorry i read like a normal person would have and discovered it does.  thanks all the same.

    regards and thanks a million for the plugin.

     

Stats

  • Category: Uncategorized
  • License: GNU General Public License (GPL) version 2
  • Updated: 2014-11-17
  • Downloads: 3379
  • Recommendations: 0

Other Projects

View ssuppe's plugins