[symfony-users] Re: Custom error page for "Integrity constraint violation"

2010-03-29 Thread Campezzi
I don't know if there's an easier way to do this, but I think I would
override the delete method on the parent model to do a custom
integrity check before actually trying to delete the record from the
database and returning false if it detects there will be constraint
problems. You can then add custom handling on your app in case the
delete method returns false, for example, redirecting the user
somewhere else, setting a flash message, etc.

In case you're wondering, here's the signature for the function you'll
need to override (declared in the Doctrine_Record class, which is the
base class of your Doctrine-generated models):

/**
 * deletes this data access object and all the related composites
 * this operation is isolated by a transaction
 *
 * this event can be listened by the onPreDelete and onDelete
listeners
 *
 * @return boolean  true if successful
 */
public function delete(Doctrine_Connection $conn = null)


Hope to have helped!

Best Regards,
Thiago Campezzi


On Mar 29, 9:01 am, bretth  wrote:
> Hi,
>
> I'm getting the error
>
> SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or
> update a parent row: a foreign key constraint fails
>
> when I delete a parent row from my admin generator. That's fine; it's
> doing what it should be doing; however I want to display a nicer error
> message for just this error along the lines of "You can't delete x
> because it has y linked to it".
>
> Currently it just goes to the standard symfony error500 page; I don't
> want to just override the 500 error page with this message, because if
> the server ever gives error500s for other reasons it could potentially
> be confusing.
>
> How can I display a custom error for "Integrity constraint violation"
> and leave my 500 page intact.
>
> ...or.. is there another way to achieve what I'm trying to do?
>
> Symfony 1.4, Doctrine, Mysql
>
> thanks!!
>
> Brett

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.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

To unsubscribe from this group, send email to 
symfony-users+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


[symfony-users] Re: Setting default error messages for forms (1.4.1)

2009-12-18 Thread Campezzi
Thanks! This worked like magic :)

Best Regards,

Thiago Campezzi
campe...@gmail.com


On 17 dez, 20:21, xplo  wrote:
> Hi,
> it s probably because you call setMessage after the validator has been
> created, the text message is set when the validator is created and
> wont be changed afterward ( it will happens will all propel/doctrine
> form since the validator are created in the setup call ).
> I just put the default message in ProjectConfiguration.class.php
> sfValidatorBase::setDefaultMessage('required', 'This field is
> required.');
> sfValidatorBase::setDefaultMessage('invalid', 'The information you
> entered is invalid..');
> bye
>
> On Dec 17, 2:39 pm, Campezzi  wrote:
>
>
>
> > Hello folks,
>
> > I've been trying to set default error messages on my forms so that I
> > don't have to "repeat myself" setting them field by field - for
> > example, setting global "required" and "invalid" messages. Looking at
> > the API, this seems simple enough by calling the setMessages() method
> > on my form's validatorSchema, so I've tried this inside my form's
> > configure() method:
>
> >     $this->validatorSchema->setMessages(array(
> >       'required' => 'This field is required.',
> >       'invalid' => 'The information you entered is invalid.'
> >     ));
>
> > However, to my surprise, it does nothing! No errors/warnings/
> > exceptions, yet nothing actually happens and the same old "Required."
> > and "Invalid." messages pop up on my form.
>
> > Is there something incredibly dumb I'm missing here or is this just a
> > bug in sf 1.4?
>
> > Thanks for your time!
>
> > Best Regards,
>
> > Thiago Campezzi
> > campe...@gmail.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-us...@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] Setting default error messages for forms (1.4.1)

2009-12-17 Thread Campezzi
Hello folks,

I've been trying to set default error messages on my forms so that I
don't have to "repeat myself" setting them field by field - for
example, setting global "required" and "invalid" messages. Looking at
the API, this seems simple enough by calling the setMessages() method
on my form's validatorSchema, so I've tried this inside my form's
configure() method:


$this->validatorSchema->setMessages(array(
  'required' => 'This field is required.',
  'invalid' => 'The information you entered is invalid.'
));

However, to my surprise, it does nothing! No errors/warnings/
exceptions, yet nothing actually happens and the same old "Required."
and "Invalid." messages pop up on my form.

Is there something incredibly dumb I'm missing here or is this just a
bug in sf 1.4?

Thanks for your time!

Best Regards,

Thiago Campezzi
campe...@gmail.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-us...@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: Looking for suggestions...

2009-12-14 Thread Campezzi
This would also work... actually, I think it's even better than the
older solution. The problem with their DB is that there are tons of
stupid fields that were created in order to get a specific report that
is not necessary anymore. There are so many of those that they ended
up losing track of their DB (in other words, there are tables and
fields that get people scratching their heads - what is THAT doing
there?! - but still they're afraid of simply deleting it because
something might stop working...

With 2 DBs I could "migrate" the info to my new clean DB, using only
the fields I need and getting more freedom with symfony :)

Thanks again for your input!

Best Regards,

Thiago Campezzi
campe...@gmail.com

On Dec 14, 8:03 pm, Alexandru-Emil Lupu  wrote:
> That basically i would call it "migration" from an old system to the
> new system.
> Yes ... you can do that ... also you can make a dirty project that
> would use 2 dbs:
>
> 1 for old data
> 1 for the new data ...
> 2 db connections should do the trick
>
> On Tue, Dec 15, 2009 at 12:00 AM, Alexandre Salomé
>
>
>
>
>
>  wrote:
> > Hi,
> >   Suppose you have an old "dirty" table named "news_website" :
> > ID  |   NAME    |    TAGS      |    CATEGORY1   |      CATEGORY2    |
> > CATEGORY3
> > Define it in Doctrine with an "old" prefix :
>
> > oldNewsWebsite:
> >   columns:
> >     id:        { type: integer(4), primary: true }
> >     name:      { type: varchar(64) }
> >     tags:      { type: varchar(255) }
> >     category1: { type: string(32) }
> >     category2: { ... }
> >     category3: { type: string(32) }
>
> > Do not try to make some "clean" model, define it as it is.
> > Now, in your oldNewsWebsite class, define for example a method :
> > getCleanNews.
> > This method must returns an object with the new schema definition :
>
> > $news = new News();
> > $topic = $this->getTable()->getCleanTopic(); // Returns the news topic named
> > "Website"
> > $news->setTopic($topic);
> > $tags = explode(", ", $this->getTags());
> > foreach ($tags as $tagName)
> > {
> >   Doctrine::getTable('oldTag')->getCleanTag($tagName);
> > }
> > if ($category1 = $this->getCleanCategory1())
> > {
> >   $news->addCategory($category1);
> > }
> > // and so on...
> > return $news;
>
> > And after, the idea is to retrieve old objects one by one, extract the clean
> > objects and save them.
> > The aim is to remove this "old" schema after the transition is complete.
> > Do you understand the idea ?
> > Alexandre
>
> >   Feel free to put schema definition in a "oldPlugin", to isolate it and
> > remove it when not needed anymore.
>
> > 2009/12/14 Alexandru-Emil Lupu 
>
> >> Well... do your stuff using symfony ... and pretend that you still
> >> work on that application ... and take some days off :)
> >> To be ready for the moment when they will say "Hey, we have a bug
> >> there..." (of course in the non sf version)... then you refactorize
> >> that area as well ...
> >> I have manage convince my boss that is better to that with symfony,
> >> because is much more maintainable and extensibile ...
> >> if they cannot afford a cool / secure / organized application ... then
> >> i might recommend you something (heard from others ): "Change your
> >> job, or change your job." or, of course the client ...
> >> Alecs
>
> >> On Mon, Dec 14, 2009 at 10:46 PM, Campezzi  wrote:
> >> > Hi Alecs, thanks for your replies! My initial idea was to upgrade
> >> > their entire plataform to run on symfony, but they didn't approve that
> >> > idea for two reasons: one, it would go over their budget... and two,
> >> > they had several random screens scattered all over the server that
> >> > were used by different team members on random occasions... They didn't
> >> > even know the full range of capabilities of their system because of
> >> > that LOL :)
>
> >> > I think I'll end up going with pure php, or maybe disabling the ORM
> >> > entirely and doing all database interactions by hand... ugh! :(
>
> >> > Unless, of course, someone else has a magical solution ;)
>
> >> > Thanks again and best regards,
>
> >> > Thiago Campezzi
> >> > campe...@gmail.com
>
> >> > On 14 dez, 16:57, Alexandru-Emil Lupu  wrote:
> >> >

[symfony-users] Re: Looking for suggestions...

2009-12-14 Thread Campezzi
That's an interesting solution, and I guess it could work on my
case... Thanks!

On Dec 14, 8:00 pm, Alexandre Salomé 
wrote:
> Hi,
>
>   Suppose you have an old "dirty" table named "news_website" :
>
> ID  |   NAME    |    TAGS      |    CATEGORY1   |      CATEGORY2    |
> CATEGORY3
>
> Define it in Doctrine with an "old" prefix :
>
> oldNewsWebsite:
>   columns:
>     id:        { type: integer(4), primary: true }
>     name:      { type: varchar(64) }
>     tags:      { type: varchar(255) }
>     category1: { type: string(32) }
>     category2: { ... }
>     category3: { type: string(32) }
>
> Do not try to make some "clean" model, define it as it is.
>
> Now, in your oldNewsWebsite class, define for example a method :
> getCleanNews.
>
> This method must returns an object with the new schema definition :
>
> $news = new News();
> $topic = $this->getTable()->getCleanTopic(); // Returns the news topic named
> "Website"
> $news->setTopic($topic);
> $tags = explode(", ", $this->getTags());
> foreach ($tags as $tagName)
> {
>   Doctrine::getTable('oldTag')->getCleanTag($tagName);}
>
> if ($category1 = $this->getCleanCategory1())
> {
>   $news->addCategory($category1);}
>
> // and so on...
> return $news;
>
> And after, the idea is to retrieve old objects one by one, extract the clean
> objects and save them.
>
> The aim is to remove this "old" schema after the transition is complete.
>
> Do you understand the idea ?
>
> Alexandre
>
>   Feel free to put schema definition in a "oldPlugin", to isolate it and
> remove it when not needed anymore.
>
> 2009/12/14 Alexandru-Emil Lupu 
>
>
>
>
>
> > Well... do your stuff using symfony ... and pretend that you still
> > work on that application ... and take some days off :)
> > To be ready for the moment when they will say "Hey, we have a bug
> > there..." (of course in the non sf version)... then you refactorize
> > that area as well ...
> > I have manage convince my boss that is better to that with symfony,
> > because is much more maintainable and extensibile ...
> > if they cannot afford a cool / secure / organized application ... then
> > i might recommend you something (heard from others ): "Change your
> > job, or change your job." or, of course the client ...
> > Alecs
>
> > On Mon, Dec 14, 2009 at 10:46 PM, Campezzi  wrote:
> > > Hi Alecs, thanks for your replies! My initial idea was to upgrade
> > > their entire plataform to run on symfony, but they didn't approve that
> > > idea for two reasons: one, it would go over their budget... and two,
> > > they had several random screens scattered all over the server that
> > > were used by different team members on random occasions... They didn't
> > > even know the full range of capabilities of their system because of
> > > that LOL :)
>
> > > I think I'll end up going with pure php, or maybe disabling the ORM
> > > entirely and doing all database interactions by hand... ugh! :(
>
> > > Unless, of course, someone else has a magical solution ;)
>
> > > Thanks again and best regards,
>
> > > Thiago Campezzi
> > > campe...@gmail.com
>
> > > On 14 dez, 16:57, Alexandru-Emil Lupu  wrote:
> > >> Sorry for my previous mail.
> > >> i was on the move and i just remembered "Symfony 1.2" ... instead of
> > >> "symfony (1.4,
> > >> doctrine 1.2)"
>
> > >> About your initial qustestion: try implement the whole system as a
> > >> symfony platform. That will allow you to put some order in your
> > >> code...
> > >> Those automatizations like sending notifications mails could resume to
> > >> 2 symfony commands run from a cron job.
>
> > >> symfony yourapp:build-notifications
> > >> symfony project:send-emails
>
> > >> Also, the interface could be easily built be using the crud.
>
> > >> Alecs
>
> > >> On Mon, Dec 14, 2009 at 8:58 PM, Alexandru-Emil Lupu
>
> > >>  wrote:
> > >> > How complex is the "old" application? Using symfony, it might be play
> > in the
> > >> > park to reorganize your old code, and make your necesarilly
> > adjustments on
> > >> > the schema as you need, or you consider proper.
> > >> > Btw... do yourself a favor and code it with 1.4 . I will tell you why
> > in 30
>

