phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] calendar/inc class.uicalendar.inc.php, 1.110 class.bo


From: skwashd
Subject: [Phpgroupware-cvs] calendar/inc class.uicalendar.inc.php, 1.110 class.bocalendar.inc.php, 1.94 hook_deleteaccount.inc.php, 1.8 hook_sidebox_menu.inc.php, 1.3
Date: Sun, 23 Oct 2005 14:57:00 +0200

Update of calendar/inc

Modified Files:
     Branch: MAIN
            class.uicalendar.inc.php lines: +166 -113
            class.bocalendar.inc.php lines: +274 -262
            hook_deleteaccount.inc.php lines: +5 -5
            hook_sidebox_menu.inc.php lines: +24 -13

Log Message:
now selection is based on contacts not account

====================================================
Index: calendar/inc/class.uicalendar.inc.php
diff -u calendar/inc/class.uicalendar.inc.php:1.109 
calendar/inc/class.uicalendar.inc.php:1.110
--- calendar/inc/class.uicalendar.inc.php:1.109 Fri Oct 14 23:33:04 2005
+++ calendar/inc/class.uicalendar.inc.php       Sun Oct 23 12:57:16 2005
@@ -57,35 +57,36 @@
                                                '4' => 
array(0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3)  // 0=0-7, 7-12h, 
3=12-18h, 4=18-23h
                                        );

-               var $public_functions = array(
-                       'mini_calendar' => True,
-                       'index' => True,
-                       'month' => True,
-                       'get_month' => True,
-                       'week'  => True,
-                       'get_week' => True,
-                       'year' => True,
-                       'view' => True,
-                       'edit' => True,
-                       'export'        => True,
-                       'reinstate_list'        => True,
-                       'reinstate'     => True,
-                       'add'  => True,
-                       'delete' => True,
-                       'preferences' => True,
-                       'day' => True,
-                       'edit_status' => True,
-                       'set_action' => True,
-                       'planner' => True,
-                       'modify_ext_partlist' => True,
-                       'matrixselect'  => True,
-                       'viewmatrix'    => True,
-                       'search' => True,
-                       'header' => True,
-                       'footer' => True,
-                       'css'           => True,
-                       'accounts_popup' => True
-               );
+               var $public_functions = array
+                       (
+                               'mini_calendar' => True,
+                               'index'         => True,
+                               'month'         => True,
+                               'get_month'     => True,
+                               'week'          => True,
+                               'get_week'      => True,
+                               'year'          => True,
+                               'view'          => True,
+                               'edit'          => True,
+                               'export'        => True,
+                               'reinstate_list'=> True,
+                               'reinstate'     => True,
+                               'add'           => True,
+                               'delete'        => True,
+                               'preferences'   => True,
+                               'day'           => True,
+                               'edit_status'   => True,
+                               'set_action'    => True,
+                               'planner'       => True,
+                               'modify_ext_partlist' => True,
+                               'matrixselect'  => True,
+                               'viewmatrix'    => True,
+                               'search'        => True,
+                               'header'        => True,
+                               'footer'        => True,
+                               'css'           => True,
+                               'participants_popup'    => True
+                       );

                function uicalendar()
                {
@@ -395,14 +396,16 @@
                        $this->bo->read_holidays();

                        $var = Array(
-                               'printer_friendly'              =>      
$printer,
-                               'bg_text'                                       
=> $this->theme['bg_text'],
-                               'small_calendar_prev'   =>      $minical_prev,
-                               'month_identifier'              =>      
lang(strftime("%B",$m)).' '.$this->bo->year,
-                               'username'                                      
=>      $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner),
-                               'small_calendar_next'   =>      $minical_next,
-                               'large_month'                           =>      
$this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner),
-                               'print'                                         
=>      $print
+                               'printer_friendly'      => $printer,
+                               'bg_text'               => 
$this->theme['bg_text'],
+                               'small_calendar_prev'   => $minical_prev,
+                               'month_identifier'      => 
lang(strftime("%B",$m)).' '.$this->bo->year,
+                               'username'              => ( $this->bo->is_group
+                                                               ? 
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)
+                                                               : 
$this->bo->contacts->get_name_of_person_id($this->bo->owner) ),
+                               'small_calendar_next'   => $minical_next,
+                               'large_month'           => 
$this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner),
+                               'print'                 => $print
                        );

                        $p = 
CreateObject('phpgwapi.Template',$this->template_dir);
@@ -485,16 +488,18 @@
                        }

                        $var = Array(
-                               'printer_friendly'      =>      $printer,
+                               'printer_friendly'      => $printer,
                                'bg_text'               => 
$this->theme['bg_text'],
-                               'small_calendar_prev'   =>      $minical_prev,
-                               'prev_week_link'        =>      $prev_week_link,
-                               'small_calendar_this'   =>      $minical_this,
-                               'week_identifier'       =>      
$this->bo->get_week_label(),
-                               'next_week_link'        =>      $next_week_link,
-                               'username'              =>      
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner),
-                               'small_calendar_next'   =>      $minical_next,
-                               'week_display'          =>      
$this->display_weekly(
+                               'small_calendar_prev'   => $minical_prev,
+                               'prev_week_link'        => $prev_week_link,
+                               'small_calendar_this'   => $minical_this,
+                               'week_identifier'       => 
$this->bo->get_week_label(),
+                               'next_week_link'        => $next_week_link,
+                               'username'              => ( $this->bo->is_group
+                                                               ? 
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)
+                                                               : 
$this->bo->contacts->get_name_of_person_id($this->bo->owner) ),
+                               'small_calendar_next'   => $minical_next,
+                               'week_display'          => 
$this->display_weekly(
                                        Array(
                                                'date'          => 
sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day),
                                                'showyear'      => true,
@@ -573,7 +578,9 @@
                                ),
                                'small_calendar'                => $minical,
                                'date'                          => 
lang(date('F',$m)).' '.sprintf("%02d",$this->bo->day).', '.$this->bo->year,
-                               'username'                      => 
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner),
+                               'username'                      => ( 
$this->bo->is_group
+                                                                       ? 
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)
+                                                                       : 
$this->bo->contacts->get_name_of_person_id($this->bo->owner) ),
                                'print'                         => $print
                        );

@@ -1287,9 +1294,11 @@
                                        )
                                ),
                                'small_calendar'        => $minical,
-                               'date'                          => 
$this->bo->long_date($now),
-                               'username'                      => 
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner),
-                               'print'                         => $print
+                               'date'                  => 
$this->bo->long_date($now),
+                               'username'              => ( $this->bo->is_group
+                                                               ? 
$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)
+                                                               : 
$this->bo->contacts->get_name_of_person_id($this->bo->owner) ),
+                               'print'                 => $print
                        );

                        $p->set_var($var);
