Re: Cake3 - Clean way to use session in models

2014-09-23 Thread alaxos

Another similar idea using a Component instead of a trait:

https://github.com/alaxos/cakephp3-libs/blob/master/src/Controller/Component/UserLinkComponent.php
https://github.com/alaxos/cakephp3-libs/blob/master/src/Model/Behavior/UserLinkBehavior.php

Nico


On Tuesday, September 23, 2014 2:03:06 PM UTC+2, euromark wrote:
>
> I would say: Pass in the data from the controller.
>
> Also - this should give you an answer:
> https://github.com/ceeram/blame
>
> mark
>
>
> Am Dienstag, 23. September 2014 10:02:27 UTC+2 schrieb bato:
>>
>> Hi,
>>
>> I would know if there is a way to access to session user in Models. I 
>> have a table with user_created and user_modified fields.
>> Saving Table user_created is only filled if Entity is new instead 
>> user_modified is always filled.
>>  
>> I can populate user_created and user_modified in controller but I'd like 
>> to set those fields in Table *beforeSave* to avoid to always remember to 
>> do that in controller each time I save that Table. 
>> Indeed this Table is saved in many controllers and other Tables can save 
>> it.
>>
>> Thanks
>> Alberto
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Is overriding AppController's beforeFilter() always recommended ?

2012-12-12 Thread alaxos

Thanks for your answers. That's also how I understand this remark in the 
cookbook. 

But it could probably be clarified, because apparently the given sample 
code may be a bit confusing for people not very confident with oop. It 
seems that it leads some people to include a beforeFilter() method in their 
child controllers even when it is not necessary.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Is overriding AppController's beforeFilter() always recommended ?

2012-12-11 Thread alaxos
While answering a recent question on stackoverflow (http://
stackoverflow.com/questions/13825073/always-call-a-function-in-
cakephp), I discovered that it seems to be recommended in the cookbook
to always override the AppController beforeFilter() in child
controllers (http://book.cakephp.org/2.0/en/controllers.html#the-app-
controller), even if it is only to call the AppController's
beforeFilter() method like this:

public function beforeFilter() {
parent::beforeFilter();
}

My feeling is that in OO programming, this is useless, because if we
don't override a method in a child class, the parent method is used.

I do know that when the beforeFilter() method is not overridden in
child controllers, the AppController's beforeFilter() is indeed
called, but as it is recommended in the cookbook, is there any
advantage to do so ? Am I missing something here ?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Acl::check() the $action parameter and the default vals , what does that mean?

2012-11-08 Thread alaxos

Some explanation here: 
http://stackoverflow.com/questions/9063617/cakephp-acl-action-mode-vs-crud-mode



Le jeudi 8 novembre 2012 03:41:53 UTC+1, polutan polution at all a écrit :
>
> anybody? Please help me
>
>
> 2012/11/5 polutan polution at all >
>
>> Hello folks :)
>> I don't understand what does $action param and its default values mean? 
>> Because i can directly write $this->Acl->check("warriors/Aragorn", 
>> "ControllerNames/myMethodName") then it works, i don't need to supply 
>> $action param.
>>
>> Then if i do something like at the manual $this->Acl->check(
>> 'warriors/Aragorn', 'Weapons', 'create'); which method in my 
>> WeaponsController class categorized as 'create' ? .
>> Then suppose i have reloadAmmunition() method in my WeaponsController 
>> class. So what reloadAmmunition() is? a create or read or update or a 
>> delete? Please somebody help me, i need your enlightenment.
>>
>> Thank You :)
>>
>> -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> cake-php+u...@googlegroups.com .
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>  
>>  
>>
>
>
>
> -- 
> *Coklat Stroberi -- Web Dev Training Centre*
> http://www.facebook.com/pages/Coklat-Stroberi/249514251728226  (info 
> lebih lanjut)
> http://coklatstroberi.net 
> Jl. Raya Padang Luwih (Dalung) No.141 - Telp. (0361) 9006118 atau 
> 08174128301 - Badung, Bali. Sebelah timur traffic light pertigaan 
> perumahan dalung permai.
>
>
> 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: how can i protect my code from the duplicaters

2011-11-03 Thread alaxos
Ryan, at first glance your answer seems very logical, but who knows
why, I must admit I have a preference for the one given by Andy... :-D

On Nov 3, 10:34 am, Ryan Schmidt  wrote:
> On Nov 2, 2011, at 23:56, rizki novian wrote:
>
> > i want to protect my code with key or something like that..
>
> I don't understand the question. Aren't you in complete control of who you 
> give your code to? If you don't want anybody to duplicate your PHP code, then 
> don't give your PHP code to anybody.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Going back to school: ACL

2011-10-31 Thread alaxos
You're welcome Eric ! :-)

As I wrote above, I think it worths to dive into ACL, even if it has
some limitations. But it was also immediately obvious to me that it
would be usable only with a graphical interface to manage the
permissions. That was the reason to write this plugin. And it is
probably obvious to many other users of ACL, since the plugin has been
downloaded many thousands of times since it is online.

Regarding a CakePHP 2.0 version, it is already available here:
http://www.alaxos.net/blaxos/posts/view/20 The reason to be still in
'beta' is that I haven't used it a lot so far. But it has been
downloaded a few tens of times already, and it seems to work quite
well. Feel free to try it and give me a feedback.


