phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: property/inc class.boadmin.inc.php,NONE,1.1 clas


From: Sigurd Nes <address@hidden>
Subject: [Phpgroupware-cvs] CVS: property/inc class.boadmin.inc.php,NONE,1.1 class.bobuilding.inc.php,NONE,1.1 class.bocommon.inc.php,NONE,1.1 class.boproperty.inc.php,NONE,1.1 class.bostatus.inc.php,NONE,1.1 class.soadmin.inc.php,NONE,1.1 class.sobuilding.inc.php,NONE,1.1 class.socommon.inc.php,NONE,1.1 class.soproperty.inc.php,NONE,1.1 class.sostatus.inc.php,NONE,1.1 class.uiadmin.inc.php,NONE,1.1 class.uibuilding.inc.php,NONE,1.1 class.uiproperty.inc.php,NONE,1.1 class.uistatus.inc.php,NONE,1.1 hook_admin.inc.php,1.7,1.8 hook_manual.inc.php,1.2,1.3 hook_preferences.inc.php,1.2,1.3 hook_settings.inc.php,1.5,1.6
Date: Wed, 11 Dec 2002 14:31:24 -0500

Update of /cvsroot/phpgroupware/property/inc
In directory subversions:/tmp/cvs-serv10817/inc

Added Files:
        class.boadmin.inc.php class.bobuilding.inc.php 
        class.bocommon.inc.php class.boproperty.inc.php 
        class.bostatus.inc.php class.soadmin.inc.php 
        class.sobuilding.inc.php class.socommon.inc.php 
        class.soproperty.inc.php class.sostatus.inc.php 
        class.uiadmin.inc.php class.uibuilding.inc.php 
        class.uiproperty.inc.php class.uistatus.inc.php 
        hook_admin.inc.php hook_manual.inc.php 
        hook_preferences.inc.php hook_settings.inc.php 
