Re: Yet another Pagination Question (custom query but don't have a model to overwrite paginator)

2009-04-10 Thread nc

Anyone?

On Apr 9, 8:51 pm, nc  wrote:
> I have a Search controller that handles search-related tasks in my
> project and one of the requirements is that given a query (let's say
> $query) it should search for $query in table a (model A), table b
> (model B), table c (model C), and table d (model D). This Search
> controller  DOES NOT have a Search model associated with it (was not
> needed). It instead sets $uses = array('A','B','C','D'). It has to
> search using MySQL's fulltext search.
>
> Right now I'm trying to get it working with only 2 of the 4 models
> (because it'll be easy to expand out to 4 once I get this working)
>
> Currently what I have is this (all in search_controller.php):
>
> var $paginate = array('fields' => array('A.id', 'A.title',
> 'A.second'));
>
> And my pagination does this:
>
> $this->paginate('A', array("1" =>
> "1 AND WHERE MATCH(A.title,A.second) AGAINST('{$query}' IN BOOLEAN
> MODE ) UNION SELECT `B`.`id`, `B`.`name`, `B`.`type` FROM `b` AS `B`
> WHERE 1 AND MATCH(`B`.`name`) AGAINST('$query' IN BOOLEAN MODE )"
> ));
>
> Naturally I get an error because the query it uses to do count(*)
> fails. I would override the entire pagination thing if I had a model
> to override (I can't override A and B's pagination because I want it
> to work normally for other things).
>
> So is there anyway I can do this or do I have to resort to hacking
> stuff to get my functionality?
>
> 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: Pagination in Search Forms

2009-04-10 Thread Sourav

Thanks

I went thru your tutorial & it worked (in general). However there is a
problem :

In my search form there is a multiple selection list, which generates
an array in the POST data.

$this->data contains the following:

Array
(
[Job] => Array
(
[job_category_id] => Array
(
[0] => 1
[1] => 3
)

[title] => xyz
[location] => New York
)

)

So, when I use your code, I get this error:

Warning (2): urlencode() expects parameter 1 to be string, array given
[APP/app_controller.php, line 135]

How to overcome this problem?


On Apr 11, 12:39 am, Miles J  wrote:
> First off it should be $this->paginate['Job'] = and secondly you do
> not pass $this->data to the paginator.
>
> Are you trying to save the forum values into the url? If so take a
> look at my tutorial 
> here:http://www.milesj.me/blog/read/30/proxy-search-_-doing-a-search-while...
--~--~-~--~~~---~--~~
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: App::import('Model', 'MyModel');

2009-04-10 Thread Miles J

$uses is fine if you have a couple models, say 1-5.

Once you start getting more then that, use class registry instead.

$results = ClassRegistry::init('Model')->find();

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



custom drop-down fields

2009-04-10 Thread Mike

I've played with cake for awhile, but only recently had time to jump
into it.
I've setup a part management system that gives the manager the ability
to create profiles to capture specific part information. They can
customize ten text fields, giving them labels that show up on the part
form. They can make the fields Text, a input="text" element or Combo,
a select element. If the choose combo, they can add acceptable values
for the data entry people. The options are stored in partoptions with
the PartProfile_id, field (txt1...txt10) and finally the value, so you
could end up with records like this:
PartProfile_id  field   value
2   txt11/8
2   txt11/4
2   txt11/2

...creating

1/8
1/4
1/2


What I have done (pre cake) was: SELECT field, value WHERE
PartProfile_id=2, then something like:
foreach($items AS $item)
{
if($item['field']=='txt1')
{
echo "{$item['value']}\n";
}
}

What is the best way to handle the custom fields the cakephp way?

Models:
Parts (belongsto PartProfiles)
id
PartProfile_id
txt1
...
txt10

PartProfiles (HABTM Parts)
id
txt1label (varchar(50))
txt1type (Text|Combo)
...
txt10label (varchar(50))
txt10type (Text|Combo)

PartOptions
PartProfile_id
field (txt1...txt10)
value

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



App::import('Model', 'MyModel');

2009-04-10 Thread Dave Maharaj :: WidePixels.com

I have been reading that using App::import('Model', 'MyModel'); is better
than var $uses = array('ModelA', 'ModelB', 'ModelC'); but how do I go about
using it? Not sure how toimplementit into the controller.

Any ifo or site that explaines it would be great.

Thanks,
 
Dave 


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



Re: Strange folders in CakePHP 1.2.

2009-04-10 Thread Miles J

Well the js could by dynamically generated and/or could contain i18n
strings.
--~--~-~--~~~---~--~~
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: Real time output from shell

2009-04-10 Thread brian

$this->out(
sprintf(
'foo is %s',
$bar
)
);

On Fri, Apr 10, 2009 at 10:27 PM, mattalexx  wrote:
>
> Sometimes my shell method will run for a long time. I'd like to be
> able to output something as it runs instead of after it ends.
>
> Is this possible with 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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Real time output from shell

2009-04-10 Thread mattalexx

Sometimes my shell method will run for a long time. I'd like to be
able to output something as it runs instead of after it ends.

Is this possible with 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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Strange folders in CakePHP 1.2.

2009-04-10 Thread peterhf

I am referring to the folders which now appear in the "layouts" folder
in
CakePHP version 1.2. I don't that these folders appeared in 1.1.

I don't understand why one would put a JavaScript file in the "js"
folder
in the "layouts" folder when JavaScript files are supposed to be
placed in the "webroot/js" folder.

On Apr 10, 5:11 pm, Miles J  wrote:
> Well the rss/xml layouts would simply be the declarations at the top.
>
> 
> 
>   
> 
> 
> 
>
> As for the js, im not really sure.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HABTM issues with spaces

2009-04-10 Thread Jack Timmons
On Fri, Apr 10, 2009 at 7:21 PM, brian  wrote:

>
> Can you give an example where Cake is doing this?
>
> DB table names should never have spaces, btw.


Apparently I needed to remove to spaces and underscores from the HABTM
arrays.
Go figure. I blame Friday.

-- 
-Jack Timmons
http://www.trotlc.com
Twitter: @codeacula

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



cake and amfphp

2009-04-10 Thread mlecho

i recently installed the amfphp framework into cake. When i go the
amfbrowser, i get this:

Fatal error: Call to undefined function loadcontroller() in /
Applications/MAMP/htdocs/SITE/webroot/amfbrowser/config.inc.php on
line 75

any thoughts on where to start debugging this?
i took the framework from here: http://cakeforge.org/projects/cakeamfphp/
and followed the instructions...several times. My cakephp build is
connecting fine to the db, so i got that correct.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HABTM issues with spaces

2009-04-10 Thread brian

Can you give an example where Cake is doing this?

DB table names should never have spaces, btw.

On Fri, Apr 10, 2009 at 5:08 PM, Jack Timmons  wrote:
> First post, been lurking.
>
> Anyway, following naming conventions, all tables have underscores instead of
> spaces. phone_numbers, for example.
>
> Anyway, trying to set up a join table makes cakephp apparently look for
> phone numbers. I did a search over the group and couldn't find the answers,
> I fear I don't know the keywords I'm looking for. TIA
> --
> -Jack Timmons
> http://www.trotlc.com
> Twitter: @codeacula
>
> >
>

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



Re: Strange folders in CakePHP 1.2.

2009-04-10 Thread Miles J

Well the rss/xml layouts would simply be the declarations at the top.



  




As for the js, im not really sure.
--~--~-~--~~~---~--~~
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: DRY function SOLVED

2009-04-10 Thread Dave Maharaj :: WidePixels.com

Solved it

$thisModel = $modelName;
$modelName = $this->User->$model_name->find('list', array('fields' =>
'name', 'order' => 'name ASC'));
$this->set($thisModel, $modelName); 

Now I can edit all my forms with 1 function from different models :)



-Original Message-
From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] 
Sent: April-10-09 8:18 PM
To: cake-php@googlegroups.com
Subject: RE: DRY function


OK I managed to get the form working but now it looks like 1 final issue. 


The:

$skills = $this->User->$model_name->find('list', array('fields' => 'name',
'order' => 'name ASC'));
  $this->set(compact('skills'));


I need to make the $skills dynamic based on the $modelName, I tried using:

$modelName = $this->User->$model_name->find('list', array('fields' =>
'name', 'order' => 'name ASC'));

But nothing shows up because $this->set(compact('skills')); is empty, tried
using $this->set(compact('$modelName')); and nothing.

Any ideas?
   




function update($slug, $modelName)
  {
  $this->User->recursive = 1;
  $user = $this->User->findBySlug($slug);
  $id = $user['User']['id'];
  $model_name = Inflector::classify($modelName);
  $this->set('model_used', $model_name);
  if ($this->RequestHandler->isAjax()) {
  $this->set('user', $this->User->read(null, $id));
  if (!empty($this->data)) {
  if ($this->User->save($this->data)) {
  }
  }
  $skills = $this->User->$model_name->find('list',
array('fields' => 'name', 'order' => 'name ASC'));
  $this->set(compact('skills'));
  }
  if (empty($this->data)) {
  $this->data = $this->User->read(null, $id);
  }
  $user = $this->User->read(null, $id);
  }

-Original Message-
From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com]
Sent: April-10-09 5:26 PM
To: cake-php@googlegroups.com
Subject: RE: DRY function


OK I went with my original idea, changed the url and created 1 function to
update everything individually. The problem I am running into now is when
the form is displayed the options are no longer selected for each section.

function update($slug, $modelName)
  {
  $user = $this->User->findBySlug($slug);
  if ($this->RequestHandler->isAjax()) {
  
  
  $this->set('user', $this->User->read(null, $id));
  if (!empty($this->data)) {
  if ($this->User->save($this->data)) {
  //$this->view_$modelName($slug);
  }
  }
  $model_name = Inflector::classify($modelName);
  $options = $this->User->$model_name->find('list',
array('fields' => 'name', 'order' => 'name ASC'));
  $this->set(compact('options'));
  debug(array($slug, $modelName, $id, $model_name));
  }
  if (empty($this->data)) {
  $this->data = $this->User->read(null, $id);
  }
  }


When I debug I get the correct info. 

$modelName = educations
$model_name - Education
$slug = the name on the account
$id = the user id

Just not sure why no info is being displayed on the form. (I have options
selected in the original rendered view, when I click edit the form appears
with all the options to choose from but the ones that were selected are now
blank)

Ideas?

Thanks,

Dave
-Original Message-
From: Walther [mailto:waltherl...@gmail.com]
Sent: April-10-09 1:49 PM
To: CakePHP
Subject: Re: DRY function


Your idea is the what I believe is the correct solution.

Instead of calling $this->User->Skills->find... You'd call $this->User-
>$modelName->find

You'd need to do something with the view_skills and view_educations type
functions. Assuming they are similar you could do $this->view ($slug,
$modelName), otherwise perhaps move them into the model and call
$this->User->$modelName->view($slug);

Walther.

On Apr 10, 5:34 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I was hoping for some info on how to take 4 functions and make the 
> into 1.They all do the same thing except its a different model that they
use.
> They simply update a users options thru a select check box form, 
> that's the only thing being edited. Basically I took the edit view and 
> broke it up into
> 4 different Ajax edits and each has its own function but since they 
> are all the same except for the model call I was hoping someone could 
> give me some advice on creating 1 standard function.
>
> They all get called from the same page  users/profile, the link in the 
> view is users/profile/[user slug]/update_eductions or 
> users/profile/[user slug]/update_skills. I am still very new with cake 
> but was thinking if I modified the link url used an additional 
> variable based on the link action to get users/profile/[user 
> slug]/educations/update  I could then use

RE: DRY function

2009-04-10 Thread Dave Maharaj :: WidePixels.com

OK I managed to get the form working but now it looks like 1 final issue. 


The:

$skills = $this->User->$model_name->find('list', array('fields' => 'name',
'order' => 'name ASC'));
  $this->set(compact('skills'));


I need to make the $skills dynamic based on the $modelName, I tried using:

$modelName = $this->User->$model_name->find('list', array('fields' =>
'name', 'order' => 'name ASC'));

But nothing shows up because $this->set(compact('skills')); is empty, tried
using $this->set(compact('$modelName')); and nothing.

Any ideas?
   




function update($slug, $modelName)
  {
  $this->User->recursive = 1;
  $user = $this->User->findBySlug($slug);
  $id = $user['User']['id'];
  $model_name = Inflector::classify($modelName);
  $this->set('model_used', $model_name);
  if ($this->RequestHandler->isAjax()) {
  $this->set('user', $this->User->read(null, $id));
  if (!empty($this->data)) {
  if ($this->User->save($this->data)) {
  }
  }
  $skills = $this->User->$model_name->find('list',
array('fields' => 'name', 'order' => 'name ASC'));
  $this->set(compact('skills'));
  }
  if (empty($this->data)) {
  $this->data = $this->User->read(null, $id);
  }
  $user = $this->User->read(null, $id);
  }

-Original Message-
From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] 
Sent: April-10-09 5:26 PM
To: cake-php@googlegroups.com
Subject: RE: DRY function


OK I went with my original idea, changed the url and created 1 function to
update everything individually. The problem I am running into now is when
the form is displayed the options are no longer selected for each section.

function update($slug, $modelName)
  {
  $user = $this->User->findBySlug($slug);
  if ($this->RequestHandler->isAjax()) {
  
  
  $this->set('user', $this->User->read(null, $id));
  if (!empty($this->data)) {
  if ($this->User->save($this->data)) {
  //$this->view_$modelName($slug);
  }
  }
  $model_name = Inflector::classify($modelName);
  $options = $this->User->$model_name->find('list',
array('fields' => 'name', 'order' => 'name ASC'));
  $this->set(compact('options'));
  debug(array($slug, $modelName, $id, $model_name));
  }
  if (empty($this->data)) {
  $this->data = $this->User->read(null, $id);
  }
  }


When I debug I get the correct info. 

$modelName = educations
$model_name - Education
$slug = the name on the account
$id = the user id

Just not sure why no info is being displayed on the form. (I have options
selected in the original rendered view, when I click edit the form appears
with all the options to choose from but the ones that were selected are now
blank)

Ideas?

Thanks,

Dave
-Original Message-
From: Walther [mailto:waltherl...@gmail.com]
Sent: April-10-09 1:49 PM
To: CakePHP
Subject: Re: DRY function


Your idea is the what I believe is the correct solution.

Instead of calling $this->User->Skills->find... You'd call $this->User-
>$modelName->find

You'd need to do something with the view_skills and view_educations type
functions. Assuming they are similar you could do $this->view ($slug,
$modelName), otherwise perhaps move them into the model and call
$this->User->$modelName->view($slug);

Walther.

On Apr 10, 5:34 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I was hoping for some info on how to take 4 functions and make the 
> into 1.They all do the same thing except its a different model that they
use.
> They simply update a users options thru a select check box form, 
> that's the only thing being edited. Basically I took the edit view and 
> broke it up into
> 4 different Ajax edits and each has its own function but since they 
> are all the same except for the model call I was hoping someone could 
> give me some advice on creating 1 standard function.
>
> They all get called from the same page  users/profile, the link in the 
> view is users/profile/[user slug]/update_eductions or 
> users/profile/[user slug]/update_skills. I am still very new with cake 
> but was thinking if I modified the link url used an additional 
> variable based on the link action to get users/profile/[user 
> slug]/educations/update  I could then use 1 function called update and 
> set the "educations" in the url to define what model to update and 
> pass that into the function. the update function would be something 
> like function update ($slug, $modelName) then in the old function replace
the model name with $modelName ?
>
> function update_eductions($slug = null)
>       {
>           $this->User->recursive = 1;
>           if ($this->RequestHandler->isAjax()) {
>   

Re: Use another model function from an unrelated model

2009-04-10 Thread Hazem Mohamed

Another way to do this simply :
$model = new Model;
$model->find(); //or any other code

I believe that this may be not recommended but it worked with me

On Apr 8, 11:55 pm, lemp  wrote:
> I’m building a statistical application and I need to access a function
> that return reference values from a model that is unrelated with the
> model where I need this data.
>
> What is the best way to achieve this?

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



HABTM issues with spaces

2009-04-10 Thread Jack Timmons
First post, been lurking.

Anyway, following naming conventions, all tables have underscores instead of
spaces. phone_numbers, for example.

Anyway, trying to set up a join table makes cakephp apparently look for
phone numbers. I did a search over the group and couldn't find the answers,
I fear I don't know the keywords I'm looking for. TIA
-- 
-Jack Timmons
http://www.trotlc.com
Twitter: @codeacula

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



Validation of dynamic fields

2009-04-10 Thread GetIT

Hello,

I want to validate dynamic fields.

Normally validation is done by defining rules for a table field.
For example:

var $validate = array('Fieldname'  =>  some rules)

But I have defined my fields in this table:
Table: fields
id:int(6)
tab_id:int(4)
attribute:varchar(60)
type:varchar(10)
options:varchar(20)
selected:varchar(2)
position:smallint(4)
value:varchar(2)
checked:tinyint(1)
optional:tinyint(1)

And a few example inputs:
INSERT INTO `fields` VALUES (1, 1,'Name',NULL,NULL,NULL,1,NULL,NULL,
0);
INSERT INTO `fields` VALUES (12,3,'mit Aphasie','radio','ja, nein','2',
3,NULL,NULL,0);
INSERT INTO `fields` VALUES (42,3,'CheckboxTest','check','',NULL,4,'4',
1,1);

So I need to define a validation like that:

foreach (values_in_table as $value) {
  if ($value['optional'] == 0) {
var $validate = array(
  $value['attribute']  =>  array(
 'rule'=>  'alphaNumeric',
 'required'  =>  'true'
  )
);
  }
}

I hope its clear what i mean.

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



Strange folders in CakePHP 1.2.

2009-04-10 Thread peterhf

I have been unable to find a reference which explains the use  of the
"js", "rss" and "xml" directories in the "layouts" directory in 1.2.
Will someone point me to such a reference?

Thanks for your help.

Peter -
--~--~-~--~~~---~--~~
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: Wap Applications

2009-04-10 Thread Alfredo Quiroga-Villamil

Alejandro:

This might come in handy:

http://api.cakephp.org/class/request-handler-component#method-RequestHandlerComponentisMobile

Regards,

Alfredo


On Fri, Apr 10, 2009 at 1:44 PM,   wrote:
>
> Anyone with experience on WAP aplications based on Cakephp framework? any
> hints,tips,docs or recomendations...
>
> 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: DRY function

2009-04-10 Thread Dave Maharaj :: WidePixels.com

OK I went with my original idea, changed the url and created 1 function to
update everything individually. The problem I am running into now is when
the form is displayed the options are no longer selected for each section.

function update($slug, $modelName)
  {
  $user = $this->User->findBySlug($slug);
  if ($this->RequestHandler->isAjax()) {
  
  
  $this->set('user', $this->User->read(null, $id));
  if (!empty($this->data)) {
  if ($this->User->save($this->data)) {
  //$this->view_$modelName($slug);
  }
  }
  $model_name = Inflector::classify($modelName);
  $options = $this->User->$model_name->find('list',
array('fields' => 'name', 'order' => 'name ASC'));
  $this->set(compact('options'));
  debug(array($slug, $modelName, $id, $model_name));
  }
  if (empty($this->data)) {
  $this->data = $this->User->read(null, $id);
  }
  }


When I debug I get the correct info. 

$modelName = educations 
$model_name - Education
$slug = the name on the account
$id = the user id

Just not sure why no info is being displayed on the form. (I have options
selected in the original rendered view, when I click edit the form appears
with all the options to choose from but the ones that were selected are now
blank)

Ideas?

Thanks,

Dave
-Original Message-
From: Walther [mailto:waltherl...@gmail.com] 
Sent: April-10-09 1:49 PM
To: CakePHP
Subject: Re: DRY function


Your idea is the what I believe is the correct solution.

Instead of calling $this->User->Skills->find... You'd call $this->User-
>$modelName->find

You'd need to do something with the view_skills and view_educations type
functions. Assuming they are similar you could do $this->view ($slug,
$modelName), otherwise perhaps move them into the model and call
$this->User->$modelName->view($slug);

Walther.

On Apr 10, 5:34 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I was hoping for some info on how to take 4 functions and make the 
> into 1.They all do the same thing except its a different model that they
use.
> They simply update a users options thru a select check box form, 
> that's the only thing being edited. Basically I took the edit view and 
> broke it up into
> 4 different Ajax edits and each has its own function but since they 
> are all the same except for the model call I was hoping someone could 
> give me some advice on creating 1 standard function.
>
> They all get called from the same page  users/profile, the link in the 
> view is users/profile/[user slug]/update_eductions or 
> users/profile/[user slug]/update_skills. I am still very new with cake 
> but was thinking if I modified the link url used an additional 
> variable based on the link action to get users/profile/[user 
> slug]/educations/update  I could then use 1 function called update and 
> set the "educations" in the url to define what model to update and 
> pass that into the function. the update function would be something 
> like function update ($slug, $modelName) then in the old function replace
the model name with $modelName ?
>
> function update_eductions($slug = null)
>       {
>           $this->User->recursive = 1;
>           if ($this->RequestHandler->isAjax()) {
>      $user = $this->User->findBySlug($slug);
>           $id = $user['User']['id'];
>               $this->set('user', $this->User->read(null, $id));
>               if (!empty($this->data)) {
>                   if ($this->User->save($this->data)) {
>                       $this->view_educations($slug);
>                   }
>               }
>               $educations= $this->User->Educations->find('list',
> array('fields' => 'name', 'order' => 'name ASC'));
>               $this->set(compact('educations'));
>           }
>           if (empty($this->data)) {
>               $this->data = $this->User->read(null, $id);
>           }
>       }
>
> or to update skills
>
> function update_skills($slug = null)
>       {
>           $this->User->recursive = 1;
>           if ($this->RequestHandler->isAjax()) {
>      $user = $this->User->findBySlug($slug);
>           $id = $user['User']['id'];
>               $this->set('user', $this->User->read(null, $id));
>               if (!empty($this->data)) {
>                   if ($this->User->save($this->data)) {
>                       $this->view_skills($slug);
>                   }
>               }
>               $skills= $this->User->Skills->find('list', 
> array('fields' => 'name', 'order' => 'name ASC'));
>               $this->set(compact('skills'));
>           }
>           if (empty($this->data)) {
>               $this->data = $this->User->read(null, $id);
>           }
>       }
>
> Ideas? Suggestions?
>
> Thanks,
>
> Dave


--~--~-~--~~~---~--~~
You received this message because you are su

Re: does cake schema handle foreign keys?

2009-04-10 Thread Miles J

Technically mine doesnt use foreign keys either. CakePHP has a built
in system where it will match a key in another table using
associations.

So if I have a column named country_id in my users table, and set an
association with users table to the countries table, cake will
automatically determine that the country_id is a foreign key to the
countries table id column.

All you need to do is set the primary and index keys on your columns.
--~--~-~--~~~---~--~~
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: Pagination in Search Forms

2009-04-10 Thread Miles J

First off it should be $this->paginate['Job'] = and secondly you do
not pass $this->data to the paginator.

Are you trying to save the forum values into the url? If so take a
look at my tutorial here:
http://www.milesj.me/blog/read/30/proxy-search-_-doing-a-search-while-using-named-parameters
--~--~-~--~~~---~--~~
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: pass variable from beforeFilter in app_controller to child controller

2009-04-10 Thread Miles J

As a personal preference, I would store it in the session. This way it
can be accessed outside of the controller as well.
--~--~-~--~~~---~--~~
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: Anyone has used a cakePHP paginator class that can paginate for non database records

2009-04-10 Thread Miles J

Were is your data coming from if its not from a database? Flatfiles?
Static arrays? It just seems odd.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



ACL denied access to logout()

2009-04-10 Thread djXternal

I have finally managed to get my ACL working, realized I was having
issues using UUID's, now the super user can access everything fine
when logged in and logout.  But users with privledges lesser than that
user, who do now have access to the 'Users' controller cannot logout.
When I go to /Users/logout I get a 'You are not authorized to access
that location.' error.  I tried adding permissions to that lesser user
to ba able to access only the logout action of the Users controller by
doing 'cake acl grant Users Users logout', Users being the low-level
group, and I still cannot access it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: ACL - How to handle multiple nested levels of accounts

2009-04-10 Thread zonium

Thank you jmcneese for showing me an alternative to the cake's ACL.
Your articles help me understand weaknesses of ACL when used to
safeguard records. It's was interesting to see immediate attentions/
reactions from the core developers on those articles as well.

One problem (in my case) with the solution you presented is that
groups are powers of two.This limits the number of groups to the
number of bits in an integer. I have unlimited numbers of "groups".

Besides, in my case, "groups" are not in one table where I can use
parent_id linking entries for tree behavior to work.

I am still looking for advice. Would like to hear from any one who has
dealt with a similar situation as mine.


On Apr 7, 7:09 am, jmcneese  wrote:
> would this help?
>
> http://jmcneese.wordpress.com/2009/04/05/row-level-model-access-contr...
>

--~--~-~--~~~---~--~~
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: Apache can't find my cake directory!

2009-04-10 Thread Andrew Care

Solved my problem. When mod-rewrite is enabled, app/webroot/index.php
defines constants, otherwise the top index.php defines constants.

I was defining constants in the top index.php when I should have been
defining the constants in app/webroot/index.php (since I'm using
mod_rewrite).

--~--~-~--~~~---~--~~
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: simple authentication with roles

2009-04-10 Thread qwanta

I also wanted to mention that if you try this out with a controller
called TestsController, the authentication doesn't seem to work -
everyone (even not logged on) is given access to all functions. I
found this out the hard way! That's why I renamed it to
TrestsController.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



simple authentication with roles

2009-04-10 Thread qwanta

After struggling a bit with Auth, especially in terms of doing "role"
or "group" authentication, I thought I would post what I found out.

Basically each user belongs to a group ("admin", "calibration",
etc...) and I wanted to set the authorized controller functions for
each group in each individual controller.

I'll assume you have successfully built a user table & model with
username/password at this point. ( see 
http://book.cakephp.org/view/172/Authentication
).

Next add the beforeFilter function to the app controller:


Auth->loginRedirect = array('controller'=>'pages',
'action'=>'display', 'home');
$this->Auth->logoutRedirect = array('controller'=>'pages',
'action'=>'display', 'home');
$this->Auth->allow('display');
$this->Auth->authorize = 'controller';

// store info for access in other controllers
$auth_id =  $this->Auth->user('id');
$this->set('logged_in', $auth_id);
if ($auth_id) {
$this->auth_role = $this->User->getRole( $auth_id );

// do this so we can use these in default.ctp
$this->set('auth_username', 
$this->Auth->user('username'));
$this->set('auth_role', $this->auth_role );
}
}
}
?>

What I have done is add a field called "role" to the user table. In my
user model, I defined a function called getRole to retrieve the role
based on a user id. Again getRole does not exist by default, you have
to make it. I declared $auth_role as a controller property so that it
can be accessed in all child controllers through $this->auth_role. We
will need this for when we add the logic to control access based on
the user role.

the set statements are used so that I can display the current user and
his role in the default.ctp layout, at the top of the page. At this
point we have only given access to non-logged on users to "display"
pages (such as home.ctp), all controller functinos will be blocked
off. Logged on users will have access to everything.

For more control over which roles have access to what, do something
like this in each controller:


auth_role == "admin" ) {
if ( $this->action == "f1" ) { return true; }
if ( $this->action == "f2" ) { return true; }
}
if ($this->auth_role == "calibration" ) {
if ( $this->action == "f1" ) { return false; }
if ( $this->action == "f2" ) { return true; }
}
return false;
}

function f1() {


}

function f2() {


}

}
?>


Basically, add an entry for each controller method under each role in
the isAuthorized method. Return true for access, false for no access.
$this->action maps out to the method that's being called in the
controller.

In the example above, any users in the admin role/group will have
access to f1 & f2, whereas the calibration role/group will only have
access to f2.
--~--~-~--~~~---~--~~
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: Apache can't find my cake directory!

2009-04-10 Thread Andrew Care

Ah! Could someone confirm this for me: the top index.php is only used
if mod_rewrite is disabled?

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



Wap Applications

2009-04-10 Thread alejandro

Anyone with experience on WAP aplications based on Cakephp framework? any
hints,tips,docs or recomendations...

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



Apache can't find my cake directory!

2009-04-10 Thread Andrew Care

Windows XP SP3
Apache 2.2 (mod_rewrite is enabled)
PHP 5.2
CakePHP 1.2.2

I've moved the cake directory outside of the application folder, my
htdocs structure is as follows:

/htdocs
/production
/cakeApp
/app
index.php
.htaccess
/staging
...
/development
...
/frameworks
/cake_1.2.2
/cake
/vendors

where ... represents the same structure as production.

I have the main DocumentRoot pointing to the production directory,
then I have two virtual hosts (based on the port used: 8008 for
staging; 8080 for development) that point to the staging and
development directories.

Everything seems to be working fine except when I try and define
CAKE_CORE_DIRECTORY in the top index.php file. My configuration looks
like this:

...
// Custom variables used to define which version of the CakePHP
framework to reference
// trying to define .../htdocs/frameworks/
define('FRAMEWORKS_ROOT', $_SERVER['DOCUMENT_ROOT'] . DS . '..' . DS .
'frameworks' . DS);
define('CAKE_VERSION', '1.2.2');

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
// trying to define .../htdocs/frameworks/cake_1.2.2
define('CAKE_CORE_INCLUDE_PATH', FRAMEWORKS_ROOT . 'cake_' .
CAKE_VERSION);
}
...

However it seems that when processing gets to the /app/webroot/
index.php file, the CAKE_CORE_INCLUDE_PATH is undefined (assigns it
the default ROOT as per the if statement in the file).

I can get it everything working if I change the /app/webroot/index.php
file like this:

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('FRAMEWORKS_ROOT', $_SERVER['DOCUMENT_ROOT'] . DS . '..' .
DS . 'frameworks' . DS);
define('CAKE_VERSION', '1.2.2');
define('CAKE_CORE_INCLUDE_PATH', FRAMEWORKS_ROOT . 'cake_' .
CAKE_VERSION);
}

but that seems messy and redundant as it should be doing all this in
the top index.php file.

Any help on a more elegant solution would be greatly 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: Anyone has used a cakePHP paginator class that can paginate for non database records

2009-04-10 Thread dr. Hannibal Lecter

Haven't seen anything like that yet..

Why not make one yourself and put it in the Bakery? :)

On Apr 10, 5:26 pm, Anibigi  wrote:
> Hi,
>
> I'm a newbie to cakePHP.
> I want a paginator class that would work well with both database and
> non database record set.
>
> I found a couple of classes for paginating records pulled from
> database but none so far for any temporaray arrays of records.
>
> Can anyone help with this please
--~--~-~--~~~---~--~~
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 components

2009-04-10 Thread brian

Remove the echo. flash() does that itself.

On Fri, Apr 10, 2009 at 11:01 AM, gimmebucks  wrote:
>
> I'm using auth component and it's working like charm.
> on layout file(default.ctp), i use:
>
> echo $session->flash('auth');
>
> and the result is:
>
> You are not authorized to access that location.
> 1
>
> How to get rid of '1' character?
> Please 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: What am I missing ($conditions in a find)?

2009-04-10 Thread czg

huh.  The 1.2 manual was wrong (very possible I missed the
announcement of a change in format).  Thanks all!


from 1.2 manual:

array
("Author.name" => "Bob", "or" => array
(
"Post.title" => "LIKE %magic%",
"Post.created" => "> " . date('Y-m-d', strtotime("-2 weeks")
)
)


On Apr 10, 8:51 am, brian  wrote:
> Put the operators on the left side:
>
> 'Node.lft >=' => $node["Node"]["lft"],
>
> On Thu, Apr 9, 2009 at 4:22 PM, cartosys  wrote:
>
> > my conditions:
>
> >                $sqlConditions = array(
> >                                'Node.lft' => ">= ".$node["Node"]["lft"],
> >                                'Node.rght' => "<= ".$node["Node"]["rght"]);
>
> >                $nodes = $this->Node->generateTreeList($sqlConditions);
>
> > and this is the resulting query (from debug level 2):
>
> > SELECT `Node`.`id`, `Node`.`title`, `Node`.`lft`, `Node`.`rght` FROM
> > `nodes` AS `Node` WHERE `Node`.`lft` = '>= 4' AND `Node`.`rght` = '<=
> > 15' ORDER BY `Node`.`lft` asc
>
> > why aren't the comparison operators <= and >= not replacing the =
> > operator?
>
> > -BP
--~--~-~--~~~---~--~~
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: DRY function

2009-04-10 Thread Walther

Your idea is the what I believe is the correct solution.

Instead of calling $this->User->Skills->find... You'd call $this->User-
>$modelName->find

You'd need to do something with the view_skills and view_educations
type functions. Assuming they are similar you could do $this->view
($slug, $modelName), otherwise perhaps move them into the model and
call $this->User->$modelName->view($slug);

Walther.

On Apr 10, 5:34 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I was hoping for some info on how to take 4 functions and make the into
> 1.They all do the same thing except its a different model that they use.
> They simply update a users options thru a select check box form, that's the
> only thing being edited. Basically I took the edit view and broke it up into
> 4 different Ajax edits and each has its own function but since they are all
> the same except for the model call I was hoping someone could give me some
> advice on creating 1 standard function.
>
> They all get called from the same page  users/profile, the link in the view
> is users/profile/[user slug]/update_eductions or users/profile/[user
> slug]/update_skills. I am still very new with cake but was thinking if I
> modified the link url used an additional variable based on the link action
> to get users/profile/[user slug]/educations/update  I could then use 1
> function called update and set the "educations" in the url to define what
> model to update and pass that into the function. the update function would
> be something like function update ($slug, $modelName) then in the old
> function replace the model name with $modelName ?
>
> function update_eductions($slug = null)
>       {
>           $this->User->recursive = 1;
>           if ($this->RequestHandler->isAjax()) {
>      $user = $this->User->findBySlug($slug);
>           $id = $user['User']['id'];
>               $this->set('user', $this->User->read(null, $id));
>               if (!empty($this->data)) {
>                   if ($this->User->save($this->data)) {
>                       $this->view_educations($slug);
>                   }
>               }
>               $educations= $this->User->Educations->find('list',
> array('fields' => 'name', 'order' => 'name ASC'));
>               $this->set(compact('educations'));
>           }
>           if (empty($this->data)) {
>               $this->data = $this->User->read(null, $id);
>           }
>       }
>
> or to update skills
>
> function update_skills($slug = null)
>       {
>           $this->User->recursive = 1;
>           if ($this->RequestHandler->isAjax()) {
>      $user = $this->User->findBySlug($slug);
>           $id = $user['User']['id'];
>               $this->set('user', $this->User->read(null, $id));
>               if (!empty($this->data)) {
>                   if ($this->User->save($this->data)) {
>                       $this->view_skills($slug);
>                   }
>               }
>               $skills= $this->User->Skills->find('list', array('fields' =>
> 'name', 'order' => 'name ASC'));
>               $this->set(compact('skills'));
>           }
>           if (empty($this->data)) {
>               $this->data = $this->User->read(null, $id);
>           }
>       }
>
> Ideas? Suggestions?
>
> Thanks,
>
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



DRY function

2009-04-10 Thread Dave Maharaj :: WidePixels.com
I was hoping for some info on how to take 4 functions and make the into
1.They all do the same thing except its a different model that they use.
They simply update a users options thru a select check box form, that's the
only thing being edited. Basically I took the edit view and broke it up into
4 different Ajax edits and each has its own function but since they are all
the same except for the model call I was hoping someone could give me some
advice on creating 1 standard function.
 
They all get called from the same page  users/profile, the link in the view
is users/profile/[user slug]/update_eductions or users/profile/[user
slug]/update_skills. I am still very new with cake but was thinking if I
modified the link url used an additional variable based on the link action
to get users/profile/[user slug]/educations/update  I could then use 1
function called update and set the "educations" in the url to define what
model to update and pass that into the function. the update function would
be something like function update ($slug, $modelName) then in the old
function replace the model name with $modelName ?
 
function update_eductions($slug = null)
  {
  $this->User->recursive = 1;
  if ($this->RequestHandler->isAjax()) {
 $user = $this->User->findBySlug($slug);
  $id = $user['User']['id'];
  $this->set('user', $this->User->read(null, $id));
  if (!empty($this->data)) {
  if ($this->User->save($this->data)) {
  $this->view_educations($slug);
  }
  }
  $educations= $this->User->Educations->find('list',
array('fields' => 'name', 'order' => 'name ASC'));
  $this->set(compact('educations'));
  }
  if (empty($this->data)) {
  $this->data = $this->User->read(null, $id);
  }
  }
 
or to update skills
 
function update_skills($slug = null)
  {
  $this->User->recursive = 1;
  if ($this->RequestHandler->isAjax()) {
 $user = $this->User->findBySlug($slug);
  $id = $user['User']['id'];
  $this->set('user', $this->User->read(null, $id));
  if (!empty($this->data)) {
  if ($this->User->save($this->data)) {
  $this->view_skills($slug);
  }
  }
  $skills= $this->User->Skills->find('list', array('fields' =>
'name', 'order' => 'name ASC'));
  $this->set(compact('skills'));
  }
  if (empty($this->data)) {
  $this->data = $this->User->read(null, $id);
  }
  }
 
Ideas? Suggestions?
 
Thanks,
 
Dave

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



Anyone has used a cakePHP paginator class that can paginate for non database records

2009-04-10 Thread Anibigi

Hi,

I'm a newbie to cakePHP.
I want a paginator class that would work well with both database and
non database record set.

I found a couple of classes for paginating records pulled from
database but none so far for any temporaray arrays of records.

Can anyone help with this please

--~--~-~--~~~---~--~~
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: pass variable from beforeFilter in app_controller to child controller

2009-04-10 Thread sbeam

On Apr 10, 11:16 am, qwanta  wrote:
> I am setting a variable value that in app_controller beforeFilter, and
> I would like to access it in all child controllers beforeFilter
> function.
>
> class AppController extends Controller {
>   var $components = array('Auth');
>   var $uses = array('User');
>
>   $auth_id =  $this->Auth->user('id');
>   if ( $auth_id ) {
>     $auth_role = $this->User->getRole($auth_id);
>   }
>
> }
>
> class XController extends AppController {
>   (...)
>   function beforeFIlter() {
>     parent::beforeFilter();
>     if ($auth_role == "calibrator") {
>        (...)
>     }
>   }
>
> }
>
> When I call a method in XController. I get an $auth_role not defined
> error. Is there a way to pass the variable value to the child
> controller?
> Thanks

one way could be ~
set your $auth_role as a property of AppController:

class AppController {
 public $auth_role;

function beforeFIlter() {
 $this->auth_role = whatever();
}
}


class XController extends AppController {
 function anyFunction()
if ($this->auth_role = blah) { }
 }
}


--~--~-~--~~~---~--~~
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: pass variable from beforeFilter in app_controller to child controller

2009-04-10 Thread qwanta

OK, nevermind. Sure enough the second I post, I come up with a
solution (after struggling all morning on the problem).

class AppController extends Controller {
 var $auth_role;
}

then refer to it as $this->auth_role in all controllers.

On Apr 10, 11:16 am, qwanta  wrote:
> I am setting a variable value that in app_controller beforeFilter, and
> I would like to access it in all child controllers beforeFilter
> function.
>
> class AppController extends Controller {
>   var $components = array('Auth');
>   var $uses = array('User');
>
>   $auth_id =  $this->Auth->user('id');
>   if ( $auth_id ) {
>     $auth_role = $this->User->getRole($auth_id);
>   }
>
> }
>
> class XController extends AppController {
>   (...)
>   function beforeFIlter() {
>     parent::beforeFilter();
>     if ($auth_role == "calibrator") {
>        (...)
>     }
>   }
>
> }
>
> When I call a method in XController. I get an $auth_role not defined
> error. Is there a way to pass the variable value to the child
> controller?
> 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
-~--~~~~--~~--~--~---



does cake schema handle foreign keys?

2009-04-10 Thread sbeam

I am using
$ cake generate schema

but see no mention of my foreign keys, using mysql/InnoDB. Am I doing
something wrong?

regads~
Sam

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



pass variable from beforeFilter in app_controller to child controller

2009-04-10 Thread qwanta

I am setting a variable value that in app_controller beforeFilter, and
I would like to access it in all child controllers beforeFilter
function.

class AppController extends Controller {
  var $components = array('Auth');
  var $uses = array('User');

  $auth_id =  $this->Auth->user('id');
  if ( $auth_id ) {
$auth_role = $this->User->getRole($auth_id);
  }
}

class XController extends AppController {
  (...)
  function beforeFIlter() {
parent::beforeFilter();
if ($auth_role == "calibrator") {
   (...)
}
  }
}

When I call a method in XController. I get an $auth_role not defined
error. Is there a way to pass the variable value to the child
controller?
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
-~--~~~~--~~--~--~---



Auth components

2009-04-10 Thread gimmebucks

I'm using auth component and it's working like charm.
on layout file(default.ctp), i use:

echo $session->flash('auth');

and the result is:

You are not authorized to access that location.
1

How to get rid of '1' character?
Please 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: change "contain" settings for $paginate on the fly

2009-04-10 Thread park

Thanks very much!

On Apr 10, 9:22 pm, brian  wrote:
> You can change it within the action by doing:
>
> $this->paginate['Model']['contain'] = array(...);
>
>
>
> On Fri, Apr 10, 2009 at 6:10 AM, park  wrote:
>
> > Hi,
>
> > $this->Model->contain() doesn't seem to affect $paginatequery result.
>
> > The following approach is mentioned in the official documentation.
> >        var $paginate= array(
> >                'Model'=> array(
> >                        'contain' => array(
> > //Containsettings goes here
> >                        )
> >                )
> >        );
>
> > But is there a way to change this settings on the fly?
>
> > 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
-~--~~~~--~~--~--~---



Looking for a HABTM solution

2009-04-10 Thread jsundquist

What I am looking to do is kind of complex and I'm not sure the best
way to go about doing it. I have two tables that get joined twice two
each other. Going the same way each time.

table_1 --> table_1_table_2 --> table_2

and

table_1 --> table_1_table_3 --> table 2

They both techically have the same information however the second join
table actually has a few extra columns in it that are needed but use
the primary keys from table 1 and table 2. Is this possible using the
cake framework? If I was to just write the statement myself I know I
could do it but don't know how CakePHP handles things like that.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



CakeFest III: Rmapage in Berlin

2009-04-10 Thread rpeterson

Hey all,

I am still on the fence on weather I can make CakeFest 3 or not,
however, in the light that I may be able to go I am interested in
finding anyone interested in splitting a hotel room and what not. Let
me know.

If your interested, contact me via http://www.serenitysoft.com/
contact details. Thanks.

~rpeterson

--~--~-~--~~~---~--~~
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 helper question?

2009-04-10 Thread rgreenphotodesign

Do you have a div with ID playlist in the view?

On Apr 7, 3:29 am, "john.die...@gmail.com" 
wrote:
> im having an error in my view like "PeriodicalExecuter is not
> defined"... i dont have an idea what causing this.
> here's my code:
>
> controller:
> public $helpers = array('html', 'javascript', 'ajax');
>
> view:
> echo $ajax->remoteTimer(array('url' => array('controller' =>
> 'schedules', 'action' => 'index'),
>                                                                'update' => 
> 'playlist',
>                                                                'complete' => 
> 'alert
> ("request complete")',
>                                                                'frequency' => 
> 2));
>
> can you help me with this guys? probably im missing something here...
>
> thank you.
--~--~-~--~~~---~--~~
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: Reverse "LIKE" sql statement

2009-04-10 Thread Mark (Germany)

if you want to find an entry whith "blue":
obviously:
"WHERE fieldName LIKE '%blue%' "

OR - if you dont want anything after the word "blue":
"WHERE fieldName LIKE '%blue' "



On 9 Apr., 23:07, Miles J  wrote:
> NOT LIKE '%term%'
>
> Is that what you mean?
>
> http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
--~--~-~--~~~---~--~~
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: Offline version of the CakePHP manual.

2009-04-10 Thread dyml

Thanks alot, This is great!

On Apr 8, 12:26 pm, psykro  wrote:
> Thanks Dardo
>
> I've had a few people ask me for it. So I have posted in online
>
> http://rapidshare.com/files/218826372/manual-builder.zip
>
> Dardo, as the creator of this script, if ever you want me to pull it
> off, let me know and I will do so.
> You created it, I'm just sharing it with your permission. :)
>
> And again to reiterate Dardo's earlier statement,
>
> "I think that publishing its output is a "derivative work" and its
> forbidden by
> the cookbook license. So you will have to ask permission before doing
> anything with cookbook's content. "
>
> I'm just using this for personal use.
>
> Cheers
>
> On Apr 7, 1:42 pm, Dardo Sordi Bogado  wrote:
>
> > > George if Dardo doesnt get back to you let me know and I can forward
> > > the script to you, I just hope he's ok with me forwarding his work to
> > > others.
>
> > I've sent the code to Mike in a private email, but I'm ok with
> > whatever you do to that code.
>
> > Regards,
> > - Dardo.
--~--~-~--~~~---~--~~
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 am I missing ($conditions in a find)?

2009-04-10 Thread brian

Put the operators on the left side:

'Node.lft >=' => $node["Node"]["lft"],

On Thu, Apr 9, 2009 at 4:22 PM, cartosys  wrote:
>
> my conditions:
>
>                $sqlConditions = array(
>                                'Node.lft' => ">= ".$node["Node"]["lft"],
>                                'Node.rght' => "<= ".$node["Node"]["rght"]);
>
>                $nodes = $this->Node->generateTreeList($sqlConditions);
>
> and this is the resulting query (from debug level 2):
>
> SELECT `Node`.`id`, `Node`.`title`, `Node`.`lft`, `Node`.`rght` FROM
> `nodes` AS `Node` WHERE `Node`.`lft` = '>= 4' AND `Node`.`rght` = '<=
> 15' ORDER BY `Node`.`lft` asc
>
>
> why aren't the comparison operators <= and >= not replacing the =
> operator?
>
> -BP
>
>
> >
>