On Oct 30, 11:35 am, Eric Blanpied  wrote:
> Jeremy,
>
> I've done a number of cakephp apps (1.1, 1.2, 1.3 - starting a 2.0,
> too), and have also always been flummoxed by ACL and gone back to my
> own code to deal with it. A current project (1.3) has *lots* of roles,
> however, including enough overlap that a many-many groups-users setup
> seemed like what I wanted. I persevered with ACLs this time, though,
> and I'm ending up glad that I did. As others have said, pulling access
> control out of most of the code is very, very nice, and the
> flexibility to add new roles with mixed degrees of access via the
> database is great. I'm experimenting with hierarchical groups to
> handle some of the overlap (add a parent_id to your groups table).
>
> One thing that's helped me is Alaxos' acl plugin (thanks, nIcO!) -
> while it doesn't map to what I'm doing exactly, having some tools to
> manage the tables is vital, and I'm sure glad I didn't have to write
> any myself. One thing I'm curious about, nIcO, is the 2.0 story for
> your plugin.
>
> Zuha, can you explain a bit further about mixing prefix routing with
> ACLs? Our setup is currently still using admin_ prefixes, but as far
> as I can tell that's pretty redundant here, unless it could provide a
> second angle of access control.
>
> Thanks, everyone!
>
> -eric
>
>
>
>
>
>
>
> On Fri, Oct 28, 2011 at 11:08 AM, alaxos  wrote:
> > Hi Jeremy,
>
> > As far as I know, the core ACL does not support multiple groups per
> > user.
>
> > Before using ACL, I used myself a home made component that allowed to
> > grant/deny access based on roles membership and action prefixes like
> > you do. It used to work :-) and it also supported many-to-many users-
> > groups. But since I have changed my habit, and I now use ACL. As
> > mentionned by zuha, I prefer the idea to have the possibility to grant/
> > deny specific permission to someone or some people without having to
> > update the code. Even if it now does not support many-to-many users-
> > groups anymore, I think it is more flexible. But I also have to admit
> > that I never developped an application with a lot of different
> > profiles (so far 4-5 max).
>
> > nIcO
>
> > On Oct 27, 6:48 pm, Jeremy Burns | Class Outfit
> >  wrote:
> >> Thanks Richard.
>
> >> Your point about flexibility and extensibility is a good one. You'd define 
> >> specific views to do specific functions and then restrict them with 
> >> permissions rather than a prefix. That also means one view can be used by 
> >> more than one group (although I guess you could equally do that with 
> >> $this->render).
>
> >> My second question is the one that puzzles me most. I've designed some 
> >> systems where this is very typical; members of staff are department heads, 
> >> managers, subordinates, team members, committee members and so on. So one 
> >> person changes his role (group) throughout a single session. I'd be 
> >> interested to see what others have to say too.
>
> >> I have some SQL that could speed up the acl table reads if you are using 
> >> Innodb.
>
> >> Jeremy Burns
> >> Class Outfit
>
> >>http://www.classoutfit.com
>
> >> On 27 Oct 2011, at 17:32, zuha wrote:
>
> >> > #1 : Would require a prefix for every role.   admin_index, 
> >> > manager_index, user_index, guest_index, etc.   With ACL being database 
> >> > driven you can have unlimited user roles and not be required to add new 
> >> > prefixes every time you add a role.
>
> >> > #2 : I don't know, interesting question.  It sounds kind of a-typical to 
> >> > me though.  You would probably add a 3rd group in that rare case called 
> >> > something like, "board-teachers".
>
> >> 

Re: Going back to school: ACL

2011-10-28 Thread alaxos
Hi Jeremy,

As far as I know, the core ACL does not support multiple groups per
user.

Before using ACL, I used myself a home made component that allowed to
grant/deny access based on roles membership and action prefixes like
you do. It used to work :-) and it also supported many-to-many users-
groups. But since I have changed my habit, and I now use ACL. As
mentionned by zuha, I prefer the idea to have the possibility to grant/
deny specific permission to someone or some people without having to
update the code. Even if it now does not support many-to-many users-
groups anymore, I think it is more flexible. But I also have to admit
that I never developped an application with a lot of different
profiles (so far 4-5 max).

nIcO

On Oct 27, 6:48 pm, Jeremy Burns | Class Outfit
 wrote:
> Thanks Richard.
>
> Your point about flexibility and extensibility is a good one. You'd define 
> specific views to do specific functions and then restrict them with 
> permissions rather than a prefix. That also means one view can be used by 
> more than one group (although I guess you could equally do that with 
> $this->render).
>
> My second question is the one that puzzles me most. I've designed some 
> systems where this is very typical; members of staff are department heads, 
> managers, subordinates, team members, committee members and so on. So one 
> person changes his role (group) throughout a single session. I'd be 
> interested to see what others have to say too.
>
> I have some SQL that could speed up the acl table reads if you are using 
> Innodb.
>
> Jeremy Burns
> Class Outfit
>
> http://www.classoutfit.com
>
> On 27 Oct 2011, at 17:32, zuha wrote:
>
>
>
>
>
>
>
> > #1 : Would require a prefix for every role.   admin_index, manager_index, 
> > user_index, guest_index, etc.   With ACL being database driven you can have 
> > unlimited user roles and not be required to add new prefixes every time you 
> > add a role.
>
> > #2 : I don't know, interesting question.  It sounds kind of a-typical to me 
> > though.  You would probably add a 3rd group in that rare case called 
> > something like, "board-teachers".  
>
> > #3 : Yes and its not small.  It can be large and a major slow down.
>
> > ACL is very flexible but the flexibility comes with the downside of speed 
> > performance.  I'm quite sure there are caching solutions to get around it, 
> > but I have not gotten that far yet (even after 2 years of using ACL 
> > extensively).
>
> > --
> > Our newest site for the community: CakePHP Video 
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


HttpRequest - single parameter, many values

2011-09-23 Thread alaxos
I'm building a datasource for the Solr search server. For the
connection, I use the HttpSocket class. I have some working
functionnalities, but I'm stumped on a problem.

Some of the Solr functionnalities need to pass many times the same
query parameter name, but with different values. For instance:

http://myserver.com/solr/select/?q=*:*&facet=true&facet.field=mot.cle.marc&facet.field=creatorFacet&fq=mot.cle.marc:humans&fq=creatorFacet:john

My problem is that when I send a GET request with the HttpSocket, only
the last occurence of the parameters are used.

I've explored a bit the code, found that the query string is parsed a
few times, before being rebuilt with the http_build_query PHP function
that only keep one occurence of the parameters. I also found that
there is a possibility to pass the same parameter many times (with an
array-like syntax supported by http_build_query()), but in this case
the query sent is not the original one and Solr does not understand
it.

