Source for file emaillist.php
Documentation is available at emaillist.php
* email lists for instrument users
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* path (bumblebee root)/inc/actions/emaillist.php
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
require_once 'inc/formslib/textfield.php';
require_once 'inc/formslib/checkbox.php';
/** CheckBoxTableList object */
require_once 'inc/formslib/checkboxtablelist.php';
/** db interrogation list object */
require_once 'inc/formslib/dblist.php';
require_once 'inc/formslib/nondbrow.php';
/** export status codes and formats */
require_once 'inc/export/exporttypes.php';
require_once 'inc/actions/actionaction.php';
* Generate a list of email addresses for users of particular instruments
* An Action to find out what instruments the lists should be prepared for
* and then return the email list.
* Designed to be use as a per instrument "announce" list.
* @todo //TODO: should this class should be split some more, with some of the details abstracted?
* forces SQL errors to be fatal
* @param BumblebeeAuth $auth Authorisation object
* @param array $pdata extra state data from the call path
if (! isset
($this->PD['selectlist'])) {
* Generate an HTML form for the user to select which email lists should be used
* - do DB look-ups on what instruments exist
* - construct a table of checkboxes to allow the user to select the lists
$selectRow =
new nonDBRow('listselect', T_('Select email lists'),
T_('Select which email lists you want to return'));
$select->addFollowHidden($hidden);
$announce =
new CheckBox('announce', T_('Announce'));
$select->addCheckBox($announce);
$select->addCheckBox($unbook);
//$select->numSpareCols = 1;
$select->connectDB('instruments', array('id', 'name', 'longname'));
$select->setFormat('id', '%s', array('name'), " %50.50s", array('longname'));
$select->addSelectAllFooter(true);
$selectRow->addElement($select);
$separator =
new TextField('separator', T_('Value separator'),
T_('Separates the returned values so you can paste them into your email client'));
$separator->defaultValue =
',';
$separator->setattr(array('size' =>
'2'));
$selectRow->addElement($separator);
echo
$selectRow->displayInTable(4);
echo
'<input type="hidden" name="selectlist" value="1" />';
echo
'<input type="submit" name="submit" value="'.
T_('Select').
'" />';
* Generate the email lists
* - work out which instruments the user has requested for inclusion
* - construct an SQL query to get the email list
* - return the formatted data to the user
$where =
array('0'); //start the WHERE with 0 in case nothing was selected (always get valid SQL)
$namebase =
'Instrument-';
for ($j=
0; isset
($this->PD[$namebase.
$j.
'-row']); $j++
) {
$instr =
issetSet($this->PD,$namebase.
$j.
'-instrument');
//echo "$j ($instr) => ($unbook, $announce)<br />";
if (issetSet($this->PD,$namebase.
$j.
'-announce')) {
$where[] =
'(permissions.instrid='.
qw($instr).
' AND permissions.announce='.
qw(1).
')' ;
$where[] =
'(permissions.instrid='.
qw($instr).
' AND permissions.unbook='.
qw(1).
')' ;
#echo "Gathering email addresses: $q<br />";
$fields =
array(new sqlFieldName('email', 'Email Address'));
$restriction =
'users.deleted<>1 AND (' .
join($where, ' OR ').
')'; //don't return deleted users
$list =
new DBList('permissions', $fields, $restriction, true);
$list->join[] =
(array('table' =>
'users', 'condition' =>
'users.id=permissions.userid'));
$list->setFormat('%s', array('email'));
if (count($list->data) ==
0) {
echo
'<p>No email addresses found</p>';
if ($this->PD['separator'] ==
'\n') {
$this->PD['separator'] =
"\n";
} elseif ($this->PD['separator'] ==
'\t') {
$this->PD['separator'] =
"\t";
Documentation generated on Tue, 06 Mar 2007 10:01:24 +0000 by phpDocumentor 1.3.0