public function actionIndex() { if(Auction::$app->user->isGuest){ Auction::warning('Guest User :: Redirecting to Login Page'); $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('site/login')); } else { switch (Auction::$app->session->get('user.role')) { case DatabaseHelper::ADMIN : Auction::info('Redirecting to Admin Module'); $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('admin')); break; case DatabaseHelper::DEALER : Auction::info('Redirecting to Dealer Module'); $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('dealer/profile')); break; case DatabaseHelper::COMPANY_USER : Auction::info('Redirecting to Company User Module'); $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('company/profile')); break; case DatabaseHelper::COMPANY_ADMIN : Auction::info('Redirecting to Company Admin Module'); $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('company/info')); break; default : $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('site/login')); Auction::warningLog('Logging Out due to Unknown Role Created On Server',['role' => Auction::userRole()]); } } }
/** * Sends an email with a link, for resetting the password. * * @return boolean whether the email was send */ public function sendEmail() { /* @var $user from User validator user variable */ $user = $this->validators[2]->user; Auction::info('User is ready to sent a new Token'); switch ($this->via){ case 'email' : ForgotPasswordHistory::model()->generateOtp($user); break; case 'sms': OptHistory::model()->generateOtp($user); } return false; }
protected function dataTables(){ $allModels = (new Query())->select( '('.(new Query())->select('count(*)')->from(Auctions::tableName())->createCommand()->rawSql.') as auctions,'. '('.(new Query())->select('count(*)')->from(Dealers::tableName())->createCommand()->rawSql.') as dealers,'. '('.(new Query())->select('count(*)')->from(Companies::tableName())->createCommand()->rawSql.') as companies,'. '('.(new Query())->select('count(*)')->from(Brands::tableName())->createCommand()->rawSql.') as brands,'. '('.(new Query())->select('count(*)')->from(Categories::tableName())->createCommand()->rawSql.') as categories' )->one(); $_message = Auction::loggerMessageFormat('Admin Dashboard Created With :: ',$allModels); Auction::info($_message); return new ArrayDataProvider([ 'allModels' => $allModels, 'pagination' => false ]); }
/** * Action to Perform User Logout * Will go Home If User is already logout */ public function actionIndex() { if(Auction::$app->user->isGuest){ Auction::warning('User Already is Logged Out'); return $this->goHome(); } Auction::$app->user->logout(); //Setting Logger @info $message = Auction::loggerMessageFormat('User logout SuccessFully' ,[ 'class' => __CLASS__ , 'function' => __METHOD__, 'username' => Auction::$app->session->get('user.name'), 'role' => Auction::$app->session->get('user.role'), 'userId' => Auction::$app->user->id ]); Auction::info($message,Auction::LOGGER_FRONTEND_CATEGORY); return $this->goHome(); }
public function afterSave(){ $_model = new AuctionEmails(); $_model->message = strtr(MessageTemplate::MessageTemplate(DatabaseHelper::DEALER_REGISTRATION_TEMPLATE),['{name}' => $this->name]); $_model->to = $this->email; $_model->subject = 'Auction :: Company Registration'; $_model->from = 'Auction'; $_model->status = DatabaseHelper::SEND_MAIL; if($_model->save()){ Auction::info('Company Registration Email registered'); } else { $message= Auction::loggerMessageFormat('Email is not send to user due to following errors',$_model->getErrors()); Auction::error($message); } }
public function update($runValidation = true, $attributeNames = null){ $this->image = UploadedFile::getInstance($this->user0, 'profile_pic'); if(!parent::validate()) return false; if($this->image instanceof UploadedFile){ if(!getimagesize($this->image->tempName)){ $this->addError('image','Please Upload a valid Image'); return false; } Auction::info('Image Upload Event Triggered'); $this->trigger(Events::UPLOAD_IMAGE); parent::update(false); $this->user0->profile_pic = $this->image; } else{ $this->user0->profile_pic = $this->user0->oldAttributes['profile_pic']; } if($this->user0->save(false)) { Auction::info('Dealer is successsfully Updated'); return true; }else{ Auction::infoLog('Dealer is not updated Due to following validation Errors',$this->user0->getErrors()); return false; } }
/** Send Reset Token */ public static function SendResetToken($event){ $message = ''; switch ($event->sender->mode){ case DatabaseHelper::TOKEN_SEND_MODE_WEB: $message = MessageTemplate::MessageTemplate(DatabaseHelper::FORGOT_PASSWORD_MAIL_TEMPLATE); $_model = new AuctionEmails(); $_model->to = $event->sender->userObject->email; $_model->subject = 'Auction :: Reset Password Email'; $_model->status = 0 ; $_model->from = 'Auction'; break; case DatabaseHelper::TOKEN_SEND_MODE_MOBILE: $message = MessageTemplate::MessageTemplate(DatabaseHelper::FORGOT_PASSWORD_SMS_TEMPLATE); $_model = new OptHistory(); $_model->mobile = $event->sender->userObject->mobile; break; } if($message == ''){ Auction::error('No Valid Msg Template Found For ' .$event->sender->mode.' in database'); throw new HttpException(400 , 'No Template Found'); } $_model->message = $message; if($_model->save()){ Auction::info('User Token successfully Created'); }else { $_message = Auction::loggerMessageFormat('User reset token template invalid ',$_model->getErrors()); Auction::error($_message); } }