本文整理汇总了PHP中Notifications::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::generate方法的具体用法?PHP Notifications::generate怎么用?PHP Notifications::generate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifications
的用法示例。
在下文中一共展示了Notifications::generate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionRetrieve
/**
* Generates a new random password and creates a new Notification item
*/
public function actionRetrieve($id, $redirect)
{
$model = $this->loadModel($id);
$new_pass = Users::model()->generatePassword();
$model->attributes = array('password' => Users::model()->hashPassword($new_pass));
$model->save();
//Notification
Notifications::generate('Users', $model->username, 'users', 'retrieve', $new_pass);
if ($redirect == 'admin') {
Yii::app()->user->setFlash('success', Yii::t('user', 'The new password is generated and was sent to user e-mail.'));
} else {
Yii::app()->user->setFlash('retrieve', Yii::t('user', 'The new password is generated and was sent to your e-mail.'));
}
$this->redirect(array($redirect));
}
示例2: actionRetrieve
/**
* Generates a new random password and creates a new Notification item
*/
public function actionRetrieve()
{
$model = new LoginForm();
if (isset($_POST['LoginForm'])) {
$user = Users::model()->findByPk($_POST['LoginForm']['username']);
if ($user === null) {
$model->addError('username', Yii::t('user', 'Username not valid'));
} else {
$new_pass = Users::model()->generatePassword();
$user->attributes = array('password' => Users::model()->hashPassword($new_pass));
$user->save();
//Notification
Notifications::generate('Users', $user->username, 'users', 'retrieve', $new_pass);
// display the login form
Yii::app()->user->setFlash('retrieve', 'The new password was sent to you via email.');
$this->redirect(array('login'));
}
}
// display the retrieve form
$this->render('retrieve', array('model' => $model));
}
示例3: afterSave
/**
* This method is invoked after saving a record.
* It creates a new Notification item
*/
public function afterSave()
{
//perform this operation only in the first save
if ($this->isNewRecord && $this->role->name == 'planner') {
//Notification
Notifications::generate('Users', $this->username, 'users', 'create');
}
return parent::afterSave();
}