Help
Discuss or request ArrowChat site notifications
User avatar
mquintero
Customer
 
Posts: 7
Joined: 15 Jun 2010, 14:32

 

by mquintero 16 Aug 2010, 20:26

I was wondering if anyone knew how to set up the buddypress notifications, such as :

-Activity Comments
-New Likes
-New Activity
-Gifts
-New Forum reply

But the most important are:
-New Messages
-New Friend Requests
User avatar
PMaitland
Customer
 
Posts: 9
Joined: 08 Jul 2010, 15:58

 

by PMaitland 01 Oct 2010, 13:39

You need to add sql code to your plugins/buddypress/bp-themes/_inc/ajax.php file. Or better yet remake the functions that are in the ajax.php in your functions.php file so you are not overriding buddypress backend code.
User avatar
AKaczorowski
Customer
 
Posts: 4
Joined: 25 Feb 2010, 17:39

 

by AKaczorowski 01 Oct 2010, 14:07

I'm willing to tackle this project. What type of SQL code are we looking at? Any snippets that I can hack from?
User avatar
AKaczorowski
Customer
 
Posts: 4
Joined: 25 Feb 2010, 17:39

 

by AKaczorowski 01 Oct 2010, 14:13

Just found documentation on the Install Guide. (Step 5)

Stand-Alone or Non-Included Notifications
In order for site notifications to function correctly, you must insert a mySQL query where the action occurs on your site. For example, if you want your users to receive notifications for private messages, you need to insert the statement whenever a private message is sent. An example mySQL query would be:

Code: Select all
$sql = "INSERT INTO arrowchat_notifications (to_id, author_id, author_name, type, alert_time)
      VALUES ('".$to_id."', '".$author_id."', '".$author_name."', '1', '".time()."')";
   mysql_query($sql);


If the notification does not have an author id or author name, you can leave those blank or null, or you can use those fields for different information.

to_id - (int) The user ID of the user that should receive the notification.
author_id - (int) The user ID of the user that sent the notification. Can be left blank if none.
author_name - (varchar) The name of the user that sent the notification. Can be left blank if none.
misc1 - (varchar) Optional, use this field for any additional information.
misc2 - (varchar) Optional, use this field for any additional information.
misc3 - (varchar) Optional, use this field for any additional information.
type - (int) The type of notification. You need to create a notification markup in the admin panel, and then insert the number of that markup as the type.
alert_time - (int) The unix time of when the notification was sent.
User avatar
PMaitland
Customer
 
Posts: 9
Joined: 08 Jul 2010, 15:58

 

by PMaitland 01 Oct 2010, 14:48

AKaczorowski wrote:Just found documentation on the Install Guide. (Step 5)

Stand-Alone or Non-Included Notifications
In order for site notifications to function correctly, you must insert a mySQL query where the action occurs on your site. For example, if you want your users to receive notifications for private messages, you need to insert the statement whenever a private message is sent. An example mySQL query would be:

Code: Select all
$sql = "INSERT INTO arrowchat_notifications (to_id, author_id, author_name, type, alert_time)
      VALUES ('".$to_id."', '".$author_id."', '".$author_name."', '1', '".time()."')";
   mysql_query($sql);


If the notification does not have an author id or author name, you can leave those blank or null, or you can use those fields for different information.

to_id - (int) The user ID of the user that should receive the notification.
author_id - (int) The user ID of the user that sent the notification. Can be left blank if none.
author_name - (varchar) The name of the user that sent the notification. Can be left blank if none.
misc1 - (varchar) Optional, use this field for any additional information.
misc2 - (varchar) Optional, use this field for any additional information.
misc3 - (varchar) Optional, use this field for any additional information.
type - (int) The type of notification. You need to create a notification markup in the admin panel, and then insert the number of that markup as the type.
alert_time - (int) The unix time of when the notification was sent.



Thats the code you'll be using.
For example here is from my functions.php file for new wall posts notifications. I am doing some other custom things but you are concerned about is the sql code.

Code: Select all
remove_action( 'wp_ajax_post_update', 'bp_dtheme_post_update' );
//add our own handler for activity posting

