x

Main chapters

  1. LimeSurvey Cloud vs LimeSurvey CE
  2. LimeSurvey Cloud - Quick start guide
  3. LimeSurvey CE - Installation
  4. How to design a good survey (Guide)
  5. Getting started
  6. LimeSurvey configuration
  7. Introduction - Surveys
  8. View survey settings
  9. View survey menu
  10. View survey structure
  11. Introduction - Questions
  12. Introduction - Question Groups
  13. Introduction - Surveys - Management
  14. Survey toolbar options
  15. Multilingual survey
  16. Quick start guide - ExpressionScript
  17. Advanced features
  18. General FAQ
  19. Troubleshooting
  20. Workarounds
  21. License
  22. Version change log
  23. Plugins - Advanced
 Actions

Notifications: Difference between revisions

From LimeSurvey Manual

Line 122: Line 122:
   'message' => 'I\'m in love with Marge. I don\'t care if everyone knows.'
   'message' => 'I\'m in love with Marge. I don\'t care if everyone knows.'
));
));
</syntaxhighlight>
'''Modal class'''
You can change the modal class of the modal popup using modal_class.
<syntaxhighlight lang="php">
$not = new Notification(array(
  'survey_id' => 316222,
  'title' => 'Error',
  'message' => 'This modal will have a red panel header, because it\'s an error.',
  'modal_class' => 'warning'
));
$not->save();
</syntaxhighlight>
</syntaxhighlight>

Revision as of 11:36, 4 August 2016

Have an icon in top menu about notifications to user. Can be bound to user, user group or survey.

Also need an 'irritating' message type that will be 'new' until a certain condition is fulfilled (like survey must be activated).

GUI

  • Bell icon
  • List of last 5 messages in menu where you can can see which messages are new
  • History view of all messages? Grid view.
  • Delete messages? Soft delete.

Usage

Should be possible for the developer to invoke new notification both from PHP and JS.

PHP:

$not = new Notification();
$not->type = 'danger';
$not->message = gT('New info!');
$not->save();

JS:

$.ajax(
  url: 'notification.php',
  data: {
    message: translatedMessageString
  }
).done(function(result) {
  updateNotifications(result);
});

For JS: When to fire new message? At reload or immediate? Set option.

Localization

Support localization for messages dynamically created by admin?

Flash

Merge system with flash message, so that programmer will call addNotification instead of setFlash.

Pro:

  • Store log of all notifications

Database

New database table required to make notifications persist between login/logout.

Fields:

  • id
  • entity, like survey, user, ...
  • entity_id, survey id, user id, ...
  • title, title of message (shown in dropdown and overview)
  • message, the actual message
  • modal_class, success, danger, default
  • type, important, log
  • status, new, read
  • created, datetime
  • read, datetime

Examples

Create a new notification for a survey

This notification will be visible for all users who visit the survey.

$not = new Notification(array(
  'survey_id' => 316222,
  'title' => 'My title',
  'message' => 'Hello, and welcome to LimeSurvey! Anyone who can see this survey can see this message.'
));
$not->save();


Send an important notification

Visible on page load.

$not = new Notification(array(
  'survey_id' => 316222,
  'title' => 'My title',
  'type' => 'important',
  'message' => 'This notification will be a pop-up modal automaticall opened at load'
));
$not->save();


Notification to a specific user

Only this user can see this notification.

$user = ...
$not = new Notification(array(
  'user_id' => $user->id,
  'title' => 'My title',
  'message' => 'This is a love letter only Marge can see.'
));
$not->save();


Broadcast

All users will get this notification.

Notification::broadcast(array(
  'title' => 'To all users',
  'message' => 'I\'m in love with Marge. I don\'t care if everyone knows.'
));

Modal class

You can change the modal class of the modal popup using modal_class.

$not = new Notification(array(
  'survey_id' => 316222,
  'title' => 'Error',
  'message' => 'This modal will have a red panel header, because it\'s an error.',
  'modal_class' => 'warning'
));
$not->save();