? ? ? Success

User tests: Successful: Unsuccessful:

avatar muhakh
muhakh
29 Aug 2016

Summary of Changes

Creating a new plugin plg_sys_userlogs and a new component com_userlogs to record users action withing the CMS. To make them installed with the CMS install/update, I added the related SQL queries to SQL files in installation/sql .

Testing Instructions

Download

Download the repository and install it as you install Joomla normally.

After Installation

After installation you need first to activate the plugin so that the users actions can be logged.
Go to http://www.example.com/index.php?option=com_installer&view=manage and look for a plugin called "System - User actions Log" and then activate it.

Now your Joomla! website can store users' actions.

Viewing the Logs

To view the logs just go to the component as shown in this image

You will have control over the logs as a super admin that allows you to sort, search, export or delete logs as you want.

Loggable Extensions

Go to http://www.example.com/index.php?option=com_installer&view=manage and look for a plugin called "System - User actions Log" and go to its options. You will find a field Select events to be logged where you can choose which Extension you need to log its actions.

Permissions

AS every component in Joomla, this component has permissions that are default to superusers only.
Just click on the options button on the top right of the component page and you will view the permissions of the component.

E-mail Notifications

Every user that has permission to view the logs can choose whether to receive e-mail notifications when a new action happen.
The user will just go to the account settings, and under "Basic Settings" tab you can choose whether to receive e-mail notifications and you also can choose which extensions you need to receive logs from.

avatar muhakh muhakh - open - 29 Aug 2016
avatar muhakh muhakh - change - 29 Aug 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 29 Aug 2016
Category Administration Components SQL Postgresql MS SQL Language & Strings Installation
avatar joomla-cms-bot joomla-cms-bot - change - 29 Aug 2016
Labels Added: ? ?
avatar yild
yild - comment - 29 Aug 2016

After quick look at this, I can say that #__user_logs table could be expanded with additional 'id' field that would store id of content/element that fired event (i.e article changed - save article id, created new article save article id, and so on). ATM 'message' field would be hard to parse (as I saw that you can export it to csv...). Or 'message' field would be filled with html strings that links to a content/element/position/user. i.e
User logged in at date/time.

avatar brianteeman
brianteeman - comment - 29 Aug 2016

In the plugin there is a field labelled
Select events to be logged

But there is nowhere for any input
apa2

avatar brianteeman
brianteeman - comment - 29 Aug 2016

Immediately after install - go to the component and try to export all the logs

PHP Fatal error:  Call to undefined function from() in administrator/components/com_userlogs/models/userlogs.php on line 259
avatar brianteeman
brianteeman - comment - 29 Aug 2016

Tested loggin of installing a basic plugin - the result was

a php notice

PHP Notice:  Array to string conversion in /libraries/joomla/language/text.php on line 312

and a field content of

Extension installed, its id="Array"
avatar brianteeman
brianteeman - comment - 29 Aug 2016

I'm getting LOTS of php notices all over the place with whatever I do. Please retest your code

avatar brianteeman
brianteeman - comment - 29 Aug 2016

Retested and now I get new errors

