/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new AccountTeamMember(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['AccountTeamMember'])) { $model->attributes = $_POST['AccountTeamMember']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->account_team_member_id)); } } $this->render('create', array('model' => $model)); }
/** * This action is used for an existing account who is invited to another team. */ public function actionJoinTeam() { if (isset($_GET['invite_id'])) { $invite_id = $_GET['invite_id']; // get invite $model = $this->loadModel($invite_id); $model->account_invitation_status = 1; $model->save(); // create team member record $teamMember = new AccountTeamMember(); $teamMember->accepting_invitation = true; $teamMember->master_account_id = $model->account_invitation_master_id; $teamMember->account_subscription_id = $model->account_invitation_subscription_id; $teamMember->member_account_id = Yii::app()->user->id; $teamMember->is_active = AccountTeamMember::ACCOUNT_TEAM_MEMBER_IS_ACTIVE; if ($model->account_invitation_type == AccountInvitation::ACCOUNT_INVITATION_TYPE_CUSTOMER) { $teamMember->is_customer = ACCOUNT_TEAM_MEMBER_IS_CUSTOMER; } else { $teamMember->is_customer = 0; } if ($teamMember->save()) { $this->redirect(array('accountTeamMember/admin')); } if ($teamMember->save()) { // create project member record if any if ($model->account_invitation_project > 0) { $projectMember = new ProjectMember(); $projectMember->project_id = $model->account_invitation_project; $projectMember->account_id = Yii::app()->user->id; $projectMember->project_member_start_date = date('Y-m-d H:i:s'); $projectMember->project_member_is_manager = PROJECT_MEMBER_IS_NOT_MANAGER; $projectMember->accepting_invitation = true; $projectMember->save(); } } } }