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:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
 4:  *
 5:  * See the enclosed file COPYING for license information (GPL). If you
 6:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 7:  *
 8:  * @author Duck <duck@obala.net>
 9:  * @package Folks
10:  */
11: class Folks_Activity_Form extends Horde_Form {
12: 
13:     /**
14:      */
15:     function __construct($vars, $title, $name)
16:     {
17:         parent::__construct($vars, $title, $name);
18: 
19:         if ($name == 'long') {
20:             $this->addVariable(_("Activity"), 'activity', 'longText', true, false, null, array(4));
21:         } else {
22:             $this->addVariable(_("Activity"), 'activity', 'text', true, false, null, array('', 80));
23:         }
24: 
25:         $this->setButtons(_("Post"));
26:     }
27: 
28:     /**
29:      */
30:     function execute()
31:     {
32:         $message = trim(strip_tags($this->_vars->get('activity')));
33: 
34:         if (empty($message)) {
35:             return PEAR::raiseError(_("You cannot post an empty activity message."));
36:         }
37: 
38:         $filters = array('text2html', 'bbcode', 'highlightquotes', 'emoticons');
39:         $filters_params = array(array('parselevel' => Horde_Text_Filter_Text2html::MICRO),
40:                                 array(),
41:                                 array(),
42:                                 array());
43: 
44:         if (($hasBBcode = strpos($message, '[')) !== false &&
45:                 strpos($message, '[/', $hasBBcode) !== false) {
46:             $filters_params[0]['parselevel'] = Horde_Text_Filter_Text2html::NOHTML;
47:         }
48: 
49:         $message = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter(trim($message), $filters, $filters_params);
50: 
51:         $result = $GLOBALS['folks_driver']->logActivity($message, 'folks:custom');
52:         if ($result instanceof PEAR_Error) {
53:             return $result;
54:         }
55: 
56:         if ($conf['facebook']['enabled']) {
57:             $message = trim(strip_tags($this->_vars->get('activity')));
58:             register_shutdown_function(array(&$this, '_facebook'), $message);
59:         }
60: 
61:         return true;
62:     }
63: 
64:     /**
65:      */
66:     public function _facebook($message)
67:     {
68:         global $conf, $prefs;
69: 
70:         // Check FB installation
71:         if (!$conf['facebook']['enabled']) {
72:             return true;
73:         }
74: 
75:         // Chacke FB user config
76:         $fbp = unserialize($prefs->getValue('facebook'));
77:         if (!$fbp || empty($fbp['uid'])) {
78:             return true;
79:         }
80: 
81:         // Load FB
82:         $context = array('http_client' => new Horde_Http_Client(),
83:                          'http_request' => $GLOBALS['injector']->getInstance('Horde_Controller_Request'));
84:         $facebook = new Horde_Service_Facebook($conf['facebook']['key'],
85:                                                $conf['facebook']['secret'],
86:                                                $context);
87: 
88:         $facebook->auth->setUser($fbp['uid'], $fbp['sid'], 0);
89: 
90:         try {
91:             $facebook->users->setStatus($message);
92:         } catch (Horde_Service_Facebook_Exception $e) {
93:             // Do noting as we are exiting
94:         }
95:     }
96: }
97: 
API documentation generated by ApiGen