mtAlertPlugin - 1.0.2

Alerts plugin.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Dependencies Releases Changelog Contribute
Show source | Show as Markdown

mtAlertPlugin

Requirements

  • Add a getUsername method to myUser class (MANDATORY)

  • If mail service is required: dcMailerPlugin (OPTIONAL)

  • If rich text editing is desired: sfFormExtraPlugin & tinyMCE library. (OPTIONAL)

Installation

  • First of all you must create some methods in the myUser class:

    • you should provide a 'getUsername' method in you myUser class. The username returned by this method should be unique for authenticated users.
  • If you like, you could add the application's credentials in the app.yml

{{ app.yml all: mt_alert_plugin: credentials: center_admin, unit_admin, unit }}

  • The plugin admin modules should be enabled in the settings.yml file to be able to add and configure alerts

{{ setting.yml: all: enabled_modules: mt_alert_message, mt_alert_message_user, mt_alert_message_credential }}

  • There's also a non administrative module that should be seen by everyone. This module show the alerts for the logged user and allows some configuration on them:

{{ setting.yml: all: enabled_modules: mt_alert_message_view }}

  • This plugin uses jQuery. If its already loaded in your app it should work ok, if don't you should add the following javascripts in your view.yml:

{{ javascripts: /mtAlertPlugin/js/no-conflict.js }}

If you use prototype, the javascript for it should be specified AFTER the jQuery's ones. Example:

{{ javascripts: /mtAlertPlugin/js/no-conflict.js, ..., %SF_PROTOTYPE_WEB_DIR%/js/prototype, ... }}

  • If you use symfony 1.3, the removal of the sfCommonFilter avoids the inclusion of stylesheets included in component's partial. If this happens to you, you should include the stylesheet for the theme you desire. By default, you should do this:

    default: stylesheets: /mtAlertPlugin/css/default.css

  • Finally, add this lines somewhere in the layout:

    <?php include_component('mt_alert_message_view', 'show') ?>
    

If mail service is desired...

  • Also you should provide some 'extra methods' if you'd like to send mails. This methods are configured in the 'app.yml' section of the plugin. Three static methods are needed:

{{ app.yml all: mt_alert_plugin: mail_retrieve_mails_method: This method should retrieve the mail address of an array of usernames passed as parameter. mail_retrieve_usernames_by_credential_method: This methos should retrieve the usernames of the user who have a credential passed as parameter. mail_retrieve_all_mails_method: This should retrieve the mail addresses of all the users of the application. }} This plugin uses the dcMailerPlugin to send mails, so its installation is needed.

APP.YML Example

  • Full example of the app.yml:

{{ mt_alert_plugin: credentials: center_admin, unit_admin, unit enable_rich_text: false tiny_mce_theme: simple theme: default mail_subject: "App Name | %%title%%" mail_from: "address@server.com" mail_retrieve_mails_method: 'getMailsByUsernames' mail_retrieve_usernames_by_credential_method: 'getUsernamesByCredential' mail_retrieve_all_mails_method: 'getAllMails' }}

  • If you want you can use a rich text editor when creating the alerts. You need to install sfFormExtraPlugin, download the tiny_mce library and set it all up. After that you must enable the rich text feature in the mt_alert_plugin app.yml section

Usage:

  1. Go to the 'mt_alert_message' module to create some alerts.

  2. That's it!

  3. To send mails use the mtAlertPlugin:sendMail task. An application and an enviroment is required:

{{ php symfony mtAlertPlugin:sendMail --application="frontend" --env="dev" }}

This task fetches all the alerts that are active and its condition evaluates to true and sends them to the corresponding users.

Themes

In the app.yml section of the plugin you can configure the 'themes' of the plugin. Currently the plugin only ships with one theme which is named 'default'. You can add others by:

1. mkdir -p apps/APP_NAME/modules/mt_alert_message_view/templates
2. Provide some HTML files:

{{ $THEMENAMEHideInThisSessionError.php $THEMENAMEHideInThisSessionSuccess.php $THEMENAMEHidePermanentlyError.php $THEMENAMEHidePermanentlySuccess.php _$THEMENAME_show_mt_alert_message_actions.php _$THEMENAME_show_mt_alert_message.php _$THEMENAME_show.php }}

3. Change the app.yml:

{{ mt_alert_plugin: theme: $THEMENAME }}

In '$THEMENAME_show.php' the stylesheets are included. If you want to use other CSS file used you must change the following line in $THEMENAME_show.php:

{{ }}

to

{{ }}