public function validate($validator, $values, $arguments = array()) { $values = $values + array('pc' => array(), 'mobile' => array(), 'invalid' => array()); $inputList = explode("\n", opToolkit::unifyEOLCharacter($values['mail_address'])); $inputList = array_unique(array_map('trim', $inputList)); foreach ($inputList as $value) { try { $result = parent::validate($validator, array('mail_address' => $value)); if (!empty($result['pc_address'])) { $values['pc'][] = $result['pc_address']; } elseif (!empty($result['mobile_address'])) { $values['mobile'][] = $result['mobile_address']; } } catch (sfValidatorError $e) { $values['invalid'][] = $value; } } if (empty($values['pc']) && empty($values['mobile'])) { throw new sfValidatorError($validator, 'All of the inputted E-mail addresses are invalid.'); } return $values; }
/** * Enables users who have recieved an invitation to setup a new account * @param string $id 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)); }
function showInviteForm() { if (Event::handle('StartShowInviteForm', array($this))) { $form = new InviteForm($this); $form->show(); Event::handle('EndShowInviteForm', array($this)); } }