[20844] update messenger

Sigurd Nes <[email protected]>
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 20844
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20844
Author:   sigurdne
Date:     2009-11-20 10:27:41 +0000 (Fri, 20 Nov 2009)
Log Message:
-----------
update messenger

Modified Paths:
--------------
    people/sigurdne/modules/messenger/trunk/inc/class.bomessenger.inc.php
    people/sigurdne/modules/messenger/trunk/inc/class.somessenger.inc.php
    people/sigurdne/modules/messenger/trunk/inc/class.uimessenger.inc.php
    people/sigurdne/modules/messenger/trunk/inc/hook_config.inc.php
    people/sigurdne/modules/messenger/trunk/setup/setup.inc.php
    people/sigurdne/modules/messenger/trunk/templates/base/form.tpl

Added Paths:
-----------
    people/sigurdne/modules/messenger/trunk/inc/class.menu.inc.php
    people/sigurdne/modules/messenger/trunk/setup/phpgw_no.lang

Modified: people/sigurdne/modules/messenger/trunk/inc/class.bomessenger.inc.php
===================================================================
--- people/sigurdne/modules/messenger/trunk/inc/class.bomessenger.inc.php	2009-11-20 10:27:37 UTC (rev 20843)
+++ people/sigurdne/modules/messenger/trunk/inc/class.bomessenger.inc.php	2009-11-20 10:27:41 UTC (rev 20844)
@@ -38,7 +38,7 @@
 			$users = array();
 
 			$config = createObject('phpgwapi.config', 'messenger');
-			$config->read_repository();
+			$config->read();
 
 			if ( !isset($GLOBALS['phpgw_info']['user']['apps']['admin']) 
 				&& isset($config->data['restrict_to_group'] )
@@ -47,7 +47,7 @@
 				$tmp_users = $GLOBALS['phpgw']->accounts->member($config->data['restrict_to_group']);
 				foreach ( $tmp_users as $user )
 				{
-					$users[$user['account_id']] = $user['account_name'];
+					$users[$user->id] = $user['account_name'];
 				}
 			}
 			else
@@ -55,7 +55,7 @@
 				$tmp_users = $GLOBALS['phpgw']->accounts->get_list('accounts', -1, 'ASC', 'account_lid', '', -1);
 				foreach ( $tmp_users as $user )
 				{
-					$users[$user['account_id']] = $GLOBALS['phpgw']->common->display_fullname($user['account_lid'], $user['account_firstname'], $user['account_lastname']);
+					$users[$user->id] = $GLOBALS['phpgw']->common->display_fullname($user->lid, $user->firstname, $user->lastname);
 				}
 			}
 			return $users;
@@ -71,9 +71,9 @@
 			}
 			else
 			{
-				$message = get_var('message',Array('POST'));
-				$send    = get_var('send',Array('POST'));
-				$cancel  = get_var('cancel',Array('POST'));
+				$message = phpgw::get_var('message');
+				$send    = phpgw::get_var('send');
+				$cancel  = phpgw::get_var('cancel');
 			}
 
 			if (! $GLOBALS['phpgw']->acl->check('run',1,'admin') || $cancel)
@@ -102,9 +102,10 @@
 				$account_info = $GLOBALS['phpgw']->accounts->get_list('accounts');
 
 				$this->so->db->transaction_begin();
-				while (list(,$account) = each($account_info))
+				
+				foreach($account_info as $account)
 				{
-					$message['to'] = $account['account_lid'];
+					$message['to'] = $account->id;
 					$this->so->send_message($message,True);
 				}
 				$this->so->db->transaction_commit();
@@ -118,7 +119,8 @@
 			if ($message['to'] > 0)
 			{
 				$user = $this->get_available_users();
-				if ( isset($user[$message['to']]) )
+
+				if ( !isset($user[$message['to']]) )
 				{
 					$errors[] = lang('You are not allow to send messages to the user you have selected');
 				}
@@ -129,7 +131,7 @@
 			}
 			
 			$acct = createobject('phpgwapi.accounts', $message['to']);
