/** * This method has been deprecated. * * @see removeRelationshipMeta() * @deprecated 4.5.1 - Nov 14, 2006 * @static */ function remove_relationship_meta($key, $db, $log, $tablename, $dictionary, $module_dir) { SugarBean::removeRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir); }
function uninstall_relationship($file, $rel_dictionary = null) { if ($rel_dictionary == null) { if (!file_exists($file)) { $GLOBALS['log']->debug('File does not exists : ' . $file); return; } include $file; $rel_dictionary = $dictionary; } foreach ($rel_dictionary as $rel_name => $rel_data) { if (!empty($rel_data['table'])) { $table = $rel_data['table']; } else { $table = ' One-to-Many '; } if ($this->db->tableExists($table) && isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables']) { SugarBean::removeRelationshipMeta($rel_name, $this->db, $table, $rel_dictionary, ''); $this->db->dropTableName($table); if (!$this->silent) { $this->log(translate('LBL_MI_UN_RELATIONSHIPS_DROP') . $table); } } //Delete Layout defs // check to see if we have any vardef or layoutdef entries to remove - must have a relationship['module'] parameter if we do if (!isset($rel_data['module'])) { $mods = array($rel_data['relationships'][$rel_name]['lhs_module'], $rel_data['relationships'][$rel_name]['rhs_module']); } else { $mods = array($rel_data['module']); } $filename = "{$rel_name}.php"; foreach ($mods as $mod) { if ($mod != 'application') { $basepath = "custom/Extension/modules/{$mod}/Ext/"; } else { $basepath = "custom/Extension/application/Ext/"; } foreach (array($filename, "custom" . $filename, $rel_name . "_" . $mod . ".php") as $fn) { //remove any vardefs $path = $basepath . "Vardefs/{$fn}"; if (file_exists($path)) { rmdir_recursive($path); } //remove any layoutdefs $path = $basepath . "Layoutdefs/{$fn}"; if (file_exists($path)) { rmdir_recursive($path); } // Remove any wireless layoutdefs $path = $basepath . "WirelessLayoutdefs/{$fn}"; if (file_exists($path)) { rmdir_recursive($path); } } // remove the subpanel layoutdefs for the relationship $subpanelFileNames = array("{$rel_name}_{$mod}.php", "_overridesubpanel-for-" . strtolower($mod) . "-{$rel_name}.php"); foreach (glob("{$basepath}/clients/*", GLOB_NOSORT | GLOB_ONLYDIR) as $path) { foreach (glob($path . "/layouts/subpanels/*.php", GLOB_NOSORT) as $file) { $baseFile = basename($file); if (in_array($baseFile, $subpanelFileNames)) { unlink($file); } } } // Need to remove stale dashlets for the Activities relationship if (isset($rel_data['relationships'][$rel_name]) && file_exists('modules/' . $mod)) { // Not our relationship $ourRel = $rel_data['relationships'][$rel_name]; $globPath = 'modules/' . $mod . '/clients/base/views/*'; foreach (glob($globPath, GLOB_NOSORT | GLOB_ONLYDIR) as $viewPath) { $platform = 'base'; $view = basename($viewPath); if ($view != 'history' && $view != 'attachments' && $view != 'planned-activities') { continue; } $viewMetaFile = $viewPath . "/" . $view . ".php"; if (!file_exists($viewMetaFile)) { continue; } include $viewMetaFile; if (!isset($viewdefs[$ourRel['lhs_module']][$platform]['view'][$view]['tabs'][0]['link'])) { continue; } foreach ($viewdefs[$ourRel['lhs_module']][$platform]['view'][$view]['tabs'] as $viewTab) { if ($viewTab['link'] == $rel_name) { rmdir_recursive(dirname($viewPath)); } } } } // Remove relationship metadata $basepath = "custom/Extension/modules/relationships/*/"; foreach (array($rel_name . "_" . $mod . ".php", $rel_name . "MetaData.php") as $fileName) { foreach (glob($basepath . $fileName, GLOB_NOSORT) as $file) { unlink($file); } } } foreach (array($filename, "custom" . $filename, $rel_name . "_" . $mod . ".php") as $fn) { // remove the table dictionary extension if (file_exists("custom/Extension/application/Ext/TableDictionary/{$fn}")) { unlink("custom/Extension/application/Ext/TableDictionary/{$fn}"); } if (file_exists("custom/metadata/{$rel_name}MetaData.php")) { unlink("custom/metadata/{$rel_name}MetaData.php"); } } } }
function uninstall_relationship($file, $rel_dictionary = null) { if ($rel_dictionary == null) { if (!file_exists($file)) { $GLOBALS['log']->debug('File does not exists : ' . $file); return; } include $file; $rel_dictionary = $dictionary; } foreach ($rel_dictionary as $rel_name => $rel_data) { if (!empty($rel_data['table'])) { $table = $rel_data['table']; } else { $table = ' One-to-Many '; } if ($this->db->tableExists($table) && isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables']) { SugarBean::removeRelationshipMeta($rel_name, $this->db, $table, $rel_dictionary, ''); $this->db->dropTableName($table); if (!$this->silent) { $this->log(translate('LBL_MI_UN_RELATIONSHIPS_DROP') . $table); } } //Delete Layout defs // check to see if we have any vardef or layoutdef entries to remove - must have a relationship['module'] parameter if we do if (!isset($rel_data['module'])) { $mods = array($rel_data['relationships'][$rel_name]['lhs_module'], $rel_data['relationships'][$rel_name]['rhs_module']); } else { $mods = array($rel_data['module']); } $filename = "{$rel_name}.php"; foreach ($mods as $mod) { if ($mod != 'application') { $basepath = "custom/Extension/modules/{$mod}/Ext/"; } else { $basepath = "custom/Extension/application/Ext/"; } foreach (array($filename, "custom" . $filename, $rel_name . "_" . $mod . ".php") as $fn) { //remove any vardefs $path = $basepath . "Vardefs/{$fn}"; if (file_exists($path)) { rmdir_recursive($path); } //remove any layoutdefs $path = $basepath . "Layoutdefs/{$fn}"; if (file_exists($path)) { rmdir_recursive($path); } $path = $basepath . "WirelessLayoutdefs/{$fn}"; if (file_exists($path)) { rmdir_recursive($path); } } $relationships_path = 'custom/Extension/modules/relationships/'; $relationships_dirs = array('layoutdefs', 'vardefs', 'wirelesslayoutdefs'); foreach ($relationships_dirs as $relationship_dir) { $realtionship_file_path = $relationships_path . $relationship_dir . "/{$rel_name}_{$mod}.php"; if (file_exists($realtionship_file_path)) { rmdir_recursive($realtionship_file_path); } } if (file_exists($relationships_path . "relationships/{$rel_name}MetaData.php")) { rmdir_recursive($relationships_path . "relationships/{$rel_name}MetaData.php"); } } foreach (array($filename, "custom" . $filename, $rel_name . "_" . $mod . ".php") as $fn) { // remove the table dictionary extension if (file_exists("custom/Extension/application/Ext/TableDictionary/{$fn}")) { unlink("custom/Extension/application/Ext/TableDictionary/{$fn}"); } if (file_exists("custom/metadata/{$rel_name}MetaData.php")) { unlink("custom/metadata/{$rel_name}MetaData.php"); } } } }
function uninstall_relationship($file) { if (!file_exists($file)) { $GLOBALS['log']->debug('File does not exists : ' . $file); return; } include_once $file; $rel_dictionary = $dictionary; foreach ($rel_dictionary as $rel_name => $rel_data) { $table = $rel_data['table']; if ($this->db->tableExists($table)) { SugarBean::removeRelationshipMeta($rel_name, $this->db, $table, $rel_dictionary, ''); $this->db->dropTableName($table); Relationship::delete_cache(); if (!$this->silent) { $GLOBALS['log']->debug('droping table ' . $table); } } } }