最適に機能しないパスワードのリセット コンポーネントを含む joomla 1.5 サイトを継承しました。ATM ユーザーが入力した電子メールにパスワードのリセットを送信することはできますが、既存のユーザーと照合して電子メールが有効かどうかをチェックする機能がコンポーネントにありません。私は PHP にかなり慣れていないので、追加の if ステートメントを導入する方法が 100% わかりません。
これまでの様子は次のとおりです。
public function submitemail() {
$db = JFactory::getDBO() ;
$requestedEmail = JRequest::getVar('emailaddr' , '') ;
$db->setQuery('select id , username, name, email from #__users where block = 0 and email = "'.$requestedEmail.'"') ;
if( $user = $db->loadObject() ) {
// Make sure the user isn't a Super Admin.
$juser = JFactory::getUser($user->id) ;
//joomla 1.6 and 1.5 check
if ($juser->authorize('core.admin') || $juser->usertype == 'Super Administrator') {
$this->setRedirect( 'index.php?option=com_resetpassword' , 'Email is not valid' ) ;
}
else {
$result = $this->sendPasswordResetEmail( $user ) ;
$this->setRedirect( 'index.php?option=com_resetpassword&layout=success' //, 'Please check your email and follow the instructions to reset your password '
) ;
}
}
else {
$this->setRedirect( 'index.php?option=com_resetpassword' );
}
}
そして、このスニペットを見つけた関連記事に出くわしました。リセットのためにユーザーが入力した電子メールに対して、現在データベースにある電子メール アドレスを確認するにはどうすればよいですか?
function validate()
{ jimport('joomla.mail.helper');
$valid = true;
if ($this->_data->email && !JMailHelper::isEmailAddress($this->_data->email))
{
$this->_app->enqueueMessage(JText::_('Invalid Email Address'),'error');
$valid = false;
}
return $valid;
}