Skip to content

Instantly share code, notes, and snippets.

@melihbuyuk
Created January 1, 2011 18:35
Show Gist options
  • Save melihbuyuk/761907 to your computer and use it in GitHub Desktop.
Save melihbuyuk/761907 to your computer and use it in GitHub Desktop.
Create Bolumu
class SipzyUser {
var $CI;
var $errors = array();
var $accounts_controller = 'account';
public function SipzyUser() {
$this->CI =& get_instance();
}
public function createNewUser() {
if (!class_exists('CI_Form_validation')) {
$this->CI->load->library('form_validation');
$this->CI->lang->load('sipzyuser', 'english');
$this->CI->load->helper('sipzyuser');
}
$config = array(
array(
'field' => 'username',
'label' => 'username',
'rules' => 'required|min_length[4]|max_length[20]|trim'
),
array(
'field' => 'password',
'label' => 'password',
'rules' => 'required|min_length[4]|matches[passwordconf]'
),
array(
'field' => 'passwordconf',
'label' => 'password Confirmation',
'rules' => 'required'
),
array(
'field' => 'email',
'label' => 'email',
'rules' => 'required|max_length[120]|valid_email|trim'
)
);
$this->CI->form_validation->set_rules($config);
if ($this->CI->form_validation->run()) {
if (!class_exists('userModel')) {
$this->CI->load->model('user/userModel');
}
$check = $this->CI->userModel->getUserNameCheck( array('username' => $this->CI->input->post('username') ) );
if ( $check === NULL ) {
$salt = $this->_generate_salt();
if ( !function_exists( 'dohash' ) ) {
$this->CI->load->helper('security');
}
$create = array(
'username' => $this->CI->input->post( 'username' ),
'password' => dohash( $salt . $this->input->post( 'password' ) ),
'hash' => $salt,
'email' => $this->input->post('email')
);
return $this->CI->userModel->newUserCreate($create);
}
$this->errors[] = $this->CI->lang->line('sipzy_auth_account_exists');
}
foreach ($this->CI->form_validation->_error_array as $error) {
$this->errors[] = $error;
}
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment