Re: use multi lang in cakephp 1.3.*

2010-11-12 Thread Tilen Majerle
yes you can...

how to do it...look here
http://book.cakephp.org/view/1228/Internationalization-Localization

--
Tilen Majerle
http://majerle.eu



2010/11/13 hoss7 

> how can i create  multi lang website?
>
> 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.comFor
>  more options, visit this group at
> http://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


use multi lang in cakephp 1.3.*

2010-11-12 Thread hoss7
how can i create  multi lang website?

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: Encrypted text does not get saved in the db

2010-11-12 Thread laduree
So, after trying everything I could think of, I baked a new project
with as fewer code as possible, and I am able to insert an encrypted
value in the database without any problem.

I don't know what was causing the problem. I'll keep testing
tomorrow.

Thanks for all who took the time to read and help me.

On Nov 12, 9:44 pm, laduree  wrote:
> I tried running the query manually with $this->Message->query() and
> the same happens, it will work correctly when a value is not encrypted
> or with a hardcoded value, but will not work with encrypted values, it
> leaves that field in the database empty.
>
> On Nov 12, 7:57 pm, laduree  wrote:
>
>
>
>
>
>
>
> > I did that and the data is there, if I hardcode a value it is entered
> > correctly in the database, if I don't encrypt it it is entered
> > correctly as well. It seems mysql is just not accepting the encrypted
> > string.
>
> > // After:
> > // if(!empty($this->data)) {
> > //     die(debug($this->data));
> > [Message] => Array
> >         (
> >             [to] => m...@gmail.com
> >             [msg] => This is a string
> >         )
>
> > // After:
> > // if($this->Message->save($this->data)){
> > //     die(debug($this->data));
> > [Message] => Array
> >         (
> >             [to] => m...@gmail.com
> >             [msg] => ÙYÃu`ï·۹ñ$!ó]
> >             [user_id] => 1
> >         )
>
> > On Nov 12, 7:46 pm, cricket  wrote:
>
> > > On Fri, Nov 12, 2010 at 1:13 PM, laduree  wrote:
> > > > I tried using Security::cipher and the same thing happened with the
> > > > same SQL output.
>
> > > > The weirdest thing is that the data is not going missing at any point
> > > > as I had passed it to the view using $this->set() both before and
> > > > after encryption with the following result:
>
> > > > Message: This string will be encrypted
> > > > Encrypted message: T j/ ު޶ l3 ] *RS I+ } Wl
>
> > > Try:
>
> > > if(!empty($this->data)) {
> > >     die(debug($this->data));

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: Doubt about admin routes / actions and Auth component

2010-11-12 Thread huoxito
I have this in my app_controller

var $components = array('Session', 'Auth');

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


# thanks to 
http://padariadodenilson.wordpress.com/2010/10/04/criando-uma-area-administrativa-com-cakephp/
if (isset($this->params['admin'])) {
$this->Auth->deny('*');
} else {
$this->Auth->allow('*');
}

$this->Auth->fields = array('username' => 'name', 'password'
=> 'password');
//$this->Auth->loginError = "No, you fool!  That's not the
right password!";
//$this->Auth->loginAction = array('admin' => false,
'controller' => 'users', 'action' => 'login');
//$this->Auth->loginRedirect = array('controller' =>
'usuarios', 'action' => 'afterLogin');
$this->Auth->authError = "Você precisa estar logado para
entrar no sistema.";
}

My routes config are:

Router::connect("/admin/:controller/:action/*", array('prefix' =>
'admin', 'admin' => true));


this way admin methods are protected but if I take off that condition
e Auth allows really everything,
thanks for helping

On 12 nov, 15:50, cricket  wrote:
> On Thu, Nov 11, 2010 at 11:44 PM, huoxito  wrote:
> > Thats what I thought as well, but it doesnt happen,
>
> > If I just let $this->Auth->allow(‘*’) in my app_controller all actions
> > are accessible without being logged in, even my admin_* methods
>
> Perhaps Auth isn't properly configured in
> AppController::beforeFilter(). Could you post that?

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: Paginate Multiple Models in the same view

2010-11-12 Thread Arak Tai'Roth
Anyone have any other ideas?

On Nov 12, 12:56 am, "Arak Tai'Roth"  wrote:
> That doesn't work, it actually disabled the working pagination on the
> Image model.
>
> I know there is a model option that can be set in the Paginator
> options, I'm wondering if it can be used for this purpose. But I have
> been unable to find anything that lists how it's used and what exactly
> it does or is used for.
>
> On Nov 11, 9:39 pm, Amit Badkas  wrote:
>
> > Hi,
>
> > Just like you set different options for $paginate in controller's action, I
> > think you need to do it for helper too, something like
>
> > $this->Paginator->options(array(
> >                'Image' => array('update' => .),
> >                'Floorplan' => array('update' => .)
> >        ));
>
> > should work.
>
> > Amit
>
> > PHP Applications for E-Biz:http://www.sanisoft.com
>
> > On Fri, Nov 12, 2010 at 8:00 AM, Arak Tai'Roth 
> > wrote:
>
> > > Hey everyone,
>
> > > I have what I thought was a simple problem, but haven't been able to
> > > find anything regarding it. Everything I can find is based off of
> > > paginating different sets of data but all from the same model.
>
> > > I have two models that are related to the model that the view is based
> > > off of. So I have a view that shows a single product, in that
> > > controller each product can have multiple images and multiple
> > > floorplans, as such:
>
> > > var $hasMany = array(
> > >        'Image' => array(
> > >                'className' => 'Image',
> > >                'dependant' => true,
> > >                'exclusive' => true
> > >        ),
> > >        'Floorplan' => array(
> > >                'className' => 'Floorplan',
> > >                'dependant' => true,
> > >                'exclusive' => true
> > >        )
> > > );
>
> > > Now I am getting the data alright with the following code in my
> > > Products controller:
>
> > > var $paginate = array(
> > >        'Image' => array(
> > >                'fields' => array(
> > >                        'Image.filename', 'Image.caption'
> > >                ),
> > >                'limit' => 3,
> > >                'order' => array(
> > >                        'Image.id' => 'asc'
> > >                )
> > >        ),
> > >        'Floorplan' => array(
> > >                'fields' => array(
> > >                        'Floorplan.filename', 'Floorplan.floorplan_name',
> > > 'Floorplan.floorplan_price'
> > >                ),
> > >                'limit' => 1,
> > >                'order' => array(
> > >                        'Floorplan.id' => 'asc'
> > >                )
> > >        )
> > > );
>
> > > $dbImages = $this->paginate('Image', array('product_id' =>
> > > $dbProduct['Product']['id']));
> > > $dbFloorplans = $this->paginate('Floorplan', array('product_id' =>
> > > $dbProduct['Product']['id']));
>
> > > However the problem becomes apparent when I go to implement the
> > > pagination in the view, I have to set the options for the paginator,
> > > so it knows what div to update and what to do on before and complete
> > > callbacks.
>
> > >  > >        $this->Paginator->options(array(
> > >                'update' => '#showProducts',
> > >                'evalScripts' => true,
> > >                'before' => 
> > > $this->Js->get('#image_box')->effect('fadeOut'),
> > >                'complete' => 
> > > $this->Js->get('#image_box')->effect('fadeIn',
> > > array('speed' => 'slow'))
> > >        ));
> > > ?>
>
> > > However, this only works for the Image model, because I need to update
> > > a different div for the Floorplans model and use different before and
> > > complete callbacks.
>
> > > Is there anyway to do this?
>
> > > 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.comFor
> > >  more options, visit this group at
> > >http://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


problem with links helper

2010-11-12 Thread Dobrogor
Hi all!
I have a little problem.
I want to use russian languale at my links in main menu. I create my
links with html helper.

For example, if i write  in code
Html->link('Works', array('controller' =>
'art_works', 'action' => 'show')) ?>

output will be like this
Works
Its work fine. 'test' - its my project name

But if I wrote title of link in another language, like russian:
Html->link('Работы', array('controller' =>
'art_works', 'action' => 'show')) ?>

output will be like this

Thats why link dont displayed

Please - help me frieds!!! I dont understand why its dont work. I
almost finished my site, but i detected this problem. :(

Thanks.

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


Help with Joins

2010-11-12 Thread Dave Maharaj
No matter what I try I cant get this to work.

 

I need to pull all records from Offer only if not in Reject

 

I tried manual JOINS but all I ever get is a list of all Reject records.

 

SELECT DISTINCT `Offer`.`id` ,  `Offer`.`title` , `Reject` . *

FROM `Offers` AS `Offer`

LEFT JOIN `Rejects` AS `Reject` ON ( `Offer`.`id` = `Reject`.`offer_id` )

WHERE `Reject`.`offer_id` = `Offer`.`id`

AND `Reject`.`profile_id` = '4b4ff09c-2580-4e21-9dbf-36b74adcd75b'

ORDER BY `Offer`.`created` DESC

LIMIT 15

 

Just trying the query directly in SQL phpMyAdmin window,  then if I can get
it to work I will put it in the model..

 

 

Basic English is there are 100 Offers as User goes thru offers they Reject
which creates a record in Reject with id, profile_id and offer_id

So the offer list that has 100 total records / user rejected 25 so that's
users list will actually only display 75 records.

 

Offers are for various users so simply deleting the offer is not an option

 

Tried=>  AND `Reject`.`Offer_id` != `Offer`.`id`but nothing is returned

 

Ideas?

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


mysql connection refused

2010-11-12 Thread rogwei
The subject search phrase returns 0 items in this group which
surprises me a little, and google isn't. Anyway, I upgraded my DB
server Ubuntu 9.10 to 10.04 LTS, and now when I try to access my
application I get the following warning and a missing database table
error. One factoid, I CAN connect with phpmyadmin using the same host
and credentials.

The only my.cnf file on the server uses port 3306. Not sure what to do
or whose issue this is. Any help?

Warning (2): mysql_connect() [function.mysql-connect]: [2002]
Connection refused (trying to connect via tcp://x.x.x.x:3306) [CORE/
cake/libs/model/datasources/dbo/dbo_mysql.php, line 552]
Code | Context
$config =   array(
"persistent" => false,
"host" => "x.x.x.x",
"login" => "x",
"password" => "",
"database" => "xx",
"port" => "3306",
"driver" => "mysql",
"prefix" => ""
)
mysql_connect - [internal], line ??
DboMysql::connect() - CORE/cake/libs/model/datasources/dbo/
dbo_mysql.php, line 552
DboSource::__construct() - CORE/cake/libs/model/datasources/
dbo_source.php, line 143
ConnectionManager::getDataSource() - CORE/cake/libs/model/
connection_manager.php, line 114
Model::setDataSource() - CORE/cake/libs/model/model.php, line 2818
Model::__construct() - CORE/cake/libs/model/model.php, line 469
AclNode::__construct() - CORE/cake/libs/model/db_acl.php, line 62
ClassRegistry::init() - CORE/cake/libs/class_registry.php, line 141
DbAcl::__construct() - CORE/cake/libs/controller/components/acl.php,
line 237
AclComponent::__construct() - CORE/cake/libs/controller/components/
acl.php, line 58
Component::_loadComponents() - CORE/cake/libs/controller/
component.php, line 249
Component::init() - CORE/cake/libs/controller/component.php, line 78
Controller::constructClasses() - CORE/cake/libs/controller/
controller.php, line 487
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 186
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - /Users/Roger/Sites/uypBarebones/index.php, line 84

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: Encrypted text does not get saved in the db

2010-11-12 Thread laduree
I tried running the query manually with $this->Message->query() and
the same happens, it will work correctly when a value is not encrypted
or with a hardcoded value, but will not work with encrypted values, it
leaves that field in the database empty.

On Nov 12, 7:57 pm, laduree  wrote:
> I did that and the data is there, if I hardcode a value it is entered
> correctly in the database, if I don't encrypt it it is entered
> correctly as well. It seems mysql is just not accepting the encrypted
> string.
>
> // After:
> // if(!empty($this->data)) {
> //     die(debug($this->data));
> [Message] => Array
>         (
>             [to] => m...@gmail.com
>             [msg] => This is a string
>         )
>
> // After:
> // if($this->Message->save($this->data)){
> //     die(debug($this->data));
> [Message] => Array
>         (
>             [to] => m...@gmail.com
>             [msg] => ÙYÃu`ï·۹ñ$!ó]
>             [user_id] => 1
>         )
>
> On Nov 12, 7:46 pm, cricket  wrote:
>
>
>
>
>
>
>
> > On Fri, Nov 12, 2010 at 1:13 PM, laduree  wrote:
> > > I tried using Security::cipher and the same thing happened with the
> > > same SQL output.
>
> > > The weirdest thing is that the data is not going missing at any point
> > > as I had passed it to the view using $this->set() both before and
> > > after encryption with the following result:
>
> > > Message: This string will be encrypted
> > > Encrypted message: T j/ ު޶ l3 ] *RS I+ } Wl
>
> > Try:
>
> > if(!empty($this->data)) {
> >     die(debug($this->data));

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: Site Development from Start to Finish

2010-11-12 Thread naidim
I don't understand. Without the var $uses = array('User', 'Drug',
etc.) line, calls to $this->User->find() give this error: Fatal error:
Call to undefined method stdClass::find() With the uses line, it works
fine.

