Administrator Notifications

Hey everybody



I was just wondering if anybody has modified the admin/control panel/dashboard area for the purpose of displaying messages for administrators as per the attachment.

[attachment=4779:cs-cart-admin-notifications.jpg]

It would be very handy to have this functionality to display messages to all administrators on the admin side.



If this hasn't already been covered, and you think you can provide a solution, please get in touch.





Thanks

cs-cart-admin-notifications.jpg

Pretty easy… Create addons/my_changes/controllers/admin/auth.post.php

add:

```php

if( !defined('AREA') ) die('Access denied');

if( $mode == 'login' && !empty($_SESSION['auth']['user_id']) )
fn_set_notification('E', "Hey You!", "Read this message!", true);
return array(CONTROLLER_STATUS_OK);
?>

```php



Might have to adjust the if statement above related to mode and user_id. But you get the idea…

Thanks, that was certainly straightforward enough - I haven't yet got the hang of my_changes just yet, but have made a few changes and borrowed some code, to create 3 language variables:



'reminder' - Reminder (instead of Warning or Note)



Value: “Reminder”



'reminder_message' - Editable message (via Languages) to be shown to administrators in control panel.



Value: “Blah blah blah…”



'reminder_message_edit_link' - Contains link to Languages search for 'reminder_message', thus it can be clicked on to take you straight to the field which requires editing for displaying the message.



Value: “[Click Here to Change Text]”




```php


//
// $Id$
//

if (!defined('AREA')) { die('Access denied'); }

if ($mode == 'login') {
if (!empty($_SESSION['auth']['user_id'])) {
fn_set_notification('E', fn_get_lang_var('reminder'), fn_get_lang_var('reminder_message'), fn_get_lang_var('reminder_message_edit_link'), 'S');

}
}

?>

```



However, reminder and reminder_message are displayed, but regardless what value I enter into reminder_message_link_edit, nothing is rendered.



What I am trying to do is have the message display like so:



Reminder: Blah Blah Blah [Click Here to Change Text]



Any idea why this wouldn't work? I've looked at other calls to 'fn_set_notification' in the cart and they use the same syntax…



Thanks!

Change this to:


fn_set_notification('E', fn_get_lang_var('reminder'), fn_get_lang_var('reminder_message') ." ". fn_get_lang_var('reminder_message_edit_link'), 'S');
[




You might bracket the whole thing in

```php

if( fn_get_lang_var('reminder') ) {

your code

}



This way you can have it do nothing if there is no reminder value in the 'reminder' variable.

Excellent, that’s done it. Thanks for your help tbirnseth, I have also included the extra if statement to make the reminder notification optional ;)



Here’s the full answer:



Create addons/my_changes/controllers/admin/auth.post.php with the following content:

<br />
<?php<br />
<br />
if (!defined('AREA')) { die('Access denied');	}<br />
<br />
if ($mode == 'login') {<br />
	if (!empty($_SESSION['auth']['user_id'])) {<br />
		if( fn_get_lang_var('reminder_message') ) {<br />
		fn_set_notification('E', fn_get_lang_var('reminder'), fn_get_lang_var('reminder_message') ." ". fn_get_lang_var('reminder_update_link'), 'S');<br />
		}<br />
	}<br />
}<br />
<br />
?>
```<br />
<br />
Now, go to Administration > Languages > 'Add Language Variable', do this step for each new language variable.<br />
<br />
Language Variable: reminder<br />
Value: Reminder<br />
<br />
Language Variable: reminder_message<br />
Value: Enter whatever message you want to show to administrators throughout the control panel.<br />
<br />
Language Variable: reminder_update_link<br />
Value: ```php
[<a href="admin.php?q=reminder_message&dispatch=languages.manage&x=0&y=0">Update Reminders</a>]
```<br />
<br />
Save, refresh the admin cache, and your reminder messages will now display on the control panel like so:<br />
<br />
Note: If you leave the 'reminder_message' value empty, the notification box will not appear, thus, you can display the admin notifications only when you require.<p><a href="127.0.0.1/uploads/monthly_12_2011/post-17808-0-75137800-1324412984.jpg">cscart-admin-notifications.jpg</a></p>

Does anyone have an idea how to do this in 4.0.3?