Index: contrib/resources/todo
===================================================================
--- contrib/resources/todo	(revision 3524)
+++ contrib/resources/todo	(revision 3524)
@@ -0,0 +1,12 @@
+TODO:
+- some artwork : general resource pictures like (room, car, beamer ...) (Benkom)
+- sitemgr module
+
+- list 
+	select all button --> add actions for selected: move to other cat,...
+	
+Long Term todo's:
+---------------------------
+advanced search dialog, accessable via sideboxmenu
+add buy and prize functionality
+add location functionality
Index: contrib/resources/inc/class.resources_hooks.inc.php
===================================================================
--- contrib/resources/inc/class.resources_hooks.inc.php	(revision 3524)
+++ contrib/resources/inc/class.resources_hooks.inc.php	(revision 3524)
@@ -0,0 +1,136 @@
+<?php
+/**
+ * eGroupWare - resources
+ * General hook object for resources
+ * It encapsulats all the diffent hook methods
+ *
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @package resources
+ * @link http://www.egroupware.org
+ * @version $Id: class.resources_hooks.inc.php 19821 2005-11-14 18:16:56Z nelius_weiss $
+ */
+
+/**
+ * General hook object for resources
+ * It encapsulats all the diffent hook methods
+ * @package resources
+ */
+class resources_hooks
+{
+	function admin_prefs_sidebox($args)
+	{
+		$this->acl =& CreateObject('resources.bo_acl');
+		
+		$appname = 'resources';
+		$location = is_array($args) ? $args['location'] : $args;
+		
+		if ($location == 'sidebox_menu')
+		{
+			$title = $GLOBALS['phpgw_info']['apps']['resources']['title'].' '.lang('Menu');
+			$file[] = array(
+					'text' => lang('resources list'),
+					'no_lang' => true,
+					'link' => $GLOBALS['phpgw']->link('/index.php',array('menuaction' => 'resources.ui_resources.index' )),
+// 					'icon' => 
+			);
+			
+			if($this->acl->get_cats(phpgw_ACL_ADD))
+			{
+				$file[] = array(
+					'text' => '<a class="textSidebox" href="'.$GLOBALS['phpgw']->link('/index.php',array('menuaction' => 'resources.ui_resources.edit')).
+						'" onclick="window.open(this.href,\'_blank\',\'dependent=yes,width=800,height=600,scrollbars=yes,status=yes\'); 
+						return false;">'.lang('add resource').'</a>',
+					'no_lang' => true,
+					'link' => false
+				);
+			}
+// 			$file[] = array(
+// 					'text' => lang('planer'),
+// 					'no_lang' => true,
+// 					'link' => $GLOBALS['phpgw']->link('/index.php',array('menuaction' => 'resources.ui_calviews.planer' )),
+// 					'icon' => 
+// 			);
+			display_sidebox($appname,$title,$file);
+		}
+
+/*		if ($GLOBALS['phpgw_info']['user']['apps']['preferences'] && $location != 'admin')
+		{
+			$file = array(
+				'Preferences'     => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname),
+				'Grant Access'    => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
+				'Edit Categories' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True')
+			);
+			if ($location == 'preferences')
+			{
+				display_section($appname,$file);
+			}
+			else
+			{
+				display_sidebox($appname,lang('Preferences'),$file);
+			}
+		}
+*/
+		if ($GLOBALS['phpgw_info']['user']['apps']['admin'] && $location != 'preferences')
+		{
+			$file = Array(
+				'Site configuration' => $GLOBALS['phpgw']->link('/index.php',array(
+					'menuaction' => 'resources.ui_resources.admin' )),
+				'Global Categories'  => $GLOBALS['phpgw']->link('/index.php',array(
+					'menuaction' => 'admin.uicategories.index',
+					'appname'    => $appname,
+					'global_cats'=> true)),
+				'Configure Access Permissions' => $GLOBALS['phpgw']->link('/index.php',
+					'menuaction=resources.ui_acl.acllist'),
+				'Custom Fields'=>$GLOBALS['phpgw']->link('/index.php',
+					'menuaction=admin.customfields.edit&appname=resources'),
+// 				'CSV-Import'         => $GLOBALS['phpgw']->link('/infolog/csv_import.php')
+			);
+			if ($location == 'admin')
+			{
+				display_section($appname,$file);
+			}
+			else
+			{
+				display_sidebox($appname,lang('Admin'),$file);
+			}
+		}
+	}
+	
+	function search_link($args)
+	{
+		return array(
+			'query' => 'resources.bo_resources.link_query',
+			'title' => 'resources.bo_resources.link_title',
+			'view' => array(
+				'menuaction' => 'resources.ui_resources.show'
+			),
+			'view_id' => 'res_id',
+			'view_popup' => '850x600',
+			'add'        => array(
+				'menuaction' => 'resources.ui_resources.edit',
+			),
+			'add_app'    => 'link_app',
+			'add_id'     => 'link_id',	
+			'add_popup'  => '800x600',
+		);
+	}
+
+	function calendar_resources($args)
+	{
+		return array(	
+			'widget' => 'resources_select',// widget to use for the selection of resources
+			'info' => 'resources.bo_resources.get_calendar_info',// info method, returns array with id, type & name for a given id
+			'max_quantity' => 'useable',// if set, key for max. quantity in array returned by info method
+			'new_status' => 'resources.bo_resources.get_calendar_new_status',// method returning the status for new items, else 'U' is used
+			'type' => 'r',// one char type-identifiy for this resources
+			'icon' => 'calicon',//icon 
+			'participants_header' => lang('resources'), // header of participants from this type
+			'cal_sidebox' => array(
+				'menu_title' => lang('Select resources'),
+				'file' => 'resources.ui_resources.get_calendar_sidebox'
+			)
+		);
+	}
+}
+
+?>
Index: contrib/resources/inc/class.bo_acl.inc.php
===================================================================
--- contrib/resources/inc/class.bo_acl.inc.php	(revision 3524)
+++ contrib/resources/inc/class.bo_acl.inc.php	(revision 3524)
@@ -0,0 +1,208 @@
+<?php
+/**
+ * eGroupWare - resources
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
+ * @package resources
+ * @link http://www.egroupware.org
+ * @version $Id: class.bo_acl.inc.php 22893 2006-12-07 08:12:19Z nelius_weiss $
+ */
+
+/**
+ * ACL business object for resources
+ *
+ * @package resources
+ */
+class bo_acl
+{
+	/**
+	* @var $permissions Holds alls permissions for resources of user 
+	*/
+	var $permissions;
+	
+	var $acl;
+	var $start = 0;
+	var $query = '';
+	var $sort  = '';
+	var $total = 0;
+	var $cats;
+
+	var $debug;
+	var $use_session = False;
+
+	function bo_acl($session=False)
+	{
+		define('phpgw_ACL_CAT_ADMIN',64);
+		define('phpgw_ACL_DIRECT_BOOKING',128);
+		define('phpgw_ACL_CALREAD',256);
+
+		$this->permissions = $GLOBALS['phpgw']->acl->get_all_location_rights($GLOBALS['phpgw_info']['user']['account_id'],'resources',true);
+		$this->phpgw_cats =& CreateObject('phpgwapi.categories','','resources');
+		$this->debug = False;
+		
+		//all this is only needed when called from uiacl.
+		if($session)
+		{
+			$this->read_sessiondata();
+			$this->use_session = True;
+			foreach(array('start','query','sort','order') as $var)
+			{
+				if (isset($_POST[$var]))
+				{
+					$this->$var = $_POST[$var];
+				}
+				elseif (isset($_GET[$var]))
+				{
+					$this->$var = $_GET[$var];
+				}
+			}
+			$this->save_sessiondata();
+			$this->cats = $this->phpgw_cats->return_sorted_array(0,false,'','','',true);
+		}
+	}
+
+	/**
+	* get list of cats where current user has given rights
+	*
+	* @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	* @param int $perm_type one of phpgw_ACL_READ, phpgw_ACL_ADD, phpgw_ACL_EDIT, phpgw_ACL_DELETE, phpgw_ACL_DIRECT_BOOKING
+	* @return array cat_id => cat_name
+	* TODO mark subcats and so on!
+	*/
+	function get_cats($perm_type)
+	{
+		$cats = $this->phpgw_cats->return_sorted_array(0,false,'','','',true);
+		while (list(,$cat) = @each($cats))
+		{
+			if($this->is_permitted($cat['id'],$perm_type))
+			{
+				for ($j=0,$s=''; $j < $cat['level']; $j++)
+				{
+					$s .= '&nbsp;';
+				}
+				$s .= $GLOBALS['phpgw']->strip_html($cat['name']);
+				if ($cat['app_name'] == 'phpgw')
+				{
+					$s .= '&nbsp;&lt;' . lang('Global') . '&gt;';
+				}
+				if ($cat['owner'] == '-1')
+				{
+					$s .= '&nbsp;&lt;' . lang('Global') . '&nbsp;' . lang($cat['app_name']) . '&gt;';
+				}
+				$perm_cats[$cat['id']] = $s;
+			}
+		}
+		return $perm_cats;
+	}
+	
+	
+	/**
+	* gets name of category 
+	*
+	* @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
+	* @param int $cat_id
+	* @return mixed name of category
+	*/
+	function get_cat_name($cat_id)
+	{
+		return $this->phpgw_cats->id2name($cat_id);
+	}
+	
+	/**
+	* gets userid of admin for given category
+	*
+	* @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	* @param int $cat_id
+	* @return int userid of cat admin
+	*/
+	function get_cat_admin($cat_id)
+	{
+		$cat_rights = $this->get_rights($cat_id);
+		foreach ($cat_rights as $userid => $right)
+		{
+			if ($right & phpgw_ACL_CAT_ADMIN)
+			{
+				return $userid;
+			}
+		}
+		return lang('none');
+	}
+	
+	/**
+	* cheks one of the following rights for current user:
+	*
+	* phpgw_ACL_READ, phpgw_ACL_ADD, phpgw_ACL_EDIT, phpgw_ACL_DELETE, phpgw_ACL_DIRECT_BOOKING
+	*
+	* @param int $cat_id
+	* @param int $right
+	* @return bool user is permitted or not for right
+	*/
+	function is_permitted($cat_id,$right)
+	{
+		return $this->permissions['L'.$cat_id] & $right;
+	}
+	
+	/**
+	* gets all rights from all user for given cat
+	*
+	* @param int $cat_id
+	* @return array userid => right
+	*/
+	function get_rights($cat_id)
+	{
+		return $GLOBALS['phpgw']->acl->get_all_rights('L'.$cat_id,'resources');
+	}
+
+
+	// privat functions from here on -------------------------------------------------------------------------
+	function save_sessiondata()
+	{
+		$data = array(
+			'start' => $this->start,
+			'query' => $this->query,
+			'sort'  => $this->sort,
+			'order' => $this->order,
+			'limit' => $this->limit,
+		);
+		if($this->debug) { echo '<br>Read:'; _debug_array($data); }
+		$GLOBALS['phpgw']->session->appsession('session_data','resources_acl',$data);
+	}
+
+	function read_sessiondata()
+	{
+		$data = $GLOBALS['phpgw']->session->appsession('session_data','resources_acl');
+		if($this->debug) { echo '<br>Read:'; _debug_array($data); }
+
+		$this->start  = $data['start'];
+		$this->query  = $data['query'];
+		$this->sort   = $data['sort'];
+		$this->order  = $data['order'];
+		$this->limit = $data['limit'];
+	}
+
+	function set_rights($cat_id,$read,$write,$calread,$calbook,$admin)
+	{
+		$readcat = $read ? $read : array();
+		$writecat = $write ? $write : array();
+		$calreadcat = $calread ? $calread : array();
+		$calbookcat = $calbook ? $calbook : array();
+		$admincat = $admin ? $admin : array();
+
+		$GLOBALS['phpgw']->acl->delete_repository('resources','L' . $cat_id,false);
+
+		foreach($GLOBALS['phpgw']->accounts->get_list() as $num => $account)
+		{
+			$account_id = $account['account_id'];
+			$rights = false;
+			$rights = in_array($account_id,$readcat) ? ($rights | phpgw_ACL_READ) : false;
+			$rights = in_array($account_id,$writecat) ? ($rights | phpgw_ACL_READ | phpgw_ACL_ADD | phpgw_ACL_EDIT | phpgw_ACL_DELETE): $rights;
+			$rights = in_array($account_id,$calreadcat) ? ($rights | phpgw_ACL_CALREAD) : $rights;
+			$rights = in_array($account_id,$calbookcat) ? ($rights | phpgw_ACL_DIRECT_BOOKING | phpgw_ACL_CALREAD) : $rights;
+			$rights = in_array($account_id,$admincat) ? ($rights = 511) : $rights;
+			if ($rights)
+			{
+				$GLOBALS['phpgw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights);
+			}
+		}
+	}
+}
Index: contrib/resources/inc/class.uicustomfields.inc.php
===================================================================
--- contrib/resources/inc/class.uicustomfields.inc.php	(revision 3524)
+++ contrib/resources/inc/class.uicustomfields.inc.php	(revision 3524)
@@ -0,0 +1,235 @@
+<?php
+	/**************************************************************************\
+	* eGroupWare - TimeSheet: Administration of custom fields                  *
+	* http://www.egroupware.org                                                *
+	* Written and (c) by Christoph Mueller Metaways Infosystems GmbH           *
+	* --------------------------------------------                             *
+	*  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; version 2 of the License.                     *
+	\**************************************************************************/
+
+	/* $Id: class.uicustomfields.inc.php 19761 2005-11-12 13:25:59Z ralfbecker $ */
+
+	/**
+	 * Administration of custom fields
+	 *
+	 * @package timesheet
+	 * @author Christoph Mueller
+	 * @copyright (c) by Ralf Becker <RalfBecker@outdoor-training.de>
+	 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+	 */
+	 
+	if (!defined('TIMESHEET_APP'))
+	{
+		define('TIMESHEET_APP','timesheet');
+	}	 
+	 
+	 
+	class uicustomfields
+	{
+		var $public_functions = array
+		(
+			'edit' => True
+		);
+
+		/**
+		 * Customfield types, without the link app-names
+		 *
+		 * @var array
+		 */
+		var $cf_types = array(
+			'text'     => 'Text',
+			'label'    => 'Label',
+			'select'   => 'Selectbox',
+			'radio'    => 'Radiobutton',
+			'checkbox' => 'Checkbox',
+		);		
+		
+		var $config;
+		var $bo;
+		var $tmpl;
+		var $fields;
+		
+		
+		function uicustomfields( )
+		{
+			$this->bo =& CreateObject('timesheet.botimesheet');
+			$this->tmpl =& CreateObject('etemplate.etemplate');
+			$this->config = &$this->bo->config;
+			$this->fields = &$this->bo->customfields;
+			
+			$GLOBALS['phpgw']->translation->add_app('etemplate');
+			foreach($this->cf_types as $name => $label) $this->cf_types[$name] = lang($label);
+			
+		}
+
+		/**
+		 * Edit/Create an Timesheet Custom field
+		 *
+		 * @param array $content Content from the eTemplate Exec
+		 */
+		function edit($content=null)
+		{
+		
+			$GLOBALS['phpgw_info']['flags']['app_header'] = lang(TIMESHEET_APP).' - '.lang('Custom fields');
+						
+			if (is_array($content))
+			{
+				//echo '<pre style="text-align: left;">'; print_r($content); echo "</pre>\n";
+				list($action) = @each($content['button']);
+				switch($action)
+				{
+					default:
+						if(!$content['fields']['create'] && !$content['fields']['delete']) {
+							break;	
+						}
+					case 'save':
+					case 'apply':
+						$this->update($content);
+						if ($action != 'save')
+						{
+							break;
+						}
+					case 'cancel':
+						$GLOBALS['phpgw']->redirect_link('/timesheet/index.php?menuaction=timesheet.uitimesheet.index');
+						exit;
+				}
+			}
+			$readonlys = array();
+
+			//echo 'customfields=<pre style="text-align: left;">'; print_r($this->fields); echo "</pre>\n";
+			$content['fields'] = array();
+			$n = 0;
+			if(is_array($this->fields)) {
+				foreach($this->fields as $name => $data)
+				{
+					if (is_array($data['values']))
+					{
+						$values = '';
+						foreach($data['values'] as $var => $value)
+						{
+							$values .= (!empty($values) ? "\n" : '').$var.'='.$value;
+						}
+						$data['values'] = $values;
+					}
+					$content['fields'][++$n] = $data + array(
+						'typ' => '',
+						'name'   => $name
+					);
+					$preserv_fields[$n]['old_name'] = $name;
+					$readonlys['fields']["create$name"] = True;
+				}
+			}
+
+			//$content['fields'][++$n] = array('typ'=>'','order' => 10 * $n);	// new line for create
+			$content['fields'][++$n] = array('typ' => '', 'label'=>'', 'help'=>'', 'values'=>'', 'len'=>'', 'rows'=>'', 'order'=>10 * $n, 'name'=>'');			
+			
+			$readonlys['fields']["delete[]"] = True;
+
+			//echo '<p>uicustomfields.edit(content = <pre style="text-align: left;">'; print_r($content); echo "</pre>\n";
+			//echo 'readonlys = <pre style="text-align: left;">'; print_r($readonlys); echo "</pre>\n";
+			$this->tmpl->read('timesheet.customfields');
+			$this->tmpl->exec('timesheet.uicustomfields.edit',$content,array(
+				'type'      => $this->cf_types,			
+			),$readonlys,array('fields' => $preserv_fields));
+		}
+
+		function update_fields(&$content)
+		{				
+			$fields = &$content['fields'];
+			$create = $fields['create'];
+			unset($fields['create']);
+
+			if ($fields['delete'])
+			{
+				list($delete) = each($fields['delete']);
+				unset($fields['delete']);
+			}
+
+			foreach($fields as $field)
+			{
+				$name = trim($field['name']);
+				$old_name = $field['old_name'];
+
+				if (!empty($delete) && $delete == $old_name)
+				{
+					//delete all timesheet extra entries with that certain name
+					$this->bo->delete_extra('',$old_name);
+					unset($this->fields[$old_name]);
+					continue;
+				}
+				if (isset($field['name']) && empty($name) && ($create || !empty($old_name)))	// empty name not allowed
+				{
+					$content['error_msg'] = lang('Name must not be empty !!!');
+				}
+				if (isset($field['old_name']))
+				{
+					if (!empty($name) && $old_name != $name)	// renamed
+					{
+						//update all timesheet_extra entries with that certain name
+						$this->bo->save_extra(True,$old_name,$name);	
+						unset($this->fields[$old_name]);
+					}
+					elseif (empty($name))
+					{
+						$name = $old_name;
+					}
+				}
+				elseif (empty($name))		// new item and empty ==> ignore it
+				{
+					continue;
+				}
+				$values = array();
+				if (!empty($field['values']))
+				{
+					foreach(explode("\n",$field['values']) as $line)
+					{
+						list($var,$value) = split('=',trim($line),2);
+						$var = trim($var);
+						$values[$var] = empty($value) ? $var : $value;
+					}
+				}
+				$this->fields[$name] = array(
+					'type'  => $field['type'],
+					'label' => empty($field['label']) ? $name : $field['label'],
+					'help'  => $field['help'],
+					'values'=> $values,
+					'len'   => $field['len'],
+					'rows'  => intval($field['rows']),
+					'order' => intval($field['order'])
+				);
+			}
+			if (!function_exists('sort_by_order'))
+			{
+				function sort_by_order($arr1,$arr2)
+				{
+					return $arr1['order'] - $arr2['order'];
+				}
+			}
+			uasort($this->fields,sort_by_order);
+
+			$n = 0;
+			foreach($this->fields as $name => $data)
+			{
+				$this->fields[$name]['order'] = ($n += 10);
+			}
+		}
+
+		function update(&$content)
+		{
+			$this->update_fields($content);
+			// save changes to repository
+			$this->save_repository();
+		}
+
+
+		function save_repository()
+		{		
+			// save changes to repository
+
+			//echo '<p>uicustomfields::save_repository() \$this->fields=<pre style="text-aling: left;">'; print_r($this->fields); echo "</pre>\n";
+			$this->config->value('customfields',$this->fields);
+			$this->config->save_repository();
+		}
+	}
Index: contrib/resources/inc/class.bocustom_fields.inc.php
===================================================================
--- contrib/resources/inc/class.bocustom_fields.inc.php	(revision 3524)
+++ contrib/resources/inc/class.bocustom_fields.inc.php	(revision 3524)
@@ -0,0 +1,90 @@
+<?php
+  /**************************************************************************\
+  * eGroupWare - Calendar - Custom fields and sorting                        *
+  * http://www.egroupware.org                                                *
+  * Written by Ralf Becker <RalfBecker@outdoor-training.de>                  *
+  * --------------------------------------------                             *
+  *  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.                                              *
+  \**************************************************************************/
+
+
+	class bocustom_fields
+	{
+		var $stock_fields = array(
+			
+			'name'    => 'name',
+			'category'    => 'Category',
+			'location'    => 'location',			
+			'cantidad'    => 'cantidad',
+			'administrador'      => 'administrador',
+			'email'	=>'email',
+			'description' => 'Description'//,
+
+//'enddate2'     => 'End Date2/End Time2'
+		);
+
+		function bocustom_fields()
+		{
+			$this->config = CreateObject('phpgwapi.config','calendar');
+			$this->config->read_repository();
+
+			$this->fields = &$this->config->config_data['fields'];
+
+			if (!is_array($this->fields)) {
+				$this->fields = array();
+			}
+
+			foreach ($this->fields as $field => $data)	// this can be removed after a while
+			{
+				if (!isset($this->stock_fields[$field]) && $field[0] != '#')
+				{
+					unset($this->fields[$field]);
+					$this->fields['#'.$field] = $data;
+				}
+			}
+
+			foreach($this->stock_fields as $field => $data)
+			{
+				if (!is_array($data))
+				{
+					$data = array('label' => $data);
+				}
+				if (!isset($this->fields[$field]))
+				{
+					$this->fields[$field] = array(
+						'name'     => $field,
+						'title'    => $data['title'],
+						'disabled' => $data['disabled']
+					);
+				}
+				$this->fields[$field]['label']  = $data['label'];
+				$this->fields[$field]['length'] = $data['length'];
+				$this->fields[$field]['shown']  = $data['shown'];
+			}
+		}
+
+		function set($data)
+		{
+			if (is_array($data) && strlen($data['name']) > 0)
+			{
+				if (!isset($this->stock_fields[$name = $data['name']]))
+				{
+					$name = '#'.$name;
+				}
+				$this->fields[$name] = $data;
+			}
+		}
+
+		function save($fields=False)
+		{
+			if ($fields)
+			{
+				$this->fields = $fields;
+			}
+			//echo "<pre>"; print_r($this->config->config_data); echo "</pre>\n";
+			$this->config->save_repository();
+		}
+	}
Index: contrib/resources/inc/inc.DBAccess.php
===================================================================
--- contrib/resources/inc/inc.DBAccess.php	(revision 3524)
+++ contrib/resources/inc/inc.DBAccess.php	(revision 3524)
@@ -0,0 +1,70 @@
+<?php
+///////////////////////////////////////////////////////////////////////
+// We dont use ths db class any more, and use the egroupware db      //
+// class instead, rewritten by Shang Wenbin <wbsh@realss.com>        //
+///////////////////////////////////////////////////////////////////////
+
+//include $settings->_ADOdbPath . "adodb.inc.php";
+
+class DatabaseAccess
+{
+	var $db;
+	/**
+	 * just copy the existent class $GLOBALS['phpgw']->db 
+	 */
+	function connect()
+	{
+		copyobj($GLOBALS['phpgw']->db,$this->db);
+	}
+
+	/**
+	 * always return true
+	 */
+	function ensureConnected()
+	{
+		if(!is_object($this->db))
+		{
+			$this->connect();
+		}
+		return true;
+	}
+
+	function getResultArray($queryStr)
+	{
+		$resArr = array();
+
+		$res = $this->db->query($queryStr,__LINE__,__FILE__);
+		$resArr = $res->GetArray();
+		$res->Close();
+		return $resArr;
+	}
+
+	/**
+	 * seems only used for update query
+	 */
+	function getResult($queryStr)
+	{
+		return $this->db->query($queryStr,__LINE__,__FILE__);
+	}
+
+	/**
+	 * get the last insert id
+	 * @param string $table
+	 * @param string $column
+	 * @return int
+	 */
+	function getInsertID($table,$column)
+	{
+		return $this->db->get_last_insert_id($table,$column);
+	}
+
+}
+
+
+$db = new DatabaseAccess();
+$db->connect();
+
+$GLOBALS['mydms']->db = new DatabaseAccess();
+$GLOBALS['mydms']->db->connect();
+
+?>
Index: contrib/resources/inc/hook_admin.inc.php
===================================================================
--- contrib/resources/inc/hook_admin.inc.php	(revision 3524)
+++ contrib/resources/inc/hook_admin.inc.php	(revision 3524)
@@ -0,0 +1,27 @@
+<?php
+	/**************************************************************************\
+	* eGroupWare                                                               *
+	* http://www.egroupware.org                                                *
+	* Written by Joseph Engo <jengo@phpgroupware.org>                          *
+	* --------------------------------------------                             *
+	*  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.                                              *
+	\**************************************************************************/
+
+{
+// Only Modify the $file and $title variables.....
+	$title = $appname;
+	$file = Array(
+		'Site Configuration' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname),
+		'Custom fields and sorting' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicustom_fields.index'),
+		'Calendar Holiday Management' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiholiday.admin'),
+		'Import CSV-File' => $GLOBALS['phpgw']->link('/calendar/csv_import.php'),
+		'Global Categories' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=calendar'),
+		'Grant Access by Group' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uigroup_access.index')
+	);
+//Do not modify below this line
+	display_section($appname,$title,$file);
+}
+?>
Index: contrib/resources/inc/class.DBAccess.inc.php
===================================================================
--- contrib/resources/inc/class.DBAccess.inc.php	(revision 3524)
+++ contrib/resources/inc/class.DBAccess.inc.php	(revision 3524)
@@ -0,0 +1,70 @@
+<?php
+///////////////////////////////////////////////////////////////////////
+// We dont use ths db class any more, and use the egroupware db      //
+// class instead, rewritten by Shang Wenbin <wbsh@realss.com>        //
+///////////////////////////////////////////////////////////////////////
+
+//include $settings->_ADOdbPath . "adodb.inc.php";
+
+class DBAccess
+{
+	var $db;
+	/**
+	 * just copy the existent class $GLOBALS['phpgw']->db 
+	 */
+	function connect()
+	{
+		copyobj($GLOBALS['phpgw']->db,$this->db);
+	}
+
+	/**
+	 * always return true
+	 */
+	function ensureConnected()
+	{
+		if(!is_object($this->db))
+		{
+			$this->connect();
+		}
+		return true;
+	}
+
+	function getResultArray($queryStr)
+	{
+		$resArr = array();
+
+		$res = $this->db->query($queryStr,__LINE__,__FILE__);
+		$resArr = $res->GetArray();
+		$res->Close();
+		return $resArr;
+	}
+
+	/**
+	 * seems only used for update query
+	 */
+	function getResult($queryStr)
+	{
+		return $this->db->query($queryStr,__LINE__,__FILE__);
+	}
+
+	/**
+	 * get the last insert id
+	 * @param string $table
+	 * @param string $column
+	 * @return int
+	 */
+	function getInsertID($table,$column)
+	{
+		return $this->db->get_last_insert_id($table,$column);
+	}
+
+}
+
+
+$db = new DBAccess();
+$db->connect();
+
+$GLOBALS['infolog']->db = new DBAccess();
+$GLOBALS['infolog']->db->connect();
+
+?>
Index: contrib/resources/inc/class.ui_resources.inc.php
===================================================================
--- contrib/resources/inc/class.ui_resources.inc.php	(revision 3524)
+++ contrib/resources/inc/class.ui_resources.inc.php	(revision 3524)
@@ -0,0 +1,562 @@
+<?php
+/**
+ * eGroupWare - resources
+ *
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @package resources
+ * @link http://www.egroupware.org
+ * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+ * @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
+ * @version $Id: class.ui_resources.inc.php 23852 2007-05-09 16:29:32Z lkneschke $
+ */
+
+/**
+ * General userinterface object for resources
+ *
+ * @package resources
+ */
+class ui_resources
+{
+	var $public_functions = array(
+		'index'		=> True,
+		'edit'		=> True,
+		'show'		=> True,
+		'select'	=> True,
+		'admin'		=> True,
+		'writeLangFile'	=> True
+		);
+
+	/**
+	 * constructor of class ui_resources
+	 *
+	 */
+	function ui_resources()
+	{
+// 		print_r($GLOBALS['phpgw_info']); die();
+		$this->tmpl	=& CreateObject('etemplate.etemplate','resources.show');
+		$this->bo	=& CreateObject('resources.bo_resources');
+		$this->html	=& $GLOBALS['phpgw']->html;
+// 		$this->calui	= CreateObject('resources.ui_calviews');
+		
+		if(!@is_object($GLOBALS['phpgw']->js))
+		{
+			$GLOBALS['phpgw']->js =& CreateObject('phpgwapi.javascript');
+		}
+	}
+
+	/**
+	 * main resources list.
+	 *
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @param array $content content from eTemplate callback
+	 * 
+	 * FIXME don't translate cats in nextmach
+	 */
+	function index($content='')
+	{
+		if (is_array($content))
+		{
+			$sessiondata = $content['nm'];
+			unset($sessiondata['rows']);
+			$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$sessiondata);
+			
+			if (isset($content['back']))
+			{
+				unset($sessiondata['view_accs_of']);
+				$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$sessiondata);
+				return $this->index();
+			}
+			if (isset($content['btn_delete_selected']))
+			{
+				foreach($content['nm']['rows'] as $row)
+				{
+					if($res_id = $row['checkbox'][0])
+					{
+						$msg .= '<p>'. $this->bo->delete($res_id). '</p><br>';
+					}
+				}
+				return $this->index($msg);
+			}
+			
+			foreach($content['nm']['rows'] as $row)
+			{
+				if(isset($row['delete']))
+				{
+					$res_id = array_search('pressed',$row['delete']);
+					return $this->index($this->bo->delete($res_id));
+				}
+				if(isset($row['view_acc']))
+				{
+					$sessiondata['view_accs_of'] = array_search('pressed',$row['view_acc']);
+					$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$sessiondata);
+					return $this->index();
+				}
+			}
+		}
+		$msg = $content;
+		$content = array();
+		$content['msg'] = $msg;
+		
+		$content['nm']['header_left']	= 'resources.resource_select.header';
+		$content['nm']['get_rows'] 	= 'resources.bo_resources.get_rows';
+		$content['nm']['no_filter'] 	= False;
+		$content['nm']['filter_label']	= lang('Category');
+		$content['nm']['filter_help']	= lang('Select a category'); // is this used???
+		$content['nm']['no_filter2']	= true;
+		$content['nm']['filter_no_lang'] = true;
+		$content['nm']['no_cat']	= true;
+		$content['nm']['bottom_too']	= true;
+		$content['nm']['order']		= 'name';
+		$content['nm']['sort']		= 'ASC';
+		
+		$nm_session_data = $GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm');
+		if($nm_session_data)
+		{
+			$content['nm'] = $nm_session_data;
+		}
+		$content['nm']['options-filter']= array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(phpgw_ACL_READ);
+		
+		// check if user is permitted to add resources
+		if(!$this->bo->acl->get_cats(phpgw_ACL_ADD))
+		{
+			$no_button['add'] = true;
+		}
+		$no_button['back'] = true;
+		$no_button['add_sub'] = true;
+		$GLOBALS['phpgw_info']['flags']['app_header'] = lang('resources');
+		
+		$GLOBALS['phpgw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
+			function js_btn_book_selected(form)
+			{
+				resources = '';
+				
+				el = form.getElementsByTagName(\"input\");
+				for (var i = 0; i < el.length; i++)
+				{
+					if(el[i].name.substr(el[i].name.length-12,el[i].name.length) == '[checkbox][]' && el[i].checked)
+					{
+						if(resources.length > 0)
+						{
+							resources += ',';
+						}
+						resources += 'r' + el[i].value;
+					}
+				}
+				if(resources.length == 0)
+				{
+					alert('". lang('No resources selected'). "');
+					return false;
+				}
+				return resources;
+			}
+		</script>";
+
+		if($content['nm']['view_accs_of'])
+		{
+			$master = $this->bo->so->read(array('res_id' => $content['nm']['view_accs_of']));
+			$content['view_accs_of'] = $content['nm']['view_accs_of'];
+			$content['nm']['get_rows'] 	= 'resources.bo_resources.get_rows';
+			$content['nm']['no_filter'] 	= true;
+			$content['nm']['no_filter2'] 	= true;
+			$no_button['back'] = false;
+			$no_button['add'] = true;
+			$no_button['add_sub'] = false;
+			$GLOBALS['phpgw_info']['flags']['app_header'] = lang('resources') . ' - ' . lang('accessories of '). ' '. $master['name'] .
+				($master['short_description'] ? ' [' . $master['short_description'] . ']' : '');
+		}
+		$preserv = $content;
+		$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$content['nm']);
+		$this->tmpl->read('resources.show');
+		return $this->tmpl->exec('resources.ui_resources.index',$content,$sel_options,$no_button,$preserv);
+	}
+
+	/**
+	 * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * invokes add or edit dialog for resources
+	 *
+	 * @param $content   Content from the eTemplate Exec call or id on inital call
+	 */
+	function edit($content=0,$accessory_of = -1)
+	{	
+		if (is_array($content))
+		{
+			if(isset($content['save']) || isset($content['delete']))
+			{
+				if(isset($content['save']))
+				{
+					unset($content['save']);
+// 					if($content['id'] != 0)
+// 					{
+// 						// links are already saved by eTemplate
+// 						unset($resource['link_to']['to_id']);
+// 					}
+					$content['msg'] = $this->bo->save($content);
+				}
+				if(isset($content['delete']))
+				{
+					unset($content['delete']);
+					$content['msg'] = $this->bo->delete($content['res_id']);
+				}
+				
+				if($content['msg'])
+				{
+					return $this->edit($content);
+				}
+				$js = "opener.location.href='".$GLOBALS['phpgw']->link('/index.php',
+					array('menuaction' => 'resources.ui_resources.index'))."';";
+				$js .= 'window.close();';
+				echo "<html><body><script>$js</script></body></html>\n";
+				$GLOBALS['phpgw']->common->phpgw_exit();
+			}
+		}
+		else
+		{
+			$res_id = $content;
+			if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
+			if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of'];
+			$content = array('res_id' => $res_id);
+			
+			if ($res_id > 0)
+			{
+				$content = $this->bo->read($res_id);
+				$content['gen_src_list'] = strpos($content['picture_src'],'.') !== false ? $content['picture_src'] : false;
+				$content['picture_src'] = strpos($content['picture_src'],'.') !== false ? 'gen_src' : $content['picture_src'];
+				$content['link_to'] = array(
+					'to_id' => $res_id,
+					'to_app' => 'resources'
+				);
+			}
+			
+		}
+		// some presetes
+		$content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true);
+		$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
+		$content['useable'] = $content['useable'] ? $content['useable'] : 1;
+		$content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of;
+		
+		$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
+		$sel_options['cat_id'] =  $this->bo->acl->get_cats(phpgw_ACL_ADD);
+		$sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] : 
+			$content['cat_id'] ? $sel_options['cat_id'] : array('' => lang('select one')) + $sel_options['cat_id'];
+		if($accessory_of > 0 || $content['accessory_of'] > 0)
+		{
+			$content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of;
+			$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
+			$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
+		}
+		
+// 		$content['general|page|pictures|links'] = 'resources.edit_tabs.page';  //debug
+		$no_button = array(); // TODO: show delete button only if allowed to delete resource
+		$preserv = $content;
+		$this->tmpl->read('resources.edit');
+		return $this->tmpl->exec('resources.ui_resources.edit',$content,$sel_options,$no_button,$preserv,2);
+		
+	}
+	
+	/**
+	 * adminsection of resources
+	 *
+	 * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 */
+	function admin($content='')
+	{
+		if(is_array($content))
+		{
+			if(isset($content['save']))
+			{
+				$this->bo->conf->read_repository();
+				$this->bo->conf->save_value('dont_use_vfs',$content['dont_use_vfs']);
+			}
+			else
+			{
+				return $GLOBALS['phpgw']->redirect_link('/admin/index.php');
+			}
+		}
+		$content = $this->bo->conf->read_repository();
+		$this->tmpl->read('resources.admin');
+		$this->tmpl->exec('resources.ui_resources.admin',$content,$sel_options,$no_button,$preserv);
+	}
+
+	/**
+	 * showes a single resource
+	 *
+	 * @param int $res_id resource id
+	 * @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
+	 */
+	function show($res_id=0)
+	{
+		if (is_array($content = $res_id))
+		{
+			if(isset($content['btn_delete']))
+			{
+				$content['msg'] = $this->bo->delete($content['res_id']);
+				if($content['msg'])
+				{
+					return $this->show($content);
+				}
+				$js = "opener.location.href='".$GLOBALS['phpgw']->link('/index.php',
+					array('menuaction' => 'resources.ui_resources.index'))."';";
+				$js .= 'window.close();';
+				echo "<html><body><script>$js</script></body></html>\n";
+				$GLOBALS['phpgw']->common->phpgw_exit();
+			}
+			if(isset($content['btn_edit']))
+			{
+				return $this->edit($content['res_id']);
+			}
+			
+		}
+		if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
+
+		$content = array('res_id' => $res_id);
+		$content = $this->bo->read($res_id);
+		$content['gen_src_list'] = strpos($content['picture_src'],'.') !== false ? $content['picture_src'] : false;
+		$content['picture_src'] = strpos($content['picture_src'],'.') !== false ? 'gen_src' : $content['picture_src'];
+		$content['link_to'] = array(
+				'to_id' => $res_id,
+				'to_app' => 'resources'
+		);
+	
+		$content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true);
+		$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
+		$content['useable'] = $content['useable'] ? $content['useable'] : 1;
+		
+		$content['quantity'] = ($content['useable'] == $content['quantity']) ? $content['quantity'] : $content['quantity'].' ('.lang('useable').' '.$content['useable'].')';
+		
+		//$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
+				
+		$content['cat_name'] =  $this->bo->acl->get_cat_name($content['cat_id']);
+		$content['cat_admin'] = $this->bo->acl->get_cat_admin($content['cat_id']);
+		
+/*		if($content['accessory_of'] > 0)
+		{
+			$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
+			$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
+		} 
+*/
+		$content['description'] = chop($content['long_description']) ? $content['long_description'] : (chop($content['short_description']) ? $content['short_description'] : lang("no description available"));
+		$content['description'] = $content['description'] ? $content['description'] : lang('no description available');
+		$content['link_to'] = array(
+					'to_id' => $res_id,
+					'to_app' => 'resources'
+				);
+		$sel_options = array();
+		$no_button = array(
+			'btn_buy' => !$content['buyable'],
+			'btn_book' => !$content['bookable'],
+			'btn_calendar' => !$content['bookable'],
+			'btn_edit' => !$this->bo->acl->is_permitted($content['cat_id'],phpgw_ACL_EDIT),
+			'btn_delete' => !$this->bo->acl->is_permitted($content['cat_id'],phpgw_ACL_DELETE)
+			);
+		$preserv = $content;
+		$this->tmpl->read('resources.showdetails');
+		return $this->tmpl->exec('resources.ui_resources.show',$content,$sel_options,$no_button,$preserv,2);
+		
+	}
+	
+	/**
+	 * select resources
+	 *
+	 * @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
+	 */
+	function select($content='')
+	{
+		if (!is_object($GLOBALS['phpgw']->js))
+		{
+			$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
+		}
+		$GLOBALS['phpgw']->js->set_onload("copyOptions('exec[resources][selectbox]');");
+		
+		$GLOBALS['phpgw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
+			window.focus();
+			
+			openerid='resources_selectbox';
+			id='exec[nm][rows][selectbox]';
+		
+			function addOption(label,value,button_id,useable)
+			{
+				quantity = document.getElementById(button_id+'[default_qty]').value;
+				value = value+':'+quantity;
+				if(quantity>useable) {
+					alert('".lang('You chose more resources than available')."');
+					return false;
+				}
+				label = label+'['+quantity+'/'+useable+']';
+				openerSelectBox = opener.document.getElementById(openerid);
+				if (openerSelectBox) {
+					select = '';
+					for(i=0; i < openerSelectBox.length; i++) {
+						with (openerSelectBox.options[i]) {
+							if (selected || openerSelectBox.selectedIndex == i) {
+								select += (value.slice(0,1)==',' ? '' : ',')+value;
+							}
+						}
+					}
+					select += (select ? ',' : '')+value;
+					opener.selectbox_add_option(openerid,label,value,0);
+				}
+				selectBox = document.getElementById(id);
+				if (selectBox) {
+					var resource_value = value.split(':');
+					for (i=0; i < selectBox.length; i++) {
+						var selectvalue = selectBox.options[i].value.split(':');
+						if (selectvalue[0] == resource_value[0]) {
+							selectBox.options[i] = null; 
+							selectBox.options[selectBox.length] = new Option(label,value,false,true);	
+							break;
+						}
+					}
+					if (i >= selectBox.length) {
+						selectBox.options[selectBox.length] = new Option(label,value,false,true);
+					}
+				}
+			}
+		
+			function removeSelectedOptions()
+			{
+				openerSelectBox = opener.document.getElementById(openerid);
+				if (openerSelectBox == null) window.close();
+				selectBox = document.getElementById(id);
+				for (i=0; i < selectBox.length; i++) {
+					if (selectBox.options[i].selected) {
+						for (j=0; j < openerSelectBox.length; j++) {
+							if (openerSelectBox[j].value == selectBox.options[i].value) {
+								openerSelectBox.removeChild(openerSelectBox[j]);
+							}
+						}
+						selectBox.options[i--] = null;
+					}
+				}
+			}
+		
+			function copyOptions()
+			{
+				openerSelectBox = opener.document.getElementById(openerid);
+				selectBox = document.getElementById(id);
+				for (i=0; i < openerSelectBox.length; i++) {
+					with (openerSelectBox.options[i]) {
+						if (selected && value.slice(0,1) != ',') {
+							selectBox.options[selectBox.length] =  new Option(text,value);
+						}
+					}
+				}
+			}
+			
+			function oneLineSubmit()
+			{
+			/*
+				openerSelectBox = opener.document.getElementById(openerid);
+		
+				if (openerSelectBox) {
+					if (openerSelectBox.selectedIndex >= 0) {
+						selected = openerSelectBox.options[openerSelectBox.selectedIndex].value;
+						if (selected.slice(0,1) == ',') selected = selected.slice(1);
+						opener.selectbox_add_option(openerid,'multiple*',selected,1);
+					}
+					else {
+						for (i=0; i < openerSelectBox.length; i++) {
+							with (openerSelectBox.options[i]) {
+								if (selected) {
+									opener.selectbox_add_option(openerid,text,value,1);
+									break;
+								}
+							}
+						}	
+					}
+				}
+			*/
+				window.close();
+			}</script>";
+		
+		$content['nm']['header_left'] = 'resources.resource_select.header';
+		$content['nm']['show_bookable'] = true;
+		$content['nm']['get_rows'] 	= 'resources.bo_resources.get_rows';
+		$content['nm']['no_filter'] 	= False;
+		$content['nm']['filter_label']	= 'Category';
+		$content['nm']['filter_help']	= lang('Select a category'); // is this used???
+		$content['nm']['options-filter']= array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(phpgw_ACL_READ);
+		$content['nm']['no_filter2']	= true;
+		$content['nm']['filter_no_lang'] = true;
+		$content['nm']['no_cat']	= true;
+		$content['nm']['rows']['js_id'] = 1;
+
+		$sel_options = array();
+		$no_button = array();
+		$this->tmpl->read('resources.resource_select');
+		return $this->tmpl->exec('resources.ui_resources.select',$content,$sel_options,$no_button,$preserv,2);
+	}
+	
+	/**
+	 * get_calendar_sidebox
+	 * get data fÃŒr calendar sidebox
+	 *
+	 * @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
+	 * @param array $param with keys menuaction, owner and optional date
+	 * @return array with: label=>link or array with text
+	 */
+	function get_calendar_sidebox($param)
+	{
+		$cats = $this->bo->acl->get_cats(phpgw_ACL_READ);
+		if (!$cats) return array();
+		
+		$owners = explode(',',$param['owner']);
+		unset($param['owner']);
+		$res_cats = $selected = array();
+
+		// this gets the resource-ids of the cats and implodes them to the array-key of the selectbox,
+		// so it is possible to select all resources of a category
+		foreach($cats as $cat_id => $cat_name) 
+		{
+			if ($resources = $this->bo->so->search(array('cat_id' => $cat_id, 'bookable' => '1'),'res_id'))
+			{
+				$keys = array();
+				foreach($resources as $res)
+				{
+					$keys[] = 'r'.$res['res_id'];
+				}
+				$res_cats[implode(',',$keys)] = $cat_name;
+				
+				if (count(array_intersect($keys,$owners)) == count($keys))
+				{
+					$selected[] = implode(',',$keys);
+					$owners = array_diff($owners,$keys);
+				}
+			}
+		}
+		// add already selected single resources to the selectbox, eg. call of the resource-calendar from the resources app
+		$resources = array('r0' => lang('none'));
+		$res_ids = array();
+		foreach($owners as $key => $owner)
+		{
+			if ($owner{0} == 'r')
+			{
+				$res_ids[] = (int) substr($owner,1);
+				$selected[] = $owner;
+			}
+		}
+		if (count($res_ids))
+		{
+			foreach($this->bo->so->search(array('res_id' => $res_ids),'res_id,name') as $data)
+			{
+				$resources['r'.$data['res_id']] = $data['name'];
+			}
+		}		
+		$selectbox = $this->html->select(
+			'owner',
+			$selected,
+			array_merge($resources,$res_cats),
+			$no_lang=true,
+			$options='style="width: 165px;" onchange="load_cal(\''.
+				$GLOBALS['phpgw']->link('/index.php',$param).'\',\'uical_select_resource\');" id="uical_select_resource"',
+			$multiple=count($selected) ? 4 : 0
+		);
+		return array(
+			array(
+				'text' => $selectbox,
+				'no_lang' => True,
+				'link' => False
+			)
+		);
+	}
+}
+
Index: contrib/resources/inc/class.uiresources.inc.php
===================================================================
--- contrib/resources/inc/class.uiresources.inc.php	(revision 3524)
+++ contrib/resources/inc/class.uiresources.inc.php	(revision 3524)
@@ -0,0 +1,1653 @@
+<?php
+  /**************************************************************************\
+  * eGroupWare - resources                                                    *
+  * http://www.eGroupWare.org                                                *
+  * Maintained and further developed by RalfBecker@outdoor-training.de       *
+  * Based on Webresources by Craig Knudsen <cknudsen@radix.net>               *
+  *          http://www.radix.net/~cknudsen                                  *
+  * Originaly modified by Mark Peters <skeeter@phpgroupware.org>             *
+  * --------------------------------------------                             *
+  *  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.                                              *
+  \**************************************************************************/
+
+
+	class uiresources
+	{
+		var $dbb;
+		var $template;
+		var $cat;
+		var $debug = False;
+		var $cat_id;
+		var $theme;
+		var $link_tpl;
+		var $public_functions = array(
+		'index' => True,		
+		'view' => True,
+		'edit' => True,
+		'update'=> True,				
+		'delete' => True,
+		'close'       => True,
+		'import_mail' => True,
+		'search' => True,
+		'search2' => True,
+		'header' => True,
+		'footer' => True			
+		);
+
+
+	var $prefs;
+	/**
+	 * instance of the bo-class
+	 * 
+	 * @var boresources
+	 */
+	var $bo;
+	/**
+	 * reference to instance of the link-class of bo
+	 * 
+	 * @var bolink
+	 */
+	var $link;
+	/**
+	 * instance of the etemplate class
+	 *
+	 * @var etemplate
+	 */
+	var $tmpl;
+	/**
+	 * reference to the html object of etemplate
+	 *
+	 * @var html
+	 */
+	var $html;
+	/**
+	 * allowed units and hours per day, can be overwritten by the projectmanager configuration, default all units, 8h
+	 * 
+	 * @var string
+	 */
+	var $duration_format = ',';	// comma is necessary!
+	
+	var $icons = array(
+		'type' => array(
+			'task'      => 'task.png',      'task_alt'      => 'Task',
+			'phone'     => 'phone.gpng',     'phone_alt'     => 'Phonecall',
+			'note'      => 'note.png',      'note_alt'      => 'Note',
+			'confirm'   => 'confirm.png',   'confirm_alt'   => 'Confirmation',
+			'reject'    => 'reject.png',    'reject_alt'    => 'Reject',
+			'email'     => 'email.png',     'email_alt'     => 'Email' ),
+		'action' => array(
+			'new'       => 'new.png',       'new_alt'       => 'Add Sub',
+			'view'      => 'view.png',      'view_alt'      => 'View Subs',
+			'parent'    => 'parent.png',    'parent_alt'    => 'View other Subs',
+			'edit'      => 'edit.png',      'edit_alt'      => 'Edit',
+			'addfile'   => 'addfile.png',   'addfile_alt'   => 'Add a file',
+			'delete'    => 'delete.png',    'delete_alt'    => 'Delete',
+			'close'     => 'done.png',      'close_alt'     => 'Close' ),
+		'status' => array(
+			'billed'    => 'billed.png',    'billed_alt'    => 'billed',
+			'done'      => 'done.png',      'done_alt'      => 'done',
+			'will-call' => 'will-call.png', 'will-call_alt' => 'will-call',
+			'call'      => 'call.png',      'call_alt'      => 'call',
+			'ongoing'   => 'ongoing.png',   'ongoing_alt'   => 'ongoing',
+			'offer'     => 'offer.png',     'offer_alt'     => 'offer' )
+	);
+	var $filters = array(
+		'none'                     => 'no Filter',
+		'done'                     => 'done',
+		'responsible'              => 'responsible',
+		'responsible-open-today'   => 'responsible open',
+		'responsible-open-overdue' => 'responsible overdue',
+		'responsible-upcoming'     => 'responsible upcoming',
+		'delegated'                => 'delegated',
+		'delegated-open-today'     => 'delegated open',
+		'delegated-open-overdue'   => 'delegated overdue',
+		'delegated-upcoming'       => 'delegated upcomming',
+		'own'                      => 'own',
+		'own-open-today'           => 'own open',
+		'own-open-overdue'         => 'own overdue',
+		'own-upcoming'             => 'own upcoming',
+		'open-today'               => 'open',
+		'open-overdue'             => 'overdue',
+		'upcoming'                 => 'upcoming',
+	);
+	var $messages = array(
+		'edit'    => 'resources - Edit',
+		'add'     => 'resources - New',
+		'add_sub' => 'resources - New Subproject',
+		'sp'      => '- Subprojects from',
+		're'      => 'Re:'
+	);
+
+
+var $optionldap;
+
+	/**
+	 * Constructor
+	 *
+	 * @return uiresources
+	 */
+
+
+
+		function uiresources()
+		{
+
+
+
+
+			
+ 
+//print_r($GLOBALS);
+
+			$GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
+			$this->bo = CreateObject('resources.boresources',1);
+			$this->cat = &$this->bo->cat;
+			//echo "pwnre".$this->bo->owner."  ".$this->bo->today."  ".$this->bo->evento;
+			$this->dbb = CreateObject('class.DBAccess',1);
+			$this->cat = &$this->bo->cat;
+
+
+			$this->resources = &$this->bo->resources;
+
+			$this->project = &$this->bo->project;
+
+$this->tarea = &$this->bo->tarea;
+
+			print_debug('BO Owner',$this->bo->owner);
+
+			$this->template = $GLOBALS['phpgw']->template;
+			$this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('resources');
+
+			$this->cat_id   = $this->bo->cat_id;
+
+			$this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir);
+			$this->link_tpl->set_unknowns('remove');
+			$this->link_tpl->set_file(
+				Array(
+					'link_picture'	=> 'link_pict.tpl'
+				)
+			);
+			$this->link_tpl->set_block('link_picture','link_pict','link_pict');
+			$this->link_tpl->set_block('link_picture','pict','pict');
+			$this->link_tpl->set_block('link_picture','link_open','link_open');
+			$this->link_tpl->set_block('link_picture','link_close','link_close');
+			$this->link_tpl->set_block('link_picture','link_text','link_text');
+
+
+
+$this->ds = $GLOBALS['phpgw']->common->ldapConnect();
+			if(!$this->ds)
+				$this->ds = $GLOBALS['phpgw']->common->ldapConnect();
+			if(!@is_object($GLOBALS['phpgw']->translation))
+			{
+				$GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation');
+			}
+			$this->user_context  = $GLOBALS['phpgw_info']['server']['ldap_context'];
+			$this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context'];
+		
+/*************************************************/
+
+			$this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots';
+
+			//print_debug('UI',$this->_debug_sqsof());
+
+			if (!is_object($GLOBALS['phpgw']->html))
+			{
+				$GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
+			}
+			$this->html = &$GLOBALS['phpgw']->html;
+		}
+
+		/* Public functions */
+
+		
+
+		function index($params='')
+
+		{
+
+			if (!$params)
+			{
+				foreach(array('date','year','month','day') as $field)
+				{
+					if (isset($_GET[$field]))
+					{
+						$params[$field] = $_REQUEST[$field];
+					}
+				}
+			}
+//$todos = $this->get_todos($todo_label);
+
+			$GLOBALS['phpgw']->redirect($this->page('search',$params));
+			
+		}
+
+
+		
+function page($_page='',$params='')
+		{
+			if($_page == '')
+			{
+				$page_ = explode('.',$this->bo->prefs['resources']['defaultresources']);
+				$_page = $page_[0];
+
+				if ($_page=='planner_cat' || $_page=='planner_user')
+				{
+					$_page = 'month';
+				}
+				elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner'))
+				{
+					$_page = 'month';
+					$GLOBALS['phpgw']->preferences->add('resources','defaultresources','month');
+					$GLOBALS['phpgw']->preferences->save_repository();
+				}
+			}
+			if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' ||
+				strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail'))	// email, felamimail, ...
+			{
+				$page_app = 'resources';
+			}
+			else
+			{
+				$page_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
+			}
+			if (is_array($params))
+			{
+				$params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page;
+			}
+			else
+			{
+				$params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params;
+			}
+			return $GLOBALS['phpgw']->link('/index.php',$params);
+		}
+
+
+
+// NDEE: printer-friendly
+function printer_friendly($body,$app_header='')
+		{
+			$_SESSION['resources']['category'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True');
+$_SESSION['resources']['resources'] = $this->resources->formated_list('select','all',$this->bo->resources_id,'True');
+			if((!isset($GLOBALS['phpgw_info']['server']['deny_user_granres_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_granres_access']) && count($this->bo->grants) > 0)
+				$_SESSION['resources']['cals'] = $this->bo->list_cals();
+
+			
+				unset($GLOBALS['phpgw_info']['flags']['noheader']);
+				unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+				unset($GLOBALS['phpgw_info']['flags']['noappheader']);
+				unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
+				if ($app_header && $this->always_app_header)
+				{
+					$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.$app_header;
+				}
+				
+				$GLOBALS['phpgw']->common->phpgw_header();
+				
+			return $new_body;
+		}
+
+
+
+
+
+function normalizeminutes(&$minutes)
+		{
+			$hour = 0;
+			$min = (int)$minutes;
+			if($min >= 60)
+			{
+				$hour += $min / 60;
+				$min %= 60;
+			}
+			settype($minutes,'integer');
+			$minutes = $min;
+			return $hour;
+		}
+
+		function header()
+		{
+			$cols = 8;
+			if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True)
+			{
+				$cols++;
+			}
+
+			$tpl = $GLOBALS['phpgw']->template;
+			$tpl->set_unknowns('remove');
+
+			if (!file_exists($file = $this->template_dir.'/header.inc.php'))
+			{
+				$file = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/resources/templates/default/header.inc.php';
+			}
+
+			include($file);
+			$refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']);
+			if($refer[2] != 'view') {
+			$header = $tpl->fp('out','head');
+			unset($tpl);
+			echo $header;
+		}
+			unset($tpl);
+		}
+
+		function footer()
+		{
+			$menuaction = $_GET['menuaction'];
+			list(,,$method) = explode('.',$menuaction);
+
+			if (@$this->bo->printer_friendly)
+			{
+				return;
+			}
+
+			$p = $GLOBALS['phpgw']->template;
+
+			$p->set_file(
+				Array(
+					'footer'	=> 'footer.tpl',
+					'form_button'	=> 'form_button_script.tpl'
+				)
+			);
+			$p->set_block('footer','footer_table','footer_table');
+			$p->set_block('footer','footer_row','footer_row');
+			$p->set_block('footer','blank_row','blank_row');
+			$p->set_block('footer','num_dias','num_dias');
+
+			$m = $this->bo->month;
+			$y = $this->bo->year;
+
+			$hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow);
+			$mes_hoje = (int)substr($hoje,4,2);
+			$mes_footer = (int)substr($_POST['date'],4,2);
+			if($_GET['sday'])
+			{
+				if($_GET['month'] == $mes_hoje)
+				{
+					$day = $this->bo->day;
+				} 
+				else
+				{
+					$day = $_GET['sday'];
+				}
+			}
+			else
+			{
+				$day = $this->bo->day;
+				$dia_ini = $day;
+			}
+			if($mes_footer == $mes_hoje)
+			{
+				$dia_ini = (int)substr($hoje,6,2);
+				$day = $dia_ini;
+			}
+			
+			/********************************************************************************************/
+
+		}
+
+		
+
+
+
+
+/****************************************************************************************/
+
+
+function edit($cd=0,$readsess=0)
+		{
+
+			$this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
+
+
+
+
+			if(!$this->bo->check_perms(PHPGW_ACL_ADD))
+			{
+				$this->index();
+			}
+			
+			if($readsess)
+			{
+
+				$event = $this->bo->restore_from_appsession;
+				if(!$event['owner'])
+				{
+					$this->bo->add_attribute('owner',$this->bo->owner);
+				}
+				$can_edit = True;
+			}
+			else
+			{
+
+
+				$this->bo->event_init();
+				$this->bo->add_attribute('id',0);
+
+				$can_edit = True;
+				$participants = (string)(get_var('participants',array('GET'),FALSE));
+				$starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['resources']['workdaystarts']));
+				$startmin  = (int)(get_var('minute',array('GET'),0));
+				$endmin    = $startmin + (int)$this->bo->prefs['resources']['defaultlength'];
+				$endhour   = $starthour + $this->bo->normalizeminutes($endmin);
+				
+				$subject	= (string)(get_var('title',array('GET'),0));
+				if ($subject != '0')
+				{
+					$description	= (string)(get_var('description',array('GET'),0));
+					$description1	= (string)(get_var('description1',array('GET'),0));
+					$location	= (string)(get_var('location',array('GET'),0));
+				}
+				else
+					unset($subject);
+				
+				$this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0);
+				$this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0);
+
+
+				if(@$this->bo->prefs['resources']['default_private'])
+				{
+					$this->bo->set_class(False);
+				}
+				else
+				{
+					$this->bo->set_class(True);
+				}
+				
+				$event = $this->bo->restore_from_appsession;
+				
+			}
+if(isset($_REQUEST['error'])){
+$cd=$_REQUEST['error'];
+}
+			$this->edit_form(
+				Array(
+					'event' => $event,
+					'cd' => $cd,
+					'plain' => $_GET['plain']
+				)
+			);
+			$GLOBALS['phpgw']->common->phpgw_footer();
+		}
+
+
+function edit_form($param)
+		{
+
+
+if(isset($_REQUEST['id'])){
+			$event=$this->select($_REQUEST['id']);
+}else{
+$event=$this->select_init();
+}
+
+                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
+
+
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			
+	
+$justthese = array("uidnumber", "gidnumber", "uid", "cn", "givenname", "sn", "mail","telephonenumber","gecos","dn");
+				$sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese);
+		
+
+if(!$sri)
+				return null;
+			$allValues = ldap_get_entries($this->ds, $sri);
+
+
+
+$ttt=count($allValues);
+
+for($i=0;$i<$ttt;$i++){
+
+							if(isset($allValues[$i]['mail'][0]))
+				{
+								$option = '    <option  value="' . $allValues[$i]['uidnumber'][0] . '" >'.$allValues[$i]['gecos'][0].'</option>'."\n";
+								$optionldap .= $option;
+								$option2 = '    <option  value="' . $allValues[$i]['uidnumber'][0] . '" >'.$allValues[$i]['gecos'][0].'</option>'."\n";
+								$optionldap2 .= $option2;
+}
+
+
+
+
+}
+
+
+
+
+
+			if(!is_array($param))
+			{
+				$this->index();
+			}
+			
+			if(isset($param['event']))
+			{
+				$event = $param['event'];
+			}
+			
+			$hourformat = substr($this->bo->users_timeformat,0,1);
+			
+			$jscal = CreateObject('phpgwapi.jscalendar');	// before phpgw_header() !!!
+			
+			unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			$GLOBALS['phpgw_info']['flags']['noappheader'] = True;
+			$GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
+			$GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding resources');
+			if ($param['plain'] != "True"){
+				$GLOBALS['phpgw']->common->phpgw_header();
+			}
+			else{
+				$GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8";
+				$GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8";
+			}
+
+			$p = &$GLOBALS['phpgw']->template;
+			$p->set_file(
+				Array(
+					'edit'		=> 'edit.tpl',
+					'form_button'	=> 'form_button_script.tpl'
+				)
+			);
+			$p->set_block('edit','edit_entry','edit_entry');
+			$p->set_block('edit','list','list');
+			$p->set_block('edit','hr','hr');
+
+			$vars = Array(
+				'font'			=> $this->theme['font'],
+				'bg_color'		=> $this->theme['bg_text'],
+				'action_url'		=> $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'resources.uiresources.update')),
+				'accounres_link'		=> $GLOBALS['phpgw']->link('/index.php','menuaction=resources.uiresources.accounres_popup'),
+				'common_hidden'	=> '<input type="hidden" name="resources[id]" value="'.$event['id'].'">'."\n"
+					. '<input type="hidden" name="resources[owner]" value="'.$event['owner'].'">'."\n"
+					. (@isset($GLOBALS['phpgw_info']['server']['deny_user_granres_access']) && $GLOBALS['phpgw_info']['server']['deny_user_granres_access']?
+					'<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''),
+				'errormsg'		=> ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'')
+			);
+			
+			$p->set_var($vars);
+
+// res_type
+	//echo $event['type'];		
+
+
+// Display Categories
+			if(strpos($event['category'],','))
+			{
+				$temp_cats = explode(',',$event['category']);
+				@reset($temp_cats);
+				while(list($key,$value) = each($temp_cats))
+				{
+					$check_cats[] = (int)$value;
+				}
+			}
+			elseif($event['category'])
+			{
+				$check_cats[] = (int)$event['category'];
+			}
+			else
+			{
+				$check_cats[] = 0;
+			}
+			$var['category'] = Array(
+				'field'	=> lang('Category'),
+				'data'	=> '<select name="resources[category]" onchange="javascript:updateTitleField(this)" >'.$this->cat->formated_list('select','all',$check_cats,True).'</select>'
+			);
+	
+
+
+
+
+// nombre
+			$var['name'] = Array(
+				'field'	=> lang('name'),
+				'data'	=> '<input type="text" name="resources[name]" maxlength="255" value="'.$event['name'].'">'
+			);
+
+
+// location
+			$var['location'] = Array(
+				'field'	=> lang('location'),
+				'data'	=> '<input type="text" name="resources[location]" maxlength="255" value="'.$event['location'].'">'
+			);
+
+
+//cantidad
+			$var['cantidad'] = Array(
+				'field'	=> lang('quantity'),
+				'data'	=> '<input type="text" name="resources[cantidad]" maxlength="255" value="'.$event['cantidad'].'">'
+			);
+
+
+
+
+// Full Description
+			$var['description'] = Array(
+				'field'	=> lang('Description'),
+				'data'	=> '<textarea name="resources[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['descripcion'].'</textarea>'
+			);
+
+
+
+
+//responsable
+			if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access'])
+			{
+				
+					
+						$str2 = utf8_decode($optionldap2);
+						
+						$var['administrador'] = array
+						(
+							'field'	=> lang('Responsable'),							
+							'data'	=> "
+									<select id='user_list' name='resources[administrador]' style='width: 220px' ><option value=0>seleccione</option>".$str2."</select>										
+											
+									
+									"
+						);
+									
+						
+						
+						
+						
+				}
+
+//email
+			$var['email'] = Array(
+				'field'	=> lang('email'),
+				'data'	=> '<input type="text" name="resources[email]" maxlength="255" value="'.$event['email'].'">'
+			);
+
+
+$valorfechainicio=$this->bo->time2array($event['fechainicio'],$alarm = 0);
+$start=$valorfechainicio['mday']."/".$valorfechainicio['month']."/".$valorfechainicio['year'];
+			$var['startdate'] = Array(
+				'field'	=> lang('Start Date'),
+
+				'data' => $jscal->input('start[str]',$start)
+			);
+
+
+//			$this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>'));
+
+			if (!isset($this->fields))
+			{
+				$this->custom_fields = CreateObject('resources.bocustom_fields');
+				$this->fields = &$this->custom_fields->fields;
+				$this->stock_fields = &$this->custom_fields->stock_fields;
+			}
+		//	$this->output_template_array($p,'row','list',$var['access']);
+			unset($var['access']);
+
+			$preserved = False;
+			foreach($this->fields as $field => $data)
+			{
+
+				if (!$data['disabled'])
+				{
+
+
+					if (isset($var[$field]))
+					{
+
+
+						switch($field)
+						{
+							case 'startdate':
+								$this->output_template_array($p,'row','list',$var['startdate']);
+								$this->output_template_array($p,'row','list',$var['starttime']);
+								break;
+							case 'enddate':
+								$this->output_template_array($p,'row','list',$var['enddate']);
+								$this->output_template_array($p,'row','list',$var['endtime']);
+								break;
+							case 'recure_type':
+								$p->set_var('tr_color',$this->theme['th_bg']);
+								$p->set_var('hr_text','<center id="rpt_label"><b>'.lang('Repeating Event Information').'</b></center>');
+								$p->parse('row','hr',True);
+								$this->output_template_array($p,'row','list',$var['recure_type']);
+								$this->output_template_array($p,'row','list',$var['recure_enddate']);
+								$this->output_template_array($p,'row','list',$var['recure_day']);
+								$this->output_template_array($p,'row','list',$var['recure_interval']);
+								break;
+							default:
+								$this->output_template_array($p,'row','list',$var[$field]);
+
+						}
+					}
+					elseif (!isset($this->stock_fields[$field]))	// Custom field
+					{
+
+
+						$lang = lang($name = substr($field,1));
+						$size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)).
+							' MAXLENGTH='.($data['length'] ? $data['length'] : 255);
+						$v = array(
+							'field'	=> $lang == $name.'*' ? $name : $lang,
+							'data'	=> '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">'
+						);
+						if ($data['title'])
+						{
+							$v['tr_color'] = $this->theme['th_bg'];
+						}
+						if (!$data['length'] && $data['title'])
+						{
+							$p->set_var('tr_color',$this->theme['th_bg']);
+							$p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>');
+							$p->parse('row','hr',True);
+						}
+						else
+						{
+							$this->output_template_array($p,'row','list',$v);
+						}
+					}
+				}
+				else	// preserve disabled fields
+				{
+
+
+					switch ($field)
+					{
+						case 'owner':
+							$preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A';
+							break;
+						case 'recure_type':
+							foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field)
+							{
+								$preserved[$field] = $event[$field];
+							}
+							break;
+						case 'startdate':
+						case 'enddate':
+							$field = substr($field,0,-4);
+						default:
+							$preserved[$field] = $event[$field];
+					}
+				}
+			}
+			unset($var);
+			if (is_array($preserved))
+			{
+				//echo "preserving<pre>"; print_r($preserved); echo "</pre>\n";
+				$p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n");
+			}
+			$p->set_var('submit_button',lang('Save'));
+
+			$delete_button = $cancel_button = '';
+			if ($event['id'] > 0)
+			{
+				$var = Array(
+					'action_url_button'	=> $this->page('delete','&cal_id='.$event['id']),
+					'action_text_button'	=> lang('Delete'),
+					'action_confirm_button'	=> "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"",
+					'action_extra_field'	=> '',
+					'button_id'	=>	'delete_button'
+				);
+				$p->set_var($var);
+				$delete_button = $p->fp('out','form_button');
+			}
+			$p->set_var('delete_button',$delete_button);
+			$p->set_var('alert_msg',lang('Required field (category) is empty'));
+
+			if ($this->bo->return_to)
+			{
+				$var = Array(
+					'action_url_button'	=> $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to),
+					'action_text_button'	=> lang('Cancel'),
+					'action_confirm_button'	=> '',
+					'action_extra_field'	=> '',
+					'button_id'	=>	'cancel_button'
+				);
+				$p->set_var($var);
+				$cancel_button = $p->fp('out','form_button');
+			}
+			$p->set_var('cancel_button',$cancel_button);
+			$p->pparse('out','edit_entry');
+		}
+
+	function output_template_array(&$p,$row,$list,$var)
+		{
+			if (!isset($var['hidden_vars']))
+			{
+				$var['hidden_vars'] = '';
+			}
+			if (!isset($var['tr_color']))
+			{
+				$var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color();
+			}
+			$p->set_var($var);
+			$p->parse($row,$list,True);
+		}
+
+
+function get_organizations($context, $selected='', $recursive = false)
+		{
+			$s = CreateObject('phpgwapi.sector_search_ldap');
+						
+			return ($recursive ? 
+				$s->get_organizations($context, $selected, false ,true) :
+				$s->get_sectors($selected, false, false));
+		}	
+	
+
+
+
+/**********************************************/
+
+
+function _debug_sqsof()
+		{
+			$data = array(
+				'filter'     => $this->bo->filter,
+				'cat_id'     => $this->bo->cat_id,
+				'owner'      => $this->bo->owner,
+				'year'       => $this->bo->year,
+				'month'      => $this->bo->month,
+				'day'        => $this->bo->day,
+				'sortby'     => $this->bo->sortby,
+				'num_months' => $this->bo->num_months
+			);
+			Return _debug_array($data,False);
+		}
+
+
+
+
+/***********************************/
+
+
+
+
+function search()
+		{
+
+//print_r($_REQUEST); 
+//echo "kkkkkkkkkkk".$_REQUEST['errormsg'];
+
+
+			unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			$error = '';
+
+			$matches = 0;
+
+		//$event = $this->bo->read_entry($res_id);	
+$event = $this->get_event_ids($adicional);
+
+
+			//$event_ids = $this->bo->search_keywords($_POST['keywords']);
+
+			
+			$matches = count($event);
+
+//echo "matches" . $matches;
+
+			if ($matches == 1)
+			{
+				$quantity = lang('1 match found').'.';
+			}
+			elseif ($matches > 0)
+			{
+				$quantity = lang('%1 matches found',$matches).'.';
+			}
+			else
+			{
+				echo lang('no matches found');
+				return;
+			}
+
+			$p = $GLOBALS['phpgw']->template;
+			$p->set_file(
+				Array(
+					'search_form'	=> 'search.tpl'
+				)
+			);
+			$p->set_block('search_form','search','search');
+			$p->set_block('search_form','search_list_header','search_list_header');
+			$p->set_block('search_form','search_list','search_list');
+			$p->set_block('search_form','search_list_footer','search_list_footer');
+
+
+$script='';
+
+		
+
+			if($matches > 0)
+			{
+				$p->parse('rows','search_list_header',True);
+			}
+
+//if($info){
+			foreach($event  as $id => $data)
+			{
+
+
+				$datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
+
+
+
+
+				$info = array(
+					'tr_color'	=> $GLOBALS['phpgw']->nextmatchs->alternate_row_color(),
+					'date'		=> $GLOBALS['phpgw']->common->show_date($datetime),
+'id'    => $data['id'],
+					'name'         => $data['name'],
+					'description'         => $data['short_description'],
+					'category'         => $data['cat_name'],
+					'picture_src' => $data['picture_src'],
+					'administrador'=>$data['administrador'],
+					'email'=>$data['email'],
+					'owner'=>$data['owner'],
+
+
+
+'accionmodificar'	=>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'],
+'accionlistar'	=>'index.php?menuaction=resources.uiresources.search2&id='.  $data['name'],
+'accionborrar'	=>'index.php?menuaction=resources.uiresources.delete&id='. $data['id'],
+'accionreservar'	=>'index.php?menuaction=calendar.uicalendar.add&location='. $data['name']
+				);
+
+
+
+//'accionagregar'	=>'index.php?menuaction=resources.uiresources.edit&parent='. $data['id']
+$p->set_var($info);
+				$p->set_var($data);
+				$p->parse('rows','search_list',True);
+			}
+//	}
+			if($matches > 0)
+			{
+				$p->parse('rows','search_list_footer',True);
+			}
+
+			$p->pparse('out','search');
+		}
+
+
+function get_event_ids($search)
+		{
+//echo "tamannn".count($search)."  ".$search[0];
+
+$from ="";
+//if (isset($_REQUEST['id'])){
+
+	//		$from = ' and t1.res_id='.$_REQUEST['id'];
+	//		}
+
+			$sql = 'select t1.*,t2.cat_name from   phpgw_resources t1 ,phpgw_categories t2 where t1.cat_id=t2.cat_id '
+					. $from;
+					//.$search;
+					//. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) '
+					//. $where . $extra;
+
+
+//echo "FULL SQL : ".$sql."<br>\n";
+
+
+			if($this->debug)
+			{
+				echo "FULL SQL : ".$sql."<br>\n";
+			}
+
+ //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar");
+
+
+$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+while( $GLOBALS['phpgw']->db->next_record() )
+			{
+			//	
+
+$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_start'),$alarm = 0);
+$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year'];
+
+$valorfechaend=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_end'),$alarm = 0);
+$end=$valorfechaend['mday']."/".$valorfechaend['month']."/".$valorfechaend['year'];
+
+$valorfechaend2=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_modified'),$alarm = 0);
+$end2=$valorfechaend2['mday']."/".$valorfechaend2['month']."/".$valorfechaend2['year'];
+
+$imagen2="";
+if($GLOBALS['phpgw']->db->f('picture_src')!=""){
+$imagen2="<img src='".$GLOBALS['phpgw_info']['server']['webserver_url']."/resources/templates/default/images/resource_icons/".$GLOBALS['phpgw']->db->f('picture_src')."'>";
+}
+
+
+
+$retval[] =  array(
+
+'id'    => $GLOBALS['phpgw']->db->f('res_id'),
+					'name'         => $GLOBALS['phpgw']->db->f('name'),
+					'description'         => $GLOBALS['phpgw']->db->f('short_description'),
+					'category'         => $GLOBALS['phpgw']->db->f('cat_name'),
+					'picture_src' => $imagen2,
+					'administrador'=>$GLOBALS['phpgw']->db->f('administrador'),
+					'location'=>$GLOBALS['phpgw']->db->f('location'),
+					'email'=>$GLOBALS['phpgw']->db->f('email'),
+					'owner'=>$GLOBALS['phpgw']->db->f('owner')
+
+					
+				);
+
+
+			}
+		
+
+
+			
+			return $retval;
+		}
+
+
+
+
+
+
+
+
+
+
+
+function update()
+		{
+
+
+
+#  $vars = get_defined_vars();  
+#   print_r($vars);
+/*foreach($_POST as $k=>$v){
+$$k=$v;
+echo $$k."<br>";
+} 
+foreach($_POST as $nombre_campo => $valor){
+   $asignacion = "\$" . $nombre_campo . "='" . $valor . "';";
+   echo $asignacion."<br>";
+} */
+
+
+
+
+
+
+
+unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			$error = '';
+
+			$matches = 0;
+
+
+
+
+
+list($dia,$mes,$ano)=split("/",$_POST['start']['str']);
+
+	$starttime = $this->bo->maketime2($_POST['start']['hour'],$_POST['start']['min'],0,$dia,$mes,$ano,$_POST['start']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
+//echo $starttime;
+
+list($dia2,$mes2,$ano2)=split("/",$_POST['end']['str']);
+
+	$endtime = $this->bo->maketime2($_POST['end']['hour'],$_POST['end']['min'],0,$dia2,$mes2,$ano2,$_POST['end']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
+//echo "gggg".$_POST['end2']['month'];
+if($_POST['end2']['str']['month']>0){
+list($dia3,$mes3,$ano3)=split("/",$_POST['end2']['str']);
+	$endtime2 = $this->bo->maketime2($_POST['end2']['hour'],$_POST['end2']['min'],0,$dia3,$mes3,$ano3,$_POST['end2']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
+}else{
+$endtime2=0;
+}
+ 
+			//$starttime = $this->bo->maketime2($starthora,$startmin,0,$startfecha) - $GLOBALS['phpgw']->datetime->tz_offset;
+//echo "kkkk3".$_POST['exec']['accesso'];
+if($_REQUEST['resources']['parent']==""){
+$parent=0;
+
+}else{
+$parent=$_REQUEST['resources']['parent'];
+
+}
+$resources=Array(
+name=>$_POST['resources']['name'],
+descripction=>$_POST['resources']['description']
+);
+$valores="&name=".$_POST['resources']['name']."&description=".$_POST['resources']['description']."&category=".$_POST['resources']['category']."&cantidad=".$_POST['resources']['cantidad']."&email=".$_POST['resources']['email']."&administrador=".$_POST['resources']['administrador']."&location=".$_POST['resources']['location']."";
+
+//$GLOBALS['phpgw']->redirect($this->page($valores,''));
+if($_POST['resources']['name']==""){
+$GLOBALS['phpgw']->redirect($this->page('edit&error=44'.$valores,''));
+}
+if($_POST['resources']['location']==""){
+$GLOBALS['phpgw']->redirect($this->page('edit&error=45'.$valores,''));
+}
+if($_POST['resources']['cantidad']==""){
+$GLOBALS['phpgw']->redirect($this->page('edit&error=46'.$valores,''));
+}
+if($_POST['resources']['email']==""){
+$GLOBALS['phpgw']->redirect($this->page('edit&error=47'.$valores,''));
+}
+if($_POST['resources']['description']==""){
+$GLOBALS['phpgw']->redirect($this->page('edit&error=48'.$valores,''));
+}
+
+/*ExecMethod('resources.uiresources.edit',			Array(
+							'cd'		=> 13,
+							'readsess'	=> 1
+						)
+					);*/
+
+//$parms['errormsg']=$GLOBALS['phpgw']->common->check_code(13);
+//echo $GLOBALS['phpgw']->common->check_code(13);
+//ExecMethod('resources.uiresources.index',$parms);
+//	$GLOBALS['phpgw']->common->phpgw_exit();
+
+		//	$endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
+if(isset($_POST['resources']['id'])&&$_POST['resources']['id']>0){
+			$sql = "update  phpgw_resources set  name='".$_POST['resources']['name']."',short_description='".$_POST['resources']['description']."',cat_id=".$_POST['resources']['category'].",quantity=".$_POST['resources']['cantidad'].",location='".$_POST['resources']['location']."',picture_src='".$_POST['resources']['picture_src']."',  administrador='". $this->get_account_name($_POST['resources']['administrador'],'gecos')."',email='".$_POST['resources']['email']."',owner=".$_POST['resources']['owner']."  where res_id='".$_POST['resources']['id']."'";
+}else{
+			$sql = "insert into  phpgw_resources (name,short_description,cat_id,quantity,location,picture_src,  administrador,email,owner) 
+values ('".$_POST['resources']['name']."','".$_POST['resources']['description']."',".$_POST['resources']['category'].",".$_POST['resources']['cantidad'].",'". $this->get_account_name($_POST['resources']['administrador'],'gecos')."','".$_POST['resources']['picture_src']."','".$_POST['resources']['administrador']."','".$_POST['resources']['email']."',".$_POST['resources']['owner'].")";
+
+
+
+  
+}
+
+$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);	
+$GLOBALS['phpgw']->redirect($this->page('edit&error=14',''));
+
+
+return "";
+		}
+
+
+
+
+function get_account_name($account_id,$valor)
+		{
+			$acct_type = $this->get_type($account_id);
+
+			/* jakjr: using justthese with ldap_search */
+			//$justthese = array("cn","uid","givenname","sn","gecos");
+
+			/* search the dn for the given uid */
+
+$justthese = array("uidnumber",  "cn",  "mail","gecos","dn");
+			//	$sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese);
+
+			if(($acct_type == 'g') && $this->group_context)
+			{
+				$sri = @ldap_search($this->ds, $this->group_context, '(gidnumber=' . (int)$account_id . ')', $justthese);
+			}
+			else
+			{
+				$sri = @ldap_search($this->ds, $this->user_context, '(uidnumber=' . (int)$account_id . ')', $justthese);
+			}
+
+//echo $this->ds.",". $this->user_context.",". '(uidnumber=' . (int)$account_id . ')'.",". $justthese;
+			if(!$sri)
+				return False;
+			$allValues = ldap_get_entries($this->ds, $sri);
+$retorna="";
+			if($acct_type =='g')
+			{
+				if($valor=='gecos') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
+				}
+				if($valor=='uidnumber') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
+				}
+				if($valor=='cn') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
+				}
+
+				if($valor=='mail') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
+				}
+				if($valor=='dn') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
+				}
+				
+			}
+			else
+			{
+				if($valor=='gecos') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
+				}
+				if($valor=='uidnumber') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
+				}
+				if($valor=='cn') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
+				}
+
+				if($valor=='mail') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
+				}
+				if($valor=='dn') {
+					$retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
+				}
+				
+
+
+
+			}
+			return $retorna;
+		}
+
+
+
+
+
+function get_type($account_id)
+		{
+			$allValues = array();
+			/* jakjr: using justthese with ldap_search */
+			$sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))', array("phpgwaccounttype"));
+			if(!$sri)
+				return False;
+			$allValues = ldap_get_entries($this->ds, $sri);
+
+			if ($allValues[0]['phpgwaccounttype'][0])
+			{
+				return $allValues[0]['phpgwaccounttype'][0];
+			}
+
+			$allValues = array();
+			/* jakjr: using justthese with ldap_search */
+			$sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))', array("phpgwaccounttype"));
+			if(!$sri)
+				return False;
+			$allValues = ldap_get_entries($this->ds, $sri);
+
+			if ($allValues[0]['phpgwaccounttype'][0])
+			{
+				return $allValues[0]['phpgwaccounttype'][0];
+			}
+			return False;
+		}
+
+
+
+
+
+
+
+function select($id)
+		{
+
+
+			$sql = "select * from   phpgw_resources where res_id='".$id."'";
+
+$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);	
+
+if( $GLOBALS['phpgw']->db->next_record() )
+			{
+
+
+
+
+$retval =  array(
+					'id'    => $GLOBALS['phpgw']->db->f('res_id'),
+					'name'         => $GLOBALS['phpgw']->db->f('name'),
+					'descripcion'         => $GLOBALS['phpgw']->db->f('short_description'),
+					'category'         => $GLOBALS['phpgw']->db->f('cat_id'),
+					'picture_src' => $GLOBALS['phpgw']->db->f('picture_src'),
+					'administrador'=>$GLOBALS['phpgw']->db->f('administrador'),
+					'email'=>$GLOBALS['phpgw']->db->f('email'),
+                                        'location'=>$GLOBALS['phpgw']->db->f('location'),
+					'cantidad'=>$GLOBALS['phpgw']->db->f('quantity'),
+					'owner'=>$GLOBALS['phpgw']->db->f('owner')
+				);
+
+			}
+		
+//echo "iddd".$id."  56666 ".$retval['id'];
+
+
+return $retval;
+		
+		}
+
+
+function select_init()
+		{
+
+$id=0;
+if(isset($_REQUEST['resources[id]'])){
+$id=$_REQUEST['resources[id]'];
+}
+
+$name="";
+if(isset($_REQUEST['name'])){
+$name=$_REQUEST['name'];
+}
+
+
+$description="";
+if(isset($_REQUEST['description'])){
+$description=$_REQUEST['description'];
+}
+
+$catgory=0;
+if(isset($_REQUEST['category'])){
+$category=$_REQUEST['category'];
+}
+$administrador="";
+if(isset($_REQUEST['administrador'])){
+$administrador=$_REQUEST['administrador'];
+}
+$email="";
+if(isset($_REQUEST['email'])){
+$email=$_REQUEST['email'];
+}
+$cantidad=0;
+if(isset($_REQUEST['cantidad'])){
+$cantidad=$_REQUEST['cantidad'];
+}
+
+$location="";
+if(isset($_REQUEST['location'])){
+$location=$_REQUEST['location'];
+}
+			
+$retval =  array(
+
+					'id'    => $id,
+					'name'         => $name,
+					'descripcion'         => $description,
+					'category'         => $category,
+					'picture_src' => 'generic.png',
+					'administrador'=>$administrador,
+					'location'=>$location,
+					'email'=>$email,
+                                        'cantidad'=>$cantidad,
+					'owner'=>$this->bo->owner
+
+
+					
+				);
+
+
+
+
+
+
+			
+
+
+return $retval;
+		
+		}
+
+
+function delete()
+		{
+
+
+
+#  $vars = get_defined_vars();  
+#   print_r($vars);
+/*foreach($_POST as $k=>$v){
+$$k=$v;
+echo $$k."<br>";
+} 
+foreach($_POST as $nombre_campo => $valor){
+   $asignacion = "\$" . $nombre_campo . "='" . $valor . "';";
+   echo $asignacion."<br>";
+} */
+
+
+
+
+unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['infolog']['title'].' - '.lang('Search Results');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			$error = '';
+
+			$matches = 0;
+
+
+
+
+		//	$endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
+
+			$sql = "delete from  phpgw_resources   where res_id='".$_GET['id']."'";
+
+
+$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);	
+
+$params['errormsg'] = '';
+$GLOBALS['phpgw']->redirect($this->page('search',$params));
+return "";
+		}
+
+
+ function translate($key,$vars=false, $not_found='*' )
+	  {
+    	    if ($this->async)
+	      return $GLOBALS['phpgw']->translation->translate_async($key, $vars);
+	    return lang($key, $vars);
+	  }
+
+function maketime($time)
+		{
+			return mktime(intval($time['hour']),intval($time['min']),intval($time['sec']),intval($time['month']),intval($time['mday']),intval($time['year']));
+		}
+
+function search2()
+		{
+
+//print_r($_REQUEST); 
+
+			$jscal = CreateObject('phpgwapi.jscalendar');	// before phpgw_header() !!!
+
+			unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			$error = '';
+
+
+
+			$matches = 0;
+
+//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288884600);
+
+//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288886400);
+if (isset($_REQUEST['fecha'])){
+list($dia,$mes,$ano)=split("/",$_REQUEST['fecha']);
+
+	$starttime = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset;
+///echo $starttime;
+$starttime2 = $this->bo->maketime2(23,59,59,$dia,$mes,$ano,'pm') - $GLOBALS['phpgw']->datetime->tz_offset;
+///echo $starttime2;
+}
+		//$event = $this->bo->read_entry($res_id);	
+$event = $this->get_event_ids2($_REQUEST['id'],$starttime,$starttime2);
+
+
+			//$event_ids = $this->bo->search_keywords($_POST['keywords']);
+
+			
+			$matches = count($event);
+
+//echo "matches" . $matches;
+
+			if ($matches == 1)
+			{
+				$quantity = lang('1 match found').'.';
+			}
+			elseif ($matches > 0)
+			{
+				$quantity = lang('%1 matches found',$matches).'.';
+			}
+			else
+			{
+				echo lang('no matches found');
+				return;
+			}
+
+			$p = $GLOBALS['phpgw']->template;
+			$p->set_file(
+				Array(
+					'search_form'	=> 'search2.tpl'
+				)
+			);
+			$p->set_block('search_form','search','search');
+			$p->set_block('search_form','search_list_header','search_list_header');
+			$p->set_block('search_form','search_list','search_list');
+			$p->set_block('search_form','search_list_footer','search_list_footer');
+
+
+$script='';
+
+		
+
+			if($matches > 0)
+			{
+				$p->parse('rows','search_list_header',True);
+			}
+
+//if($info){
+			foreach($event  as $id => $data)
+			{
+
+
+				$datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
+
+
+
+
+				$info = array(
+					'tr_color'	=> $GLOBALS['phpgw']->nextmatchs->alternate_row_color(),
+					'date'		=> $GLOBALS['phpgw']->common->show_date($datetime),
+'id'    => $data['id'],
+					'name'         => $data['name'],
+					'description'         => $data['short_description'],
+					'location'         =>$data['namelocation'],
+				
+					'owner'=>$this->get_account_name($data['owner'],'gecos'),
+					'fecha'=>$data['fech'],
+					'priority'=>$data['priority'],
+					'ispublic'=>$data['ispublic'],
+
+'accionmodificar'	=>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'],
+'accionlistar'	=>'index.php?menuaction=resources.uiresources.search2&id='. $data['id'],
+'accionborrar'	=>$data['id'],
+'accionreservar'	=>'index.php?menuaction=calendar.uicalendar.add&location='. $data['id']
+				);
+
+
+
+//'accionagregar'	=>'index.php?menuaction=resources.uiresources.edit&parent='. $data['id']
+$p->set_var($info);
+				$p->set_var($data);
+				$p->parse('rows','search_list',True);
+			}
+//	}
+			if($matches > 0)
+			{
+				$p->parse('rows','search_list_footer',True);
+			}
+
+			$p->pparse('out','search');
+		}
+
+
+
+
+function get_event_ids2($idd,$starttime,$starttime2)
+		{
+////echo "tamannn".count($search)."  ".$search[0];
+
+$from ="";
+if (isset($idd)){
+
+			$from = ' and t1.location=\''.$idd.'\' ';
+			}
+
+if (isset($starttime)){
+if (isset($starttime2)){
+
+			$from =$from .' and t1.datetime>=\''.$starttime.'\' and t1.datetime<=\''.$starttime2.'\' ';
+}
+			}
+
+			$sql = 'select t1.cal_id ,t1.owner,t1.groups,t1.datetime,t1.edatetime,
+t1.priority ,t1.cal_type, t1.is_public ,
+t1.title,t1.description,t1.location ,
+t2.list_descripcion as publico,t3.list_descripcion as priority ,t4.name as namelocation from   phpgw_cal  t1, phpgw_listas t2, phpgw_listas t3 ,phpgw_resources t4
+where t1.is_public =t2.list_id and t2.list_name=\'visibility\' 
+and t1.priority=t3.list_id and t3.list_name=\'priority\' 
+and t1.location=t4.name '
+					. $from. "order by t1.datetime desc ";
+					//.$search;
+					//. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) '
+					//. $where . $extra;
+
+
+
+
+
+			if($this->debug)
+			{
+				echo "FULL SQL : ".$sql."<br>\n";
+			}
+
+ //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar");
+
+
+$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+while( $GLOBALS['phpgw']->db->next_record() )
+			{
+			//	
+
+//$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('datetime'),$alarm = 0);
+//$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year'];
+$ini=$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('datetime'))."-".$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('edatetime'));
+
+
+
+$retval[] =  array(
+
+'id'    => $GLOBALS['phpgw']->db->f('cat_id'),
+					'name'         => $GLOBALS['phpgw']->db->f('title'),
+					'description'         => $GLOBALS['phpgw']->db->f('description'),					
+					'location'=>$GLOBALS['phpgw']->db->f('namelocation'),
+					'groups'=>$GLOBALS['phpgw']->db->f('groups'),
+					'owner'=>$this->get_account_name($GLOBALS['phpgw']->db->f('owner'),'gecos'),
+					'fecha'=>$ini,
+					'priority'=>$GLOBALS['phpgw']->db->f('priority'),
+					'ispublic'=>$GLOBALS['phpgw']->db->f('publico')
+
+					
+				);
+
+
+			}
+		
+
+
+			
+			return $retval;
+		}
+
+
+
+}
+
+?>
Index: contrib/resources/inc/class.bo_resources.inc.php
===================================================================
--- contrib/resources/inc/class.bo_resources.inc.php	(revision 3524)
+++ contrib/resources/inc/class.bo_resources.inc.php	(revision 3524)
@@ -0,0 +1,548 @@
+<?php
+/**
+ * eGroupWare - resources
+ *
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @package resources
+ * @link http://www.egroupware.org
+ * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+ * @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
+ * @version $Id: class.bo_resources.inc.php 24207 2007-06-25 16:44:20Z ralfbecker $
+ */
+
+
+/**
+ * General business object for resources
+ *
+ * @package resources
+ */
+class bo_resources
+{
+	var $vfs_basedir = '/resources/';
+	var $pictures_dir = '/resources/pictures/';
+	var $thumbs_dir = '/resources/pictures/thumbs/';
+	var $resource_icons = '/resources/templates/default/images/resource_icons/';
+	var $debug = 0;
+	/**
+	 * Instance of resources so object
+	 *
+	 * @var so_resources
+	 */
+	var $so;
+	
+	function bo_resources()
+	{
+		$this->so =& CreateObject('resources.so_resources');
+		$this->acl =& CreateObject('resources.bo_acl');
+		$this->cats = $this->acl->phpgw_cats;
+		$this->vfs =& CreateObject('phpgwapi.vfs');
+		$this->link =& CreateObject('phpgwapi.bolink');
+		$this->conf =& CreateObject('phpgwapi.config');
+		$this->conf->read_repository();
+		
+		$this->cal_right_transform = array(	
+			phpgw_ACL_CALREAD 	=> phpgw_ACL_READ,
+			phpgw_ACL_DIRECT_BOOKING 	=> phpgw_ACL_READ | phpgw_ACL_ADD | phpgw_ACL_EDIT | phpgw_ACL_DELETE,
+			phpgw_ACL_CAT_ADMIN 	=> phpgw_ACL_READ | phpgw_ACL_ADD | phpgw_ACL_EDIT | phpgw_ACL_DELETE,
+		);
+	}
+
+	/**
+	 * get rows for resources list
+	 *
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 */
+	function get_rows($query,&$rows,&$readonlys)
+	{
+		if ($this->debug) _debug_array($query);
+		$query['search'] = $query['search'] ? $query['search'] : '*';
+		$criteria = array('name' => $query['search'], 'short_description' => $query['search'], 'inventory_number' => $query['search']);
+		$read_onlys = 'res_id,name,short_description,quantity,useable,bookable,buyable,cat_id,location,storage_info';
+		
+		$accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1;
+ 		$filter = array('accessory_of' => $accessory_of);
+		if ($query['filter'])
+		{
+			$filter = $filter + array('cat_id' => $query['filter']);
+		}
+		else
+		{
+			$readcats = array_flip((array)$this->acl->get_cats(phpgw_ACL_READ));
+			if($readcats) $filter = $filter + array('cat_id' => $readcats);
+		}
+		if($query['show_bookable']) $filter = $filter + array('bookable' => true);
+		$order_by = $query['order'] ? $query['order'].' '. $query['sort'] : '';
+		$start = (int)$query['start'];
+		
+		$rows = $this->so->search($criteria,$read_onlys,$order_by,'','%',$empty=False,$op='OR',$start,$filter,$join='',$need_full_no_count=false);
+		$nr = $this->so->total;
+		
+		// we are called to serve bookable resources (e.g. calendar-dialog)
+		if($query['show_bookable'])
+		{
+			// This is somehow ugly, i know...
+			foreach((array)$rows as $num => $resource)
+			{
+				$rows[$num]['default_qty'] = 1;
+			}
+			// we don't need all the following testing
+			return $nr;
+		}
+		
+		foreach((array)$rows as $num => $resource)
+		{
+			if (!$this->acl->is_permitted($resource['cat_id'],phpgw_ACL_EDIT))
+			{
+				$readonlys["edit[$resource[res_id]]"] = true;
+			}
+			if (!$this->acl->is_permitted($resource['cat_id'],phpgw_ACL_DELETE))
+			{
+				$readonlys["delete[$resource[res_id]]"] = true;
+			}
+			if ((!$this->acl->is_permitted($resource['cat_id'],phpgw_ACL_ADD)) || $accessory_of != -1)
+			{
+				$readonlys["new_acc[$resource[res_id]]"] = true;
+			}
+			if (!$resource['bookable'])
+			{
+				$readonlys["bookable[$resource[res_id]]"] = true;
+				$readonlys["calendar[$resource[res_id]]"] = true;
+			}
+			if(!$this->acl->is_permitted($resource['cat_id'],phpgw_ACL_CALREAD))
+			{
+				$readonlys["calendar[$resource[res_id]]"] = true;
+			}
+			if (!$resource['buyable'])
+			{
+				$readonlys["buyable[$resource[res_id]]"] = true;
+			}
+			$readonlys["view_acc[$resource[res_id]]"] = true;
+			$links = $this->link->get_links('resources',$resource['res_id']);
+			if(count($links) != 0 && $accessory_of == -1)
+			{
+				foreach ($links as $link_num => $link)
+				{
+					if($link['app'] == 'resources')
+					{
+						if($this->so->get_value('accessory_of',$link['res_id']) != -1)
+						{
+							$readonlys["view_acc[$resource[res_id]]"] = false;
+						}
+					}
+				}
+			}
+			$rows[$num]['picture_thumb'] = $this->get_picture($resource['res_id']);
+			$rows[$num]['admin'] = $this->acl->get_cat_admin($resource['cat_id']);
+		}
+		return $nr;
+	}
+
+	/**
+	 * reads a resource exept binary datas
+	 *
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @param int $res_id resource id
+	 * @return array with key => value or false if not found or allowed
+	 */
+	function read($res_id)
+	{
+		if(!$this->acl->is_permitted($this->so->get_value('cat_id',$res_id),phpgw_ACL_READ))
+		{
+			echo lang('You are not permitted to get information about this resource!') . '<br>';
+			echo lang('Notify your administrator to correct this situation') . '<br>';
+			return false;
+		}
+		return $this->so->read(array('res_id' => $res_id));
+	}
+	
+	/**
+	 * saves a resource. pictures are saved in vfs
+	 *
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @param array $resource array with key => value of all needed datas
+	 * @return string msg if somthing went wrong; nothing if all right
+	 */
+	function save($resource)
+	{
+		if(!$this->acl->is_permitted($resource['cat_id'],phpgw_ACL_EDIT))
+		{
+			return lang('You are not permitted to edit this reource!');
+		}
+		
+		// we need an id to save pictures and make links...
+		if(!$resource['res_id'])
+		{
+			$resource['res_id'] = $this->so->save($resource);
+		}
+
+		switch ($resource['picture_src'])
+		{
+			case 'own_src':
+				$vfs_data = array('string' => $this->pictures_dir.$resource['res_id'].'.jpg','relatives' => array(RELATIVE_ROOT));
+				if($resource['own_file']['size'] > 0)
+				{
+					$msg = $this->save_picture($resource['own_file'],$resource['res_id']);
+					break;
+				}
+				elseif($this->vfs->file_exists($vfs_data))
+				{
+					break;
+				}
+				$resource['picture_src'] = 'cat_src';
+			case 'cat_src':
+				break;
+			case 'gen_src':
+				$resource['picture_src'] = $resource['gen_src_list'];
+				break;
+			default:
+				if($resource['own_file']['size'] > 0)
+				{
+					$resource['picture_src'] = 'own_src';
+					$msg = $this->save_picture($resource['own_file'],$resource['res_id']);
+				}
+				else
+				{
+					$resource['picture_src'] = 'cat_src';
+				}
+		}
+		// somthing went wrong on saving own picture
+		if($msg)
+		{
+			return $msg;
+		}
+		
+		// delete old pictures
+		if($resource['picture_src'] != 'own_src')
+		{
+			$this->remove_picture($resource['res_id']);
+		}
+
+		// save links
+		if(is_array($resource['link_to']['to_id']))
+		{
+			$this->link->link('resources',$resource['res_id'],$resource['link_to']['to_id']);
+		}
+		if($resource['accessory_of'] != -1)
+		{
+			$this->link->link('resources',$resource['res_id'],'resources',$resource['accessory_of']);
+		}
+		
+		if(!empty($resource['res_id']) && $this->so->get_value("cat_id",$resource['res_id']) != $resource['cat_id'] && $resource['accessory_of'] == -1)
+		{
+			$accessories = $this->get_acc_list($resource['res_id']);
+			foreach($accessories as $accessory => $name)
+			{
+				$acc = $this->so->read($accessory);
+				$acc['cat_id'] = $resource['cat_id'];
+				$this->so->data = $acc;
+				$this->so->save();
+			}
+		}
+		
+		return $this->so->save($resource) ? false : lang('Something went wrong by saving resource');
+	}
+
+	/**
+	 * deletes resource including pictures and links
+	 *
+	 * @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
+	 * @param int $res_id id of resource
+	 */
+	function delete($res_id)
+	{
+		if(!$this->acl->is_permitted($this->so->get_value('cat_id',$res_id),phpgw_ACL_DELETE))
+		{
+			return lang('You are not permitted to delete this reource!');
+		}
+		
+		if ($this->so->delete(array('res_id'=>$res_id)))
+		{
+			$this->remove_picture($res_id);
+	 		$this->link->unlink(0,'resources',$res_id);
+	 		// delete the resource from the calendar
+	 		ExecMethod('calendar.socal.change_delete_user','r'.$res_id);
+	 		return false;
+		}
+		return lang('Something went wrong by deleting resource');
+	}
+	
+	/**
+	 * gets list of accessories for resource
+	 *
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @param int $res_id id of resource
+	 * @return array
+	 */
+	function get_acc_list($res_id)
+	{
+		if($res_id < 1){return;}
+		$data = $this->so->search('','res_id,name','','','','','',$start,array('accessory_of' => $res_id),'',$need_full_no_count=true);
+		foreach($data as $num => $resource)
+		{
+			$acc_list[$resource['res_id']] = $resource['name'];
+		}
+		return $acc_list;
+	}
+	
+	/**
+	 * returns info about resource for calender
+	 * @author Cornelius Weiss<phpgw@von-und-zu-weiss.de>
+	 * @param int/array $res_id single id or array $num => $res_id
+	 * @return array 
+	 */
+	function get_calendar_info($res_id)
+	{
+		//echo "<p>bo_resources::get_calendar_info(".print_r($res_id,true).")</p>\n";
+		if(!is_array($res_id) && $res_id < 1) return;
+
+		$data = $this->so->search(array('res_id' => $res_id),'res_id,cat_id,name,useable');
+		
+		foreach($data as $num => $resource)
+		{
+			$data[$num]['rights'] = false;
+			foreach($this->cal_right_transform as $res_right => $cal_right)
+			{
+				if($this->acl->is_permitted($resource['cat_id'],$res_right))
+				{
+					$data[$num]['rights'] = $cal_right;
+				}
+			}
+			$data[$num]['responsible'] = $this->acl->get_cat_admin($resource['cat_id']);
+		}
+		return $data;
+	}
+	
+	/**
+	 * returns status for a new calendar entry depending on resources ACL
+	 * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @param int $res_id single id
+	 * @return array 
+	 */
+	function get_calendar_new_status($res_id)
+	{
+		$data = $this->so->search(array('res_id' => $res_id),'res_id,cat_id,bookable');
+		if($data[0]['bookable'] == 0) return 'x';
+		return $this->acl->is_permitted($data[0]['cat_id'],phpgw_ACL_DIRECT_BOOKING) ? A : U;
+	}
+	
+	/**
+	 * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * query infolog for entries matching $pattern
+	 *
+	 */
+	function link_query( $pattern )
+	{
+		$criteria = array('name' => $pattern, 'short_description' => $pattern);
+		$only_keys = 'res_id,name,short_description';
+		$filter = array(
+			'cat_id' => array_flip((array)$this->acl->get_cats(phpgw_ACL_READ)),
+			//'accessory_of' => '-1'
+		);
+		$data = $this->so->search($criteria,$only_keys,$order_by='',$extra_cols='',$wildcard='%',$empty,$op='OR',false,$filter);
+		foreach($data as $num => $resource)
+		{
+			$list[$resource['res_id']] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':'');
+		}
+		return $list;
+	}
+		
+	/**
+	 * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * get title for an infolog entry identified by $res_id
+	 *
+	 * @return string/boolean string with title, null if resource does not exist or false if no perms to view it
+	 */
+	function link_title( $resource )
+	{
+		if (!is_array($resource))
+		{
+			if (!($resource  = $this->so->read(array('res_id' => $resource)))) return null;
+		}
+		if(!$this->acl->is_permitted($resource['cat_id'],phpgw_ACL_READ)) return false;
+
+		return $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':'');
+	}
+	
+	/**
+	 * resizes and saves an pictures in vfs
+	 *
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @param array $file array with key => value
+	 * @param int $resource_id
+	 * @return mixed string with msg if somthing went wrong; nothing if all right
+	 * TODO make thumb an picture sizes choosable by preferences
+	 */	
+	function save_picture($file,$resouce_id)
+	{
+		// test upload dir
+		$vfs_data = array('string'=>$this->vfs_basedir,'relatives'=>array(RELATIVE_ROOT));
+		if (!($this->vfs->file_exists($vfs_data)))
+		{
+			$this->vfs->override_acl = 1;
+			$this->vfs->mkdir($vfs_data);
+			$vfs_data['string'] = $this->pictures_dir;
+			$this->vfs->mkdir($vfs_data);
+			$vfs_data['string'] = $this->thumbs_dir;
+			$this->vfs->mkdir($vfs_data);
+			$this->vfs->override_acl = 0;
+		}
+		
+		switch($file['type'])
+		{
+			case 'image/gif':
+				$src_img = imagecreatefromgif($file['tmp_name']);
+				break;
+			case 'image/jpeg':
+			case 'image/pjpeg':
+				$src_img = imagecreatefromjpeg($file['tmp_name']);
+				break;
+			case 'image/png':
+			case 'image/x-png':
+				$src_img = imagecreatefrompng($file['tmp_name']);
+				break;
+			default:
+				return lang('Picture type is not supported, sorry!');
+		}
+		
+		$src_img_size = getimagesize($file['tmp_name']);
+		$dst_img_size = array( 0 => 320, 1 => 240);
+		$thumb_size = array( 0 => 64, 1 => 48);
+		
+		$tmp_dir = $GLOBALS['phpgw_info']['server']['temp_dir'].'/';
+		if($src_img_size[0] > 64 || $src_img_size[1] > 48)
+		{
+			$f = $thumb_size[0] / $src_img_size[0];
+			$f = $thumb_size[1] / $src_img_size[1] < $f ? $thumb_size[1] / $src_img_size[1] : $f;
+			$dst_img = imagecreatetruecolor($src_img_size[0] * $f, $src_img_size[1] * $f);
+			imagecopyresized($dst_img,$src_img,0,0,0,0,$src_img_size[0] * $f,$src_img_size[1] * $f,$src_img_size[0],$src_img_size[1]);
+			imagejpeg($dst_img,$tmp_dir.$resouce_id.'.thumb.jpg');
+			if($src_img_size[0] > $dst_img_size[0] || $src_img_size[1] > $dst_img_size[1])
+			{
+				$f = $dst_img_size[0] / $src_img_size[0];
+				$f = $dst_img_size[1] / $src_img_size[1] < $f ? $dst_img_size[1] / $src_img_size[1] : $f;
+				$dst_img = imagecreatetruecolor($src_img_size[0] * $f, $src_img_size[1] * $f);
+				imagecopyresized($dst_img,$src_img,0,0,0,0,$src_img_size[0] * $f,$src_img_size[1] * $f,$src_img_size[0],$src_img_size[1]);
+				imagejpeg($dst_img,$tmp_dir.$resouce_id.'.jpg');
+			}
+			else
+			{
+				imagejpeg($src_img,$tmp_dir.$resouce_id.'.jpg');
+			}
+			imagedestroy($dst_img);
+		}
+		else
+		{
+				imagejpeg($src_img,$tmp_dir.$resouce_id.'.jpg');
+				imagejpeg($src_img,$tmp_dir.$resouce_id.'.thumb.jpg');
+		}
+		imagedestroy($src_img);
+			
+		$this->vfs->override_acl = 1;
+		$this->vfs->cp(array(
+			'from' => $tmp_dir.$resouce_id.'.jpg',
+			'to'   => $this->pictures_dir.$resouce_id.'.jpg',
+			'relatives' => array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT)
+		));
+		$this->vfs->set_attributes(array(
+			'string' => $this->pictures_dir.$resouce_id.'.jpg',
+			'relatives' => array (RELATIVE_ROOT),
+			'attributes' => array (
+				'mime_type' => 'image/jpeg',
+				'comment' => 'picture of resource no.'.$resouce_id,
+				'app' => $GLOBALS['phpgw_info']['flags']['currentapp']
+		)));
+		$this->vfs->cp(array(
+			'from' => $tmp_dir.$resouce_id.'.thumb.jpg',
+			'to'   => $this->thumbs_dir.$resouce_id.'.jpg',
+			'relatives' => array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT)
+			));
+		$this->vfs->set_attributes(array(
+			'string' => $this->thumbs_dir.$resouce_id.'.jpg',
+			'relatives' => array (RELATIVE_ROOT),
+			'attributes' => array (
+				'mime_type' => 'image/jpeg',
+				'comment' => 'thumbnail of resource no.'.$resouce_id,
+				'app' => $GLOBALS['phpgw_info']['flags']['currentapp']
+		)));
+		$this->vfs->override_acl = 0;
+		return;
+	}
+	
+	/**
+	 * get resource picture either from vfs or from symlink
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @param int $res_id id of resource
+	 * @param bool $size false = thumb, true = full pic
+	 * @return string url of picture
+	 */
+	function get_picture($res_id=0,$size=false)
+	{
+		if ($res_id > 0)
+		{
+			$src = $this->so->get_value('picture_src',$res_id);
+		}
+		switch($src)
+		{
+			case 'own_src':
+				$picture = $this->conf->config_data['dont_use_vfs'] ? $GLOBALS['phpgw_info']['server']['webserver_url'] : 'vfs:';
+				$picture .= $size ? $this->pictures_dir.$res_id.'.jpg' : $this->thumbs_dir.$res_id.'.jpg';
+				break;
+			case 'cat_src':
+				list($picture) = $this->cats->return_single($this->so->get_value('cat_id',$res_id));
+				$picture = unserialize($picture['data']);
+				if($picture['icon'])
+				{
+					$picture = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/images/'.$picture['icon'];
+					break;
+				}
+			case 'gen_src':
+			default :
+				$picture = $GLOBALS['phpgw_info']['server']['webserver_url'].$this->resource_icons;
+				$picture .= strpos($src,'.') !== false ? $src : 'generic.png';
+		}
+		return $picture;
+	}
+	
+	/**
+	 * remove_picture
+	 * removes picture from vfs
+	 *
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @param int $res_id id of resource
+	 * @return bool succsess or not
+	 */
+	function remove_picture($res_id)
+	{
+		$vfs_data = array('string' => $this->pictures_dir.$res_id.'.jpg','relatives' => array(RELATIVE_ROOT));
+		$this->vfs->override_acl = 1;
+		if($this->vfs->file_exists($vfs_data))
+		{
+			$this->vfs->rm($vfs_data);
+			$vfs_data['string'] = $this->thumbs_dir.$res_id.'.jpg';
+			$this->vfs->rm($vfs_data);
+		}
+		$this->vfs->override_acl = 0;
+	}
+
+	/**
+	 * get_genpicturelist
+	 * gets all pictures from 'generic picutres dir' in selectbox style for eTemplate
+	 *
+	 * Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+	 * @return array directory contens in eTemplates selectbox style
+	 */
+	function get_genpicturelist()
+	{
+		$icons['generic.png'] = lang('gernal resource');
+		$dir = dir(phpgw_SERVER_ROOT.$this->resource_icons);
+		while($file = $dir->read())
+		{
+			if (preg_match('/\\.(png|gif|jpe?g)$/i',$file) && $file != 'generic.png')
+			{
+				$icons[$file] = substr($file,0,strpos($file,'.'));
+			}
+		}
+		$dir->close();
+		return $icons;
+	}
+}
Index: contrib/resources/inc/class.boresources.inc.php
===================================================================
--- contrib/resources/inc/class.boresources.inc.php	(revision 3524)
+++ contrib/resources/inc/class.boresources.inc.php	(revision 3524)
@@ -0,0 +1,4482 @@
+<?php
+  /**************************************************************************\
+  * eGroupWare - resources                                                    *
+  * http://www.eGroupWare.org                                                *
+  * Maintained and further developed by RalfBecker@outdoor-training.de       *
+  * Based on Webresources by Craig Knudsen <cknudsen@radix.net>               *
+  *          http://www.radix.net/~cknudsen                                  *
+  * Originaly modified by Mark Peters <skeeter@phpgroupware.org>             *
+  * --------------------------------------------                             *
+  *  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.                                              *
+  \**************************************************************************/
+
+
+	class boresources
+	{
+
+var $db;
+	/**
+	 * resourcess config data
+	 * 
+	 * @var array
+	 */
+	var $config = array();
+
+
+	/**
+	 * resourcess config data
+	 *
+	 * @var array
+	 */
+	var $config_data = array();
+	/**
+	 * Should we show a quantity sum, makes only sense if we sum up identical units (can be used to sum up negative (over-)time)
+	 *
+	 * @var boolean
+	 */
+	var $quantity_sum=false;
+	/**
+	 * Timestaps that need to be adjusted to user-time on reading or saving
+	 * 
+	 * @var array
+	 */
+	var $timestamps = array(
+		'ts_start','ts_modified'
+	);
+	/**
+	 * Offset in secconds between user and server-time,	it need to be add to a server-time to get the user-time 
+	 * or substracted from a user-time to get the server-time
+	 * 
+	 * @var int
+	 */
+	var $tz_offset_s;
+	/**
+	 * Current time as timestamp in user-time
+	 * 
+	 * @var int
+	 */
+	var $now;
+	/**
+	 * Start of today in user-time
+	 * 
+	 * @var int
+	 */
+	var $today;
+	/**
+	 * Filter for search limiting the date-range
+	 * 
+	 * @var array
+	 */
+	var $date_filters = array(	// Start: year,month,day,week, End: year,month,day,week
+		'Today'       => array(0,0,0,0,  0,0,1,0),
+		'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
+		'This week'   => array(0,0,0,0,  0,0,0,1),
+		'Last week'   => array(0,0,0,-1, 0,0,0,0),
+		'This month'  => array(0,0,0,0,  0,1,0,0),
+		'Last month'  => array(0,-1,0,0, 0,0,0,0),
+		'2 month ago' => array(0,-2,0,0, 0,-1,0,0),
+		'This year'   => array(0,0,0,0,  1,0,0,0),
+		'Last year'   => array(-1,0,0,0, 0,0,0,0),
+		'2 years ago' => array(-2,0,0,0, -1,0,0,0),
+		'3 years ago' => array(-3,0,0,0, -2,0,0,0),
+	);
+	/**
+	 * Reference to the (bo)link class instanciated at $GLOBALS['phpgw']->link
+	 * 
+	 * @var bolink
+	 */
+	var $link;
+	/**
+	 * Grants: $GLOBALS['phpgw']->acl->get_grants(resources_APP);
+	 * 
+	 * @var array
+	 */	
+	var $grants;
+	/**
+	 * Sums of the last search in keys duration and price
+	 * 
+	 * @var array
+	 */
+	var $summary;
+	/**
+	 * Array with boolean values in keys 'day', 'week' or 'month', for the sums to return in the search
+	 * 
+	 * @var array
+	 */
+	var $show_sums;
+
+	var $customfields=array();
+
+		function boresources($session=0)
+		{
+
+			if(!is_object($GLOBALS['phpgw']->datetime))
+			{
+				$GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time');
+			}
+
+			$this->cat = CreateObject('phpgwapi.categories');
+
+$this->resources = CreateObject('phpgwapi.resources');
+
+$this->tarea = CreateObject('phpgwapi.project');
+
+$this->project = CreateObject('phpgwapi.project');
+
+
+
+
+$this->config_data =& $this->config->config_data;
+		
+
+
+if (isset($this->config_data['customfields']) && is_array($this->config_data['customfields']))
+		{
+			$this->customfields = $this->config_data['customfields'];
+		}
+
+		if (!is_object($GLOBALS['phpgw']->datetime))
+		{
+			$GLOBALS['phpgw']->datetime =& CreateObject('phpgwapi.datetime');
+		}
+		$this->tz_offset_s = $GLOBALS['phpgw']->datetime->tz_offset;
+		$this->now = time() + $this->tz_offset_s;	// time() is server-time and we need a user-time
+		$this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now));
+
+	
+
+
+			$this->grants = $GLOBALS['phpgw']->acl->get_grants('resources');
+			@reset($this->grants);
+			if(DEBUG_APP)
+			{
+				if(floor(phpversion()) >= 4)
+				{
+					$this->debug_string = '';
+					ob_start();
+				}
+
+				foreach($this->grants as $grantor => $rights)
+				{
+					print_debug('Grantor',$grantor);
+					print_debug('Rights',$rights);
+				}
+			}
+
+			print_debug('Read use_session',$session);
+
+			if($session)
+			{
+				$this->read_sessiondata();
+				$this->use_session = True;
+			}
+			print_debug('BO Filter',$this->filter);
+			print_debug('Owner',$this->owner);
+
+			if ($GLOBALS['argv']) {
+			  $this->async = true;
+			  $this->load_lang();
+			}
+
+			$this->prefs['resources']    = $GLOBALS['phpgw_info']['user']['preferences']['resources'];
+			$this->check_set_default_prefs();
+
+			$owner = get_var('owner',array('GET','POST'),$GLOBALS['owner']);
+
+			ereg('menuaction=([a-zA-Z.]+)',$_SERVER['HTTP_REFERER'],$regs);
+			$from = $regs[1];
+			if ((substr($_SERVER['PHP_SELF'],-8) == 'home.php' && substr($this->prefs['resources']['defaultresources'],0,7) == 'planner'
+				|| $_GET['menuaction'] == 'resources.uiresources.planner' &&
+				$from  != 'resources.uiresources.planner' && !$this->save_owner)
+				&& (int)$this->prefs['resources']['planner_start_with_group'] > 0)
+			{
+				// entering planner for the first time ==> saving owner in save_owner, setting owner to default
+				//
+				$this->save_owner = $this->owner;
+				$owner = 'g_'.$this->prefs['resources']['planner_start_with_group'];
+			}
+			elseif ($_GET['menuaction'] != 'resources.uiresources.planner' &&
+				$this->save_owner)
+			{
+				// leaving planner with an unchanged user/owner ==> setting owner back to save_owner
+				//
+				$owner = (int)(isset($_GET['owner']) ? $_GET['owner'] : $this->save_owner);
+				unset($this->save_owner);
+			}
+			elseif (!empty($owner) && $owner != $this->owner && $from == 'resources.uiresources.planner')
+			{
+				// user/owner changed within planner ==> forgetting save_owner
+				//
+				unset($this->save_owner);
+			}
+
+			if(isset($owner) && $owner!='' && substr($owner,0,2) == 'g_')
+			{
+				$this->set_owner_to_group(substr($owner,2));
+			}
+			elseif(isset($owner) && $owner!='')
+			{
+				$this->owner = (int)$owner;
+			}
+			elseif(!@isset($this->owner) || !@$this->owner)
+			{
+				$this->owner = (int)$GLOBALS['phpgw_info']['user']['account_id'];
+			}
+			elseif(isset($this->owner) && $GLOBALS['phpgw']->accounts->get_type($this->owner) == 'g')
+			{
+				$this->set_owner_to_group((int)$this->owner);
+			}
+
+			$this->prefs['common']    = $GLOBALS['phpgw_info']['user']['preferences']['common'];
+
+			if ($this->prefs['common']['timeformat'] == '12')
+			{
+				$this->users_timeformat = 'h:ia';
+			}
+			else
+			{
+				$this->users_timeformat = 'H:i';
+			}
+			$this->holiday_color = (substr($GLOBALS['phpgw_info']['theme']['bg07'],0,1)=='#'?'':'#').$GLOBALS['phpgw_info']['theme']['bg07'];
+
+			$friendly = (isset($_GET['friendly'])?$_GET['friendly']:'');
+			$friendly = ($friendly=='' && isset($_POST['friendly'])?$_POST['friendly']:$friendly);
+
+			$this->printer_friendly = ((int)$friendly == 1?True:False);
+
+			if(isset($_POST['filter'])) { $this->filter = $_POST['filter']; }
+			if(isset($_POST['sortby'])) { $this->sortby = $_POST['sortby']; }
+			if(isset($_POST['cat_id'])) { $this->cat_id = $_POST['cat_id']; }
+
+			if(!isset($this->filter))
+			{
+				$this->filter = ' '.$this->prefs['resources']['defaultfilter'].' ';
+			}
+
+			if(!isset($this->sortby))
+			{
+				$this->sortby = $this->prefs['resources']['defaultresources'] == 'planner_user' ? 'user' : 'category';
+			}
+
+			if($GLOBALS['phpgw']->accounts->get_type($this->owner)=='g')
+			{
+				$this->filter = ' all ';
+			}
+
+			/*$this->so = CreateObject('resources.soresources',
+				Array(
+					'owner'		=> $this->owner,
+					'filter'	=> $this->filter,
+					'category'	=> $this->cat_id,
+					'g_owner'	=> $this->g_owner
+				)
+			);*/
+			$this->rpt_day = array(	// need to be after creation of soresources
+				MCAL_M_SUNDAY    => 'Sunday',
+				MCAL_M_MONDAY    => 'Monday',
+				MCAL_M_TUESDAY   => 'Tuesday',
+				MCAL_M_WEDNESDAY => 'Wednesday',
+				MCAL_M_THURSDAY  => 'Thursday',
+				MCAL_M_FRIDAY    => 'Friday',
+				MCAL_M_SATURDAY  => 'Saturday'
+			);
+			if($this->bo->prefs['resources']['weekdaystarts'] != 'Sunday')
+			{
+				$mcals = array_keys($this->rpt_day);
+				$days  = array_values($this->rpt_day);
+				$this->rpt_day = array();
+				list($n) = $found = array_keys($days,$this->prefs['resources']['weekdaystarts']);
+				for ($i = 0; $i < 7; ++$i,++$n)
+				{
+					$this->rpt_day[$mcals[$n % 7]] = $days[$n % 7];
+				}
+			}
+			$this->rpt_type = Array(
+				MCAL_RECUR_NONE		=> 'None',
+				MCAL_RECUR_DAILY	=> 'Daily',
+				MCAL_RECUR_WEEKLY	=> 'Weekly',
+				MCAL_RECUR_MONTHLY_WDAY	=> 'Monthly (by day)',
+				MCAL_RECUR_MONTHLY_MDAY	=> 'Monthly (by date)',
+				MCAL_RECUR_YEARLY	=> 'Yearly'
+			);
+
+			$localtime = $GLOBALS['phpgw']->datetime->users_localtime;
+
+			$date = (isset($GLOBALS['date'])?$GLOBALS['date']:'');
+			$date = (isset($_GET['date'])?$_GET['date']:$date);
+			$date = ($date=='' && isset($_POST['date'])?$_POST['date']:$date);
+
+			$year = (isset($_GET['year'])?$_GET['year']:'');
+			$year = ($year=='' && isset($_POST['year'])?$_POST['year']:$year);
+
+			$month = (isset($_GET['month'])?$_GET['month']:'');
+			$month = ($month=='' && isset($_POST['month'])?$_POST['month']:$month);
+
+			$day = (isset($_GET['day'])?$_GET['day']:'');
+			$day = ($day=='' && isset($_POST['day'])?$_POST['day']:'');
+
+			$num_months = (isset($_GET['num_months'])?$_GET['num_months']:'');
+			$num_months = ($num_months=='' && isset($_POST['num_months'])?$_POST['num_months']:$num_months);
+
+			if(isset($date) && $date!='')
+			{
+				$this->year  = (int)(substr($date,0,4));
+				$this->month = (int)(substr($date,4,2));
+				$this->day   = (int)(substr($date,6,2));
+			}
+			else
+			{
+				if(isset($year) && $year!='')
+				{
+					$this->year = $year;
+				}
+				else
+				{
+					$this->year = date('Y',$localtime);
+				}
+				if(isset($month) && $month!='')
+				{
+					$this->month = $month;
+				}
+				else
+				{
+					$this->month = date('m',$localtime);
+				}
+				if(isset($day) && $day!='')
+				{
+					$this->day = $day;
+				}
+				else
+				{
+					$this->day = date('d',$localtime);
+				}
+			}
+
+			if(isset($num_months) && $num_months!='')
+			{
+				$this->num_months = $num_months;
+			}
+			elseif($this->num_months == 0)
+			{
+				$this->num_months = 1;
+			}
+
+			$this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
+
+			if(DEBUG_APP)
+			{
+				print_debug('BO Filter','('.$this->filter.')');
+				print_debug('Owner',$this->owner);
+				print_debug('Today',$this->today);
+				if(floor(phpversion()) >= 4)
+				{
+					$this->debug_string .= ob_get_contents();
+					ob_end_clean();
+				}
+			}
+
+$evento=$this->restore_from_appsession();
+			$this->xmlrpc = is_object($GLOBALS['server']) && $GLOBALS['server']->last_method;
+		}
+
+	  function load_lang() {
+	    if(!$_SESSION['phpgw_info']['resources']['langAlarm']) 
+	      {
+		$array_keys = array();
+		$fn = '../../resources/setup/phpgw_alarm_'.$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'].'.lang';			
+		echo $fn;
+		if (file_exists($fn)){
+		  $fp = fopen($fn,'r');
+		  while ($data = fgets($fp,16000))	{
+		    list($message_id,$app_name,$null,$content) = explode("\t",substr($data,0,-1));			
+		    $_SESSION['phpgw_info']['resources']['langAlarm'][$message_id] =  $content;
+		  }
+		  fclose($fp);
+		}
+	      }
+	  }
+		function list_methods($_type='xmlrpc')
+		{
+			/*
+			  This handles introspection or discovery by the logged in client,
+			  in which case the input might be an array.  The server always calls
+			  this function to fill the server dispatch map using a string.
+			*/
+			if (is_array($_type))
+			{
+				$_type = $_type['type'];
+			}
+			switch($_type)
+			{
+				case 'xmlrpc':
+					$xml_functions = array(
+						'list_methods' => array(
+							'function'  => 'list_methods',
+							'signature' => array(array(xmlrpcStruct,xmlrpcString)),
+							'docstring' => lang('Read this list of methods.')
+						),
+						'read' => array(
+							'function'  => 'read_entry',
+							'signature' => array(array(xmlrpcStruct,xmlrpcInt)),
+							'docstring' => lang('Read a single entry by passing the id and fieldlist.')
+						),
+						'read_entry' => array(	// deprecated, use read
+							'function'  => 'read_entry',
+							'signature' => array(array(xmlrpcStruct,xmlrpcInt)),
+							'docstring' => lang('Read a single entry by passing the id and fieldlist.')
+						),
+						'write' => array(
+							'function'  => 'update',
+							'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
+							'docstring' => lang('Add or update a single entry by passing the fields.')
+						),
+						'add_entry' => array(	// deprecated, use write
+							'function'  => 'update',
+							'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
+							'docstring' => lang('Add a single entry by passing the fields.')
+						),
+						'update_entry' => array(	// deprecated, use write
+							'function'  => 'update',
+							'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
+							'docstring' => lang('Update a single entry by passing the fields.')
+						),
+						'delete' => array(
+							'function'  => 'delete_entry',
+							'signature' => array(array(xmlrpcInt,xmlrpcInt)),
+							'docstring' => lang('Delete a single entry by passing the id.')
+						),
+						'delete_entry' => array(	// deprecated, use delete
+							'function'  => 'delete_entry',
+							'signature' => array(array(xmlrpcInt,xmlrpcInt)),
+							'docstring' => lang('Delete a single entry by passing the id.')
+						),
+						'delete_resources' => array(
+							'function'  => 'delete_resources',
+							'signature' => array(array(xmlrpcInt,xmlrpcInt)),
+							'docstring' => lang('Delete an entire users resources.')
+						),
+						'change_owner' => array(
+							'function'  => 'change_owner',
+							'signature' => array(array(xmlrpcInt,xmlrpcStruct)),
+							'docstring' => lang('Change all events for $params[\'old_owner\'] to $params[\'new_owner\'].')
+						),
+						'search' => array(
+							'function'  => 'store_to_cache',
+							'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
+							'docstring' => lang('Read a list of entries.')
+						),
+						'store_to_cache' => array(	// deprecated, use search
+							'function'  => 'store_to_cache',
+							'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
+							'docstring' => lang('Read a list of entries.')
+						),
+						'export_event' => array(
+							'function'  => 'export_event',
+							'signature' => array(array(xmlrpcString,xmlrpcStruct)),
+							'docstring' => lang('Export a list of entries in iCal format.')
+						),
+						'categories' => array(
+							'function'  => 'categories',
+							'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
+							'docstring' => lang('List all categories.')
+						),
+					);
+					return $xml_functions;
+					break;
+				case 'soap':
+					return $this->soap_functions;
+					break;
+				default:
+					return array();
+					break;
+			}
+		}
+
+		function set_owner_to_group($owner)
+		{
+			print_debug('resources::boresources::set_owner_to_group:owner',$owner);
+			$this->owner = (int)$owner;
+			$this->is_group = True;
+			$this->g_owner = Array();
+			$members = $GLOBALS['phpgw']->accounts->member($owner);
+			if (is_array($members))
+			{
+				foreach($members as $user)
+				{
+					// use only members which gave the user a read-grant
+					if ($this->check_perms(PHPGW_ACL_READ,0,$user['account_id']))
+					{
+						$this->g_owner[] = $user['account_id'];
+					}
+				}
+			}
+			//echo "<p>".function_backtrace().": set_owner_to_group($owner) = ".print_r($this->g_owner,True)."</p>\n";
+		}
+
+		function member_of_group($owner=0)
+		{
+			$owner = ($owner==0?$GLOBALS['phpgw_info']['user']['account_id']:$owner);
+			$group_owners = $GLOBALS['phpgw']->accounts->membership();
+			while($group_owners && list($index,$group_info) = each($group_owners))
+			{
+				if($this->owner == $group_info['account_id'])
+				{
+					return True;
+				}
+			}
+			return False;
+		}
+
+		function save_sessiondata($data='')
+		{
+			if ($this->use_session)
+			{
+				if (!is_array($data))
+				{
+					$data = array(
+						'filter'     => $this->filter,
+						'cat_id'     => $this->cat_id,
+						'owner'      => $this->owner,
+						'save_owner' => $this->save_owner,
+						'year'       => $this->year,
+						'month'      => $this->month,
+						'day'        => $this->day,
+						'date'       => $this->date,
+						'sortby'     => $this->sortby,
+						'num_months' => $this->num_months,
+						'return_to'  => $this->return_to
+					);
+				}
+				if($this->debug)
+				{
+					if(floor(phpversion()) >= 4)
+					{
+						ob_start();
+					}
+					echo '<!-- '."\n".'Save:'."\n"._debug_array($data,False)."\n".' -->'."\n";
+					if(floor(phpversion()) >= 4)
+					{
+						$this->debug_string .= ob_get_contents();
+						ob_end_clean();
+					}
+				}
+				$GLOBALS['phpgw']->session->appsession('session_data','resources',$data);
+			}
+		}
+
+		function read_sessiondata()
+		{
+			$data = $GLOBALS['phpgw']->session->appsession('session_data','resources');
+			print_debug('Read',_debug_array($data,False));
+
+			$this->filter = $data['filter'];
+			$this->cat_id = $data['cat_id'];
+			$this->sortby = $data['sortby'];
+			$this->owner  = (int)$data['owner'];
+			$this->save_owner = (int)$data['save_owner'];
+			$this->year   = (int)$data['year'];
+			$this->month  = (int)$data['month'];
+			$this->day    = (int)$data['day'];
+			$this->num_months = (int)$data['num_months'];
+			$this->return_to = $data['return_to'];
+		}
+
+		function read_entry()
+		{
+
+			$event = $this->so->read_entry($id);
+				echo $event;
+			
+			
+			return False;
+		}
+
+		function delete_single($param)
+		{
+			if($this->check_perms(PHPGW_ACL_DELETE,(int)$param['id']))
+			{
+				$temp_event = $this->get_cached_event();
+				$event = $this->read_entry((int)$param['id']);
+//				if($this->owner == $event['owner'])
+//				{
+				$exception_time = mktime($event['start']['hour'],$event['start']['min'],0,$param['month'],$param['day'],$param['year']) - $GLOBALS['phpgw']->datetime->tz_offset;
+				$event['recur_exception'][] = (int)$exception_time;
+				$this->so->cal->event = $event;
+//				print_debug('exception time',$event['recur_exception'][count($event['recur_exception']) -1]);
+//				print_debug('count event exceptions',count($event['recur_exception']));
+				$this->so->add_entry($event);
+				$cd = 16;
+
+				$this->so->cal->event = $temp_event;
+				unset($temp_event);
+			}
+			else
+			{
+				$cd = 60;
+			}
+//			}
+			return $cd;
+		}
+
+		function delete_entry($id)
+		{
+			if (is_array($id) && count($id) == 1)
+			{
+				list(,$id) = each($id);
+			}
+			if($this->check_perms(PHPGW_ACL_DELETE,$id))
+			{
+				$this->so->delete_entry($id);
+
+				if ($this->xmlrpc)
+				{
+					$this->so->expunge($id);
+				}
+				return $this->xmlrpc ? True : 16;
+			}
+			if ($this->xmlrpc)
+			{
+				$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
+			}
+			return 60;
+		}
+
+		function reinstate($params='')
+		{
+			if($this->check_perms(PHPGW_ACL_EDIT,$params['cal_id']) && isset($params['reinstate_index']))
+			{
+				$event = $this->so->read_entry($params['cal_id']);
+				@reset($params['reinstate_index']);
+				print_debug('Count of reinstate_index',count($params['reinstate_index']));
+				if(count($params['reinstate_index']) > 1)
+				{
+					while(list($key,$value) = each($params['reinstate_index']))
+					{
+						print_debug('reinstate_index ['.$key.']',(int)$value);
+						print_debug('exception time',$event['recur_exception'][(int)$value]);
+						unset($event['recur_exception'][(int)$value]);
+						print_debug('count event exceptions',count($event['recur_exception']));
+					}
+				}
+				else
+				{
+					print_debug('reinstate_index[0]',(int)$params['reinstate_index'][0]);
+					print_debug('exception time',$event['recur_exception'][(int)$params['reinstate_index'][0]]);
+					unset($event['recur_exception'][(int)$params['reinstate_index'][0]]);
+					print_debug('count event exceptions',count($event['recur_exception']));
+				}
+				$this->so->cal->event = $event;
+				$this->so->add_entry($event);
+				return 42;
+			}
+			else
+			{
+				return 43;
+			}
+		}
+
+		function delete_resources($owner)
+		{
+			if($GLOBALS['phpgw_info']['user']['apps']['admin'])
+			{
+				$this->so->delete_resources($owner);
+			}
+		}
+
+		function change_owner($params='')
+		{
+			if($GLOBALS['phpgw_info']['server']['resources_type'] == 'sql')
+			{
+				if(is_array($params))
+				{
+					$this->so->change_owner($params['old_owner'],$params['new_owner']);
+				}
+			}
+		}
+
+		function expunge()
+		{
+			reset($this->so->cal->deleted_events);
+			while(list($i,$event_id) = each($this->so->cal->deleted_events))
+			{
+				$event = $this->so->read_entry($event_id);
+				if(!$this->ex_participants)
+					$this->ex_participants = html_entity_decode($event['ex_participants']);			
+				if($this->check_perms(PHPGW_ACL_DELETE,$event))
+				{
+					$this->send_update(MSG_DELETED,$event['participants'],$event);
+				}
+				else
+				{
+					unset($this->so->cal->deleted_events[$i]);
+				}
+			}
+			$this->so->expunge();
+		}
+
+		function search_keywords($keywords)
+		{
+			$type = $GLOBALS['phpgw']->accounts->get_type($this->owner);
+
+			if($type == 'g')
+			{
+				$members = $GLOBALS['phpgw']->acl->get_ids_for_location($this->owner, 1, 'phpgw_group');
+			}
+			else
+			{
+				$members = array_keys($this->grants);
+
+				if (!in_array($this->owner,$members))
+				{
+					$members[] = $this->owner;
+				}
+			}
+			foreach($members as $n => $uid)
+			{
+				if (!($this->grants[$uid] & PHPGW_ACL_READ))
+				{
+					unset($members[$n]);
+				}
+			}
+
+
+			return $this->so->list_events_keyword($keywords,$members);
+		}
+
+		function update($params='')
+		{
+
+			if($params['from_mobile']) {
+				$ui_return = "mobile.ui_mobileresources.edit";
+				$ui_index = "mobile.ui_mobileresources.index";
+				$ui_overlap = "mobile.ui_mobileresources.overlap";
+			}
+			else {
+				$ui_return = "resources.uiresources.edit";
+				$ui_index = "resources.uiresources.index";		
+				$ui_overlap = "resources.uiresources.overlap";
+			}
+
+			if(!is_object($GLOBALS['phpgw']->datetime))
+			{
+				$GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time');
+			}
+			$l_cal = (@isset($params['info_type']) && $params['info_type']?$params['info_type']:$_POST['info_type']);
+			$l_participants = (@$params['participants']?$params['participants']:$_POST['participants']);
+			$this->ex_participants = (@$params['ex_participants']?$params['ex_participants']:$_POST['ex_participants']);
+			$l_categories = (@$params['categories']?$params['categories']:$_POST['categories']);
+			$l_start = (@isset($params['start']) && $params['start']?$params['start']:$_POST['start']);
+			$l_end = (@isset($params['end']) && $params['end']?$params['end']:$_POST['end']);
+			$l_recur_enddate = (@isset($params['recur_enddate']) && $params['recur_enddate']?$params['recur_enddate']:$_POST['recur_enddate']);
+
+			
+			$send_to_ui = True;
+			//if ((!is_array($l_start) || !is_array($l_end)) && !isset($_GET['readsess']))	// xmlrpc call
+			if ($this->xmlrpc)	// xmlrpc call
+			{
+
+				$send_to_ui = False;
+
+				$l_cal = $params;	// no extra array
+
+				foreach(array('start','end','recur_enddate') as $name)
+				{
+					$var = 'l_'.$name;
+					$$var = $GLOBALS['server']->iso86012date($params[$name]);
+					unset($l_cal[$name]);
+				}
+
+				if (!is_array($l_participants) || !count($l_participants))
+				{
+					$l_participants = array($GLOBALS['phpgw_info']['user']['account_id'].'A');
+				}
+				else
+				{
+					$l_participants = array();
+					foreach($params['participants'] as $user => $data)
+					{
+						$l_participants[] = $user.$data['status'];
+					}
+				}
+
+				unset($l_cal['participants']);
+
+				if (!is_object($GLOBALS['phpgw']->categories))
+				{
+					$GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories');
+				}
+
+				$l_categories = $GLOBALS['server']->xmlrpc2cats($params['category']);
+				unset($l_cal['category']);
+
+				// using access={public|private} in all modules via xmlrpc
+				$l_cal['public'] = $params['access'] != 'private';
+				unset($l_cal['access']);
+/*
+				$fp = fopen('/tmp/xmlrpc.log','a+');
+				ob_start();
+				echo "\nboresources::update("; print_r($params); echo ")\n";
+				//echo "\nl_start="; print_r($l_start);
+				//echo "\nl_end="; print_r($l_end);
+				fwrite($fp,ob_get_contents());
+				ob_end_clean();
+				fclose($fp);
+*/
+			}
+
+			print_debug('ID',$l_cal['id']);
+
+			// don't wrap to the next day for no time
+			if ($l_end['hour'] == 24 && $l_end['min'] == 0)
+			{
+				$l_end['hour'] = 23;
+				$l_end['min'] = 59;
+			}
+
+			if(isset($_GET['readsess']))
+			{
+
+				$event = $this->restore_from_appsession();
+				$event['title'] = stripslashes($event['title']);
+				$event['description'] = stripslashes($event['description']);
+$event['description1'] = stripslashes($event['description1']);
+$event['participants1'] = stripslashes($event['participants1']);
+				$event['ex_participants'] = stripslashes($event['ex_participants']);
+				$datetime_check = $this->validate_update($event);
+				if($datetime_check)
+				{
+					ExecMethod($ui_return,
+						Array(
+							'cd'		=> $datetime_check,
+							'readsess'	=> 1
+						)
+					);
+					if(!$params['from_mobile'])
+						$GLOBALS['phpgw']->common->phpgw_exit(True);
+					else
+						return;
+				}
+				$overlapping_events = False;
+			}
+			else
+			{
+
+				if((!$l_cal['id'] && !$this->check_perms(PHPGW_ACL_ADD)) ||
+				   ($l_cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT,$l_cal['id'])))
+				{
+
+					if ($this->xmlrpc)
+					{
+						$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
+					}
+					if (!$send_to_ui)
+					{
+						return array(($l_cal['id']?1:2) => 'permission denied');
+					}
+
+					ExecMethod($ui_index);
+
+
+					if(!$params['from_mobile'])
+						$GLOBALS['phpgw']->common->phpgw_exit();
+					else
+						return;
+				}
+
+				print_debug('Prior to fix_update_time()');
+
+				$this->fix_update_time($l_start);
+
+				$this->fix_update_time($l_end);
+
+				if(!isset($l_cal['ex_participants']))
+				{
+					$l_cal['ex_participants'] = $this->ex_participants;
+				}
+
+				if(!isset($l_categories))
+				{
+					$l_categories = 0;
+				}
+
+				$is_public = ($l_cal['type'] != 'private' && $l_cal['type'] != 'privateHiddenFields');
+
+				//$this->so->event_init();
+
+			$this->add_attribute('uid',$l_cal['uid']);
+
+				$this->add_attribute('type',$l_cal['type']);
+
+				if($l_cal['ex_participants']) {
+					$this->add_attribute('ex_participants',$l_cal['ex_participants']);
+				}
+				/*if(count($l_categories) >= 2)
+				{
+					$this->so->set_category(implode(',',$l_categories));
+				}
+				else
+				{
+					$this->so->set_category(strval($l_categories[0]));
+				}
+				$this->so->set_title($l_cal['title']);
+				$this->so->set_description($l_cal['description']);
+$this->so->set_description1($l_cal['description1']);
+$this->so->set_participants1($l_cal['participants1']);
+				$this->so->set_ex_participants($l_cal['ex_participants']);
+				$this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0);
+				$this->so->set_end($l_end['year'],$l_end['month'],$l_end['mday'],$l_end['hour'],$l_end['min'],0);
+				$this->so->set_class($is_public);
+				$this->so->add_attribute('reference',(@isset($l_cal['reference']) && $l_cal['reference']?$l_cal['reference']:0));
+				$this->so->add_attribute('location',(@isset($l_cal['location']) && $l_cal['location']?$l_cal['location']:''));*/
+				if($l_cal['id'])
+				{
+					//$this->so->add_attribute('id',$l_cal['id']);
+				}
+
+				if($l_cal['rpt_use_end'] != 'y')
+				{
+					$l_recur_enddate['year'] = 0;
+					$l_recur_enddate['month'] = 0;
+					$l_recur_enddate['mday'] = 0;
+				}
+				elseif (isset($l_recur_enddate['str']))
+				{
+					$l_recur_enddate = $this->jscal->input2date($l_recur_enddate['str'],False,'mday');
+				}
+
+				switch((int)$l_cal['recur_type'])
+				{
+
+
+					case MCAL_RECUR_NONE:
+						//$this->so->set_recur_none();
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						break;
+					case MCAL_RECUR_DAILY:
+						//$this->so->set_recur_daily((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						$tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao;
+						$init_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_init[1]),$tmp_init[0],$tmp_init[2]); // transforma a data inicial + hora + minuto em UNIX timestamp;
+
+						if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim:
+						{
+
+							$tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao;
+							$end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp;
+
+						}else { // se nao existe data final da repeticao (agendamento infinito):
+
+							$end_rept = 0; // variavel recebe zero e nao sera adicionado nenhum alarme para o agendamento;
+						}
+						break;
+					case MCAL_RECUR_WEEKLY:
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						$tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao;
+						$init_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_init[1]),$tmp_init[0],$tmp_init[2]); // transforma a data inicial + hora + minuto em UNIX timestamp;
+
+						if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim:
+						{
+
+							$tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao;
+							$end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp;
+
+						}else { // se nao existe data final da repeticao (agendamento infinito):
+
+							$end_rept = 0; // variavel recebe zero e nao sera adicionado nenhum alarme para o agendamento;
+						}
+
+						foreach(array('rpt_sun','rpt_mon','rpt_tue','rpt_wed','rpt_thu','rpt_fri','rpt_sat') as $rpt_day)
+						{
+							$l_cal['recur_data'] += (int)$l_cal[$rpt_day];
+						}
+						if (is_array($l_cal['rpt_day']))
+						{
+							foreach ($l_cal['rpt_day'] as $mask)
+							{
+								$l_cal['recur_data'] |= (int)$mask;
+								$rpt_wdays = $l_cal['recur_data']; // recebe os dias da semana (somatorio) para repetir o alarme;
+							}
+						}
+						//$this->so->set_recur_weekly((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval'],$l_cal['recur_data']);
+						break;
+					case MCAL_RECUR_MONTHLY_MDAY:
+						//$this->so->set_recur_monthly_mday((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						$tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao;
+						$init_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_init[1]),$tmp_init[0],$tmp_init[2]); // transforma a data inicial + hora + minuto em UNIX timestamp;
+
+						if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim:
+						{
+
+							$tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao;
+							$end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp;
+
+						}else { // se nao existe data final da repeticao (agendamento infinito):
+
+							$end_rept = 0; // variavel recebe zero e nao sera adicionado nenhum alarme para o agendamento;
+						}
+						break;
+					case MCAL_RECUR_MONTHLY_WDAY:
+						//$this->so->set_recur_monthly_wday((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
+						break;
+					case MCAL_RECUR_YEARLY:
+						//$this->so->set_recur_yearly((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						$tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao;
+						$init_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_init[1]),$tmp_init[0],$tmp_init[2]); // transforma a data inicial + hora + minuto em UNIX timestamp;
+
+						if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim:
+						{
+
+							$tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao;
+							$end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp;
+
+						}else { // se nao existe data final da repeticao (agendamento infinito):
+
+							$end_rept = 0; // variavel recebe zero e nao sera adicionado nenhum alarme para o agendamento;
+						}
+						break;
+				}
+
+				if($l_participants)
+				{
+					$parts = $l_participants;
+					$minparts = min($l_participants);
+					$part = Array();
+					for($i=0;$i<count($parts);$i++)
+					{
+						if (($accept_type = substr($parts[$i],-1,1)) == '0' || (int)$accept_type > 0)
+						{
+							$accept_type = 'U';
+						}
+						$acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$parts[$i]);
+						if($acct_type == 'u')
+						{
+							$part[(int)$parts[$i]] = $accept_type;
+						}
+						elseif($acct_type == 'g')
+						{
+							$part[(int)$parts[$i]] = $accept_type;
+							$groups[] = $parts[$i];
+							/* This pulls ALL users of a group and makes them as participants to the event */
+							/* I would like to turn this back into a group thing. */
+							$acct = CreateObject('phpgwapi.accounts',(int)$parts[$i]);
+							$members = $acct->member((int)$parts[$i]);
+							unset($acct);
+							if($members == False)
+							{
+								continue;
+							}
+							while($member = each($members))
+							{
+								$part[$member[1]['account_id']] = $accept_type;
+							}
+						}
+					}
+				}
+				else
+				{
+					$part = False;
+				}
+
+				if($part)
+				{
+					@reset($part);
+					while(list($key,$accept_type) = each($part))
+					{
+echo "";
+						//$this->so->add_attribute('participants',$accept_type,(int)$key);
+					}
+				}
+
+				if($groups)
+				{
+					@reset($groups);
+					//$this->so->add_attribute('groups',(int)$group_id);
+				}
+
+				$event = $this->get_cached_event();
+				if(!is_int($minparts))
+				{
+					$minparts = $this->owner;
+				}
+				if(!@isset($event['participants'][$l_cal['owner']]))
+				{
+					//$this->so->add_attribute('owner',$minparts);
+				}
+				else
+				{
+					//$this->so->add_attribute('owner',$l_cal['owner']);
+				}
+				//$this->so->add_attribute('priority',$l_cal['priority']);
+
+				foreach($l_cal as $name => $value)
+				{
+					if ($name[0] == '#')	// Custom field
+					{
+						//$this->so->add_attribute($name,stripslashes($value));
+					}
+				}
+				if (isset($_POST['preserved']) && is_array($preserved = unserialize(stripslashes($_POST['preserved']))))
+				{
+					foreach($preserved as $name => $value)
+					{
+						switch($name)
+						{
+							case 'owner':
+								//$this->so->add_attribute('participants',$value,$l_cal['owner']);
+								break;
+							default:
+echo "";
+								//$this->so->add_attribute($name,str_replace(array('&amp;','&quot;','&lt;','&gt;'),array('&','"','<','>'),$value));
+						}
+					}
+				}
+				$event = $this->get_cached_event();
+
+				if ($l_cal['alarmdays'] > 0 || $l_cal['alarmhours'] > 0 ||
+						$l_cal['alarmminutes'] > 0)
+				{
+					$offset = ($l_cal['alarmdays'] * 24 * 3600) +
+						($l_cal['alarmhours'] * 3600) + ($l_cal['alarmminutes'] * 60);
+
+					$time = $this->maketime($event['start']) - $offset;
+
+					$event['alarm'][] = Array(
+						'time'    => $time,
+						'offset'  => $offset,
+						'owner'   => $this->owner,
+						'enabled' => 1,
+						'repeat'  => $repetido, // para repetir alarme;
+						'init_rept' => $init_rept, // inicio repeticao;
+						'end_rept' => $end_rept, // fim repeticao;
+						'rpt_wdays' => $rpt_wdays // dias repeticao da semana;
+					);
+				}
+
+				$this->store_to_appsession($event);
+				$datetime_check = $this->validate_update($event);
+				print_debug('bo->validated_update() returnval',$datetime_check);
+
+				/*if($datetime_check)
+				{
+
+
+					if (!$send_to_ui)
+					{
+						return array($datetime_check => 'invalid input data');
+					}
+
+
+					ExecMethod($ui_return,
+						Array(
+							'cd'		=> $datetime_check,
+							'readsess'	=> 1
+						)
+					);
+
+					if(!$params['from_mobile'])
+						$GLOBALS['phpgw']->common->phpgw_exit(True);
+					else
+						return;
+
+				}/*/
+				if($event['id'])
+				{
+					$event_ids[] = $event['id'];
+				}
+				if($event['reference'])
+				{
+					$event_ids[] = $event['reference'];
+				}
+
+				$overlapping_events = $this->overlap(
+					$this->maketime($event['start']),
+					$this->maketime($event['end']),
+					$event['participants'],
+					$event['owner'],
+					$event_ids
+				);
+			}
+			if(!$this->ex_participants)
+				$this->ex_participants = $event['ex_participants'];			
+			if($overlapping_events)
+			{
+
+
+				if($send_to_ui)
+				{
+					$event['ex_participants'] = $this->ex_participants;
+					unset($GLOBALS['phpgw_info']['flags']['noheader']);
+					unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+					ExecMethod($ui_overlap,
+						Array(
+							'o_events'	=> $overlapping_events,
+							'this_event'	=> $event
+						)
+					);
+					if(!$params['from_mobile'])
+						$GLOBALS['phpgw']->common->phpgw_exit(True);
+					else
+						return;
+				}
+				else
+				{
+					return $overlapping_events;
+				}
+			}
+			else
+			{
+
+
+
+				if(!$event['id'])
+				{
+
+
+
+					//$this->so->add_entry($event);
+					$this->send_update(MSG_ADDED,$event['participants'],'',$this->get_cached_event());
+					print_debug('New Event ID',$event['id']);
+				}
+				else
+				{
+
+					print_debug('Updating Event ID',$event['id']);
+					$new_event = $event;
+					$old_event = $this->read_entry($event['id']);
+					// if old event has alarm and the start-time changed => update them
+					//echo "<p>checking ".count($old_event['alarm'])." alarms of event #$event[id] start moved from ".print_r($old_event['start'],True)." to ".print_r($event['start'],True)."</p>\n";
+					if ($old_event['alarm'] &&
+						$this->maketime($old_event['start']) != $this->maketime($event['start']))
+					{
+						//$this->so->delete_alarms($old_event['id']);
+						foreach($old_event['alarm'] as $id => $alarm)
+						{
+							$alarm['time'] = $this->maketime($event['start']) - $alarm['offset'];
+							$event['alarm'][] = $alarm;
+						}
+						//echo "updated alarms<pre>".print_r($event['alarm'],True)."</pre>\n";
+					}
+					//$this->so->cal->event = $event;
+					//$this->so->add_entry($event);
+					$this->prepare_recipients($new_event,$old_event);
+				}
+
+				$date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']);
+				if($send_to_ui)
+				{
+					$this->read_sessiondata();
+					if ($this->return_to)
+					{
+						$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->return_to);
+						$GLOBALS['phpgw']->common->phpgw_exit();
+					}
+					Execmethod($ui_index);
+				}
+				else
+				{
+					return (int)$event['id'];
+				}
+			}
+			return True;
+		}
+
+		/* Private functions */
+		function read_holidays($year=0)
+		{
+			if(!$year)
+			{
+				$year = $this->year;
+			}
+			$holiday = CreateObject('resources.boholiday');
+			$holiday->prepare_read_holidays($year,$this->owner);
+			$this->cached_holidays = $holiday->read_holiday();
+			unset($holiday);
+		}
+
+		function user_is_a_member($event,$user)
+		{
+			@reset($event['participants']);
+			$uim = False;
+			$security_equals = $GLOBALS['phpgw']->accounts->membership($user);
+			while(!$uim && $event['participants'] && $security_equals && list($participant,$status) = each($event['participants']))
+			{
+				if($GLOBALS['phpgw']->accounts->get_type($participant) == 'g')
+				{
+					@reset($security_equals);
+					while(list($key,$group_info) = each($security_equals))
+					{
+						if($group_info['account_id'] == $participant)
+						{
+							return True;
+							$uim = True;
+						}
+					}
+				}
+			}
+			return $uim;
+		}
+
+		function maketime($time)
+		{
+//echo "tttt".$time['month']."  ".$time['mday']."  ".$time['year']."<br>";
+			return mktime(intval($time['hour']),intval($time['min']),intval($time['sec']),intval($time['month']),intval($time['mday']),intval($time['year']));
+		}
+
+function maketime2($hora,$min,$seg,$dia,$mes,$ano,$ampm)
+		{
+if($ampm == 'pm' || $ampm == 'PM')  $hora = $hora+12; 
+
+
+			return mktime(intval($hora),intval($min),intval($seg),intval($mes),intval($dia),intval($ano));
+		}
+		/*!
+		@function time2array
+		@abstract returns a date-array suitable for the start- or endtime of an event from a timestamp
+		@syntax time2array($time,$alarm=0)
+		@param $time the timestamp for the values of the array
+		@param $alarm (optional) alarm field of the array, defaults to 0
+		@author ralfbecker
+		*/
+		function time2array($time,$alarm = 0)
+		{
+			return array(
+				'year'  => (int)(date('Y',$time)),
+				'month' => (int)(date('m',$time)),
+				'mday'  => (int)(date('d',$time)),
+				'hour'  => (int)(date('g',$time)),
+				'min'   => (int)(date('i',$time)),
+				'sec'   => (int)(date('s',$time)),
+				'ampm'=> (int)(date('a',$time)),
+                                'hourcompleta' => (int)(date('H',$time)),
+				'alarm' => (int)($alarm)
+			);
+		}
+
+
+		/*!
+		@function set_recur_date
+		@abstract set the start- and enddates of a recuring event for a recur-date
+		@syntax set_recur_date(&$event,$date)
+		@param $event the event which fields to set (has to be the original event for start-/end-times)
+		@param $date  the recuring date in form 'Ymd', eg. 20030226
+		@author ralfbecker
+		*/
+		function set_recur_date(&$event,$date)
+		{
+			$org_start = $this->maketime($event['start']);
+			$org_end   = $this->maketime($event['end']);
+			$start = mktime($event['start']['hour'],$event['start']['min'],0,substr($date,4,2),substr($date,6,2),substr($date,0,4));
+			$end   = $org_end + $start - $org_start;
+			$event['start'] = $this->time2array($start);
+			$event['end']   = $this->time2array($end);
+		}
+
+		function fix_update_time(&$time_param)
+		{
+			if (isset($time_param['str']))
+			{
+				if (!is_object($this->jscal))
+				{
+					$this->jscal = CreateObject('phpgwapi.jscalendar');
+				}
+				$time_param += $this->jscal->input2date($time_param['str'],False,'mday');
+				unset($time_param['str']);
+			}
+			if ($this->prefs['common']['timeformat'] == '12')
+			{
+				if ($time_param['ampm'] == 'pm')
+				{
+					if ($time_param['hour'] <> 12)
+					{
+						$time_param['hour'] += 12;
+					}
+				}
+				elseif ($time_param['ampm'] == 'am')
+				{
+					if ($time_param['hour'] == 12)
+					{
+						$time_param['hour'] -= 12;
+					}
+				}
+
+				if($time_param['hour'] > 24)
+				{
+					$time_param['hour'] -= 12;
+				}
+			}
+		}
+
+		function validate_update($event)
+		{
+			$error = 0;
+			// do a little form verifying
+			if (!count($event['participants']))
+			{
+				$error = 43;
+			}
+			elseif ($event['title'] == '')
+			{
+				$error = 40;
+			}
+			elseif (($GLOBALS['phpgw']->datetime->time_valid($event['start']['hour'],$event['start']['min'],0) == False) || ($GLOBALS['phpgw']->datetime->time_valid($event['end']['hour'],$event['end']['min'],0) == False))
+			{
+				$error = 41;
+			}
+			elseif (($GLOBALS['phpgw']->datetime->date_valid($event['start']['year'],$event['start']['month'],$event['start']['mday']) == False) || ($GLOBALS['phpgw']->datetime->date_valid($event['end']['year'],$event['end']['month'],$event['end']['mday']) == False) || ($GLOBALS['phpgw']->datetime->date_compare($event['start']['year'],$event['start']['month'],$event['start']['mday'],$event['end']['year'],$event['end']['month'],$event['end']['mday']) == 1))
+			{
+				$error = 42;
+			}
+			elseif ($GLOBALS['phpgw']->datetime->date_compare($event['start']['year'],$event['start']['month'],$event['start']['mday'],$event['end']['year'],$event['end']['month'],$event['end']['mday']) == 0)
+			{
+				if ($GLOBALS['phpgw']->datetime->time_compare($event['start']['hour'],$event['start']['min'],0,$event['end']['hour'],$event['end']['min'],0) == 1)
+				{
+					$error = 42;
+				}
+			}
+			return $error;
+		}
+
+		/*!
+		@function participants_not_rejected($participants,$event)
+		@abstract checks if any of the $particpants participates in $event and has not rejected it
+		*/
+		function participants_not_rejected($participants,$event)
+		{
+			//echo "participants_not_rejected()<br>participants =<pre>"; print_r($participants); echo "</pre><br>event[participants]=<pre>"; print_r($event['participants']); echo "</pre>\n";
+			foreach($participants as $uid => $status)
+			{
+				//echo "testing event[participants][uid=$uid] = '".$event['participants'][$uid]."'<br>\n";
+				if (isset($event['participants'][$uid]) && $event['participants'][$uid] != 'R' &&
+					$status != 'R')
+				{
+					return True;	// found not rejected participant in event
+				}
+			}
+			return False;
+		}
+
+		function overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False)
+		{
+//			$retval = Array();
+//			$ok = False;
+
+/* This needs some attention.. by commenting this chunk of code it will fix bug #444265 */
+
+			if($restore_cache)
+			{
+				$temp_cache_events = $this->cached_events;
+			}
+
+//			$temp_start = (int)$GLOBALS['phpgw']->common->show_date($starttime,'Ymd');
+//			$temp_start_time = (int)($GLOBALS['phpgw']->common->show_date($starttime,'Hi');
+//			$temp_end = (int)$GLOBALS['phpgw']->common->show_date($endtime,'Ymd');
+//			$temp_end_time = (int)$GLOBALS['phpgw']->common->show_date($endtime,'Hi');
+			$temp_start = (int)(date('Ymd',$starttime));
+			$temp_start_time = (int)(date('Hi',$starttime));
+			$temp_end = (int)(date('Ymd',$endtime));
+			$temp_end_time = (int)(date('Hi',$endtime));
+			if($this->debug)
+			{
+				echo '<!-- Temp_Start: '.$temp_start.' -->'."\n";
+				echo '<!-- Temp_End: '.$temp_end.' -->'."\n";
+			}
+
+			$users = Array();
+			if(count($participants))
+			{
+				while(list($user,$status) = each($participants))
+				{
+					$users[] = $user;
+				}
+			}
+			else
+			{
+				$users[] = $this->owner;
+			}
+
+			$possible_conflicts = $this->store_to_cache(
+				Array(
+					'smonth'	=> substr(strval($temp_start),4,2),
+					'sday'	=> substr(strval($temp_start),6,2),
+					'syear'	=> substr(strval($temp_start),0,4),
+					'emonth'	=> substr(strval($temp_end),4,2),
+					'eday'	=> substr(strval($temp_end),6,2),
+					'eyear'	=> substr(strval($temp_end),0,4),
+					'owner'	=> $users
+				)
+			);
+
+			if($this->debug)
+			{
+				echo '<!-- Possible Conflicts ('.($temp_start - 1).'): '.count($possible_conflicts[$temp_start - 1]).' -->'."\n";
+				echo '<!-- Possible Conflicts ('.$temp_start.'): '.count($possible_conflicts[$temp_start]).' '.count($id).' -->'."\n";
+			}
+
+			if($possible_conflicts[$temp_start] || $possible_conflicts[$temp_end])
+			{
+				if($temp_start == $temp_end)
+				{
+					if($this->debug)
+					{
+						echo '<!-- Temp_Start == Temp_End -->'."\n";
+					}
+					@reset($possible_conflicts[$temp_start]);
+					while(list($key,$event) = each($possible_conflicts[$temp_start]))
+					{
+						$found = False;
+						if($id)
+						{
+							@reset($id);
+							while(list($key,$event_id) = each($id))
+							{
+								if($this->debug)
+								{
+									echo '<!-- $id['.$key.'] = '.$id[$key].' = '.$event_id.' -->'."\n";
+									echo '<!-- '.$event['id'].' == '.$event_id.' -->'."\n";
+								}
+								if($event['id'] == $event_id)
+								{
+									$found = True;
+								}
+							}
+						}
+						if($this->debug)
+						{
+							echo '<!-- Item found: '.$found.' -->'."<br>\n";
+						}
+						if(!$found)
+						{
+							if($this->debug)
+							{
+								echo '<!-- Checking event id #'.$event['id'];
+							}
+							$temp_event_start = sprintf("%d%02d",$event['start']['hour'],$event['start']['min']);
+							$temp_event_end = sprintf("%d%02d",$event['end']['hour'],$event['end']['min']);
+//							if((($temp_start_time <= $temp_event_start) && ($temp_end_time >= $temp_event_start) && ($temp_end_time <= $temp_event_end)) ||
+							if(($temp_start_time <= $temp_event_start &&
+								$temp_end_time > $temp_event_start &&
+								$temp_end_time <= $temp_event_end ||
+								$temp_start_time >= $temp_event_start &&
+								$temp_start_time < $temp_event_end &&
+								$temp_end_time >= $temp_event_end ||
+								$temp_start_time <= $temp_event_start &&
+								$temp_end_time >= $temp_event_end ||
+								$temp_start_time >= $temp_event_start &&
+								$temp_end_time <= $temp_event_end) &&
+								$this->participants_not_rejected($participants,$event))
+							{
+								if($this->debug)
+								{
+									echo ' Conflicts';
+								}
+								$retval[] = $event['id'];
+							}
+							if($this->debug)
+							{
+								echo ' -->'."\n";
+							}
+						}
+					}
+				}
+			}
+			else
+			{
+				$retval = False;
+			}
+
+			if($restore_cache)
+			{
+				$this->cached_events = $temp_cache_events;
+			}
+
+			return $retval;
+		}
+
+		/*!
+		@function check_perms( )
+		@syntax check_perms($needed,$event=0,$other=0)
+		@abstract Checks if the current user has the necessary ACL rights
+		@author ralfbecker
+		@discussion The check is performed on an event or general on the cal of an other user
+		@param $needed necessary ACL right: PHPGW_ACL_{READ|EDIT|DELETE}
+		@param $event event as array or the event-id or 0 for general check
+		@param $other uid to check (if event==0) or 0 to check against $this->owner
+		@note Participating in an event is considered as haveing read-access on that event, \
+			even if you have no general read-grant from that user.
+		*/
+		function check_perms($needed,$event=0,$other=0)
+		{
+			$event_in = $event;
+			
+			if (is_int($event) && $event == 0)
+			{
+				$owner = $other > 0 ? $other : $this->owner;
+			}
+			else
+			{
+				if (!is_array($event))
+				{
+					$event = "";//$this->so->read_entry((int) $event);
+				}
+				if (!is_array($event))
+				{
+					if ($this->xmlrpc)
+					{
+						$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
+					}
+					return False;
+				}
+				$owner = $event['owner'];
+				$private = $event['public'] == False || $event['public'] == 0;
+			}
+			$user = $GLOBALS['phpgw_info']['user']['account_id'];
+			$grants = $this->grants[$owner];
+
+			if (is_array($event) && $needed == PHPGW_ACL_READ)
+			{
+				// Check if the $user is one of the participants or has a read-grant from one of them
+				//
+if($event['participants']){
+				foreach($event['participants'] as $uid => $accept)
+				{
+					if ($this->grants[$uid] & PHPGW_ACL_READ || $uid == $user)
+					{
+						$grants |= PHPGW_ACL_READ;
+						// if the $user is one of the participants read-grant private (restricted) too.
+						if($uid == $user || ($this->grants[$uid] & PHPGW_ACL_PRIVATE)) {
+							$grants |= PHPGW_ACL_PRIVATE;
+						}
+						//break;
+					}
+				}
+}
+			}
+
+			if ($GLOBALS['phpgw']->accounts->get_type($owner) == 'g' && $needed == PHPGW_ACL_ADD)
+			{
+				$access = False;	// a group can't be the owner of an event
+			}
+			else
+			{
+				$access = $user == $owner || $grants & $needed && (!$private || $grants & PHPGW_ACL_PRIVATE);
+			}
+			//echo "<p>".function_backtrace()." check_perms($needed,$event_id,$other) for user $user and needed_acl $needed: event='$event[title]': owner=$owner, private=$private, grants=$grants ==> access=$access</p>\n";
+
+			return $access;
+		}
+
+
+		function display_status($user_status)
+		{
+			if(@$this->prefs['resources']['display_status'] && $user_status)
+			{
+				$user_status = substr($this->get_long_status($user_status),0,1);
+
+				return ' ('.$user_status.')';
+			}
+			else
+			{
+				return '';
+			}
+		}
+
+		function get_long_status($status_short)
+		{
+			switch ($status_short)
+			{
+				case 'A':
+					$status = lang('Accepted');
+					break;
+				case 'R':
+					$status = lang('Rejected');
+					break;
+				case 'T':
+					$status = lang('Tentative');
+					break;
+				case 'U':
+					$status = lang('No Response');
+					break;
+			}
+			return $status;
+		}
+
+		function is_private($event,$owner)
+		{
+			if($owner == 0)
+			{
+				$owner = $this->owner;
+			}
+			if ($owner == $GLOBALS['phpgw_info']['user']['account_id'] || ($event['public']==1) || ($this->check_perms(PHPGW_ACL_PRIVATE,$event) && $event['public']==0) || $event['owner'] == $GLOBALS['phpgw_info']['user']['account_id'])
+			{
+				return False;
+			}
+			elseif($event['public'] == 0)
+			{
+				return True;
+			}
+			elseif($event['public'] == 2)
+			{
+				$is_private = True;
+				$groups = $GLOBALS['phpgw']->accounts->membership($owner);
+				while (list($key,$group) = each($groups))
+				{
+					if (strpos(' '.implode(',',$event['groups']).' ',$group['account_id']))
+					{
+						return False;
+					}
+				}
+			}
+			else
+			{
+				return False;
+			}
+
+			return $is_private;
+		}
+
+		function get_short_field($event,$is_private=True,$field='')
+		{
+
+
+			if($is_private)
+			{
+				return lang('private');
+			}
+
+// cut off too long titles
+			elseif(strlen($event[$field]) > 19 && !$this->printer_friendly && $field=="title")
+//			elseif(strlen($event[$field]) > 19 && $this->printer_friendly)
+			{
+// we dont use currently 160304
+//				return substr($event[$field], 0 , 19) . '&nbsp;...';
+				return $event[$field];
+			}
+			else
+			{
+				return $event[$field];
+			}
+		}
+
+		function long_date($first,$last=0)
+		{
+			if (!is_array($first))
+			{
+				$first = $this->time2array($raw = $first);
+				$first['raw'] = $raw;
+				$first['day'] = $first['mday'];
+			}
+			if ($last && !is_array($last))
+			{
+				$last = $this->time2array($raw = $last);
+				$last['raw'] = $raw;
+				$last['day'] = $last['mday'];
+			}
+			$datefmt = $this->prefs['common']['dateformat'];
+
+			$month_before_day = strtolower($datefmt[0]) == 'm' ||
+				strtolower($datefmt[2]) == 'm' && $datefmt[4] == 'd';
+
+			for ($i = 0; $i < 5; $i += 2)
+			{
+				switch($datefmt[$i])
+				{
+					case 'd':
+						$range .= $first['day'] . ($datefmt[1] == '.' ? '.' : '');
+						if ($first['month'] != $last['month'] || $first['year'] != $last['year'])
+						{
+							if (!$month_before_day)
+							{
+								$range .= ' '.lang(strftime('%B',$first['raw']));
+							}
+							if ($first['year'] != $last['year'] && $datefmt[0] != 'Y')
+							{
+								$range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year'];
+							}
+							if (!$last)
+							{
+								return $range;
+							}
+							$range .= ' - ';
+
+							if ($first['year'] != $last['year'] && $datefmt[0] == 'Y')
+							{
+								$range .= $last['year'] . ', ';
+							}
+
+							if ($month_before_day)
+							{
+								$range .= lang(strftime('%B',$last['raw']));
+							}
+						}
+						else
+						{
+							$range .= ' - ';
+						}
+						$range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : '');
+						break;
+					case 'm':
+					case 'M':
+						$range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' ';
+						break;
+					case 'Y':
+						$range .= ($datefmt[0] == 'm' ? ', ' : ' ') . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
+						break;
+				}
+			}
+			return $range;
+		}
+
+		function get_week_label()
+		{
+			$first = $GLOBALS['phpgw']->datetime->gmtdate($GLOBALS['phpgw']->datetime->get_weekday_start($this->year, $this->month, $this->day));
+			$last = $GLOBALS['phpgw']->datetime->gmtdate($first['raw'] + 518400);
+
+			return ($this->long_date($first,$last));
+		}
+
+		function normalizeminutes(&$minutes)
+		{
+			$hour = 0;
+			$min = (int)$minutes;
+			if($min >= 60)
+			{
+				$hour += $min / 60;
+				$min %= 60;
+			}
+			settype($minutes,'integer');
+			$minutes = $min;
+			return $hour;
+		}
+
+		function splittime($time,$follow_24_rule=True)
+		{
+			$temp = array('hour','minute','second','ampm');
+			$time = strrev($time);
+			$second = (int)(strrev(substr($time,0,2)));
+			$minute = (int)(strrev(substr($time,2,2)));
+			$hour   = (int)(strrev(substr($time,4)));
+			$hour += $this->normalizeminutes($minute);
+			$temp['second'] = $second;
+			$temp['minute'] = $minute;
+			$temp['hour']   = $hour;
+			$temp['ampm']   = '  ';
+			if($follow_24_rule == True)
+			{
+				if ($this->prefs['common']['timeformat'] == '24')
+				{
+					return $temp;
+				}
+
+				$temp['ampm'] = 'am';
+
+				if ((int)$temp['hour'] > 12)
+				{
+					$temp['hour'] = (int)((int)$temp['hour'] - 12);
+					$temp['ampm'] = 'pm';
+				}
+				elseif ((int)$temp['hour'] == 12)
+				{
+					$temp['ampm'] = 'pm';
+				}
+			}
+			return $temp;
+		}
+
+		function get_exception_array($exception_str='')
+		{
+			$exception = Array();
+			if(strpos(' '.$exception_str,','))
+			{
+				$exceptions = explode(',',$exception_str);
+				for($exception_count=0;$exception_count<count($exceptions);$exception_count++)
+				{
+					$exception[] = (int)$exceptions[$exception_count];
+				}
+			}
+			elseif($exception_str != '')
+			{
+				$exception[] = (int)$exception_str;
+			}
+			return $exception;
+		}
+
+		function build_time_for_display($fixed_time)
+		{
+			$time = $this->splittime($fixed_time);
+			$str = $time['hour'].':'.((int)$time['minute']<=9?'0':'').$time['minute'];
+
+			if ($this->prefs['common']['timeformat'] == '12')
+			{
+				$str .= ' ' . $time['ampm'];
+			}
+
+			return $str;
+		}
+
+		function sort_event($event,$date)
+		{
+			$inserted = False;
+			if(isset($event['recur_exception']))
+			{
+				$event_time = mktime($event['start']['hour'],$event['start']['min'],0,(int)(substr($date,4,2)),(int)(substr($date,6,2)),(int)(substr($date,0,4))) - $GLOBALS['phpgw']->datetime->tz_offset;
+				while($inserted == False && list($key,$exception_time) = each($event['recur_exception']))
+				{
+					if($this->debug)
+					{
+						echo '<!-- checking exception datetime '.$exception_time.' to event datetime '.$event_time.' -->'."\n";
+					}
+					if($exception_time == $event_time)
+					{
+						$inserted = True;
+					}
+				}
+			}
+			if($this->cached_events[$date] && $inserted == False)
+			{
+
+				if($this->debug)
+				{
+					echo '<!-- Cached Events found for '.$date.' -->'."\n";
+				}
+				$year = substr($date,0,4);
+				$month = substr($date,4,2);
+				$day = substr($date,6,2);
+
+				if($this->debug)
+				{
+					echo '<!-- Date : '.$date.' Count : '.count($this->cached_events[$date]).' -->'."\n";
+				}
+
+				for($i=0;$i<count($this->cached_events[$date]);$i++)
+				{
+					if($this->cached_events[$date][$i]['id'] == $event['id'] || $this->cached_events[$date][$i]['reference'] == $event['id'])
+					{
+						if($this->debug)
+						{
+							echo '<!-- Item already inserted! -->'."\n";
+						}
+						$inserted = True;
+						break;
+					}
+					/* This puts all spanning events across multiple days up at the top. */
+					if($this->cached_events[$date][$i]['recur_type'] == MCAL_RECUR_NONE)
+					{
+						if($this->cached_events[$date][$i]['start']['mday'] != $day && $this->cached_events[$date][$i]['end']['mday'] >= $day)
+						{
+							continue;
+						}
+					}
+					if(date('Hi',mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$day,$year)) < date('Hi',mktime($this->cached_events[$date][$i]['start']['hour'],$this->cached_events[$date][$i]['start']['min'],$this->cached_events[$date][$i]['start']['sec'],$month,$day,$year)))
+					{
+						for($j=count($this->cached_events[$date]);$j>=$i;$j--)
+						{
+							$this->cached_events[$date][$j] = $this->cached_events[$date][$j-1];
+						}
+						if($this->debug)
+						{
+							echo '<!-- Adding event ID: '.$event['id'].' to cached_events -->'."\n";
+						}
+						$inserted = True;
+						$this->cached_events[$date][$i] = $event;
+						break;
+					}
+				}
+			}
+			if(!$inserted)
+			{
+				if($this->debug)
+				{
+					echo '<!-- Adding event ID: '.$event['id'].' to cached_events -->'."\n";
+				}
+				$this->cached_events[$date][] = $event;
+			}
+		}
+
+		function check_repeating_events($datetime)
+		{
+			@reset($this->repeating_events);
+			$search_date_full = date('Ymd',$datetime);
+			$search_date_year = date('Y',$datetime);
+			$search_date_month = date('m',$datetime);
+			$search_date_day = date('d',$datetime);
+			$search_date_dow = date('w',$datetime);
+			$search_beg_day = mktime(0,0,0,$search_date_month,$search_date_day,$search_date_year);
+			if($this->debug)
+			{
+				echo '<!-- Search Date Full = '.$search_date_full.' -->'."\n";
+			}
+			$repeated = $this->repeating_events;
+			$r_events = count($repeated);
+			for ($i=0;$i<$r_events;$i++)
+			{
+				$rep_events = $this->repeating_events[$i];
+				$id = $rep_events['id'];
+				$event_beg_day = mktime(0,0,0,$rep_events['start']['month'],$rep_events['start']['mday'],$rep_events['start']['year']);
+				if($rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0)
+				{
+					$event_recur_time = $this->maketime($rep_events['recur_enddate']);
+				}
+				else
+				{
+					$event_recur_time = mktime(0,0,0,1,1,2030);
+				}
+				$end_recur_date = date('Ymd',$event_recur_time);
+				$full_event_date = date('Ymd',$event_beg_day);
+
+				if($this->debug)
+				{
+					echo '<!-- check_repeating_events - Processing ID - '.$id.' -->'."\n";
+					echo '<!-- check_repeating_events - Recurring End Date - '.$end_recur_date.' -->'."\n";
+				}
+
+				// only repeat after the beginning, and if there is an rpt_end before the end date
+				if (($search_date_full > $end_recur_date) || ($search_date_full < $full_event_date))
+				{
+					continue;
+				}
+
+				if ($search_date_full == $full_event_date)
+				{
+					$this->sort_event($rep_events,$search_date_full);
+					continue;
+				}
+				else
+				{
+					$freq = $rep_events['recur_interval'];
+					$freq = $freq ? $freq : 1;
+					$type = $rep_events['recur_type'];
+					switch($type)
+					{
+						case MCAL_RECUR_DAILY:
+							if($this->debug)
+							{
+								echo '<!-- check_repeating_events - MCAL_RECUR_DAILY - '.$id.' -->'."\n";
+							}
+							
+							if ($freq == 1 && $rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0 && $search_date_full <= $end_recur_date)
+							{
+								$this->sort_event($rep_events,$search_date_full);
+							}
+							elseif (floor(($search_beg_day - $event_beg_day)/86400) % ($freq ? $freq : 1))
+							{
+								continue;
+							}
+							else
+							{
+								$this->sort_event($rep_events,$search_date_full);
+							}
+							break;
+						case MCAL_RECUR_WEEKLY:
+							if (floor(($search_beg_day - $event_beg_day)/604800)  % ($freq ? $freq : 1))
+							{
+								continue;
+							}
+							$check = 0;
+							switch($search_date_dow)
+							{
+								case 0:
+									$check = MCAL_M_SUNDAY;
+									break;
+								case 1:
+									$check = MCAL_M_MONDAY;
+									break;
+								case 2:
+									$check = MCAL_M_TUESDAY;
+									break;
+								case 3:
+									$check = MCAL_M_WEDNESDAY;
+									break;
+								case 4:
+									$check = MCAL_M_THURSDAY;
+									break;
+								case 5:
+									$check = MCAL_M_FRIDAY;
+									break;
+								case 6:
+									$check = MCAL_M_SATURDAY;
+									break;
+							}
+							if ($rep_events['recur_data'] & $check)
+							{
+								$this->sort_event($rep_events,$search_date_full);
+							}
+							break;
+						case MCAL_RECUR_MONTHLY_WDAY:
+							if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month']) % $freq)
+							{
+								continue;
+							}
+
+							if (($GLOBALS['phpgw']->datetime->day_of_week($rep_events['start']['year'],$rep_events['start']['month'],$rep_events['start']['mday']) == $GLOBALS['phpgw']->datetime->day_of_week($search_date_year,$search_date_month,$search_date_day)) &&
+								(ceil($rep_events['start']['mday']/7) == ceil($search_date_day/7)))
+							{
+								$this->sort_event($rep_events,$search_date_full);
+							}
+							break;
+						case MCAL_RECUR_MONTHLY_MDAY:
+							if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month'])  % ($freq ? $freq : 1))
+							{
+								continue;
+							}
+							if ($search_date_day == $rep_events['start']['mday'])
+							{
+								$this->sort_event($rep_events,$search_date_full);
+							}
+							break;
+						case MCAL_RECUR_YEARLY:
+							if (($search_date_year - $rep_events['start']['year']) % ($freq ? $freq : 1))
+							{
+								continue;
+							}
+							if (date('dm',$datetime) == date('dm',$event_beg_day))
+							{
+								$this->sort_event($rep_events,$search_date_full);
+							}
+							break;
+					}
+				}
+			}	// end for loop
+		}	// end function
+
+		function store_to_cache($params)
+		{
+			if(!is_array($params))
+			{
+				return False;
+			}
+			if (isset($params['start']) && ($datearr = $GLOBALS['server']->iso86012date($params['start'])))
+			{
+				$syear = $datearr['year'];
+				$smonth = $datearr['month'];
+				$sday = $datearr['mday'];
+				$this->xmlrpc = True;
+			}
+			else
+			{
+				$syear = $params['syear'];
+				$smonth = $params['smonth'];
+				$sday = $params['sday'];
+			}
+			if (isset($params['end']) && ($datearr = $GLOBALS['server']->iso86012date($params['end'])))
+			{
+				$eyear = $datearr['year'];
+				$emonth = $datearr['month'];
+				$eday = $datearr['mday'];
+				$this->xmlrpc = True;
+			}
+			else
+			{
+				$eyear = (isset($params['eyear'])?$params['eyear']:0);
+				$emonth = (isset($params['emonth'])?$params['emonth']:0);
+				$eday = (isset($params['eday'])?$params['eday']:0);
+			}
+			if (!isset($params['owner']) && @$this->xmlrpc)
+			{
+				$owner_id = $GLOBALS['phpgw_info']['user']['user_id'];
+			}
+			else
+			{
+				$owner_id = (isset($params['owner'])?$params['owner']:0);
+				if($owner_id==0 && $this->is_group)
+				{
+					unset($owner_id);
+					$owner_id = $this->g_owner;
+					if($this->debug)
+					{
+						echo '<!-- owner_id in ('.implode(',',$owner_id).') -->'."\n";
+					}
+				}
+			}
+			if(!$eyear && !$emonth && !$eday)
+			{
+				$edate = mktime(23,59,59,$smonth + 1,$sday + 1,$syear);
+				$eyear = date('Y',$edate);
+				$emonth = date('m',$edate);
+				$eday = date('d',$edate);
+			}
+			else
+			{
+				if(!$eyear)
+				{
+					$eyear = $syear;
+				}
+				//Tratamento do valor final (mes) da pesquisa de eventos feita em $this->so->list_events.
+				//Se $emonth nao tem valor, recebe o valor de $smonth (que recebe $params['smonth']) e soma 1.
+				//O valor $params['emonth'] indica o mes final para a pesquisa de eventos, e passou a ser
+				//informado na a impressao de eventos mensais. Mudancas feitas em class.uiresources.inc.php, 
+				//function display_month_print();
+				if(!$emonth)
+				{
+					$emonth = $smonth + 1;
+					if($emonth > 12)
+					{
+						$emonth = 1;
+						$eyear++;
+					}
+				}
+				if(!$eday)
+				{
+					$eday = $sday + 1;
+				}
+				$edate = mktime(23,59,59,$emonth,$eday,$eyear);
+			}
+			//echo "<p>boresources::store_to_cache(".print_r($params,True).") syear=$syear, smonth=$smonth, sday=$sday, eyear=$eyear, emonth=$emonth, eday=$eday, xmlrpc='$param[xmlrpc]'</p>\n";
+			if($this->debug)
+			{
+				echo '<!-- Start Date : '.sprintf("%04d%02d%02d",$syear,$smonth,$sday).' -->'."\n";
+				echo '<!-- End   Date : '.sprintf("%04d%02d%02d",$eyear,$emonth,$eday).' -->'."\n";
+			}
+			//A variavel $month_print recebe o parametro 'saux' com o mes de inicio da pesquisa de eventos por
+			//$this->so->list_events. O valor do mes final da pesquisa e tratado no codigo acima;
+			//$month_ini = $params['saux'];
+
+			if($owner_id)
+			{
+				$cached_event_ids = "";//$this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id);
+				$cached_event_ids_repeating = "";//$this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id);
+			}
+			else
+			{
+				$cached_event_ids = "";//$this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
+				$cached_event_ids_repeating = "";//$this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
+			}
+
+			$c_cached_ids = count($cached_event_ids);
+			$c_cached_ids_repeating = count($cached_event_ids_repeating);
+
+			if($this->debug)
+			{
+				echo '<!-- events cached : '.$c_cached_ids.' : for : '.sprintf("%04d%02d%02d",$syear,$smonth,$sday).' -->'."\n";
+				echo '<!-- repeating events cached : '.$c_cached_ids_repeating.' : for : '.sprintf("%04d%02d%02d",$syear,$smonth,$sday).' -->'."\n";
+			}
+
+			$this->cached_events = Array();
+
+			if($c_cached_ids == 0 && $c_cached_ids_repeating == 0)
+			{
+				return;
+			}
+
+			$cache_start = (int)(sprintf("%04d%02d%02d",$syear,$smonth,$sday));
+			$cached_event=$this->get_cached_event();
+			if($c_cached_ids)
+			{
+				for($i=0;$i<$c_cached_ids;$i++)
+				{
+					$event = "";//$this->so->read_entry($cached_event_ids[$i]);
+					if ($event['recur_type'])
+					{
+						continue;	// fetch recuring events only in 2. loop
+					}
+					$startdate = (int)(date('Ymd',$this->maketime($event['start'])));
+					$enddate = (int)(date('Ymd',$this->maketime($event['end'])));
+					$this->cached_events[$startdate][] = $event;
+					if($startdate != $enddate)
+					{
+						$start['year'] = (int)(substr($startdate,0,4));
+						$start['month'] = (int)(substr($startdate,4,2));
+						$start['mday'] = (int)(substr($startdate,6,2));
+						for($j=$startdate,$k=0;$j<=$enddate;$k++,$j=(int)(date('Ymd',mktime(0,0,0,$start['month'],$start['mday'] + $k,$start['year']))))
+						{
+							$c_evt_day = count($this->cached_events[$j]) - 1;
+							if($c_evt_day < 0)
+							{
+								$c_evt_day = 0;
+							}
+							if($this->debug)
+							{
+								echo '<!-- Date: '.$j.' Count : '.$c_evt_day.' -->'."\n";
+							}
+							if($this->cached_events[$j][$c_evt_day]['id'] != $event['id'])
+							{
+								if($this->debug)
+								{
+									echo '<!-- Adding Event for Date: '.$j.' -->'."\n";
+								}
+								$this->cached_events[$j][] = $event;
+							}
+							if ($j >= $cache_start && (@$params['no_doubles'] || @$this->xmlrpc))
+							{
+								break;	// add event only once on it's startdate
+							}
+						}
+					}
+				}
+			}
+
+			$this->repeating_events = Array();
+			if($c_cached_ids_repeating)
+			{
+				for($i=0;$i<$c_cached_ids_repeating;$i++)
+				{
+					$this->repeating_events[$i] = "";//$this->so->read_entry($cached_event_ids_repeating[$i]);
+					if($this->debug)
+					{
+						echo '<!-- Cached Events ID: '.$cached_event_ids_repeating[$i].' ('.sprintf("%04d%02d%02d",$this->repeating_events[$i]['start']['year'],$this->repeating_events[$i]['start']['month'],$this->repeating_events[$i]['start']['mday']).') -->'."\n";
+					}
+				}
+				for($date=mktime(0,0,0,$smonth,$sday,$syear);$date<=$edate;$date += 86400)
+				{
+					if($this->debug)
+					{
+						$search_date = date('Ymd',$date);
+						echo '<!-- Calling check_repeating_events('.$search_date.') -->'."\n";
+					}
+					$this->check_repeating_events($date);
+					if($this->debug)
+					{
+						echo '<!-- Total events found matching '.$search_date.' = '.count($this->cached_events[$search_date]).' -->'."\n";
+						for($i=0;$i<count($this->cached_events[$search_date]);$i++)
+						{
+							echo '<!-- Date: '.$search_date.' ['.$i.'] = '.$this->cached_events[$search_date][$i]['id'].' -->'."\n";
+						}
+					}
+				}
+			}
+			$retval = Array();
+			for($j=date('Ymd',mktime(0,0,0,$smonth,$sday,$syear)),$k=0;$j<=date('Ymd',mktime(0,0,0,$emonth,$eday,$eyear));$k++,$j=date('Ymd',mktime(0,0,0,$smonth,$sday + $k,$syear)))
+			{
+				if(is_array($this->cached_events[$j]))
+				{
+					if ($this->xmlrpc)
+					{
+						foreach($this->cached_events[$j] as $event)
+						{
+							$retval[] = $this->xmlrpc_prepare($event);
+						}
+					}
+					else
+					{
+						$retval[$j] = $this->cached_events[$j];
+					}
+				}
+			}
+			//echo "store_to_cache(".print_r($params,True).")=<pre>".print_r($retval,True)."</pre>\n";
+			//$this->so->cal->event = $cached_event;
+			return $retval;
+		}
+
+		function xmlrpc_prepare(&$event)
+		{
+			$event['rights'] = $this->grants[$event['owner']];
+
+			foreach(array('start','end','modtime','recur_enddate') as $name)
+			{
+				if (isset($event[$name]))
+				{
+					$event[$name] = $GLOBALS['server']->date2iso8601($event[$name]);
+				}
+			}
+			if (is_array($event['recur_exception']))
+			{
+				foreach($event['recur_exception'] as $key => $timestamp)
+				{
+					$event['recur_exception'][$key] = $GLOBALS['server']->date2iso8601($timestamp);
+				}
+			}
+			static $user_cache = array();
+
+			if (!is_object($GLOBALS['phpgw']->perferences))
+			{
+				$GLOBALS['phpgw']->perferences = CreateObject('phpgwapi.preferences');
+			}
+			foreach($event['participants'] as $user_id => $status)
+			{
+				if (!isset($user_cache[$user_id]))
+				{
+					$user_cache[$user_id] = array(
+						'name'   => $GLOBALS['phpgw']->common->grab_owner_name($user_id),
+						'email'  => $GLOBALS['phpgw']->perferences->email_address($user_id)
+					);
+				}
+				$event['participants'][$user_id] = $user_cache[$user_id] + array(
+					'status' => $status,
+				);
+			}
+			if (is_array($event['alarm']))
+			{
+				foreach($event['alarm'] as $id => $alarm)
+				{
+					$event['alarm'][$id]['time'] = $GLOBALS['server']->date2iso8601($alarm['time']);
+					if ($alarm['owner'] != $GLOBALS['phpgw_info']['user']['account_id'])
+					{
+						unset($event['alarm'][$id]);
+					}
+				}
+			}
+			$event['category'] = $GLOBALS['server']->cats2xmlrpc(explode(',',$event['category']));
+
+			// using access={public|privat} in all modules via xmlrpc
+			$event['access'] = $event['public'] ? 'public' : 'privat';
+			unset($event['public']);
+
+			return $event;
+		}
+
+		/* Begin Appsession Data */
+		function store_to_appsession($event)
+		{
+			$GLOBALS['phpgw']->session->appsession('entry','resources',$event);
+		}
+
+		function restore_from_appsession()
+		{
+//echo "quees";
+			$this->event_init();
+			$event = $GLOBALS['phpgw']->session->appsession('entry','resources');
+//echo "quees".$event;
+			//$this->so->cal->event = $event;
+			return $event;
+		}
+		/* End Appsession Data */
+
+		/* Begin of SO functions */
+		function get_cached_event()
+		{
+			return "";//$this->so->get_cached_event();
+		}
+
+		function add_attribute($var,$value,$index='**(**')
+		{
+			//$this->so->add_attribute($var,$value,$index);
+		}
+
+		function event_init()
+		{
+			//$this->so->event_init();
+		}
+
+		function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0)
+		{
+			//$this->so->set_start($year,$month,$day,$hour,$min,$sec);
+		}
+
+		function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0)
+		{
+			//$this->so->set_end($year,$month,$day,$hour,$min,$sec);
+		}
+
+		function set_title($title='')
+		{
+			//$this->so->set_title($title);
+		}
+
+		function set_description($description='')
+		{
+			//$this->so->set_description($description);
+		}
+
+		function set_description1($description1='')
+		{
+			//$this->so->set_description1($description1);
+		}
+function set_participants1($participants1='')
+		{
+			//$this->so->set_participants1($participants1);
+		}
+		function set_ex_participants($ex_participants='')
+		{
+			//$this->so->set_ex_participants($ex_participants);
+		}
+
+		function set_class($class)
+		{
+			//$this->so->set_class($class);
+		}
+
+		function set_category($category='')
+		{
+			//$this->so->set_category($category);
+		}
+
+		function set_alarm($alarm)
+		{
+			//$this->so->set_alarm($alarm);
+		}
+
+		function set_recur_none()
+		{
+			//$this->so->set_recur_none();
+		}
+
+		function set_recur_daily($year,$month,$day,$interval)
+		{
+			//$this->so->set_recur_daily($year,$month,$day,$interval);
+		}
+
+		function set_recur_weekly($year,$month,$day,$interval,$weekdays)
+		{
+			//$this->so->set_recur_weekly($year,$month,$day,$interval,$weekdays);
+		}
+
+		function set_recur_monthly_mday($year,$month,$day,$interval)
+		{
+			//$this->so->set_recur_monthly_mday($year,$month,$day,$interval);
+		}
+
+		function set_recur_monthly_wday($year,$month,$day,$interval)
+		{
+			//$this->so->set_recur_monthly_wday($year,$month,$day,$interval);
+		}
+
+		function set_recur_yearly($year,$month,$day,$interval)
+		{
+			//$this->so->set_recur_yearly($year,$month,$day,$interval);
+		}
+		/* End of SO functions */
+
+		function prepare_matrix($interval,$increment,$part,$fulldate)
+		{
+			for($h=0;$h<24;$h++)
+			{
+				for($m=0;$m<$interval;$m++)
+				{
+					$index = (($h * 10000) + (($m * $increment) * 100));
+					$time_slice[$index]['marker'] = '&nbsp';
+					$time_slice[$index]['description'] = '';
+$time_slice[$index]['description1'] = '';
+				}
+			}
+			foreach($this->cached_events[$fulldate] as $event)
+			{
+				if ($event['participants'][$part] == 'R')
+				{
+					continue;	// dont show rejected invitations, as they are free time
+				}
+				$eventstart = $GLOBALS['phpgw']->datetime->localdates($this->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset);
+				$eventend = $GLOBALS['phpgw']->datetime->localdates($this->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset);
+				$start = ($eventstart['hour'] * 10000) + ($eventstart['minute'] * 100);
+				$starttemp = $this->splittime("$start",False);
+				$subminute = 0;
+				for($m=0;$m<$interval;$m++)
+				{
+					$minutes = $increment * $m;
+					if((int)$starttemp['minute'] > $minutes && (int)$starttemp['minute'] < ($minutes + $increment))
+					{
+						$subminute = ($starttemp['minute'] - $minutes) * 100;
+					}
+				}
+				$start -= $subminute;
+				$end =  ($eventend['hour'] * 10000) + ($eventend['minute'] * 100);
+				$endtemp = $this->splittime("$end",False);
+				$addminute = 0;
+				for($m=0;$m<$interval;$m++)
+				{
+					$minutes = ($increment * $m);
+					if($endtemp['minute'] < ($minutes + $increment) && $endtemp['minute'] > $minutes)
+					{
+						$addminute = ($minutes + $increment - $endtemp['minute']) * 100;
+					}
+				}
+				$end += $addminute;
+				$starttemp = $this->splittime("$start",False);
+				$endtemp = $this->splittime("$end",False);
+
+				for($h=$starttemp['hour'];$h<=$endtemp['hour'];$h++)
+				{
+					$startminute = 0;
+					$endminute = $interval;
+					$hour = $h * 10000;
+					if($h == (int)$starttemp['hour'])
+					{
+						$startminute = ($starttemp['minute'] / $increment);
+					}
+					if($h == (int)$endtemp['hour'])
+					{
+						$endminute = ($endtemp['minute'] / $increment);
+					}
+					$private = $this->is_private($event,$part);
+					$time_display = $GLOBALS['phpgw']->common->show_date($eventstart['raw'],$this->users_timeformat).'-'.$GLOBALS['phpgw']->common->show_date($eventend['raw'],$this->users_timeformat);
+					$time_description = '('.$time_display.') '.$this->get_short_field($event,$private,'title').$this->display_status($event['participants'][$part]);
+					for($m=$startminute;$m<$endminute;$m++)
+					{
+						$index = ($hour + (($m * $increment) * 100));
+						$time_slice[$index]['marker'] = '-';
+						$time_slice[$index]['description'] = $time_description;
+						$time_slice[$index]['id'] = $event['id'];
+					}
+				}
+			}
+			return $time_slice;
+		}
+
+		/*!
+		@function set_status
+		@abstract set the participant response $status for event $cal_id and notifies the owner of the event
+		*/
+		function set_status($cal_id,$status)
+		{
+			$status2msg = array(
+				REJECTED  => MSG_REJECTED,
+				TENTATIVE => MSG_TENTATIVE,
+				ACCEPTED  => MSG_ACCEPTED
+			);
+			if (!isset($status2msg[$status]))
+			{
+				return False;
+			}
+			$event = "";//$this->so->read_entry($cal_id);
+			$account_id = $GLOBALS['phpgw_info']['user']['account_id'];
+			if(($status2msg[$status] == "5" && $event['participants'][$account_id] == "A") ||
+			 ($status2msg[$status] == "3" && $event['participants'][$account_id] == "R")) {
+				return True;
+			}
+			//$this->so->set_status($cal_id,$status);
+			$event = "";//$this->so->read_entry($cal_id);
+			$this->send_update($status2msg[$status],$event['participants'],$event);
+
+		}
+
+		/*!
+		@function update_requested
+		@abstract checks if $userid has requested (in $part_prefs) updates for $msg_type
+		@syntax update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event)
+		@param $userid numerical user-id
+		@param $part_prefs preferces of the user $userid
+		@param $msg_type type of the notification: MSG_ADDED, MSG_MODIFIED, MSG_ACCEPTED, ...
+		@param $old_event Event before the change
+		@param $new_event Event after the change
+		@returns 0 = no update requested, > 0 update requested
+		*/
+		function update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event)
+		{
+			if ($msg_type == MSG_ALARM)
+			{
+				return True;	// always True for now
+			}
+			$want_update = 0;
+
+			// the following switch fall-through all cases, as each included the following too
+			//
+			$msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE;
+
+			switch($ru = $part_prefs['resources']['receive_updates'])
+			{
+				case 'responses':
+					if ($msg_is_response)
+					{
+						++$want_update;
+					}
+				case 'modifications':
+					if ($msg_type == MSG_MODIFIED)
+					{
+						++$want_update;
+					}
+				case 'time_change_4h':
+				case 'time_change':
+					$diff = max(abs($this->maketime($old_event['start'])-$this->maketime($new_event['start'])),
+						abs($this->maketime($old_event['end'])-$this->maketime($new_event['end'])));
+					$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
+					if ($msg_type == MSG_MODIFIED && $diff > $check)
+					{
+						++$want_update;
+					}
+				case 'add_cancel':
+					if ($old_event['owner'] == $userid && $msg_is_response ||
+						$msg_type == MSG_DELETED || $msg_type == MSG_ADDED)
+					{
+						++$want_update;
+					}
+					break;
+				case 'no':
+					break;
+			}
+			//echo "<p>boresources::update_requested(user=$userid,pref=".$part_prefs['resources']['receive_updates'] .",msg_type=$msg_type,".($old_event?$old_event['title']:'False').",".($old_event?$old_event['title']:'False').") = $want_update</p>\n";
+			return $want_update > 0;
+		}
+
+	function create_vcard($event_array)
+	{
+	if(!is_array($event_array))
+		return null;
+	$tmpattach="BEGIN:Vresources\n"
+	."PRODID:-//Expresso Livre//resources//EN\n"
+	."VERSION:1.0\n";
+		foreach ($event_array as $event)
+		{
+			// It translates int to string
+			if (!is_object($event) && !is_array($event) || !array_key_exists  ('end', $event))
+				$event = $event_array;
+			if ( $event['end']['month'] < 10 )
+				$end_event_month="0".$event['end']['month'];
+			else
+				$end_event_month=$event['end']['month'];
+			if ( $event['start']['month'] < 10 )
+				$start_event_month="0".$event['start']['month'];
+			else
+				$start_event_month=$event['start']['month'];
+			if ( $event['end']['mday'] < 10 )
+				$end_event_day="0".$event['end']['mday'];
+			else
+				$end_event_day=$event['end']['mday'];
+			if ( $event['start']['mday'] < 10 )
+				$start_event_day="0".$event['start']['mday'];
+			else
+				$start_event_day=$event['start']['mday'];
+			if ( $event['start']['hour'] < 10)
+				$start_event_hour="0".$event['start']['hour'];
+			else
+				$start_event_hour=$event['start']['hour'];
+			if ( $event['end']['hour'] < 10)
+				$end_event_hour="0".$event['end']['hour'];
+			else
+				$end_event_hour=$event['end']['hour'];
+				
+			if ( $event['start']['min'] < 10)
+				$start_event_min="0".$event['start']['min'];
+			else
+				$start_event_min=$event['start']['min'];
+			if ( $event['end']['min'] < 10)
+				$end_event_min="0".$event['end']['min'];
+			else
+				$end_event_min=$event['end']['min'];	
+		
+
+			$tmpattach.="BEGIN:VEVENT\n"
+			."DTSTART:".$event['start'][year].$start_event_month.$start_event_day."T".$start_event_hour.$start_event_min."00Z\n"
+			."DTEND:".$event[end][year].$end_event_month.$end_event_day."T".$end_event_hour.$end_event_min."00Z\n"
+			."UID:Expresso-".$event[id].$event[uid]."\n"
+			."LAST-MODIFIED:".time()."\n"
+			."DESCRIPTION:".$event[description]."\n"
+."DESCRIPTION1:".$event[description1]."\n"
+."PARTICIPANTS1:".$event[participants1]."\n"
+			."SUMMARY:".$event[title]."\n"
+			."LOCATION:".$event[location]."\n"
+			."END:VEVENT"."\n";
+		}
+			$tmpattach.="END:Vresources\n";
+			return $tmpattach;
+}
+
+		/*!
+		@function send_update
+		@abstract sends update-messages to certain participants of an event
+		@syntax send_update($msg_type,$to_notify,$old_event,$new_event=False)
+		@param $msg_type type of the notification: MSG_ADDED, MSG_MODIFIED, MSG_ACCEPTED, ...
+		@param $to_notify array with numerical user-ids as keys (!) (value is not used)
+		@param $old_event Event before the change
+		@param $new_event Event after the change
+		*/
+		function send_update($msg_type,$to_notify,$old_event,$new_event=False,$user=False)
+		{
+			
+			//echo "<p>boresources::send_update(type=$msg_type,to_notify="; print_r($to_notify); echo ", old_event="; print_r($old_event); echo ", new_event="; print_r($new_event); echo ", user=$user)</p>\n";
+			if (!is_array($to_notify))
+			{
+				$to_notify = array();
+			}
+			$owner = $old_event ? $old_event['owner'] : $new_event['owner'];
+			if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM)
+			{
+				$to_notify[$owner] = 'owner';	// always include the event-owner
+			}
+			$version = $GLOBALS['phpgw_info']['apps']['resources']['version'];
+
+			$GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences();
+			$sender = $GLOBALS['phpgw_info']['user']['email'];
+
+			$temp_tz_offset = $this->prefs['common']['tz_offset'];
+			$temp_timeformat = $this->prefs['common']['timeformat'];
+			$temp_dateformat = $this->prefs['common']['dateformat'];
+
+			$tz_offset = ((60 * 60) * (int)$temp_tz_offset);
+
+			if($old_event != False)
+			{
+				$t_old_start_time = $this->maketime($old_event['start']);
+				if($t_old_start_time < (time() - 86400))
+				{
+					return False;
+				}
+			}
+
+			$temp_user = $GLOBALS['phpgw_info']['user'];
+
+			if (!$user)
+			{
+				$user = $this->owner;
+			}
+			$GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences($user);
+
+			$event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event;
+			if($old_event != False)
+			{
+				$old_starttime = $t_old_start_time - $GLOBALS['phpgw']->datetime->tz_offset;
+			}
+			$starttime = $this->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
+			$endtime   = $this->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
+
+			switch($msg_type)
+			{
+				case MSG_DELETED:
+					$action = lang('Canceled');
+					$msg = 'Canceled';
+					$msgtype = '"resources";';
+					$method = 'cancel';
+					$typesend = 1;
+					break;
+				case MSG_MODIFIED:
+					$action = lang('Modified');
+					$msg = 'Modified';
+					$msgtype = '"resources"; Version="'.$version.'"; Id="'.$new_event['id'].'"';
+					$method = 'request';
+					$typesend = 2;
+					break;
+				case MSG_ADDED:
+					$action = lang('Added');
+					$msg = 'Added';
+					$msgtype = '"resources"; Version="'.$version.'"; Id="'.$new_event['id'].'"';
+					$method = 'request';
+					$typesend = 3;
+					break;
+				case MSG_REJECTED:
+					$action = lang('Rejected');
+					$msg = 'Response';
+					$msgtype = '"resources";';
+					$method = 'reply';
+					$typesend = 4;
+					break;
+				case MSG_TENTATIVE:
+					$action = lang('Tentative');
+					$msg = 'Response';
+					$msgtype = '"resources";';
+					$method = 'reply';
+					$typesend = 5;
+					break;
+				case MSG_ACCEPTED:
+					$action = lang('Accepted');
+					$msg = 'Response';
+					$msgtype = '"resources";';
+					$method = 'reply';
+					$typesend = 6;
+					break;
+				case MSG_ALARM:
+					$action = lang('Alarm');
+					$msg = 'Alarm';
+					$msgtype = '"resources";';
+					$method = 'publish';	// duno if thats right
+					$typesend = 7;
+					break;
+				default:
+					$method = 'publish';
+					$typesend = 8;
+			}
+			$notify_msg = $this->prefs['resources']['notify'.$msg];
+			if (empty($notify_msg))
+			{
+				$notify_msg = $this->prefs['resources']['notifyAdded'];	// use a default
+			}
+			$details = array(			// event-details for the notify-msg
+				'id'          => $msg_type == MSG_ADDED ? $new_event['id'] : $old_event['id'],
+				'action'      => $action,
+			);
+			$event_arr = $this->event2array($event);
+			foreach($event_arr as $key => $val)
+			{
+				$details[$key] = $val['data'];
+			}
+			
+			$details['participants'] = implode("\n",$details['participants']);
+
+			$details['link'] = $GLOBALS['phpgw_info']['server']['webserver_url'].'/index.php?menuaction=resources.uiresources.view&cal_id='.$event['id'];
+			// if url is only a path, try guessing the rest ;-)
+			if ($GLOBALS['phpgw_info']['server']['webserver_url'][0] == '/')
+			{
+				$details['link'] = ($GLOBALS['phpgw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
+					($GLOBALS['phpgw_info']['server']['hostname'] ? $GLOBALS['phpgw_info']['server']['hostname'] : 'localhost').
+					$details['link'];
+			}
+			
+			//Seta o email usando phpmailer
+			define('PHPGW_INCLUDE_ROOT','../');	
+			define('PHPGW_API_INC','../phpgwapi/inc');	
+			include_once(PHPGW_API_INC.'/class.phpmailer.inc.php');
+			$mail = new PHPMailer();
+			$mail->IsSMTP();
+			$boemailadmin = CreateObject('emailadmin.bo');
+			$emailadmin_profile = $boemailadmin->getProfileList();
+			$emailadmin = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
+		
+			$mail->Host = $emailadmin['smtpServer'];
+			$mail->Port = $emailadmin['smtpPort'];
+			$mail->From = $GLOBALS['phpgw']->preferences->values['email'];
+			$mail->FromName = $GLOBALS['phpgw_info']['user']['fullname'];
+			$mail->IsHTML(true);
+
+			// Aqui ï¿œ enviado o email
+			foreach($to_notify as $userid => $statusid) 
+			{
+			 	$mail->ClearAttachments();
+			 	
+				$userid = (int)$userid;
+
+				if ($statusid == 'R' || $GLOBALS['phpgw']->accounts->get_type($userid) == 'g')
+				{
+					continue;	// dont notify rejected participants
+				}
+				if($userid != $GLOBALS['phpgw_info']['user']['account_id'] ||  $msg_type == MSG_ALARM)
+				{
+					print_debug('Msg Type',$msg_type);
+					print_debug('UserID',$userid);
+
+					$preferences = CreateObject('phpgwapi.preferences',$userid);
+					$part_prefs = $preferences->read_repository();
+
+					if (!$this->update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event))
+					{
+						continue;
+					}
+					$GLOBALS['phpgw']->accounts->get_account_name($userid,$lid,$details['to-firstname'],$details['to-lastname']);
+					$details['to-fullname'] = $GLOBALS['phpgw']->common->display_fullname('',$details['to-firstname'],$details['to-lastname']);
+
+					$to = $preferences->email_address($userid);
+					
+					if (empty($to) || $to[0] == '@' || $to[0] == '$')	// we have no valid email-address
+					{
+						//echo "<p>boresources::send_update: Empty email adress for user '".$details['to-fullname']."' ==> ignored !!!</p>\n";
+						continue;
+					}
+					print_debug('Email being sent to',$to);
+
+					$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] = $part_prefs['common']['tz_offset'];
+					$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $part_prefs['common']['timeformat'];
+					$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = $part_prefs['common']['dateformat'];
+
+					$GLOBALS['phpgw']->datetime->tz_offset = ((60 * 60) * (int)$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']);
+
+					if($old_starttime)
+					{
+						$details['olddate'] = $GLOBALS['phpgw']->common->show_date($old_starttime);
+					}
+					$details['startdate'] = $GLOBALS['phpgw']->common->show_date($starttime);
+					$details['enddate']   = $GLOBALS['phpgw']->common->show_date($endtime);
+					
+					
+					list($subject,$body1) = split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2);
+					
+					switch($part_prefs['resources']['update_format'])
+ 					{
+						case  'extended':
+							//$body .= "\n\n".lang('Event Details follow').":\n";
+							$body = '';
+							$body .= "<br>".lang('Event Details follow')." :: ";
+							foreach($event_arr as $key => $val)
+							{
+								// titulo
+								if($key =='title')
+								{
+									$var1 = $val['field'];
+									$vardata1 = $details[$key];
+								}
+								//descricao
+								if($key =='description')
+								{
+									$var2 = $val['field'];
+									$vardata2 = $details[$key];
+								}
+if($key =='description1')
+								{
+									$var2 = $val['field'];
+									$vardata2 = $details[$key];
+								}
+
+if($key =='participants1')
+								{
+									$var2 = $val['field'];
+									$vardata2 = $details[$key];
+								}
+
+								//dt inicio
+								if($key =='startdate')
+								{
+									switch(trim($part_prefs['common']['dateformat']))
+									{
+										
+										case ($part_prefs['common']['dateformat'] === "m/d/Y" || $part_prefs['common']['dateformat'] === "m-d-Y" || $part_prefs['common']['dateformat'] === "m.d.Y"):
+											$var3 = $val['field'];
+											$vardata3 = $details[$key];
+											$newmounth3 = substr($vardata3,0,2);
+											$newday3 = substr($vardata3,3,2);
+											$newyear3 = substr($vardata3,6,4);
+											$newall3 =$newyear3.$newmounth3.$newday3;
+											break;
+											
+										case	($part_prefs['common']['dateformat'] === "Y/d/m" || $part_prefs['common']['dateformat'] === "Y-d-m" || $part_prefs['common']['dateformat'] === "Y.d.m"):
+
+											$var3 = $val['field'];
+											$vardata3 = $details[$key];
+											$newyear3 = substr($vardata3,0,4);
+											$newday3 = substr($vardata3,5,2);
+											$newmounth3 = substr($vardata3,8,2);
+											$newall3 =$newyear3.$newmounth3.$newday3;
+											break;
+
+										case ($part_prefs['common']['dateformat'] === "Y/m/d" || $part_prefs['common']['dateformat'] === "Y-m-d" || $part_prefs['common']['dateformat'] === "Y.m.d"):
+
+											$var3 = $val['field'];
+											$vardata3 = $details[$key];
+											$newyear3 = substr($vardata3,0,4);
+											$newmounth3 = substr($vardata3,5,2);
+											$newday3 = substr($vardata3,8,2);
+											$newall3 =$newyear3.$newmounth3.$newday3;
+											break;
+
+										case ($part_prefs['common']['dateformat'] === "d/m/Y" || $part_prefs['common']['dateformat'] === "d-m-Y" || $part_prefs['common']['dateformat'] === "d.m.Y" || $part_prefs['common']['dateformat'] === "d-M-Y"):
+										
+											$var3 = $val['field'];
+											$vardata3 = $details[$key];
+											$newday3 = substr($vardata3,0,2);
+											$newmounth3 = substr($vardata3,3,2);
+											$newyear3 = substr($vardata3,6,4);
+											$newall3 =$newyear3.$newmounth3.$newday3;
+											break;
+									
+									}
+									
+								}
+								//dt final
+								if($key =='enddate')
+								{
+									$var4 = $val['field'];
+									$vardata4 = $details[$key];
+								}
+								//localizacao
+								if($key =='location')
+								{
+									$var8 = $val['field'];
+									$vardata8 = $details[$key];
+								}
+								//participantes
+								if($key =='participants')
+								{
+									$var5 = $val['field'];
+									foreach($val['data'] as $NewKey => $NewVal)
+									{
+										//Research inside of ldap ( Pesquisa dentro do ldap )
+										$newvalue = "";//$this->so->search_uidNumber($to);
+										foreach($newvalue as $tmp)
+										{
+											$tmpmail = $tmp['mail'][0];
+											$tmpuid = $tmp['uidnumber'][0];
+											if( trim($tmpmail) == trim($to) & trim($tmpuid) == trim($NewKey))
+											{
+													if($typesend == 3)
+													{
+
+														$lang1 = lang("To See Commitment");
+														$varbuttom = "<form action=".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=resources.uiresources.view&cal_id=$event[id]&date=$newall3' method='POST'>
+																		  		  <input type='submit' value='$lang1'>
+																		  		   </form>";
+														$lang2 = lang("To accept");
+														$varbuttom1 ="<input type='submit' value='$lang2' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=resources.uiresources.set_action&cal_id=$event[id]&action=3&response=1\",\"frontpage\",\"height=100,width=400,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>";
+
+														$lang3 = lang("To reject");
+														$varbuttom2 ="<input type='submit' value='$lang3' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=resources.uiresources.set_action&cal_id=$event[id]&action=0&response=0\",\"frontpage\",\"height=100,width=400,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>";
+														
+														$lang4 = lang("Alarm");
+														$varbuttom3 = "<form action=".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=resources.uialarm.manager method='POST'>
+																		  		  <input type='submit' value='$lang4'>
+																		  		  <input type='hidden' name='cal_id' value=$event[id]>
+																		  		   </form>";
+													}
+													else
+													{
+															$varbuttom  = "";
+															$varbuttom1 = "";
+															$varbuttom2 = "";
+															$varbuttom3 = "";
+													}
+											}
+											// It only mounts variavel with the name of the participants of the list ( Monta a variavel somente com o nome dos participantes da lista)
+											if($typesend == 3)
+											{
+												list($tmpvardata5,$tmp2vardata5) = explode("(",$NewVal);
+												$vardata5 = $tmpvardata5."<br>";
+											}
+											else
+											{
+												$vardata5 = $NewVal."<br>";
+											}
+										
+										}
+										$vardata6 .= $vardata5;
+										unset($vardata5);
+									}
+								}		
+							}
+							//To mount the message as text/html (Para montar a mensagem como text/html - /phpgwapi/inc/class.send.inc.php )
+							$content_type = "text/html";
+							//It mounts the body of the message (Monta o corpo da mensagem)
+							
+							// A constante PHPGW_APP_TPL nao existe para envio de alarmes (cront, asyncservice).
+							define ("PHPGW_APP_TPL",PHPGW_API_INC . "/../../resources/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."");
+							
+							$body = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+							$body->set_file(Array('resources' => 'body_email.tpl'));
+							$body->set_block('resources','list');
+							$var = Array(
+								'script'			=> $script,
+								'subject'			=> $body1,
+								'var1'				=> $var1,
+								'vardata1'			=> $vardata1,
+								'var2'				=> $var2,
+								'vardata2'			=> $vardata2,
+								'var3'				=> $var3,
+								'vardata3'			=> $vardata3,
+								'var4'				=> $var4,
+								'vardata4'			=> $vardata4,
+								'var5'				=> $var5,
+								'vardata6'			=> $vardata6,
+								'var8'				=> $var8,
+								'vardata8'			=> $vardata8,							
+								'varbuttom'			=> $varbuttom,
+								'varbuttom1'		=> $varbuttom1,
+								'varbuttom2'		=> $varbuttom2,
+								'varbuttom3'		=> $varbuttom3 
+								
+							);
+							$body->set_var($var);
+							$tmpbody = $body->fp('out','list');
+														
+							break;
+
+						case 'ical':
+							$content_type = "resources; method=$method; name=resources.ics";
+/*							if ($body != '')
+							{
+								$boundary = '----Message-Boundary';
+								$body .= "\n\n\n$boundary\nContent-type: text/$content_type\n".
+									"Content-Disposition: inline\nContent-transfer-encoding: 7BIT\n\n";
+								$content_type = '';
+							}
+*/
+							$body = ExecMethod('resources.boiresources.export',array(
+								'l_event_id'  => $event['id'],
+								'method'      => $method,
+								'chunk_split' => False
+							));
+							break;
+					}
+					$mail->AddAddress($to);
+					$mail->Body = $tmpbody;
+					$mail->From = $sender;
+					$mail->FromName = $GLOBALS['phpgw_info']['user']['fullname'];
+					$mail->Sender = $mail->From;
+					$mail->SenderName = $mail->FromName;
+					$mail->Subject = $subject;
+					unset($vardata5);
+					unset($vardata6);
+				}
+			}
+
+			//Inicializa variï¿œvel de retorno.
+			$returncode=true;			
+			if(count($mail->to)) {				
+				// Envia aviso a todos os participantes.
+				if(!$mail->Send()) {				
+					$returncode = false;
+					$errorInfo['participants'] = $mail->ErrorInfo;
+				}
+				else
+					$returncode =  true;
+			}
+			
+			if(count($to_notify) && $this->ex_participants){
+				$mail->ClearAllRecipients();
+				$var = explode(",",trim($this->ex_participants));
+				$to = array();
+				if(!$subject) {
+					$details['startdate'] = $GLOBALS['phpgw']->common->show_date($starttime);
+					$details['enddate']   = $GLOBALS['phpgw']->common->show_date($endtime);
+					list($subject,$body1) = split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2);
+				}
+				
+				foreach($var as $index => $ex_participant){
+					$ex_participant = trim($ex_participant);
+					$ex_participant = preg_replace('#"(.*)" <(.*)\@(.*)\.(.*)>#','\\2@\\3.\\4',$ex_participant);
+						if($ex_participant)
+							$to[] = $ex_participant;
+				}		
+				
+				foreach($to as $i => $to_array)
+					$mail->AddAddress($to_array);
+				
+				$_body = explode("<hr size='1' width='100%'>",$tmpbody);
+				$tmpbody = $_body[0] ? $_body[0] : $subject ;
+				$tmpbody.= "<br><b>".lang("external participants").":: </b> ".htmlentities($this->ex_participants);
+				$tmpbody.= "<br>".lang("Summary").": "."";//$this->so->cal->event[title]."<br>";
+				$tmpbody.= "<br>".lang("Start time").": ".$GLOBALS['phpgw']->common->show_date($starttime)."<br>".lang("End date").": ".$GLOBALS['phpgw']->common->show_date($endtime)."<br>";
+				$tmpbody.= "<br><br><hr size='1' width='100%'><font color='red'>"
+				.lang("This message was sent by server. You must send a message to sender to confirm this event")."<br>"
+				.lang("This is an external event. Even if it added to your expresso its can be changed any time at all")."</font><br>";
+				
+				if ($GLOBALS['boresources']->so->cal->event[start][month] > 10)
+					$event_month=$GLOBALS['boresources']->so->cal->event[start][month];
+				else
+					$event_month="0".$GLOBALS['boresources']->so->cal->event[start][month];
+				//attach extern vcard			
+				// define('context','$GLOBALS.boresources.so.cal.event');
+				$tmpattach = $this->create_vcard($GLOBALS['boresources']->so->cal->event);
+				if($tmpattach){					
+					$tmpbody .="<a href='../index.php?menuaction=resources.uiresources.add&date="
+					.$GLOBALS['boresources']->so->cal->event[start][year]
+				.$event_month
+				.$GLOBALS['boresources']->so->cal->event[start][mday]
+					."&hour=".$GLOBALS['boresources']->so->cal->event[start][hour]
+					."&minute=".$GLOBALS['boresources']->so->cal->event[start][min]
+					."&title=".$GLOBALS['boresources']->so->cal->event['title']
+					."&description=".$GLOBALS['boresources']->so->cal->event['description']
+."&description1=".$GLOBALS['boresources']->so->cal->event['description1']
+."&participants1=".$GLOBALS['boresources']->so->cal->event['participants1']
+					."&location=".$GLOBALS['boresources']->so->cal->event['location']."'>"
+					."<h2>".lang("Add to my expresso")."</h2>";
+					$tempdir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP;
+					srand((double)microtime()*1000000);
+					$random_number = rand(100000000,999999999);
+					$newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number );
+					$filename = $tempdir . $newfilename;
+					$attach_fd = fopen($filename,"w+");
+					fwrite($attach_fd,$tmpattach);
+					$mail->AddAttachment($filename, "extern.vcard", "base64", "text/plain"); // "application/octet-stream"
+					fclose($attach_fd);
+				}
+				$mail->From = $sender;
+				$mail->FromName = $GLOBALS['phpgw_info']['user']['fullname'];
+				$mail->Sender = $mail->From;
+				$mail->SenderName = $mail->FromName;
+				$mail->Subject = lang("External event from Expresso");
+				$mail->Body = $tmpbody;
+																		
+				if(!$mail->Send()) 
+				{
+					$returncode=false;
+					$errorInfo['ex_participants'] = $mail->ErrorInfo;
+				}
+				else
+				{
+					$returncode=true;
+				}
+			}
+
+
+			if((is_int($this->user) && $this->user != $temp_user['account_id']) ||
+				(is_string($this->user) && $this->user != $temp_user['account_lid']))
+			{
+				$GLOBALS['phpgw_info']['user'] = $temp_user;
+			}	
+
+			$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] = $temp_tz_offset;
+			$GLBOALS['phpgw']->datetime->tz_offset = ((60 * 60) * $temp_tz_offset);
+			$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $temp_timeformat;
+			$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = $temp_dateformat;
+			
+			// Notifica por email o criador do compromisso, com as possï¿œveis falhas.						
+			if($errorInfo) {
+				$tmpbody = "<font color='red'>".lang("The following commitment had problems for DELIVERING the NOTIFICATION messages.").".</font><br>";
+				$tmpbody.= "<br>".lang("Summary").": "."";//$this->so->cal->event[title]."<br>";
+				$tmpbody.= "<br>".lang("Start time").": ".$GLOBALS['phpgw']->common->show_date($starttime)."<br>".lang("End date").": ".$GLOBALS['phpgw']->common->show_date($endtime)."<br>";				
+				$tmpbody.= "<br><u>".lang("Failed to delivery")."</u><br>";
+				$failed = false;				
+				if(strstr($errorInfo['participants'],"recipients_failed")){
+					$failed	= explode("recipients_failed",$errorInfo['participants']);
+					$tmpbody.= lang("to").": ".$failed[1];
+				}
+				if(strstr($errorInfo['ex_participants'],"recipients_failed")){
+					$failed = explode("recipients_failed",$errorInfo['ex_participants']);
+					$tmpbody.= lang("to").": ".$failed[1];
+				}			
+				if(!$failed) {
+					$tmpbody.= lang("Description").":<br>";
+$tmpbody.= lang("Description1").":<br>";
+$tmpbody.= lang("participants1").":<br>";
+					$tmpbody.= $errorInfo['participants'];
+					$tmpbody.= "<br>".$errorInfo['ex_participants'];
+				}
+				$tmpbody.= "<br>".lang("Subject").": ".$subject;
+				// Reinicializa o objeto, devido ao erro anterior na entrega.
+				
+				$mail = new PHPMailer();
+				$mail->IsSMTP();
+				$mail->Host = $emailadmin['smtpServer'];
+				$mail->Port = $emailadmin['smtpPort'];
+				$mail->From = $sender;
+				$mail->FromName = $GLOBALS['phpgw_info']['user']['fullname'];
+				$mail->Sender = $mail->From;
+				$mail->SenderName = $mail->FromName;
+				$mail->IsHTML(True);
+				$mail->Subject = lang("resources event")." - ".lang("email notification");							
+				$mail->Body = $tmpbody;					
+				$mail->AddAddress($sender);
+				if(!$mail->Send())			
+					$returncode = false;
+				else
+					$returncode =  true;
+			}
+			return $returncode;
+		}
+		
+		function send_alarm($alarm)
+		{
+			//echo "<p>boresources::send_alarm("; print_r($alarm); echo ")</p>\n";
+			
+			$GLOBALS['phpgw_info']['user']['account_id'] = $this->owner = $alarm['owner'];
+
+			if (!$alarm['enabled'] || !$alarm['owner'] || !$alarm['cal_id'] )
+			{
+				return False;	// event not found
+			}
+			if ($alarm['all'])
+			{
+				$to_notify = $event['participants'];
+			}
+			elseif ($this->check_perms(PHPGW_ACL_READ,$event))	// checks agains $this->owner set to $alarm[owner]
+			{
+				$to_notify[$alarm['owner']] = 'A';
+			}
+			else
+			{
+				return False;	// no rights
+			}
+			return $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
+		}
+
+		function get_alarms($event_id)
+		{
+			return "";//$this->so->get_alarm($event_id);
+		}
+
+		function alarm_today($event,$today,$starttime)
+		{
+			$found = False;
+			@reset($event['alarm']);
+			$starttime_hi = $GLOBALS['phpgw']->common->show_date($starttime,'Hi');
+			$t_appt['month'] =$GLOBALS['phpgw']->common->show_date($today,'m');
+			$t_appt['mday'] = $GLOBALS['phpgw']->common->show_date($today,'d');
+			$t_appt['year'] = $GLOBALS['phpgw']->common->show_date($today,'Y');
+			$t_appt['hour'] = $GLOBALS['phpgw']->common->show_date($starttime,'H');
+			$t_appt['min']  = $GLOBALS['phpgw']->common->show_date($starttime,'i');
+			$t_appt['sec']  = 0;
+			$t_time = $this->maketime($t_appt) - $GLOBALS['phpgw']->datetime->tz_offset;
+			$y_time = $t_time - 86400;
+			$tt_time = $t_time + 86399;
+			print_debug('T_TIME',$t_time.' : '.$GLOBALS['phpgw']->common->show_date($t_time));
+			print_debug('Y_TIME',$y_time.' : '.$GLOBALS['phpgw']->common->show_date($y_time));
+			print_debug('TT_TIME',$tt_time.' : '.$GLOBALS['phpgw']->common->show_date($tt_time));
+			while(list($key,$alarm) = each($event['alarm']))
+			{
+				if($alarm['enabled'])
+				{
+					print_debug('TIME',$alarm['time'].' : '.$GLOBALS['phpgw']->common->show_date($alarm['time']).' ('.$event['id'].')');
+					if($event['recur_type'] != MCAL_RECUR_NONE)   /* Recurring Event */
+					{
+						print_debug('Recurring Event');
+						if($alarm['time'] > $y_time && $GLOBALS['phpgw']->common->show_date($alarm['time'],'Hi') < $starttime_hi && $alarm['time'] < $t_time)
+						{
+							$found = True;
+						}
+					}
+					elseif($alarm['time'] > $y_time && $alarm['time'] < $t_time)
+					{
+						$found = True;
+					}
+				}
+			}
+			print_debug('Found',$found);
+			return $found;
+		}
+
+		function prepare_recipients(&$new_event,$old_event)
+		{
+						
+			// Find modified and deleted users.....
+			while(list($old_userid,$old_status) = each($old_event['participants']))
+			{
+				if(isset($new_event['participants'][$old_userid]))
+				{
+					print_debug('Modifying event for user',$old_userid);
+					$this->modified[(int)$old_userid] = $new_status;
+				}
+				else
+				{
+					print_debug('Deleting user from the event',$old_userid);
+					$this->deleted[(int)$old_userid] = $old_status;
+				}
+			}
+			// Find new users.....
+			while(list($new_userid,$new_status) = each($new_event['participants']))
+			{
+				if(!isset($old_event['participants'][$new_userid]))
+				{
+					print_debug('Adding event for user',$new_userid);
+					$this->added[$new_userid] = 'U';
+					$new_event['participants'][$new_userid] = 'U';
+				}
+			}
+			
+			if(count($this->added) > 0 || count($this->modified) > 0 || count($this->deleted) > 0)
+			{
+				if(count($this->added) > 0)
+				{
+					$this->ex_participants = '';
+					$this->send_update(MSG_ADDED,$this->added,'',$new_event);
+				}
+				if(count($this->modified) > 0)
+				{
+					$this->send_update(MSG_MODIFIED,$this->modified,$old_event,$new_event);
+				}
+				if(count($this->deleted) > 0)
+				{
+					$this->ex_participants = '';
+					$this->send_update(MSG_DELETED,$this->deleted,$old_event);
+				}
+			}
+		}
+
+		function remove_doubles_in_cache($firstday,$lastday)
+		{
+			$already_moved = Array();
+			for($v=$firstday;$v<=$lastday;$v++)
+			{
+				if (!$this->cached_events[$v])
+				{
+					continue;
+				}
+				$cached = $this->cached_events[$v];
+				$this->cached_events[$v] = array();
+				while (list($g,$event) = each($cached))
+				{
+					$end = date('Ymd',$this->maketime($event['end']));
+					print_debug('EVENT',_debug_array($event,False));
+					print_debug('start',$start);
+					print_debug('v',$v);
+
+					if (!isset($already_moved[$event['id']]) || $event['recur_type'] && $v > $end)
+					{
+						$this->cached_events[$v][] = $event;
+						$already_moved[$event['id']] = 1;
+						print_debug('Event moved');
+					}
+				}
+			}
+		}
+
+		function get_dirty_entries($lastmod=-1)
+		{
+			$events = false;
+			$event_ids = "";//$this->so->cal->list_dirty_events($lastmod);
+			if(is_array($event_ids))
+			{
+				foreach($event_ids as $key => $id)
+				{
+					$events[$id] = "";//$this->so->cal->fetch_event($id);
+				}
+			}
+			unset($event_ids);
+
+			$rep_event_ids = "";//$this->so->cal->list_dirty_events($lastmod,$true);
+			if(is_array($rep_event_ids))
+			{
+				foreach($rep_event_ids as $key => $id)
+				{
+					$events[$id] = "";//$this->so->cal->fetch_event($id);
+				}
+			}
+			unset($rep_event_ids);
+
+			return $events;
+		}
+
+		function _debug_array($data)
+		{
+			echo '<br>UI:';
+			_debug_array($data);
+		}
+
+		/*!
+		@function rejected_no_show
+		@abstract checks if event is rejected from user and he's not the owner and dont want rejected
+		@param $event to check
+		@returns True if event should not be shown
+		*/
+		function rejected_no_show($event)
+		{
+			$ret = !$this->prefs['resources']['show_rejected'] &&
+				$event['owner'] != $this->owner &&
+				$event['participants'][$this->owner] == 'R';
+			//echo "<p>rejected_no_show($event[title])='$ret': user=$this->owner, event-owner=$event[owner], status='".$event['participants'][$this->owner]."', show_rejected='".$this->prefs['resources']['show_rejected']."'</p>\n";
+			return $ret;
+		}
+
+		/* This is called only by list_cals().  It was moved here to remove fatal error in php5 beta4 */
+		function list_cals_add($id,&$users,&$groups)
+		{
+			$name = $GLOBALS['phpgw']->common->grab_owner_name($id);
+			if (($type = $GLOBALS['phpgw']->accounts->get_type($id)) == 'g')
+			{
+				$arr = &$groups;
+			}
+			else
+			{
+				$arr = &$users;
+			}
+			$arr[$name] = Array(
+				'grantor' => $id,
+				'value'   => ($type == 'g' ? 'g_' : '') . $id,
+				'name'    => $name
+			);
+		}
+
+		/*!
+		@function list_cals
+		@abstract generate list of user- / group-resourcess for the selectbox in the header
+		@returns alphabeticaly sorted array with groups first and then users
+		*/
+		function list_cals()
+		{
+			$users = $groups = array();
+			foreach($this->grants as $id => $rights)
+			{
+				$this->list_cals_add($id,$users,$groups);
+			}
+			
+			//by JakJr, melhora de performance na abertura da agenda
+			/*if ($memberships = $GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']))
+			{
+				foreach($memberships as $group_info)
+				{
+					$this->list_cals_add($group_info['account_id'],$users,$groups);
+
+					if ($account_perms = $GLOBALS['phpgw']->acl->get_ids_for_location($group_info['account_id'],PHPGW_ACL_READ,'resources'))
+					{
+						foreach($account_perms as $id)
+						{
+							$this->list_cals_add($id,$users,$groups);
+						}
+					}
+				}
+			}*/
+			uksort($users,'strnatcasecmp');
+			uksort($groups,'strnatcasecmp');
+
+			return $users + $groups;	// users first and then groups, both alphabeticaly
+		}
+
+	  function translate($key,$vars=false, $not_found='*' )
+	  {
+    	    if ($this->async)
+	      return $GLOBALS['phpgw']->translation->translate_async($key, $vars);
+	    return lang($key, $vars);
+	  }
+
+		/*!
+		@function event2array
+		@abstract create array with name, translated name and readable content of each attributes of an event
+		@syntax event2array($event,$sep='<br>')
+		@param $event event to use
+		@returns array of attributes with fieldname as key and array with the 'field'=translated name \
+			'data' = readable content (for participants this is an array !)
+		*/
+		function event2array($event)
+		{
+			
+			
+		  $var['title'] = Array(
+				'field'		=> $this->translate('Title'),
+				'data'		=> $event['title']
+			);
+
+			// Some browser add a \n when its entered in the database. Not a big deal
+			// this will be printed even though its not needed.
+			$var['description'] = Array(
+				'field'	=> $this->translate('Description'),
+				'data'	=> $event['description']
+			);
+$var['description1'] = Array(
+				'field'	=> $this->translate('Description1'),
+				'data'	=> $event['description1']
+			);
+
+
+$var['participants1'] = Array(
+				'field'	=> $this->translate('participants1'),
+				'data'	=> $event['participants1']
+			);
+
+			$var['ex_participants'] = Array(
+				'field'	=> $this->translate('External Participants'),
+				'data'	=> $event['ex_participants']
+			);
+			
+			$cats = Array();
+			$this->cat->categories($this->bo->owner,'resources');
+			if(strpos($event['category'],','))
+			{
+				$cats = explode(',',$event['category']);
+			}
+			else
+			{
+				$cats[] = $event['category'];
+			}
+			foreach($cats as $cat_id)
+			{
+				list($cat) = $this->cat->return_single($cat_id);
+				$cat_string[] = $cat['name'];
+			}
+			$var['category'] = Array(
+				'field'	=> $this->translate('Category'),
+				'data'	=> implode(', ',$cat_string)
+			);
+
+			$var['location'] = Array(
+				'field'	=> $this->translate('Location'),
+				'data'	=> $event['location']
+			);
+
+			$var['startdate'] = Array(
+				'field'	=> $this->translate('Start Date/Time'),
+				'data'	=> $GLOBALS['phpgw']->common->show_date($this->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset),
+			);
+
+			$var['enddate'] = Array(
+				'field'	=> $this->translate('End Date/Time'),
+				'data'	=> $GLOBALS['phpgw']->common->show_date($this->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset)
+			);
+
+			$pri = Array(
+				1	=> lang('Low'),
+				2	=> lang('Normal'),
+				3	=> lang('High')
+			);
+			$var['priority'] = Array(
+				'field'	=> lang('Priority'),
+				'data'	=> $pri[$event['priority']]
+			);
+
+			$var['owner'] = Array(
+				'field'	=> lang('Created By'),
+				'data'	=> $GLOBALS['phpgw']->common->grab_owner_name($event['owner'])
+			);
+
+			$var['updated'] = Array(
+				'field'	=> lang('Updated'),
+				'data'	=> $GLOBALS['phpgw']->common->show_date($this->maketime($event['modtime']) - $GLOBALS['phpgw']->datetime->tz_offset)
+			);
+
+			$var['access'] = Array(
+				'field'	=> lang('Access'),
+				'data'	=> $event['public'] ? lang('Public') : lang('Private')
+			);
+
+			if(@isset($event['groups'][0]))
+			{
+				$cal_grps = '';
+				for($i=0;$i<count($event['groups']);$i++)
+				{
+					if($GLOBALS['phpgw']->accounts->exists($event['groups'][$i]))
+					{
+						$cal_grps .= ($i>0?'<br>':'').$GLOBALS['phpgw']->accounts->id2name($event['groups'][$i]);
+					}
+				}
+
+				$var['groups'] = Array(
+					'field'	=> lang('Groups'),
+					'data'	=> $cal_grps
+				);
+			}
+
+			$participants = array();
+			foreach($event['participants'] as $user => $short_status)
+			{
+				if($GLOBALS['phpgw']->accounts->exists($user))
+				{
+					$participants[$user] = $GLOBALS['phpgw']->common->grab_owner_name($user).' ('.$this->get_long_status($short_status).')';
+				}
+			}
+			$var['participants'] = Array(
+				'field'	=> $this->translate('Participants'),
+				'data'	=> $participants
+			);
+
+			// Repeated Events
+			if($event['recur_type'] != MCAL_RECUR_NONE)
+			{
+				$str = lang($this->rpt_type[$event['recur_type']]);
+
+				$str_extra = array();
+				if ($event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['year'] != 0)
+				{
+					$recur_end = $this->maketime($event['recur_enddate']);
+					if($recur_end != 0)
+					{
+						$recur_end -= $GLOBALS['phpgw']->datetime->tz_offset;
+						$str_extra[] = lang('ends').': '.lang($GLOBALS['phpgw']->common->show_date($recur_end,'l')).', '.$this->long_date($recur_end).' ';
+					}
+				}
+				// only weekly uses the recur-data (days) !!!
+				if($event['recur_type'] == MCAL_RECUR_WEEKLY)
+				{
+					$repeat_days = array();
+					foreach ($this->rpt_day as $mcal_mask => $dayname)
+					{
+						if ($event['recur_data'] & $mcal_mask)
+						{
+							$repeat_days[] = lang($dayname);
+						}
+					}
+					if(count($repeat_days))
+					{
+						$str_extra[] = lang('days repeated').': '.implode(', ',$repeat_days);
+					}
+				}
+				if($event['recur_interval'] != 0)
+				{
+					$str_extra[] = lang('Interval').': '.$event['recur_interval'];
+				}
+
+				if(count($str_extra))
+				{
+					$str .= ' ('.implode(', ',$str_extra).')';
+				}
+
+				$var['recure_type'] = Array(
+					'field'	=> lang('Repetition'),
+					'data'	=> $str,
+				);
+			}
+
+			if (!isset($this->fields))
+			{
+				$this->custom_fields = CreateObject('resources.bocustom_fields');
+				$this->fields = &$this->custom_fields->fields;
+				$this->stock_fields = &$this->custom_fields->stock_fields;
+			}
+			foreach($this->fields as $field => $data)
+			{
+				if (!$data['disabled'])
+				{
+					if (isset($var[$field]))
+					{
+						$sorted[$field] = $var[$field];
+					}
+					elseif (!isset($this->stock_fields[$field]) && strlen($event[$field]))	// Custom field
+					{
+						$lang = lang($name = substr($field,1));
+						$sorted[$field] = array(
+							'field' => $lang == $name.'*' ? $name : $lang,
+							'data'  => $event[$field]
+						);
+					}
+				}
+				unset($var[$field]);
+			}
+			foreach($var as $name => $v)
+			{
+				$sorted[$name] = $v;
+
+			}
+			return $sorted;
+		}
+
+		/*!
+		@function check_set_default_prefs
+		@abstract sets the default prefs, if they are not already set (on a per pref. basis)
+		@note It sets a flag in the app-session-data to be called only once per session
+		*/
+		function check_set_default_prefs()
+		{
+			if (($set = $GLOBALS['phpgw']->session->appsession('default_prefs_set','resources')))
+			{
+				return;
+			}
+			$GLOBALS['phpgw']->session->appsession('default_prefs_set','resources','set');
+
+			//$default_prefs = $GLOBALS['phpgw']->preferences->default['resources']; jakjr
+
+			$subject = $this->translate('resources Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n";
+			$defaults = array(
+				'defaultresources' => 'week',
+				'mainscreen_showevents' => '0',
+				'summary'         => 'no',
+				'receive_updates' => 'no',
+				'update_format'   => 'extended',	// leave it to extended for now, as iCal kills the message-body
+				'notifyAdded'     => $subject . $this->translate ('You have a meeting scheduled for %1',array('$$startdate$$')),
+				'notifyCanceled'  => $subject . $this->translate ('Your meeting scheduled for %1 has been canceled',array('$$startdate$$')),
+				'notifyModified'  => $subject . $this->translate ('Your meeting that had been scheduled for %1 has been rescheduled to %2',array('$$olddate$$','$$startdate$$')),
+				'notifyResponse'  => $subject . $this->translate ('On %1 %2 %3 your meeting request for %4', array('$$date$$','$$fullname$$','$$action$$','$$startdate$$')),
+				'notifyAlarm'     => $this->translate('Alarm for %1 at %2 in %3',array('$$title$$','$$startdate$$','$$location$$')) . "\n" . $this->translate('Here is your requested alarm.'),
+				'show_rejected'   => '0',
+				'hide_event_conflict'   => '0',
+				'display_status'  => '1',
+				'weekdaystarts'   => 'Monday',
+				'workdaystarts'   => '9',
+				'workdayends'     => '17',
+				'interval'        => '30',
+				'defaultlength'   => '60',
+				'planner_start_with_group' => $GLOBALS['phpgw']->accounts->name2id('Default'),
+				'planner_intervals_per_day'=> '4',
+				'defaultfilter'   => 'all',
+				'default_private' => '0',
+				'display_minicals'=> '1',
+				'print_black_white'=>'0'
+			);
+			foreach($defaults as $var => $default)
+			{
+				if (!isset($default_prefs[$var]) || $default_prefs[$var] == '')
+				{
+					$GLOBALS['phpgw']->preferences->add('resources',$var,$default,'default');
+					$need_save = True;
+				}
+			}
+			if ($need_save)
+			{
+				$prefs = $GLOBALS['phpgw']->preferences->save_repository(False,'default');
+				$this->prefs['resources'] = $prefs['resources'];
+			}
+			if ($this->prefs['resources']['send_updates'] && !isset($this->prefs['resources']['receive_updates']))
+			{
+				$this->prefs['resources']['receive_updates'] = $this->prefs['resources']['send_updates'];
+				$GLOBALS['phpgw']->preferences->add('resources','receive_updates',$this->prefs['resources']['send_updates']);
+				$GLOBALS['phpgw']->preferences->delete('resources','send_updates');
+				$prefs = $GLOBALS['phpgw']->preferences->save_repository();
+			}
+		}
+
+		// return array with all resources categories (for xmlrpc)
+		function categories($complete = False)
+		{
+			return $GLOBALS['server']->categories($complete);
+		}
+/******************************************/
+
+function insert($params='')
+		{
+
+			if($params['from_mobile']) {
+				$ui_return = "mobile.ui_mobileresources.edit";
+				$ui_index = "mobile.ui_mobileresources.index";
+				$ui_overlap = "mobile.ui_mobileresources.overlap";
+			}
+			else {
+				$ui_return = "resources.uiresources.edit";
+				$ui_index = "resources.uiresources.index";		
+				$ui_overlap = "resources.uiresources.overlap";
+			}
+
+			if(!is_object($GLOBALS['phpgw']->datetime))
+			{
+				$GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time');
+			}
+			//$l_cal = (@isset($params['info_type']) && $params['info_type']?$params['info_type']:$_POST['info_type']);
+			$l_participants = (@$params['participants']?$params['participants']:$_POST['participants']);
+			$this->ex_participants = (@$params['ex_participants']?$params['ex_participants']:$_POST['ex_participants']);
+			$l_categories = (@$params['categories']?$params['categories']:$_POST['categories']);
+			$l_start = (@isset($params['start']) && $params['start']?$params['start']:$_POST['start']);
+			$l_end = (@isset($params['end']) && $params['end']?$params['end']:$_POST['end']);
+			$l_recur_enddate = (@isset($params['recur_enddate']) && $params['recur_enddate']?$params['recur_enddate']:$_POST['recur_enddate']);
+
+			
+			$send_to_ui = True;
+			//if ((!is_array($l_start) || !is_array($l_end)) && !isset($_GET['readsess']))	// xmlrpc call
+			if ($this->xmlrpc)	// xmlrpc call
+			{
+
+				$send_to_ui = False;
+
+				$l_cal = $params;	// no extra array
+
+				foreach(array('start','end','recur_enddate') as $name)
+				{
+					$var = 'l_'.$name;
+					$$var = $GLOBALS['server']->iso86012date($params[$name]);
+					unset($l_cal[$name]);
+				}
+
+				if (!is_array($l_participants) || !count($l_participants))
+				{
+					$l_participants = array($GLOBALS['phpgw_info']['user']['account_id'].'A');
+				}
+				else
+				{
+					$l_participants = array();
+					foreach($params['participants'] as $user => $data)
+					{
+						$l_participants[] = $user.$data['status'];
+					}
+				}
+
+				unset($l_cal['participants']);
+
+				if (!is_object($GLOBALS['phpgw']->categories))
+				{
+					$GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories');
+				}
+
+				$l_categories = $GLOBALS['server']->xmlrpc2cats($params['category']);
+				unset($l_cal['category']);
+
+				// using access={public|private} in all modules via xmlrpc
+				$l_cal['public'] = $params['access'] != 'private';
+				unset($l_cal['access']);
+/*
+				$fp = fopen('/tmp/xmlrpc.log','a+');
+				ob_start();
+				echo "\nboresources::update("; print_r($params); echo ")\n";
+				//echo "\nl_start="; print_r($l_start);
+				//echo "\nl_end="; print_r($l_end);
+				fwrite($fp,ob_get_contents());
+				ob_end_clean();
+				fclose($fp);
+*/
+			}
+
+			print_debug('ID',$l_cal['id']);
+
+			// don't wrap to the next day for no time
+			if ($l_end['hour'] == 24 && $l_end['min'] == 0)
+			{
+				$l_end['hour'] = 23;
+				$l_end['min'] = 59;
+			}
+
+			if(isset($_GET['readsess']))
+			{
+
+				$event = $this->restore_from_appsession();
+				$event['title'] = stripslashes($event['title']);
+				$event['description'] = stripslashes($event['description']);
+$event['description1'] = stripslashes($event['description1']);
+$event['participants1'] = stripslashes($event['participants1']);
+				$event['ex_participants'] = stripslashes($event['ex_participants']);
+				$datetime_check = $this->validate_update($event);
+				if($datetime_check)
+				{
+					ExecMethod($ui_return,
+						Array(
+							'cd'		=> $datetime_check,
+							'readsess'	=> 1
+						)
+					);
+					if(!$params['from_mobile'])
+						$GLOBALS['phpgw']->common->phpgw_exit(True);
+					else
+						return;
+				}
+				$overlapping_events = False;
+			}
+			else
+			{
+
+				if((!$l_cal['id'] && !$this->check_perms(PHPGW_ACL_ADD)) ||
+				   ($l_cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT,$l_cal['id'])))
+				{
+
+					if ($this->xmlrpc)
+					{
+						$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
+					}
+					if (!$send_to_ui)
+					{
+						return array(($l_cal['id']?1:2) => 'permission denied');
+					}
+
+					ExecMethod($ui_index);
+
+
+					if(!$params['from_mobile'])
+						$GLOBALS['phpgw']->common->phpgw_exit();
+					else
+						return;
+				}
+
+				print_debug('Prior to fix_update_time()');
+
+				$this->fix_update_time($l_start);
+
+				$this->fix_update_time($l_end);
+
+				if(!isset($l_cal['ex_participants']))
+				{
+					$l_cal['ex_participants'] = $this->ex_participants;
+				}
+
+				if(!isset($l_categories))
+				{
+					$l_categories = 0;
+				}
+
+				$is_public = ($l_cal['type'] != 'private' && $l_cal['type'] != 'privateHiddenFields');
+
+				//$this->so->event_init();
+
+			$this->add_attribute('uid',$l_cal['uid']);
+
+				$this->add_attribute('type',$l_cal['type']);
+
+				if($l_cal['ex_participants']) {
+					$this->add_attribute('ex_participants',$l_cal['ex_participants']);
+				}
+				if(count($l_categories) >= 2)
+				{
+					//$this->so->set_category(implode(',',$l_categories));
+				}
+				else
+				{
+					//$this->so->set_category(strval($l_categories[0]));
+				}
+				/*$this->so->set_title($l_cal['title']);
+				$this->so->set_description($l_cal['description']);
+$this->so->set_description1($l_cal['description1']);
+$this->so->set_participants1($l_cal['participants1']);
+				$this->so->set_ex_participants($l_cal['ex_participants']);
+				$this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0);
+				$this->so->set_end($l_end['year'],$l_end['month'],$l_end['mday'],$l_end['hour'],$l_end['min'],0);
+				$this->so->set_class($is_public);
+				$this->so->add_attribute('reference',(@isset($l_cal['reference']) && $l_cal['reference']?$l_cal['reference']:0));
+				$this->so->add_attribute('location',(@isset($l_cal['location']) && $l_cal['location']?$l_cal['location']:''));*/
+				if($l_cal['id'])
+				{
+					//$this->so->add_attribute('id',$l_cal['id']);
+				}
+
+				if($l_cal['rpt_use_end'] != 'y')
+				{
+					$l_recur_enddate['year'] = 0;
+					$l_recur_enddate['month'] = 0;
+					$l_recur_enddate['mday'] = 0;
+				}
+				elseif (isset($l_recur_enddate['str']))
+				{
+					$l_recur_enddate = $this->jscal->input2date($l_recur_enddate['str'],False,'mday');
+				}
+
+				switch((int)$l_cal['recur_type'])
+				{
+
+
+					case MCAL_RECUR_NONE:
+						//$this->so->set_recur_none();
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						break;
+					case MCAL_RECUR_DAILY:
+						//$this->so->set_recur_daily((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						$tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao;
+						$init_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_init[1]),$tmp_init[0],$tmp_init[2]); // transforma a data inicial + hora + minuto em UNIX timestamp;
+
+						if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim:
+						{
+
+							$tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao;
+							$end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp;
+
+						}else { // se nao existe data final da repeticao (agendamento infinito):
+
+							$end_rept = 0; // variavel recebe zero e nao sera adicionado nenhum alarme para o agendamento;
+						}
+						break;
+					case MCAL_RECUR_WEEKLY:
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						$tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao;
+						$init_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_init[1]),$tmp_init[0],$tmp_init[2]); // transforma a data inicial + hora + minuto em UNIX timestamp;
+
+						if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim:
+						{
+
+							$tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao;
+							$end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp;
+
+						}else { // se nao existe data final da repeticao (agendamento infinito):
+
+							$end_rept = 0; // variavel recebe zero e nao sera adicionado nenhum alarme para o agendamento;
+						}
+
+						foreach(array('rpt_sun','rpt_mon','rpt_tue','rpt_wed','rpt_thu','rpt_fri','rpt_sat') as $rpt_day)
+						{
+							$l_cal['recur_data'] += (int)$l_cal[$rpt_day];
+						}
+						if (is_array($l_cal['rpt_day']))
+						{
+							foreach ($l_cal['rpt_day'] as $mask)
+							{
+								$l_cal['recur_data'] |= (int)$mask;
+								$rpt_wdays = $l_cal['recur_data']; // recebe os dias da semana (somatorio) para repetir o alarme;
+							}
+						}
+						//$this->so->set_recur_weekly((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval'],$l_cal['recur_data']);
+						break;
+					case MCAL_RECUR_MONTHLY_MDAY:
+						//$this->so->set_recur_monthly_mday((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						$tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao;
+						$init_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_init[1]),$tmp_init[0],$tmp_init[2]); // transforma a data inicial + hora + minuto em UNIX timestamp;
+
+						if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim:
+						{
+
+							$tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao;
+							$end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp;
+
+						}else { // se nao existe data final da repeticao (agendamento infinito):
+
+							$end_rept = 0; // variavel recebe zero e nao sera adicionado nenhum alarme para o agendamento;
+						}
+						break;
+					case MCAL_RECUR_MONTHLY_WDAY:
+						//$this->so->set_recur_monthly_wday((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
+						break;
+					case MCAL_RECUR_YEARLY:
+						//$this->so->set_recur_yearly((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
+
+						$repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao;
+
+						$tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao;
+						$init_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_init[1]),$tmp_init[0],$tmp_init[2]); // transforma a data inicial + hora + minuto em UNIX timestamp;
+
+						if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim:
+						{
+
+							$tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao;
+							$end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp;
+
+						}else { // se nao existe data final da repeticao (agendamento infinito):
+
+							$end_rept = 0; // variavel recebe zero e nao sera adicionado nenhum alarme para o agendamento;
+						}
+						break;
+				}
+
+				if($l_participants)
+				{
+					$parts = $l_participants;
+					$minparts = min($l_participants);
+					$part = Array();
+					for($i=0;$i<count($parts);$i++)
+					{
+						if (($accept_type = substr($parts[$i],-1,1)) == '0' || (int)$accept_type > 0)
+						{
+							$accept_type = 'U';
+						}
+						$acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$parts[$i]);
+						if($acct_type == 'u')
+						{
+							$part[(int)$parts[$i]] = $accept_type;
+						}
+						elseif($acct_type == 'g')
+						{
+							$part[(int)$parts[$i]] = $accept_type;
+							$groups[] = $parts[$i];
+							/* This pulls ALL users of a group and makes them as participants to the event */
+							/* I would like to turn this back into a group thing. */
+							$acct = CreateObject('phpgwapi.accounts',(int)$parts[$i]);
+							$members = $acct->member((int)$parts[$i]);
+							unset($acct);
+							if($members == False)
+							{
+								continue;
+							}
+							while($member = each($members))
+							{
+								$part[$member[1]['account_id']] = $accept_type;
+							}
+						}
+					}
+				}
+				else
+				{
+					$part = False;
+				}
+
+				if($part)
+				{
+					@reset($part);
+					while(list($key,$accept_type) = each($part))
+					{
+						//$this->so->add_attribute('participants',$accept_type,(int)$key);
+					}
+				}
+
+				if($groups)
+				{
+					@reset($groups);
+					//$this->so->add_attribute('groups',(int)$group_id);
+				}
+
+				$event = $this->get_cached_event();
+				if(!is_int($minparts))
+				{
+					$minparts = $this->owner;
+				}
+				if(!@isset($event['participants'][$l_cal['owner']]))
+				{
+					//$this->so->add_attribute('owner',$minparts);
+				}
+				else
+				{
+					//$this->so->add_attribute('owner',$l_cal['owner']);
+				}
+				//$this->so->add_attribute('priority',$l_cal['priority']);
+
+				foreach($l_cal as $name => $value)
+				{
+					if ($name[0] == '#')	// Custom field
+					{
+						//$this->so->add_attribute($name,stripslashes($value));
+					}
+				}
+				if (isset($_POST['preserved']) && is_array($preserved = unserialize(stripslashes($_POST['preserved']))))
+				{
+					foreach($preserved as $name => $value)
+					{
+						switch($name)
+						{
+							case 'owner':
+								//$this->so->add_attribute('participants',$value,$l_cal['owner']);
+								break;
+							default:
+								//$this->so->add_attribute($name,str_replace(array('&amp;','&quot;','&lt;','&gt;'),array('&','"','<','>'),$value));
+						}
+					}
+				}
+				$event = $this->get_cached_event();
+
+				if ($l_cal['alarmdays'] > 0 || $l_cal['alarmhours'] > 0 ||
+						$l_cal['alarmminutes'] > 0)
+				{
+					$offset = ($l_cal['alarmdays'] * 24 * 3600) +
+						($l_cal['alarmhours'] * 3600) + ($l_cal['alarmminutes'] * 60);
+
+					$time = $this->maketime($event['start']) - $offset;
+
+					$event['alarm'][] = Array(
+						'time'    => $time,
+						'offset'  => $offset,
+						'owner'   => $this->owner,
+						'enabled' => 1,
+						'repeat'  => $repetido, // para repetir alarme;
+						'init_rept' => $init_rept, // inicio repeticao;
+						'end_rept' => $end_rept, // fim repeticao;
+						'rpt_wdays' => $rpt_wdays // dias repeticao da semana;
+					);
+				}
+
+				$this->store_to_appsession($event);
+				$datetime_check = $this->validate_update($event);
+				print_debug('bo->validated_update() returnval',$datetime_check);
+
+				/*if($datetime_check)
+				{
+
+
+					if (!$send_to_ui)
+					{
+						return array($datetime_check => 'invalid input data');
+					}
+
+
+					ExecMethod($ui_return,
+						Array(
+							'cd'		=> $datetime_check,
+							'readsess'	=> 1
+						)
+					);
+
+					if(!$params['from_mobile'])
+						$GLOBALS['phpgw']->common->phpgw_exit(True);
+					else
+						return;
+
+				}/*/
+				if($event['id'])
+				{
+					$event_ids[] = $event['id'];
+				}
+				if($event['reference'])
+				{
+					$event_ids[] = $event['reference'];
+				}
+
+				$overlapping_events = $this->overlap(
+					$this->maketime($event['start']),
+					$this->maketime($event['end']),
+					$event['participants'],
+					$event['owner'],
+					$event_ids
+				);
+			}
+			if(!$this->ex_participants)
+				$this->ex_participants = $event['ex_participants'];			
+			if($overlapping_events)
+			{
+
+
+				if($send_to_ui)
+				{
+					$event['ex_participants'] = $this->ex_participants;
+					unset($GLOBALS['phpgw_info']['flags']['noheader']);
+					unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+					ExecMethod($ui_overlap,
+						Array(
+							'o_events'	=> $overlapping_events,
+							'this_event'	=> $event
+						)
+					);
+					if(!$params['from_mobile'])
+						$GLOBALS['phpgw']->common->phpgw_exit(True);
+					else
+						return;
+				}
+				else
+				{
+					return $overlapping_events;
+				}
+			}
+			else
+			{
+
+
+
+				if(!$event['id'])
+				{
+
+
+
+					//$this->so->add_entry($event);
+					$this->send_update(MSG_ADDED,$event['participants'],'',$this->get_cached_event());
+					print_debug('New Event ID',$event['id']);
+				}
+				else
+				{
+
+					print_debug('Updating Event ID',$event['id']);
+					$new_event = $event;
+					$old_event = $this->read_entry($event['id']);
+					// if old event has alarm and the start-time changed => update them
+					//echo "<p>checking ".count($old_event['alarm'])." alarms of event #$event[id] start moved from ".print_r($old_event['start'],True)." to ".print_r($event['start'],True)."</p>\n";
+					if ($old_event['alarm'] &&
+						$this->maketime($old_event['start']) != $this->maketime($event['start']))
+					{
+						//$this->so->delete_alarms($old_event['id']);
+						foreach($old_event['alarm'] as $id => $alarm)
+						{
+							$alarm['time'] = $this->maketime($event['start']) - $alarm['offset'];
+							$event['alarm'][] = $alarm;
+						}
+						//echo "updated alarms<pre>".print_r($event['alarm'],True)."</pre>\n";
+					}
+					//$this->so->cal->event = $event;
+					//$this->so->add_entry($event);
+					$this->prepare_recipients($new_event,$old_event);
+				}
+
+				$date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']);
+				if($send_to_ui)
+				{
+					$this->read_sessiondata();
+					if ($this->return_to)
+					{
+						$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->return_to);
+						$GLOBALS['phpgw']->common->phpgw_exit();
+					}
+					Execmethod($ui_index);
+				}
+				else
+				{
+					return (int)$event['id'];
+				}
+			}
+			return True;
+		}
+
+function date_filter($name,&$start,&$end_param)
+	{
+		$end = $end_param;
+
+		if ($name == 'custom' && $start)
+		{
+			if ($end)
+			{
+				$end += 24*60*60;
+			}
+			else
+			{
+				$end = $start + 8*24*60*60;
+			}
+		}
+		else
+		{
+			if (!isset($this->date_filters[$name]))
+			{
+				return '1=1';
+			}
+			$year  = (int) date('Y',$this->today);
+			$month = (int) date('m',$this->today);
+			$day   = (int) date('d',$this->today);
+	
+			list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $this->date_filters[$name];
+			
+			if ($syear || $eyear)
+			{
+				$start = mktime(0,0,0,1,1,$syear+$year);
+				$end   = mktime(0,0,0,1,1,$eyear+$year);
+			}
+			elseif ($smonth || $emonth)
+			{
+				$start = mktime(0,0,0,$smonth+$month,1,$year);
+				$end   = mktime(0,0,0,$emonth+$month,1,$year);
+			}
+			elseif ($sday || $eday)
+			{
+				$start = mktime(0,0,0,$month,$sday+$day,$year);
+				$end   = mktime(0,0,0,$month,$eday+$day,$year);
+			}
+			elseif ($sweek || $eweek)
+			{
+				$wday = (int) date('w',$this->today); // 0=sun, ..., 6=sat
+				switch($GLOBALS['phpgw_info']['user']['preferences']['calendar']['weekdaystarts'])
+				{
+					case 'Sunday':
+						$weekstart = $this->today - $wday * 24*60*60;
+						break;
+					case 'Saturday':
+						$weekstart = $this->today - (6-$wday) * 24*60*60;
+						break;
+					case 'Moday':
+					default:
+						$weekstart = $this->today - ($wday ? $wday-1 : 6) * 24*60*60;
+						break;
+				}
+				$start = $weekstart + $sweek*7*24*60*60;
+				$end   = $weekstart + $eweek*7*24*60*60;
+			}
+			$end_param = $end - 24*60*60;
+		}
+		//echo "<p align='right'>date_filter($name,$start,$end) today=".date('l, Y-m-d H:i',$this->today)." ==> ".date('l, Y-m-d H:i:s',$start)." <= date < ".date('l, Y-m-d H:i:s',$end)."</p>\n"; 
+		// convert start + end from user to servertime for the filter
+		return '('.($start-$this->tz_offset_s).' <= ts_start AND ts_start < '.($end-$this->tz_offset_s).')';
+	}
+/***********************************************/
+	}
+?>
Index: contrib/resources/inc/class.so_resources.inc.php
===================================================================
--- contrib/resources/inc/class.so_resources.inc.php	(revision 3524)
+++ contrib/resources/inc/class.so_resources.inc.php	(revision 3524)
@@ -0,0 +1,104 @@
+<?php
+/**
+ * eGroupWare - resources
+ *
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @package resources
+ * @link http://www.egroupware.org
+ * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+ * @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
+ * @version $Id: class.so_resources.inc.php 19821 2005-11-14 18:16:56Z nelius_weiss $
+ */
+
+
+include_once(PHPGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
+
+/**
+ * General storage object for resources
+ *
+ * @author Cornelius Weiss <phpgw@von-und-zu-weiss.de>
+ * @package resources
+ */
+class so_resources extends so_sql
+{
+	function so_resources()
+	{
+		$this->so_sql('resources','phpgw_resources');
+		
+		$custom =& CreateObject('admin.customfields',$contact_app);
+		$this->customfields = $custom->get_customfields();
+		$this->soextra =& CreateObject('etemplate.so_sql');
+		$this->soextra->so_sql('resources','egw_resources_extra');
+	}
+
+	/**
+	 * gets the value of $key from resource of $res_id
+	 *
+	 * @param string $key key of value to get
+	 * @param int $res_id resource id
+	 * @return mixed value of key and resource, false if key or id not found.
+	 */
+	function get_value($key,$res_id)
+	{
+		if($this->db->select($this->table_name,$key,array('res_id' => $res_id),__LINE__,__FILE__))
+		{
+			$value = $this->db->row(row);
+			return $value[$key];
+		}
+		return false;
+	}
+	
+	/**
+	 * reads resource including custom fields
+	 *
+	 * @param interger $res_id res_id
+	 * @return array/boolean data if row could be retrived else False
+	 */
+	function read($res_id)
+	{
+		// read main data
+		$resource = parent::read($res_id);
+		
+		// read customfields
+		$keys = array(
+			'extra_id' => $res_id,
+			'extra_owner' => -1,
+		);
+		$customfields = $this->soextra->search($keys,false);
+		foreach ((array)$customfields as $field)
+		{
+			$resource['#'.$field['extra_name']] = $field['extra_value'];
+		}
+		return $resource;
+	}
+
+	/**
+	 * saves a resource including extra fields
+	 *
+	 * @param array $resource key => value 
+	 * @return mixed id of resource if all right, false if fale
+	 */
+	function save($resource)
+	{
+		$this->data = $resource;
+		if(parent::save() != 0) return false;
+		$res_id = $this->data['res_id'];
+		
+		// save customfields
+		foreach ($this->customfields as $field => $options)
+		{
+			$value = $resource['#'.$field];
+			$data = array(
+				'extra_id' => $res_id,
+				'extra_name' => $field,
+				'extra_owner' => -1,
+				'extra_value' => $value,
+			);
+			$this->soextra->data = $data;
+			$error_nr = $this->soextra->save();
+			if($error_nr) return false;
+		}
+		return $res_id;
+	}
+	
+}
Index: contrib/resources/inc/class.resources_select_widget.inc.php
===================================================================
--- contrib/resources/inc/class.resources_select_widget.inc.php	(revision 3524)
+++ contrib/resources/inc/class.resources_select_widget.inc.php	(revision 3524)
@@ -0,0 +1,106 @@
+<?php
+/**
+ * eGroupWare - eTemplate Extension - Resource Select Widgets
+ *
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @package resources
+ * @link http://www.egroupware.org
+ * @author RalfBecker-AT-outdoor-training.de
+ * @version $Id: class.resources_select_widget.inc.php 22438 2006-09-15 19:37:19Z nelius_weiss $
+ */
+
+/**
+ * eTemplate Extension: select a resource
+ *
+ * @package resources
+ */
+class resources_select_widget
+{
+	/** 
+	* exported methods of this class
+	* @var array
+	*/
+	var $public_functions = array(
+		'pre_process' => True,
+	);
+	/**
+	* availible extensions and there names for the editor
+	* @var array
+	*/
+	var $human_name = 'Select Resources';
+
+	/**
+	* Constructor of the extension
+	*
+	* @param string $ui '' for html
+	*/
+	function resources_select_widget($ui)
+	{
+		$this->ui = $ui;
+	}
+
+	/**
+	* pre-processing of the extension
+	*
+	* This function is called before the extension gets rendered
+	*
+	* @param string $name form-name of the control
+	* @param mixed &$value value / existing content, can be modified
+	* @param array &$cell array with the widget, can be modified for ui-independent widgets 
+	* @param array &$readonlys names of widgets as key, to be made readonly
+	* @param mixed &$extension_data data the extension can store persisten between pre- and post-process
+	* @param object &$tmpl reference to the template we belong too
+	* @return boolean true if extra label is allowed, false otherwise
+	*/
+	function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
+	{
+		if ($cell['readonly'] && !is_array($value))
+		{
+			// no acl check here cause names are allways viewable
+			list($res_id,$quantity) = explode(':',$value);
+			$data = ExecMethod('resources.bo_resources.get_calendar_info',$res_id);
+			$cell['type'] = 'label';
+			$value = $data[0]['name']. ($data[0]['useable'] > 1 ? ' ['. ($quantity > 1 ? $quantity : 1). '/'. $data[0]['useable']. ']' : '');
+			return true;
+		}
+		
+		if (!$GLOBALS['phpgw_info']['user']['apps']['resources'])
+		{
+			$cell = $tmpl->empty_cell();
+			$cell['label'] = 'no resources';
+			return false;
+		}
+		$tpl =& new etemplate('resources.resource_selectbox');
+		// keep the editor away from the generated tmpls
+		$tpl->no_onclick = true;			
+		
+		if ($value)
+		{
+			$value = is_array($value) ? $value : explode(',',$value);
+			foreach((array)$value as $id)
+			{
+				list($res_id,$quantity) = explode(':',$id);
+				$data = ExecMethod('resources.bo_resources.get_calendar_info',$res_id);
+				$sel_options[$data[0]['res_id'].($quantity > 1 ? (':'.$quantity) : '')] = 
+					$data[0]['name'].' ['.($quantity > 1 ? $quantity : 1).'/'.$data[0]['useable'].']';
+			}
+			$tpl->set_cell_attribute('resources','sel_options',$sel_options);
+		}
+		
+		$tpl->set_cell_attribute('resources','size',(int)$cell['size'].'+');
+		$tpl->set_cell_attribute('resources','label',$cell['label']);
+		$tpl->set_cell_attribute('resources','id','resources_selectbox');
+		$tpl->set_cell_attribute('resources','name',$cell['name']);
+		if ($cell['help'])
+		{
+			$tpl->set_cell_attribute('resources','help',$cell['help']);
+			$tpl->set_cell_attribute('popup','label',$cell['help']);
+		}
+		$cell['type'] = 'template';
+		$cell['size'] = $cell['label'] = '';
+		$cell['name'] = 'resources.resource_selectbox';
+		$cell['obj'] =& $tpl;
+
+		return True;	// extra Label Ok
+	}
+}
Index: contrib/resources/inc/class.soresources.inc.php
===================================================================
--- contrib/resources/inc/class.soresources.inc.php	(revision 3524)
+++ contrib/resources/inc/class.soresources.inc.php	(revision 3524)
@@ -0,0 +1,432 @@
+<?php
+  /**************************************************************************\
+  * eGroupWare - infolog                                                    *
+  * http://www.eGroupWare.org                                                *
+  * Maintained and further developed by RalfBecker@outdoor-training.de       *
+  * Based on Webinfolog by Craig Knudsen <cknudsen@radix.net>               *
+  *          http://www.radix.net/~cknudsen                                  *
+  * Originaly modified by Mark Peters <skeeter@phpgroupware.org>             *
+  * --------------------------------------------                             *
+  *  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.                                              *
+  \**************************************************************************/
+
+
+	class soinfolog
+	{
+//		var $debug = True;
+		var $debug = False;
+		var $cal;
+		var $db;
+		var $owner;
+		var $g_owner;
+		var $is_group = False;
+		var $datetime;
+		var $filter;
+		var $cat_id;
+		
+		function soinfolog($param)
+		{
+			$this->db = $GLOBALS['phpgw']->db;
+			if(!is_object($GLOBALS['phpgw']->datetime))
+			{
+				$GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time');
+			}
+
+			$this->owner = (!isset($param['owner']) || $param['owner'] == 0?$GLOBALS['phpgw_info']['user']['account_id']:$param['owner']);
+			$this->filter = (isset($param['filter']) && $param['filter'] != ''?$param['filter']:$this->filter);
+			$this->cat_id = (isset($param['category']) && $param['category'] != ''?$param['category']:$this->cat_id);
+			if(isset($param['g_owner']) && is_array($param['g_owner']))
+			{
+				$this->is_group = True;
+				$this->g_owner = $param['g_owner'];
+			}
+			if($this->debug)
+			{
+				echo '<!-- SO Filter : '.$this->filter.' -->'."\n";
+				echo '<!-- SO cat_id : '.$this->cat_id.' -->'."\n";
+			}
+			$this->cal = CreateObject('infolog.soinfolog_');
+			//$this->open_box($this->owner);
+		}
+		
+		// It returns uidNumber and cn ( Retorna o uidNumber e o cn )
+		function search_uidNumber($mail)
+		{
+			$connection = $GLOBALS['phpgw']->common->ldapConnect();
+			$justthese = array("uidNumber","cn","mail");
+			$search = ldap_search($connection, $GLOBALS['phpgw_info']['server']['ldap_context'], "mail=" . $mail, $justthese);
+			$result = ldap_get_entries($connection, $search);
+			ldap_close($connection);
+			return $result;
+		}
+
+		
+
+		function maketime($time)
+		{
+			return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']);
+		}
+
+		function read_entry($id)
+		{
+			return $this->cal->get_event_ids($id);
+		}
+
+		function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$owner_id=0)
+		{
+			$extra = '';
+			$extra .= (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'');
+			//$extra .= ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":'');
+			if ($this->cat_id)
+			{
+				if (!is_object($GLOBALS['phpgw']->categories))
+				{
+					$GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories');
+				}
+				$cats = $GLOBALS['phpgw']->categories->return_all_children($this->cat_id);
+				$extra .= "AND (phpgw_cal.category".(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '=\''.(int)$this->cat_id."'");
+				foreach($cats as $cat)
+				{
+					$extra .= " OR phpgw_cal.category LIKE '$cat,%' OR phpgw_cal.category LIKE '%,$cat,%' OR phpgw_cal.category LIKE '%,$cat'";
+				}
+				$extra .= ') ';
+			}
+			if($owner_id)
+			{
+				return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$GLOBALS['phpgw']->datetime->tz_offset,$owner_id);
+			}
+			else
+			{
+				return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$GLOBALS['phpgw']->datetime->tz_offset);
+			}
+		}
+
+		function list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id=0)
+		{
+			if(!$owner_id)
+			{
+				$owner_id = $this->is_group ? $this->g_owner : $this->owner;
+			}
+			if($GLOBALS['phpgw_info']['server']['infolog_type'] != 'sql' ||
+				!count($owner_id))	// happens with empty groups
+			{
+				return Array();
+			}
+
+			$starttime = mktime(0,0,0,$smonth,$sday,$syear) - $GLOBALS['phpgw']->datetime->tz_offset;
+			$endtime = mktime(23,59,59,$emonth,$eday,$eyear) - $GLOBALS['phpgw']->datetime->tz_offset;
+			$sql = "AND phpgw_cal.cal_type='M' AND phpgw_cal_user.cal_login IN (".
+				(is_array($owner_id) ? implode(',',$owner_id) : $owner_id).')';
+
+//			$member_groups = $GLOBALS['phpgw']->accounts->membership($this->user);
+//			@reset($member_groups);
+//			while(list($key,$group_info) = each($member_groups))
+//			{
+//				$member[] = $group_info['account_id'];
+//			}
+//			@reset($member);
+//			$sql .= ','.implode(',',$member).') ';
+//			$sql .= 'AND (phpgw_cal.datetime <= '.$starttime.') ';
+//			$sql .= 'AND (((phpgw_cal_repeats.recur_enddate >= '.$starttime.') AND (phpgw_cal_repeats.recur_enddate <= '.$endtime.')) OR (phpgw_cal_repeats.recur_enddate=0))) '
+			$sql .= ' AND (phpgw_cal_repeats.recur_enddate >= '.$starttime.' OR phpgw_cal_repeats.recur_enddate=0) '
+				. (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'')
+				. ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":'')
+				. 'ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
+
+			if($this->debug)
+			{
+				echo '<!-- SO list_repeated_events : SQL : '.$sql.' -->'."\n";
+			}
+
+			return $this->get_event_ids(True,$sql);
+		}
+
+		function list_events_keyword($keywords,$members='')
+		{
+			if (!$members)
+			{
+				$members[] = $this->owner;
+			}
+			$sql = 'AND (phpgw_cal_user.cal_login IN ('.implode(',',$members).')) AND '.
+				'(phpgw_cal_user.cal_login=' . (int)$this->owner . ' OR phpgw_cal.is_public=1) AND (';
+
+			$words = split(' ',$keywords);
+			foreach($words as $i => $word)
+			{
+				$sql .= $i > 0 ? ' OR ' : '';
+				$sql .= "(UPPER(phpgw_cal.title) LIKE UPPER('%".addslashes($word)."%') OR "
+						. "UPPER(phpgw_cal.description) LIKE UPPER('%".addslashes($word)."%') OR "
+						. "UPPER(phpgw_cal.location) LIKE UPPER('%".addslashes($word)."%') OR "
+						. "UPPER(phpgw_cal_extra.cal_extra_value) LIKE UPPER('%".addslashes($word)."%'))";
+			}
+			$sql .= ') ';
+
+			$sql .= (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'');
+			$sql .= ($this->cat_id? "AND (phpgw_cal.category='$this->cat_id' OR phpgw_cal.category like '%,".$this->cat_id.",%') ":'');
+			$sql .= 'ORDER BY phpgw_cal.datetime DESC, phpgw_cal.edatetime DESC, phpgw_cal.priority ASC';
+
+			return $this->get_event_ids(False,$sql,True);
+		}
+
+		function read_from_store($startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endDay='')
+		{
+			$events = $this->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay);
+			$events_cached = Array();
+			for($i=0;$i<count($events);$i++)
+			{
+				$events_cached[] = $this->read_entry($events[$i]);
+			}
+			return $events_cached;
+		}
+
+		function get_event_ids($search_repeats=False, $sql='',$search_extra=False)
+		{
+			return $this->cal->get_event_ids($search_repeats,$sql,$search_extra);
+		}
+
+		function find_uid($uid)
+		{
+			$sql = " AND (phpgw_cal.uid = '".$uid."') ";
+
+			$found = $this->cal->get_event_ids(False,$sql);
+			if(!$found)
+			{
+				$found = $this->cal->get_event_ids(True,$sql);
+			}
+			if(is_array($found))
+			{
+				return $found[0];
+			}
+			else
+			{
+				return False;
+			}
+		}
+
+		function add_entry(&$event)
+		{
+			return $this->cal->save_event($event);
+		}
+
+		function save_alarm($cal_id,$alarm,$id=0)
+		{
+			return $this->cal->save_alarm($cal_id,$alarm,$id);
+		}
+
+		function delete_alarm($id)
+		{
+			return $this->cal->delete_alarm($id);
+		}
+
+		function delete_alarms($cal_id)
+		{
+			return $this->cal->delete_alarms($cal_id);
+		}
+
+		function delete_entry($id)
+		{
+			return $this->cal->delete_event($id);
+		}
+
+		function expunge()
+		{
+			$this->cal->expunge();
+		}
+
+		function delete_infolog($owner)
+		{
+			$this->cal->delete_infolog($owner);
+		}
+
+		function change_owner($account_id,$new_owner)
+		{
+			if($GLOBALS['phpgw_info']['server']['infolog_type'] == 'sql')
+			{
+				$db2 = $this->cal->stream;
+				$this->cal->stream->query('SELECT cal_id FROM phpgw_cal_user WHERE cal_login='.$account_id,__LINE__,__FILE__);
+				while($this->cal->stream->next_record())
+				{
+					$id = $this->cal->stream->f('cal_id');
+					$db2->query('SELECT count(*) FROM phpgw_cal_user WHERE cal_id='.$id.' AND cal_login='.$new_owner,__LINE__,__FILE__);
+					$db2->next_record();
+					if($db2->f(0) == 0)
+					{
+						$db2->query('UPDATE phpgw_cal_user SET cal_login='.$new_owner.' WHERE cal_id='.$id.' AND cal_login='.$account_id,__LINE__,__FILE__);
+					}
+					else
+					{
+						$db2->query('DELETE FROM phpgw_cal_user WHERE cal_id='.$id.' AND cal_login='.$account_id,__LINE__,__FILE__);
+					}
+				}
+				$this->cal->stream->query('UPDATE phpgw_cal SET owner='.$new_owner.' WHERE owner='.$account_id,__LINE__,__FILE__);
+			}
+		}
+
+		function set_status($id,$status)
+		{
+			$this->cal->set_status($id,$this->owner,$status);
+		}
+
+		function get_alarm($cal_id)
+		{
+			if (!method_exists($this->cal,'get_alarm'))
+			{
+				return False;
+			}
+			return $this->cal->get_alarm($cal_id);
+		}
+
+		function read_alarm($id)
+		{
+			if (!method_exists($this->cal,'read_alarm'))
+			{
+				return False;
+			}
+			return $this->cal->read_alarm($id);
+		}
+
+		function read_alarms($cal_id)
+		{
+			if (!method_exists($this->cal,'read_alarms'))
+			{
+				return False;
+			}
+			return $this->cal->read_alarms($cal_id);
+		}
+
+		function find_recur_exceptions($event_id)
+		{
+			if($GLOBALS['phpgw_info']['server']['infolog_type'] == 'sql')
+			{
+				$arr = Array();
+				$this->cal->query('SELECT datetime FROM phpgw_cal WHERE reference='.$event_id,__LINE__,__FILE__);
+				if($this->cal->num_rows())
+				{
+					while($this->cal->next_record())
+					{
+						$arr[] = (int)$this->cal->f('datetime');
+					}
+				}
+				if(count($arr) == 0)
+				{
+					return False;
+				}
+				else
+				{
+					return $arr;
+				}
+			}
+			else
+			{
+				return False;
+			}
+		}
+
+		/* Begin mcal equiv functions */
+		function get_cached_event()
+		{
+			return $this->cal->event;
+		}
+		
+		function add_attribute($var,$value,$element='**(**')
+		{
+			$this->cal->add_attribute($var,$value,$element);
+		}
+
+		function event_init()
+		{
+			$this->cal->event_init();
+		}
+
+		function set_date($element,$year,$month,$day=0,$hour=0,$min=0,$sec=0)
+		{
+			$this->cal->set_date($element,$year,$month,$day,$hour,$min,$sec);
+		}
+
+		function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0)
+		{
+			$this->cal->set_start($year,$month,$day,$hour,$min,$sec);
+		}
+
+		function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0)
+		{
+			$this->cal->set_end($year,$month,$day,$hour,$min,$sec);
+		}
+
+		function set_title($title='')
+		{
+			$this->cal->set_title($title);
+		}
+function set_access($access='')
+		{
+			$this->cal->set_access($access);
+		}
+
+		function set_description($description='')
+		{
+			$this->cal->set_description($description);
+		}
+function set_description1($description1='')
+		{
+			$this->cal->set_description1($description1);
+		}
+function set_participants1($participants1='')
+		{
+			$this->cal->set_participants1($participants1);
+		}
+		function set_ex_participants($ex_participants='')
+		{
+			$this->cal->set_ex_participants($ex_participants);
+		}
+
+		function set_class($class)
+		{
+			$this->cal->set_class($class);
+		}
+
+		function set_category($category='')
+		{
+			$this->cal->set_category($category);
+		}
+
+		function set_alarm($alarm)
+		{
+			$this->cal->set_alarm($alarm);
+		}
+
+		function set_recur_none()
+		{
+			$this->cal->set_recur_none();
+		}
+
+		function set_recur_daily($year,$month,$day,$interval)
+		{
+			$this->cal->set_recur_daily($year,$month,$day,$interval);
+		}
+
+		function set_recur_weekly($year,$month,$day,$interval,$weekdays)
+		{
+			$this->cal->set_recur_weekly($year,$month,$day,$interval,$weekdays);
+		}
+
+		function set_recur_monthly_mday($year,$month,$day,$interval)
+		{
+			$this->cal->set_recur_monthly_mday($year,$month,$day,$interval);
+		}
+
+		function set_recur_monthly_wday($year,$month,$day,$interval)
+		{
+			$this->cal->set_recur_monthly_wday($year,$month,$day,$interval);
+		}
+
+		function set_recur_yearly($year,$month,$day,$interval)
+		{
+			$this->cal->set_recur_yearly($year,$month,$day,$interval);
+		}
+		
+		/* End mcal equiv functions */
+	}
+?>
Index: contrib/resources/inc/class.ui_acl.inc.php
===================================================================
--- contrib/resources/inc/class.ui_acl.inc.php	(revision 3524)
+++ contrib/resources/inc/class.ui_acl.inc.php	(revision 3524)
@@ -0,0 +1,138 @@
+<?php
+/**
+ * eGroupWare - resources
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
+ * @package resources
+ * @link http://www.egroupware.org
+ * @version $Id: class.ui_acl.inc.php 22893 2006-12-07 08:12:19Z nelius_weiss $
+ */
+
+/**
+ * ACL userinterface object for resources
+ *
+ * @package resources
+ */
+class ui_acl
+{
+	var $start = 0;
+	var $query = '';
+	var $sort  = '';
+	var $order = '';
+	var $bo;
+	var $nextmatchs = '';
+	var $rights;
+	var $public_functions = array(
+		'acllist' 	=> True,
+		);
+
+	function ui_acl()
+	{
+		$this->bo =& createobject('resources.bo_acl',True);
+		$this->nextmatchs =& createobject('phpgwapi.nextmatchs');
+		$this->start = $this->bo->start;
+		$this->query = $this->bo->query;
+		$this->order = $this->bo->order;
+		$this->sort = $this->bo->sort;
+		$this->cat_id = $this->bo->cat_id;
+	}
+	
+	function acllist()
+	{
+		if (!$GLOBALS['phpgw']->acl->check('run',1,'admin'))
+		{
+			$this->deny();
+		}
+
+		if ($_POST['btnDone'])
+		{
+			$GLOBALS['phpgw']->redirect_link('/admin/index.php');
+		}
+
+		$GLOBALS['phpgw']->common->phpgw_header();
+		echo parse_navbar();
+
+		if ($_POST['btnSave'])
+		{
+			foreach($_POST['catids'] as $cat_id)
+			{
+				$this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id],
+					$_POST['inputcalread'][$cat_id],$_POST['inputcalbook'][$cat_id],$_POST['inputadmin'][$cat_id]);
+			}
+		}
+
+		$GLOBALS['phpgw']->template->set_file('acl', 'acl.tpl');
+		$GLOBALS['phpgw']->template->set_block('acl','cat_list','Cblock');
+		$GLOBALS['phpgw']->template->set_var(array(
+			'title' => $GLOBALS['phpgw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'),
+			'lang_search' => lang('Search'),
+			'lang_save' => lang('Save'),
+			'lang_done' => lang('Done'),
+			'lang_read' => lang('Read permissions'),
+			'lang_write' => lang('Write permissions'),
+			'lang_implies_read' => lang('implies read permission'),
+			'lang_calread' => lang('Read Calendar permissions'),
+			'lang_calbook' => lang('Direct booking permissions'),
+			'lang_implies_book' => lang('implies booking permission'),
+			'lang_cat_admin' => lang('Categories admin')
+		));
+
+		$left  = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
+		$right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
+		
+		$GLOBALS['phpgw']->template->set_var(array(
+			'left' => $left,
+			'right' => $right,
+			'lang_showing' => $this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start),
+			'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
+			'sort_cat' => $this->nextmatchs->show_sort_order(
+				$this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=resources.uiacl.acllist'
+			),
+			'query' => $this->query,
+		));
+
+		@reset($this->bo->cats);
+		while (list(,$cat) = @each($this->bo->cats))
+		{
+			$this->rights = $this->bo->get_rights($cat['id']);
+
+			$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+			$GLOBALS['phpgw']->template->set_var(array(
+				'tr_color' => $tr_color,
+				'catname' => $cat['name'],
+				'catid' => $cat['id'],
+				'read' => $this->selectlist(phpgw_ACL_READ),
+				'write' => $this->selectlist(phpgw_ACL_ADD),
+				'calread' => $this->selectlist(phpgw_ACL_CALREAD),
+				'calbook' =>$this->selectlist(phpgw_ACL_DIRECT_BOOKING),
+				'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(phpgw_ACL_CAT_ADMIN,true)
+			));
+			$GLOBALS['phpgw']->template->parse('Cblock','cat_list',True);
+		}
+		$GLOBALS['phpgw']->template->pfp('out','acl',True);
+	}
+
+	function selectlist($right,$users_only=false)
+	{
+		foreach ($GLOBALS['phpgw']->accounts->get_list() as $num => $account)
+		{
+			if(!($users_only && $account['account_lastname'] == 'Group'))
+			{
+				$selectlist .= '<option value="' . $account['account_id'] . '"';
+					if($this->rights[$account['account_id']] & $right)
+				{
+					$selectlist .= ' selected="selected"';
+				}
+				$selectlist .= '>' . $account['account_firstname'] . ' ' . $account['account_lastname']
+									. ' [ ' . $account['account_lid'] . ' ]' . '</option>' . "\n";
+			}
+		}
+		return $selectlist;
+	}
+
+	function deny()
+	{
+		echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
+		$GLOBALS['phpgw']->common->phpgw_exit(True);
+	}
+}
Index: contrib/resources/sitemgr/class.module_resources.inc.php
===================================================================
--- contrib/resources/sitemgr/class.module_resources.inc.php	(revision 3524)
+++ contrib/resources/sitemgr/class.module_resources.inc.php	(revision 3524)
@@ -0,0 +1,25 @@
+<?php
+	/**
+	 * eGroupWare - resources
+	 * http://www.egroupware.org 
+	 *
+	 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+	 * @package resources
+	 * @author Cornelius Weiss <egw@von-und-zu-weiss.de>
+	 * @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
+	 * @version $Id: class.module_resources.inc.php 19735 2005-11-10 23:35:55Z nelius_weiss $
+	 */
+	
+	require_once (EGW_INCLUDE_ROOT.'/etemplate/inc/class.sitemgr_module.inc.php');
+	
+	class module_resources extends sitemgr_module
+	{
+		function module_resources()
+		{
+			$this->arguments = array();
+			$this->properties = array();
+			$this->title = lang('Resources');
+			$this->description = lang('This module displays the resources app');
+			$this->etemplate_method = 'resources.ui_resources.index';
+		}
+	}
Index: contrib/resources/fix_lost_links.php
===================================================================
--- contrib/resources/fix_lost_links.php	(revision 3524)
+++ contrib/resources/fix_lost_links.php	(revision 3524)
@@ -0,0 +1,42 @@
+<?php
+/**
+ * TimeSheet - fixing links lost by the bug in the links-class
+ *
+ * @link http://www.egroupware.org
+ * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
+ * @package timesheet
+ * @copyright (c) 2005 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @version $Id$ 
+ */
+
+$GLOBALS['phpgw_info'] = array(
+	'flags' => array(
+		'currentapp'	=> 'admin', 
+));
+include('../header.inc.php');
+
+require_once(PHPGW_INCLUDE_ROOT.'/timesheet/inc/class.botimesheet.inc.php');
+
+$bots =& new botimesheet();
+$so_sql =& new so_sql('timesheet',$bots->table_name);
+
+// search timesheet which have a project-field identical to an exiting PM project, but no link to it
+$rows = $so_sql->search(false,'ts_id,ts_project,ts_title','','pm_id,link_id','',false,'AND',false,array('link_id IS NULL'),
+	' JOIN phpgw_pm_projects ON ts_project='.$so_sql->db->concat('pm_number',"': '",'pm_title').
+	" LEFT JOIN phpgw_links ON (link_app1='timesheet' AND link_id1=ts_id AND link_app2='projectmanager' AND link_id2=pm_id".
+	" OR link_app1='projectmanager' AND link_id1=pm_id AND link_app2='timesheet' and link_id2=ts_id)");
+
+echo "<h1>Fixing links to ProjectManager lost by the bug in the links-class</h1>\n";
+
+if ($rows)
+{
+	foreach($rows as $row)
+	{
+		if ($bots->link->link('timesheet',$row['ts_id'],'projectmanager',$row['pm_id']))
+		{
+			echo "<p>relinked timesheet '$row[ts_title]' with project '$row[ts_project]'</p>\n";
+		}
+	}
+}
+echo "<h3>".(is_array($rows) ? count($rows) : 0)." missing links found.</h3>\n";
Index: contrib/resources/index.php
===================================================================
--- contrib/resources/index.php	(revision 3524)
+++ contrib/resources/index.php	(revision 3524)
@@ -0,0 +1,35 @@
+<?php
+/**
+ * TimeSheet - index
+ *
+ * @link http://www.egroupware.org
+ * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
+ * @package timesheet
+ * @copyright (c) 2005 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @version $Id: index.php 22356 2006-08-26 16:32:29Z ralfbecker $ 
+ */
+
+
+
+
+	$phpgw_flags = Array(
+		'currentapp'	=>	'resources',
+		'noheader'	=>	True,
+		'nonavbar'	=>	True,
+		'noappheader'	=>	True,
+		'noappfooter'	=>	True,
+		'nofooter'	=>	True
+	);
+
+	$GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
+	include('../header.inc.php');
+	
+
+
+
+	ExecMethod('resources.uiresources.index',$parms);
+	$GLOBALS['phpgw']->common->phpgw_exit();
+
+?>
+
Index: contrib/resources/templates/default/form_button_script.tpl
===================================================================
--- contrib/resources/templates/default/form_button_script.tpl	(revision 3524)
+++ contrib/resources/templates/default/form_button_script.tpl	(revision 3524)
@@ -0,0 +1,12 @@
+
+<!-- BEGIN form_button -->
+<nobr>
+<form action="{action_url_button}" method="post" name="{action_text_button}form">
+<div style="padding-top:15px; padding-right: 2px">
+	{action_extra_field} 
+	<input id="{button_id}" style="font-size:10px" type="submit" value="{action_text_button}" {action_confirm_button}>
+</div>
+</form>
+</nobr>
+
+<!-- END form_button -->
Index: contrib/resources/templates/default/locales.tpl
===================================================================
--- contrib/resources/templates/default/locales.tpl	(revision 3524)
+++ contrib/resources/templates/default/locales.tpl	(revision 3524)
@@ -0,0 +1,60 @@
+<!-- BEGIN list -->
+<p>
+ <table border="0" width="45%" align="center">
+  <tr>
+   <td align="left">{left_next_matchs}</td>
+   {center}
+   <td align="right">{right_next_matchs}</td>
+  </tr>
+ </table>
+
+ <table border="0" width="70%" align="center">
+  <tr bgcolor="{th_bg}">
+   <td>&nbsp;{sort_name}</td>
+   {header_rule}
+   <td>{header_edit}</td>
+   <td>{header_delete}</td>
+   <td>{header_extra}</td>
+  </tr>
+
+  {rows}
+
+ </table>
+
+ <table border="0" width="70%" cellspacing="5" align="center">
+  <tr>
+   <td align="left">
+    <form method="POST" action="{new_action}">
+     <input type="submit" value="{lang_add}">
+    </form>
+   </td>
+   {back_button}
+   <td width="80%" align="right">
+    <form method="POST" action="{search_action}">
+     {lang_search}&nbsp;<input name="query">
+    </form>
+   </td>
+  </tr>
+ </table>
+<!-- END list -->
+<!-- BEGIN row -->
+ <tr bgcolor="{tr_color}">
+  <td>&nbsp;{group_name}</td>
+  {rule}
+  <td width="5%">{edit_link}</td>
+  <td width="5%">{delete_link}</td>
+  <td align="center" {extra_width}>{extra_link}</td>
+ </tr>
+<!-- END row -->
+<!-- BEGIN row_empty -->
+   <tr>
+    <td colspan="5" align="center">{message}</td>
+   </tr>
+<!-- END row_empty -->
+<!-- BEGIN back_button_form -->
+   <td align="center">
+    <form method="POST" action="{back_action}">
+     <input type="submit" value="{lang_back}">
+    </form>
+   </td>
+<!-- END back_button_form -->
Index: contrib/resources/templates/default/app_print.css
===================================================================
--- contrib/resources/templates/default/app_print.css	(revision 3524)
+++ contrib/resources/templates/default/app_print.css	(revision 3524)
@@ -0,0 +1,294 @@
+/* Este documento é um css somente para impressão do calendário no papel!
+O seu efeito não aparece na tela  */
+
+.calendar_print_main {
+	text-align:center;
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	font-size: 8px;
+	color: #000066;
+	background-color: #F7F7F7;
+	border: 1px solid #CCCCCC;
+	margin: 5px;
+	padding: 5px;
+	height: 700px;
+	width: 600px;
+}
+.button {
+	display: none;
+}
+
+
+.to_continue
+{
+	font-size: 9px;
+}
+
+A.minicalendar 
+{ 
+	color: #000000; 
+	font-size: 9px;
+	
+}
+
+A.bminicalendar 
+{ 
+	color: #336699; 
+	font-style: italic;
+	font-weight: bold;
+	font-size: 9px; 
+}
+
+A.minicalendargrey 
+{ 
+	color: #999999; 
+	font-size: 10px;
+	font-weight: bold;
+}
+
+A.bminicalendargrey 
+{ 
+	color: #336699; 
+	font-style: italic; 
+	font-size:10px; 
+}
+
+A.minicalhol
+{ 
+	padding-left:3px;
+	padding-right:3px;
+	background: #dab0b0;
+	color: #000000; 
+	font-size: 10px; 
+}
+
+A.bminicalhol
+{ 
+	padding-left:3px;
+	padding-right:3px;
+	background: #dab0b0;
+	color: #336699; 
+	font-size: 10px; 
+}
+
+A.minicalgreyhol
+{ 
+	padding-left:3px;
+	padding-right:3px;
+	background: #dab0b0;
+	color: #999999; 
+	font-size: 10px; 
+}
+
+A.bminicalgreyhol
+{ 
+	padding-left:3px;
+	padding-right:3px;
+	background: #dab0b0;
+	color: #999999; 
+	font-size: 10px; 
+}
+
+
+.event-on
+{ 
+	background: #D3DCE3;
+	border: #E8F0F0 1px solid;
+}
+
+.event-off
+{ 
+	background: #E8F0F0;
+	border: #D3DCE3 1px solid;
+}
+
+.event-holiday
+{
+	font-size: 100%;
+	background: #dac0c0;
+	color:#000000;
+	vertical-align: middle;
+}
+
+.time
+{
+	background: #D3DCE3;
+	color:#000000;
+	font-size: 10px;
+	font-weight: bold;
+	vertical-align: middle;
+	width: 5.2%;
+	text-align: right;
+	padding-right: 5px;
+	line-height: 11px;
+	border: #E8F0F0 1px solid;
+}
+
+
+.planner-cell
+{
+	cursor: pointer;
+	cursor: hand;
+	border: thin solid black;
+}
+
+/* common */
+.calendar_link_print
+{
+	text-align: center;
+	font-size: 10px;
+}
+
+//Mini Calendar
+
+.calendar_minical_table
+{
+	width: 180px;
+	font-weight: bold;
+}
+
+.calendar_minical_daytable
+{
+	width: 100%;
+}
+
+.calendar_minical_dayname
+{
+	font-size: 9px;
+	text-align: right;
+}
+
+.calendar_minical_hrule
+{
+	width: 96%;
+}
+
+/* Header */
+.calendar_dropbuttons
+{
+	align: center;
+	text-align: center;
+	vertical-align: bottom;
+	font-weight: bold;
+	font-size: 8px;
+}
+
+.calendar-weekidentifier
+{
+	font-size:16px;
+	font-weight: bold;
+	text-align: center;
+}
+
+.calendar_header
+{
+	font-size: 16px;
+	font-weight: bold;
+	text-align: center;
+}
+
+.calendar_dayview_table_header
+{
+	font-size: 13px;
+	font-weight: bold;
+	text-align: center;
+}
+
+.calendar_dayview_todo_header
+{
+	margin: 0px; 
+	padding: 2px;
+	font-weight: bold;
+}
+
+/* week view */
+.calendar_week_identifier_table
+{
+	border: 0px solid black;
+	width: 100%;
+}
+
+.calendar_week_identifier
+{
+	font-size: 13px;
+	text-align: center;
+	font-weight: bold;
+}
+
+.calendar_weekview_daytitle
+{
+	font-weight: bold;
+	font-size: 12px;
+	background: #D3DCE3;
+}
+
+.calendar_m_w_table
+{
+	table-layout:fixed;
+	overflow:hidden;
+	height: 90%;
+	width: 100%;
+	border: 0px #000000 solid;
+}
+
+.calendar_m_w_tablecell
+{
+	overflow:hidden;
+	vertical-align: top;
+	padding-left: 4px;
+	padding-right: 4px;
+	padding-bottom: 6px;
+	border: 1px solid #000000;
+}
+
+.screen_only
+{
+	display:none;
+}
+
+.calendar_m_w_table_daynumber
+{
+	font-weight: bold;
+	font-family: Arial;
+	font-size: 10px;
+	vertical-align: top;
+	background-color: #778899;
+	border: 1px solid #000000;
+	margin: 1px;
+	padding: 1px;
+}
+
+A.event_entry
+{
+	font-size:10px;
+}
+
+/* month view */
+
+.calendar_month_identifier
+{
+	font-size:18px;
+	font-weight: bold;
+}
+
+.calendar_user_identifier
+{
+	font-size:12px;
+	color: #009999;
+	font-weight: bold;
+}
+
+.calendar_week_minical_table
+{
+	width:100%;
+	border: 0px solid #000000
+}
+
+.calendar_weekinfo
+{
+	color: #000000;
+	padding-left: 2px;
+	padding-right: 2px;
+	font-size: 10px;
+	font-weight: bold;
+	font-style: italic;
+}
Index: contrib/resources/templates/default/csv_import.tpl
===================================================================
--- contrib/resources/templates/default/csv_import.tpl	(revision 3524)
+++ contrib/resources/templates/default/csv_import.tpl	(revision 3524)
@@ -0,0 +1,74 @@
+<!-- BEGIN filename -->
+	  		<TR>
+	    		<TD>{lang_csvfile}</td>
+				<td><INPUT NAME="csvfile" SIZE=30 TYPE="file" VALUE="{csvfile}"></td>
+			</tr>
+			<tr>
+				<td>{lang_fieldsep}</td>
+				<td><input name="fieldsep" size=1 value="{fieldsep}"></td>
+			</tr>
+			<tr>
+				<td>{lang_charset}</td>
+				<td>
+			{select_charset}
+				</td>
+			</tr>
+			<tr><td>&nbsp;</td>
+				<td><INPUT NAME="convert" TYPE="submit" VALUE="{submit}"></TD>
+			</TR>
+<!-- END filename -->
+
+<!-- BEGIN fheader -->
+			<tr>
+				<td><b>{lang_csv_fieldname}</b></td>
+				<td><b>{lang_info_fieldname}</b></td>
+				<td><b>{lang_translation}</b></td>
+			</tr>
+<!-- END fheader -->
+
+<!-- BEGIN fields -->
+			<tr>
+				<td>{csv_field}</td>
+				<td><SELECT name="cal_fields[{csv_idx}]">{cal_fields}</select></td>
+				<td><input name="trans[{csv_idx}]" size=60 value="{trans}"></td>
+			</tr>
+<!-- END fields -->
+
+<!-- BEGIN ffooter -->
+			<tr>
+				<td rowspan="2" valign="middle" nowrap><br>{submit}</TD>
+				<td colspan="2"><br>
+					{lang_start} <INPUT name="start" type="text" size="5" value="{start}"> &nbsp; &nbsp;
+					{lang_max} <INPUT name="max" type="text" size="3" value="{max}"><td>
+			</tr>
+			<tr>
+				<td colspan="2"><INPUT name="debug" type="checkbox" value="1"{debug}> {lang_debug}</td>
+			</TR>
+			<tr><td colspan="3">&nbsp;<p>
+				{help_on_trans}
+			</td></tr>
+<!-- END ffooter -->
+
+<!-- BEGIN imported -->
+			<tr>
+				<td colspan=2 align=center>
+					{log}<p>
+					{anz_imported}
+				</td>
+			</TR>
+<!-- END imported -->
+
+<!-- BEGIN import -->
+<br/>
+<center>
+		<form {enctype} action="{action_url}" method="post">
+		<table>
+
+		{rows}
+
+		</table>
+		{hiddenvars}
+		</form>
+
+</center>
+<!-- END import -->
Index: contrib/resources/templates/default/listUsers.php
===================================================================
--- contrib/resources/templates/default/listUsers.php	(revision 3524)
+++ contrib/resources/templates/default/listUsers.php	(revision 3524)
@@ -0,0 +1,167 @@
+<?php			
+	
+	$GLOBALS['phpgw_info']['flags'] = array(
+		'noheader' => True,
+		'nonavbar' => True,
+		'currentapp' => 'calendar'		
+	);
+	
+	include('../../../header.inc.php');
+	include('../../../phpgwapi/templates/default/head.inc.php');
+
+	$owner = $GLOBALS['_GET']['owner'];
+	
+	if(!@is_object($GLOBALS['phpgw']->js))	{
+		$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
+	}
+	
+	$GLOBALS['phpgw']->js->validate_file('jscode','scripts','preferences');		
+	$t = &$GLOBALS['phpgw']->template;						
+	// seta o Template
+	$t->set_file(array('addUser_t' => '../../../calendar/templates/default/listUsers.tpl'));
+	
+	$obj_account = CreateObject('phpgwapi.accounts',$this->bo->owner);
+
+	$post_select_organization = $_POST['select_organization'];
+	$post_select_sector = $_POST['select_sector'];
+	$change_organization = $_POST['change_organization'];
+	
+	$obj_org_sector = CreateObject('phpgwapi.sector_search_ldap');
+	if ((!$post_select_organization) && (!$post_select_sector)) //primeira vez
+	{
+		$user_org = $obj_account->get_organization($GLOBALS['phpgw_info']['user']['account_dn']);
+		$user_sector = $obj_account->get_sector($GLOBALS['phpgw_info']['user']['account_dn']);
+		$user_context = $obj_account->get_context($GLOBALS['phpgw_info']['user']['account_dn']);
+		
+		$organizations_info = $obj_org_sector->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']);
+		@asort($organizations_info);
+		@reset($organizations_info);					
+		$sectors_info = $obj_org_sector->sector_search('ou='.$user_org.','.$GLOBALS['phpgw_info']['server']['ldap_context']);
+	}
+	else //mudou uma das combos
+	{
+		$user_org = $post_select_organization;
+		$user_sector = $post_select_sector;
+		if ($change_organization == "True")
+			$user_context = 'ou='.$user_org.','.$GLOBALS['phpgw_info']['server']['ldap_context'];
+		else
+			$user_context = $post_select_sector;
+		$organizations_info = $obj_org_sector->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']);
+		@asort($organizations_info);
+		@reset($organizations_info);					
+		$sectors_info = $obj_org_sector->sector_search('ou='.$user_org.','.$GLOBALS['phpgw_info']['server']['ldap_context']);
+	}
+		
+	foreach($organizations_info as $organization)
+	{
+		$combo_organization .= '<option value="' . $organization . '"'; 	
+		
+		if (!$post_select_organization)
+		{
+			if(strtolower($organization) == strtolower($user_org))
+			{
+				$combo_organization .= ' selected';
+			}
+		}
+		else
+		{
+			if(strtolower($organization) == strtolower($post_select_organization))
+			{
+				$combo_organization .= ' selected';
+			}
+		}	
+		$combo_organization .= '>' .$organization.'</option>'."\n";
+	}
+	
+	$combo_sector .= '<option value="ou='.$user_org.','.$GLOBALS['phpgw_info']['server']['ldap_context'].'"> --------- </option>'."\n";
+	foreach($sectors_info as $sector)
+	{
+		if ($sector->sector_level == 1)
+		{
+			$sector->sector_name = '- '.$sector->sector_name;
+		}
+		else
+		{
+			$sector_space = '';
+			for ($i=1; $i < $sector->sector_level; $i++)
+				$sector_space = '---'.$sector_space;
+			$sector->sector_name = $sector_space.' '.$sector->sector_name;
+		}
+	
+		$combo_sector .= '<option value="' . $sector->sector_context . '"';
+
+		if (!$post_select_sector)
+		{
+			if($sector->sector_name == $user_sector)
+				$combo_sector .= ' selected';
+		}
+		else
+		{
+			if($sector->sector_context == $post_select_sector)
+				$combo_sector .= ' selected';
+		}
+		$combo_sector .= '>' .$sector->sector_name.'</option>'."\n";
+	}			
+	
+	// Monta lista de Grupos e Usuários
+	$users = Array();
+	$groups = Array();
+
+	$ds = $GLOBALS['phpgw']->common->ldapConnect();
+    if ($ds) 
+    {
+		$sr=ldap_list($ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g))"));
+		$info = ldap_get_entries($ds, $sr);
+		for ($i=0; $i<$info["count"]; $i++)
+			$groups[$uids=$info[$i]["gidnumber"][0]] = Array('name'	=>	$uids=$info[$i]["cn"][0], 'type'	=>	g);
+
+		$sr=ldap_list($ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(cn=lista*)))"));
+		$info = ldap_get_entries($ds, $sr);
+		for ($i=0; $i<$info["count"]; $i++)
+		{
+			if ($info[$i]["phpgwaccountvisible"][0] == '-1')
+				continue;
+			$users[$uids=$info[$i]["uidnumber"][0]] = Array('name'	=>	$uids=$info[$i]["cn"][0], 'type'	=>	u);
+		}
+	}
+	ldap_close($ds);
+    	
+	@asort($users);
+	@reset($users);	
+	@asort($groups);
+	@reset($groups);
+
+	$options ='';
+	if(count($groups))
+		$options .= '<option  value="-1" disabled>--------------------&nbsp;&nbsp;&nbsp;&nbsp;Grupos&nbsp;&nbsp;&nbsp;&nbsp;------------------- </option>'."\n";
+		
+	foreach($groups as $id => $user_array) {
+			$newId = $id.'U';
+			$options .= '<option  value="'.$newId.'">'.utf8_decode($user_array['name']).$array_app.'</option>'."\n";
+	}
+	
+	if(count($users))
+		$options .= '<option  value="-1" disabled>-------------------&nbsp;&nbsp;&nbsp;&nbsp;Usuários&nbsp;&nbsp;&nbsp;&nbsp;------------------ </option>'."\n";
+	
+	foreach($users as $id => $user_array) {
+		if($owner != $id){
+			$newId = $id.'U';
+			$options .= '<option  value="'.$newId.'">'.utf8_decode($user_array['name']).$array_app.'</option>'."\n";
+		}
+	}
+
+	$t->set_var ('lang_Organization',lang('Organization'));
+	$t->set_var ('lang_Sector',lang('Sector'));
+	$t->set_var ('lang_Calendar',lang('Calendar'));
+	$t->set_var ('lang_Add_Participants',lang('Add Participants'));
+	$t->set_var ('lang_to_Search',lang('to Search'));
+	$t->set_var ('lang_Close',lang('Close'));
+	$t->set_var ('lang_Add',lang('Add'));
+	
+	$t->set_var('options',$options);
+	$t->set_var('combo_organization', $combo_organization);
+	$t->set_var('combo_sector', $combo_sector);
+	$t->parse('out','addUser_t',true);
+	$t->p('out');
+	$GLOBALS['phpgw']->common->phpgw_exit();	
+?>
Index: contrib/resources/templates/default/month.tpl
===================================================================
--- contrib/resources/templates/default/month.tpl	(revision 3524)
+++ contrib/resources/templates/default/month.tpl	(revision 3524)
@@ -0,0 +1,6 @@
+
+<table id="calendar_month_table" width="100%" border="0" bordercolor="#FFFFFF" cellspacing="2" cellpadding="2" cols={cols}>
+	{row}
+</table>
+
+
Index: contrib/resources/templates/default/viewDocument.tpll
===================================================================
--- contrib/resources/templates/default/viewDocument.tpll	(revision 3524)
+++ contrib/resources/templates/default/viewDocument.tpll	(revision 3524)
@@ -0,0 +1,499 @@
+<!-- BEGIN main -->
+
+<table width="100%" border="0" cellspacing="0" cellpading="0" bgcolor="white" hheight="100px">
+	<tr class="topRow">
+		<th width="33%">{download}</th>
+		<th width="33%">{view_online}</th>
+		<th width="33%">{delete}</th>
+	</tr>
+</table>
+<br>
+<table width="100%" border="0" cellspacing="0" cellpading="0">
+	<tr>
+		<th width="20%" id="tab1" class="activetab" onclick="javascript:tab.display(1);"><a href="#" tabindex="0" accesskey="1" onfocus="tab.display(1);" onclick="tab.display(1); return(false);" style="font-size:10px;">{lang_informations}</a></th>
+		<th width="20%" id="tab2" class="activetab" onclick="javascript:tab.display(2);"><a href="#" tabindex="0" accesskey="2" onfocus="tab.display(2);" onclick="tab.display(2); return(false);" style="font-size:10px;">{lang_all_versions}</a></th>
+		<th width="20%" id="tab3" class="activetab" onclick="javascript:tab.display(3);"><a href="#" tabindex="0" accesskey="3" onfocus="tab.display(3);" onclick="tab.display(3); return(false);" style="font-size:10px;">{lang_linked_documents}</a></th>
+		<th width="20%" id="tab4" class="activetab" onclick="javascript:tab.display(4);"><a href="#" tabindex="0" accesskey="4" onfocus="tab.display(4);" onclick="tab.display(4); return(false);" style="font-size:10px;">{lang_notifications}</a></th>
+		<th width="20%" id="tab5" class="activetab" onclick="javascript:tab.display(5);"><a href="#" tabindex="0" accesskey="5" onfocus="tab.display(5);" onclick="tab.display(5); return(false);" style="font-size:10px;">{lang_acl}</a></th>
+	</tr>
+</table>
+<div style="border-left: dotted 1px grey; border-bottom: dotted 1px grey; border-right: dotted 1px grey; background: white;">
+<div id="tabcontent1" class="inactivetab" bgcolor="white">
+	{informations}
+</div>
+
+<div id="tabcontent2" class="inactivetab">
+
+	<table cellspacing="5" cellpadding="0" border="0" width="100%">
+		<tr>
+			<td></td>
+			<td></td>
+			<td class="filelist" style="border-bottom: 1pt solid #000080;"><i>{lang_version}</i></td>
+			<td rowspan="{rownum}" style="border-left: 1pt solid #000080;">&nbsp;</td>
+			<td class="filelist" style="border-bottom: 1pt solid #000080;"><i>{lang_upload_date}</i></td>
+			<td rowspan="{rownum}" style="border-left: 1pt solid #000080;">&nbsp;</td>
+			<td class="filelist" style="border-bottom: 1pt solid #000080;"><i>{lang_comment}</i></td>
+			<td rowspan="{rownum}" style="border-left: 1pt solid #000080;">&nbsp;</td>
+			<td class="filelist" style="border-bottom: 1pt solid #000080;"><i>{lang_uploaded_by}</i></td>
+			<!-- if (($document->getAccessMode($user) >= M_READWRITE) && (count($versions) > 1))
+ -->
+			<td></td>
+		</tr>
+		{versions}
+	</table>
+</div>
+
+<div id="tabcontent3" class="inactivetab">
+<!--
+<table cellspacing="5" cellpadding="0" border="1">
+	<?
+	if ($rownum > 1)
+	{
+		?>
+		<tr>
+		<td></td>
+		<td class="filelist" style="border-bottom: 1pt solid #000080;"><i><?printMLText("name");?></i></td>
+		<td rowspan="<?print $rownum;?>" style="border-left: 1pt solid #000080;">&nbsp;</td>
+		<td class="filelist" style="border-bottom: 1pt solid #000080;"><i><?printMLText("comment");?></i></td>
+		<td rowspan="<?print $rownum;?>" style="border-left: 1pt solid #000080;">&nbsp;</td>
+		<td class="filelist" style="border-bottom: 1pt solid #000080;"><i><?printMLText("document_link_by");?></i></td>
+		<td rowspan="<?print $rownum;?>" style="border-left: 1pt solid #000080;">&nbsp;</td>
+		<td class="filelist" style="border-bottom: 1pt solid #000080;"><i><?printMLText("document_link_public");?></i></td>
+		<td></td>
+		</tr>
+		<?
+		foreach($links as $link)
+		{
+			$responsibleUser = $link->getUser();
+			$targetDoc = $link->getTarget();
+			
+			print "<tr>";
+			print "<td><img src=\"images/file.gif\" width=18 height=18 border=0></td>";
+			print "<td class=\"linklist\"><a href=\"out.ViewDocument.php?documentid=".$targetDoc->getID()."\" class=\"linklist\">".$targetDoc->getName()."</a></td>";
+			print "<td class=\"linklist\">".$targetDoc->getComment()."</td>";
+			print "<td class=\"linklist\">".$responsibleUser->getFullName()."</td>";
+			print "<td class=\"linklist\">" . (($link->isPublic()) ? getMLText("yes") : getMLText("no")) . "</td>";
+			print "<td>";
+			if (($user->getID() == $responsibleUser->getID()) || ($user->getID() == $settings->_adminID) || ($link->isPublic() && ($document->getAccessMode($user) >= M_READWRITE )))
+				print "<a href=\"../op/op.RemoveDocumentLink.php?documentid=".$documentid."&linkid=".$link->getID()."\"><img src=\"images/del.gif\" border=0></a>";
+			print "</td>";
+			print "</tr>";
+		}
+	}
+	else
+		print "<tr><td class=\"filelist\">".getMLText("no_document_links")."</td></tr>";
+	?>
+</table>
+
+
+if ($user->getID() != $settings->_guestID)
+
+	<form action="../op/op.AddDocumentLink.php" name="form1">
+	<input type="Hidden" name="documentid" value="<?print $documentid;?>">
+	<table>
+		<tr>
+			<td class="inputDescription"><?printMLText("choose_target_document");?>:</td>
+			<td><?printDocumentChooser("form1");?></td>
+		</tr>
+		<?
+			if ($document->getAccessMode($user) >= M_READWRITE)
+			{
+				print "<tr><td class=\"inputDescription\">".getMLText("document_link_public")."</td><td class=\"inputDescription\">";
+				print "<input type=\"Radio\" name=\"public\" value=\"true\" checked>" . getMLText("yes") . "&nbsp;&nbsp;";
+				print "<input type=\"Radio\" name=\"public\" value=\"false\">" . getMLText("no");
+				print "</td></tr>";
+			}
+		?>
+		<tr>
+			<td colspan="2"><br><input type="Submit" value="<?printMLText("add_document_link");?>"></td>
+		</tr>
+	</table>
+	</form>-->
+</div>
+
+<div id="tabcontent4" class="inactivetab">
+	<table cellspacing="0" cellpadding="5" border="0" width="100%">
+		<tr>
+			<td style="border-bottom: 1pt solid #000080;" width="50px">&nbsp;</td>
+			<td style="border-bottom: 1pt solid #000080;" class="notifylist"><i>{lang_name}</i></td>
+			<td style="border-bottom: 1pt solid #000080;" width="50px">&nbsp;</td>
+		</tr>
+		{notifications}
+		<tr>
+			<td colspan="3">&nbsp;</td>
+		</tr>
+	</table>
+
+	<form action="{notify_form_action}" method="post" name="notify_form">
+		<fieldset><legend>{lang_add_notification}</legend>
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td class="inputDescription">{lang_user}:</td>
+				<td>
+					{select_userid}
+				</td>
+			</tr>
+			<tr>
+				<td class="inputDescription">{lang_group}:</td>
+				<td>
+					{select_groupid}
+				</td>
+			</tr>
+		</table>
+		</fieldset>
+	</form>
+</div>
+
+<div id="tabcontent5" class="inactivetab">
+	{change_owner}
+	{display_acl}
+</div>
+
+<div id="tabcontent6" class="inactivetab">
+	<form enctype="multipart/form-data" name="update_file_form" method="post" action="{action_update_file}">
+	<table cellpadding="5" cellspacing="0" border="0" width="100%">
+		<tr class="row_on">
+			<td class="description" valign="top" width="150px">{lang_filename}:</td>
+			<td class="infos" colspan="2"><input type="file" name="userfile"></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_comment}:</td>
+			<td class="infos" colspan="2"><textarea name="comment" style="width: 100%;"></textarea></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_expires}:</td>
+			<td class="infos" valign="top" colspan="2">
+				{select_expire_update}
+				<span id="jscalspan_update" class="{expire_class_update}">{expire_date_update}</span>
+			</td>
+		</tr>
+		<tr>
+			<td colspan="3" valign="top">
+				<input type="submit" name="save" value="{lang_update}">
+				<button type="button" name="cancel" value="{lang_cancel}" onClick="javascript:tab.display(1);">
+					{lang_cancel}
+				</button>
+			</td>
+		</tr>
+	</table>
+	</form>
+</div>
+
+
+
+</div>
+<!-- END main -->
+
+<!-- BEGIN lock_row -->
+	<tr class="row_off">
+		<td class="description" valign="top">{lang_lock_status}:</td>
+		<td class="infos" colspan="2">
+			<input id="lockStatus" type="hidden" name="lockStatus" value="unchanged">
+			<input type="checkbox" onchange="javascript:toggleLock(this);" {checked_lock_status}>
+			<div id="currentLockStatus" class="active">
+				{lang_current_status}
+			</div>
+			<div id="lockFile" class="inactive">
+				{lang_file_gets_unlocked}
+			</div>
+			<div id="unlockFile" class="inactive">
+				{lang_file_gets_locked}
+			</div>
+		</td>
+	</tr>
+<!-- END lock_row -->
+
+<!-- BEGIN version_row -->
+	<tr>
+		<td>
+			{url_view_online}
+		</td>
+		<td>
+			<a href="{url_download_file}" class="oldcontent"><img src="{download_image}" width=22 height=22 border=0 title="{lang_download}"></a>
+		</td>
+		<td class="filelist" align="center">{version_version}</td>
+		<td class="filelist">{version_date}</td>
+		<td class="filelist">{version_comment}</td>
+		<td class="filelist">{version_uploadingUser}</td>
+		<td>{url_delete_file}</td>
+	</tr>
+<!-- END version_row -->
+
+<!-- BEGIN information_ro -->
+	<table cellpadding="5" cellspacing="0" border="0" width="100%">
+		<tr>
+			<td class="infos" valign="top" width="150px">{lang_filename}:</td>
+			<td style="border-left: 1pt solid #000080;" rowspan="14" width="1px">&nbsp;</td>
+			<td class="infos">{filename}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_owner}:</td>
+			<td class="infos">
+				<a class="infos" href="mailto:{owner_email}">{owner_fullname}</a>
+			</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_comment}:</td>
+			<td class="infos">{comment}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_creation_date}:</td>
+			<td class="infos">{creation_date}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_keywords}:</td>
+			<td class="infos">{keywords}</td>
+		</tr>
+		{locking}
+		<tr>
+			<td>&nbsp;</td>
+			<td>&nbsp;</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_last_update}</td>
+			<td class="infos">{last_update}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_current_version}:</td>
+			<td class="infos">{current_version}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_comment_for_current_version}:</td>
+			<td class="infos" valign="top">{current_comment}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_uploaded_by}:</td>
+			<td class="infos">
+				<a class="infos" href="mailto:{updater_email}">{updater_fullname}</a>
+			</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_file_size}:</td>
+			<td class="infos">{file_size} bytes</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_mime_type}:</td>
+			<td class="infos">
+				<img align="absmiddle" src="images/icons/<?print getMimeIcon($latestContent->getFileType());?>"> 
+				{mime_type}
+			</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_expires}:</td>
+			<td class="infos" valign="top">
+				{expire_date_ro}
+			</td>
+		</tr>
+	</table>
+<!-- END information_ro -->
+
+<!-- BEGIN information_rw -->
+	<form name="info_form" method="post" action="{action_informations}">
+	<fieldset><legend>{lang_general_information}</legend>
+	<table cellpadding="5" cellspacing="0" border="0" width="100%">
+		<tr class="row_on">
+			<td class="description" valign="top" width="150px">{lang_filename}:</td>
+			<td class="infos"><input style="width: 100%; border: dotted 1px silver;" type="text" name="fname" value="{filename}"></td>
+			<td align="center" width="150px"><a href="#" tabindex="0" onfocus="tab.display(6);" onclick="tab.display(6); return(false);" style="font-size:10px;">{lang_update_document}</a></td>
+		</tr>
+		<tr class="row_off">
+			<td class="description" valign="top" width="150px">{lang_folder}:</td>
+			<td class="infos">
+				<input id="targetname" style="width: 100%; border: dotted 1px silver;" type="text" name="targetname" value="{foldername}" disabled>
+				<input type="hidden" id="targetid" name="targetid" value="unchanged">
+			</td>
+			<td align="center" width="150px"><a href="#" onclick="selectFolder({current_folder_id},'info_form'); return(false);" style="font-size:10px;">{lang_move_document}</a></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_owner}:</td>
+			<td class="infos" colspan="2">
+				<a class="infos" href="mailto:{owner_email}">{owner_fullname}</a>
+			</td>
+		</tr>
+		<tr class="row_off">
+			<td class="description" valign="top">{lang_creation_date}:</td>
+			<td class="infos" colspan="2">{creation_date}</td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_comment}:</td>
+			<td class="infos" colspan="2"><textarea name="comment" style="width: 100%;">{comment}</textarea></td>
+		</tr>
+		<tr class="row_off">
+			<td class="description" valign="top">{lang_keywords}:</td>
+			<td class="infos" colspan="2"><textarea name="keywords" style="width: 100%;">{keywords}</textarea></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_expires}:</td>
+			<td class="infos" valign="top" colspan="2">
+				{select_expire}
+				<span id="jscalspan" class="{expire_class}">{expire_date}</span>
+			</td>
+		</tr>
+		{locking}
+		<tr class="row_on">
+			<td colspan="3" valign="top">
+				<input type="submit" name="save" value="{lang_save}">
+				<button type="button" name="cancel" value="{lang_cancel}" onClick="window.close()">
+					{lang_cancel}
+				</button>
+			</td>
+		</tr>
+	</table>
+	</fieldset>
+
+	<fieldset><legend>{lang_information_about_last_update}</legend>
+	<table cellpadding="5" cellspacing="0" border="0" width="100%">
+		<tr class="row_on">
+			<td class="description" valign="top" width="150px">{lang_last_update}</td>
+			<td class="infos">{last_update}</td>
+			<td class="description" valign="top" width="150px">{lang_current_version}:</td>
+			<td class="infos">{current_version}</td>
+		</tr>
+		<tr class="row_off">
+			<td class="description" valign="top">{lang_uploaded_by}:</td>
+			<td class="infos">
+				<a class="infos" href="mailto:{updater_email}">{updater_fullname}</a>
+			</td>
+			<td class="description" valign="top">{lang_file_size}:</td>
+			<td class="infos">{file_size} bytes</td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_comment_for_current_version}:</td>
+			<td class="infos" valign="top" colspan="3">{current_comment}</td>
+		</tr>
+		<tr>
+			<td class="description" valign="top">{lang_mime_type}:</td>
+			<td class="infos" colspan="3">
+				<img align="absmiddle" src="images/icons/<?print getMimeIcon($latestContent->getFileType());?>"> 
+				{mime_type}
+			</td>
+		</tr>
+	</table>
+	</fieldset>
+	</form>
+<!-- END information_rw -->
+
+<!-- BEGIN block_download -->
+<a href="{download_link}"><img src="{download_image}" align="middle" border="0">{lang_download}</a>
+<!-- END block_download -->
+
+<!-- BEGIN block_view_online -->
+<a target="_blank" href="{view_link}"><img src="{view_image}" align="middle" border="0">{lang_view_online}</a>
+<!-- END block_view_online -->
+
+<!-- BEGIN block_delete -->
+<a href="{delete_link}" onClick="return confirm('{lang_confirm_delete}');"><img src="{delete_image}" align="middle" border="0">{lang_delete}</a>
+<!-- END block_delete -->
+
+<!-- BEGIN notification_row -->
+	<tr>
+		<td><img src="{notify_image}" width=16 height=16></td>
+		<td class="notifylist">{notify_username}</td>
+		<td align="right"><a href="{link_notify_delete}"><img title="{lang_delete_this_notification}" src="{delete_image}" width=15 height=15 border=0></a>
+	</tr>
+<!-- END notification_row -->
+
+<!-- BEGIN block_change_owner -->
+	<form name="change_owner" action="{action_change_owner}" method="post">
+		<fieldset><legend>{lang_owner}</legend>
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td>
+					{select_ownerid}
+				</td>
+				<td><input type="Submit"></td>
+			</tr>
+		</table>
+		</fieldset>
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td>&nbsp;</td>
+			</tr>
+		</table>
+	</form>
+<!-- END block_change_owner -->
+
+<!-- BEGIN block_acl_inherite -->
+	<fieldset><legend>{lang_acl}</legend>
+	<div>{lang_acl_get_inherited}</div>
+	<p>
+	<a href="{link_acl_copy}">{lang_copy_acl}</a><br>
+	<a href="{link_acl_empty}">{lang_create_empty_acl}</a><br>
+	</fieldset>
+<!-- END block_acl_inherite -->
+
+<!-- BEGIN block_acl_notinherite -->
+	<fieldset><legend>{lang_acl}</legend>
+	<div>{lang_inherite_acl_again}</div>
+	<p>
+	<a href="{link_acl_inherit_again}">{lang_inherit_acl_again}</a><br>
+
+	<fieldset><legend>{lang_default_access}</legend>
+	<form name="change_default_access" action="{action_change_default_access}" method="post">
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td>
+					{select_default_access}
+				</td>
+			</tr>
+		</table>
+	</form>
+	</fieldset>
+
+	<fieldset><legend>{lang_current_acl}</legend>
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td></td>
+				<td class="accessList" style="border-bottom: 1pt solid #000080;"><i>{lang_name}</i></td>
+				<!-- <td rowspan="<?print $rownum;?>" style="border-left: 1pt solid #000080;">&nbsp;</td> -->
+				<td class="accessList" style="border-bottom: 1pt solid #000080;"><i>{lang_access_mode}</i></td>
+				<td></td>
+				<td></td>
+			</tr>
+			{acls}
+		</table>
+	</fieldset>
+
+	<fieldset><legend>{lang_add_acl}</legend>
+	<form name="add_acl" action="{action_add_acl}" method="post">
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td class="inputDescription">{lang_user}:</td>
+				<td>
+					{select_add_acl_userid}
+				</td>
+				<td rowspan="3">
+					<input type="Submit">
+				</td>
+			</tr>
+			<tr>
+				<td class="inputDescription">{lang_group}:</td>
+				<td>
+					{select_add_acl_groupid}
+				</td>
+			</tr>
+			<tr>
+				<td class="inputDescription">{lang_permission}:</td>
+				<td>
+					{select_add_acl_permission}
+				</td>
+			</tr>
+		</table>
+	</form>
+	</fieldset>
+
+	</fieldset>
+<!-- END block_acl_notinherite -->
+
+<!-- BEGIN acl_row -->
+	<form method="post" action="{action_acl_row}">
+	<tr>
+		<td width="20px"><img src="{acl_image}" width=16 height=16></td>
+		<td class="acllist">{acl_username}</td>
+		<td class="acllist" width="310px">{acl_selectbox}</td>
+		<td width="20px"><input type="Image" src="{save_image}" alt="{lang_save}"></td>
+		<td width="20px" align="right"><a href="{link_acl_delete}" onClick="return confirm('{lang_confirm_acl_delete}');"><img title="{lang_delete_this_acl}" alt="{lang_delete}" src="{delete_image}" width=15 height=15 border=0></a>
+	</tr>
+	</form>
+<!-- END acl_row -->
+
Index: contrib/resources/templates/default/edit.xet
===================================================================
--- contrib/resources/templates/default/edit.xet	(revision 3524)
+++ contrib/resources/templates/default/edit.xet	(revision 3524)
@@ -0,0 +1,163 @@
+<?xml version="1.0"?>
+<!-- $Id: edit.xet 23270 2007-01-12 01:27:37Z ralfbecker $ -->
+<overlay>
+	<template id="timesheet.edit.general" template="" lang="" group="0" version="1.3.001">
+		<grid width="100%" height="150">
+			<columns>
+				<column width="95"/>
+				<column width="120"/>
+				<column width="80"/>
+				<column/>
+			</columns>
+			<rows>
+				<row class="row">
+					<description options=",,,ts_title" value="Title"/>
+					<textbox size="65" maxlength="80" id="ts_title" blur="@ts_title_blur" span="all"/>
+				</row>
+				<row class="row">
+					<description options=",,,cat_id" value="Category"/>
+					<menulist span="all">
+						<menupopup type="select-cat" id="cat_id" options="None"/>
+					</menulist>
+				</row>
+				<row class="row">
+					<description options=",,,ts_start" value="Date"/>
+					<date id="ts_start" needed="1" options=",8"/>
+					<description value="Starttime"/>
+					<date-timeonly id="start_time"/>
+				</row>
+				<row class="row">
+					<description options=",,,ts_duration" value="Duration"/>
+					<date-duration id="ts_duration" options=",hm"/>
+					<description value="or endtime" class="noWrap"/>
+					<date-timeonly id="end_time"/>
+				</row>
+				<row class="row">
+					<description options=",,,ts_quantity" value="Quantity"/>
+					<textbox type="float" id="ts_quantity" statustext="empty if identical to duration" blur="@ts_quantity_blur" precision="3" span="all"/>
+				</row>
+			</rows>
+		</grid>
+	</template>
+	<template id="timesheet.edit.notes" template="" lang="" group="0" version="0.1.001">
+		<grid width="100%" height="150">
+			<columns>
+				<column/>
+			</columns>
+			<rows>
+				<row class="row" valign="top">
+					<textbox multiline="true" rows="8" cols="70" id="ts_description"/>
+				</row>
+			</rows>
+		</grid>
+	</template>
+	<template id="timesheet.edit.links" template="" lang="" group="0" version="0.1.001">
+		<grid width="100%" height="150" overflow="auto">
+			<columns>
+				<column width="100"/>
+				<column/>
+			</columns>
+			<rows>
+				<row class="th" disabled="@view">
+					<description span="all" value="Create new links"/>
+				</row>
+				<row class="row" disabled="@status_only">
+					<link-to span="all" id="link_to"/>
+				</row>
+				<row class="th">
+					<description span="all" value="Existing links"/>
+				</row>
+				<row class="row_off" valign="top">
+					<link-list span="all" id="link_to"/>
+				</row>
+			</rows>
+		</grid>
+	</template>
+	<template id="timesheet.edit" template="" lang="" group="0" version="1.3.002">
+		<grid width="100%">
+			<columns>
+				<column width="100"/>
+				<column/>
+			</columns>
+			<rows>
+				<row disabled="!@msg">
+					<description span="all" class="redItalic" id="msg" no_lang="1" align="center"/>
+					<description/>
+				</row>
+				<row class="th" height="28">
+					<description options=",,,ts_owner" value="User"/>
+					<menulist span="all">
+						<menupopup id="ts_owner" no_lang="1"/>
+					</menulist>
+				</row>
+				<row class="row">
+					<description options=",,,ts_project" value="Project"/>
+					<grid spacing="1" padding="1">
+						<columns>
+							<column/>
+						</columns>
+						<rows>
+							<row disabled="@pm_integration=none">
+								<projectmanager-select options="None" id="pm_id" span="all" statustext="Select a project" onchange="1"/>
+							</row>
+							<row disabled="@pm_integration=full">
+								<textbox id="ts_project" blur="@ts_project_blur" size="65" maxlength="80"/>
+							</row>
+						</rows>
+					</grid>
+				</row>
+				<row class="row">
+					<description options=",,ts_unitprice" value="Unitprice"/>
+					<grid>
+						<columns>
+							<column disabled="@pm_integration=none"/>
+							<column/>
+						</columns>
+						<rows>
+							<row>
+								<projectmanager-pricelist id="pl_id" options="None,all_pm_ids,ts_unitprice" onchange="this.form['exec[ts_unitprice]'].value=this.options[this.selectedIndex].text.lastIndexOf('(') &lt; 0 ? '' : this.options[this.selectedIndex].text.slice(this.options[this.selectedIndex].text.lastIndexOf('(')+1,-1);"/>
+								<textbox type="float" id="ts_unitprice" span="all"/>
+							</row>
+						</rows>
+					</grid>
+				</row>
+				<row>
+					<tabbox span="all">
+						<tabs>
+							<tab label="General" statustext=""/>
+							<tab label="Notes" statustext=""/>
+							<tab label="Links" statustext=""/>
+						</tabs>
+						<tabpanels>
+							<template id="timesheet.edit.general"/>
+							<template id="timesheet.edit.notes"/>
+							<template id="timesheet.edit.links"/>
+						</tabpanels>
+					</tabbox>
+				</row>
+				<row class="row" disabled="!@ts_modified">
+					<description value="Last modified"/>
+					<hbox>
+						<date-time id="ts_modified" readonly="true"/>
+						<menulist>
+							<menupopup type="select-account" id="ts_modifier" label="by" readonly="true"/>
+						</menulist>
+					</hbox>
+				</row>
+				<row>
+					<hbox options="0" span="2" orient="0">
+						<hbox>
+							<button label="Edit" id="button[edit]" statustext="Edit this entry"/>
+							<button id="button[save_new]" label="Save &amp; New" statustext="Saves this entry and add a new one"/>
+							<button id="button[save]" label="Save" statustext="Saves the changes made"/>
+							<button id="button[apply]" label="Apply" statustext="Applies the changes made"/>
+							<button id="button[cancel]" label="Cancel" statustext="closes the window without saving the changes" onclick="window.close();"/>
+							<html id="js"/>
+						</hbox>
+						<button label="Delete" align="right" id="button[delete]" statustext="Delete this entry" onclick="return confirm('Delete this entry');"/>
+					</hbox>
+				</row>
+			</rows>
+		</grid>
+	</template>
+</overlay>
Index: contrib/resources/templates/default/search2.tpl
===================================================================
--- contrib/resources/templates/default/search2.tpl	(revision 3524)
+++ contrib/resources/templates/default/search2.tpl	(revision 3524)
@@ -0,0 +1,174 @@
+<!-- BEGIN search -->
+
+<script language="Javascript">
+  
+    function submitit(form,campo)
+{
+
+ var texto;
+ 
+texto=document.form.start.value;
+
+
+      var url = document.location.href;
+
+      partes = url.split('/');
+
+      page=partes[partes.length-1];
+
+      partes2=page.split('&');
+
+     
+form.action=page+'&fecha='+texto;
+form.action='index.php?menuaction=resources.uiresources.search2&fecha='+texto+'&'+partes2[partes2.length-1];
+//self.location.href=page+'&fecha='+texto;
+form.submit();
+	//form.submit_button.value = '';
+	return false;
+	
+}
+ 
+</script>
+<center>
+
+<table id="calendar_search_table" width="90%">
+
+<tr><td align=left>
+<form  METHOD=POST name="form">
+<input type=hidden name=ordena value="">
+	<table><tr class="th">
+	
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Nombre</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Descripci&oacute;n</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+	
+	
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Ubicaci&oacute;n</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Grupos</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+	<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Prioridad</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Public</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Fecha
+
+<input id="start[str]" name="start" size="10"  onchange="return submitit(this.form)" type="text">
+<script type="text/javascript">
+	document.writeln('<img id="start[str]-trigger" src="phpgwapi/templates/default/images/datepopup.gif" title="Seleccionar fecha" style="cursor:pointer; cursor:hand;"/>');
+	Calendar.setup(
+	{
+		inputField  : "start[str]",
+		button      : "start[str]-trigger"
+	}
+	);
+</script>
+
+</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Due&ntilde;o</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+					
+	
+	</tr>
+
+	<tr>
+		<td colspan="2" align="center" bgcolor="{th_bg}">
+			<b></b>
+		</td>
+	</tr>
+	{rows}
+</form>
+</table>
+<!-- END search -->
+
+<!-- BEGIN search_list_header -->
+
+<!-- END search_list_header -->
+
+<!-- BEGIN search_list -->
+	<tr bgcolor="{tr_color}">
+		
+<td>	{name}</td>
+<td>{description}</td>
+<td>	{location}</td>
+<td>	{groups}</td>
+<td>	{priority}</td>
+<td>	{ispublic}</td>
+<td>	{fecha}</td>
+<td>{owner}</td>
+
+
+
+
+	</tr>
+<!-- END search_list -->
+
+<!-- BEGIN search_list_footer -->
+
+<!-- END search_list_footer -->
Index: contrib/resources/templates/default/header.inc.php
===================================================================
--- contrib/resources/templates/default/header.inc.php	(revision 3524)
+++ contrib/resources/templates/default/header.inc.php	(revision 3524)
@@ -0,0 +1,54 @@
+<?php
+  /**************************************************************************\
+  * eGroupWare                                                               *
+  * http://www.egroupware.org                                                *
+  * --------------------------------------------                             *
+  *  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.                                              *
+  \**************************************************************************/
+
+
+	function add_col(&$tpl,$str)
+	{
+		$tpl->set_var('str',$str);
+		$tpl->parse('header_column','head_col',True);
+	}
+
+	function add_image_ahref($link,$image,$alt)
+	{
+		return '<a href="'.$link.'"><img src="'.$GLOBALS['phpgw']->common->image('calendar',$image).'" alt="'.$alt.'" title="'.$alt.'" border="0"></a>';
+	}
+
+	$refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']);
+	$referrer = $refer[2];
+
+	$templates = Array(
+		'head_tpl'	=> 'head.tpl',
+		'form_button_dropdown'	=> 'form_button_dropdown.tpl',
+		'form_button_script'	=> 'form_button_script.tpl'
+	);
+	$tpl->set_file($templates);
+	$tpl->set_block('head_tpl','head','head');
+	$tpl->set_block('head_tpl','head_table','head_table');
+	$tpl->set_block('head_tpl','head_col','head_col');
+	$tpl->set_block('form_button_script','form_button');
+
+	
+		$tpl->set_var('cols',3);
+	
+
+	$today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
+
+	//$col_width = 12;
+//add_col($tpl,'  <td >&nbsp;</td>');
+
+
+	$tpl->parse('row','head_table',True);
+
+	$tpl->set_var('header_column','');
+	$tpl->set_var('cols',$cols);
+
+	
+?>
Index: contrib/resources/templates/default/holiday.tpl
===================================================================
--- contrib/resources/templates/default/holiday.tpl	(revision 3524)
+++ contrib/resources/templates/default/holiday.tpl	(revision 3524)
@@ -0,0 +1,33 @@
+<!-- BEGIN form -->
+<center>
+{message}<br>
+<table border="0" width="80%" cellspacing="2" cellpadding="2"> 
+ <form name="form" action="{actionurl}" method="POST">
+  {hidden_vars}
+{rows}
+ <tr>
+  <td colspan="2">
+   <table width="100%" border="0" cellspacing="5">
+    <tr>
+     <td>
+      <input type="submit" name="submit" value="{lang_add}"></form>
+     </td>
+     <td>
+      {cancel_button}
+     </td>
+     <td align="right" width="80%">
+      {delete_button}
+     </td>
+    </tr>
+   </table>
+  <td>
+ </tr>
+</table>
+</center>
+<!-- END form -->
+<!-- BEGIN list -->
+ <tr bgcolor="{tr_color}">
+  <td valign="top" width="35%"><b>{field}:</b></td>
+  <td valign="top" width="65%">{data}</td>
+ </tr>
+<!-- END list -->
Index: contrib/resources/templates/default/alarm.tpl
===================================================================
--- contrib/resources/templates/default/alarm.tpl	(revision 3524)
+++ contrib/resources/templates/default/alarm.tpl	(revision 3524)
@@ -0,0 +1,62 @@
+<!-- BEGIN alarm_management -->
+<form id="calendar_alarmform" action="{action_url}" method="post" name="alarmform">
+{hidden_vars}
+	<table id="calendar_alarmform_table" border="0" width="90%" align="center">
+		{rows}
+		<tr>
+			<td colspan="4">
+				<br>&nbsp;{input_days}&nbsp;{input_hours}&nbsp;{input_minutes}&nbsp;{input_owner}&nbsp;{input_add}<br>&nbsp;
+			</td>
+			<td align="right">
+				{input_cancel}
+			</td>
+		</tr>
+	</table>
+</form>
+<!-- END alarm_management -->
+
+<!-- BEGIN alarm_headers -->
+	<tr bgcolor="{tr_color}">
+		<th align="left" width="25%">{lang_time}</th>
+		<th align="left" width="30%">{lang_text}</th>
+		<th align="left" width="25%">{lang_owner}</th>
+		<th width="10%">{lang_enabled}</th>
+		<th width="10%">{lang_select}</th>
+	</tr>
+<!-- END alarm_headers -->
+
+<!-- BEGIN list -->
+	<tr bgcolor="{tr_color}">
+		<td>
+			<b>{field}:</b>
+		</td>
+		<td>
+			{data}
+		</td>
+		<td>
+			{owner}
+		</td>
+		<td align="center">
+			{enabled}
+		</td>
+		<td align="center">
+			{select}
+		</td>
+	</tr>
+<!-- END list -->
+
+<!-- BEGIN hr -->
+	<tr bgcolor="{th_bg}">
+		<td colspan="5" align="center">
+			<b>{hr_text}</b>
+		</td>
+	</tr>
+<!-- END hr -->
+
+<!-- BEGIN buttons -->
+	<tr>
+		<td colspan="6" align="right">
+			{enable_button}&nbsp;{disable_button}&nbsp;{delete_button}
+		</td>
+	</tr>
+<!-- END buttons -->
Index: contrib/resources/templates/default/pref.tpl
===================================================================
--- contrib/resources/templates/default/pref.tpl	(revision 3524)
+++ contrib/resources/templates/default/pref.tpl	(revision 3524)
@@ -0,0 +1,22 @@
+<!-- BEGIN pref -->
+<p><b>{title}:</b><hr><p>
+<form action="{action_url}" method="POST">
+ <table border="0" align="center" width="90%">
+  {row}
+ </table>
+ <center><input type="submit" name="submit" value="{submit_lang}"></center>
+</form>
+<!-- END pref -->
+
+<!-- BEGIN pref_colspan -->
+  <tr bgcolor="{bg_color}">
+   <td colspan="2">{text}</td>
+  </tr>
+<!-- END pref_colspan -->
+
+<!-- BEGIN pref_list -->
+  <tr bgcolor="{bg_color}">
+   <td align="right">{field}</td>
+   <td align="center">{data}</td>
+  </tr>
+<!-- END pref_list -->
Index: contrib/resources/templates/default/confirm.tpl
===================================================================
--- contrib/resources/templates/default/confirm.tpl	(revision 3524)
+++ contrib/resources/templates/default/confirm.tpl	(revision 3524)
@@ -0,0 +1,31 @@
+<!-- BEGIN list -->
+<html>
+<head>
+<title> .: Expresso :. </title>
+<link href='/phpgwapi/templates/classic/login.css' rel='stylesheet' type='text/css'>
+</head>
+<body class='body'>
+<br>
+<center>
+<table border='0' cellpading='0' cellspacing='0'>
+	<tr>
+		<td class='td'><b><font face='Verdana, Arial, Helvetica, sans-serif'>{notify_message}</font></b></td>
+	</tr>
+	<tr>
+</table>
+</center>
+<br>
+<center>
+<table border='0' cellpading='0' cellspacing='0'>
+<tr>
+	<td>
+		<form>
+		<input type='submit' value='Ok' onclick='javascript:window.close()'>
+		</form>
+	</td>
+</tr>
+</table>
+</center>
+</body>
+</html>
+<!-- END list -->
Index: contrib/resources/templates/default/month_header.tpl
===================================================================
--- contrib/resources/templates/default/month_header.tpl	(revision 3524)
+++ contrib/resources/templates/default/month_header.tpl	(revision 3524)
@@ -0,0 +1,12 @@
+<!-- BEGIN monthly_header -->
+<tr class="calendar_m_w_table_header" colspan="{cols}" width="{col_width}%">
+{column_header}</tr>
+<!-- END monthly_header -->
+
+<!-- BEGIN column_title -->
+<th bGCOLOR="#D3DCE3" width="14.28%">{col_title}</th>
+<!-- END column_title -->
+
+<!-- BEGIN month_column -->
+<td class="calendar_m_w_tablecell" colspan="1" width="{col_width}%"{extra}>{column_data}</td>
+<!-- END month_column -->
Index: contrib/resources/templates/default/month_day_print.tpl
===================================================================
--- contrib/resources/templates/default/month_day_print.tpl	(revision 3524)
+++ contrib/resources/templates/default/month_day_print.tpl	(revision 3524)
@@ -0,0 +1,26 @@
+
+<!-- BEGIN m_w_table -->
+
+<table id="calendar_m_w_table" class="calendar_m_w_table" border="0" width="100%">
+	<!-- from month_header.tpl -->
+	{row}
+</table>
+<!-- END m_w_table -->
+
+
+<table>
+<!-- BEGIN month_daily -->
+<tr><td style="font-size: 10px; font-weight: bold; text-decoration: underline;" width="10px">{day_number}</td>
+<td>{daily_events}</td>
+<!-- END month_daily -->
+
+<!-- BEGIN day_event -->
+
+<td>{events}</td>
+<!-- END day_event -->
+
+<!-- BEGIN event -->
+<td>{day_events}</td></tr>
+<!-- END event -->
+<br />
+</table>
Index: contrib/resources/templates/default/footer.tpl
===================================================================
--- contrib/resources/templates/default/footer.tpl	(revision 3524)
+++ contrib/resources/templates/default/footer.tpl	(revision 3524)
@@ -0,0 +1,64 @@
+<!-- BEGIN footer_table -->
+       <hr clear="all">
+       <font size="-1">
+       <table border="0" width="100%" cellpadding="0" cellspacing="0">
+        <tr>
+{table_row}
+	</tr>
+       </table>
+<!-- END footer_table -->
+<!-- BEGIN footer_row -->
+         <td valign="top" width="30%">
+          <font size="-1">
+           <form action="{action_url}" method="post" name="{form_name}">
+            <B>{label}:</B>
+			{hidden_vars}
+            <select name="{form_label}" onchange="{form_onchange}">
+	     {row}
+	    </select>
+	    <input type="hidden" name="user" value="{user}">
+	    <input type="hidden" name="dia_ini" value="{dia_ini}">
+            <noscript><input type="submit" value="{go}"></noscript>
+	   </form>
+	  </font>
+	 </td>
+<!-- END footer_row -->
+<!-- BEGIN blank_row -->
+         <td>
+         {b_row}
+         </td>
+         <td>
+         {b_row2}
+         </td>
+<!-- END blank_row -->
+
+<!-- BEGIN num_dias -->
+<td valign="top" width="30%">
+ <font size="-1">
+    <form action="{acao}" method="post" name="{formname}">
+    <span style="display: {display}" >
+ 
+	<label>
+		<b>{num_dias_label}:</b>
+	</label>
+	<select name="{num_dias_name}" onchange="{formonchange}"/>
+		{row_qtd}
+	</select>
+	<br />
+	<span style="font-size: 9px;">
+		{tip}
+	</span>
+	<br /> <br />
+    </span>
+<span style="display: {display}">
+	<b>{day_ini_label}:</b>
+	<select name="{day_ini_name}" onchange="{formonchange}">
+	{row_ini}
+	</select>
+	</span>
+<input type="hidden" name="user" value="{user}">
+	<noscript><input type="submit" value="{go}"></noscript>
+     </form>
+ </font>
+</td>
+<!-- END num_dias -->
Index: contrib/resources/templates/default/acl.tpl
===================================================================
--- contrib/resources/templates/default/acl.tpl	(revision 3524)
+++ contrib/resources/templates/default/acl.tpl	(revision 3524)
@@ -0,0 +1,54 @@
+<center>
+  <table border="0" cellspacing="2" cellpadding="2" width="100%">
+   <tr>
+    <td colspan="5" align="center" bgcolor="#c9c9c9"><b>{title}<b/></td>
+   </tr>
+   <tr>
+    <td colspan="5" align="left">
+     <table border="0" width="100%">
+      <tr>
+	   {left}
+       <td align="center">{lang_showing}</td>
+	   {right}
+      </tr>
+     </table>
+    </td>
+   </tr>
+   <tr>
+    <td>&nbsp;</td>
+    <td colspan="5" align="right">
+	<form method="POST"><input type="text" name="query"  value="{query}" />&nbsp;<input type="submit" name="btnSearch" value="{lang_search}" /></form>
+	</td>
+  </tr>
+ </table>
+ <form method="POST">
+  <table border="0" cellspacing="2" cellpadding="2" width="100%">
+   <tr bgcolor="{th_bg}" valign="middle" align="center">
+	<td>{sort_cat}<br>{lang_cat_admin}</td>
+	<td>{lang_read}</td>
+	<td>{lang_write}<br>({lang_implies_read})</td>
+	<td>{lang_calread}</td>
+	<td>{lang_calbook}<br>({lang_implies_book})</td>
+   </tr>
+   <!-- BEGIN cat_list -->
+   <tr bgcolor="{tr_color}">
+	<td>
+		{catname}<input type="hidden" name="catids[]" value="{catid}" /><br>
+		<select name="inputadmin[{catid}][]">{admin}</select>
+	</td>
+	<td align="center"><select multiple="multiple" size="5" name="inputread[{catid}][]">{read}</select></td>
+	<td align="center"><select multiple="multiple" size="5" name="inputwrite[{catid}][]">{write}</select></td>
+	<td align="center"><select multiple="multiple" size="5" name="inputcalread[{catid}][]">{calread}</select></td>
+	<td align="center"><select multiple="multiple" size="5" name="inputcalbook[{catid}][]">{calbook}</select></td>
+   </tr>
+   <!-- END cat_list -->
+   <tr>
+    <td colspan="5" align="left">
+	<br>
+	<input type="submit" name="btnSave" value="{lang_save}"> &nbsp;
+	<input type="submit" name="btnDone" value="{lang_done}">
+    </td>
+   </tr>
+  </table>
+ </form>
+</center>
Index: contrib/resources/templates/default/custom_fields.tpl
===================================================================
--- contrib/resources/templates/default/custom_fields.tpl	(revision 3524)
+++ contrib/resources/templates/default/custom_fields.tpl	(revision 3524)
@@ -0,0 +1,45 @@
+<!-- BEGIN custom_fields -->
+{lang_error}<br>
+<form action="{action_url}" method="post">
+ {hidden_vars}
+ <center>
+  <table border="0" width="90%">
+   <tr class="th">
+    <th align="left" width="30%">{lang_name}</th>
+    <th>{lang_length}</th>
+    <th>{lang_shown}</th>
+    <th>{lang_order}</th>
+    <th>{lang_title}</th>
+    <th>{lang_disabled}</th>
+    <th>&nbsp;</th>
+   </tr>
+   {rows}
+   <tr class="th">
+    <td>{name}</td>
+    <td align="center">{length}</td>
+    <td align="center">{shown}</td>
+    <td align="center">{order}</td>
+    <td align="center">{title}</td>
+    <td align="center">{disabled}</td>
+    <td align="center">{button}</td>
+   </tr>
+   <tr>
+    <td>{save_button} &nbsp; {cancel_button}</td>
+   </tr>
+  </table>
+ </center>
+</form>
+<br>
+<!-- END custom_fields -->
+
+<!-- BEGIN row -->
+   <tr bgcolor="{tr_color}">
+    <td>{name}</td>
+    <td align="center">{length}</td>
+    <td align="center">{shown}</td>
+    <td align="center">{order}</td>
+    <td align="center">{title}</td>
+    <td align="center">{disabled}</td>
+    <td align="center">{button}</td>
+   </tr>
+<!-- END row -->
Index: contrib/resources/templates/default/publicView.php
===================================================================
--- contrib/resources/templates/default/publicView.php	(revision 3524)
+++ contrib/resources/templates/default/publicView.php	(revision 3524)
@@ -0,0 +1,89 @@
+<?php 	
+	$user = $_POST['user'] ? $_POST['user'] : 
+		($_GET['user'] ? $_GET['user']: '');
+	
+	if($user) {
+		$organization = $_POST['organization'] ? $_POST['organization'] : 
+		($_GET['organization'] ? $_GET['organization']: '');
+		
+		if($organization)
+			$arg1 = $organization."-".$user;
+		else
+			$arg1 = $user;
+		
+		$params = "&account_name=".$arg1;
+	}
+	else
+		$params = '';
+?>
+<html>
+	<head><title>Visualizar Agenda</title>
+	<head>
+	<style type="text/css">
+		.grid_right{
+		border-style: groove;
+		border-width: 0px;
+		border-right-width: 1px;		
+		border-color: BLACK;		
+		}
+		.grid_top{
+		border-style: groove;
+		border-width: 0px;
+		border-top-width: 1px;		
+		border-color: BLACK;		
+		}
+	</style>
+	<LINK href="../../../phpgwapi/templates/default/css/azul.css" type=text/css rel=StyleSheet>
+	<script language="Javascript">
+		function validate(){
+			if(document.login.user.value =="")	{
+				alert('Você deve digitar um nome no campo Usuário.');
+				document.login.user.focus();
+				return false;
+			}
+			
+			return true;
+		}
+	</script>
+	</head>
+	<body>
+	  <div align="center" valign="center">
+		<table cellspacing="0" cellpadding="5" width="100%" height="100%">			
+			<tr><td width="10%" valign="center"  class="grid_right"><br>
+				<table border="0" cellpadding="0" cellspacing="0" class="login" height="100%" width="100%">
+					<tr>
+						<td valign="top">
+	  					<FORM name="login" method="post" action="publicView.php" onSubmit="javascript:return validate()">
+							<table border="0" cellpadding="0" cellspacing="0" class="tableLogin">
+								<tr>
+									<td width="66" class="loginLabel" align="center"><b>Organização</b><br><input type="text" value="<?=$organization?>" name="organization" size="15"></td>
+								</tr>
+								<tr>									
+									<td>&nbsp;</td>
+								</tr>
+								<tr>
+									<td width="136" align="center" class="loginLabel"><b>Usuário</b><br><input name="user" size="15" value="<?=$user?>"></td>
+								</tr>
+								<tr>									
+									<td height="16">&nbsp;</td>
+								</tr>
+								<tr>
+									<td width="135" colspan="2" align="center">						
+									<input type="submit" value="Visualizar" name="submitit" class=button >
+									</td>
+									</tr>
+							</table>
+							</FORM>
+						</td>
+					</tr>
+				</table>								
+			</td>
+				<td width="90%" valign="top">
+					<iframe  width="100%" height="95%" src="../../../index.php?menuaction=calendar.uipublicview.publicView<?=$params?>"
+						marginwidth="0" marginheight="0"  topmargin="0" leftmargin="0" frameborder="0" scrolling="auto" noresize>
+					</iframe>
+			</td></tr>
+		</table>
+	  </div>
+	</body>
+</html>
Index: contrib/resources/templates/default/search.tpl
===================================================================
--- contrib/resources/templates/default/search.tpl	(revision 3524)
+++ contrib/resources/templates/default/search.tpl	(revision 3524)
@@ -0,0 +1,139 @@
+<!-- BEGIN search -->
+
+<script language="Javascript">
+  
+    function submitit(form,campo)
+{
+	//alert(name+' pressed');
+ var texto;
+  //  texto = "El numero de opciones del select: " + document.form.search_info_type.length;
+    var indice = document.form.search_info_type.selectedIndex;
+    //texto += "\nIndice de la opcion escogida: " + indice;
+    var valor = document.form.search_info_type.options[indice].value;
+   // texto += "\nValor de la opcion escogida: " + valor;
+    var textoEscogido = document.form.search_info_type.options[indice].text;
+  //  texto += "\nTexto de la opcion escogida: " + textoEscogido;
+  //  alert(texto) ;
+	//document.form.ordena.value = name;
+form.action='/index.php?menuaction=resources.uiresources.search&ordenar='+campo+'&valor='+valor;
+	form.submit();
+	//form.submit_button.value = '';
+	return false;
+}
+   function submitit2(id)
+{
+
+location.href='/index.php?menuaction=resources.uiresources.delete&id='+id;
+return false;	
+}
+</script>
+<center>
+
+<table id="calendar_search_table" width="90%">
+
+<tr><td align=left>
+<form  METHOD=POST name="form">
+<input type=hidden name=ordena value="">
+	<table><tr class="th">
+	<td>
+		<table>
+			
+			<tr>
+				<td class="inactiv_sortcolumn" align="left"></td>
+			</tr>
+		</table>
+
+	</td>
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Descripci&oacute;n</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+	
+	<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Categor&iacute;a <br>Administrador</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+<td>
+		<table>
+	
+			<tr>
+			<td class="inactiv_sortcolumn" align="left">Ubicaci&oacute;n</td>
+			
+			</tr>
+			
+		</table>
+	</td>
+	
+	<td class="noPrint" align="left" width="3%">Acci&oacute;n </td>
+
+	</td>
+	</tr>
+
+	<tr>
+		<td colspan="2" align="center" bgcolor="{th_bg}">
+			<b></b>
+		</td>
+	</tr>
+	{rows}
+</form>
+</table>
+<!-- END search -->
+
+<!-- BEGIN search_list_header -->
+
+<!-- END search_list_header -->
+
+<!-- BEGIN search_list -->
+	<tr bgcolor="{tr_color}">
+		
+<td>	{picture_src}</td>
+<td>{name}<br>{description}</td>
+
+
+<td>{category}<br>{administrador}</td>
+<td>	{location}</td>
+
+<td><table><tr>
+
+
+<td>
+<a href="{accionmodificar}"><img src=/resources/templates/default/images/edit.png alt="modificar"></a>&nbsp;&nbsp;&nbsp;
+</td>
+<td>
+<a href="{accionlistar}"><img src=/resources/templates/default/images/calendar.png alt="ver recursos asignados"></a>&nbsp;&nbsp;&nbsp;
+
+</td>
+<td>
+
+
+<a href="{accionreservar}"><img src=/resources/templates/default/images/bookable.png alt="reservar"></a>&nbsp;&nbsp;&nbsp;
+</td>
+<td>
+
+<a href="" onClick="if ( 0 || confirm('eliminar esta entrada?')) return submitit2('{accionborrar}');; "><img src=/infolog/templates/default/images/delete.png alt="borrar"></a><br>
+
+
+<br>
+
+</td>
+
+
+</tr></table></td>
+	</tr>
+<!-- END search_list -->
+
+<!-- BEGIN search_list_footer -->
+
+<!-- END search_list_footer -->
Index: contrib/resources/templates/default/copyFolder.tpl
===================================================================
--- contrib/resources/templates/default/copyFolder.tpl	(revision 3524)
+++ contrib/resources/templates/default/copyFolder.tpl	(revision 3524)
@@ -0,0 +1,51 @@
+<!-- BEGIN main -->
+<script type='text/javascript'>
+	var folderChooserURL ='{folderChooserURL}';
+</script>
+
+<form name="copy_form" method="post" action="{form_action}">
+<fieldset><legend>{lang_target_folder}</legend>
+	<table border="0" cellspacing="0" cellpadding="5" width="100%">
+		<tr class="row_on">
+			<td class="description" valign="top" width="150px">{lang_folder}:</td>
+			<td class="infos">
+				<input id="targetname" style="width: 100%;" type="text" name="targetname" value="{foldername}" disabled>
+				<input type="hidden" id="targetid" name="targetid" value="{folderid}">
+			</td>
+			<td align="center" width="150px"><a href="#" onclick="selectFolder(1,'copy_form'); return(false);" style="font-size:10px;">{lang_select_target_folder}...</a></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top" width="150px">{lang_name}:</td>
+			<td class="infos">
+				<input id="newfoldername" style="width: 100%;" type="text" name="newfoldername" value="{newfoldername}">
+			</td>
+			<td align="center" width="150px"><a href="#" onclick="selectFolder(1,'copy_form'); return(false);" style="font-size:10px;">&nbsp;</td>
+		</tr>
+	</table>
+</fieldset>
+<p>
+<fieldset><legend>{lang_copy_options}</legend>
+	<table border="0" cellspacing="0" cellpadding="5" width="100%">
+		<tr class="row_off">
+			<td class="infos">
+				<input type="checkbox" name="copy_subfolder" id="copy_subfolder"> <label for="copy_subfolder">{lang_copy_subfolders}</label>
+			</td>
+		</tr>
+		<tr class="row_off">
+			<td class="infos">
+				<input type="checkbox" name="copy_documents" id="copy_documents" disabled> <label for="copy_documents">{lang_copy_documents}</label>
+			</td>
+		</tr>
+	</table>
+</fieldset>
+<p>
+	<table border="0" cellspacing="0" cellpadding="5" width="100%">
+		<tr class="row_off">
+			<td class="infos">
+				<button type="submit" name="cancel">{lang_cancel}</button>
+				<button type="submit" name="copy">{lang_copy}</button>
+			</td>
+		</tr>
+	</table>
+</form>
+<!-- END main -->
Index: contrib/resources/templates/default/images/buttons/atualizar.sh
===================================================================
--- contrib/resources/templates/default/images/buttons/atualizar.sh	(revision 3524)
+++ contrib/resources/templates/default/images/buttons/atualizar.sh	(revision 3524)
@@ -0,0 +1,14 @@
+cp /public/home/desenvolvimento/arte/imagens_file_manager/up.png uplvl_big.png
+cp /public/home/desenvolvimento/arte/imagens_file_manager/refresh.png fs_refresh.png
+cp /public/home/desenvolvimento/arte/imagens_file_manager/new_folder.png new_folder.png
+
+cp /public/home/desenvolvimento/arte/imagens_file_manager/up_load.png upload.png
+cp /public/home/desenvolvimento/arte/imagens_file_manager/lixeira.png delete_big.png
+cp /public/home/desenvolvimento/arte/imagens_file_manager/cut.png .
+cp /public/home/desenvolvimento/arte/imagens_file_manager/copy.png .
+cp /public/home/desenvolvimento/arte/imagens_file_manager/sharing.png .
+cp /public/home/desenvolvimento/arte/imagens_file_manager/searching.png ab_search.png
+
+cp /public/home/desenvolvimento/arte/imagens_file_manager/compress.png .
+cp /public/home/desenvolvimento/arte/imagens_file_manager/decompress.png .
+cp /public/home/desenvolvimento/arte/imagens_file_manager/home.png .
Index: contrib/resources/templates/default/images/index.html
===================================================================
--- contrib/resources/templates/default/images/index.html	(revision 3524)
+++ contrib/resources/templates/default/images/index.html	(revision 3524)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+	<title>eGroupWare Info Log Icons</title>
+</head>
+
+<body bgcolor=Silver>
+	Types:<br>
+	<img src="phone.gif" width="20" height="20" alt="Telefon" border="0"> &nbsp;
+	<img src="task.gif" width="20" height="20" alt="Aufgabe" border="0"> &nbsp;
+	<img src="note.gif" width="20" height="20" alt="Notiz" border="0"> &nbsp;
+	<img src="confirm.gif" width="20" height="20" alt="Bestätigung" border="0"> &nbsp;
+	<img src="reject.gif" width="20" height="20" alt="Absage" border="0">
+	<p>
+	Status:<br>
+	<img src="offer.gif" width="20" height="20" alt="Angebot" border="0"> &nbsp;
+	<img src="ongoing.gif" width="20" height="20" alt="läuft" border="0"> &nbsp;
+	<img src="call.gif" width="20" height="20" alt="anrufen" border="0"> &nbsp;
+	<img src="will-call.gif" width="20" height="20" alt="ruft zurück" border="0"> 
+&nbsp;
+	<img src="done.gif" width="20" height="20" alt="erledigt" border="0"> &nbsp;
+	<img src="billed.gif" width="20" height="20" alt="abgerechnet" border="0">
+	<p>
+	Actions:<br>
+	<img src="new.gif" width="20" height="20" alt="neue Teilaufgabe" border="0"> 
+&nbsp;
+	<img src="view.gif" width="20" height="20" alt="Teilaufgagen anzeigen" 
+border="0"> &nbsp;
+	<img src="edit.gif" width="20" height="20" alt="bearbeiten" border="0"> &nbsp;
+	<img src="delete.gif" width="20" height="20" alt="löschen" border="0">
+</body>
+</html>
+
Index: contrib/resources/templates/default/overlap.tpl
===================================================================
--- contrib/resources/templates/default/overlap.tpl	(revision 3524)
+++ contrib/resources/templates/default/overlap.tpl	(revision 3524)
@@ -0,0 +1,30 @@
+<!-- BEGIN overlap -->
+<center><br />
+<table id="calendar_overlap_table">
+	<tr>
+		<td>
+			{overlap_text}
+		</td>
+	</tr>
+	<tr>
+		<td>
+			<ul>{overlap_list}</ul>
+		</td>
+	</tr>
+	<tr>
+		<td>
+			<table id="calendar_overlap_table2" cellspacing="5">
+				<tr>
+					<td>
+						{resubmit_button}
+					</td>
+					<td>
+						{reedit_button}
+					</td>
+				</tr>
+			</table>
+		</td>
+	</tr>
+</table>
+</center>
+<!-- END overlap -->
Index: contrib/resources/templates/default/day_list.tpl
===================================================================
--- contrib/resources/templates/default/day_list.tpl	(revision 3524)
+++ contrib/resources/templates/default/day_list.tpl	(revision 3524)
@@ -0,0 +1,28 @@
+<!-- BEGIN day -->
+<div class="event-off">
+<table border="0" width="100%" cellpadding="0">
+	<tr>
+		<td class="event-on">
+{row}
+		</td>
+	</tr>
+</table>
+</div>
+<!-- END day -->
+<!-- BEGIN day_row -->
+    <font style="font-size: 8pt;">{event}</font>
+<!-- END day_row -->
+<!-- BEGIN day_event_on -->
+	<font class="event-on">{event}</font>
+<!-- END day_event_on -->
+<!-- BEGIN day_event_off -->
+	<font class="event-on">{event}</font>
+<!-- END day_event_off -->
+<!-- BEGIN day_event_holiday -->
+	{event}
+<!-- END day_event_holiday -->
+<!-- BEGIN day_time -->
+	{time}
+     <!--<td class="time" nowrap>{open_link}{time}{close_link}</td>-->
+<!-- END day_time -->
+
Index: contrib/resources/templates/default/grant_group_access.tpl
===================================================================
--- contrib/resources/templates/default/grant_group_access.tpl	(revision 3524)
+++ contrib/resources/templates/default/grant_group_access.tpl	(revision 3524)
@@ -0,0 +1,65 @@
+<div align="center" style="width:100%">
+<input type="hidden" id="txt_loading" value="{lang_Loading}">
+<input type="hidden" id="txt_searching" value="{lang_Searching}">
+<input type="hidden" id="txt_users" value="{lang_Users}">
+<input type="hidden" id="txt_groups" value="{lang_Groups}">
+<input type="hidden" id="txt_confirm" value="{lang_confirm}">
+<input type="hidden" id="txt_success" value="{lang_success}">
+<input type="hidden" id="txt_exist" value="{lang_exist}">
+<input type="hidden" id="txt_nouser" value="{lang_nouser}">
+<input type="hidden" id="txt_nogroup" value="{lang_nogroup}">
+<input type="hidden" id="txt_nopermissiontype" value="{lang_nopermissiontype}">
+<input type="hidden" id="txt_typemoreletters" value="{lang_typemoreletters}">
+<input type="hidden" id="template_set" value="{template_set}">
+<table width="80%" border="0">
+<tr>
+<td align='center' valign="bottom"><br><b>{lang_User_to_grant_access}</b><br>
+	<font color="red"><span id="cal_span_searching1">&nbsp;</span></font>
+	<br>{lang_Search_for}: <input type="text" id="cal_input_searchUser1" name="cal_input_searchUser1" value="" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching1','user','u')"/>
+	<br><br>
+	<select id="user" style="width: 300px" size="13"></select>
+</td>
+<td width="20px" valign="middle" align="left"><br><br><br><br>
+<button type="button" onClick="javascript:add_user();"><img src="{template_set}/images/add.png" style="vertical-align: middle;" >{lang_Add}</button>
+<br><br><b>{lang_access_type}</b><br>
+<input type="checkbox" id="right_L" value="L"/>{lang_read}<br>
+<input type="checkbox" id="right_A" value="A"/>{lang_add}<br>
+<input type="checkbox" id="right_E" value="E"/>{lang_edit}<br>
+<input type="checkbox" id="right_R" value="R"/>{lang_delete}<br>
+<input type="checkbox" id="right_P" value="P"/>{lang_private}
+</td>
+<td align='center' valign="bottom"><br><b>{lang_Group_to_share_calendar}</b><br>
+	<font color="red"><span id="cal_span_searching2">&nbsp;</span></font>
+	<br>{lang_Search_for}:	<input type="text" id="cal_input_searchUser2" name="cal_input_searchUser2" value="" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching2','group','g')"/><br><br>
+	<select id="group" style="width: 300px" size="13"></select>
+</td>
+</tr>
+	<tr height="20px"></tr>
+	<tr bgcolor="{tr_color}" style="font-size:0.8em">
+		<th align="left" width="25%" nowrap>&nbsp;{lang_granted_user}</th>
+		<th align="center" width="1%">{lang_access_type}</th>
+		<th align="left" width="40%" nowrap>&nbsp;{lang_shared_group}</th>
+		<th width="1%">&nbsp;</th>
+	</tr>
+<tbody id='tbody_list' >
+<!-- BEGIN list -->
+	<tr id='{select}' bgcolor="{tr_color_header}">
+		<td>
+			<b>&nbsp;&nbsp;{granted_user}</b>
+		</td>
+		<td align="center">
+			{access_type}
+		</td>		
+		<td>
+			&nbsp;&nbsp;{shared_group}
+		</td>
+		<td align="center">
+			<button  title="{lang_Remove}" type="button" onClick="javascript:remove_user('{select}');"><img alt="{lang_Remove}" src="{template_set}/images/delete.png" style="vertical-align: middle;"/></button>
+		</td>
+	</tr>
+<!-- END list -->
+</tbody>
+</table>
+<br><br>
+</div>
+{scripts}
Index: contrib/resources/templates/default/index.xet
===================================================================
--- contrib/resources/templates/default/index.xet	(revision 3524)
+++ contrib/resources/templates/default/index.xet	(revision 3524)
@@ -0,0 +1,120 @@
+<?xml version="1.0"?>
+<!-- $Id: index.xet 24276 2007-07-10 07:35:18Z ralfbecker $ -->
+<overlay>
+	<template id="timesheet.index.dates" template="" lang="" group="0" version="1.2.001">
+		<hbox rows="1" cols="1" class="custom_hide">
+			<description value="Start"/>
+			<date id="startdate"/>
+			<description value="End"/>
+			<date id="enddate" statustext="Leave it empty for a full week"/>
+		</hbox>
+		<styles>
+			.custom_hide { visibility: hidden; }
+		</styles>
+	</template>
+	<template id="timesheet.index.add" template="" lang="" group="0" version="1.3.001">
+		<button label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=timesheet.uitimesheet.edit'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;"/>
+	</template>
+	<template id="timesheet.index.rows" template="" lang="" group="0" version="1.3.002">
+		<grid width="100%">
+			<columns>
+				<column width="15%"/>
+				<column width="50%"/>
+				<column/>
+				<column/>
+				<column disabled="@ts_viewtype"/>
+				<column disabled="@ts_viewtype"/>
+				<column disabled="@ts_viewtype"/>
+				<column disabled="@no_owner_col"/>
+				<column/>
+			</columns>
+			<rows>
+				<row class="th">
+					<nextmatch-sortheader label="Date" id="ts_start"/>
+					<grid spacing="1" padding="1">
+						<columns>
+							<column/>
+						</columns>
+						<rows>
+							<row disabled="@pm_integration=full">
+								<nextmatch-filterheader options="All projects" id="ts_project" no_lang="1"/>
+							</row>
+							<row disabled="!@pm_integration=full">
+								<nextmatch-customfilter options="projectmanager-select,All projects" id="pm_id" onchange="1"/>
+							</row>
+							<row>
+								<nextmatch-sortheader label="Title" id="ts_title"/>
+							</row>
+						</rows>
+					</grid>
+					<nextmatch-sortheader label="Category" id="cat_id"/>
+					<vbox>
+						<nextmatch-sortheader label="Duration" id="ts_duration"/>
+						<date-duration id="duration" options=",h,,,1" readonly="true"/>
+					</vbox>
+					<vbox options="0,0">
+						<nextmatch-sortheader label="Quantity" id="ts_quantity"/>
+						<textbox type="float" id="quantity" readonly="true" precision="3"/>
+					</vbox>
+					<nextmatch-sortheader label="Price" id="ts_unitprice"/>
+					<vbox>
+						<nextmatch-sortheader label="Total" id="ts_total"/>
+						<textbox type="float" id="price" readonly="true" precision="2"/>
+					</vbox>
+					<nextmatch-filterheader id="ts_owner" options="User" no_lang="1" class="$cont[ownerClass]"/>
+					<description value="Actions" class="noPrint"/>
+				</row>
+				<row class="$row_cont[class]">
+					<date-time id="${row}[ts_start]" readonly="true" options=",8"/>
+					<vbox>
+						<link id="${row}[ts_link]" no_lang="1"/>
+						<description id="${row}[ts_title]" no_lang="1" class="$row_cont[titleClass]"/>
+						<description id="${row}[ts_description]" no_lang="1"/>
+					</vbox>
+					<menulist class="noWrap">
+						<menupopup type="select-cat" readonly="true" id="${row}[cat_id]"/>
+					</menulist>
+					<date-duration id="${row}[ts_duration]" readonly="true" options=",h,,,1"/>
+					<textbox type="float" id="${row}[ts_quantity]" no_lang="1" precision="3" readonly="true"/>
+					<description no_lang="1" id="${row}[ts_unitprice]"/>
+					<textbox type="float" no_lang="1" id="${row}[ts_total]" precision="2" readonly="true"/>
+					<menulist class="$cont[ownerClass]">
+						<menupopup type="select-account" id="${row}[ts_owner]" readonly="true"/>
+					</menulist>
+					<hbox class="noPrint">
+						<button image="view" label="View" id="view[$row_cont[ts_id]]" onclick="window.open(egw::link('/index.php','menuaction=timesheet.uitimesheet.view&amp;ts_id=$row_cont[ts_id]'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;" statustext="View this entry"/>
+						<button image="edit" label="Edit" id="edit[$row_cont[ts_id]]" statustext="Edit this entry" onclick="window.open(egw::link('/index.php','menuaction=timesheet.uitimesheet.edit&amp;ts_id=$row_cont[ts_id]'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;"/>
+						<button image="delete" label="Delete" id="delete[$row_cont[ts_id]]" statustext="Delete this entry" onclick="return confirm('Delete this entry');"/>
+					</hbox>
+				</row>
+			</rows>
+		</grid>
+	</template>
+	<template id="timesheet.index" template="" lang="" group="0" version="1.3.002">
+		<grid width="100%">
+			<columns>
+				<column/>
+			</columns>
+			<rows>
+				<row disabled="!@msg">
+					<description span="all" class="redItalic" no_lang="1" id="msg" align="center"/>
+				</row>
+				<row disabled="1">
+					<hbox>
+						<template id="timesheet.index.dates"/>
+						<template id="timesheet.index.add" align="right"/>
+					</hbox>
+				</row>
+				<row>
+					<nextmatch id="nm" options="timesheet.index.rows"/>
+				</row>
+				<row class="noPrint">
+					<button label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=timesheet.uitimesheet.edit'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;"/>
+				</row>
+				<row>
+					<button label="Export" onclick="timesheet_export(); return false;" id="export"/>
+				</row>
+			</rows>
+		</grid>
+	</template>
+</overlay>
Index: contrib/resources/templates/default/viewDocument.tpl
===================================================================
--- contrib/resources/templates/default/viewDocument.tpl	(revision 3524)
+++ contrib/resources/templates/default/viewDocument.tpl	(revision 3524)
@@ -0,0 +1,499 @@
+<!-- BEGIN main -->
+<script type='text/javascript'>
+	var folderChooserURL ='{folderChooserURL}';
+</script>
+
+<table width="100%" border="0" cellspacing="0" cellpading="0" bgcolor="white" hheight="100px">
+	<tr class="topRow">
+		<th width="33%">{delete}</th>
+		<th width="33%">{view_online}</th>
+		<th width="33%">{download}</th>
+	</tr>
+</table>
+<br>
+<table width="100%" border="0" cellspacing="0" cellpading="0">
+	<tr>
+		<th width="20%" id="tab1" class="activetab" onclick="javascript:tab.display(1);"><a href="#" tabindex="0" accesskey="1" onfocus="tab.display(1);" onclick="tab.display(1); return(false);" style="font-size:10px;">{lang_informations}</a></th>
+		<th width="20%" id="tab2" class="activetab" onclick="javascript:tab.display(2);"><a href="#" tabindex="0" accesskey="2" onfocus="tab.display(2);" onclick="tab.display(2); return(false);" style="font-size:10px;">{lang_all_versions}</a></th>
+		<th width="20%" id="tab3" class="activetab" onclick="javascript:tab.display(3);"><a href="#" tabindex="0" accesskey="3" onfocus="tab.display(3);" onclick="tab.display(3); return(false);" style="font-size:10px;">{lang_linked_documents}</a></th>
+		<th width="20%" id="tab4" class="activetab" onclick="javascript:tab.display(4);"><a href="#" tabindex="0" accesskey="4" onfocus="tab.display(4);" onclick="tab.display(4); return(false);" style="font-size:10px;">{lang_notifications}</a></th>
+		<th width="20%" id="tab5" class="activetab" onclick="javascript:tab.display(5);"><a href="#" tabindex="0" accesskey="5" onfocus="tab.display(5);" onclick="tab.display(5); return(false);" style="font-size:10px;">{lang_acl}</a></th>
+	</tr>
+</table>
+<div style="border-left: dotted 1px grey; border-bottom: dotted 1px grey; border-right: dotted 1px grey; background: white;">
+<div id="tabcontent1" class="inactivetab" bgcolor="white">
+	{informations}
+</div>
+
+<div id="tabcontent2" class="inactivetab">
+
+	<table cellspacing="5" cellpadding="0" border="0" width="100%">
+		<tr>
+			<td></td>
+			<td></td>
+			<td class="filelist" style="border-bottom: 1pt solid #000080;"><i>{lang_version}</i></td>
+			<td rowspan="{rownum}" style="border-left: 1pt solid #000080;">&nbsp;</td>
+			<td class="filelist" style="border-bottom: 1pt solid #000080;"><i>{lang_upload_date}</i></td>
+			<td rowspan="{rownum}" style="border-left: 1pt solid #000080;">&nbsp;</td>
+			<td class="filelist" style="border-bottom: 1pt solid #000080;"><i>{lang_comment}</i></td>
+			<td rowspan="{rownum}" style="border-left: 1pt solid #000080;">&nbsp;</td>
+			<td class="filelist" style="border-bottom: 1pt solid #000080;"><i>{lang_uploaded_by}</i></td>
+			<td></td>
+		</tr>
+		{versions}
+	</table>
+</div>
+
+<div id="tabcontent3" class="inactivetab">
+<!--
+<table cellspacing="5" cellpadding="0" border="1">
+	<?php
+	if ($rownum > 1)
+	{
+		?>
+		<tr>
+		<td></td>
+		<td class="filelist" style="border-bottom: 1pt solid #000080;"><i><?php printMLText("name");?></i></td>
+		<td rowspan="<?php print $rownum;?>" style="border-left: 1pt solid #000080;">&nbsp;</td>
+		<td class="filelist" style="border-bottom: 1pt solid #000080;"><i><?php printMLText("comment");?></i></td>
+		<td rowspan="<?php print $rownum;?>" style="border-left: 1pt solid #000080;">&nbsp;</td>
+		<td class="filelist" style="border-bottom: 1pt solid #000080;"><i><?php printMLText("document_link_by");?></i></td>
+		<td rowspan="<?php print $rownum;?>" style="border-left: 1pt solid #000080;">&nbsp;</td>
+		<td class="filelist" style="border-bottom: 1pt solid #000080;"><i><?php printMLText("document_link_public");?></i></td>
+		<td></td>
+		</tr>
+		<?php 
+		foreach($links as $link)
+		{
+			$responsibleUser = $link->getUser();
+			$targetDoc = $link->getTarget();
+			
+			print "<tr>";
+			print "<td><img src=\"images/file.gif\" width=18 height=18 border=0></td>";
+			print "<td class=\"linklist\"><a href=\"out.ViewDocument.php?documentid=".$targetDoc->getID()."\" class=\"linklist\">".$targetDoc->getName()."</a></td>";
+			print "<td class=\"linklist\">".$targetDoc->getComment()."</td>";
+			print "<td class=\"linklist\">".$responsibleUser->getFullName()."</td>";
+			print "<td class=\"linklist\">" . (($link->isPublic()) ? getMLText("yes") : getMLText("no")) . "</td>";
+			print "<td>";
+			if (($user->getID() == $responsibleUser->getID()) || ($user->getID() == $settings->_adminID) || ($link->isPublic() && ($document->getAccessMode($user) >= M_READWRITE )))
+				print "<a href=\"../op/op.RemoveDocumentLink.php?documentid=".$documentid."&linkid=".$link->getID()."\"><img src=\"images/del.gif\" border=0></a>";
+			print "</td>";
+			print "</tr>";
+		}
+	}
+	else
+		print "<tr><td class=\"filelist\">".getMLText("no_document_links")."</td></tr>";
+	?>
+</table>
+
+
+if ($user->getID() != $settings->_guestID)
+
+	<form action="../op/op.AddDocumentLink.php" name="form1">
+	<input type="Hidden" name="documentid" value="<?php print $documentid;?>">
+	<table>
+		<tr>
+			<td class="inputDescription"><?php printMLText("choose_target_document");?>:</td>
+			<td><?php printDocumentChooser("form1");?></td>
+		</tr>
+		<?php 
+			if ($document->getAccessMode($user) >= M_READWRITE)
+			{
+				print "<tr><td class=\"inputDescription\">".getMLText("document_link_public")."</td><td class=\"inputDescription\">";
+				print "<input type=\"Radio\" name=\"public\" value=\"true\" checked>" . getMLText("yes") . "&nbsp;&nbsp;";
+				print "<input type=\"Radio\" name=\"public\" value=\"false\">" . getMLText("no");
+				print "</td></tr>";
+			}
+		?>
+		<tr>
+			<td colspan="2"><br><input type="Submit" value="<?php printMLText("add_document_link");?>"></td>
+		</tr>
+	</table>
+	</form>-->
+</div>
+
+<div id="tabcontent4" class="inactivetab">
+	<table cellspacing="0" cellpadding="5" border="0" width="100%">
+		<tr>
+			<td style="border-bottom: 1pt solid #000080;" width="50px">&nbsp;</td>
+			<td style="border-bottom: 1pt solid #000080;" class="notifylist"><i>{lang_name}</i></td>
+			<td style="border-bottom: 1pt solid #000080;" width="50px">&nbsp;</td>
+		</tr>
+		{notifications}
+		<tr>
+			<td colspan="3">&nbsp;</td>
+		</tr>
+	</table>
+
+	<form action="{notify_form_action}" method="post" name="notify_form">
+		<fieldset><legend>{lang_add_notification}</legend>
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td class="inputDescription">{lang_user}:</td>
+				<td>
+					{select_userid}
+				</td>
+			</tr>
+			<tr>
+				<td class="inputDescription">{lang_group}:</td>
+				<td>
+					{select_groupid}
+				</td>
+			</tr>
+		</table>
+		</fieldset>
+	</form>
+</div>
+
+<div id="tabcontent5" class="inactivetab">
+	{change_owner}
+	{display_acl}
+</div>
+
+<div id="tabcontent6" class="inactivetab">
+	<form enctype="multipart/form-data" name="update_file_form" method="post" action="{action_update_file}">
+	<table cellpadding="5" cellspacing="0" border="0" width="100%">
+		<tr class="row_on">
+			<td class="description" valign="top" width="150px">{lang_filename}:</td>
+			<td class="infos" colspan="2"><input type="file" name="userfile"></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_comment}:</td>
+			<td class="infos" colspan="2"><textarea name="comment" style="width: 100%;"></textarea></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_expires}:</td>
+			<td class="infos" valign="top" colspan="2">
+				{select_expire_update}
+				<span id="jscalspan_update" class="{expire_class_update}">{expire_date_update}</span>
+			</td>
+		</tr>
+		<tr>
+			<td colspan="3" valign="top">
+				<input type="submit" name="save" value="{lang_update}">
+				<button type="button" name="cancel" value="{lang_cancel}" onClick="javascript:tab.display(1);">
+					{lang_cancel}
+				</button>
+			</td>
+		</tr>
+	</table>
+	</form>
+</div>
+
+
+
+</div>
+<!-- END main -->
+
+<!-- BEGIN lock_row -->
+	<tr class="row_on">
+		<td class="description" valign="top">{lang_lock_status}:</td>
+		<td class="infos" colspan="3">
+			<input id="lockStatus" type="hidden" name="lockStatus" value="unchanged">
+			<input type="checkbox" onClick="javascript:toggleLock(this);" {checked_lock_status}>
+			<div id="currentLockStatus" class="active">
+				{lang_current_status}
+			</div>
+			<div id="lockFile" class="inactive">
+				{lang_file_gets_unlocked}
+			</div>
+			<div id="unlockFile" class="inactive">
+				{lang_file_gets_locked}
+			</div>
+		</td>
+	</tr>
+<!-- END lock_row -->
+
+<!-- BEGIN version_row -->
+	<tr>
+		<td>
+			{url_view_online}
+		</td>
+		<td>
+			<a href="{url_download_file}" class="oldcontent"><img src="{download_image}" width=22 height=22 border=0 title="{lang_download}"></a>
+		</td>
+		<td class="filelist" align="center">{version_version}</td>
+		<td class="filelist">{version_date}</td>
+		<td class="filelist">{version_comment}</td>
+		<td class="filelist">{version_uploadingUser}</td>
+		<td>{url_delete_file}</td>
+	</tr>
+<!-- END version_row -->
+
+<!-- BEGIN information_ro -->
+	<table cellpadding="5" cellspacing="0" border="0" width="100%">
+		<tr>
+			<td class="infos" valign="top" width="150px">{lang_filename}:</td>
+			<td style="border-left: 1pt solid #000080;" rowspan="14" width="1px">&nbsp;</td>
+			<td class="infos">{filename}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_owner}:</td>
+			<td class="infos">
+				<a class="infos" href="mailto:{owner_email}">{owner_fullname}</a>
+			</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_comment}:</td>
+			<td class="infos">{comment}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_creation_date}:</td>
+			<td class="infos">{creation_date}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_keywords}:</td>
+			<td class="infos">{keywords}</td>
+		</tr>
+		{locking}
+		<tr>
+			<td>&nbsp;</td>
+			<td>&nbsp;</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_last_update}</td>
+			<td class="infos">{last_update}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_current_version}:</td>
+			<td class="infos">{current_version}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_comment_for_current_version}:</td>
+			<td class="infos" valign="top">{current_comment}</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_uploaded_by}:</td>
+			<td class="infos">
+				<a class="infos" href="mailto:{updater_email}">{updater_fullname}</a>
+			</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_file_size}:</td>
+			<td class="infos">{file_size} bytes</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_mime_type}:</td>
+			<td class="infos">
+				<img align="absmiddle" src="images/icons/<?php print getMimeIcon($latestContent->getFileType());?>"> 
+				{mime_type}
+			</td>
+		</tr>
+		<tr>
+			<td class="infos" valign="top">{lang_expires}:</td>
+			<td class="infos" valign="top">
+				{expire_date_ro}
+			</td>
+		</tr>
+	</table>
+<!-- END information_ro -->
+
+<!-- BEGIN information_rw -->
+	<form name="info_form" method="post" action="{action_informations}">
+	<fieldset><legend>{lang_general_information}</legend>
+	<table cellpadding="5" cellspacing="0" border="0" width="100%">
+		<tr class="row_on">
+			<td class="description" valign="top" width="150px">{lang_filename}:</td>
+			<td class="infos" colspan="2"><input style="width: 100%;" type="text" name="fname" value="{filename}"></td>
+			<td align="center" width="150px"><a href="#" tabindex="0" onfocus="tab.display(6);" onclick="tab.display(6); return(false);" style="font-size:10px;">{lang_update_document}</a></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top" width="150px">{lang_folder}:</td>
+			<td class="infos" colspan="2">
+				<input id="targetname" style="width: 100%;" type="text" name="targetname" value="{foldername}" disabled>
+				<input type="hidden" id="targetid" name="targetid" value="unchanged">
+			</td>
+			<td align="center" width="150px"><a href="#" onclick="selectFolder({current_folder_id},'info_form'); return(false);" style="font-size:10px;">{lang_move_document}</a></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_comment}:</td>
+			<td class="infos" colspan="3"><textarea name="comment" style="width: 100%; height: 80px;">{comment}</textarea></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_keywords}:</td>
+			<td class="infos" colspan="3"><textarea name="keywords" style="width: 100%; height: 30px;">{keywords}</textarea></td>
+		</tr>
+		<tr class="row_on">
+			<td class="description" valign="top">{lang_expires}:</td>
+			<td class="infos" valign="top" colspan="3">
+				{select_expire}
+				<span id="jscalspan" class="{expire_class}">{expire_date}</span>
+			</td>
+		</tr>
+		{locking}
+		<tr class="row_on">
+			<td class="description_small" valign="top">{lang_owner}:</td>
+			<td class="infos" colspan="1">
+				<a class="infos" href="mailto:{owner_email}">{owner_fullname}</a>
+			</td>
+			<td class="description_small" valign="top">{lang_creation_date}:</td>
+			<td class="infos" colspan="1">{creation_date}</td>
+		</tr>
+		<tr class="row_on">
+			<td colspan="4" valign="top">
+				<button type="submit" name="save" value="save">
+					{lang_save}
+				</button>
+				<button style="margin-left: 10px;" type="button" name="cancel" value="cancel" onClick="window.close()">
+					{lang_cancel}
+				</button>
+			</td>
+		</tr>
+	</table>
+	</fieldset>
+	<p>
+	<fieldset style="border: 1px solid silver;"><legend>{lang_information_about_last_update}</legend>
+	<table cellpadding="5" cellspacing="0" border="0" width="100%">
+		<tr class="row_off">
+			<td class="description_small" valign="top" width="150px">{lang_last_update}</td>
+			<td class="infos">{last_update}</td>
+			<td class="description_small" valign="top" width="150px">{lang_current_version}:</td>
+			<td class="infos">{current_version}</td>
+		</tr>
+		<tr class="row_off">
+			<td class="description_small" valign="top">{lang_uploaded_by}:</td>
+			<td class="infos">
+				<a class="infos" href="mailto:{updater_email}">{updater_fullname}</a>
+			</td>
+			<td class="description_small" valign="top">{lang_file_size}:</td>
+			<td class="infos">{file_size} bytes</td>
+		</tr>
+		<tr class="row_off">
+			<td class="description_small" valign="top">{lang_comment_for_current_version}:</td>
+			<td class="infos" valign="top" colspan="3">{current_comment}</td>
+		</tr>
+		<tr>
+			<td class="description_small" valign="top">{lang_mime_type}:</td>
+			<td class="infos" colspan="3">
+				<img align="absmiddle" src="images/icons/<?php print getMimeIcon($latestContent->getFileType());?>"> 
+				{mime_type}
+			</td>
+		</tr>
+	</table>
+	</fieldset>
+	</form>
+<!-- END information_rw -->
+
+<!-- BEGIN block_download -->
+<a href="{download_link}"><img src="{download_image}" align="middle" border="0">{lang_download}</a>
+<!-- END block_download -->
+
+<!-- BEGIN block_view_online -->
+<a target="_blank" href="{view_link}"><img src="{view_image}" align="middle" border="0">{lang_view_online}</a>
+<!-- END block_view_online -->
+
+<!-- BEGIN block_delete -->
+<a href="{delete_link}" onClick="return confirm('{lang_confirm_delete}');"><img src="{delete_image}" align="middle" border="0">{lang_delete}</a>
+<!-- END block_delete -->
+
+<!-- BEGIN notification_row -->
+	<tr>
+		<td><img src="{notify_image}" width=16 height=16></td>
+		<td class="notifylist">{notify_username}</td>
+		<td align="right"><a href="{link_notify_delete}"><img title="{lang_delete_this_notification}" src="{delete_image}" width=15 height=15 border=0></a>
+	</tr>
+<!-- END notification_row -->
+
+<!-- BEGIN block_change_owner -->
+	<form name="change_owner" action="{action_change_owner}" method="post">
+		<fieldset><legend>{lang_owner}</legend>
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td>
+					{select_ownerid}
+				</td>
+			</tr>
+		</table>
+		</fieldset>
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td>&nbsp;</td>
+			</tr>
+		</table>
+	</form>
+<!-- END block_change_owner -->
+
+<!-- BEGIN block_acl_inherite -->
+	<fieldset><legend>{lang_acl}</legend>
+	<div>{lang_acl_get_inherited}</div>
+	<p>
+	<a href="{link_acl_copy}">{lang_copy_acl}</a><br>
+	<a href="{link_acl_empty}">{lang_create_empty_acl}</a><br>
+	</fieldset>
+<!-- END block_acl_inherite -->
+
+<!-- BEGIN block_acl_notinherite -->
+	<fieldset><legend>{lang_acl}</legend>
+	<div>{lang_inherite_acl_again}</div>
+	<p>
+	<a href="{link_acl_inherit_again}">{lang_inherit_acl_again}</a><br>
+
+	<fieldset><legend>{lang_default_access}</legend>
+	<form name="change_default_access" action="{action_change_default_access}" method="post">
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td>
+					{select_default_access}
+				</td>
+			</tr>
+		</table>
+	</form>
+	</fieldset>
+
+	<fieldset><legend>{lang_current_acl}</legend>
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td></td>
+				<td class="accessList" style="border-bottom: 1pt solid #000080;"><i>{lang_name}</i></td>
+				<!-- <td rowspan="<?php print $rownum;?>" style="border-left: 1pt solid #000080;">&nbsp;</td> -->
+				<td class="accessList" style="border-bottom: 1pt solid #000080;"><i>{lang_access_mode}</i></td>
+				<td></td>
+				<td></td>
+			</tr>
+			{acls}
+		</table>
+	</fieldset>
+
+	<fieldset><legend>{lang_add_acl}</legend>
+	<form name="add_acl" action="{action_add_acl}" method="post">
+		<table cellspacing="0" cellpadding="5" border="0" width="100%">
+			<tr>
+				<td class="inputDescription">{lang_user}:</td>
+				<td>
+					{select_add_acl_userid}
+				</td>
+				<td rowspan="3">
+					<input type="Submit">
+				</td>
+			</tr>
+			<tr>
+				<td class="inputDescription">{lang_group}:</td>
+				<td>
+					{select_add_acl_groupid}
+				</td>
+			</tr>
+			<tr>
+				<td class="inputDescription">{lang_permission}:</td>
+				<td>
+					{select_add_acl_permission}
+				</td>
+			</tr>
+		</table>
+	</form>
+	</fieldset>
+
+	</fieldset>
+<!-- END block_acl_notinherite -->
+
+<!-- BEGIN acl_row -->
+	<form method="post" action="{action_acl_row}">
+	<tr>
+		<td width="20px"><img src="{acl_image}" width=16 height=16></td>
+		<td class="acllist">{acl_username}</td>
+		<td class="acllist" width="310px">{acl_selectbox}</td>
+		<td width="20px"><input type="Image" src="{save_image}" alt="{lang_save}"></td>
+		<td width="20px" align="right"><a href="{link_acl_delete}" onClick="return confirm('{lang_confirm_acl_delete}');"><img title="{lang_delete_this_acl}" alt="{lang_delete}" src="{delete_image}" width=15 height=15 border=0></a>
+	</tr>
+	</form>
+<!-- END acl_row -->
+
Index: contrib/resources/templates/default/app.css
===================================================================
--- contrib/resources/templates/default/app.css	(revision 3524)
+++ contrib/resources/templates/default/app.css	(revision 3524)
@@ -0,0 +1,5 @@
+/* $Id: app.css 22414 2006-09-12 10:37:13Z ralfbecker $ */
+.redItalic { color: red; font-style: italics; }
+.titleSum,.titleDetails { font-weight: bold; }
+.noWrap { white-space: nowrap; }
+.width100 { width: 100%; }
Index: contrib/resources/templates/default/hr.tpl
===================================================================
--- contrib/resources/templates/default/hr.tpl	(revision 3524)
+++ contrib/resources/templates/default/hr.tpl	(revision 3524)
@@ -0,0 +1,6 @@
+ <tr>
+  <td colspan="2">
+   {hr_text}
+  </td>
+ </tr>
+
Index: contrib/resources/templates/default/view.tpl
===================================================================
--- contrib/resources/templates/default/view.tpl	(revision 3524)
+++ contrib/resources/templates/default/view.tpl	(revision 3524)
@@ -0,0 +1,46 @@
+
+<!-- BEGIN view_event -->
+<center>
+<table id="calendar_view_event" border="0" width="90%">
+	{row}
+	<tr>
+		<td>
+			<table id="calendar_viewevent_button_left" cellspacing="5">
+				<tr>
+					{button_left}
+				</tr>
+			</table>
+		</td>
+	   <td align="center">
+			<table id="calendar_viewevent_button_center" cellspacing="5">
+				<tr>
+					{button_center}
+				</tr>
+			</table>
+		</td>
+		<td align="right">
+			<table id="calendar_viewevent_button_right" cellspacing="5">
+				<tr>
+					{button_right}
+				</tr>
+			</table>
+		</td>
+	</tr>
+</table>
+</center>
+<!-- END view_event -->
+
+<!-- BEGIN list -->
+	<tr bgcolor="{tr_color}">
+		<td valign="top" width="30%">&nbsp;<b>{field}:</b></td>
+		<td colspan="2" valign="top" width="70%">{data}</td>
+	</tr>
+<!-- END list -->
+
+<!-- BEGIN hr -->
+	<tr>
+		<td colspan="3" bgcolor="{th_bg}" align="center">
+			<b>{hr_text}</b>
+		</td>
+	</tr>
+<!-- END hr -->
Index: contrib/resources/templates/default/delete_common.tpl
===================================================================
--- contrib/resources/templates/default/delete_common.tpl	(revision 3524)
+++ contrib/resources/templates/default/delete_common.tpl	(revision 3524)
@@ -0,0 +1,16 @@
+<!-- BEGIN form -->
+ <center>
+  <table border="0" with="65%">
+   <tr>
+    <td colspan="2" align="center">
+     {messages}
+    </td>
+   </tr>
+   <tr>
+    <td align="center">{no}</td>
+    <td align="center">{yes}</td>
+   </tr>
+  </table>
+ </center>
+<!-- END form -->
+
Index: contrib/resources/templates/default/list.tpl
===================================================================
--- contrib/resources/templates/default/list.tpl	(revision 3524)
+++ contrib/resources/templates/default/list.tpl	(revision 3524)
@@ -0,0 +1,6 @@
+<!-- BEGIN list -->
+ <tr>
+  <td valign="top" width="35%"><b>{field}:</b></td>
+  <td valign="top" width="65%">{data}</td>
+ </tr>
+<!-- END list -->
Index: contrib/resources/templates/default/mini_cal.tpl
===================================================================
--- contrib/resources/templates/default/mini_cal.tpl	(revision 3524)
+++ contrib/resources/templates/default/mini_cal.tpl	(revision 3524)
@@ -0,0 +1,42 @@
+
+<!-- BEGIN mini_cal -->
+
+	<table id="calendar_minical_table" class="calendar_minical_table" border=0 cellspacing="0" cellpadding="0">
+		<tr>
+			<td style="padding-left: 8px; font-weight: bold; text-align: left;">
+				{month}
+			</td>
+			<td align="right">
+				<!-- why empty? -->
+				{prevmonth}&nbsp;&nbsp;{nextmonth}
+			</td>
+		</tr>
+		<tr>
+			<td  style="padding-left: 8px; text-align: left;">
+<!--				<img src="{cal_img_root}" width="90%" height="1"> -->
+					<hr class="calendar_minical_hrule">
+			</td>
+		</tr>
+		<tr valign="top">
+			<td>
+				<table id="calendar_minical_daytable" class="calendar_minical_daytable" cellspacing="5" cellpadding="0">
+					<tr>{daynames}</tr>
+						{display_monthweek}
+				</table>
+
+			</td>
+	 	</tr>
+	</table>
+<!-- END mini_cal -->
+
+<!-- BEGIN mini_week -->
+	<tr>
+		{monthweek_day}
+	</tr>
+<!-- END mini_week -->
+
+<!-- BEGIN mini_day -->
+		<td class="calendar_minical_dayname" {day_image}>
+			{dayname}
+		</td>
+<!-- END mini_day -->
Index: contrib/resources/templates/default/link_pict.tpl
===================================================================
--- contrib/resources/templates/default/link_pict.tpl	(revision 3524)
+++ contrib/resources/templates/default/link_pict.tpl	(revision 3524)
@@ -0,0 +1,25 @@
+
+<!-- BEGIN link_pict -->
+{picture}
+<!-- END link_pict -->
+
+<!-- BEGIN link_open -->
+<div id="calendar_event_entry" style="overflow:hidden;">
+<a class="event_entry" href="{link_link}" onMouseOver="window.status='{lang_view}'; return true;" onMouseOut="window.status=''; return true;" title="{desc} {location}"><br>
+<!-- END link_open -->
+
+<!-- BEGIN pict -->
+ <img src="{pic_image}" width="{width}" height="{height}" title="{title}" border="0" />
+<!-- END pict -->
+
+<!-- BEGIN link_text_old -->
+<nobr>&nbsp;{time}&nbsp;</nobr> {title}&nbsp;{users_status}: <i>{desc}</i><!--({location})-->
+<!-- END link_text_old -->
+
+<!-- BEGIN link_text -->
+&nbsp;<FONT SIZE=1><span style="color: black">{time}</span> {users_status}<br><b>{title}</b><br><i>{desc}</i> {location}
+<!-- END link_text -->
+
+<!-- BEGIN link_close -->
+</a></div>
+<!-- END link_close -->
Index: contrib/resources/templates/default/day.tpl
===================================================================
--- contrib/resources/templates/default/day.tpl	(revision 3524)
+++ contrib/resources/templates/default/day.tpl	(revision 3524)
@@ -0,0 +1,39 @@
+<!-- BEGIN day -->
+{printer_friendly}
+<table id="calendar_dayview_table" class="calendar_dayview_table" border="0" width="100%">
+	<tr>
+		<td valign="top" width="70%">
+			<table id="calendar_dayview1" border="0" width=100%>
+				<tr>
+					<td class="calendar_dayview_table_header">
+      					{date}&nbsp;<span class="calendar_user_identifier">:&nbsp;{username}&nbsp;:</span>
+						<br />
+     				</td>
+    			</tr>
+				{day_events}
+   			</table>
+   			<p align="center">{print}</p>
+  		</td>
+ 		 <td align="center" valign="top">
+  			 <table id="calendar_dayview2" width="100%">
+    			<tr>
+     				<td align="center">
+						{small_calendar}
+     				</td>
+    			</tr>
+
+   			</table>
+  		</td>
+ 	</tr>
+</table>
+<!-- END day -->
+
+<!-- BEGIN day_event -->
+	<tr>
+		<td>
+
+			{daily_events}
+
+		</td>
+	</tr>
+<!-- END day_event -->
Index: contrib/resources/templates/default/js/edit_exmail.js
===================================================================
--- contrib/resources/templates/default/js/edit_exmail.js	(revision 3524)
+++ contrib/resources/templates/default/js/edit_exmail.js	(revision 3524)
@@ -0,0 +1,393 @@
+/******************************************************************************\
+|**************************   CALENDAR MODULE   *******************************|
+|********** INCLUDE PARTICIPANTS - PLUGIN USING AJAX EXPRESSOMAIL COMPONENT  **|
+\******************************************************************************/
+var contacts = '';
+var expresso_offline = '';
+var array_lang = new Array();
+var finderTimeout = '';
+// onUnload edit message
+if(!document.all)
+{
+	var beforeunload = window.onbeforeunload;
+	window.onbeforeunload = function()
+	{
+		if ( typeof beforeunload == 'function' )
+			beforeunload();
+	};
+}
+	
+// Verifica versão do Firefox
+var agt = navigator.userAgent.toLowerCase();
+var is_firefox_0 = agt.indexOf('firefox/1.0') != -1 && agt.indexOf('firefox/0.') ? true : false;
+
+var handler_get_available_users = function(data)
+{	
+	select_available_users = Element('user_list_in');
+	
+	for(var i=0; i<select_available_users.options.length; i++){
+		select_available_users.options[i] = null;
+		i--;
+	}
+	var options = '###';
+	if (data) {
+		if(data.groups && data.groups.length > 0) {
+			data.groups = '<option  value="-1" disabled>------------------- '+Element("txt_groups").value+' ------------------ </option>' + data.groups;
+		}		
+		if(data.users && data.users.length > 0) {
+			data.users = '<option  value="-1" disabled>------------------- '+Element("txt_users").value+' ------------------ </option>' + data.users;
+		}
+		options +=  data.groups && data.groups.length > 0 ? data.groups : '';
+		options +=  data.users  && data.users.length  > 0 ? data.users  : '';
+		
+		if(is_firefox_0)
+			fixBugInnerSelect(select_available_users,options);
+		else
+			select_available_users.innerHTML = options;
+
+		select_available_users.outerHTML = select_available_users.outerHTML;
+		select_available_users.disabled = false;
+		select_available_users_clone = Element('user_list_in').cloneNode(true);		
+	}
+}	
+
+function get_available_users(module,context,type, autoSearch){
+	Element('cal_input_searchUser').value = '';
+	if(autoSearch != 'True'){
+		return true;
+	}
+	var context = document.getElementById('combo_org').value;	
+	cExecute (module+'.ldap_functions.get_available_users&context='+context+'&type='+type, handler_get_available_users);
+}
+
+function optionFinderTimeout(obj, numMin, type, autoSearch){
+	var oWait = Element("cal_span_searching");
+	oWait.innerHTML = 'Buscando...';
+	clearTimeout(finderTimeout);		
+	
+	if(autoSearch == "True"){
+		finderTimeout = setTimeout("optionFinderLocal('"+obj.id+"')",500);
+	}
+	else if (obj.value.length >= numMin){
+		finderTimeout = setTimeout("optionFinderLdap('"+obj.id+"','"+numMin+"','"+type+"')",500);
+	}else {
+		oWait.innerHTML = 'Mínimo de '+numMin+' letras para pesquisa';
+		var select_available_users_tmp = document.getElementById('user_list_in');
+		for(var i = 0;i < select_available_users_tmp.options.length; i++)
+		select_available_users_tmp.options[i--] = null;
+	}
+}
+// Pesquisa Javascript
+function optionFinderLocal(id){
+	var oText = Element(id);
+	var oWait = Element("cal_span_searching");
+	var select_available_users_tmp = Element('user_list_in');
+	for(var i = 0;i < select_available_users_tmp.options.length; i++)
+		select_available_users_tmp.options[i--] = null;
+	var RegExp_name = new RegExp("\\b"+oText.value, "i");
+
+	for(i = 0; i < select_available_users_clone.length; i++){
+		if (RegExp_name.test(select_available_users_clone[i].text) || select_available_users_clone[i].value =="-1")
+		{
+			sel = select_available_users_tmp.options;
+			option = new Option(select_available_users_clone[i].text,select_available_users_clone[i].value);
+			if( select_available_users_clone[i].value == "-1") option.disabled = true;
+			sel[sel.length] = option;
+		}
+	}
+	oWait.innerHTML = '&nbsp;';	
+}
+
+// Pesquisa LDAP
+function optionFinderLdap(id,numMin, type){
+		var oWait = Element("cal_span_searching");
+		var oText = Element(id);
+			
+		if (oText.value.length < numMin) {
+				oWait.innerHTML = '';
+				var select_available_users_tmp = document.getElementById('user_list_in');
+				for(var i = 0;i < select_available_users_tmp.options.length; i++)
+					select_available_users_tmp.options[i--] = null;
+		}
+		
+		if (oText.value.length >= numMin){
+			var context = document.getElementById('combo_org').value;
+			cExecute ('expressoMail1_2.ldap_functions.search_users&context='+(context)+'&type='+(type == '' ? 'list' : 'search')+'&filter='+oText.value, handler_get_available_users);
+			oWait.innerHTML = '&nbsp;';
+		}
+}
+
+function add_user()
+{
+	var select_available_users = document.getElementById('user_list_in');
+	var select_users = document.getElementById('user_list');
+	var count_available_users = select_available_users.length;
+	var count_users = select_users.options.length;
+	var new_options = '';
+	
+	for (i = 0 ; i < count_available_users ; i++) {
+		if (select_available_users.options[i].selected)	{
+			if(document.all) {
+				if ( (select_users.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) {
+					new_options +=  '<option value='
+								+ select_available_users.options[i].value
+								+ '>'
+								+ select_available_users.options[i].text
+								+ '</option>';
+				}
+			}
+			else if ( (select_users.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) {
+					new_options +=  '<option value='
+								+ select_available_users.options[i].value
+								+ '>'
+								+ select_available_users.options[i].text
+								+ '</option>';
+			}
+		}
+	}
+
+	if (new_options != '') {
+
+		if(is_firefox_0)
+			fixBugInnerSelect(select_users,'###' + new_options + select_users.innerHTML);
+		else
+			select_users.innerHTML = '###' + new_options + select_users.innerHTML;
+
+		select_users.outerHTML = select_users.outerHTML;
+	}
+}
+
+function remove_user(){
+	select_users = document.getElementById('user_list');
+	
+	for(var i = 0;i < select_users.options.length; i++)
+		if(select_users.options[i].selected)
+			select_users.options[i--] = null;
+}
+
+function submitValues(){
+	var typeField = document.getElementById('cal[type]');
+	if (typeField && typeField.value == 'hourAppointment') {
+		if(document.getElementsByName('categories[]')[0].value == ""){
+			alert(alert_msg);
+			return false;
+		}
+	}
+	var select_in = document.getElementById('user_list');
+	for(i = 0; i < select_in.length; i++)
+	 	select_in.options[i].selected = true;
+}	
+
+function Element(id){
+	return document.getElementById(id);
+}
+
+function loadScript(scriptPath){
+
+	if(!connector)
+		throw new Error("Error : Connector is not loaded.");
+		
+  	if (document.getElementById('uploadscript_'+scriptPath)) {
+  		return;
+   	}
+  	
+	connector.oxmlhttp.open("GET", scriptPath, false);
+    connector.oxmlhttp.setRequestHeader('Content-Type','text/plain');
+	connector.oxmlhttp.send(null);
+	if(connector.oxmlhttp.status != 0 && connector.oxmlhttp.status != 200 || 	connector.oxmlhttp.status == 0 && connector.oxmlhttp.responseText.length == 0)
+		throw new Error("Error " + connector.oxmlhttp.status + "("+connector.oxmlhttp.statusText+") when loading script file '"+scriptPath+"'");
+	
+	var head = document.getElementsByTagName("head")[0];
+	var script = document.createElement("SCRIPT");
+	script.id = 'uploadscript_'+scriptPath;
+	script.type = 'text/javascript';		
+	script.text = connector.oxmlhttp.responseText;
+	head.appendChild(script);
+	return;	
+}
+
+function showExParticipants(el,path){
+	Element('tbl_ext_participants').style.display='';
+	el.style.display='none';
+	loadScript(path+"/js/DropDownContacts.js");
+	loadScript(path+"/js/common_functions.js");
+	loadScript(path+"/js/QuickCatalogSearch.js");
+	loadScript("calendar/templates/default/js/over_fn_exmail.js");
+	if(!contacts)
+		cExecute (path+'.db_functions.get_dropdown_contacts', save_contacts);
+}
+
+function hideExParticipants(el,path){
+	Element('a_ext_participants').style.display = '';
+	Element('tbl_ext_participants').style.display ='none';
+}
+
+function save_contacts(data){
+	contacts = data;	
+	var input_to = Element("ex_participants");
+	input_to.style.width = "100%";
+	input_to.setAttribute("wrap","soft");	
+	input_to.onfocus = function(){clearTimeout(parseInt(setTimeOutLayer)); search_contacts('onfocus', this.id);};
+	input_to.onblur = function(){setTimeOutLayer=setTimeout('search_contacts("lostfocus","'+this.id+'")',100);};
+	if (!is_ie)
+	{
+		input_to.rows = 2;
+		input_to.onkeypress = function (e)
+		{
+			if ((e.keyCode) == 120) //F9
+			{
+				emQuickSearch(input_to);
+			}
+			else 
+			{ 
+				if (((e.keyCode == 13) || ((e.keyCode == 38)||(e.keyCode == 40))) && (document.getElementById('tipDiv').style.visibility!='hidden'))
+				{
+					e.preventDefault();
+					search_contacts(e.keyCode,this.id);
+				}
+			}
+		}
+		input_to.onkeyup = function (e)
+		{
+			if ((e.keyCode != 13) && (e.keyCode != 38) && (e.keyCode != 40))
+			{
+				search_contacts(e.keyCode,this.id);
+			}
+		}
+	}
+	else
+	{
+		input_to.rows = 3;
+		input_to.onkeyup = function (e)
+		{
+			if ((window.event.keyCode) == 120) //F9
+			{
+				emQuickSearch(input_to);
+			}
+			else 
+			{ 
+				search_contacts(window.event.keyCode,this.id);
+			}	
+		}
+	}
+}
+
+function fixBugInnerSelect(objeto,innerHTML){
+/******
+* select_innerHTML - altera o innerHTML de um select independente se é FF ou IE
+* Corrige o problema de não ser possível usar o innerHTML no IE corretamente
+* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
+* Use a vontade mas coloque meu nome nos créditos. Dúvidas, me mande um email.
+* Versão: 1.0 - 06/04/2006
+* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
+* Parametros:
+* objeto(tipo object): o select a ser alterado
+* innerHTML(tipo string): o novo valor do innerHTML
+*******/
+    objeto.innerHTML = ""
+    var selTemp = document.createElement("micoxselect")
+    var opt;
+    selTemp.id="micoxselect1"
+    document.body.appendChild(selTemp)
+    selTemp = document.getElementById("micoxselect1")
+    selTemp.style.display="none"
+    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
+        innerHTML = "<option>" + innerHTML + "</option>"
+    }
+    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
+    selTemp.innerHTML = innerHTML
+    for(var i=0;i<selTemp.childNodes.length;i++){
+        if(selTemp.childNodes[i].tagName){
+            opt = document.createElement("OPTION")
+            for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
+                opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
+            }
+            opt.value = selTemp.childNodes[i].getAttribute("value")
+            opt.text = selTemp.childNodes[i].innerHTML
+            if(document.all){ //IEca
+                objeto.add(opt)
+            }else{
+                objeto.appendChild(opt)
+            }                    
+        }    
+    }
+    document.body.removeChild(selTemp)
+    selTemp = null
+}
+
+function changeViewMode(eltype){
+	var chValue = eltype;
+	switch (chValue){
+		case 'hourAppointment':
+			var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
+			for (var i=0; i < names.length; i++)
+			{
+				var Field = document.getElementsByName('cal['+names[i]+']');
+				if (Field[0])
+					Field[0].parentNode.parentNode.style.display = "none";
+			}
+
+			Field = document.getElementsByName('participants[]');
+			Field[0].parentNode.parentNode.style.display = "none";
+			Field[1].parentNode.parentNode.style.display = "none";
+			Field = document.getElementById('txt_loading');
+			Field.parentNode.parentNode.style.display = "none";
+			Field = document.getElementsByName('cal[rpt_day][]');
+			Field[0].parentNode.parentNode.style.display = "none";
+			break;
+		case 'privateHiddenFields':
+			var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
+			for (var i=0; i < names.length; i++)
+			{
+				var Field = document.getElementsByName('cal['+names[i]+']');
+				if (Field[0])
+					Field[0].parentNode.parentNode.style.display = "";
+			}
+			Field = document.getElementsByName('participants[]');
+			Field[0].parentNode.parentNode.style.display = "none";
+			Field[1].parentNode.parentNode.style.display = "none";
+			Field = document.getElementById('txt_loading');
+			Field.parentNode.parentNode.style.display = "none";
+			Field = document.getElementsByName('cal[rpt_day][]');
+			Field[0].parentNode.parentNode.style.display = "";
+			break;
+		default:
+			var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
+			for (var i=0; i < names.length; i++)
+			{
+				var Field = document.getElementsByName('cal['+names[i]+']');
+				if (Field[0])
+					Field[0].parentNode.parentNode.style.display = "";
+			}
+			Field = document.getElementsByName('participants[]');
+			Field[0].parentNode.parentNode.style.display = "";
+			Field[1].parentNode.parentNode.style.display = "";
+			Field = document.getElementById('txt_loading');
+			Field.parentNode.parentNode.style.display = "";
+			Field = document.getElementsByName('cal[rpt_day][]');
+			Field[0].parentNode.parentNode.style.display = "";
+			break;
+	}
+
+}
+function updateTitleField(select){
+	var typeField = document.getElementsByName('cal[type]');
+	if (typeField[0].value != 'hourAppointment')
+		return;
+	var titleField = document.getElementsByName('cal[title]');
+	var optionsArray = select.childNodes;
+	titleField[0].value = '';
+	for(option in optionsArray)
+		if (optionsArray[option].selected)
+			titleField[0].value += optionsArray[option].text + ' ';
+}
+
+var __onLoad = window.onload;
+window.onload = function(){ 
+	__onLoad();
+	var cal_type = document.getElementById('cal[type]').value;
+	changeViewMode(cal_type);
+	if(cal_type == 'hourAppointment'){
+		clearTimeout(timeout_get_available_users);
+	}
+};
Index: contrib/resources/templates/default/js/edit.js
===================================================================
--- contrib/resources/templates/default/js/edit.js	(revision 3524)
+++ contrib/resources/templates/default/js/edit.js	(revision 3524)
@@ -0,0 +1,101 @@
+/******************************************************************************\
+|**************************   MODULO   AGENDA   *******************************|
+|********** SCRIPT REFERENTE A CAIXA DE INCLUSAO DE PARTICIPANTES  ************|
+\******************************************************************************/
+
+// Variaveis Locais 
+	var select_in  = document.getElementById('user_list');
+	var select_out  = document.getElementById('user_list_in');	
+	var users_out = select_out ? select_out.cloneNode(true) : '';
+	var finderTimeout = '';
+																		
+// Funcoes				
+	function showExParticipants(el,path){
+		document.getElementById('tbl_ext_participants').style.display='';
+		el.style.display='none';
+	}
+	
+	function hideExParticipants(el,path){
+		document.getElementById('a_ext_participants').style.display = '';
+		document.getElementById('tbl_ext_participants').style.display ='none';
+	}
+							
+	function optionFinderTimeout(obj){
+
+		clearTimeout(finderTimeout);	
+		var oWait = document.getElementById("wait");
+		oWait.innerHTML = 'Buscando...';
+		finderTimeout = setTimeout("optionFinder('"+obj.id+"')",500);
+	}
+	function optionFinder(id) {	
+		var oWait = document.getElementById("wait");
+		var oText = document.getElementById(id);
+		for(var i = 0;i < select_out.options.length; i++)				
+			select_out.options[i--] = null;
+																							
+		for(i = 0; i < users_out.length; i++){																							
+			if(users_out[i].text.substring(0 ,oText.value.length).toUpperCase() == oText.value.toUpperCase()) {
+				sel = select_out.options;						
+				option = new Option(users_out[i].text,users_out[i].value);				
+				sel[sel.length] = option;
+			}
+		}
+		oWait.innerHTML = '&nbsp;';
+	}			
+									
+	function rem()
+	{
+		for(var i = 0;i < select_in.options.length; i++)				
+			if(select_in.options[i].selected)
+				select_in.options[i--] = null;																	
+	}
+		
+	function submitValues(alert_msg){
+		var typeField = document.getElementById('cal[type]');
+		if (typeField && typeField.value == 'hourAppointment')
+			if(document.getElementsByName('categories[]')[0].value == ""){
+				alert(alert_msg);
+				return false;
+				}
+		for(i = 0; i < select_in.length; i++)
+		 	select_in.options[i].selected = true;
+	}
+	
+	
+	
+	function openListUsers(newWidth,newHeight, owner){					
+		newScreenX  = screen.width - newWidth;		
+		newScreenY  = 0;		
+		window.open('calendar/templates/default/listUsers.php?owner='+owner,"","width="+newWidth+",height="+newHeight+",screenX="+newScreenX+",left="+newScreenX+",screenY="+newScreenY+",top="+newScreenY+",toolbar=no,scrollbars=yes,resizable=no");
+	}
+
+ 	function adicionaListaCalendar() 
+ 	{
+		var select = window.document.getElementById('user_list_in');
+		var selectOpener = window.opener.document.getElementById('user_list');
+		for (i = 0 ; i < select.length ; i++) {				
+
+			if (select.options[i].selected) {
+				isSelected = false;
+
+				for(var j = 0;j < selectOpener.options.length; j++) {																			
+					if(selectOpener.options[j].value == select.options[i].value){
+						isSelected = true;						
+						break;	
+					}
+				}
+
+				if(!isSelected){
+
+					option = window.opener.document.createElement('option');
+					option.value =select.options[i].value;
+					option.text = select.options[i].text;
+					selectOpener.options[selectOpener.options.length] = option;	
+				}
+				
+			}
+		}
+		selectOpener.options[selectOpener.options.length-1].selected = true;
+ 	}
+	
+// Fim        
Index: contrib/resources/templates/default/js/search.js
===================================================================
--- contrib/resources/templates/default/js/search.js	(revision 3524)
+++ contrib/resources/templates/default/js/search.js	(revision 3524)
@@ -0,0 +1,108 @@
+var searchTimeout;
+
+function lang(key){
+	return document.getElementById("txt_"+key).value;
+}
+
+function remove_user(id){
+	if(!confirm(lang("confirm")))
+		return true;	
+	var handler_rem_user = function(data){
+		if(data) {
+			var tr = document.getElementById(id);
+			tr.parentNode.removeChild(tr);
+		}
+	}	
+	cExecute ('calendar.uigroup_access.rem_user&id='+id, handler_rem_user);
+}
+function add_user(){
+	var select_users = document.getElementById("user");
+	var select_groups = document.getElementById("group");
+	var a_rights = new Array("L","A","E","R","P");
+	var rights = '';
+	for(var z = 0; z < a_rights.length; z++){
+		var check = document.getElementById("right_"+a_rights[z]);
+		if(check.checked){
+			rights += check.value;
+		}
+	}
+	if(!select_users.value){
+		alert(lang("nouser"));
+		return;
+	}
+	else if(!select_groups.value){
+		alert(lang("nogroup"));
+		return;
+	}
+	else if(!rights){
+		alert(lang("nopermissiontype"));
+		return;
+	}
+	
+	var str = select_users.value+";"+select_groups.value;
+	var handler_add_user = function(data){
+		
+		if(data){
+			var t = document.getElementById('tbody_list');
+			var tr = document.createElement("TR");
+			tr.bgColor = "#DCDCDC";
+			var td1 = document.createElement("TD");
+			var td2 = document.createElement("TD");
+			var td3 = document.createElement("TD");
+			var td4 = document.createElement("TD");
+			tr.id = str;
+			td1.innerHTML = "<b>&nbsp;&nbsp;"+select_users[select_users.selectedIndex].text+"</b>";
+			td2.innerHTML = rights;
+			td2.align = "center";
+			td3.innerHTML = "&nbsp;&nbsp;"+select_groups[select_groups.selectedIndex].text;
+			td4.innerHTML = "<button  title='remove' type='button' onClick='javascript:remove_user(\""+str+"\");'><img src='"+document.getElementById("template_set").value+"/images/delete.png' style='vertical-align: middle;'/></button>";
+			tr.appendChild(td1);
+			tr.appendChild(td2);
+			tr.appendChild(td3);
+			tr.appendChild(td4);
+			t.appendChild(tr);
+			alert(lang("success"));
+		}
+		else{
+			alert(lang("exist"));
+		}
+	}
+	cExecute ('calendar.uigroup_access.add_user&id='+str+"&rights="+rights, handler_add_user);
+	return true;
+		
+}
+function search_object(input, id_span, id_select, type)
+{
+	clearTimeout(searchTimeout);	
+	var spam = document.getElementById(id_span);
+	if (input.value.length <= 3){
+		spam.innerHTML = lang("typemoreletters").replace("X",4 - input.value.length);
+	}else{
+		spam.innerHTML = lang("searching")+'...';
+		searchTimeout = setTimeout("search_ldap('"+input.id+"','"+id_span+"','"+id_select+"','"+type+"')",750);
+	}
+}
+
+function search_ldap(id_input, id_span, id_select, type)
+{
+	var search = document.getElementById(id_input).value;
+	
+	var handler_search_user = function(data)
+	{
+		var spam = document.getElementById(id_span);
+		select_available_users = document.getElementById(id_select);
+		if (data.status == 'false')
+		{
+			spam.innerHTML = data.msg;
+			// Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
+			select_available_users.innerHTML = '#';
+			select_available_users.outerHTML = select_available_users.outerHTML;
+			return;
+		}	
+		spam.innerHTML = '';
+		// Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
+		select_available_users.innerHTML = '#' + data;
+		select_available_users.outerHTML = select_available_users.outerHTML;
+	}
+	cExecute ('calendar.uigroup_access.search_user&search='+search+"&type="+type, handler_search_user);
+}
Index: contrib/resources/templates/default/js/over_fn_exmail.js
===================================================================
--- contrib/resources/templates/default/js/over_fn_exmail.js	(revision 3524)
+++ contrib/resources/templates/default/js/over_fn_exmail.js	(revision 3524)
@@ -0,0 +1,163 @@
+/******************************************************************************\
+|**************************   CALENDAR MODULE   *******************************|
+|********** PLUGIN USING AJAX EXPRESSOMAIL COMPONENT - OVERWRITE FUNCTIONS   **|
+\******************************************************************************/
+
+/******************************************************************************\
+|** Function      : emQuickSearch *********************************************|
+|** Original File : <expressoMail_module>/js/common_functions.js **************|
+\******************************************************************************/
+window.onresize = function(){};
+function emQuickSearch(el){
+
+	var emailList = el.value;
+	var field = el.id;
+	var ex_participants = Element("ex_participants");
+	var quickSearchKeyBegin;
+	var quickSearchKeyEnd;
+	
+	var handler_emQuickSearch = function(data){
+		window_DropDownContacts = Element('tipDiv');
+		if (window_DropDownContacts.style.visibility != 'hidden'){
+			window_DropDownContacts.style.visibility = 'hidden';
+		}
+		
+		if ((!data.status) && (data.error == "many results")){
+			alert(get_lang('More than %1 results. Please, try to refine your search.',200));
+			return false;
+		}
+			
+		if (data.length > 0){
+			QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd);
+		}
+		else
+			alert(get_lang('None result was found.'));
+		return true;
+	}
+	ex_participants.focus(); 				//mecessary for IE.
+	var i = getPosition(ex_participants); //inputBox.selectionStart;
+	var j = --i;
+
+    while ((j >= 0) && (emailList.charAt(j) != ',')){j--};
+    quickSearchKeyBegin = ++j;
+
+    while ((i <= emailList.length) && (emailList.charAt(i) != ',')){i++};
+    quickSearchKeyEnd = i;
+
+    var search_for = trim(emailList.substring(quickSearchKeyBegin, quickSearchKeyEnd));
+
+	if (search_for.length < 4){
+		alert(get_lang('Your search argument must be longer than 4 characters.'));
+		return false;
+	}
+	
+	cExecute ("expressoMail1_2.ldap_functions.quicksearch&search_for="+search_for+"&field="+field, handler_emQuickSearch);
+}
+
+/******************************************************************************\
+|** Function      : emQuickCatalogSearch.prototype.transfer_result ************|
+|** Original File : <expressoMail_module>/js/QuickCatalogSearch.js ************|
+\******************************************************************************/
+emQuickCatalogSearch.prototype.transfer_result = function (field, ID, begin, end){
+	cm = document.getElementById('select_QuickCatalogSearch');
+	option_selected = cm.options[cm.selectedIndex].value + ", ";
+	emailList = Element("ex_participants").value;		
+	new_emailList = emailList.substring(0, begin) + option_selected + emailList.substring((parseInt(end) + 2), emailList.length);
+	document.getElementById("ex_participants").value = new_emailList;
+	if(is_ie)
+		Element("i_blank").style.display = "none";
+	document.getElementById("ex_participants").focus();
+	this.arrayWin['window_QuickCatalogSearch'].close();
+}
+
+/******************************************************************************\
+|** Function      : emQuickCatalogSearch.prototype.close_QuickSearch_window ***|
+|** Original File : <expressoMail_module>/js/QuickCatalogSearch.js ************|
+\******************************************************************************/
+emQuickCatalogSearch.prototype.close_QuickSearch_window = function (field, ID){
+	if(is_ie)
+		Element("i_blank").style.display = "none";
+	document.getElementById("ex_participants").focus();
+	this.arrayWin['window_QuickCatalogSearch'].close();
+}
+
+/******************************************************************************\
+|** Function      : emQuickCatalogSearch.prototype.showWindow *****************|
+|** Original File : <expressoMail_module>/js/QuickCatalogSearch.js ************|
+\******************************************************************************/
+emQuickCatalogSearch.prototype.showWindow = function (div)
+{
+	if(! div) {
+		alert(get_lang('The list has no participant.'));
+		return;
+	}
+						
+	if(! this.arrayWin[div.id]) {
+		div.style.width = "700px";
+		div.style.height = "230px";
+		var title = get_lang('The results were found in the Global Catalog')+':';
+		var wHeight = div.offsetHeight + "px";
+		var wWidth =  div.offsetWidth   + "px";
+		div.style.width = div.offsetWidth - 5;
+
+		win = new dJSWin({			
+			id: 'QuickCatalogSearch_'+div.id,
+			content_id: div.id,
+			width: wWidth,
+			height: wHeight,
+			y:'300px',
+			top: '300px',
+			title_color: '#3978d6',
+			bg_color: '#eee',
+			title: title,						
+			title_text_color: 'white',
+			button_x_img: 'phpgwapi/images/winclose.gif',
+			border: true });
+		
+		this.arrayWin[div.id] = win;
+		win.draw();
+	}
+	else {
+		win = this.arrayWin[div.id];
+	}
+
+	if(is_ie) {	
+		var _IFrame = Element("i_blank");
+		if(_IFrame){
+    		_IFrame.style.display  = '' ;		
+		}
+		else {
+			_IFrame = document.body.appendChild(document.createElement('iframe'));
+			_IFrame.src = 'about:blank' ;
+		    _IFrame.frameBorder		= '0';
+		    _IFrame.scrolling		= 'no' ;
+		    _IFrame.style.left		= findPosX(div)  + document.body.scrollLeft -5;
+			_IFrame.style.top		= findPosY(div)  + document.body.scrollTop  -20;
+		    _IFrame.width			= 610;
+   		    _IFrame.style.border	= 0;
+			_IFrame.height			= 285;
+			_IFrame.border			= 0;
+			_IFrame.id				= "i_blank";
+		    _IFrame.style.position	= 'absolute';
+	   	    _IFrame.style.zIndex	= '5';
+    		_IFrame.style.display  = '' ;
+		}
+	}
+
+	win.open();
+	document.getElementById('select_QuickCatalogSearch').focus();
+}	
+
+
+/******************************************************************************\
+|** Function      :  DRAG *****************************************************|
+|** Original File : phpgwapi/js/wz_dragdrop/wz_dragdrop.js ********************|
+\******************************************************************************/
+var over_fn_DRAG = DRAG;
+DRAG = function (event){
+
+		if(is_ie)
+			return false;
+		else
+			over_fn_DRAG(event);
+}		
Index: contrib/resources/templates/default/vcal_import.tpl
===================================================================
--- contrib/resources/templates/default/vcal_import.tpl	(revision 3524)
+++ contrib/resources/templates/default/vcal_import.tpl	(revision 3524)
@@ -0,0 +1,10 @@
+<!-- vcardin form -->
+{vcal_header}
+    <form ENCTYPE="multipart/form-data" method="POST" action="{action_url}">
+      <table border=0>
+      <tr>
+       <td>{ical_lang}: <input type="file" name="uploadedfile"></td>
+       <td><input type="submit" name="action" value="{load_vcal}"></td>
+      </tr>
+      </table>
+     </form>
Index: contrib/resources/templates/default/show.xet
===================================================================
--- contrib/resources/templates/default/show.xet	(revision 3524)
+++ contrib/resources/templates/default/show.xet	(revision 3524)
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<!-- $Id: show.xet 22492 2006-09-25 08:50:53Z ralfbecker $ -->
+<overlay>
+	<template id="resources.show.rows" template="" lang="" group="0" version="">
+		<grid>
+			<columns>
+				<column/>
+				<column/>
+				<column width="3%"/>
+				<column/>
+				<column/>
+				<column width="5%"/>
+			</columns>
+			<rows>
+				<row class="nmh">
+					<description/>
+					<vbox>
+						<nextmatch-sortheader label="Name" id="name"/>
+						<nextmatch-sortheader label="Short description" id="short_description"/>
+					</vbox>
+					<vbox>
+						<nextmatch-sortheader label="Useable" id="useable" statustext="How many of this resource are usable"/>
+						<nextmatch-sortheader label="Quantity" id="quantity" statustext="How many of this resource exists"/>
+					</vbox>
+					<vbox>
+						<nextmatch-sortheader label="Category" id="cat_id"/>
+						<description value="Administrator"/>
+					</vbox>
+					<vbox>
+						<nextmatch-sortheader label="Location" id="location"/>
+						<description value="Storage Inforation"/>
+					</vbox>
+					<hbox align="right">
+						<description value="Actions"/>
+						<description/>
+						<description needed="1"/>
+						<button image="check.png" label="Check all" align="right" id="check_all" statustext="Check all" needed="1" onclick="toggle_all(this.form,form::name('nm[rows][checkbox][]'),true); return false;"/>
+					</hbox>
+				</row>
+				<row class="nmr" valign="top">
+					<button align="center" id="${row}[picture_thumb]" image="$row_cont[picture_thumb]" onclick="window.open(egw::link('/index.php','menuaction=resources.ui_resources.show&amp;res_id=$row_cont[res_id]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes');return false;"/>
+					<vbox>
+						<description no_lang="1" id="${row}[name]"/>
+						<description no_lang="1" id="${row}[short_description]"/>
+					</vbox>
+					<vbox align="right">
+						<description no_lang="1" align="right" id="${row}[useable]"/>
+						<description no_lang="1" align="right" id="${row}[quantity]"/>
+					</vbox>
+					<vbox>
+						<menulist>
+							<menupopup type="select-cat" no_lang="1" id="${row}[cat_id]" readonly="true"/>
+						</menulist>
+						<menulist>
+							<menupopup type="select-account" no_lang="1" id="${row}[admin]" readonly="true"/>
+						</menulist>
+					</vbox>
+					<vbox>
+						<description no_lang="1" id="${row}[location]"/>
+						<description no_lang="1" id="${row}[storage_info]"/>
+					</vbox>
+					<grid>
+						<columns>
+							<column/>
+							<column/>
+							<column/>
+							<column/>
+						</columns>
+						<rows>
+							<row>
+								<button image="bookable" ro_image="trams16x16" label="Book this resource" align="center" statustext="Book this resource" onclick="window.open(egw::link('/index.php','menuaction=calendar.uiforms.edit&amp;participants=r$cont[res_id]'),'','dependent=yes,width=750,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;" id="bookable[$cont[res_id]]"/>
+								<button image="edit" ro_image="trans16x16" label="Edit" align="center" statustext="Edit this entry" onclick="window.open(egw::link('/index.php','menuaction=resources.ui_resources.edit&amp;res_id=$cont[res_id]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;" id="edit[$cont[res_id]]"/>
+								<button image="new" ro_image="trans16x16" label="Create new accessory for this resource" align="center" id="new_acc[$cont[res_id]]" statustext="Create new accessory for this resource" onclick="window.open(egw::link('/index.php','menuaction=resources.ui_resources.edit&amp;res_id=0&amp;accessory_of=$cont[res_id]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;"/>
+								<button image="view" ro_image="trans16x16" label="View" align="right" id="view[$cont[res_id]]" statustext="View this entry" onclick="window.open(egw::link('/index.php','menuaction=resources.ui_resources.show&amp;res_id=$cont[res_id]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;"/>
+							</row>
+							<row>
+								<button image="calendar" ro_image="trans16x16" label="Show calendar of resource" align="center" statustext="Show calendar of resource" id="calendar[$cont[res_id]]" onclick="location=egw::link('/index.php','menuaction=calendar.uiviews.planner&amp;sortby=user&amp;owner=0,r$cont[res_id]'); return false;"/>
+								<button label="Delete" align="center" id="delete[$cont[res_id]]" statustext="Delete this entry" onclick="return confirm('Do you really want do delte this resource?');" image="delete" ro_image="trans16x16"/>
+								<button image="view_acc" ro_image="trans16x16" label="View accessories for this resource" align="center" id="view_acc[$cont[res_id]]" statustext="View accessories for this resource"/>
+								<checkbox align="right" id="checkbox[]" options="$cont[res_id]"/>
+							</row>
+						</rows>
+					</grid>
+				</row>
+			</rows>
+		</grid>
+	</template>
+	<template id="resources.show" template="" lang="" group="0" version="">
+		<grid width="100%">
+			<columns>
+				<column width="100%"/>
+			</columns>
+			<rows>
+				<row>
+					<nextmatch options="resources.show.rows" no_lang="1" id="nm"/>
+				</row>
+				<row>
+					<grid width="100%">
+						<columns>
+							<column/>
+							<column width="1%"/>
+							<column width="1%"/>
+							<column width="1%"/>
+							<column width="47px"/>
+						</columns>
+						<rows>
+							<row>
+								<description/>
+								<button image="bookable" ro_image="trans16x16" label="book selected resources" statustext="book selected resources" align="right" onclick="var resources = js_btn_book_selected(this.form); if(resources == false) { return false; } else { window.open(egw::link('/index.php','menuaction=calendar.uiforms.edit')+'&amp;participants='+resources,'','dependent=yes,width=750,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false; }" needed="1" id="btn_book_selected"/>
+								<button label="Show calendar of resource" image="calendar" ro_image="trans16x16" id="btn_cal_selected" statustext="Show calendar of resource" align="right" onclick="var resources = js_btn_book_selected(this.form); if(resources == false) { return false; } else { location=egw::link('/index.php','menuaction=calendar.uiviews.planner')+'&amp;sortby=user&amp;owner=0,'+resources; return false; }" needed="1"/>
+								<button image="delete" label="delete selected resources" id="btn_delete_selected" statustext="delete selected resources" align="right" onclick="var resources = js_btn_book_selected(this.form); if(resources == false) { return false; } else { return confirm('Do you really want do delete the selected resources?'); }" needed="1"/>
+								<vbox>
+									<description/>
+									<button image="arrow_ltr" label="select/deselect all" statustext="select/deselect all" onclick="toggle_all(this.form,form::name('nm[rows][checkbox][]'),true); return false;" needed="1"/>
+									<description/>
+								</vbox>
+							</row>
+						</rows>
+					</grid>
+				</row>
+				<row>
+					<hbox>
+						<button label="Add" onclick="window.open(egw::link('/index.php','menuaction=resources.ui_resources.edit'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false; return false;" id="add"/>
+						<button label="Add accessory" id="add_sub" onclick="window.open(egw::link('/index.php','menuaction=resources.ui_resources.edit&amp;content=0&amp;accessory_of=$cont[view_accs_of]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;"/>
+						<button label="Back" id="back"/>
+					</hbox>
+				</row>
+			</rows>
+		</grid>
+	</template>
+</overlay>
Index: contrib/resources/templates/default/month_day.tpl
===================================================================
--- contrib/resources/templates/default/month_day.tpl	(revision 3524)
+++ contrib/resources/templates/default/month_day.tpl	(revision 3524)
@@ -0,0 +1,21 @@
+
+<!-- BEGIN m_w_table -->
+
+<table id="calendar_m_w_table" class="calendar_m_w_table" border="0" width="100%">
+	<! from month_header.tpl -->
+	{row}
+</table>
+<!-- END m_w_table -->
+
+<!-- BEGIN month_daily -->
+<span class="screen_only">[ </span><span class="calendar_m_w_table_daynumber" >{day_number}</span><span class="screen_only"> ]</span>{new_event_link}<br />
+    {daily_events}
+<!-- END month_daily -->
+
+<!-- BEGIN day_event -->
+{events}
+<!-- END day_event -->
+
+<!-- BEGIN event -->
+{day_events}
+<!-- END event -->
Index: contrib/resources/templates/default/preference_acl_row.tpl
===================================================================
--- contrib/resources/templates/default/preference_acl_row.tpl	(revision 3524)
+++ contrib/resources/templates/default/preference_acl_row.tpl	(revision 3524)
@@ -0,0 +1,7 @@
+<!-- $Id: preference_acl_row.tpl 20159 2005-12-19 04:23:14Z ralfbecker $ -->
+   <tr class="{row_class}">
+    <td>{user}</td>
+    <td align="center"><input type="checkbox" name="{read}" value="Y"{read_selected}></td>
+    <td align="center"><input type="checkbox" name="{edit}" value="Y"{edit_selected}></td>
+    <td align="center"><input type="checkbox" name="{delete}" value="Y"{delete_selected}></td>
+   </tr>
Index: contrib/resources/templates/default/edit.tpl
===================================================================
--- contrib/resources/templates/default/edit.tpl	(revision 3524)
+++ contrib/resources/templates/default/edit.tpl	(revision 3524)
@@ -0,0 +1,123 @@
+<!-- BEGIN edit_entry -->
+<style type="text/css">
+div#tipDiv {
+  position:absolute; visibility:hidden; left:0; top:0; z-index:10000;
+  background-color:#EFEFEF; border:1px solid #337;
+  width:220px; padding:3px;
+  color:#000; font-size:11px; line-height:1.2;
+  cursor: default;
+}
+</style>
+
+
+
+<style type="text/css">
+<!--
+.hideFrom input { display: none; }
+.link_select select { width: 250px; }
+-->
+</style>
+
+
+
+
+<div class="sideboxSpace"></div>
+
+<table id="calendar_head_table" class="calendar_head_table" border="0" width="100%" cols="{cols}" cellpadding="6" cellspacing="0">
+	<tr>
+		<td rowspan=10>
+	
+	<div id="divSubContainer">
+		<table cellpadding="0" cellspacing="0" width="100%">
+		<tbody><tr>
+		<!-- Sidebox Column -->
+<td id="tdSidebox" valign="top"><div id="thesideboxcolumn" style="width: 203px;"><div id="sideresize"></div>
+<div class="divSidebox">
+	<div class="divSideboxHeader"><span>Recursos Men&uacute;</span></div>
+
+	<div>
+		<table cellpadding="0" cellspacing="0" width="100%">
+		<tbody><tr class="divSideboxEntry">
+			<td class="textSidebox" align="center" valign="middle" width="20"><img class="sideboxstar" src="/resources/templates/default/images/orange-ball.png" alt="ball" height="9" width="9"></td><td class="textSidebox"><a class="textSidebox" href="index.php?menuaction=resources.uiresources.search">Lista del registro</a></td>
+		</tr>
+		<tr class="divSideboxEntry">
+			<td class="textSidebox" align="center" valign="middle" width="20"><img class="sideboxstar" src="/resources/templates/default/images/orange-ball.png" alt="ball" height="9" width="9"></td><td class="textSidebox"><a class="textSidebox" href=""></a><a class="textSidebox" href="index.php?menuaction=resources.uiresources.edit"  >A&ntilde;adir</a></td>
+		</tr>
+
+		</tbody></table>	
+	</div>
+</div>
+
+<div class="sideboxSpace"></div>
+
+</td> <td>  
+<font color="#000000" face="{font}">
+
+<form action="{action_url}" method="post" name="app_form">
+{common_hidden}
+<table id="editFormTable" border="0" width="90%"   class="prefTable">
+ <tr>
+  <td colspan="2">
+   <center><font size="+1"><b id="formStatus">{errormsg}</b></font></center>
+  </td>
+ </tr>
+{row}
+
+ <tr>
+  <td>
+  <table><tr valign="top">
+  <td>
+  <div style="padding-top:15px; padding-right: 2px">
+  	<script language="JavaScript">
+		var alert_field = '{alert_msg}';
+	</script>
+  	<center><input id="submit_button" style="font-size:10px" type="submit" value="{submit_button}" onClick="return submitValues(alert_field);"></center></div></form>
+  </td>
+  <td>{cancel_button}</td>
+  </tr></table>
+  </td>
+  <td align="right"></td>
+ </tr>
+</table>
+</font>
+</center>
+
+<table width="100%">
+	<tbody>
+
+<!-- END edit_entry -->
+<!-- BEGIN list -->
+ <tr bgcolor="{tr_color}">
+  <td valign="top" width="25%">&nbsp;<b>{field}:</b></td>
+  <td valign="top" width="75%">{data}</td>
+ </tr>
+
+<!-- END list -->
+
+<tr>
+<td>
+
+</td>
+</tr>
+<!-- BEGIN hr -->
+ <tr bgcolor="{tr_color}">
+  <td colspan="2">
+  {hr_text}
+  </td>
+ </tr>
+<!-- END hr -->
+</tbody>
+</table>
+
+
+
+
+
+
+
+
+
+</td>
+	</tr>
+</table>
+
Index: contrib/resources/templates/default/showdetails.xet
===================================================================
--- contrib/resources/templates/default/showdetails.xet	(revision 3524)
+++ contrib/resources/templates/default/showdetails.xet	(revision 3524)
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<!-- $Id: showdetails.xet 19840 2005-11-14 21:40:50Z nelius_weiss $ -->
+<overlay>
+	<template id="resources.showdetails" template="" lang="" group="0" version="">
+		<grid width="750" height="480">
+			<columns>
+				<column width="43%"/>
+				<column width="100%"/>
+			</columns>
+			<rows>
+				<row class="nmh" height="240px">
+					<image src="resource_picture" align="center"/>
+					<grid>
+						<columns>
+							<column/>
+							<column/>
+						</columns>
+						<rows>
+							<row>
+								<description options="b" value="Name:"/>
+								<description options="b" no_lang="1" id="name"/>
+							</row>
+							<row>
+								<description value="Inventory number:"/>
+								<description no_lang="1" id="inventory_number"/>
+							</row>
+							<row>
+								<description value="Category:"/>
+								<menulist>
+									<menupopup type="select-cat" id="cat_id" readonly="true"/>
+								</menulist>
+							</row>
+							<row>
+								<description value="Responsible: "/>
+								<menulist>
+									<menupopup type="select-account" id="cat_admin" readonly="true"/>
+								</menulist>
+							</row>
+							<row valign="top">
+								<description value="Quantity: "/>
+								<description id="quantity"/>
+							</row>
+							<row>
+								<description value="Useable:"/>
+								<description id="useable"/>
+							</row>
+							<row>
+								<description value="Location:"/>
+								<description no_lang="1" id="location"/>
+							</row>
+							<row>
+								<description value="Storage information:"/>
+								<description id="storage_info"/>
+							</row>
+						</rows>
+					</grid>
+				</row>
+				<row>
+					<description/>
+					<description/>
+				</row>
+				<row height="1%">
+					<html span="2" id="description" readonly="true"/>
+				</row>
+				<row>
+					<description/>
+					<description/>
+				</row>
+				<row class="th" disabled="@!link_to">
+					<description span="2" data="" rows="1" cols="4" value="Related links"/>
+				</row>
+				<row class="row_off" valign="top">
+					<link-list span="all" id="link_to" readonly="true"/>
+				</row>
+				<row>
+					<hbox label="Cancel" span="2" 3="label" 4="button">
+						<hbox label="Edit" span="2" id="btn_edit">
+							<button label="Edit" span="2" id="btn_edit" statustext="Buy this article"/>
+							<button label="Cancel" onclick="window.close()"/>
+							<button label="Calendar" span="2" id="btn_calendar" statustext="Show calendar of resource" onclick="opener.location=egw::link('/index.php','menuaction=calendar.uiviews.month&amp;owner=r$cont[res_id]'); return false;"/>
+							<button label="Book" onclick="window.open(egw::link('/index.php','menuaction=calendar.uiforms.edit&amp;participants=r$cont[res_id]'),'','dependent=yes,width=750,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes');" id="btn_book" statustext="Book this resource"/>
+						</hbox>
+						<hbox align="right">
+							<button label="Delete" onclick="return confirm('Do you really want do delte this resource?');" id="btn_delete"/>
+						</hbox>
+					</hbox>
+				</row>
+			</rows>
+		</grid>
+	</template>
+</overlay>
Index: contrib/resources/templates/default/matrix_query.tpl
===================================================================
--- contrib/resources/templates/default/matrix_query.tpl	(revision 3524)
+++ contrib/resources/templates/default/matrix_query.tpl	(revision 3524)
@@ -0,0 +1,25 @@
+<!-- BEGIN matrix_query -->
+<center>
+<form action="{action_url}" method="post" name="matrixform">
+<table border="0" width="90%">
+ <tr bgcolor="{th_bg}">
+  <td colspan="2" align="center"><b>{title}</b></td>
+ </tr>
+ {rows}
+ <tr>
+  <td>
+   <table cellspacing="5"><tr>
+    <td><input type="submit" value="{submit_button}"></form></td>
+    <td>{cancel_button}</td>
+   </tr></table>
+  </td>
+ </tr>
+</table>
+</center>
+<!-- END matrix_query -->
+<!-- BEGIN list -->
+ <tr bgcolor="{tr_color}">
+  <td valign="top" width="35%"><b>&nbsp;{field}:</b></td>
+  <td valign="top" width="65%">{data}</td>
+ </tr>
+<!-- END list -->
Index: contrib/resources/templates/default/week.tpl
===================================================================
--- contrib/resources/templates/default/week.tpl	(revision 3524)
+++ contrib/resources/templates/default/week.tpl	(revision 3524)
@@ -0,0 +1,3 @@
+{week_display}
+<!-- from month_day.tpl -->
+<p align="center">{printer_friendly}</p>
Index: contrib/resources/templates/default/day_cal.tpl
===================================================================
--- contrib/resources/templates/default/day_cal.tpl	(revision 3524)
+++ contrib/resources/templates/default/day_cal.tpl	(revision 3524)
@@ -0,0 +1,24 @@
+<!-- BEGIN day -->
+<div class="th">
+ <table class="calendar_dayview_maintable" width="100%" cellpadding="0">
+{row}
+</table>
+ </div>
+<!-- END day -->
+<!-- BEGIN day_row -->
+    <tr>{time}{event}
+    </tr>
+<!-- END day_row -->
+<!-- BEGIN day_event_on -->
+     <td class="event-on"{extras}>&nbsp;{event}</td>
+<!-- END day_event_on -->
+<!-- BEGIN day_event_off -->
+     <td class="event-off"{extras}>&nbsp;{event}</td>
+<!-- END day_event_off -->
+<!-- BEGIN day_event_holiday -->
+     <td class="event-holiday"{extras}>&nbsp;{event}</td>
+<!-- END day_event_holiday -->
+<!-- BEGIN day_time -->
+     <td class="time" nowrap>{open_link}{time}{close_link}</td>
+<!-- END day_time -->
+
Index: contrib/resources/templates/default/preference_acl.tpl
===================================================================
--- contrib/resources/templates/default/preference_acl.tpl	(revision 3524)
+++ contrib/resources/templates/default/preference_acl.tpl	(revision 3524)
@@ -0,0 +1,27 @@
+{errors}
+{title}
+<table border="0" align="center" width="70%">
+ <tr>
+  {nml}
+  <td width="40%">
+   <div align="center">
+    <form method="POST" action="{action_url}">
+{common_hidden_vars}
+     <input type="text" name="query" value="{search_value}">
+     <input type="submit" name="search" value="{search}">
+    </form>
+   </div>
+  </td>
+  {nmr}
+ </tr>
+</table>
+<form method="POST" action="{action_url}">
+ <table border="0" align="center" width="50%" cols="4">
+{row}
+ </table>
+{common_hidden_vars_form}
+ <input type="hidden" name="processed" value="{processed}">
+ <center><input type="submit" name="submit" value="{submit_lang}"></center>
+</form>
+
+
Index: contrib/resources/templates/default/preference_colspan.tpl
===================================================================
--- contrib/resources/templates/default/preference_colspan.tpl	(revision 3524)
+++ contrib/resources/templates/default/preference_colspan.tpl	(revision 3524)
@@ -0,0 +1,6 @@
+  <tr class="th">
+    <td>{string}</td>
+    <td align="center" width="8%">{lang_read}</td>
+    <td align="center" width="8%">{lang_edit}</td>
+    <td align="center" width="8%">{lang_delete}</td>
+  </tr>
Index: contrib/resources/templates/default/folderChooser.tpl
===================================================================
--- contrib/resources/templates/default/folderChooser.tpl	(revision 3524)
+++ contrib/resources/templates/default/folderChooser.tpl	(revision 3524)
@@ -0,0 +1,11 @@
+<!-- BEGIN main -->
+<script language="JavaScript">
+
+var targetName = opener.document.{formName}.targetname;
+var targetID   = opener.document.{formName}.targetid;
+
+</script>
+
+<div id="mydmstreebox" style="top:0px; left:0px; width:200px; height:400px; border:dotted 0px silver; text-align:left;"></div>
+{folderTree}
+<!-- END main -->
Index: contrib/resources/templates/default/event_link.tpl
===================================================================
--- contrib/resources/templates/default/event_link.tpl	(revision 3524)
+++ contrib/resources/templates/default/event_link.tpl	(revision 3524)
@@ -0,0 +1,41 @@
+
+<!-- BEGIN link_event_pict -->
+{picture}
+<!-- END link_event_pict -->
+
+<!-- BEGIN link_event_open -->
+<table>
+
+<!--<div id="calendar_event_entry" style="overflow:hidden;">-->
+<!--<a class="event_entry" href="{link_link}" onMouseOver="window.status='{lang_view}'; return true;" onMouseOut="window.status=''; return true;" title="{desc} {location}"><br />--><br />
+<!-- END link_event_open -->
+
+<!-- BEGIN event_pict -->
+<!--<img src="{pic_image}" width="{width}" height="{height}" title="{title}" border="0" />-->
+<!-- END event_pict -->
+
+<!-- BEGIN link_event_text_old -->
+<!--<nobr>&nbsp;{time}&nbsp;</nobr> {title}&nbsp;{users_status}: <i>{desc}</i>({location}) -->
+<!-- END link_event_text_old -->
+
+<!-- BEGIN link_event_text -->
+	<tr style="font-size: 10px;background: #dddddd;">
+		<td valign="top" style="color: black; font-size: 11px;">
+			<span>
+				{time}
+			</span>
+		</td>
+		<td style="font-size: 11px; border: #E8F0F0 1px solid;" colspan="3">
+			<span><b>{title}</b></span>
+			<br />
+			<span><i>{desc}</i></span>
+			<span>{location}</span>
+			<br />
+		</td>
+	</tr>
+<!-- END link_event_text -->
+
+<!-- BEGIN link_event_close -->
+<!--</a></div><br />-->
+</table>
+<!-- END link_event_close -->
Index: contrib/resources/templates/default/year.tpl
===================================================================
--- contrib/resources/templates/default/year.tpl	(revision 3524)
+++ contrib/resources/templates/default/year.tpl	(revision 3524)
@@ -0,0 +1,35 @@
+<!-- BEGIN year -->
+{print}
+<center>
+<table id="calendar_year_table" border="0" cellspacing="3" cellpadding="4" cols=4>
+	<tr>
+		<td align="center">
+			{left_link}
+		</td>
+		<td align="center">
+			<font face="{font}" size="+1">{year_text}</font>
+		</td>
+		<td align="center">
+			{right_link}
+		</td>
+		{row}
+	</tr>
+</table>
+</center>
+<p>
+<div class="calendar_link_print">
+{printer_friendly}
+</div>
+<!-- END year -->
+
+<!-- BEGIN month -->
+<td valign="top">
+	{mini_month}
+</td>
+<!-- END month -->
+
+<!-- BEGIN month_sep -->
+</tr>
+<tr valign="top">
+<!-- END month_sep -->
+
Index: contrib/resources/templates/default/head.tpl
===================================================================
--- contrib/resources/templates/default/head.tpl	(revision 3524)
+++ contrib/resources/templates/default/head.tpl	(revision 3524)
@@ -0,0 +1,52 @@
+<!-- BEGIN head -->
+<script language="Javascript">
+function openwindow(url)
+{ 
+	
+	var window_features = 	"scrollbars=yes,resizable=yes,location=no,menubar=no," + 
+							"personalbar=no,status=no,titlebar=no,toolbar=no," + 
+							"screenX=screen.width/3,screenY=screen.height/3,top=screen.height/3,left=screen.width/3,width=" + 
+							screen.width/4*3 + ",height=" + screen.height/8*3; 
+	
+	self.open(url,'', window_features); 
+}
+</script>
+{row}<br />
+<!-- END head -->
+<!-- BEGIN head_table -->
+<table id="calendar_head_table" class="calendar_head_table" border="0" width="100%" cols="{cols}" cellpadding="6" cellspacing="0">
+	<tr>
+		<td rowspan=10>
+	
+	<div id="divSubContainer">
+		<table cellpadding="0" cellspacing="0" width="100%">
+		<tbody><tr>
+		<!-- Sidebox Column -->
+<td id="tdSidebox" valign="top"><div id="thesideboxcolumn" style="width: 203px;"><div id="sideresize"></div>
+<div class="divSidebox">
+	<div class="divSideboxHeader"><span>Recursos Men&uacute;</span></div>
+
+	<div>
+		<table cellpadding="0" cellspacing="0" width="100%">
+		<tbody><tr class="divSideboxEntry">
+			<td class="textSidebox" align="center" valign="middle" width="20"><img class="sideboxstar" src="/resources/templates/default/images/orange-ball.png" alt="ball" height="9" width="9"></td><td class="textSidebox"><a class="textSidebox" href="index.php?menuaction=resources.uiresources.search">Lista del registro</a></td>
+		</tr>
+		<tr class="divSideboxEntry">
+			<td class="textSidebox" align="center" valign="middle" width="20"><img class="sideboxstar" src="/resources/templates/default/images/orange-ball.png" alt="ball" height="9" width="9"></td><td class="textSidebox"><a class="textSidebox" href=""></a><a class="textSidebox" href="index.php?menuaction=resources.uiresources.edit"  >A&ntilde;adir</a></td>
+		</tr>
+
+		</tbody></table>	
+	</div>
+</div>
+
+<div class="sideboxSpace"></div>
+
+</td> <td> 
+
+
+
+
+<!-- END head_table -->
+<!-- BEGIN head_col -->
+
+<!-- END head_col -->
Index: contrib/resources/templates/default/month_print.tpl
===================================================================
--- contrib/resources/templates/default/month_print.tpl	(revision 3524)
+++ contrib/resources/templates/default/month_print.tpl	(revision 3524)
@@ -0,0 +1,26 @@
+{printer_friendly}
+<table class="calendar_index_table" id="calendar_index_table"  width="100%" cols="5">
+	<tr>
+		<td align="left" width="33%">
+			<span class="calendar_user_identifier">
+					{username}
+			</span>
+		</td>
+		<td align="center" width="33%">
+			<span class="calendar_month_identifier">
+				{month_identifier}
+			</span>
+		</td>
+		<td align="right" style="width: 33%; font-size: 14px;">
+			<span class="calendar_user_identifier">
+				<p>Agenda de Eventos</p>
+			</span>
+		</td>
+	</tr>
+</table>
+{large_month}
+<p>
+<p>
+<div class="calendar_link_print">
+	{print}
+</div>
Index: contrib/resources/templates/default/month_column.tpl
===================================================================
--- contrib/resources/templates/default/month_column.tpl	(revision 3524)
+++ contrib/resources/templates/default/month_column.tpl	(revision 3524)
@@ -0,0 +1,4 @@
+
+<td valign="top" colspan="1" width="{col_width}%"{extra}>
+	{column_data}
+</td>
Index: contrib/resources/templates/default/body_email.tpl
===================================================================
--- contrib/resources/templates/default/body_email.tpl	(revision 3524)
+++ contrib/resources/templates/default/body_email.tpl	(revision 3524)
@@ -0,0 +1,32 @@
+<html>
+<head>
+<meta http-equiv="Content-Language" content="en" />
+<meta name="GENERATOR" content="PHPEclipse 1.0" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>title</title>
+</head>
+<body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">
+<!-- BEGIN list -->
+<b><p align='left'>{subject}</p></b>
+<br>
+<table border='0' cellpadding='0' cellspacing='0' width='100%'>
+<tr><td width='30%' valign='top'><b>{var1} ::</b></td><td>{vardata1}</td></tr>	
+<tr><td width='30%' valign='top'><b>{var2} ::</b></td><td>{vardata2}</td></tr>
+<tr><td width='30%' valign='top'><b>{var3} ::</b></td><td>{vardata3}</td></tr>
+<tr><td width='30%' valign='top'><b>{var4} ::</b></td><td>{vardata4}</td></tr>
+<tr><td width='25%' valign='top'><b>{var8} ::</b></td><td>{vardata8}</td></tr>
+<tr><td width='25%' valign='top'><b>{var5} ::</b></td><td>{vardata6}</td></tr>
+</table>
+<br>
+<hr size='1' width='100%'>
+<table border='0' cellpadding='4' cellspacing='4' width='100%'>
+<tr>
+<td width='2%' align='left'>{varbuttom}</td>
+<td width='2%' align='left' valign='top'>{varbuttom1}</td>
+<td width='2%' align='left' valign='top'>{varbuttom2}</td>
+<td width='94%' align='left' valign='top'>{varbuttom3}</td>
+</tr>
+</table>
+<!-- END list -->
+</body>
+</html>
Index: contrib/resources/templates/default/config.tpl
===================================================================
--- contrib/resources/templates/default/config.tpl	(revision 3524)
+++ contrib/resources/templates/default/config.tpl	(revision 3524)
@@ -0,0 +1,56 @@
+<!-- BEGIN header -->
+<p style="text-align: center; color: {th_err};">{error}</p>
+<form name=frm method="POST" action="{action_url}">
+{hidden_vars}
+<table border="0" align="left">
+   <tr class="th">
+    <td colspan="2">&nbsp;<b>{title}</b></td>
+   </tr>
+<!-- END header -->
+
+<!-- BEGIN body -->
+<tr class="row_on">
+<td>{lang_ProjectManager_integration}:</td>
+<td>
+<select name="newsettings[pm_integration]">
+<option value="">{lang_Both:_allow_to_use_ProjectManager_and_free_project-names}</option>
+<option value="none"{selected_pm_integration_none}>{lang_None:_use_only_free_project-names}</option>
+<option value="full"{selected_pm_integration_full}>{lang_Full:_use_only_ProjectManager}</option>
+</select>
+</td>
+</tr>
+<tr class="row_on">
+<td>{lang_Mode}:</td>
+<td>
+<select name="newsettings[ts_viewtype]">
+<option value="normal"{selected_ts_viewtype_normal}>{lang_Regular}</option>
+<option value="short"{selected_ts_viewtype_short}>{lang_Simple}</option>
+</select>
+</td>
+</tr>
+<tr class="row_on">
+<td>{lang_Show_a_quantity_sum_(eg._to_sum_up_negative_overtime)}:</td>
+<td>
+<select name="newsettings[quantity_sum]">
+<option value="">{lang_No}</option>
+<option value="true"{selected_quantity_sum_true}>{lang_Yes}</option>
+</select>
+</td>
+</tr>
+<!-- END body -->
+
+<!-- BEGIN footer -->
+  <tr class="th">
+    <td colspan="2">
+&nbsp;
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2" align="center">
+      <input type="submit" name="submit" value="{lang_submit}">
+      <input type="submit" name="cancel" value="{lang_cancel}">
+    </td>
+  </tr>
+</table>
+</form>
+<!-- END footer -->
Index: contrib/resources/templates/default/index.tpl
===================================================================
--- contrib/resources/templates/default/index.tpl	(revision 3524)
+++ contrib/resources/templates/default/index.tpl	(revision 3524)
@@ -0,0 +1,32 @@
+{printer_friendly}
+<table id="calendar_index_table" border="0" width="100%" cols="5">
+	<tr>
+		<td align="left" valign="top" width="20%">
+			{small_calendar_prev}
+		</td>
+		<td align="center" valign="middle" width="15%">
+			<b>{prev_month_link}</b>
+		</td>
+		<td align="center" width="30%">
+			<span class="calendar_month_identifier">
+				{month_identifier}
+			</span>
+				<br />
+			<span class="calendar_user_identifier">
+				:&nbsp;{username}&nbsp;:
+			</span>
+		</td>
+		<td align="center" valign="middle" width="15%">
+			{next_month_link}
+		</td>
+		<td align="right" valign="top" width="20%">
+			{small_calendar_next}
+		</td>
+	</tr>
+</table>
+{large_month}
+<p>
+<p>
+<div class="calendar_link_print">
+	{print}
+</div>
Index: contrib/resources/templates/default/month_header_print.tpl
===================================================================
--- contrib/resources/templates/default/month_header_print.tpl	(revision 3524)
+++ contrib/resources/templates/default/month_header_print.tpl	(revision 3524)
@@ -0,0 +1,12 @@
+<!-- BEGIN monthly_header -->
+<tr class="calendar_m_w_table_header" colspan="{cols}" width="{col_width}%">
+{column_header}</tr>
+<!-- END monthly_header -->
+
+<!-- BEGIN column_title -->
+<tr bGCOLOR="#D3DCE3" width="14.28%">{col_title}</tr>
+<!-- END column_title -->
+
+<!-- BEGIN month_column -->
+<tr class="calendar_m_w_tablecell" colspan="1" width="{col_width}%"{extra}>{column_data}</tr>
+<!-- END month_column -->
Index: contrib/resources/templates/default/form_button_dropdown.tpl
===================================================================
--- contrib/resources/templates/default/form_button_dropdown.tpl	(revision 3524)
+++ contrib/resources/templates/default/form_button_dropdown.tpl	(revision 3524)
@@ -0,0 +1,13 @@
+<form action="{form_link}" method="post" name="{form_name}form">
+<td width="{form_width}%" align="center" valign="top" style="padding-top:16px">
+	<span style="font-size:10px"><b>{title}:</b>
+    {hidden_vars}    
+    <select name="{form_name}" onchange="document.{form_name}form.submit()">
+		{form_options}
+	</select>
+    <noscript>
+    	<input type="submit" value="{button_value}">
+    </noscript>
+	</span>
+</td>
+</form>
