[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: |
Sun, 19 Nov 2006 19:04:33 +0000 |
CVSROOT: /sources/phpgwapi
Module name: phpgwapi
Changes by: Sigurd Nes <sigurdne> 06/11/19 19:04:33
Modified files:
inc : class.custom_fields.inc.php
Log message:
partially updated for custom fields and custom funtions
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.custom_fields.inc.php?cvsroot=phpgwapi&r1=1.12&r2=1.13
Patches:
Index: class.custom_fields.inc.php
===================================================================
RCS file: /sources/phpgwapi/phpgwapi/inc/class.custom_fields.inc.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- class.custom_fields.inc.php 10 Oct 2006 11:33:39 -0000 1.12
+++ class.custom_fields.inc.php 19 Nov 2006 19:04:33 -0000 1.13
@@ -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.12 2006/10/10 11:33:39
skwashd Exp $
+ * @version $Id: class.custom_fields.inc.php,v 1.13 2006/11/19 19:04:33
sigurdne Exp $
*/
/**
@@ -635,13 +635,13 @@
return '';
}
- function read_custom_function($data = array())
+ function read_custom_function($data = '')
{
if(is_array($data))
{
$start = isset($data['start']) ?
(int)$data['start'] : 0;
$query = isset($data['query']) ?
$this->db->db_addslashes($data['query']) : '';
- $sort = ($data['sort'] && $data['sort'] ==
'ASC') ? 'ASC' : 'DESC';
+ $sort = (isset($data['sort']) && $data['sort']
== 'ASC') ? 'ASC' : 'DESC';
$order = isset($data['order']) ?
$this->db->db_addslashes($data['order']) : '';
$allrows = isset($data['allrows']) ?
!!$data['allrows'] : false;
$appname = isset($data['appname']) ?
$this->db->db_addslashes($data['appname']) : '';
@@ -666,6 +666,7 @@
$table = 'phpgw_cust_function';
+ $querymethod = '';
if($query)
{
$querymethod = " AND file_name $this->like
'%$query%' OR descr $this->like '%$query%'";
@@ -1065,5 +1066,176 @@
$next_id = $this->db2->f('maximum')+1;
return $next_id;
}
+
+ /**
+ * Prepare custom attributes for ui
+ *
+ * @param array $values values and definitions of custom
attributes
+ * @return array values and definitions of custom attributes
prepared for ui
+ */
+
+ function prepare_attributes($values='',$appname, $location)
+ {
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $input_type_array = array(
+ 'R' => 'radio',
+ 'CH' => 'checkbox',
+ 'LB' => 'listbox'
+ );
+
+ $sep = '/';
+ $dlarr[strpos($dateformat,'Y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $m=0;
+ for ($i=0;$i<count($values['attributes']);$i++)
+ {
+ $values['attributes'][$i]['datatype_text']
= $this->translate_datatype($values['attributes'][$i]['datatype']);
+ if($values['attributes'][$i]['datatype']=='D'
&& $values['attributes'][$i]['value'])
+ {
+ $timestamp_date=
mktime(0,0,0,date(m,strtotime($values['attributes'][$i]['value'])),date(d,strtotime($values['attributes'][$i]['value'])),date(y,strtotime($values['attributes'][$i]['value'])));
+ $values['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
+ }
+ if($values['attributes'][$i]['datatype']=='AB')
+ {
+ if($values['attributes'][$i]['value'])
+ {
+ $contact_data =
$contacts->read_single_entry($values['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$values['attributes'][$i]['contact_name'] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
+ }
+
+ $insert_record_values[] =
$values['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
$this->currentapp.'.uilookup.addressbook', 'column'=>
$values['attributes'][$i]['name']));
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $values['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+/*
if($values['attributes'][$i]['datatype']=='VENDOR')
+ {
+ if($values['attributes'][$i]['value'])
+ {
+ $vendor_data =
$vendor->read_single(array('values_id'=>$values['attributes'][$i]['value']));
+
+ for
($n=0;$n<count($vendor_data['attributes']);$n++)
+ {
+
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+ {
+
$values['attributes'][$i]['vendor_name']=
$vendor_data['attributes'][$n]['value'];
+ $n
=count($vendor_data['attributes']);
+ }
+ }
+ }
+
+ $insert_record_values[] =
$values['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
$this->currentapp.'.uilookup.vendor', 'column'=>
$values['attributes'][$i]['name']));
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $values['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+*/
+
if($values['attributes'][$i]['datatype']=='user')
+ {
+ if($values['attributes'][$i]['value'])
+ {
+
$values['attributes'][$i]['user_name']=
$GLOBALS['phpgw']->accounts->id2name($values['attributes'][$i]['value']);
+ }
+
+ $insert_record_values[] =
$values['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
$this->currentapp.'.uilookup.phpgw_user', 'column'=>
$values['attributes'][$i]['name']));
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $values['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
+ if($values['attributes'][$i]['datatype']=='R'
|| $values['attributes'][$i]['datatype']=='CH' ||
$values['attributes'][$i]['datatype']=='LB')
+ {
+ $values['attributes'][$i]['choice']
= $this->so->read_attrib_choice($appname,
$location,$values['attributes'][$i]['attrib_id']);
+
$input_type=$input_type_array[$values['attributes'][$i]['datatype']];
+
+
if($values['attributes'][$i]['datatype']=='CH')
+ {
+
$values['attributes'][$i]['value']=unserialize($values['attributes'][$i]['value']);
+
$values['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($values['attributes'][$i]['value'],$values['attributes'][$i]['choice'],$input_type);
+
+ }
+ else
+ {
+ for
($j=0;$j<count($values['attributes'][$i]['choice']);$j++)
+ {
+
$values['attributes'][$i]['choice'][$j]['input_type']=$input_type;
+
if($values['attributes'][$i]['choice'][$j]['id']==$values['attributes'][$i]['value'])
+ {
+
$values['attributes'][$i]['choice'][$j]['checked']='checked';
+ }
+ }
+ }
+ }
+
+ $values['attributes'][$i]['datatype_text'] =
$this->translate_datatype($values['attributes'][$i]['datatype']);
+ $values['attributes'][$i]['counter'] = $i;
+// $values['attributes'][$i]['type_id'] =
$data['type_id'];
+ }
+
+ if(isset($lookup_functions) &&
is_array($lookup_functions))
+ {
+ for ($j=0;$j<count($lookup_functions);$j++)
+ {
+ $values['lookup_functions'] .=
'function ' . $lookup_functions[$j]['name'] ."\r\n";
+ $values['lookup_functions'] .=
'{'."\r\n";
+ $values['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
+ $values['lookup_functions'] .=
'}'."\r\n";
+ }
+ }
+
+ if(isset($lookup_functions) && $lookup_functions)
+ {
+
$GLOBALS['phpgw']->session->appsession('insert_record_values' .
$location,$appname,$insert_record_values);
+ }
+
+//_debug_array($values);
+ return $values;
+ }
+
+ /**
+ * Preserve attribute values from post in case of an error
+ *
+ * @param array $values_attribute attribute definition and
values from posting
+ * @param array $values value set with
+ * @return array Array with attribute definition and values
+ */
+ function preserve_attribute_values($values,$values_attribute)
+ {
+ foreach ( $values_attribute as $key => $attribute )
+ {
+ for ($i=0;$i<count($values['attributes']);$i++)
+ {
+
if($values['attributes'][$i]['attrib_id'] == $attribute['attrib_id'])
+ {
+
$values['attributes'][$i]['value'] = $attribute['value'];
+
+
if(isset($values['attributes'][$i]['choice']) &&
is_array($values['attributes'][$i]['choice']))
+ {
+ for
($j=0;$j<count($values['attributes'][$i]['choice']);$j++)
+ {
+
if($values['attributes'][$i]['choice'][$j]['id'] == $attribute['value'])
+ {
+
$values['attributes'][$i]['choice'][$j]['checked'] = 'checked';
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $values;
+ }
}
?>
- [Phpgroupware-cvs] phpgwapi/inc class.custom_fields.inc.php,
Sigurd Nes <=