-			$acct->read_repository();
+			$acct->read();
 			if ($acct->is_expired() && $GLOBALS['phpgw']->accounts->name2id($message['to']))
 			{
 				$errors[] = lang("Sorry, %1's account is not currently active",$message['to']);
@@ -191,6 +193,7 @@
 			$_messages = array();
 
 			$messages = $this->so->read_inbox($params);
+
 			foreach ( $messages as $message )
 			{
 				if ($message['from'] == -1)
@@ -202,10 +205,9 @@
 				// Cache our results, so we don't query the same account multiable times
 				if ( !isset($cached[$message['from']]) || !$cached[$message['from']] )
 				{
-					$acct = createobject('phpgwapi.accounts',$message['from']);
-					$acct->read_repository();
+					$acct = $GLOBALS['phpgw']->accounts->get($message['from']);
 					$cached[$message['from']]       = $message['from'];
-					$cached_names[$message['from']] = $GLOBALS['phpgw']->common->display_fullname($acct->data['account_lid'],$acct->data['firstname'],$acct->data['lastname']);
+					$cached_names[$message['from']] = $acct->__toString();
 				}
 
 				/*
@@ -256,9 +258,8 @@
 			}
 			else
 			{
-				$acct = createobject('phpgwapi.accounts',$message['from']);
-				$acct->read_repository();
-				$message['from'] = $GLOBALS['phpgw']->common->display_fullname($acct->data['account_lid'],$acct->data['firstname'],$acct->data['lastname']);
+				$acct = $GLOBALS['phpgw']->accounts->get($message['from']);
+				$message['from'] = $acct->__toString();
 			}
 
 			return $message;
@@ -268,20 +269,19 @@
 		{
 			if(!$n_message)
 			{
-				$n_message = get_var('n_message',Array('POST'));
+				$n_message = phpgw::get_var('n_message');
 			}
 
 			$message = $this->so->read_message($message_id);
 
-			$acct = createobject('phpgwapi.accounts',$message['from']);
-			$acct->read_repository();
+			$acct = $GLOBALS['phpgw']->accounts->get($message['from']);
 
 			if (! $n_message['content'])
 			{
 				$content_array = explode("\n",$message['content']);
 
 				$new_content_array[] = ' ';
-				$new_content_array[] = '> ' . $GLOBALS['phpgw']->common->display_fullname($acct->data['account_lid'],$acct->data['firstname'],$acct->data['lastname']) . ' wrote:';
+				$new_content_array[] = '> ' . $acct->__toString() . ' wrote:';
 				$new_content_array[] = '>';
 				while (list(,$line) = each($content_array))
 				{
@@ -291,8 +291,7 @@
 			}
 
 			$message['subject'] = $type . ': ' . $message['subject'];
-			$message['from']    = $acct->data['account_lid'];
-
+			$message['from_fullname']    = $acct->__toString();
 			return $message;
 		}
 
@@ -300,7 +299,7 @@
 		{
 			if(!$messages)
 			{
-				$messages = get_var('messages',Array('GET','POST'));
+				$messages = phpgw::get_var('messages');
 			}
 
 			if (! is_array($messages))
@@ -319,14 +318,18 @@
 
 		function reply($message_id='',$n_message='')
 		{
+			if (phpgw::get_var('cancel','bool') == true)
+			{
+				$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'messenger.uimessenger.inbox'));
+			}
 			if(!$message_id)
 			{
-				$message_id = get_var('message_id',Array('POST'));
-				$n_message  = get_var('n_message',Array('POST'));
+				$message_id = phpgw::get_var('message_id');
+				$n_message  = phpgw::get_var('n_message');
 			}
 
 			$errors = $this->check_for_missing_fields($n_message);
-			if (is_array($errors))
+			if ($errors)
 			{
 				ExecMethod('messenger.uimessenger.reply',array($errors,$n_message));
 				//$this->ui->reply($errors, $n_message);
@@ -343,8 +346,8 @@
 		{
 			if(!$message_id)
 			{
-				$message_id = get_var('message_id',Array('POST'));
-				$n_message  = get_var('n_message',Array('POST'));
+				$message_id = phpgw::get_var('message_id');
+				$n_message  = phpgw::get_var('n_message');
 			}
 
 			$errors = $this->check_for_missing_fields($n_message);

Added: people/sigurdne/modules/messenger/trunk/inc/class.menu.inc.php
===================================================================
--- people/sigurdne/modules/messenger/trunk/inc/class.menu.inc.php	                        (rev 0)
+++ people/sigurdne/modules/messenger/trunk/inc/class.menu.inc.php	2009-11-20 10:27:41 UTC (rev 20844)
@@ -0,0 +1,120 @@
+<?php
+	/**
+	* phpGroupWare - messenger
+	*
+	* @author Sigurd Nes <[email protected]>
+	* @copyright Copyright (C) 2009 Free Software Foundation, Inc. http://www.fsf.org/
+	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
+	* @package messenger
+	* @subpackage ???
+ 	* @version $Id$
+	*/
+
+	/*
+	   This program is free software: you can redistribute it and/or modify
+	   it under the terms of the GNU General Public License as published by
+	   the Free Software Foundation, either version 2 of the License, or
+	   (at your option) any later version.
+
+	   This program is distributed in the hope that it will be useful,
+	   but WITHOUT ANY WARRANTY; without even the implied warranty of
+	   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	   GNU General Public License for more details.
+
+	   You should have received a copy of the GNU General Public License
+	   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+	 */
+
+	 /**
+	 * Description
+	 * @package messenger
+	 */
+
+	class messenger_menu
+	{
+		/**
+		 * Get the menus for the messenger
+		 *
+		 * @return array available menus for the current user
+		 */
+		public function get_menu()
+		{
+			$incoming_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
+			$GLOBALS['phpgw_info']['flags']['currentapp'] = 'messenger';
+			$acl = & $GLOBALS['phpgw']->acl;
+
+			$menus = array();
+
+			$menus['navbar'] = array
+			(
+				'messenger' => array
+				(
+					'text'	=> lang('messenger'),
+					'url'	=> $GLOBALS['phpgw']->link('/index.php', array('menuaction' => "messenger.uimessenger.inbox") ),
+					'image'	=> array('messenger', 'navbar'),
+					'order'	=> 35,
+					'group'	=> 'office'
+				),
+			);
+
+			$menus['toolbar'] = array();
+			if ( isset($GLOBALS['phpgw_info']['user']['apps']['admin']) )
+			{
+				$menus['admin'] = array
+				(
+					'index'	=> array
+					(
+						'text'	=> lang('Configuration'),
+						'url'	=> $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiconfig.index', 'appname' => 'messenger') )
+					)
+				);
+			}
+
+			if ( isset($GLOBALS['phpgw_info']['user']['apps']['preferences']) )
+			{
+				$menus['preferences'] = array
+				(
+					array
+					(
+						'text'	=> $GLOBALS['phpgw']->translation->translate('Preferences', array(), true),
+						'url'	=> $GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' => 'messenger', 'type'=> 'user') )
+					),
+					array
+					(
+						'text'	=> $GLOBALS['phpgw']->translation->translate('Grant Access', array(), true),
+						'url'	=> $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'preferences.uiadmin_acl.aclprefs', 'acl_app'=> 'messenger') )
+					)
+				);
+
+				$menus['toolbar'][] = array
+				(
+					'text'	=> $GLOBALS['phpgw']->translation->translate('Preferences', array(), true),
+					'url'	=> $GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname'	=> 'messenger')),
+					'image'	=> array('messenger', 'preferences')
+				);
+			}
+
+			$menus['navigation'] = array
+			(
+				'inbox' => array
+				(
+					'url'   => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'messenger.uimessenger.inbox')),
+					'text'  => $GLOBALS['phpgw']->translation->translate('inbox', array(), true),
+					'image' => array('messenger', 'navbar')
+				),
+				'compose' => array
+				(
+					'url'   => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'messenger.uimessenger.compose')),
+					'text'  => $GLOBALS['phpgw']->translation->translate('compose', array(), true),
+				),
+				'compose_global' => array
+				(
+					'url'   => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'messenger.uimessenger.compose_global')),
+					'text'  => $GLOBALS['phpgw']->translation->translate('compose global', array(), true),
+				)
+			);
+
+			$GLOBALS['phpgw_info']['flags']['currentapp'] = $incoming_app;
+			return $menus;
+		}
+	}


