phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] property/class.soadmin_entity.php, 1.1.1.9


From: nomail
Subject: [Phpgroupware-cvs] property/class.soadmin_entity.php, 1.1.1.9
Date: Sun, 23 May 2004 04:10:39 -0000

Update of /property
Modified Files:
        Branch: 
          class.soadmin_entity.php

date: 2004/05/04 08:42:06;  author: sigurdne;  state: Exp;  lines: +36 -26

Log Message:
no message
=====================================================================
Index: property/class.soadmin_entity.php
diff -u property/class.soadmin_entity.php:1.1.1.8 
property/class.soadmin_entity.php:1.1.1.9
--- property/class.soadmin_entity.php:1.1.1.8   Mon May  3 20:56:47 2004
+++ property/class.soadmin_entity.php   Tue May  4 08:42:06 2004
@@ -425,8 +425,9 @@
                        $GLOBALS['phpgw']->db->Execute("INSERT INTO 
fm_entity_category (entity_id,id,name, 
descr,prefix,lookup_tenant,tracking,location_level,fileupload,loc_link) "
                                . "VALUES ($values_insert)");
 
+                       $acl_location_id= '.entity.' . $values['entity_id'] . 
'.' . $values['id'];
                        $values_acl_location= array(
-                               '.entity.' . $values['entity_id'] . '.' . 
$values['id'],
+                               $acl_location_id,
                                $values['name'],
                                1
                                );
@@ -503,6 +504,8 @@
                                else
                                {
                                        $GLOBALS['phpgw']->db->Execute("DELETE 
FROM fm_entity_category WHERE id=" . $values['id'] . " AND entity_id=" . 
$values['entity_id']);
+                                       $GLOBALS['phpgw']->db->Execute("DELETE 
FROM fm_acl_location WHERE id= '$acl_location_id'");
+                                       $GLOBALS['phpgw']->db->Execute("DELETE 
FROM fm_entity_attribute WHERE id = 1 AND cat_id=" . $values['id'] . " AND 
entity_id=" . $values['entity_id']);
                                        unset($receipt['id']);
 
                                }
@@ -676,12 +679,14 @@
                function delete_category($id,$entity_id)
                {
                        $this->init_process();
-                       $this->oProc->DropTable('fm_entity_' . $entity_id . '_' 
. $id);
-//                     $this->oProc->DropTable('fm_entity_' . $entity_id . '_' 
. $id . '_' . 'status');
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_entity_category WHERE entity_id= $entity_id AND id= $id");
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_entity_attribute WHERE entity_id= $entity_id AND cat_id= $id");
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_acl_location WHERE id='.entity." . $entity_id . "." . $id ."'");
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM fm_acl2 
WHERE acl_location='.entity." . $entity_id . "." . $id ."'");
+                       if($this->oProc->DropTable('fm_entity_' . $entity_id . 
'_' . $id))
+                       {
+//                             $this->oProc->DropTable('fm_entity_' . 
$entity_id . '_' . $id . '_' . 'status');
+                               $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_entity_category WHERE entity_id= $entity_id AND id= $id");
+                               $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_entity_attribute WHERE entity_id= $entity_id AND cat_id= $id");
+                               $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_acl_location WHERE id='.entity." . $entity_id . "." . $id ."'");
+                               $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_acl2 WHERE acl_location='.entity." . $entity_id . "." . $id ."'");
+                       }
                }
 
                function delete_attrib($cat_id,$entity_id,$attrib_id)
@@ -693,21 +698,28 @@
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        $ColumnName             = 
$dbresult->fields['column_name'];
 
