History: Daily Reports
Source of version: 25 (current)
Copy to clipboard
! Daily reports Daily Reports is a new feature in ((Tiki4)), and improved in ((Tiki8)) and ((Tiki9)) that informs you about changes on sites you are watching with one periodic email. It is a summarised version of the normal notifications and it replaces them. !! Enabling the feature User Watches and Daily Reports have to be enabled. I recommend to enable the My Tiki menu too. In ((Tiki6)), for instance, you can enable them here: *Admin Home -> Features -> Show My tiki: check *Admin Home -> Features -> User Watches: check *Admin Home -> Features -> Daily Reports: check Since ((Tiki8)), at least, all three features are found in "Admin Home → Community", and ''Show My tiki'' is only found in "Admin Home → Community" If User Watches and Daily Reports are enabled, each user can decide to enable reports, or to further use normal notifications. !! Usage To use reports, go to My Watches in the main application Menu from your tiki site (__MyTiki > My Watches__ - __tiki-user_watches.php__) and adjust your preferences to fit your needs. {CENTER()}{img fileId="262" alt="" rel="box[g]" class=reflect }{CENTER} !! Prepare the cron job The next step is to prepare the cron job. * Before ((Tiki6)): ** Open tiki-user_reports_send.php and link $tikiUrl in line 15 to your Tikiwiki installation. ++ Since ((Tiki6)) this step is not needed any more. * Since ((Tiki9)): ** You can call the cron job from external servers, by means of using a ((token)) to allow the cron job to be launched remotely. ** You can also, as always, launch the cron job locally from the same server where the tiki is hosted, without using any token. * Since ((Tiki12)).3: ** You can use ((Console)) (console.php script) to manage the daily reports on the command line. Therefore, you can now use this feature in ((MultiTiki)) setups, appending the param like -+--site=sitename.example.com+-. Then you can enable a cronjob. Example for a cronjob that calls the script every day at 3 am: {VERSIONS(nav="y" default="Since 12.3")} __Since Tiki12.3__ {CODE(colors="bash")}00 3 * * * cd /var/www; php console.php daily-report:send{CODE} Or {CODE(colors="bash")}00 3 * * * cd /var/www; php console.php d:s{CODE} Replace __/var/www__ with your __/path/from/root/to/tiki__ In case of Tikis with domains -+site1.example.com+- & -+site2.example.com+-, in a ''MultiTiki'' setup, append an argument like -+--site=sitename.example.com+- {CODE()} 00 3 * * * cd /var/www;php console.php d:s --site=site1.example.com 00 3 * * * cd /var/www;php console.php d:s --site=site2.example.com {CODE} The above may not work on all server configurations. You are encouraged to test the command first on the console at the server, to check that there is no error message or suspicious warning. If you can't run it this way, the cron may be called through the web server. {CODE()}00 3 * * * wget -O /tmp/out http://localhost/tiki-user_reports_send.php{CODE} or something like {CODE()}00 3 * * * /usr/local/bin/wget -O - -q -t 1 http://localhost/tiki-user_reports_send.php{CODE} or even with some command based on the other command __curl__ and an associated command (like "mutt", which needs to be installed separatedly) to send the output of the cron job to an email account. See the exmple below. ---(Before 12.3)--- __Before Tiki12.3__: {CODE()}00 3 * * * php /var/www/tiki-user_reports_send.php{CODE} or {CODE(colors="bash")}00 3 * * * cd /var/www; php tiki-user_reports_send.php{CODE} Replace __/var/www__ with your __/path/from/root/to/tiki__ The above may not work on all server configurations. You are encouraged to test the command first on the console at the server, to check that there is no error message or suspicious warning. If you can't run it this way, the cron may be called through the web server. {CODE()}00 3 * * * wget -O /tmp/out http://localhost/tiki-user_reports_send.php{CODE} or something like {CODE()}00 3 * * * /usr/local/bin/wget -O - -q -t 1 http://localhost/tiki-user_reports_send.php{CODE} or even with some command based on the other command __curl__ and an associated command (like "mutt", which needs to be installed separatedly) to send the output of the cron job to an email account. See the exmple below. {VERSIONS} !! Token access for anonymous users And since ((Tiki9)), you can use a ((token)) in the url to call, in order to allow the cron script to be launched from an external server. An example of using the token and sending the output by email at 5, 11, 17 and 23h each day is shown below: {CODE()} 0 5,11,17,23 * * * curl 'http://externaldomain.org/tiki-user_reports_send.php?TOKEN=98762542c722d08b14bb54b029389612' 2> /tmp/output.txt | mutt -s "[FOO]tiki-user_reports_send.php?TOKEN=... error output" foo@bar.org < /tmp/output.txt {CODE} Tip: For __wget__ to work in virtual servers, you need to ensure that you have the package __xterm__ installed. !! How it works internally __lib/reportslib.php__ Contains the main class and all important code for reports. __tiki-user_reports.php__ This file is used to enable or disble reports and to set the report preferences. It catches POST requests from tiki-user_watches.php __tiki-user_reports_send.php__ This file is the file that initiates sending reportemails. It can and may only be called by the server. If you want to use reports before ((Tiki6)), open the file and set $tikiUrl in line 15 to your Tikiwiki installation. The last step is to enable a cronjob that calls this file. Once there are some actions done that would send emails to the user, those action leave a record in the mysql table __tiki_user_reports_cache__, and when the cron job is run, the records in this table will be used to feed the report to be sent to the user by email. !! Example of a Html report: {img src="tiki-download_file.php?fileId=137&preview" alt="reports_example.png (120.26 Kb)"} !! Changing groups of users to receive daily reports by default It was not until Tiki6.5, 7.3 and 8.0 that a tiki admin could indicate that new users receive daily digests of notification emails by default. Therefore, many live tiki sites using previous versions of the software since long ago, with potentially hundreds of users already, might not benefit from that performance improvement untill all users manually indicated that they wanted to receive daily digests instead of instantaneous emails. However, there is some performance limitation in tiki when you have hundreds of users receiving instantaneous notification emails each time a user adds some new content. This can mean moving from a couple of seconds, on a shared hosting, to have tiki back ready after sending some new coment or trakcer item, for instance, into lasting 45 seconds before tiki is ready back after sending all the emails associated to that same action (posting a new comment or tracker item, in this example) Therefore, it's not rare that an admin would want to change at once a whole group of users from receiving instantaneous emails, to receiving them grouped daily based on a cron job. This change alleviates tiki from sending so many emails with every new action, and brings tiki back to a fast performance from the end user point of view. This change can be applied directly with a SQL query on the database (through phpmyadmin or by other means). If your groups of users is "__foo_group__", then the SQL query to run directly in your mysql db is: {CODE(caption="sql code to run directly on the on mysql database" wrap="1" colors="sql" ln="" rtl="")}INSERT INTO `tiki_user_reports` (`user`, `interval`, `view`, `type`, `time_to_send`, `always_email`, `last_report`) (SELECT uu.`login`, 'daily', 'detailed', 'html', '0000-00-00 00:00:00', 1, NOW() FROM `users_users` uu, `users_usergroups` uug WHERE uug.`groupName` = 'foo_group' AND uu.`userId` = uug.`userId` AND uu.`login` NOT IN (SELECT user FROM tiki_user_reports));{CODE} -=Related=- ((User Watches)) ((Action log)) -=alias names for this page=- (alias(Daily Reports for User Watches)) | (alias(DailyReports)) | (alias(PeriodicReports)) | (alias(Periodic Reports)) | (alias(Daily digest)) | (alias(DailyReport)) | (alias(Daily Report))