SiteController::actionAcceptInvite PHP Method

actionAcceptInvite() public method

Enables users who have recieved an invitation to setup a new account
public actionAcceptInvite ( string $id = NULL )
$id string The activation id the of the user that we want to activate
    public function actionAcceptInvite($id = NULL)
    {
        $this->layout = '//layouts/main';
        $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Site', 'Accept Invitation'))));
        if ($id === NULL) {
            throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.'));
        }
        // Make sure we have a user first
        $meta = UserMetadata::model()->findByAttributes(array('key' => 'invitationKey', 'value' => $id));
        if ($meta === NULL) {
            throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.'));
        }
        $model = new InviteForm();
        $model->email = Users::model()->findByPk($meta->user_id)->email;
        if (Cii::get($_POST, 'InviteForm', NULL) !== NULL) {
            $model->attributes = Cii::get($_POST, 'InviteForm', NULL);
            $model->id = $meta->user_id;
            if ($model->acceptInvite()) {
                $meta->delete();
                return $this->render('invitesuccess');
            }
        }
        $this->render('acceptinvite', array('model' => $model));
    }