Re: Auth/ACL -> using auth->Authorize='crud' and non-standard actions

2009-09-03 Thread delocalizer

Hi;
as long as you're happy to allow 'moveUp' in same group as one of
c,r,u,d, you can use Auth->mapActions to do what you want:
http://book.cakephp.org/view/813/mapActions
Otherwise you will have to use Auth->authorize='actions' and recreate
your acos and aros_acos.


On Sep 3, 1:02 pm, mig_akira  wrote:
> OOOPS!!!
> where I said
> $this->Auth->actionPath = 'controllers/'
>
> I really meant
> auth->Authorize='crud'
>
> sorry for the confusion!!!
>
>
>
> mig_akira wrote:
>
> > Hello everyone.
>
> > I'm using auth and acl in my website, and I'm using the 'crud' way to
> > grant or deny access. Everything is fine, except that I don't know how to
> > grant or deny access to a non-standard action in a controller.
>
> > For example, in my postsController, I have the actions add, read, index,
> > view, etc. All of those are standard, so I just type in the command line:
>
> > cake acl grant Admin Posts '*'  
>
> > And I have access for all those actions, because aros_acos table will be
> > changed accordingly.
>
> > But what if I have an action there called "moveUp", for example? How can I
> > grant or deny access to this action?
>
> > FOr now I'm using
>
> > Function beforeFilter {
> >    $this->Auth->allowedActions = array('moveUp');
> > }
>
> > But this isn't safe, as you can imagine =P
>
> > Thanks guys! I hope I made myself clear, this ACL/Auth stuff is still a
> > bit confusing to me!
>
> --
> View this message in 
> context:http://www.nabble.com/Auth-ACL--%3E-using-actionPath-%3E%27controller...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Radio with WRONG LABEL ID

2009-09-01 Thread delocalizer

You can specify 'id' directly in input method like this:
$form->input('User.SecurityAccess.'.$aco_id, array(
'id'=>"UserSecurityAccess$aco_id",
)
);
But the reason the problem is happening in the first place the syntax
of your input fieldname, with $aco_id at the end... try this instead:
$form->input('User.'.$aco_id.'.SecurityAccess, array(
...)
);


On Sep 2, 6:28 am, ProgDario  wrote:
> You're right brian, two radios for every group, so the two radios
> shown have different ids but another group has the same id.
>
> Any ideas to correct this?
>
> Thanks!!
>
> On 28 Ago, 17:12, brian  wrote:
>
> > I think the problem is not so much the value of the labels' "for"
> > attribute (NOT the id, which it doesn't have) but the id of the radio
> > elements. There are several groups of these, so there are several
> > radio buttons with the same id.
>
> > On Thu, Aug 27, 2009 at 10:25 PM, delocalizer 
> > wrote:
>
> > > Do you mean the name is the same? Because it is supposed to be - both
> > > buttons provide a value to the same field.
> > > What is the symptom of your problem?
>
> > > On Aug 27, 9:19 pm, "lacenaepro...@gmail.com"
> > >  wrote:
> > >> HI,
>
> > >> I can't resolve a strange problem. This is my code:
>
> > >> echo $form->input('User.SecurityAccess.'.$aco_id,
> > >>                   array
> > >>                   (
> > >>                     'div' => false,
> > >>                     'label' => false,
> > >>                     'type' => 'radio',
> > >>                     'legend' => false,
> > >>                     'default' => $selected,
> > >>                     'options' => array('allow' => " {$allow}",
> > >> 'deny' => " {$deny}")
> > >>                   )
> > >>             );
>
> > >> I try to create a set of radio groups, every group has 2 raàdio
> > >> buttons. I want taht every radio group has different id in their
> > >> label, so the user can click directly on the label, BUT CAKE SEEMS TO
> > >> PUT the same id in the code. This is the resulting code:
>
> > >>  > >> id="GroupSecurityAccessAllow" value="allow"  />
> > >>  Allow
>
> > >>  > >> id="GroupSecurityAccessDeny" value="deny" checked="checked"  />
> > >>  Deny
>
> > >> The other pairs of radio buttons has the SAME LABEL ID.
>
> > >> ANY IDEAS?
>
> > >> Tnx!! AS?
>
> > >> Tnx!!- Nascondi testo citato
>
> > - Mostra testo citato -
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: checkboxes with alternative value

2009-08-31 Thread delocalizer

Hi Fabio -
same way you would do for any array - look at the output from this:
foreach (data['Amenity'] as $key => $value){
   echo "key: ".$key."";
   echo "name: ".$value[name]."";
}

On Aug 31, 8:01 pm, fabio <3bi...@gmail.com> wrote:
> Dears delocalizer and DrLoboto,
>
> tnx for your suggestions... i'm working in that way now but i hade
> some difficulties...
>
> Basically I have this portion of the $form array:
>
>             [Amenity] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 6
>                             [name] => Pets
>                             [AmenitiesProperty] => Array
>                                 (
>                                     [id] => 17
>                                     [property_id] => 1
>                                     [amenity_id] => 6
>                                     [specify] => no
>                                 )
>
>                         )
>
>                     [1] => Array
>                         (
>                             [id] => 1
>                             [name] => Type
>                             [AmenitiesProperty] => Array
>                                 (
>                                     [id] => 16
>                                     [property_id] => 1
>                                     [amenity_id] => 1
>                                     [specify] => no
>                                 )
>
>                         )
>
>                     [2] => Array
>                         (
>                             [id] => 2
>                             [name] => Floors
>                             [AmenitiesProperty] => Array
>                                 (
>                                     [id] => 15
>                                     [property_id] => 1
>                                     [amenity_id] => 2
>                                     [specify] => no
>                                 )
>
>                         )
>
>                     [3] => Array
>                         (
>                             [id] => 3
>                             [name] => Last Remodeled
>                             [AmenitiesProperty] => Array
>                                 (
>                                     [id] => 14
>                                     [property_id] => 1
>                                     [amenity_id] => 3
>                                     [specify] => no
>                                 )
>
>                         )
>
>                     [4] => Array
>                         (
>                             [id] => 4
>                             [name] => Constructed
>                             [AmenitiesProperty] => Array
>                                 (
>                                     [id] => 13
>                                     [property_id] => 1
>                                     [amenity_id] => 4
>                                     [specify] => no
>                                 )
>
>                         )
>
>                     [5] => Array
>                         (
>                             [id] => 5
>                             [name] => Smoking
>                             [AmenitiesProperty] => Array
>                                 (
>                                     [id] => 12
>                                     [property_id] => 1
>                                     [amenity_id] => 5
>                                     [specify] => no
>                                 )
>
>                         )
>
>                 )
>
> and i need looping through it and echoing separte elements
> individually...
>
> I know how i can access and echo elements from this array:
>
> ie.
> echo $this->data['Amenity'][0]['name'];
>
> and i think i should use a "for each ... " statement... but how can i
> loop this kind of multidimensional associative array in CakePHP ?
>
> tnx a lot
>
> fabio
>
> On 30 Ago, 06:50, delocalizer  wrote:
>
> > Hi Fabio;
> > Dr Loboto is correct - you'll have to output the elements individually
> > rather than as a group. You can use the form helper to create the
> > individual checkboxes, but getting the text field to display inline
> > nicely may require some tinkering. Or just code the html you

Re: Using belongsTo and hasMany relationships: Is it possible to access tables through a chain of relationships?

2009-08-30 Thread delocalizer

now I understand, you want associated user & animal info for all
specified Userpages...
so as I suggested before, do the find on Userpage model...
but use contain to provide the associated stuff:

$pages = $this->Userpage->find('all',array(
'conditions'=>array(
 'or'=>array(
 'approved'=>1,
 'and'=>array(
 'Userpage.approved' => -1,
 'user_id' => $id
 )
 )
 ),
'contain'=>array(
User=>array(
Animal=>array(
'fields'=>array(
'frontfilename'
 )
)
)
)
))


cheers,
C.

On Aug 31, 10:42 am, Sarah  wrote:
> I would like the results from the query to include all userpages that
> either have an approved value of 1 or belong to the current user
> (whose id is stored in the $id var) and have an approved value of -1.
> Basically I want a list of all userpages that are approved for public
> viewing or that are not approved but belong to the logged in user.  So
> a user can see all of their userpages and only the approved userpages
> of the other users.
>
> I'm sorry that by use of "the user".  I did not mean specifically the
> user stored in $id (which is not a variable used for a loop, but holds
> the user stored in the session), I mean each author of the the
> userpages.  So for each userpage I would like its id, its author's id,
> and its author's frontfilename.
>
> I hope this clarified the relationship between Userpages and Users.
>
> Perhaps it is, sorry.  I am relatively new to both cake and mysql, so
> I'm still trying to figure out and understand the capabilities of
> both.
>
> Again, thanks.  :)
> ~Sarah
>
> On Aug 30, 4:16 pm, delocalizer  wrote:
>
>
>
> > ok... but I'm still not sure exactly what your intent is. When you say
> > you need information on THE user's animal - do you mean there is a
> > particular user that you are trying to get information on, like the
> > current requesting user? $id is a unique value in your method (ie. not
> > a loop iterator or something)? If so, why have find('all') and
> > 'order'=>array('User.id'=>'asc')?  Part of my confusion is that you
> > don't have a well-defined belongsTo relationship between Userpages and
> > Users - which user does a page with approved = 1 belongTo? But if you
> > need only info on the user with 'id'=>$id, set 'conditions' at the
> > User model level as well:
>
> >                  $array = $this->User->find('first', array(
> >                         'conditions'=>array('id'=>$id),
> >                         'fields'=>array('id', 'animal_id'),
> >                          'contain'=>array(
> >                                 'Animal'=>array(
> >                                         'fields'=>array
> > ('frontfilename')
> >                                 ),
> >                                 'Userpage'=>array(
> >                                         'conditions'=>array(
> >                                                 'or'=>array(
>
> > 'approved'=>1,
> >                                                         'and'=>array(
> > 'Userpage.approved' => -1,
> > 'user_id' => $id
> >                                                         )
> >                                                 )
> >                                         ),
> >                                         'order'=>array(
> >                                                 'id'=>'desc')
> >                                         )
> >                                 )
> >                         )
> >                 );
>
> > I think this thread might be straying outside the scope of cakephp
> > into program design details :)
>
> > On Aug 31, 7:14 am, Sarah  wrote:
>
> > > I'm performing this in the Userpages controller.  I was calling find
> > > on Users because I need information on the user's animal.
>
> > > User hasMany Userpages
> > > User belongsTo Animal
> > > The foreign keys are set up appropriately.
>
> > > I need to get a list of all userpages in which: (Userpages.approved =
> >

Re: Using belongsTo and hasMany relationships: Is it possible to access tables through a chain of relationships?

2009-08-30 Thread delocalizer

ok... but I'm still not sure exactly what your intent is. When you say
you need information on THE user's animal - do you mean there is a
particular user that you are trying to get information on, like the
current requesting user? $id is a unique value in your method (ie. not
a loop iterator or something)? If so, why have find('all') and
'order'=>array('User.id'=>'asc')?  Part of my confusion is that you
don't have a well-defined belongsTo relationship between Userpages and
Users - which user does a page with approved = 1 belongTo? But if you
need only info on the user with 'id'=>$id, set 'conditions' at the
User model level as well:

 $array = $this->User->find('first', array(
'conditions'=>array('id'=>$id),
'fields'=>array('id', 'animal_id'),
 'contain'=>array(
'Animal'=>array(
'fields'=>array
('frontfilename')
),
'Userpage'=>array(
'conditions'=>array(
'or'=>array(
 
'approved'=>1,
'and'=>array(
'Userpage.approved' => -1,
'user_id' => $id
)
)
),
'order'=>array(
'id'=>'desc')
)
)
)
);

I think this thread might be straying outside the scope of cakephp
into program design details :)

