[help] CakePHP 3 - associated entities not coming through from find() (or get) even with contain clause

2015-09-17 Thread Ernesto Borio


Some associated data is not coming through, although it's in the contain
 clause.

I can get $project->Participants if I set a belongsToMany relationship in 
the Projects table, relating to Participants through ProjectParticipants, 
but that way I still can't reach other tables associated with 
ProjectParticipants even with 
$project->participants->_joinData->other_related_table

How would I do to get ProjectParticipants and Participants with the same 
query?

Code:

// Database: Projects <--1:N-- ProjectParticipants --M:1--> Participants
// ProjectController:
$project = $this->Projects->get($id, ['contain'=>[
'ProjectParticipants.Participants']);// ProjectsTable:
$this->hasMany('ProjectParticipants', [
'foreignKey' => 'project_id']);// ProjectParticipantsTable:
$this->belongsTo('Participants', [
'foreignKey' => 'participant_id']);


Thanks!

http://stackoverflow.com/questions/32634856/cakephp3-associated-entities-not-coming-through-from-find-or-get-even-with-c

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


Table's save() fails, where to get the error message? (other than validation errors)

2015-09-14 Thread Ernesto Borio
I can't find in the documentation how to collect error messages (other than 
validation errors) for when a table's save() or delete() fail, how is it 
done?

-- 
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: Cake 3.0 - Convenient way to retrieve if the current Table/Behavior is part of a plugin or not

2015-02-02 Thread Ernesto
that probably gives me chills :P

what do you think about this solution?

//in my table class
public function plugin ()
{
foreach (Configure::read('App.paths.plugins') as $pluginPath) {
return string_between(strtolower(__FILE__), strtolower($pluginPath), DS);
}
}

//somewhere
function string_between($string, $start, $end)
{ 
$string =   . $string;
$ini = strpos($string, $start);
 if ($ini == 0) {
return ;
} else {
$ini += strlen($start);
return substr($string, $ini, strpos($string, $end, $ini) - $ini);
}
}

Il giorno venerdì 30 gennaio 2015 23:16:11 UTC+1, José Lorenzo ha scritto:

 Check the namespace of the class:

 list($namespace, $class) = namespaceSplit(get_class($table));

 if ($namespace !== 'App\Model\Table')  // Probably a plugin :)

 On Friday, January 30, 2015 at 4:10:31 PM UTC+1, Ernesto wrote:

 Hi all

 is there a convenient way to retrieve if the current Table/Behavior is 
 part of a plugin or not?

 in Controllers and Helpers i can inspect the request object and get it 
 done.



-- 
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: Cake 3.0 - Convenient way to retrieve if the current Table/Behavior is part of a plugin or not

2015-02-02 Thread Ernesto
that probably gives me chills :P

what do you think about this solution?