Is there any workaround that would still allow to use the HttpSocket
class, in order to keep the other HttpSocket features ?
If not, is it something that the HttpSocket should be able to do ?

Thanks,
nIcO

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: $this->Acl->check() and max execution time in cake\libs\model\datasources\dbo\dbo_mysql.php on line 600

2011-09-20 Thread alaxos
Hi,

It seems that you don't use the latest version of the plugin, because
in this one the code you mention is not on line 258.

I'm not sure which one you use, but since version 1.0.4 (january
2011), the roles permissions page can be loaded with Ajax. Basically
it means that instead of one very heavy query, there is one query for
each controller / role couple. With many controllers and actions, it
is still a heavy load for the server, but at least it should prevent
server timeouts.

To enable Ajax loading, just set the acl.gui.roles_permissions.ajax
parameter to true.

Cheers,
nIcO


On 20 sep, 11:57, sathyashrayan  wrote:
> Group,
>   I used Alaxos ACL plugin found here..
>
> http://www.alaxos.net/blaxos/pages/view/plugin_acl
>
> In my project i have more than 165 actions and 55 controllers,
> including ADD, EDIT ect. When I clicked role wise permission in the
> plugin (admin/acl/aros/role_permissions) i get
>
> Fatal error: Maximum execution time of 60 seconds exceeded in [path]
> \cake\libs\model\datasources\dbo\dbo_mysql.php on line 600
>
> I know i could just use set_time_limit(0); in the action
> admin_role_permissions() of [path]\app\plugins\acl\controllers
> \aros_controller.php
>
> But when I went on commenting out some lines in that controller, i got
> the point where the execution exceeds the limit. If i am not wrong
> then it is on this line
>
>  $authorized = $this->Acl->check($role, $full_action); Line-258
>
> The I saw this function in core cakephp [path]\cake\libs\controller
> \components\acl.php on the 
> functionhttp://book.cakephp.org/view/1249/Checking-Permissions-The-ACL-Component
>
> I see two foreach after Set::extract() call. Can anyone point out
> where the execution exceeds the limit. Thanks for any help.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: step by step how to implement ALAXOS plugins

2011-07-19 Thread alaxos
Hi,

I know this plugin is not very well documented (if not at all... ;-),
but in order to help a bit, I just put a sample application available
to download here: http://www.alaxos.net/blaxos/pages/view/demo_plugins
Also I think another easy way to start is probably to use the
templates that the plugin provides for the bake script and explore the
generated code.

Hope this helps.

Kind regards,
nIcO




On Jul 11, 11:19 am, ddk  wrote:
> Hi all,
>
> I'm new and want to ask step by step how to implementALAXOSplugins
> there is manual instruction to install it. but i have not seen the
> filter form.
>
> link websitenya :
> Code:
>
> http://www.alaxos.net/blaxos/pages/view/plugin_alaxos
>
> link live demo :
> Code:
>
> http://demo.alaxos.ch/admin/users
>
> link download :
> Code:
>
> http://www.alaxos.net/blaxos/downloads/get/alaxos_plugin_1.0.4
>
> any help will be appreciated.
>
> many thanks!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Cake dispatcher is synchronous?

2011-05-05 Thread alaxos
Hi,

Just to add my two cents here, instead of closing the session in your
action code, another possibility to get your prices would be to get
them not one by one, but with only one Ajax request to whom you would
pass the necessary ids as parameters. Your action would then be called
only once and would perform only one query to the database (with the
SQL query containing something like 'WHERE id IN (1, 2, 17, ...)').
And you would obviously save 11 HTTP requests that can also take time
to initialize.

Cheers,
nIcO




On May 5, 10:55 am, ojonam  wrote:
> Hi Ryan and Mark,
>
> thank you both for your responses. I am not specifically looking for
> multithreaded behavior, so I will stick for the PHP language (and hence
> Cake) for a bit more.
> For now, I am using the hack in Ryan's link, and it seems to work for now. I
> just call the function at the beginning of the "books/getprice" action. I
> suppose that when calling another action, the session will be restarted
> again, therefore not interfering with other parts of the application. Please
> correct me if this is wrong.
>
> Cheers,
> ojonam

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: How much to charge?

2011-02-17 Thread alaxos
I definitely like 'hold your breath while you give the number to your
client' and 'instruct a lawyer now because clients like to hold out on
payment' ! :-)

On Feb 16, 11:57 pm, Jeremy Burns | Class Outfit
 wrote:
> The only way to price something is to:
> - get the proper requirements
> - make sure they are what the customer wants
> - write them up and get the client to sign it off
> - work out how long it will take you to do it
> - double it (because you always underestimate)
> - make sure the customer agrees that the time and price will rise if they 
> make changes
> - decide how much each of your hours is worth
> - multiply the hours by the hourly rate
> - hold your breath while you give the number to your client
> - get half the money up front
> - get a proper contract between you signed
> - instruct a lawyer now because clients like to hold out on payment
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 16 Feb 2011, at 22:47, euromark wrote:
>
> > its a suggestive question like "what car should i bye"
> > plus its not even remotely cake related
>
> > so nobody in this group will probably be able to help you with this...
>
> > On 16 Feb., 23:17, hydra12  wrote:
> >> I've been offered a one-time job to develop a database driven form for
> >> someone's website.  I don't have any idea what to charge.  I've done
> >> some of this before, but always when I was on salary.  Anybody want to
> >> give me some advice?
>
> >> Thanks in advance!
>
> >> hydra12
>
> > --
> > Our newest site for the community: CakePHP Video 
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: ACL How to get logged user information, like user name, id in user table, group name, etc.

2011-01-24 Thread alaxos
If it is not a typo, the reason is that it is not $this->Auth-
>user["id] but $this->Auth->user("id).
user() is a function of the AuthComponent, not a property.

Regards,
nIcO

