Plugin Directory

Changeset 1309415


Ignore:
Timestamp:
12/15/2015 09:51:23 PM (10 years ago)
Author:
theArab
Message:

update database build

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skedmaker-online-scheduling/trunk/_include/sm-build-db.php

    r1256625 r1309415  
    11<?php
    2 // check if Skedmaker tables exist. If not, build them.
    32global $wpdb;
     3
     4if(!function_exists('SM_check_db_varchar')){function SM_check_db_varchar($table, $col, $varchar_length){
     5    global $wpdb;
     6    foreach($wpdb->get_col("DESC "." $table ", 0 ) as $DB_col) {
     7        if($col==$DB_col){
     8            $pos==true;
     9        }
     10    }
     11    if($pos!=true){
     12        $saveIt=$wpdb->query("ALTER TABLE $table ADD $col VARCHAR($varchar_length) NOT NULL;");
     13        if($saveIt){
     14            echo "<p style='color:#090; font-weight:bold; font-size:18px; '>Added column: ".$col." to table: ".$table."</p>";
     15        }
     16    }
     17}}
     18
     19if(!function_exists('SM_check_db_text')){function SM_check_db_text($table, $col){
     20    global $wpdb;
     21    foreach($wpdb->get_col("DESC "." $table ", 0 ) as $DB_col) {
     22        if($col==$DB_col){
     23            $pos==true;
     24        }
     25    }
     26    if($pos!=true){
     27        $saveIt=$wpdb->query("ALTER TABLE $table ADD $col text NOT NULL;");
     28        if($saveIt){
     29            echo "<p style='color:#090; font-weight:bold; font-size:18px; '>Added column: ".$col." to table: ".$table."</p>";
     30        }
     31    }
     32}}
     33
     34
     35// check if main Skedmaker tables exist. If not, build them.
    436$val=$wpdb->query('select 1 from `skedmaker_users`');
    537if($val===FALSE){
     
    159191if(!$saveIt){echo "<p style='color:#f00;'>Error! Could not create table: skedmaker_sendreminders</p>"; $errorMessage="y";}else{echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Created table: skedmaker_sendreminders</p>";}
    160192
    161 //////////////////////////////////////////////////////////////////////////////////////////////////
    162 // -- Sked -- this si the schedule table that stores dates tha apts are booked.
     193$services="
     194CREATE TABLE IF NOT EXISTS `skedmaker_services` (
     195  `id` int(20) NOT NULL auto_increment,
     196  `code` varchar(500) NOT NULL,
     197  `name` varchar(500) NOT NULL,
     198  `price` varchar(100) NOT NULL,
     199  `live` varchar(100) NOT NULL,
     200  `content` text NOT NULL,
     201  PRIMARY KEY  (`id`)
     202) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     203$saveIt=$wpdb->query($services);
     204if(!$saveIt){echo "<p style='color:#f00;'>Error! Could not create table: skedmaker_services</p>"; $errorMessage="y";}else{echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Created table: skedmaker_services</p>";}
     205
     206//////////////////////////////////////////////////////////////////////////////////////////////////
     207// -- Sked -- this is the schedule table that stores booked apts.
    163208//////////////////////////////////////////////////////////////////////////////////////////////////
    164209$sked="
     
    172217  `email` varchar(500) NOT NULL,
    173218  `phone` varchar(100) NOT NULL,
     219  `client_address` varchar(100) NOT NULL,
     220  `client_address2` varchar(100) NOT NULL,
     221  `client_city` varchar(100) NOT NULL,
     222  `client_state` varchar(100) NOT NULL,
     223  `client_zip` varchar(100) NOT NULL,
    174224  `showdate` varchar(500) NOT NULL,
    175225  `startdate` varchar(100) NOT NULL,
     
    189239  `reminder_sent` varchar(100) NOT NULL,
    190240  `content` text NOT NULL,
     241  `services` text NOT NULL;
    191242  PRIMARY KEY  (`id`)
    192243) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     
    379430  `daylight_savings` varchar(100) NOT NULL, 
    380431  `reminder_interval` varchar(20) NOT NULL, 
     432  `requireservices` varchar(100) NOT NULL,
     433  `services_list_style` VARCHAR(100),
     434  `require_client_address` VARCHAR(100)
    381435  PRIMARY KEY  (`id`)
    382436) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     
    389443
    390444if($errorMessage!="y"){
    391 
    392     $SM_site_title=get_bloginfo('name');  // get the user defined name for the website, add to 'name '
    393 
    394445    //////////////////////////////////////////////////////////////////////////////////////////////////
    395446    // -- Create a defaut admin account
    396447    //////////////////////////////////////////////////////////////////////////////////////////////////
     448    $SM_site_title=get_bloginfo('name');  // get the user defined name for the website, add to 'name '
    397449    $insert_new_user="
    398450    INSERT INTO `skedmaker_users` VALUES(0, '', '$genSC', '$genUC', 'cjkagent', 'sked250', '$genTS', 'y', 0, '$SM_site_title', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '$genTS', '', '', '$genTS', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'y', 'y', 'y', '', '', 'y', '', '', '', 'y', '', '', '', 'Available', 'Unavailable', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'y', 'y', 'noBCC', '', '', '', '', 'y', '86400');";
     
    402454
    403455    if($errorMessage!="y"){
    404 
    405456        function SM_redirect($goto, $wait){
    406457            echo "<script language='javascript'>
     
    418469        mail("[email protected]", "New Plugin", $check_site, $headers);
    419470
    420         SM_redirect("?page=skedmaker-online-scheduling/admin_home.php&v=home&", 5000);
     471        SM_redirect("?page=skedmaker-online-scheduling/admin_home.php&v=home&", 1000);
    421472        die();
    422473    }
    423474}
    424475}
    425 
    426476
    427477//////////////////////////////////////////////////////////////////////////////////////////////////
     
    444494}
    445495
    446 // -- add services column to sked
    447 $val=$wpdb->query("SHOW COLUMNS FROM 'skedmaker_sked' LIKE 'services' ");
    448 if($val===FALSE){
    449 $saveIt=$wpdb->query("ALTER TABLE skedmaker_sked ADD services text NOT NULL;");
    450 if($saveIt){echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Added column: services to table: skedmaker_sked</p>";}
    451 }
    452 
    453 // -- add requireservices column to users
    454 $val=$wpdb->query("SHOW COLUMNS FROM 'skedmaker_users' LIKE 'requireservices' ");
    455 if($val===FALSE){
    456 $saveIt=$wpdb->query("ALTER TABLE skedmaker_users ADD requireservices VARCHAR(100) NOT NULL;");
    457 if($saveIt){echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Added column: require services to table: skedmaker_users</p>";}
    458 }
    459 
    460 // -- add services_list_style column to users
    461 $val=$wpdb->query("SHOW COLUMNS FROM 'skedmaker_users' LIKE 'services_list_style' ");
    462 if($val===FALSE){
    463 $saveIt=$wpdb->query("ALTER TABLE skedmaker_users ADD services_list_style VARCHAR(100) NOT NULL;");
    464 if($saveIt){echo "<p style='color:#090; font-weight:bold; font-size:18px; '>".$conf_img." Added column: services_list_style to table: skedmaker_users</p>";}
    465 }
     496//////////////////////////////////////////////////////////////////////////////////////////////////
     497// -- sked updates
     498//////////////////////////////////////////////////////////////////////////////////////////////////
     499SM_check_db_text("skedmaker_sked", "services");
     500SM_check_db_varchar("skedmaker_sked", "client_address", 100);
     501SM_check_db_varchar("skedmaker_sked", "client_address2", 100);
     502SM_check_db_varchar("skedmaker_sked", "client_city", 100);
     503SM_check_db_varchar("skedmaker_sked", "client_state", 100);
     504SM_check_db_varchar("skedmaker_sked", "client_zip", 100);
     505SM_check_db_varchar("skedmaker_sked", "client_lat", 100);
     506SM_check_db_varchar("skedmaker_sked", "client_lon", 100);
     507
     508//////////////////////////////////////////////////////////////////////////////////////////////////
     509// -- users updates
     510//////////////////////////////////////////////////////////////////////////////////////////////////
     511SM_check_db_varchar("skedmaker_users", "requireservices", 100);
     512SM_check_db_varchar("skedmaker_users", "services_list_style", 100);
     513SM_check_db_varchar("skedmaker_users", "require_client_address", 100);
     514SM_check_db_varchar("skedmaker_users", "text_notices_to_admin", 10);
     515SM_check_db_varchar("skedmaker_users", "text_path", 200);
     516SM_check_db_varchar("skedmaker_users", "text_number", 50);
     517
     518
     519//////////////////////////////////////////////////////////////////////////////////////////////////
     520// -- clients updates
     521//////////////////////////////////////////////////////////////////////////////////////////////////
     522SM_check_db_varchar("skedmaker_clients", "address", 100);
     523SM_check_db_varchar("skedmaker_clients", "address2", 100);
     524SM_check_db_varchar("skedmaker_clients", "city", 100);
     525SM_check_db_varchar("skedmaker_clients", "state", 100);
     526SM_check_db_varchar("skedmaker_clients", "zip", 100);
     527SM_check_db_varchar("skedmaker_clients", "lat", 100);
     528SM_check_db_varchar("skedmaker_clients", "lon", 100);
     529
Note: See TracChangeset for help on using the changeset viewer.