Commit 7526e34d authored by floh1111's avatar floh1111

Reports improved

parent 72206818
......@@ -9419,4 +9419,49 @@ $lang=Array(
"Last pages" => "Letzte Seiten",
"Tiki RSS feed for the wiki pages" => "Tiki RSS Wiki Feed",
"Last modifications to the Wiki." => "Zuletzt geänderte Wikiseiten.",
//Report-Translations (Email)
"changes" => "Änderungen",
"change" => "Änderung",
"No changes" => "Keine Änderungen",
"Daily report from" => "Tägliche Zusammenfassung vom",
"Monthly report from" => "Monatliche Zusammenfassung vom",
"Weekly report from" => "Wöchentliche Zusammenfassung vom",
"Report for" => "Zusammenfassung für",
"Last Report sent on" => "Letzter Report am",
"Changes in detail:" => "Änderungen im Detail:",
"changed the picture gallery" => "Änderte die Bildergalerie",
"uploaded the picture" => "lud das Bild",
"onto" => "nach",
"removed the picture" => "entfernte das Bild",
"edited the wikipage" => "Änderte die Seite",
"this history" => "diese Änderung",
"all history" => "alle Änderungen",
"edited the file gallery" => "änderte das Dateiarchiv",
"Last Report sent on" => "Letzter Report am",
"Last Report sent on" => "Letzter Report am",
"uploaded the file" => "lud die Datei",
"added the file" => "fügte die Datei",
"added the image" => "fügte das Bild",
"added the article" => "fügte den Artikel",
"added the wiki page" => "fügte die Wikiseite",
"to the category" => "zur folgenden Kategorie hinzu:",
"removed the file" => "entfernte die Datei",
"removed the image" => "entfernte das Bild",
"removed the article" => "entfernte den Artikel",
"removed the wiki page" => "entfernte die Wikiseite",
"from the category" => "von der Kategorie",
"created the subcategory" => "erstellte die Unterkategorie",
"removed the subcategory" => "entfernte die Unterkategorie",
"edited the category" => "änderte die Kategorie",
"removed the article" => "löschte den Artikel",
"created the article" => "erstellte den Artikel",
"edited the article" => "Änderte den Artikel",
"replied to the blog" => "antwortete auf den Blog",
"created the topic" => "erstellte das Thema",
"at forum" => "im Forum",
"replied" => "antwortete",
"to the topic" => "auf das Thema",
"Nothing has happened." => "Es wurde nichts gndert",
"more changes of the same type..." => "weitere Änderungen der selben Art...",
//Report-Translations (Email) END
"###end###"=>"###end###");
......@@ -6,8 +6,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
exit;
}
include_once('lib/reportslib.php');
class ArtLib extends TikiLib {
function ArtLib($db) {
$this->TikiLib($db);
......@@ -102,9 +100,8 @@ class ArtLib extends TikiLib {
//Reports added by Clemens John <clemens-john@gmx.de> May 19th 2009
//Pr�fen ob Reports versendet werden d�rfen
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
global $reportslib;
//Benutzer die Reports eingeschaltet haben holen
$report_users = $reportslib->getUsersForReport();
$report_users = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
......@@ -114,7 +111,7 @@ class ArtLib extends TikiLib {
}
}
//Daten in den Reportcache schaufeln
$reportslib->add_report_chache_entries($report_nots, 'article_deleted', array("articleId"=>$articleId, "articleTitle"=>$article_data['title'], "authorName"=>$article_data['authorName'], "user"=>$user));
$tikilib->add_report_chache_entries($report_nots, 'article_deleted', array("articleId"=>$articleId, "articleTitle"=>$article_data['title'], "authorName"=>$article_data['authorName'], "user"=>$user));
}
if (count($nots) || is_array($emails)) {
......@@ -331,12 +328,12 @@ class ArtLib extends TikiLib {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
global $prefs, $reportslib;
global $prefs;
//Reports added by Clemens John <clemens-john@gmx.de> May 19th 2009
//Pr�fen ob Reports versendet werden d�rfen
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
//Benutzer die Reports eingeschaltet haben holen
$report_users = $reportslib->getUsersForReport();
$report_users = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
......@@ -346,7 +343,7 @@ class ArtLib extends TikiLib {
}
}
//Daten in den Reportcache schaufeln
$reportslib->add_report_chache_entries($report_nots, $event, array("articleId"=>$articleId, "articleTitle"=>$title, "authorName"=>$authorName, "user"=>$user));
$tikilib->add_report_chache_entries($report_nots, $event, array("articleId"=>$articleId, "articleTitle"=>$title, "authorName"=>$authorName, "user"=>$user));
}
if (count($nots) || is_array($emails)) {
......
......@@ -284,13 +284,11 @@ class BlogLib extends TikiLib {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
include_once ('lib/reportslib.php');
//Reports added by Clemens John <clemens-john@gmx.de> May 19th 2009
//Pr�fen ob Reports versendet werden d�rfen
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
//Benutzer die Reports eingeschaltet haben holen
$report_users = $reportslib->getUsersForReport();
$report_users = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
......@@ -302,7 +300,7 @@ class BlogLib extends TikiLib {
//Daten in den Reportcache schaufeln
$query = "select `title` from `tiki_blogs` where `blogId`=?";
$blogTitle = $this->getOne($query, array((int)$blogId));
$reportslib->add_report_chache_entries($report_nots, 'blog_post', array("blogId"=>$blogId, "blogTitle"=>$blogTitle, "postId"=>$id, "user"=>$user));
$tikilib->add_report_chache_entries($report_nots, 'blog_post', array("blogId"=>$blogId, "blogTitle"=>$blogTitle, "postId"=>$id, "user"=>$user));
}
if (count($nots)) {
......
......@@ -909,13 +909,11 @@ class ImageGalsLib extends TikiLib {
$event = 'image_gallery_changed';
$nots = $this->get_event_watches($event, $galleryId);
include_once ('lib/reportslib.php');
//Reports added by Clemens John <clemens-john@gmx.de> May 19th 2009
//Pr�fen ob Reports versendet werden d�rfen
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
//Benutzer die Reports eingeschaltet haben holen
$report_users = $reportslib->getUsersForReport();
$report_users = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
......@@ -926,7 +924,7 @@ class ImageGalsLib extends TikiLib {
}
//Daten in den Reportcache schaufeln
$reportslib->add_report_chache_entries($report_nots, $event, array("imageId"=>$imageId, "imageName"=>$name, "fileName"=>$filename, "galleryId"=>$galleryId, "galleryName"=>$galleryName, "action"=>$action, "user"=>$user));
$tikilib->add_report_chache_entries($report_nots, $event, array("imageId"=>$imageId, "imageName"=>$name, "fileName"=>$filename, "galleryId"=>$galleryId, "galleryName"=>$galleryName, "action"=>$action, "user"=>$user));
}
include_once('lib/notifications/notificationemaillib.php');
......
......@@ -9,8 +9,6 @@
* \param $topicName name of the parent topic
*/
include_once ('lib/reportslib.php');
function sendForumEmailNotification($event, $object, $forum_info, $title, $data, $author, $topicName, $messageId='', $inReplyTo='', $threadId, $parentId, $contributions='', $postId='') {
global $tikilib, $prefs, $smarty, $userlib;
......@@ -107,9 +105,8 @@ function sendForumEmailNotification($event, $object, $forum_info, $title, $data,
//Reports added by Clemens John <clemens-john@gmx.de> May 19th 2009
//Pr�fen ob Reports versendet werden d�rfen
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
global $reportslib;
//Benutzer die Reports eingeschaltet haben holen
$report_users = $reportslib->getUsersForReport();
$report_users = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
......@@ -119,7 +116,7 @@ function sendForumEmailNotification($event, $object, $forum_info, $title, $data,
}
}
//Daten in den Reportcache schaufeln
$reportslib->add_report_chache_entries($report_nots, $event, array("forumId"=>$forum_info['forumId'], "forumName"=>$forum_info['name'], "topicId"=>$threadId, "threadId"=>$postId, "threadName"=>$topicName, "user"=>$author));
$tikilib->add_report_chache_entries($report_nots, $event, array("forumId"=>$forum_info['forumId'], "forumName"=>$forum_info['name'], "topicId"=>$threadId, "threadId"=>$postId, "threadName"=>$topicName, "user"=>$author));
}
if (count($nots)) {
......@@ -235,9 +232,8 @@ function sendWikiEmailNotification($event, $pageName, $edit_user, $edit_comment,
//Reports added by Clemens John <clemens-john@gmx.de> May 19th 2009
//Pr�fen ob Reports versendet werden d�rfen
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
global $reportslib;
//Benutzer die Reports eingeschaltet haben holen
$report_users = $reportslib->getUsersForReport();
$report_users = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
......@@ -248,7 +244,7 @@ function sendWikiEmailNotification($event, $pageName, $edit_user, $edit_comment,
}
//Daten in den Reportcache schaufeln
$reportslib->add_report_chache_entries($report_nots, $event, array("pageName"=>$pageName, "object"=>$pageName, "editUser"=>$edit_user, "editComment"=>$edit_comment, "oldVer"=>$oldver));
$tikilib->add_report_chache_entries($report_nots, $event, array("pageName"=>$pageName, "object"=>$pageName, "editUser"=>$edit_user, "editComment"=>$edit_comment, "oldVer"=>$oldver));
}
if (count($nots)) {
......@@ -388,9 +384,8 @@ function sendFileGalleryEmailNotification($event, $galleryId, $galleryName, $nam
//Reports added by Clemens John <clemens-john@gmx.de> May 19th 2009
//Pr�fen ob Reports versendet werden d�rfen
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
global $reportslib;
//Benutzer die Reports eingeschaltet haben holen
$report_users = $reportslib->getUsersForReport();
$report_users = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
......@@ -401,7 +396,7 @@ function sendFileGalleryEmailNotification($event, $galleryId, $galleryName, $nam
}
//Daten in den Reportcache schaufeln
$reportslib->add_report_chache_entries($report_nots, $event, array("name"=>$name, "fileId"=>$fileId, "fileName"=>$filename, "galleryId"=>$galleryId, "galleryName"=>$galleryName, "action"=>$action, "user"=>$user));
$tikilib->add_report_chache_entries($report_nots, $event, array("name"=>$name, "fileId"=>$fileId, "fileName"=>$filename, "galleryId"=>$galleryId, "galleryName"=>$galleryName, "action"=>$action, "user"=>$user));
}
if (count($nots)) {
......@@ -486,9 +481,8 @@ function sendCategoryEmailNotification($values) {
//Reports added by Clemens John <clemens-john@gmx.de> May 19th 2009
//Pr�fen ob Reports versendet werden d�rfen
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
global $reportslib;
//Benutzer die Reports eingeschaltet haben holen
$report_users = $reportslib->getUsersForReport();
$report_users = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
......@@ -500,7 +494,7 @@ function sendCategoryEmailNotification($values) {
//Daten in den Reportcache schaufeln
$values['user'] = $user;
$reportslib->add_report_chache_entries($report_nots, $event, $values);
$tikilib->add_report_chache_entries($report_nots, $event, $values);
}
if (count($nots)) {
......
This diff is collapsed.
......@@ -531,6 +531,113 @@ class TikiLib extends TikiDB {
return $ret;
}
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));
return true;
}
function delete_user_report($user) {
$query = "delete from `tiki_user_reports` where `user`=?";
$this->query($query,array($user));
return true;
}
function get_report_preferences_by_user($user) {
$query = "select `id`, `interval`, `view`, `type`, `always_email`, `last_report` from `tiki_user_reports` where `user` = ?";
$result = $this->query($query, array($user));
if (!$result->numRows()) {
return false;
}
$ret = array();
while ($res = $result->fetchRow()) {
$ret = $res;
}
return $ret;
}
function getUsersForReport() {
$query = "select `user`, `interval`, `last_report` from tiki_user_reports";
$result = $this->query($query);
if (!$result->numRows()) {
return false;
}
$ret = array();
while ($res = $result->fetchRow()) {
$ret[] = $res['user'];
}
return $ret;
}
function getUsersForSendingReport() {
$query = "select `user`, `interval`, UNIX_TIMESTAMP(`last_report`) as last_report from tiki_user_reports";
$result = $this->query($query);
if (!$result->numRows()) {
return false;
}
$ret = array();
while ($res = $result->fetchRow()) {
if ($res['interval']=="daily" AND ($res['last_report']+86400)<=time()) {
$ret[] = $res['user'];
}
if ($res['interval']=="weekly" AND ($res['last_report']+604800)<=time()) {
$ret[] = $res['user'];
}
if ($res['interval']=="monthly" AND ($res['last_report']+2419200)<=time()) {
$ret[] = $res['user'];
}
}
return $ret;
}
function add_report_chache_entries($users, $event, $data) {
foreach ($users as $user) {
$query = "insert into `tiki_user_reports_cache`(`user`, `event`, `data`,`time`) ";
$query.= "values(?,?,?,NOW())";
$this->query($query,array($user, $event, serialize($data)));
}
return true;
}
function get_report_cache_entries_by_user($user, $order_by) {
$query = "select `user`, `event`, `data`, `time` from `tiki_user_reports_cache` where `user` = ? ORDER BY $order_by";
$result = $this->query($query, array($user));
if (!$result->numRows()) {
return false;
}
$ret = array();
while ($res = $result->fetchRow()) {
$res['data'] = unserialize($res['data']);
$ret[] = $res;
}
return $ret;
}
function deleteUsersReportCache($user_data) {
$query = "delete from `tiki_user_reports_cache` where `user`=?";
$this->query($query,array($user_data['login']));
return true;
}
function updateLastSent($user_data) {
$query = "update `tiki_user_reports` set last_report = NOW() where `user`=?";
$this->query($query,array($user_data['login']));
return true;
}
/*shared*/
function dir_stats() {
$aux = array();
......
Report for {$report_user}.<br><!--{$report_interval}-Report from {$report_date};-->
Last Report sent on {$report_last_report_date}.<br><br>
<!--Total changes: {$report_total_changes};-->
<u>Changes in detail:</u><br>
{tr}Report for{/tr} {$report_user}.<br>
{tr}Last Report sent on{/tr} {$report_last_report_date}.<br><br>
<u>{tr}Changes in detail:{/tr}</u><br>
{$report_body}
{if $mail_contributions}{tr}Contribution{/tr}: {$mail_contributions}{/if}
\ No newline at end of file
......@@ -22,14 +22,14 @@ include_once ('lib/reportslib.php');
//Enable User Report
if (isset($_POST['report_preferences']) && $_POST['use_daily_reports']=="true") {
$reportslib->add_user_report($user,$_POST['interval'],$_POST['view'],$_POST['type'], $_POST['always_email']);
$tikilib->add_user_report($user,$_POST['interval'],$_POST['view'],$_POST['type'], $_POST['always_email']);
header('Location: tiki-user_watches.php');
die;
}
//Enable User Report
if (isset($_POST['report_preferences']) && $_POST['use_daily_reports']!="true") {
$reportslib->delete_user_report($user);
$tikilib->delete_user_report($user);
header('Location: tiki-user_watches.php');
die;
}
......
......@@ -20,22 +20,23 @@ include_once ('lib/imagegals/imagegallib.php');
include_once ('lib/imagegals/imagegallib.php');
include_once ('lib/reportslib.php');
foreach ($reportslib->getUsersForReport() as $key => $user) {
$report_preferences = $reportslib->get_report_preferences_by_user($user);
foreach ($tikilib->getUsersForSendingReport() as $key => $user) {
$report_preferences = $tikilib->get_report_preferences_by_user($user);
$user_data = $userlib->get_user_info($user);
//Wenn keine Emailadresse gesetzt ist, mache nichts und leere den Cache
if (!empty($user_data['email'])) {
//Hole Cache
$report_cache = $reportslib->get_report_cache_entries_by_user($user, "time ASC");
$report_cache = $tikilib->get_report_cache_entries_by_user($user, "time ASC");
//Schicke Email wenn: Einträge vorhanden oder always_email = true
if ($report_cache OR (!$report_cache && $report_preferences['always_email']))
$reportslib->sendEmail($user_data, $report_preferences, $report_cache);
}
//LastReportSent updaten
$tikilib->updateLastSent($user_data);
//Cache leeren
// $reportslib->deleteUsersReportCache($user_data);
//Last Report send setzen
$reportslib->updateLastSent($user_data);
$tikilib->deleteUsersReportCache($user_data);
}
......
......@@ -8,7 +8,6 @@
$section = 'mytiki';
include_once ('tiki-setup.php');
include_once ('lib/reportslib.php');
if ($prefs['feature_ajax'] == "y") {
require_once ('lib/ajax/ajaxlib.php');
......@@ -170,7 +169,7 @@ user_watches_ajax();
$smarty->assign("mootab",'y');
}
$report_preferences = $reportslib->get_report_preferences_by_user($user);
$report_preferences = $tikilib->get_report_preferences_by_user($user);
if ($report_preferences) {
$smarty->assign_by_ref('report_preferences', $report_preferences);
}
......
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