Re: REST API in 2.x (authenticate for some actions, etc)

2012-10-22 Thread Ivan Rimac
you can use cURL for simulating post requests:

$data = 'data[User][token]=87f77a583929c700119878128dc108bd62ca7772';
$data .= '&data[Ride][start_address]=Osijek, Croatia';
$data .= '&data[Ride][end_address]=Pula, Croatia';

$ch = curl_init('http://domain.com/controller/action.json');

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$head = curl_exec($ch);
print_r($head);
curl_close($ch);

Then, in some  controller you go:

function action() {
  if ($this->RequetsHandler->ext === 'json') {
//ext could be an xml also, and here you do stuff with post data
  }
}

also inside your routes.php file:
Router::parseExtensions('json');

hope this example helps you.


On Mon, Oct 22, 2012 at 12:42 PM, Zap  wrote:

> Hi everyone.
>
> The webfront of my website is ready, but I want to give access to core
> functions via an API.
>
> Thing is, for public data (like juse rinfo and such), I already used
> request handler to have json or XML special views, so I guess that's ok.
>
> But, I was wondering how to achieve POST action ?
>
> Indeed, I want some actions to need authentification :
>
> Posts -> add
> Posts -> delete
>
> Plus, for the "add" action, I'm wondering how is the data sent ? My posts
> allow 300 characters, bu I Guess it isn't in the url parameters ? Or is it ?
>
> I'm wonering about the routing also, as some actions are under User ->
> view and new one I want to emplement under Posts - >add etc.
>
> Is it possible to regroup this as /api/post/add or api/users/view/ ?
>
> Thanks a lot but the REST doc  wasn't really helpfull to me.
>
> Thanks !
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>



-- 
*Ivan Rimac***
mail: ivn...@gmail.com
*tel: +385 95 555 99 66*
*http://ivanrimac.com*

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

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




Re: Allow special characters in HtmlHelper

2012-10-22 Thread Chetan Varshney
Use this for example $imgTag = $this->Html->image($image['Image']
['thumb_path'], array( 'alt' => $title )); $options = array('class' =>
'thumb', 'name' => trim(Inflector::slug($title)), 'title' => trim($title),
'escape'=>false);

echo $this->Html->link($imgTag, $this->Html->url($image['Image']
['small_path'],true), $options);

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

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




Allow special characters in HtmlHelper

2012-10-22 Thread bs28723

  


  
  
I would like to use Html->image and Html->link together, but
Html->link will convert characters like <, ", etc to htmlize
them. 

for example 
            $imgTag =
$this->Html->image($image['Image']['thumb_path'], array( 'alt'
=> $title )); 
                
$options = array('class' => 'thumb', 'name' =>
trim(Inflector::slug($title)), 'title' => trim($title)); 
                
           echo 
$this->Html->link($imgTag,
$this->Html->url($image['Image']['small_path'],true),
$options); 

Will actually produce 


<img 
src="/2d3cf4770eefa1244464b0371009c2b0_resized_100x75.jpg" 
alt="tree " />

Yes the < etc is really in the file, so the image does not get 
recognized by the browser as HTML. But it just gets displayed as text.

Any way to get the Html->link to not convert the string?
Or do I need to just build this manually?


  





--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Allow-special-characters-in-HtmlHelper-tp5711911.html
Sent from the CakePHP mailing list archive at Nabble.com.

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

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




Re: Get Data From Associations

2012-10-22 Thread ecko usil
Thanks guys, CounterCache more suitable for my case.. and its worked