//in my table class
public function plugin()
{
foreach (Configure::read('App.paths.plugins') as $pluginPath) {
if (is_numeric(strpos(strtolower(__FILE__), strtolower($pluginPath {
return string_between(strtolower(__FILE__), strtolower($pluginPath), DS);
}
}
}

//somewhere
function string_between($string, $start, $end)
{ 
$string =   . $string;
$ini = strpos($string, $start);
 if ($ini == 0) {
return ;
} else {
$ini += strlen($start);
return substr($string, $ini, strpos($string, $end, $ini) - $ini);
}
}

Il giorno venerdì 30 gennaio 2015 23:16:11 UTC+1, José Lorenzo ha scritto:

 Check the namespace of the class:

 list($namespace, $class) = namespaceSplit(get_class($table));

 if ($namespace !== 'App\Model\Table')  // Probably a plugin :)

 On Friday, January 30, 2015 at 4:10:31 PM UTC+1, Ernesto wrote:

 Hi all

 is there a convenient way to retrieve if the current Table/Behavior is 
 part of a plugin or not?

 in Controllers and Helpers i can inspect the request object and get it 
 done.



-- 
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: Cake 3.0 - Convenient way to retrieve if the current Table/Behavior is part of a plugin or not

2015-02-02 Thread Ernesto
Because i have some tables with the same name (eg. orders), in different 
plugins.

Il giorno lunedì 2 febbraio 2015 23:14:47 UTC+1, José Lorenzo ha scritto:

 Why do you need to know if something is in a plugin, btw?

 On Monday, February 2, 2015 at 10:12:34 AM UTC-4:30, Ernesto wrote:

 that probably gives me chills :P

 what do you think about this solution?

 //in my table class
 public function plugin()
 {
 foreach (Configure::read('App.paths.plugins') as $pluginPath) {
 if (is_numeric(strpos(strtolower(__FILE__), strtolower($pluginPath {
 return string_between(strtolower(__FILE__), strtolower($pluginPath), DS);
 }
 }
 }

 //somewhere
 function string_between($string, $start, $end)
 { 
 $string =   . $string;
 $ini = strpos($string, $start);
  if ($ini == 0) {
 return ;
 } else {
 $ini += strlen($start);
 return substr($string, $ini, strpos($string, $end, $ini) - $ini);
 }
 }

 Il giorno venerdì 30 gennaio 2015 23:16:11 UTC+1, José Lorenzo ha scritto:

 Check the namespace of the class:

 list($namespace, $class) = namespaceSplit(get_class($table));

 if ($namespace !== 'App\Model\Table')  // Probably a plugin :)

 On Friday, January 30, 2015 at 4:10:31 PM UTC+1, Ernesto wrote:

 Hi all

 is there a convenient way to retrieve if the current Table/Behavior is 
 part of a plugin or not?

 in Controllers and Helpers i can inspect the request object and get it 
 done.



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


Cake 3.0 - Convenient way to retrieve if the current Table/Behavior is part of a plugin or not

2015-01-30 Thread Ernesto
Hi all

is there a convenient way to retrieve if the current Table/Behavior is part 
of a plugin or not?

in Controllers and Helpers i can inspect the request object and get it done.

-- 
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: Helper callback not working

2015-01-27 Thread Ernesto
NVM i found out why.

callbacks are disabled in FormHelper (for performance reasons, maybe?)

i added this to MyFormHelper

public function implementedEvents () {
return ['View.afterLayout' = 'afterLayout'];
}

and now my callback is working... but i'm getting this warning:

Warning (4096): Argument 1 passed to 
App\View\Helper\MyFormHelper::afterLayout() must be an instance of 
App\View\Helper\Event, instance of Cake\Event\Event given, called in 
C:\path-to-my-app\vendor\cakephp\cakephp\src\Event\EventManager.php on line 
274 and defined [C:\path-to-my-app\src\View\Helper\MyFormHelper.php, line 
22]

any clue?

Il giorno martedì 27 gennaio 2015 10:06:48 UTC+1, Ernesto ha scritto:

 Hi all

 i made a custom FormHelper and the callbacks are not working

 did i miss something?

 here's my code

 ?php

 namespace App\View\Helper;

 use Cake\View\Helper\FormHelper;

 class MyFormHelper extends FormHelper
 {
  public function afterLayout(Event $event, $layoutFile)
 {
 $this-Html-script('jquery', ['block' = true]);
 $this-Html-script('jquery-ui', ['block' = true]);
 $this-Html-css('jquery-ui', null, ['block' = true]);
 parent::afterLayout($event, $layoutFile);
 }

 }


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


Helper callback not working

2015-01-27 Thread Ernesto
Hi all

i made a custom FormHelper and the callbacks are not working

did i miss something?

here's my code

?php

namespace App\View\Helper;

use Cake\View\Helper\FormHelper;

class MyFormHelper extends FormHelper
{
 public function afterLayout(Event $event, $layoutFile)
{
$this-Html-script('jquery', ['block' = true]);
$this-Html-script('jquery-ui', ['block' = true]);
$this-Html-css('jquery-ui', null, ['block' = true]);
parent::afterLayout($event, $layoutFile);
}

}

-- 
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: Cake 3.0 - get source table and schema of each field in a recordset

2015-01-23 Thread Ernesto
Here's what i ended up with

class TableHelper extends Helper {

public function build(ResultSet $resultset)
{
 foreach ($resultset as $result) {
 $schema = $this-getSchema($result-source(), $result-toArray());
 break;
 }
 debug($schema);
 //do stuff
}

public function getSchema($table, $data)
{
 $schema = [];
 foreach ($data as $field = $value) {
 if (is_array($value)) {
 $schema[$field] = $this-getSchema($field, $value);
 } else {
 $schema[$field] = TableRegistry::get($table)-schema()-columnType($field);
 }
 }
 return $schema; 
}

}

here's the result

[
'id' = 'integer',
'name' = 'string',
'group_id' = 'integer',
'sconto' = 'decimal',
'bilancio' = 'decimal',
'groups' = [

'id' = 'integer'

'name' = 'string' ] ]


i'm looking to load the whole schema for each field, how can i do? i still 
haven't found a way.

Looking forward for your advices/enhanchments :)

Il giorno giovedì 22 gennaio 2015 16:40:54 UTC+1, Ernesto ha scritto:

 Ok i'll try.

 i'll let you know

 Thank you very much

 Il giorno giovedì 22 gennaio 2015 15:30:51 UTC+1, José Lorenzo ha scritto:

 Associations are already loaded, as you define them in the initialize() 
 method of the table.

 You can inspect the associations tree in a query by calling 
 $query-eagerLoader()-normalized($query-repository());

 On Thursday, January 22, 2015 at 2:47:35 PM UTC+1, Ernesto wrote:

 The inspect the contain tree way sounds better.

 i'll try to explain:

 With your method you will end up loading every belongsTo and hasOne 
 association, even if not used.
 The table i'm using right now has 3 belongsTo relationships but i need 
 to show only one

 On the second hand: first level association are not always enough.
 This worsen the problem quite a bit.
 if i use your method i must recursively loop throug tables and theyr 
 relationships, loading a ton of useless classes.

 What do you think?

 Il giorno giovedì 22 gennaio 2015 12:56:19 UTC+1, José Lorenzo ha 
 scritto:

 The associations used in a find are represented in a Tree-like 
 structure. I guess in your case it will be more than enough getting the 
 first-level associations
 of type belongsTo and hasOne, as those are the only types that can be 
 represented in a html table (they are in the same level of nesting)

 So to get associations of a table of type belongsTo and hasOne:

 $firstLevelAssociations = 
 collection($mainTable-associations()-type('HasOne'))
 -append($mainTable-associations()-type('BelongsTo'));

 $schemas = [];
 foreach ($firstLevelAssociations as $association) {
$schemas[$association-property()] = $association-schema();
 }

 At the end of the loop you will have an array of property names 
 pointing to the table schema. So, finally:

 foreach ($schemas as $property = $schema) {
if ($singleResultFromQuery-has($property)) {
 // Do stuff with the schema
}
 }


 This is one way to do it. The other way is inspecting the query object 
 to get the 'contain' tree. Let me know if you need to know more about it :)
 On Thursday, January 22, 2015 at 11:01:35 AM UTC+1, Ernesto wrote:

 what about getting all the associations used in a record set?

 Il giorno giovedì 22 gennaio 2015 10:02:02 UTC+1, José Lorenzo ha 
 scritto:

 foreach ($results as $result) {
 $source = $result-source();
 $sourceSchema = TableRegistry::get($source)-schema();
 }

 Usually all records in a result set are of the same table, so you 
 on;y need to do that for the first result.

 If you have associations, then you can get the property in the result:

 $associationSource = $result-association_property-source();


 On Thursday, January 22, 2015 at 9:07:31 AM UTC+1, Ernesto wrote:

 Hi all

 i'm migrating an HtmlTableHelper from a Cake 2.x project to  new 3.0 
 one

 The main function of this helper scans the array of data passed as 
 argument and uses ClassRegistry to obtain schemas for each Model.field.
 Later on these informations are used to format the TDs (text fields 
 justified to the left, number fields justified to the right and so on).

 in 3.0 data arrays are gone, replaced by resultsets.

 I tried to rewrite a similar approach but i'm struggling with Cake's 
 new ORM

 what's the best way to get source table and schema of each field in 
 a recordset?

 Thank you very much




-- 
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: Cake 3.0 - get source table and schema of each field in a recordset

2015-01-23 Thread Ernesto
Here's what i ended up with

class TableHelper extends Helper {

public function build(ResultSet $resultset)
{
 foreach ($resultset as $result) {
 $schema = $this-getSchema($result-source(), $result-toArray());
 break;
 }
 debug($schema);
 //do stuff
}

public function getSchema($table, $data)
{
 $schema = [];
 foreach ($data as $field = $value) {
 if (is_array($value)) {
 $schema[$field] = $this-getSchema($field, $value);
 } else {
 $schema[$field] = TableRegistry::get($table)-schema()-columnType($field);
 }
 }
 return $schema; 
}

}

here's the result

[
'id' = 'integer',
'name' = 'string',
'group_id' = 'integer',
'value_1' = 'decimal',
'value_2' = 'decimal',
'groups' = [

'id' = 'integer'

'name' = 'string' ] ]


i'm looking to load the whole schema for each field, how can i do? i still 
haven't found a way.

Looking forward for your advices/enhanchments :)

PS: how can i access the query of a recordset? i'm not good at oop :(


Il giorno giovedì 22 gennaio 2015 16:40:54 UTC+1, Ernesto ha scritto:

 Ok i'll try.

 i'll let you know

 Thank you very much

 Il giorno giovedì 22 gennaio 2015 15:30:51 UTC+1, José Lorenzo ha scritto:

 Associations are already loaded, as you define them in the initialize() 
 method of the table.

 You can inspect the associations tree in a query by calling 
 $query-eagerLoader()-normalized($query-repository());

 On Thursday, January 22, 2015 at 2:47:35 PM UTC+1, Ernesto wrote:

 The inspect the contain tree way sounds better.

 i'll try to explain:

 With your method you will end up loading every belongsTo and hasOne 
 association, even if not used.
 The table i'm using right now has 3 belongsTo relationships but i need 
 to show only one

 On the second hand: first level association are not always enough.
 This worsen the problem quite a bit.
 if i use your method i must recursively loop throug tables and theyr 
 relationships, loading a ton of useless classes.

 What do you think?

 Il giorno giovedì 22 gennaio 2015 12:56:19 UTC+1, José Lorenzo ha 
 scritto:

 The associations used in a find are represented in a Tree-like 
 structure. I guess in your case it will be more than enough getting the 
 first-level associations
 of type belongsTo and hasOne, as those are the only types that can be 
 represented in a html table (they are in the same level of nesting)

 So to get associations of a table of type belongsTo and hasOne:

 $firstLevelAssociations = 
 collection($mainTable-associations()-type('HasOne'))
 -append($mainTable-associations()-type('BelongsTo'));

 $schemas = [];
 foreach ($firstLevelAssociations as $association) {
$schemas[$association-property()] = $association-schema();
 }

 At the end of the loop you will have an array of property names 
 pointing to the table schema. So, finally:

 foreach ($schemas as $property = $schema) {
if ($singleResultFromQuery-has($property)) {
 // Do stuff with the schema
}
 }


 This is one way to do it. The other way is inspecting the query object 
 to get the 'contain' tree. Let me know if you need to know more about it :)
 On Thursday, January 22, 2015 at 11:01:35 AM UTC+1, Ernesto wrote:

 what about getting all the associations used in a record set?

 Il giorno giovedì 22 gennaio 2015 10:02:02 UTC+1, José Lorenzo ha 
 scritto:

 foreach ($results as $result) {
 $source = $result-source();
 $sourceSchema = TableRegistry::get($source)-schema();
 }

 Usually all records in a result set are of the same table, so you 
 on;y need to do that for the first result.

 If you have associations, then you can get the property in the result:

 $associationSource = $result-association_property-source();


 On Thursday, January 22, 2015 at 9:07:31 AM UTC+1, Ernesto wrote:

 Hi all

 i'm migrating an HtmlTableHelper from a Cake 2.x project to  new 3.0 
 one

 The main function of this helper scans the array of data passed as 
 argument and uses ClassRegistry to obtain schemas for each Model.field.
 Later on these informations are used to format the TDs (text fields 
 justified to the left, number fields justified to the right and so on).

 in 3.0 data arrays are gone, replaced by resultsets.

 I tried to rewrite a similar approach but i'm struggling with Cake's 
 new ORM

 what's the best way to get source table and schema of each field in 
 a recordset?

 Thank you very much




-- 
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: Cake 3.0 - get source table and schema of each field in a recordset

2015-01-22 Thread Ernesto
The inspect the contain tree way sounds better.

i'll try to explain:

With your method you will end up loading every belongsTo and hasOne 
association, even if not used.
The table i'm using right now has 3 belongsTo relationships but i need to 
show only one

On the second hand: first level association are not always enough.
This worsen the problem quite a bit.
if i use your method i must recursively loop throug tables and theyr 
relationships, loading a ton of useless classes.

What do you think?

Il giorno giovedì 22 gennaio 2015 12:56:19 UTC+1, José Lorenzo ha scritto:

 The associations used in a find are represented in a Tree-like structure. 
 I guess in your case it will be more than enough getting the first-level 
 associations
 of type belongsTo and hasOne, as those are the only types that can be 
 represented in a html table (they are in the same level of nesting)

 So to get associations of a table of type belongsTo and hasOne:

 $firstLevelAssociations = 
 collection($mainTable-associations()-type('HasOne'))
 -append($mainTable-associations()-type('BelongsTo'));

 $schemas = [];
 foreach ($firstLevelAssociations as $association) {
$schemas[$association-property()] = $association-schema();
 }

 At the end of the loop you will have an array of property names pointing 
 to the table schema. So, finally:

 foreach ($schemas as $property = $schema) {
if ($singleResultFromQuery-has($property)) {
 // Do stuff with the schema
}
 }


 This is one way to do it. The other way is inspecting the query object to 
 get the 'contain' tree. Let me know if you need to know more about it :)
 On Thursday, January 22, 2015 at 11:01:35 AM UTC+1, Ernesto wrote:

 what about getting all the associations used in a record set?

 Il giorno giovedì 22 gennaio 2015 10:02:02 UTC+1, José Lorenzo ha scritto:

 foreach ($results as $result) {
 $source = $result-source();
 $sourceSchema = TableRegistry::get($source)-schema();
 }

 Usually all records in a result set are of the same table, so you on;y 
 need to do that for the first result.

 If you have associations, then you can get the property in the result:

 $associationSource = $result-association_property-source();


 On Thursday, January 22, 2015 at 9:07:31 AM UTC+1, Ernesto wrote:

 Hi all

 i'm migrating an HtmlTableHelper from a Cake 2.x project to  new 3.0 one

 The main function of this helper scans the array of data passed as 
 argument and uses ClassRegistry to obtain schemas for each Model.field.
 Later on these informations are used to format the TDs (text fields 
 justified to the left, number fields justified to the right and so on).

 in 3.0 data arrays are gone, replaced by resultsets.

 I tried to rewrite a similar approach but i'm struggling with Cake's 
 new ORM

 what's the best way to get source table and schema of each field in a 
 recordset?

 Thank you very much




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


Cake 3.0 - get source table and schema of each field in a recordset

2015-01-22 Thread Ernesto
Hi all

i'm migrating an HtmlTableHelper from a Cake 2.x project to  new 3.0 one

The main function of this helper scans the array of data passed as argument 
and uses ClassRegistry to obtain schemas for each Model.field.
Later on these informations are used to format the TDs (text fields 
justified to the left, number fields justified to the right and so on).

in 3.0 data arrays are gone, replaced by resultsets.

I tried to rewrite a similar approach but i'm struggling with Cake's new ORM

what's the best way to get source table and schema of each field in a 
recordset?

Thank you very much


-- 
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: Cake 3.0 - get source table and schema of each field in a recordset

2015-01-22 Thread Ernesto
what about getting all the associations used in a record set?

Il giorno giovedì 22 gennaio 2015 10:02:02 UTC+1, José Lorenzo ha scritto:

 foreach ($results as $result) {
 $source = $result-source();
 $sourceSchema = TableRegistry::get($source)-schema();
 }

 Usually all records in a result set are of the same table, so you on;y 
 need to do that for the first result.

 If you have associations, then you can get the property in the result:

 $associationSource = $result-association_property-source();


 On Thursday, January 22, 2015 at 9:07:31 AM UTC+1, Ernesto wrote:

 Hi all

 i'm migrating an HtmlTableHelper from a Cake 2.x project to  new 3.0 one

 The main function of this helper scans the array of data passed as 
 argument and uses ClassRegistry to obtain schemas for each Model.field.
 Later on these informations are used to format the TDs (text fields 
 justified to the left, number fields justified to the right and so on).

 in 3.0 data arrays are gone, replaced by resultsets.

 I tried to rewrite a similar approach but i'm struggling with Cake's new 
 ORM

 what's the best way to get source table and schema of each field in a 
 recordset?

 Thank you very much




-- 
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: Cake 3.0 - get source table and schema of each field in a recordset

2015-01-22 Thread Ernesto
Ok i'll try.

i'll let you know

Thank you very much

Il giorno giovedì 22 gennaio 2015 15:30:51 UTC+1, José Lorenzo ha scritto:

 Associations are already loaded, as you define them in the initialize() 
 method of the table.

 You can inspect the associations tree in a query by calling 
 $query-eagerLoader()-normalized($query-repository());

 On Thursday, January 22, 2015 at 2:47:35 PM UTC+1, Ernesto wrote:

 The inspect the contain tree way sounds better.

 i'll try to explain:

 With your method you will end up loading every belongsTo and hasOne 
 association, even if not used.
 The table i'm using right now has 3 belongsTo relationships but i need to 
 show only one

 On the second hand: first level association are not always enough.
 This worsen the problem quite a bit.
 if i use your method i must recursively loop throug tables and theyr 
 relationships, loading a ton of useless classes.

 What do you think?

 Il giorno giovedì 22 gennaio 2015 12:56:19 UTC+1, José Lorenzo ha scritto:

 The associations used in a find are represented in a Tree-like 
 structure. I guess in your case it will be more than enough getting the 
 first-level associations
 of type belongsTo and hasOne, as those are the only types that can be 
 represented in a html table (they are in the same level of nesting)

 So to get associations of a table of type belongsTo and hasOne:

 $firstLevelAssociations = 
 collection($mainTable-associations()-type('HasOne'))
 -append($mainTable-associations()-type('BelongsTo'));

 $schemas = [];
 foreach ($firstLevelAssociations as $association) {
$schemas[$association-property()] = $association-schema();
 }

 At the end of the loop you will have an array of property names pointing 
 to the table schema. So, finally:

 foreach ($schemas as $property = $schema) {
if ($singleResultFromQuery-has($property)) {
 // Do stuff with the schema
}
 }


 This is one way to do it. The other way is inspecting the query object 
 to get the 'contain' tree. Let me know if you need to know more about it :)
 On Thursday, January 22, 2015 at 11:01:35 AM UTC+1, Ernesto wrote:

 what about getting all the associations used in a record set?

 Il giorno giovedì 22 gennaio 2015 10:02:02 UTC+1, José Lorenzo ha 
 scritto:

 foreach ($results as $result) {
 $source = $result-source();
 $sourceSchema = TableRegistry::get($source)-schema();
 }

 Usually all records in a result set are of the same table, so you on;y 
 need to do that for the first result.

 If you have associations, then you can get the property in the result:

 $associationSource = $result-association_property-source();


 On Thursday, January 22, 2015 at 9:07:31 AM UTC+1, Ernesto wrote:

 Hi all

 i'm migrating an HtmlTableHelper from a Cake 2.x project to  new 3.0 
 one

 The main function of this helper scans the array of data passed as 
 argument and uses ClassRegistry to obtain schemas for each Model.field.
 Later on these informations are used to format the TDs (text fields 
 justified to the left, number fields justified to the right and so on).

 in 3.0 data arrays are gone, replaced by resultsets.

 I tried to rewrite a similar approach but i'm struggling with Cake's 
 new ORM

 what's the best way to get source table and schema of each field in a 
 recordset?

 Thank you very much




-- 
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: 3.0 change default table order

2015-01-19 Thread Ernesto
you're right

thank for your help

Il giorno lunedì 19 gennaio 2015 18:55:58 UTC+1, José Lorenzo ha scritto:

 How would it know it is useless?

 On Monday, January 19, 2015 at 5:25:38 PM UTC+1, Ernesto wrote:

 Shouldn't Cake itself take care of useless clauses?

 Il giorno lunedì 19 gennaio 2015 16:57:43 UTC+1, José Lorenzo ha scritto:

 That's almost right. I would change it a bit by doing this:

 public function beforeFind ($event, $query, $options, $primary) {
 $order = $query-clause('order');
 if ($order === null || !count($order)) {
  $query-order(nome);
 }
 return parent::beforeFind($event, $query, $options, $primary);
 }

 That will prevent adding more order clauses than you'd need.

 On Monday, January 19, 2015 at 4:04:09 PM UTC+1, Ernesto wrote:

 Hi all

 i noticed that the variable order, used in cake 1.x/2.x models to 
 alter the default table sort, has gone.
 i haven't found any hint in the 3.0 cookbook so i'm asking: what's the 
 best practice to do this in 3.0?

 i did this:

 public function beforeFind ($event, $query, $options, $primary) {
 $query-order(nome);
 return parent::beforeFind($event, $query, $options, $primary);
 }

 is that right?

 Sorry for my engRish



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


3.0 change default table order

2015-01-19 Thread Ernesto
Hi all

i noticed that the variable order, used in cake 1.x/2.x models to alter 
the default table sort, has gone.
i haven't found any hint in the 3.0 cookbook so i'm asking: what's the best 
practice to do this in 3.0?

i did this:

public function beforeFind ($event, $query, $options, $primary) {
$query-order(nome);
return parent::beforeFind($event, $query, $options, $primary);
}

is that right?

Sorry for my engRish

-- 
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: 3.0 change default table order

2015-01-19 Thread Ernesto
Shouldn't Cake itself take care of useless clauses?

Il giorno lunedì 19 gennaio 2015 16:57:43 UTC+1, José Lorenzo ha scritto:

 That's almost right. I would change it a bit by doing this:

 public function beforeFind ($event, $query, $options, $primary) {
 $order = $query-clause('order');
 if ($order === null || !count($order)) {
  $query-order(nome);
 }
 return parent::beforeFind($event, $query, $options, $primary);
 }

 That will prevent adding more order clauses than you'd need.

 On Monday, January 19, 2015 at 4:04:09 PM UTC+1, Ernesto wrote:

 Hi all

 i noticed that the variable order, used in cake 1.x/2.x models to alter 
 the default table sort, has gone.
 i haven't found any hint in the 3.0 cookbook so i'm asking: what's the 
 best practice to do this in 3.0?

 i did this:

 public function beforeFind ($event, $query, $options, $primary) {
 $query-order(nome);
 return parent::beforeFind($event, $query, $options, $primary);
 }

 is that right?

 Sorry for my engRish



-- 
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: 3.0 change default table order

2015-01-19 Thread Ernesto
Nice thought

Thank you

Il giorno lunedì 19 gennaio 2015 16:57:43 UTC+1, José Lorenzo ha scritto:

 That's almost right. I would change it a bit by doing this:

 public function beforeFind ($event, $query, $options, $primary) {
 $order = $query-clause('order');
 if ($order === null || !count($order)) {
  $query-order(nome);
 }
 return parent::beforeFind($event, $query, $options, $primary);
 }

 That will prevent adding more order clauses than you'd need.

 On Monday, January 19, 2015 at 4:04:09 PM UTC+1, Ernesto wrote:

 Hi all

 i noticed that the variable order, used in cake 1.x/2.x models to alter 
 the default table sort, has gone.
 i haven't found any hint in the 3.0 cookbook so i'm asking: what's the 
 best practice to do this in 3.0?

 i did this:

 public function beforeFind ($event, $query, $options, $primary) {
 $query-order(nome);
 return parent::beforeFind($event, $query, $options, $primary);
 }

 is that right?

 Sorry for my engRish



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


Advices on sessions in multi app environment

2013-07-09 Thread Ernesto
Hi all

my working environment has 3 branches (dev, test, prod).
every branch has 5 apps, a shared cake core and a folder containing some 
shared classes

i'm having some troubles on logging the same app in different branches.
for example if i log into dev/app1 i lose the prod/app1 session.

what's the best practice to keep every app session indipendent from each 
other?

i'm using Cake 2.3.7

Thanks in advance

-- 
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/groups/opt_out.




Disable pagination in one action

2013-07-03 Thread Ernesto
Hi all

can i disable pagination just for one action?
i tried

$this-Components-disable(Paginator);
$this-Helpers-disable(Paginator);

in my controller's action but the only things i get are errors

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 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/groups/opt_out.




Re: SecurityComponent + very large form = BlackHole

2013-03-13 Thread Ernesto
hi romel.

the only thing i can do is splitting the form in multiple views.
ajax won't help as all those fields are needed

Il giorno venerdì 8 marzo 2013 17:13:56 UTC+1, romel javier gomez herrera 
ha scritto:

 hi ernesto. 

 Why 1000 fields? there is probably a better way to do the job, have you 
 tried using ajax?

 saludos.


 2013/3/8 Ernesto e.fa...@gmail.com javascript:

 Hello.

 i have an action with a very large form (nearly 1000 inputs)

 SecurityComponent isn't amused and, as result, he's blackholing all my 
 POST requests from this page.

 why?

 maybe the string to generate security hashes is becoming too long?


  -- 
 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+u...@googlegroups.com javascript:.
 To post to this group, send email to cake...@googlegroups.comjavascript:
 .
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: SecurityComponent + very large form = BlackHole

2013-03-13 Thread Ernesto
i solved by increasing the

max_inputs_vars 

value in php.ini

Il giorno mercoledì 13 marzo 2013 09:53:29 UTC+1, Ernesto ha scritto:

 hi romel.

 the only thing i can do is splitting the form in multiple views.
 ajax won't help as all those fields are needed

 Il giorno venerdì 8 marzo 2013 17:13:56 UTC+1, romel javier gomez herrera 
 ha scritto:

 hi ernesto. 

 Why 1000 fields? there is probably a better way to do the job, have you 
 tried using ajax?

 saludos.


 2013/3/8 Ernesto e.fa...@gmail.com

 Hello.

 i have an action with a very large form (nearly 1000 inputs)

 SecurityComponent isn't amused and, as result, he's blackholing all my 
 POST requests from this page.

 why?

 maybe the string to generate security hashes is becoming too long?


  -- 
 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+u...@googlegroups.com.
 To post to this group, send email to cake...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




SecurityComponent + very large form = BlackHole

2013-03-08 Thread Ernesto
Hello.

i have an action with a very large form (nearly 1000 inputs)

SecurityComponent isn't amused and, as result, he's blackholing all my POST 
requests from this page.

why?

maybe the string to generate security hashes is becoming too long?


-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Enhance CakePHP app privacy

2012-11-07 Thread Ernesto
Hi all.

i'm making a simple app for a company concerned (almost paranoid) about 
data privacy.
they fear that theyr data can leak through HTML browser caching.

i added $this-request-disableCache(); to my AppController's beforeFilter 
callback.

is this enough?

any advice?

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




File Downloads corrupted with CRLF at beginning

2012-07-19 Thread Ernesto
Hi all

i have an action wich generates a CSV list that the user can download.
This CSV gets corrupted by a CRLF placed at the beginning of the file.

i tried these 2 ways:

*A - using CakeResponse and passing the fileContent directly, without 
creating any file*
$this-autoRender = false;
$this-response-type(application/csv);
$this-response-download(list.csv);
$this-response-body($fileContent);

*B - writing a file on server's hdd and then download it using MediaView*
App::uses(File, Utility);
$file = new File ($filePath . $fileName, true);
$file-write($listaTaglio);
$file-close();
$this-viewClass = Media;

$this-set(array(
id= $fileName,
download  = true,
path  = $filePath
));
*
*
In both cases i get the same issue.
My server runs on W7Pro, PHP 5.3.13, Apache 2.2.22
Any clue?

-- 
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: File Downloads corrupted with CRLF at beginning

2012-07-19 Thread Ernesto
i forgot to say that the generated file in method B doesn't have the 
starting CRLF

Il giorno giovedì 19 luglio 2012 17:10:08 UTC+2, Ernesto ha scritto:

 Hi all

 i have an action wich generates a CSV list that the user can download.
 This CSV gets corrupted by a CRLF placed at the beginning of the file.

 i tried these 2 ways:

 *A - using CakeResponse and passing the fileContent directly, without 
 creating any file*
 $this-autoRender = false;
 $this-response-type(application/csv);
 $this-response-download(list.csv);
 $this-response-body($fileContent);

 *B - writing a file on server's hdd and then download it using MediaView*
 App::uses(File, Utility);
 $file = new File ($filePath . $fileName, true);
 $file-write($listaTaglio);
 $file-close();
 $this-viewClass = Media;

 $this-set(array(
 id= $fileName,
 download  = true,
 path  = $filePath
 ));
 *
 *
 In both cases i get the same issue.
 My server runs on W7Pro, PHP 5.3.13, Apache 2.2.22
 Any clue?



-- 
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: File Downloads corrupted with CRLF at beginning

2012-07-19 Thread Ernesto
i solved :)

the issues were a double CRLF after the PHP closing tag in one of my helpers

Il giorno giovedì 19 luglio 2012 17:10:08 UTC+2, Ernesto ha scritto:

 Hi all

 i have an action wich generates a CSV list that the user can download.
 This CSV gets corrupted by a CRLF placed at the beginning of the file.

 i tried these 2 ways:

 *A - using CakeResponse and passing the fileContent directly, without 
 creating any file*
 $this-autoRender = false;
 $this-response-type(application/csv);
 $this-response-download(list.csv);
 $this-response-body($fileContent);

 *B - writing a file on server's hdd and then download it using MediaView*
 App::uses(File, Utility);
 $file = new File ($filePath . $fileName, true);
 $file-write($listaTaglio);
 $file-close();
 $this-viewClass = Media;

 $this-set(array(
 id= $fileName,
 download  = true,
 path  = $filePath
 ));
 *
 *
 In both cases i get the same issue.
 My server runs on W7Pro, PHP 5.3.13, Apache 2.2.22
 Any clue?



-- 
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: Issues with edits and afterSave in Cake 2.2

2012-07-10 Thread Ernesto
hi all thx for the response.

@cricket
thanks for the suggestion, i'll try your way

@albert
the data in the DB is ok


Il giorno venerdì 6 luglio 2012 12:06:03 UTC+2, Ernesto ha scritto:

 Hi all

 i'm having a weird issue with Cake 2.2 model's afterSave()

 i need to update some csv files after any order has been saved or updated.
 to achieve this i made a function processCsv wich is called by my 
 afterSave().

 but my finds() called afterSave() are returning the data without the last 
 updates. why?

 here's my code

 //in controller
 $this-Order-save($this-data);

 //in Order model
 public function afterSave ($created) {
 $this-processCsv($this-data[Order][id]);
 }

 public function processCsv ($id) {
 pr($this-findById($id));
 //my code goes here
 }


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


Issues with edits and afterSave in Cake 2.2

2012-07-06 Thread Ernesto
Hi all

i'm having a weird issue with Cake 2.2 model's afterSave()

i need to update some csv files after any order has been saved or updated.
to achieve this i made a function processCsv wich is called by my 
afterSave().

but my finds() called afterSave() are returning the data without the last 
updates. why?

here's my code

//in controller
$this-Order-save($this-data);

//in Order model
public function afterSave ($created) {
$this-processCsv($this-data[Order][id]);
}

public function processCsv ($id) {
pr($this-findById($id));
//my code goes here
}

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


Cake becomes super-slow when loading assets from Plugins

2012-05-29 Thread Ernesto
Hi all!

i noticed that Cake gets very, very slow (about 50x times slower) if i load 
assets from Plugins.

Here's my layout code

html xmlns=http://www.w3.org/1999/xhtml;
head
?php
echo $this-Html-charset();
echo title. $title ./title;
echo $this-Html-meta(icon);
echo $this-Html-css(array(
generic,
$this-layout ./form,
$this-layout ./menu,
$this-layout ./top,
/. $this-request-plugin ./css/. $this-layout //this css gives 
troubles 
));
?
/head
body
div id='wrapper'
div id='top'
?php 
echo $this-Menu-output();
echo div id='title'. $title ./div;
echo $this-Azioni-output();
?
/div
div id='content'?php echo $this-fetch(content); ?/div
/div
/body
/html

Am i doing something wrong?

-- 
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 becomes super-slow when loading assets from Plugins

2012-05-29 Thread Ernesto
i forgot to say i'm usign Cake 2.2.0-RC1 on a Win7 server

Il giorno martedì 29 maggio 2012 09:51:28 UTC+2, Ernesto ha scritto:

 Hi all!

 i noticed that Cake gets very, very slow (about 50x times slower) if i 
 load assets from Plugins.

 Here's my layout code

 html xmlns=http://www.w3.org/1999/xhtml;
 head
 ?php
 echo $this-Html-charset();
 echo title. $title ./title;
 echo $this-Html-meta(icon);
 echo $this-Html-css(array(
 generic,
 $this-layout ./form,
 $this-layout ./menu,
 $this-layout ./top,
 /. $this-request-plugin ./css/. $this-layout //this css gives 
 troubles 
 ));
 ?
 /head
 body
 div id='wrapper'
 div id='top'
 ?php 
 echo $this-Menu-output();
 echo div id='title'. $title ./div;
 echo $this-Azioni-output();
 ?
 /div
 div id='content'?php echo $this-fetch(content); ?/div
 /div
 /body
 /html

 Am i doing something wrong?


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


redefine Helper settings in plugin

2012-05-23 Thread Ernesto
Hi all

i have an app with a plugin. The app uses a MenuHelper that builds a 
secondary menu based on an array of settings.

this is my standard menu, defined in AppController:
public $helpers = array(Menu = array(choice 1, choice 2, choice 
3));

and this should be the menu in Plugin. (this line of code is in my 
PluginAppController)
public $helpers = array(Menu = array(drawings, 3d models, 
schemes)); 

i expected the $helpers array to be overridden but i get a 6-choices menu.
how can i override the original helper settings?


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


Get helper to work only if rsponse type is text/html

2012-05-03 Thread Ernesto
Hi all

i have a simple helper wich does some html cleaning.
All works ok except for PDF views where this helper corrupts the document.

is there any way to get this helper to work only if the response in 
text/html?


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


generateTreeList starting from an id

2012-03-15 Thread Ernesto
Hi all.

i'm using TreeBehavior in one of my Models and everything is working ok.

just one question:
generateTreeList returns a list containing ALL the entries in the table.

i want the treeList just for the category with id = 20 and his childrens

how can i do?

-- 
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: generateTreeList starting from an id

2012-03-15 Thread Ernesto
i forgot to say i've already tried the conditions argument but the 
function will return just the first layer of results

Il giorno giovedì 15 marzo 2012 16:49:30 UTC+1, Ernesto ha scritto:

 Hi all.

 i'm using TreeBehavior in one of my Models and everything is working ok.

 just one question:
 generateTreeList returns a list containing ALL the entries in the table.

 i want the treeList just for the category with id = 20 and his childrens

 how can i do?


Il giorno giovedì 15 marzo 2012 16:49:30 UTC+1, Ernesto ha scritto:

 Hi all.

 i'm using TreeBehavior in one of my Models and everything is working ok.

 just one question:
 generateTreeList returns a list containing ALL the entries in the table.

 i want the treeList just for the category with id = 20 and his childrens

 how can i do?


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


AppComponent

2012-03-12 Thread Ernesto
Hi all

i have an app with 4 components.
every component has some parts wich are common (calculating sessionVar, 
some default settings and so on)
is there any way to have a class, like AppController is for Controllers 
where i can define some standards for my components?

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


HTML link to a file on a shared folder

2012-02-20 Thread Ernesto
Hi all.

is it possible to link a file (in this case a .dwg or .dxf cad drawing) 
located in a LAN shared folder?


-- 
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: HTML link to a file on a shared folder

2012-02-20 Thread Ernesto
yes it's an intranet page.

i was just asking if it's possible using cake's htmlhelper.

-- 
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: Helper aliasing acting weird in 2.1 Beta

2012-02-12 Thread Ernesto
Hi Lorenzo, thanks for the response :)

You're right, CakePHP loads my TableHelper instead of loading 
PdftableHelper and aliasing it.

i think this is a bug. Can you test it?

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


Aliasing helper in another helper

2012-02-10 Thread Ernesto
Hi all.

i'm having some trouble with Helper aliasing.
I have 2 helpers: Pdf and his sub-helper PdfTable.

i'm getting a Call to a member function output() on a non-object in D:\...

my view code:

echo $this-Pdf-Table-output();

the first helper:

class PdfHelper extends AppHelper { 
public $helpers = array(
Table = array(
className = Pdftable
)
);
}

The second one:

class PdftableHelper extends AppHelper { 
function output () {
  return omg my table!!;
}
}

Why?
is Helper aliasing not working when used inside another helper?

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


Helper aliasing acting weird in 2.1 Beta

2012-02-10 Thread Ernesto
Hi all.
i'm having some troubles with Helper aliasing in Cake 2.1 Beta

i have 3 helpers:
PdfHelper.php
PdftableHelper.php 
TableHelper.php 

this is my PdfHelper code

class PdfHelper extends AppHelper {
public $helpers = array(
  Table = array(
  className = Pdftable
 )
);
}

and this is my view code

echo $this-Pdf-Table-myfunc();

i'm getting a 
call to undefined function myfunc() in TableHelper.

why is cake still using Table and ignoring my alias?

if i modify the code this way 

class PdfHelper extends AppHelper {
public $helpers = array(
  Whatever = array(
  className = Pdftable
 )
);
}

View:
echo $this-Pdf-Whatever-myfunc();

everything works.

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


issue with CSS in Cake 2.1

2012-01-24 Thread Ernesto
Hi all.
i'm having a strange issue with Cake 2.1 HtmlHelper and CSS files.

here's my layout

?php echo $this-Html-docType(); ?
html xmlns=http://www.w3.org/1999/xhtml;
head
?php 
echo $this-Html-charset(); 
echo title. $this-fetch(title) ./title;
echo $this-Html-css(myapp);
echo $this-Html-css(common/form);
echo $this-Html-css(common/menu);
?
/head
body
div id='wrapper'
div id='top'?php echo $this-fetch(top); ?/div
div id='menu'?php echo $this-fetch(menu); ?/div
div id='content'?php echo $this-fetch(content); ?/div
/div
/body
/html

everything is working perfectly but if there's a form in the page the CSS 
links get all messed up

Link generated with a plain HTML page:
link rel=stylesheet type=text/css href=
/cakephp/development/myapp/theme/webapp/css/generic.csshttp://appserver/cakephp/development/apps/consegne/theme/ErnyWebApp/css/generic.css
 
