Exemplo n.º 1
0
 /**
  * Creates a new CodeMember model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new CodeMember();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
 public function actionAccept()
 {
     $codeMember = new CodeMember();
     $codeMember->user_id = Yii::$app->request->get('user_id');
     $codeMember->codeBank_code = Yii::$app->request->get('code');
     $codeMember->auth_item_name = Yii::$app->request->get('role');
     $message_id = Yii::$app->request->get('message_id');
     $codeMember->save();
     //Check auth_assignment
     if (Yii::$app->authManager->getAssignment($codeMember->auth_item_name, $codeMember->user_id) == null) {
         $role = Yii::$app->authManager->getRole($codeMember->auth_item_name);
         Yii::$app->authManager->assign($role, $codeMember->user_id);
     }
     $username = $codeMember->user->username;
     $message = Messages::findOne(intval($message_id));
     $message->content = Yii::$app->controller->renderPartial('_accepted_message', ['username' => $username, 'role' => $codeMember->auth_item_name, 'code' => $codeMember->codeBank_code]);
     $message->save();
     Yii::$app->session->setFlash('success', 'You have been added to participate for Hybrizy code: ' . $codeMember->codeBank_code);
     return $this->redirect(['/messages/index']);
 }