[symfony-users] Re: Looking for suggestions...

2009-12-14 Thread Campezzi
Hi Alecs, thanks for your replies! My initial idea was to upgrade
their entire plataform to run on symfony, but they didn't approve that
idea for two reasons: one, it would go over their budget... and two,
they had several random screens scattered all over the server that
were used by different team members on random occasions... They didn't
even know the full range of capabilities of their system because of
that LOL :)

I think I'll end up going with pure php, or maybe disabling the ORM
entirely and doing all database interactions by hand... ugh! :(

Unless, of course, someone else has a magical solution ;)

Thanks again and best regards,

Thiago Campezzi
campe...@gmail.com

On 14 dez, 16:57, Alexandru-Emil Lupu  wrote:
> Sorry for my previous mail.
> i was on the move and i just remembered "Symfony 1.2" ... instead of
> "symfony (1.4,
> doctrine 1.2)"
>
> About your initial qustestion: try implement the whole system as a
> symfony platform. That will allow you to put some order in your
> code...
> Those automatizations like sending notifications mails could resume to
> 2 symfony commands run from a cron job.
>
> symfony yourapp:build-notifications
> symfony project:send-emails
>
> Also, the interface could be easily built be using the crud.
>
> Alecs
>
> On Mon, Dec 14, 2009 at 8:58 PM, Alexandru-Emil Lupu
>
>
>
>
>
>  wrote:
> > How complex is the "old" application? Using symfony, it might be play in the
> > park to reorganize your old code, and make your necesarilly adjustments on
> > the schema as you need, or you consider proper.
> > Btw... do yourself a favor and code it with 1.4 . I will tell you why in 30
> > mins
> > Alecs
>
> > sent via htc magic
>
> > On Dec 14, 2009 8:24 PM, "Campezzi"  wrote:
>
> > Hello everyone, I'm starting a new project and I'd like some input
> > from the community as to what is the best way to approach this
> > implementation. Here it goes:
>
> > The project goal is to automate the client's invoice generation and
> > management (email notifications,etc). The client already has a custom
> > system in place (pure php + mysql) that includes a database of clients
> > and projects and also some basic accounting screens. This new project
> > should interact with these systems that are already in place (i.e.
> > getting client e-mail addresses from the database to send invoices,
> > creating accounting entries when invoices are paid, etc.)
>
> > As you can expect, their systems are currently a mess of unmanageable
> > code, and I wanted to create the invoicing system using symfony (1.4,
> > doctrine 1.2). Here's where your input is appreciated: how should I go
> > about integrating the new sf-based project with the old database where
> > necessary?
>
> > So far, my only idea is to duplicate the old database layout in my
> > schema.yml file but I'd like to avoid that since the current db is
> > really, really messy...
>
> > Any ideas?
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "symfony users" group.
> > To post to this group, send email to symfony-us...@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.
>
> --
> Have a nice day!
> Alecs
>
> As programmers create bigger & better idiot proof programs, so the
> universe creates bigger & better idiots!
> I am on web:  http://www.alecslupu.ro/
> I am on twitter:http://twitter.com/alecslupu
> I am on linkedIn:http://www.linkedin.com/in/alecslupu
> Tel: (+4)0748.543.798

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@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] Looking for suggestions...

2009-12-14 Thread Campezzi
Hello everyone, I'm starting a new project and I'd like some input
from the community as to what is the best way to approach this
implementation. Here it goes:

The project goal is to automate the client's invoice generation and
management (email notifications,etc). The client already has a custom
system in place (pure php + mysql) that includes a database of clients
and projects and also some basic accounting screens. This new project
should interact with these systems that are already in place (i.e.
getting client e-mail addresses from the database to send invoices,
creating accounting entries when invoices are paid, etc.)

As you can expect, their systems are currently a mess of unmanageable
code, and I wanted to create the invoicing system using symfony (1.4,
doctrine 1.2). Here's where your input is appreciated: how should I go
about integrating the new sf-based project with the old database where
necessary?

So far, my only idea is to duplicate the old database layout in my
schema.yml file but I'd like to avoid that since the current db is
really, really messy...

Any ideas?

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@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: Foreign key violation when saving embedded forms

2009-06-30 Thread Campezzi

Hi there!

I don't know if this applies to 1:1 relationships, but I had a similar
problem when trying to embed a for on a 1:n (an Author has many Books)
relationship and found the solution on this TRAC entry:

http://trac.symfony-project.org/ticket/4906

Towards the end of the discussion, jwage points this solution (it's
Doctrine, btw, but I don't think that is too relevant here):

# This is for a blank new book at the form
$Book = new Book();
$Book['author_id'] = $this->object['id'];
$bookForm = new BookForm($Book);
unset($bookForm['author_id']);
$form->embedForm('new', $bookForm);

So you see, you have to create a Book object first and "manually" link
it to the Author object. I think Doctrine handles 1:1 relationships
automatically, but Propel may not. I'm not sure about that. But I
guess if you take the manual approach from the example above, you may
have a good starting point :)

Also be sure to read through some of the messages posted to that TRAC
discussion, they really helped me grasp the concept of embedded forms
a bit better! ;)

Regards,

Thiago Campezzi



On Jun 29, 7:12 am, "Java geek"  wrote:
> Sorry, there was a typo...
>
> Here's the code.
>
> Schema
> propel:
>
>   user:
>     id: ~
>     name: {type: varchar(100)}
>
>   registrations:
>     id: ~
>     user_id: {type: integer, foreignTable: user, foreignReference: id, 
> required: true}
>
> RegistrationForm
>
> class RegistrationsForm extends BaseRegistrationsForm
> {
>   public function configure()
>   {
>     unset($this['user_id']);
>     $userform = new UserForm($this->object->getUser());
>     $this->embedForm("User", $userform);  
>   }
>
> }
>
> UserForm
> class UserForm extends BaseUserForm
> {
>   public function configure()
>   {
>   }
>
> }
>
> If I don't use required = true in required: true, in that case.. user is 
> saved in db.. but still user_id is null in registration, so no association is 
> made, user_id is not getting set.
>
>   - Original Message -
>   From: Java geek
>   To: symfony-users@googlegroups.com
>   Sent: Monday, June 29, 2009 3:27 PM
>   Subject: [symfony-users] Re: Foreign key violation when saving embedded 
> forms
>
>   I am using Symfony 1.2 and propel...
>     - Original Message -
>     From: Java geek
>     To: symfony-users@googlegroups.com
>     Sent: Monday, June 29, 2009 2:30 PM
>     Subject: [symfony-users] Foreign key violation when saving embedded forms
>
>     I have following schema.
>
> User
>   id: ~
>   name: {type: varchar(100)}
>
> Registrations
>   id: ~
>   user_id: {type: integer, foreignTable: User, foreignReference: id}
>
>     schema is not complete, It shows important fields only.
>
>     RegistrationForm
>
> unset($this['user_id']);
> $userform = new UserForm($this->object->getUser());
> $this->embedForm($userform);
>
>     Form is displayed.. and it works when updating existing registrations.
>
>     But it throws foreign key constraint violation when creating new 
> registrations. because user_id is null. Some how new user is not being set on 
> registration.
>
>     What am I doing wrong?
>
>     SN
>    http://www.jsptube.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: Multiple selects for one field : How to do that ?

2009-06-21 Thread Campezzi

Hi William,

I'm not sure if I get what you want, but if the issue is populating 2
form fields with entries from the same Model using one of the model
properties as a sort of "filter" for each form field, then you can use
a custom query to populate the form field. You basically have to
create 2 Doctrine form widgets on your form (for example, two
sfWidgetFormDoctrineSelect widget) passing the "query" option when
creating them. So, on your Form code, adding something like this:

$this->widgetSchema['cv_select'] = new sfWidgetFormDoctrineSelect(array
(
  'model' => 'Document',
  'query' => $cv_query
));

$this->widgetSchema['letter_select'] = new sfWidgetFormDoctrineSelect
(array(
  'model' => 'Document',
  'query' => $letter_query
));

Of course, you'll have to create the two custom Doctrine queries (I
named them $cv_query and $letter_query on this example) using the type
field to filter what each widget will display, but I think you can
handle that part - the trick is passing the query option when creating
the widget.

More info here: 
http://www.symfony-project.org/api/1_2/sfWidgetFormDoctrineSelect

Hope that was helpful!

Kind Regards,
Thiago Campezzi


