[Vtigercrm-commits] [vtiger-commits] r3942 - in /vtigercrm/branches/4.2: install.php install/5createTables.inc.php install/5createTables.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Sun Feb 26 23:57:30 EST 2006
Author: mfedyk
Date: Sun Feb 26 21:57:27 2006
New Revision: 3942
Log:
create install/5createTables.inc.php and modify install.php to use it when called from the command line. see #28
Added:
vtigercrm/branches/4.2/install/5createTables.inc.php
- copied, changed from r3915, vtigercrm/branches/4.2/install/5createTables.php
Modified:
vtigercrm/branches/4.2/install.php
vtigercrm/branches/4.2/install/5createTables.php
Modified: vtigercrm/branches/4.2/install.php
==============================================================================
--- vtigercrm/branches/4.2/install.php (original)
+++ vtigercrm/branches/4.2/install.php Sun Feb 26 21:57:27 2006
@@ -34,6 +34,12 @@
$_GET = array_map("stripslashes_checkstrings", $_GET);
}
+//Run command line if no web var detected
+if (!isset($_SERVER['REQUEST_METHOD'])) {
+ require("install/5createTables.inc.php");
+ exit;
+}
+
if (isset($_POST['file']))
$the_file = $_POST['file'];
else
Modified: vtigercrm/branches/4.2/install/5createTables.php
==============================================================================
--- vtigercrm/branches/4.2/install/5createTables.php (original)
+++ vtigercrm/branches/4.2/install/5createTables.php Sun Feb 26 21:57:27 2006
@@ -37,170 +37,7 @@
if (isset($_REQUEST['admin_password']))
$admin_password = $_REQUEST['admin_password'];
-$new_tables = 0;
-
-require_once('include/database/PearDatabase.php');
-require_once('include/logging.php');
-require_once('modules/Leads/Lead.php');
-require_once('modules/Settings/FileStorage.php');
-//require_once('modules/imports/Headers.php');
-require_once('modules/Contacts/Contact.php');
-require_once('modules/Accounts/Account.php');
-require_once('modules/Potentials/Opportunity.php');
-require_once('modules/Activities/Activity.php');
-require_once('modules/Notes/Note.php');
-require_once('modules/Emails/Email.php');
-require_once('modules/Users/User.php');
-require_once('modules/Import/SugarFile.php');
-require_once('modules/Import/ImportMap.php');
-require_once('modules/Import/UsersLastImport.php');
-require_once('modules/Users/TabMenu.php');
-require_once('modules/Users/LoginHistory.php');
-require_once('modules/Settings/FileStorage.php');
-require_once('data/Tracker.php');
-require_once('include/utils.php');
-require_once('modules/Users/Security.php');
-
-// load the config.override.php file to provide default user settings
-if (is_file("config.override.php")) {
- require_once("config.override.php");
-}
-
-$db = new PearDatabase();
-
-$log =& LoggerManager::getLogger('create_table');
-
-function createSchemaTable() {
- global $log;
-
- // create the schema tables
- $query = "CREATE TABLE modules (id int(11) NOT NULL auto_increment, name text,PRIMARY KEY ( ID ))";
-
- $this->query($query);
-}
-
-function createObjectTable() {
- global $log;
-
- // create the object tables
- $query = "CREATE TABLE objects (module_id int(11), name text, PRIMARY KEY ( module_id, name ))";
-
- $this->query($query);
-}
-
-function createAttributesTable() {
- global $log;
-
- // create the attributes tables
- $query = "CREATE TABLE attributes (module_id int(11), object_name text, name text, PRIMARY KEY ( module_id, object_name ))";
- // fk module_id, object_name -> object table.
-
- $this->query($query);
-}
-
-function createLabelsTable() {
- global $log;
-
- // create the translation tables
- $query = "CREATE TABLE labels (module_id int(11), name text, value text, value_long text, value_popup text, PRIMARY KEY ( module_id, name ))";
-
- $this->query($query);
-}
-
-// drop old tables if table exists and told to drop it
-function drop_table_install(&$focus) {
- global $log, $db;
-
- $result = $db->requireSingleResult("SHOW TABLES LIKE '".$focus->table_name."'");
-
- if (!empty($result)) {
- $focus->drop_tables();
- $log->info("Dropped old ".$focus->table_name." table.");
- return 1;
- }
- else {
- $log->info("Did not need to drop old ".$focus->table_name." table. It doesn't exist.");
- return 0;
- }
-}
-
-// create new tables if they don't exist.
-function create_table_install(&$focus) {
- global $log, $db;
-
- $result = $db->query("SHOW TABLES LIKE '".$focus->table_name."'");
-
- if ($db->getRowCount($result) == 0) {
- $focus->create_tables();
- $log->info("Created ".$focus->table_name." table.");
- return 1;
- }
- else {
- $log->info("Table ".$focus->table_name." already exists.");
- return 0;
- }
-}
-
-function create_default_users() {
- global $log, $db;
- global $admin_email;
- global $admin_password;
- global $create_default_user;
- global $default_user_name;
- global $default_password;
- global $default_user_is_admin;
-
- // create default admin user
- $user = new User();
- $user->last_name = 'Administrator';
- $user->user_name = 'admin';
- $user->status = 'Active';
- $user->is_admin = 'on';
- $user->user_password = $user->encrypt_password($admin_password);
- $user->tz = 'Europe/Berlin';
- $user->holidays = 'de,en_uk,fr,it,us,';
- $user->workdays = '0,1,2,3,4,5,6,';
- $user->weekstart = '1';
- $user->namedays = '';
- $user->date_format = 'yyyy-mm-dd';
- $user->email = $admin_email;
- $user->save();
-
- // we need to change the admin user to a fixed id of 1.
- //$query = "update users set id='1' where user_name='$user->user_name'";
- //$result = $db->query($query, true, "Error updating admin user ID: ");
-
- $log->info("Created ".$user->table_name." table. for user $user->id");
-
- if($create_default_user) {
- $default_user = new User();
- $default_user->last_name = $default_user_name;
- $default_user->user_name = $default_user_name;
- $default_user->status = 'Active';
-
- if (isset($default_user_is_admin) && $default_user_is_admin)
- $default_user->is_admin = 'on';
-
- $default_user->user_password = $default_user->encrypt_password($default_password);
- $default_user->tz = 'Europe/Berlin';
- $default_user->holidays = 'de,en_uk,fr,it,us,';
- $default_user->workdays = '0,1,2,3,4,5,6,';
- $default_user->weekstart = '1';
- $default_user->namedays = '';
- $default_user->save();
- }
-
- // insert values into user2role table
- $role_query = "select roleid from role where name='administrator'";
- $db->database->SetFetchMode(ADODB_FETCH_ASSOC);
- $role_result = $db->query($role_query);
- $role_id = $db->query_result($role_result,0,"roleid");
-
- $sql_stmt1 = "insert into user2role values(".$user->id.",".$role_id.")";
- $db->query($sql_stmt1) or die($app_strings['ERR_CREATING_TABLE'].mysql_error());
-}
?>
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
@@ -237,193 +74,14 @@
<tr>
<td>
<?php
-$startTime = microtime();
-$modules = array(
- "Contact"
- ,"Account"
- ,"potential"
- ,"Lead"
- ,"Tab"
- ,"Security"
- ,"LoginHistory"
- ,"FileStorage"
- ,"User"
- ,"Tracker"
- ,"Activity"
- ,"Note"
- ,"Email"
- ,"SugarFile"
- ,"ImportMap"
- ,"UsersLastImport"
-);
+// Output html instead of plain text for the web
+$useHtmlEntities = true;
-$focus = 0;
-
-// tables creation
-
-// temporary
-require_once('config.php');
-
-$success = $db->createTables("schema/DatabaseSchema.xml");
-
-// TODO HTML
-if($success==0)
- print("Tables not created");
-else if($success==1)
- print("Tables partially created");
-else
- print("Tables Successfully created");
-
-foreach ( $modules as $module ) {
- $focus = new $module();
-
- /*
- if ($db_drop_tables == true ) {
- $existed = drop_table_install($focus);
-
- if ($existed)
- echo "<font color=red>Dropped existing ".$focus->table_name." table</font><BR>\n";
- else
- echo "<font color=green>Table ".$focus->table_name." does not exist</font><BR>\n";
- }
-
- $success = create_table_install($focus);
-
- if ( $success) {
- echo "<font color=green>Created new ".$focus->table_name." table</font><BR>\n";
-
- if ( $module == "User")
- $new_tables = 1;
- }
- else
- echo "Table ".$focus->table_name." already exists<BR>\n";
- */
-
- $focus->create_tables(); // inserts only rows
-}
-
-/*
-if ($new_tables)
- create_default_users();
-*/
-
-/*
-if($success==2) {
-*/
- create_default_users();
-//}
-
-// populate users table
-$uid = $db->getUniqueID("users");
-$sql_stmt1 = "insert into users(id,user_name,user_password,last_name,email1,date_format) values(".$uid.",'standarduser','stX/AHHNK/Gkw','standarduser','standarduser at standard.user.com','yyyy-mm-dd')";
-$db->query($sql_stmt1) or die($app_strings['ERR_CREATING_TABLE'].mysql_error());
-
-//$sql_stmt1 = "insert into user2role values(1,1)";
-//$db->query($sql_stmt1) or die($app_strings['ERR_CREATING_TABLE'].mysql_error());
-
-$role_query = "select roleid from role where name='standard_user'";
-$db->database->SetFetchMode(ADODB_FETCH_ASSOC);
-$role_result = $db->query($role_query);
-$role_id = $db->query_result($role_result,0,"roleid");
-
-$sql_stmt2 = "insert into user2role values(".$uid.",".$role_id.")";
-$db->query($sql_stmt2) or die($app_strings['ERR_CREATING_TABLE'].mysql_error());
-
-// create and populate combo tables
-require_once('include/PopulateComboValues.php');
-$combo = new PopulateComboValues();
-$combo->create_tables();
-
-// create and populate custom field tables;
-require_once('include/PopulateCustomFieldTables.php');
-create_custom_field_tables();
-
-// default report population
-require_once('modules/Reports/PopulateReports.php');
-
-// default customview population
-require_once('modules/CustomView/PopulateCustomView.php');
-
-// create and Populate PHPBB tables and data
-//require_once('include/PopulatePhpBBtables.php');
-//create_populate_phpbb();
-
-// populate the db with seed data
-if ($db_populate) {
- echo "Populate seed data into $db_name";
- include("install/populateSeedData.php");
- echo "...<font color=\"00CC00\">done</font><BR><P>\n";
-}
-
-// populate forums data
-global $log, $db;
-/*
-$db->query("update phpbb_config set config_value='".$admin_email."' where config_name='board_email'");
-$db->query("update phpbb_config set config_value='modules/MessageBoard/images/smiles' where config_name='smilies_path'");
-$db->query("update phpbb_config set config_value='".$server_name."' where config_name='server_name'");
-$db->query("update phpbb_config set config_value='".$server_port."' where config_name='server_port'");
-$db->query("update phpbb_config set config_value='modules/MessageBoard' where config_name='script_path'");
-$curr_time=time();
-$db->query("insert phpbb_config values('board_startdate','".$curr_time."')");
-$db->query("insert phpbb_config values('default_lang', 'english')");
-*/
-
-$endTime = microtime();
-$deltaTime = microtime_diff($startTime, $endTime);
-
-function populatePermissions4StandardUser() {
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Leads','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Leads','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Leads','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Accounts','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Accounts','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Accounts','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Contacts','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Contacts','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Contacts','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Opportunities','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Opportunities','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Opportunities','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Calls','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Calls','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Calls','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Emails','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Emails','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Emails','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Tasks','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Tasks','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Tasks','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Notes','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Notes','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Notes','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Meetings','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Meetings','Delete',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Cases','EditView',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Cases','Delete',1,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Cases','index',1,1,'')");
-
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','imports','fetchfile',0,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Contacts','BusinessCard',0,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Contacts','Import',0,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Accounts','Import',0,1,'')");
- mysql_query("insert into role2permission(roleid,permissionid,module,module_action,action_permission,module_permission,description) values (2,'','Opportunities','Import',0,1,'')");
-}
-
-// populate calendar data
-//include("modules/Calendar/admin/scheme.php");
+require_once('install/5createTables.inc.php');
?>
-The database tables are now set up.<HR></HR>
+<HR></HR>
total time: <?php echo "$deltaTime"; ?> seconds.<BR />
</td></tr>
<tr><td><hr></td></tr>
More information about the vtigercrm-commits
mailing list