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_tickets extends Folks_Notification {
14: 
15:     /**
16:      * Returns method human name
17:      */
18:     public function getName()
19:     {
20:         return $GLOBALS['registry']->get('name', 'whups');
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 (!$GLOBALS['registry']->hasInterface('tickets') ||
33:                 $type == 'admins') {
34:             return false;
35:         }
36: 
37:         return false;
38:     }
39: 
40:     /**
41:      * Notify user
42:      *
43:      * @param mixed  $user        User or array of users to send notification to
44:      * @param string $subject     Subject of message
45:      * @param string $body        Body of message
46:      * @param array  $attachments Attached files
47:      *
48:      * @return true on succes, PEAR_Error on failure
49:      */
50:     public function notify($user, $subject, $body, $attachments = array())
51:     {
52:         global $registry;
53: 
54:         $info = array_merge($this->_params['ticket_params'],
55:                             array('summary' => $subject,
56:                                     'comment' => $body,
57:                                     'user_email' => $this->_getUserFromAddr()));
58: 
59:         $ticket_id = $registry->call('tickets/addTicket', array($info));
60: 
61:         if (empty($attachments) ||
62:             !$registry->hasMethod('tickets/addAttachment')) {
63:             return $result;
64:         }
65: 
66:         foreach ($attachments as $attachment) {
67:             $result = $registry->call(
68:                 'tickets/addAttachment',
69:                         array('ticket_id' => $ticket_id,
70:                                 'name' => $attachment['name'],
71:                                 'data' => file_get_contents($attachment['file'])));
72:         }
73: 
74:         return true;
75:     }
76: }
77: 
API documentation generated by ApiGen