@@ -1496,13 +1505,17 @@
                                $hdr[0][$i] = "<b><a 
href=\"$prev_link\">&lt;&lt;</a> &nbsp $month &nbsp <a 
href=\"$next_link\">&gt;&gt;</a></b>";

                                $add_owner = array();   // if no add-rights on 
the showed cal use own cal
-                               if (!$this->bo->save_owner && 
!$this->bo->check_perms(PHPGW_ACL_ADD) ||
-                                       
!$this->bo->check_perms(PHPGW_ACL_ADD,0,$this->bo->save_owner))
+                               if ( !$this->bo->save_owner
+                                       && 
!$this->bo->check_perms(PHPGW_ACL_ADD)
+                                       || 
!$this->bo->check_perms(PHPGW_ACL_ADD,0,$this->bo->save_owner))
                                {
-                                       $add_owner = array(
-                                               'owner' => 
$GLOBALS['phpgw_info']['user']['account_id']
-                                       );
+                                       $add_owner = array('owner' => 
$this->contacts->is_contact($GLOBALS['phpgw_info']['user']['account_id']));
                                }
+                               else
+                               {
+                                       $add_owner = array('owner' => 
$this->bo->save_onwer);
+                               }
+
                                for ($d=1; $d<=$days; $d++)
                                {
                                        $dayname = 
substr(lang(date('D',mktime(0,0,0,$m,$d,$y))),0,2);
@@ -1532,9 +1545,10 @@
                                        $hdr[2]['.'.$index] .= " 
bgcolor=\"$color\"";

                                        $hdr[2][$index] = '<a 
href="'.$this->planner_html->link('/index.php',
-                                                               array(
-                                                                       
'menuaction' => 'calendar.uicalendar.add',
-                                                                       'date' 
=> $date
+                                                               array
+                                                               (
+                                                                       
'menuaction'    => 'calendar.uicalendar.add',
+                                                                       'date'  
        => $date
                                                                ) + $add_owner
                                                        ).'">'.$dayname.'<br 
/>'.$d.'</a>';
                                }
@@ -2266,7 +2280,7 @@
                                'sortby'     => $this->bo->sortby,
                                'num_months' => $this->bo->num_months
                        );
-                       Return _debug_array($data,False);
+                       return _debug_array($data,False);
                }

                function output_template_array(&$p,$row,$list,$var)
@@ -2302,7 +2316,7 @@
                                }
                        }
                        if($GLOBALS['phpgw_info']['flags']['currentapp'] == 
'home' ||
-                          
strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail'))        // email, 
felamimail, ...
+                          
strpos($GLOBALS['phpgw_info']['flags']['currentapp'],'mail') !== false) // 
email, felamimail, ...
                        {
                                $page_app = 'calendar';
                        }
@@ -2310,7 +2324,14 @@
                        {
                                $page_app = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        }
-                       return 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params);
+                       if ( !is_array($params) )
+                       {
+                               parse_str($params, $new_params);
+                               $params =& $new_params;
+                       }
+
+                       $params['menuaction'] = 
"{$page_app}.ui{$page_app}.{$_page}";
+                       return $GLOBALS['phpgw']->link('/index.php', $params);
                }

                function header()
@@ -3516,9 +3537,60 @@
                        return '<table width="100%"><tr 
align="center">'."\n".$str.'</tr></table>'."\n";
                }

-               function accounts_popup()
+               function participants_popup()
                {
-                       $GLOBALS['phpgw']->accounts->accounts_popup('calendar');
+                       $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
+                       $t =& $GLOBALS['phpgw']->template;
+                       $t->set_unknowns('remove');
+
+                       if ( isset($_GET['lookup']) )
+                       {
+                               $contacts = 
$this->bo->get_contacts($_GET['lookup'], @intval($_GET['cat_id']));
+
+                               foreach ( $contacts as $contact )
+                               {
+                                       echo "<option 
value=\"{$contact['contact_id']}\">{$contact['per_first_name']} 
{$contact['per_last_name']}</option>\n";
+                               }
+                       }
+                       else
+                       {
+                               $t->set_file( array('popup' => 
'contacts_popup.tpl') );
+                               $t->set_block('popup', 'cat_option', 
'cat_options');
+
+                               $cats = createObject('phpgwapi.categories');
+                               $cats->app_name = 'addressbook';
+                               $cat_list = $cats->return_array('all', 0, 
false);
+                               foreach ( $cat_list as $cat )
+                               {
+                                       $t->set_var(
+                                               array
+                                               (
+                                                       'cat_id'        => 
$cat['id'],
+                                                       'cat_name'      => 
stripslashes($cat['name'])
+                                               ));
+                                       $t->parse('cat_options', 'cat_option', 
true);
+                               }
+
+                               $t->set_var(
+                                       array
+                                       (
+                                               'base_url'              => 
$GLOBALS['phpgw']->link('/'),
+                                               'lang_all'              => 
lang('all'),
+                                               'lang_title'            => 
lang('calendar event participants selector'),
+                                               'lang_show_contacts'    => 
lang('show contacts'),
+                                               'lang_category'         => 
lang('category'),
+                                               'lang_search'           => 
lang('search'),
+                                               'lang_contacts'         => 
lang('contacts'),
+                                               'lang_add'              => 
lang('add'),
+                                               'lang_remove'           => 
lang('remove'),
+                                               'lang_close'            => 
lang('close'),
+                                               'img_add'               => 
$GLOBALS['phpgw']->common->image('calendar', 'right-24x24'),
+                                               'img_remove'            => 
$GLOBALS['phpgw']->common->image('calendar', 'left-24x24'),
+                                               'img_close'             => 
$GLOBALS['phpgw']->common->image('calendar', 'close-24x24')
+                                       ));
+                               $t->pparse('out', 'popup');
+                       }
+                       $GLOBALS['phpgw']->common->phpgw_exit();
                }

                function edit_form($param)
@@ -3567,7 +3639,7 @@
                                'font'                  => $this->theme['font'],
                                'bg_color'              => 
$this->theme['bg_text'],
                                'action_url'            => 
$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')),
-                               'accounts_link'         => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'),
+                               'popup_url'             => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.participants_popup'),
                                'common_hidden' => '<input type="hidden" 
name="cal[id]" value="'.$event['id'].'">'."\n"
                                                                                
. '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n"
                                                                                
. '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n"
@@ -3686,6 +3758,29 @@
                        );

 // Participants
+                       if ( !is_array($event['participants']) )
+                       {
+                               $event['participants'] = array();
+                       }
+
+                       foreach ( $event['participants'] as $id => $ignore )
+                       {
+                               if($id != intval($event['owner']))
+                               {
+                                       $str .= '<option value="' . 
$id.$event['participants'][$id] . '"'
+                                                       
.($event['participants'][$id]?' selected="selected"':'').'>'
+                                                       . 
$this->bo->contacts->get_name_of_person_id($id) . '</option>' . "\n";
+                               }
+                       }
+                       $var['participants'] = array
+                       (
+                               'field' => '<input type="button" value="' . 
lang('Participants') . '" onClick="accounts_popup();">' . "\n"
+                                               . '<input type="hidden" 
name="accountid" value="' . $accountid . '" />',
+                               'data'  => "\n".'   <select 
id="event_participants" name="participants[]" multiple="multiple" size="7">'
+                                               . "\n{$str}</select>"
+                       );
+
+                       /* Old code no longer used
                        
if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || 
!$GLOBALS['phpgw_info']['server']['deny_user_grants_access'])
                        {
                                
switch($GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection'])
@@ -3695,8 +3790,10 @@
                                                {
                                                        if($id != 
intval($event['owner']))
                                                        {
-                                                               $str .= 
'<option value="' . $id.$event['participants'][$id] . 
'"'.($event['participants'][$id]?' 
selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id)
-                                                                               
.') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n";
+                                                               $str .= 
'<option value="' . $id.$event['participants'][$id] . '"'
+                                                                               
.($event['participants'][$id]?' selected="selected"':'').'>'
+                                                                               
. '(' . ($this->bo->contacts->get_account_id($id) ? 'u' : 'c') .') '
+                                                                               
. $this->bo->contacts->get_name_of_person_id($id) . '</option>' . "\n";
                                                        }
                                                }
                                                $var['participants'] = array
@@ -3730,50 +3827,6 @@
                                                );
                                                break;
                                }
-/*
-// External Participants
-
-                               // FIXME: where does the list of external 
participants come from?
-                               //
-                               $id = '1_h';
-                               $test_contact[$id] = array();
-                               $test_contact[$id]['name'] = "Stephan Cremer";
-                               $id = '3_b';
-                               $test_contact[$id] = array();
-                               $test_contact[$id]['name'] = "Stephan_Uni 
Cremer_Uni";
-
-                               $part = "";
-                               $ext_disp = '<textarea 
name="external_participants" rows="5" cols="40" readonly="readonly">'."\n";
-                               while(list($id,$contact) = each($test_contact)) 
{
-                                 $part .= $part!= '' ? ',' : '';
-                                 $part .= $id;
-                                 $ext_disp .= '(FIXME: 
b_OR_h)'.$contact['name']."\n";
-                               }
-                               $ext_disp .= '</textarea>'."\n".'<br />';
-
-                               $url = $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uiextpartlist.modify'));
-                               // $url = $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uicalendar.modify_ext_partlist'));
-                               $mod_ext = '<script language="JavaScript">'."\n"
-                                                       . 'function 
modify_window(url) {'."\n"
-                                                       . '   
document.addform.ext_part_id.value="";'."\n"
-                                                       . '   awin = 
window.open(url,"modify","width=500,height=400,toolbar=no,resizable=yes");'."\n"
-// DEBUG START
-. '}'."\n".'function show() {'."\n"
-. '   alert("Participants: " + document.addform.ext_part_id.value);'."\n"
-// DEBUG END
-                                                       . 
'}'."\n</script>\n".$ext_disp."\n"
-// DEBUG START
-. '<input type="button" value="Status" onClick="javascript:show()">'."\n"
-// DEBUG END
-                                                       . '<input type="button" 
onClick="javascript:modify_window(\''.$url.'&part='.$part
-                                                       . '\')" 
value="'.lang('Modify List of External Participants').'">'."\n"
-                                                       . '<input type="hidden" 
name="ext_part_id" value="'.$part.'">'."\n";
-
-                               $var[] = Array(
-                                       'field' => "\n".lang('External 
Participants'),
-                                       'data'  => "\n".$mod_ext."\n"
-                               );
-*/
 // I Participate
                                if((($event['id'] > 0) && 
isset($event['participants'][$event['owner']])) || !$event['id'])
                                {
@@ -3784,11 +3837,11 @@
                                        $checked = '';
                                }
                                $var['owner'] = Array(
-                                       'field' => 
$GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' 
'.lang('Participates'),
+                                       'field' => 
$this->bo->contacts->get_name_of_person_id($event['owner']).' 
'.lang('Participates'),
                                        'data'  => '<input type="checkbox" 
name="participants[]" 
value="'.$event['owner'].$event['participants'][$event['owner']].'"'.$checked.'>'
                                );
                        }
-
+                       */
 // Reminder
                        // The user must use "Alarm Management" to 
change/modify an alarm
                        // so only display the email reminder fields if this is 
a new event

