<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class user_install extends InstallController
{

    public function __construct()
    {
        parent::__construct();

        // Set acl module name
        $this->module_config['module_acl_name'] = 'user';

        // Set title
        $this->module_config['module_title'] = $this->lang->line('User');

        // Set module image
        $this->module_config['module_image'] = '';

        // Set actions
        $this->module_config['module_actions'] = array(
            // 'acl_action' => 'description'
            'view_user' => $this->lang->line('View'),
            'edit_user' => $this->lang->line('Edit'),
        );

        // Set menu items
        $this->module_config['module_menu_items'] = array(
//            array('method in admin controller', 'title in menu', 'path to the image. empty - default image', 'acl_action')
//            array('index', $this->lang->line('View'), '', 'view_slider'),
        );
    }

    public function install()
    {
        $check = $this->db->limit(1)->get('acl_user')->row_array();
        if (!isset($check['phone'])) {
            $this->db->query('ALTER TABLE  `acl_user` ADD  `phone` VARCHAR( 255 ) NOT NULL');
        }
        if (!isset($check['sex'])) {
            $this->db->query("ALTER TABLE  `acl_user` ADD  `sex` TINYINT( 1 ) NOT NULL DEFAULT  '1' COMMENT  '1 - male; 2 - female'");
        }
        if (!isset($check['subscribe'])) {
            $this->db->query('ALTER TABLE  `acl_user` ADD  `subscribe` BOOLEAN NOT NULL DEFAULT FALSE');
        }
        
        return parent::install();
    }

    public function uninstall()
    {
        return parent::uninstall(array(
                    'dropTables' => array(
//                        'table',
                    ),
        ));
    }

}