/ 

Same app, same layout, the view contains a form
link rel=stylesheet type=text/css href=
/cakephp/development/myapp/webroot/index.php/myapp/theme/webapp/css/generic.csshttp://appserver/cakephp/development/apps/consegne/webroot/index.php/sedi/theme/ErnyWebApp/css/generic.css
 
/ 

i can't get rid of this. any help?

sry for my bad english

-- 
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: issue with CSS in Cake 2.1

2012-01-24 Thread Ernesto
Ops sry i pasted the wrong layout

?php echo $this-Html-docType(); ?
html xmlns=http://www.w3.org/1999/xhtml;
head
?php 
echo $this-Html-charset(); 
echo title. $this-fetch(title) ./title;
$this-Html-css(generic, null, array(inline = false));
$this-Html-css(common/form, null, array(inline = false)); 
$this-Html-css(common/menu, null, array(inline = false));
echo $this-fetch(css);
?
/head
body
div id='wrapper'
div id='top'?php echo $this-fetch(top); ?/div
div id='menu'?php echo $this-fetch(menu); ?/div
div id='content'?php echo $this-fetch(content); ?/div
/div
/body
/html

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


CSS issue in Cake 2.1 and themes

2012-01-24 Thread Ernesto
Hi all

i'm experiencing a strange behavior with Cake 2.1 and HtmlHelper.
if the url contains the action the css links get all messed up.

link rel=stylesheet type=text/css href=
/cakephp/myapp/webroot/index.php/mycontroller/theme/mytheme/css/generic.csshttp://appserver/cakephp/development/apps/consegne/webroot/index.php/sedi/theme/ErnyWebApp/css/generic.css
 
/ 

i can't get rid of this. any idea?

-- 
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: CSS issue in Cake 2.1 and themes

2012-01-24 Thread Ernesto
i found the issue :)

the culprit was webroot's htaccess

the last rewriterule has been updated. now it's working flawlessly

-- 
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: issue with CSS in Cake 2.1

2012-01-24 Thread Ernesto
you're right :)

i updated the webroot's htaccess and now everything is ok

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


dealing with multicolumn unique indexes... best practice?

2012-01-19 Thread Ernesto
Hi all

What's the most Cake-ish way to deal with multicolumn unique indexes?

let me explain:

i have two models *Material HABTM Mix*.
I must keep track of some addtional infos (% of material for each mix) in 
the join table so, as stated in the cookbook, i scomposed the relationship 
in *2x hasMany*.
*Material hasMany MaterialMix hasMany Mix*.
here comes the problem: *each material can only be in a mix one time*.
so the combination between *materials_mixes.material_id* and *
materials_mixes.mix_id* must be unique.
how can i do that?

Note: the *combination* of field values must be unique, not the value itself

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


W3C validator doesn't like FormHelper's hidden field

2012-01-12 Thread Ernesto
Hi all

hidden fields genetared with FormHelper are failing my validation.
that's because they arent' wrapped in a DIV.

is that intended?

-- 
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: saveAll() + blank records = headache

2012-01-11 Thread Ernesto
This isn't working :\

Here's my Behavior

?php

class CleanableBehavior extends ModelBehavior {

function beforeValidate ($model) { 

foreach ($model-data as $modelAlias = $modelData) {
if (isset($model-hasMany[$modelAlias])) {
  foreach ($modelData as $key = $record) {
 //here i loop through fields. if no fields are set 
i unset the $key
  }
  }
}

//here's the set() function  
$model-set($model-data);

return true;

}

}

?

-- 
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: saveAll() + blank records = headache

2012-01-11 Thread Ernesto
at this point it's simpler to override the saveAll() function in my AppModel

function saveAll ($data = null, $options = array()) {
//some loops to clear the unused records
return parent::saveAll($data, $options);
}

but that's what i'm trying to avoid :)

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


saveAll() + blank records = headache

2012-01-10 Thread Ernesto
Hi all

i have 2 models
Customer hasMany Phonenumber

my customers/add view has a form with a html table where a user can enter 
multiple phone numbers (up to five) for each customer.

Each phone number is referenced as 

Phonenumber.0.number
Phonenumber.0.description

Phonenumber.1.number
Phonenumber.1.description
and so on.

When i fire the saveAll() function the Phonenumber model throws many 
validation errors beacuse the field number is mandatory.
That's because Cake is processing the empty records.
I solved overriding the saveAll() function, looping through the data array 
and unsetting the blank records, but this solution looks kinda nasty to me.

