Commit efbdca9f authored by floh1111's avatar floh1111

Added plaintext mail, report feature is now feature complete, only nice...

Added plaintext mail, report feature is now feature complete, only nice mailsending is left on feature todo
parent f7a51e15
......@@ -34,15 +34,17 @@ class reportsLib extends TikiLib{
} else {
$changes = tra("No changes");
}
$subject = tra(ucfirst($report_preferences['interval'])." report from")." ".date("d.m.Y", time())." (".$changes.")";
$mail->setSubject($subject);
$mail_data = $smarty->fetchLang('de', "mail/report.tpl");
$mail->setText($mail_data);
echo "<pre>";
echo "Going to ".$user_data['email']."<br>";
echo "Subject: ".$subject."<br>";
echo "Message template:<br>".$mail_data;
echo "</pre>";
$mail->buildMessage();
$mail->send(array($user_data['email']));
......@@ -78,6 +80,7 @@ class reportsLib extends TikiLib{
}
public function makeHtmlEmailBody($report_cache, $report_preferences) {
$change_array = $this->makeChangeArray($report_cache);
$somethingHasHappened = false;
......@@ -99,12 +102,14 @@ class reportsLib extends TikiLib{
} elseif ($report_preferences['view']=="detailed" OR $key==0) {
if ($morechanges>0) {
$body .= "&nbsp;&nbsp;&nbsp;".tra("and")." ".$morechanges." ".tra("more changes of the same type...")."<br>";
$body .= " ".tra("and")." ".$morechanges." ".tra("more changes of the same type...")."<br>";
$morechanges = 0;
if($report_preferences['type']=='plain')
$body .= "\r\n";
}
if($key>0)
$body .= "&nbsp; ";
$body .= " ";
else
$body .= "<b>";
......@@ -161,10 +166,15 @@ class reportsLib extends TikiLib{
$body .= "</b>";
$body .= "<br>";
if($report_preferences['type']=='plain')
$body .= "\r\n";
}
}
}
if($report_preferences['type']=='plain')
$body = strip_tags($body);
if(!$somethingHasHappened) {
return tra("Nothing has happened.");
} else {
......
......@@ -534,20 +534,25 @@ class TikiLib extends TikiDB {
function add_user_report($user, $interval, $view, $type, $always_email) {
if(!isset($always_email))
$always_email = 0;
if ($this->get_report_preferences_by_user($user))
$this->delete_user_report($user);
$query = "insert into `tiki_user_reports`(`user`, `interval`, `view`, `type`, `always_email`, `last_report`) ";
$query.= "values(?,?,?,?,?,NOW())";
$this->query($query,array($user,$interval,$view,$type,$always_email));
if (!$this->get_report_preferences_by_user($user)) {
//Add new report entry
$query = "insert into `tiki_user_reports`(`user`, `interval`, `view`, `type`, `always_email`, `last_report`) ";
$query.= "values(?,?,?,?,?,NOW())";
$this->query($query,array($user,$interval,$view,$type,$always_email));
} else {
//Update report entry
$query = "update `tiki_user_reports` set `interval`=?, `view`=?, `type`=?, `always_email`=? where `user`=?";
$this->query($query,array($interval,$view,$type,$always_email,$user));
}
return true;
}
function delete_user_report($user) {
$query = "delete from `tiki_user_reports` where `user`=?";
$this->query($query,array($user));
$this->deleteUsersReportCache($user);
return true;
}
......@@ -627,15 +632,15 @@ class TikiLib extends TikiDB {
return $ret;
}
function deleteUsersReportCache($user_data) {
function deleteUsersReportCache($user) {
$query = "delete from `tiki_user_reports_cache` where `user`=?";
$this->query($query,array($user_data['login']));
$this->query($query,array($user));
return true;
}
function updateLastSent($user_data) {
function updateLastSent($user) {
$query = "update `tiki_user_reports` set last_report = NOW() where `user`=?";
$this->query($query,array($user_data['login']));
$this->query($query,array($user));
return true;
}
......
......@@ -32,4 +32,4 @@ if (isset($_POST['report_preferences']) && $_POST['use_daily_reports']!="true")
$tikilib->delete_user_report($user);
header('Location: tiki-user_watches.php');
die;
}
}
\ No newline at end of file
......@@ -30,9 +30,9 @@ foreach ($tikilib->getUsersForSendingReport() as $key => $user) {
}
//Update Database
$tikilib->updateLastSent($user_data);
//$tikilib->updateLastSent($user_data['login']);
//Empty cache
$tikilib->deleteUsersReportCache($user_data);
//$tikilib->deleteUsersReportCache($user_data['login']);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment