Re: 1 model for multiple database tables

2009-05-02 Thread Bogdan I. Bursuc

You could do something like this:
Add a field in the posts table named type
and do the associations like this:

var $hasAndBelongsToMany = array(
// this here is the HABTM for teams
'Team' => array(
'className' => 'Tag',
'joinTable' => 'posts_teams',
'foreignKey' => 'post_id',
'associationForeignKey' => 'team_id',
'unique' => true,
'conditions' => array('Post.type' => 't')
),
// and this is the HABTM for groups
'Group' => array(
'className' => 'Group',
'joinTable' => 'posts_groups',
'foreignKey' => 'post_id',
'associationForeignKey' => 'group_id',
'unique' => true,
'conditions' => array('Post.type' => 'g')
)
);

and in the other models you put the condition the same Post.type =>
"type"

Don't know for sure if it works, i just used it on hasMany relations not
on HABTM, but if things are the same it should work just fine.

Good luck.


On Sat, 2009-05-02 at 13:06 -0700, Miles J wrote:
> So I am building a forum system, that will be used for multiple areas.
> The table structure is as follows.
> 
> posts
> posts_teams
> posts_groups
> topics
> topics_teams
> topics_groups
> 
> For example, all the posts tables are identical, except for the fact
> that posts_teams is only teams posts, and posts_groups is only for
> groups.
> 
> I want to be able to use only ONE model (posts) that can manipulate
> all 3 tables. Since they are all the same data and structure, I don't
> want to have duplicate a single model 3 times. Is there a method for
> this already, or a behavior?
> 
> If not I think ill go ahead and develop one.
> > 



--~--~-~--~~~---~--~~
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: Telling PHP to put "&" NOT "&"

2009-05-02 Thread Dr. Loboto

If you posted exact code for restore_html_ecoded_characters this
function do nothing on array values. In foreach($pArray as $key =>
$value) variable $value contains copy of value but not reference to
it. On is_array($value) you need to call restore_html_ecoded_characters
($pArray[$key]); as you do for non-array values.

On May 3, 8:17 am, rartavia  wrote:
> Here is the code by the way...
>
> function restore_html_ecoded_characters(&$pArray){
>         foreach($pArray as $key => $value){
>                 if(is_array($value)){
>                         restore_html_ecoded_characters($value);
>                 }else{
>                         $pArray[$key] = str_replace("_#", "&#", $value);
>                 }
>         }}
>
> In Controller:
>
> function save(){
>         $this->layout = null;
>
>         $thisdata = $this->data;
>         restore_html_ecoded_characters($thisdata);
> ...
>         $this->Denouncement->saveAll($thisdata);
> ...
>
> Is there any weird thing to know about when trying to edit $this->data?
--~--~-~--~~~---~--~~
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: $ajax->form in Ajax response not working

2009-05-02 Thread Dr. Loboto

You should not see 

Re: Telling PHP to put "&" NOT "&"

2009-05-02 Thread Lapinski


Why did you need to hack it this way?  Why not just leave the user
input intact and convert them to html entities by php?
http://us3.php.net/htmlentities

On May 2, 6:13 pm, rartavia  wrote:
> Hi there.
>
> Benedikt: I did try str_replace, preg_replace and strtr, same result.
>
> Lapinski: What I'm doing is with JavaScript replacing some characters
> (á,é,í,ó,ú,&) to there html character (ie -> á: á) but if I sent
> to server data[Model][value]=á would fail since the ampersand is
> the parameter separator so when I read in my controller data['Model']
> ['value'] it would be blank, my solution for that was using _#225;
> instead of á and then my idea is to replace it in the server for
> the ampersand and then save to DB.
>
> Despite everything, there are two details, one; that I i'm seeing the
> & in the log (debugger::log($value)) so it may be the log() the
> one converting it (sorry if this is known, i didn't know, and its only
> a supposition of mine) and also, if you see my code I'm using a
> reference parameter (&pArray) so that my original array gets modified
> there, and then I saveAll($modified_array). But when I look at the
> database, the value is saved as if it was never modified, as _#
> instead of &# or even &. So I think the real problem is else
> where.
>
> thanks for your answers, I appreciate any help
--~--~-~--~~~---~--~~
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: Trying to Understand the Containable Behavior

2009-05-02 Thread Blackymetal



On May 2, 9:40 pm, Brendon Kozlowski  wrote:
> If you can figure out the SQL query, then it could be reverse
> engineered in to a CakePHP find call.  Containable is merely a
> mechanism to reduce any unnecessary joins that you don't need for that
> particular query; it's to help make your find() calls more efficient.
> First, you'd need to discover the appropriate query syntax.  For more
> advanced SQL commands if you're not too versed in SQL (like myself)
> you'd have to work a bit backwards.  Come up with the query first,
> then convert it back in to a CakePHP find() call.  After awhile,
> through the practice of doing that, creating properly formed find()
> calls will become easier and start to allow you to use the features of
> Cake as it was intended to be (such as Containable, for instance).
>
> The nice thing about Cake's find() calls is that they're written very
> modularly, so it's very easy to see where to add, or remove certain
> code to come up with almost a completely different result set with
> very little effort.  I think it might do some caching internally too
> that the regular query() call does not do, but I'm not entirely sure
> about that.  The most difficult things I've found with find() are
> defining something other than a LEFT join, but I believe Nate showed
> how to do it somewhere, either in the Google Groups, bakery, or
> somewhere else.
>
> On May 2, 8:54 pm, Rob Wilkerson  wrote:
>
> > On May 2, 7:25 pm, Rob Wilkerson  wrote:
>
> > > I'm trying to do something that I think is reasonably complex (and
> > > maybe outside of what the behavior was intended to do) with the
> > > Containable behavior and, although I seem to be dancing all around it,
> > > I can't get it quite right. I'm hoping someone here can either tell me
> > > I'm trying to do something that can't be done or help me get it right.
>
> > The more I read, the more I think it sounds like this isn't something
> > that the Containable behavior is designed for. Although my SQL isn't
> > great, I also can't think of any way - outside of subqueries - to do
> > it using standard SQL, so that's probably the answer to my specific
> > question. Instead, I'm wondering if there's another "Cake way" to
> > solve the higher level problem. Snipped from my original message:
>
> > "What I'd like to do is, for a given Account, retrieve all of the
> > alerts that are relevant to that Account - including those related to
> > its Campaigns and the Creatives related to the Campaigns."
>
> > Any chance that such an operation is possible in a way I haven't been
> > able to see/find/figure out?
>
> > Thanks again.
>
>
--~--~-~--~~~---~--~~
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: (noob) trouble with belongsTo from another controller

