当前位置: 首页>>代码示例>>PHP>>正文


PHP Yum::setFlash方法代码示例

本文整理汇总了PHP中Yum::setFlash方法的典型用法代码示例。如果您正苦于以下问题:PHP Yum::setFlash方法的具体用法?PHP Yum::setFlash怎么用?PHP Yum::setFlash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Yum的用法示例。


在下文中一共展示了Yum::setFlash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionUpdate

 public function actionUpdate($id = null)
 {
     if (!$id) {
         $id = Yii::app()->user->id;
     }
     $user = $this->loadModel($id);
     $profile = $user->profile;
     if (isset($_POST['YumUser']) || isset($_POST['YumProfile'])) {
         $user->attributes = @$_POST['YumUser'];
         $profile->attributes = @$_POST['YumProfile'];
         $profile->user_id = $user->id;
         $profile->validate();
         $user->validate();
         if (!$user->hasErrors() && !$profile->hasErrors()) {
             if ($user->save() && $profile->save()) {
                 Yum::setFlash('Your changes have been saved');
                 $this->redirect(array('//profile/profile/view', 'id' => $user->id));
             }
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial(Yum::module('profile')->profileEditView, array('user' => $user, 'profile' => $profile));
     } else {
         $this->render(Yum::module('profile')->profileEditView, array('user' => $user, 'profile' => $profile));
     }
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:26,代码来源:YumProfileController.php

示例2: actionEditAvatar

 public function actionEditAvatar()
 {
     $model = YumUser::model()->findByPk(Yii::app()->user->id);
     if (isset($_POST['YumUser'])) {
         $model->attributes = $_POST['YumUser'];
         $model->setScenario('avatarUpload');
         if (Yum::module('avatar')->avatarMaxWidth != 0) {
             $model->setScenario('avatarSizeCheck');
         }
         $model->avatar = CUploadedFile::getInstanceByName('YumUser[avatar]');
         if ($model->validate()) {
             if ($model->avatar instanceof CUploadedFile) {
                 // Prepend the id of the user to avoid filename conflicts
                 $filename = Yum::module('avatar')->avatarPath . '/' . $model->id . '_' . $_FILES['YumUser']['name']['avatar'];
                 $model->avatar->saveAs($filename);
                 $model->avatar = $filename;
                 if ($model->save()) {
                     Yum::setFlash(Yum::t('The image was uploaded successfully'));
                     Yum::log(Yum::t('User {username} uploaded avatar image {filename}', array('{username}' => $model->username, '{filename}' => $model->avatar)));
                     $this->redirect(array('//profile/profile/view'));
                 }
             }
         }
     }
     $this->render('edit_avatar', array('model' => $model));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:26,代码来源:YumAvatarController.php

示例3: actionLeave

 public function actionLeave($id = null)
 {
     if ($id !== null) {
         $p = YumUsergroup::model()->findByPk($id);
         $participants = $p->participants;
         if (!in_array(Yii::app()->user->id, $participants)) {
             Yum::setFlash(Yum::t('You are not participating in this group'));
         } else {
             $participants = $p->participants;
             foreach ($participants as $key => $participant) {
                 if ($participant == Yii::app()->user->id) {
                     unset($participants[$key]);
                 }
             }
             $p->participants = $participants;
             if ($p->save(array('participants'))) {
                 Yum::setFlash(Yum::t('You have left this group'));
                 Yum::log(Yum::t('User {username} left group id {id}', array('{username}' => Yii::app()->user->data()->username, '{id}' => $id)));
             }
         }
         $this->redirect(array('//usergroup/groups/index'));
     } else {
         throw new CHttpException(404);
     }
 }
开发者ID:usmansaleem10,项目名称:youthpowered,代码行数:25,代码来源:YumUsergroupController.php

示例4: actionDelete

 public function actionDelete()
 {
     $permission = YumPermission::model()->findByPk($_GET['id']);
     if ($permission->delete()) {
         Yum::setFlash(Yum::t('The permission has been removed'));
     } else {
         Yum::setFlash(Yum::t('Error while removing the permission'));
     }
     $this->redirect(array('//role/permission/admin'));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:10,代码来源:YumPermissionController.php

示例5: actionExtend

 public function actionExtend()
 {
     $membership = YumMembership::model()->findByPk($_POST['membership_id']);
     if (!$membership) {
         throw new CHttpException(404);
     }
     if ($membership->user_id != Yii::app()->user->id) {
         throw new CHttpException(403);
     }
     $subscription = $_POST['subscription'];
     $membership->subscribed = $subscription == 'cancel' ? -1 : $subscription;
     $membership->save(false, array('subscribed'));
     Yum::setFlash('Your subscription setting has been saved');
     $this->redirect(Yum::module('membership')->membershipIndexRoute);
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:15,代码来源:YumMembershipController.php

示例6: actionInvite

 public function actionInvite($user_id = null)
 {
     if (isset($_POST['user_id'])) {
         $user_id = $_POST['user_id'];
     }
     if ($user_id == null) {
         return false;
     }
     if (isset($_POST['message']) && isset($user_id)) {
         $friendship = new YumFriendship();
         if ($friendship->requestFriendship(Yii::app()->user->id, $_POST['user_id'], $_POST['message'])) {
             Yum::setFlash('The friendship request has been sent');
             $this->redirect(array('//profile/profile/view', 'id' => $user_id));
         }
     }
     $this->render('invitation', array('inviter' => YumUser::model()->findByPk(Yii::app()->user->id), 'invited' => YumUser::model()->findByPk($user_id), 'friendship' => isset($friendship) ? $friendship : null));
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:17,代码来源:YumFriendshipController.php

示例7: actionRegistration

 public function actionRegistration()
 {
     Yii::import('application.modules.profile.models.*');
     $profile = new YumProfile();
     if (isset($_POST['Profile'])) {
         $profile->attributes = $_POST['YumProfile'];
         if ($profile->save()) {
             $user = new YumUser();
         }
         $password = YumUser::generatePassword();
         // we generate a dummy username here, since yum requires one
         $user->register(md5($profile->email), $password, $profile);
         $this->sendRegistrationEmail($user, $password);
         Yum::setFlash('Thank you for your registration. Please check your email.');
         $this->redirect(Yum::module()->loginUrl);
     }
     $this->render('/registration/registration', array('profile' => $profile));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:18,代码来源:RegistrationController.php

示例8: actionJoin

 public function actionJoin($id = null)
 {
     if ($id !== null) {
         $p = YumUsergroup::model()->findByPk($id);
         $participants = $p->participants;
         if (in_array(Yii::app()->user->id, $participants)) {
             Yum::setFlash(Yum::t('You are already participating in this group'));
         } else {
             $participants[] = Yii::app()->user->id;
             $p->participants = $participants;
             if ($p->save(array('participants'))) {
                 Yum::setFlash(Yum::t('You have joined this group'));
                 Yum::log(Yum::t('User {username} joined group id {id}', array('{username}' => Yii::app()->user->data()->username, '{id}' => $id)));
             }
         }
         $this->redirect(array('//usergroup/groups/view', 'id' => $id));
     }
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:18,代码来源:YumUsergroupController.php

示例9: actionCompose

 public function actionCompose($to_user_id = null, $answer_to = 0)
 {
     $model = new YumMessage();
     $this->performAjaxValidation('YumMessage', 'yum-message-form');
     if (isset($_POST['YumMessage'])) {
         $model->attributes = $_POST['YumMessage'];
         $model->from_user_id = Yii::app()->user->id;
         $model->validate();
         if (!$model->hasErrors()) {
             $model->save();
             Yum::setFlash(Yum::t('Message "{message}" has been sent to {to}', array('{message}' => $model->title, '{to}' => YumUser::model()->findByPk($model->to_user_id)->username)));
             $this->redirect(Yum::module('message')->inboxRoute);
         }
     }
     $fct = 'render';
     if (Yii::app()->request->isAjaxRequest) {
         $fct = 'renderPartial';
     }
     $this->{$fct}('compose', array('model' => $model, 'to_user_id' => $to_user_id, 'answer_to' => $answer_to));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:20,代码来源:YumMessageController.php

示例10: actionSubscribeToNewsLetter

 public function actionSubscribeToNewsLetter()
 {
     $zipcode = $_POST['zipcode'];
     $email = $_POST['email'];
     // check if email already exists in the database
     $subscObj = Newslettersubscribers::model()->find('email =:email', array(':email' => $email));
     if ($subscObj) {
         Yum::setFlash(Yum::t('Email already added in subscriber list'));
         $this->redirect(Yum::module()->loginUrl);
     }
     $newsSubcModel = new Newslettersubscribers();
     $newsSubcModel->setAttribute('zipcode', $zipcode);
     $newsSubcModel->setAttribute('email', $email);
     $newsSubobj = $newsSubcModel->save();
     if ($newsSubobj) {
         Yum::setFlash(Yum::t('Your email has been added to the subscriber list'));
     } else {
         Yum::setFlash(Yum::t('Error: please try again later'));
     }
     $this->redirect(Yum::module()->loginUrl);
 }
开发者ID:usmansaleem10,项目名称:youthpowered,代码行数:21,代码来源:YumNewsletterController.php

示例11: actionUpdate

 public function actionUpdate()
 {
     $model = YumPrivacySetting::model()->findByPk(Yii::app()->user->id);
     if (isset($_POST['YumPrivacysetting'])) {
         $model->attributes = $_POST['YumPrivacysetting'];
         $profile_privacy = 0;
         foreach ($_POST as $key => $value) {
             if ($value == 1 && substr($key, 0, 18) == 'privacy_for_field_') {
                 $data = explode('_', $key);
                 $data = (int) $data[3];
                 $profile_privacy += $data;
             }
         }
         $model->public_profile_fields = $profile_privacy;
         $model->validate();
         if (isset($_POST['YumProfile'])) {
             $profile = $model->user->profile;
             $profile->attributes = $_POST['YumProfile'];
             $profile->validate();
         }
         if (!$model->hasErrors()) {
             $profile->save();
             $model->save();
             Yum::setFlash('Your privacy settings have been saved');
             $this->redirect(array('//profile/profile/view', 'id' => $model->user_id));
         }
     }
     // If the user does not have a privacy setting entry yet, create an
     // empty one
     if (!$model) {
         $model = new YumPrivacySetting();
         $model->user_id = Yii::app()->user->id;
         $model->save();
         $this->refresh();
     }
     $this->render(Yum::module('profile')->privacySettingView, array('model' => $model, 'profile' => isset($model->user) && isset($model->user->profile) ? $model->user->profile : null));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:37,代码来源:YumPrivacysettingController.php

示例12: actionUpdate

 public function actionUpdate($category = null, $message = null, $language = null)
 {
     $models = array();
     foreach (Yum::getAvailableLanguages() as $language) {
         $models[] = $this->loadModel($category, $message, $language);
     }
     if (isset($_POST['YumTranslation'])) {
         $category = $_POST['YumTranslation']['category'];
         $message = $_POST['YumTranslation']['message'];
         foreach ($_POST as $key => $translation) {
             if (substr($key, 0, 11) == 'translation') {
                 $lang = explode('_', $key);
                 if (isset($lang[1])) {
                     $lang = $lang[1];
                     foreach (Yum::getAvailableLanguages() as $language) {
                         if ($language == $lang) {
                             $model = YumTranslation::model()->find('category = :category and message = :message and language = :language ', array(':category' => $category, ':message' => $message, ':language' => $lang));
                             if (!$model) {
                                 $model = new YumTranslation();
                             }
                             if ($translation != '') {
                                 $model->message = $message;
                                 $model->category = $category;
                                 $model->translation = $translation;
                                 $model->language = $lang;
                                 $model->save();
                             }
                         }
                     }
                 }
             }
         }
         Yum::setFlash('Translations have been saved');
         $this->redirect(array('admin'));
     }
     $this->render('update', array('models' => $models));
 }
开发者ID:Canyian,项目名称:yii-user-management-facebook,代码行数:37,代码来源:YumTranslationController.php

示例13: actionRecovery

 /**
  * Password recovery routine. The User will receive an email with an
  * activation link. If clicked, he will be prompted to enter his new
  * password.
  */
 public function actionRecovery($email = null, $key = null)
 {
     $form = new YumPasswordRecoveryForm();
     if ($email != null && $key != null) {
         if ($profile = YumProfile::model()->find('email = :email', array('email' => $email))) {
             $user = $profile->user;
             if ($user->status <= 0) {
                 throw new CHttpException(403, 'User is not active');
             } else {
                 if ($user->activationKey == urldecode($key)) {
                     $passwordform = new YumUserChangePassword();
                     if (isset($_POST['YumUserChangePassword'])) {
                         $passwordform->attributes = $_POST['YumUserChangePassword'];
                         if ($passwordform->validate()) {
                             $user->setPassword($passwordform->password);
                             $user->activationKey = CPasswordHelper::hashPassword(microtime() . $passwordform->password, Yum::module()->passwordHashCost);
                             $user->save();
                             Yum::setFlash('Your new password has been saved.');
                             if (Yum::module('registration')->loginAfterSuccessfulRecovery) {
                                 $login = new YumUserIdentity($user->username, false);
                                 $login->authenticate(true);
                                 Yii::app()->user->login($login);
                                 $this->redirect(Yii::app()->homeUrl);
                             } else {
                                 $this->redirect(Yum::module()->loginUrl);
                             }
                         }
                     }
                     $this->render(Yum::module('registration')->changePasswordView, array('form' => $passwordform));
                     Yii::app()->end();
                 } else {
                     $form->addError('login_or_email', Yum::t('Invalid recovery key'));
                     Yum::log(Yum::t('Someone tried to recover a password, but entered a wrong recovery key. Email is {email}, associated user is {username} (id: {uid})', array('{email}' => $email, '{uid}' => $user->id, '{username}' => $user->username)));
                 }
             }
         }
     } else {
         if (isset($_POST['YumPasswordRecoveryForm'])) {
             $form->attributes = $_POST['YumPasswordRecoveryForm'];
             if ($form->validate()) {
                 if ($form->user instanceof YumUser) {
                     if ($form->user->status <= 0) {
                         throw new CHttpException(403, 'User is not active');
                     }
                     $form->user->generateActivationKey();
                     $recovery_url = $this->createAbsoluteUrl(Yum::module('registration')->recoveryUrl[0], array('key' => urlencode($form->user->activationKey), 'email' => $form->user->profile->email));
                     Yum::log(Yum::t('{username} successfully requested a new password in the password recovery form. A email with the password recovery url {recovery_url} has been sent to {email}', array('{email}' => $form->user->profile->email, '{recovery_url}' => $recovery_url, '{username}' => $form->user->username)));
                     $mail = array('from' => Yii::app()->params['adminEmail'], 'to' => $form->user->profile->email, 'subject' => 'You requested a new password', 'body' => strtr('You have requested a new password. Please use this URL to continue: {recovery_url}', array('{recovery_url}' => $recovery_url)));
                     $sent = YumMailer::send($mail);
                     Yum::setFlash('Instructions have been sent to you. Please check your email.');
                 } else {
                     Yum::log(Yum::t('A password has been requested, but no associated user was found in the database. Requested user/email is: {username}', array('{username}' => $form->login_or_email)));
                 }
                 $this->redirect(Yum::module()->loginUrl);
             }
         }
     }
     $this->render(Yum::module('registration')->recoverPasswordView, array('form' => $form));
 }
开发者ID:kumarsivarajan,项目名称:yii-user-management,代码行数:64,代码来源:YumRegistrationController.php

示例14: actionuploadDocuments

 public function actionuploadDocuments()
 {
     if (!empty(Yii::app()->user->_data)) {
         $userId = Yii::app()->user->_data->id;
     }
     // getting project Id
     $projectId = Yii::app()->request->getPost('project_id');
     if (isset($_POST['YumUserdocuments']) && isset($_POST['YumUserdocuments']['name'])) {
         $model = new YumUserdocuments();
         $model->attributes = $_POST['YumUserdocuments'];
         $model->name = CUploadedFile::getInstanceByName('YumUserdocuments[name]');
         if ($model->name instanceof CUploadedFile) {
             //  $userId =5;
             // Prepend the id of the user to avoid filename conflicts
             $fileName = $_FILES['YumUserdocuments']['name']['name'];
             $filePath = Yum::module('userdocuments')->documentPath . '/' . $userId . '_' . $_FILES['YumUserdocuments']['name']['name'];
             $model->name->saveAs($filePath);
             $attrArr = array('name' => $fileName, 'path' => $filePath, 'created_by' => $userId);
             $model->attributes = $attrArr;
             if ($model->save(false)) {
                 if ($projectId) {
                     $userProjectDocuments = new YumUserdocumentsprojects();
                     $attrArrProject = array('project_id' => $projectId, 'userdocuments_id' => $model['userdocuments_id'], 'created_by' => $userId);
                     $userProjectDocuments->attributes = $attrArrProject;
                     if ($userProjectDocuments->save()) {
                         Yum::setFlash(Yum::t('The Document was uploaded successfully'));
                         $this->redirect(array('//userproject/userproject/projectdetails?project_id=' . $projectId));
                     }
                 }
                 Yum::setFlash(Yum::t('The Document was uploaded successfully'));
                 $this->redirect(array('//userdocuments/userdocuments/index'));
             }
         }
     }
 }
开发者ID:usmansaleem10,项目名称:youthpowered,代码行数:35,代码来源:YumUserdocumentsController.php

示例15: actionRecovery

	/**
	 * Password recovery routine. The User will receive an email with an
	 * activation link. If clicked, he will be prompted to enter his new
	 * password.
	 */
	public function actionRecovery($email = null, $key = null) {
		$form = new YumPasswordRecoveryForm;

		if ($email != null && $key != null) {
			if($profile = YumProfile::model()->find('email = :email', array(
							'email' =>  $email))) {
				$user = $profile->user;
				if($user->activationKey == $key) {
					$passwordform = new YumUserChangePassword;
					if (isset($_POST['YumUserChangePassword'])) {
						$passwordform->attributes = $_POST['YumUserChangePassword'];
						if ($passwordform->validate()) {
							$user->password = YumUser::encrypt($passwordform->password);
							$user->activationKey = YumUser::encrypt(microtime() . $passwordform->password);
							$user->save();
							Yum::setFlash('Your new password has been saved.');
							$this->redirect(Yum::module()->loginUrl);
						}
					}
					$this->render(
							Yum::module('registration')->changePasswordView, array(
								'form' => $passwordform));
					Yii::app()->end();
				} else {
					$form->addError('login_or_email', Yum::t('Invalid recovery key'));
					Yum::log(Yum::t(
								'Someone tried to recover a password, but entered a wrong recovery key. Email is {email}, associated user is {username} (id: {uid})', array(
									'{email}' => $email,
									'{uid}' => $user->id,
									'{username}' => $user->username)));
				}
			}
		} else {
			if (isset($_POST['YumPasswordRecoveryForm'])) {
				$form->attributes = $_POST['YumPasswordRecoveryForm'];

				if ($form->validate()) {
					Yum::setFlash(
							'Instructions have been sent to you. Please check your email.');

					if($form->user instanceof YumUser) {
						$form->user->generateActivationKey();
						$recovery_url = $this->createAbsoluteUrl(
								Yum::module('registration')->recoveryUrl[0], array(
									'key' => $form->user->activationKey,
									'email' => $form->user->profile->email));

						Yum::log(Yum::t(
									'{username} successfully requested a new password in the password recovery form. A email with the password recovery url {recovery_url} has been sent to {email}', array(
										'{email}' => $form->user->profile->email,
										'{recovery_url}' => $recovery_url,
										'{username}' => $form->user->username)));

						$content = YumTextSettings::model()->find(
								'language = :lang', array('lang' => Yii::app()->language));
						$sent = null;

						if (is_object($content)) {
							$mail = array(
									'from' => Yii::app()->params['adminEmail'],
									'to' => $form->user->profile->email,
									'subject' => $content->subject_email_registration,
									'body' => strtr($content->text_email_recovery, array(
											'{recovery_url}' => $recovery_url)),
									);
							$sent = YumMailer::send($mail);
						} else {
							throw new CException(Yum::t('The messages for your application language are not defined.'));
						}
					} else
						Yum::log(Yum::t(
									'A password has been requested, but no associated user was found in the database. Requested user/email is: {username}', array(
										'{username}' => $form->login_or_email)));
					$this->redirect(Yum::module()->loginUrl);
				}
			}
		}
		$this->render(Yum::module('registration')->recoverPasswordView, array(
					'form' => $form));

	}
开发者ID:richardh68,项目名称:yii-user-management,代码行数:86,代码来源:YumRegistrationController.php


注:本文中的Yum::setFlash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。