36 lines
994 B
PHP
36 lines
994 B
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 17/mar/2016
|
|
*/
|
|
|
|
class GenerateCommentiWarningMailTask extends Task {
|
|
public static function getName(){
|
|
return "generateCommentiWarning";
|
|
}
|
|
|
|
public static function getLabel(){
|
|
return "Genera email su ricezione commenti";
|
|
}
|
|
|
|
public static function execute(){
|
|
$admins = GlobalVariables::get("dao")->query("AdminModel",array("active"=>true));
|
|
|
|
$commenti = GlobalVariables::get("dao")->query("CommentoModel",array("mailSent"=>false),array("limit"=>10));
|
|
|
|
if(sizeof($commenti)>0 && sizeof($admins)>0){
|
|
foreach ($admins as $admin){
|
|
if ($admin->hasRole(AdminModel::ADMIN_TYPE_COMMENTI_SUPERVISOR) && !$admin->hasRole(AdminModel::ADMIN_TYPE_SUPERADMIN)){
|
|
foreach ($commenti as $commento){
|
|
$mail = FDN_MailHelper::getNewCommentoMail($commento,$admin);
|
|
GlobalVariables::get("dao")->save($mail);
|
|
$commento->mailSent = true;
|
|
GlobalVariables::get("dao")->save($commento);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|