2015-04-06 01:12:06 -07:00
< ? php
/*
* e107 website system
*
* Copyright ( C ) 2008 - 2015 e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*/
if ( ! defined ( 'e107_INIT' )) { exit ; }
class faqs_cron // include plugin-folder in the name.
{
function config ()
{
$cron = array ();
$cron [] = array (
'name' => " Unanswered Questions Report " , //TODO LAN
'function' => " unanswered " ,
2015-04-06 13:59:15 -07:00
'category' => " notify " ,
2015-04-06 01:12:06 -07:00
'description' => " Mails a report of unanswered questions to " . e107 :: pref ( 'core' , 'siteadminemail' ) . '.' // TODO LAN
);
return $cron ;
}
function unanswered ()
{
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2015-06-19 09:52:29 -07:00
$limit = 25 ;
2015-04-06 01:12:06 -07:00
2015-06-19 09:52:29 -07:00
$count = $sql -> retrieve ( 'faqs' , 'faq_id' , " faq_answer='' " , true );
$existing = $sql -> retrieve ( 'faqs' , 'faq_id,faq_question,faq_datestamp' , " faq_answer='' ORDER BY faq_datestamp DESC LIMIT " . $limit , true );
2015-04-06 01:12:06 -07:00
if ( empty ( $existing ))
{
return ;
}
$questions = array ();
foreach ( $existing as $row )
{
2015-06-19 09:52:29 -07:00
$questions [] = " <i> " . $row [ 'faq_question' ] . " </i><br /><small> " . $tp -> toDate ( $row [ 'faq_datestamp' ], 'short' ) . " </small> \n " ;
// $questions[] = $row['faq_question'];
2015-04-06 01:12:06 -07:00
}
2015-06-19 09:52:29 -07:00
//
// $questions = array( "<i>Test Question</i><br /><small>".$tp->toDate(time(),'short')."</small>");
2015-04-06 01:12:06 -07:00
$name = SITENAME . " Automation " ;
$email = e107 :: pref ( 'core' , 'siteadminemail' );
$name = e107 :: pref ( 'core' , 'siteadmin' );
2015-05-28 09:47:28 -07:00
$link = $tp -> replaceConstants ( " { e_PLUGIN}faqs/admin_config.php?mode=main&action=list&filter=pending " , 'full' );
2015-04-06 01:12:06 -07:00
2015-06-19 09:52:29 -07:00
$body = " <h2> " . count ( $count ) . " Unuanswered Questions at " . SITENAME . " </h2>To answer these questions, please login to " . SITENAME . " and then <a href=' { $link } '>click here</a>.<br />
The " . $limit . " most recent questions are displayed below .
< ul >< li > " .implode( " </ li >< li > " , $questions ). " </ li ></ ul > " ;
2015-04-06 01:12:06 -07:00
$eml = array (
2015-06-19 09:56:13 -07:00
'subject' => count ( $count ) . " Unuanswered Question as of " . date ( 'd-M-Y' ) . " " ,
2015-04-06 01:12:06 -07:00
// 'sender_email' => $email,
'sender_name' => SITENAME . " Automation " ,
// 'replyto' => $email,
'html' => true ,
'template' => 'default' ,
2015-06-19 09:52:29 -07:00
'body' => $body
2015-04-06 01:12:06 -07:00
);
e107 :: getEmail () -> sendEmail ( $email , $name , $eml );
}
}
?>