[29-Aug-2016 17:40:02 Europe/London] PHP Notice:  Trying to get property of non-object in /Applications/MAMP/htdocs/github-joomla-cms/plugins/system/userlogs/userlogs.php on line 397
[29-Aug-2016 17:40:02 Europe/London] PHP Notice:  Trying to get property of non-object in /Applications/MAMP/htdocs/github-joomla-cms/plugins/system/userlogs/userlogs.php on line 400
[29-Aug-2016 17:40:09 Europe/London] PHP Notice:  Undefined variable: type in /Applications/MAMP/htdocs/github-joomla-cms/plugins/system/userlogs/userlogs.php on line 688
[29-Aug-2016 17:40:09 Europe/London] PHP Notice:  Undefined index: extension_name in /Applications/MAMP/htdocs/github-joomla-cms/plugins/system/userlogs/userlogs.php on line 648
[29-Aug-2016 17:40:09 Europe/London] PHP Notice:  Undefined index: extension_name in /Applications/MAMP/htdocs/github-joomla-cms/plugins/system/userlogs/userlogs.php on line 648
[29-Aug-2016 17:40:09 Europe/London] PHP Notice:  Undefined variable: type in /Applications/MAMP/htdocs/github-joomla-cms/plugins/system/userlogs/userlogs.php on line 596
[29-Aug-2016 17:40:09 Europe/London] PHP Notice:  Undefined variable: type in /Applications/MAMP/htdocs/github-joomla-cms/plugins/system/userlogs/userlogs.php on line 596
[29-Aug-2016 17:40:09 Europe/London] PHP Notice:  Undefined index: extension_name in /Applications/MAMP/htdocs/github-joomla-cms/plugins/system/userlogs/userlogs.php on line 644
avatar muhakh
muhakh - comment - 29 Aug 2016

Thank you @brianteeman for your feedback.
Are the notices still there after this last commit?
And sorry for the missed up code ?

avatar Llewellynvdm
Llewellynvdm - comment - 29 Aug 2016

The language strings for the profile is not showing correctly at:
www.website.com/administrator/index.php?option=com_admin&view=profile&layout=edit&id=659

PLG_SYSTEM_USERLOGS_NOTIFICATIONS
PLG_SYSTEM_USERLOGS_NOTIFICATIONS_DESC
PLG_SYSTEM_USERLOGS_EXTENSIONS_NOTIFICATIONS
PLG_SYSTEM_USERLOGS_EXTENSIONS_NOTIFICATIONS_DESC
avatar jsubri
jsubri - comment - 29 Aug 2016

A great new feature, I like it very much, well done.

I had to create the table manually using phpMyAdmin-4.4.15.5 and still running PHP5.4 on 1 server.

CREATE TABLE IF NOT EXISTS #__user_logs (
...
message text NOT NULL DEFAULT '',
...
MySQL said: Documentation
#1101 - BLOB/TEXT column 'message' can't have a default value

EDIT: seems to be old MySQL "bug/limitation/compatibility across platforms". I'm running Windows with MySQL 5.5.24

EDIT2: works on Windows with MySQL 5.6.21 XAMPP V3.2.1

avatar jeckodevelopment jeckodevelopment - change - 30 Aug 2016
Labels Added: ?
avatar jeckodevelopment jeckodevelopment - change - 30 Aug 2016
Labels Added: ?
avatar andrepereiradasilva
andrepereiradasilva - comment - 30 Aug 2016

you need to fix conflicts because of #11795 merge

avatar brianteeman
brianteeman - comment - 30 Aug 2016
  1. As soon as I enable the plugin and do anything then I get an error
[30-Aug-2016 14:24:50 Europe/London] PHP Notice:  Undefined variable: type_title in /plugins/system/userlogs/userlogs.php on line 188
  1. Take a look at com_finder and see how it displays a message when you do not have the plugin enabled. Need to do something similar for userlogs

  2. Issues I reported about search filters and sort dropdown are still present

avatar muhakh
muhakh - comment - 31 Aug 2016

Thank you all for your feedback. I'm woking on these issues but I need only one day to fix them.
Thank you for your patience.

avatar andrepereiradasilva
andrepereiradasilva - comment - 31 Aug 2016

sure, take your time @muhakh

avatar yild
yild - comment - 31 Aug 2016

hmm can't make it work... applied PR by patch tester - it says its applied successfully, no new component visible in 'components' menu, had to discover it, then no tables present, had to fix database... and no System - User actions Log plugin was installed only User actions Log component visible in management.

mysql 5.5.50
php 5.6.24
Joomla! 3.6.3-dev Development

any pointers?

avatar jsubri
jsubri - comment - 31 Aug 2016