Log Message:
no message

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class boadmin
        {
                var $start;
                var $query;
                var $filter;
                var $sort;
                var $order;
                var $cat_id;
                var $submodule_id;
                var $permission;

                var $public_functions = array
                (
                        'read'                          => True,
                        'read_single'           => True,
                        'save'                          => True,
                        'delete'                        => True,
                        'check_perms'           => 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 boadmin($session='')
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so               = 
CreateObject($this->currentapp.'.soadmin');
                        $this->socommon = 
CreateObject($this->currentapp.'.socommon');


                        if ($session)
                        {
                                $this->read_sessiondata();
                                $this->use_session = True;
                        }


                        $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'));
                        $submodule_id   = 
get_var('submodule_id',array('POST','GET'));
                        $permission     = 
get_var('permission',array('POST','GET'));

                        if ($start)
                        {
                                $this->start=$start;
                        }
                        else
                        {
                                $this->start=0;
                        }

                        if(isset($query))
                        {
                                $this->query = $query;
                        }
                        if(!empty($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($submodule_id))
                        {
                                $this->submodule_id = $submodule_id;
                        }
                        if(isset($permission))
                        {
                                $this->permission = $permission;
                        }

                }


                function read_sessiondata()
                {
                        $data = 
$GLOBALS['phpgw']->session->appsession('session_data','fm');

//      _debug_array($data);

                        $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->submodule_id     = $data['submodule_id'];
                        $this->permission       = $data['permission'];
                }

                function select_submodule($format='',$selected='')
                {

//                      $selected       = 
get_var('submodule_id',array('POST','GET'));

                        switch($format)
                        {
                                case 'select':
                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('select_submodule',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                                        break;
                                case 'filter':
                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_submodule',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                                        break;
                        }

                        $submodules= $this->so->select_submodule();

                        while (is_array($submodules) && list(,$sub) = 
each($submodules))
                        {
                                $sel_sub = '';
                                if ($sub['id']==$selected)
                                {
                                        $sel_sub = 'selected';
                                }

                                $submodule_list[] = array
                                (
                                        'id'            => $sub['id'],
                                        'descr'         => lang($sub['id']),
                                        'selected'      => $sel_sub
                                );
                        }

                        for ($i=0;$i<count($submodule_list);$i++)
                        {
                                if ($submodule_list[$i]['selected'] != 
'selected')
                                {
                                        unset($submodule_list[$i]['selected']);
                                }
                        }

                        return $submodule_list;
                }


                function select_permission($selected='',$sub_module='')
                {


                        
$GLOBALS['phpgw']->xslttpl->add_file(array('select_permission',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
//                      
$GLOBALS['phpgw']->xslttpl->add_file('select_permission');

                        $permission[0]['id']= 'can_read';
                        $permission[1]['id']= 'can_add';
                        $permission[2]['id']= 'can_edit';
                        $permission[3]['id']= 'can_delete';
                        $permission[4]['id']= 'admin';

                        if ($sub_module=='invoice')
                        {
                                $permission[5]['id']= 'janitor';
                                $permission[6]['id']= 'supervisor';
                                $permission[7]['id']= 'budget_responsible';
                                $permission[8]['id']= 'transfer';
                        }


                        while (is_array($permission) && list(,$perm) = 
each($permission))
                        {
                                $sel_perm = '';
                                if ($perm['id']==$selected)
                                {
                                        $sel_perm = 'selected';
                                }

                                $permission_list[] = array
                                (
                                        'id'            => $perm['id'],
                                        'descr'         => lang($perm['id']),
                                        'selected'      => $sel_perm
                                );
                        }

                        for ($i=0;$i<count($permission_list);$i++)
                        {
                                if ($permission_list[$i]['selected'] != 
'selected')
                                {
                                        unset($permission_list[$i]['selected']);
                                }
                        }

                        return $permission_list;
                }


                function read_permission()
                {
                        $admins = $this->so->read_permission(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                                                                
        'filter' => $this->filter,'cat_id' => $this->cat_id,'submodule_id' => 
$this->submodule_id));
                        $this->total_records = $this->so->total_records;

                        return $admins;
                }

                function 
select_users($format='',$submodule_id='',$permission='')
                {

                        switch($format)
                        {
                                case 'select':
                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('select_user',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                                        break;
                                case 'filter':
                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_user',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                                        break;
                                case 'select_multi':
                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('select_multi_user',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                                        break;
                        }

                        if (!$submodule_id || !$permission)
                        {
                                return false;
                        }


                        $is_admin = 
$this->so->is_admin($submodule_id,$permission);

//_debug_array($is_admin);

                        $order='account_lastname';

                        $allusers = 
$GLOBALS['phpgw']->accounts->get_list('accounts', $this->start, ASC, $order, 
$this->query);

                        $j=0;
                        while (list($null,$ad_account) = each($allusers))
                        {
                                $users_list[$j]['key_id'] = $j;
                                $users_list[$j]['account_id'] = 
$ad_account['account_id'];
                                $users_list[$j]['account_lid'] = 
$ad_account['account_lid'];
                                $users_list[$j]['account_firstname'] = 
$ad_account['account_firstname'];
                                $users_list[$j]['account_lastname'] = 
$ad_account['account_lastname'];

                                for ($i=0;$i<count($is_admin);$i++)
                                {
                                        if($is_admin[$i]['account_id'] == 
$ad_account['account_id'])
                                        {
                                                $users_list[$j]['checked'] = 
'checked';
                                        }
                                }

                                $j++;
                        }

//_debug_array($users_list);

                        return $users_list;
                }


                function 
select_groups($format='',$submodule_id='',$permission='')
                {

                        if (!$submodule_id || !$permission)
                        {
                                return false;
                        }
/*                      switch($format)
                        {
                                case 'select':
                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('select_group',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                                        break;
                                case 'filter':
                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_group',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                                        break;
                                case 'select_multi':
                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('select_multi_group',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                                        break;
                        }

*/                      $is_group = 
$this->so->is_group($submodule_id,$permission);

//_debug_array($is_group);

                        $order='account_lastname';

                        $allgroups = 
$GLOBALS['phpgw']->accounts->get_list('groups', $start, ASC, $order, $query);

                        $j=0;
                        while (list($null,$ad_group) = each($allgroups))
                        {
                                $groups_list[$j]['key_id'] = $j;
                                $groups_list[$j]['account_id'] = 
$ad_group['account_id'];
                                $groups_list[$j]['account_lid'] = 
$ad_group['account_lid'];
                                $groups_list[$j]['account_firstname'] = 
$ad_group['account_firstname'];
                                $groups_list[$j]['account_lastname'] = 
$ad_group['account_lastname'];

                                for ($i=0;$i<count($is_group);$i++)
                                {
                                        if($is_group[$i]['account_id'] == 
$ad_group['account_id'])
                                        {
                                                $groups_list[$j]['checked'] = 
'checked';
                                        }
                                }

                                $j++;
                        }

//_debug_array($groups_list);

                        return $groups_list;
                }

                function edit_perm($values='')
                {

                        $message = $this->so->edit_perm($values);
                        return $message;

                }

                function read_fm_id()
                {

                        $fm_ids = $this->so->read_fm_id();
                        return $fm_ids;

                }
                function edit_id($values='')
                {

                        $message = $this->so->edit_id($values);
                        return $message;

                }

        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class bobuilding
        {
                var $start;
                var $query;
                var $filter;
                var $sort;
                var $order;
                var $cat_id;

                var $public_functions = array
                (
                        'read'                          => True,
                        'read_single'           => True,
                        'save'                          => True,
                        'delete'                        => True,
                        'check_perms'           => 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 bobuilding($session=False)
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so               = 
CreateObject($this->currentapp.'.sobuilding');
                        $this->socommon = 
CreateObject($this->currentapp.'.socommon');

                        $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'));

                        if ($start)
                        {
                                $this->start=$start;
                        }
                        else
                        {
                                $this->start=0;
                        }

                        if(isset($query))
                        {
                                $this->query = $query;
                        }
                        if(!empty($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;
                        }
                }


                function read()
                {
                        $building = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                                                                
        'filter' => $this->filter,'cat_id' => $this->cat_id));
                        $this->total_records = $this->so->total_records;

                        for ($i=0; $i<count($building); $i++)
                        {
                                $building[$i]['date']  = 
$GLOBALS['phpgw']->common->show_date($building[$i]['date']);
                                $building[$i]['owner'] = 
$GLOBALS['phpgw']->accounts->id2name($building[$i]['owner']);
                        }
                        return $building;
                }

                function read_single($property_id,$building_id)
                {
                        return 
$this->so->read_single($property_id,$building_id);
                }

                function select_part_of_town($part_of_town_id)
                {
                        return 
$this->socommon->select_part_of_town($part_of_town_id);
                }

                function save($building,$action='')
                {
                        if ($building['access'])
                        {
                                $building['access'] = 'private';
                        }
                        else
                        {
                                $building['access'] = 'public';
                        }

                        if ($action=='edit')
                        {
                                if ($building['building_id'] != 0)
                                {
                                        $message = $this->so->edit($building);
                                }
                        }
                        else
                        {

                                
$building['location_code']=$this->socommon->location_code($building['property_id'],$building['building_id']);
                                $message = $this->so->add($building);
//print_r($ids);
//print_();
                        }
                        return $message;
                }

                function delete($property_id,$building_id)
                {
                        $this->so->delete($property_id,$building_id);
                }
        }
?>

***** Error reading new file: [Errno 2] No such file or directory: 
'class.bocommon.inc.php'
--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class boproperty
        {
                var $start;
                var $query;
                var $filter;
                var $sort;
                var $order;
                var $cat_id;

                var $public_functions = array
                (
                        'read'                          => True,
                        'read_single'           => True,
                        'save'                          => True,
                        'delete'                        => True,
                        'check_perms'           => 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 boproperty($session=False)
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so               = 
CreateObject($this->currentapp.'.soproperty');
                        $this->socommon = 
CreateObject($this->currentapp.'.socommon');

                        $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'));

                        if ($start)
                        {
                                $this->start=$start;
                        }
                        else
                        {
                                $this->start=0;
                        }

                        if(isset($query))
                        {
                                $this->query = $query;
                        }
                        if(!empty($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;
                        }
                }


                function read()
                {
                        $property = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                                                                
        'filter' => $this->filter,'cat_id' => $this->cat_id));
                        $this->total_records = $this->so->total_records;

                        for ($i=0; $i<count($property); $i++)
                        {
                                $property[$i]['date']  = 
$GLOBALS['phpgw']->common->show_date($property[$i]['date']);
                                $property[$i]['owner'] = 
$GLOBALS['phpgw']->accounts->id2name($property[$i]['owner']);
                        }
                        return $property;
                }

                function read_single($property_id)
                {
                        return $this->so->read_single($property_id);
                }

                function select_part_of_town($part_of_town_id)
                {
                        return 
$this->socommon->select_part_of_town($part_of_town_id);
                }

                function save($property,$action='')
                {
                        if ($property['access'])
                        {
                                $property['access'] = 'private';
                        }
                        else
                        {
                                $property['access'] = 'public';
                        }

                        if ($action=='edit')
                        {
                                if ($property['property_id'] != 0)
                                {
                                        $message = $this->so->edit($property);
                                }
                        }
                        else
                        {
                                $message = $this->so->add($property);
                        }
                        return $message;
                }

                function delete($params)
                {
                        if (is_array($params))
                        {
                                $this->so->delete($params[0]);
                        }
                        else
                        {
                                $this->so->delete($params);
                        }
                }
        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class bostatus
        {
                var $start;
                var $query;
                var $filter;
                var $sort;
                var $order;
                var $cat_id;

                var $public_functions = array
                (
                        'read'                          => True,
                        'read_single'           => True,
                        'save'                          => True,
                        'delete'                        => True,
                        'check_perms'           => 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 bostatus($session=False)
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so               = 
CreateObject($this->currentapp.'.sostatus');
                        $this->socommon = 
CreateObject($this->currentapp.'.socommon');

                        $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'));

                        if ($start)
                        {
                                $this->start=$start;
                        }
                        else
                        {
                                $this->start=0;
                        }

                        if(isset($query))
                        {
                                $this->query = $query;
                        }
                        if(!empty($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;
                        }
                }


                function read($status_type='')
                {
                        $status = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                                                                
        'status_type' => $status_type));

                        $this->total_records = $this->so->total_records;

                        return $status;
                }

                function read_single($status_id,$status_type)
                {
                        return $this->so->read_single($status_id,$status_type);
                }

                function select_part_of_town($part_of_town_id)
                {
                        return 
$this->socommon->select_part_of_town($part_of_town_id);
                }

                function save($status,$action='',$status_type ='')
                {
                        if ($action=='edit')
                        {
                                if ($status['status_id'] != '')
                                {

                                        $message = 
$this->so->edit($status,$status_type);
                                }
                        }
                        else
                        {
                                $message = $this->so->add($status,$status_type);
                        }
                        return $message;

                }

                function delete($status_id,$status_type)
                {
                        $this->so->delete($status_id,$status_type);
                }
        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class soadmin
        {
                var $grants;

                function soadmin()
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->db               = $GLOBALS['phpgw']->db;
                        $this->db2              = $this->db;
                        $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
                        {
                                $this->join = " JOIN ";
                        }
                        else
                        {
                                $this->join = " LEFT JOIN ";
                        }


                }

                function is_admin($sub_module='',$permission='')
                {
                        $this->db->query("SELECT account_id from fm_admin WHERE 
type='u' and sub_module ='$sub_module' and $permission='1'",__LINE__,__FILE__);
                        $i = 0;
                        while ($this->db->next_record())
                        {
                                $is_admin[] = array('account_id' => 
$this->db->f('account_id'));
                        }
                        return $is_admin;
                }


                function is_group($sub_module='',$permission='')
                {
                        $this->db->query("SELECT account_id from fm_admin WHERE 
type='g' and sub_module ='$sub_module' and $permission='1'",__LINE__,__FILE__);
                        $i = 0;
                        while ($this->db->next_record())
                        {
                                $is_group[] = array('account_id' => 
$this->db->f('account_id'));
                        }
                        return $is_group;
                }


                function select_submodule($submodule_id='')
                {

                        $this->db->query("SELECT * FROM fm_submodule ORDER BY 
id ");

                                $i = 0;
                                while ($this->db->next_record())
                                {
                                                $submodule[$i]['id']            
                = $this->db->f('id');
                                                $submodule[$i]['descr']         
                = stripslashes($this->db->f('descr'));
                                $i++;
                                }

                                return $submodule;
                }


                function read_permission($data)
                {
                        if(is_array($data))
                        {
                                if ($data['start'])
                                {
                                        $start=$data['start'];
                                }
                                else
                                {
                                        $start=0;
                                }
                                $filter = 
(isset($data['filter'])?$data['filter']:'none');
                                $query = 
(isset($data['query'])?$data['query']:'');
                                $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
                                $order = 
(isset($data['order'])?$data['order']:'');
                                $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
                                $submodule_id = 
(isset($data['submodule_id'])?$data['submodule_id']:0);
                        }

                        if ($order)
                        {
                                $ordermethod = " order by $order $sort";
                        }
                        else
                        {
                                $ordermethod = ' order by account_lastname 
DESC';
                        }

                        if ($filter == 'none')
                        {
                                $filtermethod = ' ( owner=' . $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 (access='public' 
AND owner IN(" . implode(',',$public_user_list) . ")))";
                                }
                                else
                                {
                                        $filtermethod .= ' )';
                                }
                        }
                        elseif ($filter == 'yours')
                        {
                                $filtermethod = " owner='" . $this->account . 
"'";
                        }
                        else
                        {
                                $filtermethod = " owner='" . $this->account . 
"' AND access='private'";
                        }

                        if ($cat_id > 0)
                        {
                                $filtermethod .= " AND cat_id='$cat_id' ";
                        }

                        if($query)
                        {
                                $query = ereg_replace("'",'',$query);
                                $query = ereg_replace('"','',$query);

                                $querymethod = " AND objekt_id LIKE '%$query%' 
or byggnavn LIKE '%$query%'";
                        }

                        $sql = "SELECT 
janitor,supervisor,budget_responsible,transfer,fm_admin.account_id,account_lid,account_firstname,account_lastname,
 account_type, can_read,can_add,can_edit,can_delete,admin from fm_admin "
                        . " $this->join phpgw_accounts on 
fm_admin.account_id=phpgw_accounts.account_id  WHERE sub_module='$submodule_id' 
";// $querymethod ";


//print_r($sql);
                        $this->db2->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db2->num_rows();
                        $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);

                        while ($this->db->next_record())
                        {
                                $admins[] = array('id' => 
$this->db->f('account_id'),
                                                        'lid' => 
$this->db->f('account_lid'),
                                                        'firstname' => 
$this->db->f('account_firstname'),
                                                        'lastname' => 
$this->db->f('account_lastname'),
                                                        'read' => 
$this->db->f('can_read'),
                                                        'add' => 
$this->db->f('can_add'),
                                                        'edit' => 
$this->db->f('can_edit'),
                                                        'delete' => 
$this->db->f('can_delete'),
                                                        'admin' => 
$this->db->f('admin'),
                                                        'janitor' => 
$this->db->f('janitor'),
                                                        'supervisor' => 
$this->db->f('supervisor'),
                                                        'budget_responsible' => 
$this->db->f('budget_responsible'),
                                                        'transfer' => 
$this->db->f('transfer'),
                                                        'account_type' => 
$this->db->f('account_type'));
                        }

                        return $admins;
                }


                function edit_perm($values='')
                {

//_debug_array($values);
                        $users                  =       $values[users];
                        $groups                 =       $values[groups];
                        $permission             =       $values[permission];
                        $sub_module     =       $values[submodule_id];

                        $this->db->query("update fm_admin set update_right = 
NULL ",__LINE__,__FILE__);
                        if (count($users) != 0)
                        {
                                while($activ=each($users))
                                {

                                        $this->db->query("SELECT count(*) from 
fm_admin WHERE type='u' and account_id ='$activ[1]' and 
sub_module='$sub_module'",__LINE__,__FILE__);
                                        $this->db->next_record();
                                        if ($this->db->f(0) == 0)
                                        {
                                                $this->db->query("insert into 
fm_admin (account_id,type, sub_module,update_right,$permission) values 
('$activ[1]','u','$sub_module','$permission','1' )",__LINE__,__FILE__);
                                        }
                                        else
                                        {

                                                $this->db->query("update 
fm_admin set update_right ='$permission', $permission='1' where 
account_id='$activ[1]' and sub_module='$sub_module'",__LINE__,__FILE__);

                                        }

                                }
                        }


                        if (count($groups) != 0)
                        {
                                while($activ=each($groups))
                                {
                                        $this->db->query("SELECT count(*) from 
fm_admin WHERE type='g' and account_id ='$activ[1]' and 
sub_module='$sub_module'",__LINE__,__FILE__);
                                        $this->db->next_record();
                                        if ($this->db->f(0) == 0)
                                        {
                                                $this->db->query("insert into 
fm_admin (account_id,type, sub_module,update_right, $permission) values 
('$activ[1]','g','$sub_module','$permission','1' )",__LINE__,__FILE__);
                                        }
                                        else
                                        {
                                                $this->db->query("update 
fm_admin set update_right ='$permission', $permission='1' where 
account_id='$activ[1]'",__LINE__,__FILE__);
                                        }
                                }
                        }


                        $this->db2->query("SELECT * from fm_admin WHERE 
update_right is NULL and sub_module='$sub_module'",__LINE__,__FILE__);
                        while ($this->db2->next_record())
                        {
                                if($this->db2->f($permission))
                                {
                                        $to_update[] = array('account_id' => 
$this->db2->f('account_id'));
                                }
                        }

                        if ($to_update)
                        {
                                $i = 0;
                                while(each($to_update))
                                {
                                        
$account_id=$to_update[$i]['account_id'];
                                        $this->db2->query("update fm_admin set 
$permission = NULL WHERE account_id = '$account_id' and 
sub_module='$sub_module'",__LINE__,__FILE__);
                                        $i++;
                                }
                        }

                        $this->db2->query("SELECT * from fm_admin WHERE 
update_right is NULL and sub_module='$sub_module'",__LINE__,__FILE__);
                        while ($this->db2->next_record())
                        {

                                if(!$this->db2->f('can_read') && 
!$this->db2->f('can_add') && !$this->db2->f('can_edit') && 
!$this->db2->f('can_delete') && !$this->db2->f('janitor') && 
!$this->db2->f('supervisor') && !$this->db2->f('budget_responsible') && 
!$this->db2->f('transfer'))
                                {
                                        $to_delete[] = array('account_id' => 
$this->db2->f('account_id'));
                                }
                        }

                        if ($to_delete)
                        {
                                $i = 0;
                                while(each($to_delete))
                                {
                                        
$account_id=$to_delete[$i]['account_id'];
                                        $this->db2->query("DELETE from fm_admin 
WHERE account_id = '$account_id' and 
sub_module='$sub_module'",__LINE__,__FILE__);
                                        $i++;
                                }

                        }

                        $message=lang('Permission updated');

                        return $message;
                }

                function read_single($property_id,$building_id)
                {
                        $sql = "SELECT * FROM boei_bygg  where 
objekt_id='$property_id' and bygg_id='$building_id'";

                        $this->db->query($sql,__LINE__,__FILE__);

                        if ($this->db->next_record())
                        {
                                $building['property_id']                = 
(int)$this->db->f('objekt_id');
                                $building['building_id']                = 
(int)$this->db->f('bygg_id');
                                $building['owner']                              
= $this->db->f('owner');
                                $building['name']                               
= stripslashes($this->db->f('byggnavn'));
                                $building['generaladdress']             = 
stripslashes($this->db->f('generelladresse'));
                                $building['access']                             
= $this->db->f('access');
                                $building['date']                               
= $this->db->f('entry_date');
                                $building['cat_id']                             
= (int)$this->db->f('cat_id');
                                $building['omraade_id']                 = 
$this->db->f('omraade_id');
                                $building['part_of_town']               = 
$this->db->f('bydel');
                                $building['building_type_id']   = 
$this->db->f('building_type_id');
                                $building['location_code']              = 
$this->db->f('location_code');

                                return $building;
                        }
                }

                function read_fm_id()
                {
                        $sql = "select * from fm_idgenerator ";
                        $this->db->query($sql,__LINE__,__FILE__);

                        while ($this->db->next_record())
                        {
                                $fm_ids[] = array(
                                                        'descr'         => 
$this->db->f('name'),
                                                        'value'         => 
$this->db->f('value'),
                                                        'remark'        => 
$this->db->f('remark')
                                );

                        }

                        return $fm_ids;
                }

                function edit_id($values='')
                {
                        $field=$values['field'];
                        $select=$values['select'];

                        while($entry=each($select))
                                {
                                        $n=$entry[0];


                                        $sql = "update  fm_idgenerator set 
value='$values[$n]' where name='$field[$n]'";
                                        
$this->db->query($sql,__LINE__,__FILE__);

                                }


                        $message = lang('ID is updated');
                        return $message;

                }

        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class sobuilding
        {
                var $grants;

                function sobuilding()
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->db               = $GLOBALS['phpgw']->db;
                        $this->db2              = $this->db;
                        $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
                        {
                                $this->join = " JOIN ";
                        }
                        else
                        {
                                $this->join = " LEFT JOIN ";
                        }


                }

                function read($data)
                {
                        if(is_array($data))
                        {
                                if ($data['start'])
                                {
                                        $start=$data['start'];
                                }
                                else
                                {
                                        $start=0;
                                }
                                $filter = 
(isset($data['filter'])?$data['filter']:'none');
                                $query = 
(isset($data['query'])?$data['query']:'');
                                $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
                                $order = 
(isset($data['order'])?$data['order']:'');
                                $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
                        }

                        if ($order)
                        {
                                $ordermethod = " order by $order $sort";
                        }
                        else
                        {
                                $ordermethod = ' order by objekt_id DESC';
                        }

                        if ($filter == 'none')
                        {
                                $filtermethod = ' ( owner=' . $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 (access='public' 
AND owner IN(" . implode(',',$public_user_list) . ")))";
                                }
                                else
                                {
                                        $filtermethod .= ' )';
                                }
                        }
                        elseif ($filter == 'yours')
                        {
                                $filtermethod = " owner='" . $this->account . 
"'";
                        }
                        else
                        {
                                $filtermethod = " owner='" . $this->account . 
"' AND access='private'";
                        }

                        if ($cat_id > 0)
                        {
                                $filtermethod .= " AND cat_id='$cat_id' ";
                        }

                        if($query)
                        {
                                $query = ereg_replace("'",'',$query);
                                $query = ereg_replace('"','',$query);

                                $querymethod = " AND objekt_id LIKE '%$query%' 
or byggnavn LIKE '%$query%'";
                        }

                        $sql = "SELECT * FROM boei_bygg WHERE $filtermethod 
$querymethod";

                        $this->db2->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db2->num_rows();
                        $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);

                        while ($this->db->next_record())
                        {
                                $ngrants = 
(int)$this->grants[$this->db->f('building_owner')];
                                $building[] = array
                                (
                                        'property_id'   => 
$this->db->f('objekt_id'),
                                        'building_id'   => 
$this->db->f('bygg_id'),
                                        'owner'         => 
$this->db->f('owner'),
                                        'owner_id'      => 
(int)$this->db->f('owner'),
                                        'access'        => 
$this->db->f('access'),
                                        'date'          => 
$this->db->f('entry_date'),
                                        'cat_id'        => 
(int)$this->db->f('cat_id'),
                                        'name'  => 
stripslashes($this->db->f('byggnavn')),
                                        'grants'        => $ngrants
                                );
                        }
                        return $building;
                }

                function read_single($property_id,$building_id)
                {
                        $sql = "SELECT * FROM boei_bygg  where 
objekt_id='$property_id' and bygg_id='$building_id'";

                        $this->db->query($sql,__LINE__,__FILE__);

                        if ($this->db->next_record())
                        {
                                $building['property_id']                = 
(int)$this->db->f('objekt_id');
                                $building['building_id']                = 
(int)$this->db->f('bygg_id');
                                $building['owner']                              
= $this->db->f('owner');
                                $building['name']                               
= stripslashes($this->db->f('byggnavn'));
                                $building['generaladdress']             = 
stripslashes($this->db->f('generelladresse'));
                                $building['access']                             
= $this->db->f('access');
                                $building['date']                               
= $this->db->f('entry_date');
                                $building['cat_id']                             
= (int)$this->db->f('cat_id');
                                $building['omraade_id']                 = 
$this->db->f('omraade_id');
                                $building['part_of_town']               = 
$this->db->f('bydel');
                                $building['building_type_id']   = 
$this->db->f('building_type_id');
                                $building['location_code']              = 
$this->db->f('location_code');

                                return $building;
                        }
                }

                function add($building)
                {
//print_r($building);

                        $this->db->query("INSERT INTO boei_bygg (location_code, 
objekt_id,bygg_id,owner,access,entry_date,byggnavn,generelladresse,cat_id) "
                                . "VALUES ('" . $building['location_code']. 
"','" . $building['property_id'] . "','" . $building['building_id'] . "','" . 
$this->account . "','" . $building['access'] . "','" . time() . "','" . 
$building['name']
                                . "','" . $building['generaladdress'] ."','" . 
$building['cat_id']. "')",__LINE__,__FILE__);

                        $ids['building_id'] = $building['building_id'];
                        $ids['property_id'] = $building['property_id'];

                        $message = lang('Building has been saved');
                        return $message;
                }

                function edit($building)
                {
                        $building['content'] = 
$this->db->db_addslashes($building['content']);

                        $this->db->query("UPDATE boei_bygg set byggnavn='" . 
$building['name'] . "', entry_date='" . time()
                                                . "', cat_id='" . 
$building['cat_id'] . "', generelladresse='" . $building['generaladdress'] . 
"', access='" . $building['access']
                                                . "' WHERE objekt_id= '" . 
$building['property_id']
                                                . "' AND bygg_id=" . 
$building['building_id'],__LINE__,__FILE__);

                        $message = lang('Building has been edited');
                        return $message;
                }

                function delete($property_id,$building_id )
                {
                        $this->db->query('DELETE FROM boei_bygg WHERE 
objekt_id=' . $property_id . ' and bygg_id=' . $building_id,__LINE__,__FILE__);
                }
        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class socommon
        {
                var $grants;

                function socommon()
                {
                        $this->db               = $GLOBALS['phpgw']->db;
                        $this->db2              = $this->db;
                        $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants('property');
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
                        {
                                $this->join = " JOIN ";
                        }
                        else
                        {
                                $this->join = " LEFT JOIN ";
                        }


                }

                function select_part_of_town($bydel_id='')
                {

                        $this->db->query("SELECT bydel, bydel_id FROM 
boei_bydel ORDER BY bydel ");

                                $i = 0;
                                while ($this->db->next_record())
                                {
                                                $part_of_town[$i]['id']         
                = $this->db->f('bydel_id');
                                                $part_of_town[$i]['name']       
                        = stripslashes($this->db->f('bydel'));
                                $i++;
                                }

                                return $part_of_town;
                }



                function 
location_code($property_id='',$building_id='',$entrance_id='',$apartment='')
                {

                        $location_code=$property_id;

                        if($building_id)
                        {
                                $location_code.= "-".$building_id;
                        }
                        if($entrance_id)
                        {
                                $location_code.= "-".$entrance_id;
                        }
                        if($apartment)
                        {
                                $location_code.= "-".$apartment;
                        }

                        return $location_code;

                }

        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class soproperty
        {
                var $grants;

                function soproperty()
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->db               = $GLOBALS['phpgw']->db;
                        $this->db2              = $this->db;
                        $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
                        {
                                $this->join = " JOIN ";
                        }
                        else
                        {
                                $this->join = " LEFT JOIN ";
                        }


                }

                function read($data)
                {
                        if(is_array($data))
                        {
                                if ($data['start'])
                                {
                                        $start=$data['start'];
                                }
                                else
                                {
                                        $start=0;
                                }
                                $filter = 
(isset($data['filter'])?$data['filter']:'none');
                                $query = 
(isset($data['query'])?$data['query']:'');
                                $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
                                $order = 
(isset($data['order'])?$data['order']:'');
                                $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
                        }

                        if ($order)
                        {
                                $ordermethod = " order by $order $sort";
                        }
                        else
                        {
                                $ordermethod = ' order by objekt_id asc';
                        }

                        if ($filter == 'none')
                        {
                                $filtermethod = ' ( owner=' . $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 (access='public' 
AND owner IN(" . implode(',',$public_user_list) . ")))";
                                }
                                else
                                {
                                        $filtermethod .= ' )';
                                }
                        }
                        elseif ($filter == 'yours')
                        {
                                $filtermethod = " owner='" . $this->account . 
"'";
                        }
                        else
                        {
                                $filtermethod = " owner='" . $this->account . 
"' AND access='private'";
                        }

                        if ($cat_id > 0)
                        {
                                $filtermethod .= " AND cat_id='$cat_id' ";
                        }

                        if($query)
                        {
                                $query = ereg_replace("'",'',$query);
                                $query = ereg_replace('"','',$query);

                                $querymethod = " AND objekt_id LIKE '%$query%' 
or navn LIKE '%$query%'";
                        }

                        $sql = "SELECT * FROM boei_objekt $this->join 
boei_bydel on boei_objekt.bydel_id = boei_bydel.bydel_id "
                                . " WHERE $filtermethod $querymethod";

                        $this->db2->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db2->num_rows();
                        $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);

                        while ($this->db->next_record())
                        {
                                $ngrants = 
(int)$this->grants[$this->db->f('property_owner')];
                                $property[] = array
                                (
                                        'property_id'   => 
(int)$this->db->f('objekt_id'),
                                        'owner'                 => 
$this->db->f('owner'),
                                        'owner_id'              => 
(int)$this->db->f('owner'),
                                        'access'                => 
$this->db->f('access'),
                                        'date'                  => 
$this->db->f('entry_date'),
                                        'cat_id'                => 
(int)$this->db->f('cat_id'),
                                        'name'                  => 
stripslashes($this->db->f('navn')),
                                        'area_id'               => 
$this->db->f('omraade_id'),
                                        'part_of_town'  => 
$this->db->f('bydel'),
                                        'grants'                => $ngrants
                                );
                        }
                        return $property;
                }

                function read_single($property_id)
                {
                        $sql = "SELECT * FROM boei_objekt $this->join 
boei_bydel on boei_objekt.bydel_id = boei_bydel.bydel_id where 
objekt_id='$property_id'";

                        $this->db->query($sql,__LINE__,__FILE__);

                        if ($this->db->next_record())
                        {
                                $property['property_id']                        
                = (int)$this->db->f('objekt_id');
                                $property['owner']                              
= $this->db->f('owner');
                                $property['name']                               
= stripslashes($this->db->f('navn'));
                                $property['generaladdress']             = 
stripslashes($this->db->f('generelladresse'));
                                $property['access']                             
= $this->db->f('access');
                                $property['date']                               
= $this->db->f('entry_date');
                                $property['cat_id']                             
= (int)$this->db->f('cat_id');
                                $property['area_id']                    = 
$this->db->f('omraade_id');
                                $property['part_of_town']               = 
$this->db->f('bydel');
                                $property['part_of_town_id']    = 
$this->db->f('bydel_id');
                                $property['property_type_id']   = 
$this->db->f('property_type_id');
                                $property['location_code']              = 
$this->db->f('location_code');
                                $property['generellinfo']               = 
$this->db->f('generellinfo');

                                return $property;
                        }
                }

                function add($property)
                {
//print_r($property);
                        $property['generellinfo'] = 
$this->db->db_addslashes($property['generellinfo']);

                        $this->db->query("INSERT INTO boei_objekt 
(location_code, 
objekt_id,bydel_id,owner,access,entry_date,navn,generelladresse,cat_id,generellinfo)
 "
                                . "VALUES ('" . $property['property_id'] . 
"','" . $property['property_id'] . "','" . $property['part_of_town_id'] . "','" 
. $this->account . "','" . $property['access'] . "','" . time() . "','" . 
$property['name']
                                . "','" . $property['generaladdress'] ."','" . 
$property['cat_id'] ."','" . $property['generellinfo']. "')",__LINE__,__FILE__);

                        $message = lang('Property has been saved');
                        return $message;
                }

                function edit($property)
                {
                        $property['content'] = 
$this->db->db_addslashes($property['content']);

                        $this->db->query("UPDATE boei_objekt set navn='" . 
$property['name'] . "', entry_date='" . time() . "', cat_id='"
                                                        . $property['cat_id'] . 
"', generelladresse='" . $property['generaladdress'] . "', access='" . 
$property['access'] . "', bydel_id='" . $property['part_of_town_id']. "', 
generellinfo='" . $property['generellinfo']
                                                        . "' WHERE objekt_id=" 
. intval($property['property_id']),__LINE__,__FILE__);

                        $message = lang('Property has been edited');
                        return $message;
                }

                function delete($property_id)
                {
                        $this->db->query('DELETE FROM boei_objekt WHERE 
objekt_id=' . intval($property_id),__LINE__,__FILE__);
                }
        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class sostatus
        {
                var $grants;

                function sostatus()
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->db               = $GLOBALS['phpgw']->db;
                        $this->db2              = $this->db;
                        $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
                        {
                                $this->join = " JOIN ";
                        }
                        else
                        {
                                $this->join = " LEFT JOIN ";
                        }


                }

                function read($data)
                {
                        if(is_array($data))
                        {
                                if ($data['start'])
                                {
                                        $start=$data['start'];
                                }
                                else
                                {
                                        $start=0;
                                }
                                $query = 
(isset($data['query'])?$data['query']:'');
                                $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
                                $order = 
(isset($data['order'])?$data['order']:'');
                                $status_type = 
(isset($data['status_type'])?$data['status_type']:0);
                        }

                        if ($order)
                        {
                                $ordermethod = " order by $order $sort";
                        }
                        else
                        {
                                $ordermethod = ' order by status asc';
                        }



                        if($status_type=='workorder'):
                        {
                                $table='fm_wo_wrkorders_status';
                        }
                        elseif ($status_type=='request'):
                        {
                                $table='fm_request_status';
                        }
                        endif;

                        if($query)
                        {
                                $query = ereg_replace("'",'',$query);
                                $query = ereg_replace('"','',$query);

                                $querymethod = " where status LIKE '%$query%' 
or descr LIKE '%$query%'";
                        }

                        $sql = "SELECT * FROM $table $querymethod";

                        $this->db2->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db2->num_rows();
                        $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);

                        while ($this->db->next_record())
                        {
                                $status[] = array
                                (
                                        'status_id'     => 
$this->db->f('status'),
                                        'descr'                 => 
$this->db->f('descr')
                                );
                        }
                        return $status;
                }

                function read_single($status_id,$status_type)
                {
                        if($status_type=='workorder'):
                        {
                                $table='fm_wo_wrkorders_status';
                        }
                        elseif ($status_type=='request'):
                        {
                                $table='fm_request_status';
                        }
                        endif;


                        $sql = "SELECT * FROM $table  where 
status='$status_id'";

                        $this->db->query($sql,__LINE__,__FILE__);

                        if ($this->db->next_record())
                        {
                                $status['status_id']                    = 
$this->db->f('status');
                                $status['descr']                                
= $this->db->f('descr');

                                return $status;
                        }
                }

                function add($status,$status_type)
                {
                        if($status_type=='workorder'):
                        {
                                $table='fm_wo_wrkorders_status';
                        }
                        elseif ($status_type=='request'):
                        {
                                $table='fm_request_status';
                        }
                        endif;

                        $status['descr'] = 
$this->db->db_addslashes($status['descr']);

                        $this->db->query("INSERT INTO $table (status, descr) "
                                . "VALUES ('" . $status['status_id'] . "','" . 
$status['descr']. "')",__LINE__,__FILE__);

                        $message = lang('status has been saved');
                        return $message;
                }

                function edit($status,$status_type)
                {

//_debug_array($status);
                        if($status_type=='workorder'):
                        {
                                $table='fm_wo_wrkorders_status';
                        }
                        elseif ($status_type=='request'):
                        {
                                $table='fm_request_status';
                        }
                        endif;

                        $status['descr'] = 
$this->db->db_addslashes($status['descr']);

                        $this->db->query("UPDATE $table set descr='" . 
$status['descr']
                                                        . "' WHERE status='" . 
$status['status_id']. "'",__LINE__,__FILE__);

                        $message = lang('status has been edited');
                        return $message;
                }

                function delete($status_id,$status_type)
                {
                        if($status_type=='workorder'):
                        {
                                $table='fm_wo_wrkorders_status';
                        }
                        elseif ($status_type=='request'):
                        {
                                $table='fm_request_status';
                        }
                        endif;

                        $this->db->query("DELETE FROM $table WHERE status='" . 
$status_id . "'",__LINE__,__FILE__);
                }
        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * -------------------------------------------------                     
    *
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/
        class uiadmin
        {
                var $grants;
                var $cat_id;
                var $start;
                var $query;
                var $sort;
                var $order;
                var $filter;
                var $submodule_id;
                var $permission;
                var $sub;
                var $currentapp;

                var $public_functions = array
                (
                        'list_perm'  => True,
                        'view'   => True,
                        'edit_perm'   => True,
                        'edit_id' => True
                );

                function uiadmin()
                {
                        $this->currentapp                       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->cats                                     = 
CreateObject('phpgwapi.categories');
                        $this->cats->app_name           = 'fm_admin';
                        $this->nextmatchs                       = 
CreateObject('phpgwapi.nextmatchs');
                        $this->account                          = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        $this->grants                           = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->grants[$this->account] = PHPGW_ACL_READ + 
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
                        $this->bo                                       = 
CreateObject($this->currentapp.'.boadmin',false);
                        $this->bocommon                         = 
CreateObject($this->currentapp.'.bocommon');

                        $this->start                            = 
$this->bo->start;
                        $this->query                            = 
$this->bo->query;
                        $this->sort                                     = 
$this->bo->sort;
                        $this->order                            = 
$this->bo->order;
                        $this->filter                           = 
$this->bo->filter;
                        $this->cat_id                           = 
$this->bo->cat_id;
                        $this->submodule_id                     = 
$this->bo->submodule_id;
                        $this->permission                       = 
$this->bo->permission;
                }

                function save_sessiondata()
                {
                        $data = array
                        (
                                'start'                 => $this->start,
                                'query'                 => $this->query,
                                'sort'                  => $this->sort,
                                'order'                 => $this->order,
                                'filter'                => $this->filter,
                                'cat_id'                => $this->cat_id,
                                'submodule_id'  => $this->submodule_id,
                                'permission'    => $this->permission
                        );
//      _debug_array($data);

                        $this->bocommon->save_sessiondata($data);
                }

                function list_perm()
                {

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'filter_select',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field'));
                                                                //              
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'nextmatchs'));

//                      $sub = get_var('sub',array('POST','GET'));

                        $admins = $this->bo->read_permission();

//_debug_array($admins);

                        for ($i=0;$i<count($admins);$i++)
                        {
                                $lid = $admins[$i]['lid'];

                                $rights = '';
                                if ($admins[$i]['read'])
                                {
                                        $rights .= lang('read') .', ';
                                }

                                if ($admins[$i]['add'])
                                {
                                        $rights .=lang(add) .', ';
                                }

                                if ($admins[$i]['edit'])
                                {
                                        $rights .=lang('edit') .', ';
                                }

                                if ($admins[$i]['delete'])
                                {
                                        $rights .=lang(delete) .', ';
                                }

                                if ($admins[$i]['admin'])
                                {
                                        $rights .=lang(Admin) .', ';
                                }

                                $roles = '';
                                if ($admins[$i]['janitor'])
                                {
                                        $roles .= lang('Janitor') .', ';
                                }
                                if ($admins[$i]['supervisor'])
                                {
                                        $roles .=lang('Supervisor') .', ';
                                }
                                if ($admins[$i]['budget_responsible'])
                                {
                                        $roles .=lang('Budget Responsible') .', 
';
                                }
                                if ($admins[$i]['transfer'])
                                {
                                        $roles .=lang(Transfer) .', ';
                                }

                                if ($admins[$i]['account_type']=='u')
                                {
                                        $firstname = $admins[$i]['firstname'];
                                        if (!$firstname) { $firstname = ''; }
                                        $lastname = $admins[$i]['lastname'];
                                        if (!$lastname) { $lastname = ''; }
                                }
                                else
                                {
                                        $firstname = '';
                                        $lastname = '';
                                }

                                $content[] = array
                                (
                                        'lid'           => $lid,
                                        'rights'        => $rights,
                                        'roles'         => $roles,
                                        'firstname' => $firstname,
                                        'lastname'      => $lastname
                                );

                        }

                        $table_header[] = array
                        (
                                'sort_lid'      => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   =>      'account_lid',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra' => array('menuaction'   => 
$this->currentapp.'.uiadmin.list_perm',
                                                                                
                                                        'cat_id'        
=>$this->cat_id,
                                                                                
                                                        'submodule_id'  
=>$this->submodule_id)
                                                                                
)),
                                'sort_lastname' => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  =>      $this->sort,
                                                                                
        'var'   =>      'account_lastname',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra' =>      array('menuaction'      => 
$this->currentapp.'.uiadmin.list_perm',
                                                                                
                                                        'cat_id'        
=>$this->cat_id,
                                                                                
                                                        'submodule_id'  
=>$this->submodule_id)
                                                                                
)),
                                'sort_firstname'        => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  =>      $this->sort,
                                                                                
        'var'   =>      'account_firstname',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra' =>      array('menuaction'      => 
$this->currentapp.'.uiadmin.list_perm',
                                                                                
                                                        'cat_id'        
=>$this->cat_id,
                                                                                
                                                        'submodule_id'  
=>$this->submodule_id)
                                                                                
)),


                                'lang_lid'                      => 
lang('Username / Group'),
                                'lang_lastname'         => lang('Lastname'),
                                'lang_firstname'        => lang('Firstname'),
                                'lang_rights'           => lang('Rights'),
                                'lang_roles'            => lang('Roles')
                        );


                                $hidden_vars[] = array('name' => 
'submodule_id', 'value' => $this->submodule_id);
                                $hidden_vars[] = array('name' => 'permission', 
'value' => $this->permission);
                                $hidden_vars[] = array('name' => 'query', 
'value' => $this->query);


                        $table_add[] = array
                        (
                                'hidden_vars'                   => $hidden_vars,
                                'lang_no_permission'                    => 
lang('No Permission selected'),
                                'lang_permission_statustext'    => lang('Select 
Permission'),
                                'select_name_permission'                => 
'permission',
                                'permission_list'                               
=> $this->bo->select_permission($this->permission,$this->submodule_id),
                                'lang_add'                              => 
lang('Edit'),
                                'lang_add_statustext'   => lang('Edit 
permissions'),
                                'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.edit_perm'),
                                'lang_done'                             => 
lang('done'),
                                'lang_done_statustext'  => lang('Back to 
Admin'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php')
                        );

                        $data = array
                        (
                                'hidden_vars'                                   
=> $hidden_vars,
                                'links'                                         
        => $links,
                                'allow_all_rows'                                
=> false,
                                'start_record'                                  
=> $this->start,
                                'record_limit'                                  
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
                                'num_records'                                   
=> count($admins),
                                'all_records'                                   
=> $this->bo->total_records,
                                'link_url'                                      
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.list_perm'),
                                'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi'),
                                'appname'                                       
        => lang($this->currentapp),
                                'function_msg'                                  
=> lang('list permission'),
                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the building belongs to. To do not use a category 
select NO CATEGORY'),
                                'select_name'                                   
=> 'cat_id',
                                'cat_list'                                      
        => $this->cats->formatted_xslt_list(array('selected' => 
$this->cat_id,'globals' => True)),
                                'select_action'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.list_perm'),
                                'filter_list'                                   
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' => 
'yes')),
                                'lang_filter_statustext'                => 
lang('Select the filter. To show all entries select SHOW ALL'),
                                'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
                                'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
                                'query'                                         
        => $this->query,
                                'lang_submit'                                   
=> lang('submit'),
                                'table_header'                                  
=> $table_header,
                                'values'                                        
        => $content,
                                'lang_no_submodule'                             
=> lang('No submodule'),
                                'lang_submodule_statustext'             => 
lang('Select submodule'),
                                'select_name_submodule'                 => 
'submodule_id',
                                'submodule_list'                                
=> $this->bo->select_submodule('filter',$this->submodule_id),
                                'table_add'                                     
        => $table_add
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_perm' => $data));
                        $this->save_sessiondata();
                }


                function edit_perm()
                {
                        $submodule_id = 
get_var('submodule_id',array('POST','GET'));
                        $permission = get_var('permission',array('POST','GET'));
                        $values         = get_var('values',array('POST'));

//_debug_array($values);

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('admin',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));

                        if ($values['save'])
                        {
                                $message = $this->bo->edit_perm($values);
                        }

                        $function_msg = lang('edit permission');

                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uiadmin.edit_perm',
                                'permission'    => $this->permission,
                                'submodule_id'  => $this->submodule_id
                        );

                        $user_list = 
