Elgg Enemy System

Last updated by DhrupDeScoop

"Enemy System" ;-)
(@1095 days ago)


if (isloggedin()) {
    if ($_SESSION['user']->getGUID() != $vars['entity']->getGUID()) {
        echo "<p class=\"user_menu_block_user\">"
        . "<a href=\"" // we want to zap this user fro all our content ;-)
        . "{$vars['url']}action/friends/userblock?usertoblock={$vars['entity']->getGUID()}\">"
        . elgg_echo("userblock:zaphim")
        . "</a></p>";
}
. . .

// and later
$Block = get_metadata_byname($_SESSION['user']->getGUID(), 'BLOCKED');
$Blocked = $Block->value; // bool
if ($Blocked) // we zapped him ?
    header("Location: {$CONFIG->url}" ); // do not allow access -> fwd to site home page


Replies:

    Shouvik Mukherjee 1095 days ago

    I didn't get it. What exactly is this supposed to do?


    DhrupDeScoop 1095 days ago

    read here for the background -->

    http://community.elgg.org/mod/groups/topicposts.php?topic=200333&group_guid=23300


    DhrupDeScoop 1095 days ago

    The code posted above is simply a part of the fuller working plugin that has been implemented elsewhere. For obvious reasons I am not able to post the full code here for the public ;-(


    DhrupDeScoop 1095 days ago

    For anyone else who's interested.. this piece of code ==>

     . elgg_echo("userblock:zaphim")

    as any experienced Elgg Developers would already know - is the standard Elgg way to perform a php echo, although the elgg_echo extends php's abilities by hooking into the Elgg language files.


    Malaga Jack 1095 days ago

    the code stops anyone you block from seeing your content

    Dhrup why are you explaining elgg echo anyone who does understand this does not understand code at all so any code above would be pointless to them anyway and they should not be messing around inside the code as they are liable to break their toy


    DhrupDeScoop 828 days ago

    Hmm...

    seems that there were some bugs in the original code ;-) MH emailed me about this and so -- debug, debug.. and finally got the pesky bad code.

    The harder part was to prevent blocked users from seeing *any content created by the other. Profile viewing and message sending were relatively simpler. After much head scratching and hair pulling - I do believe the solution has presented itself out of the ether.

    I will be looking in more details into this to make sure everything will work as intended. The basic design is to check currently logged-in user and page_owner() and if the two users are blocked -- not display content but redirect to the dashboard.

    More testing and refining....


    DhrupDeScoop 826 days ago

    Update on my devel - testing :=

    2-Way block now works between normal users only and if they were friends before - no more friends ;-)

    Admins (the FK admins) are exempt from being blocked and also do not/cannot block users.

    Messages between blocked users are 50% working.

    Bigger issue -->
    After users "A" and "B" are blocked - Neither one should be to able see each others content, pages, blogs, photos, nothing...

    I have some Elgg-way ideas on how this can be done.. took me a while to think on this ;-) and I'm quite sure it will work - I have coded about 50% for this and just need to finish the code and test to make sure.

    Latest News -->
    Blogs    Block Works
    Files    Block Works
    Pages    Block Works
    Photos    Block Works
    Groups    Does Not Work ;-(

     
    rohonupe99 474 days ago

    i'm trying to add a user block feature on my site so that users can block a user from contacting them. where would i add the code about in order to enable this?


    iionly 474 days ago

    @rohunupe99:
    There's a plugin that might be useful for you:
    http://community.elgg.org/pg/plugins/project/475802/developer/costelloc/messages-controls
    It restricts sending messages to friends only. Maybe that will be enough for you already. Otherwise, you might find some inspiration in the plugin code at least.


    rohonupe99 474 days ago
    thanks for the response. i'll try that out

``````````````````````````````````````````````````````````````

reviving muah old fave topic..
some plugins have been done since wayback then
that handle various forms of blocking, privacy and so on.
we've had out fbfk 'enemy system' in place since way back then.
coz the kids & parents had wanted this way.

a real and more proper way to appoach thsi eneym system
would be (a la fb!) access controls like the rolez/permz plugin
but also a finer level - by the owner guid and the viewer guid
-> so that a more global net can be put out to protect privacy
of all of a user's content, beyond just profile views and
messages...

what's the use if you cannot see my profile or send me messages ?
-- BUT you can still see ALL my group posts, blogs, albums, everything
else ? that's really a 1/2 x approach to a real problem, isn't it ?

 

``````````````````````````````````````````````````````````````