2009-05-02 Thread brian

Try this:
$allies = $this->Ally->find( 'all' );


On Sat, May 2, 2009 at 10:31 PM, craig.kaminsky
 wrote:
>
> Hi,
>
> I'm a CakePHP noob who is converting a site from Fusebox/ColdFusion to
> CakePHP (1.2.x). Without boring anyone with the domain details, I want
> to output a list of 'allies' and their associated organizations
> (belongs to an organization in the model). The problem I am running
> into is that I cannot get CakePHP to recognize the relationship
> between Allies and Organizations from a "third-party" controller (the
> "HomeController").
>
> Here's my setup:
>
> MODEL:
> FILENAME: ally.php
> class Ally extends AppModel {
>
>        var $name = 'Ally';
>
>        //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>        var $belongsTo = array(
>                'Organization' => array(
>                        'className' => 'Organization',
>                        'dependent' => true,
>                        'foreignKey' => 'organization_id'
>                )
>        );
> }
>
> FILENAME: organization.php
> class Organization extends AppModel {
>
>        var $name = 'Organization';
>        var $displayName = 'name';
>
>        //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>        var $belongsTo = array(
>                'OrganizationType' => array(
>                        'className' => 'OrganizationType',
>                        'foreignKey' => 'organization_type_id'
>                )
>        );
>
>        var $hasMany =  array(
>                'Ally' => array(
>                        'className' => 'Ally',
>                        'foreignKey' => 'organization_id'
>                )
>        );
>
> }
>
> CONTROLLER:
> FILENAME: home_controller.php
> class HomeController extends AppController
> {
>        var $name = 'Home';
>        var $uses = array( 'Allies');
>
>        function index()
>        {
>                $allies = $this->Allies->find( 'all' );
>                $this->set( 'allies', $allies );
>        }
>
> }
>
> DB:
> The tables (allies and organizations) are plural and both have a
> primary key named 'id". The allies table has a column called
> 'organization_id' to act as a foreign key (MySQL 5 DB).
>
> RESULTING SQL IN DEBUG OUTPUT:
> SELECT `Allies`.`id`, `Allies`.`organization_id`, `Allies`.`sfa_href`,
> `Allies`.`logo`, `Allies`.`overview`, `Allies`.`active` FROM `allies`
> AS `Allies` WHERE 1 = 1
>
> Why wouldn't this setup/configuration result in the allies select
> trying to join the organizations table from the home controller?
>
> It does work properly when I set it up from the Allies controller in
> that I see both Ally data and Organization data. I'm just a little
> stumped as to how to make this work from the HomeController.
>
> Any help or guidance would be much appreciated.
>
> Thanks!
> Craig
>
> >
>

--~--~-~--~~~---~--~~
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: Question about render()

2009-05-02 Thread brian

On Sat, May 2, 2009 at 6:42 PM, Rick  wrote:
>
> In my controller I have an action 'add' and an action 'search'.  In
> the search action I do some things then want to render the 'add' view
> so as the last line in the search I add $this->render('add');
>
> This does indeed show the add page but then it renders the search
> page.  So I end up with the add page and search page combined into one
> page. (I hope this is clear).
>
> Obviously I'm doing something wrong but what?   Do I need to "turn
> off" the automatic rendering of the search page somehow?

Yes. $this->autoRender = false;

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



(noob) trouble with belongsTo from another controller

2009-05-02 Thread craig.kaminsky

Hi,

I'm a CakePHP noob who is converting a site from Fusebox/ColdFusion to
CakePHP (1.2.x). Without boring anyone with the domain details, I want
to output a list of 'allies' and their associated organizations
(belongs to an organization in the model). The problem I am running
into is that I cannot get CakePHP to recognize the relationship
between Allies and Organizations from a "third-party" controller (the
"HomeController").

Here's my setup:

MODEL:
FILENAME: ally.php
class Ally extends AppModel {

var $name = 'Ally';

//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $belongsTo = array(
'Organization' => array(
'className' => 'Organization',
'dependent' => true,
'foreignKey' => 'organization_id'
)
);
}

FILENAME: organization.php
class Organization extends AppModel {

var $name = 'Organization';
var $displayName = 'name';

//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $belongsTo = array(
'OrganizationType' => array(
'className' => 'OrganizationType',
'foreignKey' => 'organization_type_id'
)
);

var $hasMany =  array(
'Ally' => array(
'className' => 'Ally',
'foreignKey' => 'organization_id'
)
);

}

CONTROLLER:
FILENAME: home_controller.php
class HomeController extends AppController
{
var $name = 'Home';
var $uses = array( 'Allies');

function index()
{
$allies = $this->Allies->find( 'all' );
$this->set( 'allies', $allies );
}

}

DB:
The tables (allies and organizations) are plural and both have a
primary key named 'id". The allies table has a column called
'organization_id' to act as a foreign key (MySQL 5 DB).

RESULTING SQL IN DEBUG OUTPUT:
SELECT `Allies`.`id`, `Allies`.`organization_id`, `Allies`.`sfa_href`,
`Allies`.`logo`, `Allies`.`overview`, `Allies`.`active` FROM `allies`
AS `Allies` WHERE 1 = 1

Why wouldn't this setup/configuration result in the allies select
trying to join the organizations table from the home controller?

It does work properly when I set it up from the Allies controller in
that I see both Ally data and Organization data. I'm just a little
stumped as to how to make this work from the HomeController.

Any help or guidance would be much appreciated.

Thanks!
Craig

--~--~-~--~~~---~--~~
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: Telling PHP to put "&" NOT "&"

2009-05-02 Thread Brendon Kozlowski

These posts may give you further insight in to why this is happening.
I'm about to go to bed, my eyes are blurry so I didn't actually read
it all the way through...but I believe somewhere in CakePHP, it's
autoconverting it for you, but I *think* it can be overridden.

http://groups.google.com/group/cake-php/browse_thread/thread/7c5b494440ac4888
http://groups.google.com/group/cake-php/browse_thread/thread/a8c5e4ac36691724

On May 2, 9:17 pm, rartavia  wrote:
> Here is the code by the way...
>
> function restore_html_ecoded_characters(&$pArray){
>         foreach($pArray as $key => $value){
>                 if(is_array($value)){
>                         restore_html_ecoded_characters($value);
>                 }else{
>                         $pArray[$key] = str_replace("_#", "&#", $value);
>                 }
>         }}
>
> In Controller:
>
> function save(){
>         $this->layout = null;
>
>         $thisdata = $this->data;
>         restore_html_ecoded_characters($thisdata);
> ...
>         $this->Denouncement->saveAll($thisdata);
> ...
>
> Is there any weird thing to know about when trying to edit $this->data?
--~--~-~--~~~---~--~~
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: Trying to Understand the Containable Behavior

2009-05-02 Thread Brendon Kozlowski

If you can figure out the SQL query, then it could be reverse
engineered in to a CakePHP find call.  Containable is merely a
mechanism to reduce any unnecessary joins that you don't need for that
particular query; it's to help make your find() calls more efficient.
First, you'd need to discover the appropriate query syntax.  For more
advanced SQL commands if you're not too versed in SQL (like myself)
you'd have to work a bit backwards.  Come up with the query first,
then convert it back in to a CakePHP find() call.  After awhile,
through the practice of doing that, creating properly formed find()
calls will become easier and start to allow you to use the features of
Cake as it was intended to be (such as Containable, for instance).

The nice thing about Cake's find() calls is that they're written very
modularly, so it's very easy to see where to add, or remove certain
code to come up with almost a completely different result set with
very little effort.  I think it might do some caching internally too
that the regular query() call does not do, but I'm not entirely sure
about that.  The most difficult things I've found with find() are
defining something other than a LEFT join, but I believe Nate showed
how to do it somewhere, either in the Google Groups, bakery, or
somewhere else.

On May 2, 8:54 pm, Rob Wilkerson  wrote:
> On May 2, 7:25 pm, Rob Wilkerson  wrote:
>
> > I'm trying to do something that I think is reasonably complex (and
> > maybe outside of what the behavior was intended to do) with the
> > Containable behavior and, although I seem to be dancing all around it,
> > I can't get it quite right. I'm hoping someone here can either tell me
> > I'm trying to do something that can't be done or help me get it right.
>
> The more I read, the more I think it sounds like this isn't something
> that the Containable behavior is designed for. Although my SQL isn't
> great, I also can't think of any way - outside of subqueries - to do
> it using standard SQL, so that's probably the answer to my specific
> question. Instead, I'm wondering if there's another "Cake way" to
> solve the higher level problem. Snipped from my original message:
>
> "What I'd like to do is, for a given Account, retrieve all of the
> alerts that are relevant to that Account - including those related to
> its Campaigns and the Creatives related to the Campaigns."
>
> Any chance that such an operation is possible in a way I haven't been
> able to see/find/figure out?
>
> Thanks again.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Timezone issues

2009-05-02 Thread Turgs

Hi

The TimeHelper's convert() function takes a userOffset parameter as an
integer (hours from GMT).

What do you do for locations that are not an *exact* hour from GMT?
Such as:

   * Mumbai, Maharashtra, India (UTC+5:30)
   * Kathmandu, Nepal (UTC+5:45)
   * Dhaka, Bangladesh (UTC+6)
   * Yangon, Myanmar (UTC+6:30)
   * Adelaide, Australia (UTC+9:30)

Thanks
Turgs
--~--~-~--~~~---~--~~
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: Telling PHP to put "&" NOT "&"

2009-05-02 Thread rartavia

Here is the code by the way...

function restore_html_ecoded_characters(&$pArray){
foreach($pArray as $key => $value){
if(is_array($value)){
restore_html_ecoded_characters($value);
}else{
$pArray[$key] = str_replace("_#", "&#", $value);
}
}
}
In Controller:

function save(){
$this->layout = null;

$thisdata = $this->data;
restore_html_ecoded_characters($thisdata);
...
$this->Denouncement->saveAll($thisdata);
...

Is there any weird thing to know about when trying to edit $this->data?
--~--~-~--~~~---~--~~
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: Telling PHP to put "&" NOT "&"

2009-05-02 Thread rartavia

Hi there.

Benedikt: I did try str_replace, preg_replace and strtr, same result.

Lapinski: What I'm doing is with JavaScript replacing some characters
(á,é,í,ó,ú,&) to there html character (ie -> á: á) but if I sent
to server data[Model][value]=á would fail since the ampersand is
the parameter separator so when I read in my controller data['Model']
['value'] it would be blank, my solution for that was using _#225;
instead of á and then my idea is to replace it in the server for
the ampersand and then save to DB.

Despite everything, there are two details, one; that I i'm seeing the
& in the log (debugger::log($value)) so it may be the log() the
one converting it (sorry if this is known, i didn't know, and its only
a supposition of mine) and also, if you see my code I'm using a
reference parameter (&pArray) so that my original array gets modified
there, and then I saveAll($modified_array). But when I look at the
database, the value is saved as if it was never modified, as _#
instead of &# or even &. So I think the real problem is else
where.

thanks for your answers, I appreciate any help
--~--~-~--~~~---~--~~
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: Trying to Understand the Containable Behavior

2009-05-02 Thread Rob Wilkerson



On May 2, 7:25 pm, Rob Wilkerson  wrote:
> I'm trying to do something that I think is reasonably complex (and
> maybe outside of what the behavior was intended to do) with the
> Containable behavior and, although I seem to be dancing all around it,
> I can't get it quite right. I'm hoping someone here can either tell me
> I'm trying to do something that can't be done or help me get it right.

The more I read, the more I think it sounds like this isn't something
that the Containable behavior is designed for. Although my SQL isn't
great, I also can't think of any way - outside of subqueries - to do
it using standard SQL, so that's probably the answer to my specific
question. Instead, I'm wondering if there's another "Cake way" to
solve the higher level problem. Snipped from my original message:

