Example improvement to notifications.

User and Staff mailers did not behave as one might expect. The staff mailer could send content to recipients who were not staff members. Also there was also no easy way to adjust the outgoing name and email on individual templates without setting up multiple providers and disabling the correct combination on each template.

--------------------------

Improvements:

Public Provider
- will send to any valid recipient object but never to a Admin_User object
- allows for a Sender_Name and Sender_Email to be set for each template.
- Allowing administrators to overide the Sender_Name and Sender_Field is optional

Private Provider
- will only send to recipients that are Admin_User objects
- no longer requires use of internal_recipients flag

----------------------------------------
Previous usage example:

//fetch public recipients
$recipients = $schedule_entry->get_attending_clients();
//send public emails
foreach($recipients as $recipient){
Notify::trigger('xeducation:client_schedule_notification', array('recipient'=>$recipient,'internal'=>'0'));
}

//fetch admins for internal notification of template
$recipients = Admin_User::list_users_having_permission('xeducation', 'manage_courses');
foreach($recipients as $recipient){
Notify::trigger('xeducation:client_schedule_notification', array('recipient'=>$recipient,'internal'=>'1'));
}

//as far as I can tell, when using ::trigger in a loop you need to indicate if a recipient is internal or external as a parameter and then handle it correctly in prepare_template() , by using ->add_recipient($recipient, $internal) , where $internal can be true or false.

-----------------------------------------------
Improved Usage Example using the updated Public/Private providers:

//fetch public recipients
$clients = $schedule_entry->get_attending_clients();
//fetch internal recipients
$users = Admin_User::list_users_having_permission('xeducation', 'manage_courses');
//merge them into one big recipient list.
$recipients = array_merge($clients,$users);

foreach($recipients as $recipient){
Notify::trigger('xeducation:client_schedule_notification', array('recipient'=>$recipient));
//if public and private providers are active, an admin recipient will only received the private/internal content while the other recipients only get the public content.
}

//this is much better to use. You do not need to identify if a recipient is internal or external when adding recipients to a template, the public and private email providers do this.  It also means that private notification content is more secure, as it cannot be accidentally sent to an address that is not registered as an Admin_User.
--------------------

The Public provider allows you to set the sender name and email by simply declaring them in the template class. Declaring them in the class also allows the fields to be  changed on template edit screen.

class module_my_notification_template extends Notify_Template_Base
{
    public $required_params = array('recipient');
    public $sender_name = 'Courses Department';
    public $sender_email = 'courses@our-company.com';
}

------------------