[symfony-users] Re: What i have to do to update my tables correctly?
Try doctrine:rebuild-db to tear the database down and rebuild from scratch. Also, you might want to look at symfony migrations: http://www.symfony-project.org/doctrine/1_2/en/07-Migrations Migrations are an easy way to make changes to your database schema once in production (when you can't rebuild the db, because you'll lose data), and probably a good thing to get in the habit of using while in development. That said, I just launched my first symfony site, so this is just my opinion, may be a better practice out there. Justin On Jul 16, 5:35 am, tirengarfio tirengar...@gmail.com wrote: Hi, yesterday i created some tables from an schema using doctrine:build- all-load. Today i have changed some things in that schema, so after that i have removed the database, i have created a new one and finally i have executed again doctrine:build-all-load to generate the new tables with the changes i have just made. But when i check the new tables nothing has changed. So, what i have to do to update my tables correctly? Ciao --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Duplicate DB entry...help me read this code
Hey ya'll - Here's a strange problem. Originally, I was getting an error in Record.php on line 1231 using Doctrine and saving an embedded form. I found a hack solution to this problem here: http://trac.symfony-project.org/ticket/6547 In my app, this is occuring when trying to create an sf_guard_user and profile record together. Per the above link, I added the following methods to my sfGuardUserForm class: protected function doSave($con = null) { $this-saveProfile($con); parent::doSave($con); } public function saveProfile($con = null) { $usr = $this-object-Profile; $usr-fromArray($this-values['profile']); $this-values['profile'] = $usr; } Once I did this, I no longer got the error above, but each time I create a new Profile object, I get two records - one with all the right details, and one that's blank, except the sf_user_guard_id. Here are the log lines showing the duplicate queries: --- Jul 13 21:23:29 symfony [info] {sfDoctrineLogger} executeQuery : INSERT INTO sf_guard_user (algorithm, is_active, is_super_admin, username, salt, password, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?) - (sha1, 1, 0, jdavistest3, 38e46915177a1e36173b86075fad360c, d164ebb2c5a6e2b9dec0b19a6584052083becacb, 2009-07-13 21:23:29, 2009-07-13 21:23:29 ) Jul 13 21:23:29 symfony [info] {sfDoctrineLogger} executeQuery : INSERT INTO profile (sf_guard_user_id, first_name, last_name, email, zip) VALUES (?, ?, ?, ?, ?) - (11, fsd, fdasf, f...@fda.com, 37064 ) Jul 13 21:23:29 symfony [info] {sfDoctrineLogger} executeQuery : DELETE FROM profile_index WHERE id = ? - (14 ) Jul 13 21:23:29 symfony [info] {sfDoctrineLogger} executeQuery : INSERT INTO profile (sf_guard_user_id) VALUES (?) - (11 ) Jul 13 21:23:29 symfony [info] {sfDoctrineLogger} executeQuery : DELETE FROM profile_index WHERE id = ? - (15 ) --- Obviously, I'm a bit in over my head here. Not sure what's going on with this - can anyone help out? Thanks so much, Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Return objects within distance
Hey all - I've been working on getting this implemented for awhile, and can't figure it out. I want my users to be able to search by proximity (i.e. show all the records within X miles from the user). My table has lat/long columns, and getting that data in there is fairly easy (using Google maps API to populate data when the object is created). However, for the life of me, I can't figure out how to do the query. I know there are two options available, somewhat out of the box: the Doctrine Geolocatable behavior and Centre{Source}'s plugin: csDoctrineActAsGeolocatablePlugin. Neither of them offer much in the way of instruction when it comes to creating queries. Here is my current query (and pager): $q = Doctrine_Query::create() -from('Profile p') -where('p.bio NOT LIKE ?', ); // do not return objects where the bio is left blank $this-pager-setQuery($q); $this-pager-setPage($request-getParameter('page', 1)); $this-pager-init(); Anyone have any snippets or advice as to how to implement a radius/ geographic search into this? Thanks so much! Justin Davis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: Return objects within distance
Thanks Jon. I had seen that (and am using that behavior on that table), but didn't understand how to incorporate it into a query like I've got above (since the docs show the query being created off an object, not just off a Doctrine_Query::create() kind of statement). Probably just means I need to a) experiment and b) learn more :) Thanks. Justin On Jun 29, 4:31 pm, Jonathan Wage jonw...@gmail.com wrote: Check this out. http://www.doctrine-project.org/documentation/manual/1_1/en/behaviors... - Jon On Mon, Jun 29, 2009 at 4:27 PM, oweit...@gmx.de oweit...@gmx.de wrote: try rhis link http://codeidol.com/sql/sql-hack/Number-Crunching/Calculate-the-Dista... On 29 Jun., 21:32, justin_davis jdavis1...@gmail.com wrote: Hey all - I've been working on getting this implemented for awhile, and can't figure it out. I want my users to be able to search by proximity (i.e. show all the records within X miles from the user). My table has lat/long columns, and getting that data in there is fairly easy (using Google maps API to populate data when the object is created). However, for the life of me, I can't figure out how to do the query. I know there are two options available, somewhat out of the box: the Doctrine Geolocatable behavior and Centre{Source}'s plugin: csDoctrineActAsGeolocatablePlugin. Neither of them offer much in the way of instruction when it comes to creating queries. Here is my current query (and pager): $q = Doctrine_Query::create() -from('Profile p') -where('p.bio NOT LIKE ?', ); // do not return objects where the bio is left blank $this-pager-setQuery($q); $this-pager-setPage($request-getParameter('page', 1)); $this-pager-init(); Anyone have any snippets or advice as to how to implement a radius/ geographic search into this? Thanks so much! Justin Davis -- Jonathan H. Wage (+1 415 992 5468) Open Source Software Developer Evangelist sensiolabs.com | jwage.com | doctrine-project.org | symfony-project.org You can contact Jonathan about Doctrine, Symfony and Open-Source or for training, consulting, application development, or business related questions at jonathan.w...@sensio.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: Customizing sfGuardAuth signin
Yeah, that's the problem. There's a redirect at the end of the executeSignin action that sends the user back to the page they were on before doing the signin loop. I'm not sure how to override the signin action to log the signin without having it redirect before it gets to my action. Perhaps a symfony event? On Jun 24, 9:17 pm, Nickolas Daskalou n...@daskalou.com wrote: Does the [parent::executeSignin($request)] line redirect maybe? This would mean no code after it would get executed. 2009/6/25 justin_davis jdavis1...@gmail.com Hey ya'll - I'm trying to extend the sfGuardAuth signin action, and am having trouble. What I want to do is log the number of times a user has logged in since registering. I've added a column to the user's profile called sess_ct for logging this number. Right now, I've got this set up like this: class sfGuardAuthActions extends BasesfGuardAuthActions { public function executeSignin($request){ parent::executeSignin($request); $user = $this-getUser()-getGuardUser()-getProfile(); $user-sess_ct = $user-sess_ct + 1; $user-save(); } } Obviously though, this doesn't work. I'd like to extend the sfGuardAuth actions, instead of editing them (again, for obvious reasons). Any ideas on the correct way to go about this? Thanks so much! Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: Customizing sfGuardAuth signin
Beautiful - works like a charm. Thanks so much! Justin On Jun 25, 10:25 am, Richtermeister nex...@gmail.com wrote: Hey Justin, as part of the authorization, a signin() method is called on the sfGuardSecurityUser object (myUser). That's the function I would overwrite and add the logging to. Hope this helps, Daniel On Jun 25, 7:59 am, justin_davis jdavis1...@gmail.com wrote: Yeah, that's the problem. There's a redirect at the end of the executeSignin action that sends the user back to the page they were on before doing the signin loop. I'm not sure how to override the signin action to log the signin without having it redirect before it gets to my action. Perhaps a symfony event? On Jun 24, 9:17 pm, Nickolas Daskalou n...@daskalou.com wrote: Does the [parent::executeSignin($request)] line redirect maybe? This would mean no code after it would get executed. 2009/6/25 justin_davis jdavis1...@gmail.com Hey ya'll - I'm trying to extend the sfGuardAuth signin action, and am having trouble. What I want to do is log the number of times a user has logged in since registering. I've added a column to the user's profile called sess_ct for logging this number. Right now, I've got this set up like this: class sfGuardAuthActions extends BasesfGuardAuthActions { public function executeSignin($request){ parent::executeSignin($request); $user = $this-getUser()-getGuardUser()-getProfile(); $user-sess_ct = $user-sess_ct + 1; $user-save(); } } Obviously though, this doesn't work. I'd like to extend the sfGuardAuth actions, instead of editing them (again, for obvious reasons). Any ideas on the correct way to go about this? Thanks so much! Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Customizing sfGuardAuth signin
Hey ya'll - I'm trying to extend the sfGuardAuth signin action, and am having trouble. What I want to do is log the number of times a user has logged in since registering. I've added a column to the user's profile called sess_ct for logging this number. Right now, I've got this set up like this: class sfGuardAuthActions extends BasesfGuardAuthActions { public function executeSignin($request){ parent::executeSignin($request); $user = $this-getUser()-getGuardUser()-getProfile(); $user-sess_ct = $user-sess_ct + 1; $user-save(); } } Obviously though, this doesn't work. I'd like to extend the sfGuardAuth actions, instead of editing them (again, for obvious reasons). Any ideas on the correct way to go about this? Thanks so much! Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: Authentication with email
Just following up. Found a nice, simple solution for making this work, and wanted to pass it on. Thanks to Jon Wage for the help on this one! I'm using sfDoctrineGuardPlugin. Also, I've got another table called sfGuardUserProfile for the profile fields (including email). In plugins/sfDoctrineGuardPlugin/lib/validator/ sfGuardValidatorUser.class.php there's a line that looks for the username and gets the user object: if ($user = Doctrine::getTable('sfGuardUser')-findOneByUsername ($username)) So, to get the user object with the email instead, simply override the findOneByUsername function in the sfGuardUserTable class: public function findOneByUsername($username) { $user = Doctrine::getTable('sfGuardUserProfile')-findOneByEmail ($username); return $user-getsfGuardUser(); } Hope that helps someone out! Justin Davis On May 5, 2:53 pm, justin_davis jdavis1...@gmail.com wrote: Hey all, I'm using Symfony 1.2 and Doctrine, with the sfDoctrineGuard plugin. I have a table for profile information called sfDoctrineGuardProfile. Creating a new user and profile works great. I want the user to be able to log in with their email address, instead of a username. I set the username field in the sfDoctrineGuard schema to allow null values. I found an email signin validation script here (http://bluehorn.co.nz/2009/04/29/implementing-email-login-with- sfguardplugin/) and modified it to work with doctrine. The email validation is as follows: class sfGuardUserByEmailValidator extends sfValidator { public function initialize($context, $parameters = null) { // initialize parent parent::initialize($context); // set defaults $this-getParameterHolder()-set(’username_error’, ‘Email or password is not valid.’); $this-getParameterHolder()-set(’password_field’, ‘password’); $this-getParameterHolder()-set(’remember_field’, ‘remember’); $this-getParameterHolder()-add($parameters); return true; } public function execute($value, $error) { $password_field = $this-getParameterHolder()-get(’password_field’); $password = $this-getContext()-getRequest()-getParameter ($password_field); $remember = false; $remember_field = $this-getParameterHolder()-get(’remember_field’); $remember = $this-getContext()-getRequest()-getParameter ($remember_field); $email = $value; $profile = sfGuardUserProfileTable::retrieveByEmail($email); if (!$profile) return false; $user = $profile-getsfGuardUser(); // user exists and active? if ($user and $user-getIsActive()) { // password is ok? if ($user-checkPassword($password)) { $this-getContext()-getUser()-signIn($user, $remember); return true; } } $error = $this-getParameterHolder()-get(’username_error’); return false; } } How do I make sfGuardAuth use this validator instead of the default one? I tried, per the blog post, creating a signin.yml file with the following values: methods: post: [username, password] names: username: required: true required_msg: Your username is required validators: [userValidator] password: required: true required_msg: Your password is required userValidator: class: sfGuardUserByEmailValidator param: password_field: password remember_field: remember Placed that in apps/frontend/modules/sfGuardAuth/validate/signin.yml and it doesn't seem to be working. I'm still getting username/ password errors, instead of email/password errors. Basically, how do I override the standard sfGuardAuth validator and substitute this one? Thanks so much! Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Authentication with email
Hey all, I'm using Symfony 1.2 and Doctrine, with the sfDoctrineGuard plugin. I have a table for profile information called sfDoctrineGuardProfile. Creating a new user and profile works great. I want the user to be able to log in with their email address, instead of a username. I set the username field in the sfDoctrineGuard schema to allow null values. I found an email signin validation script here (http://bluehorn.co.nz/2009/04/29/implementing-email-login-with- sfguardplugin/) and modified it to work with doctrine. The email validation is as follows: class sfGuardUserByEmailValidator extends sfValidator { public function initialize($context, $parameters = null) { // initialize parent parent::initialize($context); // set defaults $this-getParameterHolder()-set(’username_error’, ‘Email or password is not valid.’); $this-getParameterHolder()-set(’password_field’, ‘password’); $this-getParameterHolder()-set(’remember_field’, ‘remember’); $this-getParameterHolder()-add($parameters); return true; } public function execute($value, $error) { $password_field = $this-getParameterHolder()-get(’password_field’); $password = $this-getContext()-getRequest()-getParameter ($password_field); $remember = false; $remember_field = $this-getParameterHolder()-get(’remember_field’); $remember = $this-getContext()-getRequest()-getParameter ($remember_field); $email = $value; $profile = sfGuardUserProfileTable::retrieveByEmail($email); if (!$profile) return false; $user = $profile-getsfGuardUser(); // user exists and active? if ($user and $user-getIsActive()) { // password is ok? if ($user-checkPassword($password)) { $this-getContext()-getUser()-signIn($user, $remember); return true; } } $error = $this-getParameterHolder()-get(’username_error’); return false; } } How do I make sfGuardAuth use this validator instead of the default one? I tried, per the blog post, creating a signin.yml file with the following values: methods: post: [username, password] names: username: required: true required_msg: Your username is required validators: [userValidator] password: required: true required_msg: Your password is required userValidator: class:sfGuardUserByEmailValidator param: password_field: password remember_field: remember Placed that in apps/frontend/modules/sfGuardAuth/validate/signin.yml and it doesn't seem to be working. I'm still getting username/ password errors, instead of email/password errors. Basically, how do I override the standard sfGuardAuth validator and substitute this one? Thanks so much! Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: Save an embedded form that relies on the other form
I'm doing something like this, and this is my solution: Let's say you have two forms, one is an sfGuardUser form (Form 1), the other is a Profile form (Form 2) (representing those two models). When a new user is created, a new profile must be also created that depends on that record (Profile depends on sfGuardUser): (this is sfGuardUserForm.class.php): $profileForm = new ProfileForm(); $profileForm-getObject()-setsfGuardUserId($this-getObject()); $this-embedForm('profile', $profileForm); You'll also want to unset the sfGuardUserId field: unset($profileForm ['sf_guard_user_id']); So, it's basically creating a ProfileForm, getting the object related to it, then telling symfony to set that object's sfUserGuardId to equal the sfGuardUser object that this class represents. Does that make sense? Hope this helps. I'm somewhat of a newb myself, so I may be telling you something that doesn't apply. Good luck! Justin On Feb 5, 4:25 pm, Timmy m...@timothybowler.com wrote: I have two forms form 1 and form 2. Form 2 is embedded into form 1. On save form1 must be saved as a new row and therefore recieving a primary key, Afterwards this foreign key needs to be injected into form 2 before it can save. The only way i have figured out at the mo is after the form is valid. Instantiate the two models, populate them, add form2 model to form 1 model then save. Isn't there an easier way? Thanx --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Pass values from one form to another
Hey all, I'm trying to create a multi-page signup form. The first page is a form that creates the user (sfGuardUser) and also creates a profile for them (table name: Profile). After that is submitted, it redirects to a second form, for the user to fill out more profile details. However, I don't know how to load the appropriate Profile object on this page. After I create it in the first form submission, how should I pass it to the second form, so the second form simply updates the profile? One thought I just had was to create the user, then after form submission, sign them in automatically then send them to the second form where I can then just use $this-getUser-getGuardUser()- getProfile() to get the corresponding profile object. Not sure if that's the best way or not. What do you all think? Thanks! Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Doctrine Validator fails on unique field
Hey all, I've got one that I can't figure out. I'm using Doctrine and sfGuardDoctrine on my site. I have a registration form consisting of three embedded forms. Registration works great, unless the user tries registering a username that is not valid. If that happens, instead of some sort of message on the form, symfony throws a Doctrine Exception as follows: Validation failed in class sfGuardUser 1 field had validation error: * 1 validator failed on username (unique) Here are my schemas: sfGuardGroup: actAs: [Timestampable] columns: id: type: integer(4) primary: true autoincrement: true name: type: string(255) unique: true description: string(1000) relations: users: class: sfGuardUser refClass: sfGuardUserGroup local: group_id foreign: user_id foreignAlias: Groups permissions: class: sfGuardPermission local: group_id foreign: permission_id refClass: sfGuardGroupPermission foreignAlias: Groups sfGuardPermission: actAs: [Timestampable] columns: id: type: integer(4) primary: true autoincrement: true name: type: string(255) unique: true description: string(1000) sfGuardGroupPermission: actAs: [Timestampable] columns: group_id: type: integer(4) primary: true permission_id: type: integer(4) primary: true relations: sfGuardGroup: local: group_id onDelete: CASCADE sfGuardPermission: local: permission_id onDelete: CASCADE sfGuardUser: actAs: [Timestampable] columns: id: type: integer(4) primary: true autoincrement: true username: type: string(128) notnull: true unique: true algorithm: type: string(128) default: sha1 notnull: true salt: string(128) password: string(128) is_active: type: boolean default: 1 is_super_admin: type: boolean default: 0 last_login: type: timestamp indexes: is_active_idx: fields: [is_active] relations: groups: class: sfGuardGroup local: user_id foreign: group_id refClass: sfGuardUserGroup foreignAlias: Users permissions: class: sfGuardPermission local: user_id foreign: permission_id refClass: sfGuardUserPermission foreignAlias: Users CovGroup: { local: id, foreign: group_leader } sfGuardUserPermission: actAs: [Timestampable] columns: user_id: type: integer(4) primary: true permission_id: type: integer(4) primary: true relations: sfGuardUser: local: user_id onDelete: CASCADE sfGuardPermission: local: permission_id onDelete: CASCADE sfGuardUserGroup: actAs: [Timestampable] columns: user_id: type: integer(4) primary: true group_id: type: integer(4) primary: true relations: sfGuardUser: local: user_id onDelete: CASCADE sfGuardGroup: local: group_id onDelete: CASCADE sfGuardRememberKey: actAs: [Timestampable] columns: id: type: integer(4) primary: true autoincrement: true user_id: type: integer(4) remember_key: string(32) ip_address: type: string(50) primary: true relations: sfGuardUser: local: user_id foreignAlias: RememberKeys onDelete: CASCADE GroupSettings: columns: group_id: { type: integer } language: { type: string(100), notnull: true } num_requests: { type: integer(3), notnull: true } send_day: { type: integer(1), notnull: true } relations: CovGroup: { local: group_id, foreign: id } CovGroup: actAs: { Timestampable: ~ } columns: group_leader: { type: integer(4), notnull: true } relations: GroupSettings: { local: id, foreign: group_id } sfGuardUser: { local: group_leader, foreign: id } Prayer: actAs: { Timestampable: ~ } columns: prayer_for: { type: string(100), notnull: true } state_for:{ type: string(50), notnull: true } country_for: { type: string(100), notnull: true } prayer_from: { type: string(100), notnull: true } state_from: { type: string(50), notnull: true } country_from: { type: string(100), notnull: true } text: { type: string(1000), notnull: true } sent: { type: boolean } sfGuardUserProfile: columns: sf_guard_user_id: integer(4) first_name: string(20) last_name: string(20) email: string(100) relations: sfGuardUser: { local: sf_guard_user_id, foreign: id } Any ideas? Thanks so much! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to