Permissions is not a part of validate.yml it is inside the generator.yml

Lee Bolding wrote:
>
> Just an idea...
>
>  
>
> This is something I've quickly thrown together, not tested - so it's 
> probably got a few errors in it, but should be relatively simple to fix J
>
>  
>
> Let me know if you get it working J
>
>  
>
> <?php
>
>  
>
> class sfRequiredIfPermissionValidator extends sfValidator
>
> {
>
>  
>
>   public function execute(&$value, &$error)
>
>   {
>
>     $required = $this->getContext()->getRequest()->getParameter(
>
>       $this->getParameterHolder()->get('required'));
>
>      
>
>     $permission = $this->getParameterHolder()->get('permission');
>
>  
>
>     if (!isset($required)) return TRUE; // it has no value, no need to 
> validate
>
>    
>
> if (!($this->getContext()->getUser()->hasPermission($permission) && 
> !empty($required)))
>
>     {
>
>       $error = $this->getParameterHolder()->get('error');
>
>       return FALSE;
>
>     }
>
>  
>
>     return TRUE;
>
>   }
>
>  
>
>   public function initialize($context, $parameters = null)
>
>   {
>
>     // initialize parent
>
>     parent::initialize($context);
>
>  
>
>     // set defaults
>
>     $this->getParameterHolder()->set('error', 'required error');
>
>     $this->getParameterHolder()->add($parameters);
>
>  
>
>     return TRUE;
>
>   }
>
> }
>
>  
>
> *From:* symfony-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] *On Behalf Of *Paul Wiegers
> *Sent:* 02 March 2008 09:25
> *To:* symfony-users@googlegroups.com
> *Subject:* [symfony-users] Re: Credentials for fields and validation
>
>  
>
> On Sun, Mar 2, 2008 at 9:45 AM, Haris Zukanovic' <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
> I think that action is never reached when there are validation errors.
> There may be other places where to insert such a hack :)
>
>
> I think I could end up with a number of hacks that could provide all 
> kinds of workarounds. My real question is: it would look like simple, 
> basic functionality, because fo the nature of symfony you would 
> exepect it to be used for online database systems. Virtualy all of 
> those systems need some kind of rights-management. In most cases this 
> will involve showing fields only to certain users. Then you run in to 
> this problem. Of course, you could create different partials (that 
> would be my first path I'd take), but I would like to know that is 'te 
> real' symfony way of doing this......?
>
> thanks for any insights!
>
> Paul
>
>
> >

-- 
Haris Zukanovic
CEO
Software development and research
International Business Development, SOFTING ltd.
 

office  +387 36 318 339
GSM     +387 61 839 069
 
http://www.eu-softing.com




 
CONFIDENTIALITY NOTICE
This e-mail and any attached files, sent by a company e - mail system, contains 
company confidential and/or privileged information and is intended only for the 
person or entity to which it is addressed and only for the purposes therein set 
forth. If you are not the intended recipient (or have received this e-mail in 
error) please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure, distribution or other use of, or taking of 
any action in reliance upon, the material in this e-mail by persons or entities 
other than the intended recipient is strictly forbidden.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to