Property changes on: people/sigurdne/modules/messenger/trunk/inc/class.menu.inc.php
___________________________________________________________________
Added: svn:keywords
   + Id Revision
Added: svn:eol-style
   + native

Modified: people/sigurdne/modules/messenger/trunk/inc/class.somessenger.inc.php
===================================================================
--- people/sigurdne/modules/messenger/trunk/inc/class.somessenger.inc.php	2009-11-20 10:27:37 UTC (rev 20843)
+++ people/sigurdne/modules/messenger/trunk/inc/class.somessenger.inc.php	2009-11-20 10:27:41 UTC (rev 20844)
@@ -12,7 +12,7 @@
 
 	// Now we can use this again later if we need it
 	$GLOBALS['phpgw']->config  = CreateObject('phpgwapi.config', 'messenger');
-	$GLOBALS['phpgw']->config->read_repository();
+	$GLOBALS['phpgw']->config->read();
 
 	if ( !is_array($GLOBALS['phpgw']->config->config_data) 
 		|| !isset($GLOBALS['phpgw_info']['server']['smtp_server']) 
@@ -121,4 +121,3 @@
 			return 0;
 		}
 	}
-?>

Modified: people/sigurdne/modules/messenger/trunk/inc/class.uimessenger.inc.php
===================================================================
--- people/sigurdne/modules/messenger/trunk/inc/class.uimessenger.inc.php	2009-11-20 10:27:37 UTC (rev 20843)
+++ people/sigurdne/modules/messenger/trunk/inc/class.uimessenger.inc.php	2009-11-20 10:27:41 UTC (rev 20844)
@@ -38,7 +38,6 @@
 			}
 		}
 
