Exemplo n.º 1
0
 /**
  * Deletes the field from fields_meta_data and drops the database column then it rebuilds the cache
  * Use the widgets get_db_modify_alter_table() method to get the table sql - some widgets do not need any custom table modifications
  * @param STRING $name - field name
  */
 function deleteField($widget)
 {
     require_once 'modules/DynamicFields/templates/Fields/TemplateField.php';
     global $beanList;
     if (!$widget instanceof TemplateField) {
         $field_name = $widget;
         $widget = new TemplateField();
         $widget->name = $field_name;
     }
     $object_name = $beanList[$this->module];
     //Some modules like cases have a bean name that doesn't match the object name
     if (empty($GLOBALS['dictionary'][$object_name])) {
         $newName = BeanFactory::getObjectName($this->module);
         $object_name = $newName != false ? $newName : $object_name;
     }
     $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='" . $this->module . $widget->name . "'");
     $sql = $widget->get_db_delete_alter_table($this->bean->table_name . "_cstm");
     if (!empty($sql)) {
         $GLOBALS['db']->query($sql);
     }
     $this->removeVardefExtension($widget);
     VardefManager::clearVardef();
     VardefManager::refreshVardefs($this->module, $object_name);
 }
Exemplo n.º 2
0
 /**
  * Deletes the field from fields_meta_data and drops the database column then it rebuilds the cache
  * Use the widgets get_db_modify_alter_table() method to get the table sql - some widgets do not need any custom table modifications
  * @param STRING $name - field name
  */
 function deleteField($widget)
 {
     require_once 'modules/DynamicFields/templates/Fields/TemplateField.php';
     global $beanList;
     if (!$widget instanceof TemplateField) {
         $field_name = $widget;
         $widget = new TemplateField();
         $widget->name = $field_name;
     }
     $object_name = $beanList[$this->module];
     if ($object_name == 'aCase') {
         $object_name = 'Case';
     }
     $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='" . $this->module . $widget->name . "'");
     $sql = $widget->get_db_delete_alter_table($this->bean->table_name . "_cstm");
     if (!empty($sql)) {
         $GLOBALS['db']->query($sql);
     }
     $this->removeVardefExtension($widget);
     VardefManager::clearVardef();
     VardefManager::refreshVardefs($this->module, $object_name);
 }