is there any way to do this from a behavior?

-- 
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: saveAll() + blank records = headache

2012-01-10 Thread Ernesto
A Phonenumber without the number is pretty pointless :\

-- 
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: saveAll() + blank records = headache

2012-01-10 Thread Ernesto
A Phonenumber without the number is pretty pointless :\

-- 
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: Form in HomePage

2012-01-10 Thread Ernesto
usually UsersController takes those requests.

u can also force PagesController to use the User model

$this-uses = User

-- 
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: saveAll() + blank records = headache

2012-01-10 Thread Ernesto
manipulating data in the controller doesn't sound MVC-ish to me.
I was searching a way to avoid that. My first though was coding this in a 
Behavior but... how?

i can't put the code in beforeSave because if validation fails (and it 
will, because as stated above the number field is mandatory) this 
callback will not be triggered

-- 
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: saveAll() + blank records = headache

2012-01-10 Thread Ernesto
i've already made a try with beforeValidate.

the problem here is that once the saveAll() is called and the model data is 
passed as argument any mod to the data array will be useless.
The saving process will go on with the array passed to saveAll

-- 
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: saveAll() + blank records = headache

2012-01-10 Thread Ernesto
uhm... i'll try the set() function.

thanks for the support :)

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


Updating application source without breaking sessions

2011-11-28 Thread Ernesto
Hi all

i have a multi-app, single-core environment.
how can i update the source code without resetting sessions?
a friend of mine told me to not overwrite the tmp folder. Is this enough?


-- 
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: Updating application source without breaking sessions

2011-11-28 Thread Ernesto
oh i forgot to say i'm using cake session handler

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


Auth issue with Multi-app enviroment

2011-11-22 Thread Ernesto
Hi all.

i have a multi-app enviroment (more apps sharing the same core).

two of those apps are using Cake's AuthComponent.

i followed the cake's conventions so both apps have
- an UsersController
- a UserModel

and, in theyr own db (they use different DBs)
- a users table, with username and password fields

Let's say i'm logged in the first app.
If i log in from the second one i get disconnected from the first.

This is weird! it looks like a Session issue to me. Maybe the second login 
is overwriting the first one

Any advice?

PS: sry for my bad english

-- 
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: Auth issue with Multi-app enviroment

2011-11-22 Thread Ernesto
It looks like i solved my issue modifying

Configure::write('Session', array('cookie' = APP_DIR));

3 CakePHP

-- 
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: Concurrency control

2011-11-15 Thread Ernesto
that's exactly what i'm doing. :)

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


step loops in WizardComponent

2011-11-15 Thread Ernesto
hi all.

i'm trying to code a multi-page form using WizardComponent.

here's my step array
$this-Wizard-steps = array(
order //here the user selects the customer, the shipping type etc
article = array(
code //the article.id is selected
color //colors are loaded based on the article_id
optionals //same as colors
),
review //this step just shows the added articles
)

i want my customers to be able to add more than one article per order.
How can i force WizardComponent to go back to the code step, if the 
button add another article is pressed in the review step?

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


Concurrency control

2011-11-14 Thread Ernesto
Hi all

i'm looking to implement a Concurrency Control Behavior who looks if data 
has been modified by someone between the time user loads and tries to save 
it.

Is there any pre-made behavior? i lurked the bakery but found nothing.

-- 
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: Need a little help with HABTM joins

2011-11-09 Thread Ernesto
nothing happens. users cannot de-associate Articles and Pieces

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


extracting Model and Field from a Set compatible path

2011-11-09 Thread Ernesto
Hi all

i have an array containing a series of set compatible paths

array(
 [0] = Article.code,
 [1] = {n}.Piece.code,
 [2] = Note.{n}.text
)

is there any built-in function that extracts the Model and the field those 
paths are referencing?

-- 
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: extracting Model and Field from a Set compatible path

2011-11-09 Thread Ernesto
hi jeremy. thanks for the response.

Set::extract extracts data from an arary.

i wan to extract Model and field from the Path itself

-- 
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: Need a little help with HABTM joins

2011-11-08 Thread Ernesto
Thanks for the effort, i solved this way:

- in both articles/add and pieces/add users can enter just code and 
description, no related model data 
- after a successfull add() both Article and Piece models add every 
possible combination between them and the other model. The app then 
redirects diretcly to the edit action
- in both edit actions there's a simple hasMany form where the users can 
modify the ArticlePieces data.

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


Need a little help with HABTM joins

2011-11-07 Thread Ernesto
Hi all.

i have 2 models, Articles and Pieces.

They should've been linked by a HABTM but i need to save some additional 
fields in the join table so i made 2x hasMany.
Here's my situation:

Article hasMany ArticlePiece
Piece hasMany  ArticlePiece 
ArticlePiece belongsTo Article
ArticlePiece belongsTo Piece

How can i load an article, with ALL the pieces, even if they haven't a 
relationship, using Cake's find function?

i need an array like this:

Array
(
[Article] = Array
(
[id] = 1
[code] = XY
[description] = rotflrotflrotfl
)

[ArticlePiece] = Array
(
[0] = Array
(
[id] = 1
[article_id] = 1
[piece_id] = 1
[quantity] = 10.00
[cost_each] = 5.00
)

[1] = Array
(
[id] = 2
[article_id] = 1
[piece_id] = 2
[quantity] = 3.00
[cost_each] = 15.00
)

[2] = Array
(
[id] = 3
[article_id] = 1
[piece_id] = 3
[quantity] = //no cost, no quantity = not related
[cost_each] = //no cost, no quantity = not related
)

)
)

Sorry for my bad english

-- 
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: Need a little help with HABTM joins

2011-11-07 Thread Ernesto
this will load only related models :\

-- 
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: Need a little help with HABTM joins

2011-11-07 Thread Ernesto
Hi. thx for the answer.

This will not solve my issue. i want to load all the Pieces, even if 
they're not related to the Article Model

-- 
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: Need a little help with HABTM joins

2011-11-07 Thread Ernesto
ENG: Thanks for the effort but this isn't my problem
ITA: Grazie del tentativo ma non é quello il mio problema :)

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


Am i breaking MVC?

2011-10-19 Thread Ernesto
Hi all.

i have a simple app wich uses 2 different DBs.
The second DB is used just to import data on a daily basis, no writes.

i have 2 options:

1 - switch DB on-the-fly in my Order::import function

function import() {
$this-useDbConfig = external_db;
$this-query(SELECT * FROM blah);
$this-useDbConfig = default;
$this-saveAll(/* still to code */);
}

2 - add a new Model called Import with a different useDbConfig.

wich one is best in your opinion? i don't want to break MVC.

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


UNION queries returning 1 in Cake 2.0

2011-10-18 Thread Ernesto
Hi all.

i'm quering an SQL Server DB with a query like this

(
SELECT 
name
FROM 
customers
) UNION (
SELECT 
name
FROM 
suppliers
)
ORDER BY name

and i'm always getting 1 as response.

model::query doesn't support UNION queries?


-- 
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: Troubles with Cake 2.0 + SQLServer datasource

2011-10-14 Thread Ernesto
There's no PDO Driver installed and i cannot install it :(

-- 
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: Troubles with Cake 2.0 + SQLServer datasource

2011-10-12 Thread Ernesto
Hi Mark thanks for the answer.

i'll check if the PDO driver is installed. The SQL Server is a 2005 release

-- 
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: Troubles with Cake 2.0 + SQLServer datasource

2011-10-12 Thread Ernesto
i forgot to say that this same app written with Cake 1.3.10, was working 
perfectly  before migrating to 2.0.

i'll check the old datasource :) 

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


Cannot login in cake 2.0 app

2011-10-12 Thread Ernesto
Hi all

i'm having some troubles with the renewed 2.0 AuthComponent.

please note that i'm not following cake conventions on controllers/models 
naming.
UsersController = UtentiController
UserModel = UtenteModel

i simply cannot login. The $this-Auth-login() returns false every time

here's my component declaration in AppController

var $components = array(
Auth = array(
authenticate = array(
Form = array(
userModel = Utenti.Utente
)
),
loginAction = array(
controller = Utenti,
action = login
)
)
);

my Login method in UtentiController

function login() {

if ($this-request-is('post')) {
if ($this-Auth-login()) {
$this-redirect($this-Auth-redirect());
} else {
//still no code here
}
  }
  $this-layout = login;
}



-- 
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: Cannot login in cake 2.0 app

2011-10-12 Thread Ernesto
nvm.
found the typo, now it's all working ok

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


Troubles with Cake 2.0 + SQLServer datasource

2011-10-10 Thread Ernesto
Hi all.
i'm having some troubles with Cake 2.0 + SQLServer datasource

i'm getting a Sqlserver requires a database connection error every time i 
use the external_db config.

here's my database.php

class DATABASE_CONFIG {

 public $default = array(
datasource = Database/Mysql,
persistent = false,
host = 127.0.0.1,
  login = ernesto,
  password = ***,
  database = my_db
 );

 public $external_db = array(
datasource = Database/Sqlserver,
persistent = false,
  host = 192.168.0.10\MSSQLDB,
  port = 1970,
  login = ernesto,
  password = ***,
  database = Ernesto_DB
 );

}


-- 
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: One core, multiple apps, shared classes

2011-10-04 Thread Ernesto
nvm i figured it out.

wrongly set CAKE_CORE_INCLUDE_PATH :)

-- 
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: One core, multiple apps, shared classes

2011-10-04 Thread Ernesto
everything is working fine except the assets sharing.

it looks like cake cannot find my Assets plugin :\

