本文整理汇总了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;
}