On Tuesday, October 23, 2012 12:36:42 AM UTC+7, jsundquist wrote:
>
> Specifically look at the following within the cake book
>
>
> http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#creating-and-destroying-associations-on-the-fly
>
> On Mon, Oct 22, 2012 at 12:29 PM, Jonathan Sundquist 
> 
> > wrote:
>
>> Change the join type to an outer join instead of an inner join.  In order 
>> to do this within your controller before you make the query you will need 
>> to flip either your belongsTo or hasMany depending on which way you have 
>> your model set up.
>>
>>
>> On Mon, Oct 22, 2012 at 12:27 PM, lowpass 
>> > wrote:
>>
>>> I think the simplest approach would be to use counterCache. Then you
>>> could do a find on Categories where the count is 0.
>>>
>>> On Mon, Oct 22, 2012 at 1:00 PM, ecko usil > 
>>> wrote:
>>> > Categories has many articles. How can I get list all categories with
>>> > conditions categories doesn't have any articles?
>>> >
>>> > thanks in advance.
>>> > regards ucil
>>> >
>>> > --
>>> > Like Us on FaceBook https://www.facebook.com/CakePHP
>>> > Find us on Twitter http://twitter.com/CakePHP
>>> >
>>> > ---
>>> > You received this message because you are subscribed to the Google 
>>> Groups
>>> > "CakePHP" group.
>>> > To post to this group, send email to cake...@googlegroups.com
>>> .
>>> > To unsubscribe from this group, send email to
>>> > cake-php+u...@googlegroups.com .
>>> > Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>> >
>>> >
>>>
>>> --
>>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>> Find us on Twitter http://twitter.com/CakePHP
>>>
>>> ---
>>> You received this message because you are subscribed to the Google 
>>> Groups "CakePHP" group.
>>> To post to this group, send email to cake...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> cake-php+u...@googlegroups.com .
>>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>>
>>>
>>>
>>
>

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

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




REST API in 2.x (authenticate for some actions, etc)

2012-10-22 Thread Zap
Hi everyone.

The webfront of my website is ready, but I want to give access to core 
functions via an API.

Thing is, for public data (like juse rinfo and such), I already used 
request handler to have json or XML special views, so I guess that's ok.

But, I was wondering how to achieve POST action ?

Indeed, I want some actions to need authentification :

Posts -> add
Posts -> delete

Plus, for the "add" action, I'm wondering how is the data sent ? My posts 
allow 300 characters, bu I Guess it isn't in the url parameters ? Or is it ?

I'm wonering about the routing also, as some actions are under User -> view 
and new one I want to emplement under Posts - >add etc.

Is it possible to regroup this as /api/post/add or api/users/view/ ?

Thanks a lot but the REST doc  wasn't really helpfull to me.

Thanks !

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

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




HttpSocket in Ajax

2012-10-22 Thread Ingvar
I'm having promlem with sending post request in ajax request handler. In 
ajax request handler the body of response is always null, in the regular 
request handler it's not null. How to send http requests in ajax request 
handler?

class DataController extends AppController
{
public function ajax_get_name()
{
$this->layout = 'ajax';
$http = new HttpSocket();
$res = $http->get('http://www.google.com/search', 'q=cakephp');
if($res)
{
$data = json_decode($res->body);
debug($data); // null
}
}

publiс function index()
{
$http = new HttpSocket();
$res = $http->get('http://www.google.com/search', 'q=cakephp');
if($res)
{
$data = json_decode($res->body);
debug($data); // *not *null
}
}
}

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

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




Re: Making database queries secure

2012-10-22 Thread Jamie
The best way to secure your update and insert queries? Use the proper model 
interface, i.e. save(), saveAll(), etc.

On Monday, October 22, 2012 6:22:54 AM UTC-7, Daniel wrote:
>
> I do some custom database queries using some values derived from a call to 
> find.  I think I should make these more secure using a security function, 
> but I am not sure which function to use.  Should I use Sanitize or 
> mysql_real_escape_string, and what parameters should I pass?  Here is the 
> relevant code:
>  
>   $user = $this->User->Find('first', array('conditions' => array('User.id' 
> => $id)));
>   $username = $user['User']['username'];
>   $email = $user['User']['email'];
> ...
>   $qry = $this->User->query('UPDATE outemails SET to_user_id=null, 
> recipient="'.$username.
>'" WHERE to_user_id="'.$id.'";');
>   $qry = $this->User->query('INSERT INTO delemails (username, email, 
> blacklisted, created) VALUES ("'.
>$username.'","'.$email.'",false,NOW());');
> Thanks.
>

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

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




Re: Get Data From Associations

2012-10-22 Thread Jonathan Sundquist
Specifically look at the following within the cake book

http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#creating-and-destroying-associations-on-the-fly

On Mon, Oct 22, 2012 at 12:29 PM, Jonathan Sundquist
wrote:

