&& ! $this->ldap_login($username, $password))
return FALSE;
+ if (empty($user['email']) || empty($user['first_name'])
+ || empty($user['last_name']))
+ $user['import'] = TRUE;
+
// Update last login time.
$this->db->query("UPDATE `users`
SET last_login = UTC_TIMESTAMP()
$data['password'] = sha1($data['password']);
// TODO picture data: save, convert, make it thumbnail
+ if (empty($data['birth_date']))
+ $data['birth_date'] = NULL;
+
$cols = '';
$vals = '';
foreach ($data as $col=> $val)
{
+ if ($val === NULL)
+ {
+ $cols .= "$col, ";
+ $vals .= "NULL, ";
+ continue;
+ }
+
$cols .= "$col, ";
if (is_int($val))
$vals .= "$val, ";
- else
+ else if (is_string($val))
$vals .= "'$val', ";
}
$cols = substr($cols, 0, -2);
$query = $this->db->query("INSERT INTO `users`
($cols, registration_date, last_login)
VALUES ($vals, utc_timestamp(), utc_timestamp())");
-
if ($query === FALSE)
return FALSE;
// If registered with internal authentication it needs to activate
// the account.
- $activation_code = Users_model::gen_activation_code($data['username']);
- $user_id = $this->get_user_id($data['username']);
- $query = $this->db->query("INSERT INTO `users_unactivated`
- (user_id, activation_code)
- VALUES ($user_id, '$activation_code')");
- $this->send_activation_email($user_id, $data['email'],
- $activation_code, $data['username']);
+ if ($data['auth_src'] == 'internal')
+ {
+ $activation_code = Users_model::gen_activation_code($data['username']);
+ $user_id = $this->get_user_id($data['username']);
+ $query = $this->db->query("INSERT INTO `users_unactivated`
+ (user_id, activation_code)
+ VALUES ($user_id, '$activation_code')");
+ $this->send_activation_email($user_id, $data['email'],
+ $activation_code, $data['username']);
+ }
// TODO exception on failure
return $query;
if ($query->num_rows() === 0)
return FALSE;
- return $query->row_array();
+ $userdata = $query->row_array();
+
+ // Post process userdata.
+ if (isset($userdata['picture']))
+ {
+ $userdata['picture_thumb'] = site_url(
+ "data/user_pictures/{$userdata['picture']}-thumb.jpg");
+ $userdata['picture'] = site_url(
+ "data/user_pictures/{$userdata['picture']}");
+ }
+
+ return $userdata;
}
/**
$data['password'] = sha1($data['password']);
// TODO picture data: save, convert, make it thumbnail
+ if (empty($data['birth_date']))
+ $data['birth_date'] = NULL;
+
$set = '';
foreach ($data as $col => $val)
{
+ if ($val === NULL)
+ {
+ $set .= "$col = NULL, ";
+ continue;
+ }
+
if (is_int($val))
$set .= "$col = $val, ";
- else
+ else if (is_string($val))
$set .= "$col = '$val', ";
}
$set = substr($set, 0, -2);