On Nov 12, 11:13 am, Shaz  wrote:
> It's better practice to use model relationships rather than $uses.
> i.e. $this->User->Drug->find();

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: Why only pass $data to view instead of model instance?

2010-11-12 Thread Miles J
I dislike this also. Cake really should have more than 1 model type:
DAOModel and DataModel.

One deals with database interactions, while the other manipulates a
dataset for the view.

However, there is nothing stopping you creating these extra models.

$this->set('data', new UserDataModel($this->User->find()));

On Nov 12, 5:23 am, Joshua Muheim  wrote:
> I'd like to warm up this topic again. :-)
>
> I decided to pass model instances to the views instead of just their
> $data attributes. So is there a way to tweak the paginator to do
> exactly this?
>
> Thanks,
> Josh
>
> On Thu, Oct 28, 2010 at 8:26 PM, euromark  wrote:
> > i tend to do those things "on demand"
> > using a behavior to add new keys or even doing it in the model
> > afterFind() etc often results in additional work without actually
> > needing this information
> > but of course this depends on the particular case
>
> > On 28 Okt., 20:10, cricket  wrote:
> >> On Thu, Oct 28, 2010 at 10:03 AM, euromark  
> >> wrote:
> >> > thats not correct for PHP5 anymore
> >> > in PHP4 you needed to do this
> >> > but in PHP5 it is passed by reference by default, afaik
>
> >> Agreed on passing the model to the view. But this could also be
> >> accomplished in afterFind(), adding new key => value to the data
> >> array.
>
> > 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: Is there a reason why I shouln't make $this->Html available in views as $html? --psybear