> Change the join type to an outer join instead of an inner join.  In order
> to do this within your controller before you make the query you will need
> to flip either your belongsTo or hasMany depending on which way you have
> your model set up.
>
>
> On Mon, Oct 22, 2012 at 12:27 PM, lowpass  wrote:
>
>> I think the simplest approach would be to use counterCache. Then you
>> could do a find on Categories where the count is 0.
>>
>> On Mon, Oct 22, 2012 at 1:00 PM, ecko usil  wrote:
>> > Categories has many articles. How can I get list all categories with
>> > conditions categories doesn't have any articles?
>> >
>> > thanks in advance.
>> > regards ucil
>> >
>> > --
>> > Like Us on FaceBook https://www.facebook.com/CakePHP
>> > Find us on Twitter http://twitter.com/CakePHP
>> >
>> > ---
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "CakePHP" group.
>> > To post to this group, send email to cake-php@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > cake-php+unsubscr...@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/cake-php?hl=en.
>> >
>> >
>>
>> --
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com.
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>
>>
>>
>

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

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




Re: Get Data From Associations

2012-10-22 Thread Jonathan Sundquist
Change the join type to an outer join instead of an inner join.  In order
to do this within your controller before you make the query you will need
to flip either your belongsTo or hasMany depending on which way you have
your model set up.

On Mon, Oct 22, 2012 at 12:27 PM, lowpass  wrote:

> I think the simplest approach would be to use counterCache. Then you
> could do a find on Categories where the count is 0.
>
> On Mon, Oct 22, 2012 at 1:00 PM, ecko usil  wrote:
> > Categories has many articles. How can I get list all categories with
> > conditions categories doesn't have any articles?
> >
> > thanks in advance.
> > regards ucil
> >
> > --
> > Like Us on FaceBook https://www.facebook.com/CakePHP
> > Find us on Twitter http://twitter.com/CakePHP
> >
> > ---
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com.
> > Visit this group at http://groups.google.com/group/cake-php?hl=en.
> >
> >
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>

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

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




Re: Get Data From Associations

2012-10-22 Thread lowpass
I think the simplest approach would be to use counterCache. Then you
could do a find on Categories where the count is 0.

On Mon, Oct 22, 2012 at 1:00 PM, ecko usil  wrote:
> Categories has many articles. How can I get list all categories with
> conditions categories doesn't have any articles?
>
> thanks in advance.
> regards ucil
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

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

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




Get Data From Associations

2012-10-22 Thread ecko usil
Categories has many articles. How can I get list all categories with 
conditions categories doesn't have any articles?

thanks in advance.
regards ucil

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

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




RE: Change Image Path

2012-10-22 Thread Advantage+
Worked perfect!

 

Thanks.

 

Dave

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of Vanja Dizdarevic
Sent: Monday, October 22, 2012 3:12 AM
To: cake-php@googlegroups.com
Subject: Re: Change Image Path

 

The core bootstrap (lib/Cake/bootstrap.php) is loaded before app bootstrap
(app/Config/bootstrap.php) and defines the IMAGES_URL.

Do redefine it, you should put the definition in index.php, before the core
boot is loaded.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
--- 
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

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

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




Request gets blackholed.

2012-10-22 Thread Advantage+
I have a standard function in AppController that's used for various
controllers to simply order / re-order users records for various controller.

There are no views as the ordering (drag and drop ) is done on the
manage_index view for what ever controller.

It worked in 1.3 but migrating to 2.2.3 and now the request gets black
holed.

 

AppController:

public function manage_order() {



if ( $this->request->is('ajax') &&
$this->request->is('post')) {



//$this->_ajaxSetup();
//simple function that has $this->autoRender = false; $this->autoLayout =
false;

 



if( !empty(
$this->request->data )){



$count = 0;

foreach (
$this->request->data as $record ) {

 
$count++;

 
$record = substr( $record, 4 );//remove set_ from beginning of the id

 
$this->{$this->modelClass}->id = $record;

 
if ( $this->{$this->modelClass}->hasAny( array( 'id' => $record, 'user_id'
=> $this->owner_id ) ) ) {

 
$this->{$this->modelClass}->saveField( 'order', $count );

 
}

}

}

} else {

$this->redirect( array(
'manage' => true, 'action' => 'index' ) );

}

}

 

routes.php:

Router::connect('/manage/showcases/order',array(

'controller' => 'showcases',

'action' => 'order',

'prefix' => 'manage',

'manage' => true));

 

If I access the url directly I get redirected so it gets to the function,
but the ajax request results in Error. Address not found your request has
been blackholed.

But I see the POST data sent as it should to the correct URL.

 

I am using security component. Any ideas?

 

Thanks,

Dave

 

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

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




Re: Making database queries secure

2012-10-22 Thread Felipe Zavan
I don't know about cleaning the query data, but you really should be
using cake methods.

Is there any special reason you don't?

2012/10/22 Daniel :
> I do some custom database queries using some values derived from a call to
> find.  I think I should make these more secure using a security function,
> but I am not sure which function to use.  Should I use Sanitize or
> mysql_real_escape_string, and what parameters should I pass?  Here is the
> relevant code:
>
>   $user = $this->User->Find('first', array('conditions' => array('User.id'
> => $id)));
>   $username = $user['User']['username'];
>   $email = $user['User']['email'];
> ...
>   $qry = $this->User->query('UPDATE outemails SET to_user_id=null,
> recipient="'.$username.
>'" WHERE to_user_id="'.$id.'";');
>   $qry = $this->User->query('INSERT INTO delemails (username, email,
> blacklisted, created) VALUES ("'.
>$username.'","'.$email.'",false,NOW());');
> Thanks.
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

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

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




Making database queries secure

2012-10-22 Thread Daniel
I do some custom database queries using some values derived from a call to 
find.  I think I should make these more secure using a security function, 
but I am not sure which function to use.  Should I use Sanitize or 
mysql_real_escape_string, and what parameters should I pass?  Here is the 
relevant code:
 
  $user = $this->User->Find('first', array('conditions' => array('User.id' 
=> $id)));
  $username = $user['User']['username'];
  $email = $user['User']['email'];
...
  $qry = $this->User->query('UPDATE outemails SET to_user_id=null, 
recipient="'.$username.
   '" WHERE to_user_id="'.$id.'";');
  $qry = $this->User->query('INSERT INTO delemails (username, email, 
blacklisted, created) VALUES ("'.
   $username.'","'.$email.'",false,NOW());');
Thanks.

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

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




Re: Copy branch of Tree to another parent

2012-10-22 Thread bs28723
Sorry, if my question was not clear.

I want to "copy" the entire branch to another location.  So, if I want 
to copy a branch that has 5 children,
then I need to create the new parent node first, then once I have this 
ID, I can then create the 5 children nodes.
That is a fairly easy example.  But what about a branch that has 4 
levels and 5 nodes?

Is seems like I have to walk the original tree and create each node, 
then sub-node, then leaf, etc, etc.
Anyone done this before? Any suggestions?

Example - Before Copy
Root
|--Node1
||-- Node2
||-- Node3
|  |--Node4
||--Node5
|--Node6
  |--Node7

After Copy
Root
|--Node1
||-- Node2
||-- Node3
|  |--Node4
||--Node5
|--Node6
  |--Node7
   |--Node1
|-- Node2
|-- Node3
  |--Node4
|--Node5

On 10/22/2012 12:27 AM, Jeremy Burns | Class Outfit [via CakePHP] wrote:
> Surely you can just change the parent_id of the top of the branch you 
> want to move? Then let the Tree behaviour take care of the rest.
>
> Jeremy Burns
> Class Outfit
>
> http://www.classoutfit.com
>
> On 21 Oct 2012, at 23:24:53, bs28723 <[hidden email] 
> > wrote:
>
>> Hi,
>> I am using the tree behavior for one of my models, and I want to
>> copy a branch of a tree, with all the sub-branches, leafs etc to another
>> parent.
>> It looks like I am going to have to get a list of the children of the
>> copy from node, and then do a save for each new node.
>> would it work to do a find('threaded')  clear out all the parent_ids,
>> set the top node parent_id to the new parent_id, and do a save()?
>>
>> Is there another way to do this?
>>
>> Thanks,
>> bill
>>
>>
>> 
>> View this message in context: Copy branch of Tree to another parent 
>> 
>> Sent from the CakePHP mailing list archive 
>>  at Nabble.com 
>> .
>>
>> -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> ---
>> You received this message because you are subscribed to the Google 
>> Groups "CakePHP" group.
>> To post to this group, send email to [hidden email] 
>> .
>> To unsubscribe from this group, send email to [hidden email] 
>> .
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>
>>
>
> -- 
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google 
> Groups "CakePHP" group.
> To post to this group, send email to [hidden email] 
> .
> To unsubscribe from this group, send email to [hidden email] 
> .
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
>
> 
> If you reply to this email, your message will be added to the 
> discussion below:
> http://cakephp.1045679.n5.nabble.com/Copy-branch-of-Tree-to-another-parent-tp5711875p5711880.html
>  
>
> To start a new topic under CakePHP, email 
> ml-node+s1045679n125572...@n5.nabble.com
> To unsubscribe from CakePHP, click here 
> .
> NAML 
> 
>  
>





