We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Friends pluging serious bug confirmed - Friends | Forum

Marcus
Marcus Nov 22 '19
Folks just confirmed a bug!!!


Use mobile device cellphone!!!! 

Disable mobile version. Don't turn on desktop version. Visit user profile with friends pluging enabled. Reload the page. On each profile reload it will either request or cancel friends request. 
Leaving profile acts same way. 
Chrome Android browser. 

The Forum post is edited by Marcus Nov 23 '19
Marcus
Marcus Nov 22 '19
Firefox OK only Chrome...

Conformed on demo
dave Leader
dave Nov 22 '19
Interesting, ill test this as well thanks 
Marcus
Marcus Nov 22 '19
Make sure u use mobile device desktop won't do.

Started today. I tested on demo and it behaives same way. 
Marcus
Marcus Nov 23 '19
Apart from Dave wtf nobody is trying to fix this quite serios bug thats screwing everything up...

This stuff happens on demo site to I'm not some isolated ocurrance. 

I was able to narrow the issue down to this function.... 

onCollectProfileActionTools


It pops the button on profile. 

Now why and how chrome is able to execute or click on that button I'm not sure plus it keeps doing that on after you leave profile... 
The Forum post is edited by Marcus Nov 23 '19
Marcus
Marcus Nov 23 '19
I'm thinking about adding onload script to strip url from button link convert that to variable and Create onclick event for it. 
Oxwall Germany Club
Oxwall Germany Nov 23 '19
Topic was moved from Bug reports and troubleshooting.
Oxwall Germany Club
Oxwall Germany Nov 23 '19
We'll forward this to the dev team. Thank you for reporting.
Marcus
Marcus Nov 23 '19
Thanks oxwall Germany please fix it asap my site looks really bad case I'm using responsive theme. Keep us posted on the progress of this bug
Oxwall Germany Club
Oxwall Germany Nov 23 '19
We already forwarded it to the dev team. Unfortunately, we don't have the possibility to fix it directly.
Marcus
Marcus Nov 23 '19
Anyways thanks buddy appreciate it. 
Marcus
Marcus Nov 24 '19

Folks found the issue! Not sure why developer of this plugin included the link inside the href as appose to create an event onclick like other buttons do.


<a href="/friends/action/request/id/21616/" id="friendship838695">
                        Add to Friends
                    </a>


Should be like so...


<a href="javascript://" id="friendship838695">
                        Add to Friends
                    </a>


No we can use some like this:



(function(_scope) {


            $("#friendship838695").click(function()
            {
             
// do stuff here
            

        })({});



Not sure what to do inside the even... Maybe call the URL??? Can someone shed some light!!


The Forum post is edited by Marcus Nov 24 '19
Marcus
Marcus Nov 24 '19

Here is my patch please feel free to comment....



public function onCollectProfileActionTools( BASE_CLASS_EventCollector $event )
    {
        $params = $event->getParams();

        if ( empty($params['userId']) )
        {
            return;
        }

        $userId = (int) $params['userId'];

        if ( !OW::getUser()->isAuthenticated() || OW::getUser()->getId() == $userId )
        {
            return;
        }

        $language = OW::getLanguage();
        $router = OW::getRouter();
        $dto = $this->service->findFriendship($userId, OW::getUser()->getId());
        $linkId = 'friendship' . rand(10, 1000000);
        $extra_label = null;
        if ( $dto === null )
        {
            if( !OW::getUser()->isAuthorized('friends', 'add_friend') )
            {
                $status = BOL_AuthorizationService::getInstance()->getActionStatus('friends', 'add_friend');
           
                if ( $status['status'] == BOL_AuthorizationService::STATUS_PROMOTED )
                {
                    $href = 'javascript://';
                    $script = '$({$link}).click(function(){
                        window.OW.error({$message});
                    });';

                    $script = UTIL_JsGenerator::composeJsString($script, array('link' => '#'.$linkId, 'message' => $status['msg'] ));
                    OW::getDocument()->addOnloadScript($script);
                }
                else if ( $status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE )
                {
                    return;
                }
            }
            else if ( BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId) )
            {
                $href = 'javascript://';
                $script = '$({$link}).click(function(){
                    window.OW.error({$message});
                });';
               
                $script = UTIL_JsGenerator::composeJsString($script, array('link' => '#'.$linkId, 'message' => OW::getLanguage()->text('base', 'user_block_message') ));
                OW::getDocument()->addOnloadScript($script);
            }
            else
            {
                $href = $router->urlFor('FRIENDS_CTRL_Action', 'request', array('id' => $userId));
            }

            $label = OW::getLanguage()->text('friends', 'add_to_friends');
        }
        elseif ( $dto === null )
        {
            $status = BOL_AuthorizationService::getInstance()->getActionStatus('friends', 'add_friend');
           
            if($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED)
            {
                $href = $router->urlFor('FRIENDS_CTRL_Action', 'request', array('id' => $userId));
                $label = OW::getLanguage()->text('friends', 'add_to_friends');
            }
            else
            {
                return;
            }           
           
        }
        else
        {
            switch ( $dto->getStatus() )
            {
                case FRIENDS_BOL_Service::STATUS_ACTIVE:
                    $label = $language->text('friends', 'remove_from_friends');
                    $href = $router->urlFor('FRIENDS_CTRL_Action', 'cancel', array('id' => $userId, 'redirect'=>true));
                    break;

                case FRIENDS_BOL_Service::STATUS_PENDING:

                    if ( $dto->getUserId() == OW::getUser()->getId() )
                    {
                        $label = $language->text('friends', 'friend_request_was_sent');
                        $href = $router->urlFor('FRIENDS_CTRL_Action', 'cancel', array('id' => $userId, 'redirect'=>true));
                        $extra_label = $language->text('friends', 'cancel_request');
                    }
                    else
                    {
                        if ( !OW::getUser()->isAuthorized('friends', 'add_friend') )
                        {
                            return;
                        }
                        $label = $language->text('friends', 'add_to_friends');
                        $href = $router->urlFor('FRIENDS_CTRL_Action', 'accept', array('id' => $userId));
                    }
                    break;

                case FRIENDS_BOL_Service::STATUS_IGNORED:

                    if ( $dto->getUserId() == OW::getUser()->getId() )
                    {
                        $label = $language->text('friends', 'remove_from_friends');
                        $href = $router->urlFor('FRIENDS_CTRL_Action', 'cancel', array('id' => $userId));
                    }
                    else
                    {
                        if ( !OW::getUser()->isAuthorized('friends', 'add_friend') )
                        {
                            return;
                        }
                        $label = $language->text('friends', 'add_to_friends');
                        $href = $router->urlFor('FRIENDS_CTRL_Action', 'activate', array('id' => $userId));
                    }
            }
        }
       
       