-
 		function compose($errors = '')
 		{
 			$message = isset($_POST['message']) ? $_POST['message'] : array('subject' => '', 'content' => '');
@@ -253,6 +252,7 @@
 			$this->_display_headers();
 			$this->_set_compose_read_blocks();
 			$this->_set_common_langs();
+			$this->template->set_block('_form','form_reply_to');
 
 			if (is_array($errors))
 			{
@@ -261,15 +261,15 @@
 
 			$this->template->set_var('header_message',lang('Reply to a message'));
 
-			$this->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'messenger.bomessenger.reply', 'message_id=' . $message['id']) ) );
-			$this->template->set_var('value_to','<input name="n_message[to]" value="' . $message['from'] . '" size="30">');
+			$this->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'messenger.bomessenger.reply', 'message_id' => $message['id']) ) );
+			$this->template->set_var('value_to',"<input type= 'hidden' name='n_message[to]' value={$message['from']}>{$message['from_fullname']}");
 			$this->template->set_var('value_subject','<input name="n_message[subject]" value="' .  $GLOBALS['phpgw']->strip_html(stripslashes($message['subject'])) . '" size="30">');
 			$this->template->set_var('value_content','<textarea name="n_message[content]" rows="20" wrap="hard" cols="76">' .  $GLOBALS['phpgw']->strip_html(stripslashes($message['content'])) . '</textarea>');
 
 			$this->template->set_var('button_send','<input type="submit" name="send" value="' . lang('Send') . '">');
 			$this->template->set_var('button_cancel','<input type="submit" name="cancel" value="' . lang('Cancel') . '">');
 
-			$this->template->fp('to','form_to');
+			$this->template->fp('to','form_reply_to');
 			$this->template->fp('buttons','form_buttons');
 			$this->template->pfp('out','form');
 		}
@@ -293,6 +293,18 @@
 			$this->_set_compose_read_blocks();
 			$this->_set_common_langs();
 
+			$users = $this->bo->get_available_users();
+			foreach ( $users as $uid => $name )
+			{
+				$this->template->set_var(array
+				(
+					'uid'		=> $uid,
+					'full_name'	=> $name
+				));
+				$this->template->parse('select_tos', 'select_to', true);
+			}
+
+
 			if (is_array($errors))
 			{
 				$this->template->set_var('errors',$GLOBALS['phpgw']->common->error_list($errors));
@@ -341,7 +353,6 @@
 			die( lang('exiting with error!') . "<br />\n" . lang('Unable to connect to server, please contact your system administrator') );
 		}
 		
-		
 		function _set_common_langs()
 		{
 			$this->template->set_var('lang_to',lang('Send message to'));
@@ -365,4 +376,3 @@
 			$this->template->set_block('_form','form_read_buttons_for_global');
 		}
 	}
-?>

Modified: people/sigurdne/modules/messenger/trunk/inc/hook_config.inc.php
===================================================================
--- people/sigurdne/modules/messenger/trunk/inc/hook_config.inc.php	2009-11-20 10:27:37 UTC (rev 20843)
+++ people/sigurdne/modules/messenger/trunk/inc/hook_config.inc.php	2009-11-20 10:27:41 UTC (rev 20844)
@@ -15,7 +15,7 @@
 *  option) any later version.                                              *
 \**************************************************************************/
 