-                       $this->oProc->DropColumn('fm_entity_' .$entity_id.'_'. 
$cat_id,'', $ColumnName);
+                       if($this->oProc->DropColumn('fm_entity_' 
.$entity_id.'_'. $cat_id, $ColumnName))
+                       {
+                               $sql = "SELECT attrib_sort FROM 
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id AND 
id=$attrib_id";
+                               $dbresult = 
$GLOBALS['phpgw']->db->Execute($sql);
+                               $attrib_sort    = 
$dbresult->fields['attrib_sort'];
+                               $sql2 = "SELECT max(attrib_sort) as max_sort 
FROM fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
+                               $dbresult = 
$GLOBALS['phpgw']->db->Execute($sql2);
+                               $max_sort       = $dbresult->fields['max_sort'];
+                               if($max_sort>$attrib_sort)
+                               {
+                                       $sql = "UPDATE fm_entity_attribute set 
attrib_sort=attrib_sort-1 WHERE entity_id=$entity_id AND cat_id=$cat_id AND 
attrib_sort > $attrib_sort";
+                                       $GLOBALS['phpgw']->db->Execute($sql);
+                               }
 
-                       $sql = "SELECT attrib_sort FROM fm_entity_attribute 
where entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
-                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-                       $attrib_sort    = $dbresult->fields['attrib_sort'];
-                       $sql2 = "SELECT max(attrib_sort) as max_sort FROM 
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
-                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql2);
-                       $max_sort       = $dbresult->fields['max_sort'];
-                       if($max_sort>$attrib_sort)
+                               $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_entity_attribute WHERE entity_id=$entity_id AND cat_id=$cat_id AND 
id=$attrib_id");
+                       }
+                       else
                        {
-                               $sql = "UPDATE fm_entity_attribute set 
attrib_sort=attrib_sort-1 WHERE entity_id=$entity_id AND cat_id=$cat_id AND 
attrib_sort > $attrib_sort";
-                               $GLOBALS['phpgw']->db->Execute($sql);
+                               $receipt['error'][] = array('msg'       => 
lang('Attribute has NOT been deleted'));
                        }
 
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_entity_attribute WHERE entity_id=$entity_id AND cat_id=$cat_id AND 
id=$attrib_id");
+                       return $receipt;
                }
 
                function delete_status($cat_id,$entity_id,$status_id)
@@ -927,9 +939,6 @@
                function init_process()
                {
                        $this->oProc            = 
CreateObject($this->currentapp.'_oproc');
-//                     $this->oProc                                            
= 
CreateObject('phpgwapi_schema_proc',$GLOBALS['phpgw_data']['server']['db_type']);
-//                     $this->oProc->m_odb                                     
= $this->db;
-//                     $this->oProc->m_odb->Halt_On_Error      = 'report';
                }
 
                function edit_attrib($attrib)
@@ -940,12 +949,14 @@
                        $attrib['statustext'] = 
$this->functions->db_addslashes($attrib['statustext']);
                        $attrib['default'] = 
$this->functions->db_addslashes($attrib['default']);
 
-                       $GLOBALS['phpgw']->db->Execute("SELECT column_name FROM 
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" . 
$attrib['cat_id']. " AND id='" . $attrib['id']. "'");
+                       $choice_table = 'fm_entity_choice';
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND 
cat_id=" . $attrib['cat_id']. " AND id='" . $attrib['id']. "'");
                        $OldColumnName          = 
$dbresult->fields['column_name'];
 
                        $GLOBALS['phpgw']->db->begintrans();
 
-                       if($OldColumnName !=$attrib['column_name'])
+                       if(($OldColumnName !=$attrib['column_name']) || 
($attrib['column_info']['type'] != $dbresult->fields['datatype']))
                        {
 
                                $value_set=array(
@@ -984,11 +995,10 @@
 
                                $this->init_process();
 
-                               
$this->oProc->RenameColumn('fm_entity_'.$attrib['entity_id'] . '_' . 
$attrib['cat_id'], $OldColumnName, $attrib['column_name']);
-                               
$this->oProc->AlterColumn('fm_entity_'.$attrib['entity_id'] . '_' . 
$attrib['cat_id'],$attrib['column_name'],$attrib['column_info']);
+                               
//$this->oProc->RenameColumn('fm_entity_'.$attrib['entity_id'] . '_' . 
$attrib['cat_id'], $OldColumnName, $attrib['column_name']);
+                               
$this->oProc->AlterColumn('fm_entity_'.$attrib['entity_id'] . '_' . 
$attrib['cat_id'],$OldColumnName,$attrib['column_name'],$attrib['column_info']);
                        }
 
-                       $choice_table ='fm_entity_choice';
 
                        if($attrib['new_choice'])
                        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]