2010-11-12 Thread Miles J
It was mainly so that user variables don't overwrite helper variables.
I ran into this problem a few times during my 1.2 days.

If it really bothers you that much.

$f = $this->Form;

On Nov 12, 5:25 am, Joshua Muheim  wrote:
> I don't see the big deal, too. I just wondered whether there's a
> knockout argument for doing it the CakePHP-way. But I guess I will
> stick to the CakePHP-way now for some time and see later if I still
> want to change it... :-)
>
> On Fri, Nov 12, 2010 at 2:23 PM, Jeremy Burns | Class Outfit
>
>  wrote:
> > I like the way Cake does it, regardless of what else others do. I can 
> > imagine that if you had a helper function called "display" and then you 
> > added another helper that had a function with the same name you *could* 
> > isolate and rectify the clashes, but I'd rather avoid that extra work in 
> > the first place by just pre-pending the helper name in the first place. I 
> > don't see the big deal.
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.com
> >http://www.classoutfit.com
>
> > On 12 Nov 2010, at 08:18, Joshua Muheim wrote:
>
> >> I'd really like to know why it has switched to $this->Html. Is there a
> >> decision log or something for CakePHP?
>
> >> Coming from the RoR world (which is far more widespread in the
> >> webworld than CakePHP, I guess) I like things as simple as anyhow
> >> possible, even if you have to stick to some conventions for its sake.
> >> I haven't worked with RoR since 2 years or so, so maybe things have
> >> changed now, but up then as far as I remember things like helper
> >> methods had been mixed right into the view *without* anything like a
> >> $helper method or so.
>
> >> E.g. a helper Bla with methods abc and xyz were accessible in the view
> >> directly by calling abc and xyz, so you had to see for yourself that
> >> no collisions appeared (and if one did, I guess you would still have
> >> been able to distinguish your helpers by prepending the helper's name,
> >> e.g. Bla.abc or Foo.abc).
>
> >> So RoR went the way that's the most convenient to use, and by having a
> >> good test battery in the background conflicts like the mentioned above
> >> were located and fixed easily while still having all the convenience
> >> in those spots that didn't have collisions (which are in most cases
> >> many more than the ones that do).
>
> >> Well, just writing some thoughts down here, no intention to blame
> >> CakePHP or something... I'm just curious about some stuff... ;-)
>
> >> On Fri, Nov 12, 2010 at 1:41 PM, euromark  
> >> wrote:
> >>> actually its the other way around
> >>> it used to be $html and NOW is $this->Html (cake >=1.3)
> >>> and yes, there are plenty reasons why this is now a view object (and
> >>> not just an object variable)
>
> >>> it is a bad idea to want to go back to the old syntax
>
> >>> and your argument is bad: For the sake of simplicity $this->Html makes
> >>> more sense (no collisions in the view anymore)
>
> >>> hope that clears things up
>
> >>> On 12 Nov., 11:42, psybear83  wrote:
>  Hi everybody
>
>  For the sake of simplicity I'd like to make my helpers available in my
>  views not as $this->Helper but as $helper using the set(...) method in
>  the controller.
>
>  Is there any reason why this could be a bad idea? Or is there already
>  an option to tell CakePHP to make the helpers available this way?
>
>  Thanks for help
>  Josh
>
> >>> 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 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 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 re

Re: Encrypted text does not get saved in the db

2010-11-12 Thread laduree
I did that and the data is there, if I hardcode a value it is entered
correctly in the database, if I don't encrypt it it is entered
correctly as well. It seems mysql is just not accepting the encrypted
string.

// After:
// if(!empty($this->data)) {
//     die(debug($this->data));
[Message] => Array
(
[to] => m...@gmail.com
[msg] => This is a string
)


