tiki-user_reports_send.php 1.28 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4 5
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6 7

include_once ('tiki-setup.php');
changi67's avatar
changi67 committed
8
if ($_SERVER['REMOTE_ADDR'] != "127.0.0.1" AND !empty($_SERVER['REMOTE_ADDR'])) die("This script can only be called by the server!");
9
if ($prefs['feature_daily_report_watches'] != 'y') {
10
	die("This feature is disabled");
11
}
12
include_once ('lib/reportslib.php');
13 14
foreach($reportslib->getUsersForSendingReport() as $key => $user) {
	$report_preferences = $reportslib->get_report_preferences_by_user($user);
15
	$user_data = $userlib->get_user_info($user);
16

17
	//If Emailadress isn´t set, do nothing but clear the cache
18
	if (!empty($user_data['email'])) {
19
		//Fetch cache
20
		$report_cache = $reportslib->get_report_cache_entries_by_user($user, "time ASC");
21
		//Send email if there is a cache or if always_email = true
changi67's avatar
changi67 committed
22
		if ($report_cache OR (!$report_cache && $report_preferences['always_email'])) $reportslib->sendEmail($user_data, $report_preferences, $report_cache);
23
	}
24
	//Update Database
25
	//$reportslib->updateLastSent($user_data['login']);
26
	//Empty cache
27
	//$reportslib->deleteUsersReportCache($user_data['login']);
changi67's avatar
changi67 committed
28
	
29
}