On Aug 31, 7:14 am, Sarah  wrote:
> I'm performing this in the Userpages controller.  I was calling find
> on Users because I need information on the user's animal.
>
> User hasMany Userpages
> User belongsTo Animal
> The foreign keys are set up appropriately.
>
> I need to get a list of all userpages in which: (Userpages.approved =
> 1) OR (Userpages.approved = -1 AND User.id/user_id = $id)
>
> But I want the following information: the Userpage id, the userpage
> user_id, and the frontfilename from the user's animal.
>
> The concept is similar to a list of comments:
> I want the id and contents of the comment, I want the information on
> the user, including the user's picture (in this case frontfilename
> which is a column in Animal).
>
> I suppose the catch is that more than one user can be the same animal
> (users are in groups).
>
> I've been searching everything that I can think of and searching based
> off what I find.  Do you think the kind of join matters?
>
> I appreciate your following up and your help.
>
> Thank you,
> ~Sarah
>
> On Aug 30, 1:28 am, delocalizer  wrote:
>
>
>
> > Ah I hadn't realised you just wanted Userpages - in which case why not
> > call find on Userpage?
> > If you're in Users controller:
> > $pages = $this->User->Userpage->find('all',array(
> >     'conditions'=>array(
> >          'or'=>array(
> >              'approved'=>1,
> >              'and'=>array(
> >                  'Userpage.approved' => -1,
> >                  'user_id' => $id
> >              )
> >          )
> >      )
> > ))
>
> > On Aug 30, 3:21 pm, Sarah  wrote:
>
> > > Wow, this was very cool.  Thank you for the advice.
>
> > > I realized I had forgotten a condition.  So this is where I am now:
>
> > >                  $array = $this->User->find('all', array(
> > >                         'fields'=>array('id', 'animal_id'),
> > >                         'order'=>array('User.id'=>'asc'),
> > >                         'contain'=>array(
> > >                                 'Animal'=>array(
> > >                                         'fields'=>array
> > > ('frontfilename')
> > >                                 ),
> > >                                 'Userpage'=>array(
> > >                                         &#x

Re: Using belongsTo and hasMany relationships: Is it possible to access tables through a chain of relationships?

2009-08-30 Thread delocalizer

Ah I hadn't realised you just wanted Userpages - in which case why not
call find on Userpage?
If you're in Users controller:
$pages = $this->User->Userpage->find('all',array(
'conditions'=>array(
 'or'=>array(
 'approved'=>1,
 'and'=>array(
 'Userpage.approved' => -1,
 'user_id' => $id
 )
 )
 )
))

On Aug 30, 3:21 pm, Sarah  wrote:
> Wow, this was very cool.  Thank you for the advice.
>
> I realized I had forgotten a condition.  So this is where I am now:
>
>                  $array = $this->User->find('all', array(
>                         'fields'=>array('id', 'animal_id'),
>                         'order'=>array('User.id'=>'asc'),
>                         'contain'=>array(
>                                 'Animal'=>array(
>                                         'fields'=>array
> ('frontfilename')
>                                 ),
>                                 'Userpage'=>array(
>                                         'conditions'=>array(
>                                                 'or'=>array(
>                                                         'approved'=>1,
>                                                         'and'=>array(
>
> 'Userpage.approved' => -1,
>
> 'user_id' => $id
>                                                         )
>                                                 )
>                                         ),
>                                         'order'=>array(
>                                                 'id'=>'desc')
>                                         )
>                                 )
>                         )
>                 );
>
> This does not cause any errors.  :)  However, I'm not quite sure that
> this is what I need.  To my understand based of the reading on
> containable (and the results that I received from the query), this
> query will return all users and only return their userpage information
> if it matches the conditions.  I suppose I could just check each user
> from the query to see if that user had any userpage info returned by
> the query, but I imagine this would slow things down?
>
> I thank you very much for your time and help.  I would appreciate any
> advice you can give.  :)
>
> Thanks,
> ~Sarah
>
> On Aug 29, 1:08 am, delocalizer  wrote:
>
> > Hi Sarah,
> > If you have a reasonably complicated find query with associated models
> > and conditions, the core 'Containable' behaviour is very 
> > handy:http://book.cakephp.org/view/474/Containable
> > so in your AppModel put this (and all your models will have access to
> > the behaviour):
> > var $actsAs = array('Containable');
> > then you would have for your query something like this:
> > $array = $this->User->find('all',array(
> >     'fields'=>array('id','animal_id'),
> >     'order'=>array('id'=>'asc'),
> >     'contain'=>array(
> >          Animal=>array(
> >             fields=>array('frontfilename')
> >          ),
> >          Userpage=>array(
> >             'conditions'=>array(
> >                 'approved' => '1'
> >             ),
> >             'order'=>array(
> >                 'id'=>'desc')
> >          )
> >     )
> > ));
> > Note that conditions, fields and order options are all specified on a
> > per-model basis  - you get back only what you want from each model.
> > Containable is definitely worth the effort to learn.
>
> > cheers,
> > C.
>
> > On Aug 29, 7:40 am, Sarah  wrote:
>
> > > I fixed my syntax,
>
> > > $conditions = array('or' => array( 'Userpage.approved' => 1, 'User.id'
> > > => $id) );
> > > $order = array('User.id ASC', 'Userpage.id DESC');
> > > $array = $this->User->find('all', array('fields'=>array('id',
> > > 'Userpage.id', 'User.animal_id', 'Animal.frontfilename'),
> > > 'conditions'=>$conditions, 'order'=>$or

Re: checkboxes with alternative value

2009-08-29 Thread delocalizer

Hi Fabio;
Dr Loboto is correct - you'll have to output the elements individually
rather than as a group. You can use the form helper to create the
individual checkboxes, but getting the text field to display inline
nicely may require some tinkering. Or just code the html yourself -
that's what I ended up doing recently for a similar scenario with
radio buttons. Form helper is nice but can't be expected to cover
every formatting possibility.
Don't forget to add some javascript that will clear the text field
again if its checkbox is unselected
regards,
C.

On 28 Ago, 19:01, fabio <3bi...@gmail.com> wrote:
> Thanks again Dr.Loboto,
>
> that's what i came up to as well, but it works only for the last
> checkbox of the list (or the first if i used 'before' parameter)...
> what i need is a text field associated for each checkbox of a group of
> checkboxes... don't know if it's possible at this point... :-(
>
> damn ! i think i'll end avoiding the FormHelper and coding it with
> pure html even if like this i'm gonna loose all the benefits of Cake
>
> Anyway thank you again for your tips
>
> fabio
>
> On 28 Ago, 10:16, "Dr. Loboto"  wrote:
>
> > Read 
> > manual.http://book.cakephp.org/view/191/options-before-options-between-optio...
>
> > echo $form->input(
> >     'Amenity',
> >     array(
> >         'type' => 'select',
> >         'multiple' => 'checkbox',
> >         'after' => $form->input(
> >             'User.name',
> >             array('onfocus' => 'CheckCheckBox(this.form)')
> >         )
> >     )
> > );
>
> > On Aug 28, 2:57 pm, fabio <3bi...@gmail.com> wrote:
>
> > > Dear Dr.Loboto, thank you very much for your suggestion... i'm
> > > handling on it but i would first need to know how to set the
> > > FormHelper options to show one text field beside each checkbox...
>
> > > I was thinking about something like  markup injections using
> > > parameters "between[string]" or "after[string]" but i'm not really
> > > sure it make sense...
>
> > > Any additional suggestion ?
>
> > > thanks a lot, really appreciate
>
> > > fabio
>
> > > On 28 Ago, 07:59, "Dr. Loboto"  wrote:
>
> > > > echo $form->input('User.name', array('onfocus' => 'CheckCheckBox
> > > > (this.form)'));
>
> > > > On Aug 27, 9:18 pm, fabio <3bi...@gmail.com> wrote:
>
> > > > > Dear all,
>
> > > > > i'm a CakePHP newbie and i'm looking for some help regarding a
> > > > > particular use of checkboxes in a form.
>
> > > > > Basically i've got a check-boxes-section in the form of a baked
> > > > > edit.ctp, called with a basic
>
> > > > > echo $form->input('Amenity', array( 'type' => 'select', 'multiple' =>
> > > > > 'checkbox' ));
>
> > > > > The models refers to a join table with an additional field 'specify':
>
> > > > > CREATE TABLE IF NOT EXISTS `amenities_properties` (
> > > > >   `id` int(11) unsigned NOT NULL auto_increment,
> > > > >   `property_id` int(11) NOT NULL,
> > > > >   `amenity_id` int(11) NOT NULL,
> > > > >   `specify` varchar(100) NOT NULL default 'yes',
> > > > >   PRIMARY KEY  (`id`)
> > > > > );
>
> > > > > The idea is to set values like this:
>
> > > > > 'no' if unchecked
> > > > > 'yes' ..if checked
> > > > > 'whatever'... if checked and a string 'whatever' is inserted
>
> > > > > In other words I need to associate to each checkboxes an additional
> > > > > input text field to be eventually filled only if the checkboxes are
> > > > > previously checked
>
> > > > > I've found what it seems a perfect solution for this, but now I need
> > > > > some help to implement it in CakePHP terms.
>
> > > > > Here it is:
>
> > > > > http://www.w3.org/
> > > > > TR/html4/strict.dtd">
> > > > > 
> > > > >         
> > > > >                 
> > > > >                 Test Checkbox
> > > > >                 
> > > > >                         function CheckCheckBox(frm)
> > > > >                         {
> > > > >                         if (!frm.CheckThis.checked)
> > > > >                         frm.CheckThis.focus()
> > > > >                         }
> > > > >                 
> > > > >         
> > > > >         
> > > > >          
> > > > >                 
> > > > >                 To insert your name check the box.
> > > > >                 
> > > > >                 Name:
> > > > >                  > > > > onfocus="CheckCheckBox
> > > > > (this.form)">
> > > > >      
> > > > >         
> > > > > 
>
> > > > > (see it in action here:http://www.html.it/articoli/1756/esempio.html
> > > > > )
>
> > > > > How you can see, the javascript function allows the user to input an
> > > > > alternative value to yes/no only if the checkbox is previously checked
>
> > > > > So the point is:
> > > > > how to get done this behaviour togheter with CakePHP default Form
> > > > > Helper ?
> > > > > Do you think it's possible somehow or another approach would be better
> > > > > to achieve the same result ?
>
> > > > > Thanks a lot in advance for some suggestions
>
> > > > > Best regards
>
> > > > > 

Re: Using belongsTo and hasMany relationships: Is it possible to access tables through a chain of relationships?

2009-08-29 Thread delocalizer

Hi Sarah,
If you have a reasonably complicated find query with associated models
and conditions, the core 'Containable' behaviour is very handy:
http://book.cakephp.org/view/474/Containable
so in your AppModel put this (and all your models will have access to
the behaviour):
var $actsAs = array('Containable');
then you would have for your query something like this:
$array = $this->User->find('all',array(
'fields'=>array('id','animal_id'),
'order'=>array('id'=>'asc'),
'contain'=>array(
 Animal=>array(
fields=>array('frontfilename')
 ),
 Userpage=>array(
'conditions'=>array(
'approved' => '1'
),
'order'=>array(
'id'=>'desc')
 )
)
));
Note that conditions, fields and order options are all specified on a
per-model basis  - you get back only what you want from each model.
Containable is definitely worth the effort to learn.

cheers,
C.

On Aug 29, 7:40 am, Sarah  wrote:
> I fixed my syntax,
>
> $conditions = array('or' => array( 'Userpage.approved' => 1, 'User.id'
> => $id) );
> $order = array('User.id ASC', 'Userpage.id DESC');
> $array = $this->User->find('all', array('fields'=>array('id',
> 'Userpage.id', 'User.animal_id', 'Animal.frontfilename'),
> 'conditions'=>$conditions, 'order'=>$order));
>
>  but I'm still getting the same errors as before.
>
> I verified that a User has many userpage and that a userpage belongs
> to a user.
> The SELECTing of the Animal picture is not a problem...I don't
> understand why it won't SELECT the userpage information...
>
> My recursive level is set to 1, I tried setting it to 2, but it didn't
> make a difference.
>
> Thanks for your time and help,
> ~Sarah
>
> On Aug 28, 12:23 pm, WebbedIT  wrote:
>
> > Looks like you very nearly had it.  Just got your find syntax slightly
> > wrong, try:
>
> > $array = $this->User->find('all', array(
> >   'fields'=>array('id, 'Userpage.id', 'User.animal_id',
> > 'Animal.frontfilename'),
> >   'conditions'=>$conditions,
> >   'order'=>$order
> > );
>
> > Then go have a look at the cookbook and study the syntax of the find
> > command a bit more.  The first parameter should be the type of call,
> > in this instance 'all'.
>
> > The second parameter needs to be an array with your fields,
> > conditions, order etc.
>
> > Hope this helps
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP for online examination application?

2009-08-28 Thread delocalizer

Hi Vijay;
you could certainly develop something like what you suggest in
cakePHP. But check out limesurvey (http://www.limesurvey.org/) -
probably it could do what you want straight out of the box and save
you a lot of time...

On Aug 28, 3:29 pm, Vijay Pandey  wrote:
> Hi !
>
> I am new to cakephp...I do not know if the question is relevant or
> not..but I prefer asking to experts rather than assuming things...
>
> My question is "IS CAKEPHP APPROPRIATE FOR DEVELOPING A ROBUST
> APPLICATION FOR ABILITY AND PERSONALITY ASSESSMENT?". Below are the
> key features that I am looking for:
>
> 1. Test questions should come in random and progressively difficult
> manner (computer adaptive testing)
> 2. There should be possibility to generate detailed reports (scores
> +comments+guidance for improvement) and multiple reports (e.g. summary
> report, report for interviewer, report for individual etc.) that
> includes texts and graphs.
> 3. There should be a controll pannel to create assessments, assign
> reports and manage everything.
>
> I have used cakephp successfully to develop few small to medium size
> applications like todo list, reporting system, HR Process etc. but do
> not have much knowledge about it.
>
> Please give your comments.
>
> Regards,
>
> Vijay
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using belongsTo and hasMany relationships: Is it possible to access tables through a chain of relationships?

2009-08-27 Thread delocalizer

Hi Sarah;
I'm not sure what you are asking.
User hasmany Userpages, so Userpage array will contain all the
Userpages belonging to User.
$example = $this->User->find('first');
foreach($example['Userpage'] as $key=>$value){
 debug($value['id']);
}


On Aug 28, 9:18 am, Sarah  wrote:
> To clarify, I get the error message:
> Warning (512): SQL Error: 1054: Unknown column 'Userpage.id' in 'field
> list' [CORE/cake/libs/model/datasources/dbo_source.php, line 525]
> When I try to get select the Userpage.id field.
>
> On Aug 27, 3:19 pm, delocalizer  wrote:
>
>
>
> > Hi Sarah;
> > If your relationships are set up correctly and you have recursive >
> > -1, the usual 'find' method on User model should be returning the
> > parent 'Animal' anyway - what do you see if you put this in one of
> > your user controller functions:
> > $example = $this->User->find('first');
> > debug($example);
> > ?
>
> > On Aug 28, 6:01 am, Sarah  wrote:
>
> > > This is my setup:
>
> > > A 'user' hasMany 'userpage's.
> > > A 'user' belongsTo an 'animal'.
>
> > > I would like to be able to display user information as well as some
> > > information about the user's animal on a userpage view.
>
> > > I perform a find query to get the userpage id, user_id, animal_id.
>
> > > Is there a way to search for Animal information as well?
> > > This won't work because of the last field, but this is conceptually
> > > what I want:
>
> > > 'fields'=>array('user_id', 'id', 'User.animal_id',
> > > 'User.Animal.frontfilename')
>
> > > Thanks in advance!
> > > ~Sarah
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Radio with WRONG LABEL ID

2009-08-27 Thread delocalizer

Do you mean the name is the same? Because it is supposed to be - both
buttons provide a value to the same field.
What is the symptom of your problem?

On Aug 27, 9:19 pm, "lacenaepro...@gmail.com"
 wrote:
> HI,
>
> I can't resolve a strange problem. This is my code:
>
> echo $form->input('User.SecurityAccess.'.$aco_id,
>                   array
>                   (
>                     'div' => false,
>                     'label' => false,
>                     'type' => 'radio',
>                     'legend' => false,
>                     'default' => $selected,
>                     'options' => array('allow' => " {$allow}",
> 'deny' => " {$deny}")
>                   )
>             );
>
> I try to create a set of radio groups, every group has 2 raàdio
> buttons. I want taht every radio group has different id in their
> label, so the user can click directly on the label, BUT CAKE SEEMS TO
> PUT the same id in the code. This is the resulting code:
>
>  id="GroupSecurityAccessAllow" value="allow"  />
>  Allow
>
>  id="GroupSecurityAccessDeny" value="deny" checked="checked"  />
>  Deny
>
> The other pairs of radio buttons has the SAME LABEL ID.
>
> ANY IDEAS?
>
> Tnx!!AS?
>
> Tnx!!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using belongsTo and hasMany relationships: Is it possible to access tables through a chain of relationships?

2009-08-27 Thread delocalizer

Hi Sarah;
If your relationships are set up correctly and you have recursive >
-1, the usual 'find' method on User model should be returning the
parent 'Animal' anyway - what do you see if you put this in one of
your user controller functions:
$example = $this->User->find('first');
debug($example);
?

On Aug 28, 6:01 am, Sarah  wrote:
> This is my setup:
>
> A 'user' hasMany 'userpage's.
> A 'user' belongsTo an 'animal'.
>
> I would like to be able to display user information as well as some
> information about the user's animal on a userpage view.
>
> I perform a find query to get the userpage id, user_id, animal_id.
>
> Is there a way to search for Animal information as well?
> This won't work because of the last field, but this is conceptually
> what I want:
>
> 'fields'=>array('user_id', 'id', 'User.animal_id',
> 'User.Animal.frontfilename')
>
> Thanks in advance!
> ~Sarah
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: ACL bug when Auth::authorize = 'actions'? 1.2.4.8284

2009-08-26 Thread delocalizer

Hi hb,
I don't know if this will reassure you or frustrate you - but it's not
a bug in db_acl. Acl with Auth->authorize = 'actions' works nicely for
me for a long time, including in 1.2.4.8284. May I ask, in your
AppController::beforeFilter, to what you have set the Auth-
>actionPath?

regards,
C.

On Aug 26, 8:03 pm, housebolt  wrote:
> Hi All,
>
> Currently using version 1.2.4.8284
>
> I spent a good half-day trying to get the Auth and Acl components to
> play nicely with the Auth::authorize var equal to 'actions' and a
> single root ACO node of 'controllers', accessible by the ARO that is
> connected to a Group model, which has many users (see the ACL tutorial
> in the cakephp cookbook).
>
> I checked and quadruple checked my aros/acos/aros_acos tables to make
> sure everything was properly connected with a very basic setup, but I
> was still get an error saying the ACL node could not be found, so I
> set about 20 break points and systematically narrowed it down to a
> section in the AclNode class.
>
> I think I've narrowed it down to a problem with the way the
> AclNode::node() method handles the controller action info that is
> passed to it from the Auth component. There's a section in /cake/libs/
> model/db_acl.php lines 127-133
>
> // $result is the ACO that the AclNode has attempted to find, it
> returns an array with all of the current ACO row
> // info
>
> if (!isset($result[0][$type]) ||
>     // Here is where the problem is, the $path is an array of the
> current controller and action
>     // This next line tries to compare the ACO 'alias' field to the
> current controller action in $path, but if the
>     // ACO is at root, like 'controllers' in the cookbook tutorial,
> the ACO alias is equal to 'controllers', and not a
>     // controller action, say, 'index'. However the following line is
> looking for a controller action and fails the node
>     // check
>     (!empty($path) && $result[0][$type]['alias'] != $path[count($path)
> - 1]) ||
>     (empty($path) && $result[0][$type]['alias'] != $start)
> ) {
>   return false;
>
> }
>
> I'd be interested to see if anyone else has run into this problem. I
> basically commented out the bad line (line 129) and then it worked.
>
> Yes, I'm being lazy right now because I got a little frustrated trying
> to figure thing out and now I want to sleep, the real fix will come
> once I get some rest. I just wanted to make sure I'm not crazy, if
> anyone else wants to verify it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: FormHelper Select

2009-08-25 Thread delocalizer

Hi Sarah;
If you declare in your user model file:
var $displayField = 'username';
then find('list') returns an array with keys of id's and values of
usernames...
and then if you have in your view:
$form->input('user_id',$users);
cake automatically generates a  select-type input field for user_id
from your list of $users, with labels being usernames and values as
ids. So the value of user_id is assigned automatically to an id - no
need for another query.

cheers,
C.



On Aug 26, 9:13 am, Sarah  wrote:
> I have an add form for "userpages".  Each user hasMany userpages.
>
> I want a list of the usernames to be in the select list, but I want
> the foreign key user_id to be stored in the userpages table.
>
> The hasMany relationship is already set up.
>
> In my controller I have:
>
> $users = $this->Userpage->User->find('list');
>
> $this->set(compact('users'));
>
> Then in my view:
>
> $form-select('User.username', $users);
>
> but a select  box with the user_id's is displayed instead.
>
> How can I get the list of usernames to be displayed, and once I have
> the usernames in the select do I get the selected username and then
> make a query for that user's id and store that as the user_id?
>
> I appreciate all advice.
>
> Thanks,
> ~Sarah
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Edit function not working properly it always returns ID=(1)

2009-08-25 Thread delocalizer

oops, bit quick to post there...
because if it's tinyint(1) in MySQL, then cake understands that as
boolean
(see, for example 
http://teknoid.wordpress.com/2008/10/06/cakephp-mysql-tinyint1-confusion/)

On Aug 25, 9:31 pm, delocalizer  wrote:
> Hi Vijay;
> What datatype is status_id in your database?
>
> On Aug 25, 2:12 pm, Vijay Pandey  wrote:
>
> > Hi,
>
> > Thanks for response
>
> > Status model has relationship with two tables "projects" and "tasks".
> > both relationships are one two many (one status can have many projects
> > and tasks)
>
> > here is status model (I have followed cake convention)
>
> > class Status extends AppModel {
>
> >         var $name = 'Status';
>
> >         //The Associations below have been created with all possible keys,
> > those that are not needed can be removed
> >         var $hasMany = array(
> >                 'Project' => array(
> >                         'className' => 'Project',
> >                         'foreignKey' => 'status_id',
> >                         'dependent' => false,
> >                         'conditions' => '',
> >                         'fields' => '',
> >                         'order' => '',
> >                         'limit' => '',
> >                         'offset' => '',
> >                         'exclusive' => '',
> >                         'finderQuery' => '',
> >                         'counterQuery' => ''
> >                 ),
> >                 'Task' => array(
> >                         'className' => 'Task',
> >                         'foreignKey' => 'status_id',
> >                         'dependent' => false,
> >                         'conditions' => '',
> >                         'fields' => '',
> >                         'order' => '',
> >                         'limit' => '',
> >                         'offset' => '',
> >                         'exclusive' => '',
> >                         'finderQuery' => '',
> >                         'counterQuery' => ''
> >                 )
> >         );
>
> > }
>
> > Yes, the tables have conventional structure...
>
> > Strangly, the problem is only with stauses table..(I can not modify
> > anything in status table...even when I edit projects, I can not change
> > their status with always shows as 1 =not started.
>
> > I am not very familiar with CakePHP...please help..
>
> > Regards,
>
> > Vijay
>
> > On Aug 24, 9:07 pm, DavidH  wrote:
>
> > > I guess there's some relationship between Tasks Projects and Statuses
> > > because the SQL you're reproduced here shows what's being selected
> > > from the related models not from the statuses model. Does anything get
> > > selected from statuses at all?
>
> > > What does your statuses model look like?
>
> > > Do the underlying tables have conventional structures, I.e. id for the
> > > primary key and table_id for the foreign keys?
>
> > > David
>
> > > On Aug 24, 3:56 pm, Vijay Pandey  wrote:
>
> > > > Hi !
>
> > > > I have a little problem with edit function...I have developed a small
> > > > application to manage projects. Every project has a status...there are
> > > > totoal 5 statuses..I want to change the name of 5th status but I can
> > > > not do it...no matter which "status" I select to "edit" it always
> > > > displays status 1 for editing...
>
> > > > Here is the url
>
> > > > localhost/myapp/statuses/edit/4
>
> > > > and here is what it did:
>
> > > > SELECT `Project`.`id`, `Project`.`name`, `Project`.`description`,
> > > > `Project`.`status_id`, `Project`.`created`, `Project`.`modified` FROM
> > > > `projects` AS `Project` WHERE `Project`.`status_id` = (1)
>
> > > > SELECT `Task`.`id`, `Task`.`project_id`, `Task`.`name`,
> > > > `Task`.`description`, `Task`.`status_id`, `Task`.`created`,
> > > > `Task`.`modifie

Re: Edit function not working properly it always returns ID=(1)

2009-08-25 Thread delocalizer

Hi Vijay;
What datatype is status_id in your database?

On Aug 25, 2:12 pm, Vijay Pandey  wrote:
> Hi,
>
> Thanks for response
>
> Status model has relationship with two tables "projects" and "tasks".
> both relationships are one two many (one status can have many projects
> and tasks)
>
> here is status model (I have followed cake convention)
>
> class Status extends AppModel {
>
>         var $name = 'Status';
>
>         //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>         var $hasMany = array(
>                 'Project' => array(
>                         'className' => 'Project',
>                         'foreignKey' => 'status_id',
>                         'dependent' => false,
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => '',
>                         'limit' => '',
>                         'offset' => '',
>                         'exclusive' => '',
>                         'finderQuery' => '',
>                         'counterQuery' => ''
>                 ),
>                 'Task' => array(
>                         'className' => 'Task',
>                         'foreignKey' => 'status_id',
>                         'dependent' => false,
>                         'conditions' => '',
>                         'fields' => '',
>                         'order' => '',
>                         'limit' => '',
>                         'offset' => '',
>                         'exclusive' => '',
>                         'finderQuery' => '',
>                         'counterQuery' => ''
>                 )
>         );
>
> }
>
> Yes, the tables have conventional structure...
>
> Strangly, the problem is only with stauses table..(I can not modify
> anything in status table...even when I edit projects, I can not change
> their status with always shows as 1 =not started.
>
> I am not very familiar with CakePHP...please help..
>
> Regards,
>
> Vijay
>
> On Aug 24, 9:07 pm, DavidH  wrote:
>
> > I guess there's some relationship between Tasks Projects and Statuses
> > because the SQL you're reproduced here shows what's being selected
> > from the related models not from the statuses model. Does anything get
> > selected from statuses at all?
>
> > What does your statuses model look like?
>
> > Do the underlying tables have conventional structures, I.e. id for the
> > primary key and table_id for the foreign keys?
>
> > David
>
> > On Aug 24, 3:56 pm, Vijay Pandey  wrote:
>
> > > Hi !
>
> > > I have a little problem with edit function...I have developed a small
> > > application to manage projects. Every project has a status...there are
> > > totoal 5 statuses..I want to change the name of 5th status but I can
> > > not do it...no matter which "status" I select to "edit" it always
> > > displays status 1 for editing...
>
> > > Here is the url
>
> > > localhost/myapp/statuses/edit/4
>
> > > and here is what it did:
>
> > > SELECT `Project`.`id`, `Project`.`name`, `Project`.`description`,
> > > `Project`.`status_id`, `Project`.`created`, `Project`.`modified` FROM
> > > `projects` AS `Project` WHERE `Project`.`status_id` = (1)
>
> > > SELECT `Task`.`id`, `Task`.`project_id`, `Task`.`name`,
> > > `Task`.`description`, `Task`.`status_id`, `Task`.`created`,
> > > `Task`.`modified` FROM `tasks` AS `Task` WHERE `Task`.`status_id` =
> > > (1)
>
> > > (i got this beacuse I have kept debug variable on )
>
> > > What to do? this problem is only with "ststuses" only...all other
> > > edits are working fine...
>
> > > Here are other information
>
> > > statuses_controller.php
>
> > > function edit($id = null) {
> > >                 if (!$id && empty($this->data)) {
> > >                         $this->Session->setFlash(__('Invalid Status', 
> > > true));
> > >                         $this->redirect(array('action'=>'index'));
> > >                 }
> > >                 if (!empty($this->data)) {
> > >                         if ($this->Status->save($this->data)) {
> > >                                 $this->Session->setFlash(__('The Status 
> > > has been saved', true));
> > >                                 $this->redirect(array('action'=>'index'));
> > >                         } else {
> > >                                 $this->Session->setFlash(__('The Status 
> > > could not be saved.
> > > Please, try again.', true));
> > >                         }
> > >                 }
> > >                 if (empty($this->data)) {
> > >                         $this->data = $this->Status->read(null,$id);
> > >                 }
> > >         }
>
> > > edit.ctp    file
>
> > > create('Status');?>
> > >         
> > >                 
> > >          > >                 echo $form->input('id');
> > >                 echo $form->input('name');
> > >         ?>
> > >         
> > > end('Submit');?>
>
> > > default.ctp file
>
> > > 
> > >         
> > >                 
>

Re: Request help with a model definition.

2009-08-25 Thread delocalizer

Hi Gerard,
consider using Tree behaviour for your Comments model?
http://book.cakephp.org/view/91/Tree

On Aug 25, 8:43 pm, gedm  wrote:
> Brian,
>
> Sorry if I wasn't clear.  The problem is the ChildComment User_ID
> doesn't associate with the User Model so I can't get the username
> information for the ChildComments.  I jst don't know how to assicate
> the ChildComment model with the User model.  I'm sure it's very easy I
> just can't get my head around associating with the ChildComment Class
> when it's not actually a table.  I know newbie.
>
> Gerard
>
> On Aug 25, 2:15 am, brian  wrote:
>
> > On Sun, Aug 23, 2009 at 9:23 AM, gedm wrote:
>
> > > Hi,
>
> > > I am very new to Cake and have searched for an answer to this but
> > > can't quite get my head around it enough to ask ask the right
> > > question.
>
> > I'm not sure you asked anything. What's your question?
>
> > The debug array you posted looks ok to me. That is, if $id = 1. Is
> > that the case? Have you reied it with $id = 2? You should see the
> > ParentComment then, and the ChildComment array should be empty.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HABTM not saving

2009-08-25 Thread delocalizer

Hi Bryan;
Try this:
Array
(
 [Channel]=>Array(
 [id] => 16
 )
 [Area]=>Array(
[Area]=>Array(
   [0] => 14
)
)
That format is the automagic way for cake to save habtm.
Can't remember where I saw it documented but my memory is that the
manual is not clear on this.


On Aug 25, 12:15 am, Bryan Paddock  wrote:
> Hey all,
> Ok I'm pulling my hair out here.
>
> HABTM save/edit/removes are not happening.
>
> I have two models. Channel and Area. The model definitions are configured
> properly (channel: *var $hasAndBelongsToMany = array( 'Area' )* and area: *var
> $hasAndBelongsToMany = array( 'Channel' )* )
>
> I have no clue why this is not working because I am not getting any error
> messages back from cake at all.
>
> I am calling validates() before save() and it validates but it does not
> save.
>
> I am trying to save this array
>
> $data =
>
> Array
> (
>     [Channel] => Array
>         (
>             [id] => 16
>         )
>
>     [Area] => Array
>         (
>             [0] => Array
>                 (
>                     [id] => 14
>                 )
>
>         )
>
> )
>
> I have tried saving this too
>
> Array
> (
>     [Channel] => Array
>         (
>             [id] => 16
>         )
>
>     [Area] => Array
>         (
>             [0] => 14
>         )
>
> )
>
> Is there something I am doing incorrectly? When I push debug level up
> to 3 I can see cake is not even trying to do any of the habtm queries.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to save a record but not clear an empty field?

2009-08-23 Thread delocalizer

Yes nice, I hadn't though of that. So you would test for:
if (isset($this->data['User]]['password']) && $this->data['User']
['password'] == Security::hash(Configure::read('Security.salt')))

On Aug 24, 1:27 pm, "Dr. Loboto"  wrote:
> > If you do this you'll have to hash your own password rather than let
> > Auth do it automatically, because Auth will hash a blank password and
> > the 'if' condition will never be true.
>
> If do not touch Auth hashing behavior password field can be checked
> not as "notBlank" but by comparison with hashed empty string.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to save a record but not clear an empty field?

2009-08-23 Thread delocalizer

Hi Gerard;
There would be many ways to do this - one way would be to put some
logic in the User model beforeValidate method that checks if password
field is set in the data but blank, then password field is unset - so
it won't be validated or saved.
eg.
function beforeValidate(){
if (isset($this->data['User']['pwd'] && strlen($this->data['User']
['pwd'])==0)){
unset($this->data['User']['pwd]);
}
return true;
}
If you do this you'll have to hash your own password rather than let
Auth do it automatically, because Auth will hash a blank password and
the 'if' condition will never be true.

On Aug 24, 12:04 am, gedm  wrote:
> I'm wondering how the cakephp bakery site ignores the blank password
> field when a user is updating their profile?
>
> That is, if the password is left blank it updates the other fields in
> the record but does not clear the password when the record is saved.
> How is this done?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Validation alphaNumeric issue.

2009-08-23 Thread delocalizer

You're very welcome. That will work for ASCII characters only of
course. I've never looked into why that library isn't compiled with
Unicode support by default - RHEL releases tend towards the
conservative, but it seems a strange omission to me to ignore the
character sets of most of the world's languages!

On Aug 24, 12:20 am, Tmyclyk Dmytryk  wrote:
> Thank you for the thorough description, I appreciate it - I could have
> sworn I had it working on my other CentOS box without doing anything
> specific, but I may not have, for now I am using
>
> "rule" => array('custom', '/^[a-z0-9]*$/i')
>
> and it works fine, thank you again!
>
> Best Regards,
> Howard
>
> On Aug 23, 6:37 am, delocalizer  wrote:
>
>
>
> > It's nothing to do with php version - the problem is CentOS (or RHEL)
> > - cake's built-in 'alphaNumeric' rule uses unicode matching in its
> > regex, which is not supported by the PCRE library that comes with
> > those flavours of Linux. If you know what you're doing you could try
> > to compile the library with unicode support, but probably the easiest
> > solution is write your own custom validation rule - just copy what is
> > in the cake core & replace the unicode stuff (in the curly braces)
> > with plain old ASCII regex
>
> > cheers,
> > Conrad.
>
> > On Aug 23, 1:09 pm, Howard  Lince  wrote:
>
> > > I am having a problem with alphaNumeric validation on my application,
> > > we redid the server (changed the os from opensuse to centos), and
> > > while alphaNumeric validation worked before, it constantly returns
> > > false now. I was told earlier it's the php 5.1.x so I upgraded to
> > > 5.2.6, which was said to resolve this issue and it's still doing it,
> > > what can I do about this?- Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Validation alphaNumeric issue.

2009-08-23 Thread delocalizer

It's nothing to do with php version - the problem is CentOS (or RHEL)
- cake's built-in 'alphaNumeric' rule uses unicode matching in its
regex, which is not supported by the PCRE library that comes with
those flavours of Linux. If you know what you're doing you could try
to compile the library with unicode support, but probably the easiest
solution is write your own custom validation rule - just copy what is
in the cake core & replace the unicode stuff (in the curly braces)
with plain old ASCII regex

cheers,
Conrad.

On Aug 23, 1:09 pm, Howard  Lince  wrote:
> I am having a problem with alphaNumeric validation on my application,
> we redid the server (changed the os from opensuse to centos), and
> while alphaNumeric validation worked before, it constantly returns
> false now. I was told earlier it's the php 5.1.x so I upgraded to
> 5.2.6, which was said to resolve this issue and it's still doing it,
> what can I do about this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Export to Excel

2009-08-23 Thread delocalizer

Adam Royle's csv helper is very nice for this...
http://bakery.cakephp.org/articles/view/csv-helper-php5

cheers,
Conrad.

On Aug 23, 12:41 am, AMF  wrote:
> I've been looking for a good tutorial/exaple on exporting data to
> excel like format.
>
> Any success/ideas/pinters.
>
> Thanks
>
> AMF
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth doesn't hash password field

2009-08-22 Thread delocalizer

You really need to provide a bit more information...
But If you are satisfied that the data is being saved correctly to
your database and the only symptom is that the password field is not
hashed then the first things you should check are that everything is
set up as in the documentation http://book.cakephp.org/view/172/Authentication:
1) In your user controller (or AppController) you should have the Auth
component declared like this:
var $components = array('Auth');
2) Your user model should be 'User' (db table 'users' by default) and
the password field 'password', unless you have specified them
differently in controller beforeFilter with $this->Auth->userModel =
'customName' and $this->Auth->fields = array
('password'=>'anotherName')

Post the code from your controller & add view?

On Aug 22, 4:59 am, Veoempleo  wrote:
> Hello,
>
> I have a very simple form with username, name and password fields. But
> the Auth component is saving the password field without hashing it.
>
> Why? Thank you in advantage
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: If-else within a foreach cycle

2009-08-21 Thread delocalizer

updateAll is the way to go...
eg. $this->Post->updateAll(array('options'=>value2),array('id <>
'=>'$var));
reducing the number of transactions in this case from n(Posts) to just
2 - one for the matching record and one for all the rest.

On Aug 21, 8:45 pm, brian  wrote:
> Almost, but $value_2 will never be assigned. Perhaps the OP could shed
> some light on the bigger picture as there may be a better way to
> approach this.
>
> On Fri, Aug 21, 2009 at 5:07 AM, rich...@home wrote:
>
> > You don't need the else branch in the 2nd example, its taken care of
> > in the read:
>
> > // fetch back the record with an id of $var
> > $post = $this->Post->read(null, $var);
>
> > // update the record
> > $post['Post']['options'] = value1;
>
> > // save the record
> > $this->Post->save($post);
>
> > In the first example, you fetch back a number of records and loop
> > through them looking for one with an id of $var. It's quite likely
> > that id will be unique (its should be a primary key) so there's no
> > need for the loop.
>
> > On Aug 20, 5:21 pm, albe  wrote:
> >> foreach($posts as $p) {
>
> >>         if ($p['Post']['id'] == $var) {
> >>           $p['Post']['options'] = value1;
> >>         } else {
> >>           $p['Post']['options'] = value 2;
> >>         }
> >>         $this->Post->save($p);
>
> >> }
>
> >> This works! I just can't say how much I am grateful for your help!
> >> However I still don't understand why my code was wrong...
>
> >> About your second way:
>
> >> $post = $this->Post->read(null, $var);
> >> $post['Post']['options'] = value1;
> >> $this->Post->save($post);
>
> >> If I use this, where shall i put the ELSE branch?
>
> >> On 20 Ago, 18:00, "rich...@home"  wrote:
>
> >> > Shouldn't that be:
>
> >> > foreach($posts as $p) {
>
> >> >         if ($p['Post']['id'] == $var) {
> >> >           $p['Post']['options'] = value1;
> >> >         } else {
> >> >           $p['Post']['options'] = value 2;
> >> >         }
> >> >         $this->Post->save($p);
>
> >> > }
>
> >> > also, if you are just matching against the id, you could just write it
> >> > as:
>
> >> > $post = $this->Post->read(null, $var);
> >> > $post['Post']['options'] = value1;
> >> > $this->Post->save($post);
>
> >> > and forget about the loop
>
> >> > On Aug 20, 3:26 pm, AD7six  wrote:
>
> >> > > On 20 ago, 15:39, albe  wrote:
>
> >> > > > I have to make a foreach cycle to check every item of a certain 
> >> > > > group.
> >> > > > For each and every item I've got to check a condition and make a data
> >> > > > modification depending on this condition.
> >> > > > My code is the following:
>
> >> > > > foreach($posts as $p) {
>
> >> > > >         $this->Post->id = $p['Post']['id']; //consider the posts one
> >> > > > by one
>
> >> > > >         if ($this->Post->id == $var) {
> >> > > >           $this->data['Post']['options'] = value1;
> >> > > >         } else {
> >> > > >           $this->data['Post']['options'] = value 2;
> >> > > >         }
>
> >> > > >         $this->Post->save($this->data);
>
> >> > > > }
>
> >> > > > Here is my problem: the modifications are performed correctly for the
> >> > > > IF branch, but NEVER for the else branch.
> >> > > > Do you know why this occurs?
>
> >> > > aliens?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Strange contain/find issue

2009-08-19 Thread delocalizer

I experienced something similar a while ago and logged this -
https://trac.cakephp.org/ticket/6268
Nate's reply was (quite correctly) that I should write a test case to
prove/disprove.
4 months later & I still haven't done it :(
My lazy solution: refactor my code until it went away! (No excuse
really, but I was busy... and I can't even remember now what changes I
made)
@MonkeyGirl: got time to write a tc? Your relationship context looks a
bit simpler than the one I had...


On Aug 18, 10:31 pm, MonkeyGirl  wrote:
> I believe this may be the same issue I'm experiencing.  After a bit of
> investigation, I've found out the issue is that specifying "contain"
> would appear to affect things in subsequent queries.
>
> For example, say I have Cart hasMany CartedProduct belongsTo Product
> belongsTo Brand.  Product also belongsTo VatRate.  (In other words,
> CartedProduct is a linking table between Cart and Product.  It has a
> quantity column, hence I'm not using hABTM.)  I might have a piece of
> code like this, in a method of the Cart model:
>
> // This is fine.  It displays products along with their brand.
> $products = $this->CartedProduct->Product->find('all', array(
>   'contain' => array(
>     'Brand'
>   )
> ));
>
> pr($products);
>
> // This causes issues
> $ignore = $this->find('first', array(
>   'conditions' => array(
>     'Cart.id' => $cartID
>   ),
>   'contain' => array(
>     'CartedProduct.Product.VatRate' => array(
>       'fields' => array(
>         'percentage'
>       )
>     )
>   )
> ));
>
> // This is now broken.  The brand is no longer displayed.
> $products = $this->CartedProduct->Product->find('all', array(
>   'contain' => array(
>     'Brand'
>   )
> ));
>
> pr($products);
>
> There are a few interesting things to note here:
>
> Product is now broken, even though the query that broke it was
> performed on Cart.
>
> If I contain 'CartedProduct.Product.VatRate' then it's fine, but as
> soon as I get as far as specifying its field, in this case
> "percentage", it breaks.  This is regardless of whether I specify
> 'CartedProduct.Product.VatRate.percentage' or use the proper array-
> based method above.
>
> By "breaking", I specifically mean that any subsequent queries
> regarding products will only show data that meet the contain criteria
> above as well as any new contain criteria.
>
> I would expect this from unbindModel() if I was telling it to remember
> the unbinding, but I wouldn't expect it from a contain argument passed
> to find().
>
> I've checked, and yes, Product does still belongTo both Brand and
> VatRate after the query.  A pr() of $this->CartedProduct->Product and
> of $this (the Cart) show that both are identical before and after the
> troublesome query.
>
> Before anyone asks, I'm using CakePHP version 8166.
>
> I've implemented a temporary workaround: because I know I want Brand
> in a subsequent query, I'm including it in the contain in the query
> that breaks the subsequent ones.  However, that's not a viable long-
> term solution as I'm concerned that I may have some other piece of
> code somewhere that thinks it's pulling out important data that it now
> isn't.
>
> Is this a bug?  should I go ahead and report it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: about helper.php

2009-08-15 Thread delocalizer

?
cake/libs/view/helper.php

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Ubdate HABTM and hasMany

2009-08-15 Thread delocalizer

Hi Luke,
Yes the problem is that your data array is not in the right format.
The manual is pretty clear on the hasMany format (for your
ingredients) ... (http://book.cakephp.org/view/75/Saving-Your-Data)
but the format for the habtm model is not so obvious... if you are
attaching multiple subcategories from your view using say a checkbox,
you would set a variable to a list of subcategories in your controller
like: $subcategories=$this->Subcategory->find('list')
and then in your view if you put:
$form->input('Subcategory.Subcategory',array
('type'=>'select','multiple'=>'checkbox')
the data will be returned in the right format for save to
automatically save the lot: something like this:

Array(
Recipe=>Array(...)
Ingredient=>Array(
[0]=>Array('ingredientname'=>'meat'),
[1]=>Array('ingredientname'=>'pepper),
[2]=>...
)
Subcategory=>Array(
Subcategory=>Array(
[0]=>'id1',
[1]=>'id2',

   )
)
)



On Aug 14, 7:39 pm, Luke  wrote:
> Hi,
>
> Sorry that I have to get back again. I am still hanging on this
> issue.
>
> recipe HABTM subcategories
> recipe hasMany ingredients
>
> My $this->data array
>
> Array
> (
>     [Recipe] => Array
>         (
>             [id] => 6
>             [RecipeUIED] =>
>             [recipe_name] => Testname
>          )
>
>     [Ingredient] => Array
>         (
>             [ingredientname] => Array
>                 (
>                     [0] => water
>                     [1] => meat
>                     [2] => salt
>                     [3] => pepper
>                 )
>
>         )
>
>         [Subcategory] => Array
>         (
>             [checkbox] => Array
>                 (
>                     [1] => 1
>                     [2] => 0
>                 )
>
>         )
>
> Is the Array correct formated or what is wrong? saveAll does not want
> to save everything.
> INSERT INTO `ingredients` (`ingredientname`) VALUES (Array)
>
> So, $this->Recipe->saveAll($this->data) does not seem to work. How can
> I save the hasMany and HABTM relationship than?
> I tried to implement Persivo's hint, but was not successfull either.
> Any hint is much appreciate, since I don't seem to move any step.
>
> Thanks a lot in advance. Luke
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: wtf find id=1

2009-08-14 Thread delocalizer

As AD7six says, it's very hard to say anything useful given that you
have just typed in some stuff and not actually pasted any relevant
code, but from what you have above, you do not seem to be following
any helpful naming convention - you've called Position->find and from
the 'SQL' you posted clearly cake thinks that that model is associated
with a table called mgt_positions - which is not convention but fine,
but then what is the field called 'position_id'!? That is convention
for a foreign key to a table called "positions"! Just very confusing.

On Aug 14, 10:22 am, AgBorkowski  wrote:
> $this->Position->find('all',array('conditions' => 'position_id = '.
> $id,'fields'=>'position,position_id') this working fine...
> 9       SELECT `Position`.`position`, `Position`.`position_id` FROM
> `mgt_positions` AS `Position` WHERE position_id = 3
>
> fucking stupid bug
>
> On 14 Sie, 02:18, "andrzejborkow...@gmail.com"
>
>  wrote:
> > fk find(){
> > echo $id; //3
> >                         
> > debug($this->Position->find('all',array('conditions' => array
> > ('position_id'=>$id),'fields'=>'position,position_id')));
>
> > }
>
> > at page
> > miopromo\controllers\signups_controller.php (line 70)
>
> > Array
> > (
> >     [0] => Array
> >         (
> >             [Position] => Array
> >                 (
> >                     [position] => Wlasciciel/Wspolwlasciciel
> >                     [position_id] => 1
> >                 )
>
> >         )
>
> > 9       SELECT `Position`.`position`, `Position`.`position_id` FROM
> > `mgt_positions` AS `Position` WHERE `position_id` = 1
>
> > WTF ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: wtf find id=1

2009-08-14 Thread delocalizer

you're right, it is certainly a bug... but not in cake... for starters
it should be 'fields'=>array('position','position_id')...

On Aug 14, 10:22 am, AgBorkowski  wrote:
> $this->Position->find('all',array('conditions' => 'position_id = '.
> $id,'fields'=>'position,position_id') this working fine...
> 9       SELECT `Position`.`position`, `Position`.`position_id` FROM
> `mgt_positions` AS `Position` WHERE position_id = 3
>
> fucking stupid bug
>
> On 14 Sie, 02:18, "andrzejborkow...@gmail.com"
>
>  wrote:
> > fk find(){
> > echo $id; //3
> >                         
> > debug($this->Position->find('all',array('conditions' => array
> > ('position_id'=>$id),'fields'=>'position,position_id')));
>
> > }
>
> > at page
> > miopromo\controllers\signups_controller.php (line 70)
>
> > Array
> > (
> >     [0] => Array
> >         (
> >             [Position] => Array
> >                 (
> >                     [position] => Wlasciciel/Wspolwlasciciel
> >                     [position_id] => 1
> >                 )
>
> >         )
>
> > 9       SELECT `Position`.`position`, `Position`.`position_id` FROM
> > `mgt_positions` AS `Position` WHERE `position_id` = 1
>
> > WTF ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Unknown top margin in layout

2009-08-13 Thread delocalizer

Hi,
(your link to 'css-code' doesn't show any css so it's hard to tell,
but...)
just looks like some padding in the header div or one of its
children.
Note that the cake.generic.css has the following style:
#header{
padding: 10px 20px;
}
and you have a div with id=header, so unless you've overridden this
somewhere it's no surprise...


On Aug 14, 7:11 am, MASTER-UA  wrote:
> I have spent all this day to find decision of my problem. I couldn't
> (( I ask you for help!
>
> This is my project 
> header:http://picasaweb.google.com/lh/photo/0One86YagXvaYLagEsBlnQ?feat=dire...
>
> This is it's 
> css-codehttp://picasaweb.google.com/lh/photo/WMZwY0ba_OvDzM143LUrqQ?feat=dire...
>
> This is CakePHP 
> result:http://picasaweb.google.com/Masterr.UA/CakePHP#5369555370927441378
>
> This is CakePHP layout 
> code:http://picasaweb.google.com/lh/photo/WMZwY0ba_OvDzM143LUrqQ?feat=dire...
>
> WHERE this margin can be?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: DeleteQuery in HABTM is like 'dependent'=> true in hasMany associations?

2009-08-13 Thread delocalizer

Hi Josoroma;
This nice post: (http://groups.google.com/group/cake-php/msg/
c10840be78a34df0) although it is about finderQuery, will probably help
you a lot. I have to ask though - you sure you want to delete the Tags
themeselves and not just the ArticlesTags associations? What happens
if a Tag is shared between an article being deleted and one that
isn't? Or now that I think about it what you probably want is to
delete Tags that no longer belong to any Articles - in which case you
could also put some logic in your Article model afterDelete that calls
delete on unassociated Tags. Just a thought.

On Aug 13, 3:34 am, Josoroma  wrote:
> Im using the following structure:
>
> User hasMany Listing
> Listing hasMany Contacts
> Listings hasAndBelongsToMany Articles
> Articles hasMany Tags
>
> When i delete a User or a Listing all their associated Listings and
> Articles are successfully deleted. But not their Tags. Listings and
> Articles are deleted because we are using 'dependent'=> true in the
> hasMany Model Structure. But how can i delete the Tags of the Articles
> associated? do i have to use deleteQuery to achieve 
> that?http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM
>
> I was searching in Google and there is not tutorial or post related to
> deleteQuery in HABTM associations.
>
> An example will help us a lot.
>
> Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: AuthComponent - Need more explanation about "$this->Auth->authorize"

2009-08-08 Thread delocalizer

Hi Miguel
Remember that Acl and Auth are quite different things - Acl only
establishes the *rules* for what can control what, Auth does the
actual authentication (permits or denies). Having said that, Auth is
designed to work with Acl, and it can do that in a couple of different
ways - if you set the authorize property to 'actions' (easiest to do
this in your AppController::beforeFilter, so it's set for all your
controllers) then Auth will expect to validate against aros_acos table
where acos are aliases for controllers/actions. You don't need to use
mapActions if you're doing that. The example in the manual (http://
book.cakephp.org/view/641/Simple-Acl-controlled-Application) is
excellent. If you set authorize to 'crud' then it expects that the
acos are database objects.

On Aug 8, 5:05 am, mig_akira  wrote:
> Hello everyone!
>
> I've been trying to make a simple site using Acl/Auth. Everything is going
> fine, except that I don't quite understand the differences between the 4
> kinds of 'authorizes', nor how to implement them.
>
> For example, I don't understand how can I use the AclComponent::check() to
> authenticate the user when using authorize->'actions'. The same with
> authorize->'crud'. Where do I put the mapAction? In appController, or in
> every controller? What does it exactly do?
>
> Sorry, but every blog I found about this say that they don't really know how
> to use those, and the manual is very briefly about this!
>
> Thanks!!!
>
> (By the way, I'm using authorize->'actions' and I keep getting
> [code]
>  DbAcl::check() - Failed ARO/ACO node lookup in permissions check.  Node
> references:
> Aro: Array
> (
>     [User] => Array
>       (
>             [id] => 3
>             [username] => normaluser
>             [name] => miguel
>             [email] => d...@d.com
>             [group_id] => 2
>             [active] => 1
>             [created] => -00-00 00:00:00
>             [modified] => -00-00 00:00:00
>         )
>
> )
> [/code]
> )
>
> --
> View this message in 
> context:http://www.nabble.com/AuthComponent---Need-more-explanation-about-%22...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: do I get it? ACL's purpose

2009-08-07 Thread delocalizer

Hi Mateo;
It's true - getting your head around Acl takes some time, but if I may
say so - you're probably overthinking the problem. My experience was
that it is conceptually simpler than I had imagined, but more
complicated to implement than I hoped... if that makes sense! So I
suggest you actually start coding, because that's the only way you'll
really figure out how it all fits together. Some hints:
* As mentioned in the manual, it's important to realise that there are
two distinct modes that cake's Acl operates: model/foreign key (for
object-level control) OR aliases (eg. if you want to have controllers/
actions as your acos, or some other abstract things that don't
correspond to database objects)
* Other than that though, aros and acos can be whatever you want them
to be! So sure, no problem - users (and/or groups) could be both aros
and acos. The key to it all is how you set up the heirarchy of your
objects - and there is no universal solution to that (precisely
because acl is a generic concept that can be applied to many
situations) - but plenty of prior art available in tutorials etc. At
the end of the day it's not that complicated - it's just 2 trees and a
map between them.
* Lastly, remember Acl is only part of the story - once you've got
your permissions set up, you need to actually enforce them - and if
you've got some custom abstract aliases happening then you'll need to
do that manually in your controllers with Acl->check(), but if you've
used the model/foreign key approach or the typical 'controllers/
actions' aliases you can use Auth component to do all the heavy
lifting - just set the Auth->authorize property to 'crud' or 'actions'
as required.

cheers,
C.

On Aug 6, 6:07 am, Mateo  wrote:
>   After some reading, tinkering, and observing, I think I'm starting
> to understand what Cake's ACL is supposed to do and what it isn't. If
> you can take issue with any point (or part of any point) below, please
> do so and, if you can, give an example as to how it is incorrect. Or,
> if you have helpful additions to the lists below, please don't
> hesitate to make them known.
>
> Cake's ACL is designed to:
> * Create a dynamic (though with some initial setup), logical aro
> structure
> * Determine what aro's can do to a given type of aco (By type, I
> essentially mean class)
> * Abstract these permissions determinations from your code so you can
> simply ask "can 'x' do 'y' to an aco of type 'z' "
>
> Cake's ACL is NOT designed to:
> * Determine what aro's can do to a specific instance of an aco - this
> is to be handled by you in your code
> * Allow aro's act also as aco's (e.g. a user can edit another user's
> info, but not delete the other user)
> * Create a user heirarchy (e.g. this employee 'a' is a supervisor of
> employees 'b', 'c', and 'd' while employee 'e' supervises employees
> 'f' and 'g')
>
> Am I pretty close? Way off? (Most likely, somewhere in between?)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Certain strings crashing CakePHP - where do I look first?

2009-08-07 Thread delocalizer

Hi tt;
How long are these strings? What datatype are you using to store these
strings in the db? b.t.w. the links in your post to the examples don't
appear to go anywhere useful... :(

On Aug 6, 8:23 pm, technicaltitch  wrote:
> Dear all,
>
> Please I'm desperate - if you had a simple CakePHP app, and certain
> strings in any text field caused it to give up without any error and
> display the default homepage, where could you look? I'm not asking for
> possible solutions as I realise this is too obscure for that, but I've
> absolutely no idea what part of the server could possibly have this
> effect. Anything that has anything to do with looking at form strings
> site-wide.
>
> I have removed all my controller code, I have removed the TinyMCE
> controllers and seen the bug in plain text inputs as well as
> textareas, I have tried GET and POST forms, I have tried entering the
> text via phpMyAdmin, or on a non-CakePHP site hosted on the same
> infrastructure and they work fine.
>
> Entering this string into any text field causes the 
> error:http://geocities.com/
> but entering this doesn't:http://geocities.com(ie, without the last
> character). Similarly for the string in Spanish in my original post -
> each sentence on it's own doesn't, but the two together does cause
> this error.
>
> Please ANY tip would be hugely appreciated - my PHP isn't at a level
> where I can trace through the Cake code, I've spent nearly a week on
> this, my next step is to rewrite the CMS in plain PHP which is several
> weeks' unpaid work I've no idea how I'll fit in.
>
> Thanks for any time or help whatsoever,
> Chris
>
> www.intiwarayassi.org
>
> On Aug 1, 4:20 pm, technicaltitch  wrote:
>
> > Dear all,
>
> > Thanks for your time. I've written a simple CakePHP+TinyMCE CMS and
> > I'm having a horrendous time tracking a very strange error. Specific
> > strings in any of the text fields are causing my website to do
> > something that looks like a 404 error.
>
> > These are the strings I have found so far - I can paste these into any
> > of my text fields on the site and it causes a complete failure:
>
> > "http://geocities.com/"; or
>
> > "Los animales silvestres del refugio fueron sacados de los circos, de
> > los mercados y de las jaulas inhumanas, o fueron una vez de mascotas
> > que muchos fueron muy maltratados por el amo. El proyecto consiste en
> > la rehabilitación y la restauracion de nuevas especies para luego ser
> > devueltos a su hábitat natural"
>
> > (and several others I'm painstakingly tracking down). If I remove even
> > just part of the string it works perfectly. The behaviour is 100%
> > predictable once you isolate the string. If I put a space in the
> > middle, or delete the end '/', the problem disappears.
>
> > I have commented out all of my controller code including the save and
> > redirect and I still get the error. It happens whether or not model
> > validation is taking place. I am doing nothing clever - just a simple
> > POST form, 'edit' method and redirect to an index/admin page. I can
> > find no error messages anywhere. Where do I start?
>
> > I'm using CakePHP version 1.1.17.5612 on a standard CPanel-based host.
>
> > Massive thanks for any tips whatsoever, I am completely lost on this,
> > Chris
>
> > The website is herewww.intiwarayassi.org-I'm a professional
> > developer but did this for free
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Form with saving of true/false/null

2009-07-31 Thread delocalizer

As for the coding, just use the form helper's automagic radio input:
eg
input('fieldname',array('type'=>'radio','options'=>
$optarray)); ?>
$optarray is the array of options, eg. array
('0'=>'No','1'=>'Yes','2'=>'No info') for the example you give.

On Jul 31, 8:29 pm, delocalizer  wrote:
> The other way you can approach clearing radio input groups is to add
> some little button or widget next to each group with a javascript
> onClick function that sets the values to empty. At least that's what I
> do. It looks prettier & and a bit more logical than an extra radio
> option.
>
> cheers,
> Conrad.
>
> On Jul 31, 4:13 pm, Kanten  wrote:
>
>
>
> > I have been giving this some thought and I do get what you mean, but
> > it is very important that the user can always change e.g. an "yes"
> > answer into "not info on subject". Database wise I think you are
> > right, that I should define three different values (no = 0, yes = 1,
> > no info = 2) instead of using no info = Null.
>
> > Thank you very much for your help.
>
> > /Anders
>
> > On Jul 30, 9:41 am, delocalizer  wrote:
>
> > > You sure you want an explicit third option 'no information on the
> > > subject'? Wouldn't it be better to just have a radio group with 2
> > > buttons (Yes/No or True/False) with a default value of NULL for that
> > > field in your database? Or if you really want to have a third option
> > > to force a user to enter something, mapping to a value other than
> > > empty string or 'null' might be wise, as depending on how your db
> > > field is defined, these may not be distinguishable from 'no data
> > > entered'. The 'right' solution really depends on the particular logic
> > > of your application - what data your users should enter and how that
> > > data will be used and analysed once it's in the database.
>
> > > On Jul 30, 12:40 am, "rich...@home"  wrote:
>
> > > > I'd use a drop down select instead of an option group.
>
> > > > This should do the trick:
>
> > > > input("Model.field", array("options"=>array(""=>"No
> > > > information on subject", true=>"True", false=>"False))); ?>
>
> > > > On Jul 29, 12:29 pm, Kanten  wrote:
>
> > > > > Is there really noone, that can help me with this one?
>
> > > > > Thanks
> > > > > Anders
>
> > > > > On Jul 10, 1:49 pm, Kanten  wrote:
>
> > > > > > Hi,
>
> > > > > > I am making a database for research and for this project I have a 
> > > > > > lot
> > > > > > of dichotomous (binary) variables where I need to be able to
> > > > > > discrimate between true, false and "no information on
> > > > > > subject" (=null). I would like to store it as a bool field in MySQL.
> > > > > > User interface wise I was thinking of using radio buttons with the
> > > > > > option of choosing between the three posibilities.
>
> > > > > > Is there some easy way of doing this using the builtin form helper, 
> > > > > > or
> > > > > > do I need to to modify it somehow?
>
> > > > > > Thanks
> > > > > > Anders
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Form with saving of true/false/null

2009-07-31 Thread delocalizer

The other way you can approach clearing radio input groups is to add
some little button or widget next to each group with a javascript
onClick function that sets the values to empty. At least that's what I
do. It looks prettier & and a bit more logical than an extra radio
option.

cheers,
Conrad.

On Jul 31, 4:13 pm, Kanten  wrote:
> I have been giving this some thought and I do get what you mean, but
> it is very important that the user can always change e.g. an "yes"
> answer into "not info on subject". Database wise I think you are
> right, that I should define three different values (no = 0, yes = 1,
> no info = 2) instead of using no info = Null.
>
> Thank you very much for your help.
>
> /Anders
>
> On Jul 30, 9:41 am, delocalizer  wrote:
>
>
>
> > You sure you want an explicit third option 'no information on the
> > subject'? Wouldn't it be better to just have a radio group with 2
> > buttons (Yes/No or True/False) with a default value of NULL for that
> > field in your database? Or if you really want to have a third option
> > to force a user to enter something, mapping to a value other than
> > empty string or 'null' might be wise, as depending on how your db
> > field is defined, these may not be distinguishable from 'no data
> > entered'. The 'right' solution really depends on the particular logic
> > of your application - what data your users should enter and how that
> > data will be used and analysed once it's in the database.
>
> > On Jul 30, 12:40 am, "rich...@home"  wrote:
>
> > > I'd use a drop down select instead of an option group.
>
> > > This should do the trick:
>
> > > input("Model.field", array("options"=>array(""=>"No
> > > information on subject", true=>"True", false=>"False))); ?>
>
> > > On Jul 29, 12:29 pm, Kanten  wrote:
>
> > > > Is there really noone, that can help me with this one?
>
> > > > Thanks
> > > > Anders
>
> > > > On Jul 10, 1:49 pm, Kanten  wrote:
>
> > > > > Hi,
>
> > > > > I am making a database for research and for this project I have a lot
> > > > > of dichotomous (binary) variables where I need to be able to
> > > > > discrimate between true, false and "no information on
> > > > > subject" (=null). I would like to store it as a bool field in MySQL.
> > > > > User interface wise I was thinking of using radio buttons with the
> > > > > option of choosing between the three posibilities.
>
> > > > > Is there some easy way of doing this using the builtin form helper, or
> > > > > do I need to to modify it somehow?
>
> > > > > Thanks
> > > > > Anders
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Form with saving of true/false/null

2009-07-30 Thread delocalizer

You sure you want an explicit third option 'no information on the
subject'? Wouldn't it be better to just have a radio group with 2
buttons (Yes/No or True/False) with a default value of NULL for that
field in your database? Or if you really want to have a third option
to force a user to enter something, mapping to a value other than
empty string or 'null' might be wise, as depending on how your db
field is defined, these may not be distinguishable from 'no data
entered'. The 'right' solution really depends on the particular logic
of your application - what data your users should enter and how that
data will be used and analysed once it's in the database.

On Jul 30, 12:40 am, "rich...@home"  wrote:
> I'd use a drop down select instead of an option group.
>
> This should do the trick:
>
> input("Model.field", array("options"=>array(""=>"No
> information on subject", true=>"True", false=>"False))); ?>
>
> On Jul 29, 12:29 pm, Kanten  wrote:
>
>
>
> > Is there really noone, that can help me with this one?
>
> > Thanks
> > Anders
>
> > On Jul 10, 1:49 pm, Kanten  wrote:
>
> > > Hi,
>
> > > I am making a database for research and for this project I have a lot
> > > of dichotomous (binary) variables where I need to be able to
> > > discrimate between true, false and "no information on
> > > subject" (=null). I would like to store it as a bool field in MySQL.
> > > User interface wise I was thinking of using radio buttons with the
> > > option of choosing between the three posibilities.
>
> > > Is there some easy way of doing this using the builtin form helper, or
> > > do I need to to modify it somehow?
>
> > > Thanks
> > > Anders
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: validates() not working on all functions...

2009-07-28 Thread delocalizer

Are you setting your data to the model in the controller action before
validating/saving?
$this->Model->set($this->data);
$this->Model->save();
etc.

On Jul 28, 12:27 am, number9  wrote:
> I'm using a validates function in a model in order to validate image
> uploads. I want to validate the filetype, and also make it required.
>
> I know cake has built in validation for these, but I could never get
> it to work. The image upload component I am using uses an array,
> accessible via $this->data['Img']['pic'].
>
> The problem I am having, is that the /add/ function works great, but
> when I use the image field (Img.pic) on another function (/
> edit_image/) the validation function isn't applied.
>
> Here is the model code:
>
>         function validates()
>     {
>
>                 $image = $this->data['Img']['pic']['name'];
>                 // Grab the file extension:
>                 $path = pathinfo($image);
>                 $filetype = $path['extension'];
>
>                 if(!empty($image)) {
>
>                 if (($filetype != 'JPG') && ($filetype != 'jpg') && 
> ($filetype !=
> 'GIF') && ($filetype != 'gif') && ($filetype != 'JPEG') && ($filetype !
> = 'jpeg'))
>                         {
>             $this->invalidate('Img.pic');
>                         }
>                 }
>                 else {
>                         $this->invalidate('Img.pic');
>                 }
>
>         $errors = $this->invalidFields();
>         return count($errors) == 0;
>     }
>
> Is there something I have to include in the controller to make the
> above happen automatically?
>
> I would appreciate any guidance on this, I can include more code if
> requested.
>
> Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Form fields repopulating with default data.

2009-07-28 Thread delocalizer

Is your field a 'select' type? How are you setting the default value?
>From memory, using 'selected'=>'value' forces the input view to show
initial 'value', but using 'default'=>'value' will only populate
'value' if data is not present for that field - so in the case of
failed validation (where data is returned to the view) the user-
entered value will stand.

On Jul 27, 11:54 pm, Shaun  wrote:
> I have a form field named user_first_name with no default value.  When
> a user named Fred completes this field correctly, but enters invalid
> data in another field such as user_password, user_first_name is
> automatically repopulated with "Fred" so Fred doesn't need to write
> his first name again.  Nice!
>
> However, I also have a form field named user_birth_year with a default
> value of "".  Fred enters a valid birth year, but an invalid
> password.  Rather than saving his correct birth year, the field is
> automatically repopulated with "".
>
> How can this be avoided?  Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Download code for downloading a file

2009-07-27 Thread delocalizer

Just so this is searchable & on the record here at the cakephp group:
using ob_gzhandler in conjunction with ob_* functions like the
ob_clean and ob_end_clean in the code snippets in above posts can
cause headaches.
In particular, you might have output_handler set = ob_gzhandler in
your php.ini and not even realise it... this caused downloads to fail
completely for me (php-5.1.6 on CentOS 5.3). Seems to be an old php
bug (http://bugs.php.net/bug.php?id=34071 & variations...).
Answer = if you want to use ob_gzhandler, invoke it at function level,
and not in conjunction with ob_clean.

On Jul 24, 6:34 pm, Vijay Kumbhar  wrote:
> Hey Crazy,
>
> thanks a lot ... i will try this out.
>
>
>
> On Fri, Jul 24, 2009 at 1:56 PM, Crazy  wrote:
>
> > Will there be allot of file downloads?
>
> > If there will be a big load on the site from file downloads,
> > especially big files. Then it's not smart to handle it in cakephp.
> > Especially if you want to support download accellerators/resume
> > support
>
> > On every request(someone that uses a download accelerator and makes 10
> > requests), the cakephp framework is loaded.
> > This is accually not needed, because it's a plain file download.
> > Even if you want to check a couple of things in the database, it's
> > better to do it manually.
>
> > This ofcouse depends on the situation you're in.
> > In my case, using cakephp this way would crash my server within 5
> > minutes(if not faster)
>
> > You can find the code I use here:
>
> >http://pastebin.com/f179e1e49
>
> > I've been using it for several years and transfer 15 to 20tb per month
> > using that piece of code.
>
> > /Crazy
>
> > On Jul 24, 9:58 am, Vijay Kumbhar  wrote:
> > > Yeah...
>
> > > Thanks rufus it works .
>
> > > only i changed this line,
>
> > > header('Content-Type: application/octet-stream'); to
>
> > > header("Content-Type: ".$result['Application']['resume'])."");
>
> > > that is the content type of the uploaded file coming from my database.
>
> > > Thanks again...
>
> > > On Fri, Jul 24, 2009 at 12:53 PM, Rufus  wrote:
>
> > > > Here is my code:
>
> > > > pdfDir is defined constant fyi
>
> > > >        function download($id = null) {
>
> > > >                if (!$id && empty($this->data)) {
> > > >                        $this->Session->setFlash(__('Invalid Invoice',
> > > > true));
> > > >                        $this->redirect(array('action'=>'index'));
> > > >                }
>
> > > >                Configure::write('debug', 0);
> > > >                $file = $this->Invoice->findById($id);
> > > >    if (file_exists(pdfDir.$file['Invoice']['file_name'])) {
> > > >        header('Content-Description: File Transfer');
> > > >        header('Content-Type: application/octet-stream');
> > > >        header('Content-Disposition: attachment; filename='.basename
> > > > (pdfDir.$file['Invoice']['file_name']));
> > > >        header('Content-Transfer-Encoding: binary');
> > > >        header('Expires: 0');
> > > >        header('Cache-Control: must-revalidate, post-check=0, pre-
> > > > check=0');
> > > >        header('Pragma: public');
> > > >        header('Content-Length: ' . filesize(pdfDir.$file['Invoice']
> > > > ['file_name']));
> > > >        ob_clean();
> > > >        flush();
> > > >        readfile(pdfDir.$file['Invoice']['file_name']);
> > > >        exit;
> > > >    } else {
> > > >                        $this->Session->setFlash(__('File Does Not
> > Exist',
> > > > true));
> > > >                        $this->redirect(array('action'=>'index'));
> > > >     }
>
> > > >        }
>
> > > > On Jul 24, 12:44 am, Vijay  wrote:
> > > > > Hello All,
>
> > > > > I uploads the files to webroot/uploads folder from the file uploading
> > > > > component.
>
> > > > > Now I am trying to download that file from webroot/uploads folder but
> > > > > it is giving me 0 byte file.
>
> > > > > Code is as follows,
>
> > > > > function admin_download($id)
> > > > >     {
> > > > >         $this->adminchecksession();
> > > > >             // you'll want to check the login status here ...
>
> > > > >             $result = $this->Application->findById($id);
>
> > > > >             Configure::write('debug', 0);
> > > > >             $this->view = 'Media';
>
> > > > >             /* MediaView is really irritating
> > > > >              */
> > > > >             //$name = $result['Application']['resume'];
>
> > > > >             $ext = explode("." ,$result['Application']['resume']);
>
> > > > >             $params = array(
> > > > >                     'name' => $ext[0],
> > > > >                     'download' => true,
> > > > >                     'extension' => $ext[1],
> > > > >                     'path' => APP."webroot/uploads".DS,
> > > > >                     'mimeType' => array($result['Application']
> > > > > ['type'])
> > > > >             );
>
> > > > >             $this->set($params);
>
> > > > >     }
>
> > > > > Please help me on this.
>
> > > --
> > > Thanks & Regards,

Re: saveField updates more than the field

2009-07-25 Thread delocalizer

Surely the whole point of 'modified' and 'created' is that they are
updated automagically every time a record is modified or created!
Otherwise why would you include them in your table with the names that
cake will recognize? You could always define a custom field 'altered'
or something that you save explicitly only when you want to.

On Jul 24, 9:51 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I have
>
> $this->Calculations->saveField('percent', $percent); which saves a math
> formula to the field
>
> But "modified" field is also getting updated which I do not want. Can we
> specify that we only want the one field saved? Or just use save() and
> include the fields we want to save instead of saveField?
>
> Thanks
>
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth - get all public Controllers for SitemapDeluxe

2009-07-16 Thread delocalizer

Configure::listObjects('controller')

returns an array list of all the controllers - first element is 'App'
which you probably don't want.


On Jul 15, 8:52 pm, ixopo  wrote:
> Hello,
>
> we are using Auth and this is working fine so far.
> I'm just implementing the SitemapDeluxe 
> =>http://bakery.cakephp.org/articles/view/sitemap-deluxe
>
> and cauze i dont want to add every controller manually when new
> controllers are available 
> i search for a way to get this automatically done by reading all the
> Public Controllers from Auth so the Sitemap will be automatically
> up2date all the time.
>
> Is there a way to read all Public Controllers ?
>
> Thx 4 any Help
> ixopo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Containable grabbing too much data

2009-06-27 Thread delocalizer

Thanks for posting that. I also have an afterFind callback in the
model that is giving me too much data, so that must be the problem.
I'm kinda glad it's not because I wasn't understanding 'contain'
behaviour. Unfortunately the afterFind contains some logic that I
can't do without, so I'll have to stick with a custom query solution I
think.

On Jun 28, 10:02 am, Miles J  wrote:
> I found the problem, but cannot fix it. Its my afterFind() method for
> my Article model.
>
>         /**
>          * Executed after a find() call
>          */
>         function afterFind($results) {
>                 if (!empty($results)) {
>                         foreach ($results as &$result) {
>                                 if (is_array($result) && 
> !empty($result['Article']['id'])) {
>                                         $result['Article']['favorites'] = 
> $this->Favorites->find('count',
> array(
>                                                 'conditions' => 
> array('Favorites.article_id' => $result
> ['Article']['id']),
>                                                 'contain' => false,
>                                                 'recursive' => -1
>                                         ));
>
>                                         $result['Article']['comments'] = 
> $this->Comments->find('count',
> array(
>                                                 'conditions' => 
> array('Comments.item_id' => $result['Article']
> ['id'], 'Comments.status' => 'approved'),
>                                                 'contain' => false,
>                                                 'recursive' => -1
>                                         ));
>                                 }
>                         }
>                 }
>
>                 return $results;
>         }
>
> Even when I disable contain and recursive, it still grabs all the
> extra data. BUT WHEN I remove the after find, the correct data is
> returned.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Containable grabbing too much data

2009-06-26 Thread delocalizer

spooky... I came across the identical thing just today. And (I think)
the simple answer is that it is because your Article belongsTo User.
I've also used containable for a while and assumed that chaining
arrays of associations as in your example works (restricts the db
query) in either 'direction', but having tested it out a bit this
doesn't seem to be the case. If you were to have 'contain' => array
('Article' => array('Favorite')) then that works fine coz Article
hasMany Favorites. The thing is I'm surprised I've not noticed this
before when using 'contain', it's just because I was paginating a
whole heap of records and it was taking forever that I even bothered
to look at the actual data. Now I don't know if this is intended
behaviour, but it sure is a pain in the rear! A case for custom
pagination function with plain old SQL query in my model for sure.
Happy if someone tells me I'm wrong.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: What debug/IDE do you use?

2009-06-20 Thread delocalizer

Eclipse with PHPeclipse plugin. I've never used anything else, and
never really felt the need. Worksforme.

On Jun 20, 2:01 am, kdubya  wrote:
> What development environment/debugger do you use when developing
> CakePHP apps? Have you used others? What do like/dislike about the one
> you use?
>
> Ken
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: TreeBehavior across different models

2009-06-18 Thread delocalizer

Hi Greg;
Yes my experience is that if it's not easily implemented with the core
Tree behaviour then there is probably a better or at least alternative
way to do it. Once (and only once) was I determined (desperate?)
enough to have a heterogeneous model tree, and in that case I used a
separate model with Tree behaviour just for the structure, with fields
for the class name & UUID of the model object referred to by each
node. Worked quite well but had to be careful to keep the the
structure tree in sync with its models using callbacks so that adding/
editing/deleting a model did likewise to the tree and vice versa
Sounds like it all worked out for you anyway.

cheers mate.

On Jun 17, 8:28 pm, Greg Baker  wrote:
> Basically I wanted to create a chain of alternating objects.  For
> example:
>
> document-comment-document-comment-document-comment
>
> Not really a tree I guess but I thought I could make use of some of
> the tree behaviour to help me.  I've since come up with my own
> solution so I don't have to use tree.
>
> On Jun 9, 7:52 am, delocalizer  wrote:
>
> > Can you describe the context of the problem? ie. what is it that you
> > want to achieve?
>
> > On Jun 6, 1:38 am, Greg Baker  wrote:
>
> > > Is it possible to use TreeBehavior where parent_id points to an id in
> > > another model, which also uses TreeBehavior?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: TreeBehavior across different models

2009-06-09 Thread delocalizer

Can you describe the context of the problem? ie. what is it that you
want to achieve?

On Jun 6, 1:38 am, Greg Baker  wrote:
> Is it possible to use TreeBehavior where parent_id points to an id in
> another model, which also uses TreeBehavior?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: after-validation data

2009-06-08 Thread delocalizer

Hi Balanza;
beforeSave callback (in your model) would be the place to do that.
Although for the example you give, if you use the Auth component a
password will be hashed by default.



On Jun 8, 4:25 am, Balanza  wrote:
> Hi,
> i wonder i couldn't find anything about make some elaboration to data
> coming from a form after it's been validated by my model. For
> instance, ti could be very useful for saving an encrypted password. I
> actually haven't found anything besides doing it in the controller -
> and of course it messes with built-in cake validation.
>
> Does anybody know any way to avoid this or a doc i can read?
>
> thanks,
>
> balanza
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How setting path for only one layout

2009-06-03 Thread delocalizer

Hi Petr, I'm not sure what you're asking here... if you just want to
change the layout for an action's view, then set the $layout variable
in the controller like: $this->layout = 'layoutname' where you have
'layoutname.ctp' in /app/views/layouts. Or are you saying that you
want the controller to render a view to a layout defined on a user's
machine? Because if you think about it that's just not remotely
possible - all the php action happens on the server before anything
gets sent to client (browser). How would the server know what is on a
client?

>
, 4:40 am, Petr Vytlačil  wrote:
> APP CONTROLLER
>
>  function beforeRender(){
>             if($this->params['controller']=='frontends'){
>                  // This do nothing
>                  $viewPaths = array(CAKE_CORE_INCLUDE_PATH .'\shared
> items\views');
>
>                  // This do nothing
>                  define('LAYOUTS','C:'.DS.'Program
> Files'.DS.'VertrigoServ'.DS.'www'.DS.'projekty'.DS.'klientpenzion'.DS.'app'.DS.'view'.DS);
>             }
>     }
>
> please help, how i can set directory for layout, thx.
>
> On 2 čvn, 13:50, Petr Vytlačil  wrote:
>
> > Hi I develop simple CMS, but it will be multisite system.
> > One core (controller, admin, frontend views, models)
> > User: (frontend layout, css, images)
>
> > Pleas is any idea how I can chagne path for on layout in any action in
> > controller?
> > Path must be in some adr for example: /root/cake/layout/frontend.ctp
>
> > THX
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: taking down the scaffold...

2009-06-02 Thread delocalizer

 $scaffold doesn't really have anything to do with it. But you can
hide SQL log by changing your debug setting (in /app/config/core.php)
from 2 to 1 or less.

On Jun 2, 4:52 am, cake_eater101  wrote:
> When I delete the $scoffold variable from any given controller, I
> still see the SQL query summary information at the bottom of my pages.
> Would anyone know how to turn off the SQL summary?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: List leafs in Tree Behavior

2009-05-31 Thread delocalizer

or:
TreeModel->query('SELECT * FROM model_things WHERE  model_things + 1 =
model_things.rght').
'TreeModel' is obviously the name of your model that behaves as Tree
and 'model_things' is its db table.

On May 31, 8:42 am, Jorge Horacio Cué Cantú 
wrote:
> Hello,
>
> I have a system with a Model behaving as Tree, the question is.
> I need to get a list of rows with out children meaning records that are
> leafs in the tree.
> Is there a way to accomplish that?
>
> Of course It is the "brute force method", but since the tree might be very
> large, I rather have a most efficient way.
>
> Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: List leafs in Tree Behavior

2009-05-31 Thread delocalizer

Hi Jorge;
Easiest way is to do a find with condition that TreeModel.lft+1 =
TreeModel.rght


On May 31, 8:42 am, Jorge Horacio Cué Cantú 
wrote:
> Hello,
>
> I have a system with a Model behaving as Tree, the question is.
> I need to get a list of rows with out children meaning records that are
> leafs in the tree.
> Is there a way to accomplish that?
>
> Of course It is the "brute force method", but since the tree might be very
> large, I rather have a most efficient way.
>
> Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---