[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] admin/inc class.so_custom.inc.php
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] admin/inc class.so_custom.inc.php |
Date: |
Sun, 19 Nov 2006 12:42:09 +0000 |
CVSROOT: /sources/phpgroupware
Module name: admin
Changes by: Sigurd Nes <sigurdne> 06/11/19 12:42:09
Removed files:
inc : class.so_custom.inc.php
Log message:
obsolete - clean up
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/admin/inc/class.so_custom.inc.php?cvsroot=phpgroupware&r1=1.5&r2=0
Patches:
Index: class.so_custom.inc.php
===================================================================
RCS file: class.so_custom.inc.php
diff -N class.so_custom.inc.php
--- class.so_custom.inc.php 9 Oct 2006 10:44:29 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,731 +0,0 @@
-<?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 admin
- * @version $Id: class.so_custom.inc.php,v 1.5 2006/10/09 10:44:29
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class so_custom
- {
- var $grants;
-
- function so_custom($appname='',$location='')
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->db = $this->bocommon->new_db();
- $this->db2 = $this->bocommon->new_db();
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
-
- if($appname && $location)
- {
- $this->category_name =
$this->read_category_name($appname,$location);
- }
- }
-
-
-
- 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');
- $sql2 = "SELECT max(attrib_sort) as max_sort FROM
phpgw_cust_attribute 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>$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 read_attrib($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $appname =
(isset($data['appname'])?$data['appname']:0);
- $location =
(isset($data['location'])?$data['location']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by attrib_sort asc';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (phpgw_cust_attribute.name
$this->like '%$query%' or phpgw_cust_attribute.descr $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM phpgw_cust_attribute WHERE
appname='$appname' AND location = '$location' $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $attrib[] = array
- (
- 'id' => $this->db->f('id'),
- 'entity_type' =>
$this->db->f('type_id'),
- 'attrib_sort' =>
$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'),
- 'size' => $this->db->f('size'),
- 'statustext' =>
$this->db->f('statustext'),
- 'input_text' =>
$this->db->f('input_text'),
- 'type_name' => $this->db->f('type'),
- 'datatype' =>
$this->db->f('datatype'),
- 'search' =>
$this->db->f('search')
- );
- }
- return $attrib;
- }
-
- function read_single_attrib($appname,$location,$id)
- {
- $sql = "SELECT * FROM phpgw_cust_attribute where
appname='$appname' AND location='$location' AND id=$id";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $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;
- }
- }
-
- function read_attrib_choice($appname,$location,$attrib_id)
- {
- $choice_table = 'phpgw_cust_choice';
- $sql = "SELECT * FROM $choice_table WHERE
appname='$appname' AND location='$location' AND attrib_id=$attrib_id";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'value' => $this->db->f('value')
- );
- }
- return $choice;
- }
-
-
- 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');
- }
-
- function add_attrib($attrib)
- {
- $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']
- );
-
- $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'])
- {
- if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
- {
-
$attrib['column_info']['precision']=$precision;
- }
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->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;
- }
-
- 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';
- }
-
- 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'])
- {
- $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->bocommon->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->bocommon->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 resort_attrib($data)
- {
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $appname =
(isset($data['appname'])?$data['appname']:0);
- $location =
(isset($data['location'])?$data['location']:0);
- $id = (isset($data['id'])?$data['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');
- $sql2 = "SELECT max(attrib_sort) as max_sort FROM
phpgw_cust_attribute where appname='$appname' AND location='$location'";
- $this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
-
- switch($resort)
- {
- 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;
- 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:
- return;
- break;
- }
- $this->db->transaction_commit();
- }
-
- function read_custom_function($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $appname =
(isset($data['appname'])?$data['appname']:'');
- $location =
(isset($data['location'])?$data['location']:'');
- }
-
- if(!$location || !$appname)
- {
- return;
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by custom_sort asc';
- }
-
- $table = 'phpgw_cust_function';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND file_name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table WHERE appname='$appname'
AND location='$location' $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $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')
- );
- }
- return $custom_function;
- }
-
-
- function read_single_custom_function($appname,$location,$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())
- {
- $custom_function['id'] =
$this->db->f('id');
- $custom_function['descr'] =
$this->db->f('descr');
- $custom_function['custom_function_file']=
$this->db->f('file_name');
- $custom_function['active'] =
$this->db->f('active');
-
- return $custom_function;
- }
-
- }
-
- function add_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();
- $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;
- }
-
- 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;
- }
-
- function resort_custom_function($data)
- {
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $appname =
(isset($data['appname'])?$data['appname']:'');
- $location =
(isset($data['location'])?$data['location']:'');
- $id = (isset($data['id'])?$data['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');
- $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');
-
- switch($resort)
- {
- 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;
- 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:
- return;
- break;
- }
- $this->db->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();
- }
- }
-?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] admin/inc class.so_custom.inc.php,
Sigurd Nes <=