public function getProfile() { if (is_array($this->prefetched)) { if (in_array('profile', $this->prefetched)) { if (in_array('profile', $this->prefetchedObjects)) { return $this->prefetchedObjects['profile']; } else { $obj = new DB_Profile($this->sourceRow); $obj->setNew(false); $this->prefetchedObjects['profile'] = $obj; return $obj; } } } return DB_ProfilePeer::instance()->selectByPrimaryKey($this->getUserId()); }
public function finalizeEvent($runData, $skipEvcode = false) { // get the form data $pl = $runData->getParameterList(); if (!$skipEvcode) { $evcode = $pl->getParameterValue("evcode", "AMODULE"); //check if the email vercode is correct $evcode2 = $runData->sessionGet('evcode'); if ($evcode !== $evcode2) { throw new ProcessException(_("Invalid email verification code."), "invalid_code"); } } $data = $runData->sessionGet("ca_data"); $name = $data['name']; $email = $data['email']; $password = $data['password']; $lang = $data['language']; $db = Database::connection(); $db->begin(); // check again if email and nick are not duplicate! $c = new Criteria(); $c->add("lower(email)", strtolower($email)); $u = DB_OzoneUserPeer::instance()->selectOne($c); if ($u != null) { $runData->resetSession(); throw new ProcessException(_("A user with this email already exists. Must have been created meanwhile... " . "Unfortunately you have to repeat the whole procedure. :-("), "user_exists"); } $unixified = WDStringUtils::toUnixName($name); $c = new Criteria(); $c->add("unix_name", $unixified); $u = DB_OzoneUserPeer::instance()->selectOne($c); if ($u != null) { $runData->resetSession(); throw new ProcessException(_("A user with this name (or very similar) already exists. Must have been created meanwhile... " . "Unfortunately you have to repeat the whole procedure. :-("), "user_exists"); } // add new user!!! $nuser = new DB_OzoneUser(); /* email as the username!!! */ $nuser->setName($email); $nuser->setEmail($email); $nuser->setPassword(md5($password)); $nuser->setNickName($name); $nuser->setUnixName($unixified); $nuser->setLanguage($lang); $date = new ODate(); $nuser->setRegisteredDate($date); $nuser->setLastLogin($date); $nuser->save(); // profile $profile = new DB_Profile(); $profile->setUserId($nuser->getUserId()); $profile->save(); $us = new DB_UserSettings(); $us->setUserId($nuser->getUserId()); $us->save(); // profile page $c = new Criteria(); $c->add("unix_name", "profiles"); $nsite = DB_SitePeer::instance()->selectOne($c); $ncategory = DB_CategoryPeer::instance()->selectByName('profile', $nsite->getSiteId()); $dup = new Duplicator(); $dup->setOwner($nuser); $dup->duplicatePage(DB_PagePeer::instance()->selectByName($nsite->getSiteId(), 'template:profile'), $nsite, $ncategory, 'profile:' . $nuser->getUnixName()); $page = DB_PagePeer::instance()->selectByName($nsite->getSiteId(), 'profile:' . $nuser->getUnixName()); $ou = new Outdater(); $ou->pageEvent('new_page', $page); $db->commit(); /* Handle originalUrl. */ $originalUrl = $runData->sessionGet('loginOriginalUrl'); if ($originalUrl) { $runData->ajaxResponseAdd('originalUrl', $originalUrl); if ($runData->sessionGet('loginOriginalUrlForce')) { $runData->ajaxResponseAdd('originalUrlForce', true); } } // reset session etc. $runData->resetSession(); $runData->getSession()->setUserId($nuser->getUserId()); setcookie("welcome", $nuser->getUserId(), time() + 10000000, "/", GlobalProperties::$SESSION_COOKIE_DOMAIN); setcookie(GlobalProperties::$SESSION_COOKIE_NAME_IE, $runData->getSessionId(), null, "/"); }