On Jan 24, 11:49 am, raymond  wrote:
> Hi, everyone.
> I ve entered CakePHP world recently and bumped into one issue.
> I need to get logged users information, especially primary key value
> in user table.
> I have tried $this->Auth->user["id] because I have read it from one
> post in this group, but I checked that $this->Auth does not have any
> user value there.
> So what solution will help me?
> Regards, Raymond.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: ACL how controll more type of action?

2011-01-24 Thread alaxos
Actually you can do exactly what you say with CakePHP ACL. By default,
the AclComponent allow() and deny() methods save 1 and -1 respectively
for all fields _create, _read, _update and _delete. Then if you use
the AclComponent to check if a user is authorized to do some actions,
the check() method simply returns a boolean, used to grant or deny
access.

I have never used the specific values of _create, _read, _update and
_delete, but I guess they are more useful in other situations, but not
to check users permissions on actions. At least in my case, the
aros_acos table contains only records with four 1, or four -1.

Regards,
nIcO

On Jan 24, 1:20 am, Petr Vytlačil  wrote:
> I understand ACL logic and what is ACO etc...
> But I thing this solution is stupid. Why I should setting premissions
> (update,delete,save,add) for action deleteItems of some Controller.
> Its sure I want only check if i can call deleteItems for this i dont
> need check if i has premission for update, delete, etc. for this
> action. .-)
>
> Understand me?
>
> Better solution:
> I has controller Entries and methos deleteEntry, addEntry.
> User role ADMIN has setting permission for ACO: Entries::deleteEntry
> and Entries::addEntry
>
> In app controller i check premission: $this->Acl->check(this->userRole, 
> 'Entries::addEntry');
>
> This is more simple and i dont need controll if users can read, save,
> delete, add this action.
>
> On Jan 12, 9:24 am, Andi  wrote:
>
> > Hi,
>
> > I think that you didn't understand the complex ACL logik. But it is
> > really complex.
>
> > The "actions" update, delete, save, add are the actions for the ACO.
> > So the first question is: what is an ACO? It is an Access Control
> > Object. Read here more about the 
> > logic:http://book.cakephp.org/view/465/Understanding-How-ACL-Works
> > So a typical ACO for CakePHP is a method of a controller.
> > Example:
> > Controller for Usergroups
> > Methods:
> > * add
> > * delete
> > * index
> > * list
> > * mygroups
> > * admin
> > * view
> > Every Method is an ACO and for every ACO you can set the permissions
> > update, delete, save, add.
>
> > More Information about setting the 
> > permissions:http://book.cakephp.org/view/648/Setting-up-permissions
>
> > On 9 Jan., 22:18,PetrVytlaèil  wrote:
>
> > > Hi in ACL you can controll only action (update, delete, save, add) It
> > > is bad because app can has more other metod is any solutuion how
> > > control access for other methor for example:
>
> > > Controller Users
> > > Function list(){
> > >    ..
>
> > > }
>
> > > THX

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Retrieve specific Associated Models

2011-01-15 Thread alaxos
you're welcome :-)

