[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc class.socommon.inc.php
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] property/inc class.socommon.inc.php |
Date: |
Sat, 28 Jan 2006 12:59:32 +0000 |
CVSROOT: /sources/phpgroupware
Module name: property
Branch:
Changes by: Sigurd Nes <address@hidden> 06/01/28 12:59:32
Modified files:
inc : class.socommon.inc.php
Log message:
no message
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.socommon.inc.php.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
Patches:
Index: property/inc/class.socommon.inc.php
diff -u property/inc/class.socommon.inc.php:1.14
property/inc/class.socommon.inc.php:1.15
--- property/inc/class.socommon.inc.php:1.14 Fri Jan 27 14:05:43 2006
+++ property/inc/class.socommon.inc.php Sat Jan 28 12:59:32 2006
@@ -1,29 +1,27 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.socommon.inc.php,v 1.14 2006/01/27 14:05:43
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class socommon
- {
-
- function socommon()
- {
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
-// $this->db = $GLOBALS['phpgw']->db;
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.socommon.inc.php,v 1.15 2006/01/28 12:59:32
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class socommon
+ {
+ function socommon()
+ {
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->db = CreateObject('phpgwapi.db');
$this->db->Host =
$GLOBALS['phpgw_info']['server']['db_host'];
$this->db->Type =
$GLOBALS['phpgw_info']['server']['db_type'];
@@ -31,302 +29,302 @@
$this->db->User =
$GLOBALS['phpgw_info']['server']['db_user'];
$this->db->Password =
$GLOBALS['phpgw_info']['server']['db_pass'];
-// $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
- {
- $this->join = " JOIN ";
- $this->like = "ILIKE";
- }
- else
- {
- $this->join = " INNER JOIN ";
- $this->like = "LIKE";
- }
-
- $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 account_status =
'A' AND acl_location $this->like '%$acl_location%' order by account_lastname
ASC";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
+ {
+ $this->join = " JOIN ";
+ $this->like = "ILIKE";
+ }
+ else
+ {
+ $this->join = " INNER JOIN ";
+ $this->like = "LIKE";
+ }
+
+ $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 account_status =
'A' AND acl_location $this->like '%$acl_location%' order by account_lastname
ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
{
$active_accounts[] = array(
'acl_account' =>
$this->db->f('acl_account'),
'account_id' =>
$this->db->f('account_id'),
- 'account_type' =>
$this->db->f('account_type'),
+ 'account_type' =>
$this->db->f('account_type'),
);
}
-
- foreach ($active_accounts as $entry)
+
+ foreach ($active_accounts as $entry)
{
-
if($acl2->check($acl_location,$right,$entry['acl_account']))
- {
- if($entry['account_type']=='g')
- {
- $members =
$myaccounts->member($entry['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[$entry['acl_account']] = array($entry['acl_account']);
- }
- }
- }
-
+
if($acl2->check($acl_location,$right,$entry['acl_account']))
+ {
+ if($entry['account_type']=='g')
+ {
+ $members =
$myaccounts->member($entry['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[$entry['acl_account']] = array($entry['acl_account']);
+ }
+ }
+ }
+
unset($active_accounts);
- unset($myaccounts);
-
- $sql = "SELECT account_id FROM phpgw_accounts WHERE
account_status = 'I'";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- unset($accounts[$this->db->f('account_id')]);
- }
-
- 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++)
- {
- $in_list[] = $accounts[$i];
- }
-
- if($in_list)
- {
- $sql = 'SELECT * FROM phpgw_accounts where
account_id in ('. implode(',',$in_list) . ') order by account_lastname';
- $this->db->query($sql,__LINE__,__FILE__);
- while ($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')
- );
-
- }
- }
-/* 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;
- }
-
- function increment_id($name)
- {
- $this->db->query("SELECT value FROM fm_idgenerator
WHERE name='$name'");
- $this->db->next_record();
- $next_id=$this->db->f('value') +1;
-
- $this->db->query("update fm_idgenerator set value =
$next_id WHERE name = 'workorder'");
- return $next_id;
- }
-
- function select_wo_hours_category_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_wo_hours_category ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $category_list[$i]['id'] = $this->db->f('id');
- $category_list[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
- return $category_list;
+ unset($myaccounts);
+
+ $sql = "SELECT account_id FROM phpgw_accounts WHERE
account_status = 'I'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ unset($accounts[$this->db->f('account_id')]);
+ }
+
+ 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++)
+ {
+ $in_list[] = $accounts[$i];
+ }
+
+ if($in_list)
+ {
+ $sql = 'SELECT * FROM phpgw_accounts where
account_id in ('. implode(',',$in_list) . ') order by account_lastname';
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($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')
+ );
+
+ }
+ }
+/* 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 new_db()
- {
$db = CreateObject('phpgwapi.db');
+ 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;
+ }
+
+ function increment_id($name)
+ {
+ $this->db->query("SELECT value FROM fm_idgenerator
WHERE name='$name'");
+ $this->db->next_record();
+ $next_id=$this->db->f('value') +1;
+
+ $this->db->query("update fm_idgenerator set value =
$next_id WHERE name = 'workorder'");
+ return $next_id;
+ }
+
+ function select_wo_hours_category_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_wo_hours_category ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $category_list[$i]['id'] = $this->db->f('id');
+ $category_list[$i]['name'] =
stripslashes($this->db->f('descr'));
+ $i++;
+ }
+
+ return $category_list;
+ }
+
+ function new_db()
+ {
+ $db = CreateObject('phpgwapi.db');
$db->Host = $GLOBALS['phpgw_info']['server']['db_host'];
$db->Type = $GLOBALS['phpgw_info']['server']['db_type'];
$db->Database =
$GLOBALS['phpgw_info']['server']['db_name'];
$db->User = $GLOBALS['phpgw_info']['server']['db_user'];
$db->Password =
$GLOBALS['phpgw_info']['server']['db_pass'];
- return $db;
- }
- }
-?>
+ return $db;
+ }
+ }
+?>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc class.socommon.inc.php,
Sigurd Nes <=