<?php

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

/**
 * Upgrade Callme module to version 3.2.0
 *
 * @author CIEXT skeleton
 */
class Callme_upgrade_3_1_0 extends Abstract_upgrade
{

    public function up()
    {
        $ci = & get_instance();
        $ci->db->where('acl_resource', 'callme')
                ->where('acl_action', 'configuration')
                ->update('admin_menu', ['active' => 0]);

        $ci->load->library('ciext/configurator');
        $ci->configurator->set_resource('callme');
        $configuration = $ci->configurator->get_config();
        $subject = !empty($configuration['subject']) ? $configuration['subject'] : 'Call me';
        $ci->load->library('emailmng/emailmng_installer')
                ->set_subject($subject, '')
                ->set_message($configuration['template'], '')
                ->add_template('callme_me_tpl');

        return '3.2.0';
    }

    public function down()
    {
        return '1.1.0';
    }

}
