Commit 57bbf0be authored by floh1111's avatar floh1111

Factorized the code and translated comments to englisch (Nyloth), added more...

Factorized the code and translated comments to englisch (Nyloth), added more transaltion an added SQL-Querrys to tiki.sql but the conversionscript does not work
parent 0e843f59
......@@ -2674,29 +2674,6 @@ CREATE TABLE tiki_user_watches (
PRIMARY KEY (`user`(50),event,object(100),email(50))
) ENGINE=MyISAM;
DROP TABLE IF EXISTS `tiki_user_reports`;
CREATE TABLE IF NOT EXISTS `tiki_user_reports` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(200) COLLATE latin1_general_ci NOT NULL,
`interval` varchar(20) COLLATE latin1_general_ci NOT NULL,
`view` varchar(8) COLLATE latin1_general_ci NOT NULL,
`type` varchar(5) COLLATE latin1_general_ci NOT NULL,
`time_to_send` datetime NOT NULL,
`always_email` tinyint(1) NOT NULL,
`last_report` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
DROP TABLE IF EXISTS `tiki_user_reports_cache`;
CREATE TABLE IF NOT EXISTS `tiki_user_reports_cache` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(200) COLLATE latin1_general_ci NOT NULL,
`event` varchar(200) COLLATE latin1_general_ci NOT NULL,
`data` text COLLATE latin1_general_ci NOT NULL,
`time` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
DROP TABLE IF EXISTS tiki_userfiles;
CREATE TABLE tiki_userfiles (
user varchar(200) NOT NULL default '',
......
......@@ -3863,3 +3863,25 @@ CREATE TABLE tiki_plugin_security (
KEY last_object (last_objectType, last_objectId)
);
DROP TABLE IF EXISTS `tiki_user_reports`;
CREATE TABLE IF NOT EXISTS `tiki_user_reports` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(200) COLLATE latin1_general_ci NOT NULL,
`interval` varchar(20) COLLATE latin1_general_ci NOT NULL,
`view` varchar(8) COLLATE latin1_general_ci NOT NULL,
`type` varchar(5) COLLATE latin1_general_ci NOT NULL,
`time_to_send` datetime NOT NULL,
`always_email` tinyint(1) NOT NULL,
`last_report` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
DROP TABLE IF EXISTS `tiki_user_reports_cache`;
CREATE TABLE IF NOT EXISTS `tiki_user_reports_cache` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(200) COLLATE latin1_general_ci NOT NULL,
`event` varchar(200) COLLATE latin1_general_ci NOT NULL,
`data` text COLLATE latin1_general_ci NOT NULL,
`time` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
\ No newline at end of file
......@@ -9463,5 +9463,17 @@ $lang=Array(
"to the topic" => "auf das Thema",
"Nothing has happened." => "Es wurde nichts gndert",
"more changes of the same type..." => "weitere Änderungen der selben Art...",
"Use reports to summarise notifications about objects you are watching." => "Nutze Reports um Notifikations in einer Email zusammenzufassen.",
"Interval in witch you want to get the reports" => "Intervall in dem dir Reports gesendet werden sollen",
"Use reports" => "Reports benutzen",
"Short report" => "Kurzer Report",
"Detailed report" => "Detailierter Report",
"HTML-Email" => "HTML-Email",
"Plain text" => "Nur Text",
"Send me an email also if nothing happened" => "Schicke mir eine Email, auch wenn nichts passiert ist",
"Reports are disabled, only standard reporting is available" => "Reports sind ausgeschaltet, nur Standart-Reporting ist verfgbar",
//Report-Translations (Email) END
"###end###"=>"###end###");
......@@ -97,21 +97,8 @@ class ArtLib extends TikiLib {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
//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 = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
if (in_array($not['user'], $report_users)) {
$report_nots[] = $not['user'];
unset($nots[$key]);
}
}
//Daten in den Reportcache schaufeln
$tikilib->add_report_chache_entries($report_nots, 'article_deleted', array("articleId"=>$articleId, "articleTitle"=>$article_data['title'], "authorName"=>$article_data['authorName'], "user"=>$user));
$tikilib->makeReportCache($nots, array("event"=>'article_deleted', "articleId"=>$articleId, "articleTitle"=>$article_data['title'], "authorName"=>$article_data['authorName'], "user"=>$user));
}
if (count($nots) || is_array($emails)) {
......@@ -329,21 +316,8 @@ class ArtLib extends TikiLib {
}
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 = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
if (in_array($not['user'], $report_users)) {
$report_nots[] = $not['user'];
unset($nots[$key]);
}
}
//Daten in den Reportcache schaufeln
$tikilib->add_report_chache_entries($report_nots, $event, array("articleId"=>$articleId, "articleTitle"=>$title, "authorName"=>$authorName, "user"=>$user));
$tikilib->makeReportCache($nots, array("event"=>$event, "articleId"=>$articleId, "articleTitle"=>$title, "authorName"=>$authorName, "user"=>$user));
}
if (count($nots) || is_array($emails)) {
......
......@@ -283,24 +283,11 @@ class BlogLib extends TikiLib {
if (!isset($_SERVER["SERVER_NAME"])) {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
//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 = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
if (in_array($not['user'], $report_users)) {
$report_nots[] = $not['user'];
unset($nots[$key]);
}
}
//Daten in den Reportcache schaufeln
if ($prefs['feature_daily_report_watches'] == 'y') {
$query = "select `title` from `tiki_blogs` where `blogId`=?";
$blogTitle = $this->getOne($query, array((int)$blogId));
$tikilib->add_report_chache_entries($report_nots, 'blog_post', array("blogId"=>$blogId, "blogTitle"=>$blogTitle, "postId"=>$id, "user"=>$user));
$tikilib->makeReportCache($nots, array("event"=>'blog_post', "blogId"=>$blogId, "blogTitle"=>$blogTitle, "postId"=>$id, "user"=>$user));
}
if (count($nots)) {
......
......@@ -909,22 +909,8 @@ class ImageGalsLib extends TikiLib {
$event = 'image_gallery_changed';
$nots = $this->get_event_watches($event, $galleryId);
//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 = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
if (in_array($not['user'], $report_users)) {
$report_nots[] = $not['user'];
unset($nots[$key]);
}
}
//Daten in den Reportcache schaufeln
$tikilib->add_report_chache_entries($report_nots, $event, array("imageId"=>$imageId, "imageName"=>$name, "fileName"=>$filename, "galleryId"=>$galleryId, "galleryName"=>$galleryName, "action"=>$action, "user"=>$user));
if ($prefs['feature_daily_report_watches'] == 'y') {
$tikilib->makeReportCache($nots, array("event"=>$event, "imageId"=>$imageId, "imageName"=>$name, "fileName"=>$filename, "galleryId"=>$galleryId, "galleryName"=>$galleryName, "action"=>$action, "user"=>$user));
}
include_once('lib/notifications/notificationemaillib.php');
......
......@@ -101,22 +101,9 @@ function sendForumEmailNotification($event, $object, $forum_info, $title, $data,
$not['language'] = $defaultLanguage;
$nots[] = $not;
}
//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 = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
if (in_array($not['user'], $report_users)) {
$report_nots[] = $not['user'];
unset($nots[$key]);
}
}
//Daten in den Reportcache schaufeln
$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));
$tikilib->makeReportCache($nots, array("event"=>$event, "forumId"=>$forum_info['forumId'], "forumName"=>$forum_info['name'], "topicId"=>$threadId, "threadId"=>$postId, "threadName"=>$topicName, "user"=>$author));
}
if (count($nots)) {
......@@ -229,22 +216,8 @@ function sendWikiEmailNotification($event, $pageName, $edit_user, $edit_comment,
if ($edit_user=='') $edit_user = tra('Anonymous');
//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 = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
if (in_array($not['user'], $report_users)) {
$report_nots[] = $not['user'];
unset($nots[$key]);
}
}
//Daten in den Reportcache schaufeln
$tikilib->add_report_chache_entries($report_nots, $event, array("pageName"=>$pageName, "object"=>$pageName, "editUser"=>$edit_user, "editComment"=>$edit_comment, "oldVer"=>$oldver));
$tikilib->makeReportCache($nots, array("event"=>$event, "pageName"=>$pageName, "object"=>$pageName, "editUser"=>$edit_user, "editComment"=>$edit_comment, "oldVer"=>$oldver));
}
if (count($nots)) {
......@@ -379,26 +352,12 @@ function sendFileGalleryEmailNotification($event, $galleryId, $galleryName, $nam
for ($i = count($nots) - 1; $i >=0; --$i) {
$nots[$i]['language'] = $tikilib->get_user_preference($nots[$i]['user'], "language", $defaultLanguage);
}
if ($prefs['feature_daily_report_watches'] == 'y') {
$tikilib->makeReportCache($nots, array("event"=>$event, "name"=>$name, "fileId"=>$fileId, "fileName"=>$filename, "galleryId"=>$galleryId, "galleryName"=>$galleryName, "action"=>$action, "user"=>$user));
}
}
//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 = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
if (in_array($not['user'], $report_users)) {
$report_nots[] = $not['user'];
unset($nots[$key]);
}
}
//Daten in den Reportcache schaufeln
$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)) {
include_once('lib/webmail/tikimaillib.php');
$mail = new TikiMail();
......@@ -476,25 +435,14 @@ function sendCategoryEmailNotification($values) {
for ($i = count($nots) - 1; $i >=0; --$i) {
$nots[$i]['language'] = $tikilib->get_user_preference($nots[$i]['user'], "language", $defaultLanguage);
}
}
//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 = $tikilib->getUsersForReport();
//Benutzer die Reports eingeschaltet haben in das Report-Array verschieben.
foreach ($nots as $key=>$not) {
if (in_array($not['user'], $report_users)) {
$report_nots[] = $not['user'];
unset($nots[$key]);
}
if ($prefs['feature_daily_report_watches'] == 'y') {
$cache_data = $values;
$cache_data['user'] = $user;
$cache_data['event'] = $event;
$tikilib->makeReportCache($nots, $cache_data);
}
//Daten in den Reportcache schaufeln
$values['user'] = $user;
$tikilib->add_report_chache_entries($report_nots, $event, $values);
}
if (count($nots)) {
......
......@@ -5,7 +5,7 @@ class reportsLib extends TikiLib{
$this->TikiLib($db);
}
//Fügt die verscheidenen Emailteile zusammen
//Sends the Email
public function sendEmail($user_data, $report_preferences, $report_cache) {
global $prefs, $smarty;
......@@ -57,7 +57,7 @@ class reportsLib extends TikiLib{
return true;
}
//Erstellt eine schöne Zeitangabe
//Makes time short
private function makeTime($time) {
if (date("d.m.Y", $time)==date("d.m.Y", time()-86400)) {
return tra("Yesterday")." ".date("H:i", $time);
......
......@@ -565,20 +565,6 @@ class TikiLib extends TikiDB {
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);
......@@ -601,16 +587,31 @@ class TikiLib extends TikiDB {
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)));
function makeReportCache(&$nots, $cache_data) {
//Get all users that have enabled reports
$query = "select `user` from tiki_user_reports";
$result = $this->query($query);
$report_users = array();
while ($res = $result->fetchRow()) {
$report_users[] = $res['user'];
}
return true;
foreach ($nots as $key=>$not) {
//If user in $nots has enabled reports
if (in_array($not['user'], $report_users)) {
//dump the report-data to the report cache
$query = "insert into `tiki_user_reports_cache`(`user`, `event`, `data`,`time`) ";
$query.= "values(?,?,?,NOW())";
$this->query($query,array($not['user'], $cache_data['event'], serialize($cache_data)));
//and reove the user from $nots so that he doesn´t get a notification for the event
unset($nots[$key]);
}
}
}
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));
......
......@@ -5,37 +5,37 @@
<h2>Report Preferences</h2>
{if $prefs.feature_daily_report_watches eq 'y'}
{remarksbox type="tip" title="{tr}Tip{/tr}"}{tr}Use "reports" to summarise notifications about objects you are watching.{/tr}{/remarksbox}
{remarksbox type="tip" title="{tr}Tip{/tr}"}{tr}Use reports to summarise notifications about objects you are watching.{/tr}{/remarksbox}
<form action="tiki-user_reports.php" method="post" id='formi'>
<input type="hidden" name="report_preferences" value="true"/>
<p><input type="checkbox" name="use_daily_reports" value="true" {if $report_preferences != false}checked{/if}/> Use reports</p>
<p><input type="checkbox" name="use_daily_reports" value="true" {if $report_preferences != false}checked{/if}/> {tr}Use reports{/tr}</p>
<p>
Interval in witch you want to get the reports
{tr}Interval in witch you want to get the reports{/tr}
<select name="interval">
<option value="daily" {if $report_preferences.interval eq "daily"}selected{/if}>{tr}daily{/tr}</option>
<option value="weekly" {if $report_preferences.interval eq "weekly"}selected{/if}>{tr}weekly{/tr}</option>
<option value="monthly" {if $report_preferences.interval eq "monthly"}selected{/if}>{tr}monthly{/tr}</option>
<option value="daily" {if $report_preferences.interval eq "daily"}selected{/if}>{tr}Daily{/tr}</option>
<option value="weekly" {if $report_preferences.interval eq "weekly"}selected{/if}>{tr}Weekly{/tr}</option>
<option value="monthly" {if $report_preferences.interval eq "monthly"}selected{/if}>{tr}Monthly{/tr}</option>
</select>
</p>
<div style="float:left; margin-right: 50px;">
<input type="radio" name="view" value="short" {if $report_preferences.view eq "short"}checked{/if}> Short report<br>
<input type="radio" name="view" value="detailed" {if $report_preferences.view eq "detailed" OR $report_preferences eq false}checked{/if}> Detailed report<br>
<input type="radio" name="view" value="short" {if $report_preferences.view eq "short"}checked{/if}> {tr}Short report{/tr}<br>
<input type="radio" name="view" value="detailed" {if $report_preferences.view eq "detailed" OR $report_preferences eq false}checked{/if}> {tr}Detailed report{/tr}<br>
</div>
<div style="float:left; margin-right: 50px;">
<input type="radio" name="type" value="html" {if $report_preferences.type eq "html" OR $report_preferences eq false}checked{/if}> HTML-Email<br>
<input type="radio" name="type" value="plain" {if $report_preferences.type eq "plain"}checked{/if}> Plain text<br>
<input type="radio" name="type" value="html" {if $report_preferences.type eq "html" OR $report_preferences eq false}checked{/if}> {tr}HTML-Email{/tr}<br>
<input type="radio" name="type" value="plain" {if $report_preferences.type eq "plain"}checked{/if}> {tr}Plain text{/tr}<br>
</div>
<div>
<input type="checkbox" name="always_email" value="1" {if $report_preferences.always_email eq 1 OR $report_preferences eq false}checked{/if}/> Send me an email also if nothing happened
<input type="checkbox" name="always_email" value="1" {if $report_preferences.always_email eq 1 OR $report_preferences eq false}checked{/if}/> {tr}Send me an email also if nothing happened{/tr}
</div>
<p><input type="submit" name="submit" value=" {tr}Apply{/tr} "></p>
</form>
{else}
<p>Reports are disabled, only standard reporting is available</p>
<p>{tr}Reports are disabled, only standard reporting is available{/tr}</p>
{/if}
<h2>Sites you are watching</h2>
......
......@@ -20,14 +20,14 @@ if ($prefs['feature_daily_report_watches'] != 'y') {
include_once ('lib/reportslib.php');
//Enable User Report
//Enable User Reports
if (isset($_POST['report_preferences']) && $_POST['use_daily_reports']=="true") {
$tikilib->add_user_report($user,$_POST['interval'],$_POST['view'],$_POST['type'], $_POST['always_email']);
header('Location: tiki-user_watches.php');
die;
}
//Enable User Report
//Disable User Reports
if (isset($_POST['report_preferences']) && $_POST['use_daily_reports']!="true") {
$tikilib->delete_user_report($user);
header('Location: tiki-user_watches.php');
......
......@@ -15,27 +15,24 @@ if ($prefs['feature_daily_report_watches'] != 'y') {
}
include_once ('lib/tikilib.php');
include_once ('lib/wiki/histlib.php');
include_once ('lib/imagegals/imagegallib.php');
include_once ('lib/imagegals/imagegallib.php');
include_once ('lib/reportslib.php');
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 Emailadress isn´t set, do nothing but clear the cache
if (!empty($user_data['email'])) {
//Hole Cache
//Fetch cache
$report_cache = $tikilib->get_report_cache_entries_by_user($user, "time ASC");
//Schicke Email wenn: Einträge vorhanden oder always_email = true
//Send email if there is a cache or if always_email = true
if ($report_cache OR (!$report_cache && $report_preferences['always_email']))
$reportslib->sendEmail($user_data, $report_preferences, $report_cache);
}
//LastReportSent updaten
//Update Database
$tikilib->updateLastSent($user_data);
//Cache leeren
//Empty cache
$tikilib->deleteUsersReportCache($user_data);
}
......
......@@ -169,10 +169,7 @@ user_watches_ajax();
$smarty->assign("mootab",'y');
}
$report_preferences = $tikilib->get_report_preferences_by_user($user);
if ($report_preferences) {
$smarty->assign_by_ref('report_preferences', $report_preferences);
}
$smarty->assign_by_ref('report_preferences', $tikilib->get_report_preferences_by_user($user));
$smarty->assign('mid', 'tiki-user_watches.tpl');
$smarty->display("tiki.tpl");
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