vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Notification on New Database Row (https://vborg.vbsupport.ru/showthread.php?t=289105)

CoffeeLovesYou 10-15-2012 09:03 PM

Notification on New Database Row
 
Hi,

I have a form set up to make a request. After a user makes a request, it then shows up on a table and our Mod views it.
However, how can I make a Notification appear on the notification list when there is a new request, aka a new row in the table?
I am using the Group Membership Requests modification, and all it has is 1 phrase and the rest is 1 plugin, which is using the hook notifications_list. Here is the only plugin.

PHP Code:

$requests $vbulletin->db->query_read("
                SELECT COUNT(*) AS CountRequests, "
.TABLE_PREFIX."usergrouprequest.usergroupid as GroupID, ".TABLE_PREFIX."usergroupleader.userid
                FROM "
.TABLE_PREFIX."usergrouprequest
                                INNER JOIN "
.TABLE_PREFIX."usergroupleader ON
                                ("
.TABLE_PREFIX."usergrouprequest.usergroupid = ".TABLE_PREFIX."usergroupleader.usergroupid)
                                WHERE "
.TABLE_PREFIX."usergroupleader.userid= ".$vbulletin->userinfo['userid']."
                                GROUP BY GroupID
        "
);

if (
$vbulletin->db->num_rows($requests) == 1) {
  
$request $vbulletin->db->fetch_array($requests);
  
$vbulletin->userinfo['groupmembership_requests'] = $request['CountRequests'];
  
$groupurl "joinrequests.php?usergroupid=".$request['GroupID'];
 }
else if (
$vbulletin->db->num_rows($requests) > 1) {
  
$vbulletin->userinfo['groupmembership_requests'] = 0;
  
$count $vbulletin->db->num_rows($requests);
  for ( ; 
$count 0$count-- ) {
   
$request $vbulletin->db->fetch_array($requests);
     
$vbulletin->userinfo['groupmembership_requests'] += $request['CountRequests'];

  }
      
$groupurl "profile.php?do=editusergroups";
 } else {
  
$groupurl "profile.php?do=editusergroups";
  
$vbulletin->userinfo['groupmembership_requests'] = 0;
 }
          

    
$notifications['groupmembership_requests'] = array(
            
'phrase' => $vbphrase['groupmembership_requests'],
            
'link'   => $groupurl $vbulletin->session->vars['sessionurl_q'],
            
'order'  => 12); 

This mod basically, if you are a leader of a usergroup that has 1 or more join requests that need to be processed, you get a notification.
I want to modify it to give a notification when a new row is added to my table.
If anyone can guide me, please and Thank You!

kh99 10-16-2012 12:32 AM

Well, here's a thread where we talked about adding something to the notifications menu: www.vbulletin.org/forum/showthread.php?t=286095 . It's basically the same thing that 's done in the plugin you posted (but of course yours is more complicated because it actually checks something instead of using a constant). If you can figure out the code to get the number of notifications you want, you should be able to follow that example to display them in the menu.

CoffeeLovesYou 10-16-2012 08:51 AM

Hmm.
Well, basically, if the status of the row is '1', I want it to show a notification.
So like, SELECT * FROM mytable WHERE status='1'
Gonna see if I can incorporate it in that plugin, thanks


All times are GMT. The time now is 11:22 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01786 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete