phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] hrm/inc class.uiuser.inc.php, 1.6 class.souser.inc.ph


From: sigurdne
Subject: [Phpgroupware-cvs] hrm/inc class.uiuser.inc.php, 1.6 class.souser.inc.php, 1.4 class.bouser.inc.php, 1.6 class.boadmin.inc.php, 1.4 class.bocommon.inc.php, 1.5 class.acl2.inc.php, 1.2
Date: Tue, 29 Nov 2005 14:09:00 +0100

Update of hrm/inc

Modified Files:
     Branch: MAIN
            class.uiuser.inc.php lines: +63 -15
            class.souser.inc.php lines: +29 -10
            class.bouser.inc.php lines: +4 -3
            class.boadmin.inc.php lines: +404 -404
            class.bocommon.inc.php lines: +659 -659
            class.acl2.inc.php lines: +38 -7

Log Message:
*** empty log message ***

====================================================
Index: hrm/inc/class.uiuser.inc.php
diff -u hrm/inc/class.uiuser.inc.php:1.5 hrm/inc/class.uiuser.inc.php:1.6
--- hrm/inc/class.uiuser.inc.php:1.5    Mon Nov 28 15:06:48 2005
+++ hrm/inc/class.uiuser.inc.php        Tue Nov 29 13:09:40 2005
@@ -47,6 +47,7 @@
                        $this->menu                             = 
CreateObject($this->currentapp.'.menu');
                        $this->menu->sub                        ='user';

+                       $this->grants                           = 
$this->bo->grants;
                        $this->start                            = 
$this->bo->start;
                        $this->query                            = 
$this->bo->query;
                        $this->sort                             = 
$this->bo->sort;
@@ -184,6 +185,11 @@
                {
                        $user_id        = 
get_var('user_id',array('POST','GET'));

+                       if (!$this->grants[$user_id])
+                       {
+                               return;
+                       }
+
                        $receipt = 
$GLOBALS['phpgw']->session->appsession('session_data','hrm_training_receipt');
                        
$GLOBALS['phpgw']->session->appsession('session_data','hrm_training_receipt','');

@@ -297,21 +303,34 @@
                                        $entry['end_date']      = 
$GLOBALS['phpgw']->common->show_date($entry['end_date'],$dateformat);
                                }

+                               
if($this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_EDIT))
+                               {
+                                       $link_edit      = 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.".uiuser.edit&user_id=$user_id&training_id="
 . $entry['training_id']);
+                                       $text_edit      = lang('edit');
+                                       $lang_edit_text = lang('edit training 
item');
+                               }
+                               
if($this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_DELETE))
+                               {
+                                       $link_delete            = 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.".uiuser.delete&user_id=$user_id&training_id="
 . $entry['training_id']);
+                                       $text_delete            = 
lang('delete');
+                                       $lang_delete_text       = lang('delete 
training item');
+                               }
+
                                $content[] = array
                                (
                                        'title'                 => 
$entry['title'],
                                        'place'                 => 
$entry['place'],
                                        'start_date'            => 
$entry['start_date'],
                                        'end_date'              => 
$entry['end_date'],
-                                       'link_edit'             => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.".uiuser.edit&user_id=$user_id&training_id="
 . $entry['training_id']),
+                                       'link_edit'             => $link_edit,
                                        'link_view'             => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.".uiuser.view&user_id=$user_id&training_id="
 . $entry['training_id']),
-                                       'link_delete'           => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.".uiuser.delete&user_id=$user_id&training_id="
 . $entry['training_id']),
+                                       'link_delete'           => $link_delete,
                                        'lang_view_text'        => lang('view 
training item'),
-                                       'lang_edit_text'        => lang('edit 
training item'),
-                                       'lang_delete_text'      => lang('delete 
training item'),
+                                       'lang_edit_text'        => 
$lang_edit_text,
+                                       'lang_delete_text'      => 
$lang_delete_text,
                                        'text_view'             => lang('view'),
-                                       'text_edit'             => lang('edit'),
-                                       'text_delete'           => 
lang('delete')
+                                       'text_edit'             => $text_edit,
+                                       'text_delete'           => $text_delete
                                );
                        }

@@ -350,22 +369,26 @@
                                'lang_delete'   => lang('delete'),
                        );

-
-
                        $function_msg = lang('list training');

-
                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uiuser.edit',
                                'user_id'       => $user_id
                        );

+                       
if($this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_ADD))
+                       {
+                               $add_action     = 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiuser.edit&user_id='.$user_id);
+                               $lang_add       = lang('add');
+                       }
+
+
                        $table_add[] = array
                        (
-                               'lang_add'                      => lang('add'),
+                               'lang_add'                      => $lang_add,
                                'lang_add_training_text'        => lang('add a 
training item'),
-                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiuser.edit&user_id='.$user_id),
+                               'add_action'                    => $add_action,
                                'lang_done'                     => lang('done'),
                                'lang_done_training_text'       => lang('back 
to user list'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiuser.index')
@@ -408,7 +431,22 @@
                        $training_id    = 
get_var('training_id',array('POST','GET'));
                        $user_id        = 
get_var('user_id',array('POST','GET'));
                        $values         = get_var('values',array('POST'));
-
+
+                       if(!$training_id)
+                       {
+                               
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_ADD))
+                               {
+                                       return;
+                               }
+                       }
+                       else
+                       {
+                               
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_EDIT))
+                               {
+                                       return;
+                               }
+                       }
+
                        $GLOBALS['phpgw']->xslttpl->add_file(array('user'));

                        if (is_array($values))
@@ -592,7 +630,11 @@
                {
                        $training_id            = 
get_var('training_id',array('POST','GET'));
                        $user_id        = 
get_var('user_id',array('POST','GET'));
-                       $values         = get_var('values',array('POST'));
+
+                       
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_READ))
+                       {
+                               unset($training_id);
+                       }

                        $GLOBALS['phpgw']->xslttpl->add_file(array('user'));

@@ -673,6 +715,12 @@
                {
                        $training_id            = 
get_var('training_id',array('POST','GET'));
                        $user_id        = 
get_var('user_id',array('POST','GET'));
+
+                       
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_DELETE))
+                       {
+                               return;
+                       }
+
                        $confirm                = 
get_var('confirm',array('POST'));

                        $link_data = array
@@ -707,4 +755,4 @@
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
                }

-       }
\ No newline at end of file
+       }

====================================================
Index: hrm/inc/class.souser.inc.php
diff -u hrm/inc/class.souser.inc.php:1.3 hrm/inc/class.souser.inc.php:1.4
--- hrm/inc/class.souser.inc.php:1.3    Wed Nov 23 10:55:40 2005
+++ hrm/inc/class.souser.inc.php        Tue Nov 29 13:09:40 2005
@@ -31,10 +31,11 @@
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');

-                       $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants('hrm');
-                       $this->left_join                = 
$this->bocommon->left_join;
-                       $this->join                     = $this->bocommon->join;
-                       $this->like                     = $this->bocommon->like;
+                       $this->acl              = 
CreateObject($this->currentapp.'.acl2');
+                       $this->grants           = 
$this->acl->get_grants('hrm','user');
+                       $this->left_join        = $this->bocommon->left_join;
+                       $this->join             = $this->bocommon->join;
+                       $this->like             = $this->bocommon->like;
                }

                function read($data)
@@ -55,6 +56,22 @@
                                $allrows        = 
(isset($data['allrows'])?$data['allrows']:'');
                        }

+                       $filtermethod = ' ( account_id=' . $this->account;
+                       if (is_array($this->grants))
+                       {
+                               $grants = $this->grants;
+                               while (list($user) = each($grants))
+                               {
+                                       $public_user_list[] = $user;
+                               }
+                               reset($public_user_list);
+                               $filtermethod .= " OR ( account_id IN(" . 
implode(',',$public_user_list) . ")))";
+                       }
+                       else
+                       {
+                               $filtermethod .= ' )';
+                       }
+
                        if ($order)
                        {
                                $ordermethod = " order by $order $sort";
@@ -75,7 +92,7 @@
                                $querymethod = " AND account_firstname 
$this->like '%$query%' or account_lastname $this->like '%$query%'";
                        }

-                       $sql = "SELECT * FROM $table WHERE account_type = 'u' 
$querymethod";
+                       $sql = "SELECT * FROM $table WHERE account_type = 'u' 
AND account_status = 'A' AND $filtermethod $querymethod";

                        $this->db2->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db2->num_rows();
@@ -91,11 +108,13 @@

                        while ($this->db->next_record())
                        {
+                               $ngrants = 
$this->grants[$this->db->f('account_id')];
                                $account_info[] = array
                                (
-                                       'account_id'    => 
$this->db->f('account_id'),
+                                       'account_id'            => 
$this->db->f('account_id'),
                                        'account_firstname'     => 
stripslashes($this->db->f('account_firstname')),
-                                       'account_lastname'      => 
stripslashes($this->db->f('account_lastname'))
+                                       'account_lastname'      => 
stripslashes($this->db->f('account_lastname')),
+                                       'grants'                => $ngrants
                                );
                        }

@@ -163,7 +182,7 @@
                        $this->db->query($sql . $ordermethod 
,__LINE__,__FILE__);

                        while ($this->db->next_record())
-                       {
+                       {
                                $training[] = array
                                (
                                        'training_id'   => 
$this->db->f('training_id'),
@@ -309,4 +328,4 @@
                        return $place;
                }

-       }
\ No newline at end of file
+       }

====================================================
Index: hrm/inc/class.bouser.inc.php
diff -u hrm/inc/class.bouser.inc.php:1.5 hrm/inc/class.bouser.inc.php:1.6
--- hrm/inc/class.bouser.inc.php:1.5    Mon Nov 28 15:06:48 2005
+++ hrm/inc/class.bouser.inc.php        Tue Nov 29 13:09:40 2005
@@ -57,7 +57,8 @@
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so               = 
CreateObject($this->currentapp.'.souser');
-                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->grants = $this->so->grants;

                        if ($session)
                        {
@@ -245,4 +246,4 @@
                        $place_list = 
$this->bocommon->select_list($selected,$places);
                        return $place_list;
                }
-       }
\ No newline at end of file
+       }

====================================================
Index: hrm/inc/class.boadmin.inc.php
diff -u hrm/inc/class.boadmin.inc.php:1.3 hrm/inc/class.boadmin.inc.php:1.4
--- hrm/inc/class.boadmin.inc.php:1.3   Fri Nov 25 11:58:29 2005
+++ hrm/inc/class.boadmin.inc.php       Tue Nov 29 13:09:39 2005
@@ -1,404 +1,404 @@
-<?php
-       /**
-       * phpGroupWare - HRM: a  human resource competence management system.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package hrm
-       * @subpackage admin
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class boadmin
-       {
-               var $start;
-               var $query;
-               var $filter;
-               var $sort;
-               var $order;
-               var $cat_id;
-
-               function boadmin($session='')
-               {
-                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->so                       = 
CreateObject($this->currentapp.'.soadmin');
-                       $this->catbo = createobject('phpgwapi.categories');
-
-//                     $this->acl              = $GLOBALS['phpgw']->acl;
-                       $this->acl              = 
CreateObject($this->currentapp.'.acl2');
-                       $this->right            = array(1,2,4,8,16);
-
-                       if ($session)
-                       {
-                               $this->read_sessiondata();
-                               $this->use_session = True;
-                       }
-
-                       $acl_app        = 
get_var('acl_app',array('POST','GET'));
-                       $start  = get_var('start',array('POST','GET'));
-                       $query  = get_var('query',array('POST','GET'));
-                       $sort   = get_var('sort',array('POST','GET'));
-                       $order  = get_var('order',array('POST','GET'));
-                       $filter = get_var('filter',array('POST','GET'));
-                       $cat_id = get_var('cat_id',array('POST','GET'));
-                       $permission     = 
get_var('permission',array('POST','GET'));
-                       $module = get_var('module',array('POST','GET'));
-                       $granting_group = 
get_var('granting_group',array('POST','GET'));
-                       $allrows        = 
get_var('allrows',array('POST','GET'));
-
-                       if ($start)
-                       {
-                               $this->start=$start;
-                       }
-                       else
-                       {
-                               $this->start=0;
-                       }
-
-                       if($acl_app)
-                       {
-                               $this->acl_app = $acl_app;
-                       }
-                       else
-                       {
-                               $this->acl_app = $this->currentapp;
-                       }
-                       if(isset($query))
-                       {
-                               $this->query = $query;
-                       }
-                       if(isset($filter))
-                       {
-                               $this->filter = $filter;
-                       }
-                       if(isset($sort))
-                       {
-                               $this->sort = $sort;
-                       }
-                       if(isset($order))
-                       {
-                               $this->order = $order;
-                       }
-                       if(isset($cat_id))
-                       {
-                               $this->cat_id = $cat_id;
-                       }
-                       if(isset($module))
-                       {
-                               $this->location = $module;
-                       }
-                       if(isset($granting_group))
-                       {
-                               $this->granting_group = $granting_group;
-                       }
-                       if(isset($allrows))
-                       {
-                               $this->allrows = $allrows;
-                       }
-               }
-
-
-               function read_sessiondata()
-               {
-                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin');
-
-                       $this->start            = $data['start'];
-                       $this->query            = $data['query'];
-                       $this->filter           = $data['filter'];
-                       $this->sort                     = $data['sort'];
-                       $this->order            = $data['order'];
-                       $this->cat_id           = $data['cat_id'];
-                       $this->location         = $data['location'];
-                       $this->granting_group   = $data['granting_group'];
-                       $this->allrows  = $data['allrows'];
-               }
-
-               function save_sessiondata($data)
-               {
-                       if ($this->use_session)
-                       {
-                               
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin',$data);
-                       }
-               }
-
-               function select_location($format='',$selected='',$grant='')
-               {
-
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('select_location'));
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_location'));
-                                       break;
-                       }
-
-//                     $locations= $this->so->select_location($grant);
-                       $i=0;
-                       $locations[$i]['id']                    = 'run';
-                       $locations[$i]['descr']         = 'Hrm-main';
-                       $i++;
-                       $locations[$i]['id']                    = 'user';
-                       $locations[$i]['descr']         = 'Hrm-user';
-                       $i++;
-                       $locations[$i]['id']                    = 'C-1';
-                       $locations[$i]['descr']         = 
lang('contact_information');
-                       $i++;
-                       $locations[$i]['id']                    = 'C-2';
-                       $locations[$i]['descr']         = lang('photo');
-                       $i++;
-
-
-                       $api_cats = $this->catbo->return_array('all', 0, True, 
False, False, 'cat_name', True);
-                       if ( is_array($api_cats) )
-                       {
-                               foreach ($api_cats as $cat)
-                               {
-                                       $locations[$i]['id']    = 'C' . 
$cat['id'];
-                                       $locations[$i]['descr'] = $cat['name'];
-                                       $i++;
-                               }
-                       }
-                       unset($api_cats);
-
-                       while (is_array($locations) && list(,$loc) = 
each($locations))
-                       {
-                               $sel_loc = '';
-                               if ($loc['id']==$selected)
-                               {
-                                       $sel_loc = 'selected';
-                               }
-
-                               $location_list[] = array
-                               (
-                                       'id'            => $loc['id'],
-                                       'descr'         => $loc['id'] . ' [' . 
$loc['descr'] . ']',
-                                       'selected'      => $sel_loc
-                               );
-                       }
-
-                       for ($i=0;$i<count($location_list);$i++)
-                       {
-                               if ($location_list[$i]['selected'] != 
'selected')
-                               {
-                                       unset($location_list[$i]['selected']);
-                               }
-                       }
-
-                       return $location_list;
-               }
-
-               function select_category_list($format='',$selected='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
-                                       break;
-                       }
-
-
-                       $categories[0]['id']    = 'groups';
-                       $categories[0]['name']  = lang('Groups');
-                       $categories[1]['id']    = 'accounts';
-                       $categories[1]['name']  = lang('Users');
-
-                       while (is_array($categories) && list(,$category) = 
each($categories))
-                       {
-                               $sel_category = '';
-                               if ($category['id']==$selected)
-                               {
-                                       $sel_category = 'selected';
-                               }
-
-                               $category_list[] = array
-                               (
-                                       'cat_id'        => $category['id'],
-                                       'name'          => $category['name'],
-                                       'selected'      => $sel_category
-                               );
-                       }
-
-                       for ($i=0;$i<count($category_list);$i++)
-                       {
-                               if ($category_list[$i]['selected'] != 
'selected')
-                               {
-                                       unset($category_list[$i]['selected']);
-                               }
-                       }
-
-                       return $category_list;
-               }
-
-
-               function set_permission2($values,$r_processed, $grantor = 
False, $type = False)
-               {
-                       @reset($values);
-                       $totalacl = array();
-                       while(list($rowinfo,$perm) = each($values))
-                       {
-                               list($user_id,$rights) = split('_',$rowinfo);
-                               $totalacl[$user_id] += $rights;
-                       }
-                       @reset($totalacl);
-                       while(list($user_id,$rights) = @each($totalacl))
-                       {
-                               $user_checked[]=$user_id;
-
-                               $this->acl->account_id=$user_id;
-                               $this->acl->read_repository();
-                               $this->acl->delete($appname = $this->acl_app, 
$this->location,$grantor,$type);
-                               $this->acl->add($appname = $this->acl_app, 
$this->location, $rights,$grantor,$type);
-                               $this->acl->save_repository();
-                       }
-
-                       if(is_array($r_processed) && is_array($user_checked))
-                       {
-                               $user_delete    = array_diff($r_processed, 
$user_checked);
-                       }
-                       else
-                       {
-                               $user_delete    = $r_processed;
-                       }
-                       if(is_array($user_delete) && count($user_delete)>0)
-                       {
-                               while(list(,$user_id) = each($user_delete))
-                               {
-                                       $this->acl->account_id=$user_id;
-                                       $this->acl->read_repository();
-                                       $this->acl->delete($appname = 
$this->acl_app, $this->location,$grantor,$type);
-                                       $this->acl->save_repository();
-                               }
-                       }
-               }
-
-               function set_permission($values,$r_processed,$set_grant = '')
-               {
-
-                       $r_processed=explode("_",$r_processed);
-
-                       if(!$values['right'])
-                       {
-                               $values['right'] = array();
-                       }
-                       if(!$values['mask'])
-                       {
-                               $values['mask'] = array();
-                       }
-
-                       if($set_grant)
-                       {
-                               if($this->granting_group)
-                               {
-                                       $grantor = $this->granting_group;
-                               }
-                               else
-                               {
-                                       $grantor = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                               }
-                       }
-
-                       
$this->set_permission2($values['right'],$r_processed,$grantor,0);
-                       
$this->set_permission2($values['mask'],$r_processed,$grantor,1);
-
-                       $receipt['message'][] = array('msg' => 
lang('permissions are updated!'));
-                       return $receipt;
-               }
-
-
-               function get_user_list($type='',$get_grants='')
-               {
-                       if($type == 'groups')
-                       {
-                               $check_account_type = array('accounts');
-                       }
-                       else
-                       {
-                               $check_account_type = 
array('groups','accounts');
-                       }
-
-                       if($get_grants)
-                       {
-                               if($this->granting_group)
-                               {
-                                       $grantor = $this->granting_group;
-                               }
-                               else
-                               {
-                                       $grantor = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                               }
-                       }
-
-                       $right=$this->right;
-
-                       if ($this->allrows)
-                       {
-                               $this->start = -1;
-                               $offset = -1;
-                       }
-
-                       $allusers = 
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort, 
$this->order, $this->query, $offset);
-
-                       if (isSet($allusers) AND is_array($allusers))
-                       {
-                               $j=0;
-                               foreach($allusers as $account)
-                               {
-                                       $user_list[$j]['account_id']            
= $account['account_id'];
-                                       $user_list[$j]['account_lid']           
= $account['account_lid'];
-                                       $user_list[$j]['account_firstname']     
= $account['account_firstname'];
-                                       $user_list[$j]['account_lastname']      
= $account['account_lastname'];
-
-                                       
$this->acl->account_id=$account['account_id'];
-
-                                       $this->acl->read_repository();
-
-                                       $count_right=count($right);
-                                       for ($i=0;$i<$count_right;$i++)
-                                       {
-                                               
if($this->acl->check_brutto($this->location, 
$right[$i],$this->acl_app,$grantor,0,$check_account_type))
-                                               {
-                                                       
if($this->acl->account_type == 'g')
-                                                       {
-                                                               
$user_list[$j]['right'][$right[$i]] = 'from_group';
-                                                       }
-                                                       else
-                                                       {
-                                                               
$user_list[$j]['right'][$right[$i]] = 'checked';
-                                                       }
-                                                       
$user_list[$j]['result'][$right[$i]] = 'checked';
-                                               }
-                                               
if($this->acl->check_brutto($this->location, 
$right[$i],$this->acl_app,$grantor,1,$check_account_type))
-                                               {
-                                                       
if($this->acl->account_type == 'g')
-                                                       {
-                                                               
$user_list[$j]['mask'][$right[$i]] = 'from_group';
-                                                       }
-                                                       else
-                                                       {
-                                                               
$user_list[$j]['mask'][$right[$i]] = 'checked';
-                                                       }
-                                                       
unset($user_list[$j]['result'][$right[$i]]);
-                                               }
-                                       }
-
-                                       $j++;
-                               }
-                       }
-
-                       $this->total_records = 
$GLOBALS['phpgw']->accounts->total;
-
-                       return $user_list;
-               }
-       }
\ No newline at end of file
+<?php
+       /**
+       * phpGroupWare - HRM: a  human resource competence management system.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package hrm
+       * @subpackage admin
+       * @version $Id$
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+
+       class boadmin
+       {
+               var $start;
+               var $query;
+               var $filter;
+               var $sort;
+               var $order;
+               var $cat_id;
+
+               function boadmin($session='')
+               {
+                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->so                       = 
CreateObject($this->currentapp.'.soadmin');
+                       $this->catbo = createobject('phpgwapi.categories');
+
+//                     $this->acl              = $GLOBALS['phpgw']->acl;
+                       $this->acl              = 
CreateObject($this->currentapp.'.acl2');
+                       $this->right            = array(1,2,4,8,16);
+
+                       if ($session)
+                       {
+                               $this->read_sessiondata();
+                               $this->use_session = True;
+                       }
+
+                       $acl_app        = 
get_var('acl_app',array('POST','GET'));
+                       $start  = get_var('start',array('POST','GET'));
+                       $query  = get_var('query',array('POST','GET'));
+                       $sort   = get_var('sort',array('POST','GET'));
+                       $order  = get_var('order',array('POST','GET'));
+                       $filter = get_var('filter',array('POST','GET'));
+                       $cat_id = get_var('cat_id',array('POST','GET'));
+                       $permission     = 
get_var('permission',array('POST','GET'));
+                       $module = get_var('module',array('POST','GET'));
+                       $granting_group = 
get_var('granting_group',array('POST','GET'));
+                       $allrows        = 
get_var('allrows',array('POST','GET'));
+
+                       if ($start)
+                       {
+                               $this->start=$start;
+                       }
+                       else
+                       {
+                               $this->start=0;
+                       }
+
+                       if($acl_app)
+                       {
+                               $this->acl_app = $acl_app;
+                       }
+                       else
+                       {
+                               $this->acl_app = $this->currentapp;
+                       }
+                       if(isset($query))
+                       {
+                               $this->query = $query;
+                       }
+                       if(isset($filter))
+                       {
+                               $this->filter = $filter;
+                       }
+                       if(isset($sort))
+                       {
+                               $this->sort = $sort;
+                       }
+                       if(isset($order))
+                       {
+                               $this->order = $order;
+                       }
+                       if(isset($cat_id))
+                       {
+                               $this->cat_id = $cat_id;
+                       }
+                       if(isset($module))
+                       {
+                               $this->location = $module;
+                       }
+                       if(isset($granting_group))
+                       {
+                               $this->granting_group = $granting_group;
+                       }
+                       if(isset($allrows))
+                       {
+                               $this->allrows = $allrows;
+                       }
+               }
+
+
+               function read_sessiondata()
+               {
+                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin');
+
+                       $this->start            = $data['start'];
+                       $this->query            = $data['query'];
+                       $this->filter           = $data['filter'];
+                       $this->sort                     = $data['sort'];
+                       $this->order            = $data['order'];
+                       $this->cat_id           = $data['cat_id'];
+                       $this->location         = $data['location'];
+                       $this->granting_group   = $data['granting_group'];
+                       $this->allrows  = $data['allrows'];
+               }
+
+               function save_sessiondata($data)
+               {
+                       if ($this->use_session)
+                       {
+                               
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin',$data);
+                       }
+               }
+
+               function select_location($format='',$selected='',$grant='')
+               {
+
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('select_location'));
+                                       break;
+                               case 'filter':
+                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_location'));
+                                       break;
+                       }
+
+//                     $locations= $this->so->select_location($grant);
+                       $i=0;
+                       $locations[$i]['id']                    = 'run';
+                       $locations[$i]['descr']         = 'Hrm-main';
+                       $i++;
+                       $locations[$i]['id']                    = 'user';
+                       $locations[$i]['descr']         = 'Hrm-user';
+                       $i++;
+                       $locations[$i]['id']                    = 'C-1';
+                       $locations[$i]['descr']         = 
lang('contact_information');
+                       $i++;
+                       $locations[$i]['id']                    = 'C-2';
+                       $locations[$i]['descr']         = lang('photo');
+                       $i++;
+
+
+                       $api_cats = $this->catbo->return_array('all', 0, True, 
False, False, 'cat_name', True);
+                       if ( is_array($api_cats) )
+                       {
+                               foreach ($api_cats as $cat)
+                               {
+                                       $locations[$i]['id']    = 'C' . 
$cat['id'];
+                                       $locations[$i]['descr'] = $cat['name'];
+                                       $i++;
+                               }
+                       }
+                       unset($api_cats);
+
+                       while (is_array($locations) && list(,$loc) = 
each($locations))
+                       {
+                               $sel_loc = '';
+                               if ($loc['id']==$selected)
+                               {
+                                       $sel_loc = 'selected';
+                               }
+
+                               $location_list[] = array
+                               (
+                                       'id'            => $loc['id'],
+                                       'descr'         => $loc['id'] . ' [' . 
$loc['descr'] . ']',
+                                       'selected'      => $sel_loc
+                               );
+                       }
+
+                       for ($i=0;$i<count($location_list);$i++)
+                       {
+                               if ($location_list[$i]['selected'] != 
'selected')
+                               {
+                                       unset($location_list[$i]['selected']);
+                               }
+                       }
+
+                       return $location_list;
+               }
+
+               function select_category_list($format='',$selected='')
+               {
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+                                       break;
+                               case 'filter':
+                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+                                       break;
+                       }
+
+
+                       $categories[0]['id']    = 'groups';
+                       $categories[0]['name']  = lang('Groups');
+                       $categories[1]['id']    = 'accounts';
+                       $categories[1]['name']  = lang('Users');
+
+                       while (is_array($categories) && list(,$category) = 
each($categories))
+                       {
+                               $sel_category = '';
+                               if ($category['id']==$selected)
+                               {
+                                       $sel_category = 'selected';
+                               }
+
+                               $category_list[] = array
+                               (
+                                       'cat_id'        => $category['id'],
+                                       'name'          => $category['name'],
+                                       'selected'      => $sel_category
+                               );
+                       }
+
+                       for ($i=0;$i<count($category_list);$i++)
+                       {
+                               if ($category_list[$i]['selected'] != 
'selected')
+                               {
+                                       unset($category_list[$i]['selected']);
+                               }
+                       }
+
+                       return $category_list;
+               }
+
+
+               function set_permission2($values,$r_processed, $grantor = 
False, $type = False)
+               {
+                       @reset($values);
+                       $totalacl = array();
+                       while(list($rowinfo,$perm) = each($values))
+                       {
+                               list($user_id,$rights) = split('_',$rowinfo);
+                               $totalacl[$user_id] += $rights;
+                       }
+                       @reset($totalacl);
+                       while(list($user_id,$rights) = @each($totalacl))
+                       {
+                               $user_checked[]=$user_id;
+
+                               $this->acl->account_id=$user_id;
+                               $this->acl->read_repository();
+                               $this->acl->delete($appname = $this->acl_app, 
$this->location,$grantor,$type);
+                               $this->acl->add($appname = $this->acl_app, 
$this->location, $rights,$grantor,$type);
+                               $this->acl->save_repository();
+                       }
+
+                       if(is_array($r_processed) && is_array($user_checked))
+                       {
+                               $user_delete    = array_diff($r_processed, 
$user_checked);
+                       }
+                       else
+                       {
+                               $user_delete    = $r_processed;
+                       }
+                       if(is_array($user_delete) && count($user_delete)>0)
+                       {
+                               while(list(,$user_id) = each($user_delete))
+                               {
+                                       $this->acl->account_id=$user_id;
+                                       $this->acl->read_repository();
+                                       $this->acl->delete($appname = 
$this->acl_app, $this->location,$grantor,$type);
+                                       $this->acl->save_repository();
+                               }
+                       }
+               }
+
+               function set_permission($values,$r_processed,$set_grant = '')
+               {
+
+                       $r_processed=explode("_",$r_processed);
+
+                       if(!$values['right'])
+                       {
+                               $values['right'] = array();
+                       }
+                       if(!$values['mask'])
+                       {
+                               $values['mask'] = array();
+                       }
+
+                       if($set_grant)
+                       {
+                               if($this->granting_group)
+                               {
+                                       $grantor = $this->granting_group;
+                               }
+                               else
+                               {
+                                       $grantor = 
$GLOBALS['phpgw_info']['user']['account_id'];
+                               }
+                       }
+
+                       
$this->set_permission2($values['right'],$r_processed,$grantor,0);
+                       
$this->set_permission2($values['mask'],$r_processed,$grantor,1);
+
+                       $receipt['message'][] = array('msg' => 
lang('permissions are updated!'));
+                       return $receipt;
+               }
+
+
+               function get_user_list($type='',$get_grants='')
+               {
+                       if($type == 'groups')
+                       {
+                               $check_account_type = array('accounts');
+                       }
+                       else
+                       {
+                               $check_account_type = 
array('groups','accounts');
+                       }
+
+                       if($get_grants)
+                       {
+                               if($this->granting_group)
+                               {
+                                       $grantor = $this->granting_group;
+                               }
+                               else
+                               {
+                                       $grantor = 
$GLOBALS['phpgw_info']['user']['account_id'];
+                               }
+                       }
+
+                       $right=$this->right;
+
+                       if ($this->allrows)
+                       {
+                               $this->start = -1;
+                               $offset = -1;
+                       }
+
+                       $allusers = 
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort, 
$this->order, $this->query, $offset);
+
+                       if (isSet($allusers) AND is_array($allusers))
+                       {
+                               $j=0;
+                               foreach($allusers as $account)
+                               {
+                                       $user_list[$j]['account_id']            
= $account['account_id'];
+                                       $user_list[$j]['account_lid']           
= $account['account_lid'];
+                                       $user_list[$j]['account_firstname']     
= $account['account_firstname'];
+                                       $user_list[$j]['account_lastname']      
= $account['account_lastname'];
+
+                                       
$this->acl->account_id=$account['account_id'];
+
+                                       $this->acl->read_repository();
+
+                                       $count_right=count($right);
+                                       for ($i=0;$i<$count_right;$i++)
+                                       {
+                                               
if($this->acl->check_brutto($this->location, 
$right[$i],$this->acl_app,$grantor,0,$check_account_type))
+                                               {
+                                                       
if($this->acl->account_type == 'g')
+                                                       {
+                                                               
$user_list[$j]['right'][$right[$i]] = 'from_group';
+                                                       }
+                                                       else
+                                                       {
+                                                               
$user_list[$j]['right'][$right[$i]] = 'checked';
+                                                       }
+                                                       
$user_list[$j]['result'][$right[$i]] = 'checked';
+                                               }
+                                               
if($this->acl->check_brutto($this->location, 
$right[$i],$this->acl_app,$grantor,1,$check_account_type))
+                                               {
+                                                       
if($this->acl->account_type == 'g')
+                                                       {
+                                                               
$user_list[$j]['mask'][$right[$i]] = 'from_group';
+                                                       }
+                                                       else
+                                                       {
+                                                               
$user_list[$j]['mask'][$right[$i]] = 'checked';
+                                                       }
+                                                       
unset($user_list[$j]['result'][$right[$i]]);
+                                               }
+                                       }
+
+                                       $j++;
+                               }
+                       }
+
+                       $this->total_records = 
$GLOBALS['phpgw']->accounts->total;
+
+                       return $user_list;
+               }
+       }

====================================================
Index: hrm/inc/class.bocommon.inc.php
diff -u hrm/inc/class.bocommon.inc.php:1.4 hrm/inc/class.bocommon.inc.php:1.5
--- hrm/inc/class.bocommon.inc.php:1.4  Fri Nov 25 11:58:29 2005
+++ hrm/inc/class.bocommon.inc.php      Tue Nov 29 13:09:40 2005
@@ -1,659 +1,659 @@
-<?php
-       /**
-       * phpGroupWare - HRM: a  human resource competence management system.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package hrm
-       * @subpackage core
-       * @version $Id$
-       */
-
-       /**
-        * Description
-        * @package hrm
-        */
-
-       class bocommon
-       {
-               var $start;
-               var $query;
-               var $filter;
-               var $sort;
-               var $order;
-               var $cat_id;
-               var $district_id;
-
-
-               var $public_functions = array
-               (
-                       'select_part_of_town'   => True,
-                       'menu'  => True,
-               );
-
-               var $soap_functions = array(
-                       'list' => array(
-                               'in'  => 
array('int','int','struct','string','int'),
-                               'out' => array('array')
-                       ),
-                       'read' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array('array')
-                       ),
-                       'save' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array()
-                       ),
-                       'delete' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array()
-                       )
-               );
-
-               function bocommon()
-               {
-//                     $GLOBALS['phpgw_info']['flags']['currentapp']   =       
'hrm';
-                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->socommon                 = 
CreateObject($this->currentapp.'.socommon');
-                       $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
-
-                       if (!is_object($GLOBALS['phpgw']->asyncservice))
-                       {
-                               $GLOBALS['phpgw']->asyncservice = 
CreateObject('phpgwapi.asyncservice');
-                       }
-                       $this->async = &$GLOBALS['phpgw']->asyncservice;
-
-                       $this->join                     = $this->socommon->join;
-                       $this->left_join        = $this->socommon->left_join;
-                       $this->like                     = $this->socommon->like;
-
-                       switch($GLOBALS['phpgw_info']['server']['db_type'])
-                       {
-                               case 'mssql':
-                                       $this->dateformat               = "M d 
Y";
-                                       $this->datetimeformat   = "M d Y g:iA";
-                                       break;
-                               case 'mysql':
-                                       $this->dateformat               = 
"Y-m-d";
-                                       $this->datetimeformat   = "Y-m-d G:i:s";
-                                       break;
-                               case 'pgsql':
-                                       $this->dateformat               = 
"Y-m-d";
-                                       $this->datetimeformat   = "Y-m-d G:i:s";
-//                                     $this->dateformat               = "F j, 
Y";
-//                                     $this->datetimeformat   = "F j, Y g:iA";
-                                       break;
-                       }
-
-       /*              if 
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
-                       {
-                               $this->dateformat               = "M d Y";
-                               $this->datetimeformat   = "M d Y g:iA";
-                       }
-                       else
-                       {
-                               $this->dateformat               = "Y-m-d";
-                               $this->datetimeformat   = "Y-m-d G:i:s";
-                       }
-
-
-                       if(!$GLOBALS['phpgw_info']['flags']['css'])
-                       {
-                               $GLOBALS['phpgw_info']['flags']['css'] .= 
"-->\n</style>\n"
-                                       . '<link rel="stylesheet" 
type="text/css" media="all" href="'
-                                       . 
$GLOBALS['phpgw_info']['server']['webserver_url'].'/' . $this->currentapp . 
'/templates/'
-                                       . 
$GLOBALS['phpgw_info']['server']['template_set']
-                                       . 
'/css/'.$GLOBALS['phpgw_info']['server']['template_set'].'.css" 
title="'.$GLOBALS['phpgw_info']['server']['template_set'].'" />'
-                                       . "\n<style type=\"text/css\">\n<!--\n";
-                       }
-*/
-               }
-
-
-               function check_perms($rights, $required)
-               {
-       //              return (!!($rights & $required) == True);
-                       return ($rights & $required);
-               }
-
-               function create_preferences($app='',$user_id='')
-               {
-                       return 
$this->socommon->create_preferences($app,$user_id);
-               }
-
-               function msgbox_data($receipt)
-               {
-                       $msgbox_data_error=array();
-                       if (isSet($receipt['error']) AND 
is_array($receipt['error']))
-                       {
-                               foreach($receipt['error'] as $errors)
-                               {
-                                       $msgbox_data_error += 
array($errors['msg']=> False);
-                               }
-                       }
-
-                       $msgbox_data_message=array();
-
-                       if (isSet($receipt['message']) AND 
is_array($receipt['message']))
-                       {
-                               foreach($receipt['message'] as $messages)
-                               {
-                                       $msgbox_data_message += 
array($messages['msg']=> True);
-                               }
-                       }
-
-                       $msgbox_data = $msgbox_data_error + 
$msgbox_data_message;
-
-                       return $msgbox_data;
-               }
-
-               function moneyformat($amount)
-               {
-                       if 
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
-                       {
-                               $moneyformat    = 
"CONVERT(MONEY,"."'$amount'".",0)";
-                       }
-                       else
-                       {
-                               $moneyformat    = "'" . $amount . "'";
-                       }
-
-                       return $moneyformat;
-               }
-
-
-               function date_array($date)
-               {
-                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                       $dateformat = str_replace(".","",$dateformat);
-                       $dateformat = str_replace("-","",$dateformat);
-                       $dateformat = str_replace("/","",$dateformat);
-                       $y=strpos($dateformat,'y');
-                       $d=strpos($dateformat,'d');
-                       $m=strpos($dateformat,'m');
-
-                       $dateparts = explode('/', $date);
-                       $date_array['day']              = $dateparts[$d];
-                       $date_array['month']    = $dateparts[$m];
-                       $date_array['year']             = $dateparts[$y];
-
-                       return $date_array;
-               }
-
-               function date_to_timestamp($date)
-               {
-                       if($date)
-                       {
-                               $date_array     = $this->date_array($date);
-                               $date   = mktime 
(8,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
-                       }
-                       return $date;
-               }
-
-
-               function select_multi_list($selected='',$input_list)
-               {
-                       $j=0;
-                       if (isset($input_list) AND is_array($input_list))
-                       {
-                               foreach($input_list as $entry)
-                               {
-                                       $output_list[$j]['id'] = $entry['id'];
-                                       $output_list[$j]['name'] = 
$entry['name'];
-
-                                       for ($i=0;$i<count($selected);$i++)
-                                       {
-                                               if($selected[$i] == 
$entry['id'])
-                                               {
-                                                       
$output_list[$j]['selected'] = 'selected';
-                                               }
-                                       }
-                                       $j++;
-                               }
-                       }
-
-                       for ($i=0;$i<count($output_list);$i++)
-                       {
-                               if ($output_list[$i]['selected'] != 'selected')
-                               {
-                                       unset($output_list[$i]['selected']);
-                               }
-                       }
-
-                       return $output_list;
-               }
-
-
-               function select_list($selected='',$input_list='')
-               {
-                       if (isset($input_list) AND is_array($input_list))
-                       {
-                               foreach($input_list as $entry)
-                               {
-                                       $sel_entry = '';
-                                       if ($entry['id']==$selected)
-                                       {
-                                               $sel_entry = 'selected';
-                                       }
-                                       $entry_list[] = array
-                                       (
-                                               'id'            => $entry['id'],
-                                               'name'          => 
$entry['name'],
-                                               'selected'      => $sel_entry
-                                       );
-                               }
-                               for ($i=0;$i<count($entry_list);$i++)
-                               {
-                                       if ($entry_list[$i]['selected'] != 
'selected')
-                                       {
-                                               
unset($entry_list[$i]['selected']);
-                                       }
-                               }
-                       }
-                       return $entry_list;
-               }
-
-
-               function 
get_user_list($format='',$selected='',$extra='',$default='',$start='', 
$sort='', $order='', $query='',$offset='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
-                                       break;
-                       }
-
-                       if(!$selected && $default)
-                       {
-                               $selected = $default;
-                       }
-
-                       if (is_array($extra))
-                       {
-                               foreach($extra as $extra_user)
-                               {
-                                       $users_extra[]=array
-                                       (
-                                               'account_id' => $extra_user,
-                                               'account_firstname' => 
lang($extra_user)
-                                       );
-                               }
-                       }
-
-                       $accounts       = CreateObject('phpgwapi.accounts');
-                       $users = $accounts->get_list('accounts', $start, $sort, 
$order, $query,$offset);
-                       unset($accounts);
-                       if (is_array($users_extra) && is_array($users))
-                       {
-                               $users = $users_extra + $users;
-                       }
-
-                       if (isSet($users) AND is_array($users))
-                       {
-                               foreach($users as $user)
-                               {
-                                       $sel_user = '';
-                                       if ($user['account_id']==$selected)
-                                       {
-                                               $sel_user = 'selected';
-                                       }
-
-                                       $user_list[] = array
-                                       (
-                                               'user_id'       => 
$user['account_id'],
-                                               'name'          => 
$user['account_lastname'].' '.$user['account_firstname'],
-                                               'selected'      => $sel_user
-                                       );
-                               }
-                       }
-
-                       $user_count= count($user_list);
-                       for ($i=0;$i<$user_count;$i++)
-                       {
-                               if ($user_list[$i]['selected'] != 'selected')
-                               {
-                                       unset($user_list[$i]['selected']);
-                               }
-                       }
-
-//_debug_array($user_list);
-                       return $user_list;
-               }
-
-               function get_group_list($format='',$selected='',$start='', 
$sort='', $order='', $query='',$offset='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('group_select'));
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('group_filter'));
-                                       break;
-                       }
-
-                       $accounts       = CreateObject('phpgwapi.accounts');
-                       $users = $accounts->get_list('groups', $start, $sort, 
$order, $query,$offset);
-                       unset($accounts);
-                       if (isSet($users) AND is_array($users))
-                       {
-                               foreach($users as $user)
-                               {
-                                       $sel_user = '';
-                                       if ($user['account_id']==$selected)
-                                       {
-                                               $sel_user = 'selected';
-                                       }
-
-                                       $user_list[] = array
-                                       (
-                                               'id'    => $user['account_id'],
-                                               'name'          => 
$user['account_firstname'],
-                                               'selected'      => $sel_user
-                                       );
-                               }
-                       }
-
-                       $user_count= count($user_list);
-                       for ($i=0;$i<$user_count;$i++)
-                       {
-                               if ($user_list[$i]['selected'] != 'selected')
-                               {
-                                       unset($user_list[$i]['selected']);
-                               }
-                       }
-
-//_debug_array($user_list);
-                       return $user_list;
-               }
-
-
-               function initiate_ui_alarm($data)
-               {
-                       $boalarm                = 
CreateObject($this->currentapp.'.boalarm');
-
-                       if($data['type']=='view')
-                       {
-                               
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_view'));
-                       }
-                       else
-                       {
-                               
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_form'));
-                       }
-
-                       $alarm['header'][] = array
-                       (
-                               'lang_time'             => lang('Time'),
-                               'lang_text'     => lang('Text'),
-                               'lang_user'                     => lang('User'),
-                               'lang_enabled'          => lang('Enabled'),
-                               'lang_select'           => lang('Select')
-                               );
-
-                       $alarm['values'] = 
$boalarm->read_alarms($data['alarm_type'],$data['id'],$data['text']);
-                       if(!count($alarm['values'])>0)
-                       {
-                               unset($alarm['values']);
-                       }
-
-                       if($data['type']=='form')
-                       {
-                               $alarm['alter_alarm'][] = array
-                               (
-                                       'lang_enable'           => 
lang('Enable'),
-                                       'lang_disable'          => 
lang('Disable'),
-                                       'lang_delete'           => 
lang('Delete')
-                                       );
-
-                               for ($i=1; $i<=31; $i++)
-                               {
-                                       
$alarm['add_alarm']['day_list'][($i-1)][id] = $i;
-                               }
-                               $alarm['add_alarm']['lang_day']                 
                = lang('Day');
-                               $alarm['add_alarm']['lang_day_statustext']      
        = lang('Day');
-
-                               for ($i=1; $i<=24; $i++)
-                               {
-                                       
$alarm['add_alarm']['hour_list'][($i-1)][id] = $i;
-                               }
-                               $alarm['add_alarm']['lang_hour']                
                        = lang('Hour');
-                               $alarm['add_alarm']['lang_hour_statustext']     
                = lang('Hour');
-
-                               for ($i=1; $i<=60; $i++)
-                               {
-                                       
$alarm['add_alarm']['minute_list'][($i-1)][id] = $i;
-                               }
-                               $alarm['add_alarm']['lang_minute']              
                        = lang('Minutes before the event');
-                               $alarm['add_alarm']['lang_minute_statustext']   
        = lang('Minutes before the event');
-
-                               $alarm['add_alarm']['user_list'] = 
$this->get_user_list_right2('select',4,False,$data['acl_location'],False,$default=$this->account);
-
-                               $alarm['add_alarm']['lang_user']                
                        = lang('User');
-                               $alarm['add_alarm']['lang_user_statustext']     
                = lang('Select the user the alarm belongs to.');
-                               $alarm['add_alarm']['lang_no_user']             
                        = lang('No user');
-                               $alarm['add_alarm']['lang_add']                 
                        = lang('Add');
-                               $alarm['add_alarm']['lang_add_alarm']           
                                = lang('Add alarm');
-                               $alarm['add_alarm']['lang_add_statustext']      
                = lang('Add alarm for selected user');
-
-                       }
-
-//_debug_array($alarm['values']);
-                       return $alarm;
-               }
-
-
-               function 
select_multi_list_2($selected='',$input_list,$input_type='')
-               {
-                       $j=0;
-                       if (isset($input_list) AND is_array($input_list))
-                       {
-                               foreach($input_list as $entry)
-                               {
-                                       $output_list[$j]['id'] = $entry['id'];
-                                       $output_list[$j]['value'] = 
$entry['value'];
-                                       $output_list[$j]['input_type'] = 
$input_type;
-
-                                       for ($i=0;$i<count($selected);$i++)
-                                       {
-                                               if($selected[$i] == 
$entry['id'])
-                                               {
-                                                       
$output_list[$j]['checked'] = 'checked';
-                                               }
-                                       }
-                                       $j++;
-                               }
-                       }
-
-                       for ($i=0;$i<count($output_list);$i++)
-                       {
-                               if ($output_list[$i]['checked'] != 'checked')
-                               {
-                                       unset($output_list[$i]['checked']);
-                               }
-                       }
-
-                       return $output_list;
-               }
-
-
-               function list_methods($_type='xmlrpc')
-               {
-                       /*
-                         This handles introspection or discovery by the logged 
in client,
-                         in which case the input might be an array.  The 
server always calls
-                         this function to fill the server dispatch map using a 
string.
-                       */
-                       if (is_array($_type))
-                       {
-                               $_type = $_type['type'] ? $_type['type'] : 
$_type[0];
-                       }
-                       switch($_type)
-                       {
-                               case 'xmlrpc':
-                                       $xml_functions = array(
-                                               'read' => array(
-                                                       'function'  => 'read',
-                                                       'signature' => 
array(array(xmlrpcInt,xmlrpcStruct)),
-                                                       'docstring' => 
lang('Read a single entry by passing the id and fieldlist.')
-                                               ),
-                                               'save' => array(
-                                                       'function'  => 'save',
-                                                       'signature' => 
array(array(xmlrpcStruct,xmlrpcStruct)),
-                                                       'docstring' => 
lang('Update a single entry by passing the fields.')
-                                               ),
-                                               'delete' => array(
-                                                       'function'  => 'delete',
-                                                       'signature' => 
array(array(xmlrpcBoolean,xmlrpcInt)),
-                                                       'docstring' => 
lang('Delete a single entry by passing the id.')
-                                               ),
-                                               'list' => array(
-                                                       'function'  => '_list',
-                                                       'signature' => 
array(array(xmlrpcStruct,xmlrpcStruct)),
-                                                       'docstring' => 
lang('Read a list of entries.')
-                                               ),
-                                               'list_methods' => array(
-                                                       'function'  => 
'list_methods',
-                                                       'signature' => 
array(array(xmlrpcStruct,xmlrpcString)),
-                                                       'docstring' => 
lang('Read this list of methods.')
-                                               )
-                                       );
-                                       return $xml_functions;
-                                       break;
-                               case 'soap':
-                                       return $this->soap_functions;
-                                       break;
-                               default:
-                                       return array();
-                                       break;
-                       }
-               }
-
-               function add_leading_zero($num)
-               {
-
-                       if ($id_type == "hex")
-                       {
-                               $num = hexdec($num);
-                               $num++;
-                               $num = dechex($num);
-                       }
-                       else
-                       {
-                               $num++;
-                       }
-
-                       if (strlen($num) == 4)
-                               $return = $num;
-                       if (strlen($num) == 3)
-                               $return = "0$num";
-                       if (strlen($num) == 2)
-                               $return = "00$num";
-                       if (strlen($num) == 1)
-                               $return = "000$num";
-                       if (strlen($num) == 0)
-                               $return = "0001";
-
-                       return strtoupper($return);
-               }
-
-
-               function validate_db_insert($values)
-               {
-                       foreach($values as $value)
-                       {
-                               if($value || $value === 0)
-                               {
-                                       $insert_value[] = "'".$value."'";
-                               }
-                               else
-                               {
-                                       $insert_value[] = 'NULL';
-                               }
-                       }
-
-                       $values = implode(",", $insert_value);
-                       return $values;
-               }
-
-               function validate_db_update($value_set)
-               {
-                       while (is_array($value_set) && list($field,$value) = 
each($value_set))
-                       {
-                               if($value || $value === 0)
-                               {
-                                       $value_entry[]= "$field='$value'";
-                               }
-                               else
-                               {
-                                       $value_entry[]= "$field=NULL";
-                               }
-                       }
-
-                       $value_set      = implode(",", $value_entry);
-                       return $value_set;
-               }
-
-               function fm_cache($name='',$value='')
-               {
-                       return $this->socommon->fm_cache($name,$value);
-               }
-
-               function next_id($table,$key='')
-               {
-                       return $this->socommon->next_id($table,$key);
-               }
-
-
-               function excel($list,$name,$descr,$input_type='')
-               {
-                       $GLOBALS['phpgw_info']['flags'][noheader] = True;
-                       $GLOBALS['phpgw_info']['flags'][nofooter] = True;
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
-                       $filename= 
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
-
-                       $workbook       = 
CreateObject($this->currentapp.'.excel',"-");
-                       $browser = CreateObject('phpgwapi.browser');
-                       
$browser->content_header($filename,'application/vnd.ms-excel');
-
-                       $count_uicols_name=count($name);
-
-                       $worksheet1 =& $workbook->add_worksheet('First One');
-
-                       $j=0;
-                       if (isset($list) AND is_array($list))
-                       {
-                               foreach($list as $entry)
-                               {
-                                       $m=0;
-                                       for ($k=0;$k<$count_uicols_name;$k++)
-                                       {
-                                               if($input_type[$k]!='hidden')
-                                               {
-                                                       $content[$j][$m]        
= str_replace("\r\n"," ",$entry[$name[$k]]);
-                                                       
$worksheet1->write_string(0, $m, $descr[$k]);
-                                                       $m++;
-                                               }
-                                       }
-                                       $j++;
-                               }
-
-                               foreach($content as $row)
-                               {
-                                       $line++;
-                                       for ($i=0; $i<count($row); $i++)
-                                       {
-                                               
$worksheet1->write($line,$i,$row[$i]);
-                                       }
-                               }
-                       }
-                       $workbook->close();
-
-               }
-
-       }
\ No newline at end of file
+<?php
+       /**
+       * phpGroupWare - HRM: a  human resource competence management system.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package hrm
+       * @subpackage core
+       * @version $Id$
+       */
+
+       /**
+        * Description
+        * @package hrm
+        */
+
+       class bocommon
+       {
+               var $start;
+               var $query;
+               var $filter;
+               var $sort;
+               var $order;
+               var $cat_id;
+               var $district_id;
+
+
+               var $public_functions = array
+               (
+                       'select_part_of_town'   => True,
+                       'menu'  => True,
+               );
+
+               var $soap_functions = array(
+                       'list' => array(
+                               'in'  => 
array('int','int','struct','string','int'),
+                               'out' => array('array')
+                       ),
+                       'read' => array(
+                               'in'  => array('int','struct'),
+                               'out' => array('array')
+                       ),
+                       'save' => array(
+                               'in'  => array('int','struct'),
+                               'out' => array()
+                       ),
+                       'delete' => array(
+                               'in'  => array('int','struct'),
+                               'out' => array()
+                       )
+               );
+
+               function bocommon()
+               {
+//                     $GLOBALS['phpgw_info']['flags']['currentapp']   =       
'hrm';
+                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->socommon                 = 
CreateObject($this->currentapp.'.socommon');
+                       $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
+
+                       if (!is_object($GLOBALS['phpgw']->asyncservice))
+                       {
+                               $GLOBALS['phpgw']->asyncservice = 
CreateObject('phpgwapi.asyncservice');
+                       }
+                       $this->async = &$GLOBALS['phpgw']->asyncservice;
+
+                       $this->join                     = $this->socommon->join;
+                       $this->left_join        = $this->socommon->left_join;
+                       $this->like                     = $this->socommon->like;
+
+                       switch($GLOBALS['phpgw_info']['server']['db_type'])
+                       {
+                               case 'mssql':
+                                       $this->dateformat               = "M d 
Y";
+                                       $this->datetimeformat   = "M d Y g:iA";
+                                       break;
+                               case 'mysql':
+                                       $this->dateformat               = 
"Y-m-d";
+                                       $this->datetimeformat   = "Y-m-d G:i:s";
+                                       break;
+                               case 'pgsql':
+                                       $this->dateformat               = 
"Y-m-d";
+                                       $this->datetimeformat   = "Y-m-d G:i:s";
+//                                     $this->dateformat               = "F j, 
Y";
+//                                     $this->datetimeformat   = "F j, Y g:iA";
+                                       break;
+                       }
+
+       /*              if 
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
+                       {
+                               $this->dateformat               = "M d Y";
+                               $this->datetimeformat   = "M d Y g:iA";
+                       }
+                       else
+                       {
+                               $this->dateformat               = "Y-m-d";
+                               $this->datetimeformat   = "Y-m-d G:i:s";
+                       }
+
+
+                       if(!$GLOBALS['phpgw_info']['flags']['css'])
+                       {
+                               $GLOBALS['phpgw_info']['flags']['css'] .= 
"-->\n</style>\n"
+                                       . '<link rel="stylesheet" 
type="text/css" media="all" href="'
+                                       . 
$GLOBALS['phpgw_info']['server']['webserver_url'].'/' . $this->currentapp . 
'/templates/'
+                                       . 
$GLOBALS['phpgw_info']['server']['template_set']
+                                       . 
'/css/'.$GLOBALS['phpgw_info']['server']['template_set'].'.css" 
title="'.$GLOBALS['phpgw_info']['server']['template_set'].'" />'
+                                       . "\n<style type=\"text/css\">\n<!--\n";
+                       }
+*/
+               }
+
+
+               function check_perms($rights, $required)
+               {
+       //              return (!!($rights & $required) == True);
+                       return ($rights & $required);
+               }
+
+               function create_preferences($app='',$user_id='')
+               {
+                       return 
$this->socommon->create_preferences($app,$user_id);
+               }
+
+               function msgbox_data($receipt)
+               {
+                       $msgbox_data_error=array();
+                       if (isSet($receipt['error']) AND 
is_array($receipt['error']))
+                       {
+                               foreach($receipt['error'] as $errors)
+                               {
+                                       $msgbox_data_error += 
array($errors['msg']=> False);
+                               }
+                       }
+
+                       $msgbox_data_message=array();
+
+                       if (isSet($receipt['message']) AND 
is_array($receipt['message']))
+                       {
+                               foreach($receipt['message'] as $messages)
+                               {
+                                       $msgbox_data_message += 
array($messages['msg']=> True);
+                               }
+                       }
+
+                       $msgbox_data = $msgbox_data_error + 
$msgbox_data_message;
+
+                       return $msgbox_data;
+               }
+
+               function moneyformat($amount)
+               {
+                       if 
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
+                       {
+                               $moneyformat    = 
"CONVERT(MONEY,"."'$amount'".",0)";
+                       }
+                       else
+                       {
+                               $moneyformat    = "'" . $amount . "'";
+                       }
+
+                       return $moneyformat;
+               }
+
+
+               function date_array($date)
+               {
+                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                       $dateformat = str_replace(".","",$dateformat);
+                       $dateformat = str_replace("-","",$dateformat);
+                       $dateformat = str_replace("/","",$dateformat);
+                       $y=strpos($dateformat,'y');
+                       $d=strpos($dateformat,'d');
+                       $m=strpos($dateformat,'m');
+
+                       $dateparts = explode('/', $date);
+                       $date_array['day']              = $dateparts[$d];
+                       $date_array['month']    = $dateparts[$m];
+                       $date_array['year']             = $dateparts[$y];
+
+                       return $date_array;
+               }
+
+               function date_to_timestamp($date)
+               {
+                       if($date)
+                       {
+                               $date_array     = $this->date_array($date);
+                               $date   = mktime 
(8,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+                       }
+                       return $date;
+               }
+
+
+               function select_multi_list($selected='',$input_list)
+               {
+                       $j=0;
+                       if (isset($input_list) AND is_array($input_list))
+                       {
+                               foreach($input_list as $entry)
+                               {
+                                       $output_list[$j]['id'] = $entry['id'];
+                                       $output_list[$j]['name'] = 
$entry['name'];
+
+                                       for ($i=0;$i<count($selected);$i++)
+                                       {
+                                               if($selected[$i] == 
$entry['id'])
+                                               {
+                                                       
$output_list[$j]['selected'] = 'selected';
+                                               }
+                                       }
+                                       $j++;
+                               }
+                       }
+
+                       for ($i=0;$i<count($output_list);$i++)
+                       {
+                               if ($output_list[$i]['selected'] != 'selected')
+                               {
+                                       unset($output_list[$i]['selected']);
+                               }
+                       }
+
+                       return $output_list;
+               }
+
+
+               function select_list($selected='',$input_list='')
+               {
+                       if (isset($input_list) AND is_array($input_list))
+                       {
+                               foreach($input_list as $entry)
+                               {
+                                       $sel_entry = '';
+                                       if ($entry['id']==$selected)
+                                       {
+                                               $sel_entry = 'selected';
+                                       }
+                                       $entry_list[] = array
+                                       (
+                                               'id'            => $entry['id'],
+                                               'name'          => 
$entry['name'],
+                                               'selected'      => $sel_entry
+                                       );
+                               }
+                               for ($i=0;$i<count($entry_list);$i++)
+                               {
+                                       if ($entry_list[$i]['selected'] != 
'selected')
+                                       {
+                                               
unset($entry_list[$i]['selected']);
+                                       }
+                               }
+                       }
+                       return $entry_list;
+               }
+
+
+               function 
get_user_list($format='',$selected='',$extra='',$default='',$start='', 
$sort='', $order='', $query='',$offset='')
+               {
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
+                                       break;
+                               case 'filter':
+                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
+                                       break;
+                       }
+
+                       if(!$selected && $default)
+                       {
+                               $selected = $default;
+                       }
+
+                       if (is_array($extra))
+                       {
+                               foreach($extra as $extra_user)
+                               {
+                                       $users_extra[]=array
+                                       (
+                                               'account_id' => $extra_user,
+                                               'account_firstname' => 
lang($extra_user)
+                                       );
+                               }
+                       }
+
+                       $accounts       = CreateObject('phpgwapi.accounts');
+                       $users = $accounts->get_list('accounts', $start, $sort, 
$order, $query,$offset);
+                       unset($accounts);
+                       if (is_array($users_extra) && is_array($users))
+                       {
+                               $users = $users_extra + $users;
+                       }
+
+                       if (isSet($users) AND is_array($users))
+                       {
+                               foreach($users as $user)
+                               {
+                                       $sel_user = '';
+                                       if ($user['account_id']==$selected)
+                                       {
+                                               $sel_user = 'selected';
+                                       }
+
+                                       $user_list[] = array
+                                       (
+                                               'user_id'       => 
$user['account_id'],
+                                               'name'          => 
$user['account_lastname'].' '.$user['account_firstname'],
+                                               'selected'      => $sel_user
+                                       );
+                               }
+                       }
+
+                       $user_count= count($user_list);
+                       for ($i=0;$i<$user_count;$i++)
+                       {
+                               if ($user_list[$i]['selected'] != 'selected')
+                               {
+                                       unset($user_list[$i]['selected']);
+                               }
+                       }
+
+//_debug_array($user_list);
+                       return $user_list;
+               }
+
+               function get_group_list($format='',$selected='',$start='', 
$sort='', $order='', $query='',$offset='')
+               {
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('group_select'));
+                                       break;
+                               case 'filter':
+                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('group_filter'));
+                                       break;
+                       }
+
+                       $accounts       = CreateObject('phpgwapi.accounts');
+                       $users = $accounts->get_list('groups', $start, $sort, 
$order, $query,$offset);
+                       unset($accounts);
+                       if (isSet($users) AND is_array($users))
+                       {
+                               foreach($users as $user)
+                               {
+                                       $sel_user = '';
+                                       if ($user['account_id']==$selected)
+                                       {
+                                               $sel_user = 'selected';
+                                       }
+
+                                       $user_list[] = array
+                                       (
+                                               'id'    => $user['account_id'],
+                                               'name'          => 
$user['account_firstname'],
+                                               'selected'      => $sel_user
+                                       );
+                               }
+                       }
+
+                       $user_count= count($user_list);
+                       for ($i=0;$i<$user_count;$i++)
+                       {
+                               if ($user_list[$i]['selected'] != 'selected')
+                               {
+                                       unset($user_list[$i]['selected']);
+                               }
+                       }
+
+//_debug_array($user_list);
+                       return $user_list;
+               }
+
+
+               function initiate_ui_alarm($data)
+               {
+                       $boalarm                = 
CreateObject($this->currentapp.'.boalarm');
+
+                       if($data['type']=='view')
+                       {
+                               
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_view'));
+                       }
+                       else
+                       {
+                               
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_form'));
+                       }
+
+                       $alarm['header'][] = array
+                       (
+                               'lang_time'             => lang('Time'),
+                               'lang_text'     => lang('Text'),
+                               'lang_user'                     => lang('User'),
+                               'lang_enabled'          => lang('Enabled'),
+                               'lang_select'           => lang('Select')
+                               );
+
+                       $alarm['values'] = 
$boalarm->read_alarms($data['alarm_type'],$data['id'],$data['text']);
+                       if(!count($alarm['values'])>0)
+                       {
+                               unset($alarm['values']);
+                       }
+
+                       if($data['type']=='form')
+                       {
+                               $alarm['alter_alarm'][] = array
+                               (
+                                       'lang_enable'           => 
lang('Enable'),
+                                       'lang_disable'          => 
lang('Disable'),
+                                       'lang_delete'           => 
lang('Delete')
+                                       );
+
+                               for ($i=1; $i<=31; $i++)
+                               {
+                                       
$alarm['add_alarm']['day_list'][($i-1)][id] = $i;
+                               }
+                               $alarm['add_alarm']['lang_day']                 
                = lang('Day');
+                               $alarm['add_alarm']['lang_day_statustext']      
        = lang('Day');
+
+                               for ($i=1; $i<=24; $i++)
+                               {
+                                       
$alarm['add_alarm']['hour_list'][($i-1)][id] = $i;
+                               }
+                               $alarm['add_alarm']['lang_hour']                
                        = lang('Hour');
+                               $alarm['add_alarm']['lang_hour_statustext']     
                = lang('Hour');
+
+                               for ($i=1; $i<=60; $i++)
+                               {
+                                       
$alarm['add_alarm']['minute_list'][($i-1)][id] = $i;
+                               }
+                               $alarm['add_alarm']['lang_minute']              
                        = lang('Minutes before the event');
+                               $alarm['add_alarm']['lang_minute_statustext']   
        = lang('Minutes before the event');
+
+                               $alarm['add_alarm']['user_list'] = 
$this->get_user_list_right2('select',4,False,$data['acl_location'],False,$default=$this->account);
+
+                               $alarm['add_alarm']['lang_user']                
                        = lang('User');
+                               $alarm['add_alarm']['lang_user_statustext']     
                = lang('Select the user the alarm belongs to.');
+                               $alarm['add_alarm']['lang_no_user']             
                        = lang('No user');
+                               $alarm['add_alarm']['lang_add']                 
                        = lang('Add');
+                               $alarm['add_alarm']['lang_add_alarm']           
                                = lang('Add alarm');
+                               $alarm['add_alarm']['lang_add_statustext']      
                = lang('Add alarm for selected user');
+
+                       }
+
+//_debug_array($alarm['values']);
+                       return $alarm;
+               }
+
+
+               function 
select_multi_list_2($selected='',$input_list,$input_type='')
+               {
+                       $j=0;
+                       if (isset($input_list) AND is_array($input_list))
+                       {
+                               foreach($input_list as $entry)
+                               {
+                                       $output_list[$j]['id'] = $entry['id'];
+                                       $output_list[$j]['value'] = 
$entry['value'];
+                                       $output_list[$j]['input_type'] = 
$input_type;
+
+                                       for ($i=0;$i<count($selected);$i++)
+                                       {
+                                               if($selected[$i] == 
$entry['id'])
+                                               {
+                                                       
$output_list[$j]['checked'] = 'checked';
+                                               }
+                                       }
+                                       $j++;
+                               }
+                       }
+
+                       for ($i=0;$i<count($output_list);$i++)
+                       {
+                               if ($output_list[$i]['checked'] != 'checked')
+                               {
+                                       unset($output_list[$i]['checked']);
+                               }
+                       }
+
+                       return $output_list;
+               }
+
+
+               function list_methods($_type='xmlrpc')
+               {
+                       /*
+                         This handles introspection or discovery by the logged 
in client,
+                         in which case the input might be an array.  The 
server always calls
+                         this function to fill the server dispatch map using a 
string.
+                       */
+                       if (is_array($_type))
+                       {
+                               $_type = $_type['type'] ? $_type['type'] : 
$_type[0];
+                       }
+                       switch($_type)
+                       {
+                               case 'xmlrpc':
+                                       $xml_functions = array(
+                                               'read' => array(
+                                                       'function'  => 'read',
+                                                       'signature' => 
array(array(xmlrpcInt,xmlrpcStruct)),
+                                                       'docstring' => 
lang('Read a single entry by passing the id and fieldlist.')
+                                               ),
+                                               'save' => array(
+                                                       'function'  => 'save',
+                                                       'signature' => 
array(array(xmlrpcStruct,xmlrpcStruct)),
+                                                       'docstring' => 
lang('Update a single entry by passing the fields.')
+                                               ),
+                                               'delete' => array(
+                                                       'function'  => 'delete',
+                                                       'signature' => 
array(array(xmlrpcBoolean,xmlrpcInt)),
+                                                       'docstring' => 
lang('Delete a single entry by passing the id.')
+                                               ),
+                                               'list' => array(
+                                                       'function'  => '_list',
+                                                       'signature' => 
array(array(xmlrpcStruct,xmlrpcStruct)),
+                                                       'docstring' => 
lang('Read a list of entries.')
+                                               ),
+                                               'list_methods' => array(
+                                                       'function'  => 
'list_methods',
+                                                       'signature' => 
array(array(xmlrpcStruct,xmlrpcString)),
+                                                       'docstring' => 
lang('Read this list of methods.')
+                                               )
+                                       );
+                                       return $xml_functions;
+                                       break;
+                               case 'soap':
+                                       return $this->soap_functions;
+                                       break;
+                               default:
+                                       return array();
+                                       break;
+                       }
+               }
+
+               function add_leading_zero($num)
+               {
+
+                       if ($id_type == "hex")
+                       {
+                               $num = hexdec($num);
+                               $num++;
+                               $num = dechex($num);
+                       }
+                       else
+                       {
+                               $num++;
+                       }
+
+                       if (strlen($num) == 4)
+                               $return = $num;
+                       if (strlen($num) == 3)
+                               $return = "0$num";
+                       if (strlen($num) == 2)
+                               $return = "00$num";
+                       if (strlen($num) == 1)
+                               $return = "000$num";
+                       if (strlen($num) == 0)
+                               $return = "0001";
+
+                       return strtoupper($return);
+               }
+
+
+               function validate_db_insert($values)
+               {
+                       foreach($values as $value)
+                       {
+                               if($value || $value === 0)
+                               {
+                                       $insert_value[] = "'".$value."'";
+                               }
+                               else
+                               {
+                                       $insert_value[] = 'NULL';
+                               }
+                       }
+
+                       $values = implode(",", $insert_value);
+                       return $values;
+               }
+
+               function validate_db_update($value_set)
+               {
+                       while (is_array($value_set) && list($field,$value) = 
each($value_set))
+                       {
+                               if($value || $value === 0)
+                               {
+                                       $value_entry[]= "$field='$value'";
+                               }
+                               else
+                               {
+                                       $value_entry[]= "$field=NULL";
+                               }
+                       }
+
+                       $value_set      = implode(",", $value_entry);
+                       return $value_set;
+               }
+
+               function fm_cache($name='',$value='')
+               {
+                       return $this->socommon->fm_cache($name,$value);
+               }
+
+               function next_id($table,$key='')
+               {
+                       return $this->socommon->next_id($table,$key);
+               }
+
+
+               function excel($list,$name,$descr,$input_type='')
+               {
+                       $GLOBALS['phpgw_info']['flags'][noheader] = True;
+                       $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+                       $filename= 
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
+
+                       $workbook       = 
CreateObject($this->currentapp.'.excel',"-");
+                       $browser = CreateObject('phpgwapi.browser');
+                       
$browser->content_header($filename,'application/vnd.ms-excel');
+
+                       $count_uicols_name=count($name);
+
+                       $worksheet1 =& $workbook->add_worksheet('First One');
+
+                       $j=0;
+                       if (isset($list) AND is_array($list))
+                       {
+                               foreach($list as $entry)
+                               {
+                                       $m=0;
+                                       for ($k=0;$k<$count_uicols_name;$k++)
+                                       {
+                                               if($input_type[$k]!='hidden')
+                                               {
+                                                       $content[$j][$m]        
= str_replace("\r\n"," ",$entry[$name[$k]]);
+                                                       
$worksheet1->write_string(0, $m, $descr[$k]);
+                                                       $m++;
+                                               }
+                                       }
+                                       $j++;
+                               }
+
+                               foreach($content as $row)
+                               {
+                                       $line++;
+                                       for ($i=0; $i<count($row); $i++)
+                                       {
+                                               
$worksheet1->write($line,$i,$row[$i]);
+                                       }
+                               }
+                       }
+                       $workbook->close();
+
+               }
+
+       }

