Jump to content

Missing argument


Xtremer360

Recommended Posts

For some reason I'm getting the following errors and I'm not quite sure where in my code I need to adjust I know it says it but what to change it to is what I'm confused about.

 

A PHP Error was encountered

 

Severity: Warning

 

Message: Missing argument 5 for Tank_auth::create_user(), called in /home/xtremer/public_html/kowmanager/application/controllers/auth.php on line 136 and defined

 

Filename: libraries/Tank_auth.php

 

Line Number: 162 A PHP Error was encountered

 

Severity: Notice

 

Message: Undefined property: Tank_auth::$users

 

Filename: libraries/Tank_auth.php

 

Line Number: 188

 

Fatal error: Call to a member function UpdateProfileInfo() on a non-object in /home/xtremer/public_html/kowmanager/application/libraries/Tank_auth.php on line 188

 

controller/auth.php

<?php
function register()
{
	if ($this->tank_auth->is_logged_in()) {									// logged in
		redirect('');

	} elseif ($this->tank_auth->is_logged_in(FALSE)) {						// logged in, not activated
		redirect('/auth/send_again/');

	} elseif (!$this->config->item('allow_registration', 'tank_auth')) {	// registration is off
		$this->_show_message($this->lang->line('auth_message_registration_disabled'));

	} else {
		$use_username = $this->config->item('use_username', 'tank_auth');
		if ($use_username) {
			$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|min_length['.$this->config->item('username_min_length', 'tank_auth').']|max_length['.$this->config->item('username_max_length', 'tank_auth').']|alpha_dash');
		}
		$this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email');
		$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|min_length['.$this->config->item('password_min_length', 'tank_auth').']|max_length['.$this->config->item('password_max_length', 'tank_auth').']|alpha_dash');
		$this->form_validation->set_rules('confirm_password', 'Confirm Password', 'trim|required|xss_clean|matches[password]');
            $this->form_validation->set_rules('first_name', 'First Name', 'trim|required|xss_clean');
            $this->form_validation->set_rules('last_name', 'Last Name', 'trim|required|xss_clean');
            
		$data['errors'] = array();

		$email_activation = $this->config->item('email_activation', 'tank_auth');

		$userInfo['first_name'] = $this->form_validation->set_value('first_name');
            $userInfo['last_name']  = $this->form_validation->set_value('last_name');

            if ($this->form_validation->run()) {								// validation ok
			if (!is_null($data = $this->tank_auth->create_user(
					$use_username ? $this->form_validation->set_value('username') : '',
					$this->form_validation->set_value('email'),
					$this->form_validation->set_value('password'),
					$email_activation))) {									// success

				$data['site_name'] = $this->config->item('website_name', 'tank_auth');

				if ($email_activation) {									// send "activate" email
					$data['activation_period'] = $this->config->item('email_activation_expire', 'tank_auth') / 3600;

					$this->_send_email('activate', $data['email'], $data);

					unset($data['password']); // Clear password (just for any case)

					$this->_show_message($this->lang->line('auth_message_registration_completed_1'));

				} else {
					if ($this->config->item('email_account_details', 'tank_auth')) {	// send "welcome" email

						$this->_send_email('welcome', $data['email'], $data);
					}
					unset($data['password']); // Clear password (just for any case)

					$this->_show_message($this->lang->line('auth_message_registration_completed_2').' '.anchor('/login/', 'Login'));
				}
			} else {
				$errors = $this->tank_auth->get_error_message();
				foreach ($errors as $k => $v)	$data['errors'][$k] = $this->lang->line($v);
			}
		}
		$data['use_username'] = $use_username;
            $this->template->set_layout('default')->enable_parser(false);
            $this->template->build('/auth/register_form', $data);
	}
}
?>

 

 

libraries/Tank_Auth.php

<?php
function create_user($username, $email, $password, $email_activation, $userInfo)
{
	if ((strlen($username) > 0) AND !$this->ci->users->is_username_available($username)) {
		$this->error = array('username' => 'auth_username_in_use');

	} elseif (!$this->ci->users->is_email_available($email)) {
		$this->error = array('email' => 'auth_email_in_use');

	} else {
		// Hash password using phpass
		$hasher = new PasswordHash(
				$this->ci->config->item('phpass_hash_strength', 'tank_auth'),
				$this->ci->config->item('phpass_hash_portable', 'tank_auth'));
		$hashed_password = $hasher->HashPassword($password);

		$data = array(
			'username'	=> $username,
			'password'	=> $hashed_password,
			'email'		=> $email,
			'last_ip'	=> $this->ci->input->ip_address(),
		);

		if ($email_activation) {
			$data['new_email_key'] = md5(rand().microtime());
		}
		if (!is_null($res = $this->ci->users->create_user($data, !$email_activation))) {
			$this->users->UpdateProfileInfo($userInfo["first_name"],$userInfo["last_name"]);
                $data['user_id'] = $res['user_id'];
			$data['password'] = $password;
			unset($data['last_ip']);
			return $data;
		}
	}
	return NULL;
}
?>

 

models/users.php

<?php
function create_user($data, $activated = TRUE)
{
        $data['created'] = date('Y-m-d H:i:s');
	$data['activated'] = $activated ? 1 : 0;

	if ($this->db->insert($this->table_name, $data)) {
		$user_id = $this->db->insert_id();
		if ($activated)	$this->create_profile($user_id, $data);
		return array('user_id' => $user_id);
	}
	return NULL;
}
    
    function UpdateProfileInfo ($userID, $first_name, $last_name)
    {
        return $this->db->update('user_profiles', array('first_name'=>$first_name, 'last_name'=>$last_name), array('user_id' => $userID)); 
    }

private function create_profile($user_id, $data)
{
	$this->db->set('user_id', $user_id);
        $this->db->set('first_name', $data['first_name']);
        $this->db->set('last_name', $data['last_name'] );
	return $this->db->insert($this->profile_table_name);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/244975-missing-argument/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.