--~--~-~--~~~---~--~~
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: Little problem with "edit" forms

2009-04-10 Thread brian

Do you have a route for this action? I'm wondering if it's related to
something I've seen.

Also, is there any chance that $utente_id is being set somewhere as,
eg "4/4"? Maybe put
echo $utente_id
in your view to see if it's being set like that.

On Fri, Apr 10, 2009 at 7:53 AM, Ernesto  wrote:
>
> Hello.
>
> i have a view, located @ CakeROOT/applicazione/utenti/modifica/
> [utente_id]
>
> - "modifica" it's the italian equivalent of "edit"
> - "utente" it's the italian equivalent of "user"
>
> I'm working with a legacy DB. I can't fully respect Cake's
> conventions.
>
> This view contains a form, coded this way:
>
> echo $form->create("utente", array("url" => array("controller" =>
> "utenti", "action" => "modifica/$utente_id")));
>
> //form elements
>
> echo $form->end("Conferma");
>
> everything works fine but, if i voluntarily submit unvalid data for
> two times or more in a row i get this in browser's adress bar
>
> CakeROOT/applicazione/utenti/modifica/[utente_id]/[utente_id]
>
> ** note that the parameter utente_id is repeated two times. **
>
> that's not a problem in this view cause it has just one input
> parameter the second is ignored... but... why is that happening?
> >
>

--~--~-~--~~~---~--~~
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: Model config for table with no ID

2009-04-10 Thread brian

Can you add a PK to the table? Create a new table with the same
columns plus an auto_increment/serial/whatever and insert the rows
from the 1st table. Drop the 1st one, then rename the 2nd.

On Thu, Apr 9, 2009 at 10:45 PM, mattalexx  wrote:
>
> Hi
>
> I am trying to access a database table that was built without a
> primary key (I know). How would I go about this in CakePHP. Is it
> possible or do I have to just use Model::query all the time?
> >
>

--~--~-~--~~~---~--~~
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: change "contain" settings for $paginate on the fly

2009-04-10 Thread brian

You can change it within the action by doing:

$this->paginate['Model']['contain'] = array(...);


On Fri, Apr 10, 2009 at 6:10 AM, park  wrote:
>
> Hi,
>
> $this->Model->contain() doesn't seem to affect $paginate query result.
>
> The following approach is mentioned in the official documentation.
>        var $paginate = array(
>                'Model'=> array(
>                        'contain' => array(
> // Contain settings goes here
>                        )
>                )
>        );
>
> But is there a way to change this settings on the fly?
>
> 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: Pagination with non-fixed page size (how can I customize paginateCount?)

2009-04-10 Thread brian

If you want to use pagination, you'll have to make an initial query to
find that month's sermons, then change the controller's $paginate
array in your action like so:

$this->paginate[KEY]['order'] = $num_sermons;

Leave out the KEY part if you just have one "set" of paginate values.

BUT, you're far better off just using find() instead. ie. no
pagination. You could get the same effect by creating a series of
links for each month, plus previous/next links. This would be simplest
if you pass the number of the month (1-12). You could then set up a
route with:

Router::connect(
'/sermons/:month',
array(
'controller' => 'sermons',
'action' => 'index'
),
array(
'month' => '0[1-9]|1[012]',
'pass' => 'month'
)
);

function index($month = null)
{
if (is_null($month))
{
/* get number for present month
 */
$month = date('n');
}
// ...
}

BIG NOTE: the above assumes Julian dates. I don't know how to do the
same for Hijri.

Of course, you can also pass the name of the month, which might look better.


On Thu, Apr 9, 2009 at 5:53 PM, ahmedhelmy007  wrote:
>
> Hi all.
>
> A brief description of my problem:
>
> I need to make pagination with non-fixed page size, every page must
> contain items from certain month only. I wrote the query correctly ,
> but the CAKE cannot count pages correctly because it calculates the
> number of pages by dividing the total count of items by the page size -
> the $limit variable- .
>
> how can i make a custom paginateCount that returns the right number of
> pages instead of the total count of items ?
> I want a way to provide the CAKE with the number of pages instead of
> leaving paginateCount to calculate it by dividing the total count of
> items by the page size.
>
> Is there any way to do this without hacking the core ? Or I will have
> to dispense with the CAKE pagination and make my own one?
>
>
> Detailed problem description:
>
> I have a table called “sermons”  , each sermon have a “hijri_date”
> field holds the sermon date.
>
> The table is something like this:
>
>     id     |   hijri_date   |
> -|--|
>     1      |  1429-1-1    |
>     2      |  1429-1-8    |
>     3      |  1429-1-15  |
>     4      |  1429-1-22  |
>     5      |  1429-3-5    |
>     6      |  1429-3-12  |
>     7      |  1429-4-4    |
>
>
>
> I wanted to display sermons with pagination, each page contains the
> sermon of a certain month.
>
> According to the above table pages will be like this:
>
> page 1 - all sermons that was in month #1 - :
>
>    id      |   hijri_date   |
> -|---|
>     1      |  1429-1-1    |
>     2      |  1429-1-8    |
>     3      |  1429-1-15  |
>     4      |  1429-1-22  |
>
>
> page 2 - all sermons that was in month #3 - :
>
>    id      |   hijri_date   |
> |---|
>     5      |  1429-3-5    |
>     6      |  1429-3-12  |
>
>
> page 3  - all sermons that was in month #4 - :
>
>    id      |   hijri_date   |
> -|--|
>     7      |  1429-4-4    |
>
>
>
>
> The SQL query is like this:
>
>
> SELECT *
> FROM sermons
> WHERE CONCAT(YEAR(hijri_date),'-',MONTH(hijri_date)) = (
>                        SELECT DISTINCT( 
> CONCAT(YEAR(hijri_date),'-',MONTH(hijri_date)))
>                        FROM sermons
>                        ORDER BY id DESC
>                        LIMIT $offset , 1       )
> ORDER BY id DESC
>
>
> here are my controller and model
>
> sermons_controller.php:
>
>
>  class SermonsController extends AppController {
>        var $name = 'Sermons';
>        var $paginate = array('Sermon' => array());
>
>        function index() {
>
>                if(! isset($this->passedArgs["page"])) $pageNumber=0;
>                else $pageNumber=$this->passedArgs["page"]-1;
>
>                $this->paginate = Set::merge($this->paginate,
>                        array('Sermon'=>array('limit'=>2, 'page'=>1, 'extra'=>
> $pageNumber)));
>
>                $this->set('sermons', $this->paginate('Sermon'));
>        }
>
> }
> ?>
>
>
> and  sermon.php :
>
>  class Sermon extends AppModel {
>        var $name = 'Sermon';
>
>        function paginate($conditions, $fields, $order, $limit, $page = 1,
> $recursive = null, $extra = array()) {
>        global $Sermons;
>
>                return $this->query(
> "SELECT *
> FROM sermons
> WHERE
>  CONCAT(YEAR(hijri_date),'-',MONTH(hijri_date)) = (
>                        SELECT DISTINCT( 
> CONCAT(YEAR(hijri_date),'-',MONTH(hijri_date)))
>                        FROM sermons
>                        ORDER BY id DESC
>                        LIMIT $offset,1 )
> ORDER BY id DESC");
>
>        }
>
>
>
>        function paginateCount($conditions = null, $recursive = 0, $extra =
> array()) {
>
>                $results =$this->query(
> "SELECT COUNT(DISTINCT( C

Re: login voodoo

2009-04-10 Thread brian

Please don't apologise! It's all good. I just wanted to set the record
straight for anyone who might come across the thread.Thanks again,
this was driving me nuts.

2009/4/9 Jorge Horacio Cué Cantú :
> Your wellcome, sorry for the small mistake.
>
>
> 2009/4/9 brian 
>>
>> 2009/4/9 Jorge Horacio Cué Cantú :
>> > Hello,
>> >
>> >
>> > Set
>> >
>> > $this->Auth->redirect = false
>> >
>> > in AppController::beforeFilter().
>> >
>> > The   the login() action will be called after a successful login.
>> >
>>
>> Thanks, that's it (sort of). The var is actually
>> $this->Auth->autoRedirect.
>>
>> So, for the record:
>>
>> AppController:
>> function beforeFilter()
>> {
>>        $this->Auth->fields = array('username' => 'email', 'password' =>
>> 'password');
>>        $this->Auth->loginError = 'No matching user found.';
>>        $this->Auth->loginAction = array('controller' => 'users', 'action'
>> => 'login');
>>        $this->Auth->loginRedirect = array('controller' => 'pages',
>> 'action'
>> => 'display', 'home');
>>        $this->Auth->autoRedirect = false;
>>        $this->Auth->logoutRedirect = array('controller' => 'users',
>> 'action'
>> => 'login');
>>
>>        if (isset($this->params['admin']) && $this->params['admin'])
>>        {
>>                $this->layout = 'admin';
>>        }
>> }
>>
>>
>> UsersController:
>> public function login()
>> {
>>        if ($user = $this->Auth->user())
>>        {
>>                $this->User->id = $user['User']['id'];
>>                $this->User->saveField('last_login', date('Y-m-d H:i:s'));
>>
>>                if (!$user['User']['eula_accepted'])
>>                {
>>                        $this->redirect(
>>                                array('controller' => 'users', 'action' =>
>> 'eula')
>>                        );
>>                }
>>                $this->redirect($this->Auth->loginRedirect);
>>        }
>> }
>>
>> public function eula()
>> {
>>        if (!empty($this->data) && $this->data['User']['eula_accepted'])
>>        {
>>                $this->User->id = $this->Auth->user('id');
>>                $this->User->saveField('eula_accepted', 1);
>>                $this->Session->write('Auth.User.eula_accepted', 1);
>>
>>                $this->redirect(
>>                        array('controller' => 'pages', 'action' =>
>> 'display', 'home')
>>                );
>>        }
>> }
>>
>> Thanks again, Jorge!
>>
>>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Putting a label on same line as an input field

2009-04-10 Thread Danny Lieberman

Well I finally cracked this myself - it is due to the infamous IE6
float margin bug
What I do is:

CSS:
label {
padding-left: 10px;
padding-right: 1px;

}

.idbox {
float:  left;
background:#ffc;
}

Cake Code:
echo $form->input('idcode', array('label'=>
$lb,'type'=>'text','length'=>2,'maxlength'=>2, 'div'=>'idbox') );


The only caveat is that all the field labels are on the left (which is
fine...) and it's a) simple and b) works in all browsers I tested
today
(Safari,  FF3 (Ubuntu, XP), Konqueror (Ubuntu) and IE6, IE8 (XP)

Danny

On Ap

r 10, 12:02 am, Danny Lieberman  wrote:
> Dardo
>
> Thanks - I already tried this direction and it doesn't affect the
> location of the label - it still appears above the input box.
>
> I can change label placement for all the forms but in this case I only
> want to change one particular field label
>
> In the view:
>
> echo $form->input('idcode', array('label'=>'Patient ID
> Code','type'=>'text','length'=>2,'maxlength'=>2, 'div' =>array('id' =>
> 'left-label')) );
>
> and this is what I have in the css
> left-label { float: left; width: 100px; display: block; }
>
> label {
>         display: block;
>         font-size: 110%;
>         padding-right: 20px;}
>
> input, textarea {
>         clear: both;
>         font-size: 140%;
>         font-family: "frutiger linotype", "lucida grande", "verdana", sans-
> serif;
>         padding: 2px;
>
> Danny
>
> On Apr 8, 5:59 pm, Dardo Sordi Bogado  wrote:
>
> > > Wouldn't you want all labels in side a form to appear on the left?
>
> > Perhaps I misunderstand the question, I thought he was asking how to
> > set an specific label in the left side.
>
> > > If so then why not do something along the lines of
> > > label {
> > >        float: left;
> > >        width: 75px;
> > >        display: block;
> > >        clear: left;
> > >        text-align: left;
> > >        cursor: hand;
> > >    }
>
> > In that case is better not to clear the labels, so ther don't affect
> > floating divs. I prefer to simply float them, and set overflow:auto to
> > de wrapping divs:
>
> > label { float: left; width: 75px; display: block; }
> > .input { overflow: auto; }
>
> > Regards,
> > - Dardo.
>
> > > On Apr 8, 6:31 am, Dardo Sordi Bogado  wrote:
> > >> Assign some specific css selector (setting an id or class in the
> > >> wrapping div should work), then set label { display: inline } or float
> > >> the things left...
>
> > >> $form->input('lefty-input', array('div' =>array('id' => 
> > >> 'make-me-left')));
>
> > >> HTH,
> > >> - Dardo
>
> > >> On Wed, Apr 8, 2009 at 8:26 AM, Danny Lieberman  
> > >> wrote:
>
> > >> > This is sort of a classic css question but I have not been able to
> > >> > position an label on the left side of an input field - it always
> > >> > slides to the top.  When I did get the label on the left-it impacted
> > >> > the layout of the entire form.
>
> > >> > br
> > >> > Danny
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pagination problem in search functionality

2009-04-10 Thread kaushik

I have a search form for Blog with pagination. The form is like below.










I want to set so that the url after hitting search button, it should
come with all the params. I mean it should: "http://
videon.smallbizmavericks.com/blogs/search/keywords:test1/
category:test2", so that in pagination I can use the in pagination
link like below:

$paginator->options(array('url' => $this->passedArgs));

If it is not possible, how to pass this arguments to paginator for
first time?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Little problem with "edit" forms

2009-04-10 Thread Ernesto

Hello.

i have a view, located @ CakeROOT/applicazione/utenti/modifica/
[utente_id]

- "modifica" it's the italian equivalent of "edit"
- "utente" it's the italian equivalent of "user"

I'm working with a legacy DB. I can't fully respect Cake's
conventions.

This view contains a form, coded this way:

echo $form->create("utente", array("url" => array("controller" =>
"utenti", "action" => "modifica/$utente_id")));

//form elements

echo $form->end("Conferma");

everything works fine but, if i voluntarily submit unvalid data for
two times or more in a row i get this in browser's adress bar

CakeROOT/applicazione/utenti/modifica/[utente_id]/[utente_id]

** note that the parameter utente_id is repeated two times. **

that's not a problem in this view cause it has just one input
parameter the second is ignored... but... why is that happening?
--~--~-~--~~~---~--~~
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: share elements, helpers etc across multiple apps

2009-04-10 Thread Ernesto

thx for the hint :)

On 9 Apr, 13:40, majna  wrote:
> Did you see output from debug(Configure::getInstance()); ?
>
> $behaviorPaths= array(ROOT.'common'.DS.'models'.DS.'behaviors');
>
> controllerPaths
> componentPaths
> helperPaths
> pluginPaths
>
> On Apr 8, 3:19 pm, Ernesto  wrote:
>
>
>
> > And... to share a behavior?
>
> > On 7 Apr, 18:11, majna  wrote:
>
> > > Setup additional view paths in config/bootstrap.php
> > > $viewPaths = array(ROOT.'common'.DS.'views'.DS);
>
> > > debug(Configure::getInstance());
>
> > > On Apr 7, 4:34 pm, Ernesto  wrote:
>
> > > > Hello.
>
> > > > Is there a way tosharethe same helper or element file across
> > > >multipleapps?
--~--~-~--~~~---~--~~
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: Putting a label on same line as an input field

2009-04-10 Thread Danny Lieberman

Well I finally gave up and put all the labels on left hand side of the
imput fields - i made a little class called xg with a background in
order to emphasize the field in question  works nicely in Firefox
and Konqueror

label { float: left;
width: 150px;
display: block;
clear: none;
text-align: left;
vertical-align: middle;
padding-right: 0px;}

.xg {
display: block;
background:#ffc;
float:left;
}


You can override the wrapping div in the $form->input like this:
echo $form->input('idcode', array('label'=>
$lb,'type'=>'text','length'=>2,'maxlength'=>2,'div'=>'xg') );

BUT
it doesn't work in IE6
:-(

Danny

On Apr 10, 12:02 am, Danny Lieberman  wrote:
> Dardo
>
> Thanks - I already tried this direction and it doesn't affect the
> location of the label - it still appears above the input box.
>
> I can change label placement for all the forms but in this case I only
> want to change one particular field label
>
> In the view:
>
> echo $form->input('idcode', array('label'=>'Patient ID
> Code','type'=>'text','length'=>2,'maxlength'=>2, 'div' =>array('id' =>
> 'left-label')) );
>
> and this is what I have in the css
> left-label { float: left; width: 100px; display: block; }
>
> label {
>         display: block;
>         font-size: 110%;
>         padding-right: 20px;}
>
> input, textarea {
>         clear: both;
>         font-size: 140%;
>         font-family: "frutiger linotype", "lucida grande", "verdana", sans-
> serif;
>         padding: 2px;
>
> Danny
>
> On Apr 8, 5:59 pm, Dardo Sordi Bogado  wrote:
>
> > > Wouldn't you want all labels in side a form to appear on the left?
>
> > Perhaps I misunderstand the question, I thought he was asking how to
> > set an specific label in the left side.
>
> > > If so then why not do something along the lines of
> > > label {
> > >        float: left;
> > >        width: 75px;
> > >        display: block;
> > >        clear: left;
> > >        text-align: left;
> > >        cursor: hand;
> > >    }
>
> > In that case is better not to clear the labels, so ther don't affect
> > floating divs. I prefer to simply float them, and set overflow:auto to
> > de wrapping divs:
>
> > label { float: left; width: 75px; display: block; }
> > .input { overflow: auto; }
>
> > Regards,
> > - Dardo.
>
> > > On Apr 8, 6:31 am, Dardo Sordi Bogado  wrote:
> > >> Assign some specific css selector (setting an id or class in the
> > >> wrapping div should work), then set label { display: inline } or float
> > >> the things left...
>
> > >> $form->input('lefty-input', array('div' =>array('id' => 
> > >> 'make-me-left')));
>
> > >> HTH,
> > >> - Dardo
>
> > >> On Wed, Apr 8, 2009 at 8:26 AM, Danny Lieberman  
> > >> wrote:
>
> > >> > This is sort of a classic css question but I have not been able to
> > >> > position an label on the left side of an input field - it always
> > >> > slides to the top.  When I did get the label on the left-it impacted
> > >> > the layout of the entire form.
>
> > >> > br
> > >> > Danny
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pagination in Search Forms

2009-04-10 Thread Sourav

I am building a search form which allows users to search for Jobs by
category, location & job title.

My controller code is as follows:

function search() {
if(!empty($this->data)) {

$title = $this->data['Job']['title'];
$location = $this->data['Job']['location'];
$this->paginate = array(
   'conditions' => array(
'AND' => array(
  'Job.status' 
=> 'A',
  'Job.title 
like' => '%' . $title . '%',
  'Job.location 
like' => '%' . $location . '%',
  
'Job.job_category_id' => $this->data['Job']
['job_category_id'],

)
),
   'limit' => 5,
   'order' => array(
'Job.type' => 'asc',
'Job.id' => 'desc'
   )
  );
$data = $this->paginate('Job');
$this->set(compact('data'));
}



I have the following code in my view:

options(array('update' => 'content', 'url' =>
serialize($this->data), 'indicator' => 'spinner')); ?>

But when I tried to unserialize the data, it is giving the following
error:

Notice (8): unserialize() [function.unserialize]: Error at offset 0 of
134 bytes

How can I implement the pagination, such that all the form values are
retained ?

- 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 am I missing ($conditions in a find)?

2009-04-10 Thread Paul

You need to put the condition in the key, that is:

$conds = array('Node.lft >=' => $node['Node']['lft'], 'Node.rght <='
=> $node['Node']['rght']);

On Apr 10, 6:22 am, cartosys  wrote:
> my conditions:
>
>                 $sqlConditions = array(
>                                 'Node.lft' => ">= ".$node["Node"]["lft"],
>                                 'Node.rght' => "<= ".$node["Node"]["rght"]);
>
>                 $nodes = $this->Node->generateTreeList($sqlConditions);
>
> and this is the resulting query (from debug level 2):
>
> SELECT `Node`.`id`, `Node`.`title`, `Node`.`lft`, `Node`.`rght` FROM
> `nodes` AS `Node` WHERE `Node`.`lft` = '>= 4' AND `Node`.`rght` = '<=
> 15' ORDER BY `Node`.`lft` asc
>
> why aren't the comparison operators <= and >= not replacing the =
> operator?
>
> -BP

--~--~-~--~~~---~--~~
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 am I missing ($conditions in a find)?

2009-04-10 Thread benjamw

Try putting the <= and >= operators into the array key as follows:

$sqlConditions = array(
'Node.lft >=' => $node["Node"]["lft"],
'Node.rght <=' => $node["Node"]
["rght"]);


On Apr 9, 10:23 pm, czg  wrote:
> Same thing happens if I replace "generatetreelist" with "findAll"
> -BP
>
> On Apr 9, 3:22 pm, cartosys  wrote:
>
> > my conditions:
>
> >                 $sqlConditions = array(
> >                                 'Node.lft' => ">= ".$node["Node"]["lft"],
> >                                 'Node.rght' => "<= ".$node["Node"]["rght"]);
>
> >                 $nodes = $this->Node->generateTreeList($sqlConditions);
>
> > and this is the resulting query (from debug level 2):
>
> > SELECT `Node`.`id`, `Node`.`title`, `Node`.`lft`, `Node`.`rght` FROM
> > `nodes` AS `Node` WHERE `Node`.`lft` = '>= 4' AND `Node`.`rght` = '<=
> > 15' ORDER BY `Node`.`lft` asc
>
> > why aren't the comparison operators <= and >= not replacing the =
> > operator?
>
> > -BP
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



change "contain" settings for $paginate on the fly

2009-04-10 Thread park

Hi,

$this->Model->contain() doesn't seem to affect $paginate query result.

The following approach is mentioned in the official documentation.
var $paginate = array(
'Model'=> array(
'contain' => array(
// Contain settings goes here
)
)
);

But is there a way to change this settings on the fly?

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: Looking for something better then requestAction?

2009-04-10 Thread Walther

Ah, great!

Thanks.

On Apr 7, 6:15 pm, majna  wrote:
> Use  cache key for each element():
> echo $this->element('news/featured', array('cache'=>array('time'=>'+1
> hour', 'key'=>'featured_news_2')));
>
> On Apr 6, 1:33 pm, Walther  wrote:
>
> > I did try using the cache, but because I may be calling the same
> > element a few times but with different inputs it won't work (It just
> > redisplays the first item for that element).
>
> > On Apr 6, 1:23 pm, majna  wrote:
>
> > > Use elements cache 
> > > :)http://bakery.cakephp.org/articles/view/creating-reusable-elements-wi...
>
> > > On Apr 6, 12:06 pm, Walther  wrote:
>
> > > > I believe I've found a solution.
>
> > > > For each possible item that can be added to the homepage I store the
> > > > name of the controller that is called. By simply changing this to the
> > > > model name and using App::Import in the homepage model (Where I fetch
> > > > the items from the database) I have gotten rid of the requestActions.
>
> > > > Seems to be working quite well.
>
> > > > From those who are more experienced at Cake, is this a better way of
> > > > doing it?
>
> > > > On Apr 6, 10:51 am, Walther  wrote:
>
> > > > > Hi all
>
> > > > > In an app that I am currently developing I wish to give the
> > > > > administrator the ability to customise the home page of the app by
> > > > > being able to include various other things into the home page (For
> > > > > example, the admin may wish to show a welcome message which uses the
> > > > > pages controller, and they may wish to show a calendar using the
> > > > > calendars controller and an unlimited number of other views).
>
> > > > > What I am currently doing is on the homepage view I do a loop through
> > > > > the homepages table and call the homepages.ctp element and sends it
> > > > > the relevant data for the view that needs to be displayed. The
> > > > > homepage element then calls the relevant element for whatever
> > > > > controller the admin has chosen, this controller may be part of a
> > > > > plugin.
>
> > > > > The homepages.ctp element looks as follows:
> > > > >  > > > > if ($item['MenuLink']['plugin_id'] == 0)
> > > > > {
> > > > >         $View =& ClassRegistry::getObject('view');
> > > > >         echo $View->element('homepages/' . 
> > > > > $item['MenuLink']['controller'],
> > > > > array('item' => $item));}
>
> > > > > else
> > > > > {
> > > > >         $View =& ClassRegistry::getObject('view');
> > > > >         echo $View->element('homepages/' . 
> > > > > $item['MenuLink']['controller'],
> > > > > array('item' => $item, 'plugin' => $item['MenuLink']['Plugin']
> > > > > ['directory']));}
>
> > > > > ?>
>
> > > > > As an example the homepages/pages.ctp element looks as follows:
> > > > > requestAction('/pages/index/' . $item
> > > > > ['Homepage']['options']); ?>
> > > > > 
> > > > >         
> > > > >                 
> > > > >                         Created: prettyDate($pageToShow['Page']
> > > > > ['created']); ?>
> > > > >                         Modified: prettyDate($pageToShow
> > > > > ['Page']['modified']); ?>
> > > > >                         Tags:  > > > > ?>
> > > > >                 
>
> > > > >                  > > > > $pageToShow['Page']['title']; ?>
> > > > >                 
> > > > >                          > > > >                         echo $pageToShow['Page']['text'];
> > > > >                         ?>
> > > > >                 
> > > > >         
> > > > > 
> > > > > No page
> > > > > 
>
> > > > > It is working well. However, I realise that requestAction is quite
> > > > > intensive as it acts like another server request, is there some other
> > > > > method that I can use that will achieve the same outcome but use less
> > > > > server resources?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



how to make Multiple section in url interface for pretty url

2009-04-10 Thread Saleh Souzanchi

hi
plz see  this sample :


domain/portal/action
domain/portal/system/action's
domain/portal/profile/action's
domain/portal/mybox/action's

how to config Routing settings?



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



how to make defined multi porfix?

2009-04-10 Thread Saleh Souzanchi

hi dear's

i have define some prefix in my project

for example
domain/setting/user/add
domain/setting/user/edit
domain/setting/user/del

setting = prefix
user = controller

and

domain/setting/profile/edit
domain/setting/profile/view
domain/setting/profile/share

setting = prefix
profile= controller


how to config routter and controller?

plz help me

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



Yet another Pagination Question (custom query but don't have a model to overwrite paginator)

2009-04-10 Thread nc

I have a Search controller that handles search-related tasks in my
project and one of the requirements is that given a query (let's say
$query) it should search for $query in table a (model A), table b
(model B), table c (model C), and table d (model D). This Search
controller  DOES NOT have a Search model associated with it (was not
needed). It instead sets $uses = array('A','B','C','D'). It has to
search using MySQL's fulltext search.

Right now I'm trying to get it working with only 2 of the 4 models
(because it'll be easy to expand out to 4 once I get this working)

Currently what I have is this (all in search_controller.php):

var $paginate = array('fields' => array('A.id', 'A.title',
'A.second'));

And my pagination does this:

$this->paginate('A', array("1" =>
"1 AND WHERE MATCH(A.title,A.second) AGAINST('{$query}' IN BOOLEAN
MODE ) UNION SELECT `B`.`id`, `B`.`name`, `B`.`type` FROM `b` AS `B`
WHERE 1 AND MATCH(`B`.`name`) AGAINST('$query' IN BOOLEAN MODE )"
));

Naturally I get an error because the query it uses to do count(*)
fails. I would override the entire pagination thing if I had a model
to override (I can't override A and B's pagination because I want it
to work normally for other things).

So is there anyway I can do this or do I have to resort to hacking
stuff to get my functionality?

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