if this is my function:
<?php
//dsm($query);
function customstatsB_menu() {
$items['customstatsB'] = array(
'title' => 'Maestros Inactivos + email',
'page callback' => 'customstatsB_all',
'access arguments' => array('access customstatsB content'),
'type' => MENU_CALLBACK
);
return $items;
}
/**
* Valid permissions for this module
* @return array An array of valid permissions for the customstats module
* No repetir permisos, este es únicamente un modulo, y cada query NO necesita permisos. PERMISOS A NIVEL MODULE x ROL.
*/
function customstatsB_perm() {
return array('access customstatsB content');
} // function customstats_perm()
//return array('access customstats content', 'administer customstats');
function customstatsB_all() {
/**
* MAESTROS INACTIVOS
*/
$query = "
SELECT name, status, rid, mail
FROM users
JOIN users_roles ON users.uid = users_roles.uid
WHERE mail NOT LIKE '%@hotmail.com'
AND users_roles.rid =6
AND users.status =0
";
// get the links (no range limit here)
$queryResult = db_query($query);
while ($links = db_fetch_object($queryResult)) {
//$page_content .= l($links->name, 'node/'.$links->mail) . '<br />';
$page_content .=
l($links->name, 'mailto:'.$links->mail) . '<br />';
}
// check to see if there was any content before
// returning the page
if ($page_content == '') {
// let the user know there is no content to show
$page_content = "No existe información para mostrar.";
}
return $page_content;
}
return array('access customstatsB content', 'administer customstatsB');
/**
* Email configs
*/
function customstatsB_mail($key, &$message, $params)
{
$params = array(
'subject' => t('SQL Results Tester'),
'body' => t("Body of the email goes here"),
);
drupal_mail("customstatsB", "customstatsB_normal_mail", "[email protected]", language_default(), $params, "[email protected]");
drupal_mail("customstatsB", "customstatsB_html_mail", "[email protected]", language_default(), $params, "[email protected]");
}
$language = $message['language'];
switch ($key)
{
case 'customstats_normal_mail':
$message['subject'] = t($params['subject'], $var, $language->language);
$message['body'][] = $params['body'];
break;
case 'customstats_html_mail':
$message['subject'] = t($params['subject'], $var, $language->language);
$body = "<html><body>
<h2>HTML Email Sample with Drupal</h2>
<hr /><br /><br />
{$params['body']}
</body></html>";
$message['body'][] = $body;
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
break;
}
}
and I am using hook_mail and drupal_mail to send an email, how should I insert the query results into the body of the mail?
Also, I have created pagecallbacks customstats1 to customstats15 via hook_menu and I need to send indivual mails when users visit each page independently. I have read a few tutorials but I haven't been able to do this.
Thanks in advance for your help.