"What I'd like to do is, for a given Account, retrieve all of the
alerts that are relevant to that Account - including those related to
its Campaigns and the Creatives related to the Campaigns."

Any chance that such an operation is possible in a way I haven't been
able to see/find/figure out?

Thanks again.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Question about render()

2009-05-02 Thread Rick

In my controller I have an action 'add' and an action 'search'.  In
the search action I do some things then want to render the 'add' view
so as the last line in the search I add $this->render('add');

This does indeed show the add page but then it renders the search
page.  So I end up with the add page and search page combined into one
page. (I hope this is clear).

Obviously I'm doing something wrong but what?   Do I need to "turn
off" the automatic rendering of the search page somehow?

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



Trying to Understand the Containable Behavior

2009-05-02 Thread Rob Wilkerson

I'm trying to do something that I think is reasonably complex (and
maybe outside of what the behavior was intended to do) with the
Containable behavior and, although I seem to be dancing all around it,
I can't get it quite right. I'm hoping someone here can either tell me
I'm trying to do something that can't be done or help me get it right.

I have models for Account, Campaign and Creative. An Account hasMany
Campaign and a Campaign hasMany Creative. I have an alert model that
belongs to all of these via a "generic" entity_id foreign key. This
allows me to set an alert for any of these models and retrieve them
accordingly without having to create a bunch of separate models. So
here's the thing:

What I'd like to do is, for a given Account, retrieve all of the
alerts that are relevant to that Account - including those related to
its Campaigns and the Creatives related to the Campaigns. I think (or
maybe "hope" is more appropriate) that's possible using Containable.
Ideally, I'd like to get back an array containing the Alert object and
the object to which it belongs, but no empty objects. In other words,
don't return an Account object if the Alert is attached to a Campaign.

I've tried separately "containing" those models as well as containing
them in a nested manner. Here is the current code for the nested
containment being called from the Account model:

$alerts = $this->Alert->find (
'all',
array (
'contain' => array (
'Account' => array (
'conditions' => array ( 
'Account.id' => $account_id ),
'Campaign' => array (
'conditions' => array ( 
'Campaign.account_id' => $account_id )
)
)
)
)
);

Any thoughts would be much appreciated.
--~--~-~--~~~---~--~~
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: 1 model for multiple database tables

2009-05-02 Thread brian

There are a few ways to do this with Cake. Here are some behaviors
that immediately come to mind.

http://bakery.cakephp.org/articles/view/extendablebehavior
http://bakery.cakephp.org/articles/view/subclass-behavior
http://bakery.cakephp.org/articles/view/inheritable-behavior-missing-link-of-cake-model

On Sat, May 2, 2009 at 5:59 PM, Miles J  wrote:
>
> They are a bit different, with each having a different column or two.
> If I combine, I guess I can just have a bunch of null fields depending
> on what I do.
>
> I like Matts suggestion also right now.
> >
>

--~--~-~--~~~---~--~~
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: 1 model for multiple database tables

2009-05-02 Thread Miles J

They are a bit different, with each having a different column or two.
If I combine, I guess I can just have a bunch of null fields depending
on what I do.

I like Matts suggestion also right now.
--~--~-~--~~~---~--~~
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: 1 model for multiple database tables

2009-05-02 Thread jszoja

Shouldn't you use only one table instead of three? Table structure is
the same so you can add to it additional column called type which can
be null - posts, 't' - post_teams and 'g' for post_groups. In my
opinion this is the easier way to solve the problem if it is possible
to manipulate the table structure.

On May 2, 9:06 pm, Miles J  wrote:
> So I am building a forum system, that will be used for multiple areas.
> The table structure is as follows.
>
> posts
> posts_teams
> posts_groups
> topics
> topics_teams
> topics_groups
>
> For example, all the posts tables are identical, except for the fact
> that posts_teams is only teams posts, and posts_groups is only for
> groups.
>
> I want to be able to use only ONE model (posts) that can manipulate
> all 3 tables. Since they are all the same data and structure, I don't
> want to have duplicate a single model 3 times. Is there a method for
> this already, or a behavior?
>
> If not I think ill go ahead and develop one.

--~--~-~--~~~---~--~~
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: 1 model for multiple database tables

2009-05-02 Thread Matt Curry

A simple trick would be to make a PostBase model that extends
AppModel, then have all your Posts related models extend PostBase.
These would just be shell models and all your real code would go into
PostBase.  You'd have extra models, but no code duplication.

-Matt
http://www.pseudocoder.com

On May 2, 4:06 pm, Miles J  wrote:
> So I am building a forum system, that will be used for multiple areas.
> The table structure is as follows.
>
> posts
> posts_teams
> posts_groups
> topics
> topics_teams
> topics_groups
>
> For example, all the posts tables are identical, except for the fact
> that posts_teams is only teams posts, and posts_groups is only for
> groups.
>
> I want to be able to use only ONE model (posts) that can manipulate
> all 3 tables. Since they are all the same data and structure, I don't
> want to have duplicate a single model 3 times. Is there a method for
> this already, or a behavior?
>
> If not I think ill go ahead and develop one.
--~--~-~--~~~---~--~~
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: 1 model for multiple database tables

2009-05-02 Thread Miles J

Because they all work slightly differently.

For example, the regular posts/topics models belong to a forum model
(forums table), where as the teams/groups do not belong to any parent.
The teams/groups also have different moderator systems in place.
--~--~-~--~~~---~--~~
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: 1 model for multiple database tables

2009-05-02 Thread John Andersen

I do not think you can handle more than one table in each model, but
somebody will correct me if I am wrong!

What I don't understand is why you have three tables with the same
content, just to separate team posts and group posts from ordinary
posts! Change your data model into this:

Topic hasMany Post
Post belongsTo Topic
Team hasAndBelongsToMany Topic
Team hasAndBelongsToMany Post
Group hasAndBelongsToMany Topic
Group hasAndBelongsToMany Post

Thus you will only have one model for each and will be able to handle
all the posts from the same model.
Enjoy,
   John

On May 2, 11:06 pm, Miles J  wrote:
> So I am building a forum system, that will be used for multiple areas.
> The table structure is as follows.
>
> posts
> posts_teams
> posts_groups
> topics
> topics_teams
> topics_groups
>
> For example, all the posts tables are identical, except for the fact
> that posts_teams is only teams posts, and posts_groups is only for
> groups.
>
> I want to be able to use only ONE model (posts) that can manipulate
> all 3 tables. Since they are all the same data and structure, I don't
> want to have duplicate a single model 3 times. Is there a method for
> this already, or a behavior?
>
> If not I think ill go ahead and develop one.
--~--~-~--~~~---~--~~
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 model for multiple database tables

2009-05-02 Thread Miles J

So I am building a forum system, that will be used for multiple areas.
The table structure is as follows.

posts
posts_teams
posts_groups
topics
topics_teams
topics_groups

For example, all the posts tables are identical, except for the fact
that posts_teams is only teams posts, and posts_groups is only for
groups.

I want to be able to use only ONE model (posts) that can manipulate
all 3 tables. Since they are all the same data and structure, I don't
want to have duplicate a single model 3 times. Is there a method for
this already, or a behavior?

If not I think ill go ahead and develop one.
--~--~-~--~~~---~--~~
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: Advanced Pagination

2009-05-02 Thread sbutch

Behavior of array_merge() was modified in PHP 5.
Unlike PHP 4, array_merge()  now only accepts parameters of type
array.

So if you have problem with next() function, try modify line 312 of
paginator.php helper, with a typecast:

It was:$url = array_merge(array('page' => $paging['page'] +
($which == 'Prev' ? $step * -1 : $step)), $url);
now is: $url = array_merge(array('page' => $paging['page'] + ($which
== 'Prev' ? $step * -1 : $step)), (array)$url);

Hope will help!

--~--~-~--~~~---~--~~
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: Search engine like function?

2009-05-02 Thread Lapinski


check out http://bakery.cakephp.org/articles/view/sphinx-behavior  and
see if it fits your need?

On May 1, 9:00 am, mbourque  wrote:
> I am building a data warehouse site that contains a lot of customer info. I
> need to allow users of my app to have a search page that lets them enter
> natural search strings to find and narrow search results.
>
> I wanted each word on the search field to be treated as AND clause in my
> search. I also need the search to act like full text where multiple fields
> are considered for a match. I also have a special case whereas a numeric
> keyword is treated special and only certain fields are searched in that
> case.
>
> Examples:
>
> Keyword: dave
> Searches: ( `User`.`name` like '%dave%' OR `User`.`email` like '%dave%'  )
>
> Keyword: dave thomas
> Searches: ( ( `User`.`name` like '%dave%' OR `User`.`email` like '%dave%'  )
> AND ( `name` like '% thomas%' OR `email` like '% thomas%' ) )
>
> Keyword: 341
> Searches: ( `User`.`id` = '341'  )
>
> I have written a model function that divides the keywords into an array and
> creates an array of conditions that I pass to the find() command. This works
> great.
>
> However this feels like a very common pattern, and I wonder if I just
> reinvented the wheel? Sooner or later I will be asked to add special keyword
> handlers such as:
>
> dave OR thomas
> dave AND thomas
> "dave thomas"
> "dave thomas" OR "david thomas"
>
> Is there already a cake pattern or helper that exists that I should be
> using? If not I may just create one for the good of the community.
> --
> View this message in 
> context:http://n2.nabble.com/Search-engine-like-function--tp2753945p2753945.html
> Sent from the CakePHP mailing list archive at Nabble.com.

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



Re: Telling PHP to put "&" NOT "&"

2009-05-02 Thread Lapinski


did you try to debug your output right after the replacement?  it
looks to me that you're reading the XHTML output from the browser...

On May 2, 12:29 am, rartavia  wrote:
> Hello, i'm trying to make a replace of a character in a string for an
> '&'. I tried several ways of replacement but (cake)PHP, when I do
> str_replace("_", "&") it returns "&"(HTML encoded). How can I get
> the replacement to be an ampersand itself?
>
> My code:
> /**
>  *      From client comes all special characters encoded
>  *      HTML encoded but instead of &#NUMBER; => _#NUMBER;
>  *      This Method restores to &#NUMBER;
> **/
> function restoreHTMLEcodedCharacters(&$pArray){
>         foreach($pArray as $key => $value){
>                 if(is_array($value)){
>                         restoreHTMLEcodedCharacters($value);
>                 }else{
>                         //debugger::log($value);
>                         $value = preg_replace("_#", "&#", $value);
>                         $value = str_replace("&", "&", $value);
>                 }
>         }
>
> }
>
> Thanks

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



Re: Accessing Other Models

2009-05-02 Thread brian

Do you have 'RiskCategory' in your data array? Try debug($this->data)
in the view. If not, you might want to look at ContainableBehavior to
include it.

On Fri, May 1, 2009 at 2:14 PM, jake1729  wrote:
>
> I have the following setup:
>
> Contractor hasMany Projects
>
> Project hasMany Risks
>
> Risk belongsTo Riskcategory
>
> ===
> In my projects view, I am shown related project risks.  One of the
> column headers is the "Risk Category".  However, it only shows the
> primary key id (riskcategories_id), which is a foreign key in the
> Risks table.
>
> How can I show the actual category name in the related Project Risks
> table in the view?
>
> >
>

--~--~-~--~~~---~--~~
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: Removing an item from a set using Set::Remove.

2009-05-02 Thread Dave Maharaj :: WidePixels.com

I have run into something similar where I wanted to remove, but first find
out why a Part of the array was even showing up.

