2013-03-09 2 views
1

나는 최적의 기능을하지 못하는 비밀번호 재설정 구성 요소가있는 joomla 1.5 사이트를 상속 받았습니다. ATM 사용자가 입력 한 전자 메일로 암호 재설정을 보낼 수 있지만 구성 요소에는 전자 메일이 유효한지 확인하기 위해 기존 사용자를 확인하는 기능이 없습니다. 나는 PHP에 익숙하지 않기 때문에 if 문을 추가로 소개하는 방법을 100 % 확신 할 수는 없습니다.Joomla 1.5 비밀번호 확인

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; 
} 
+0

는'com_users' 폴더에있는 파일에서이 코드인가? – Lodder

+0

아니요, com_resetpassword 폴더에 있습니다. – juneuprising

답변

1

실제로 실제로 이미 수행하고있는 작업입니다. 정상은 제출 된 전자 메일 주소를 기반으로 사용자에 대한 행을로드 :

else { 
    $this->_app->enqueueMessage(JText::_('Invalid Email Address'),'error'); 
    $this->setRedirect('index.php?option=com_resetpassword' ); 
} 
:

$requestedEmail = JRequest::getVar('emailaddr' , '') ; 
$db->setQuery('select id , username, name, email from #__users where block = 0 and email = "'.$requestedEmail.'"') ; 
if($user = $db->loadObject()) { 
    ... 

당신은 가능성이 맨 아래에있는 다른 문에 실패 할 경우에 대한 메시지를 추가하기 만하면됩니다

$this->_app가 설정되지 않은 경우, 당신은 대신을 사용하여 해당를 얻을 수 있어야합니다 :

JFactory::getApplication()->enqueueMessage(JText::_('Invalid Email Address'),'error'); 
+0

그래서 그렇게 보일까요? 'else { \t \t \t JFactory :: getApplication() -> enqueueMessage (JText :: _ (잘못된 이메일 주소), 'error'); \t \t \t $ this-> setRedirect ('index.php? option = com_resetpassword'); \t \t \t \t \t \t \t \t \t \t \t은}' – juneuprising

+0

는 작업있어! 다윗에게 정말 감사드립니다. – juneuprising