function process($option)
 {
     switch ($option) {
         case 'ViewCustomFields':
             parent::process($option);
             require_once 'modules/Studio/EditCustomFields/ListView.php';
             break;
         case 'CreateCustomFields':
             if (empty($_REQUEST['to_pdf'])) {
                 parent::process($option);
             }
             require_once 'modules/Studio/EditCustomFields/EditView.php';
             break;
         case 'SaveCustomField':
             require_once 'modules/Studio/EditCustomFields/Save.php';
             break;
         case 'DeleteCustomField':
             require_once 'modules/Studio/EditCustomFields/Delete.php';
             break;
         case 'EditCustomField':
             parent::process($option);
             require_once 'modules/Studio/EditCustomFields/EditView.php';
             break;
         case 'ClearCache':
             require_once 'modules/DynamicFields/DynamicField.php';
             DynamicField::deleteCache();
             echo '<script>YAHOO.util.Event.addListener(window, "load", function(){ajaxStatus.showStatus("cache cleared");window.setTimeout(\'ajaxStatus.hideStatus();\', 2000);});</script>';
             parent::process($option);
             break;
         case 'RepairCustomFields':
             header('Location: index.php?module=Administration&action=UpgradeFields');
             sugar_cleanup(true);
         default:
             parent::process($option);
     }
 }
예제 #2
0
 /**
  * Delete the primary table for the module implementing the class.
  * If custom fields were added to this table/module, the custom table will be removed too, along with the cache
  * entries that define the custom fields.
  *
  */
 function drop_tables()
 {
     global $dictionary;
     $key = $this->getObjectName();
     if (!array_key_exists($key, $dictionary)) {
         $GLOBALS['log']->fatal("drop_tables: Metadata for table " . $this->table_name . " does not exist");
         echo "meta data absent for table " . $this->table_name . "<br>\n";
     } else {
         if (empty($this->table_name)) {
             return;
         }
         if ($this->db->tableExists($this->table_name)) {
             $this->dbManager->dropTable($this);
         }
         if ($this->db->tableExists($this->table_name . '_cstm')) {
             $this->dbManager->dropTableName($this->table_name . '_cstm');
             DynamicField::deleteCache();
         }
         if ($this->db->tableExists($this->get_audit_table_name())) {
             $this->dbManager->dropTableName($this->get_audit_table_name());
         }
     }
 }
            }
            unset($fields[$col]);
            echo "Dropping Column {$col} from {$mod->table_name}" . "_cstm for module {$the_module}<br>";
        } else {
            if ($col != 'id_c') {
                //$db_data_type = $dbManager->helper->getColumnType(strtolower($the_field->data_type));
                $db_data_type = strtolower(str_replace(' ', '', $the_field->get_db_type()));
                $type = strtolower(str_replace(' ', '', $type));
                if (strcmp($db_data_type, $type) != 0) {
                    echo "Fixing Column Type for {$col} changing {$type} to " . $db_data_type . "<br>";
                    if (!$simulate) {
                        $db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm'));
                    }
                }
            }
            unset($fields[$col]);
        }
    }
    echo sizeof($fields) . " field(s) missing from {$mod->table_name}" . "_cstm<br>";
    foreach ($fields as $field) {
        echo "Adding Column {$field} to {$mod->table_name}" . "_cstm<br>";
        if (!$simulate) {
            $mod->custom_fields->add_existing_custom_field($field);
        }
    }
}
DynamicField::deleteCache();
echo '<br>Done<br>';
if ($simulate) {
    echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>';
}
 function dropFieldById($id)
 {
     $result = $GLOBALS['db']->query("SELECT custom_module, name FROM fields_meta_data WHERE id='{$id}'");
     if ($row = $GLOBALS['db']->fetchByAssoc($result)) {
         $GLOBALS['db']->query("DELETE FROM  fields_meta_data WHERE id='{$id}'");
         $db_name = ' COLUMN ' . $row['name'];
         $module = $row['custom_module'];
         if (!empty($GLOBALS['beanList'][$module])) {
             $class = $GLOBALS['beanList'][$module];
             require_once $GLOBALS['beanFiles'][$class];
             $mod = new $class();
             $GLOBALS['db']->query("ALTER TABLE " . $mod->table_name . "_cstm DROP {$db_name}");
         }
     }
     DynamicField::deleteCache();
 }