本文整理汇总了PHP中User_Model::as_array方法的典型用法代码示例。如果您正苦于以下问题:PHP User_Model::as_array方法的具体用法?PHP User_Model::as_array怎么用?PHP User_Model::as_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User_Model
的用法示例。
在下文中一共展示了User_Model::as_array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _edit
/**
* Edit basic info
*/
public function _edit()
{
$this->tab_id = 'profile';
$this->history = false;
// only owner or admin
if ($this->member->id !== $this->user->id && !$this->visitor->logged_in('admin')) {
url::back('members');
}
$form_errors = array();
$form_values = $this->member->as_array();
// check post
if (request::method() == 'post') {
$post = array_merge($this->input->post(), $_FILES);
$extra = array();
// location
if (empty($post['address_street']) && empty($post['address_city'])) {
// empty address, clear location
$extra['latitude'] = 0;
$extra['longitude'] = 0;
} else {
if ($post['address_street'] != $this->member->address_street || $post['address_city'] != $this->member->address_city) {
// update location
list($extra['latitude'], $extra['longitude']) = Gmap::address_to_ll(implode(', ', array($post['address_street'], $post['address_zip'], $post['address_city'])));
}
}
if ($this->member->validate($post, true, $extra)) {
// handle picture upload
if (isset($post->image) && empty($post->image['error'])) {
$image = Image_Model::factory('members.image', $post->image, $this->member->id);
if ($image->id) {
$this->member->add($image);
$this->member->default_image_id = $image->id;
$this->member->save();
}
}
url::redirect(url::user($this->member));
} else {
$form_errors = $post->errors();
}
$form_values = arr::overwrite($form_values, $post->as_array());
}
// City autocomplete
$this->_autocomplete_city('address_city');
// Date pickers
widget::add('footer', html::script_source("\$('input#dob').datepicker({ dateFormat: 'd.m.yy', firstDay: 1, changeFirstDay: false, showOtherMonths: true, showStatus: true, showOn: 'both', minDate: '-60Y', maxDate: 0 });"));
if (empty($errors)) {
widget::add('main', View::factory('member/info_edit', array('values' => $form_values, 'errors' => $form_errors)));
} else {
$this->_error(Kohana::lang('generic.error'), $errors);
}
$this->_side_views();
}
示例2: _join
/**
* Register with code
*
* @param Invitation_Model $invitation
*/
public function _join(Invitation_Model $invitation)
{
$this->history = false;
$user = new User_Model();
$form_values = $user->as_array();
$form_errors = array();
// handle post
if (request::method() == 'post') {
$post = $this->input->post();
$post['email'] = $invitation->email;
$post['username_clean'] = utf8::clean($post['username']);
if ($user->validate($post, false, null, null, array('rules' => 'register', 'callbacks' => 'register'))) {
$invitation->delete();
$user->add(ORM::factory('role', 'login'));
$user->save();
$this->visitor->login($user, $post->password);
url::back();
} else {
$form_errors = $post->errors();
$form_values = arr::overwrite($form_values, $post->as_array());
}
}
widget::add('main', View::factory('member/signup', array('values' => $form_values, 'errors' => $form_errors, 'invitation' => $invitation)));
}