-	/* $Id: hook_config.inc.php 690 2008-02-02 10:11:33Z dave $ */
+	/* $Id: hook_config.inc.php 2266 2009-01-31 16:05:36Z sigurd $ */
 
 	function restrict_to_group($config)
 	{
@@ -23,8 +23,8 @@
 		$groups = $GLOBALS['phpgw']->accounts->get_list('groups', -1, 'ASC', 'account_lid', '', -1);
 		foreach ( $groups as $group )
 		{
-			$str .= '<option value="' . $group['account_id'] . '"' . ($config['restrict_to_group'] == $group['account_id'] ? ' selected="selected"' : '' ) .'>'
-				. $GLOBALS['phpgw']->common->display_fullname($group['account_lid'], $group['account_firstname'], $group['account_lastname'])
+			$str .= '<option value="' . $group->id . '"' . ($config['restrict_to_group'] == $group->id ? ' selected="selected"' : '' ) .'>'
+				. $GLOBALS['phpgw']->common->display_fullname($group->lid, $group->firstname, $group->lastname)
 			."</option>\n";
 		}
 		return $str;

Added: people/sigurdne/modules/messenger/trunk/setup/phpgw_no.lang
===================================================================
--- people/sigurdne/modules/messenger/trunk/setup/phpgw_no.lang	                        (rev 0)
+++ people/sigurdne/modules/messenger/trunk/setup/phpgw_no.lang	2009-11-20 10:27:41 UTC (rev 20844)
@@ -0,0 +1,34 @@
+compose	messenger	no	Ny melding
+compose global message	admin	en	Ny global melding
+compose message	messenger	no	Ny melding
+delete a message.	messenger	no	slett en melding.
+delete selected	messenger	no	Slett valgt
+forward	messenger	no	Videresend
+forward a message	messenger	no	Videresend a en melding
+forward a message to another user.	messenger	no	Videresend a en melding til en anne bruker.
+forwarded	messenger	no	Videresent
+from	messenger	no	Fra
+global message	messenger	no	Global Melding
+i can't find the username %1 on the system	messenger	no	Finner ikke bruker %1 i systemet
+inbox	messenger	no	Innboks
+message from	messenger	no	Melding fra
+messenger	common	en	Messenger
+new	messenger	no	Ny
+read a list of messages.	messenger	no	Les liste av meldinger.
+read a single message.	messenger	no	Les en enkelt melding.
+read message	messenger	no	Les melding
+replied	messenger	no	Svart på
+reply	messenger	no	Svar
+reply to a message	messenger	no	Svar på en melding
+reply to a received message.	messenger	no	Svar på en mottatt melding.
+send	messenger	no	Send
+send a global message.	messenger	no	Send en global melding.
+send a message to a single recipient.	messenger	no	Send en melding til en enkelt mottaker.
+send message to	messenger	no	Send melding til
+sorry, %1's account is not currently active	messenger	no	Beklager, %1's konto er ikke aktiv
+you didn't enter anything for the message	messenger	no	Meldingen er tom
+you have %1 new message	messenger	no	Du har %1 ny melding
+you have %1 new messages	messenger	no	Du har %1 nye meldinger
+you have no messages	messenger	no	Du har ingen meldinger
+you must enter a subject	messenger	no	Du må skrive en tittel
+you must enter the username this message is for	messenger	no	Du må velge en addressat for meldingen

Modified: people/sigurdne/modules/messenger/trunk/setup/setup.inc.php
===================================================================
--- people/sigurdne/modules/messenger/trunk/setup/setup.inc.php	2009-11-20 10:27:37 UTC (rev 20843)
+++ people/sigurdne/modules/messenger/trunk/setup/setup.inc.php	2009-11-20 10:27:41 UTC (rev 20844)
@@ -27,11 +27,15 @@
 	);
 
 	/* The hooks this app includes, needed for hooks registration */
-	$setup_info['messenger']['hooks'][] = 'admin';
-	$setup_info['messenger']['hooks'][] = 'preferences';
-	$setup_info['messenger']['hooks'][] = 'home';
-	$setup_info['messenger']['hooks'][] = 'after_navbar';
-	$setup_info['messenger']['hooks'][] = 'config';
+	$setup_info['messenger']['hooks'] = array
+	(
+		'admin',
+		'preferences',
+		'home',
+		'after_navbar',
+		'config',
+		'menu'	=> 'messenger.menu.get_menu'
+	);
 
 	/* Dependencies for this app to work */
 	$setup_info['messenger']['depends'][] = array(

Modified: people/sigurdne/modules/messenger/trunk/templates/base/form.tpl
===================================================================
--- people/sigurdne/modules/messenger/trunk/templates/base/form.tpl	2009-11-20 10:27:37 UTC (rev 20843)
+++ people/sigurdne/modules/messenger/trunk/templates/base/form.tpl	2009-11-20 10:27:41 UTC (rev 20844)
@@ -64,6 +64,14 @@
    </td>
   </tr>
 <!-- END form_to -->
+<!-- BEGIN form_reply_to -->
+  <tr bgcolor="{row_off}">
+   <td>{lang_to}</td>
+   <td>
+		{value_to}
+   </td>
+  </tr>
+<!-- END form_reply_to -->
 
 <!-- BEGIN form_read_buttons -->
 {link_reply}&nbsp;|&nbsp;{link_forward}&nbsp;|&nbsp;{link_delete}&nbsp;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.