<?php

class ModelSettingEmailValidate extends Model{

    public function enable(){

        if($this->config->get('email_validation_status') != 1){
            $this->db->query("ALTER TABLE ".DB_PREFIX."customer ADD valided BOOL DEFAULT 1");

            $this->db->query("ALTER TABLE " .DB_PREFIX."customer ALTER valided SET DEFAULT 0");
        }

    }

    public function disable(){
        $sql = "SELECT COUNT(COLUMN_NAME) AS valided FROM INFORMATION_SCHEMA.COLUMNS
        WHERE TABLE_NAME = '". DB_PREFIX."customer' AND  TABLE_SCHEMA = '".DB_DATABASE."'  AND  COLUMN_NAME = 'valided'";

        $query = $this->db->query($sql);

        if($query->rows[0]["valided"] > 0){
            $this->db->query("ALTER TABLE " .DB_PREFIX ."customer DROP COLUMN valided");
        }

    }
}