[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/class.socommon.php, 1.1.1.3
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/class.socommon.php, 1.1.1.3 |
Date: |
Fri, 21 May 2004 19:30:26 -0000 |
Update of /property
Modified Files:
Branch:
class.socommon.php
date: 2004/04/23 21:26:33; author: sigurdne; state: Exp; lines: +253 -253
Log Message:
no message
=====================================================================
Index: property/class.socommon.php
diff -u property/class.socommon.php:1.1.1.2 property/class.socommon.php:1.1.1.3
--- property/class.socommon.php:1.1.1.2 Fri Apr 23 20:25:41 2004
+++ property/class.socommon.php Fri Apr 23 21:26:33 2004
@@ -1,253 +1,253 @@
-<?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 property_socommon
- {
-
- function property_socommon()
- {
- $this->currentapp = 'property';
//$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account = $GLOBALS['phpgw_data']['user']['id'];
-
- if
($GLOBALS['phpgw_data']['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);
- $GLOBALS['phpgw']->db->Execute("INSERT INTO
fm_cache (name,value)VALUES ('$name','$value')");
- }
- else
- {
- $dbresult =
$GLOBALS['phpgw']->db->Execute("SELECT value FROM fm_cache where name='$name'");
- $value= unserialize($dbresult->fields['value']);
- return $value;
-
- }
- }
-
- function create_preferences($app='',$user_id='')
- {
- $dbresult =
$GLOBALS['phpgw']->db->Execute("SELECT preference_value FROM phpgw_preferences
where preference_app = '$app' AND preference_owner=".(int)$user_id );
-
- $value=
unserialize($dbresult->fields['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";
- $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
- while (!$dbresult->EOF)
- {
-
if($acl2->check($acl_location,$right,$dbresult->fields['acl_account']))
- {
-
if($dbresult->fields['account_type']=='g')
- {
- $members =
$myaccounts->member($dbresult->fields['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[$dbresult->fields['acl_account']] =
array($dbresult->fields['acl_account']);
- }
- }
- $dbresult->MoveNext();
- }
- 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];
- $dbresult =
$GLOBALS['phpgw']->db->Execute($sql);
-
- $employees[] = Array(
- 'account_id' =>
$dbresult->fields['account_id'],
- 'account_lid' =>
$dbresult->fields['account_lid'],
- 'account_type' =>
$dbresult->fields['account_type'],
- 'account_firstname' =>
$dbresult->fields['account_firstname'],
- 'account_lastname' =>
$dbresult->fields['account_lastname'],
- 'account_status' =>
$dbresult->fields['account_status'],
- 'account_expires' =>
$dbresult->fields['account_expires']
- );
- }
- return $employees;
- }
-
- function read_single_tenant($tenant_id)
- {
-
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_tenant WHERE tenant_id ='$tenant_id'");
-
-
- $tenant_data = array
- (
- 'first_name' =>
$dbresult->fields['first_name'],
- 'last_name' =>
$dbresult->fields['last_name'],
- 'contact_phone' =>
$dbresult->fields['contact_phone']
- );
-
-//html_print_r($tenant_data);
- return $tenant_data;
- }
-
- function check_location($location_code='',$type_id='')
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
count(*) FROM fm_location$type_id where location_code='$location_code'");
-
-
-
- if ( $dbresult->fields[0])
- {
- return True;
- }
- }
-
- function select_part_of_town()
- {
-
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
name, part_of_town_id FROM fm_part_of_town ORDER BY name ");
-
- $i = 0;
- while (!$dbresult->EOF)
- {
- $part_of_town[$i]['id'] =
$dbresult->fields['part_of_town_id'];
- $part_of_town[$i]['name'] =
stripslashes($dbresult->fields['name']);
- $i++;
- $dbresult->MoveNext();
- }
-
- return $part_of_town;
- }
-
- function select_district_list()
- {
-
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id,
descr FROM fm_district where id >'0' ORDER BY id ");
-
- $i = 0;
- while (!$dbresult->EOF)
- {
- $district[$i]['id']
= $dbresult->fields['id'];
- $district[$i]['name'] =
stripslashes($dbresult->fields['descr']);
- $i++;
- $dbresult->MoveNext();
- }
-//print_r($district);
- 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);
- }
-
- $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
max(id) as maximum FROM $table $where");
-
- $next_id = $dbresult->fields['maximum']+1;
- return "$next_id";
- }
-
- function get_lookup_entity($location)
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("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 (!$dbresult->EOF)
- {
- $entity[$i]['id']
= $dbresult->fields['entity_id'];
- $entity[$i]['name']
= $dbresult->fields['name'];
- $i++;
- $dbresult->MoveNext();
- }
- return $entity;
- }
-
- function get_start_entity($location)
- {
- $dbresult = $GLOBALS['phpgw']->db->Execute("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 (!$dbresult->EOF)
- {
- $entity[$i]['id']
= $dbresult->fields['entity_id'];
- $entity[$i]['name']
= $dbresult->fields['name'];
- $i++;
- $dbresult->MoveNext();
- }
- return $entity;
- }
-
-
-
- }
-?>
+<?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 property_socommon
+ {
+
+ function property_socommon()
+ {
+ $this->currentapp = 'property';
//$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->db = $GLOBALS['phpgw']->db;
+ $this->db2 = $this->db;
+ $this->account = $GLOBALS['phpgw_data']['user']['id'];
+
+ if
($GLOBALS['phpgw_data']['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);
+ $GLOBALS['phpgw']->db->Execute("INSERT INTO
fm_cache (name,value)VALUES ('$name','$value')");
+ }
+ else
+ {
+ $dbresult =
$GLOBALS['phpgw']->db->Execute("SELECT value FROM fm_cache where name='$name'");
+ $value= unserialize($dbresult->fields['value']);
+ return $value;
+
+ }
+ }
+
+ function create_preferences($app='',$user_id='')
+ {
+ $dbresult =
$GLOBALS['phpgw']->db->Execute("SELECT preference_value FROM phpgw_preferences
where preference_app = '$app' AND preference_owner=".(int)$user_id );
+
+ $value=
unserialize($dbresult->fields['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";
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+ while (!$dbresult->EOF)
+ {
+
if($acl2->check($acl_location,$right,$dbresult->fields['acl_account']))
+ {
+
if($dbresult->fields['account_type']=='g')
+ {
+ $members =
$myaccounts->member($dbresult->fields['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[$dbresult->fields['acl_account']] =
array($dbresult->fields['acl_account']);
+ }
+ }
+ $dbresult->MoveNext();
+ }
+ 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];
+ $dbresult =
$GLOBALS['phpgw']->db->Execute($sql);
+
+ $employees[] = Array(
+ 'account_id' =>
$dbresult->fields['account_id'],
+ 'account_lid' =>
$dbresult->fields['account_lid'],
+ 'account_type' =>
$dbresult->fields['account_type'],
+ 'account_firstname' =>
$dbresult->fields['account_firstname'],
+ 'account_lastname' =>
$dbresult->fields['account_lastname'],
+ 'account_status' =>
$dbresult->fields['account_status'],
+ 'account_expires' =>
$dbresult->fields['account_expires']
+ );
+ }
+ return $employees;
+ }
+
+ function read_single_tenant($tenant_id)
+ {
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT *
FROM fm_tenant WHERE tenant_id ='$tenant_id'");
+
+
+ $tenant_data = array
+ (
+ 'first_name' =>
$dbresult->fields['first_name'],
+ 'last_name' =>
$dbresult->fields['last_name'],
+ 'contact_phone' =>
$dbresult->fields['contact_phone']
+ );
+
+//html_print_r($tenant_data);
+ return $tenant_data;
+ }
+
+ function check_location($location_code='',$type_id='')
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
count(*) FROM fm_location$type_id where location_code='$location_code'");
+
+
+
+ if ( $dbresult->fields[0])
+ {
+ return True;
+ }
+ }
+
+ function select_part_of_town()
+ {
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
name, part_of_town_id FROM fm_part_of_town ORDER BY name ");
+
+ $i = 0;
+ while (!$dbresult->EOF)
+ {
+ $part_of_town[$i]['id'] =
$dbresult->fields['part_of_town_id'];
+ $part_of_town[$i]['name'] =
stripslashes($dbresult->fields['name']);
+ $i++;
+ $dbresult->MoveNext();
+ }
+
+ return $part_of_town;
+ }
+
+ function select_district_list()
+ {
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id,
descr FROM fm_district where id >'0' ORDER BY id ");
+
+ $i = 0;
+ while (!$dbresult->EOF)
+ {
+ $district[$i]['id']
= $dbresult->fields['id'];
+ $district[$i]['name'] =
stripslashes($dbresult->fields['descr']);
+ $i++;
+ $dbresult->MoveNext();
+ }
+//print_r($district);
+ 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);
+ }
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
max(id) as maximum FROM $table $where");
+
+ $next_id = $dbresult->fields['maximum']+1;
+ return "$next_id";
+ }
+
+ function get_lookup_entity($location)
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("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 (!$dbresult->EOF)
+ {
+ $entity[$i]['id']
= $dbresult->fields['entity_id'];
+ $entity[$i]['name']
= $dbresult->fields['name'];
+ $i++;
+ $dbresult->MoveNext();
+ }
+ return $entity;
+ }
+
+ function get_start_entity($location)
+ {
+ $dbresult = $GLOBALS['phpgw']->db->Execute("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 (!$dbresult->EOF)
+ {
+ $entity[$i]['id']
= $dbresult->fields['entity_id'];
+ $entity[$i]['name']
= $dbresult->fields['name'];
+ $i++;
+ $dbresult->MoveNext();
+ }
+ return $entity;
+ }
+
+
+
+ }
+?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/class.socommon.php, 1.1.1.3,
nomail <=