1
suico
How does the notify function works?
  • 2005/6/20 20:34

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


I am implementing a module by myself and i need to inform a user that i have just made an insert.

How does XOOPS treat this? I saw I have to alter the xoops_version.php file but i really can' t understand. Can sanyone write a bit on the matter? Or maybe show me where to read about this?

2
Mithrandir
Re: How does the notify function works?

I assume you have read this: Using the Built-in Notification System

The notification systems works like this:
1. A user can subscribe to be notified when certain "Events" occur
2. When the event occurs, code in the module triggers the notification
3. The notification code sends out messages to all users currently subscribed to this event, using the method specified in the user's profile

3
suico
Re: How does the notify function works?
  • 2005/6/20 22:14

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


Thanks mith , as always you have thought of everything and we users are making stupid questions :) But i have looked for something like this before :( Anyway it wis exactly what i was looking fo, thanks too much!

4
suico
Re: How does the notify function works?
  • 2005/6/20 22:36

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


Still about notifications:

I ve red the article you pointed me and it helped me a lot!

I have though a few doubts:

Quote:

item_name: the HTTP //get// parameter to watch, which specifies the ID of the specific item in the category (e.g. forum ID or thread ID)

What if i have more than one get parameter to be wacthed together? Is it possible to be implemented? Or do I have to change my code to have a unique variable?

5
suico
Re: How does the notify function works?
  • 2005/6/21 18:00

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


ok forget the last message.

Now i am able to subscribe the members to an event it seems everything is ok for this feature but when i try to use the trigger method it does not send a message to the user. :(

$notification_handler =& xoops_gethandler('notification');
$notification_handler->triggerEvent('Espera'$num 'Reserva');


in the code espera is a category, reserva is an event and $num is a variable that i have now set to 1 for test purposes only . Maybe someone can give me a tip on what to do to make it works? Or at least to test it.

6
Mithrandir
Re: How does the notify function works?

And there are users, who subscribe to the event?

7
suico
Re: How does the notify function works?
  • 2005/6/21 19:01

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


yes there are.
Table xoopsnotifications data:

id    modid   itemid    category event         uid    mode
48      53      9      Espera  Reserva      9      0
49     53     10     Espera     Reserva     1     0
50     53     1     Espera     Reserva     12     0
51     53     12     Espera     Reserva     1     0


Any idea mith? Or anyone else?

8
suico
Re: How does the notify function works?
  • 2005/6/21 19:53

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


Trying to help you to help me:



Resized Image

Even beeing subscribed i didn t receive a private message (it is my form of notification)
Anyone has a idea of what i am doing wrong?

9
suico
Re: How does the notify function works?
  • 2005/6/22 12:54

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


I must be doing something wrong, the triggerevent simly seems to be doing nothing:


###############################################  ---- INSERÇÕES DE OUTROS ARQUIVOS  ----------- ###############################
#INsere o cabeçalho e cria a formatação
include("../../mainfile.php");
#O cabeçalho do nosso módulo
include("header.php");
//$xoopsOption['show_rblock'] = 0;
#Vamos puxar os arquivos do calendário arrumadinho
if (file_exists(XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/calendar.php')) {
    include_once 
XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/calendar.php';
} else {
    include_once 
XOOPS_ROOT_PATH.'/language/english/calendar.php';
}
#Uma outra inclusão desta vez da classe de formulários
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";

######################## ------ BUSCANDO DADOS DAS RESERVAS ---------- ########################################
#agora vamos puxar no banco as reservas para esse dia e turnos caso alguém não tenha cadastrado antes dele né
$codigo_da_reserva $_GET['cod'];

$quem_libera = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
if (
$xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
$isadmin true;
} else {
$isadmin false;
}

if (
$isadmin)
{  



###################### --- Procurar lista de espera para o dia turno tipo ------ ################################
//vamos começar buscando os dados da reserva que está sendo liberada
$sql_reserva "SELECT * FROM ".$xoopsDB->prefix('carros_reservas').' , '.$xoopsDB->prefix('carros_carros')." WHERE ".$xoopsDB->prefix('carros_carros.placa').' = '.$xoopsDB->prefix('carros_reservas.placa').' AND cod_reserva='.$codigo_da_reserva;
$tabela_reserva $xoopsDB->query($sql_reserva) or exit("Erro ao conectar");

while (
$vetor $xoopsDB->fetchArray($tabela_reserva))
{
// Agora temos a data o turno e o modelo que estava reservado
$data_reserva $vetor['inicio'];
$turno_reserva $vetor['turno'];
$modelo_reserva $vetor['modelo'];
$placa_reserva $vetor['placa'];
}

// vamos atras do primeiro da lista se é que tem uma
$sql_reservas_espera "SELECT * FROM ".$xoopsDB->prefix('carros_espera')." WHERE lista_data_reserva ='".$data_reserva."' AND lista_turno ='".$turno_reserva."' AND lista_tipo='".$modelo_reserva."' AND cancela=0 LIMIT 0 , 1"
//echo $sql_reservas_espera;
//echo $sql_reservas_espera;
$tabela_reservas_espera $xoopsDB->query($sql_reservas_espera) or exit("Erro ao conectar sss");    
$qtd_espera $xoopsDB->getRowsNum($tabela_reservas_espera);



//print_r ($xoopsDB->fetchArray($tabela_reservas_espera));
while ($vetor2 $xoopsDB->fetchArray($tabela_reservas_espera))
{
// Agora temos a data o turno e o modelo que estava reservado
$uid_lista $vetor2['lista_uid'];
$trajeto_lista $vetor2['lista_trajeto'];
$ramal_lista $vetor2['lista_ramal'];
$data_ato_lista $vetor2['lista_data_registro'];
$cod_lista $vetor2['cod_lista'];
}
//vamos agora inserir a reserva no banco
$sql_insere "INSERT INTO ".$xoopsDB->prefix('carros_reservas')." (placa, uid, inicio, turno, trajeto, data_ato, ramal) values ('".$placa_reserva."',".$uid_lista.",'".$data_reserva."','".$turno_reserva."','".$trajeto_lista."', '".$data_ato_lista."' , '".$ramal_lista."')";
//echo '



'.$sql_insere;
$inserir=mysql_query($sql_insere);// or exit("Erro ao Inserir xx");

//vamos cancelar o item da lista de espera
$sql_cancela_espera "UPDATE ".$xoopsDB->prefix('carros_espera')." SET cancela='1' WHERE cod_lista=".$cod_lista;
//echo '



'.$sql_cancela_espera;
$inserir=mysql_query($sql_cancela_espera);


//echo ($cod_lista);


//vamos mudar o status da reserva para devolvido
$sql_libera "UPDATE ".$xoopsDB->prefix('carros_reservas')." SET devolvido='1' WHERE cod_reserva=".$codigo_da_reserva;

$liberar=mysql_query($sql_libera);

//Vamos avisar que mudou para reserva
$tags['A_NAME'] = '1';
$tags['A_URL'] = '2';

$notification_handler =& xoops_gethandler('notification');
$notification_handler->triggerEvent'Espera' $cod_lista 'Reserva' $tags );

if (
$qtd_espera==0)
{
redirect_header(XOOPS_URL."/modules/carros/index.php",10,'Este turno foi liberado com sucesso!
Não havia ninguém na lista de espera aguardando esta liberação'
);
}
redirect_header(XOOPS_URL."/modules/carros/index.php",15,'Este turno foi liberado com sucesso!
O primeiro da lista de espera assumiu a reserva!'
);

}
else
{
redirect_header(XOOPS_URL."/modules/carros/index.php",3,'Somente os administradores do módulo podem liberar uma reserva!');
}
## Rodapé que irá fechar conexões etc...
include(XOOPS_ROOT_PATH."/footer.php");



?>

10
McNaz
Re: How does the notify function works?
  • 2005/6/22 13:47

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


I'm probably off here but XOOPS will not send a notification to you if you are logged in user who has generated the notification event...

Login

Who's Online

393 user(s) are online (274 user(s) are browsing Support Forums)


Members: 0


Guests: 393


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits