Notify a user with notifications or alert Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
4 posters

    Notify a user with notifications or alert

    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Notify a user with notifications or alert

    Post by TheCrow November 22nd 2016, 3:18 pm

    Technical Details


    Forum version : #phpBB3
    Position : Administrator
    Concerned browser(s) : Mozilla Firefox, Google Chrome
    Who the problem concerns : All members
    Forum link : http://www.forum-promotion.com/

    Description of problem


    Hello,

    So i create a donation system that a member can use it, tag a member and request a donation of points from his/her profile to the member (s)he tagged. What i want is that member who gets tagged to get notified wither to the notification list of fa_toolbar or to his/her browser that the member who posted has donated to him/her the X amount of points.

    I do not wish to share the donation system code but if you know how i can add a script or something in my code in order to do this i would appreciate the help.

    Thanks
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51515
    Reputation : 3519
    Language : English
    Location : United States

    Solved Re: Notify a user with notifications or alert

    Post by SLGray November 22nd 2016, 9:22 pm

    Do you mean the tag system?

    @SLGray

    If yes, you will get a notification if you have it set in your profile.



    Notify a user with notifications or alert Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow November 22nd 2016, 9:59 pm

    Despite the tag mention, there are people that don't pay attention to the notifications. Maybe if an alert of the browser is sent to them it may be something better. But still with the notifications i want a notification that will contain information about the donation and not a single tag.



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow November 24th 2016, 2:10 pm

    Bump!



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow November 25th 2016, 9:58 pm

    Luffy wrote:Bump!



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow November 28th 2016, 7:25 pm

    Bump!



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow December 1st 2016, 3:59 pm

    Bump.



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Kyo Panda
    Kyo Panda
    Forumember


    Male Posts : 33
    Reputation : 19
    Language : Portuguese, English
    Location : Brazil

    Solved Re: Notify a user with notifications or alert

    Post by Kyo Panda December 3rd 2016, 1:35 am

    Hello,

    Rely on the FA.Notification for any function you wish to create is a painful path — trust me, I've been there. I would suggest that you intercept the "donation action" and, before it happens, you send a PM via Ajax with the notice.

    Code:
    ; (function ($) {
        'use strict';

        $(function () {
            /** Before doing donation stuff */
            $.post('/privmsg', {
                username: 'Donation Receiver',
                subject: 'I\'ve just sent you a donation!',
                message: 'Lorem ipsum dolor sit amet.',
                mode: 'post',
                post: 1
            }).then(function () {
                /** Do the donation stuff */
                console.log('I\'m doing stuff.')
            });
        });
    })(jQuery);

    PMs have a natural alert, so that should be covered up.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow December 3rd 2016, 9:59 am

    Hello @Kyo Panda and thank you for your reply.
    That code pretty much does what i want but is there a possibility that we can add an alert on the browser too? Within that code, the member who receives the coins to receive an alert also?



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Kyo Panda
    Kyo Panda
    Forumember


    Male Posts : 33
    Reputation : 19
    Language : Portuguese, English
    Location : Brazil

    Solved Re: Notify a user with notifications or alert

    Post by Kyo Panda December 3rd 2016, 11:51 pm

    The member who receive the coins (and the message) will receive the "You got a new message!" alert, default on Forumotion, assuming that the username field on the ajax call is properly filled with the receiver username.

    Of course, we can go rad on this topic and on overall_header:

    Code:
    <!-- BEGIN switch_enable_pm_popup -->
        pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
        if(pm != null) { pm.focus(); }
    <!-- END switch_enable_pm_popup -->

    Inside the switch, we can make another interception to do "custom stuff":

    Code:
    <!-- BEGIN switch_enable_pm_popup -->
        $.get('/privmsg?folder=inbox', function (data) {
            if ($('a.topictitle:eq(0)', data).text().trim() === 'I\'ve just sent you a donation!') {
                console.log('Do awesome stuff!');
                return;
            }

            /** Default PM codez */
            pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
            if(pm != null) { pm.focus(); }
        });
    <!-- END switch_enable_pm_popup -->

    ^ Like zis. Bouncy
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow December 4th 2016, 1:44 pm

    Hello @Kyo Panda,

    Just to make sure i understood this correctly, with the second code to do custom stuff this reads the title of the PM and if it's the one entered 'I\'ve just sent you a donation!' it will show the alert on the console? If this is it then it's perfect.



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Kyo Panda
    Kyo Panda
    Forumember


    Male Posts : 33
    Reputation : 19
    Language : Portuguese, English
    Location : Brazil

    Solved Re: Notify a user with notifications or alert

    Post by Kyo Panda December 4th 2016, 2:03 pm

    Yep, exactly.

    ---

    Basically:

    Code:
    /** When a new PM is received and the alert option is ON on the Administrative Panel (default) */
    <!-- BEGIN switch_enable_pm_popup -->
        /** Load the receiver PM page */
        $.get('/privmsg?folder=inbox', function (data) {
            /** If the last PM received has the title "I've just sent you a donation!" */
            if ($('a.topictitle:eq(0)', data).text().trim() === 'I\'ve just sent you a donation!') {
                /** Do custom stuff */
                console.log('Do awesome stuff!');
                /** And return without executing the default PM code below */
                return;
            }
     
            /** Default PM codez */
            pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
            if(pm != null) { pm.focus(); }
        });
    <!-- END switch_enable_pm_popup -->

    Bouncy
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow December 4th 2016, 2:06 pm

    An do i have to add the <script> tags or not? Because it's in the templates?



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Kyo Panda
    Kyo Panda
    Forumember


    Male Posts : 33
    Reputation : 19
    Language : Portuguese, English
    Location : Brazil

    Solved Re: Notify a user with notifications or alert

    Post by Kyo Panda December 4th 2016, 2:13 pm

    This particular part on overall_header is already within a script tag, so you should be covered up.

    Code:
       <script type="text/javascript">
       //<![CDATA[
       $(document).ready(function(){
          <!-- BEGIN switch_enable_pm_popup -->
             pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
             if(pm != null) { pm.focus(); }
          <!-- END switch_enable_pm_popup -->
          <!-- BEGIN switch_report_popup -->
             report = window.open('{switch_report_popup.U_REPORT_POPUP}', '_phpbbreport', 'HEIGHT={switch_report_popup.S_HEIGHT},resizable=yes,scrollbars=no,WIDTH={switch_report_popup.S_WIDTH}');
             if(report != null) { report.focus(); }
          <!-- END switch_report_popup -->
          <!-- BEGIN switch_ticker -->
             $(document).ready(function() {
                Ticker.start({
                   height : {switch_ticker.HEIGHT},
                   spacing : {switch_ticker.SPACING},
                   speed : {switch_ticker.SPEED},
                   direction : '{switch_ticker.DIRECTION}',
                   pause : {switch_ticker.STOP_TIME}
                });
             });
          <!-- END switch_ticker -->
       });

       <!-- BEGIN switch_login_popup -->
          var logInPopUpLeft, logInPopUpTop, logInPopUpWidth = {LOGIN_POPUP_WIDTH}, logInPopUpHeight = {LOGIN_POPUP_HEIGHT}, logInBackgroundResize = true, logInBackgroundClass = false;
       <!-- END switch_login_popup -->

       <!-- BEGIN switch_login_popup -->
       $(document).ready( function() {
          $(window).resize(function() {
             var windowWidth = document.documentElement.clientWidth;
             var popupWidth = $("#login_popup").width();
             var mypopup = $("#login_popup");

             $("#login_popup").css({
             "left": windowWidth/2 - popupWidth/2
                });
          });
       });
       <!-- END switch_login_popup -->
       //]]>
       </script>
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow December 4th 2016, 2:18 pm

    So it should be like this:

    or entered within the
    Code:
    //<![CDATA[


    My bad, i didn't see the code very well. I did enter the code in the overall header but there is nothing showing up once i send a donation. I do get the pm and the notifications on the fa_toolbar but no browser alert.



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Kyo Panda
    Kyo Panda
    Forumember


    Male Posts : 33
    Reputation : 19
    Language : Portuguese, English
    Location : Brazil

    Solved Re: Notify a user with notifications or alert

    Post by Kyo Panda December 4th 2016, 2:35 pm

    Can you post your overall_header here, so we can check what is happening? Smile

    ---

    EDIT.: No problems. ^-^


    Last edited by Kyo Panda on December 4th 2016, 2:40 pm; edited 1 time in total
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow December 4th 2016, 2:38 pm

    Oh well, i changed the console.log to alert and it worked. All i wanted is an alert to show up!!

    Thanks so much @Kyo Panda!!



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    brandon_g
    brandon_g
    Manager
    Manager


    Male Posts : 10112
    Reputation : 923
    Language : English
    Location : USA

    Solved Re: Notify a user with notifications or alert

    Post by brandon_g December 4th 2016, 2:56 pm

    May this be archived now @Luffy ?

    -Brandon



    Notify a user with notifications or alert Brando10
    Remember to mark your topic Notify a user with notifications or alert Solved15 when a solution is found.
    General Rules | Tips & Tricks | FAQ | Forgot Founder Password?

    Notify a user with notifications or alert Scre1476
    Team Leader
    Review Section Rules | Request A Review | Sticker Points
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6921
    Reputation : 795
    Language : Greek, English

    Solved Re: Notify a user with notifications or alert

    Post by TheCrow December 4th 2016, 3:08 pm

    Oops! Embarassed I completely forgot i could do that! Razz
    Thanks once again Kyo Panda!!

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules



    Notify a user with notifications or alert Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!