[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: |
Dave Hall |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.custom_fields.inc.php |
Date: |
Mon, 09 Oct 2006 15:02:16 +0000 |
CVSROOT: /sources/phpgwapi
Module name: phpgwapi
Changes by: Dave Hall <skwashd> 06/10/09 15:02:16
Modified files:
inc : class.custom_fields.inc.php
Log message:
notices and other minor fixes
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.custom_fields.inc.php?cvsroot=phpgwapi&r1=1.8&r2=1.9
Patches:
Index: class.custom_fields.inc.php
===================================================================
RCS file: /sources/phpgwapi/phpgwapi/inc/class.custom_fields.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- class.custom_fields.inc.php 9 Oct 2006 13:45:37 -0000 1.8
+++ class.custom_fields.inc.php 9 Oct 2006 15:02:16 -0000 1.9
@@ -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.8 2006/10/09 13:45:37
sigurdne Exp $
+ * @version $Id: class.custom_fields.inc.php,v 1.9 2006/10/09 15:02:16
skwashd Exp $
*/
/**
@@ -97,10 +97,15 @@
*/
function add_attrib($attrib)
{
+ // Checkboxes are only present if ticked, so we declare
them here to stop errors
+ $attrib['search'] = isset($attrib['search']) ?
!!$attrib['search'] : false;
+ $attrib['list'] = isset($attrib['list']) ?
!!$attrib['list'] : false;
+ $attrib['history'] = isset($attrib['history']) ?
!!$attrib['history'] : false;
+
$attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
$attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
$attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes((isset($attrib['default'])?$attrib['default']:''));
+ $attrib['default'] = isset($arrib['default']) ?
$this->db->db_addslashes($attrib['default']) : '';
$this->db->transaction_begin();
$sql = 'SELECT MAX(attrib_sort) AS max_sort, MAX(id) AS
current_id FROM phpgw_cust_attribute'
@@ -112,7 +117,7 @@
if($attrib['column_info']['type']=='R' ||
$attrib['column_info']['type']== 'CH' || $attrib['column_info']['type'] =='LB'
|| $attrib['column_info']['type'] =='AB' || $attrib['column_info']['type']
=='VENDOR')
{
- if ($attrib['history'])
+ if ( $attrib['history'] )
{
$receipt['error'][] = array('msg'
=> lang('History not allowed for this datatype'));
}
@@ -120,7 +125,8 @@
$attrib['history'] = false;
}
- $values= array(
+ $values= array
+ (
$attrib['appname'],
$attrib['location'],
$attrib['id'],
@@ -140,7 +146,6 @@
$values = $this->db->validate_insert($values);
-
$this->db->query("INSERT INTO phpgw_cust_attribute
(appname,location,id,column_name, input_text,
statustext,search,list,history,attrib_sort,
datatype,precision_,scale,default_value,nullable) "
. "VALUES ($values)",__LINE__,__FILE__);
@@ -217,7 +222,8 @@
$this->db->next_record();
$custom_sort = $this->db->f('max_sort')+1;
- $values= array(
+ $values= array
+ (
$appname,
$location,
$custom_function['id'],
@@ -268,6 +274,11 @@
*/
function edit_attrib($attrib)
{
+ // Checkboxes are only present if ticked, so we declare
them here to stop errors
+ $attrib['search'] = isset($attrib['search']) ?
!!$attrib['search'] : false;
+ $attrib['list'] = isset($attrib['list']) ?
!!$attrib['list'] : false;
+ $attrib['history'] = isset($attrib['history']) ?
!!$attrib['history'] : false;
+
$attrib_table =
$this->get_attrib_table($attrib['appname'],$attrib['location']);
$choice_table = 'phpgw_cust_choice';
@@ -396,6 +407,9 @@
}
+ /**
+ * @internal TODO document me :)
+ */
function edit_custom_function($custom_function)
{
if(!$custom_function['location'] ||
!$custom_function['appname'])
@@ -524,6 +538,11 @@
return $attribs;
}
+ /**
+ * Read a single attribute record
+ *
+ * @internal TODO document me
+ */
function get_attrib_single($appname, $location, $id,
$inc_choices = false)
{
$appname = $this->db->db_addslashes($appname);
@@ -563,25 +582,34 @@
}
}
+ /**
+ * Get the name of a table for a location
+ *
+ * @internal document me
+ * @return string the name of the table
+ */
function get_attrib_table($appname,$location)
{
$sql = "SELECT c_attrib_table FROM phpgw_acl_location
WHERE appname='$appname' AND id='$location'";
$this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
+ if ( $this->db->next_record() )
+ {
return $this->db->f('c_attrib_table');
}
+ return '';
+ }
function read_custom_function($data = array())
{
if(is_array($data))
{
$start = isset($data['start']) ?
(int)$data['start'] : 0;
- $query =
$this->db->db_addslashes(isset($data['query']) ? $data['query'] : '');
- $sort =
$this->db->db_addslashes(isset($data['sort']) && $data['sort'] == 'ASC' ? 'ASC'
: 'DESC');
- $order =
$this->db->db_addslashes(isset($data['order']) ? $data['order'] : '');
- $allrows =
$this->db->db_addslashes(isset($data['allrows']) ? $data['allrows'] : false);
- $appname =
$this->db->db_addslashes(isset($data['appname']) ? $data['appname'] : '');
- $location =
$this->db->db_addslashes(isset($data['location']) ? $data['location'] : '');
+ $query = isset($data['query']) ?
$this->db->db_addslashes($data['query']) : '';
+ $sort = ($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']) : '';
+ $location = isset($data['location']) ?
$this->db->db_addslashes($data['location']) : '';
}
else
{
@@ -593,15 +621,12 @@
return array();
}
+ $ordermethod = ' ORDER BY custom_sort ASC';
if ($order)
{
$ordermethod = " ORDER BY $order $sort";
}
- else
- {
- $ordermethod = ' ORDER BY custom_sort ASC';
- }
$table = 'phpgw_cust_function';
@@ -665,7 +690,7 @@
$location = $this->db->db_addslashes($location);
$id = (int)$id;
- $sql = "SELECT * FROM phpgw_cust_function where
appname='$appname' AND location='$location' AND id = $id";
+ $sql = "SELECT * FROM phpgw_cust_function WHERE
appname='$appname' AND location='$location' AND id = $id";
$this->db->query($sql,__LINE__,__FILE__);