本文整理匯總了PHP中Model\User::FilterEmail方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::FilterEmail方法的具體用法?PHP User::FilterEmail怎麽用?PHP User::FilterEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model\User
的用法示例。
在下文中一共展示了User::FilterEmail方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: changeEmailAjax
public function changeEmailAjax()
{
# some validation...
$new_email = User::FilterEmail($this->request->getPost()['new_email']);
$response = array();
if ($new_email) {
$user = Session::get('user');
$old_email = $user->getEmail();
$user->setEmail($new_email);
$model = App::getModel('login');
$model->setUser($user);
if ($model->update($user->getId())) {
$response['msg'] = 'Success';
} else {
$response['msg'] = 'Error';
$response['error'] = 'Could not update user!';
$user->setEmail($old_email);
}
Session::set('user', $user);
} else {
$response['msg'] = 'Error';
}
echo json_encode($response);
}
示例2: filterPost
private function filterPost($data)
{
$email = User::FilterEmail($data['email']);
$password = isset($data['password']) ? $data['password'] : null;
$role = isset($data['roles']) ? $data['roles'] : 'default';
if (!in_array($role, ['default', 'admin', 'owner'])) {
$role = 'default';
}
$this->user = App::getModel('user')->init(null, $email, $password);
$this->user->setRole($role);
if (strlen(trim($password)) < 3) {
$this->errors = ['Password is too short.'];
return false;
}
return true;
}