protected function returnSuccess() { if ($this->isAjax()) { echo CJSON::encode(array('result' => 0, 'message' => Yii::t('user', 'Login successful'))); Yii::app()->end(); } else { Flashes::addInfoFlash(Yii::t('user', 'Login successful')); $this->getController()->redirect(Yii::app()->user->returnUrl); } }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'index' page. */ public function actionDelete() { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request if (LocationService::loadModel()->delete()) { Flashes::addInfoFlash(Yii::t('amo', 'Location deleted')); } else { Flashes::addErrorFlash(Yii::t('amo', 'Could not delete the location.') . ' ' . Yii::t('amo', 'Please, try again later.')); } $this->redirect(array('index')); } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
protected function returnSuccess($user) { $newPassword = UserService::resetPassword($user); $message = $newPassword ? "" : Yii::t('user', 'An email was sent with a new password'); if ($this->isAjax()) { echo CJSON::encode(array('result' => $newPassword ? 0 : -1, 'message' => $message)); Yii::app()->end(); } else { if ($emailSent) { Flashes::addInfoFlash($message); $this->getController()->redirect(Yii::app()->user->returnUrl); } } }
protected function returnSuccess($user) { $registrationSuccessful = UserService::register($user); $message = $registrationSuccessful ? "" : Yii::t('user', 'An email was sent with the registration password'); if ($this->isAjax()) { echo CJSON::encode(array('result' => $registrationSuccessful ? 0 : -1, 'message' => $message)); Yii::app()->end(); } else { if ($registrationSuccessful) { Flashes::addInfoFlash($message); $this->getController()->redirect(Yii::app()->user->returnUrl); } } }
<?php StdLib::Functions(); Flashes::render(); $prefix = $_REQUEST["prefix"]; $num = $_REQUEST["num"]; $title = Yii::app()->db->createCommand()->select("title")->from("course_syllabi")->where("prefix = :prefix AND num = :num", array(":prefix" => $prefix, ":num" => $num))->queryScalar(); $department = Yii::app()->db->createCommand()->select("label")->from("departments")->where("id = :prefix", array(":prefix" => $prefix))->queryScalar(); $classes = Yii::app()->db->createCommand()->select("id")->from("course_syllabi")->where("prefix = :prefix AND num = :num", array(":prefix" => $prefix, ":num" => $num))->order("year DESC, (term = 'Fall') DESC, (term = 'Summer') DESC, (term = 'Spring') DESC")->queryAll(); $COREUSER = !Yii::app()->user->isGuest ? new UserObj(Yii::app()->user->name) : new UserObj(); ?> <ul class="breadcrumb"> <li><a href="<?php echo Yii::app()->homeUrl; ?> ">Home</a></li> <li><a href="<?php echo Yii::app()->homeUrl; ?> ?prefix=<?php echo $prefix; ?> "><?php echo $department; ?> </a></li> <li class="active"><?php echo $prefix . " " . $num . " - " . $title; ?> </li>
<?php /** * Login page */ $this->pageTitle = Yii::app()->name . ' - Login'; $imager = new Imager(LOCAL_IMAGE_LIBRARY . "lock.png"); $imager->width = "16px"; $imager->height = "16px"; $imager->attributes["title"] = "This password is passed through 256-bit encryption for authentication."; $flashes = new Flashes(); $flashes->render(); ?> <style> div.authen-container { margin:auto; width:480px; border:1px solid #ccc; padding:8px; } div.authen-title { padding:5px; margin-bottom:12px; } form#login-form div.input-container input { font-family: Verdana, Geneva, sans-serif; font-size:12px; padding:5px; letter-spacing:1px; margin-bottom:5px; width: 300px;
public static function addErrorFlash($flash) { Flashes::addFlash('error', $flash); }
<?php $flashes = Flashes::getFlashes(); $existFlashes = isset($flashes) && is_array($flashes); ?> <ul style="display:<?php echo $existFlashes ? "block" : "none"; ?> "> <?php if ($existFlashes) { ?> <?php foreach ($flashes as $flash) { ?> <li class="<?php echo $flash['level']; ?> " > <?php echo $flash['message']; ?> </li> <?php } } ?> </ul>
public function actionLogout() { Yii::app()->user->logout(); Flashes::addInfoFlash(Yii::t('amo', 'You have logged out. Thank you for visiting us!')); $this->redirect(Yii::app()->homeUrl); }
/** Deletes a particular model. If deletion is successful, the browser will be redirected to the 'list' page. */ public function actionDelete() { $model = $this->loadVehicle(); if (Yii::app()->user->checkAccess('editOwnVehicle', array('vehicle' => $model), false)) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request if ($model->delete()) { Flashes::addInfoFlash(Yii::t('amo', 'Vehicle deleted successfully')); } else { Flashes::addErrorFlash(Yii::t('amo', 'Could not delete the vehicle.') . ' ' . Yii::t('amo', 'Please, try again later.')); } $this->redirect(array('list')); } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } } else { $this->accessDenied(Yii::app()->user); } }