On Jun 20, 9:22 pm, William  wrote:
> Hi Alexandru,
> i'm so sorry for this "resend" of my message, there was a bug that
> resent my message, I had deleted them (as soon as i've seen it).
> I know tha some of us are busy or might not reply anything.
>
> I've ever thought to split CVs from letters, but i would like to know
> if i could be in a different way.
> Gonna to explain a bit more :
> - I've an object Document with its attributes : filename, description,
> type...
> - Type attribute can be CV or Letter.
> - I've an another object Mail (one field is document_list) that has
> m2m relation with Document.
> - Some restrictions : a Mail can have 2 Document objects max : 1 CV
> and 1 Letter.
> No logical problem i think. The only problem is to split one form
> field into two : a select with just Documents thave have CV type and
> an another one that just have Letter type.
> I'm using Symfony 1.2 and Doctrine. In 1.0, i could be what you said
> but in 1.2 don't know how to do.
> Else, i'll rebuild my model by adding two attributes document_cv_id
> and document_letter_id in my Mail object.
> What do you think about it ?
>
> Thanks for your reply and sorry for multiple messages.
> William.
>
> On 20 juin, 23:09, Alexandru-Emil Lupu  wrote:
>
> > HI william!there is no valable reason to do this "resend" of your message,
> > in that short interval (4 mails in 2 hours). If you did not got any replies,
> > it's maybe because some of us might not know what to answer, or maybe we're
> > out. it is still (was for me ) Saturday.
>
> > And, for your question, If you ask us how to solve it, then obviously you
> > have a logic problem. For a start i would split CVs from letters, and i
> > would use a relational table: to keep the track of what letter was attached
> > to the CV. From what i may understand from your question, it might be a job
> > offer website.
>
> > IF you use Propel:
> > You might wanna use 2 custom Peer functions that are using "doSelect"
> > function.
>
> > public static function getCVs(Criteria $c){
> > $cv = array();
> > $c = clone $c;
> > $results  = self::doSelect($c);
> > foreach ($results as $document){
> > if ($document->isCV()){
> > array_push($cv,$document)}
> > }
>
> > return count($cv)>0 ? $cv : null;
>
> > }
>
> > public static function getLetters(){
> > $letter = array();
> > $c = clone $c;
> > $results  = self::doSelect($c);
> > foreach ($results as $document){
> > if ( ! $document->isCV()){
> > array_push($letter,$document)}
> > }
>
> > return count($letter)>0 ? $letter : null;}
>
> > public static function doSelect($c){
> > if (!isset(self::$list_of_documents)){
> > $c = clone $c;
> > self::$list_of_documents = parent::doSelect($c)
>
> > }
>
> > return self::$list_of_documents;
>
> > }
>
> > if your problem was that you need to make 2 queries, well that's the
> > solution, however, but, i would suggest that $list_of_documents to be an
> > array having as key a hash after the serialization of the Criteria object.
> > Just to be sure that you will be able to make another doSelect intergation
> > with another Criteria.
>
> > Alecs
>
> > On Sat, Jun 20, 2009 at 2:33 PM, William  wrote:
>
> > > Hi,
>
&g

[symfony-users] Re: Timing for Registering Routes in sf1.0

2009-06-19 Thread Campezzi

Hi Daniel,

What Jacob said is true - you should use variables instead of adding
each route manually. However, you're not limited to using the /
categories/:name format; you can simply add a rule like /:name and
have the url layout you want. You just need to worry about 2 things:

1. this rule will match every url like domain.com/directory. that
means that if you want to use the same url structure for things that
are not categories, you should create specific rules for them BEFORE
the general category rule on routing.yml. for example, let's say you
want to have domain.com/contact where "contact" is not a category
name; in that case, you would first add a rule matching simply /
contact, pointing to the module/action responsible for that page, and
later in routing.yml your /:name rule pointing to some other module/
action that you use to handle categories.

2. as a side effect of point #1, you won't be able to create a
category with a name used on a specific rule. so using the same
example, if you want to create a category named "contact", you will
never be able to reach it since symfony will match the specific /
contact rule and stop reading the routing file at that point. In other
words, you're creating possible url conflicts, and to avoid that
you'll have to code some sort of "reserved keywords" system in the
category creation part.

Hope that helped clear up things a bit!

Regards,
Thiago Campezzi



On Jun 19, 3:00 pm, Richtermeister  wrote:
> Hi all,
>
> there's one thing I'm always struggling with, and that is registering
> new routes dynamically in sf 1.0.
> For example, my current site has product categories, and I would like
> to add a new route for each category so that I get urls like
>
> /category1
> /category2
> etc.
>
> I know I can just do
> /categories/category1
> /categories/category2
>
> but for something this central to the site I would like to use the
> first solution.
> Now, in sf1.0 it seems the best time to add these routes would be the
> config.php file in the current app directory, but if I add the routes
> after the call to sfCore::bootstrap(), the current route will already
> be determined (disregarding my routed). If I try to add the routes
> before the call, symfony has not been initialized enough to understand
> the command.
>
> How should I go about adding those routes? Please keep in mind that I
> need to use the ORM as well, in order to get a list of the current
> categories..
>
> Thanks for your help,
> and have a great day.
>
> Daniel
--~--~-~--~~~---~--~~
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: jobeet day 2 (subversion)

2009-06-10 Thread Campezzi

Yep, it's a standalone program. You can download it on 
http://subversion.tigris.org/
If you're in Windows, I recommend using TortoiseSVN since it's very
simple and you can usually run it without having any "technical"
knowledge of SVN. If you're feeling hardcore, you can always get the
command-line version. In that case, you should definitely download the
free SVN book (or should I say Bible?) here: http://svnbook.red-bean.com/

Good luck!

Regards,
Thiago Campezzi

On Jun 10, 2:03 am, Gareth McCumskey  wrote:
> Subversion isn't an apache thing as far as I know. Its a standalone program
>  feel free to correct anyone but I'm pretty sure it isn't
>
> On Tue, Jun 9, 2009 at 1:48 PM, sm9...@gmail.com  wrote:
>
> > Jobeet doc describes how to create a repository for IIS in
> >http://www.symfony-project.com/cookbook/1_0/web_server_iis
>
> > I use WAMP, any pointer for using subversion in Apache?
>
> > Thanks
>
> --
> Gareth McCumskeyhttp://garethmccumskey.blogspot.com
> twitter: @garethmcc
--~--~-~--~~~---~--~~
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: Option ids in routing rules?

2009-06-08 Thread Campezzi

Hi Eno,

Not sure if this is the best solution, but nothing stops you from
creating another rule without the page parameter:

url: /getarticle_by_id/:id
param: { module: xxx, action: yyy }

url: /getarticle_by_id/:id/:page
param: { module: xxx, action: zzz }


Cheers
Thiago Campezzi

On Jun 8, 12:58 pm, Eno  wrote:
> Is it possible to make parameters in routing rules optional?
>
> i.e.
>
> /getarticle_by_id/:id/:page
>
> I want the second parameter (page) to be optional - if it isn't
> present then the urls will look like /getarticle_by_id/:id and I want
> my action to retrieve all pages instead.
--~--~-~--~~~---~--~~
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: sfDoctrineRoute does not match

2009-06-04 Thread Campezzi

Hi Eric,

Wild guess - it could be something related to the method of the
request (i.e. it matches with a GET method but not with a POST method
or maybe with a PUT method, which is used on update forms in symfony).
Try adding this to the route requirements:

sf_method: [get,post,put]

And see if you have any luck.

Kind Regards,

Campezzi



On Jun 3, 12:23 pm, Eric  wrote:
> Hi,
>
> I have a form and I use the following route as url:
>
> --- routing.yml
> messages_view_conversation_update:
>   url:       /messages/reply/:id/update
> #  class:     sfDoctrineRoute
>   options:   { model: Conversation, type: object }
>   param:     { module: messages, action: reply, id: 1 }
>   requirements:
>     id: \d+
>
> --- _form.php
> 
>
> This works as expected. But once I uncomment sfDoctrineRoute, it does
> not match any more (form is displayed correctly with url but once I
> submit it, it matches /:action/:method/*).
>
> Can you tell me why this happens and how I can fix this?
>
> Regards
>
> Eric
--~--~-~--~~~---~--~~
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: Weird upload problem

2009-06-03 Thread Campezzi

Hi Sidney,

Unfortunately, there seems to be a bug with files uploaded inside
embedded forms in symfony. You'll find a workaround in this URL:

http://stereointeractive.com/blog/2008/12/23/symfony-12-upload-a-file-inside-an-embedded-form/

Also, it appears that when using this workaround you can't set a
specific function to handle the file name (in other words, you're
stuck with the name symfony generates by default).

This bug is also probably documented in Trac, if you need more info.

Good luck taming your embedded forms! :)

PS: Are you brazilian too?

Best Regards,
Thiago Campezzi


On Jun 3, 11:23 am, Sid Ferreira  wrote:
> Sample schema:
>
> > tableA:
>
>   id: ~
>
>   title : varchar(16)
>
>
>
> > tableB:
>
>   id: ~
>
>   a_id: (FK)
>
>   file: varchar(64);
>
>
>
> > tableC:
>
>   id: ~
>
>   a_id: (FK)
>
>   file: varchar(64);
>
>
>
> In the forms, TableA  embed all TableB and TableC that belongs to it.
>
> Sometimes the upload of B simply fails. why?
>
> obs: I hope it is enough information
>
> --
> Sidney G B Ferreira
> Desenvolvedor Web
--~--~-~--~~~---~--~~
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: Which classes should I use for this validation logic?

2009-06-03 Thread Campezzi

Hi Alex,

I haven't looked too deep in the subject, so this is not going to be a
magical solution ;) But since there's some validation logic that
involves more than 1 field, you'll have to play around with global
validators - take a look at
http://www.symfony-project.org/forms/1_2/en/02-Form-Validation#chapter_02_global_validators

Hope that was a valid starting point! :)

Best Regards,
Campezzi


On Jun 2, 12:43 pm, Alex Gilbert  wrote:
> Field A is not required, but if Field A does contain a value then
> Field B is required.
>
> Can I use sfValidatorOr to do this or is there something more involved
> with sfValidatorSchema I need to be looking into?
>
> Thanks!
--~--~-~--~~~---~--~~
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: Integrate sfGuardUser and sfGuardUserProfile in the same Admin-Backend Module

2009-05-29 Thread Campezzi

Hey Daniel,

Yup, embedding is the way. I was about to point you to this excellent
tutorial when you found the answer by yourself:

http://www.symfony-project.org/blog/2008/11/12/call-the-expert-customizing-sfdoctrineguardplugin

A good read, anyways.

Cheers!


On May 28, 7:55 pm, halla  wrote:
> I think, I figured out the way it works. I'm going to embed the
> sfGuardUser-Form in my sfGuardUserProfile-Form :-)
>
> On 28 Mai, 22:13, halla  wrote:
>
> > Hi everybody,
>
> > I'm using the sfDoctrineGuardPlugin and it's default Admin-Generator
> > Backend for the sfGuardUser-Model. I'm also using a sfGuardUserProfile-
> > Class for storing Profile-Data, like E-Mail Address, First Name, Date
> > of Birth and so on.
>
> > How do I integrate my Profile-Class to the sfGuardUser-Backend, so
> > that I can f.e. edit fields from both Tables (sfGuardUser and
> > sfGuardUserProfile) on the same page in the Backend? I don't want to
> > have two backend modules for that (one for the user and another for
> > it's profile)
>
> > Is there a way to do this? Or do you have a link for a tutorial or
> > something (didn't find anything on Google for this)...?
>
> > Thank you,
> > Daniel
--~--~-~--~~~---~--~~
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: sfDoctrineGuardPlugin: automatically add new user to a group

2009-05-26 Thread Campezzi

Thanks Fabien, that's exactly what I wanted! I just didn't know
exactly which method to override. I'm still finding my way around
symfony ;)

Cheers!

Best Regards,
Campezzi


On May 26, 6:09 am, "FlyLM [ML]"  wrote:
> 2009/5/25 Campezzi :
>
>
>
> > Hi Fabien,
>
> > Thanks for the answer. Since the group was supposed to be added
> > automatically, I had the groups_list widget unset in my form. The
> > function you pointed me to seems to take what was stored in that
> > variable and link the values to the user being registered. I assume I
> > can get this working by making the groups_list field a hidden one and
> > setting the default value on the action or even on the form code
> > itself - then the code line you pointed out would do ther rest.
> > However, I'm unsure about how safe this is - couldn't an user
> > deliberately change the value of my hidden groups_list field in an
> > attempt to be added to another group, one with a different permission
> > set?
>
> Hi Campezzi,
>
> I had a same behavior in my last project. When I create a new user,
> the group is automaticaly associated, there is no choice in the form.
> First, I had thought about used a hidden field for "goup_list", but I
> didn't keep this idea. I have override the doSave method of my form.
>
> So, my "doSave" method looks like this :
>
> class backendSfGuardUserAdminForm extends BasesfGuardUserAdminForm
> {
>   []
>
>   /**
>    * (non-PHPdoc)
>    * @see 
> lib/form/doctrine/sfDoctrineGuardPlugin/base/BasesfGuardUserForm#doSave()
>    */
>   protected function doSave($con = null)
>   {
>     $isNew = $this->isNew();
>
>     if( $isNew )
>     {
>       $password = substr(md5(rand(10, 99)), 0, 8);
>       $this->getObject()->setPassword($password);
>     }
>
>     parent::doSave($con);
>
>     if( $isNew )
>     {
>       // Set the group, here "customer"
>       $group = Doctrine::getTable('sfGuardGroup')->findOneByName('customer');
>
>       $this->getObject()->link('groups', $group->getId());
>     }
>   }
>
>   []
>
> }
>
> Fabien
>
>
>
> > Best Regards,
> > Campezzi
>
> > On May 25, 12:53 pm, "FlyLM [ML]"  wrote:
> >> Hi,
>
> >> If you have always sfDoctrineGuardPlugin installed, take a look at
> >> this file line 84 (savegroupsList method)
>
> >> /lib/form/doctrine/sfDoctrineGuardPlugin/base/BasesGuardUserForm.class.php
>
> >> => $this->object->link('groups', array_values($link));
>
> >> Fabien
>
> >> 2009/5/25 Campezzi :
>
> >> > Hi there!
>
> >> > I'm getting started with sfDoctrineGuardPlugin and after doing a few
> >> > tutorials, I started to implement it in one of my projects. I have
> >> > created a registration form and embedded the Profile class form. So
> >> > far, so good - whenever a new user registers, both the sfGuardUser and
> >> > Profile objects get saved to the database and are correctly
> >> > associated.
>
> >> > Now, I have a "users" sfGuardGroup with a set of permissions (its id
> >> > is 1), and I'd like to put all members who sign up via this
> >> > registration form automatically in this group. My first idea was to
> >> > override the save() method of the Profile model to do that:
>
> >> > class Profile extends BaseProfile
> >> > {
> >> >        public function save(Doctrine_Connection $conn = null)
> >> >        {
> >> >                $ret = parent::save($conn);
>
> >> >                $relation = new sfGuardUserGroup();
> >> >                $relation->user_id = $this->sf_guard_user_id;
> >> >                $relation->group_id = 1;
> >> >                $relation->save();
>
> >> >                return $ret;
> >> >        }
> >> > }
>
> >> > However, when I try to add a new user through the form I get a SQL
> >> > error:
>
> >> > SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
> >> > '5-1' for key 'PRIMARY'
>
> >> > ... where 5 is the id of the newly created sfGuardUser and 1 is the id
> >> > of the sfGuardGroup I'm trying to add the user to. Of course, I
> >> > checked the database and there are no other sfGuardUserGroup objects
> >> > with th

[symfony-users] Re: sfDoctrineGuard groups/permissions/credentials problem

2009-05-25 Thread Campezzi

Worth pointing out that for this test I obviously did NOT unset the
groups_list widget on the registration form...

On May 25, 6:21 pm, Campezzi  wrote:
> Did a few more tests and found indication that the problem might
> actually not be in the plugin, but on the sample registration form I
> used as a base - the one from this tutorial:
>
> http://www.symfony-project.org/blog/2008/12/03/call-the-expert-simple...
>
> My guess is that the problem is here:
>
>     if ($this->form->isValid())
>     {
>       $this->form->save();
>
>       $this->getUser()->signIn($this->form->getObject());
>       $this->redirect('@homepage');
>     }
>
> As you can see, the signIn method is called with the form object as
> the parameter. The form object, in this case, is the sfGuardUser
> object. Now, in the plugin file sfGuardSecurityUser.class.php, the
> signIn method has this call:
>
>     $this->addCredentials($user->getAllPermissionNames());
>
> Finally, on to getAllPermissionNames():
>
>   public function getAllPermissionNames()
>   {
>     return $this->getGuardUser() ? 
> $this->getGuardUser()->getAllPermissionNames() : array();
>
>   }
>
> So here's my guess: to do the automatic sign-in after registration, we
> passed an sfGuardUser object as the first parameter. When signIn tried
> running getAllPermissionNames(), the $this->getGuardUser() test
> returned FALSE, since we're ALREADY "in" the guard user object. And so
> we get an empty - array()
>
> Now, if I log out completely and use a log in form to log a previously
> created works, I get the permissions as expected.
>
> Did I completely miss the point here or does that make sense?
>
> If this is indeed the issue, would be nice if that tutorial got a
> correction ;)
>
> Thanks again :)
>
> On May 25, 5:05 pm, Campezzi  wrote:
>
> > Hi there,
>
> > I've been messing with sfDoctrineGuardPlugin for the last few days (as
> > you can notice from my posts in this period) and I'm running into a
> > strange problem.
>
> > - It is my understanding that a user "inherits" permissions from his
> > groups.
> > - It is also my understanding that during the signIn() method,
> > sfDoctrineGuard adds credentials for all permissions my user has so
> > that I can do a simple $sf_user->hasCredential('permission_name')
> > check on my templates.
>
> > However, when I add a user on my previously created "moderators" group
> > and run a hasCredential('delete_message') check on my user, it returns
> > false (delete_message is, of course, a permission that is set in the
> > moderators group).
>
> > The weird thing is that if I print $sf_user->getAllPermissionNames() ,
> > I get an array with all permissions inherited from the moderators
> > group, including the one I want. BUT $sf_user->listCredentials()
> > returns an empty set. Odd.
>
> > Any ideas?
--~--~-~--~~~---~--~~
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: sfDoctrineGuard groups/permissions/credentials problem

