This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » User management plugins » sf_guard_user question
sf_guard_user question [message #101282] Mon, 21 June 2010 02:32 Go to next message
ricardojguzman  is currently offline ricardojguzman
Messages: 26
Registered: March 2010
Junior Member
Hello

One of the modules of my application manages the appointments of users. Is there a way to apply sf_guard_user so that when I log to that module as an user, only the appointments related to that user appears?

Thanks.
Re: sf_guard_user question [message #101310 is a reply to message #101282 ] Mon, 21 June 2010 13:04 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
In short, no - since symfony doesn't know what column to filter on, and what value to match on for your logged-in or anonymous users. But as luck would have it, I wrote an article recently about this - it's quite easy. I use symfony 1.0 but the principles still apply, afaik.

As a minimum you need a user profile table, and a way of recalling the user-based value that you wish to filter on. You can then integrate this value into your database calls that retrieve user-connected items, such as appointments.

Let me know how you get on!


Remember Palestine
Re: sf_guard_user question [message #101333 is a reply to message #101310 ] Mon, 21 June 2010 15:57 Go to previous messageGo to next message
ricardojguzman  is currently offline ricardojguzman
Messages: 26
Registered: March 2010
Junior Member
Hello Halfer

Wow that post on your blog is very interesting. I'll give it a check with my partner later.

I found this
http://www.sogeek.info/recuperer-lid-utilisateur-depuis-sfdo ctrineguardplugin.html

But it's giving me an



 500 | Internal Server Error | sfException
Call to undefined method sfPHPView::getUser.
]

EDIT

Hello

I used this in my actions.php

And it worked.

  public function executeIndex(sfWebRequest $request)
  {
      $id=$this->getUser()->getGuardUser()->getId();
    $this->personass = Doctrine::getTable('personas')
       ->createQuery('a')
       ->WHERE('a.usuarioid = ?', $id)
      ->execute();
  }


And that way only the logged user info appears in the page.

[Updated on: Mon, 21 June 2010 16:30]

Re: sf_guard_user question [message #101346 is a reply to message #101282 ] Mon, 21 June 2010 18:57 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Yep, that's pretty much it! It gets more complex if you have several different user types for the same screen, all requiring filtering on different columns, or via different tables that require different joins. But you've got the basis absolutely right.


Remember Palestine
Re: sf_guard_user question [message #101364 is a reply to message #101346 ] Mon, 21 June 2010 22:35 Go to previous message
ricardojguzman  is currently offline ricardojguzman
Messages: 26
Registered: March 2010
Junior Member
A couple of question Halfer

Where can I find reference on the different functions that sf_guard_user and getUser both have?

also

On the sfGuardUser module, is there a way to change the filter options?

and

On a module in the /new form. I want to create my own /new form. How can I do that?

Thank you!

[Updated on: Mon, 21 June 2010 22:37]

Previous Topic:sf_guard_user: Need help on 1005 Can't create table
Next Topic:sfGuardUser inheritance with Doctrine
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software