@yild, for existing websites the SQL IDs are likely already used by other assets.
Out of curiosity , it the below query runs without error on mysql 5.5.50?
CREATE TABLE IF NOT EXISTS #__user_logs (
...
message text NOT NULL DEFAULT '',

avatar yild
yild - comment - 31 Aug 2016

@jsubri

0 row(s) affected, 1 warning(s): 1101 BLOB/TEXT column 'message' can't have a default value

avatar yild
yild - comment - 31 Aug 2016

@jsubri thanks for a tip about existing instalation, installed J from last commit in this PR and it works.

CREATE TABLE IF NOT EXISTS #__user_logs (
...
ip_address VARCHAR(30) NOT NULL DEFAULT 'PLG_SYSTEM_USERLOG_DISABLED',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

Using language strings for field default values isn't a good idea IMO, which language would you use in multilingual website? Either use 0.0.0.0 or 255.255.255.255.

btw. PLG_SYSTEM_USERLOG_DISABLED is missing from any language file.

As I said in my first post, more beautification for logs would be great ;)

Edit: 'Select events to be logged' option displays components titles but extension column in component shows system names (ie COM_CONTENT).

Edit2: Each item in list of components/extension in 'Select events to be logged' takes full width of page its easy to uncheck an item if you click on 'empty' space.

avatar jsubri
jsubri - comment - 2 Sep 2016

Still a notice when deleting a user:

Notice: Undefined index: edited_user in ...\plugins\system\userlogs\userlogs.php on line 673 User "" deleted

avatar muhakh
muhakh - comment - 5 Sep 2016

@brianteeman Do you still see the field Select events to be logged
and there is nowhere for input

avatar brianteeman
brianteeman - comment - 5 Sep 2016

@muhakh yes no change

avatar brianteeman
brianteeman - comment - 6 Sep 2016

Sorry I still cannot get this to work. This is what I have done - maybe you can see the error

  1. Install Joomla 3.7
  2. Apply this PR using com_patchtester
  3. Discover install the plugin and component
  4. Database fix

This shows the component and plugin installed but I still dont get the Select events to be logged list

avatar muhakh
muhakh - comment - 6 Sep 2016

I have a problem with applying the PR with com_patchtester. It gives me error Fatal error: Allowed memory size of 268435456 bytes exhausted. But when I go to discover, I find the plugin and the component and I find the database tables that needs to be created in the database part. When I see the tables __user_logs_extensions and #__user_logs_tables_data in the database, I find them empty as the insert queries here are not executed.
What could cause such an error?

avatar andrepereiradasilva
andrepereiradasilva - comment - 6 Sep 2016

Try using patchtester 3alpha available in the patchtester repository
https://github.com/joomla-extensions/patchtester/releases/tag/3.0.0-alpha2

avatar muhakh
muhakh - comment - 7 Sep 2016

Patchtester 3 alpha doesn't get the plugin. Patchtester 2 gets the plugin and the component but has the previous error.

avatar mbabker
mbabker - comment - 7 Sep 2016

Patch tester does not install new extensions. It simply grabs the files that are marked as changed in a pull request and downloads them to your local filesystem (backing up existing files to allow a clean revert). No matter the version of patch tester you're using you'd have to discover and install any new extensions after the patch is applied or manually run any needed database changes to test a patch.

avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Sep 2016

@mbabker @muhakh my comment

Try using patchtester 3alpha available in the patchtester repository
https://github.com/joomla-extensions/patchtester/releases/tag/3.0.0-alpha2

was because of this comment

I have a problem with applying the PR with com_patchtester. It gives me error Fatal error: Allowed memory size of 268435456 bytes exhausted.

This is solved in v3alpha of the patchtester

avatar muhakh
muhakh - comment - 7 Sep 2016

@mbabker @andrepereiradasilva The problem I have with patchtester v3alpha is that it doesn't grab the plugin files and the v2 grabs all the files but produces the error

Fatal error: Allowed memory size of 268435456 bytes exhausted.

avatar mbabker
mbabker - comment - 7 Sep 2016

