Xataface Email Module 0.2
Email/Mailmerge Module for Xataface
actions/get_email_addresses.php
Go to the documentation of this file.
00001 <?php
00002 class actions_get_email_addresses {
00003         function handle(&$params){
00004                 $app =& Dataface_Application::getInstance();
00005                 $query = $app->getQuery();
00006                 $query['-skip'] = 0;
00007                 $query['-limit'] = 999999999;
00008                 
00009                 $at = Dataface_ActionTool::getInstance();
00010                 $emailAction = $at->getAction(array('name'=>'email'));
00011                 if ( $emailAction ){
00012                         import('Dataface/Ontology.php');
00013                         Dataface_Ontology::registerType('Person', 'Dataface/Ontology/Person.php', 'Dataface_Ontology_Person');
00014                         $ontology = Dataface_Ontology::newOntology('Person', $query['-table']);
00015                         //print_r($ontology->getFieldname('email'));exit;
00016                         $emailAction['email_column'] = $ontology->getFieldname('email');
00017                         
00018                 }
00019                 if ( !isset($emailAction) or !isset($emailAction['email_column']) ){
00020                         return PEAR::raiseError("No email column specified");
00021                 }
00022                 
00023                 
00024                 $col = $emailAction['email_column'];
00025                 
00026                 $qb = new Dataface_QueryBuilder($query['-table'], $query);
00027                 $sql = "select distinct (`".$col."`) `".$col."` ".$qb->_from().$qb->_secure($qb->_where());
00028                 
00029                 $res = mysql_query($sql, df_db());
00030                 if ( !$res ) trigger_error(mysql_error(df_db()), E_USER_ERROR);
00031                 
00032                 $addresses = array();
00033                 while ($row = mysql_fetch_row($res) ) $addresses[] = $row[0];
00034                 @mysql_free_result($res);
00035                 header("Content-type: text/plain");
00036                 echo implode(', ', $addresses);
00037                 exit;
00038                 
00039         }
00040 }
 All Data Structures Files Functions Variables Enumerations