<?php

/**
 *      【橙创家校通v4.0】 (C)2010-2012 Tuntron Inc.
 *      
 *    	 http://www.tuntron.com   QQ：1121251729
 *
 *      &短信设置类文件&
 */

if (!defined('IS_RUN')) die('Forbidden');

class tj_setsms extends tj_model {

    var $table = 'dbpre_smsconfig';
	var $key = 'id';
	
    function __construct() {
        parent::__construct();
        $this->init_field();
    }

    function tj_usergroup() {
        $this->__construct();
    }

    function init_field() {
        $this->add_field('id,smsname,smspwd,http');
		$this->add_field_fun('smsname,smspwd', '_T');
		$this->add_field_fun('smsname,smspwd', 'trim');
    }
	
	
	 function read_one($type=null) {
        $this->db->from($this->table);
		if($type){
			$this->db->where('id', $type);
		}
        $this->db->select('id,smsname,smspwd,http');
        return $this->db->once_fetch_assoc();
    }


    function update(& $post) {
        if(!is_array($post)) return;
        foreach($post as $key => $val) {
			$p = array($key=>$val);
            $this->save($p, $post['id'], FALSE);
        }
    }

    function save($post,$variable=null) {
		
        $variable = parent::save($post,$variable);
        return $variable;
    }

    function check_post(& $post, $edit = FALSE) {
        //if($edit && isset($post['groupname']) && !$post['groupname']) redirect('membercp_usergroup_empty_name');
      //  if(!$edit && !$post['groupname']) redirect('membercp_usergroup_empty_name');
       // if(!$edit && !in_array($post['grouptype'],array('member','special','system'))) redirect('membercp_usergroup_empty_type');
      //  if(!$edit && $post['grouptype']=='member' && !is_numeric($post['point'])) redirect('membercp_usergroup_empty_point');
    }
}
?>