From c4bb0dcf988a5a23ef0428a7427d00f92aedef35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Thu, 7 Sep 2006 06:58:58 +0000 Subject: [PATCH] me again against svn --- .../inc/class.iface_notification.inc.php | 31 ---- notifications/inc/class.notification.inc.php | 128 -------------- .../inc/class.notification_popup.inc.php | 163 ------------------ .../inc/class.uinotificationprefs.inc.php | 83 --------- notifications/inc/hook_after_navbar.inc.php | 29 ---- notifications/inc/hook_preferences.inc.php | 23 --- notifications/js/notificationajaxpopup.js | 41 ----- notifications/setup/etemplates.inc.php | 9 - notifications/setup/phpgw_de.lang | 4 - notifications/setup/phpgw_en.lang | 4 - notifications/setup/setup.inc.php | 48 ------ notifications/setup/tables_current.inc.php | 24 --- .../templates/default/images/navbar.png | Bin 1496 -> 0 bytes 13 files changed, 587 deletions(-) delete mode 100644 notifications/inc/class.iface_notification.inc.php delete mode 100644 notifications/inc/class.notification.inc.php delete mode 100644 notifications/inc/class.notification_popup.inc.php delete mode 100644 notifications/inc/class.uinotificationprefs.inc.php delete mode 100644 notifications/inc/hook_after_navbar.inc.php delete mode 100644 notifications/inc/hook_preferences.inc.php delete mode 100644 notifications/js/notificationajaxpopup.js delete mode 100644 notifications/setup/etemplates.inc.php delete mode 100644 notifications/setup/phpgw_de.lang delete mode 100644 notifications/setup/phpgw_en.lang delete mode 100644 notifications/setup/setup.inc.php delete mode 100644 notifications/setup/tables_current.inc.php delete mode 100644 notifications/templates/default/images/navbar.png diff --git a/notifications/inc/class.iface_notification.inc.php b/notifications/inc/class.iface_notification.inc.php deleted file mode 100644 index 872bc56706..0000000000 --- a/notifications/inc/class.iface_notification.inc.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @version $Id: $ - */ - -/** - * Instant user notification - */ -interface iface_notification { - - /** - * constructor - * - * @param object $_account - * @param object $_preferences - */ - public function __construct( $_account, $_preferences ); - - /** - * sends notification - * - * @param string $_message - */ - public function send( $_message ); -} diff --git a/notifications/inc/class.notification.inc.php b/notifications/inc/class.notification.inc.php deleted file mode 100644 index f490463946..0000000000 --- a/notifications/inc/class.notification.inc.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @version $Id: $ - */ - -/** - * Notifies users according to there preferences. - * - * @abstract NOTE:Notifications are small messages. No subject and no attechments. - * If you need this kind of elements you probably want to send a mail, woun't you :-) - * @abstract NOTE: This is for instant notifications. If you need time dependend notifications use the - * asyncservices wrapper! - * - * The classes doing the notifications are called notification_ and should only be - * called from this class. - * The gets extractd out of the preferences labels. - * - */ -final class notification { - - /** - * Appname - */ - const _appname = 'notifications'; - - /** - * array with objects of receivers - * @var array - */ - private $receivers = array(); - - /** - * holds notification message - * @var string - */ - private $message = ''; - - /** - * sets notification message - * @param string &$message - */ - public function set_message($_message) { - $this->message = $_message; - return true; - } - - /** - * Set receivers for the current notification - * - * @param array $_receivers array with objects of accounts - * as long as the accounts class isn't a nice object, it's an array of account id's :-( - */ - public function set_receivers(array $_receivers) { - foreach ($_receivers as $receiver_id) { - $receiver = $GLOBALS['egw']->accounts->get_account_data($receiver_id); - $receiver[$receiver_id]['id'] = $receiver_id; - $this->receivers[$receiver_id] = (object)$receiver[$receiver_id]; - } - } - - /** - * sends notification - */ - public function send() { - if (empty($this->receivers) || !$this->message) { - throw new Exception('Error: Coud not send notification. No receiver or no message where supplied'); - } - - foreach ($this->receivers as $receiver) { - $prefs = new preferences($receiver->id); - $preferences = $prefs->read(); - $preferences = (object)$preferences[self::_appname ]; - - if (!$preferences->disable_ajaxpopup) { - $notification_backends[] = 'notification_popup'; - } - - $send_succseed = 0; - foreach ((array)$notification_backends as $notification_backend) { - try { - require_once(EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.'. $notification_backend. '.inc.php'); - - $obj = @new $notification_backend( $receiver, $preferences ); - if ( !is_a( $obj, iface_notification )) { - unset ( $obj ); - throw new Exception('Error: '.$notification_backend. ' is no implementation of iface_notification'); - } - - $obj->send( $this->message ); - $send_succseed++; - } - catch (Exception $exception) { - $send_succseed--; - echo $exception->getMessage(), "\n"; - } - } - - if ($send_succseed == 0) { - throw new Exception('Error: Was not able to send Notification to user!'); - } - } - } - - /** - * gets message - * - * @return string - */ - public function get_message() { - return $this->message; - } - - /** - * gets receivers - * - * @return array of account objects - */ - public function get_receivers() { - return $this->receivers; - } - -} diff --git a/notifications/inc/class.notification_popup.inc.php b/notifications/inc/class.notification_popup.inc.php deleted file mode 100644 index 452ed22db6..0000000000 --- a/notifications/inc/class.notification_popup.inc.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @version $Id: $ - */ - -require_once('class.iface_notification.inc.php'); - -/** - * Instant user notification with egroupware popup. - * egwpopup is a two stage notification. In the first stage - * notification is written into self::_notification_egwpopup - * table. In the second stage a request from the client reads - * out the table to look if there is a notificaton for this - * client. (multidisplay is supported) - */ -class notification_popup implements iface_notification { - - /** - * Notification window {div|alert} - */ - const _window = 'div'; - - /** - * Appname - */ - const _appname = 'notifications'; - - /** - * Notification table in SQL database - */ - const _notification_table = 'egw_notificationpopup'; - - /** - * holds account object for user to notify - * - * @var object - */ - private $account; - - /** - * holds preferences object of user to notify - * - * @var unknown_type - */ - private $preferences; - - /** - * holds db object of SQL database - * - * @var unknown_type - */ - private $db; - - /** - * constructor of notification_egwpopup - * - * @param object $_account - * @param object $_preferences - */ - public function __construct( $_account=false, $_preferences=false) { - // If we are called from class notification account and prefs are objects. - // otherwise we have to fetch this objects for current user. - if (!is_object($_account)) { - $account_id = $GLOBALS['egw_info']['user']['account_id']; - $this->account = $GLOBALS['egw']->accounts->get_account_data($account_id); - $this->account[$account_id]['id'] = $account_id; - $this->account = (object)$this->account[$account_id]; - } - else { - $this->account = $_account; - } - $this->preferences = is_object($_preferences) ? $_preferences : $GLOBALS['egw']->preferences; - $this->db = &$GLOBALS['egw']->db; - $this->db->set_app( self::_appname ); - } - - /** - * sends notification if user is online - * - * @param string $_message - */ - public function send( $_message ) { - $sessions = $GLOBALS['egw']->session->list_sessions(0, 'asc', 'session_dla', true); - $user_sessions = array(); - foreach ($sessions as $session) { - if ($session['session_lid'] == $this->account->lid. '@'. $GLOBALS['egw_info']['user']['domain']) { - $user_sessions[] = $session['session_id']; - } - } - if ( empty($user_sessions) ) throw new Exception("Notice: User isn't online. Can't send notification via popup"); - $this->save( $_message, $user_sessions ); - } - - /** - * Gets all notification for current user. - * Requests and response is done via xajax - * - * @return xajax response - */ - public function ajax_get_notifications() { - $response =& new xajaxResponse(); - $session_id = $GLOBALS['egw_info']['user']['sessionid']; - $message = ''; - $this->db->select(self::_notification_table, - '*', array( - 'account_id' => $this->account->id, - 'session_id' => $session_id, - ), - __LINE__,__FILE__); - if ($this->db->num_rows() != 0) { - while ($notification = $this->db->row(true)) { - switch (self::_window ) { - case 'div' : - $message .= nl2br($notification['message']). '
'; - break; - case 'alert' : - $message .= $notification['message']. "\n"; - break; - } - } - $this->db->delete(self::_notification_table,array( - 'account_id' =>$this->account->id, - 'session_id' => $session_id, - ),__LINE__,__FILE__); - - switch (self::_window) { - case 'div' : - $response->addAppend('notificationwindow_message','innerHTML',$message); - $response->addScript('notificationwindow_display();'); - break; - case 'alert' : - $response->addAlert($message); - break; - } - } - return $response->getXML(); - } - - /** - * saves notification into database so that the client can fetch it from - * there via notification->get - * - * @param string $_message - * @param array $_user_sessions - */ - private function save( $_message, array $_user_sessions ) { - foreach ($_user_sessions as $user_session) { - $result =& $this->db->insert( self::_notification_table, array( - 'account_id' => $this->account->id, - 'session_id' => $user_session, - 'message' => $_message - ), false,__LINE__,__FILE__); - } - if ($result === false) throw new Exception("Error: Can't save notification into SQL table"); - } -} diff --git a/notifications/inc/class.uinotificationprefs.inc.php b/notifications/inc/class.uinotificationprefs.inc.php deleted file mode 100644 index b6644a34c7..0000000000 --- a/notifications/inc/class.uinotificationprefs.inc.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @version $Id: $ - */ - -require_once(EGW_INCLUDE_ROOT. SEP. 'etemplate'. SEP. 'inc'. SEP. 'class.etemplate.inc.php'); - -class uinotificationprefs { - - const _appname = 'notifications'; - - public $public_functions = array( - 'index' => true, - ); - - /** - * This are the preferences for notifications - * - * @var array - */ - private $notification_preferences = array( - 'disable_ajaxpopup' => '', // bool: true / false - ); - - /** - * Holds preferences object for current user - * - * @var object - */ - private $preferences; - - public function __construct($_account_id = 0, $_referer = false) { - $account_id = $_account_id > 0 ? $_account_id : $GLOBALS['egw_info']['user']['account_id']; - $this->preferences = new preferences($account_id); - $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences for notification'); - } - - public function index($_content = false) { - $et = new etemplate(self::_appname. '.prefsindex'); - $content = array(); - $sel_options = array(); - $readonlys = array(); - $preserv = array(); - if (is_array($_content)) { - if (is_array($_content['button'])) { - $preferences = array_intersect_key($_content, $this->notification_preferences); - list($button) = each($_content['button']); - switch ($button) { - case 'save' : - $this->save($preferences); - $GLOBALS['egw']->redirect_link($_content['referer']); - case 'apply' : - $this->save($preferences); - break; - case 'cancel' : - default : - $GLOBALS['egw']->redirect_link($_content['referer']); - } - } - } - else { - $preferences = $this->preferences->read(); - $preferences = $preferences[self::_appname]; - $preserv['referer'] = $GLOBALS['egw']->common->get_referer(); - } - - $content = array_merge($content,(array)$preferences); - return $et->exec(self::_appname. '.uinotificationprefs.index',$content,$sel_options,$readonlys,$preserv); - } - - private function save($_preferences) { - $this->preferences->read(); - $this->preferences->user[self::_appname] = $_preferences; - $this->preferences->save_repository(); - return; - } -} \ No newline at end of file diff --git a/notifications/inc/hook_after_navbar.inc.php b/notifications/inc/hook_after_navbar.inc.php deleted file mode 100644 index 5e96f7325a..0000000000 --- a/notifications/inc/hook_after_navbar.inc.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @version $Id: $ - * @todo check if user wants notifications via egw popup! - */ -$GLOBALS['egw']->translation->add_app('notifications'); -if (!$GLOBALS['egw_info']['user']['preferences']['notifications']['disable_ajaxpopup']) { - echo ''; - echo ''; - echo ' -