File an issue on the patch tester repo with all of the info requested in the template. I would also suggest turning error reporting to maximum and debug mode on; the patch tester component might not raise an error about the plugin files not being downloaded but one of the core Joomla APIs may.

No matter the issue the patch tester has known limitations; for example executing the SQL statements needed for a patch just won't happen and it's out of scope for the extension to do so.

avatar AlexRed
AlexRed - comment - 11 Sep 2016

deleting an article does not complete the message in the User Actions Log:

(s) [""] became trashed


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11834.

avatar muhakh
muhakh - comment - 11 Sep 2016

I think I found the problem that makes you @brianteeman and @AlexRed have the problems that you see.
These INSERT queries

are essential for the extension to work well. If you apply the PR using the patch tester and go and fix the database, you will get 163 database changes did not alter table structure and were skipped. These skipped database changes include those queries above.

I don't know how to solve it, but you can test the PR from my fork https://github.com/muhakh/joomla-cms/tree/staging

avatar ghazal ghazal - test_item - 15 Sep 2016 - Tested successfully
avatar ghazal
ghazal - comment - 15 Sep 2016

I have tested this item successfully on b4e09c7

Tested with muhakh's fork.
Looks like brianteeman and AlexRed 's issue has been corrected.
Nice addition.

I guess it will need to be thoroughly explained and advertised if only not to let users overload unnecessarily their DB.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11834.

avatar jsubri
jsubri - comment - 26 Sep 2016

I had "patchtester" issue as the plugins/system/userlogs/. didn't got copied over.
Beside that works fine. +1

avatar gunjanpatel
gunjanpatel - comment - 14 Oct 2016

In my opinion there should be a headers for csv to get clear understanding of data.

Headers are missing?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11834.

avatar gunjanpatel gunjanpatel - test_item - 14 Oct 2016 - Tested successfully
avatar gunjanpatel
gunjanpatel - comment - 14 Oct 2016

I have tested this item successfully on b4e09c7


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11834.

avatar rdeutz rdeutz - change - 25 Oct 2016
Labels Removed: ?
avatar muhakh muhakh - change - 21 Nov 2016
The description was changed
avatar joomla-cms-bot joomla-cms-bot - change - 21 Nov 2016
Category Administration Components SQL Postgresql MS SQL Language & Strings Installation Administration com_admin SQL Postgresql MS SQL Language & Strings Installation Components
avatar andrepereiradasilva
andrepereiradasilva - comment - 21 Nov 2016

@muhakh make a second pass code review in the code. I focused on sql (install and update), ini language and xml here.

Added a lot of comments, some are minor CS, some are issues with conflicts with recently merged com_fields, some, if not fixed would probably break all joomla on update.

Please fix all of these. Thanks

avatar brianteeman
brianteeman - comment - 21 Nov 2016

I still have the same problem I reported before

Sorry I still cannot get this to work. This is what I have done - maybe you can see the error
Install Joomla 3.7
Apply this PR using com_patchtester
Discover install the plugin and component
Database fix
This shows the component and plugin installed but I still dont get the Select events to be logged list


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11834.

avatar muhakh muhakh - change - 26 Nov 2016
Labels Added: ?
avatar mbabker
mbabker - comment - 21 May 2017

Is this still being worked on?

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 May 2017
The description was changed
Status Pending Information Required
avatar joomla-cms-bot joomla-cms-bot - edited - 22 May 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

If this PR get no Response, it will be closed at 22th June 2017.

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Jun 2017
Status Information Required Closed - No Reply
Closed_Date 0000-00-00 00:00:00 2017-06-22 06:39:34
Closed_By franz-wohlkoenig
avatar joomla-cms-bot
joomla-cms-bot - comment - 22 Jun 2017
avatar joomla-cms-bot joomla-cms-bot - close - 22 Jun 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 Jun 2017

closed as stated above.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11834.

Add a Comment

Login with GitHub to post a comment