private function addBot(BotNick $nick, $dateBorn, BotData $data = null) { $bot = new sfGuardUser(); $botProfile = new sfGuardUserProfile(); $botProfile->setUser($bot); $Bot = new Bot(); $bot->username = $nick->nick; $bot->email_address = ($data ? $data->uid : md5($nick->nick . "uberlov mail")) . "@uberlov.ru"; $bot->created_at = $dateBorn; $bot->updated_at = $dateBorn; $bot->last_login = $dateBorn; if (!empty($data)) { if (isset($data->userpic) && strstr($data->userpic, 'jpg')) { $userpic = new sfThumbnail(48, 48, false); $userpic->loadFile("Z:/home/ht/www/images/userpic/bot/" . $data->userpic); $name = md5($data->uid . 'userpic f**k yea') . '.png'; $userpic->save(sfConfig::get('sf_user_pic_dir') . $name, 'image/png'); $botProfile->userpic = $name; } if (isset($data->name)) { $names = explode(" ", $data->name); $bot->last_name = isset($names[1]) ? $names[1] : ""; $bot->first_name = isset($names[0]) ? $names[0] : ""; } $Bot->setBotDataId($data->id); $this->activeBots->add($bot); } $botProfile->sex = 1; $botProfile->validate_at = $dateBorn; $botProfile->created_at = $dateBorn; $botProfile->updated_at = $dateBorn; $bot->save(); $botProfile->save(); $Bot->setBotNickId($nick->id); $Bot->setProfileId($botProfile->id); $Bot->save(); $this->totalBots++; }
/** * Serialize the form into the database. **/ public function save($con = null) { if (!is_null($this->getValue("photographer_id"))) { $p = $this->getObject(); } else { $sfUser = new sfGuardUser(); $sfUser->setUsername($this->getValue("email")); $sfUser->setPassword($this->getValue("password")); $sfUser->save(); if (strpos($this->getValue("name"), " ") !== false) { list($firstName, $lastName) = explode(" ", $this->getValue("name")); } else { $firstName = ""; $lastName = ""; } $sfProfile = new sfGuardUserProfile(); $sfProfile->setUserTypeId(sfConfig::get("app_user_type_photographer")); $sfProfile->setUserId($sfUser->getId()); $sfProfile->setEmail($this->getValue("email")); $sfProfile->setFirstName($firstName); $sfProfile->setLastName($lastName); $sfProfile->save(); $p = new Photographer(); $p->setUserId($sfProfile->getId()); } $p->setName($this->getValue("name")); $p->setEmail($this->getValue("email")); $p->setPhone($this->getValue("phone")); $p->setAffiliation($this->getValue("affiliation")); $p->setWebsite($this->getValue("website")); $p->setDescription($this->getValue("description")); $p->setBillingAddress($this->getValue("billing_info")); $p->save(); if ($this->getValue("reset_password")) { $user = $p->getsfGuardUserProfile()->getsfGuardUser(); $user->setPassword($this->getValue("password")); $user->save(); } }
/** * Executes edit action * * @param sfRequest $request A request object */ public function executeEdit(sfWebRequest $request) { // Get user profile from database $user = $this->getUser()->getGuardUser(); $profile = Doctrine_Core::getTable("SfGuardUserProfile")->findOneByUserId($user->getId()); $this->ldapAuthentication = sfConfig::get("app_authentication_method", "symfony") == "ldap" ? true : false; // If user has no profile, create a new one for him if (empty($profile)) { $profile = new sfGuardUserProfile(); $profile->setUserId($user->getId()); $profile->setToken(MiscUtils::generateToken()); $profile->setSecurityLevel(sfConfig::get("app_security_level_new_user", 0)); $profile->save(); } $this->form = new ProfileForm(array('first_name' => $user->getFirstName(), 'last_name' => $user->getLastName(), 'email' => $user->getEmailAddress())); $this->token = $profile->getToken(); $this->securityLevel = Labeler::getSecurityLevelLabel($profile->getSecurityLevel()); // Process form if ($request->isMethod("post")) { $this->processEdit($request, $this->form); } }
/** * Declares an association between this object and a sfGuardUserProfile object. * * @param sfGuardUserProfile $v * @return JobNotes The current object (for fluent API support) * @throws PropelException */ public function setsfGuardUserProfile(sfGuardUserProfile $v = null) { if ($v === null) { $this->setUserId(NULL); } else { $this->setUserId($v->getId()); } $this->asfGuardUserProfile = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the sfGuardUserProfile object, it will not be re-added. if ($v !== null) { $v->addJobNotes($this); } return $this; }
public function transformJobs() { $statusHash = array(); $statusObjects = StatusPeer::doSelect(new Criteria()); foreach ($statusObjects as $s) { $statusHash[$s->getState()] = $s->getId(); } $this->jobKeys = array(); $dom = DOMDocument::load("tuftsph_jm2db.xml"); $jobs = $dom->getElementsByTagName("jobs"); $total = $jobs->length; $count = 1; $jobList = array(); foreach ($jobs as $job) { $jid = 0; $childNodes = $job->childNodes; $j = new Job(); $del = new Delivery(); $jid = 1; $startTime = null; $shootStart = null; $shootEnd = null; $endTime = null; $notes = ""; $photog = 0; $slug = ""; $childNodes = $job->childNodes; foreach ($childNodes as $child) { switch ($child->nodeName) { case "id": $jid = $child->textContent; break; case "shoot_name": $j->setEvent($child->textContent); break; case "shoot_date": $j->setDate($child->textContent); break; case "shoot_startT": $startTime = $child->textContent; break; case "shoot_start": $shootStart = $child->textContent; break; case "shoot_endT": $endTime = $child->textContent; break; case "shoot_end": $shootEnd = $child->textContent; break; case "shoot_duedate": $j->setDueDate($child->textContent); break; case "submitted_at": $j->setCreatedAt($child->textContent); break; case "requester_address": $j->setStreet($child->textContent); break; case "requester_campus": $j->setCity($child->textContent); break; case "requester_name": $j->setContactName($child->textContent); break; case "requester_email": $j->setContactEmail($child->textContent); break; case "requester_phone": $j->setContactPhone($child->textContent); break; case "internal_notes": $notes .= $child->textContent . "<br/>"; break; case "billing_notes": $notes .= $child->textContent . "<br/>"; break; case "estimate": $j->setEstimate($child->textContent); break; case "billing_acctnum": $j->setAcctNum($child->textContent); break; case "billing_deptid": $j->setDeptId($child->textContent); break; case "billing_grantid": $j->setGrantId($child->textContent); break; case "shoot_directions": $j->setOther($child->textContent); break; case "status": $j->setStatusId($statusHash[$child->textContent]); break; case "photog_id": $photog = $child->textContent; break; case "delivery_pubname": $del->setPubName($child->textContent); break; case "delivery_pubtype": $del->setPubType($child->textContent); break; case "delivery_other": $del->setOther($child->textContent); break; case "delivery_format": break; case "delivery_color": $del->setColor($child->textContent); break; case "delivery_format": $del->setFormat($child->textContent); break; case "delivery_size": $del->setSize($child->textContent); break; case "delivery_method": $del->setMethod($child->textContent); break; case "delivery_special": $del->setInstructions($child->textContent); break; case "slug": $slug = $child->textContent; break; case "#text": default: break; } } if (is_null($endTime)) { $endTime = $shootEnd; } if (is_null($startTime)) { $startTime = $shootStart; } if ($j->getCity() == "Boston") { $j->setZip("02101"); } else { $j->setZip("02155"); } $j->setNotes($notes); $j->setState("Massachusetts"); list($hour, $min, $sec) = explode(":", $endTime); list($shour, $smin, $ssec) = explode(":", $startTime); $t = new DateTime(); $t->setTime($hour, $min, $sec); $j->setEndTime($t); $t = new DateTime(); $t->setTime($shour, $smin, $ssec); $j->setStartTime($t); $j->addTag($slug); if (isset($this->jobProjectKeys[$jid])) { $j->setProjectId($this->projectKeys[$this->jobProjectKeys[$jid]]); } while (count($jobList) - 1 != $jid) { $jobList[] = false; } $jobList[intval($jid)] = array("job" => $j, "del" => $del, "photog" => $photog); } for ($i = 1; $i < count($jobList); $i++) { sleep(1); $obj = $jobList[$i]; $c = new Criteria(); $c->add(JobPeer::ID, $i); if (JobPeer::doCount($c) > 0) { continue; } echo $i . "/" . $total . "\n"; // keep the ids lined up if ($obj == false) { $myJob = new Job(); try { $myJob->save(); } catch (Exception $ex) { echo $ex->getMessage(); } $myJob->delete(); } else { $j = $obj["job"]; $del = $obj["del"]; $photog = $obj["photog"]; try { $j->save(); } catch (Exception $ex) { echo $ex->getMessage(); echo $ex->getTraceAsString(); } $del->setJobId($j->getId()); $del->save(); $this->jobKeys[$jid] = $j->getId(); if ($photog) { $jp = new JobPhotographer(); $jp->setPhotographerId($this->photogKeys[$photog]); $jp->setJobId($j->getId()); try { $jp->save(); } catch (Exception $ex) { echo $ex->getMessage(); } } // add the requester as a client $c = new Criteria(); $c->add(sfGuardUserPeer::USERNAME, $j->getContactEmail()); if (ClientPeer::doCount($c) == 0 && trim(strlen($j->getContactEmail())) != 0) { $user = new sfGuardUser(); $user->setUsername($j->getContactEmail()); $user->setPassword("admin"); $user->save(); $userProfile = new sfGuardUserProfile(); $userProfile->setUserId($user->getId()); $userProfile->setUserTypeId(sfConfig::get("app_user_type_client")); $userProfile->save(); $clientProfile = new Client(); $clientProfile->setUserId($userProfile->getId()); $clientProfile->setName($j->getContactName()); $clientProfile->setEmail($j->getContactEmail()); $clientProfile->setPhone($j->getContactPhone()); $clientProfile->save(); $jobClient = new JobClient(); $jobClient->setClientId($clientProfile->getId()); $jobClient->setJobId($j->getId()); $jobClient->save(); } } $count += 1; } }
public function setUp() { parent::setUp(); $this->hasOne('ScssTroopEnrollment as troop_enrollment_id', array('local' => 'troop_enrollment_id', 'foreign' => 'id')); }
/** * Executes apply action * * @param sfRequest $request A request object */ public function executeApply(sfRequest $request) { $this->form = $this->newForm('sfApplyApplyForm'); if ($request->isMethod('post')) { $parameter = $request->getParameter('sfApplyApply'); $this->form->bind($request->getParameter('sfApplyApply')); if ($this->form->isValid()) { $guid = "n" . self::createGuid(); $this->form->setValidate($guid); $this->form->save(); // Generate unique token based on random time list($usec, $sec) = explode(" ", microtime()); $rand_num = substr(sha1((int) ($usec * 1000000 * ($sec / 1000000))), 0, 20); // Retrieve current user $user = $this->form->getObject(); $now = date("Y-m-d H:i:s"); // Create new entry into sfGuardUserProfile table $profileObject = new sfGuardUserProfile(); $profileObject->setUserId($user->getId()); $profileObject->setToken($rand_num); $profileObject->setSecurityLevel(sfConfig::get('app_security_level_new_user')); $userPermission = Doctrine_Core::getTable("sfGuardPermission")->findOneByName(sfConfig::get('app_permission_new_user')); if (empty($userPermission)) { return; } // Create new entry into sfGuardUserPermission table $permissionObject = new sfGuardUserPermission(); $permissionObject->setUserId($user->getId()); $permissionObject->setPermissionId($userPermission->getId()); $permissionObject->setCreatedAt($now); $permissionObject->setUpdatedAt($now); $userGroup = Doctrine_Core::getTable("sfGuardGroup")->findOneByName(sfConfig::get('app_project_group')); if (empty($userGroup)) { return; } // Create new entry into sfGuardUserGroup table $groupObject = new sfGuardUserGroup(); $groupObject->setUserId($user->getId()); $groupObject->setGroupId($userGroup->getId()); $groupObject->setCreatedAt($now); $groupObject->setUpdatedAt($now); try { // Send mail $this->sendVerificationMail($user); // Save tables entries $profileObject->save(); $permissionObject->save(); $groupObject->save(); return 'After'; } catch (Exception $e) { $groupObject->delete(); $permissionObject->delete(); $profileObject->delete(); $user->delete(); throw $e; // You could re-throw $e here if you want to // make it available for debugging purposes return 'MailerError'; } } } }
public function addsfGuardUserProfile(sfGuardUserProfile $l) { $this->collsfGuardUserProfiles[] = $l; $l->setsfGuardUser($this); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param sfGuardUserProfile $value A sfGuardUserProfile object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(sfGuardUserProfile $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
public function getInboxQuery(sfGuardUserProfile $profile) { return $this->createQuery('i')->leftJoin('i.Inboxed id')->leftJoin('i.CommentInbox с')->leftJoin('i.CreatedBy p')->leftJoin('p.User')->where('i.created_by = ?', $profile->getId())->orWhere('id.id = ?', $profile->getId()); }
public function executeInvite($request) { $this->user_invite_form = new UserInviteForm(); if ($request->isMethod('post')) { $userParams = $request->getParameter('user'); $this->user_invite_form->bind($userParams); if ($this->user_invite_form->isValid()) { $db = Doctrine_Manager::connection(); try { $db->beginTransaction(); //create user $user = new sfGuardUser(); $user->username = $userParams['email']; $user->algorithm = 'sha1'; $user->setPassword('pending'); $user->is_active = false; $user->addGroupByName($userParams['group']); $user->save(); //create user profile $profile = new sfGuardUserProfile(); $profile->user_id = $user->id; $profile->name_first = $userParams['name_first']; $profile->name_last = $userParams['name_last']; $profile->email = $userParams['email']; $profile->is_visible = false; $profile->invitation_code = substr(sha1($profile->getEmail() . time()), 0, 10); $profile->save(); //send welcome email $mailBody = $this->getPartial($userParams['template'], array('profile' => $profile)); $mailer = new Swift(new Swift_Connection_NativeMail()); $message = new Swift_Message("You're invited to become a LittleSis analyst!", $mailBody, 'text/plain'); $address = new Swift_Address(sfConfig::get('app_mail_invite_sender_address'), sfConfig::get('app_mail_invite_sender_name')); $mailer->send($message, $profile->email, $address); $mailer->disconnect(); //all's well, commit transaction $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } $this->redirect('user/list'); } //gather errors $this->errors = $this->user_invite_form->getErrorSchema()->getErrors(); } }
public function executeSignUp($request) { $this->form = new SignUpForm(); if ($request->isMethod('get')) { return; } $this->form->bind($request->getParameter('form')); if (!$this->form->isValid()) { return; } $sfGuardUser = new sfGuardUser(); $sfGuardUser->setUsername($this->form->getValue('username')); $sfGuardUser->setPassword($this->form->getValue('password')); $sfGuardUser->setIsActive(false); $sfGuardUser->save(); $sfGuardUserProfile = new sfGuardUserProfile(); $sfGuardUserProfile->setSfGuardUser($sfGuardUser); $sfGuardUserProfile->setEmail($this->form->getValue('email')); $sfGuardUserProfile->setFirstName($this->form->getValue('first_name')); $sfGuardUserProfile->setLastName($this->form->getValue('last_name')); $sfGuardUserProfile->setGender($this->form->getValue('gender')); $sfGuardUserProfile->setBirthday($this->form->getValue('birthday')); $sfGuardUserProfile->setWebpage($this->form->getValue('webpage')); $sfGuardUserProfile->save(); try { $connection = new Swift_Connection_SMTP('mail.sis-nav.com', 25); $connection->setUsername('*****@*****.**'); $connection->setPassword('gahve123'); $mailer = new Swift($connection); $message = new Swift_Message('Account Confirmation'); $mailContext = array('email' => $sfGuardUserProfile->getEmail(), 'full_name' => $sfGuardUserProfile->getFullName(), 'activation_key' => $sfGuardUserProfile->getActivationKey()); $message->attach(new Swift_Message_Part($this->getPartial('mail/signUpHtmlBody', $mailContext), 'text/html')); $message->attach(new Swift_Message_Part($this->getPartial('mail/signUpTextBody', $mailContext), 'text/plain')); $mailer->send($message, $sfGuardUserProfile->getEmail(), '*****@*****.**'); $mailer->disconnect(); } catch (Exception $e) { $mailer->disconnect(); } $this->getUser()->setFlash('info', 'A confirmation email has been sent to your email address.'); $this->forward('site', 'message'); }
public function executeJoin($request) { $userParams = $request->getParameter('user'); $this->is_invited = false; $this->group = $request->getParameter('group'); if ($this->group && $this->getUser()->isAuthenticated()) { $this->redirect('@groupView?name=' . $this->group); } //if there's an invitation code supplied, it should match an invitation generated by an invite if ($code = $request->getParameter('code')) { $profile = Doctrine_Query::create()->from('sfGuardUserProfile p')->where('p.invitation_code = ?', $code)->fetchOne(); if ($profile) { $this->is_invited = true; } } if (!$this->is_invited) { $profile = new sfGuardUserProfile(); } //if a network name is supplied if ($network_name = $request->getParameter('network')) { if ($network = LsListTable::getNetworkByDisplayName($network_name)) { $profile->home_network_id = $network["id"]; } } $this->user_form = new UserJoinForm($profile); $this->profile = $profile; //if form is posted, validate if ($request->isMethod('post')) { //bind request params to form $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field')); $userParams = array_merge($userParams, array('captcha' => $captcha)); $this->user_form->bind($userParams); //if public_name is valid, check that it's unique $errors = $this->user_form->getErrorSchema()->getErrors(); if (!isset($errors['public_name'])) { $q = LsDoctrineQuery::create()->from('sfGuardUserProfile p')->where('p.public_name LIKE ?', $userParams['public_name']); if (in_array($userParams['public_name'], sfGuardUserProfileTable::$prohibitedPublicNames) || $q->count()) { $validatorSchema = $this->user_form->getValidatorSchema(); $validatorSchema['public_name']->setMessage('invalid', 'Sorry, the public name you chose is already taken!'); $this->user_form->getErrorSchema()->addError(new sfValidatorError($validatorSchema['public_name'], 'invalid'), 'public_name'); } } //look for user with duplicate email $q = LsDoctrineQuery::create()->from('sfGuardUserProfile p')->where('REPLACE(p.email, \'.\', \'\') = REPLACE(?, \'.\', \'\')', $userParams['email']); //if user was invited, the duplicate user shouldn't have the same code //if ($code) //{ // $q->addWhere('p.invitation_code <> ?', $code); //} if ($q->count()) { $request->setError('email', 'There is already a user with that email'); } //proceed if there are no errors if ($this->user_form->isValid() && !$request->hasErrors()) { //if user is invited, consider user confirmed if ($this->is_invited) { $user = $profile->User; $user->is_active = true; $profile->invitation_code = null; $profile->is_visible = true; $profile->is_confirmed = true; } else { $user = new sfGuardUser(); //auto-approve? $user->is_active = sfConfig::get('app_accounts_auto_approve') ? true : false; } $db = Doctrine_Manager::connection(); try { $db->beginTransaction(); //save submitted email as password $user->username = $userParams['email']; $user->algorithm = 'sha1'; $user->setPassword($userParams['password1']); if (!$user->hasPermission('contributor')) { $user->addPermissionByName('contributor'); } if (!$user->hasPermission('editor')) { $user->addPermissionByName('editor'); } $user->save(); //save submitted profile fields $profile->user_id = $user->id; $profile->name_first = $userParams['name_first']; $profile->name_last = $userParams['name_last']; $profile->email = $userParams['email']; $profile->reason = $userParams['reason']; $profile->analyst_reason = $userParams['analyst_reason']; $profile->public_name = $userParams['public_name']; $profile->home_network_id = $userParams['home_network_id']; //if not invited, generate code for email confirmation if (!$this->is_invited) { $code = substr(sha1($profile->email . time()), 0, 20); $profile->confirmation_code = $code; } $profile->save(); //add user to group, if requested if ($this->group) { $db = Doctrine_Manager::connection(); $sql = 'SELECT id FROM sf_guard_group WHERE name = ?'; $stmt = $db->execute($sql, array($this->group)); if ($groupId = $stmt->fetch(PDO::FETCH_COLUMN)) { $ug = new sfGuardUserGroup(); $ug->user_id = $user->id; $ug->group_id = $groupId; $ug->is_owner = 0; $ug->save(); } } //send email to notify administrator of new account creation $mailBody = $this->getPartial('accountcreatenotify', array('user' => $user, 'analyst' => $userParams['analyst_reason'], 'group' => $this->group)); if ($this->is_invited) { $subject = 'LittleSis account invitation accepted by ' . $userParams['name_first'] . ' ' . $userParams['name_last']; } else { $subject = 'LittleSis account ' . ($user->is_active ? 'created' : 'requested') . ' by ' . $userParams['name_first'] . ' ' . $userParams['name_last']; } $mailer = new Swift(new Swift_Connection_NativeMail()); $message = new Swift_Message($subject, $mailBody, 'text/plain'); $address = new Swift_Address(sfConfig::get('app_mail_join_sender_address'), sfConfig::get('app_mail_join_sender_name')); $mailer->send($message, sfConfig::get('app_mail_join_sender_address'), $address); $mailer->disconnect(); //notify user that the account has been created/requested $subject = $user->is_active ? 'Welcome to LittleSis!' : 'Your request to become a LittleSis analyst'; $mailBody = $this->getPartial($user->is_active ? 'accountcreatereceipt' : 'accountrequestreceipt', array('user' => $user, 'password' => $userParams['password1'], 'is_invited' => $this->is_invited)); $mailer = new Swift(new Swift_Connection_NativeMail()); $message = new Swift_Message('Welcome to LittleSis!', $mailBody, 'text/plain'); $address = new Swift_Address(sfConfig::get('app_mail_join_sender_address'), sfConfig::get('app_mail_join_sender_name')); $mailer->send($message, $profile->email, $address); $mailer->disconnect(); //if invited, sign in user and record login time if ($this->is_invited) { // signin user $this->getUser()->setAttribute('user_id', $user->id, 'sfGuardSecurityUser'); $this->getUser()->setAuthenticated(true); $this->getUser()->clearCredentials(); $this->getUser()->addCredentials($user->getAllPermissionNames()); // save last login $user->last_login = date('Y-m-d H:i:s'); $user->save(); } //commit changes $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } //redirect to requested or joined page if ($user->is_active) { $this->redirect('home/joined' . ($this->is_invited ? '?conf=1' : '')); } else { $this->redirect('home/requested'); } } } }
public function addsfGuardUserProfile(sfGuardUserProfile $l) { $this->collsfGuardUserProfiles[] = $l; $l->setSubdepartment($this); }
/** * * @param sfWebRequest $request * @param LdapForm $form */ protected function processLdap(sfWebRequest $request, LdapForm $form) { $form->bind($request->getParameter('signin')); if ($form->isValid()) { $values = $form->getValues(); // Check if user already exists in the DB $user = Doctrine::getTable('sfGuardUser')->findOneByUsername($values["username"]); // If not, create an account for him if (empty($user)) { $datetime = date("Y-m-d H:i:s"); // Create entry in sfGuardUser $sfGuardUser = new sfGuardUser(); $sfGuardUser->setEmailAddress($values["username"]); $sfGuardUser->setUsername($values["username"]); $sfGuardUser->setFirstName($values["firstname"]); $sfGuardUser->setLastName($values["lastname"]); $sfGuardUser->setCreatedAt($datetime); $sfGuardUser->setUpdatedAt($datetime); $sfGuardUser->save(); // Additional informations for user's profile $sfGuardUserProfile = new sfGuardUserProfile(); $sfGuardUserProfile->setUserId($sfGuardUser->getId()); $sfGuardUserProfile->setToken(MiscUtils::generateToken()); $sfGuardUserProfile->setSecurityLevel(sfConfig::get("app_security_level_new_user", 0)); $sfGuardUserProfile->save(); $permission = Doctrine_Core::getTable("sfGuardPermission")->findOneByName(sfConfig::get("app_permission_new_user", "User")); if (!$permission) { $this->getUser()->setFlash("error", "Unable to set permissions for this account! Contact your administrator."); $sfGuardUserProfile->delete(); $sfGuardUser->delete(); return; } // Give basic permissions for user $sfGuardPermission = new sfGuardUserPermission(); $sfGuardPermission->setUserId($sfGuardUser->getId()); $sfGuardPermission->setPermissionId($permission->getId()); $sfGuardPermission->setCreatedAt($datetime); $sfGuardPermission->setUpdatedAt($datetime); $sfGuardPermission->save(); $userGroup = Doctrine_Core::getTable("sfGuardGroup")->findOneByName(sfConfig::get("app_project_group")); if (!$userGroup) { $this->getUser()->setFlash("error", "Unable to set project group for this account! Contact your administrator."); $sfGuardUserProfile->delete(); $sfGuardUser->delete(); $sfGuardPermission->delete(); return; } // Create new entry into sfGuardUserGroup table $sfGuardGroup = new sfGuardUserGroup(); $sfGuardGroup->setUserId($sfGuardUser->getId()); $sfGuardGroup->setGroupId($userGroup->getId()); $sfGuardGroup->setCreatedAt($datetime); $sfGuardGroup->setUpdatedAt($datetime); $sfGuardGroup->save(); $user = $sfGuardUser; } $this->getUser()->signIn($user, array_key_exists('remember', $values) ? $values['remember'] : false); // Set the tow previous referer to the same value for: // 1) redirect to previous user's location // 2) avoid redirect loop in signin $this->getUser()->setReferer($this->getUser()->getReferer()); // Redirect to referer return $this->redirect($this->getUser()->getReferer()); } }