本文整理汇总了PHP中VBX_User::update方法的典型用法代码示例。如果您正苦于以下问题:PHP VBX_User::update方法的具体用法?PHP VBX_User::update怎么用?PHP VBX_User::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VBX_User
的用法示例。
在下文中一共展示了VBX_User::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit()
{
$is_admin = $this->session->userdata('is_admin');
$user = new VBX_User();
$params = array();
foreach ($user->fields as $field) {
$val = $this->input->post($field);
/* Disallow people from changing certain settings */
if (in_array($field, $user->admin_fields)) {
if ($val && $is_admin) {
$params[$field] = $val;
}
} else {
if ($val) {
$params[$field] = $val;
}
}
// The value for some fields should also be saved to the session
if ($field === 'email') {
$this->session->set_userdata('email', trim($val));
}
}
if ($user->update($this->user_id, $params)) {
$this->session->set_flashdata('message_edit', 'User data changed');
redirect('account');
} else {
$this->data['error_edit'] = '';
$this->index();
}
}
示例2: edit
public function edit()
{
if (!$this->session->userdata('loggedin')) {
redirect('auth/login');
}
$is_admin = $this->session->userdata('is_admin');
$user = new VBX_User();
$params = array();
foreach ($user->fields as $field) {
$val = $this->input->post($field);
/* Disallow people from changing certain settings */
if (in_array($field, $user->admin_fields)) {
if (($val || $val === '0') && $is_admin) {
$params[$field] = $val;
}
} else {
if ($val || $val === '0') {
$params[$field] = $val;
}
}
// The value for some fields should also be saved to the session
if ($field === 'email') {
$this->session->set_userdata('email', trim($val));
}
}
$success = $user->update($this->user_id, $params);
if ($this->response_type == 'json') {
$data = isset($this->data) ? $this->data : array();
$data['json']['error'] = !$success;
$data['json']['message'] = !$success ? 'an error occurred while updating the user' : 'user status updated';
$this->respond('', null, $data);
} else {
if ($success) {
$this->session->set_flashdata('message_edit', 'User data changed');
redirect('account');
} else {
$this->data['error_edit'] = '';
$this->index();
}
}
}