2009-05-25 Thread Campezzi

Did a few more tests and found indication that the problem might
actually not be in the plugin, but on the sample registration form I
used as a base - the one from this tutorial:

http://www.symfony-project.org/blog/2008/12/03/call-the-expert-simple-registration-with-sfdoctrineguardplugin

My guess is that the problem is here:

if ($this->form->isValid())
{
  $this->form->save();

  $this->getUser()->signIn($this->form->getObject());
  $this->redirect('@homepage');
}

As you can see, the signIn method is called with the form object as
the parameter. The form object, in this case, is the sfGuardUser
object. Now, in the plugin file sfGuardSecurityUser.class.php, the
signIn method has this call:

$this->addCredentials($user->getAllPermissionNames());

Finally, on to getAllPermissionNames():

  public function getAllPermissionNames()
  {
return $this->getGuardUser() ? $this->getGuardUser()-
>getAllPermissionNames() : array();
  }

So here's my guess: to do the automatic sign-in after registration, we
passed an sfGuardUser object as the first parameter. When signIn tried
running getAllPermissionNames(), the $this->getGuardUser() test
returned FALSE, since we're ALREADY "in" the guard user object. And so
we get an empty - array()

Now, if I log out completely and use a log in form to log a previously
created works, I get the permissions as expected.

Did I completely miss the point here or does that make sense?

If this is indeed the issue, would be nice if that tutorial got a
correction ;)

Thanks again :)



On May 25, 5:05 pm, Campezzi  wrote:
> Hi there,
>
> I've been messing with sfDoctrineGuardPlugin for the last few days (as
> you can notice from my posts in this period) and I'm running into a
> strange problem.
>
> - It is my understanding that a user "inherits" permissions from his
> groups.
> - It is also my understanding that during the signIn() method,
> sfDoctrineGuard adds credentials for all permissions my user has so
> that I can do a simple $sf_user->hasCredential('permission_name')
> check on my templates.
>
> However, when I add a user on my previously created "moderators" group
> and run a hasCredential('delete_message') check on my user, it returns
> false (delete_message is, of course, a permission that is set in the
> moderators group).
>
> The weird thing is that if I print $sf_user->getAllPermissionNames() ,
> I get an array with all permissions inherited from the moderators
> group, including the one I want. BUT $sf_user->listCredentials()
> returns an empty set. Odd.
>
> Any ideas?
--~--~-~--~~~---~--~~
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: sfDoctrineGuardPlugin: automatically add new user to a group

2009-05-25 Thread Campezzi

Hi Fabien,

Thanks for the answer. Since the group was supposed to be added
automatically, I had the groups_list widget unset in my form. The
function you pointed me to seems to take what was stored in that
variable and link the values to the user being registered. I assume I
can get this working by making the groups_list field a hidden one and
setting the default value on the action or even on the form code
itself - then the code line you pointed out would do ther rest.
However, I'm unsure about how safe this is - couldn't an user
deliberately change the value of my hidden groups_list field in an
attempt to be added to another group, one with a different permission
set?

Best Regards,
Campezzi