$this->bo->select_users('select_multi',$this->submodule_id,$this->permission);

                        if (!$user_list)
                        {
                                $message = lang('please select both submodule 
and permission to edit');
                        }

                        $group_list = 
$this->bo->select_groups('select_multi',$this->submodule_id,$this->permission);
                        if (!$group_list)
                        {
                                $message = lang('please select both submodule 
and permission to edit');
                        }
//      _debug_array($group_list);


                        $data = array
                        (
                                'appname'                                       
        => lang($this->currentapp),
                                'permission'                                    
=> $permission,
                                'submodule_id'                                  
=> $submodule_id,
                                'function_msg'                                  
=> $function_msg,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.list_perm'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
                                'message'                                       
        => $message,

                                'lang_user_list'                                
=> lang('User List'),
                                'user_list'                                     
        => $user_list,
                                'lang_no_user'                                  
=> lang('No User'),
                                'lang_user_statustext'                  => 
lang('Select the user to give the permission'),
                                'select_name_user'                              
=> 'values[user_id][]',


                                'lang_group_list'                               
=> lang('Group List'),
                                'group_list'                                    
=> $group_list,
                                'lang_no_group'                                 
=> lang('No group'),
                                'lang_group_statustext'                 => 
lang('Select the group to give the permission'),
                                'select_name_group'                             
=> 'values[group_id][]',
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_perm' => $data));
                }

                function edit_id()
                {

                        $GLOBALS['phpgw']->xslttpl->add_file(array('admin',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header'));

                        $values         = get_var('values',array('POST'));

                        if ($values['select'])
                        {
                                $message = $this->bo->edit_id($values);
                        }

                        $fm_ids = $this->bo->read_fm_id();

                        for ($i=0;$i<count($fm_ids);$i++)
                        {

                                $content[] = array
                                (
                                        'descr'         => $fm_ids[$i]['descr'],
                                        'value'         => $fm_ids[$i]['value'],
                                        'remark'        => 
$fm_ids[$i]['remark'],
                                        'key_id'        => $i
                                );
                        }

                        $table_header[] = array
                        (
                                'lang_select'           => lang('Select'),
                                'lang_descr'            => lang('Descr'),
                                'lang_value'            => lang('Value'),
                                'lang_remark'           => lang('Remark'),
                        );

                        $data = array
                        (
                                'appname'                               => 
lang($this->currentapp),
                                'function_msg'                  => lang('Edit 
ID'),
                                'form_action'                   => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.edit_id'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
                                'lang_submit'                   => 
lang('submit'),
                                'lang_save'                             => 
lang('Edit'),
                                'lang_add_statustext'   => lang('Edit ID'),
                                'lang_done'                             => 
lang('done'),
                                'lang_done_statustext'  => lang('Back to 
Admin'),
                                'lang_select'                   => 
lang('Select'),
                                'lang_descr'                    => 
lang('Descr'),
                                'lang_value'                    => 
lang('Value'),
                                'lang_remark'                   => 
lang('Remark'),
                                'message'                               => 
$message,
                                'id_table_header'               => 
$table_header,
                                'id_values'                             => 
$content,
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_id' => $data));
                        $this->save_sessiondata();
                }

        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * -------------------------------------------------                     
    *
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/
        class uibuilding
        {
                var $grants;
                var $cat_id;
                var $start;
                var $query;
                var $sort;
                var $order;
                var $filter;
                var $part_of_town_id;
                var $sub;
                var $currentapp;

                var $public_functions = array
                (
                        'index'  => True,
                        'view'   => True,
                        'edit'   => True,
                        'delete' => True
                );

                function uibuilding()
                {
                        $this->currentapp                       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->cats                                     = 
CreateObject('phpgwapi.categories');
                        $this->cats->app_name           = 'building';
                        $this->nextmatchs                       = 
CreateObject('phpgwapi.nextmatchs');
                        $this->account                          = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        $this->grants                           = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->grants[$this->account] = PHPGW_ACL_READ + 
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
                        $this->bo                                       = 
CreateObject($this->currentapp.'.bobuilding',True);
                        $this->bocommon                                 = 
CreateObject($this->currentapp.'.bocommon',True);

                        $this->start                            = 
$this->bo->start;
                        $this->query                            = 
$this->bo->query;
                        $this->sort                                     = 
$this->bo->sort;
                        $this->order                            = 
$this->bo->order;
                        $this->filter                           = 
$this->bo->filter;
                        $this->cat_id                           = 
$this->bo->cat_id;
                        $this->part_of_town_id          = 
$this->bocommon->part_of_town_id;
                }

                function save_sessiondata()
                {
                        $data = array
                        (
                                'start'         => $this->start,
                                'query'         => $this->query,
                                'sort'          => $this->sort,
                                'order'         => $this->order,
                                'filter'        => $this->filter,
                                'cat_id'        => $this->cat_id
                        );
                        $this->bocommon->save_sessiondata($data);
                }

                function index()
                {

                        $GLOBALS['phpgw']->xslttpl->add_file(array('building',
                                                                                
'menu',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'filter_select',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'nextmatchs'));

                        $sub = get_var('sub',array('POST','GET'));
                        $links = $this->bocommon->menu($sub);

                        $building_list = $this->bo->read();

                        while (is_array($building_list) && list(,$building) = 
each($building_list))
                        {
                                $words = split(' ',$building['name']);
                                $first = "$words[0] $words[1] $words[2] 
$words[3] .....";

                                $content[] = array
                                (
                                        'property_id'                           
=> $building['property_id'],
                                        'building_id'                           
=> $building['building_id'],
                                        'first'                                 
        => $first,
                                        'date'                                  
        => $building['date'],
                                        'owner'                                 
        => $building['owner'],
                                        'link_view'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.view&property_id='
 . $building['property_id'].'&building_id=' . $building['building_id']),
                                        'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.edit&property_id='
 . $building['property_id'].'&building_id=' . $building['building_id']),
                                        'link_delete'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.delete&property_id='
 . $building['property_id'].'&building_id=' . $building['building_id']),
                                        'lang_view_statustext'          => 
lang('view the building'),
                                        'lang_edit_statustext'          => 
lang('edit the building'),
                                        'lang_delete_statustext'        => 
lang('delete the building'),
                                        'text_view'                             
        => lang('view'),
                                        'text_edit'                             
        => lang('edit'),
                                        'text_delete'                           
=> lang('delete')
                                );
                        }

                        $table_header[] = array
                        (
                                'lang_name'             => lang('name'),
                                'lang_time_created'     => lang('time created'),
                                'lang_view'                     => lang('view'),
                                'lang_edit'                     => lang('edit'),
                                'lang_delete'           => lang('delete'),
                                'lang_property_id'              => 
lang('property id'),
                                'lang_building_id'              => 
lang('building id'),
                                'lang_owner'            => lang('owner')
                        );

                        $table_add[] = array
                        (
                                'lang_add'                              => 
lang('add'),
                                'lang_add_statustext'   => lang('add a 
building'),
                                'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.edit')
                        );


                        $data = array
                        (
                                'links'                                         
        => $links,
                                'allow_all_rows'                                
=> True,
                                'start_record'                                  
=> $this->start,
                                'record_limit'                                  
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
                                'num_records'                                   
=> count($building_list),
                                'all_records'                                   
=> $this->bo->total_records,
                                'link_url'                                      
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.index'),
                                'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi'),
                                'appname'                                       
        => lang($this->currentapp),
                                'function_msg'                                  
=> lang('list building'),
                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the building belongs to. To do not use a category 
select NO CATEGORY'),
                                'select_name'                                   
=> 'cat_id',
                                'cat_list'                                      
        => $this->cats->formatted_xslt_list(array('selected' => 
$this->cat_id,'globals' => True)),
                                'select_action'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.index'),
                                'filter_list'                                   
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' => 
'yes')),
                                'lang_filter_statustext'                => 
lang('Select the filter. To show all entries select SHOW ALL'),
                                'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
                                'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
                                'query'                                         
        => $this->query,
                                'lang_submit'                                   
=> lang('submit'),
                                'table_header'                                  
=> $table_header,
                                'values'                                        
        => $content,
                                'table_add'                                     
        => $table_add
                        );

//print_r($data).'<br>';
//print_($menu);
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
                        $this->save_sessiondata();
                }

                function edit()
                {
                        $property_id = get_var('property_id',array('GET'));
                        $building_id = 
get_var('building_id',array('POST','GET'));
                        $values         = get_var('values',array('POST'));

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('building',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));

                        if ($values['save'])
                        {
                                if($building_id)
                                {
                                        $values['property_id']=$property_id;
                                        $values['building_id']=$building_id;
                                        $action='edit';
                                }
                                else
                                {
                                        $property_id =  $values['property_id'];
                                        $building_id =  $values['building_id'];
                                }

                                $message = $this->bo->save($values,$action);
                        }

                        if ($building_id)
                        {
                                $building = 
$this->bo->read_single($property_id,$building_id);
//print_r($building).'<br>';
//print_($building).'<br>';
                                $function_msg = lang('edit building');
                        }
                        else
                        {
                                $function_msg = lang('add building');
                        }

                        if ($building['cat_id'] > 0)
                        {
                                $this->cat_id = $building['cat_id'];
                        }
                        if ($building['part_of_town_id'] > 0)
                        {
                                $this->part_of_town_id = 
$building['part_of_town_id'];
                        }

                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uibuilding.edit',
                                'property_id'   => $property_id,
                                'building_id'   => $building_id
                        );

                        $data = array
                        (
                                'appname'                                       
        => lang('building'),
                                'function_msg'                                  
=> $function_msg,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.index'),
                                'lang_property_id'                              
=> lang('Property ID'),
                                'lang_building_id'                              
=> lang('Building ID'),
                                'lang_name'                                     
        => lang('name'),
                                'lang_generaladdress'                   => 
lang('General Address'),
                                'lang_generellinfo'                             
=> lang('General Info'),
                                'lang_category'                                 
=> lang('category'),
                                'lang_access'                                   
=> lang('private'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
                                'value_property_id'                             
=> $property_id,
                                'value_building_id'                             
=> $building_id,
                                'value_name'                                    
=> $building['name'],
                                'value_generaladdress'                  => 
$building['generaladdress'],
                                'value_access'                                  
=> $building['access'],
                                'value_cat'                                     
        => $building['cat'],
                                'message'                                       
        => $message,
                                'lang_name_statustext'                  => 
lang('Enter the name of the building'),
                                'lang_property_id_statustext'   => lang('Enter 
Property ID'),
                                'lang_building_id_statustext'   => lang('Enter 
Building ID'),
                                'lang_generaladdress_statustext'=> lang('Enter 
the general address'),
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the building'),
                                'lang_access_off_statustext'    => lang('The 
building is public. If the building should be private, check this box'),
                                'lang_access_on_statustext'             => 
lang('The building is private. If the building should be public, uncheck this 
box'),
                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the building belongs to. To do not use a category 
select NO CATEGORY'),
                                'select_name'                                   
=> 'values[cat_id]',
                                'lang_town_statustext'                  => 
lang('Select the part of town the building belongs to. To do not use a part of 
town -  select NO PART OF TOWN'),
                                'lang_part_of_town'                             
=> lang('Part of town'),
                                'lang_no_part_of_town'                  => 
lang('No part of town'),
                                'cat_list'                                      
        => $this->cats->formatted_xslt_list(array('format' => 
'select','selected' => $this->cat_id,'globals' => True)),
                                'part_of_town_list'                             
=> $this->bocommon->select_part_of_town('select',$this->part_of_town_id),
                                'select_name_part_of_town'              => 
'values[part_of_town_id]',
                                'omraade_id'                                    
=> $building['omraade_id'],
                                'part_of_town'                                  
=> $building['part_of_town'],
                                'building_type_id'                              
=> $building['building_type_id'],
                                'location_code'                                 
=> $building['location_code'],
                                'value_generellinfo'                    => 
$building['generellinfo']


                        );
//print_r($data).'<br>';
//print_();

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
                }

                function delete()
                {
                        $property_id = get_var('property_id',array('GET'));
                        $building_id = 
get_var('building_id',array('POST','GET'));
                        $confirm        = get_var('confirm',array('POST'));

                        $link_data = array
                        (
                                'menuaction' => 
$this->currentapp.'.uibuilding.index'
                        );

                        if (get_var('confirm',array('POST')))
                        {
                                $this->bo->delete($property_id,$building_id);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                        }

                        
$GLOBALS['phpgw']->xslttpl->add_file(array($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_delete',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header'));

                        $data = array
                        (
                                'appname'                               => 
lang('building'),
                                'function_msg'                  => lang('delete 
building'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
                                'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.delete&property_id='
 . $property_id.'&building_id=' . $building_id),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),
                                'lang_yes_statustext'   => lang('Delete the 
entry'),
                                'lang_no_statustext'    => lang('Back to the 
list'),
                                'lang_no'                               => 
lang('no')
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
                }

                function view()
                {
                        $property_id = get_var('property_id',array('GET'));
                        $building_id = get_var('building_id',array('GET'));

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('building',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));

                        $building = 
$this->bo->read_single($property_id,$building_id);

                        $data = array
                        (
                                'appname'                       => 
lang('building'),
                                'function_msg'          => lang('view 
building'),
                                'done_action'           => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uibuilding.index'),
                                'lang_name'                     => lang('name'),
                                'lang_category'         => lang('category'),
                                'lang_access'           => lang('access'),
                                'lang_time_created'     => lang('time created'),
                                'lang_done'                     => lang('done'),
                                'value_name'            => $building['name'],
                                'value_access'          => 
lang(ucfirst($building['access'])),
                                'value_cat'                     => 
$this->cats->id2name($building['cat']),
                                'value_date'            => 
$GLOBALS['phpgw']->common->show_date($building['date'])
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
                }
        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * -------------------------------------------------                     
    *
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/
        class uiproperty
        {
                var $grants;
                var $cat_id;
                var $start;
                var $query;
                var $sort;
                var $order;
                var $filter;
                var $part_of_town_id;
                var $sub;
                var $currentapp;

                var $public_functions = array
                (
                        'index'  => True,
                        'view'   => True,
                        'edit'   => True,
                        'delete' => True
                );

                function uiproperty()
                {
                        $this->currentapp                       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->cats                                     = 
CreateObject('phpgwapi.categories');
                        $this->nextmatchs                       = 
CreateObject('phpgwapi.nextmatchs');
                        $this->account                          = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        $this->grants                           = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->grants[$this->account] = PHPGW_ACL_READ + 
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
                        $this->bo                                       = 
CreateObject($this->currentapp.'.boproperty');
                        $this->bocommon                         = 
CreateObject($this->currentapp.'.bocommon',True);

                        $this->start                            = 
$this->bo->start;
                        $this->query                            = 
$this->bo->query;
                        $this->sort                                     = 
$this->bo->sort;
                        $this->order                            = 
$this->bo->order;
                        $this->filter                           = 
$this->bo->filter;
                        $this->cat_id                           = 
$this->bo->cat_id;
                        $this->part_of_town_id          = 
$this->bocommon->part_of_town_id;
                }

                function save_sessiondata()
                {
                        $data = array
                        (
                                'start'         => $this->start,
                                'query'         => $this->query,
                                'sort'          => $this->sort,
                                'order'         => $this->order,
                                'filter'        => $this->filter,
                                'cat_id'        => $this->cat_id
                        );
                        $this->bocommon->save_sessiondata($data);
                }

                function index()
                {

                        $GLOBALS['phpgw']->xslttpl->add_file(array('property',
                                                                                
'menu',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'filter_select',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'nextmatchs'));

                        $sub = get_var('sub',array('POST','GET'));
                        $links = $this->bocommon->menu($sub);

//echo 'hei';
//print_r($links);
//print_();


                        $property_list = $this->bo->read();

                        while (is_array($property_list) && list(,$property) = 
each($property_list))
                        {
                                $words = split(' ',$property['name']);
                                $first = "$words[0] $words[1] $words[2] 
$words[3]";

                                $content[] = array
                                (
                                        'property_id'                           
=> $property['property_id'],
                                        'first'                                 
        => $first,
                                        'area_id'                               
        => $property['area_id'],
                                        'part_of_town'                          
=> $property['part_of_town'],
                                        'owner'                                 
        => $property['owner'],
                                        'link_view'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.view&property_id='
 . $property['property_id']),
                                        'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.edit&property_id='
 . $property['property_id']),
                                        'link_delete'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.delete&property_id='
 . $property['property_id']),
                                        'lang_view_statustext'          => 
lang('view the property'),
                                        'lang_edit_statustext'          => 
lang('edit the property'),
                                        'lang_delete_statustext'        => 
lang('delete the property'),
                                        'text_view'                             
        => lang('view'),
                                        'text_edit'                             
        => lang('edit'),
                                        'text_delete'                           
=> lang('delete')
                                );
                        }

                        $table_header[] = array
                        (

                                'sort_name'     => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   =>      'navn',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uiproperty.index',
                                                                                
                                                        'cat_id'        
=>$this->cat_id)
                                                                                
)),

                                'lang_name'                     => lang('Name'),
                                'lang_area'                     => lang('Area'),
                                'lang_part_of_town'     => lang('Part of town'),
                                'lang_view'                     => lang('view'),
                                'lang_edit'                     => lang('edit'),
                                'lang_delete'           => lang('delete'),
                                'sort_property_id'      => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   =>      'objekt_id',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uiproperty.index',
                                                                                
                                                        'cat_id'        
=>$this->cat_id)
                                                                                
)),
                                'lang_property_id'      => lang('property id'),
                                'lang_owner'            => lang('owner')
                        );

                        $table_add[] = array
                        (
                                'lang_add'                              => 
lang('add'),
                                'lang_add_statustext'   => lang('add a 
property'),
                                'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.edit')
                        );


                        $data = array
                        (
                                'links'                                         
        => $links,
                                'allow_all_rows'                                
=> False,
                                'start_record'                                  
=> $this->start,
                                'record_limit'                                  
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
                                'num_records'                                   
=> count($property_list),
                                'all_records'                                   
=> $this->bo->total_records,
                                'link_url'                                      
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.index'),
                                'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi'),
                                'appname'                                       
        => lang($this->currentapp),
                                'function_msg'                                  
=> lang('list property'),
                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the property belongs to. To do not use a category 
select NO CATEGORY'),
                                'select_name'                                   
=> 'cat_id',
                                'cat_list'                                      
        => $this->cats->formatted_xslt_list(array('selected' => 
$this->cat_id,'globals' => True)),
                                'select_action'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.index'),
                                'filter_list'                                   
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' => 
'yes')),
                                'lang_filter_statustext'                => 
lang('Select the filter. To show all entries select SHOW ALL'),
                                'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
                                'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
                                'query'                                         
        => $this->query,
                                'lang_submit'                                   
=> lang('submit'),
                                'table_header'                                  
=> $table_header,
                                'values'                                        
        => $content,
                                'table_add'                                     
        => $table_add
                        );