// After:
// if($this->Message->save($this->data)){
// die(debug($this->data));
[Message] => Array
(
[to] => m...@gmail.com
[msg] => ÙYÃu`ï·۹ñ$!ó]
[user_id] => 1
)

On Nov 12, 7:46 pm, cricket  wrote:
> On Fri, Nov 12, 2010 at 1:13 PM, laduree  wrote:
> > I tried using Security::cipher and the same thing happened with the
> > same SQL output.
>
> > The weirdest thing is that the data is not going missing at any point
> > as I had passed it to the view using $this->set() both before and
> > after encryption with the following result:
>
> > Message: This string will be encrypted
> > Encrypted message: T j/ ު޶ l3 ] *RS I+ } Wl
>
> Try:
>
> if(!empty($this->data)) {
>     die(debug($this->data));

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: CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear

2010-11-12 Thread Miles J
It will error out when you try to access a component that doesn't
exist. Adding an invalid string to an array should not cause CakePHP
to barf errors.

On Nov 12, 10:09 am, cricket  wrote:
> On Fri, Nov 12, 2010 at 5:05 AM, psybear83  wrote:
> > Hi all
>
> > I don't get it why CakePHP doesn't complain about stuff like when one
> > specifies missing components or fixtures:
>
> > var $components = array('SomeNotExistingComponent');
> > var $fixtures = array('app.this_fixture_does_not_exist');
> > App::import('Lib', 'TheresNoSuchFileInLib');
>
> > All the three lines do not result in any error, and I guess there's
> > more of that like $uses or stuff, but I didn't investigate this any
> > further.
>
> It would have taken you all of ... four seconds? ... to add 'Foo' to
> some controller's $uses array and load up a route pointing to it.
>
> For those who can't bear the suspense: Cake will complain that the
> table for the model is missing. Remember that Cake can "virtualize" a
> model, so a missing model class is not necessarily a show-stopper.
>
> > Can anyone tell me why CakePHP just doesn't care about stuff like
> > that? Seems vry unresponsible to me...
>
> It's not that Cake "doesn't care"--it'll simply return false when, eg.
> failing to load a missing component. What's "unresponsible" is listing
> components, plugins, etc. that don't exist.

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: Encrypted text does not get saved in the db

2010-11-12 Thread cricket
On Fri, Nov 12, 2010 at 1:13 PM, laduree  wrote:
> I tried using Security::cipher and the same thing happened with the
> same SQL output.
>
> The weirdest thing is that the data is not going missing at any point
> as I had passed it to the view using $this->set() both before and
> after encryption with the following result:
>
> Message: This string will be encrypted
> Encrypted message: �T�j/�ު޶�l3�] *RS I+ }�Wl�

Try:

if(!empty($this->data)) {
die(debug($this->data));

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: Encrypted text does not get saved in the db

2010-11-12 Thread laduree
I tried using Security::cipher and the same thing happened with the
same SQL output.

The weirdest thing is that the data is not going missing at any point
as I had passed it to the view using $this->set() both before and
after encryption with the following result:

Message: This string will be encrypted
Encrypted message: �T�j/�ު޶�l3�] *RS I+ }�Wl�



On Nov 12, 6:57 pm, cricket  wrote:
> On Thu, Nov 11, 2010 at 4:13 PM, laduree  wrote:
> > I have some data coming from a form, and I'm trying to encrypt part of
> > it and save it in a mysql db. Everything gets saved, except the
> > encrypted field, which is empty when I look in the database.
>
> > I'm new to CakePHP and wasn't successful googling for a solution,
> > thanks for taking the time to read this.
>
> > /*
> >  * Encrypts and saves message
> >  */
> > function compose() {
> >                if(!empty($this->data)) {
>
> >                        $this->data['Message']['user_id'] = $this->Session-
> >>read('Auth.User.id');
>
> >                        // Encrypt message
> >                        $security = new Security;
>
> >                        $this->data['Message']['msg'] = 
> > $security->cipher($this-
> >>data['Message']['msg'],
> >                                                                             
> >                    Configure::read('Security.cipherSeed'));
>
> >                        // Save message
> >                        if($this->Message->save($this->data)){
> >                                $this->Session->setFlash('Ok', 'flash_ok');
> >                        } else {
> >                                $this->Session->setFlash('Error');
> >                        }
> >                }
> >        }
> > }
>
> Instead of instantiating Security, try:
>
> $this->data['Message']['msg'] =
> Security::cipher($this->data-'Message']['msg'],
> Configure::read('Security.cipherSeed'));
>
> You might also want to use $this->log() in a few places to try to
> track down where it's going missing. Especially *before* you call
> cipher(). Are you certain that the data is even there to begin with?
> Check your form fields and the submitted data array.

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: Site Development from Start to Finish

2010-11-12 Thread Shaz
It's better practice to use model relationships rather than $uses.
i.e. $this->User->Drug->find();

On Nov 12, 4:30 pm, naidim  wrote:
> For the homepage controller, if User and Drug are not related but you
> want to use those models, you have to include them both. Maybe I
> should specify that, thanks.
>
> Not sure I understand the 1.3 point. 'add' was added because I noticed
> scaffold methods are not allowed when you allow('*'); so you have to
> allow it specifically. Is that what the "^^" does?
>
> I don't change my hash, but just mention the option is there because
> others might want to. How important is it to not change it?
>
> I totally don't understand the last point, sorry.
>
> On Nov 10, 7:07 pm, euromark  wrote:
>
> > a few things
>
> > var $uses = array('User', 'Drugs');
> > i guess the drugs are related to users?
> > var $uses = array('User');
> > might be just enough then
>
> > you mix 1.3 helper syntax and old syntax
>
> > $this->Auth->allow('*', 'add');
> > probably was meant to be
> > $this->Auth->allow('*'); ^^
>
> > i would not change the security hash function (and not to md5 in
> > particular)
>
> > "$this->Auth->loginRedirect" etc
> > careful: the urls should contain admin=>false and plugin=>false to
> > avoid problems if you are
> > in those routes!
>
> > other than that a nice tutorial for beginners

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: CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear

2010-11-12 Thread cricket
On Fri, Nov 12, 2010 at 5:05 AM, psybear83  wrote:
> Hi all
>
> I don't get it why CakePHP doesn't complain about stuff like when one
> specifies missing components or fixtures:
>
> var $components = array('SomeNotExistingComponent');
> var $fixtures = array('app.this_fixture_does_not_exist');
> App::import('Lib', 'TheresNoSuchFileInLib');
>
> All the three lines do not result in any error, and I guess there's
> more of that like $uses or stuff, but I didn't investigate this any
> further.

It would have taken you all of ... four seconds? ... to add 'Foo' to
some controller's $uses array and load up a route pointing to it.

For those who can't bear the suspense: Cake will complain that the
table for the model is missing. Remember that Cake can "virtualize" a
model, so a missing model class is not necessarily a show-stopper.

> Can anyone tell me why CakePHP just doesn't care about stuff like
> that? Seems vry unresponsible to me...

It's not that Cake "doesn't care"--it'll simply return false when, eg.
failing to load a missing component. What's "unresponsible" is listing
components, plugins, etc. that don't exist.

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: Encrypted text does not get saved in the db

2010-11-12 Thread cricket
On Thu, Nov 11, 2010 at 4:13 PM, laduree  wrote:
> I have some data coming from a form, and I'm trying to encrypt part of
> it and save it in a mysql db. Everything gets saved, except the
> encrypted field, which is empty when I look in the database.
>
> I'm new to CakePHP and wasn't successful googling for a solution,
> thanks for taking the time to read this.
>
> /*
>  * Encrypts and saves message
>  */
> function compose() {
>                if(!empty($this->data)) {
>
>                        $this->data['Message']['user_id'] = $this->Session-
>>read('Auth.User.id');
>
>                        // Encrypt message
>                        $security = new Security;
>
>                        $this->data['Message']['msg'] = 
> $security->cipher($this-
>>data['Message']['msg'],
>                                                                               
>                  Configure::read('Security.cipherSeed'));
>
>                        // Save message
>                        if($this->Message->save($this->data)){
>                                $this->Session->setFlash('Ok', 'flash_ok');
>                        } else {
>                                $this->Session->setFlash('Error');
>                        }
>                }
>        }
> }

Instead of instantiating Security, try:

$this->data['Message']['msg'] =
Security::cipher($this->data-'Message']['msg'],
Configure::read('Security.cipherSeed'));

You might also want to use $this->log() in a few places to try to
track down where it's going missing. Especially *before* you call
cipher(). Are you certain that the data is even there to begin with?
Check your form fields and the submitted data array.

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: Doubt about admin routes / actions and Auth component

2010-11-12 Thread cricket
On Thu, Nov 11, 2010 at 11:44 PM, huoxito  wrote:
> Thats what I thought as well, but it doesnt happen,
>
> If I just let $this->Auth->allow(‘*’) in my app_controller all actions
> are accessible without being logged in, even my admin_* methods

Perhaps Auth isn't properly configured in
AppController::beforeFilter(). Could you post that?

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: Site Development from Start to Finish

2010-11-12 Thread naidim
For the homepage controller, if User and Drug are not related but you
want to use those models, you have to include them both. Maybe I
should specify that, thanks.

Not sure I understand the 1.3 point. 'add' was added because I noticed
scaffold methods are not allowed when you allow('*'); so you have to
allow it specifically. Is that what the "^^" does?

I don't change my hash, but just mention the option is there because
others might want to. How important is it to not change it?

I totally don't understand the last point, sorry.

On Nov 10, 7:07 pm, euromark  wrote:
> a few things
>
> var $uses = array('User', 'Drugs');
> i guess the drugs are related to users?
> var $uses = array('User');
> might be just enough then
>
> you mix 1.3 helper syntax and old syntax
>
> $this->Auth->allow('*', 'add');
> probably was meant to be
> $this->Auth->allow('*'); ^^
>
> i would not change the security hash function (and not to md5 in
> particular)
>
> "$this->Auth->loginRedirect" etc
> careful: the urls should contain admin=>false and plugin=>false to
> avoid problems if you are
> in those routes!
>
> other than that a nice tutorial for beginners

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: Encrypted text does not get saved in the db

2010-11-12 Thread laduree
Sorry, the SQL output got all messed up after I clicked send,

Nr: 1 _ Query: DESCRIBE `messages` _ Affected: 6 _ Num. Rows: 6 _
Took (ms): 2
Nr: 2 _ Query: DESCRIBE `users` _ Affected: 6 _ Num. Rows: 6 _ Took
(ms): 3
Nr: 3 _ Query: _ Affected: 1 _ Num.
Rows:_ Took (ms): 1
Nr: 4 _ Query: SELECT LAST_INSERT_ID() AS insertID _ Affected: 1 _
Num. Rows: 1 _ Took (ms): 0

On Nov 12, 4:41 pm, laduree  wrote:
> It is strange that the log says there is not an INSERT query at all;
> however, the Message.to data is captured from the form and inserted in
> the db. And the 'created' and 'modified' fields are inserted
> automagically. The output from the SQL log is the following:
>
> Nr      Query                                  Error       Affected        
> Num.
> rows       Took (ms)
> 1       DESCRIBE `messages`                                6
> 6                  2
> 2       DESCRIBE `users`                                           6
> 6                  3
> 3
> 1                                  1
> 4       SELECT LAST_INSERT_ID() AS insertID        1
> 1                  0
>
> I have the debug level set to 3
>
> On Nov 12, 5:33 am, Amit Badkas  wrote:> Hi,
>
> > I don't see any problem with the code. Have you looked at INSERT SQL query
> > by setting debug level to 2?
>
> > Amit
>
> > PHP Applications for E-Biz:http://www.sanisoft.comOnFri, Nov 12, 2010 at 
> > 2:43 AM, laduree  wrote:
> > > I have some data coming from a form, and I'm trying to encrypt part of
> > > it and save it in a mysql db. Everything gets saved, except the
> > > encrypted field, which is empty when I look in the database.
>
> > > I'm new to CakePHP and wasn't successful googling for a solution,
> > > thanks for taking the time to read this.
>
> > > /*
> > >  * Encrypts and saves message
> > >  */
> > > function compose() {
> > >                if(!empty($this->data)) {
>
> > >                        $this->data['Message']['user_id'] = $this->Session-
> > > >read('Auth.User.id');
>
> > >                        // Encrypt message
> > >                        $security = new Security;
>
> > >                        $this->data['Message']['msg'] =
> > > $security->cipher($this-
> > > >data['Message']['msg'],
>
> > >                    Configure::read('Security.cipherSeed'));
>
> > >                        // Save message
> > >                        if($this->Message->save($this->data)){
> > >                                $this->Session->setFlash('Ok', 'flash_ok');
> > >                        } else {
> > >                                $this->Session->setFlash('Error');
> > >                        }
> > >                }
> > >        }
> > > }
>
> > > 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 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: Encrypted text does not get saved in the db

2010-11-12 Thread laduree
It is strange that the log says there is not an INSERT query at all;
however, the Message.to data is captured from the form and inserted in
the db. And the 'created' and 'modified' fields are inserted
automagically. The output from the SQL log is the following:

Nr  Query  Error   AffectedNum.
rows   Took (ms)
1   DESCRIBE `messages`6
6  2
2   DESCRIBE `users`   6
6  3
3
1  1
4   SELECT LAST_INSERT_ID() AS insertID1
1  0

I have the debug level set to 3

On Nov 12, 5:33 am, Amit Badkas  wrote:
> Hi,
>
> I don't see any problem with the code. Have you looked at INSERT SQL query
> by setting debug level to 2?
>
> Amit
>
> PHP Applications for E-Biz:http://www.sanisoft.comOn Fri, Nov 12, 2010 at 
> 2:43 AM, laduree  wrote:
> > I have some data coming from a form, and I'm trying to encrypt part of
> > it and save it in a mysql db. Everything gets saved, except the
> > encrypted field, which is empty when I look in the database.
>
> > I'm new to CakePHP and wasn't successful googling for a solution,
> > thanks for taking the time to read this.
>
> > /*
> >  * Encrypts and saves message
> >  */
> > function compose() {
> >                if(!empty($this->data)) {
>
> >                        $this->data['Message']['user_id'] = $this->Session-
> > >read('Auth.User.id');
>
> >                        // Encrypt message
> >                        $security = new Security;
>
> >                        $this->data['Message']['msg'] =
> > $security->cipher($this-
> > >data['Message']['msg'],
>
> >                    Configure::read('Security.cipherSeed'));
>
> >                        // Save message
> >                        if($this->Message->save($this->data)){
> >                                $this->Session->setFlash('Ok', 'flash_ok');
> >                        } else {
> >                                $this->Session->setFlash('Error');
> >                        }
> >                }
> >        }
> > }
>
> > 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 > om>For more options, visit this group at
> >http://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: CakePHP Stores the user login information to Cookies automatically

2010-11-12 Thread Muhaimen Ezabbad
Amit, 

Thanks for the reply,

Amit, Team, 

I'm using 1.3.5 Stable version.

BTW, I also created a new empty project with two tables, items and users

in the AppController I wrote:

var $components=array('Auth');

function  beforeFilter() {
$this->Auth->loginRedirect = 
array('controller'=>'items','action'=>'index');
$this->Auth->logoutRedirect = 
array('controller'=>'users','action'=>'login');
$this->set('loggedIn',$this->Auth->user('id'));
//$this->Auth->allow('signup');
}

function  isAuthorized() {
//parent::isAuthorized();
return true;
}


and I didn't write anything in the login function in the UserController.


My problem again the login informations stored in the cookies ,  I 
don't want to store these data without the user confirmation.

Thanks for your help


On Nov 12, 2010, at 5:53 AM, Amit Badkas wrote:

> Hi,
> 
> Which CakePHP version are you using?
> 
> Amit
> 
> PHP Applications for E-Biz: http://www.sanisoft.com
> 
> 
> On Thu, Nov 11, 2010 at 6:32 AM, Muhaimen Ezabbad  wrote:
> Hello Experts,
> 
>I'm new to CakePHP world, I'm working on an internal project to test 
> myself.
> 
>My Issue with the Auth.  The Login Process works fine, but my issue 
> that the CakePHP stores the login data in the cookies automatically.
> 
>How can I prevent the automatic storing of the login data to the 
> cookies?   BTW, I tried to use the remeberme checkbox, but I found that it 
> creates another cookie!
> 
> Best regards
> 
> Muhaimen Ezabbad
> Mobile: +218 91 3930082
> Tripoli, Libya
> 
> 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
> 
> 
> 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

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: Is there a reason why I shouln't make $this->Html available in views as $html? --psybear

2010-11-12 Thread Joshua Muheim
I don't see the big deal, too. I just wondered whether there's a
knockout argument for doing it the CakePHP-way. But I guess I will
stick to the CakePHP-way now for some time and see later if I still
want to change it... :-)

On Fri, Nov 12, 2010 at 2:23 PM, Jeremy Burns | Class Outfit
 wrote:
> I like the way Cake does it, regardless of what else others do. I can imagine 
> that if you had a helper function called "display" and then you added another 
> helper that had a function with the same name you *could* isolate and rectify 
> the clashes, but I'd rather avoid that extra work in the first place by just 
> pre-pending the helper name in the first place. I don't see the big deal.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.com
> http://www.classoutfit.com
>
> On 12 Nov 2010, at 08:18, Joshua Muheim wrote:
>
>> I'd really like to know why it has switched to $this->Html. Is there a
>> decision log or something for CakePHP?
>>
>> Coming from the RoR world (which is far more widespread in the
>> webworld than CakePHP, I guess) I like things as simple as anyhow
>> possible, even if you have to stick to some conventions for its sake.
>> I haven't worked with RoR since 2 years or so, so maybe things have
>> changed now, but up then as far as I remember things like helper
>> methods had been mixed right into the view *without* anything like a
>> $helper method or so.
>>
>> E.g. a helper Bla with methods abc and xyz were accessible in the view
>> directly by calling abc and xyz, so you had to see for yourself that
>> no collisions appeared (and if one did, I guess you would still have
>> been able to distinguish your helpers by prepending the helper's name,
>> e.g. Bla.abc or Foo.abc).
>>
>> So RoR went the way that's the most convenient to use, and by having a
>> good test battery in the background conflicts like the mentioned above
>> were located and fixed easily while still having all the convenience
>> in those spots that didn't have collisions (which are in most cases
>> many more than the ones that do).
>>
>> Well, just writing some thoughts down here, no intention to blame
>> CakePHP or something... I'm just curious about some stuff... ;-)
>>
>> On Fri, Nov 12, 2010 at 1:41 PM, euromark  wrote:
>>> actually its the other way around
>>> it used to be $html and NOW is $this->Html (cake >=1.3)
>>> and yes, there are plenty reasons why this is now a view object (and
>>> not just an object variable)
>>>
>>> it is a bad idea to want to go back to the old syntax
>>>
>>> and your argument is bad: For the sake of simplicity $this->Html makes
>>> more sense (no collisions in the view anymore)
>>>
>>> hope that clears things up
>>>
>>> On 12 Nov., 11:42, psybear83  wrote:
 Hi everybody

 For the sake of simplicity I'd like to make my helpers available in my
 views not as $this->Helper but as $helper using the set(...) method in
 the controller.

 Is there any reason why this could be a bad idea? Or is there already
 an option to tell CakePHP to make the helpers available this way?

 Thanks for help
 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
>>>
>>
>> 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
>
> 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
>

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: Why only pass $data to view instead of model instance?

2010-11-12 Thread Joshua Muheim
I'd like to warm up this topic again. :-)

I decided to pass model instances to the views instead of just their
$data attributes. So is there a way to tweak the paginator to do
exactly this?

Thanks,
Josh

On Thu, Oct 28, 2010 at 8:26 PM, euromark  wrote:
> i tend to do those things "on demand"
> using a behavior to add new keys or even doing it in the model
> afterFind() etc often results in additional work without actually
> needing this information
> but of course this depends on the particular case
>
>
> On 28 Okt., 20:10, cricket  wrote:
>> On Thu, Oct 28, 2010 at 10:03 AM, euromark  
>> wrote:
>> > thats not correct for PHP5 anymore
>> > in PHP4 you needed to do this
>> > but in PHP5 it is passed by reference by default, afaik
>>
>> Agreed on passing the model to the view. But this could also be
>> accomplished in afterFind(), adding new key => value to the data
>> array.
>
> 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
>

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: Is there a reason why I shouln't make $this->Html available in views as $html? --psybear

2010-11-12 Thread Jeremy Burns | Class Outfit
I like the way Cake does it, regardless of what else others do. I can imagine 
that if you had a helper function called "display" and then you added another 
helper that had a function with the same name you *could* isolate and rectify 
the clashes, but I'd rather avoid that extra work in the first place by just 
pre-pending the helper name in the first place. I don't see the big deal.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 12 Nov 2010, at 08:18, Joshua Muheim wrote:

> I'd really like to know why it has switched to $this->Html. Is there a
> decision log or something for CakePHP?
> 
> Coming from the RoR world (which is far more widespread in the
> webworld than CakePHP, I guess) I like things as simple as anyhow
> possible, even if you have to stick to some conventions for its sake.
> I haven't worked with RoR since 2 years or so, so maybe things have
> changed now, but up then as far as I remember things like helper
> methods had been mixed right into the view *without* anything like a
> $helper method or so.
> 
> E.g. a helper Bla with methods abc and xyz were accessible in the view
> directly by calling abc and xyz, so you had to see for yourself that
> no collisions appeared (and if one did, I guess you would still have
> been able to distinguish your helpers by prepending the helper's name,
> e.g. Bla.abc or Foo.abc).
> 
> So RoR went the way that's the most convenient to use, and by having a
> good test battery in the background conflicts like the mentioned above
> were located and fixed easily while still having all the convenience
> in those spots that didn't have collisions (which are in most cases
> many more than the ones that do).
> 
> Well, just writing some thoughts down here, no intention to blame
> CakePHP or something... I'm just curious about some stuff... ;-)
> 
> On Fri, Nov 12, 2010 at 1:41 PM, euromark  wrote:
>> actually its the other way around
>> it used to be $html and NOW is $this->Html (cake >=1.3)
>> and yes, there are plenty reasons why this is now a view object (and
>> not just an object variable)
>> 
>> it is a bad idea to want to go back to the old syntax
>> 
>> and your argument is bad: For the sake of simplicity $this->Html makes
>> more sense (no collisions in the view anymore)
>> 
>> hope that clears things up
>> 
>> On 12 Nov., 11:42, psybear83  wrote:
>>> Hi everybody
>>> 
>>> For the sake of simplicity I'd like to make my helpers available in my
>>> views not as $this->Helper but as $helper using the set(...) method in
>>> the controller.
>>> 
>>> Is there any reason why this could be a bad idea? Or is there already
>>> an option to tell CakePHP to make the helpers available this way?
>>> 
>>> Thanks for help
>>> 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
>> 
> 
> 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

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: Is there a reason why I shouln't make $this->Html available in views as $html? --psybear

2010-11-12 Thread Joshua Muheim
I'd really like to know why it has switched to $this->Html. Is there a
decision log or something for CakePHP?

Coming from the RoR world (which is far more widespread in the
webworld than CakePHP, I guess) I like things as simple as anyhow
possible, even if you have to stick to some conventions for its sake.
I haven't worked with RoR since 2 years or so, so maybe things have
changed now, but up then as far as I remember things like helper
methods had been mixed right into the view *without* anything like a
$helper method or so.

E.g. a helper Bla with methods abc and xyz were accessible in the view
directly by calling abc and xyz, so you had to see for yourself that
no collisions appeared (and if one did, I guess you would still have
been able to distinguish your helpers by prepending the helper's name,
e.g. Bla.abc or Foo.abc).

So RoR went the way that's the most convenient to use, and by having a
good test battery in the background conflicts like the mentioned above
were located and fixed easily while still having all the convenience
in those spots that didn't have collisions (which are in most cases
many more than the ones that do).

Well, just writing some thoughts down here, no intention to blame
CakePHP or something... I'm just curious about some stuff... ;-)

On Fri, Nov 12, 2010 at 1:41 PM, euromark  wrote:
> actually its the other way around
> it used to be $html and NOW is $this->Html (cake >=1.3)
> and yes, there are plenty reasons why this is now a view object (and
> not just an object variable)
>
> it is a bad idea to want to go back to the old syntax
>
> and your argument is bad: For the sake of simplicity $this->Html makes
> more sense (no collisions in the view anymore)
>
> hope that clears things up
>
> On 12 Nov., 11:42, psybear83  wrote:
>> Hi everybody
>>
>> For the sake of simplicity I'd like to make my helpers available in my
>> views not as $this->Helper but as $helper using the set(...) method in
>> the controller.
>>
>> Is there any reason why this could be a bad idea? Or is there already
>> an option to tell CakePHP to make the helpers available this way?
>>
>> Thanks for help
>> 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
>

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: Is there a reason why I shouln't make $this->Html available in views as $html? --psybear

2010-11-12 Thread euromark
actually its the other way around
it used to be $html and NOW is $this->Html (cake >=1.3)
and yes, there are plenty reasons why this is now a view object (and
not just an object variable)

it is a bad idea to want to go back to the old syntax

and your argument is bad: For the sake of simplicity $this->Html makes
more sense (no collisions in the view anymore)

hope that clears things up

On 12 Nov., 11:42, psybear83  wrote:
> Hi everybody
>
> For the sake of simplicity I'd like to make my helpers available in my
> views not as $this->Helper but as $helper using the set(...) method in
> the controller.
>
> Is there any reason why this could be a bad idea? Or is there already
> an option to tell CakePHP to make the helpers available this way?
>
> Thanks for help
> 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


Is there a reason why I shouln't make $this->Html available in views as $html? --psybear

2010-11-12 Thread psybear83
Hi everybody

For the sake of simplicity I'd like to make my helpers available in my
views not as $this->Helper but as $helper using the set(...) method in
the controller.

Is there any reason why this could be a bad idea? Or is there already
an option to tell CakePHP to make the helpers available this way?

Thanks for help
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


CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear

2010-11-12 Thread psybear83
Hi all

I don't get it why CakePHP doesn't complain about stuff like when one
specifies missing components or fixtures:

var $components = array('SomeNotExistingComponent');
var $fixtures = array('app.this_fixture_does_not_exist');
App::import('Lib', 'TheresNoSuchFileInLib');

All the three lines do not result in any error, and I guess there's
more of that like $uses or stuff, but I didn't investigate this any
further.

Can anyone tell me why CakePHP just doesn't care about stuff like
that? Seems vry unresponsible to me...

Thanks for any hints
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: beforeFilter() after initialization of components but before beforeRender? --psybear

2010-11-12 Thread Joshua Muheim
Well, I found a way to implement another controller hook that is
called between initialization of components and execution of action
logic:

_afterComponentsInitialization();
  }
}

You think this is a good way? :-)

On Fri, Nov 12, 2010 at 10:59 AM, Joshua Muheim  wrote:
> Oh, and by the way: why is the "filter" in beforeFilter resp.
> afterFilter? beforeRender makes sense to me, but beforeFilter seems a
> strange name to me...
>
> On Fri, Nov 12, 2010 at 10:30 AM, Joshua Muheim  wrote:
>> I'm using a component called SimpleAuth and SimpleAcl (instead of the
>> standard Auth and Acl ones because they are too complicated for my
>> small project).
>>
>> SimpleAuth features a getActiveUser() method which returns the
>> currently logged in user. This method calls $this->Controller, which
>> is only available when the component's startup(...) method was called
>> from CakePHP.
>>
>> In my view I'd like to have a $user object contains all the user's
>> data and which can also handle stuff like $user->isAllowedTo(...) or
>> $user->isGuest(). I have created some UserProxy class for this:
>>
>> class UserProxy {
>>  var $auth;
>>  var $acl;
>>  var $guestId = 1;
>>
>>  function __construct($auth, $acl) {
>>    $this->auth = $auth;
>>    $this->acl = $acl;
>>    $this->user = $this->auth->getActiveUser(); // This line will be 
>> important!
>>  }
>>
>>  function name() {
>>    return $this->user['User']['name'];
>>  }
>>
>>  function isGuest() {
>>    return $this->user['User']['id'] == $this->guestId;
>>  }
>> }
>>
>> To automatically have this $user object available in my views, I want
>> to set it in a beforeFilter().
>>
>>  function _prepareUser() {
>>    $this->user = new UserProxy($this->SimpleAuth, $this->SimpleAcl);
>>    $this->set('user', $this->user);
>>  }
>>
>> This requires the SimpleAuth and SimpleAcl components to already be
>> initalized, because in $this->auth->getActiveUser() in the constructor
>> of UserProxy the SimpleAuth components needs access to the controller
>> and the session:
>>
>>  function getActiveUser() {
>>    if 
>> ($activeUserId=$this->Controller->Session->read($this->userModel.'.id'))
>> {
>>      ...
>>    }
>>    ...
>>  }
>>
>> And because the startup() method doesn't seem to be called at this
>> time already, I get the following error:
>>
>> Warning: Trying to get property of non-object
>> [APP/controllers/components/simple_auth.php, line 120]
>> SimpleAuthComponent::getActiveUser() -
>> APP/controllers/components/simple_auth.php, line 120
>> UserProxy::__construct() - APP/controllers/app_controller.php, line 10
>> AppController::_prepareUser() - APP/controllers/app_controller.php, line 37
>> AppController::beforeFilter() - APP/controllers/app_controller.php, line 28
>> Controller::startupProcess() -
>> CORE/cake/libs/controller/controller.php, line 526
>> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 187
>> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
>> [main] - APP/webroot/index.php, line 83
>>
>> Fatal error: Call to a member function read() on a non-object in
>> /Users/josh/Sites/working_tests/checking_out_simple_auth_and_simple_acl/app/controllers/components/simple_auth.php
>> on line 120
>>
>> So I need a filter that's called before the components are initialized
>> (that's the beforeFilter()) and a filter that's called after the
>> initialization of the components but before the controller and view
>> codes are processed.
>>
>> So @Miles: no, the beforeFilter() can't be executed after the
>> components' initialization, because often we set component-specific
>> parameters in the beforeFilter, like
>>
>> function beforeFilter() {
>>  $this->Security->blackHoleCallback = '_blackHole';
>>  parent::beforeFilter();
>> }
>>
>> Anyone got an idea on how to accomplish this? IMHO there should be a
>> beforeComponents() and an afterComponents() filter...
>>
>> On Thu, Nov 11, 2010 at 8:43 PM, Miles J  wrote:
>>> Also forgot to mention that there is an afterFilter() as well.
>>>
>>> On Nov 11, 10:30 am, Miles J  wrote:
 Components are initialized before they get to beforeFilter(), so
 beforeFilter() should work fine.

 https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/c...

 On Nov 11, 9:24 am, Bogdan Bursuc  wrote:

 > Why do you need one ?

 > On Thu, Nov 11, 2010 at 7:18 PM, psybear83  wrote:
 > > Hi all

 > > Is there a filter that runs after the initialization of components but
 > > before beforeRender?

 > > Thanks for help
 > > Josh

 > > 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.comFor
>>>

Re: beforeFilter() after initialization of components but before beforeRender? --psybear

2010-11-12 Thread Joshua Muheim
Oh, and by the way: why is the "filter" in beforeFilter resp.
afterFilter? beforeRender makes sense to me, but beforeFilter seems a
strange name to me...

On Fri, Nov 12, 2010 at 10:30 AM, Joshua Muheim  wrote:
> I'm using a component called SimpleAuth and SimpleAcl (instead of the
> standard Auth and Acl ones because they are too complicated for my
> small project).
>
> SimpleAuth features a getActiveUser() method which returns the
> currently logged in user. This method calls $this->Controller, which
> is only available when the component's startup(...) method was called
> from CakePHP.
>
> In my view I'd like to have a $user object contains all the user's
> data and which can also handle stuff like $user->isAllowedTo(...) or
> $user->isGuest(). I have created some UserProxy class for this:
>
> class UserProxy {
>  var $auth;
>  var $acl;
>  var $guestId = 1;
>
>  function __construct($auth, $acl) {
>    $this->auth = $auth;
>    $this->acl = $acl;
>    $this->user = $this->auth->getActiveUser(); // This line will be important!
>  }
>
>  function name() {
>    return $this->user['User']['name'];
>  }
>
>  function isGuest() {
>    return $this->user['User']['id'] == $this->guestId;
>  }
> }
>
> To automatically have this $user object available in my views, I want
> to set it in a beforeFilter().
>
>  function _prepareUser() {
>    $this->user = new UserProxy($this->SimpleAuth, $this->SimpleAcl);
>    $this->set('user', $this->user);
>  }
>
> This requires the SimpleAuth and SimpleAcl components to already be
> initalized, because in $this->auth->getActiveUser() in the constructor
> of UserProxy the SimpleAuth components needs access to the controller
> and the session:
>
>  function getActiveUser() {
>    if ($activeUserId=$this->Controller->Session->read($this->userModel.'.id'))
> {
>      ...
>    }
>    ...
>  }
>
> And because the startup() method doesn't seem to be called at this
> time already, I get the following error:
>
> Warning: Trying to get property of non-object
> [APP/controllers/components/simple_auth.php, line 120]
> SimpleAuthComponent::getActiveUser() -
> APP/controllers/components/simple_auth.php, line 120
> UserProxy::__construct() - APP/controllers/app_controller.php, line 10
> AppController::_prepareUser() - APP/controllers/app_controller.php, line 37
> AppController::beforeFilter() - APP/controllers/app_controller.php, line 28
> Controller::startupProcess() -
> CORE/cake/libs/controller/controller.php, line 526
> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 187
> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
> [main] - APP/webroot/index.php, line 83
>
> Fatal error: Call to a member function read() on a non-object in
> /Users/josh/Sites/working_tests/checking_out_simple_auth_and_simple_acl/app/controllers/components/simple_auth.php
> on line 120
>
> So I need a filter that's called before the components are initialized
> (that's the beforeFilter()) and a filter that's called after the
> initialization of the components but before the controller and view
> codes are processed.
>
> So @Miles: no, the beforeFilter() can't be executed after the
> components' initialization, because often we set component-specific
> parameters in the beforeFilter, like
>
> function beforeFilter() {
>  $this->Security->blackHoleCallback = '_blackHole';
>  parent::beforeFilter();
> }
>
> Anyone got an idea on how to accomplish this? IMHO there should be a
> beforeComponents() and an afterComponents() filter...
>
> On Thu, Nov 11, 2010 at 8:43 PM, Miles J  wrote:
>> Also forgot to mention that there is an afterFilter() as well.
>>
>> On Nov 11, 10:30 am, Miles J  wrote:
>>> Components are initialized before they get to beforeFilter(), so
>>> beforeFilter() should work fine.
>>>
>>> https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/c...
>>>
>>> On Nov 11, 9:24 am, Bogdan Bursuc  wrote:
>>>
>>> > Why do you need one ?
>>>
>>> > On Thu, Nov 11, 2010 at 7:18 PM, psybear83  wrote:
>>> > > Hi all
>>>
>>> > > Is there a filter that runs after the initialization of components but
>>> > > before beforeRender?
>>>
>>> > > Thanks for help
>>> > > Josh
>>>
>>> > > 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.comFor
>>> > >  more options, visit this group at
>>> > >http://groups.google.com/group/cake-php?hl=en
>>>
>>> > --
>>> > Thanks,
>>> > Bogdan Iulian Bursuc
>>
>> 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 c

Re: beforeFilter() after initialization of components but before beforeRender? --psybear

2010-11-12 Thread Joshua Muheim
I'm using a component called SimpleAuth and SimpleAcl (instead of the
standard Auth and Acl ones because they are too complicated for my
small project).

SimpleAuth features a getActiveUser() method which returns the
currently logged in user. This method calls $this->Controller, which
is only available when the component's startup(...) method was called
from CakePHP.

In my view I'd like to have a $user object contains all the user's
data and which can also handle stuff like $user->isAllowedTo(...) or
$user->isGuest(). I have created some UserProxy class for this:

class UserProxy {
  var $auth;
  var $acl;
  var $guestId = 1;

  function __construct($auth, $acl) {
$this->auth = $auth;
$this->acl = $acl;
$this->user = $this->auth->getActiveUser(); // This line will be important!
  }

  function name() {
return $this->user['User']['name'];
  }

  function isGuest() {
return $this->user['User']['id'] == $this->guestId;
  }
}

To automatically have this $user object available in my views, I want
to set it in a beforeFilter().

  function _prepareUser() {
$this->user = new UserProxy($this->SimpleAuth, $this->SimpleAcl);
$this->set('user', $this->user);
  }

This requires the SimpleAuth and SimpleAcl components to already be
initalized, because in $this->auth->getActiveUser() in the constructor
of UserProxy the SimpleAuth components needs access to the controller
and the session:

  function getActiveUser() {
if ($activeUserId=$this->Controller->Session->read($this->userModel.'.id'))
{
  ...
}
...
  }

And because the startup() method doesn't seem to be called at this
time already, I get the following error:

Warning: Trying to get property of non-object
[APP/controllers/components/simple_auth.php, line 120]
SimpleAuthComponent::getActiveUser() -
APP/controllers/components/simple_auth.php, line 120
UserProxy::__construct() - APP/controllers/app_controller.php, line 10
AppController::_prepareUser() - APP/controllers/app_controller.php, line 37
AppController::beforeFilter() - APP/controllers/app_controller.php, line 28
Controller::startupProcess() -
CORE/cake/libs/controller/controller.php, line 526
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 187
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83

Fatal error: Call to a member function read() on a non-object in
/Users/josh/Sites/working_tests/checking_out_simple_auth_and_simple_acl/app/controllers/components/simple_auth.php
on line 120

So I need a filter that's called before the components are initialized
(that's the beforeFilter()) and a filter that's called after the
initialization of the components but before the controller and view
codes are processed.

So @Miles: no, the beforeFilter() can't be executed after the
components' initialization, because often we set component-specific
parameters in the beforeFilter, like

function beforeFilter() {
  $this->Security->blackHoleCallback = '_blackHole';
  parent::beforeFilter();
}

Anyone got an idea on how to accomplish this? IMHO there should be a
beforeComponents() and an afterComponents() filter...

On Thu, Nov 11, 2010 at 8:43 PM, Miles J  wrote:
> Also forgot to mention that there is an afterFilter() as well.
>
> On Nov 11, 10:30 am, Miles J  wrote:
>> Components are initialized before they get to beforeFilter(), so
>> beforeFilter() should work fine.
>>
>> https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/c...
>>
>> On Nov 11, 9:24 am, Bogdan Bursuc  wrote:
>>
>> > Why do you need one ?
>>
>> > On Thu, Nov 11, 2010 at 7:18 PM, psybear83  wrote:
>> > > Hi all
>>
>> > > Is there a filter that runs after the initialization of components but
>> > > before beforeRender?
>>
>> > > Thanks for help
>> > > Josh
>>
>> > > 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.comFor
>> > >  more options, visit this group at
>> > >http://groups.google.com/group/cake-php?hl=en
>>
>> > --
>> > Thanks,
>> > Bogdan Iulian Bursuc
>
> 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
>

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"