On May 25, 12:53 pm, "FlyLM [ML]"  wrote:
> Hi,
>
> If you have always sfDoctrineGuardPlugin installed, take a look at
> this file line 84 (savegroupsList method)
>
> /lib/form/doctrine/sfDoctrineGuardPlugin/base/BasesGuardUserForm.class.php
>
> => $this->object->link('groups', array_values($link));
>
> Fabien
>
> 2009/5/25 Campezzi :
>
>
>
> > Hi there!
>
> > I'm getting started with sfDoctrineGuardPlugin and after doing a few
> > tutorials, I started to implement it in one of my projects. I have
> > created a registration form and embedded the Profile class form. So
> > far, so good - whenever a new user registers, both the sfGuardUser and
> > Profile objects get saved to the database and are correctly
> > associated.
>
> > Now, I have a "users" sfGuardGroup with a set of permissions (its id
> > is 1), and I'd like to put all members who sign up via this
> > registration form automatically in this group. My first idea was to
> > override the save() method of the Profile model to do that:
>
> > class Profile extends BaseProfile
> > {
> >        public function save(Doctrine_Connection $conn = null)
> >        {
> >                $ret = parent::save($conn);
>
> >                $relation = new sfGuardUserGroup();
> >                $relation->user_id = $this->sf_guard_user_id;
> >                $relation->group_id = 1;
> >                $relation->save();
>
> >                return $ret;
> >        }
> > }
>
> > However, when I try to add a new user through the form I get a SQL
> > error:
>
> > SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
> > '5-1' for key 'PRIMARY'
>
> > ... where 5 is the id of the newly created sfGuardUser and 1 is the id
> > of the sfGuardGroup I'm trying to add the user to. Of course, I
> > checked the database and there are no other sfGuardUserGroup objects
> > with the 5-1 key combination, hence it's not a duplicate record thing.
>
> > I tried searching around, but found nothing about this error other
> > than a few complaints about the save() method not being called on
> > objects saved through embedded forms. It seems that is the issue here
> > - I'm trying to create a many-to-many relation, but the user is not
> > yet saved to the database when I try saving the relation, so the
> > database throws an error because I'm adding a reference to an object
> > that does not exist. However, if that is really the problem, isn't it
> > weird that my profile actually has its sf_guard_user_id property set?!
>
> > So, the 64.5 million dollar question: how do I get this to act like I
> > expect it to do? :)
--~--~-~--~~~---~--~~
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] sfDoctrineGuard groups/permissions/credentials problem

2009-05-25 Thread Campezzi

Hi there,

I've been messing with sfDoctrineGuardPlugin for the last few days (as
you can notice from my posts in this period) and I'm running into a
strange problem.

- It is my understanding that a user "inherits" permissions from his
groups.
- It is also my understanding that during the signIn() method,
sfDoctrineGuard adds credentials for all permissions my user has so
that I can do a simple $sf_user->hasCredential('permission_name')
check on my templates.

However, when I add a user on my previously created "moderators" group
and run a hasCredential('delete_message') check on my user, it returns
false (delete_message is, of course, a permission that is set in the
moderators group).

The weird thing is that if I print $sf_user->getAllPermissionNames() ,
I get an array with all permissions inherited from the moderators
group, including the one I want. BUT $sf_user->listCredentials()
returns an empty set. Odd.

Any ideas?
--~--~-~--~~~---~--~~
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] sfDoctrineGuardPlugin: automatically add new user to a group

2009-05-25 Thread Campezzi

Hi there!

I'm getting started with sfDoctrineGuardPlugin and after doing a few
tutorials, I started to implement it in one of my projects. I have
created a registration form and embedded the Profile class form. So
far, so good - whenever a new user registers, both the sfGuardUser and
Profile objects get saved to the database and are correctly
associated.

Now, I have a "users" sfGuardGroup with a set of permissions (its id
is 1), and I'd like to put all members who sign up via this
registration form automatically in this group. My first idea was to
override the save() method of the Profile model to do that:

class Profile extends BaseProfile
{
public function save(Doctrine_Connection $conn = null)
{
$ret = parent::save($conn);

$relation = new sfGuardUserGroup();
$relation->user_id = $this->sf_guard_user_id;
$relation->group_id = 1;
$relation->save();

return $ret;
}
}

However, when I try to add a new user through the form I get a SQL
error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
'5-1' for key 'PRIMARY'

... where 5 is the id of the newly created sfGuardUser and 1 is the id
of the sfGuardGroup I'm trying to add the user to. Of course, I
checked the database and there are no other sfGuardUserGroup objects
with the 5-1 key combination, hence it's not a duplicate record thing.

I tried searching around, but found nothing about this error other
than a few complaints about the save() method not being called on
objects saved through embedded forms. It seems that is the issue here
- I'm trying to create a many-to-many relation, but the user is not
yet saved to the database when I try saving the relation, so the
database throws an error because I'm adding a reference to an object
that does not exist. However, if that is really the problem, isn't it
weird that my profile actually has its sf_guard_user_id property set?!

So, the 64.5 million dollar question: how do I get this to act like I
expect it to do? :)
--~--~-~--~~~---~--~~
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] sfDoctrineGuardPlugin: linking Groups to other model

2009-05-20 Thread Campezzi

Hello everyone,

I recently started implementing sfDoctrineGuardPlugin on the intranet
of the company I work for. Currently, their database of employees is
separated in two main models: Department and Employee. A Department
has many Positions and a Position has many employees.

When implementing sfDoctrineGuard, I linked the sfGuardUser model to
the Employee model (so the Employee model is the "profile" class for
sfGuardUser), and that is fine.

Now, I wanted to link the Department model to the sfGuardGroup model.
In other words, I'd like each Department to have a default set of
permissions (set in a related sfGuardGroup) so that every Employee in
that Department shares the same permissions on the site.

Is there a way to do that? IMO, the best would be to create a 1:1
relationship between a Department and a sfGuardGroup. When creating an
Employee, I could then find the sfGuardGroup related to the Department
he's being added to and setting it to his sfGuardUser.

Did I make sense? :)

Thanks
Campezzi
--~--~-~--~~~---~--~~
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: Best Practice for sfDoctrineGuardPlugin - how to tie other tables with user-related content?

2009-05-20 Thread Campezzi

Interesting you should ask that, because I was just about to do the
same thing ;) However, when I tried linking another model to
sfGuardUser (a 1:n relationship, like "a user has many posts"), I got
a doctrine error when building the models (don't remember the wording
exactly, but the syntax error occurred exactly when adding the foreign
key to the table). I assumed the problem is that doctrine tries to
make a "reciprocal" relation between the models, thus attempting to
change the sfGuardUser model. Since it was just a simple test
application, I worked around the problem by relating the Post model to
the Profile model... but since it seems the best practice is to link
things directly to sfGuarUser, I'll probably run into this problem in
a real-life situation soon.

Did anyone experience the same situation? And if so, how could it be
"fixed" so I don't have to link all my stuff to the Profile class? :)

Thanks and kind regards,
Campezzi


On May 19, 9:01 pm, "David Ashwood" 
wrote:
> Use sfGuard as the root for all that need to reference the user.
> The profile is just one of them.  Keep it simple, keep it dry :)
>
> -Original Message-
> From: symfony-users@googlegroups.com [mailto:symfony-us...@googlegroups.com]
>
> On Behalf Of halla
> Sent: 20 May 2009 01:41
> To: symfony users
> Subject: [symfony-users] Re: Best Practice for sfDoctrineGuardPlugin - how
> to tie other tables with user-related content?
>
> Hi David,
>
> I'm afraid your answer won't help me.
>
> > Checkout:http://www.symfony-project.org/plugins/sfDoctrineApplyPlugin
> > It's a profile plugin that's extendable with instructions on how to hook
> > itto sfDoctrineGuardPlugin
>
> This plugin demonstrate on how to extend a Guard-User with Profile
> Fields, using 1:1-related Table. This is what I also desribe in my
> posting (and what's also described in the Guard-Manual as well).
>
> What I want to know, is how OTHER tables have to be related to the
> User? Do I tie them directly to the Original sfGuardUser-Table using a
> 1:m relationship or do I tie them 1:m to my Profile-Table, which is
> tied again 1:1 to the sfGuardUser? (both described in my example)
>
> Hope, my problem is understandable so far... :-)
>
> Daniel
--~--~-~--~~~---~--~~
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: is it possible to change database without loosing any data ?

2009-05-14 Thread Campezzi

This is an interesting thread - I had been looking at migrations from
a distance for some time now, and this discussion got me to start
reading and experimenting with it. Thanks for the useful information,
everyone :)

Now... I have been taking a look at the Doctrine 1.1 Migrations
documentation here...

http://www.doctrine-project.org/documentation/manual/1_1/en/migrations

... and I see the last point on the page is the "Diff tool". Now this
seems really interesting to me - a tool that compares YAML schemas and
creates migrations automatically? Yes please! Is there a symfony task
that can trigger this? Otherwise I should be able to just call the
Doctrine::generateMigrationsFromDiff(...) method from somewhere else
in my code...

Thanks again for the great info!

Best Regards,
Thiago Campezzi