On 15 jan, 23:29, Santiago Basulto  wrote:
> This is exactly what i need!!
>
> Thank you very much brother!
>
> On Jan 15, 7:12 pm, alaxos  wrote:
>
> > Have you looked at the Containable behavior ? It can call the
> > unbindModel() for you.
>
> >http://book.cakephp.org/view/1323/Containable
>
> > Regards,
> > nIcO
>
> > On 15 jan, 20:56, Santiago Basulto  wrote:
>
> > > Hello people. I'm facing a little problem here.
>
> > > Supose i've my Car Model defined like this:
>
> > > class Car extends AppModel{
> > >    $name = 'Car';
>
> > >    // Associations
> > >    $hasOne = array('engine');
>
> > >    $hasMany = array('Tyre','Color','OtherModel', . );
>
> > > }
>
> > > I would like to read the data from my Car model but just get the data
> > > for the engine. Not the other associated models (Tyre, Color, etc).
>
> > > Something like this:
>
> > > $this->Car->read(null,$id) =
>
> > > array(
> > >    [Car] = Array(  //car data  )
> > >    [Engine] = Array(// Engine data)
> > > )
>
> > > if i set recursive to -1, i just get the Car data. If it's 1, i get
> > > all the data (Car, Engine, Tyre, etc).
>
> > > I could unbind the models i don't want to read, something like this:
>
> > > $this->Car->unbindMoldel(
> > > array('hasMany'=>array('Tyre','Color','OtherModel')), true).
>
> > > I was wondering if there's a better solution.
>
> > > Also, if i have my model "loaded" in $this->Car, how can i get the
> > > associated models from here?
> > > I mean, if i do this:
>
> > > $this->Car->recursive= -1;
> > > with a call to read() i get the Car data. How can, from here, get the
> > > other associated models?
>
> > > Something like:
> > > $this->Car->Engine->readCurrent ??
>
> > > Thanks
>
> > > --
> > > Santiago Basulto.-

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Retrieve specific Associated Models

2011-01-15 Thread alaxos
Have you looked at the Containable behavior ? It can call the
unbindModel() for you.

http://book.cakephp.org/view/1323/Containable

Regards,
nIcO

On 15 jan, 20:56, Santiago Basulto  wrote:
> Hello people. I'm facing a little problem here.
>
> Supose i've my Car Model defined like this:
>
> class Car extends AppModel{
>    $name = 'Car';
>
>    // Associations
>    $hasOne = array('engine');
>
>    $hasMany = array('Tyre','Color','OtherModel', . );
>
> }
>
> I would like to read the data from my Car model but just get the data
> for the engine. Not the other associated models (Tyre, Color, etc).
>
> Something like this:
>
> $this->Car->read(null,$id) =
>
> array(
>    [Car] = Array(  //car data  )
>    [Engine] = Array(// Engine data)
> )
>
> if i set recursive to -1, i just get the Car data. If it's 1, i get
> all the data (Car, Engine, Tyre, etc).
>
> I could unbind the models i don't want to read, something like this:
>
> $this->Car->unbindMoldel(
> array('hasMany'=>array('Tyre','Color','OtherModel')), true).
>
> I was wondering if there's a better solution.
>
> Also, if i have my model "loaded" in $this->Car, how can i get the
> associated models from here?
> I mean, if i do this:
>
> $this->Car->recursive= -1;
> with a call to read() i get the Car data. How can, from here, get the
> other associated models?
>
> Something like:
> $this->Car->Engine->readCurrent ??
>
> Thanks
>
> --
> Santiago Basulto.-

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

2011-01-05 Thread alaxos
Hi,

AFAIK, the standard permission check done by the pair Auth + Acl only
works if your users belong to one role only.
If your users can have many roles, you are not in the standard Acl
tree structure.

This means that you will have to implement your own authorization
logic. This may probably be done by setting the AuthComponent::
$authorize variable to 'controller' and then by implementing the
Controller::isAuthorized() method in your AppController.

Something like this:

function beforeFilter()
{
  $this->Auth->authorize = 'controller'; //-> Auth will use the
isAuthorized() method
}

function isAuthorized()
{
  // Get the logged user

  // Loop on his associated groups

// For each group call $this->Acl->check($group,
$current_aco_path)

// if one call to Acl->check(...) return true, then return true.


  //else return false;
}

I've never done it, but I suppose it should work.

Regards,
nIcO


On Jan 5, 10:58 am, Jens Dittrich  wrote:
> Hello everyone, I have a problem with Acl. I have an Application where
> my ACO's are my Controllers and their functions. My ARO's should be
> Roles that People are in. The setup looks like this:
> User hasOne Person
> Person hasAndBelongsToMany Roles
>
> In the tutorials the setup is simpler, there you have User and Group
> and you use bindNode() to let ACL look up in the Group. In my
> situation I want it to look one step further: User over Person to
> Role. Is that possible?
>
> Is it supported to belong to multiple ARO's (Roles in my case) by Acl
> or will I run into Problems?
>
> Regards,
> Jens

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


ACL permission on plugin's default controller

2010-11-17 Thread alaxos
Hi,

Some time ago I wrote a plugin to manage ACL permissions in my
applications (http://www.alaxos.net/blaxos/pages/view/plugin_acl). It
works fine, but someone sent me an email to tell me that one of the
plugins he uses in his application is not recognized by my ACL plugin
at all.

I just had a look at the code of this 'invisible' plugin (Cakemenu
plugin: http://nik.chankov.net/2010/09/01/cakephp-cakemenu-plugin) and
discovered that all of its actions are placed in a default controller:

cakemenu
  controllers
 cakemenu_controller.php
- index
- preview
- ...

When I wrote my ACL plugin, I did specifically hide these actions
placed in such default controllers because I discovered that they may
cause problem when the ACL permissions are checked.

Indeed, in this situation, the ACO tree needed by Auth+Acl would look
like this:

- controllers
   - Cakemenu
  - Cakemenu
 - index
 - preview
 - ...

And the ACL permission check seems to have good chances to fail here
as the path contains twice the alias 'Cakemenu'. By looking at the
Cake code, I found that the method node($ref = null) of the AclNode
class builds SQL queries with LEFT joins based on the aliases. And
this is a problem with same aliases appearing more than once.

Has anyone encountered this problem ? Is it a bug in Cake ? Any
solution ?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Standard mechanism for telling why a record hasn't been deleted?

2010-11-04 Thread alaxos
I hadn't noticed the onError callback. This is perfect in this case
indeed. Thanks for the pointer.

Regarding the broken MVC architecture, you're absolutely right. My
solution was a bit quick and dirty, and I probably shouldn't have
posted it as a good example.

But I will definitly keep getting the error message from the database,
translating it in the Model layer and putting it in the
validationErrors variable. It allows to prevent writing a function for
each potential error case, such as hasDependentRecords() or whatever.

nIcO

On 3 nov, 09:27, AD7six  wrote:
> On Nov 3, 9:02 am, alaxos  wrote:
>
> > Yes, but the point for me is that this solution needs really less
> > code. Once you have modified the AppModel and the layout, it works for
> > every controller and every action, without adding code in controllers.
>
> and you can't turn it off.
>
> Btw there's an onError callback which is in part for handling this
> sort of thing.
>
>
>
> > But it is a matter of choice... :-)
>
> If you want something like that where's the hardship in using your app
> controller beforeRender to look for the errors and set flash messages
> appropriately or whatever display logic you choose. Mixing MVC to save
> a line of code isn't going to save you anything the first time
> someone, probably someone else,  looks at your code and  can't see
> where or how these db errors they want to hide/modify/whatever are
> coming from.
>
> On the plus side, at least you used validation errors which is
> contextually more relevant than creating a new variable for storing
> your delete-only errors IMO.
>
> AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Standard mechanism for telling why a record hasn't been deleted?

2010-11-03 Thread alaxos
Yes, but the point for me is that this solution needs really less
code. Once you have modified the AppModel and the layout, it works for
every controller and every action, without adding code in controllers.

But it is a matter of choice... :-)


On Nov 3, 2:24 am, cricket  wrote:
> On Tue, Nov 2, 2010 at 6:31 PM, alaxos  wrote:
> > Hi,
>
> > Personally for these kinds of errors, I prefer to rely on the errors
> > raised by the database.
>
> > However, AFAIK, CakePHP does not return these errors automatically. I
> > found a solution, but it uses a very discussed technique: accessing
> > the Session in the model layer. It could also use a model variable
> > instead, that would be then read in the controller actions, but this
> > would mean updating a lot of them...
>
> Or you could just let the controller get the error from the model and
> set it for the view. Far less complicated.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Standard mechanism for telling why a record hasn't been deleted?

2010-11-02 Thread alaxos
Hi,

Personally for these kinds of errors, I prefer to rely on the errors
raised by the database.

However, AFAIK, CakePHP does not return these errors automatically. I
found a solution, but it uses a very discussed technique: accessing
the Session in the model layer. It could also use a model variable
instead, that would be then read in the controller actions, but this
would mean updating a lot of them...

This is what it looks like:

app_controller


function beforeFilter()
{
AppModel :: $cakeSession = $this->Session;
}


app_model
---

class AppModel extends Model
{
static $cakeSession = null;

function delete($id = null, $cascade = true)
{
$result = parent :: delete($id, $cascade);

$this->store_datasource_error();

return $result;
}

/*
* Override save() and saveAll() functions here as well if you want
*/

function store_datasource_error()
{
if(!empty($this->getDataSource()->error))
{
$this->validationErrors['datasource'] = $this-
>translate_datasource_error($this->getDataSource()->error);

AppModel :: $cakeSession->write('datasource_error', $this-
>validationErrors['datasource']);
}
}

function translate_datasource_error($error_msg)
{
if(stripos($error_msg, 'violates foreign key constraint) !==
false)
{
$error_msg = __('this item is referenced in the database',
true);
}
elseif(stripos($error_msg, 'duplicate key value violates
unique constraint') !== false)
{
$error_msg = __('this value already exists', true);
}
elseif( ... )
{
 ...
}

return $error_msg;
}
}


Layout
-

Session->check('datasource_error'))
{
echo $this->Session->read('datasource_error');
$this->Session->delete('datasource_error');
}
?>

Kind regards,
nIcO



On 2 nov, 15:09, psybear83  wrote:
> Hi all layer
>
> Is there a standard mechanism for telling why a record hasn't been
> deleted?
>
> When a record isn't deleted, it just tells "Xxx was not deleted", but
> without any reason. So for example, when I'm creating a
> beforeDelete(..) hook that prevents the record from deletion, how
> should I let the user know why it hasn't been deleted?
>
> Would using a $deletionError variable be an acceptable way?
>
> function beforeDelete($cascade) {
>   if($this->hasDependentRecords()) {
>     $this->deletionError = 'record has dependent records';
>     return false;
>   }
>
> }
>
> And in the controller:
>
> if ($this->Post->delete($id)) {
>   ...} else {
>
>   $this->Session->setFlash('Post was not deleted because '.$this->Post-
>
> >deletionError);
> }
>
> What do you think about this solution? Is there a better way?
>
> Thanks, Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 Acl on plugins HOWTOs

2010-09-19 Thread alaxos
Hi Bryan,

This won't answer your question precisely, as I'm not sure where you
can find such a tutorial, but I have written a plugin that may help
you in your application: it is a plugin that allows to manage ACL
roles and users permissions on controllers' actions. And it supports
plugins' controllers as well (see at the bottom of the roles'
permissions list in the demo).

If interested, you can find it here: 
http://www.alaxos.net/blaxos/pages/view/plugin_acl

nIcO

On 16 sep, 22:08, Bryan de Asis  wrote:
> Hello,
>
> Is there any tutorial the can teach us to use the acl to set
> permissions to plugins?
>
> Let say...
>
> Role 1
> Role 2
>
> Role1 access
>  - plugin 1
>  - plugin 1 / controller 1
>  - plugin 1 / controller 1 / action 1
>  - plugin 1 / controller 1 / action 2
>  - plugin 1 / controller 2 / action 1
>  - plugin 1 / controller 2 / action 2
>
>  - plugin 2
>  - plugin 2 / controller 1
>  - plugin 2 / controller 1 / action 1
>  - plugin 2 / controller 1 / action 2
>  - plugin 2 / controller 2 / action 1
>  - plugin 2 / controller 2 / action 2
>
>  - plugin 3
>  - plugin 3 / controller 1
>  - plugin 3 / controller 1 / action 1
>  - plugin 3 / controller 1 / action 2
>  - plugin 3 / controller 2 / action 1
>  - plugin 3 / controller 2 / action 2
>
> Role 2 access
>  - plugin 1
>  - plugin 1 / controller 1
>  - plugin 1 / controller 1 / action 1
>  - plugin 1 / controller 2 / action 2
>
>  - plugin 3
>  - plugin 3 / controller 1
>  - plugin 3 / controller 1 / action 1
>  - plugin 3 / controller 2 / action 1
>  - plugin 3 / controller 2 / action 2
>
> anyone can help me... please i need your help... i'm creating a
> scalable app..
>
> Thanks,
>
> Bryan

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Component code

2010-09-03 Thread alaxos
Hello,

You can call a model function from a component.

Here's a way to do it:

-
class MyComponent
{
  private $controller;

  public function initialize(&$controller)
  {
$this->controller = $controller;
  }

  public function my_function()
  {
$this->controller->Order->function();
  }
}
-

Just test if $this->controller->Order and/or $this->OrderItem->Order
are set, depending on your needs.

Regards,
Nico

On 3 sep, 07:05, Jeremy Burns | Class Outfit
 wrote:
> I should mention that I both read from and write to the session...
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.com
> (t) +44 (0) 208 123 3822
> (m) +44 (0) 7973 481949
> Skype: jeremy_burnshttp://www.classoutfit.com
>
> On 3 Sep 2010, at 06:00, Dave Maharaj wrote:
>
> > Place the code in the model and pass the Session data as vars from the
> > controller?
>
> > -Original Message-
> > From: Jeremy Burns [mailto:jeremybu...@classoutfit.com]
> > Sent: September-03-10 2:24 AM
> > To: CakePHP
> > Subject: Component code
>
> > I have a chunk of code that appears in two controllers
> > (orders_controller and order_items_controller) that is virtually
> > identical in each case. I'd like to move it to a single location, so
> > this sounds like an ideal candidate for a component.
>
> > Part of the code calls a function in the Order model, so whilst one
> > calls it via $this->Order->function() the other calls it via $this-
> >> OrderItem->Order->function(); hence the difference.
>
> > I could also consider moving the code into the Order model and calling
> > it from both controllers, but unfortunately the code also refers to
> > $this->Session, which is not allowed in models.
>
> > So I'm stuck. I can't move it to a component because a component can't
> > call a model function, and I can't move it to a model because a model
> > can't talk to the Session.
>
> > Any ideas?
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > 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
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Customizing the HTML generated by the paginator->numbers() method

2010-06-17 Thread alaxos
Hi,

I'm not aware of the CSS technique you mention, but if the $option
array of the numbers() method can't help you, what I would personally
do is creating my own Helper in my app inheriting from the core
PaginatorHelper.

This would allow to override the numbers() method to do what you need,
without modifying the core helper. Modifying code under the cake
folder is always a bad idea and in your case it can easily be avoid by
using inheritance.


On 17 juin, 00:25, mvanderw  wrote:
> Hi all,
>
> I'm getting ready to deploy my first full-blown Cake app and am
> polishing the last bits and pieces of the front-end. One of the things
> I'd like to do is to use the sliding doors CSS technique to create
> reusable buttons. For this purpose I'd like to generate spans inside
> the anchor tags that the Paginator helper outputs, but it doesn't seem
> like the numbers() method accepts any option that lets me do that.
>
> Am I overlooking something, or will I have to hack PaginatorHelper to
> generate spans inside the anchors?
>
> Thanks in advance for any pointers!
>
> - Mike

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Validate data & md5

2010-06-04 Thread alaxos
If you don't want to reenter the password, you can use a different
name for the password input.

For instance:

View:

$this->Form->input('new_password', array('type' => 'password'));

Controller:

if(!empty($this->data['User']['new_password']))
{
$this->data['User']['password'] = $this->Auth->password($this-
>data['User']['new_password']);
}

This way if your form is printed again, the field new_password is not
hashed.

Regards,
nIcO

On 4 juin, 19:08, vekija  wrote:
> When you have an error on the registration form, it is a best practice
> to clear the password value and force the user to renter that info.
>
> So, in the controller...
>
> if($this->User->save($this->data)) {
>    // ... whatever you do after user had registered successfully} else {
>
>  // ... there was an error
>  $this->data['User']['password'] = null;
>
> }
>
> V
>
> On Jun 4, 4:21 pm, Chrriss  wrote:
>
> > Hi,
>
> > I have a form to add a user and I use an md5 encryption when I save
> > the password in the database.
> > I use $validate to check if the email address is valid. If it's not,
> > the form shows the data again with the error message but the password
> > is not the right one in this case. It's the hashed password. So when I
> > re-enter a valid email address, the password that is saved in the
> > database is not the one I wanted!
>
> > How can I do ?
>
> > Thank you in advance!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 do I save a field on my User without breaking the ACL?

2010-06-04 Thread alaxos
The point is that Session is not defined in models. So if you do like
this, you will have to do it each time you want to save a User without
the group_id field, in each of your controller's actions.

Doing it directly in the model allows you to care about the presence
of the group_id field only once. But it is done through an extra SQL
query to retrieve the group_id value. We could of course retrieve the
group_id in the model by directly using the $_SESSION variable.

By the way, I have always wondered if it was a design choice to not
have access to the CakeSession object in the model. If anyone has the
answer, I would be happy to read it.

nIcO


On 4 juin, 22:25, stefano  wrote:
> try with
>
> $this->data["User"]["group_id"] = $this->Session-
>
> >read("Auth.User.group_id");
>
> :)
>
> s.
>
> On May 24, 10:59 am, Jon Chin  wrote:
>
> > I'm using Auth and db ACL, but I have an action that screws up my ACL
> > records every time.  I have ACL set up just like the Book instructs.  I'm
> > building a "change password" page where I want to just update the password.
> >  I run the following commands:
> >  $this->User->id = $this->Session->read('Auth.User.id');
> > $this->User->saveField('password', $this->data['User']['password']);
> > (I've also tried $this->User->save()).  When I execute this, it deletes the
> > user's parent_id from the aros table as well as corrupts the tree-ness of
> > the ACL tables.  What am I doing wrong?  Thanks in advance.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 do I save a field on my User without breaking the ACL?

2010-06-04 Thread alaxos
Hi !

If you used the code given in the Simple Acl controlled application,
it doesn't work out of the box if you save only one User's field.

The parentNode() function check if the group_id field is not empty,
and if it is, it returns null. This makes the Acl component think the
User doesn't have any parent to store in the Aros.

If you save only one field - without the goup_id field - you will have
to reload the group_id value.

I use the following code:

function parentNode()
{
if (!$this->id && empty($this->data))
{
return null;
}

$data = $this->data;

if (empty($this->data))
{
$data = $this->read();
}
elseif(isset($this->id) && empty($data['User']['role_id']))
{
/*
 * The role_id field was not intended to be saved,
 * but we need it in order to find the parent node in the
Aros
 */
$data['User']['role_id'] = $this->field('role_id',
array('User.id' => $this->id));
}

if (empty($data['User']['role_id']))
{
return null;
}
else
{
return array('Role' => array('id' => $data['User']
['role_id']));
}
}

Just replace role_id by groupid or whatever name you used.

Regards,
nIcO


On 4 juin, 17:53, stefano  wrote:
> i have the same problem :( any idea??
>
> On May 24, 9:25 pm, Jon Chin  wrote:
>
> > I tried that and have the same result.  Do I need to unbind a relationship
> > or something?
>
> > On Mon, May 24, 2010 at 2:06 PM, Filipe Teles Rodrigues <
>
> > filipe.t2...@gmail.com> wrote:
> > > I use $this->User->save($this->data) instead of saveField.
>
> > > 2010/5/24 Jon Chin 
>
> > >> I'm using Auth and db ACL, but I have an action that screws up my ACL
> > >> records every time.  I have ACL set up just like the Book instructs.  I'm
> > >> building a "change password" page where I want to just update the 
> > >> password.
> > >>  I run the following commands:
> > >>  $this->User->id = $this->Session->read('Auth.User.id');
> > >> $this->User->saveField('password', $this->data['User']['password']);
> > >> (I've also tried $this->User->save()).  When I execute this, it deletes
> > >> the user's parent_id from the aros table as well as corrupts the 
> > >> tree-ness
> > >> of the ACL tables.  What am I doing wrong?  Thanks in advance.
>
> > >> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > >> others with their CakePHP related questions.
>
> > >> 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 > >>  om>For more options, visit this group at
> > >>http://groups.google.com/group/cake-php?hl=en
>
> > >  Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > > others with their CakePHP related questions.
>
> > > 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 > >  om>For more options, visit this group at
> > >http://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


ACL with routes

2010-05-03 Thread alaxos
Hi all,

I have a question regarding the usage of ACL with routes.

A long time ago (when ACL was only based on the INI file...) I wrote a
component that allows me to easily grant/block access to actions
depending on roles the authenticated users are linked to. Its
configuration allows to check for distinct action names or by granting/
blocking access on whole routes.

This allows me to say for instance that all admin_xxx actions can be
accessed only by users linked to an ADMIN role, and manage_xxx actions
can only be accessed by users linked to a MANAGER role.

But today I'm really considering to replace my custom Component by the
ACL + Auth core components, as it has become fully usable over time. I
have read the ACL doc and made the ACL tutorial, and I didn't see
anything about using routes as ACOs.

So my question is simple, is the ACL configurable in a way that routes
can be considered as ACOs ? Or do we have to manage ACL rights each
time a new action is added in a controller if we want a user/group to
be able to access the new action ?

Thanks,
Nicolas

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Custom library functions

2009-08-12 Thread alaxos

Excellent, that will really help to keep my code clean.

Thanks a lot for your answers,
nIcO


On 11 août, 17:13, Martin Westin  wrote:
> If you start adding more functions you may want to put them into a
> separate file.
> The top of my bootstrap.php looks like this:
>
> // This would mess things up royally--> App::import('Vendor',
> 'basics');
> require_once(APP.'vendors'.DS.'basics.php');
>
> I mention it mostly because you have to do a good old require unless
> you want Cake's internals all confused. App::import() can't be used
> because of Cake's bootstrapping order. Simply put bootstrap.php is
> loaded before the "App" is ready to run. It took me a lot of time and
> effort to track down that this was the cause for all sorts of
> strangeness.
>
> /Martin
>
> On Aug 11, 4:54 pm, Robert P  wrote:
>
> > The file /app/config/bootstrap.php is there for this exact reason.
>
> > On Aug 11, 8:56 pm, alaxos  wrote:
>
> > > Hello,
>
> > > I have tried to figure out what would be the best way to add generic
> > > functions to an app, in order to then be able to use them everywhere
> > > in a Cake application.
>
> > > I wrote some time ago (nothing to do with cake) classes with methods
> > > that I use to do different things. They are generic classes, that I
> > > use for instance to manipulate strings, or whatever.
>
> > > I could off course copy/paste them in my components or helper that
> > > need them, but I would prefer to have it written at only one place,
> > > and be able to call it from everywhere.
>
> > > I could also for instance include the files I need somewhere in the
> > > app (in 'app_controller.php' maybe).
>
> > > But I'd like to know what would be the best way to do it in order to
> > > respect the Cake guidelines ?
>
> > > 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
-~--~~~~--~~--~--~---



Custom library functions

2009-08-11 Thread alaxos

Hello,

I have tried to figure out what would be the best way to add generic
functions to an app, in order to then be able to use them everywhere
in a Cake application.

I wrote some time ago (nothing to do with cake) classes with methods
that I use to do different things. They are generic classes, that I
use for instance to manipulate strings, or whatever.

I could off course copy/paste them in my components or helper that
need them, but I would prefer to have it written at only one place,
and be able to call it from everywhere.

I could also for instance include the files I need somewhere in the
app (in 'app_controller.php' maybe).

But I'd like to know what would be the best way to do it in order to
respect the Cake guidelines ?

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



Multiple INNER JOIN

2009-07-01 Thread alaxos

Hello,

I have a situation where I need to make a query with multiple INNER
JOIN. I'm developping my sport club website and here is the situation:
users belong to teams, teams belong to seasons, teams belong to
teamcategories, and teams belong to leagues.

On the users details page, I'd like to display all the teams the user
belonged to, with the whole history. It should look like this:

Season 2009
  Championship
League 1
  Team n°1,
  Cup
League 2
  Team n°4

Season 2008
  Championship
League 2
  Team n°3
...

Getting only the needed data for a specific user is easy with a custom
SQL query with multiple INNER JOIN like this:

$this->set('teams', $this->User->query('SELECT * FROM ctt_teams as
Team
INNER JOIN ctt_users_teams as UserTeam ON Team.id = UserTeam.team_id
NNER JOIN ctt_teamcategories as Teamcategory ON Teamcategory.id =
Team.teamcategory_id
INNER JOIN ctt_saisons as Saison ON Saison.id = Team.saison_id
INNER JOIN ctt_ligues as Ligue ON Team.ligue_id = Ligue.id
WHERE UserTeam.user_id = ' . $id . '
ORDER BY Saison.dateDebut DESC, Ligue.order, Team.numero'));

But I'd like to know what is the best Cake way to achieve this.

I tried to use Model->unbindModel() and Model->bindModel() methods.
Even if I think I succeeded to get the needed data (and only the
needed data), I'm unable to understand how to sort these data.
And I'm wondering if what I do is correct, as playing with models
relations seems to ask to write more code that using the query()
method with my own SQL query.

Here the code I wrote with model methods:

$this->User->unbindModel(array('hasAndBelongsToMany' => array('Role',
'Team', 'Saison')));
$this->User->Team->unbindModel(array('hasMany' => array('Message'),
'hasAndBelongsToMany'=>array('User'),  'belongsTo' => array('Saison',
'Ligue')));
$this->User->Team->Saison->unbindModel(array('hasMany' => array
('Team'), 'hasAndBelongsToMany' => array('User')));
$this->User->Team->Teamcategory->unbindModel(array('hasMany' => array
('Team')));

$this->User->bindModel(array('hasAndBelongsToMany' => array('Team' =>
array('joinTable' => 'users_teams';
$this->User->Team->bindModel(array('belongsTo' => array('Saison' =>
array('foreignKey' => 'saison_id';

$this->User->recursive = 2;
$this->set('user', $this->User->read(null, $id));

Could you please tell me how you would do 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
-~--~~~~--~~--~--~---