/** * * */ function Install() { include_once 'RCCWP_Options.php'; global $wpdb; // First time installation if (get_option(RC_CWP_OPTION_KEY) === false) { // Giving full rights to folders. @chmod(FLUTTER_UPLOAD_FILES_DIR, 777); @chmod(FLUTTER_IMAGES_CACHE_DIR, 777); @chmod(FLUTTER_MODULES_DIR, 777); //Initialize options $options['hide-write-post'] = 0; $options['hide-write-page'] = 0; $options['hide-visual-editor'] = 0; $options['prompt-editing-post'] = 0; $options['assign-to-role'] = 0; $options['use-snipshot'] = 0; $options['enable-editnplace'] = 1; $options['eip-highlight-color'] = "#FFFFCC"; $options['enable-swfupload'] = 1; $options['default-custom-write-panel'] = ""; if (version_compare(PHP_VERSION, '5.0.0') === 1) { $options['enable-HTMLPurifier'] = 0; } else { $options['enable-HTMLPurifier'] = 0; } $options['tidy-level'] = "medium"; $options['canvas_show_instructions'] = 1; $options['canvas_show_zone_name'] = 0; $options['canvas_show'] = 1; $options['ink_show'] = 0; $options['enable-broserupload'] = 0; RCCWP_Options::Update($options); } //for backward compatibility if ($options['enable-swfupload'] == 1) { $options['enable-browserupload'] = 0; } else { $options['enable-broserupload'] = 1; } RCCWP_Options::Update($options); //comment sniptshot preference $checking_options = RCCWP_Options::Get(); $checking_options['use-snipshot'] = 0; RCCWP_Options::Update($checking_options); // Check blog database if (get_option("RC_CWP_BLOG_DB_VERSION") == '') { update_option("RC_CWP_BLOG_DB_VERSION", 0); } if (get_option("RC_CWP_BLOG_DB_VERSION") < RC_CWP_DB_VERSION) { $BLOG_DBChanged = true; } else { $BLOG_DBChanged = false; } // Install blog tables if (!$wpdb->get_var("SHOW TABLES LIKE '" . RC_CWP_TABLE_POST_META . "'") == RC_CWP_TABLE_POST_META || $BLOG_DBChanged) { $blog_tables[] = "CREATE TABLE " . RC_CWP_TABLE_POST_META . " (\n\t\t\t\tid integer NOT NULL,\n\t\t\t\tgroup_count integer NOT NULL,\n\t\t\t\tfield_count integer NOT NULL,\n\t\t\t\tpost_id integer NOT NULL,\n\t\t\t\tfield_name text NOT NULL,\n order_id integer NOT NULL,\n\t\t\t\tPRIMARY KEY (id) )"; $blog_tables[] = "CREATE TABLE " . FLUTTER_TABLE_LAYOUT_MODULES . " (\n\t\t block_id INT NOT NULL AUTO_INCREMENT,\n\t \t\t\tmodule_id INT NOT NULL,\n\t\t\t\ttheme tinytext NOT NULL,\n\t\t\t\tpage text NOT NULL,\n\t\t\t\tposition tinytext NOT NULL,\n\t\t\t\ttemplate_name text NOT NULL,\n\t\t\t\ttemplate_size text NOT NULL,\n\t\t\t\tduplicate_id INT NOT NULL,\n\t\t\t\tPRIMARY KEY (block_id)\n\t\t\t\t);"; $blog_tables[] = "CREATE TABLE " . FLUTTER_TABLE_LAYOUT_VARIABLES . " (\n\t \t\t\tvariable_id INT NOT NULL AUTO_INCREMENT,\n\t \t\t\tvariable_name text NOT NULL,\n\t \t\t\tparent INT NOT NULL,\n\t \t\t\ttype text NOT NULL,\n\t \t\t\tvalue text NOT NULL,\n\t \t\t\tdefault_value text NOT NULL,\n\t \t\t\tdescription text NOT NULL,\n\t \t\t\toptions text NOT NULL,\n\t \t\t\tPRIMARY KEY (variable_id)\n\t\t\t\t);"; $blog_tables[] = "CREATE TABLE " . FLUTTER_TABLE_LAYOUT_SETTINGS . " (\n\t\t settings_id INT NOT NULL AUTO_INCREMENT,\n\t\t\t\ttheme tinytext NOT NULL,\n\t\t\t\tpage text NOT NULL,\n\t\t\t\tsettings text NOT NULL,\n\t\t\t\tPRIMARY KEY (settings_id)\n\t\t\t\t);"; // try to get around // these includes like http://trac.mu.wordpress.org/ticket/384 // and http://www.quirm.net/punbb/viewtopic.php?pid=832#p832 if (file_exists(ABSPATH . 'wp-includes/pluggable.php')) { require_once ABSPATH . 'wp-includes/pluggable.php'; } else { require_once ABSPATH . 'wp-includes/pluggable-functions.php'; } require_once ABSPATH . 'wp-admin/upgrade-functions.php'; foreach ($blog_tables as $blog_table) { dbDelta($blog_table); } } update_option('RC_CWP_BLOG_DB_VERSION', RC_CWP_DB_VERSION); //canvas_install($BLOG_DBChanged); // Upgrade Blog if ($BLOG_DBChanged) { RCCWP_Application::UpgradeBlog(); } if (RCCWP_Application::IsWordpressMu()) { if (get_site_option("RC_CWP_DB_VERSION") == '') { update_site_option("RC_CWP_DB_VERSION", 0); } if (get_site_option("RC_CWP_DB_VERSION") < RC_CWP_DB_VERSION) { $DBChanged = true; } else { $DBChanged = false; } } else { if (get_option("RC_CWP_DB_VERSION") == '') { update_option("RC_CWP_DB_VERSION", 0); } if (get_option("RC_CWP_DB_VERSION") < RC_CWP_DB_VERSION) { $DBChanged = true; } else { $DBChanged = false; } } // -- Create Tables if they don't exist or the database changed if (!$wpdb->get_var("SHOW TABLES LIKE '" . RC_CWP_TABLE_PANELS . "'") == RC_CWP_TABLE_PANELS) { $not_installed = true; } if ($not_installed || $DBChanged) { $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANELS . " (\n\t\t\t\tid int(11) NOT NULL auto_increment,\n\t\t\t\tname varchar(50) NOT NULL,\n single tinyint(1) NOT NULL default 0,\n\t\t\t\tdescription varchar(255),\n\t\t\t\tdisplay_order tinyint,\n\t\t\t\tcapability_name varchar(50) NOT NULL,\n\t\t\t\ttype varchar(50) NOT NULL,\n\t\t\t\tPRIMARY KEY (id) )"; $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " (\n\t\t\t\tid tinyint(11) NOT NULL auto_increment,\n\t\t\t\tname varchar(50) NOT NULL,\n\t\t\t\tdescription varchar(100),\n\t\t\t\thas_options enum('true', 'false') NOT NULL,\n\t\t\t\thas_properties enum('true', 'false') NOT NULL,\n\t\t\t\tallow_multiple_values enum('true', 'false') NOT NULL,\n\t\t\t\tPRIMARY KEY (id) )"; $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_GROUP_FIELDS . " (\n\t\t\t\tid int(11) NOT NULL auto_increment,\n\t\t\t\tgroup_id int(11) NOT NULL,\n\t\t\t\tname varchar(50) NOT NULL,\n\t\t\t\tdescription varchar(255),\n\t\t\t\tdisplay_order tinyint,\n\t\t\t\tdisplay_name enum('true', 'false') NOT NULL,\n\t\t\t\tdisplay_description enum('true', 'false') NOT NULL,\n\t\t\t\ttype tinyint NOT NULL,\n\t\t\t\tCSS varchar(100),\n\t\t\t\trequired_field tinyint,\n\t\t\t\tduplicate tinyint(1) NOT NULL,\n\t\t\t\tPRIMARY KEY (id) )"; $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_OPTIONS . " (\n\t\t\t\tcustom_field_id int(11) NOT NULL,\n\t\t\t\toptions text,\n\t\t\t\tdefault_option text,\n\t\t\t\tPRIMARY KEY (custom_field_id) )"; $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANEL_CATEGORY . " (\n\t\t\t\tpanel_id int(11) NOT NULL,\n\t\t\t\tcat_id int(11) NOT NULL,\n\t\t\t\tPRIMARY KEY (panel_id, cat_id) )"; $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANEL_STANDARD_FIELD . " (\n\t\t\t\tpanel_id int(11) NOT NULL,\n\t\t\t\tstandard_field_id int(11) NOT NULL,\n\t\t\t\tPRIMARY KEY (panel_id, standard_field_id) )"; $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_PROPERTIES . " (\n\t\t\t\tcustom_field_id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tproperties TEXT,\n\t\t\t\tPRIMARY KEY (custom_field_id)\n\t\t\t\t);"; $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_MODULES . " (\n\t\t\t\tid int(11) NOT NULL auto_increment,\n\t\t\t\tname varchar(50) NOT NULL,\n\t\t\t\tdescription text,\n\t\t\t\tPRIMARY KEY (id) )"; $qst_tables[] = "CREATE TABLE " . RC_CWP_TABLE_PANEL_GROUPS . " (\n\t\t\t\tid int(11) NOT NULL auto_increment,\n\t\t\t\tpanel_id int(11) NOT NULL,\n\t\t\t\tname varchar(50) NOT NULL,\n\t\t\t\tduplicate tinyint(1) NOT NULL,\n\t\t\t\tat_right tinyint(1) NOT NULL,\n\t\t\t\tPRIMARY KEY (id) )"; $qst_tables[] = "CREATE TABLE " . FLUTTER_TABLE_MODULES_DUPLICATES . " (\n\t\t duplicate_id INT NOT NULL AUTO_INCREMENT,\n\t \t\t\tmodule_id INT NOT NULL,\n\t\t\t\tduplicate_name text NOT NULL,\n\t\t\t\tPRIMARY KEY(duplicate_id)\n\t\t\t\t);"; // try to get around // these includes like http://trac.mu.wordpress.org/ticket/384 // and http://www.quirm.net/punbb/viewtopic.php?pid=832#p832 if (file_exists(ABSPATH . 'wp-includes/pluggable.php')) { require_once ABSPATH . 'wp-includes/pluggable.php'; } else { require_once ABSPATH . 'wp-includes/pluggable-functions.php'; } require_once ABSPATH . 'wp-admin/upgrade-functions.php'; foreach ($qst_tables as $qst_table) { dbDelta($qst_table); } if (RCCWP_Application::IsWordpressMu()) { update_site_option('RC_CWP_DB_VERSION', RC_CWP_DB_VERSION); } else { update_option('RC_CWP_DB_VERSION', RC_CWP_DB_VERSION); } } // Insert standard fields definition if ($not_installed) { $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (1, 'Textbox', NULL, 'false', 'true', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (2, 'Multiline Textbox', NULL, 'false', 'true', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (3, 'Checkbox', NULL, 'false', 'false', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (4, 'Checkbox List', NULL, 'true', 'false', 'true')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (5, 'Radiobutton List', NULL, 'true', 'false', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (6, 'Dropdown List', NULL, 'true', 'false', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (7, 'Listbox', NULL, 'true', 'true', 'true')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (8, 'File', NULL, 'false', 'false', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (9, 'Image', NULL, 'false', 'true', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (10, 'Date', NULL, 'false', 'true', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (11, 'Audio', NULL, 'false', 'false', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (12, 'Color Picker', NULL, 'false', 'false', 'false')"; $wpdb->query($sql6); $sql6 = "INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (13, 'Slider', NULL, 'false', 'true', 'false')"; $wpdb->query($sql6); } // Upgrade Blog site if ($DBChanged) { RCCWP_Application::UpgradeBlogSite(); } if (RC_CWP_DB_VERSION >= 36) { $wpdb->query("INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (12, 'Color Picker', NULL, 'false', 'false', 'false')"); } if (RC_CWP_DB_VERSION >= 36) { $wpdb->query("INSERT IGNORE INTO " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " VALUES (13, 'Slider', NULL, 'false', 'true', 'false')"); } if (RC_CWP_DB_VERSION >= 40) { $wpdb->query("ALTER TABLE " . RC_CWP_TABLE_PANELS . " MODIFY name varchar(255) NOT NULL"); $wpdb->query("ALTER TABLE " . RC_CWP_TABLE_PANELS . " MODIFY capability_name varchar(255) NOT NULL"); $wpdb->query("ALTER TABLE " . RC_CWP_TABLE_CUSTOM_FIELD_TYPES . " MODIFY name varchar(255) NOT NULL"); $wpdb->query("ALTER TABLE " . RC_CWP_TABLE_GROUP_FIELDS . " MODIFY name varchar(255) NOT NULL"); $wpdb->query("ALTER TABLE " . RC_CWP_TABLE_MODULES . " MODIFY name varchar(255) NOT NULL"); $wpdb->query("ALTER TABLE " . RC_CWP_TABLE_PANEL_GROUPS . " MODIFY name varchar(255) NOT NULL"); //$wpdb->query('update '.RC_CWP_TABLE_POST_META.' ps, '.RC_CWP_TABLE_GROUP_FIELDS.' cf, '.RC_CWP_TABLE_PANEL_GROUPS.' mg set ps.order_id=-1 where mg.name="__default" and mg.id=cf.group_id AND cf.name=ps.field_name'); } //Import Default modules if (RCCWP_Application::IsWordpressMu()) { if (get_site_option('FLUTTER_fist_time') == '') { RCCWP_Application::import_default_modules(); update_site_option('FLUTTER_fist_time', '1'); } } else { if (get_option('FLUTTER_fist_time') == '') { RCCWP_Application::import_default_modules(); update_option('FLUTTER_fist_time', '1'); } } }