====================================================
Index: calendar/inc/class.bocalendar.inc.php
diff -u calendar/inc/class.bocalendar.inc.php:1.93 
calendar/inc/class.bocalendar.inc.php:1.94
--- calendar/inc/class.bocalendar.inc.php:1.93  Sun May 15 06:57:37 2005
+++ calendar/inc/class.bocalendar.inc.php       Sun Oct 23 12:57:16 2005
@@ -16,7 +16,7 @@

        class bocalendar
        {
-               var $public_functions = Array(
+               var $public_functions = array(
                        'read_entry'      => True,
                        'delete_entry'    => True,
                        'delete_calendar' => True,
@@ -29,64 +29,64 @@
                        'reinstate'       => True
                );

-               var $soap_functions = Array(
-                       'read_entry' => Array(
-                               'in' => Array(
+               var $soap_functions = array(
+                       'read_entry' => array(
+                               'in' => array(
                                        'int'
                                ),
-                               'out' => Array(
+                               'out' => array(
                                        'SOAPStruct'
                                )
                        ),
-                       'delete_entry' => Array(
-                               'in' => Array(
+                       'delete_entry' => array(
+                               'in' => array(
                                        'int'
                                ),
-                               'out' => Array(
+                               'out' => array(
                                        'int'
                                )
                        ),
-                       'delete_calendar' => Array(
-                               'in' => Array(
+                       'delete_calendar' => array(
+                               'in' => array(
                                        'int'
                                ),
-                               'out' => Array(
+                               'out' => array(
                                        'int'
                                )
                        ),
-                       'change_owner' => Array(
-                               'in' => Array(
+                       'change_owner' => array(
+                               'in' => array(
                                        'array'
                                ),
-                               'out' => Array(
+                               'out' => array(
                                        'int'
                                )
                        ),
-                       'update' => Array(
-                               'in' => Array(
+                       'update' => array(
+                               'in' => array(
                                        'array',
                                        'array',
                                        'array',
                                        'array',
                                        'array'
                                ),
-                               'out' => Array(
+                               'out' => array(
                                        'array'
                                )
                        ),
-                       'store_to_cache'        => Array(
-                               'in' => Array(
+                       'store_to_cache'        => array(
+                               'in' => array(
                                        'struct'
                                ),
-                               'out' => Array(
+                               'out' => array(
                                        'SOAPStruct'
                                )
                        ),
-                       'store_to_cache'        => Array(
-                               'in' => Array(
+                       'store_to_cache'        => array(
+                               'in' => array(
                                        'array'
                                ),
-                               'out' => Array(
+                               'out' => array(
                                        'string'
                                )
                        )
@@ -96,6 +96,8 @@
 //             var $debug = True;

                var $so;
+               var $contacts;
+
                var $cached_events;
                var $repeating_events;
                var $day;
@@ -109,7 +111,7 @@

                var $cached_holidays;

-               var $g_owner = 0;
+               var $g_owner = array();

                var $filter;
                var $cat_id;
@@ -131,11 +133,11 @@
                var $sortby;
                var $num_months;

-               function bocalendar($session=0)
+               function bocalendar($session = 0)
                {
                        $this->cat = CreateObject('phpgwapi.categories');
+                       $this->contacts = createObject('phpgwapi.contacts');
                        $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('calendar');
-                       @reset($this->grants);
                        if(DEBUG_APP)
                        {
                                if(floor(phpversion()) >= 4)
@@ -158,19 +160,19 @@
                                $this->read_sessiondata();
                                $this->use_session = True;
                        }
-                       print_debug('BO Filter',$this->filter);
-                       print_debug('Owner',$this->owner);
+                       print_debug('BO Filter', $this->filter);
+                       print_debug('Owner', $this->owner);

                        $this->prefs['calendar']    = 
$GLOBALS['phpgw_info']['user']['preferences']['calendar'];
                        $this->check_set_default_prefs();

-                       $owner = 
get_var('owner',array('GET','POST'),$GLOBALS['owner']);
-
+                       $owner = get_var('owner', array('GET','POST'), 
$this->contacts->is_contact($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['calendar']['defaultcalendar'],0,7) == 'planner'
                                 || $GLOBALS['phpgw_info']['menuaction'] == 
'calendar.uicalendar.planner' &&
-                                   $from  != 'calendar.uicalendar.planner' && 
!$this->save_owner)
+                                       $from  != 'calendar.uicalendar.planner' 
&& !$this->save_owner)
                                 && 
intval($this->prefs['calendar']['planner_start_with_group']) > 0)
                        {
                                // entering planner for the first time ==> 
saving owner in save_owner, setting owner to default
@@ -178,8 +180,8 @@
                                $this->save_owner = $this->owner;
                                $owner = 
'g_'.$this->prefs['calendar']['planner_start_with_group'];
                        }
-                       elseif ($GLOBALS['phpgw_info']['menuaction'] != 
'calendar.uicalendar.planner' &&
-                               $this->save_owner)
+                       elseif ( $GLOBALS['phpgw_info']['menuaction'] != 
'calendar.uicalendar.planner'
+                               && $this->save_owner )
                        {
                                // leaving planner with an unchanged user/owner 
==> setting owner back to save_owner
                                //
@@ -193,7 +195,7 @@
                                unset($this->save_owner);
                        }

-                       if(isset($owner) && $owner!='' && substr($owner,0,2) == 
'g_')
+                       if( isset($owner) && $owner != '' && substr($owner,0,2) 
== 'g_')
                        {
                                $this->set_owner_to_group(substr($owner,2));
                        }
@@ -201,16 +203,12 @@
                        {
                                $this->owner = intval($owner);
                        }
-                       elseif(address@hidden($this->owner) || 
address@hidden>owner)
+                       elseif(!isset($this->owner) || !$this->owner)
                        {
-                               $this->owner = 
intval($GLOBALS['phpgw_info']['user']['account_id']);
-                       }
-                       elseif(isset($this->owner) && 
$GLOBALS['phpgw']->accounts->get_type($this->owner) == 'g')
-                       {
-                               $this->set_owner_to_group(intval($this->owner));
+                               $this->owner = 
$this->contacts->is_contact($GLOBALS['phpgw_info']['user']['account_id']);
                        }

-                       $this->prefs['common']    = 
$GLOBALS['phpgw_info']['user']['preferences']['common'];
+                       $this->prefs['common'] = 
$GLOBALS['phpgw_info']['user']['preferences']['common'];

                        if ($this->prefs['common']['timeformat'] == '12')
                        {
@@ -241,13 +239,13 @@
                           $this->sortby = 
$this->prefs['calendar']['defaultcalendar'] == 'planner_user' ? 'user' : 
'category';
                        }

-                       
if($GLOBALS['phpgw']->accounts->get_type($this->owner)=='g')
+                       if(isset($this->g_owner) && $this->g_owner)
                        {
                                $this->filter = ' all ';
                        }

                        $this->so = CreateObject('calendar.socalendar',
-                               Array(
+                               array(
                                        'owner'         => $this->owner,
                                        'filter'        => $this->filter,
                                        'category'      => $this->cat_id,
@@ -274,7 +272,7 @@
                                        $this->rpt_day[$mcals[$n % 7]] = 
$days[$n % 7];
                                }
                        }
-                       $this->rpt_type = Array(
+                       $this->rpt_type = array(
                                MCAL_RECUR_NONE         => 'None',
                                MCAL_RECUR_DAILY        => 'Daily',
                                MCAL_RECUR_WEEKLY       => 'Weekly',
@@ -431,21 +429,24 @@
                        $this->owner = intval($owner);
                        $this->is_group = True;
                        settype($this->g_owner,'array');
-                       $this->g_owner = Array();
+                       $this->g_owner = array();
                        $group_owners = 
$GLOBALS['phpgw']->accounts->member($owner);
-                       while($group_owners && list($index,$group_info) = 
each($group_owners))
+                       if ( is_array($group_owners) && count($group_owners) )
                        {
-                               $this->g_owner[] = $group_info['account_id'];
+                               foreach ( $group_owners as $group_info )
+                               {
+                                       $this->g_owner[] = 
$this->contacts->is_contact($group_info['account_id']);
+                               }
                        }
                }

                function member_of_group($owner=0)
                {
-                       $owner = 
($owner==0?$GLOBALS['phpgw_info']['user']['account_id']:$owner);
+                       $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'])
+                               if($this->owner == 
$this->contacts->is_contact($group_info['account_id']) )
                                {
                                        return True;
                                }
@@ -513,13 +514,6 @@
                        {
                                $event = $this->so->read_entry($id);

-                               /*FIXME: Test and uncomment
-                               if( strpos($event['uid'],'-') === 0)
-                               {
-                                       $event['uid'] = md5($event['title']) . 
'-' . md5($event['description']) . '@' . $_SERVER['HOSTNAME'];
-                               }
-                               */
-
                                if(!isset($event['participants'][$this->owner]) 
&& $this->user_is_a_member($event,$this->owner))
                                {
                                        
$this->so->add_attribute('participants','U',intval($this->owner));
@@ -613,7 +607,7 @@
                {
                        if($GLOBALS['phpgw_info']['user']['apps']['admin'])
                        {
-                               $this->so->delete_calendar($owner);
+                               
$this->so->delete_calendar($this->contacts->is_contact($owner));
                        }
                }

@@ -623,7 +617,8 @@
                        {
                                if(is_array($params))
                                {
-                                       
$this->so->change_owner($params['old_owner'],$params['new_owner']);
+                                       
$this->so->change_owner($this->contacts->is_contact($params['old_owner']),
+                                                               
$this->contacts->is_contact($params['new_owner']));
                                }
                        }
                }
@@ -646,11 +641,10 @@
                        $this->so->expunge();
                }

+               //FIXME fix security
                function search_keywords($keywords)
                {
-                       $type = 
$GLOBALS['phpgw']->accounts->get_type($this->owner);
-
-                       if($type == 'g')
+                       if($this->is_group)
                        {
                                $members = 
$GLOBALS['phpgw']->acl->get_ids_for_location($this->owner, 1, 'phpgw_group');
                        }
@@ -675,13 +669,13 @@

                function update($params='')
                {
-                       $l_cal = (@isset($params['cal']) && 
$params['cal']?$params['cal']:$_POST['cal']);
-                       $l_participants = 
(@$params['participants']?$params['participants']:$_POST['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']);
-                       $l_recur_exception = explode (",", 
$_POST['recur_exception']);
+                       $l_cal = isset($params['cal']) && $params['cal'] ? 
$params['cal'] : $_POST['cal'];
+                       $l_participants = isset($params['participants']) ? 
$params['participants'] : $_POST['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'];
+                       $l_recur_exception = explode (',', 
$_POST['recur_exception']);

                        $send_to_ui = True;
                        if($this->debug)
@@ -704,7 +698,7 @@
                                if($datetime_check)
                                {
                                        ExecMethod('calendar.uicalendar.edit',
-                                               Array(
+                                               array(
                                                        'cd'            => 
$datetime_check,
                                                        'readsess'      => 1
                                                )
@@ -799,61 +793,32 @@
                                                break;
                                }

-                               if($l_participants)
+                               $part = False;
+                               if ( is_array($l_participants) && 
count($l_participants) )
                                {
+                                       $accept_type = 'U'; //TODO add option 
for 'C' == Contact
                                        $parts = $l_participants;
                                        $minparts = min($l_participants);
-                                       $part = Array();
-                                       for($i=0;$i<count($parts);$i++)
+                                       $part = true;
+                                       foreach ( $l_participants as 
$participant )
                                        {
-                                               if (($accept_type = 
substr($parts[$i],-1,1)) == '0' || intval($accept_type) > 0)
+                                               if ( substr($participant, 0, 2) 
== 'g_' )
                                                {
-                                                       $accept_type = 'U';
+                                                       //do group handling 
here when groups are added back in
+                                                       /*
+                                                               get all members 
from group
+                                                               loop it
+                                                                       get 
contact id
+                                                                       add to 
db
+                                                               done
+                                                       */
                                                }
-                                               $acct_type = 
$GLOBALS['phpgw']->accounts->get_type(intval($parts[$i]));
-                                               if($acct_type == 'u')
-                                               {
-                                                       
$part[intval($parts[$i])] = $accept_type;
-                                               }
-                                               elseif($acct_type == 'g')
+                                               else
                                                {
-                                                       
//$part[intval($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',intval($parts[$i]));
-                                                       $members = 
$acct->member(intval($parts[$i]));
-                                                       unset($acct);
-                                                       if($members == False)
-                                                       {
-                                                               continue;
-                                                       }
-                                                       while($member = 
each($members))
-                                                       {
-                                                               
$part[$member[1]['account_id']] = $accept_type;
-                                                       }
+                                                       
$this->so->add_attribute('participants', $accept_type, intval($participant));
                                                }
                                        }
                                }
-                               else
-                               {
-                                       $part = False;
-                               }
-
-                               if($part)
-                               {
-                                       @reset($part);
-                                       while(list($key,$accept_type) = 
each($part))
-                                       {
-                                               
$this->so->add_attribute('participants',$accept_type,intval($key));
-                                       }
-                               }
-
-                               if($groups)
-                               {
-                                       @reset($groups);
-                                       
$this->so->add_attribute('groups',intval($group_id));
-                               }

                                $event = $this->get_cached_event();
                                if(!is_int($minparts))
@@ -901,7 +866,7 @@
                                                ($l_cal['alarmhours'] * 3600) -
                                                ($l_cal['alarmminutes'] * 60);

-                                       $event['alarm'][] = Array(
+                                       $event['alarm'][] = array(
                                                'time'    => $time,
                                                'owner'   => $this->owner,
                                                'enabled' => 1
@@ -916,7 +881,7 @@
                                if($datetime_check)
                                {
                                   ExecMethod('calendar.uicalendar.edit',
-                                       Array(
+                                       array(
                                                'cd'            => 
$datetime_check,
                                                'readsess'      => 1
                                        )
@@ -948,7 +913,7 @@
                                        
unset($GLOBALS['phpgw_info']['flags']['noheader']);
                                        
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
                                        
ExecMethod('calendar.uicalendar.overlap',
-                                               Array(
+                                               array(
                                                        'o_events'      => 
$overlapping_events,
                                                        'this_event'    => 
$event
                                                )
@@ -1006,11 +971,16 @@
                        unset($holiday);
                }

-               function user_is_a_member($event,$user)
+               function user_is_a_member($event, $contact)
                {
-                       @reset($event['participants']);
                        $uim = False;
-                       $security_equals = 
$GLOBALS['phpgw']->accounts->membership($user);
+                       $security_equals = 
$GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw']->accounts->search_person($contact));
+
+                       if ( !is_array($event['participants']) )
+                       {
+                               return false;
+                       }
+
                        while(!$uim && $event['participants'] && 
$security_equals && list($participant,$status) = each($event['participants']))
                        {
                                
if($GLOBALS['phpgw']->accounts->get_type($participant) == 'g')
@@ -1034,14 +1004,13 @@
                        return 
mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']);
                }

-               /*!
-               @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
-               */
+               /**
+                * returns a date-array suitable for the start- or endtime of 
an event from a timestamp
+               *
+                * @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(
@@ -1055,14 +1024,13 @@
                        );
                }

-               /*!
-               @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
-               */
+               /**
+                * set the start- and enddates of a recuring event for a 
recur-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']);
@@ -1138,10 +1106,10 @@
                        return $error;
                }

-               /*!
-               @function participants_not_rejected($participants,$event)
-               @abstract checks if any of the $particpants participates in 
$event and has not rejected it
-               */
+               /**
+                * 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";
@@ -1149,7 +1117,7 @@
                        {
                                //echo "testing event[participants][uid=$uid] = 
'".$event['participants'][$uid]."'<br />\n";
                                if (isset($event['participants'][$uid]) && 
$event['participants'][$uid] != 'R' &&
-                                   $status != 'R')
+                                       $status != 'R')
                                {
                                        return True;    // found not rejected 
participant in event
                                }
@@ -1159,7 +1127,7 @@

                function 
overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False)
                {
-//                     $retval = Array();
+//                     $retval = array();
 //                     $ok = False;

 /* This needs some attention.. by commenting this chunk of code it will fix 
bug #444265 */
@@ -1183,7 +1151,7 @@
                                echo '<!-- Temp_End: '.$temp_end.' -->'."\n";
                        }

-                       $users = Array();
+                       $users = array();
                        if(count($participants))
                        {
                                while(list($user,$status) = each($participants))
@@ -1197,7 +1165,7 @@
                        }

                        $possible_conflicts = $this->store_to_cache(
-                               Array(
+                               array(
                                        'smonth'        => 
substr(strval($temp_start),4,2),
                                        'sday'  => 
substr(strval($temp_start),6,2),
                                        'syear' => 
substr(strval($temp_start),0,4),
@@ -1256,15 +1224,15 @@
                                                        $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) &&
+                                                               $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)
@@ -1294,23 +1262,27 @@
                        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)
-               {
-                       if (is_int($event) && $event == 0)
-                       {
-                               $owner = $other > 0 ? $other : $this->owner;
+               /**
+                * Checks if the current user has the necessary ACL rights
+                *
+                * @author ralfbecker
+                * @author skwashd
+                * 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
+                * 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)
+               {
+                       if ( $event === 0)
+                       {
+                               //convert back to phpgw account id for acls
+                               $owner =  
$GLOBALS['phpgw']->accounts->search_person($other > 0
+                                               ? $other
+                                               : $this->owner
+                                       );
                        }
                        else
                        {
@@ -1322,19 +1294,25 @@
                                {
                                        return False;
                                }
-                               $owner = $event['owner'];
+                               $owner = 
$GLOBALS['phpgw']->accounts->search_person($event['owner']);
                                $private = $event['public'] == False || 
$event['public'] == 0;
                        }
                        $user = $GLOBALS['phpgw_info']['user']['account_id'];
                        $grants = $this->grants[$owner];
+
+                       if ( $owner == $user ) //if the current user is the 
owner they have full rights
+                       {
+                               return True;
+                       }

                        if (is_array($event) && 
is_array($event['participants']) && ($needed == PHPGW_ACL_READ))
                        {
                                // Check if the $user is one of the 
participants or has a read-grant from one of them
                                //
-                               foreach($event['participants'] as $uid => 
$accept)
+                               foreach($event['participants'] as $contact_id 
=> $accept)
                                {
-                                       if ($this->grants[$uid] & 
PHPGW_ACL_READ || $uid == $user)
+                                       if 
($this->grants[$GLOBALS['phpgw']->accounts->search_person($contact_id)] & 
PHPGW_ACL_READ
+                                               || 
$GLOBALS['phpgw']->accounts->search_person($contact_id) == $user)
                                        {
                                                $grants |= PHPGW_ACL_READ;
                                                break;
@@ -1342,7 +1320,7 @@
                                }
                        }

-                       if ($GLOBALS['phpgw']->accounts->get_type($owner) == 
'g' && $needed == PHPGW_ACL_ADD)
+                       if ( $this->is_group && $needed == PHPGW_ACL_ADD)
                        {
                                $access = False;        // a group can't be the 
owner of an event
                        }
@@ -1350,7 +1328,7 @@
                        {
                                $access = $user == $owner || $grants & $needed 
&& (!$private || $grants & PHPGW_ACL_PRIVATE);
                        }
-                       //echo "<p>rb_check_perms for user $user and needed_acl 
$needed: event=$event[title]: owner=$owner, privat=$private, grants=$grants ==> 
access=$access</p>\n";
+                       //echo "<p>bo_calendar::check_perms for user $user and 
needed_acl $needed: event=$event[title]: owner=$owner, privat=$private, 
grants=$grants ==> access=$access is_group: {$this->is_group}</p>\n";

                        return $access;
                }
@@ -1512,7 +1490,7 @@
                {
                        $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));
                }

@@ -1555,9 +1533,9 @@
                                {
                                        $temp['hour'] = 
(int)((int)$temp['hour'] - 12);
                                        $temp['ampm'] = 'pm';
-                  }
-               elseif ((int)$temp['hour'] == 12)
-               {
+                               }
+                               elseif ((int)$temp['hour'] == 12)
+                               {
                                        $temp['ampm'] = 'pm';
                                }
                        }
@@ -1566,7 +1544,7 @@

                function get_exception_array($exception_str='')
                {
-                       $exception = Array();
+                       $exception = array();
                        if(strpos(' '.$exception_str,','))
                        {
                                $exceptions = explode(',',$exception_str);
@@ -1898,7 +1876,7 @@
                                echo '<!-- repeating events cached : 
'.$c_cached_ids_repeating.' : for : 
'.sprintf("%04d%02d%02d",$syear,$smonth,$sday).' -->'."\n";
                        }

-                       $this->cached_events = Array();
+                       $this->cached_events = array();

                        if($c_cached_ids == 0 && $c_cached_ids_repeating == 0)
                        {
@@ -1942,7 +1920,7 @@
                                }
                        }

-                       $this->repeating_events = Array();
+                       $this->repeating_events = array();
                        if($c_cached_ids_repeating)
                        {
                                for($i=0;$i<$c_cached_ids_repeating;$i++)
@@ -1974,7 +1952,7 @@
                                        }
                                }
                        }
-                       $retval = Array();
+                       $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]))
@@ -2157,10 +2135,10 @@
                        return $time_slice;
                }

-               /*!
-               @function set_status
-               @abstract set the participant response $status for event 
$cal_id and notifies the owner of the event
-               */
+               /**
+                * set the participant response $status for event $cal_id and 
notifies the owner of the event
+               *
+                */
                function set_status($cal_id,$status)
                {
                        $status2msg = array(
@@ -2179,17 +2157,16 @@
                        return True;
                }

-               /*!
-               @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
-               */
+               /**
+                * checks if $userid has requested (in $part_prefs) updates for 
$msg_type
+               *
+                * @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
+                * @return 0 = no update requested, > 0 update requested
+                */
                function 
update_requested($userid,$part_prefs,$msg_type,$old_event,$new_event)
                {
                        if ($msg_type == MSG_ALARM)
@@ -2225,7 +2202,7 @@
                                        }
                                case 'add_cancel':
                                        if ($old_event['owner'] == $userid && 
$msg_is_response ||
-                                           $msg_type == MSG_DELETED || 
$msg_type == MSG_ADDED)
+                                               $msg_type == MSG_DELETED || 
$msg_type == MSG_ADDED)
                                        {
                                                ++$want_update;
                                        }
@@ -2237,15 +2214,14 @@
                        return $want_update > 0;
                }

-               /*!
-               @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
-               */
+               /**
+                * sends update-messages to certain participants of an event
+               *
+                * @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>bocalendar::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";
@@ -2583,7 +2559,7 @@

                function remove_doubles_in_cache($firstday,$lastday)
                {
-                       $already_moved = Array();
+                       $already_moved = array();
                        for($v=$firstday;$v<=$lastday;$v++)
                        {
                                if (!$this->cached_events[$v])
@@ -2641,26 +2617,26 @@
                        _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
-               */
+               /**
+                * checks if event is rejected from user and he's not the owner 
and dont want rejected
+               *
+                * @param $event to check
+                * @return True if event should not be shown
+                */
                function rejected_no_show($event)
                {
                        $ret = !$this->prefs['calendar']['show_rejected'] &&
-                              $event['owner'] != $this->owner &&
-                              $event['participants'][$this->owner] == 'R';
+                                  $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['calendar']['show_rejected']."'</p>\n";
                        return $ret;
                }

-               /*!
-               @function list_cals
-               @abstract generate list of user- / group-calendars for the 
selectbox in the header
-               @returns alphabeticaly sorted array with groups first and then 
users
-               */
+               /**
+                * generate list of user- / group-calendars for the selectbox 
in the header
+               *
+                * @return alphabeticaly sorted array with groups first and 
then users
+                */
                function list_cals()
                {
                        $users = $groups = array();
@@ -2668,11 +2644,13 @@
                        {
                                $this->list_cals_add($id,$users,$groups);
                        }
+                       /*
                        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);
+                                       //Now group membership doesn't 
automatically grant rights
+                                       
//$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,'calendar'))
                                        {
@@ -2683,6 +2661,7 @@
                                        }
                                }
                        }
+                       */
                        uksort($users,'strnatcasecmp');
                        uksort($groups,'strnatcasecmp');

@@ -2698,47 +2677,55 @@
                * @param array ref to array of users
                * @param array ref to array of groups
                */
-               function list_cals_add($id,&$users,&$groups)
+               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;
+                               $value = "g_{$id}";
+                               $name = 
$GLOBALS['phpgw']->common->grab_owner_name($id);
+                               //echo "group name:{$name} acct_id:{$id} 
contact_id:{$value}<br />\n";
                        }
                        else
                        {
                                $arr = &$users;
+                               $value = $this->contacts->is_contact($id);
+                               $name = 
$this->contacts->get_name_of_person_id($value);
                        }
-                       $arr[$name] = Array(
+                       $arr[$name] = array(
                                'grantor'       => $id,
-                               'value'         => ($type == 'g' ? 'g_' : '') . 
$id,
+                               'value'         => $value,
                                'name'          => $name
                        );
                }

-               /*!
-               @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 !)
-               */
+               /**
+                * create array with name, translated name and readable content 
of each attributes of an event
+               *
+                * @param $event event to use
+                * @return 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(
+                       if ( !is_object($GLOBALS['phpgw']->contacts) )
+                       {
+                               $GLOBALS['phpgw']->contacts = 
createObject('phpgwapi.contacts');
+                       }
+
+                       $var['title'] = array(
                                'field'         => lang('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(
+                       $var['description'] = array(
                                'field' => lang('Description'),
                                'data'  => $event['description']
                        );

-                       $cats = Array();
+                       $cats = array();
                        $this->cat->categories($this->bo->owner,'calendar');
                        if(strpos($event['category'],','))
                        {
@@ -2753,47 +2740,47 @@
                                list($cat) = $this->cat->return_single($cat_id);
                                $cat_string[] = $cat['name'];
                        }
-                       $var['category'] = Array(
+                       $var['category'] = array(
                                'field' => lang('Category'),
                                'data'  => implode(', ',$cat_string)
                        );

-                       $var['location'] = Array(
+                       $var['location'] = array(
                                'field' => lang('Location'),
                                'data'  => $event['location']
                        );

-                       $var['startdate'] = Array(
+                       $var['startdate'] = array(
                                'field' => lang('Start Date/Time'),
                                'data'  => 
$GLOBALS['phpgw']->common->show_date($this->maketime($event['start']) - 
$GLOBALS['phpgw']->datetime->tz_offset),
                        );

-                       $var['enddate'] = Array(
+                       $var['enddate'] = array(
                                'field' => lang('End Date/Time'),
                                'data'  => 
$GLOBALS['phpgw']->common->show_date($this->maketime($event['end']) - 
$GLOBALS['phpgw']->datetime->tz_offset)
                        );

-                       $pri = Array(
+                       $pri = array(
                                1       => lang('Low'),
                                2       => lang('Normal'),
                                3       => lang('High')
                        );
-                       $var['priority'] = Array(
+                       $var['priority'] = array(
                                'field' => lang('Priority'),
                                'data'  => $pri[$event['priority']]
                        );

-                       $var['owner'] = Array(
+                       $var['owner'] = array(
                                'field' => lang('Created By'),
-                               'data'  => 
$GLOBALS['phpgw']->common->grab_owner_name($event['owner'])
+                               'data'  => 
$GLOBALS['phpgw']->contacts->get_name_of_person_id($GLOBALS['phpgw']->contacts->is_contact($event['owner']))
                        );

-                       $var['updated'] = Array(
+                       $var['updated'] = array(
                                'field' => lang('Updated'),
                                'data'  => 
$GLOBALS['phpgw']->common->show_date($this->maketime($event['modtime']) - 
$GLOBALS['phpgw']->datetime->tz_offset)
                        );

-                       $var['access'] = Array(
+                       $var['access'] = array(
                                'field' => lang('Access'),
                                'data'  => $event['public'] ? lang('Public') : 
lang('Privat')
                        );
@@ -2805,11 +2792,12 @@
                                {
                                        
if($GLOBALS['phpgw']->accounts->exists($event['groups'][$i]))
                                        {
-                                               $cal_grps .= ($i>0?'<br 
/>':'').$GLOBALS['phpgw']->accounts->id2name($event['groups'][$i]);
+                                               $cal_grps .= ($i>0?'<br />':'')
+                                                       . 
$GLOBALS['phpgw']->contacts->get_name_of_person_id($GLOBALS['phpgw']->contacts->is_contact($event['groups'][$i]));
                                        }
                                }

-                               $var['groups'] = Array(
+                               $var['groups'] = array(
                                        'field' => lang('Groups'),
                                        'data'  => $cal_grps
                                );
@@ -2820,13 +2808,10 @@
                        {
                                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).')';
-                                       }
+                                       $participants[$user] = 
$GLOBALS['phpgw']->contacts->get_name_of_person_id($user).' 
('.$this->get_long_status($short_status).')';
                                }
                        }
-                       $var['participants'] = Array(
+                       $var['participants'] = array(
                                'field' => lang('Participants'),
                                'data'  => $participants
                        );
@@ -2871,7 +2856,7 @@
                                        $str .= ' ('.$str_extra.')';
                                }

-                               $var['recure_type'] = Array(
+                               $var['recure_type'] = array(
                                        'field' => lang('Repetition'),
                                        'data'  => $str,
                                );
@@ -2910,11 +2895,11 @@
                        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
-               */
+               /**
+                * sets the default prefs, if they are not already set (on a 
per pref. basis)
+               *
+                * 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','calendar')))
@@ -2971,6 +2956,33 @@
                                
$GLOBALS['phpgw']->preferences->delete('calendar','send_updates');
                                $prefs = 
$GLOBALS['phpgw']->preferences->save_repository();
                        }
+               }
+
+               /**
+               * Search for a list of contacts based on their [first|last]name
+               *
+               * @author skwashd
+               * @param string $lookup the name to search for
+               * @param int $cat_id the category to limit the search to
+               * @returns array contacts found
+               */
+               function get_contacts($lookup, $cat_id)
+               {
+                       $fields = array ('contact_id', 'per_first_name', 
'per_last_name');
+
+                       $criteria_search[] = sql_criteria::token_begin( 
'per_first_name', $lookup);
+                       $criteria_search[] = 
sql_criteria::token_begin('per_last_name', $lookup);
+
+                       $criteria[] = 
sql_criteria::_append_or($criteria_search);
+                       $criteria[] = 
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id']);
+
+                       if ( $cat_id )
+                       {
+                               $criteria[] = sql_criteria::_equal('cat_id', 
$_GET['cat_id']);
+                       }
+
+                       $criteria_token = sql_criteria::_append_and($criteria);
+                       return $this->contacts->get_persons($fields, 0, 0, 
'per_first_name, per_last_name', 'ASC', '', $criteria_token);
                }
        }
 ?>

====================================================
Index: calendar/inc/hook_deleteaccount.inc.php
diff -u calendar/inc/hook_deleteaccount.inc.php:1.7 
calendar/inc/hook_deleteaccount.inc.php:1.8
--- calendar/inc/hook_deleteaccount.inc.php:1.7 Sun May 15 06:57:37 2005
+++ calendar/inc/hook_deleteaccount.inc.php     Sun Oct 23 12:57:16 2005
@@ -12,16 +12,16 @@
        /* $Id$ */

        // Delete all records for a user
-       if(intval($GLOBALS['HTTP_POST_VARS']['new_owner'])==0)
+       if(intval($_POST['new_owner']) == 0)
        {
-               
ExecMethod('calendar.bocalendar.delete_calendar',intval($GLOBALS['HTTP_POST_VARS']['account_id']));
+               ExecMethod('calendar.bocalendar.delete_calendar', 
intval($_POST['account_id']));
        }
        else
        {
                ExecMethod('calendar.bocalendar.change_owner',
                        Array(
-                               'old_owner'     => 
intval($GLOBALS['HTTP_POST_VARS']['account_id']),
-                               'new_owner'     => 
intval($GLOBALS['HTTP_POST_VARS']['new_owner'])
+                               'old_owner'     => intval($_POST['account_id']),
+                               'new_owner'     => intval($_POST['new_owner'])
                        )
                );
        }

====================================================
Index: calendar/inc/hook_sidebox_menu.inc.php
diff -u calendar/inc/hook_sidebox_menu.inc.php:1.2 
calendar/inc/hook_sidebox_menu.inc.php:1.3
--- calendar/inc/hook_sidebox_menu.inc.php:1.2  Sun May 15 06:57:37 2005
+++ calendar/inc/hook_sidebox_menu.inc.php      Sun Oct 23 12:57:16 2005
@@ -23,26 +23,26 @@
        display_sidebox can be called as much as you like
  */

-       $menu_title = $GLOBALS['phpgw_info']['apps'][$appname]['title'] . ' '. 
lang('Menu');
+       $menu_title = lang($appname) . ' '. lang('Menu');
        $file = Array(
                        array('text'  => 'New Entry',
-                               'url' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.add')),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uicalendar.add'))),
                        array('text'  => '_NewLine_'),
                        array('text'  => 'Today',
-                               'url' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.day')),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uicalendar.day'))),
                        array('text'  => 'This week',
-                               'url' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.week')),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uicalendar.week'))),
                        array('text'  => 'This month',
-                               'url' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.month')),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uicalendar.month'))),
                        array('text'  => 'This year',
-                               'url' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.year')),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uicalendar.year'))),
                        array('text'  => '_NewLine_'), // give a newline
                        array('text'  => 'Group Planner',
-                               'url' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.planner')),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uicalendar.planner'))),
                        array('text'  => 'Daily Matrix View',
-                               'url' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.matrixselect')),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uicalendar.matrixselect'))),
                        array('text'  => 'Import',
-                               'url' 
=>$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import')),
+                               'url' =>$GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'calendar.uiicalendar.import'))),
        );
        display_sidebox($appname,$menu_title,$file);

@@ -51,11 +51,22 @@
                $menu_title = lang('Preferences');
                $file = Array(
                                array('text'  => 'Calendar preferences',
-                                       'url' 
=>$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=calendar')),
+                                       'url' 
=>$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' => 
'calendar'))),
                                array('text'  => 'Grant Access',
-                                       'url' 
=>$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app=calendar')),
+                                       'url' 
=>$GLOBALS['phpgw']->link('/index.php',array
+                                                                               
(
+                                                                               
        'menuaction' => 'preferences.uiaclprefs.index',
+                                                                               
        'acl_app' => 'calendar'
+                                                                               
))),
                                array('text'  => 'Edit Categories',
-                                       'url' 
=>$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=calendar&cats_level=True&global_cats=True')),
+                                       'url' 
=>$GLOBALS['phpgw']->link('/index.php',
+                                                                               
array
+                                                                               
(
+                                                                               
        'menuaction'    => 'preferences.uicategories.index',
+                                                                               
        'cats_app'      => 'calendar',
+                                                                               
        'cats_level'    => '1',
+                                                                               
        'global_cats'   => 1
+                                                                               
))),
                );
                display_sidebox($appname,$menu_title,$file);
        }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]