[20872] Clean?\194?\160up?\194?\160locations, ?\194?\160custom?\194? \160fields?\194?\160and?\194?\160ACL on uninstall

Sigurd Nes <[email protected]>
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 20872
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20872
Author:   sigurdne
Date:     2009-11-21 11:01:46 +0000 (Sat, 21 Nov 2009)
Log Message:
-----------
Clean?\194?\160up?\194?\160locations,?\194?\160custom?\194?\160fields?\194?\160and?\194?\160ACL on uninstall

Modified Paths:
--------------
    people/sigurdne/modules/phpgwapi/trunk/inc/class.setup.inc.php

Modified: people/sigurdne/modules/phpgwapi/trunk/inc/class.setup.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/class.setup.inc.php	2009-11-21 10:43:36 UTC (rev 20871)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/class.setup.inc.php	2009-11-21 11:01:46 UTC (rev 20872)
@@ -530,6 +530,28 @@
 			$appname = $this->db->db_addslashes($appname);
 			$setup_info =& $GLOBALS['setup_info'];
 
+			// Clean up locations, custom fields and ACL
+			$this->db->query("SELECT app_id FROM phpgw_applications WHERE app_name = '{$appname}'");
+			$this->db->next_record();
+			$app_id = $this->db->f('app_id');
+
+			$this->db->query("SELECT location_id FROM phpgw_locations WHERE app_id = {$app_id}");
+
+			$locations = array();
+			while ($this->db->next_record())
+			{
+				$locations[] = $this->db->f('location_id');
+			}
+
+			if(count($locations))
+			{
+				$this->db->query('DELETE FROM phpgw_cust_choice WHERE location_id IN ('. implode (',',$locations) . ')');
+				$this->db->query('DELETE FROM phpgw_cust_attribute WHERE location_id IN ('. implode (',',$locations). ')');
+				$this->db->query('DELETE FROM phpgw_acl  WHERE location_id IN ('. implode (',',$locations) . ')');
+			}
+
+			$this->db->query("DELETE FROM phpgw_locations WHERE app_id = {$app_id}");
+
 			//echo 'DELETING application: ' . $appname;
 			$this->db->query("DELETE FROM phpgw_applications WHERE app_name='{$appname}'",__LINE__,__FILE__);
 			$this->clear_session_cache();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.