<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User_model extends MY_Model{
	function __construct(){
		parent::__construct();
		
		$this->table = "WEB_USER";
		
		$this->join .= "LEFT JOIN WEB_GROUP ON WEB_GROUP.PKKEY = <T>.USER_GROUP ";
		$this->join .= "LEFT JOIN WEB_USER AS CREATE_USER ON CREATE_USER.PKKEY = <T>.CREATED_BY ";
		$this->join .= "LEFT JOIN WEB_USER AS MODIFY_USER ON MODIFY_USER.PKKEY = <T>.MODIFIED_BY ";
	}
	
	function save_before($post, $save_mode){
		if(isset($post['PASSWORD'])) $post['PASSWORD'] = sha1($post['PASSWORD']);
		
		return $post;
	}
	
	function reset_password($post){
		$pk = $this->sql_get_pk();
		
		$data['PASSWORD'] = sha1("1234");
		
		$update_return = $this->sql_update($data, $post[$pk]);
		return $update_return['success'];
	}
}