1
chromehand
triggerEvent() returns false no matter what
  • 2004/7/19 17:20

  • chromehand

  • Just popping in

  • Posts: 11

  • Since: 2004/6/25


I've been trying to trigger and event using

//grab the handler for notification
$nh =& xoops_gethandler('notification');

//trigger the event
$nh->triggerEvent("file",$obj_id,"file_view",$tags)

It keeps returning false.
All of the params going to the method are fine.
I traced my problem inside the method to the lines below:

$config_handler =& xoops_gethandler('config');
$mod_config=&$config_handler->getConfigsByCat(0,$module->getVar('mid'));
if (empty($mod_config['notification_enabled'])) {
return false;
}

I have the line

$modversion['hasNotification']=1;

in the xoops_version.php
along with:

$modversion['notification']['category'][1]['name'] = "file";
$modversion['notification']['category'][1]['title'] = "File";
$modversion['notification']['category'][1]['description'] = "File Notifications";
$modversion['notification']['category'][1]['subscribe_from'] = "file_options.php";
$modversion['notification']['category'][1]['item_name'] = "obj_id";
$modversion['notification']['category'][1]['allow_bookmark'] = 0;

//ADDED: File events
$modversion['notification']['event'][1]['name'] = "file_view" ;
$modversion['notification']['event'][1]['category'] = "file";
$modversion['notification']['event'][1]['title'] = "File Viewed Notification";
$modversion['notification']['event'][1]['caption'] = "Notify me when this file is viewed";
$modversion['notification']['event'][1]['description'] = "No Description";
$modversion['notification']['event'][1]['mail_template'] = "file_viewed";
$modversion['notification']['event'][1]['mail_subject'] = "DMS Notice - File Deleted";


Users are able to subscribe/unsibscribe just fine, yet the event trigger keeps returning false no matter what I do to it.

Any ideas? I'm clue free......



THanks!!!!!!!

2
Dave_L
Re: triggerEvent() returns false no matter what
  • 2004/7/19 17:41

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Aside from the fact that triggerEvent is returning false, are the notifications working? Do subscribed users receive the notifications (PM or email)?

If so, just ignore the returned value, unless you want to figure out exactly what triggerEvent is doing, and submit a bug report, patch or feature request.

I looked at triggerEvent, and didn't see anyplace where it returns true, so the return value is probably not intended to be meaningful. Also, the method's header comment doesn't say anything about the return value.

3
chromehand
Re: triggerEvent() returns false no matter what
  • 2004/7/19 18:43

  • chromehand

  • Just popping in

  • Posts: 11

  • Since: 2004/6/25



Thanks for the reply.
No, the notices are not being sent because the method is returning false before message generation.
FYI: I'm adding notification to the DMS 0.91 module.

// Check if event is enabled
$config_handler =& xoops_gethandler('config');
$mod_config=&$config_handler->getConfigsByCat(0,$module->getVar('mid'));
if (empty($mod_config['notification_enabled'])) {
return false;

}

Wild guess:
The method returning false at this point stops the execution of the method because it can't find the configuration for the module?


I have returned $mod_config before the method could return false and $mod_config is empty.


WHere should I look to make sure the xoops_version.php is being parsed for the particular module?

I am absolutely lost....

Thanks again



4
Dave_L
Re: triggerEvent() returns false no matter what
  • 2004/7/19 19:30

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Is $mod_config completely empty, or just $mod_config['notification_enabled']? If the latter, are you sure Enable Notification is on, in the module's control-panel preferences?

If that doesn't help, I would try printing more stuff out. Did you try dumping $mod_config inside triggerEvent?

$mod_config =& $config_handler->getConfigsByCat(0,$module->getVar('mid'));
[
color=ff0000]var_dump('triggerEvent, mod_config'$mod_config);#*#DEBUG#[/color]


Also, I assume you updated the module after making the changes? And I've found that some changes don't get picked up by an update, and a module uninstall/reinstall is required.

5
chromehand
Re: triggerEvent() returns false no matter what
  • 2004/7/19 19:51

  • chromehand

  • Just popping in

  • Posts: 11

  • Since: 2004/6/25


string(24) "triggerEvent, mod_config"
array(2) {
["notification_enabled"]=>
int(3)
["notification_events"]=>
array(0) {
}
}

I updated the module. (Now I really feel like a goober)
Above is what pops up when I dump inside triggerEvent.
I am making some progress. I'll keep diggin and post the clues

Thanks much for the help


6
chromehand
Re: triggerEvent() returns false no matter what
  • 2004/7/20 13:33

  • chromehand

  • Just popping in

  • Posts: 11

  • Since: 2004/6/25


Well I now have the notification preferences showing up in my module, and the one 'event' category notice.
One thing I have not found in the XoopsWiki about the notification system, is whether or not you can randomly make up the category and event names ......
Is there a specific set of category / event names that are allowed or is it free-form?