miss the good old 1.2 method :(

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


One core, multiple apps, shared classes

2011-10-03 Thread Ernesto
Hello.

i can't figure out how to configure a single cake core, multiple app 
enviroment in Cake 2.0.

i did it in 1.3 but it isn't working anymore.

is it still possible?

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


Problem with bools and forms

2011-05-09 Thread Ernesto
Hello.

when the bool field is FALSE Cake reads that value as  (empty
value).

this is causing some troubles in my newest app, where due to
customer's habits i'm using boolean selects (simple select boxes with
Yes ans No options) instead of checkboxes.

my select boxes' options are defined this way:
array(0 = No, 1 = Yes)

is there any way to change the default false boolean value to
0 (zero) ??

-- 
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: Problem with bools and forms

2011-05-09 Thread Ernesto
Hi Tilen, thanks for your effort.
Sadly your solution doesn't work

i ended up modifying dbo_source's function boolean from

public function boolean($data, $quote = false) {
if ($quote) {
return !empty($data) ? '1' : '0';
}
return !empty($data);
}

to

public function boolean($data, $quote = false) {
return !empty($data) ? '1' : '0';
}

Any dev can confirm this modify wouldn't break anything? :D

On 9 Mag, 15:34, Tilen Majerle tilen.maje...@gmail.com wrote:
 check thishttp://book.cakephp.org/view/1402/options-default

 http://book.cakephp.org/view/1402/options-defaultand 
 thishttp://book.cakephp.org/view/1405/options-empty
 --
 Lep pozdrav, Tilen Majerlehttp://majerle.eu

 2011/5/9 Ernesto e.fanz...@gmail.com



  Hello.

  when the bool field is FALSE Cake reads that value as  (empty
  value).

  this is causing some troubles in my newest app, where due to
  customer's habits i'm using boolean selects (simple select boxes with
  Yes ans No options) instead of checkboxes.

  my select boxes' options are defined this way:
  array(0 = No, 1 = Yes)

  is there any way to change the default false boolean value to
  0 (zero) ??

  --
  Our newest site for the community: CakePHP Video Tutorials
 http://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: Cake loads FALSE values as (empty)

2011-02-03 Thread Ernesto
@ Miles J

i'm masochist ;-D

usually i try to strictly respect cake conventions.

this is the first time i notice this behavior.
cake always worked flawlessly with his  empty false values

On 2 Feb, 19:19, Miles J mileswjohn...@gmail.com wrote:
 Well, why are you even using 2.0?

 On Feb 2, 8:59 am, euromark dereurom...@googlemail.com wrote:



  nope, tilen

  its tinyint(1) !!!
  ideally unsigned (cant be negative anyway)
  thats what booleans are stored as

  tinyint(2) is for pseudo enum fields or small integer values

  On 2 Feb., 15:05, Tilen Majerle tilen.maje...@gmail.com wrote:

   for values like this, cake uses in database tinyint(2) fieldtype, where 1
   means true and 0 means false (compatible with form helper)
   --
   Lep pozdrav, Tilen Majerlehttp://majerle.eu

   2011/2/2 Ernesto e.fanz...@gmail.com

Hello.

i noticed that Cake loads boolean values stored in DB as  (empty
value) instead of 0 (zero).

is that intended?
is there a way to avoid this?

i'm using 2.0-dev

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

To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.comcake-php%2Bunsubscr...@googlegroups.c
 omFor more options, visit this group at
   http://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


Get current response type in helper (Cake 2.0-dev)

2011-02-02 Thread Ernesto
hello.

i'm refactoring my Helpers to comply with Cake 2.0

i'm having problem with my TidyHelper.
As stated by his name this helper uses Tidy to clean up the output
HTML.
The problem comes when my app renders a PDF, a CSV or any document !=
text/html.

so... is there a way to get CakeResponse::type() in helper, other than
brutally, manually, load that class?

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


Cake loads FALSE values as (empty)

2011-02-02 Thread Ernesto
Hello.

i noticed that Cake loads boolean values stored in DB as  (empty
value) instead of 0 (zero).

is that intended?
is there a way to avoid this?

i'm using 2.0-dev

-- 
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 loads FALSE values as (empty)

2011-02-02 Thread Ernesto
uhm...
that looks like a workaround to me...

http://book.cakephp.org/view/743/MySQL

A tinyint(1) field is considered a boolean by CakePHP.

so why Cake is ignoring the FALSE (zero) value?

On 2 Feb, 15:05, Tilen Majerle tilen.maje...@gmail.com wrote:
 for values like this, cake uses in database tinyint(2) fieldtype, where 1
 means true and 0 means false (compatible with form helper)
 --
 Lep pozdrav, Tilen Majerlehttp://majerle.eu

 2011/2/2 Ernesto e.fanz...@gmail.com



  Hello.

  i noticed that Cake loads boolean values stored in DB as  (empty
  value) instead of 0 (zero).

  is that intended?
  is there a way to avoid this?

  i'm using 2.0-dev

  --
  Our newest site for the community: CakePHP Video Tutorials
 http://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.comcake-php%2Bunsubscribe@googlegroups.c­omFor
   more options, visit this group at
 http://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: Need advice for custom ACL

2011-01-27 Thread Ernesto
the only alternative path i can see is to make hundreds of
controllers, each with his own specific model.
this will lead to hundreds of controllers.

Right now i'm acting this way:
- i use the standard Cake ACL to prevent unwanted page views.
- i added an Authorization model, with HABTM relationship to User
model (and vice-versa)
- i added a Vendor class named CheckAuthorizations, loaded in both
AppController and AppModel's constructors. This class checks if
there's any coincidence between the current logged user and the
requested authorization code (authorization_id), by fetching data from
Authorizations_Users (the HABTM join model).
- Authorization request are done this way:
$this-CheckAuthorization-check([AUTHCODE])
or
$this-CheckAuthorization-require([AUTHCODE])

Any advice?

On 27 Gen, 13:57, Zaky Katalan-Ezra procsh...@gmail.com wrote:
 In that case my honest advice to you is to revise your design.

 If it's not simple it's should simply not (In Hebrew it sounds better)

-- 
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: Need advice for custom ACL

2011-01-27 Thread Ernesto
Hi ShadowCross.

thx for your suggestions.

i'll surely try them


On 27 Gen, 20:31, ShadowCross adri...@jps.net wrote:
 Ernesto:

 Some things to try:

 For your first example: ignore some validation rules if the user has
 authorization X.
 - validate the data from the controller, using the $options parameter
 to specify which subset of the validation rules to apply.  There is a
 (albeit simplistic) example in the Cookbook (http://book.cakephp.org/
 view/1182/Validating-Data-from-the-Controller), where only a couple of
 the fields are validated.  If you have multiple rules for a field, and
 you want only some, not all, those rules checked on that field, you
 can adjust rules array for that field in the Model's beforeValidate()
 function (or an attached Behavior's beforeValidate()) -- the
 $optionsparameter of Model::validates() is passed to the
 Model::beforeValidate(), and only the 'fieldList' key is reserved.
 Unfortunately, if you have to resort to the beforeValidate(), your
 permissions logic will not be confined to your controller.
 - if no errors, call the Model::save() or Model::saveAll(), but set
 the validate parameter to false to avoid using the model's full
 validation

 =
 For your second example: hide or modify some form fields if user
 hasn't authorization Y.
 - in your controller, you can create an array of what authorizations
 the user has and save that to a view variable.
 - in your view, use that array to determine whether a form field
 should be hidden or adjusted.

 example:
 foo_controller.php:

         function edit($id = null) {
                 ...
                 $aro = 'user/' . $this-Auth-user('id');

                 // Create list of authorizations that user has
                 $authorizations = array();
                 foreach(array('Bar/Y_1', 'Bar/Y_2', 'Bar/Y_3') as $aco) {
                         if ($this-Acl-check($aro, $aco) {
                                 $authorizations[] = $aco;
                         }
                 }
                 $this-set(compact('authorizations'));
         }

 foo/edit.ctp:

         ...

         if (in_array('Bar/Y_2', $authorizations)) {
                 echo $this-Form-input('fieldX1');
         } else {
                 echo $this-Form-hidden('fieldX1');
         }
         if (in_array('Bar/Y_3', $authorizations)) {
                 echo $this-Form-input('fieldX2', array(
                         'options' = array('1', '2', '3')
                 ));
         } else {
                 echo $this-Form-input('fieldX2', array(
                         'options' = array('4', '5', '6')
                 ));
         }

 Note that in Cake's built-in ACL, the ACO (Access Control Object)
 nodes do not have to correspond to controllers or actions. ACO nodes
 that correspond to actions is just one of the built-in behaviors.  You
 can also define arbitrary ACO nodes.  To extend my example above, I
 can have the following ACO nodes defined:

         controllers/Foo/add
         controllers/Foo/edit
         controllers/Foo/index
         controllers/Foo/view
         Bar/Y_1
         Bar/Y_2
         Bar/Y_3

 and in app_controller.php:

         var $components = array('Auth' = array(
                 'authorize' = 'actions',
                 'actionPath' = 'controllers/'
         ));

 Note the 'actionPath' AuthComponent variable; any ACO nodes NOT nested
 under the 'controllers' (or whatever you specify as the actionPath)
 node are ignored for the purposes of the standard Cake ACL.  To
 check permissions manually for everything else, you can use the
 check($aro, $aco, $action = '*') function of the AclComponent.

 There may be some advantages of using Cake's AclComponent in this way
 instead of your custom CheckAuthorizations class, including:
 - using existing tables (aros, acos, aros_acos, and not having to add
 the authorizations and authorizations_users tables)
 - inheritance.  ARO nodes can refer to groups and/or users -- if a
 UserX is part of GroupA and GroupA has access to AuthB, UserX also has
 AuthB (unless access to AuthB is explicitly revoked from UserX.  And
 if groups are defined as heirarchical (i.e. TreeBehavior), GroupA can
 inherit access rights from it's parents and ancestors.  The same
 applies to ACO nodes.  In fact, you *could*, in theory, define field-
 level access in the following manner:

 ARO:
         Group 1 (all users)
         Group 2 (admin)

 ACO:
         controllers/Foo/edit
         controllers/Foo/edit/name
         controllers/Foo/edit/fieldX1
         controllers/Foo/edit/fieldX2

 ARO/ACO:

         // All users can access the edit page for Foo
         $this-Acl-allow('Group 1', 'controllers/Foo/edit');

         // Revoke access to fieldX1 and fieldX2 from the public at large
         $this-Acl-deny('Group 1', 'controllers/Foo/edit/fieldX1');
         $this-Acl-deny('Group 1', 'controllers/Foo/edit/fieldX2');

         // Grant access to fieldX1 and fieldX2 to the admins

Need advice for custom ACL

2011-01-26 Thread Ernesto
Hello.

in my app i need to (some examples):

- ignore some validation rules if the user has authorization X
- hide or modify some form fields if user hasn't authorization Y
- do the usual ACL things (if you're a Customer you can't modify
users and so on)

not all of those authorizations are referred to a specific
controller's action so cake's built-in ACL isn't very useful.

in your opinion, what's the best way to implement this?

-- 
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: Need advice for custom ACL

2011-01-26 Thread Ernesto
HiJohn thx for your response

acting that way will bloat my app
i have hundreds of possible combinations :\

On 26 Gen, 15:05, Jon Bennett jmbenn...@gmail.com wrote:
 hi,

  in my app i need to (some examples):

  - ignore some validation rules if the user has authorization X
  - hide or modify some form fields if user hasn't authorization Y
  - do the usual ACL things (if you're a Customer you can't modify
  users and so on)

  not all of those authorizations are referred to a specific
  controller's action so cake's built-in ACL isn't very useful.

  in your opinion, what's the best way to implement this?

 Not tried this, but could you:

 1. Have multiple views per auth type, stops you needing to hide/show form 
 fields
 2. Have multiple Models that connect to the same table, each with a
 different set of validation rules
 3. Use the correct model above in your controller and views

 ... which would mean your ACL logic stays in the controller.

 Might work,

 Cheers,

 Jon

 --
 jon bennett -www.jben.net- blog.jben.net

-- 
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: Need advice for custom ACL

2011-01-26 Thread Ernesto
They don't refer to anything particular.

Look @ my example in first post

On 26 Gen, 18:40, Zaky Katalan-Ezra procsh...@gmail.com wrote:
 not all of those authorizations are referred to a specific
 controller's action so cake's built-in ACL isn't very useful.

 Then what they refer to?

 It looks like you need to create an engine to create your views on the fly.

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


Check if a record has at least one relation with another model

2011-01-21 Thread Ernesto
Hello.

in my app_model i wrote a simple function that takes 2 arguments:
- an id, pointing to any record in the current model
- an associated model

this function checks if the selected record has any relation with the
selected model. if yes, it will return TRUE.

since i prefer to use standard cake functions... is there any built-in
cake function that does that?

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


Indirect modification of overloaded property CarsController::$data has no effect in C:\[...]

2011-01-13 Thread Ernesto
Hi all.

why cake is firing that error?
here's my code

$this-data[Car][mileage] = $mileage;

is this method deprecated ???

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: PDF output issue after upgrading to 2.0-dev

2011-01-12 Thread Ernesto
update:

Opera and Firefox can't open my PDF while IE8 does it flawlessly (lol)

i bet this is a header/render issue

On 11 Gen, 12:03, Ernesto e.fanz...@gmail.com wrote:
 Hi all

 i just upgraded to 2.0-dev
 the only big problem i'm encountering are on-the-fly generated PDFs
 i'll use one of my views as example

 model/controller: this is a PageController action, without data and
 without model. it just changes the layout from default to pdf

 PdfHelper: that's a simple TCPDF wrapper that loads an istance of
 TCPDF during startup

 layout:
 [PHP]
 header(content-type: application/pdf);
 echo $content_for_layout
 [/PHP]

 view:
 [PHP]
 $this-Pdf-PdfLib-addPage()
 //some random TCPDF commands
 $this-Pdf-pdfLib-Output(myPDF);
 [/PHP]

 all this code worked flawlessy in 1.3.6 but in 2.0-dev the PDFs are
 printed just like HTML code

 %PDF-1.7 7 0 obj  /Type /Page /Parent 1 0 R /LastModified (D:
 2011020027+01'00') /Resources 2 0 R /MediaBox [0.00 0.00 595.28
 841.89] /CropBox [0.00 0.00 595.28 841.89] /BleedBox [0.00 0.00 595.28
 841.89] /TrimBox [0.00 0.00 595.28 841.89] /ArtBox [0.00 0.00 595.28
 841.89] /Contents 8 0 R /Rotate 0 /Group  /Type /Group /S /
 Transparency /CS /DeviceRGB  /Annots [ 6 0 R ] /PZ 1  endobj 8 0
 obj  stream x ]] 6 }  #   jێ x* z\S Om -IlSl{ H
 $] h ʃ Q

 why?

 is cake formatting the output?

 i can't get rid of 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: PDF output issue after upgrading to 2.0-dev

