27/10/2010, 00:47:35
Voilà pour recevoir un mail avec les 5 dernières modifications.
Je regarde pour le username.
Code :
$output = '<html><head></head><body><ul>';
$leadin = "Modifié : ";
$number = 5;
$showtitle='true';
$dateformat = "d.m.y h:m";
global $gCms;
$hm =& $gCms->GetHierarchyManager();
$db = &$gCms->db;
$q = "SELECT * FROM ".cms_db_prefix()."content WHERE (type='content' OR type='link')
AND default_content != 1 AND active = 1 AND show_in_menu = 1
ORDER BY modified_date DESC LIMIT 10";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
while ($dbresult && $updated_page = $dbresult->FetchRow())
{
$curnode =& $hm->getNodeById($updated_page['content_id']);
$curcontent =& $curnode->GetContent();
$output .= '<li>';
$output .= '<a href="'.$curcontent->GetURL().'">'.$updated_page['content_name'].'</a>';
if ((FALSE == empty($updated_page['titleattribute'])) && ($showtitle=='true'))
{
$output .= '<br />';
$output .= $updated_page['titleattribute'];
}
$output .= '<br />';
$output .= $leadin;
$output .= date($dateformat,strtotime($updated_page['modified_date']));
$output .= '</li>';
}
$output .= '</ul></body></html>';
$cmsmailer =& $gCms->modules['CMSMailer']['object'];
$cmsmailer->AddAddress('adresse@destinataire.fr');
$cmsmailer->SetFrom('webmaster@site.fr');
$cmsmailer->SetBody($output);
$cmsmailer->IsHTML(true);
$cmsmailer->SetSubject('modification de pages');
$cmsmailer->Send();