public function actionViewforgotpass($id)
{
$this->layout='/layouts/column2';
$model=new R('forgotpass');
$this->render('viewforgotpass',array('model'=>$model));
}
public function actionForgotPassword()
{
try
{
$this->pageTitle = "CareerSnaps - Forgot Password";
$this->layout='main';
$model=new R('forgotpass');
$codeGenerator=new codeGenerator;
$this->performAjaxValidation($model);
if(isset($_POST['R']))
{
$model->attributes=$_POST['R'];
if($model->validate())
{
$email_sent=new mailer();
if($_POST['R']['email']!=NULL)
$email=$_POST['R']['email'];
$model=R::model()->findByAttributes(array('email'=>$email));
$verification_code=$codeGenerator->generate();
$model->password=md5($verification_code);
if($model->save())
{
$name_portal=CHtml::encode(Yii::app()->name);
$from_email=Yii::app()->params['adminEmail'];
$to_email="abc@yahoo.com";
$forgot_pass="<table width='100%' style='border:5px solid #33CCCC'>
<tr bgcolor='#54ACBF'><td>&nbsp;</td></tr>
<tr>
<td width='594' style='color:#FFFFFF;font-size:32px; margin-bottom:10px;margin-left:10px';>
<div style='float:left'><img src='".'http://'.Yii::app()->request->getServerName().'/'.Yii::app()->baseUrl."/images/logo.png' /></div><div style='float:right;margin-right:150px;'>&nbsp;&nbsp;&nbsp;&nbsp;</div></td></tr>
<tr><td align='center'>
<table align='center'>
<tr height='40' style='background:#54ACBF;'><td align='center'>
<p style='color:#FFFFFF;font-size:16px;font-weight:bold;'>
Information of changed password.
</p>
</td></tr>
<tr><td><p style='color:#54ACBF;'>Dear Admin</p></td></tr>
<tr><td>
<p style='margin-left:20px;color:#54ACBF;'>
<br>
We are pleased to in form you that your jobseeker account password has been change.<br /> The details of jobseeker account are given below.
</p>
<p style='color:#54ACBF;margin-left:20px;'>
Email : ".$model->email."<br />
New Password: ".$verification_code."<br />
</p>
</td></tr>
<br>
<tr><td align='left'>
<p style='color:#54ACBF;'>Thanks </p>
</td></tr>
</table>
</td></tr>
</table>";
$email_sent->sentmailjobseeker($to_email,"Information of changed password ",$name_portal,$forgot_pass,$model->email);
var_dump($forgot_pass);exit;
$this->redirect(array('viewforgotpass','id'=>$model->r_id));
Yii::app()->end();
}
else
{
$msg = Yii::app()->getUser()->setFlash('error','Sorry your registration is not done due to some internal problame.Please try again. ');
$this->redirect(array('site/forgotPassMsg'));
Yii::app()->end();
}
}
}
$this->render('forgotpass',array('model'=>$model,));
}
catch (Exception $e)
{
$model->addError(NULL, "Error while updating to database");
}
}