On May 14, 8:34 am, Jason  wrote:
> When learning about sf doctrine migrations I found this page to be the
> most 
> informative:http://www.doctrine-project.org/documentation/cookbook/1_0/en/symfony...
>
> On May 13, 2:45 am, dziobacz  wrote:
>
> > OK - I know :)))
> > If we have files: 001_file1.class.php and 002_file2.class.php
> > symfony doctrine:migrate 002 - migrate from 001 version
> > (001_file1.class.php) to 002 version (002_file2.class.php)
> > symfony doctrine:migrate 000 - migrate from 002 version -> 001 version
> > -> 000 version (database at the beginning, not file)
> > symfony doctrine:migrate 001 - migrate to 001 version
>
> > WONDERFUL !! xD
>
> > On 13 Maj, 08:27, dziobacz  wrote:
>
> > > You have written: 'Each class essentially represents a version of your
> > > database and the up() and down() methods allow you to walk backwards
> > > and forwards between versions of your database.' - so I can return in
> > > symfony to previous version database ? May I know how ? :)
>
> > > On 12 Maj, 22:55, Jonathan Wage  wrote:
>
> > > > Not at the same level of Doctrine.
>
> > > > - Jon
>
> > > > On Tue, May 12, 2009 at 3:47 PM, Craig  wrote:
>
> > > > > Hi,
>
> > > > > Is there something similar for migrating database schemas in Propel?
>
> > > > > Cheers
> > > > > Craig
>
> > > > > On May 13, 5:17 am, dziobacz  wrote:
> > > > > > WoW !! Thx so much !!
>
> > > > > > I have one more question - If I have for example 100. files (I don't
> > > > > > have but I am interested) migration class - can I choose file to
> > > > > > migration, for example: 090_something.class.php ?
>
> > > > > > So the solution for other people is:
> > > > > > In \lib\migration\doctrine create new file - the name isn't 
> > > > > > important
> > > > > > but the name must begin number, for example: 001_, 002_, 003 ...
> > > > > > for example: 001_something.class.php, in this file write (the name 
> > > > > > of
> > > > > > class isn't important):
> > > > > > class Cheese extends Doctrine_Migration
> > > > > > {
> > > > > >         public function up()
> > > > > >         {
> > > > > >                 $this->addColumn('table_name', 'new_column_name',
> > > > > 'string', array
> > > > > > ('length' => '255'));
> > > > > >         }
>
> > > > > >         public function down()
> > > > > >         {
>
> > > > > >         }
>
> > > > > > }
>
> > > > > > And then write: symfony doctrine:migrate - and we have new column :)
>
> > > > > > On 12 Maj, 18:51, Jonathan Wage  wrote:
>
> > > > > > > bootstrap.php is something you would have seen earlier in the
> > > > > documentation.
> > > > > > > The examples in the Doctrine documentation are for use outside of
> > > > > symfony.
> > > > > > > You can simply place your migration class in 
> > > > > > > lib/migrations/doctrine
> > > > > and
> > > > > > > then run the command ./symfony doctrine:migrate
>
> > > > > > > - Jon
>
> > > > > > > On Tue, May 12, 2009 at 11:49 AM, dziobacz 
> > > > > > > 
> > > > > wrote:
>
> > > > > > > > my migrate.php file:
> > > > > > > > require_once('bootstrap.

[symfony-users] Re: About method "sfWidgetFormPropelChoice"

2009-05-06 Thread Campezzi

Hahaha, yes, your solution works, but you really should dive into the
API (and even peek on the sf source code itself) since there are many
little useful methods and bits of code that are not present in any
tutorials, but that will ultimately save the day. Anyways, glad you
got your stuff working.

See ya!
Campezzi

On May 6, 12:30 pm, Stephen  wrote:
> I think I need read through the sfForm API
> lol
>
> On May 7, 1:14 am, Campezzi  wrote:
>
> > Hi Stephen,
>
> > In your action code, when you're creating the form so that it's
> > available on the view, you can do so with two parameters. The first
> > one is an object used to populate the fields with default data; the
> > second one is an array of variables you're passing from the action to
> > the form object itself. So...
>
> > $this->form = new FormClassName(array(), array('user_id' => $this-
>
> > >getUser()->getId());
>
> > ... would give you a form with no populated fields (the first
> > parameter is an empty array), with a variable called user_id passed to
> > the FormClassName object. You can then access the user_id variable on
> > the form class by using the getOption method of the sfForm class:
>
> > $this->getOption('user_id')
>
> > Mix this with a custom method for getting the form field choices and I
> > guess you have a solution there!
>
> > Hope to have helped. Good luck! :)
>
> > Thiago Campezzi
>
> > On May 6, 11:45 am, Stephen  wrote:
>
> > > Thanks, but how can I pass a value to the method?
>
> > > On Apr 20, 7:13 am, Joan Teixidó  wrote:
>
> > > > hi,
>
> > > > you can create an instance of sfWidgetFormPropelChoice with the opcion
> > > > peer_method:
>
> > > > form['addres] = new  sfWidgetFormPropelChoice(array('model' =>
> > > > 'myModel'',peer_method' => 'myMethod'))
>
> > > > Joan
> > > > 2009/4/19 Stephen 
>
> > > > > A form generated by symfony, there is a field "address". I don't want
> > > > > it lists all the addresses in the dropdown list, but only the ones
> > > > > associated with the user who is browsing this page, user has a user
> > > > > ID. Could any one tell me how to implement this?
--~--~-~--~~~---~--~~
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: About method "sfWidgetFormPropelChoice"

2009-05-06 Thread Campezzi

Hi Stephen,

In your action code, when you're creating the form so that it's
available on the view, you can do so with two parameters. The first
one is an object used to populate the fields with default data; the
second one is an array of variables you're passing from the action to
the form object itself. So...

$this->form = new FormClassName(array(), array('user_id' => $this-
>getUser()->getId());

... would give you a form with no populated fields (the first
parameter is an empty array), with a variable called user_id passed to
the FormClassName object. You can then access the user_id variable on
the form class by using the getOption method of the sfForm class:

$this->getOption('user_id')

Mix this with a custom method for getting the form field choices and I
guess you have a solution there!

Hope to have helped. Good luck! :)

Thiago Campezzi


On May 6, 11:45 am, Stephen  wrote:
> Thanks, but how can I pass a value to the method?
>
> On Apr 20, 7:13 am, Joan Teixidó  wrote:
>
> > hi,
>
> > you can create an instance of sfWidgetFormPropelChoice with the opcion
> > peer_method:
>
> > form['addres] = new  sfWidgetFormPropelChoice(array('model' =>
> > 'myModel'',peer_method' => 'myMethod'))
>
> > Joan
> > 2009/4/19 Stephen 
>
> > > A form generated by symfony, there is a field "address". I don't want
> > > it lists all the addresses in the dropdown list, but only the ones
> > > associated with the user who is browsing this page, user has a user
> > > ID. Could any one tell me how to implement this?
--~--~-~--~~~---~--~~
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: we are going to convert a site from Propel to Doctrine. What are the pain points?

2009-04-28 Thread Campezzi

Doctrine is different from Propel in several things - some big (like
the schema.yml file format, for example) and some small (like subtle
changes in the way Doctrine form fields work when compared to Propel).
If your project is big, you have a lot of work coming your way. If you
have encapsulated everything perfectly in the MVC model, you'll mostly
have to worry about rewriting your Model codes and your Form codes
(assuming you're using the 1.2 branch, where forms are isolated in
their own classes). This by itself should be a lot of work, depending
on the size of your project.

However, I'd say your biggest pain would be to go through your
Controller layer (your actions) and check if there are any Propel-
specific calls there. In the best case scenario, you won't have any
direct database queries in your Controller, but you'll still have to
update method calls to "Peer" classes since Doctrine uses a different
syntax for its "Table" classes. Worst case scenario, you'll have
direct database queries in your Controllers, and then you'll have not
only to "translate" the calls to the Doctrine syntax but also probably
to refactor some code in order to put everything on its proper MVC
layer.

IMO checking the actions is the worst part, since projects usually
have several modules and countless actions - checking and updating one-
by-one is really, really boring and error-prone.

Good luck!

Best Regards,
Thiago Campezzi



On Apr 25, 3:44 pm, Lawrence Krubner  wrote:
> We are going to convert a site from using Propel to using Doctrine.
> Have others done this? Can you suggest what the pain points are?
>
> I haven't looked, but I assume the Doctrine interface is different and
> therefore we need to crawl through our code changing a lot of method
> calls.
--~--~-~--~~~---~--~~
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: Accessing doctrine route object in layout.php

2009-04-10 Thread Campezzi

Hey Tom!

I understand what you're trying to do now! I'm not sure if there's a
way to do that, but I'll run some tests and let you know the results.

Meanwhile, an alternate solution would be to consider using partials
and/or components on your layout.php file. That way, you'll be able to
update parts of the layout which are "outside" the view area (on the
decoration part). That might also be a more elegant design choice,
thinking on the MVC pattern and on the code/design separation talks :)

Take a look at the chapter "Inside the View Layer >> Code Fragments"
on the symfony book, you might get some ideas from there!




On Apr 9, 5:19 pm, "Tom Haskins-Vaughan" 
wrote:
> Thanks Thiago.
>
> Essentially my problem is that I need access to the property object in 
> layout.php.
>
> I am using the doctine route class:
>
> property:
>    url:     /:id/:action
>    class:   sfDoctrineRoute
>    options: { model: Property, type: object }
>    param:   { module: property }
>    requirements:
>      id: \d+
>      sf_method: [get]
>
> And I have no trouble accessing the property object from the routing and I 
> can use this in actions and templates. However, I cannot pass this object to 
> the layout.
>
> In the layout I need to know the property_id, property_name, etc but I have 
> no idea how to access them. I think you used to be able to in sf1.0.
>
> I thought about using a component, but I couldn't access the property object 
> from the route in a component either.
>
> I'm sure there must be something simple that I'm over looking, but I can't 
> put my finger on it.
>
> Anyone?
>
> Cheers,
>
> Tom
>
> - Start Original Message -
> Sent: Thu, 9 Apr 2009 08:00:55 -0700 (PDT)
> From: Campezzi 
> To: symfony users 
> Subject: [symfony-users] Re: Accessing doctrine route object in layout.php
>
>
>
>
>
> > Hi Tom,
>
> > I believe you can get access to the routing from the layout by using
> > the $sf_context variable. $sf_context->getRouting() should return a
> > sfRouting object (http://www.symfony-project.org/api/1_2/sfRouting).
> > You can then use the getRoutes() method of this object in order to get
> > access to a collection of sfRoute objects (http://www.symfony-
> > project.org/api/1_2/sfRoute). I haven't tested this, but in theory it
> > should give you access to what you want :)
>
> > However, I'm not too sure if this is a good practice. Depending on
> > what you want to achieve, it would be best to simply set different
> > routing rules. For example, for the photos section you would have a
> > routing rule like this:
>
> > photos:
> >   url: /:id/photos.htm
> >   param: { module: property, action: photos }
>
> > then on the actions for this module you can use the ID passed by the
> > user to do whatever:
>
> >   public function executePhotos(sfWebRequest $request)
> >   {
> >    $this->image = $request->getParameter('id') .'.png';
> >   }
>
> > and then obviously you could use this variable on the view:
>
> > 
>
> > Hope to have helped!
>
> > Best Regards,
>
> > Thiago Campezzi
>
> > On Apr 9, 12:09 am, Tom Haskins-Vaughan 
> > wrote:
> > > Hi,
>
> > > I have a website where the people are given a url from some off-line
> > > source. e.g.
>
> > > example.com/22
>
> > > I'm using the doctrine routing object for my routes.
>
> > > 22 is the id of a property and needs to be included in the routing in
> > > order to see other parts of the property:
>
> > > example.com/22/photos.htm
> > > example.com/22/town-info.htm
> > > example.com/22/view-property.htm
>
> > > So in layout.php I'd like to have access to the route object, but I
> > > don't see a way of accessing the route object in the layout. Is there a 
> > > way?
>
> > > Thanks in advance.
>
> > > Tom
>
> - End Original Message -
--~--~-~--~~~---~--~~
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: Accessing doctrine route object in layout.php

2009-04-09 Thread Campezzi

Hi Tom,

I believe you can get access to the routing from the layout by using
the $sf_context variable. $sf_context->getRouting() should return a
sfRouting object (http://www.symfony-project.org/api/1_2/sfRouting).
You can then use the getRoutes() method of this object in order to get
access to a collection of sfRoute objects (http://www.symfony-
project.org/api/1_2/sfRoute). I haven't tested this, but in theory it
should give you access to what you want :)

However, I'm not too sure if this is a good practice. Depending on
what you want to achieve, it would be best to simply set different
routing rules. For example, for the photos section you would have a
routing rule like this:

photos:
  url: /:id/photos.htm
  param: { module: property, action: photos }


then on the actions for this module you can use the ID passed by the
user to do whatever:

  public function executePhotos(sfWebRequest $request)
  {
$this->image = $request->getParameter('id') .'.png';
  }


and then obviously you could use this variable on the view:




Hope to have helped!

Best Regards,

Thiago Campezzi





On Apr 9, 12:09 am, Tom Haskins-Vaughan 
wrote:
> Hi,
>
> I have a website where the people are given a url from some off-line
> source. e.g.
>
> example.com/22
>
> I'm using the doctrine routing object for my routes.
>
> 22 is the id of a property and needs to be included in the routing in
> order to see other parts of the property:
>
> example.com/22/photos.htm
> example.com/22/town-info.htm
> example.com/22/view-property.htm
>
> So in layout.php I'd like to have access to the route object, but I
> don't see a way of accessing the route object in the layout. Is there a way?
>
> Thanks in advance.
>
> Tom
--~--~-~--~~~---~--~~
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: Upload file name

