Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » RADICORE Suggestions » Message of the Day
Message of the Day [message #2034] Mon, 04 May 2009 12:35 Go to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Tony,

Thought it would be useful to have the ability to display a "Message of the Day" on the Home screen. This could be used to notify users of upcoming events / system changes, or to advise of significant changes following an upgrade etc.

Maybe this could be configured and set in the Menu Controls?

What do you think?

Graham
Re: Message of the Day [message #2037 is a reply to message #2034] Mon, 04 May 2009 15:42 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Perhaps instead of having just a single message on the control table it might be more flexible to have a separate MOTD table with a separate record for each message. This would provide the opportunity to scroll though previous messages. I will see what I can do for the next release.

Re: Message of the Day [message #2039 is a reply to message #2034] Mon, 04 May 2009 17:58 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Sounds good. May I suggest some kind of use of the start and end date functionality, so that a message can 'expire'. Perhaps only current messages are displayed automatically, whilst expired messages can be retrieved via scrolling etc? This would avoid having a very old message constantly displayed if it hasn't been superseded by a new one.
Re: Message of the Day [message #2040 is a reply to message #2039] Wed, 06 May 2009 06:50 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Try the attached update and let me know what you think.

I've created a new database table, with associated tasks, for MOTD (message of the day). There is also a new screen which shows unexpired messages, latest first, immediately after passing through the logon screen. If there are no messages then the screen will not be shown.


Re: Message of the Day [message #2041 is a reply to message #2034] Wed, 06 May 2009 08:48 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
At first look this is perfect and just what I had in mind. Couple of questions:
1. To display a message for a single day only I assume you enter the end date = start date. I noticed that due to a quirk with the current/historic properties, if I add a new motd for today only, it doesn't appear in the motd list unless I RESET the screen. It DOES, however, correctly appear in the Show screen so it's not an issue, just a bit confusing at first.
2. This functionality meets all my needs, but thinking ahead it might be appropriate to include the ability to filter which messages are shown by Role. The risk here is that it complicates what is nice and simple at the moment, but could be worth thinking about for the furture.

I've added some messages to start and end over the next few days, so I'll just keep an eye that it behaves as I'm expecting it will.

Great Work!
Re: Message of the Day [message #2042 is a reply to message #2041] Wed, 06 May 2009 09:34 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
I tried to duplicate your point #1, but I could not. I went into the 'List Message of the Day' screen which, by default, is set to display 'current' records only (where start_date<=today and end_date>=today), then I pressed 'New' to create a new message with today's date as both the start and end dates. When I returned to the 'List' screen it showed up as I expected.

As for your point #2, I can add role_id as an optional field on the mnu_motd table so that a message can be specific to a particular role or available to all roles.


Re: Message of the Day [message #2043 is a reply to message #2034] Wed, 06 May 2009 10:12 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
I've tried running through my debugger to see why I'm not getting todays messages listed, and I think I may have found a bug - please correct me if I'm wrong...

Lines 315 and 316 in std.table.class.inc show:
$search[$start_date] = "<='$date 00:00:00'";
$search[$end_date] = ">='$date 23:59:59'";

If I'm not mistaken the times on these two rows should be reversed, to become:
$search[$start_date] = "<='$date 23:59:59'";
$search[$end_date] = ">='$date 00:00:00'";

The start and end date fields in the mnu_motd table are defined as date fields rather than datetime fields, so I'm not sure why the times may be having an effect - maybe it's to do with different implementations of MySQL.

Regarding point 2 - this isn't something I need at the moment, but thought it might be a useful addition.

Graham
Re: Message of the Day [message #2044 is a reply to message #2042] Wed, 06 May 2009 10:21 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
The attached update adds 'role_id' as an optional field on the 'mnu_motd' table. The 'Show MOTD' screen will therefore be restricted to messages which are current and either linked to the user's role or are not linked to any role.

Re: Message of the Day [message #2045 is a reply to message #2043] Wed, 06 May 2009 10:35 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
I think you are correct. I put that code in there for ORACLE users as the DATE data type includes the TIME whether you like it or not. I'm testing with MySQL 4.1 which didn't complain, so I didn't spot it. I assume you're using MySQL 5?

I'll fix this is the next release.


Re: Message of the Day [message #2046 is a reply to message #2034] Wed, 06 May 2009 10:41 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
If you want to let me know when you have a fix for that I'll test it against my database to see if it corrects the problem.
Re: Message of the Day [message #2047 is a reply to message #2046] Wed, 06 May 2009 11:02 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
The fix is exactly as you suggested, just reverse the times in lines 315 and 316 to the following:
$search[$start_date] = "<='$date 23:59:59'";
$search[$end_date]   = ">='$date 00:00:00'";


Re: Message of the Day [message #2048 is a reply to message #2034] Wed, 06 May 2009 11:28 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Yes, I've tested, and that fixes the problem.

Although it isn't used in this case, the same code also appears in include.general.inc I assume it needs to be corrected here too.
Re: Message of the Day [message #2049 is a reply to message #2048] Wed, 06 May 2009 12:32 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
That's correct. I'll make the same change in my code.

Re: Message of the Day [message #2050 is a reply to message #2034] Thu, 07 May 2009 06:37 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Tony,

I've noticed today that the Show task is displaying a message that should have expired (i.e. one that I set with start and end dates both as 2009-05-06).

Graam
Re: Message of the Day [message #2051 is a reply to message #2034] Thu, 07 May 2009 06:56 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Tony,

A further qualification on my previous message. The error is related to the role_id. If a message has a blank role_id then it IS excluded from the Show task. However, if a role_id is present it is not being excluded.

Graham
Re: Message of the Day [message #2052 is a reply to message #2051] Thu, 07 May 2009 10:05 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
In file menu.php can you change line 26 so that it reads:
... AND (role_id IS NULL OR role_id='$role_id')";

Notice the parentheses around the two possible values for role_id.


Re: Message of the Day [message #2053 is a reply to message #2034] Thu, 07 May 2009 10:23 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Done, and all now working correctly.
Thanks
Re: Message of the Day [message #2054 is a reply to message #2034] Thu, 07 May 2009 11:49 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
I'm afraid I've discovered a new bug since the addition of the Role functionality (always a problem adding something as an afterthought!)

If you create a message with NO role id (i.e. for all roles) and then login with a role that has not been given access to the Show task (other than the Global role) the system tries to display the message and crashes, rather than ignoring the fact that you don't have access and not trying to display the screen.

I discovered this because I forgot to give task access!!
Re: Message of the Day [message #2055 is a reply to message #2054] Thu, 07 May 2009 12:45 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
You must give access to task 'mnu_motd(show)' to all roles, otherwise they won't be able to see that screen.

Re: Message of the Day [message #2056 is a reply to message #2055] Thu, 07 May 2009 12:59 Go to previous message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Run this SQL statement and it will insert entries into MNU_ROLE_TASK for all available roles:
INSERT INTO mnu_role_task (role_id, task_id) 
     SELECT mnu_role.role_id, 'mnu_motd(show)'     
       FROM mnu_role 
      WHERE NOT EXISTS (SELECT 1 FROM mnu_role_task AS mrt 
                         WHERE mrt.role_id=mnu_role.role_id AND mrt.task_id='mnu_motd(show)');

I shall include this in the update script.


Previous Topic: Auto numerate records in a list view
Next Topic: PDF facility to produce letters
Goto Forum:
  


Current Time: Tue Dec 03 13:53:39 EST 2024

Total time taken to generate the page: 0.01597 seconds