//print_r($data).'<br>';
//print_($menu);
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
                        $this->save_sessiondata();
                }

                function edit()
                {
                        $property_id    = 
get_var('property_id',array('POST','GET'));
                        $values                 = 
get_var('values',array('POST'));

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('property',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));

                        if ($values['save'])
                        {
                                if($property_id)
                                {
                                        $values['property_id']=$property_id;
                                        $action='edit';
                                }
                                else
                                {
                                        $property_id =  $values['property_id'];
                                }

                                $message = $this->bo->save($values,$action);
                        }

                        if ($property_id)
                        {
                                $property = 
$this->bo->read_single($property_id);
                                $function_msg = lang('edit property');
                                $action='edit';
                        }
                        else
                        {
                                $function_msg = lang('add property');
                                $action='add';
                        }

                        if ($property['cat_id'] > 0)
                        {
                                $this->cat_id = $property['cat_id'];
                        }
                        if ($property['part_of_town_id'] > 0)
                        {
                                $this->part_of_town_id = 
$property['part_of_town_id'];
                        }

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

                        $data = array
                        (
                                'appname'                                       
        => lang('property'),
                                'function_msg'                                  
=> $function_msg,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.index'),
                                'lang_property_id'                              
=> lang('Property ID'),
                                'lang_name'                                     
        => lang('name'),
                                'lang_generaladdress'                   => 
lang('General Address'),
                                'lang_generellinfo'                             
=> lang('General Info'),
                                'lang_category'                                 
=> lang('category'),
                                'lang_access'                                   
=> lang('private'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
                                'value_property_id'                             
=> $property_id,
                                'value_name'                                    
=> $property['name'],
                                'value_generaladdress'                  => 
$property['generaladdress'],
                                'value_access'                                  
=> $property['access'],
                                'value_cat'                                     
        => $property['cat'],
                                'message'                                       
        => $message,
                                'lang_property_id_statustext'   => lang('Enter 
the Property ID'),
                                'lang_name_statustext'                  => 
lang('Enter the name of the property'),
                                'lang_generaladdress_statustext'=> lang('Enter 
the general address'),
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the property'),
                                'lang_access_off_statustext'    => lang('The 
property is public. If the property should be private, check this box'),
                                'lang_access_on_statustext'             => 
lang('The property is private. If the property should be public, uncheck this 
box'),
                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the property belongs to. To do not use a category 
select NO CATEGORY'),
                                'select_name'                                   
=> 'values[cat_id]',
                                'lang_town_statustext'                  => 
lang('Select the part of town the property belongs to. To do not use a part of 
town -  select NO PART OF TOWN'),
                                'lang_part_of_town'                             
=> lang('Part of town'),
                                'lang_no_part_of_town'                  => 
lang('No part of town'),
                                'cat_list'                                      
        => $this->cats->formatted_xslt_list(array('format' => 
'select','selected' => $this->cat_id,'globals' => True)),
                                'part_of_town_list'                             
=> $this->bocommon->select_part_of_town('select',$this->part_of_town_id),
                                'select_name_part_of_town'              => 
'values[part_of_town_id]',
                                'area_id'                                       
        => $property['area_id'],
                                'part_of_town'                                  
=> $property['part_of_town'],
                                'property_type_id'                              
=> $property['property_type_id'],
                                'location_code'                                 
=> $property['location_code'],
                                'value_generellinfo'                    => 
$property['generellinfo']


                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
                }

                function delete()
                {
                        $property_id    = 
get_var('property_id',array('POST','GET'));
                        $confirm        = get_var('confirm',array('POST'));

                        $link_data = array
                        (
                                'menuaction' => 
$this->currentapp.'.uiproperty.index'
                        );

                        if (get_var('confirm',array('POST')))
                        {
                                $this->bo->delete($property_id);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                        }

                        
$GLOBALS['phpgw']->xslttpl->add_file(array($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_delete',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header'));

                        $data = array
                        (
                                'appname'                               => 
lang('property'),
                                'function_msg'                  => lang('delete 
property'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
                                'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.delete&property_id='
 . $property_id),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),
                                'lang_yes_statustext'   => lang('Delete the 
entry'),
                                'lang_no_statustext'    => lang('Back to the 
list'),
                                'lang_no'                               => 
lang('no')
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
                }

                function view()
                {
                        $property_id = get_var('property_id',array('GET'));

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('property',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));

                        $property = $this->bo->read_single($property_id);

                        $data = array
                        (
                                'appname'                       => 
lang('property'),
                                'function_msg'          => lang('view 
property'),
                                'done_action'           => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproperty.index'),
                                'lang_content'          => lang('content'),
                                'lang_category'         => lang('category'),
                                'lang_access'           => lang('access'),
                                'lang_time_created'     => lang('time created'),
                                'lang_done'                     => lang('done'),
                                'value_content'         => $property['content'],
                                'value_access'          => 
lang(ucfirst($property['access'])),
                                'value_cat'                     => 
$this->cats->id2name($property['cat']),
                                'value_date'            => 
$GLOBALS['phpgw']->common->show_date($property['date'])
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
                }
        }
?>

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * -------------------------------------------------                     
    *
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/
        class uistatus
        {
                var $grants;
                var $start;
                var $query;
                var $sort;
                var $order;
                var $sub;
                var $currentapp;

                var $public_functions = array
                (
                        'index'  => True,
                        'view'   => True,
                        'edit'   => True,
                        'delete' => True
                );

                function uistatus()
                {
                        $this->currentapp                       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->nextmatchs                       = 
CreateObject('phpgwapi.nextmatchs');
                        $this->account                          = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        $this->grants                           = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->grants[$this->account] = PHPGW_ACL_READ + 
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
                        $this->bo                                       = 
CreateObject($this->currentapp.'.bostatus');
                        $this->bocommon                         = 
CreateObject($this->currentapp.'.bocommon',True);

                        $this->start                            = 
$this->bo->start;
                        $this->query                            = 
$this->bo->query;
                        $this->sort                                     = 
$this->bo->sort;
                        $this->order                            = 
$this->bo->order;
                }

                function save_sessiondata()
                {
                        $data = array
                        (
                                'start'         => $this->start,
                                'query'         => $this->query,
                                'sort'          => $this->sort,
                                'order'         => $this->order,
                        );
                        $this->bocommon->save_sessiondata($data);
                }

                function index()
                {
                        $status_type    = 
get_var('status_type',array('POST','GET'));

                        $GLOBALS['phpgw']->xslttpl->add_file(array('status',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'nextmatchs'));

                        $status_list = $this->bo->read($status_type);

                        while (is_array($status_list) && list(,$status) = 
each($status_list))
                        {
                                $words = split(' ',$status['descr']);
                                $first = "$words[0] $words[1] $words[2] 
$words[3]";

                                $content[] = array
                                (
                                        'status_id'                             
        => $status['status_id'],
                                        'first'                                 
        => $first,
                                        'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistatus.edit&status_id='
 . $status['status_id'].'&status_type='.$status_type),
                                        'link_delete'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistatus.delete&status_id='
 . $status['status_id'].'&status_type='.$status_type),
                                        'lang_view_statustext'          => 
lang('view the status'),
                                        'lang_edit_statustext'          => 
lang('edit the status'),
                                        'lang_delete_statustext'        => 
lang('delete the status'),
                                        'text_view'                             
        => lang('view'),
                                        'text_edit'                             
        => lang('edit'),
                                        'text_delete'                           
=> lang('delete')
                                );
                        }

//_debug_array($content);

                        $table_header[] = array
                        (

                                'lang_descr'            => lang('Descr'),
                                'lang_edit'                     => lang('edit'),
                                'lang_delete'           => lang('delete'),
                                'sort_status_id'        => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   =>      'status',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uistatus.index',
                                                                                
                                                        'status_type'   
=>$status_type)
                                                                                
)),
                                'lang_status_id'        => lang('status id'),
                        );

                        $table_add[] = array
                        (
                                'lang_add'                              => 
lang('add'),
                                'lang_add_statustext'   => lang('add a status'),
                                'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistatus.edit&status_type='.$status_type),
                                'lang_done'                             => 
lang('done'),
                                'lang_done_statustext'  => lang('back to 
admin'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php')
                        );


                        $data = array
                        (
                                'allow_all_rows'                                
=> False,
                                'start_record'                                  
=> $this->start,
                                'record_limit'                                  
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
                                'num_records'                                   
=> count($status_list),
                                'all_records'                                   
=> $this->bo->total_records,
                                'link_url'                                      
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistatus.index&status_type='.$status_type),
                                'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi'),
                                'appname'                                       
        => lang($this->currentapp),
                                'function_msg'                                  
=> lang('list '.$status_type.' status'),
                                'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
                                'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
                                'query'                                         
        => $this->query,
                                'lang_submit'                                   
=> lang('submit'),
                                'table_header'                                  
=> $table_header,
                                'values'                                        
        => $content,
                                'table_add'                                     
        => $table_add
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
                        $this->save_sessiondata();
                }

                function edit()
                {
                        $status_type    = 
get_var('status_type',array('POST','GET'));
                        $status_id      = 
get_var('status_id',array('POST','GET'));
                        $values                 = 
get_var('values',array('POST'));

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('status',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));

                        if ($values['save'])
                        {
                                if($status_id)
                                {
                                        $values['status_id']=$status_id;
                                        $action='edit';
                                }
                                else
                                {
                                        $status_id =    $values['status_id'];
                                }


                                $message = 
$this->bo->save($values,$action,$status_type);
                        }

                        if ($status_id)
                        {
                                $status = 
$this->bo->read_single($status_id,$status_type);
                                $function_msg = lang('edit status');
                                $action='edit';
                        }
                        else
                        {
                                $function_msg = lang('add status');
                                $action='add';
                        }


                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uistatus.edit',
                                'status_id'     => $status_id,
                                'status_type' => $status_type
                        );
//_debug_array($link_data);
                        $data = array
                        (
                                'appname'                                       
        => lang('status'),
                                'function_msg'                                  
=> $function_msg,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistatus.index&status_type='.$status_type),
                                'lang_status_id'                                
=> lang('status ID'),
                                'lang_name'                                     
        => lang('name'),
                                'lang_descr'                                    
=> lang('Descr'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
                                'value_status_id'                               
=> $status_id,
                                'value_name'                                    
=> $status['name'],
                                'value_generaladdress'                  => 
$status['generaladdress'],
                                'message'                                       
        => $message,
                                'lang_status_id_statustext'     => lang('Enter 
the status ID'),
                                'lang_descr_statustext'                 => 
lang('Enter a description the status'),
                                'lang_generaladdress_statustext'=> lang('Enter 
the general address'),
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the status'),
                                'status_type_id'                                
=> $status['status_type_id'],
                                'location_code'                                 
=> $status['location_code'],
                                'value_descr'                                   
=> $status['descr']


                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
                }

                function delete()
                {
                        $status_type    = 
get_var('status_type',array('POST','GET'));
                        $status_id              = 
get_var('status_id',array('POST','GET'));
                        $confirm                = 
get_var('confirm',array('POST'));

                        $link_data = array
                        (
                                'menuaction' => 
$this->currentapp.'.uistatus.index',
                                'status_type' => $status_type
                        );

                        if (get_var('confirm',array('POST')))
                        {
                                $this->bo->delete($status_id,$status_type);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                        }

                        
$GLOBALS['phpgw']->xslttpl->add_file(array($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_delete',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header'));

                        $data = array
                        (
                                'appname'                               => 
lang('status'),
                                'function_msg'                  => lang('delete 
status'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
                                'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistatus.delete&status_id='
 . $status_id.'&status_type='.$status_type),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),
                                'lang_yes_statustext'   => lang('Delete the 
entry'),
                                'lang_no_statustext'    => lang('Back to the 
list'),
                                'lang_no'                               => 
lang('no')
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
                }

        }
?>








reply via email to

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