$supported_languages = Translator::getSupportedLanguages(); if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') { /* * Validate the user submitted data and proceed to the user registration. */ $form = new UserRegistrationForm(); $form->fillWithPostData(); if ($form->isValid()) { $user_dataAr = $form->toArray(); $user_dataAr['username'] = $_POST['email']; $userObj = new ADAUser($user_dataAr); $userObj->setLayout(''); $userObj->setType(AMA_TYPE_STUDENT); $userObj->setStatus(ADA_STATUS_PRESUBSCRIBED); // Random password. $userObj->setPassword(sha1(time())); /** * giorgio 19/ago/2013 * * if it's not multiprovider, must register the user * in the selected tester only. * if it is multiprovider, must register the user * in the public tester only. */ if (!MULTIPROVIDER && isset($GLOBALS['user_provider'])) { $regProvider = array($GLOBALS['user_provider']); } else { $regProvider = array(ADA_PUBLIC_TESTER); } $id_user = Multiport::addUser($userObj, $regProvider); if ($id_user < 0) {
/** * adds a user whose data are coming from the login provider to the proper ADA DB * * @param array $userArr array of user data to be added * @param function $successCallback callback function accepting a ADALoggableUser parameter to be called just before returning * @param function $errorCallback callback function accepting no parameters to be called just before redirecting * * @return ADALoggableUser|null (redirects if MultiPort::addUser fails) * * @access public */ public function addADAUser($userArr, $successCallback = null, $errorCallback = null) { /** * build user object */ $userObj = new ADAUser($userArr); $userObj->setLayout(''); $userObj->setType(isset($userArr['tipo']) ? $userArr['tipo'] : AMA_TYPE_STUDENT); $userObj->setStatus(ADA_STATUS_REGISTERED); $userObj->setPassword(sha1(time())); // force unguessable password /** * save the user in the appropriate provider */ if (!MULTIPROVIDER && isset($GLOBALS['user_provider'])) { $regProvider = array($GLOBALS['user_provider']); } else { $regProvider = array(ADA_PUBLIC_TESTER); } $id_user = Multiport::addUser($userObj, $regProvider); if ($id_user < 0) { if (!is_null($errorCallback)) { call_user_func($errorCallback); } $message = translateFN('Impossibile procedere. Un utente con questi dati esiste?') . ' ' . urlencode($userObj->getEmail()); header('Location:' . HTTP_ROOT_DIR . '/browsing/registration.php?message=' . $message); exit; } else { /** * reload user object just to double check */ $retObj = MultiPort::findUserByUsername($userArr['username']); if (!is_null($successCallback)) { call_user_func($successCallback, $retObj); } return $retObj; } }
$admtypeAr = array(AMA_TYPE_ADMIN); $admList = $common_dh->get_users_by_type($admtypeAr); if (!AMA_DataHandler::isError($admList)) { $adm_uname = $admList[0]['username']; } else { $adm_uname = ''; // ??? FIXME: serve un superadmin nel file di config? } $courseTitle = $courseObj->getTitle(); foreach ($usersToSubscribe as $subscriber) { $canSubscribeUser = false; $userDataAr = explode(',', $subscriber); $subscriberObj = MultiPort::findUserByUsername(trim($userDataAr[2])); if ($subscriberObj == NULL) { $subscriberObj = new ADAUser(array('nome' => trim($userDataAr[0]), 'cognome' => trim($userDataAr[1]), 'email' => trim($userDataAr[2]), 'tipo' => AMA_TYPE_STUDENT, 'username' => trim($userDataAr[2]), 'stato' => ADA_STATUS_PRESUBSCRIBED, 'birthcity' => '')); $subscriberObj->setPassword(time()); /** * @author giorgio 06/mag/2014 11:25:21 * * If it's not a multiprovider environment, * user must be subscribed to switcher's own * provider only. * User must be subscribed to the ADA_PUBLIC_TESTER * only in a multiprovider environment. */ $provider_to_subscribeAr = array($sess_selected_tester); if (MULTIPROVIDER) { array_unshift($provider_to_subscribeAr, ADA_PUBLIC_TESTER); } $result = MultiPort::addUser($subscriberObj, $provider_to_subscribeAr); if ($result > 0) {