2011-01-12 Thread Ernesto
user lorenzo resolved my problem

http://ask.cakephp.org/questions/view/pdf_output_issue_after_upgrading_to_2_0-dev

i used

$this-response-type(pdf)

instead of

header(Content-type: application/pdf)

On 12 Gen, 16:41, Ernesto e.fanz...@gmail.com wrote:
 update:

 Opera and Firefox can't open my PDF while IE8 does it flawlessly (lol)

 i bet this is a header/render issue

 On 11 Gen, 12:03, Ernesto e.fanz...@gmail.com wrote:



  Hi all

  i just upgraded to 2.0-dev
  the only big problem i'm encountering are on-the-fly generated PDFs
  i'll use one of my views as example

  model/controller: this is a PageController action, without data and
  without model. it just changes the layout from default to pdf

  PdfHelper: that's a simple TCPDF wrapper that loads an istance of
  TCPDF during startup

  layout:
  [PHP]
  header(content-type: application/pdf);
  echo $content_for_layout
  [/PHP]

  view:
  [PHP]
  $this-Pdf-PdfLib-addPage()
  //some random TCPDF commands
  $this-Pdf-pdfLib-Output(myPDF);
  [/PHP]

  all this code worked flawlessy in 1.3.6 but in 2.0-dev the PDFs are
  printed just like HTML code

  %PDF-1.7 7 0 obj  /Type /Page /Parent 1 0 R /LastModified (D:
  2011020027+01'00') /Resources 2 0 R /MediaBox [0.00 0.00 595.28
  841.89] /CropBox [0.00 0.00 595.28 841.89] /BleedBox [0.00 0.00 595.28
  841.89] /TrimBox [0.00 0.00 595.28 841.89] /ArtBox [0.00 0.00 595.28
  841.89] /Contents 8 0 R /Rotate 0 /Group  /Type /Group /S /
  Transparency /CS /DeviceRGB  /Annots [ 6 0 R ] /PZ 1  endobj 8 0
  obj  stream x ]] 6 }  #   jێ x* z\S Om -IlSl{ H
  $] h ʃ Q

  why?

  is cake formatting the output?

  i can't get rid of 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


PDF output issue after upgrading to 2.0-dev

2011-01-11 Thread Ernesto
Hi all

i just upgraded to 2.0-dev
the only big problem i'm encountering are on-the-fly generated PDFs
i'll use one of my views as example

model/controller: this is a PageController action, without data and
without model. it just changes the layout from default to pdf

PdfHelper: that's a simple TCPDF wrapper that loads an istance of
TCPDF during startup

layout:
[PHP]
header(content-type: application/pdf);
echo $content_for_layout
[/PHP]

view:
[PHP]
$this-Pdf-PdfLib-addPage()
//some random TCPDF commands
$this-Pdf-pdfLib-Output(myPDF);
[/PHP]

all this code worked flawlessy in 1.3.6 but in 2.0-dev the PDFs are
printed just like HTML code

%PDF-1.7 7 0 obj  /Type /Page /Parent 1 0 R /LastModified (D:
2011020027+01'00') /Resources 2 0 R /MediaBox [0.00 0.00 595.28
841.89] /CropBox [0.00 0.00 595.28 841.89] /BleedBox [0.00 0.00 595.28
841.89] /TrimBox [0.00 0.00 595.28 841.89] /ArtBox [0.00 0.00 595.28
841.89] /Contents 8 0 R /Rotate 0 /Group  /Type /Group /S /
Transparency /CS /DeviceRGB  /Annots [ 6 0 R ] /PZ 1  endobj 8 0
obj  stream x��]]��6�}#�  ��jێ�x*��z\S Om� ��-IlSl{� H� 
$] h ��ʃ Q�

why?

is cake formatting the output?

i can't get rid of 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


Sharing assets between more apps

2010-12-09 Thread Ernesto
hello.

i'm using some assets (a bunch of css files and some icons) in 3 of my
CakePHP apps.
those 3 apps are sharing the same layout.
every time i mod one of those style sheets i need to copy/paste it to
other apps.
i feel very uncomfortable :(
Is there any way to share those assets between my apps?

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


  1   2   3   >