Bulkmail extension and db query

Author Message

Claus Jensen

Monday 12 January 2004 3:28:47 am

Hi,
I have started making a bulkmail extension. But when I try to fetch something from the database in one of my php files I get this error message:
Fatal error: Call to a member function on a non-object in /opt/ezpublish/3.2.4/extension/bulkmail/modules/bulkmail/sendmail.php on line 29
Fatal error: eZ publish did not finish it's request

It seems $db is not an object. How do I get the $db object so I can query the dataase in my module? Here is the code:
<?php

include_once( "kernel/common/template.php" );

include_once( "lib/ezutils/classes/ezdebug.php" );
include_once( "lib/ezutils/classes/ezmodule.php" );
eZmodule::setGlobalPathList( array("kernel") );
include_once( "lib/ezutils/classes/ezhttptool.php" );
include_once( "lib/ezutils/classes/ezini.php" );
//eZini::setIsCacheEnabled( false );
include_once( "lib/ezutils/classes/ezexecution.php" );

$db = null;
$db &= eZDB::instance();

$http =& eZHTTPTool::instance();
$tpl =& templateInit();

$from_email = $http->variable("from");
$from_name = $http->variable("from_name");
$to = $http->variable("togroup");
This is line 29:
$rows =& $db->arrayQuery( "SELECT * FROM ezsite_data" );

Any ideas??

regards,
claÜs

Claus Jensen

Tuesday 13 January 2004 4:12:21 am

Hello,
I cant believe that nobody knows how to make a correct db-connection in a ezpublish extension. NOBODY? Please check my last message...
regards,
claÜs

Willie Seabrook

Wednesday 14 January 2004 9:09:56 pm

There is a problem there... I remember having the exact same one myself I just can't remember how I fixed it. Sorry. But this is how I do it (taken from working code, that I've long forgotten how it works) You can get the db params from site.ini if you need. I just know I figured out why you can't just get the db straight up but damnit I just can't remember.

$params = array('server' => 'localhost',
'user' => 'root',
'password' => 'thisismypassword',
'database' => 'ez',
'use_slave_server' => 'false',
'slave_server' => '',
'slave_user' => '',
'slave_password' => '',
'slave_database' => '',
'charset' => '',
'socket' => '',
'builtin_encoding' => '',
'connect_retries' => '',
'use_persistent_connection' => false);

$db = eZDb::instance('ezmysql', $params, true);

.... do all your stuff

Oh yeah and I have myself built a bulk mail extension to ez operating using workflows though, not its own module. Ie the user can choose to bulk mail an object to a list after they publish it. Which is quite usefull if I might say so... ;-)

Regards,
Willie

Claus Jensen

Thursday 15 January 2004 3:40:46 am

Hi Willie,
It worked!! Thanks! By the way the workflow bulkmail you built is it public, do it contain any php coding and was is difficult?

cheers,
claÜs

Eirik Alfstad Johansen

Thursday 15 January 2004 4:53:17 am

Wow, that sounds like an awesome event, Willie! I too would love to see this, or perhaps get some hints as to how it was built.

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Willie Seabrook

Thursday 15 January 2004 3:05:18 pm

The bulk mail part was easy, it was getting the content | publish event to allow the fetching of a template to work that was the hard bit. It is built around this and since the fetch template stuff is very hacky I'm not sure if I'll release it - most people would probably find it mucks up their system.

Regards,
Willie

Paul Borgermans

Friday 16 January 2004 5:41:52 am

Something similar will be posted by Hans and Tom soon: ad hoc distribution lists for use in post-publishing events. That is after tests proved it works with the ezmultiplexer workflow (it already works without).

It is taylored to what we need locally, but we also try to make it useful enough to cover a larger scope too.

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Hans Melis

Friday 16 January 2004 6:47:00 am

Actually, Tom is preparing a little readme for the "bulkmail" event. Our tests of the event after an ezmultiplexer redirection have been succesful.

The event will use one or more attributes of a class and search for email addresses in that text (e.g. a class containing the ezauthor datatype).

--
Hans

Hans
http://blog.hansmelis.be

Hans Melis

Friday 16 January 2004 7:03:52 am

The workflow event has been posted: http://ez.no/developer/ez_publish_3/contributions/mailinglist_workflow_event

It's mostly suited to our needs, but it should work as a general solution as well.

--
Hans

Hans
http://blog.hansmelis.be

Eirik Alfstad Johansen

Monday 26 January 2004 12:37:36 am

Hi Hans,

Thanks for making your mailinglist extension available to the public. Having just installed it, I have a few questions regarding this extension.

First of all, I'm confused about the parent node/current node setting. If I have understood it correctly (which I don't think I have), selecting "current node" will publish the current node as an email, and selecting "parent node" will publish the parent node of the current node as an email. However, why would one want to publish the parent node?

Also, I assumed that the extension fetched email address from a list of objects (like objects of the user class) but that doesn't seems to be the case. Are the recipients instead stored as part of the published object?

Thanks in advance for clearing things up !

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Claus Jensen

Monday 26 January 2004 12:49:07 am

Hi,
I wanted do download, or at least check the link to Hans's article: http://ez.no/developer/ez_publish...ributions/mailinglist_workflow_event but I get module not found. I believe this is happening after the new sitelayout of ez.no, could you please correct the link ez???

regards,
claÜs

Eirik Alfstad Johansen

Monday 26 January 2004 1:01:01 am

Meanwhile, here's the correct link:

http://ez.no/community/contributions/workflow/mailinglist_workflow_event

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Claus Jensen

Monday 26 January 2004 1:28:54 am

Thanks Eirik,
I already figured that I actually could navigate there myself ;) So I have checked it out, but thanks anyway for guidance.

claÜs

Paul Borgermans

Monday 26 January 2004 6:45:46 am

Hi Eirik,

About the confusion on "this node" or "parent node": it only refers to the link that is sent out which can be a parent node or the node itself. The first (parent node) is useful if you want to "attach" a distribution list to a node as child. The latter (this node) is useful if the distribution list is part of the object you want to send out an email . For the rest you need to configure the attribute which contains the email adresses and which can be for example a list based on the author datatype or even a text field where you typed a series of email addresses.

Please note it works ouside the notification system since you can configure to send out emails on first publishing only or also when updates are done.

Hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.