public function __construct() { parent::__construct(); $this->addTextInput('username', translateFN('Nome utente'))->setRequired()->setValidator(FormValidator::EMAIL_VALIDATOR); $this->addPasswordInput('password', translateFN('Password'))->setRequired()->setValidator(FormValidator::PASSWORD_VALIDATOR); $this->addPasswordInput('passwordcheck', translateFN('Conferma la password'))->setRequired()->setValidator(FormValidator::PASSWORD_VALIDATOR); $this->addSelect('tipo', translateFN('Tipo Utente'), array(0 => translateFN('Scegli il tipo...'), AMA_TYPE_AUTHOR => translateFN('Autore'), AMA_TYPE_STUDENT => translateFN('Studente'), AMA_TYPE_TUTOR => translateFN('Tutor'), AMA_TYPE_SUPERTUTOR => translateFN('Super Tutor')), 0)->setRequired()->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR); }
/** * {@inheritDoc} * @see CUserIdentity::authenticate() */ public function authenticate() { $dbconn = Yii::app()->getModule('user')->getDatabaseConnection(); if ($dbconn === null) { return false; } $users = UserUser::model()->findAllByAttributes(array('hash_email' => sha1($this->username))); if ($users === array()) { $criteria = new CDbCriteria(); $criteria->with = array('userProfile' => array('alias' => 'p')); $criteria->compare('p.pseudo', $this->username); $users = UserUser::model()->findAll($criteria); } if (count($users) === 0) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { $this->errorCode = self::ERROR_PASSWORD_INVALID; } foreach ($users as $user) { /* @var $user UserUser */ $hash = UserRegistrationForm::hash($this->password, $user->hash_salt); if (!strcmp($hash, $user->hash_password)) { $this->errorCode = self::ERROR_NONE; $this->user = $user; } } if ($this->errorCode === self::ERROR_NONE) { $profile = $this->user->userProfile; $this->id = $this->user->hash_email; if ($profile !== null) { $this->username = $profile->getName(); } else { $this->username = $this->user->email; } /* @var $session CHttpSession */ $session = Yii::app()->session; $session->regenerateID(); $this->setState('ring_value.current', IPluggableAccessRole::RING_AUTHENTICATED); } return !$this->errorCode; }
/** * Handle submission of the user registration form */ function register() { $this->addCheck(new HandlerValidatorSchedConf($this)); $this->validate(); $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $paymentManager =& OCSPaymentManager::getManager(); if (!$paymentManager->isConfigured()) { Request::redirect(null, null, 'index'); } $user =& Request::getUser(); $registrationDao =& DAORegistry::getDAO('RegistrationDAO'); if ($user && ($registrationId = $registrationDao->getRegistrationIdByUser($user->getId(), $schedConf->getId()))) { // This user has already registered. $registration =& $registrationDao->getRegistration($registrationId); $this->_updateRegistration($registrationDao, $registration); // $isUpdate = Request::getUserVar("update"); if (!$registration || $registration->getDatePaid()) { // And they have already paid. Redirect to a message explaining. // $notifyEmail = Request::getUserVar("notifyEmail"); // // if ($notifyEmail) { // echo "有!"; // exit; // //$this->notifyEmail($registration->getTypeId()); // } // else { // echo '沒有!!'; // exit; // } Request::redirect(null, null, null, 'registration'); } else { // Allow them to resubmit the form to change type or pay again. $registrationDao->deleteRegistrationById($registrationId); } } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageHierarchy', array(array(Request::url(null, 'index', 'index'), $conference->getConferenceTitle(), true), array(Request::url(null, null, 'index'), $schedConf->getSchedConfTitle(), true))); SchedConfHandler::setupTemplate($conference, $schedConf); import('registration.form.UserRegistrationForm'); $typeId = (int) Request::getUserVar('registrationTypeId'); if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor $form = new UserRegistrationForm($typeId); } else { $form =& new UserRegistrationForm($typeId); } $form->readInputData(); if ($form->validate()) { if (($registrationError = $form->execute()) != REGISTRATION_SUCCESSFUL) { $templateMgr->assign('isUserLoggedIn', Validation::isLoggedIn()); // In case a user was just created, make sure they appear logged in if ($registrationError == REGISTRATION_FAILED) { // User not created $templateMgr->assign('message', 'schedConf.registration.failed'); $templateMgr->assign('backLinkLabel', 'common.back'); $templateMgr->assign('backLink', Request::url(null, null, 'index')); $templateMgr->display('common/message.tpl'); } elseif ($registrationError == REGISTRATION_NO_PAYMENT) { // Automatic payment failed; display a generic // "you will be contacted" message. $templateMgr->assign('message', 'schedConf.registration.noPaymentMethodAvailable'); $templateMgr->assign('backLinkLabel', 'common.back'); $templateMgr->assign('backLink', Request::url(null, null, 'index')); $templateMgr->display('common/message.tpl'); } elseif ($registrationError == REGISTRATION_FREE) { // Registration successful; no payment required (free) $templateMgr->assign('message', 'schedConf.registration.free'); $templateMgr->assign('backLinkLabel', 'common.back'); $templateMgr->assign('backLink', Request::url(null, null, 'index')); //$templateMgr->display('common/message.tpl'); //$registration =& $registrationDao->getRegistration($registrationId); //$this->_registrationDisplay($registration); //$this->_updateRegistration($registrationDao, $registration); $notifyEmail = Request::getUserVar("notifyEmail"); $registrationTypeId = (int) Request::getUserVar("registrationTypeId"); if ($notifyEmail) { $this->notifyEmail($registrationTypeId); } Request::redirect(null, null, null, 'registration'); return; } } // Otherwise, payment is handled for us. } else { $templateMgr->assign('isUserLoggedIn', Validation::isLoggedIn()); // In case a user was just created, make sure they appear logged in $form->display(); } }
/** * @author giorgio 29/mag/2013 * * added extra parameter to constructor to allow editing of student confirmed registration * */ public function __construct($languages = array(), $allowEditProfile = false, $allowEditConfirm = false, $action = null) { parent::__construct(); $this->addHidden('id_utente')->withData(0); /* * @author:Sara 20/05/2014 * Workaround to remove the Google-Chrome autocomplete functionality. */ $j = 'return remove_false_element()'; $this->setOnSubmit($j); $false_username = FormControl::create(FormControl::INPUT_TEXT, 'false_username', ''); $false_password = FormControl::create(FormControl::INPUT_PASSWORD, 'false_password', ''); $false_elements_fieldset = FormControl::create(FormControl::FIELDSET, 'false_elements_fieldset', ''); $false_elements_fieldset->setHidden(); $false_elements_fieldset->withData(array($false_username, $false_password)); $this->addControl($false_elements_fieldset); $this->addPasswordInput('password', translateFN('Password')); //->setValidator(FormValidator::PASSWORD_VALIDATOR); $this->addPasswordInput('passwordcheck', translateFN('Conferma la password')); /** * If the swithcer does not use this form to edit her own * profile, the avatar upload must be disabled */ if ($_SESSION['sess_userObj']->getType() != AMA_TYPE_SWITCHER || !$allowEditConfirm) { $this->addFileInput('avatarfile', translateFN('Seleziona un file immagine per il tuo avatar')); $this->addTextInput('avatar', NULL); } if ($action != null) { $this->setAction($action); } /// $this->addTextInput('telefono', translateFN('Telefono')); $telefono = FormControl::create(FormControl::INPUT_TEXT, 'telefono', translateFN('Telefono')); $cap = FormControl::create(FormControl::INPUT_TEXT, 'cap', translateFN('cap')); $citta = FormControl::create(FormControl::INPUT_TEXT, 'citta', translateFN('Città')); $indirizzo = FormControl::create(FormControl::INPUT_TEXT, 'indirizzo', translateFN('Indirizzo')); $provincia = FormControl::create(FormControl::INPUT_TEXT, 'provincia', translateFN('Provincia')); $countries = countriesList::getCountriesList($_SESSION['sess_user_language']); $nazione = FormControl::create(FormControl::SELECT, 'nazione', translateFN('Nazione')); $nazione->withData($countries); $this->addFieldset(translateFN('Dati residenza'), 'residenza')->withData(array($indirizzo, $cap, $citta, $provincia, $nazione, $telefono)); // $this->addTextInput('indirizzo', translateFN('Indirizzo')); // $this->addTextInput('citta', translateFN('Città')); // $this->addTextInput('provincia', translateFN('Provincia')); /* $countries = countriesList::getCountriesList($_SESSION['sess_user_language']); $this->addSelect( 'nazione', translateFN('Nazione'), $countries, 'IT'); * */ $this->addTextInput('codice_fiscale', translateFN('Cod. Fiscale')); /** * @author giorgio 29/mag/2013 * * added select field to allow editing of user confirmed registration status */ if ($allowEditConfirm) { $this->addSelect('stato', translateFN('Confermato'), array(ADA_STATUS_PRESUBSCRIBED => translateFN('No'), ADA_STATUS_REGISTERED => translateFN('Si')), 0); } //->setValidator(FormValidator::PASSWORD_VALIDATOR); if ($allowEditProfile) { $this->addTextarea('profilo', translateFN('Il tuo profilo utente')); } $layoutsAr = array('' => translateFN('seleziona un layout')); $layoutObj = new UILayout(); $avalaibleLayoutAr = $layoutObj->getAvailableLayouts(); $layouts = array_merge($layoutsAr, $avalaibleLayoutAr); $this->addSelect('layout', translateFN('Layout'), $layouts, 0); if (is_array($languages) && count($languages) > 0) { $languagesAr[0] = translateFN('seleziona una lingua'); $languages = array_replace($languagesAr, $languages); // $languages = array_merge($languagesAr,$languages); $this->addSelect('lingua', translateFN('Lingua'), $languages, 0); } }
/** * Handle submission of the user registration form */ function register() { $this->addCheck(new HandlerValidatorSchedConf($this)); $this->validate(); $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $paymentManager =& OCSPaymentManager::getManager(); if (!$paymentManager->isConfigured()) { Request::redirect(null, null, 'index'); } $user =& Request::getUser(); $registrationDao =& DAORegistry::getDAO('RegistrationDAO'); $registration = null; if ($user && ($registrationId = $registrationDao->getRegistrationIdByUser($user->getId(), $schedConf->getId()))) { // This user has already registered. $registration =& $registrationDao->getRegistration($registrationId); if (!$registration || $registration->getDatePaid()) { // And they have already paid. Redirect to a message explaining. Request::redirect(null, null, null, 'registration'); } } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageHierarchy', array(array(Request::url(null, 'index', 'index'), $conference->getConferenceTitle(), true), array(Request::url(null, null, 'index'), $schedConf->getLocalizedTitle(), true))); SchedConfHandler::setupTemplate($conference, $schedConf); import('classes.registration.form.UserRegistrationForm'); $typeId = (int) Request::getUserVar('registrationTypeId'); if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor $form = new UserRegistrationForm($typeId, $registration); } else { $form =& new UserRegistrationForm($typeId, $registration); } $form->readInputData(); if ($form->validate()) { if (($registrationError = $form->execute()) == REGISTRATION_SUCCESSFUL) { $registration =& $form->getRegistration(); $queuedPayment =& $form->getQueuedPayment(); // Successful: Send an email. import('mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTRATION_NOTIFY'); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO'); $registrationType =& $registrationTypeDao->getRegistrationType($typeId); // Determine the registration options for inclusion $registrationOptionText = ''; $totalCost = $registrationType->getCost(); $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO'); $registrationOptionIterator =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId()); $registrationOptionCosts = $registrationTypeDao->getRegistrationOptionCosts($typeId); $registrationOptionIds = $registrationOptionDao->getRegistrationOptions($registration->getRegistrationId()); while ($registrationOption =& $registrationOptionIterator->next()) { if (in_array($registrationOption->getOptionId(), $registrationOptionIds)) { $registrationOptionText .= $registrationOption->getRegistrationOptionName() . ' - ' . sprintf('%.2f', $registrationOptionCosts[$registrationOption->getOptionId()]) . ' ' . $registrationType->getCurrencyCodeAlpha() . "\n"; $totalCost += $registrationOptionCosts[$registrationOption->getOptionId()]; } unset($registrationOption); } $mail->assignParams(array('registrantName' => $user->getFullName(), 'registrationType' => $registrationType->getSummaryString(), 'registrationOptions' => $registrationOptionText, 'totalCost' => sprintf('%.2f', $totalCost) . ' ' . $registrationType->getCurrencyCodeAlpha(), 'username' => $user->getUsername(), 'specialRequests' => $registration->getSpecialRequests(), 'invoiceId' => $queuedPayment->getInvoiceId(), 'registrationContactSignature' => $schedConf->getSetting('registrationName'))); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } else { // Not successful $templateMgr->assign('isUserLoggedIn', Validation::isLoggedIn()); // In case a user was just created, make sure they appear logged in if ($registrationError == REGISTRATION_FAILED) { // User not created $templateMgr->assign('message', 'schedConf.registration.failed'); $templateMgr->assign('backLinkLabel', 'common.back'); $templateMgr->assign('backLink', Request::url(null, null, 'index')); $templateMgr->display('common/message.tpl'); } elseif ($registrationError == REGISTRATION_NO_PAYMENT) { // Automatic payment failed; display a generic // "you will be contacted" message. $templateMgr->assign('message', 'schedConf.registration.noPaymentMethodAvailable'); $templateMgr->assign('backLinkLabel', 'common.back'); $templateMgr->assign('backLink', Request::url(null, null, 'index')); $templateMgr->display('common/message.tpl'); } elseif ($registrationError == REGISTRATION_FREE) { // Registration successful; no payment required (free) $templateMgr->assign('message', 'schedConf.registration.free'); $templateMgr->assign('backLinkLabel', 'common.back'); $templateMgr->assign('backLink', Request::url(null, null, 'index')); $templateMgr->display('common/message.tpl'); } } // Otherwise, payment is handled for us. } else { $templateMgr->assign('isUserLoggedIn', Validation::isLoggedIn()); // In case a user was just created, make sure they appear logged in $form->display(); } }
if (!MULTIPROVIDER) { // if provider is not set the redirect if (!isset($GLOBALS['user_provider']) || empty($GLOBALS['user_provider'])) { header('Location: ' . HTTP_ROOT_DIR); die; } } /* * Display the registration form. */ $help = translateFN('Da questa pagina puoi effettuare la registrazione ad ADA'); if (isset($message) && strlen($message) > 0) { $help = $message; unset($message); } $form = new UserRegistrationForm(); $data = $form->render(); } $layout_dataAr['JS_filename'] = array(JQUERY, JQUERY_MASKEDINPUT, JQUERY_NO_CONFLICT); $optionsAr['onload_func'] = 'initDateField();'; $title = translateFN('Informazioni'); $content_dataAr = array('user_name' => isset($user_name) ? $user_name : '', 'home' => isset($home) ? $home : '', 'data' => isset($data) ? $data : '', 'help' => isset($help) ? $help : '', 'message' => isset($message) ? $message : '', 'status' => isset($status) ? $status : ''); if (isset($msg)) { $help = CDOMElement::create('label'); $help->addChild(new CText(translateFN(ltrim($msg)))); $divhelp = CDOMElement::create('div'); $divhelp->setAttribute('id', 'help'); $divhelp->addChild($help); $content_dataAr['help'] = $divhelp->getHtml(); } /**