2009-04-01 Thread Campezzi

Glad I could help! Rock on :)


On Mar 31, 12:04 pm, HAUSa
 wrote:
> Campezzi, thanks a lot! This indeed works! I did the Jobeet tutorial,
> but oviously I read over it.
>
>         public function generateFileFilename(){
>                 return 'testnow.pdf';
>         }
>
> My file has a neat testnow.pdf file name on upload.
>
> On 31 mrt, 15:05, Campezzi  wrote:
>
> > I didn't test this, but I remember seeing something like that in the
> > Jobeet tutorial:
>
> > "If a generateLogoFilename() method exists in the model, it will be
> > called by the validator and the result will override the default
> > generated logo  filename. The method is given the sfValidatedFile
> > object as an argument."
>
> > More info here:http://www.symfony-project.org/jobeet/1_2/Doctrine/en/10
>
> > Let me know if that worked! :)
>
> > Cheers
>
> > On Mar 30, 6:51 am, HAUSa 
> > wrote:
>
> > > When I upload a file using sfWidgetFormInputFile() and sfValidatorFile
> > > (), it gets some sort of MD5 / SHA1 filename. For example,
> > > cf95672e445d03249959d832441ff5095b6b6d12.docx.
>
> > > Is it possible to keep the original file name, eventually slugified?
>
> > > Example:
> > > Upload: our marketing plan.docx
> > > File: our-marketing-plan.docx
--~--~-~--~~~---~--~~
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: how to use generator.yml

2009-04-01 Thread Campezzi

As everyone else said, generator.yml is a configuration file that is
only valid to configure modules created with the doctrine:generate-
admin [applicationName] [modelName] command (or its Propel
counterpart). That being said, you can invoke generate-admin to create
configurable admins in any application - frontend, backend, whatever
you wish.

If your site is simple enough that basic CRUD operations are enough to
satisfy your requirements, it's entirely possible to create it only
using generated admins. Just be sure to add some sort of
authentication and access controls (for obvious reasons) and you're
golden.

If you need more info about how to customize your generator.yml file,
I highly recommend Day 12 of the Jobeet tutorial - it's really
broad ;)
http://www.symfony-project.org/jobeet/1_2/Doctrine/en/12

Regards,

Thiago



On Mar 31, 6:37 am, sachin jain  wrote:
> how  to use generator.yml  in frontend
--~--~-~--~~~---~--~~
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: Upload file name

2009-03-31 Thread Campezzi

I didn't test this, but I remember seeing something like that in the
Jobeet tutorial:

"If a generateLogoFilename() method exists in the model, it will be
called by the validator and the result will override the default
generated logo  filename. The method is given the sfValidatedFile
object as an argument."

More info here:
http://www.symfony-project.org/jobeet/1_2/Doctrine/en/10

Let me know if that worked! :)

Cheers

On Mar 30, 6:51 am, HAUSa 
wrote:
> When I upload a file using sfWidgetFormInputFile() and sfValidatorFile
> (), it gets some sort of MD5 / SHA1 filename. For example,
> cf95672e445d03249959d832441ff5095b6b6d12.docx.
>
> Is it possible to keep the original file name, eventually slugified?
>
> Example:
> Upload: our marketing plan.docx
> File: our-marketing-plan.docx
--~--~-~--~~~---~--~~
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: Unchecked check boxes (Apologies for the double post.)

2009-03-31 Thread Campezzi

>From what I could gather, the problem is that this is a dynamic form,
where the user can add new fields on the fly. When the form is
submitted, the script doesn't know exactly how many checkboxes exist
(because the user could have created 2, 3, 10, or 50 of them). That's
why Mark can't use $request->hasParameter - it can both mean that the
field wasn't checked OR that it never existed in the first place. It
makes a difference :)

I didn't face that problem yet, but it seems that Klemens got a nice
solution there - a custom widget that renders both a checkbox and a
hidden field on the form, hence emulating the workaround mentioned on
the original post.

Cheers :)

On Mar 27, 8:33 am, Mark Smith 
wrote:
> Apologies for the double post. I accidentially hit return  before I
> had finished:
>
> I am reading a dynamic form with a bunch of check boxes on it. It
> would make my task so much easier if the unchecked fields got posted
> with false or null values.
>
> The common workaround for this is a hidden input tag with the same
> name:http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/
>
> But in symfony you can't have 2 form widgets with the same name on the
> schema... So is there a way  to ensure that unchecked check boxes
> still submit a value with symfony?
>
> Thanks for any help.
--~--~-~--~~~---~--~~
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: Propel vs. Doctrine - Pros and Cons

2009-03-24 Thread Campezzi

Hello everyone,

Thanks for the replies. From what I heard, I'd better take a closer
look into Doctrine before "sealing the deal" with Propel. At the
moment, I'm inclined to think that working with Propel is a bit more
intuitive (at least it has been easier for me to understand), but I
have already run into some JOIN quirks. Also, the Behaviors in
Doctrine seem to be especially useful for the project I'm starting
now, which will only use soft deletes - to accomplish that in Propel,
I was overriding the doSelect and doDelete methods in every peer class
- quite a bit of work!

Kind Regards,

Campezzi



On Mar 24, 9:58 am, Campezzi  wrote:
> Hello there,
>
> I've been a PHP developer for some time now, and recently I began
> exploring the world of Symfony. So far, I like what I see, but there's
> one thing that I still haven't quite figured out: in a real-world
> environment, what are the basic advantages and drawbacks of Propel and
> Doctrine?
>
> I think the only way of getting a realistic answer is to ask people
> who are clearly more experienced with real projects using sf than me.
> So, if you feel like it, please share a quick view on what you love
> and hate about Propel and Doctrine! :)
>
> Cheers!
--~--~-~--~~~---~--~~
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] Propel vs. Doctrine - Pros and Cons

2009-03-24 Thread Campezzi

Hello there,

I've been a PHP developer for some time now, and recently I began
exploring the world of Symfony. So far, I like what I see, but there's
one thing that I still haven't quite figured out: in a real-world
environment, what are the basic advantages and drawbacks of Propel and
Doctrine?

I think the only way of getting a realistic answer is to ask people
who are clearly more experienced with real projects using sf than me.
So, if you feel like it, please share a quick view on what you love
and hate about Propel and Doctrine! :)

Cheers!
--~--~-~--~~~---~--~~
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: Missing Javascript Libraries after PEAR installation

2009-03-21 Thread Campezzi

OK, after looking everywhere, I managed to find a solution.

Turns out things changes in 1.2 - the prototype directory is now not
located on the web folder, but inside a plugin. That plugin needs to
be activated on the command line by issuing the following command:

symfony plugin:publish-assets

After doing that, symfony seems to set up special redirection rules
for the plugins used on the proejct, like for example the /
sfProtoculousPlugin directory that my templates kept trying to access.
Then, bingo! Things work like magic :P

So it seems all that is missing is to add that command to the Ajax
Tutorial for 1.2

Thanks for the help :)


On Mar 21, 8:51 pm, Campezzi  wrote:
> Hi again Lee, thanks for answering :)
>
> Indeed, installing v1.1 gave me the folder I was missing. Maybe there
> is something wrong with the 1.2.4 package after all... I wonder how
> that could be informed to the folks that take care of the project?
>
> Kind Regards,
> Campezzi
>
> On Mar 21, 8:28 pm, Lee Bolding  wrote:
>
> > Hmm... you're missing a directory data/symfony/web/sf/prototype, which  
> > contains :
>
> > css/input_auto_complete_tag.css
> > and
> > js/builder.js          
> > js/dragdrop.js          
> > js/index.html          
> > js/scriptaculous.js    
> > js/sound.js
> > js/controls.js          
> > js/effects.js
> > js/prototype.js        
> > js/slider.js            
> > js/unittest.js
>
> > I wouldn't be surprised if you've also got other files missing...
>
> > I guess it could be a bad path or directory separator in the PEAR  
> > package.
>
> > I'm out of ideas, other than suggesting you try installing 1.1 and see  
> > if that works - if it does, it eliminates your platform and points the  
> > finger at the package you've been trying to install.
>
> > On 21 Mar 2009, at 23:07, Campezzi wrote:
>
> > > Hi Lee,
>
> > > Thanks for your answer. I checked my cli php.ini settings and they
> > > seemed to be fine - just in case, I uninstalled symfony and installed
> > > again, and still got the same issues (even though the installation
> > > returns an OK message). I'm going to try VirtualBox, but I don't think
> > > it will work - I downloaded the symfony source from symfony-
> > > project.org and, browsing the files, I see that the file structure
> > > there looks just like my installation does.
>
> > > Any other ideas?
>
> > > Thanks again,
>
> > > Campezzi
>
> > > On Mar 21, 7:30 pm, Lee Bolding  wrote:
> > >> Possibly your the php.ini for cli didn't have high enough
> > >> memory_limit. This makes the PEAR installer bail halfway through
> > >> installation - I guess those are the kind of symptoms you'd get,
> > >> missing file cos they weren't copied before the installation bailed.
>
> > >> Try uninstalling (via PEAR), changing your cli memory_limit to 128M
> > >> and then reinstalling via PEAR.
>
> > >> Windows is a bitch to develop on. I'd recommend you build yourself a
> > >> Linux VM with VirtualBox (it's free) and save yourself a world of
> > >> pain :)
>
> > >> On 21 Mar 2009, at 20:59, Campezzi wrote:
>
> > >>> Hi there,
>
> > >>> I recently installed symfony on my test server at home (Windows box
> > >>> running WAMP) using PEAR. The installation went well, and everything
> > >>> seemed to be working. However, when I tried running the Ajax  
> > >>> tutorial,
> > >>> I noticed it wasn't working for a simple reason - the necessary
> > >>> libraries were not being included.
>
> > >>> At first I thought it was a simple httpd.conf problem, but when I
> > >>> checked my data folder, I noticed there were no JS files there.  
> > >>> All I
> > >>> have is:
>
> > >>> data/symfony/web/sf/calendar
> > >>> data/symfony/web/sf/sf_admin
> > >>> data/symfony/web/sf/sf_default
> > >>> data/symfony/web/sf/sf_web_debug
>
> > >>> I could download script.aculo.us (which comes with prototype  
> > >>> bundled),
> > >>> but I don't know where exactly the JS files should go.
>
> > >>> So my question is twofold:
>
> > >>> 1. why would the PEAR installation not install the JS libraries on  
> > >>> the
> > >>> data folder by default? that's odd.
> > >>> 2. if the solution is to actually download the libraries, where  
> > >>> should
> > >>> I drop them exactly in my symfony data folder? I know I'll use  
> > >>> them in
> > >>> other projects, so it would be better to have a "permanent" solution
> > >>> on this one...
>
> > >>> Thanks for your time and patience!
--~--~-~--~~~---~--~~
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: Missing Javascript Libraries after PEAR installation

