Overview

Packages

  • Folks
  • None

Classes

  • Folks
  • Folks_Activity_Form
  • Folks_Api
  • Folks_Application
  • Folks_Block_Activities
  • Folks_Block_Friends
  • Folks_Block_Know
  • Folks_Block_New
  • Folks_Block_Random
  • Folks_Block_Recent
  • Folks_Driver
  • Folks_Driver_sql
  • Folks_Friends
  • Folks_Friends_application
  • Folks_Friends_facebook
  • Folks_Friends_prefs
  • Folks_Friends_shared
  • Folks_Friends_sql
  • Folks_Login_Form
  • Folks_Notification
  • Folks_Notification_facebook
  • Folks_Notification_letter
  • Folks_Notification_mail
  • Folks_Notification_tickets
  • Folks_Search_Form
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Folks Notification Class.
 4:  *
 5:  * Copyright Obala d.o.o. (www.obala.si)
 6:  *
 7:  * See the enclosed file COPYING for license information (GPL). If you
 8:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 9:  *
10:  * @author  Duck <duck@obala.net>
11:  * @package Folks
12:  */
13: class Folks_Notification_letter extends Folks_Notification {
14: 
15:     /**
16:      * Returns method human name
17:      */
18:     public function getName()
19:     {
20:         return $GLOBALS['registry']->get('name', 'letter');
21:     }
22: 
23:     /**
24:      * Checks if a driver is available for a certain notification type
25:      *
26:      * @param string $type Notification type
27:      *
28:      * @return boolean
29:      */
30:     public function isAvailable($type)
31:     {
32:         if ($type == 'friends') {
33:             return $GLOBALS['registry']->hasMethod('users/getFriends');
34:         }
35: 
36:         return true;
37:     }
38: 
39:     /**
40:      * Notify user
41:      *
42:      * @param mixed  $user        User or array of users to send notification to
43:      * @param string $subject     Subject of message
44:      * @param string $body        Body of message
45:      * @param array  $attachments Attached files
46:      *
47:      * @return true on succes, PEAR_Error on failure
48:      */
49:     public function notify($user, $subject, $body, $attachments = array())
50:     {
51:         if (empty($user)) {
52:             return true;
53:         }
54: 
55:         return $GLOBALS['registry']->callByPackage(
56:             'letter', 'sendMessage', array($user,
57:                                            array('title' => $subject,
58:                                                  'content' => $body,
59:                                                  'attachments' => $attachments)));
60:     }
61: 
62:     /**
63:      * Notify user's friends
64:      *
65:      * @param mixed  $user        User or array of users to send notification to
66:      * @param string $subject     Subject of message
67:      * @param string $body        Body of message
68:      * @param array  $attachments Attached files
69:      *
70:      * @return true on succes, PEAR_Error on failure
71:      */
72:     public function notifyFriends($user, $subject, $body, $attachments = array())
73:     {
74:         $friends = $GLOBALS['registry']->call('users/getFriends');
75:         return $this->notify($friends, $subject, $body, $attachments);
76:     }
77: }
78: 
API documentation generated by ApiGen