// my fix start       
$script = UTIL_JsGenerator::composeJsString('

            $("#' . $linkId . '").click(function()
            {
    window.location.href="'.$href.'";      
        }
       
        );');

OW::getDocument()->addOnloadScript($script);
// my fix end       
       

        $resultArray = array(
            BASE_CMP_ProfileActionToolbar::DATA_KEY_LABEL => $label,
            BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_HREF => 'javascript://',
            BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ID => $linkId,
            BASE_CMP_ProfileActionToolbar::DATA_KEY_ITEM_KEY => 'friends.action',
            BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ORDER => 1,
            BASE_CMP_ProfileActionToolbar::DATA_KEY_EXTRA_LABEL => $extra_label
        );

        $event->add($resultArray);
    }

Marcus
Marcus Nov 24 '19
Hi Dave looks like I was able to fix this friends bug.. Please have a look and maybe patch your ow copy... https://developers.oxwall.com/forum/topic/65928


dave Leader
dave Nov 24 '19
I took yesterday off sorry, i was not feeling well.  I am glad you found it. 


I was wondering if we should be using


javascript:void(0)


instead of 


javascript://


The reason is that void traps the undefined value as 0 where the javascript:// gives no allowance to trap anything and sometimes javascript:// will not work when using void(0) will. 


Your thougths ?

The Forum post is edited by dave Nov 24 '19
Marcus
Marcus Nov 24 '19
Not sure Dave I'm not the expert in all this js sorry my fix was based on other neer by buttons like follow all of thich have same js structure. 
dave Leader
dave Nov 24 '19
I am no JS guru either but i do know that using void is better than the other.  I think your fix is good, nice job. :)


Maybe our JS expert SD will chime in and let us know, he is really really great with JS.

Marcus
Marcus Nov 24 '19
Thanks Dave really appreciate it. I hope they will make a permanent fix asap but for time being I'm glad we were able to patch this bug and restore the site to normal working condition.


Now I could return addressing stuff we descused earlier. Thanks again. 


Ebenezer from Bluetide Webs
@Marcus, I found this very late. I haven't been here for a while but I'm glad you figured it out.


@Dave, here are the various differences in the JS pattern:


 * javascript:// - This will run JavaScript that evaluates an empty comment, returns undefined.

 * javascript:void(0) - This will run JavaScript that evaluates the statement 0 and then returns undefined.

 *  javascript:; - This will run JavaScript that evaluates an empty JavaScript statement and then returns undefined.


See test result below:




None of this method in my opinion is better than the other. Another alternative is to use the hashbang:


<a href="#!">A link that does nothing</a>


Notice the #! in the anchor tag.

The Forum post is edited by Ebenezer from Bluetide Webs Nov 27 '19
dave Leader
dave Nov 27 '19
Thanks Ebenezer for the tuturial on that, good info :)     Great to see you again, hope youll be around more often :)
Pages: 1 2 »
You do not have permission to reply this topic