--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Copy-branch-of-Tree-to-another-parent-tp5711875p5711898.html
Sent from the CakePHP mailing list archive at Nabble.com.

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

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




Re: How can i edit a record?

2012-10-22 Thread Nattapong Suwansukho
??  AUTO_INCREMENT  :-)

?  22 ?? ?.?. 2012, 15 ?? 57  16 ?? UTC+7, 
suttipong Pratum :
>
>   u must show  filed id  in  edit view page  or  hidden filed   when 
> submit   and call  save()   cakephp auto  update
>
>
>   ? ??  pk  ??? table  hidden filed  
> ??? view ?? ? sumit  controller 
> ???  new data 
>
>    
>
> ? ? 21 ?? ?.?. 2012, 4 ?? 14  49 ?? UTC+7, 
> Nattapong Suwansukho :
>>
>> I cannot update a record and i don't know why. Pls see the pictures below 
>> and suggest me , if i did something's wrong.
>> *sorry for not good in English.
>>
>>
>>
>> 
>>
>

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

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




Re: How can i edit a record?

2012-10-22 Thread Nattapong Suwansukho
Thx for you suggestion , i've really forgot to set AUTO_INCREMENT. :-)

เมื่อ วันอาทิตย์ที่ 21 ตุลาคม ค.ศ. 2012, 11 นาฬิกา 7 นาที 55 วินาที UTC+7, 
Wallace Cardoso Colaço Ricardo เขียนว่า:
>
> The field ID has to be Primary Key and AUTO_INCREMENT.
>
> You need to change the table countries
>
> On Oct 20, 2012, at 5:14 PM, Nattapong Suwansukho wrote:
>
> I cannot update a record and i don't know why. Pls see the pictures below 
> and suggest me , if i did something's wrong.
> *sorry for not good in English.
>
>
>
> 
>
> -- 
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>  
> --- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> cake-php+u...@googlegroups.com .
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>  
>  
>
>
>

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

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




CakeResponse::expires() Fatal Error

2012-10-22 Thread gimmebucks
I'm using cake 2.2.2 and trying to set expires headers.
in my AppController.php

> public function beforeRender(){
> CakeResponse::expires(new DateTime('+5 day'));
> }


but i got this error

> *Fatal error*: Call to undefined method 
> CakeErrorController::_getUTCDate() in *
> F:\www\mail-us\lib\Cake\Network\CakeResponse.php* on line *858*


please help.
p/s : i'm trying this on individual action but got the same error. 

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

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




How to get posts that match specified several tags

2012-10-22 Thread Anna P
Hello.

I'm creating a search engine for a blog and I've got a problem with 
selecting posts based on a given, several tags.

I have following models:
- Post  (posts)
- Tag  (tags)
- PostsTag  (posts_tags)
In Post model there is a hasAndBelongsToMany relationship with Tag model 
defined.

Let's say I have following posts and tags assigned to them:
- "Raspberry icecream" - with "icecream" tag assigned
- "Pineapple icecream" - with "icecream" and "pineapple" tags assigned
- "Pineapple pie" - with "pineapple" and "pie" tags assigned

What I'm trying to do is select posts that match not only one tag, but all 
the tags that are specified in a search phrase.
Let's say that I've entered to the search engine following search phrase: 
"pineapple icecream" .

Now, what I want to achieve is to posts that have "pineapple" tag assigned 
to them and also have "icecream" tag assigned.
So in search results there is only "Pineapple icecream" displayed, because 
it is assigned to both search conditions words - pineapple and icecream.

How can I do this?
I tried like that:

