[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc/class.socommon.inc.php, 1.2
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/inc/class.socommon.inc.php, 1.2 |
Date: |
Wed, 2 Jun 2004 20:54:28 +0200 |
Update of /property/inc
Added Files:
Branch:
class.socommon.inc.php
date: 2004/06/02 18:54:28; author: sigurdne; state: Exp; lines: +248 -0
Log Message:
no message
=====================================================================
<?php
/**************************************************************************\
* phpGroupWare - property
*
* http://www.phpgroupware.org
*
*
*
* Facilities Management
*
* Written by Sigurd Nes [sigurdne at online.no]
*
*
------------------------------------------------------------------------ *
* Copyright 2000 - 2003 Free Software Foundation, Inc
*
* This program is part of the GNU project, see http://www.gnu.org/
*
*
------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\**************************************************************************/
class socommon
{
function socommon()
{
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->db = $GLOBALS['phpgw']->db;
$this->db2 = $this->db;
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
{
$this->join = " JOIN ";
}
else
{
$this->join = " INNER JOIN ";
// $this->join = " LEFT JOIN ";
}
$this->left_join = " LEFT JOIN ";
}
function fm_cache($name='',$value='')
{
if($value)
{
$value = serialize($value);
$this->db->query("INSERT INTO fm_cache
(name,value)VALUES ('$name','$value')",__LINE__,__FILE__);
}
else
{
$this->db->query("SELECT value FROM fm_cache
where name='$name'");
$this->db->next_record();
$value= unserialize($this->db->f('value'));
return $value;
}
}
function create_preferences($app='',$user_id='')
{
$this->db->query("SELECT preference_value FROM
phpgw_preferences where preference_app = '$app' AND
preference_owner=".(int)$user_id );
$this->db->next_record();
$value=
unserialize($this->db->f('preference_value'));
return $value;
}
function get_user_list_right($right='',$acl_location='')
{
$acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
$myaccounts = CreateObject('phpgwapi.accounts');
while($my_memberships && list($key,$group) =
each($my_memberships))
{
$security .= "," . $group['account_id'];
}
$sql = "SELECT * FROM phpgw_accounts $this->join
fm_acl2 on phpgw_accounts.account_id=fm_acl2.acl_account where acl_location
LIKE '%$acl_location%' order by account_lastname ASC";
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
if($acl2->check($acl_location,$right,$this->db->f('acl_account')))
{
if($this->db->f('account_type')=='g')
{
$members =
$myaccounts->member($this->db->f('account_id'));
if (isset($members) AND
is_array($members))
{
foreach($members as
$user)
{
$accounts[$user['account_id']] = array($user['account_id']);
}
unset($members);
}
}
else
{
$accounts[$this->db->f('acl_account')] = array($this->db->f('acl_account'));
}
}
}
unset($myaccounts);
if (isset($accounts) AND is_array($accounts))
{
foreach($accounts as $account_id)
{
$i=0;
if(!$acl2->check($acl_location,$right,$account_id[0]))
{
unset($accounts[$account_id[0]]);
}
$i++;
}
}
address@hidden($accounts);
$k=count($accounts);
for ($i=0;$i<$k;$i++)
{
$sql = 'SELECT * FROM phpgw_accounts where
account_id=' . (int)$accounts[$i];
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
$employees[] = Array(
'account_id' =>
$this->db->f('account_id'),
'account_lid' =>
$this->db->f('account_lid'),
'account_type' =>
$this->db->f('account_type'),
'account_firstname' =>
$this->db->f('account_firstname'),
'account_lastname' =>
$this->db->f('account_lastname'),
'account_status' =>
$this->db->f('account_status'),
'account_expires' =>
$this->db->f('account_expires')
);
}
return $employees;
}
function read_single_tenant($id)
{
$this->db->query("SELECT * FROM fm_tenant WHERE id
=$id",__LINE__,__FILE__);
$this->db->next_record();
$tenant_data = array
(
'first_name' =>
$this->db->f('first_name'),
'last_name' =>
$this->db->f('last_name'),
'contact_phone' =>
$this->db->f('contact_phone')
);
//_debug_array($tenant_data);
return $tenant_data;
}
function check_location($location_code='',$type_id='')
{
$this->db->query("SELECT count(*) FROM
fm_location$type_id where location_code='$location_code'");
$this->db->next_record();
if ( $this->db->f(0))
{
return True;
}
}
function select_part_of_town()
{
$this->db->query("SELECT name, part_of_town_id FROM
fm_part_of_town ORDER BY name ");
$i = 0;
while ($this->db->next_record())
{
$part_of_town[$i]['id'] =
$this->db->f('part_of_town_id');
$part_of_town[$i]['name'] =
stripslashes($this->db->f('name'));
$i++;
}
return $part_of_town;
}
function select_district_list()
{
$this->db->query("SELECT id, descr FROM fm_district
where id >'0' ORDER BY id ");
$i = 0;
while ($this->db->next_record())
{
$district[$i]['id']
= $this->db->f('id');
$district[$i]['name']
= stripslashes($this->db->f('descr'));
$i++;
}
return $district;
}
function next_id($table='',$key='')
{
if(is_array($key))
{
while (is_array($key) && list($column,$value) =
each($key))
{
if($value)
{
$condition[] = $column . '=' .
$value;
}
}
$where=' WHERE ' . implode(" AND ", $condition);
}
$this->db->query("SELECT max(id) as maximum FROM $table
$where",__LINE__,__FILE__);
$this->db->next_record();
$next_id = $this->db->f('maximum')+1;
return "$next_id";
}
function get_lookup_entity($location)
{
$this->db->query("SELECT entity_id,name FROM
fm_entity_lookup $this->join fm_entity on
fm_entity_lookup.entity_id=fm_entity.id WHERE type='lookup' AND
location='$location' ");
$i = 0;
while ($this->db->next_record())
{
$entity[$i]['id']
= $this->db->f('entity_id');
$entity[$i]['name']
= $this->db->f('name');
$i++;
}
return $entity;
}
function get_start_entity($location)
{
$this->db->query("SELECT entity_id,name FROM
fm_entity_lookup $this->join fm_entity on
fm_entity_lookup.entity_id=fm_entity.id WHERE type='start' AND
location='$location' ");
$i = 0;
while ($this->db->next_record())
{
$entity[$i]['id']
= $this->db->f('entity_id');
$entity[$i]['name']
= $this->db->f('name');
$i++;
}
return $entity;
}
}
?>
- [Phpgroupware-cvs] property/inc/class.socommon.inc.php, 1.2,
nomail <=