Anyone?

The event seems to be firing properly now, yet alas I still recieve no notice in my PM box............................onward I struggle.......

7
Mithrandir
Re: triggerEvent() returns false no matter what

Quote:
The event seems to be firing properly now, yet alas I still recieve no notice in my PM box

Note that you do not receive notifications on actions you perform yourself (what's the point of being notified of new posts in the forums, if you are the poster - you know that already )

8
chromehand
Re: triggerEvent() returns false no matter what
  • 2004/7/20 18:09

  • chromehand

  • Just popping in

  • Posts: 11

  • Since: 2004/6/25


Thanks again for all the help.
I've tried with differen't users to no avail.
The notification system seems very good, but alas the module I'm trying to add it to (DMS 0.91) wasn't created to be extended easily. Great idea, but difficult to work on.


I've managed to find the notification object that should be doing something in the code block in notifications.php

foreach ($notifications as $notification) {
if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) {

// user-specific tags
//$tags['X_UNSUBSCRIBE_URL'] = 'TODO';
// TODO: don't show unsubscribe link if it is 'one-time' ??
$tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php';
$tags = array_merge ($tags, $extra_tags);
$notification->notifyUser($template_dir, $template, $subject, $tags);

var_dump($notification);
}
}



//From the var dump above
object(xoopsnotification)(6) {
["vars"]=>
array(7) {
["not_id"]=>
array(6) {
["value"]=>
string(2) "29"
["required"]=>
bool(false)
["data_type"]=>
int(3)
["maxlength"]=>
NULL
["changed"]=>
bool(false)
["options"]=>
string(0) ""
}
["not_modid"]=>
array(6) {
["value"]=>
string(2) "20"
["required"]=>
bool(false)
["data_type"]=>
int(3)
["maxlength"]=>
NULL
["changed"]=>
bool(false)
["options"]=>
string(0) ""
}
["not_category"]=>
array(6) {
["value"]=>
string(5) "event"
["required"]=>
bool(false)
["data_type"]=>
int(1)
["maxlength"]=>
int(30)
["changed"]=>
bool(false)
["options"]=>
string(0) ""
}
["not_itemid"]=>
array(6) {
["value"]=>
string(3) "188"
["required"]=>
bool(false)
["data_type"]=>
int(3)
["maxlength"]=>
NULL
["changed"]=>
bool(false)
["options"]=>
string(0) ""
}
["not_event"]=>
array(6) {
["value"]=>
string(13) "dms_file_view"
["required"]=>
bool(false)
["data_type"]=>
int(1)
["maxlength"]=>
int(30)
["changed"]=>
bool(false)
["options"]=>
string(0) ""
}
["not_uid"]=>
array(6) {
["value"]=>
string(1) "1"
["required"]=>
bool(true)
["data_type"]=>
int(3)
["maxlength"]=>
NULL
["changed"]=>
bool(false)
["options"]=>
string(0) ""
}
["not_mode"]=>
array(6) {
["value"]=>
string(1) "0"
["required"]=>
bool(false)
["data_type"]=>
int(3)
["maxlength"]=>
NULL
["changed"]=>
bool(false)
["options"]=>
string(0) ""
}
}
["cleanVars"]=>
array(0) {
}
["_isNew"]=>
bool(false)
["_isDirty"]=>
bool(false)
["_errors"]=>
array(0) {
}
["_filters"]=>
array(0) {
}
}

Now - I have found that the method of that object

$notification->notifyUser($template_dir, $template, $subject, $tags);

is returning bool(true) and according to the comments in that functions header, it returns true if the $xoopsMailer() was successful. I should get a notification message right?
Not happening with any user - Where else can I possibly look? I'm on a rope looking at a short drop and a quick stop......
FYI:
This isn't a 'post' or 'new_thread' type of triggerEvent -
It's called when a script named file_view.php is accessed
so subscribed users are notified when someone views the selected file in the document manager system. There are no errors being generated anywhere and I have debug mode for PHP on.
I think I'll give up on the DMS after today........

9
chromehand
Re: triggerEvent() returns false no matter what
  • 2004/7/20 18:57

  • chromehand

  • Just popping in

  • Posts: 11

  • Since: 2004/6/25


Good news - I managed to get it working through the email -
Somewhere I must have a setting hosed for PM'ing through the notification system.
Either way - Thanks much for all of your help!

After I add all of the file/folder notifications to the module , I'll release it.
Any suggestions as to how I should go about giving it a new version? All of the original GPL stuff is still in there....
I've never 'officially' released anything so any pointers are welcome

Login

Who's Online

138 user(s) are online (70 user(s) are browsing Support Forums)


Members: 0


Guests: 138


more...

Donat-O-Meter

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

Latest GitHub Commits