add_action(  'wp_ajax_post_update', 'bp_mytheme_post_update' );

/* AJAX update posting */
function bp_mytheme_post_update() {
    global $bp, $wpdb;

    /* Check the nonce */
    check_admin_referer( 'post_update', '_wpnonce_post_update' );

    if ( !is_user_logged_in() ) {
        echo '-1';
        return false;
    }

    if ( empty( $_POST['content'] ) ) {
        echo '-1<div id="message"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>';
        return false;
    }

    if ( empty( $_POST['object'] ) && function_exists( 'bp_activity_post_update' ) ) {

        //this is what I have changed

        if(!bp_is_home()&&bp_is_member())
        $content="@". bp_get_displayed_user_username()." ".$_POST['content'];
        else
        $content=$_POST['content'];

        $activity_id = bp_activity_post_update( array( 'content' => $content ) );

        //end of my changes
    } elseif ( $_POST['object'] == 'groups' ) {
        if ( !empty( $_POST['item_id'] ) &&function_exists( 'groups_post_update' ) )
            $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) );
    } else
        $activity_id = apply_filters( 'bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content'] );

    if ( !$activity_id ) {
        echo '-1<div id="message"><p>' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '</p></div>';
        return false;
    }else{
        if($bp->current_component == 'wall' && $bp->displayed_user->id !=$bp->loggedin_user->id){
               $sql = "INSERT INTO arrowchat_notifications (to_id, author_id, author_name, type, alert_time, misc1, misc2)
            VALUES (".$bp->displayed_user->id.", ".$bp->loggedin_user->id.",'".ucfirst(xprofile_get_field_data('First Name',$bp->loggedin_user->id))." ".ucfirst(xprofile_get_field_data('Last Name',$bp->loggedin_user->id)) ."',3,".time().",'".$bp->displayed_user->userdata->user_url ."','".$bp->loggedin_user->userdata->user_url ."')";
            $wpdb->query($sql);
            //echo $sql;
        }
    }

    if ( bp_has_activities ( 'include=' . $activity_id ) ) : ?>
        <?php while ( bp_activities() ) : bp_the_activity(); ?>
            <?php locate_template( array( 'activity/entry.php' ), true ) ?>
        <?php endwhile; ?>
    <?php endif;
}
User avatar
BBHATHAL
Customer
 
Posts: 1
Joined: 26 Aug 2011, 02:19

 

by BBHATHAL 26 Aug 2011, 02:46

Can anyone help me to setup this, I have purchased arrowchat and Using on oxwall 1.2.3
Where and How can I add this ?

Stand-Alone or Non-Included Notifications
In order for site notifications to function correctly, you must insert a mySQL query where the action occurs on your site. For example, if you want your users to receive notifications for private messages, you need to insert the statement whenever a private message is sent. An example mySQL query would be:

$sql = "INSERT INTO arrowchat_notifications (to_id, author_id, author_name, type, alert_time)
VALUES ('".$to_id."', '".$author_id."', '".$author_name."', '1', '".time()."')";
mysql_query($sql);

If the notification does not have an author id or author name, you can leave those blank or null, or you can use those fields for different information.

to_id - (int) The user ID of the user that should receive the notification.
author_id - (int) The user ID of the user that sent the notification. Can be left blank if none.
author_name - (varchar) The name of the user that sent the notification. Can be left blank if none.
misc1 - (varchar) Optional, use this field for any additional information.
misc2 - (varchar) Optional, use this field for any additional information.
misc3 - (varchar) Optional, use this field for any additional information.
type - (int) The type of notification. You need to create a notification markup in the admin panel, and then insert the number of that markup as the type.
alert_time - (int) The unix time of when the notification was sent.
User avatar
Staff Bot
ArrowChat Team
 
Posts: 8996
Joined: 07 Nov 2012, 13:41

 

by Staff Bot 07 Nov 2012, 12:40

This thread has been locked because the last post is greater than six months old. There is a good chance that the information in this thread is outdated. Please open a new topic if you wish to discuss this further.