[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi inc/class.config.inc.php inc/class.con...
From: |
Dave Hall |
Subject: |
[Phpgroupware-cvs] phpgwapi inc/class.config.inc.php inc/class.con... |
Date: |
Wed, 19 Jul 2006 01:40:12 +0000 |
CVSROOT: /cvsroot/phpgwapi
Module name: phpgwapi
Changes by: Dave Hall <skwashd> 06/07/19 01:40:12
Modified files:
inc : class.config.inc.php class.contacts_sql.inc.php
class.categories.inc.php
class.validator.inc.php class.sql.inc.php
class.jscalendar.inc.php
class.custom_fields.inc.php
inc/accounts : class.accounts_.inc.php
templates/idots: head.inc.php navbar.inc.php
templates/idots/css: idots.css
templates/idots/source: navbar32.xcf
Log message:
cleanups and code tweaks from person version
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.config.inc.php?cvsroot=phpgwapi&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.contacts_sql.inc.php?cvsroot=phpgwapi&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.categories.inc.php?cvsroot=phpgwapi&r1=1.126&r2=1.127
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.validator.inc.php?cvsroot=phpgwapi&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.sql.inc.php?cvsroot=phpgwapi&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.jscalendar.inc.php?cvsroot=phpgwapi&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.custom_fields.inc.php?cvsroot=phpgwapi&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/accounts/class.accounts_.inc.php?cvsroot=phpgwapi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/templates/idots/head.inc.php?cvsroot=phpgwapi&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/templates/idots/navbar.inc.php?cvsroot=phpgwapi&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/templates/idots/css/idots.css?cvsroot=phpgwapi&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/templates/idots/source/navbar32.xcf?cvsroot=phpgwapi&rev=1.7
Patches:
Index: inc/class.config.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.config.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- inc/class.config.inc.php 2 May 2005 16:38:57 -0000 1.11
+++ inc/class.config.inc.php 19 Jul 2006 01:40:11 -0000 1.12
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General
Public License
* @package phpgwapi
* @subpackage application
- * @version $Id: class.config.inc.php,v 1.11 2005/05/02 16:38:57
fipsfuchs Exp $
+ * @version $Id: class.config.inc.php,v 1.12 2006/07/19 01:40:11 skwashd
Exp $
*/
/**
@@ -27,24 +27,25 @@
{
$appname =
$GLOBALS['phpgw_info']['flags']['currentapp'];
}
-
- $this->db = $GLOBALS['phpgw']->db;
- $this->appname = $appname;
+ $this->db =& $GLOBALS['phpgw']->db;
+ $this->appname = $this->db->db_addslashes($appname);
}
function read_repository()
{
- $this->db->query("select * from phpgw_config where
config_app='" . $this->appname . "'",__LINE__,__FILE__);
+ $this->config_data = array();
+
+ $this->db->query("SELECT * FROM phpgw_config WHERE
config_app='{$this->appname}'",__LINE__,__FILE__);
while ($this->db->next_record())
{
- $test =
@unserialize($this->db->f('config_value'));
+ $test =
@unserialize($this->db->f('config_value', true));
if($test)
{
$this->config_data[$this->db->f('config_name')] = $test;
}
else
{
-
$this->config_data[$this->db->f('config_name')] = $this->db->f('config_value');
+
$this->config_data[$this->db->f('config_name')] = $this->db->f('config_value',
true);
}
}
}
@@ -53,15 +54,17 @@
{
$config_data = $this->config_data;
- if ($config_data)
+ if ( is_array($config_data) && count($config_data) )
{
$this->db->lock(array('phpgw_config','phpgw_app_sessions'));
- $this->db->query("delete from phpgw_config
where config_app='" . $this->appname . "'",__LINE__,__FILE__);
+ $this->delete_repository();
if($this->appname == 'phpgwapi')
{
- $this->db->query("delete from
phpgw_app_sessions where sessionid = '0' and loginid = '0' and app =
'".$this->appname."' and location = 'config'",__LINE__,__FILE__);
+ $this->db->query('DELETE FROM
phpgw_app_sessions'
+ . "
WHERE sessionid = '0' and loginid = '0' and app = '{$this->appname}' AND
location = 'config'",
+
__LINE__,__FILE__);
}
- while (list($name,$value) = each($config_data))
+ foreach ( $config_data as $name => $value )
{
if(is_array($value))
{
@@ -69,10 +72,9 @@
}
$name =
$this->db->db_addslashes($name);
$value =
$this->db->db_addslashes($value);
- $this->db->query("delete from
phpgw_config where config_name='" . $name . "'",__LINE__,__FILE__);
- $query = "insert into phpgw_config
(config_app,config_name,config_value) "
- . "values ('" . $this->appname
. "','" . $name . "','" . $value . "')";
-
$this->db->query($query,__LINE__,__FILE__);
+ $query = "INSERT INTO phpgw_config
(config_app,config_name,config_value) "
+ . "VALUES ('{$this->appname}',
'{$name}', '{$value}')";
+ $this->db->query($query, __LINE__,
__FILE__);
}
$this->db->unlock();
}
@@ -80,7 +82,7 @@
function delete_repository()
{
- $this->db->query("delete from phpgw_config where
config_app='" . $this->appname . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM phpgw_config WHERE
config_app='{$this->appname}'",__LINE__,__FILE__);
}
function value($variable_name,$variable_data)
Index: inc/class.contacts_sql.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.contacts_sql.inc.php,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- inc/class.contacts_sql.inc.php 30 Dec 2004 06:47:30 -0000 1.25
+++ inc/class.contacts_sql.inc.php 19 Jul 2006 01:40:11 -0000 1.26
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package phpgwapi
* @subpackage contacts
- * @version $Id: class.contacts_sql.inc.php,v 1.25 2004/12/30 06:47:30
skwashd Exp $
+ * @version $Id: class.contacts_sql.inc.php,v 1.26 2006/07/19 01:40:11
skwashd Exp $
* @internal Development of this application was funded by
http://www.sogrp.com
*/
@@ -3557,8 +3557,9 @@
function get_contacts_shared($owner_id,
$acl_type=PHPGW_ACL_READ)
{
+ $required_grants = array();
$this->grants =
$GLOBALS['phpgw']->acl->get_grants('addressbook');
- if($GLOBALS['phpgw']->acl->check('addressmaster', 7,
'addressbook'))
+ if ( $GLOBALS['phpgw_info']['server']['addressmaster']
&& $GLOBALS['phpgw']->acl->check('addressmaster', 7, 'addressbook'))
{
$required_grants[] =
$GLOBALS['phpgw_info']['server']['addressmaster'];
}
@@ -3566,9 +3567,12 @@
{
if($this->check_perms($perm, $acl_type))
{
+ if ( $owner )
+ {
$required_grants[] = $owner;
}
}
+ }
return $required_grants;
}
Index: inc/class.categories.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.categories.inc.php,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -b -r1.126 -r1.127
--- inc/class.categories.inc.php 18 Apr 2006 13:50:18 -0000 1.126
+++ inc/class.categories.inc.php 19 Jul 2006 01:40:11 -0000 1.127
@@ -7,7 +7,7 @@
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General
Public License
* @package phpgwapi
* @subpackage utilities
- * @version $Id: class.categories.inc.php,v 1.126 2006/04/18 13:50:18
skwashd Exp $
+ * @version $Id: class.categories.inc.php,v 1.127 2006/07/19 01:40:11
skwashd Exp $
*/
/**
@@ -32,9 +32,9 @@
* @param integer $accountid Account id
* @param string $app_name Application name defaults to current
application
*/
- function categories($accountid = '',$app_name = '')
+ function categories($accountid = '', $app_name = '')
{
- $account_id = get_account_id($accountid);
+ $account_id = (int)get_account_id($accountid);
if (! $app_name)
{
@@ -42,10 +42,8 @@
}
$this->account_id = $account_id;
- $this->app_name =
$GLOBALS['phpgw']->db->db_addslashes($app_name);
$this->db =&
$GLOBALS['phpgw']->db;
- $this->db2 = clone( $this->db);
- $this->grants =
$GLOBALS['phpgw']->acl->get_grants($app_name);
+ $this->set_appname($app_name);
}
/**
@@ -56,15 +54,29 @@
*/
function filter($type)
{
+ $s = '';
switch ($type)
{
- case 'subs': $s = ' AND cat_parent
!= 0'; break;
- case 'mains': $s = ' AND cat_parent =
0'; break;
- case 'appandmains': $s = " AND
cat_appname='" . $this->app_name . "' AND cat_parent =0"; break;
- case 'appandsubs': $s = " AND
cat_appname='" . $this->app_name . "' AND cat_parent !=0"; break;
- case 'noglobal': $s = " AND cat_appname
!= '" . $this->app_name . "'"; break;
- case 'noglobalapp': $s = " AND cat_appname
= '" . $this->app_name . "' AND cat_owner != " . $this->account_id; break;
- default: return False;
+ case 'subs':
+ $s = ' AND cat_parent != 0';
+ break;
+ case 'mains':
+ $s = ' AND cat_parent = 0';
+ break;
+ case 'appandmains':
+ $s = " AND
cat_appname='{$this->app_name}' AND cat_parent = 0";
+ break;
+ case 'appandsubs':
+ $s = " AND
cat_appname='{$this->app_name}' AND cat_parent <> 0";
+ break;
+ case 'noglobal':
+ $s = " AND cat_appname !=
'{$this->app_name}'";
+ break;
+ case 'noglobalapp':
+ $s = " AND cat_appname =
'{$this->app_name}' AND cat_owner <> {$this->account_id}";
+ break;
+ default:
+ return '';
}
return $s;
}
@@ -84,13 +96,13 @@
case 'appandsubs': $w = " WHERE
cat_appname='" . $this->app_name . "' AND cat_parent !=0"; break;
case 'subs': $w = ' WHERE cat_parent
!= 0'; break;
case 'mains': $w = ' WHERE cat_parent
= 0'; break;
- default: return False;
+ default: return 0;
}
- $this->db->query("SELECT COUNT(cat_id) FROM
phpgw_categories $w",__LINE__,__FILE__);
+ $this->db->query("SELECT COUNT(cat_id) as cnt_cats FROM
phpgw_categories $w",__LINE__,__FILE__);
$this->db->next_record();
- return $this->db->f(0);
+ return $this->db->f('cnt_cats');
}
/**
@@ -197,8 +209,8 @@
$sql = "SELECT $table_column from phpgw_categories
WHERE (cat_appname='" . $this->app_name . "' AND" . $grant_cats . $global_cats
. ')'
. $parent_filter . $querymethod . $filter;
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
+ $this->db->query($sql, __LINE__, __FILE__);
+ $this->total_records = $this->db->num_rows();
if ($limit)
{
@@ -890,5 +902,16 @@
return False;
}
}
+
+ /**
+ * Sets the app to use for category look ups, handy for getting
around recycling the class
+ *
+ * @param string $appname the new app name
+ */
+ function set_appname($appname)
+ {
+ $this->app_name =
$GLOBALS['phpgw']->db->db_addslashes($appname);
+ $this->grants =
$GLOBALS['phpgw']->acl->get_grants($appname);
+ }
}
?>
Index: inc/class.validator.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.validator.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- inc/class.validator.inc.php 30 Dec 2004 06:47:31 -0000 1.5
+++ inc/class.validator.inc.php 19 Jul 2006 01:40:11 -0000 1.6
@@ -8,7 +8,7 @@
* @license http://www.fsf.org/licenses/gpl.html GNU eneral Public
License
* @package phpgwapi
* @subpackage utilities
- * @version $Id: class.validator.inc.php,v 1.5 2004/12/30 06:47:31
skwashd Exp $
+ * @version $Id: class.validator.inc.php,v 1.6 2006/07/19 01:40:11
skwashd Exp $
*/
/**
@@ -101,9 +101,7 @@
function array_echo ($array, $name='Array')
{
- echo '<pre>';
- print_r($array);
- echo '<pre>';
+ echo '<pre>' . print_r($array, true) . '<pre>';
}
function is_email ($address='')
Index: inc/class.sql.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.sql.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- inc/class.sql.inc.php 22 Mar 2005 14:23:24 -0000 1.4
+++ inc/class.sql.inc.php 19 Jul 2006 01:40:11 -0000 1.5
@@ -8,7 +8,7 @@
* @license http://www.fsf.org/licenses/gpl.html GNU General Public
License
* @package phpgwapi
* @subpackage database
- * @version $Id: class.sql.inc.php,v 1.4 2005/03/22 14:23:24 fipsfuchs
Exp $
+ * @version $Id: class.sql.inc.php,v 1.5 2006/07/19 01:40:11 skwashd Exp
$
* @internal Development of this application was funded by
http://www.sogrp.com
* @link http://www.sogrp.com/
*/
@@ -245,7 +245,7 @@
function in($field, $values, $type='integer')
{
// This must be changed by anything
- if(count($values) > 1)
+ if ( is_array($values) && count($values) > 1)
{
if($type != 'integer' && $type != '')
{
@@ -261,6 +261,7 @@
$type = $type ? $type : 'integer';
if (is_array($values))
{
+ //this never gets executed!
return sql::equal($field,
sql::$type(current($values)));
}
else
Index: inc/class.jscalendar.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.jscalendar.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- inc/class.jscalendar.inc.php 26 Mar 2006 10:53:26 -0000 1.9
+++ inc/class.jscalendar.inc.php 19 Jul 2006 01:40:11 -0000 1.10
@@ -7,7 +7,7 @@
* @license http://www.fsf.org/licenses/gpl.html GNU General Public
License
* @package phpgwapi
* @subpackage gui
- * @version $Id: class.jscalendar.inc.php,v 1.9 2006/03/26 10:53:26
skwashd Exp $
+ * @version $Id: class.jscalendar.inc.php,v 1.10 2006/07/19 01:40:11
skwashd Exp $
*/
/**
@@ -51,6 +51,11 @@
}
}
+ function add_listener($name)
+ {
+ $this->_input_modern($name);
+ }
+
/*!
@function input
@syntax input( $name,$date,$year=0,$month=0,$day=0 )
@@ -62,39 +67,18 @@
@param $helpmsg a helpmessage for the statusline of the browser
@param $options any other options to the inputfield
*/
- function
input($name,$date,$year=0,$month=0,$day=0,$helpmsg='',$options='')
+ function input($name, $date=0, $year=0, $month=0, $day=0, $helpmsg='',
$options='')
{
- //echo "<p>jscalendar::input(name='$name',
date='$date'='".date('Y-m-d',$date)."', year='$year', month='$month',
day='$day')</p>\n";
-
- if ($date && (is_int($date) || is_numeric($date)))
+ if ( isset($GLOBALS['phpgw_info']['flags']['xslt_app'])
+ && $GLOBALS['phpgw_info']['flags']['xslt_app'])
{
- $year =
intval($GLOBALS['phpgw']->common->show_date($date,'Y'));
- $month =
intval($GLOBALS['phpgw']->common->show_date($date,'n'));
- $day =
intval($GLOBALS['phpgw']->common->show_date($date,'d'));
- }
- if ($year && $month && $day)
- {
- $date =
date($this->dateformat,mktime(12,0,0,$month,$day,$year));
- }
- if ($helpmsg !== '')
- {
- $options .= "
onFocus=\"self.status='".addslashes($helpmsg)."'; return true;\"" .
- " onBlur=\"self.status=''; return true;\"";
+ $this->_input_modern($name);
+ return '';
}
- return
- '<input type="text" id="'.$name.'" name="'.$name.'" size="12"
value="'.$date.'"'.$options.'/>
- <script type="text/javascript">
- <!--
- document.writeln(\'<img id="'.$name.'-trigger"
src="'.$GLOBALS['phpgw']->common->find_image('phpgwapi','cal').'" alt="' .
lang('date selector') . '" title="'.lang('Select date').'"
style="cursor:pointer; cursor:hand;"/>\');
- Calendar.setup(
+ else
{
- inputField : "'.$name.'",
- button : "'.$name.'-trigger"
+ return $this->_input_legacy($name, $date, $year,
$month, $day, $helpmsg, $options);
}
- );
- //-->
- </script>
- ';
}
/*!
@@ -140,4 +124,46 @@
return $ret;
}
+
+
+ function _input_legacy($name, $date, $year, $month, $day, $helpmsg,
$options)
+ {
+ //echo "<p>jscalendar::input(name='$name',
date='$date'='".date('Y-m-d',$date)."', year='$year', month='$month',
day='$day')</p>\n";
+
+ if ($date && (is_int($date) || is_numeric($date)))
+ {
+ $year =
intval($GLOBALS['phpgw']->common->show_date($date,'Y'));
+ $month =
intval($GLOBALS['phpgw']->common->show_date($date,'n'));
+ $day =
intval($GLOBALS['phpgw']->common->show_date($date,'d'));
+ }
+ if ($year && $month && $day)
+ {
+ $date =
date($this->dateformat,mktime(12,0,0,$month,$day,$year));
+ }
+ if ($helpmsg !== '')
+ {
+ $options .= "
onFocus=\"self.status='".addslashes($helpmsg)."'; return true;\"" .
+ " onBlur=\"self.status=''; return true;\"";
+ }
+ return
+ '<input type="text" id="'.$name.'" name="'.$name.'" size="12"
value="'.$date.'"'.$options.'/>
+ <script type="text/javascript">
+ <!--
+ document.writeln(\'<img id="'.$name.'-trigger"
src="'.$GLOBALS['phpgw']->common->find_image('phpgwapi','cal').'" alt="' .
lang('date selector') . '" title="'.lang('Select date').'"
style="cursor:pointer; cursor:hand;"/>\');
+ Calendar.setup(
+ {
+ inputField : "'.$name.'",
+ button : "'.$name.'-trigger"
+ }
+ );
+ //-->
+ </script>
+ ';
+ }
+
+ function _input_modern($name)
+ {
+ $GLOBALS['phpgw']->js->add_event('load',
"Calendar.setup({inputField : '$name', button : '{$name}-trigger'});");
+ }
}
+?>
Index: inc/class.custom_fields.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.custom_fields.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- inc/class.custom_fields.inc.php 12 Mar 2006 11:20:08 -0000 1.1
+++ inc/class.custom_fields.inc.php 19 Jul 2006 01:40:11 -0000 1.2
@@ -1,266 +1,974 @@
<?php
-/**
-* phpGroupWare custom fields
-* @author Dave Hall dave.hall at skwashd.com
-* @copyright Copyright (C) 2006 Free Software Foundation http://www.fsf.org/
-* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
-* @version $Id: class.custom_fields.inc.php,v 1.1 2006/03/12 11:20:08 skwashd
Exp $
-*/
+ /**
+ * phpGroupWare custom fields
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @author Dave Hall dave.hall at skwashd.com
+ * @copyright Copyright (C) 2003-2006 Free Software Foundation
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 phpgwapi
+ * @version $Id: class.custom_fields.inc.php,v 1.2 2006/07/19 01:40:11
skwashd Exp $
+ */
-class custom_fields
-{
/**
- * @var sting appname the name of the application the fields are for
+ * Custom Fields
+ * @package phpgwapi
+ */
+ class custom_fields
+ {
+ /**
+ * @var string $appname the name of the current application
*/
var $appname;
/**
- * @var object $db reference to global db object
+ * @var array $grants the various rights for this current
location
+ */
+ var $grants;
+
+ /**
+ * @var string $location the name of the current location
+ */
+ var $location;
+
+
+ /**
+ * @var array $public_functions the publicly available methods
of this class
+ * @internal TODO remove most of these as it is an api bo+so
class
*/
- var $db;
+ var $public_functions = array
+ (
+ 'check_perms' => true,
+ 'delete' => true,
+ 'read' => true,
+ 'read_single' => true,
+ 'save' => true
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
/**
* @constructor
*/
- function custom_fields($appname)
+ function custom_fields($appname='', $location='')
{
$this->appname = $appname;
+ if ( strlen($this->appname) == 0 )
+ {
+ $this->appname =&
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ }
+
+ $this->location = $location;
+
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
$this->db =& $GLOBALS['phpgw']->db;
+ $this->join = $this->db->join;
+ $this->like = $this->db->like;
+
+ if($this->appname && $$this->location)
+ {
+ $this->category_name =
$this->read_category_name($this->appname, $this->location);
+ }
}
/**
- * Add a new field
+ * Add a custom field/attribute
+ *
+ * @param array $attirb the field data
+ * @return int the the new custom field db pk
*/
- function add_field($field)
+ function add_attrib($attrib)
{
- $sql = $this->db->adodb->Prepare('INSERT INTO
phpgw_cust_fields(cust_field_name, cust_field_type_id, cust_field_label,
appname) '
- . 'VALUES( ?, ? , ?, ?)');
- $params = array
- (
- $field->name,
- $field->type,
- $field->label,
- $this->appname != 'admin' ?
$this->appname : ''
+ $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($attrib['default']);
+ $this->db->transaction_begin();
+
+ $sql = 'SELECT MAX(attrib_sort) AS max_sort, MAX(id) AS
current_id FROM phpgw_cust_attribute'
+ . " WHERE
appname='{$attrib['appname']}' AND location='{$attrib['location']}'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('max_sort')+1;
+ $attrib['id'] = $this->db->f('current_id')+1;
+
+ 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'])
+ {
+ $receipt['error'][] = array('msg'
=> lang('History not allowed for this datatype'));
+ }
+
+ $attrib['history'] = false;
+ }
+
+ $values= array(
+ $attrib['appname'],
+ $attrib['location'],
+ $attrib['id'],
+ $attrib['column_name'],
+ $attrib['input_text'],
+ $attrib['statustext'],
+ $attrib['search'],
+ $attrib['list'],
+ $attrib['history'],
+ $attrib_sort,
+ $attrib['column_info']['type'],
+ $attrib['column_info']['precision'],
+ $attrib['column_info']['scale'],
+ $attrib['column_info']['default'],
+ $attrib['column_info']['nullable']
);
- if ( $this->db->adodb->Execute($sql, $params) )
+ $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__);
+
+ $receipt['id']= $attrib['id'];
+
+ if(!$attrib['column_info']['precision'])
{
- return $this->db->adodb->Insert_ID();
+ if($precision =
$this->translate_datatype_precision($attrib['column_info']['type']))
+ {
+
$attrib['column_info']['precision']=$precision;
+ }
}
- return 0;
+
+ $attrib['column_info']['type'] =
$this->translate_datatype_insert($attrib['column_info']['type']);
+
+ if(!$attrib['column_info']['default'])
+ {
+ unset($attrib['column_info']['default']);
+ }
+
+ $attrib_table =
$this->get_attrib_table($attrib['appname'],$attrib['location']);
+
+ $this->_init_process();
+
+
if($this->oProc->AddColumn($attrib_table,$attrib['column_name'],
$attrib['column_info']))
+ {
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
+ $this->db->transaction_commit();
+
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('column could not be added') );
+ if($this->db->Transaction)
+ {
+ $this->db->transaction_abort();
+ }
+ else
+ {
+ $this->db->query("DELETE FROM
phpgw_cust_attribute WHERE appname='" . $attrib['appname']. "' AND location='"
. $attrib['id']. "' AND id='" . $receipt['id'] . "'",__LINE__,__FILE__);
+ unset($receipt['id']);
+
+ }
+ }
+ return $receipt;
}
/**
- * Delete a field from the database
+ * Add a custom function
*
- * @param int $id the field to delete
- * address@hidden bool was the record deleted?
+ * @internal get more info from sigud so this can be documented
- skwashd Apr2006
*/
- function delete_field($id)
+ function add_custom_function($custom_function)
+ {
+ if(!$custom_function['location'] ||
!$custom_function['appname'])
{
- $sql = $this->db->adodb->Prepare('DELETE FROM phpgw_cust_fields
WHERE cust_field_id = ?');
- $this->db->adodb->Execute($sql, array($id));
- return ($this->db->adodb->Affected_Rows() == 1);
+ return $receipt['error'][] = array('msg' =>
lang('location or appname is missing'));
+ }
+ else
+ {
+ $location = $custom_function['location'];
+ $appname = $custom_function['appname'];
+ }
+
+ $custom_function['descr'] =
$this->db->db_addslashes($custom_function['descr']);
+
+ $this->db->transaction_begin();
+ $this->db->query("SELECT max(id) as maximum FROM
phpgw_cust_function WHERE appname='$appname' AND
location='$location'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_function['id'] = $this->db->f('maximum')+1;
+
+ $sql = "SELECT max(custom_sort) as max_sort FROM
phpgw_cust_function where appname='$appname' AND location='$location'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('max_sort')+1;
+
+ $values= array(
+ $appname,
+ $location,
+ $custom_function['id'],
+ $custom_function['custom_function_file'],
+ $custom_function['descr'],
+ $custom_function['active'],
+ $custom_sort
+ );
+
+ $values = $this->db->validate_insert($values);
+
+ $this->db->query("INSERT INTO phpgw_cust_function
(appname,location, id, file_name, descr, active, custom_sort) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+ $receipt['id']= $custom_function['id'];
+
+ $this->db->transaction_commit();
+
+ return $receipt;
}
/**
- * Get a field
+ * Delete a custom attribute or custom function
+ *
+ * @param string $location the location
+ * @param string $appname the application name
+ * @param int $attrib_id the db pk for the attribute to delete
+ * @param int $function_id the db pk of the function to delete
*/
- function get_field($id)
+ function delete($location, $appname,
$attrib_id=0,$function_id=0)
{
- $field = array();
-
- $rs = $this->db->adodb->Execute('SELECT phpgw_cust_fields.*,
phpgw_cust_field_types.cust_field_type_descr '
- . '
FROM phpgw_cust_fields, phpgw_cust_field_types '
- . '
WHERE cust_field_id = ' . intval($id)
- . ' AND
phpgw_cust_field_types.cust_field_type_id =
phpgw_cust_fields.cust_field_type_id');
- while ( !$rs->EOF )
+ if($attrib_id && $location && $appname &&
!$function_id):
{
- $field[$rs->Fields('cust_field_id')] = array
- (
- 'id' =>
$rs->Fields('cust_field_id'),
- 'appname' =>
$rs->Fields('appname'),
- 'name' =>
$rs->Fields('cust_field_name'),
- 'label' =>
$rs->Fields('cust_field_label'),
- 'type_id' =>
$rs->Fields('cust_field_type_id'),
- 'type_descr'=>
$rs->Fields('cust_field_type_descr'),
- 'is_active' =>
!!$rs->Fields('cust_field_active')
- );
- $rs->MoveNext();
+
$this->_delete_attrib($location,$appname,$attrib_id);
+ }
+ elseif($function_id && $appname && $location):
+ {
+
$this->_delete_custom_function($appname,$location,$function_id);
}
- return $field;
+ endif;
}
/**
- * Check to see if a field is in use or not
+ * Edit a custom field
+ *
+ * @param array $attrib the field data
+ * @return int the field db pk
*/
- function is_used($id)
+ function edit_attrib($attrib)
+ {
+ $attrib_table =
$this->get_attrib_table($attrib['appname'],$attrib['location']);
+ $choice_table = 'phpgw_cust_choice';
+
+ $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['column_info']['default'] =
$this->db->db_addslashes($attrib['column_info']['default']);
+
+ 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'])
+ {
+ $receipt['error'][] = array('msg'
=> lang('History not allowed for this datatype'));
+ }
+
+ $attrib['history'] = false;
+ }
+
+ $this->db->query("SELECT column_name,
datatype,precision_ FROM phpgw_cust_attribute WHERE appname='" .
$attrib['appname']. "' AND location='" . $attrib['location']. "' AND id='" .
$attrib['id']. "'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $OldColumnName = $this->db->f('column_name');
+ $OldDataType = $this->db->f('datatype');
+ $OldPrecision = $this->db->f('precision_');
+
+// $table_def =
$this->get_table_def($attrib['appname'],$attrib['location']);
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'input_text' => $attrib['input_text'],
+ 'statustext' => $attrib['statustext'],
+ 'search' => $attrib['search'],
+ 'list' => $attrib['list'],
+ 'history' => $attrib['history'],
+ );
+
+ $value_set =
$this->db->validate_update($value_set);
+
+ $this->db->query("UPDATE phpgw_cust_attribute set
$value_set WHERE appname='" . $attrib['appname']. "' AND location='" .
$attrib['location']. "' AND id=" . $attrib['id'],__LINE__,__FILE__);
+
+ $this->_init_process();
+
+ $this->oProc->m_odb->transaction_begin();
+
+// $this->oProc->m_aTables = $table_def;
+
+ if($OldColumnName !=$attrib['column_name'])
{
- $rs = $this->db->adodb->Execute('SELECT COUNT(cust_field_id) as
cnt FROM phpgw_cust_field_values WHERE cust_field_id = ' . (int) $id);
- return ($rs->Fields('cnt') > 0);
+ $value_set=array('column_name' =>
$attrib['column_name']);
+
+ $value_set =
$this->db->validate_update($value_set);
+
+ $this->db->query("UPDATE phpgw_cust_attribute
set $value_set WHERE appname='" . $attrib['appname']. "' AND location='" .
$attrib['location']. "' AND id=" . $attrib['id'],__LINE__,__FILE__);
+
+ $this->oProc->RenameColumn($attrib_table,
$OldColumnName, $attrib['column_name']);
+ }
+
+ if (($OldDataType != $attrib['column_info']['type']) ||
($OldPrecision != $attrib['column_info']['precision']) )
+ {
+ if($attrib['column_info']['type']!='R' &&
$attrib['column_info']['type']!='CH' && $attrib['column_info']['type']!='LB')
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE appname='" . $attrib['appname']. "' AND location='" .
$attrib['location']. "' AND attrib_id=" . $attrib['id'],__LINE__,__FILE__);
+ }
+
+ if(!$attrib['column_info']['precision'])
+ {
+ if($precision =
$this->translate_datatype_precision($attrib['column_info']['type']))
+ {
+
$attrib['column_info']['precision']=$precision;
+ }
+ }
+
+ if(!isset($attrib['column_info']['default']))
+ {
+
unset($attrib['column_info']['default']);
+ }
+
+ $value_set=array(
+ 'column_name' =>
$attrib['column_name'],
+ 'datatype' =>
$attrib['column_info']['type'],
+ 'precision_' =>
$attrib['column_info']['precision'],
+ 'scale' =>
$attrib['column_info']['scale'],
+ 'default_value' =>
$attrib['column_info']['default'],
+ 'nullable' =>
$attrib['column_info']['nullable']
+ );
+
+ $value_set =
$this->db->validate_update($value_set);
+
+ $this->db->query("UPDATE phpgw_cust_attribute
set $value_set WHERE appname='" . $attrib['appname']. "' AND location='" .
$attrib['location']. "' AND id=" . $attrib['id'],__LINE__,__FILE__);
+
+ $attrib['column_info']['type'] =
$this->translate_datatype_insert($attrib['column_info']['type']);
+
$this->oProc->AlterColumn($attrib_table,$attrib['column_name'],$attrib['column_info']);
+ }
+
+ if($attrib['new_choice'])
+ {
+ $choice_id =
$this->bocommon->next_id($choice_table
,array('appname'=>$attrib['appname'],'location'=>$attrib['location'],'attrib_id'=>$attrib['id']));
+
+ $values= array(
+ $attrib['appname'],
+ $attrib['location'],
+ $attrib['id'],
+ $choice_id,
+ $attrib['new_choice']
+ );
+
+ $values = $this->db->validate_insert($values);
+
+ $this->db->query("INSERT INTO $choice_table
(appname,location,attrib_id,id,value) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+ }
+
+ if($attrib['delete_choice'])
+ {
+ for
($i=0;$i<count($attrib['delete_choice']);$i++)
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE appname='" . $attrib['appname']. "' AND location='" .
$attrib['location']. "' AND attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i],__LINE__,__FILE__);
+ }
+ }
+
+ $this->db->transaction_commit();
+ $this->oProc->m_odb->transaction_commit();
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
+
+ return $receipt;
+ }
+
+
+ function edit_custom_function($custom_function)
+ {
+ if(!$custom_function['location'] ||
!$custom_function['appname'])
+ {
+ return $receipt['error'][] = array('msg' =>
lang('location or appname is missing'));
+ }
+ else
+ {
+ $location = $custom_function['location'];
+ $appname = $custom_function['appname'];
+ }
+
+ $custom_function['descr'] =
$this->db->db_addslashes($custom_function['descr']);
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'descr' =>
$custom_function['descr'],
+ 'file_name' =>
$custom_function['custom_function_file'],
+ 'active' =>
$custom_function['active']
+ );
+
+ $value_set =
$this->db->validate_update($value_set);
+
+ $this->db->query("UPDATE phpgw_cust_function
set $value_set WHERE appname='$appname' AND location='$location' AND id=" .
$custom_function['id'],__LINE__,__FILE__);
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' => lang('Custom
function has been edited'));
+
+ return $receipt;
}
/**
- * List available fields
+ * Get a list of attributes
*
- * @param bool $inc_global include globally available fields
+ * @param string $appname the name of the application
+ * @param string $location the name of the location
*/
- function list_fields($inc_global = true)
+ function get_attribs($appname, $location, $start = 0, $query =
'', $sort = 'ASC', $order = 'attrib_sort', $allrows = false, $inc_choices =
false)
{
- if ( $inc_global && $this->appname != 'admin' && $this->appname
!= '' )
+ $start = (int) $start;
+ $query = $this->db->db_addslashes($query);
+ $sort = $sort == 'ASC' ? 'ASC' : 'DESC';
+ $order = $this->db->db_addslashes($order);
+ $allrows = !!$allrows;
+ $appname = $this->db->db_addslashes($appname);
+ $location = $this->db->db_addslashes($location);
+
+ if ( $allrows )
{
- $where = "appname = '' OR appname = " .
$this->db->adodb->Quote($this->appname);
+ $this->allrows = $allrows;
}
- else if ( !$inc_global && $this->appname != 'admin' &&
$this->appname != '' )
+
+ if ( $order != '')
{
- $where = 'appname = ' .
$this->db->adodb->Quote($this->appname);
+ $ordermethod = " ORDER BY $order $sort";
+
}
else
{
- $where = "appname = ''";
+ $ordermethod = ' ORDER BY attrib_sort ASC';
}
- $fields = array();
- $rs = $this->db->adodb->Execute('SELECT
phpgw_cust_fields.cust_field_id, phpgw_cust_fields.cust_field_name,
phpgw_cust_fields.cust_field_active '
- . '
FROM phpgw_cust_fields'
- . "
WHERE $where");
+ if($query)
+ {
+ $query = $this->db->db_addslashes($query);
+ $querymethod = " AND (phpgw_cust_attribute.name
$this->like '%$query%' or phpgw_cust_attribute.descr $this->like '%$query%')";
+ }
+
+ $sql = "FROM phpgw_cust_attribute WHERE
appname='$appname' AND location = '$location' $filtermethod $querymethod";
+ if ( $allrows )
+ {
+ $this->db->query("SELECT * $sql" .
$ordermethod, __LINE__, __FILE__);
+ }
+ else
+ {
+ $this->db->limit_query("SELECT * $sql" .
$ordermethod,$start, __LINE__, __FILE__);
+ }
- while ( !$rs->EOF )
+ $attribs = array();
+ while ($this->db->next_record())
{
- $fields[$rs->Fields('cust_field_id')] = array
+ $attribs[] = array
(
- 'id' =>
$rs->Fields('cust_field_id'),
- 'field_name'=>
$rs->Fields('cust_field_name'),
- 'active' =>
!!$rs->Fields('cust_field_active')
+ 'id' =>
$this->db->f('id'),
+ 'entity_type' =>
$this->db->f('type_id'),
+ 'attrib_sort' => (int)
$this->db->f('attrib_sort'),
+ 'list' =>
$this->db->f('list'),
+ 'lookup_form' =>
$this->db->f('lookup_form'),
+ 'entity_form' =>
$this->db->f('entity_form'),
+ 'column_name' =>
$this->db->f('column_name'),
+ 'name' =>
$this->db->f('input_text', true),
+ 'size' =>
$this->db->f('size'),
+ 'statustext' =>
$this->db->f('statustext', true),
+ 'input_text' =>
$this->db->f('input_text', true),
+ 'type_name' =>
$this->db->f('type'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'search' =>
$this->db->f('search'),
+ 'trans_datatype' =>
$this->translate_datatype($this->db->f('datatype'))
);
- $rs->MoveNext();
}
- return $fields;
+
+ $this->total_records = 0;
+ $this->db->query("SELECT COUNT(id) AS cnt_rec
$sql",__LINE__,__FILE__);
+ if ( $this->db->next_record() )
+ {
+ $this->total_records = $this->db->f('cnt_rec');;
+ }
+
+ return $attribs;
}
- function list_field_types($inc_inactive = false)
+ function get_attrib_single($appname, $location, $id,
$inc_choices = false)
{
- $sql = 'SELECT cust_field_type_id, cust_field_type_descr,
cust_field_type_active'
- . ' FROM phpgw_cust_field_types ';
+ $appname = $this->db->db_addslashes($appname);
+ $location = $this->db->db_addslashes($location);
+ $id = (int) $id;
+
+ $sql = "SELECT * FROM phpgw_cust_attribute where
appname='$appname' AND location='$location' AND id=$id";
+ $this->db->query($sql,__LINE__,__FILE__);
- if ( !$inc_inactive )
+ if ($this->db->next_record())
{
- $sql .= 'WHERE
phpgw_cust_field_types.cust_field_type_active = 1';
+ $attrib['id'] =
$this->db->f('id');
+ $attrib['column_name'] =
$this->db->f('column_name');
+ $attrib['input_text'] =
$this->db->f('input_text');
+ $attrib['statustext'] =
$this->db->f('statustext');
+ $attrib['column_info']['precision'] =
$this->db->f('precision_');
+ $attrib['column_info']['scale'] =
$this->db->f('scale');
+ $attrib['column_info']['default'] =
$this->db->f('default_value');
+ $attrib['column_info']['nullable'] =
$this->db->f('nullable');
+ $attrib['column_info']['type'] =
$this->db->f('datatype');
+ $attrib['type_id'] =
$this->db->f('type_id');
+ $attrib['type_name'] =
$this->db->f('type_name');
+ $attrib['lookup_form'] =
$this->db->f('lookup_form');
+ $attrib['list'] =
$this->db->f('list');
+ $attrib['search'] =
$this->db->f('search');
+ $attrib['history'] =
$this->db->f('history');
+
+ if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
+ {
+ $attrib['choice'] =
$this->read_attrib_choice($appname,$location,$id);
+ }
+
+ return $attrib;
+ }
}
- $fields = array();
+ 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();
+ return $this->db->f('c_attrib_table');
+ }
- $rs = $this->db->adodb->Execute($sql);
- while ( !$rs->EOF )
+ function read_custom_function($data = array())
{
- $fields[$rs->Fields('cust_field_type_id')] = array
- (
- 'id' =>
$rs->Fields('cust_field_type_id'),
- 'value' =>
$rs->Fields('cust_field_type_descr'),
- 'active'=>
!!$rs->Fields('cust_field_type_active')
- );
- $rs->MoveNext();
+ 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'] : '');
}
- return $fields;
+ else
+ {
+ return array();
}
- /**
- * Search for records based on a particular string
- *
- * @param string $search the string to search for
- * @param int $field_id the field to search on
- * @param bool $inc_lookup include lookup values - performance hit so
not encouraged or implemented yet
- * @param string $location the location for the records
- * @return array the relevant record ids
- */
- function search_values($search, $field_id = 0, $inc_lookup = false,
$location = '')
+ if( $location == '' || $appname == '' )
+ {
+ return array();
+ }
+
+ if ($order)
{
- $where = array();
- $records = array();
+ $ordermethod = " ORDER BY $order $sort";
- $where[] = 'phpgw_custom_field_values.cust_field_id =
phpgw_custom_fields.cust_field_id';
- if ( $field_id <> 0 )
+ }
+ else
{
- $where[] = 'phpgw_custom_fields.cust_field_id = ' .
(int) $field_id;
+ $ordermethod = ' ORDER BY custom_sort ASC';
}
- if ( $this->appname != '' )
+ $table = 'phpgw_cust_function';
+
+ if($query)
{
- $where[] = "phpgw_custom_fields.appname = '' OR
phpgw_custom_fields.appname = . $this->db->adodb->Quote($this->appname) . ";
+ $querymethod = " AND file_name $this->like
'%$query%' OR descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table WHERE appname='$appname'
AND location='$location' $querymethod";
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
}
else
{
- $where[] = "phpgw_custom_fields.appname = ''";
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
}
- if ( $location != '' )
+ while ($this->db->next_record())
{
- $where[] = "phpgw_custom_field_values.locations= ''";
+ $custom_function[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'file_name' =>
$this->db->f('file_name'),
+ 'sorting' =>
$this->db->f('custom_sort'),
+ 'descr' =>
$this->db->f('descr'),
+ 'active' =>
$this->db->f('active')
+ );
}
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db->num_rows();
+
+ return $custom_function;
+ }
+
+ function read_attrib_choice($appname, $location, $attrib_id)
+ {
+ $appname = $this->db->db_addslashes($appname);
+ $location = $this->db->db_addslashes($location);
+ $ttrib_id = (int)$attrib_id;
+
+ $sql = "SELECT * FROM phpgw_cust_choice WHERE
appname='$appname' AND location='$location' AND attrib_id = $attrib_id";
+ $this->db->query($sql,__LINE__,__FILE__);
- $rs = $this->db->adodb->Execute('SELECT
phpgw_cust_field_values.rec_id, phpgw_cust_field_values.cust_field_id ' .
-
' FROM phpgw_cust_fields, phpgw_cust_field_values ' .
-
" WHERE phpgw_cust_field_values.cust_field_value_val = " .
$this->db->adodb->Quote($search) .
-
" AND " . implode(' AND ', $where));
- while ( !$rs->EOF )
+ $choices = array();
+ while ($this->db->next_record())
{
- $records[$rs->Fields('rec_id')] =
$rs->Fields('cust_field_id');
- $rs->MoveNext();
+ $choices[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'value' => $this->db->f('value', true)
+ );
+ }
+ return $choices;
}
- if ( !$inc_lookup )
+ function read_single_custom_function($appname, $location, $id)
+ {
+ $appname = $this->db->db_addslashes($appname);
+ $location = $this->db->db_addslashes($location);
+ $id = (int)$id;
+
+ $sql = "SELECT * FROM phpgw_cust_function where
appname='$appname' AND location='$location' AND id = $id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
{
- return $records;
+ return array
+ (
+ 'id'
=> (int)$this->db->f('id'),
+ 'descr'
=> $this->db->f('descr', true),
+ 'custom_function_file' =>
$this->db->f('file_name'),
+ 'active'
=> !!$this->db->f('active')
+ );
}
- //Lookups not yet implemented
- return $records;
+
}
/**
- * Set the application for the fields
+ * Resort an attribute's position in relation to other
attributes
*
- * @param string $appname the application name
+ * @param int $id the attribute db pk
+ * @param string $resort the direction to move the field
[up|down]
*/
- function set_application($appname)
+ function resort_attrib($id, $resort, $appname, $location)
{
- $this->appname = $appname;
+ $resort = $resort == 'down' ? 'down' : 'up';
+ $appname = $this->db_db_addslashes($appname);
+ $location = $this->db_db_addslashes($location);
+ $id = (int) $id;
+
+ $this->db->transaction_begin();
+
+ $sql = "SELECT attrib_sort FROM phpgw_cust_attribute
where appname='$appname' AND location='$location' AND id=$id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
phpgw_cust_attribute where appname='$appname' AND location='$location'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+
+ switch($resort)
+ {
+ case 'down':
+ if($max_sort > $attrib_sort)
+ {
+ $sql = "UPDATE
phpgw_cust_attribute set attrib_sort=$attrib_sort WHERE appname='$appname' AND
location='$location' AND attrib_sort =" . ($attrib_sort+1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
phpgw_cust_attribute set attrib_sort=" . ($attrib_sort+1) ." WHERE
appname='$appname' AND location='$location' AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ default:
+ case 'up':
+ if($attrib_sort>1)
+ {
+ $sql = "UPDATE
phpgw_cust_attribute set attrib_sort=$attrib_sort WHERE appname='$appname' AND
location='$location' AND attrib_sort =" . ($attrib_sort-1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
phpgw_cust_attribute set attrib_sort=" . ($attrib_sort-1) ." WHERE
appname='$appname' AND location='$location' AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ }
+ $this->db->transaction_commit();
+ }
+
+ function resort_custom_function($id, $resort, $appname,
$location)
+ {
+ $resort = $resort == 'down' ? 'down' : 'up';
+ $appname = $this->db->db_addslashes($this->appname);
+ $location = $this->db->db_addslashes($this->location);
+ $id = (int)$id;
+
+ if(!$location || !$appname)
+ {
+ return $receipt['error'][] = array('msg' =>
lang('location or appname is missing'));
+ }
+
+ $this->db->transaction_begin();
+
+ $sql = "SELECT custom_sort FROM phpgw_cust_function
WHERE appname='$appname' AND location='$location' AND id=$id";
+ $this->db->query($sql, __LINE__, __FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('custom_sort');
+ $sql = "SELECT MAX(custom_sort) AS max_sort FROM
phpgw_cust_function WHERE appname='$appname' AND location='$location'";
+ $this->db->query($sql, __LINE__, __FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+
+ switch($resort)
+ {
+ case 'down':
+ if($max_sort > $custom_sort)
+ {
+ $sql = "UPDATE
phpgw_cust_function set custom_sort=$custom_sort WHERE appname='$appname' AND
location='$location' AND custom_sort =" . ($custom_sort+1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
phpgw_cust_function set custom_sort=" . ($custom_sort+1) ." WHERE
appname='$appname' AND location='$location' AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ default:
+ case 'up':
+ if($custom_sort>1)
+ {
+ $sql = "UPDATE
phpgw_cust_function set custom_sort=$custom_sort WHERE appname='$appname' AND
location='$location' AND custom_sort =" . ($custom_sort-1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
phpgw_cust_function set custom_sort=" . ($custom_sort-1) ." WHERE
location='$location' AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ }
+ $this->db->transaction_commit();
}
/**
- * Set the value of a field
+ * Save an attribute record
*
- * @param int $field_id the id of the field
- * @param string $val the value of the field
- * @param int $rec_id the application record id for the field
- * @param string the application location for the field (not needed for
most apps)
- * @return int the new field id, 0 on failure
- */
- function set_field_value($field_id, $val, $rec_id, $location = '')
- {
- $sql = $this->db->adodb->Prepare('INSERT INTO
phpgw_cust_field_values(cust_field_value_val, cust_field_id, appname, location,
record_id)'
- .
'VALUES(?, ?, ?, ?, ?)');
- $params = array
+ * @param array $attrib the attribute data
+ * @param string $action the save action to use [edit|save]
+ * @return int the attribute id (db pk)
+ */
+ function save_attrib($attrib, $action='edit')
+ {
+ if ($action=='edit')
+ {
+ if ( isset($attrib['id']) && $attrib['id'])
+ {
+
+ return $this->so->edit_attrib($attrib);
+ }
+ }
+ return $this->so->add_attrib($attrib);
+ }
+
+ function save_custom_function($custom_function,$action='')
+ {
+ $receipt = 0;
+ if ($action=='edit')
+ {
+ if ($custom_function['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_custom_function($custom_function);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add_custom_function($custom_function);
+ }
+ return $receipt;
+ }
+
+ function select_custom_function($selected='', $appname)
+ {
+
+ $dir_handle = @opendir(PHPGW_SERVER_ROOT . SEP .
$appname . SEP . 'inc' . SEP . 'custom');
+ $i=0; $myfilearray = '';
+ if ($dir_handle)
+ {
+ while ($file = readdir($dir_handle))
+ {
+ if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'inc' . SEP . 'custom' . SEP
. $file) )
+ {
+ $myfilearray[$i] = $file;
+ $i++;
+ }
+ }
+ closedir($dir_handle);
+ sort($myfilearray);
+ }
+
+ for ($i=0;$i<count($myfilearray);$i++)
+ {
+ $fname = ereg_replace('_',' ',$myfilearray[$i]);
+ $sel_file = '';
+ if ($myfilearray[$i]==$selected)
+ {
+ $sel_file = 'selected';
+ }
+
+ $file_list[] = array
(
- $this->db->adodb->Quote($val),
- $field_id,
- $this->db->Quote($appname),
- strlen($location) ?
$this->db->Quote($location) : 'NULL',
- $rec_id
+ 'id' => $myfilearray[$i],
+ 'name' => $fname,
+ 'selected' => $sel_file
);
- $this->db->adodb->Execute($sql, $params);
- return $this->db->adodb->Insert_ID();
}
- /**
- * Update the value of a field
- *
- * @param int $cust_id custom field id
- * @param string $val the value of the field
- * @return bool did the request suceed?
- */
- function update_field_value($cust_id, $val)
+ for ($i=0;$i<count($file_list);$i++)
{
- return $this->db->adodb->Execute('UPDATE
phpgw_cust_field_values SET cust_field_value_val = ? WHERE cust_field_value_id
= ?', array ($this->db->adodb->Quote($val), (int) $cust_id ) );
+ if ($file_list[$i]['selected'] != 'selected')
+ {
+ unset($file_list[$i]['selected']);
+ }
+ }
+
+ return $file_list;
+ }
+
+ function translate_datatype($datatype)
+ {
+ $datatype_text = array(
+ 'V' => 'Varchar',
+ 'I' => 'Integer',
+ 'C' => 'char',
+ 'N' => 'Float',
+ 'D' => 'Date',
+ 'T' => 'Memo',
+ 'R' => 'Muliple radio',
+ 'CH' => 'Muliple checkbox',
+ 'LB' => 'Listbox',
+ 'AB' => 'Contact',
+ 'VENDOR' => 'Vendor',
+ 'email' => 'Email',
+ 'link' => 'Link'
+ );
+
+ $datatype = lang($datatype_text[$datatype]);
+
+ return $datatype;
+ }
+
+ function translate_datatype_insert($datatype)
+ {
+ $datatype_text = array(
+ 'V' => 'varchar',
+ 'I' => 'int',
+ 'C' => 'char',
+ 'N' => 'decimal',
+ 'D' => 'timestamp',
+ 'T' => 'text',
+ 'R' => 'int',
+ 'CH' => 'text',
+ 'LB' => 'int',
+ 'AB' => 'int',
+ 'VENDOR' => 'int',
+ 'email' => 'varchar',
+ 'link' => 'varchar'
+ );
+
+ return $datatype_text[$datatype];
+ }
+
+ function translate_datatype_precision($datatype)
+ {
+ $datatype_precision = array(
+ 'I' => 4,
+ 'R' => 4,
+ 'LB' => 4,
+ 'AB' => 4,
+ 'VENDOR' => 4,
+ 'email' => 64,
+ 'link' => 255
+ );
+
+ return $datatype_precision[$datatype];
+ }
+
+ function _delete_attrib($location,$appname,$attrib_id)
+ {
+ $this->_init_process();
+ $this->oProc->m_odb->transaction_begin();
+ $this->db->transaction_begin();
+
+ $sql = "SELECT * FROM phpgw_cust_attribute WHERE
appname='$appname' AND location='$location' AND id=$attrib_id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $ColumnName = $this->db->f('column_name');
+ $table = $this->get_attrib_table($appname,$location);
+
+ $this->oProc->DropColumn($table,false, $ColumnName);
+
+ $sql = "SELECT attrib_sort FROM phpgw_cust_attribute
where appname='$appname' AND location='$location' AND id=$attrib_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
phpgw_cust_attribute where appname='$appname' AND location='$location'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+
+ if($max_sort>$attrib_sort)
+ {
+ $sql = "UPDATE phpgw_cust_attribute set
attrib_sort=attrib_sort-1 WHERE appname='$appname' AND location='$location' AND
attrib_sort > $attrib_sort";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ $this->db->query("DELETE FROM phpgw_cust_attribute
WHERE appname='$appname' AND location='$location' AND
id=$attrib_id",__LINE__,__FILE__);
+ // $this->db->query("DELETE FROM history...
+ $this->db->transaction_commit();
+ $this->oProc->m_odb->transaction_commit();
+ }
+
+ function
_delete_custom_function($appname,$location,$custom_function_id)
+ {
+ $this->db->transaction_begin();
+ $sql = "SELECT custom_sort FROM phpgw_cust_function
where appname='$appname' AND location='$location' AND id=$custom_function_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('custom_sort');
+ $sql2 = "SELECT max(custom_sort) as max_sort FROM
phpgw_cust_function where appname='$appname' AND location='$location'";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ if($max_sort>$custom_sort)
+ {
+ $sql = "UPDATE phpgw_cust_function set
custom_sort=custom_sort-1 WHERE appname='$appname' AND location='$location' AND
custom_sort > $custom_sort";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+ $this->db->query("DELETE FROM phpgw_cust_function WHERE
appname='$appname' AND location='$location' AND
id=$custom_function_id",__LINE__,__FILE__);
+ $this->db->transaction_commit();
+ }
+
+ function _init_process()
+ {
+ $this->oProc =
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+ $this->oProc->m_odb =& $this->db;
+ $this->oProc->m_odb->Halt_On_Error = 'report';
+ }
}
-}
?>
Index: inc/accounts/class.accounts_.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/accounts/class.accounts_.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- inc/accounts/class.accounts_.inc.php 8 Apr 2005 08:55:56 -0000
1.3
+++ inc/accounts/class.accounts_.inc.php 19 Jul 2006 01:40:11 -0000
1.4
@@ -8,7 +8,7 @@
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General
Public License
* @package phpgwapi
* @subpackage accounts
- * @version $Id: class.accounts_.inc.php,v 1.3 2005/04/08 08:55:56
fipsfuchs Exp $
+ * @version $Id: class.accounts_.inc.php,v 1.4 2006/07/19 01:40:11
skwashd Exp $
*/
if (empty($GLOBALS['phpgw_info']['server']['account_repository']))
{
@@ -246,12 +246,12 @@
$security_equals = Array();
$security_equals =
$GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id);
- if ($security_equals == False)
+ if ( !$security_equals )
{
- return False;
+ return false;
}
- $this->memberships = Array();
+ $this->memberships = array();
for ($idx=0; $idx<count($security_equals); $idx++)
{
Index: templates/idots/head.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/templates/idots/head.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- templates/idots/head.inc.php 24 Apr 2006 09:49:25 -0000 1.10
+++ templates/idots/head.inc.php 19 Jul 2006 01:40:11 -0000 1.11
@@ -13,6 +13,8 @@
$GLOBALS['phpgw']->template->set_block('head', 'theme_stylesheet',
'theme_stylesheets');
$app = $GLOBALS['phpgw_info']['flags']['currentapp'];
+ if ( ! (isset($GLOBALS['phpgw_info']['flags']['noframework']) &&
$GLOBALS['phpgw_info']['flags']['noframework']) )
+ {
if(file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/templates/idots/css/' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '.css'))
{
$theme_styles[] =
"{$GLOBALS['phpgw_info']['server']['webserver_url']}/phpgwapi/templates/idots/css/{$GLOBALS['phpgw_info']['user']['preferences']['common']['theme']}.css";
@@ -43,6 +45,7 @@
$GLOBALS['phpgw']->template->set_var('theme_style', $style);
$GLOBALS['phpgw']->template->parse('theme_stylesheets',
'theme_stylesheet', true);
}
+ }
$app = $app ? ' ['.(isset($GLOBALS['phpgw_info']['apps'][$app]) ?
$GLOBALS['phpgw_info']['apps'][$app]['title'] : lang($app)).']':'';
Index: templates/idots/navbar.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/templates/idots/navbar.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- templates/idots/navbar.inc.php 10 Apr 2006 02:17:16 -0000 1.9
+++ templates/idots/navbar.inc.php 19 Jul 2006 01:40:11 -0000 1.10
@@ -5,7 +5,7 @@
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package phpgwapi
* @subpackage gui
- * @version $Id: navbar.inc.php,v 1.9 2006/04/10 02:17:16 skwashd Exp $
+ * @version $Id: navbar.inc.php,v 1.10 2006/07/19 01:40:11 skwashd Exp $
*/
@@ -110,7 +110,7 @@
$file[] = array('text' => 'Home',
'url' =>
$GLOBALS['phpgw_info']['navbar']['home']['url']);
- if ($GLOBALS['phpgw_info']['user']['apps']['preferences'])
+ if ( isset($GLOBALS['phpgw_info']['navbar']['preferences']))
{
$file[] = array ('text' => 'Preferences',
'url' =>
$GLOBALS['phpgw_info']['navbar']['preferences']['url']
Index: templates/idots/css/idots.css
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/templates/idots/css/idots.css,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- templates/idots/css/idots.css 12 Apr 2006 10:41:13 -0000 1.10
+++ templates/idots/css/idots.css 19 Jul 2006 01:40:11 -0000 1.11
@@ -3,7 +3,7 @@
Originally written by Pim Snel
Currently Maintained by Dave Hall
- $Id: idots.css,v 1.10 2006/04/12 10:41:13 skwashd Exp $
+ $Id: idots.css,v 1.11 2006/07/19 01:40:11 skwashd Exp $
*/
#articlecontent
@@ -118,6 +118,11 @@
width: 190px;
}
+#navpanel li.phpgw_logo img
+{
+ padding: 0px;
+}
+
#navpanel a, #navpanel a:hover
{
text-decoration: none;
@@ -128,6 +133,8 @@
-moz-opacity: 0.65; /* old mozilla/gecko */
filter: alpha(opacity=6.5); /* IE 5.5+? */
opacity: 0.65; /* CSS3 */
+ padding-top: 18px;
+ padding-bottom: 8px;
}
#navpanel a:hover img, #navpanel li.phpgw_logo a img
@@ -184,7 +191,7 @@
width: 150px;
}
-h2.sideboxtitle
+#sidecontent h2
{
background-image: url(../images/boxbg.png);
background-position: center 50%;
@@ -192,9 +199,9 @@
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
- height: 26px;
+ height: 24px;
margin: 0px;
- padding: 6px 0px 0px 0px;
+ padding: 3px 0px 0px 0px;
text-align: center;
}
Index: templates/idots/source/navbar32.xcf
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/templates/idots/source/navbar32.xcf,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
Binary files /tmp/cvsagFKgg and /tmp/cvsGiWELb differ
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi inc/class.config.inc.php inc/class.con...,
Dave Hall <=