====================================================
Index: hrm/inc/class.acl2.inc.php
diff -u hrm/inc/class.acl2.inc.php:1.1 hrm/inc/class.acl2.inc.php:1.2
--- hrm/inc/class.acl2.inc.php:1.1      Fri Nov 25 12:35:20 2005
+++ hrm/inc/class.acl2.inc.php  Tue Nov 29 13:09:39 2005
@@ -656,7 +656,7 @@
                        {
                                $app = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        }
-                       $sql = "select acl_account, acl_rights from hrm_acl 
where acl_appname = '$app' and ";
+                       $sql = "select acl_account, acl_rights from phpgw_acl 
where acl_appname = '$app' and ";
                        $sql .= "acl_location = '".$location."'";
                        $this->db->query($sql ,__LINE__,__FILE__);
                        $rights = 0;
@@ -730,13 +730,36 @@
                        return $apps;
                }

+               function get_grants($app='',$location='')
+               {
+                       $grant_rights = 
$this->get_grants_type($app,$location,0);
+                       $grant_mask = $this->get_grants_type($app,$location,1);
+                       if(is_array($grant_mask))
+                       {
+                               while($grant_mask && (list($user_id,$mask) = 
each($grant_mask)))
+                               {
+                                       if($grant_rights[$user_id])
+                                       {
+                                               $grant_rights[$user_id] &= (~ 
$mask);
+                                               if($grant_rights[$user_id]<=0)
+                                               {
+                                                       unset 
($grant_rights[$user_id]);
+                                               }
+                                       }
+                               }
+                       }
+                       return $grant_rights;
+               }
+
                /**
                * Get application specific account based granted rights list
                *
                * @param string $app Application name, defaults to 
$phpgw_info['flags']['currentapp']
+               * @param string $location location within Application name
+               * @param integer $type mask or right (1 means mask , 0 means 
right) to check against
                * @return array Assoziativ array with granted access rights for 
accounts
                */