I have the 2 debug statements in concession so I can see what data goes in
the save and what is actually saved
Line 225
debug($this->data);
Returns
Array
(
[System] => Array
(
[System] => Array
(
[0] => 3
[1] => 5
[2] => 6
[3] => 1
)

)

)
Line 226
debug($this->User->save($this->data[$model_table], true,
array_keys($this->User->$join_table->schema(;
Returns
Array
(
[User] => Array
(
[id] => 3
)

[System] => Array
(
[0] => 3
[1] => 5
[2] => 6
[3] => 1
[4] => 3
[5] => 5
[6] => 6
[7] => 1
)

)

SQL = UPDATE `users` SET `id` = 3 WHERE `users`.`id` = 3

Howwould I remove the 

[User] => Array
(
[id] => 3
)
 

-Original Message-
From: brian [mailto:bally.z...@gmail.com] 
Sent: May-02-09 1:18 PM
To: cake-php@googlegroups.com
Subject: Re: Removing an item from a set using Set::Remove.


Wait--that's not right at all! I just looked more closely at what you had
there (it's still early here; 1st coffee). Set::remove() doesn't work like
that.  Say you wanted to remove all of the 'name' parts from the input
array. You'd do:

$events = Set::remove($events, '{n}.Event.name');

Giving you something like:

Array
(
   [0] => Array
   (
   [Event] => Array
   (
   [id] => 1
   )

   )

   [1] => Array
   (
   [Event] => Array
   (
   [id] => 2
)
   )

   [2] => Array
   (
   [Event] => Array
   (
   [id] => 3
)

   )

)

There's no 3rd param.

For your purposes, why don't you simply use the conditions to keep certain
rows from being selected at all? Either that, or re-think how you're storing
this data. Why do you need to remove this or other rows? Perhaps there's a
more elegant solution.

On Sat, May 2, 2009 at 11:39 AM, brian  wrote:
> I've never used it myself but that looks correct. Maybe you left it 
> out of your example but make sure to assign the return from remove() 
> back to your var.
>
> $events = Set::remove($events, '{n}.Event.id' , 2);
>
> On Fri, May 1, 2009 at 11:28 AM, Krist van Besien 
>  wrote:
>>
>> Suppose I have the following set:
>>
>> Array
>> (
>>    [0] => Array
>>        (
>>            [Event] => Array
>>                (
>>                    [id] => 1
>>                    [name] => 1
>>                               )
>>
>>        )
>>
>>    [1] => Array
>>        (
>>            [Event] => Array
>>                (
>>                    [id] => 2
>>                    [name] => 2
>>                                  )
>>        )
>>
>>    [2] => Array
>>        (
>>            [Event] => Array
>>                (
>>                    [id] => 3
>>                    [name] => 3
>>                                  )
>>
>>        )
>>
>> )
>>
>> ( This set was generate using $this->Event->find('all'); )
>>
>> Now suppose I want to remove from this set the "Event" with id "2".
>> How would I do this? I don't want to remove it from the DB, I just 
>> want to remove it from the set, so it doesn't get displayed in the 
>> view.
>>
>> I thought I could do this with Set::Remove. However the documentation 
>> here is quite sparse. And doing a search for "Set::Remove" on both 
>> the cakephp sites and this groups didn't turn up a single hit...
>>
>> Anyway, I tried:
>> Set::remove($events, '{n}.Event.id' , 2);
>>
>> But that didn't do anything.
>>
>> Any pointers to help me in the right direction?
>>
>> Krist
>>
>> --
>> krist.vanbes...@gmail.com
>> kr...@vanbesien.org
>> Bremgarten b. Bern, Switzerland
>> --
>> A: It reverses the normal flow of conversation.
>> Q: What's wrong with top-posting?
>> A: Top-posting.
>> Q: What's the biggest scourge on plain text email discussions?
>>
>> >>
>>
>



--~--~-~--~~~---~--~~
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: trouble with Media view

2009-05-02 Thread brian

I don't see how that would change anything, as it's the $id that's
appended to $path. The issue appears to be that is_dir() can take a
relative path.

On Fri, May 1, 2009 at 5:04 PM, bram  wrote:
>
> Did you try 'name' => 'test' (without extension)?
>
> I don't know why the parameters to the media view are that
> complicated... note that the extension should be lower case. In my
> application, the absolute path to the file is known. Even then, it's
> quite a hassle to get in properlly in the media template. I've used
> the following code:
>
> $path_parts = pathinfo($filepath);
>
> $params = array();
> $params['id'] = $path_parts['basename'];
> $params['name'] = $path_parts['filename'];
> $params['extension'] = strtolower($path_parts['extension']);
> $params['path'] = $path_parts['dirname'] . DS;
> $params['download'] = true;
>
>
> On Apr 21, 6:30 am, brian  wrote:
>> Mediaviewkeeps throwing up a 404 because of the following code:
>>
>> if (is_dir($path)) {
>>         $path = $path . $id;} else {
>>
>>         $path = APP . $path . $id;
>>
>> }
>>
>> if (!file_exists($path)) {
>>         header('Content-Type: text/html');
>>         $this->cakeError('error404');
>>
>> }
>>
>> Here are my params, btw:
>>
>> Array
>> (
>>     [id] => test.jpg
>>     [name] => test.jpg
>>     [download] => 1
>>     [extension] => jpg
>>     [path] => files/test/
>> )
>>
>> That path is under APP, not WWW_ROOT, as it should be.
>>
>> What's happening is that is_dir() can take a relative path and so is
>> checking relative tp APP and returning true. However, file_exists()
>> must have an absolute path.
>>
>> When I changed my code to:
>> 'path' => APP.$result['ItemFile']['directory'].DS
>>
>> Everything worked.
>>
>> I didn't see anything on bugtrac. Shouldn't this problem be cropping
>> up for everybody that uses the recommended relative-to-app path?!?
> >
>

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



Re: Auth ignoring Session, redirecting to login under heavy load.

2009-05-02 Thread brian

On Fri, May 1, 2009 at 7:16 AM, j0n4s.h4rtm...@googlemail.com
 wrote:
>
> Hello Brian,
>
> about PLESK:
>
> 1. Your DOCUMENT ROOT will be something like /var/www/domains/
> domain.tld/httpdocs you will need to change that via ssh for instance.
> You can do that multiple ways but the PLESK way is to go to /var/www/
> domains/domain.tld/conf/ and add vhost.conf there which only has
> DocumentRoot /foo/bar. vhost is included by PLESK (at least on
> HostEurope).
>
> 2. I had issues with unix permissions. There are some users and some
> groups and you can only have one user and group. Webserver runs on
> root and/or www-data - I did not understand that fully why it even
> runs under root. FTPUser (so that you can change/add files) is
> something like ftpDOMAIN and then there is something like psacln
> GROUP. I played around with switching groups and users to www-data and/
> or root - sometimes webserver worked sometimes ftp. Finally I went
> with very open unix permissions :/
>
> in my /var/www/domains/domain.tld/httpdocs/web/ (insides that lies
> my ./app and ./cake folder)
>
> chown -R ftpDOMAIN:psacln .
> chmod -R 755 .
>
> ./app/tmp required even 777 as  well as ./app/webroot/uploads (there
> go my MeioUpload uploads)
>
> I even wonder why I need execute flag to be able to use FTP (no
> joke) :/.

You need execute on directories so that you can read them (list contents).


> PLESK is a mess, I am weak on the linux side but PLESK is really
> bad :/.
> At domainfactory for instance (which costs more, yes) you can just set
> your Document Root per subdomain in a web interface, PLESK with all
> its useless stuff cannot do that.

I hate Plesk, also. My app will be on my client's server and he
doesn't know a lot about linux, either. I've done a few things for him
and Plesk has always been a huge pain. This will be the 1st Cake site
I do for him so I'm a bit concerned how this is going to go.

Thanks for the heads-up!

--~--~-~--~~~---~--~~
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: Removing an item from a set using Set::Remove.

2009-05-02 Thread brian

Wait--that's not right at all! I just looked more closely at what you
had there (it's still early here; 1st coffee). Set::remove() doesn't
work like that.  Say you wanted to remove all of the 'name' parts from
the input array. You'd do:

$events = Set::remove($events, '{n}.Event.name');

Giving you something like:

Array
(
   [0] => Array
   (
   [Event] => Array
   (
   [id] => 1
   )

   )

   [1] => Array
   (
   [Event] => Array
   (
   [id] => 2
)
   )

   [2] => Array
   (
   [Event] => Array
   (
   [id] => 3
)

   )

)

There's no 3rd param.

For your purposes, why don't you simply use the conditions to keep
certain rows from being selected at all? Either that, or re-think how
you're storing this data. Why do you need to remove this or other
rows? Perhaps there's a more elegant solution.

On Sat, May 2, 2009 at 11:39 AM, brian  wrote:
> I've never used it myself but that looks correct. Maybe you left it
> out of your example but make sure to assign the return from remove()
> back to your var.
>
> $events = Set::remove($events, '{n}.Event.id' , 2);
>
> On Fri, May 1, 2009 at 11:28 AM, Krist van Besien
>  wrote:
>>
>> Suppose I have the following set:
>>
>> Array
>> (
>>    [0] => Array
>>        (
>>            [Event] => Array
>>                (
>>                    [id] => 1
>>                    [name] => 1
>>                               )
>>
>>        )
>>
>>    [1] => Array
>>        (
>>            [Event] => Array
>>                (
>>                    [id] => 2
>>                    [name] => 2
>>                                  )
>>        )
>>
>>    [2] => Array
>>        (
>>            [Event] => Array
>>                (
>>                    [id] => 3
>>                    [name] => 3
>>                                  )
>>
>>        )
>>
>> )
>>
>> ( This set was generate using $this->Event->find('all'); )
>>
>> Now suppose I want to remove from this set the "Event" with id "2".
>> How would I do this? I don't want to remove it from the DB, I just
>> want to remove it from the set, so it doesn't get displayed in the
>> view.
>>
>> I thought I could do this with Set::Remove. However the documentation
>> here is quite sparse. And doing a search for "Set::Remove" on both the
>> cakephp sites and this groups didn't turn up a single hit...
>>
>> Anyway, I tried:
>> Set::remove($events, '{n}.Event.id' , 2);
>>
>> But that didn't do anything.
>>
>> Any pointers to help me in the right direction?
>>
>> Krist
>>
>> --
>> krist.vanbes...@gmail.com
>> kr...@vanbesien.org
>> Bremgarten b. Bern, Switzerland
>> --
>> A: It reverses the normal flow of conversation.
>> Q: What's wrong with top-posting?
>> A: Top-posting.
>> Q: What's the biggest scourge on plain text email discussions?
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
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: Removing an item from a set using Set::Remove.

2009-05-02 Thread brian

I've never used it myself but that looks correct. Maybe you left it
out of your example but make sure to assign the return from remove()
back to your var.

$events = Set::remove($events, '{n}.Event.id' , 2);

On Fri, May 1, 2009 at 11:28 AM, Krist van Besien
 wrote:
>
> Suppose I have the following set:
>
> Array
> (
>    [0] => Array
>        (
>            [Event] => Array
>                (
>                    [id] => 1
>                    [name] => 1
>                               )
>
>        )
>
>    [1] => Array
>        (
>            [Event] => Array
>                (
>                    [id] => 2
>                    [name] => 2
>                                  )
>        )
>
>    [2] => Array
>        (
>            [Event] => Array
>                (
>                    [id] => 3
>                    [name] => 3
>                                  )
>
>        )
>
> )
>
> ( This set was generate using $this->Event->find('all'); )
>
> Now suppose I want to remove from this set the "Event" with id "2".
> How would I do this? I don't want to remove it from the DB, I just
> want to remove it from the set, so it doesn't get displayed in the
> view.
>
> I thought I could do this with Set::Remove. However the documentation
> here is quite sparse. And doing a search for "Set::Remove" on both the
> cakephp sites and this groups didn't turn up a single hit...
>
> Anyway, I tried:
> Set::remove($events, '{n}.Event.id' , 2);
>
> But that didn't do anything.
>
> Any pointers to help me in the right direction?
>
> Krist
>
> --
> krist.vanbes...@gmail.com
> kr...@vanbesien.org
> Bremgarten b. Bern, Switzerland
> --
> A: It reverses the normal flow of conversation.
> Q: What's wrong with top-posting?
> A: Top-posting.
> Q: What's the biggest scourge on plain text email discussions?
>
> >
>

--~--~-~--~~~---~--~~
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: Security requireAuth on admin_add and admin_edit

2009-05-02 Thread Stinkbug

I might be mistaken, but I'm using the Security component not the Auth
component.  I believe it's two different things.  My problem is with
the Security component not blackholing the request when I try to
maliciously modify the form.

On May 1, 3:43 pm, "Benedikt R."  wrote:
> Did you try this?:
>
> $this->Auth->deny('*');
> $this->Auth->allow('index', 'view');
--~--~-~--~~~---~--~~
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: Buggy radio buttons using Form Helper?

2009-05-02 Thread majna

instead of label, try to set 'legend'=>'my fieldset legend'

On Apr 30, 5:42 pm, Martin Westin  wrote:
> Hi,
> I was playing with radio.-buttons today. (rarely used form element in
> my work)
>
> I think it is strage if this is a proper bug but radio buttons seem to
> be missing seem of the magic of other elements. Am  doing something
> staggeringly wrong here?
>
> echo $form->input('spelling_important', array(
>     'type'=>'radio',
>     'options'=>$required_variable,
>     'label'=>'this does nothing',
>     'empty'=>'this does nothing either'
> ));
>
> 1. The naming (first argument to input) makes a lot of difference.
> Calling the input "fieldname" I get no "label" for the whole group.
> Calling it "Modename.fieldname" and "Fieldname" will apear in front of
> the group in the resulting html.
>
> 2. The key "label" does nothing as far as I can see. Not even to
> replace the above auto-label.
>
> 3. The key "options" is required. If I leave out type=>radio the same
> tag will automagically pick up on the set variable of the same name as
> the fieldname given. E.g. setting $houses and calling the input houses
> will fill the select with options from the variable. Not so when  the
> type is set to radio.
>
> 4. The key "empty" does nothing even though it can be very useful
> since you can "uncheck" a radio button.
>
> The first thing I found was just a bit strange but the rest of it is
> really an inconsistency with the select input-type. Since they
> generally can serve the same logical purpose I expect them to work the
> same but they don't for some reason. Anyone know why?
>
> (I haven't checked these things with checkboxes yet)
> /Martin
--~--~-~--~~~---~--~~
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: 404 File not found when try to browse my first project

2009-05-02 Thread majna

did you set debug to 1?

On Apr 30, 11:14 pm, Nathan  wrote:
> Here is the background.
> - cakePHP 1.2 in Linux with Apache
> - everything was extract to /root/cakePHP
> - when I browsehttp://localhost/cakePHP, it shows the first page
> correctly (CSS, tmp writable, DB connected.)
>
> I establish my first project by creating files (in Dreamweaver) and
> store them in app/controllers/books_controller.php and app/views/books/
> index.ctp to just display simple text "THIS IS A TEST".
>
> I've got error when I browse tohttp://localhost/cakePHP/books/. The
> error is just normal HTML 404 file not found. I guess I miss some
> setup, didn't I?
--~--~-~--~~~---~--~~
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: Telling PHP to put "&" NOT "&"

2009-05-02 Thread Benedikt R.

Did you try any another function? For example:
http://de3.php.net/strtr



On 2 Mai, 09:29, rartavia  wrote:
> Hello, i'm trying to make a replace of a character in a string for an
> '&'. I tried several ways of replacement but (cake)PHP, when I do
> str_replace("_", "&") it returns "&"(HTML encoded). How can I get
> the replacement to be an ampersand itself?
>
> My code:
> /**
>  *      From client comes all special characters encoded
>  *      HTML encoded but instead of &#NUMBER; => _#NUMBER;
>  *      This Method restores to &#NUMBER;
> **/
> function restoreHTMLEcodedCharacters(&$pArray){
>         foreach($pArray as $key => $value){
>                 if(is_array($value)){
>                         restoreHTMLEcodedCharacters($value);
>                 }else{
>                         //debugger::log($value);
>                         $value = preg_replace("_#", "&#", $value);
>                         $value = str_replace("&", "&", $value);
>                 }
>         }
>
> }
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: what is LIBS inside cake\libs\inflector.php line 34

2009-05-02 Thread Bogdan I. Bursuc

LIBS is a defined variable that stores the path to the cakePHP libs
directory

you can test that in your code :


See what contains

On Sat, 2009-05-02 at 02:15 -0700, kani wrote:
> what is LIBS inside cake\libs\inflector.php line 34
> 
> if (!class_exists('Set')) {
>   require LIBS . 'set.php';
> }
> 
> infector can't open set.php
> > 


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



what is LIBS inside cake\libs\inflector.php line 34

2009-05-02 Thread kani

what is LIBS inside cake\libs\inflector.php line 34

if (!class_exists('Set')) {
require LIBS . 'set.php';
}

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



Will httpd.conf change affect other applications?

2009-05-02 Thread shinokada

My school server is running on Windows 2003, XAMPP.
I have other applications running such as Joomla and Moodle.

In the doc of CakePHP, I need to change httpd.conf as follows.

Options FollowSymLinks
AllowOverride All
# Order deny,allow
# Deny from all


At the moment I have as follows.


Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all



Will the change affect other applications?

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



Telling PHP to put "&" NOT "&"

2009-05-02 Thread rartavia

Hello, i'm trying to make a replace of a character in a string for an
'&'. I tried several ways of replacement but (cake)PHP, when I do
str_replace("_", "&") it returns "&"(HTML encoded). How can I get
the replacement to be an ampersand itself?

My code:
/**
 *  From client comes all special characters encoded
 *  HTML encoded but instead of &#NUMBER; => _#NUMBER;
 *  This Method restores to &#NUMBER;
**/
function restoreHTMLEcodedCharacters(&$pArray){
foreach($pArray as $key => $value){
if(is_array($value)){
restoreHTMLEcodedCharacters($value);
}else{
//debugger::log($value);
$value = preg_replace("_#", "&#", $value);
$value = str_replace("&", "&", $value);
}
}

}

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



Telling PHP to put "&" NOT "&"

2009-05-02 Thread rartavia

Hello, i'm trying to make a replace of a character in a string for an
'&'. I tried several ways of replacement but (cake)PHP, when I do
str_replace("_", "&") it returns "&"(HTML encoded). How can I get
the replacement to be an ampersand itself?

My code:
/**
 *  From client comens all special characters encoded
 *  HTML encoded but instead of &#NUMBER; => _#NUMBER;
 *  This Method restores to &#NUMBER;
**/
function restoreHTMLEcodedCharacters(&$pArray){
$amp = '&';
foreach($pArray as $key => $value){
if(is_array($value)){
restoreHTMLEcodedCharacters($value);
}else{
//debugger::log($value);
$value = preg_replace("_#", "&#", $value);
$value = str_replace("&", "&", $value);
}
}
return $pArray;
}

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