2009-03-21 Thread Campezzi

Hi again Lee, thanks for answering :)

Indeed, installing v1.1 gave me the folder I was missing. Maybe there
is something wrong with the 1.2.4 package after all... I wonder how
that could be informed to the folks that take care of the project?

Kind Regards,
Campezzi



On Mar 21, 8:28 pm, Lee Bolding  wrote:
> Hmm... you're missing a directory data/symfony/web/sf/prototype, which  
> contains :
>
> css/input_auto_complete_tag.css
> and
> js/builder.js          
> js/dragdrop.js          
> js/index.html          
> js/scriptaculous.js    
> js/sound.js
> js/controls.js          
> js/effects.js
> js/prototype.js        
> js/slider.js            
> js/unittest.js
>
> I wouldn't be surprised if you've also got other files missing...
>
> I guess it could be a bad path or directory separator in the PEAR  
> package.
>
> I'm out of ideas, other than suggesting you try installing 1.1 and see  
> if that works - if it does, it eliminates your platform and points the  
> finger at the package you've been trying to install.
>
> On 21 Mar 2009, at 23:07, Campezzi wrote:
>
>
>
> > Hi Lee,
>
> > Thanks for your answer. I checked my cli php.ini settings and they
> > seemed to be fine - just in case, I uninstalled symfony and installed
> > again, and still got the same issues (even though the installation
> > returns an OK message). I'm going to try VirtualBox, but I don't think
> > it will work - I downloaded the symfony source from symfony-
> > project.org and, browsing the files, I see that the file structure
> > there looks just like my installation does.
>
> > Any other ideas?
>
> > Thanks again,
>
> > Campezzi
>
> > On Mar 21, 7:30 pm, Lee Bolding  wrote:
> >> Possibly your the php.ini for cli didn't have high enough
> >> memory_limit. This makes the PEAR installer bail halfway through
> >> installation - I guess those are the kind of symptoms you'd get,
> >> missing file cos they weren't copied before the installation bailed.
>
> >> Try uninstalling (via PEAR), changing your cli memory_limit to 128M
> >> and then reinstalling via PEAR.
>
> >> Windows is a bitch to develop on. I'd recommend you build yourself a
> >> Linux VM with VirtualBox (it's free) and save yourself a world of
> >> pain :)
>
> >> On 21 Mar 2009, at 20:59, Campezzi wrote:
>
> >>> Hi there,
>
> >>> I recently installed symfony on my test server at home (Windows box
> >>> running WAMP) using PEAR. The installation went well, and everything
> >>> seemed to be working. However, when I tried running the Ajax  
> >>> tutorial,
> >>> I noticed it wasn't working for a simple reason - the necessary
> >>> libraries were not being included.
>
> >>> At first I thought it was a simple httpd.conf problem, but when I
> >>> checked my data folder, I noticed there were no JS files there.  
> >>> All I
> >>> have is:
>
> >>> data/symfony/web/sf/calendar
> >>> data/symfony/web/sf/sf_admin
> >>> data/symfony/web/sf/sf_default
> >>> data/symfony/web/sf/sf_web_debug
>
> >>> I could download script.aculo.us (which comes with prototype  
> >>> bundled),
> >>> but I don't know where exactly the JS files should go.
>
> >>> So my question is twofold:
>
> >>> 1. why would the PEAR installation not install the JS libraries on  
> >>> the
> >>> data folder by default? that's odd.
> >>> 2. if the solution is to actually download the libraries, where  
> >>> should
> >>> I drop them exactly in my symfony data folder? I know I'll use  
> >>> them in
> >>> other projects, so it would be better to have a "permanent" solution
> >>> on this one...
>
> >>> Thanks for your time and patience!
--~--~-~--~~~---~--~~
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: Missing Javascript Libraries after PEAR installation

2009-03-21 Thread Campezzi

Hi Lee,

Thanks for your answer. I checked my cli php.ini settings and they
seemed to be fine - just in case, I uninstalled symfony and installed
again, and still got the same issues (even though the installation
returns an OK message). I'm going to try VirtualBox, but I don't think
it will work - I downloaded the symfony source from symfony-
project.org and, browsing the files, I see that the file structure
there looks just like my installation does.

Any other ideas?

Thanks again,

Campezzi


On Mar 21, 7:30 pm, Lee Bolding  wrote:
> Possibly your the php.ini for cli didn't have high enough  
> memory_limit. This makes the PEAR installer bail halfway through  
> installation - I guess those are the kind of symptoms you'd get,  
> missing file cos they weren't copied before the installation bailed.
>
> Try uninstalling (via PEAR), changing your cli memory_limit to 128M  
> and then reinstalling via PEAR.
>
> Windows is a bitch to develop on. I'd recommend you build yourself a  
> Linux VM with VirtualBox (it's free) and save yourself a world of  
> pain :)
>
> On 21 Mar 2009, at 20:59, Campezzi wrote:
>
>
>
> > Hi there,
>
> > I recently installed symfony on my test server at home (Windows box
> > running WAMP) using PEAR. The installation went well, and everything
> > seemed to be working. However, when I tried running the Ajax tutorial,
> > I noticed it wasn't working for a simple reason - the necessary
> > libraries were not being included.
>
> > At first I thought it was a simple httpd.conf problem, but when I
> > checked my data folder, I noticed there were no JS files there. All I
> > have is:
>
> > data/symfony/web/sf/calendar
> > data/symfony/web/sf/sf_admin
> > data/symfony/web/sf/sf_default
> > data/symfony/web/sf/sf_web_debug
>
> > I could download script.aculo.us (which comes with prototype bundled),
> > but I don't know where exactly the JS files should go.
>
> > So my question is twofold:
>
> > 1. why would the PEAR installation not install the JS libraries on the
> > data folder by default? that's odd.
> > 2. if the solution is to actually download the libraries, where should
> > I drop them exactly in my symfony data folder? I know I'll use them in
> > other projects, so it would be better to have a "permanent" solution
> > on this one...
>
> > Thanks for your time and patience!
--~--~-~--~~~---~--~~
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: Missing Javascript Libraries after PEAR installation

2009-03-21 Thread Campezzi

Hi Sid,

I mean the Ajax Tutorial on the symfony home page -
http://www.symfony-project.org/tutorial/1_2/symfony-ajax

And as you can guess from that URL, I'm using symfony v1.2.

cheers!


On Mar 21, 6:57 pm, Sid Bachtiar  wrote:
> Hi,
>
> I'm most likely can't help you here since I have never used
> Script.aculo.us with Symfony. But out of curiosity, which Ajax
> tutorial?
>
> Also, what Symfony version are you using?
>
>
>
> On Sun, Mar 22, 2009 at 9:59 AM, Campezzi  wrote:
>
> > Hi there,
>
> > I recently installed symfony on my test server at home (Windows box
> > running WAMP) using PEAR. The installation went well, and everything
> > seemed to be working. However, when I tried running the Ajax tutorial,
> > I noticed it wasn't working for a simple reason - the necessary
> > libraries were not being included.
>
> > At first I thought it was a simple httpd.conf problem, but when I
> > checked my data folder, I noticed there were no JS files there. All I
> > have is:
>
> > data/symfony/web/sf/calendar
> > data/symfony/web/sf/sf_admin
> > data/symfony/web/sf/sf_default
> > data/symfony/web/sf/sf_web_debug
>
> > I could download script.aculo.us (which comes with prototype bundled),
> > but I don't know where exactly the JS files should go.
>
> > So my question is twofold:
>
> > 1. why would the PEAR installation not install the JS libraries on the
> > data folder by default? that's odd.
> > 2. if the solution is to actually download the libraries, where should
> > I drop them exactly in my symfony data folder? I know I'll use them in
> > other projects, so it would be better to have a "permanent" solution
> > on this one...
>
> > Thanks for your time and patience!
>
> --
> Blue Horn Ltd - System Developmenthttp://bluehorn.co.nz
--~--~-~--~~~---~--~~
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: Missing Javascript Libraries after PEAR installation

2009-03-21 Thread Campezzi

Just did some poking on the HTML code that the Ajax Tutorial was
generating and I saw this:



So I ran a search for that file on my system and I found it in:
C:\wamp\bin\php\php5.2.9-1\PEAR\symfony\plugins\sfProtoculousPlugin\web
\js

However, my PHP data folder is:
C:\wamp\bin\php\php5.2.9-1\data\symfony\web\sf

Now I'm even more confused than I were initially. Help! :)


On Mar 21, 5:59 pm, Campezzi  wrote:
> Hi there,
>
> I recently installed symfony on my test server at home (Windows box
> running WAMP) using PEAR. The installation went well, and everything
> seemed to be working. However, when I tried running the Ajax tutorial,
> I noticed it wasn't working for a simple reason - the necessary
> libraries were not being included.
>
> At first I thought it was a simple httpd.conf problem, but when I
> checked my data folder, I noticed there were no JS files there. All I
> have is:
>
> data/symfony/web/sf/calendar
> data/symfony/web/sf/sf_admin
> data/symfony/web/sf/sf_default
> data/symfony/web/sf/sf_web_debug
>
> I could download script.aculo.us (which comes with prototype bundled),
> but I don't know where exactly the JS files should go.
>
> So my question is twofold:
>
> 1. why would the PEAR installation not install the JS libraries on the
> data folder by default? that's odd.
> 2. if the solution is to actually download the libraries, where should
> I drop them exactly in my symfony data folder? I know I'll use them in
> other projects, so it would be better to have a "permanent" solution
> on this one...
>
> Thanks for your time and patience!
--~--~-~--~~~---~--~~
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] Missing Javascript Libraries after PEAR installation

2009-03-21 Thread Campezzi

Hi there,

I recently installed symfony on my test server at home (Windows box
running WAMP) using PEAR. The installation went well, and everything
seemed to be working. However, when I tried running the Ajax tutorial,
I noticed it wasn't working for a simple reason - the necessary
libraries were not being included.

At first I thought it was a simple httpd.conf problem, but when I
checked my data folder, I noticed there were no JS files there. All I
have is:

data/symfony/web/sf/calendar
data/symfony/web/sf/sf_admin
data/symfony/web/sf/sf_default
data/symfony/web/sf/sf_web_debug

I could download script.aculo.us (which comes with prototype bundled),
but I don't know where exactly the JS files should go.

So my question is twofold:

1. why would the PEAR installation not install the JS libraries on the
data folder by default? that's odd.
2. if the solution is to actually download the libraries, where should
I drop them exactly in my symfony data folder? I know I'll use them in
other projects, so it would be better to have a "permanent" solution
on this one...

Thanks for your time and patience!

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---