-               function get_grants($app='',$location='')
+               function get_grants_type($app='',$location='',$type = '')
                {
                        $db2 = $this->db;

@@ -749,7 +772,7 @@
                                $at_location = " AND acl_location = 
'$location'";
                        }

-                       $sql = "select acl_account,acl_grantor, acl_rights from 
hrm_acl where acl_appname = '$app' $at_location AND acl_grantor IS NOT NULL and 
"
+                       $sql = "SELECT acl_account,acl_grantor, acl_rights FROM 
hrm_acl WHERE acl_appname = '$app' $at_location AND acl_grantor IS NOT NULL AND 
acl_type = $type AND "
                                . "acl_account in ";
                        $security = "('". $this->account_id ."'";
                        $myaccounts = CreateObject('phpgwapi.accounts');
@@ -764,7 +787,7 @@
                        $db2->query($sql . $security ,__LINE__,__FILE__);
                        $rights = 0;
                        $accounts = Array();
-                       if ($db2->num_rows() == 0)
+                       if ($db2->num_rows() == 0 && $type==0)
                        {
                                
$grants[$GLOBALS['phpgw_info']['user']['account_id']] = 31;
                                return $grants;
@@ -777,7 +800,7 @@
                                // cache the group-members for performance
                                {
                                        // if $grantor is a group, get its 
members
-                                       $members = 
$this->get_ids_for_location($grantor,1,'phpgw_group');
+                                       $members = 
$this->get_ids_for_location($grantor,1,'phpgw_group');
                                        if(!$members)
                                        {
                                                $accounts[$grantor] = 
Array($grantor);
@@ -813,7 +836,15 @@
                                }
                                reset($accounts[$grantor]);
                        }
-                       $grants[$GLOBALS['phpgw_info']['user']['account_id']] = 
31;
+                       if($type==0)
+                       {
+                               
$grants[$GLOBALS['phpgw_info']['user']['account_id']] = 31;
+                       }
+                       else
+                       {
+                               unset 
($grants[$GLOBALS['phpgw_info']['user']['account_id']]);
+                       }
+
                        return $grants;
                }
        }






reply via email to

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