[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc class.custom_fields.inc.php
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.custom_fields.inc.php |
Date: |
Mon, 09 Oct 2006 17:11:10 +0000 |
CVSROOT: /sources/phpgwapi
Module name: phpgwapi
Changes by: Sigurd Nes <sigurdne> 06/10/09 17:11:10
Modified files:
inc : class.custom_fields.inc.php
Log message:
fix next_id
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.custom_fields.inc.php?cvsroot=phpgwapi&r1=1.9&r2=1.10
Patches:
Index: class.custom_fields.inc.php
===================================================================
RCS file: /sources/phpgwapi/phpgwapi/inc/class.custom_fields.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- class.custom_fields.inc.php 9 Oct 2006 15:02:16 -0000 1.9
+++ class.custom_fields.inc.php 9 Oct 2006 17:11:10 -0000 1.10
@@ -8,7 +8,7 @@
* @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 phpgwapi
- * @version $Id: class.custom_fields.inc.php,v 1.9 2006/10/09 15:02:16
skwashd Exp $
+ * @version $Id: class.custom_fields.inc.php,v 1.10 2006/10/09 17:11:10
sigurdne Exp $
*/
/**
@@ -80,6 +80,7 @@
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
$this->db = clone($GLOBALS['phpgw']->db); //
clone to awoid conflict the db in lang-function
+ $this->db2 = clone($this->db);
$this->join = $this->db->join;
$this->like = $this->db->like;
@@ -375,7 +376,7 @@
if(isset($attrib['new_choice']) &&
$attrib['new_choice'])
{
- $choice_id =
$this->bocommon->next_id($choice_table
,array('appname'=>$attrib['appname'],'location'=>$attrib['location'],'attrib_id'=>$attrib['id']));
+ $choice_id = $this->next_id($choice_table
,array('appname'=>$attrib['appname'],'location'=>$attrib['location'],'attrib_id'=>$attrib['id']));
$values= array(
$attrib['appname'],
@@ -543,7 +544,7 @@
*
* @internal TODO document me
*/
- function get_attrib_single($appname, $location, $id,
$inc_choices = false)
+ function get_attrib_single($appname, $location, $id,
$inc_choices = true)
{
$appname = $this->db->db_addslashes($appname);
$location = $this->db->db_addslashes($location);
@@ -1013,5 +1014,35 @@
$this->oProc->m_odb =& $this->db;
$this->oProc->m_odb->Halt_On_Error = 'report';
}
+
+ /**
+ * Finds the next ID for a record at a table
+ *
+ * @param string $table tablename in question
+ * @param array $key conditions
+ * @return int the next id
+ */
+
+ function next_id($table='',$key='')
+ {
+ $where = '';
+ if(is_array($key))
+ {
+ while (is_array($key) && list($column,$value) =
each($key))
+ {
+ if($value)
+ {
+ $condition[] = $column . "='" .
$value;
+ }
+ }
+
+ $where='WHERE ' . implode("' AND ", $condition)
. "'";
+ }
+
+ $this->db2->query("SELECT max(id) as maximum FROM
$table $where",__LINE__,__FILE__);
+ $this->db2->next_record();
+ $next_id = $this->db2->f('maximum')+1;
+ return $next_id;
+ }
}
?>