/**
  * @ticket 39407
  */
 public function testRemoveFieldFromLayoutsDocumentsException()
 {
     $SM = new StudioModule("Documents");
     try {
         $SM->removeFieldFromLayouts("aFieldThatDoesntExist");
         $this->assertTrue(true);
     } catch (Exception $e) {
         $this->assertTrue(false, "Studio module threw exception :" . $e->getMessage());
     }
 }
Esempio n. 2
0
 /**
  * @ticket 39407
  *
  */
 public function testRemoveFieldFromLayoutsDocumentsException()
 {
     $this->markTestSkipped('Skip this test');
     $SM = new StudioModule("Documents");
     try {
         $SM->removeFieldFromLayouts("aFieldThatDoesntExist");
         $this->assertTrue(true);
     } catch (Exception $e) {
         //Studio module threw exception
         $this->assertTrue(true);
     }
 }
Esempio n. 3
0
 function uninstall_relationships($include_studio_relationships = false)
 {
     $relationships = array();
     //Find and remove studio created relationships.
     global $beanList, $beanFiles, $dictionary;
     //Load up the custom relationship definitions.
     if (file_exists('custom/application/Ext/TableDictionary/tabledictionary.ext.php')) {
         include 'custom/application/Ext/TableDictionary/tabledictionary.ext.php';
     }
     //Find all the relatioships/relate fields involving this module.
     $rels_to_remove = array();
     foreach ($beanList as $mod => $bean) {
         //Some modules like cases have a bean name that doesn't match the object name
         $bean = BeanFactory::getObjectName($mod);
         VardefManager::loadVardef($mod, $bean);
         //We can skip modules that are in this package as they will be removed anyhow
         if (!in_array($mod, $this->modulesInPackage) && !empty($dictionary[$bean]) && !empty($dictionary[$bean]['fields'])) {
             $field_defs = $dictionary[$bean]['fields'];
             foreach ($field_defs as $field => $def) {
                 //Weed out most fields first
                 if (isset($def['type'])) {
                     //Custom relationships created in the relationship editor
                     if ($def['type'] == "link" && !empty($def['relationship']) && !empty($dictionary[$def['relationship']])) {
                         $rel_name = $def['relationship'];
                         $rel_def = $dictionary[$rel_name]['relationships'][$rel_name];
                         //Check against mods to be removed.
                         foreach ($this->modulesInPackage as $removed_mod) {
                             if ($rel_def['lhs_module'] == $removed_mod || $rel_def['rhs_module'] == $removed_mod) {
                                 $dictionary[$rel_name]['from_studio'] = true;
                                 $relationships[$rel_name] = $dictionary[$rel_name];
                             }
                         }
                     }
                     //Custom "relate" fields created in studio also need to be removed
                     if ($def['type'] == 'relate' && isset($def['module'])) {
                         foreach ($this->modulesInPackage as $removed_mod) {
                             if ($def['module'] == $removed_mod) {
                                 require_once 'modules/ModuleBuilder/Module/StudioModule.php';
                                 $studioMod = new StudioModule($mod);
                                 $studioMod->removeFieldFromLayouts($field);
                                 if (isset($def['custom_module'])) {
                                     require_once 'modules/DynamicFields/DynamicField.php';
                                     require_once $beanFiles[$bean];
                                     $seed = new $bean();
                                     $df = new DynamicField($mod);
                                     $df->setup($seed);
                                     //Need to load the entire field_meta_data for some field types
                                     $field_obj = $df->getFieldWidget($mod, $field);
                                     $field_obj->delete($df);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->uninstall_relationship(null, $relationships);
     if (isset($this->installdefs['relationships'])) {
         $relationships = $this->installdefs['relationships'];
         $this->log(translate('LBL_MI_UN_RELATIONSHIPS'));
         foreach ($relationships as $relationship) {
             // remove the metadata entry
             $filename = basename($relationship['meta_data']);
             $pathname = file_exists("custom/metadata/{$filename}") ? "custom/metadata/{$filename}" : "metadata/{$filename}";
             if (isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables']) {
                 $this->uninstall_relationship($pathname);
             }
             if (file_exists($pathname)) {
                 unlink($pathname);
             }
         }
     }
     if (file_exists("custom/Extension/application/Ext/TableDictionary/{$this->id_name}.php")) {
         unlink("custom/Extension/application/Ext/TableDictionary/{$this->id_name}.php");
     }
     Relationship::delete_cache();
     $this->rebuild_tabledictionary();
 }