$tags=$this->Tag->find('all',array('conditions'=>$cond,'fields'=>array('id'))); 
   
//here I get all the tags that match every word in search conditions
if($tags) {
  foreach($tags as $t) {
$tags_ids[]=$t['Tag']['id'];
  }
  
$posts_tags=$this->PostsTag->find('all',array('conditions'=>array('tag_id'=>$tags_ids),'fields'=>array('post_id')));
  if($posts_tags) {
foreach($posts_tags as $pt) {
  $posts_ids[]=$pt['PostsTag']['post_id'];
}  
  }
}

and then I do the search for posts based on the $posts_ids condition.

But with this solution, I get in search results all the posts, which have 
either "icecream" tag or "pineapple" tag. Which does not suit my needs.

Any help will be greatly appreciated.




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

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




Re: How can i edit a record?

2012-10-22 Thread suttipong Pratum
  u must show  filed id  in  edit view page  or  hidden filed   when 
submit   and call  save()   cakephp auto  update


  ? ??  pk  ??? table  hidden filed  
??? view ?? ? sumit  controller 
???  new data 

   

? ? 21 ?? ?.?. 2012, 4 ?? 14  49 ?? UTC+7, 
Nattapong Suwansukho :
>
> I cannot update a record and i don't know why. Pls see the pictures below 
> and suggest me , if i did something's wrong.
> *sorry for not good in English.
>
>
>
> 
>

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

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




Re: Locale prefix

2012-10-22 Thread Ivan Rimac
Nema na čemu! :-)

I had to do only once, and I had dedicated server at my disposal, so it was
relatively easy for me to do it in this way. I did not want to mess with
i18n database strucuture, and all of that things, so I dont have experience
with other ways how to do it. So i am not able to help you with that,
reading the book would be my option :-)

http://book.cakephp.org/1.3/en/view/1230/Localization-in-CakePHP

cheers



On Mon, Oct 22, 2012 at 9:18 AM, Vanja Dizdarević  wrote:

> Hvala Ivane! :D
>
> The code helps a lot.
>
> Subdomains were also my first impulse. But it is much easier for me to
> have it on the same domain for multiple reasons (security
> certificates, seo, cross-domain requests, practical urls, css/js/img
> caching, sessions, portability, etc).
>
> Anyways, I'm currently at "modify the *.htaccess *rewrites and *App.base*".
> Any better ideas?
>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>



-- 
*Ivan Rimac***
mail: ivn...@gmail.com
*tel: +385 95 555 99 66*
*http://ivanrimac.com*

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

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




Re: is it possible create schedule post with cakephp?

2012-10-22 Thread ecko usil
This is my case: I create some task with date time > now(), it means 
scheduled task. When task time is coming that task will run another task. 
ex: Create some email message now but scheduled for sent next week to 
multiple accounts. 

thanks all for your reply. Any code sample will help me a lot :D

On Monday, October 22, 2012 2:26:48 PM UTC+7, Vanja Dizdarević wrote:
>
> ...you mean published < NOW() ...
>
> That typo cost me 5 minutes of thinking. :D
>

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

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




Re: is it possible create schedule post with cakephp?

2012-10-22 Thread Vanja Dizdarević
...you mean published < NOW() ...

That typo cost me 5 minutes of thinking. :D

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

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




Re: is it possible create schedule post with cakephp?

2012-10-22 Thread AD7six


On Monday, 22 October 2012 05:37:19 UTC+2, ecko usil wrote:
>
> Thanks kani for your answer, I know that cakephp is not CMS. In my case, I 
> just develop application with cakePHP and I want scheduling some task, and 
> automate update some action when scheduled time is coming. What can I say, 
> maybe create automated cronjob and crontab from controller. 


OR

just have a published date field in the db, which defaults to the date of 
creation, and select posts with published > NOW().

Why do you want to make a simple task more difficult?

AD

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

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




Re: Locale prefix

2012-10-22 Thread Vanja Dizdarević
Hvala Ivane! :D

The code helps a lot.

Subdomains were also my first impulse. But it is much easier for me to have 
it on the same domain for multiple reasons (security certificates, seo, 
cross-domain requests, practical urls, css/js/img caching, sessions, 
portability, etc).

Anyways, I'm currently at "modify the *.htaccess *rewrites and *App.base*". 
Any better ideas?

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

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