Re: HABTM (tags) - using a text input instead of a select.

2009-05-26 Thread Dan Soendergaard

Take a look the the Simple Tagging Behavior:
http://bakery.cakephp.org/articles/view/simple-tagging-behavior

On May 26, 6:49 pm, number9  wrote:
> It really isn't feasible to use a select input since a project I am
> working on is likely to produce a large amount of tags. I basically am
> looking to create something akin to wordpress where when a new "post"
> is created, there is a single text box where you can enter tags with
> comments. If they do not exist they are created at the same time.
>
> I have searched around for any help/information relating to this but
> haven't really found anything. Before I try and put something together
> myself if anybody knows of a "cake" way of doing this, or any links
> that could help it would be appreciated!
>
> 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 do you develop in (ide, text editor, etc.)?

2009-03-01 Thread Dan Soendergaard

Gedit :)

On Feb 28, 9:14 pm, adam  wrote:
> I'm using Eclipse with PDT, but Dreamweaver for making layouts.
--~--~-~--~~~---~--~~
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: Complex model relationship problems

2009-03-01 Thread Dan Soendergaard

The problem is completely different. I need to use $this->SpacesUser-
>find() get the Spaces which belong to a certain User (it's a HABTM
relationship), using $this->find() won't help. However, Cake confuses
itself and looks for the column parent_id in the table called
spaces_users although the model Space was set to act as a Tree. That
is the problem I'm trying to solve, sorry for confusing you :) I
simply want a nested tree (the array has "children") with the spaces
that are associated with a certain user through the SpacesUser model.

On Mar 1, 4:26 am, mscdex  wrote:
> On Feb 28, 6:10 pm, Dan Soendergaard  wrote:
>
> > No, the function is in my model so calling $this->Space->find();
> > results in Undefined property:  Space::$Space.
>
> Sorry, I had forgotten it was a model function and not in your
> controller. It should be $this->find() in the code I posted above,
> instead.
--~--~-~--~~~---~--~~
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: Complex model relationship problems

2009-02-28 Thread Dan Soendergaard

No, the function is in my model so calling $this->Space->find();
results in Undefined property:  Space::$Space.

The error isn't that strange, it happens because I removed the Space
from the fields so that 'Space.description' became 'description. Cake
thinks that 'name' is a model, which of course doesn't exist.

I've posted my full Space model at http://pastebin.com/m46f3797b with
some modifications. Right now I'm just testing using find('all'), but
changing 'all' to 'threaded' will show the error that I mentioned in
the first post. I also renamed the function and made some convenience
functions. Might as well work with the parts that I can get working :)

On Feb 28, 11:14 pm, mscdex  wrote:
> On Feb 28, 2:07 pm, Dan Soendergaard  wrote:
>
> > That doesn't help much, I've tried it and it gives errors like this:
>
> > Model "Space" is not associated with model "name" [CORE/cake/libs/
> > model/behaviors/containable.php, line 340]
>
> Strange error. Is this what you tried:
>
>         function get_structure($user = null) {
>                 $spaces = $this->Space->find('threaded', array(
>                                 'conditions' => array('User.id' =>
> $user),
>                                 'fields' => array('Space.name',
> 'Space.description', 'Space.created', 'Space.parent_id', 'Space.lft',
> 'Space.rght', 'User.id', 'User.username'),
>                                 'contain' => array(
>                                         'User', 'Document'
>                                 ),
>                                 'order' => array('Space.name')
>                         )
>                 );
>
>                 return array('spaces' => $spaces);
>         }
--~--~-~--~~~---~--~~
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: Complex model relationship problems

2009-02-28 Thread Dan Soendergaard

That doesn't help much, I've tried it and it gives errors like this:

Model "Space" is not associated with model "name" [CORE/cake/libs/
model/behaviors/containable.php, line 340]

for alle fields that I specified for Space.* in the contain options.
Also, an invalid query is now being created which gives the following
error:

SQL Error: 1054: Unknown column 'User.id' in 'where clause'

Any suggestions? :)

On Feb 28, 6:40 pm, mscdex  wrote:
> In get_structure(), have you tried changing: $this->SpacesUser->find()
> to $this->find() ? Then maybe also move the Space.* entries from
> 'contain' to the 'fields' array.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Complex model relationship problems

2009-02-28 Thread Dan Soendergaard

Hi bakers!

In my application I've got the concept of "Spaces" which are basically
directories. I also have User and Document models.

Space -> HABTM <- User (a user may have access to several spaces)
Space -> hasMany -> Document
Document -> HABTM <- User (a document can have several owners)

The HABTM relationships are set up according to the solution shown
here: 
http://www.cricava.com/blogs/index.php?blog=6&title=modelizing_habtm_join_tables_in_cakephp_&more=1&c=1&tb=1&pb=1

Space uses the Tree behavior and the spaces table is properly
configured to use it (lft, rght and parent_id columns). A Space
contains Documents, and both Space and Document can be created by a
User.

I've been trying for two days to try figuring out how to do this:

1. Get a tree of all rooms and documents that a specific user is
associated with
2. Do the same, but only for a sub-tree

This seems impossible to do because Cake thinks that it should look
for parent_id, lft, and rght in the table spaces_users when using the
following query:

$spaces = $this->SpacesUser->find('threaded', array(
'conditions' => array('User.id' => $user),
'contain' => array(
'User.id', 'User.username',
'Space.name', 'Space.description', 'Space.created',
'Space.parent_id', 'Space.lft', 'Space.rght',
'Document'
),
'order' => array('Space.name')
)
);

On the other hand, this is the only way I can think of that allows me
to get the spaces associated with the user. Cake gives the following
errors:

Model "SpacesUser" is not associated with model "Document" [CORE/cake/
libs/model/behaviors/containable.php, line 340]

Undefined index:  parent_id [CORE/cake/libs/model/model.php, line
2163]

Note that when setting find('threaded'), the tree is not properly
built. Cake still returns a flat list.

Here are my models:

 array(
'with' => 'SpacesUser'
)
);

var $hasMany = array(
'Document'
);

function get_structure($user = null) {
$spaces = $this->SpacesUser->find('threaded', array(
'conditions' => array('User.id' => $user),
'contain' => array(
'User.id', 'User.username',
'Space.name', 'Space.description', 
'Space.created',
'Space.parent_id', 'Space.lft', 
'Space.rght',
'Document'
),
'order' => array('Space.name')
)
);

return array('spaces' => $spaces);
}

}
?>

 array(
'with' => 'SpacesUser'
),
'Document' => array(
'with' => 'DocumentsUser'
)
);

}
?>

 array(
'with' => 'DocumentsUser'
)
);

}
?>





 array('Space.name' => 'asc')
);

function index() {
$this->set('spaces', $this->Space->get_structure(7));
}

}
?>

I hope that someone will be able to help :) Thanks in advance!

- Dan
--~--~-~--~~~---~--~~
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: Sortable AJAX list doesn't trigger update

2008-08-30 Thread Dan Soendergaard

> I think the problem is that you use $item['Item']['id'] for your item-
> IDs and not an incrementing number. But I am not sure, maybe it's only
> the format, you could try "item_" instead of "item-", you can also set
> the format as option with a regular expression.

Wow! I simply changed "item-" to "item_", and now it all works
perfectly! This should be documented far better in the Cookbook, or
people should be able to choose their own style.

Thanks a bunch, mate! :D
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Sortable AJAX list doesn't trigger update

2008-08-30 Thread Dan Soendergaard

Hi bakers!

I'm trying to create a list of div's which should be sortable by
drag'n'drop. The code can be seen here http://bin.cakephp.org/view/649090085

Basically, I'm using the Javascript and Ajax helpers, the libraries
are included in the layout,

---
echo $javascript->link(array('prototype', 'scriptaculous'));
---

and using some other functionality form the libraries (like the
remoteTimer for updating a div) works just fine, thus it cannot be the
security settings, my browser, or the Ajax helper.

Firebug doesn't show any requests being sent to the server when I drag
an item, and the Java Console doesn't show any errors... So, I'm
completely out of ideas of what the problem could be.

The HTML being sent to the browser looks like this 
http://bin.cakephp.org/view/389641311

Any help is appreciated :)

Sincerely,
Dan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: File upload

2008-08-20 Thread Dan Soendergaard

I've written this behavior which I typically use for file uploads.
It's short and pretty easy to use, maybe you'll find it useful. You
can set the directory in which the file should be saved by setting the
option "destination".

If you attact the behavior like this,
$this->YourController->Behaviors->attach('File', array('destination'
=> 'yourpath'));

you can construct the path from variables available to your
controller.


On 19 Aug., 22:18, bartez <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> I've scouted both here and the bakery etc and have had no success in
> finding the answer to my problem.
>
> I would like to upload an image and save it in a file system (not a
> database).
>
> I would like the structure to be as follows
>
> img
>     / items
>         / groups
>             /id
>                 /each individual image here
>
> I've done this before in normal php but I'm sure there must be a cake
> way!!
>
> Thanks for your help in advance.
>
> Alex
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Set root entry in Tree Behavior and fetch children?

2008-07-02 Thread Dan Soendergaard

Hah! It's not a problem at all, got it working using your sweet
TreeHelper ;) Amazing work, thanks!

On Jul 2, 4:09 pm, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
> That looks good, and you're right. However, I'm not an MPTT expert so
> it was obvious to use recursion. Now I'm heading towards a different
> problem since every ForumEntry belongsTo User, I get an array like
> this:http://bin.cakephp.org/view/723954878which is impossible to
> work with. Any good ideas?
>
> On Jul 2, 3:54 pm, AD7six <[EMAIL PROTECTED]> wrote:
>
> > On Jul 2, 11:49 am, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
>
> > > I'm doing a simple forum which should support nested replies. So, I
> > > decided to use the Tree Behavior.
>
> > > models/forum_entry.php
> > > -
> > >  > > class ForumEntry extends ForumAppModel {
>
> > >         var $name = 'ForumEntry';
> > >         var $displayField = 'subject';
> > >         var $actsAs = array('Tree', 'Containable');
> > >         var $belongsTo = array('User');
>
> > > }
>
> > > ?>
> > > -
>
> > > The tree in my database looks like this:
>
> > > - Testing
> > > --- ASubSubject
> > > -- ASubSubSubject
> > > - Another Subject
>
> > > How do I retrieve a node with parent_id = 0 (like "Testing" or
> > > "Another Subject") and all of its children while preserving the tree
> > > structure?
>
> > > Using $this->ForumEntry->children($id) flattens the tree structure..
>
> > What's the point of using the tree behavior, and expecting it to give
> > you recursive data.
>
> >http://bakery.cakephp.org/articles/view/tree-helper-1
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Set root entry in Tree Behavior and fetch children?

2008-07-02 Thread Dan Soendergaard

That looks good, and you're right. However, I'm not an MPTT expert so
it was obvious to use recursion. Now I'm heading towards a different
problem since every ForumEntry belongsTo User, I get an array like
this: http://bin.cakephp.org/view/723954878 which is impossible to
work with. Any good ideas?

On Jul 2, 3:54 pm, AD7six <[EMAIL PROTECTED]> wrote:
> On Jul 2, 11:49 am, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm doing a simple forum which should support nested replies. So, I
> > decided to use the Tree Behavior.
>
> > models/forum_entry.php
> > -
> >  > class ForumEntry extends ForumAppModel {
>
> >         var $name = 'ForumEntry';
> >         var $displayField = 'subject';
> >         var $actsAs = array('Tree', 'Containable');
> >         var $belongsTo = array('User');
>
> > }
>
> > ?>
> > -
>
> > The tree in my database looks like this:
>
> > - Testing
> > --- ASubSubject
> > -- ASubSubSubject
> > - Another Subject
>
> > How do I retrieve a node with parent_id = 0 (like "Testing" or
> > "Another Subject") and all of its children while preserving the tree
> > structure?
>
> > Using $this->ForumEntry->children($id) flattens the tree structure..
>
> What's the point of using the tree behavior, and expecting it to give
> you recursive data.
>
> http://bakery.cakephp.org/articles/view/tree-helper-1
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Set root entry in Tree Behavior and fetch children?

2008-07-02 Thread Dan Soendergaard

When I couldn't figure it out I started reading this article (http://
www.sitepoint.com/print/hierarchical-data-database) about MTPP trees.
I was quite surprised to find that it's really quite simple. I then
wanted to write the solution here, but looks like you came first :D
Well, thank you for your help, it's greatly appreciated!

On Jul 2, 2:18 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
> And put this in your ForumEntry model.
>
> var $order = 'ForumEntry.lft ASC';
>
> On Jul 2, 9:00 pm, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
>
> > Tried that already, it doesn't allow for setting a root node. Also,
> > it's deprecated (it's recommended to use Model::find('threaded')
> > instead).
>
> > On Jul 2, 12:47 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > > Try a $this->ForumEntry->findAllThreaded() call. It's part of the
> > > Model class.
>
> > > Cheers,
> > > Adam
>
> > > On Jul 2, 7:49 pm, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
>
> > > > I'm doing a simple forum which should support nested replies. So, I
> > > > decided to use the Tree Behavior.
>
> > > > models/forum_entry.php
> > > > -
> > > >  > > > class ForumEntry extends ForumAppModel {
>
> > > >         var $name = 'ForumEntry';
> > > >         var $displayField = 'subject';
> > > >         var $actsAs = array('Tree', 'Containable');
> > > >         var $belongsTo = array('User');
>
> > > > }
>
> > > > ?>
> > > > -
>
> > > > The tree in my database looks like this:
>
> > > > - Testing
> > > > --- ASubSubject
> > > > -- ASubSubSubject
> > > > - Another Subject
>
> > > > How do I retrieve a node with parent_id = 0 (like "Testing" or
> > > > "Another Subject") and all of its children while preserving the tree
> > > > structure?
>
> > > > Using $this->ForumEntry->children($id) flattens the tree structure to
> > > > this:
>
> > > > -
> > > > Array
> > > > (
> > > >     [0] => Array
> > > >         (
> > > >             [ForumEntry] => Array
> > > >                 (
> > > >                     [id] => 5
> > > >                     [parent_id] => 4
> > > >                     [lft] => 2
> > > >                     [rght] => 5
> > > >                     [user_id] => 1
> > > >                     [subject] => ASubSubject
> > > >                     [body] =>
> > > >                     [created] => 2008-07-01 22:58:56
> > > >                     [modified] => 2008-07-01 22:58:56
> > > >                 )
>
> > > >         )
>
> > > >     [1] => Array
> > > >         (
> > > >             [ForumEntry] => Array
> > > >                 (
> > > >                     [id] => 6
> > > >                     [parent_id] => 5
> > > >                     [lft] => 3
> > > >                     [rght] => 4
> > > >                     [user_id] => 1
> > > >                     [subject] => ASubSubSubject
> > > >                     [body] =>
> > > >                     [created] => 2008-07-01 23:16:52
> > > >                     [modified] => 2008-07-01 23:16:52
> > > >                 )
>
> > > >         )
>
> > > > )
> > > > -
>
> > > > Suggestions are very much appreciated :) Been wasting a whole day on
> > > > this issue now.
>
> > > > Thanks in advance!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Set root entry in Tree Behavior and fetch children?

2008-07-02 Thread Dan Soendergaard

Tried that already, it doesn't allow for setting a root node. Also,
it's deprecated (it's recommended to use Model::find('threaded')
instead).

On Jul 2, 12:47 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
> Try a $this->ForumEntry->findAllThreaded() call. It's part of the
> Model class.
>
> Cheers,
> Adam
>
> On Jul 2, 7:49 pm, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
>
> > I'm doing a simple forum which should support nested replies. So, I
> > decided to use the Tree Behavior.
>
> > models/forum_entry.php
> > -
> >  > class ForumEntry extends ForumAppModel {
>
> >         var $name = 'ForumEntry';
> >         var $displayField = 'subject';
> >         var $actsAs = array('Tree', 'Containable');
> >         var $belongsTo = array('User');
>
> > }
>
> > ?>
> > -
>
> > The tree in my database looks like this:
>
> > - Testing
> > --- ASubSubject
> > -- ASubSubSubject
> > - Another Subject
>
> > How do I retrieve a node with parent_id = 0 (like "Testing" or
> > "Another Subject") and all of its children while preserving the tree
> > structure?
>
> > Using $this->ForumEntry->children($id) flattens the tree structure to
> > this:
>
> > -
> > Array
> > (
> >     [0] => Array
> >         (
> >             [ForumEntry] => Array
> >                 (
> >                     [id] => 5
> >                     [parent_id] => 4
> >                     [lft] => 2
> >                     [rght] => 5
> >                     [user_id] => 1
> >                     [subject] => ASubSubject
> >                     [body] =>
> >                     [created] => 2008-07-01 22:58:56
> >                     [modified] => 2008-07-01 22:58:56
> >                 )
>
> >         )
>
> >     [1] => Array
> >         (
> >             [ForumEntry] => Array
> >                 (
> >                     [id] => 6
> >                     [parent_id] => 5
> >                     [lft] => 3
> >                     [rght] => 4
> >                     [user_id] => 1
> >                     [subject] => ASubSubSubject
> >                     [body] =>
> >                     [created] => 2008-07-01 23:16:52
> >                     [modified] => 2008-07-01 23:16:52
> >                 )
>
> >         )
>
> > )
> > -
>
> > Suggestions are very much appreciated :) Been wasting a whole day on
> > this issue now.
>
> > Thanks in advance!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Set root entry in Tree Behavior and fetch children?

2008-07-02 Thread Dan Soendergaard

I'm doing a simple forum which should support nested replies. So, I
decided to use the Tree Behavior.

models/forum_entry.php
-

-

The tree in my database looks like this:

- Testing
--- ASubSubject
-- ASubSubSubject
- Another Subject

How do I retrieve a node with parent_id = 0 (like "Testing" or
"Another Subject") and all of its children while preserving the tree
structure?

Using $this->ForumEntry->children($id) flattens the tree structure to
this:

-
Array
(
[0] => Array
(
[ForumEntry] => Array
(
[id] => 5
[parent_id] => 4
[lft] => 2
[rght] => 5
[user_id] => 1
[subject] => ASubSubject
[body] =>
[created] => 2008-07-01 22:58:56
[modified] => 2008-07-01 22:58:56
)

)

[1] => Array
(
[ForumEntry] => Array
(
[id] => 6
[parent_id] => 5
[lft] => 3
[rght] => 4
[user_id] => 1
[subject] => ASubSubSubject
[body] =>
[created] => 2008-07-01 23:16:52
[modified] => 2008-07-01 23:16:52
)

)

)
-

Suggestions are very much appreciated :) Been wasting a whole day on
this issue now.

Thanks in advance!

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



Blank line at beginning of RSS feed

2008-06-12 Thread Dan Soendergaard

Hi,

I followed http://book.cakephp.org/view/483/creating-an-rss-feed-with-the-
to create an RSS project for my app (Cake 1.2 RC1, rev. 7089).
Debugging is turned off. Going to http://example.com/projects/index.rss
causes Firefox to download the RSS feed instead of showing it the
usual way. Also, when validating the feed results in this:

This feed does not validate.
  line 1, column 0: XML parsing error: :2:0: xml
declaration not at start of external entity

Apparently the first line of the file is blank which messes everything
up. I've tried moving all echo statements to the same line as the https://trac.cakephp.org/ticket/2761 but it should be solved a
long time ago :)

Suggestions are welcome!

Sincerely,
Dan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth Component not working using PagesController

2008-05-30 Thread Dan Soendergaard

Thanks! So simple, I don't believe it... But it works :)

On 29 Maj, 23:47, francky06l <[EMAIL PROTECTED]> wrote:
> Did you copy the PagesController in your application ? If so, create
> the beforeFilter and call parent::beforeFiler ..
> hth
>
> On May 29, 10:47 pm, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
>
> > Hi everybody,
>
> > I use the AuthComponent on my site for authentication. I've specified
> > all of the things that it needs to know in the app_controller.php,
> > where I also set a variable, $user, which contains the object of the
> > current user. I use this for showing custom menus, log out links etc.
>
> > However, I'm also using the built-in PagesController to show static
> > pages on the site. But apparently the $user variable isn't set when
> > viewing pages. I tried adding the AuthComponent directly to the
> > PagesController, allowing all pages, and setting the $user variable
> > directly in the PagesController also. Still, menus and links don't
> > show up.
>
> > Any suggestions here? This is the code for app_controller.php,
>
> >  > class AppController extends Controller
> > {
> >         var $helpers = array( 'Html', 'Javascript', 'Form' );
> >         var $components = array( 'Auth' );
>
> >         function beforeFilter()
> >         {
> >                 Security::setHash('sha1');
>
> >                 $this->Auth->loginAction = '/users/login';
> >                 $this->Auth->loginRedirect = array('controller' => 'events',
> > 'action' => 'index');
> >                 $this->Auth->logoutRedirect = '/events/index';
> >                 $this->Auth->loginError = __('Wrong username or password.', 
> > true);
> >                 $this->Auth->authError = __('You have to log in to access 
> > this
> > page.', true);
> >                 $this->Auth->authorize = 'controller';
> >                 $this->Auth->deny('*');
>
> >                 if ($this->Auth->user())
> >                 {
> >                         $this->set('user', $this->Auth->user());
> >                 }
> >                 else
> >                 {
> >                         $this->set('user', null);
> >                 }
> >         }
>
> >         public function isAuthorized()
> >         {
> >                 return true;
> >         }}
>
> > ?>
>
> > Thanks in advance :)
>
> > - Dan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Auth Component not working using PagesController

2008-05-29 Thread Dan Soendergaard

Hi everybody,

I use the AuthComponent on my site for authentication. I've specified
all of the things that it needs to know in the app_controller.php,
where I also set a variable, $user, which contains the object of the
current user. I use this for showing custom menus, log out links etc.

However, I'm also using the built-in PagesController to show static
pages on the site. But apparently the $user variable isn't set when
viewing pages. I tried adding the AuthComponent directly to the
PagesController, allowing all pages, and setting the $user variable
directly in the PagesController also. Still, menus and links don't
show up.

Any suggestions here? This is the code for app_controller.php,

Auth->loginAction = '/users/login';
$this->Auth->loginRedirect = array('controller' => 'events',
'action' => 'index');
$this->Auth->logoutRedirect = '/events/index';
$this->Auth->loginError = __('Wrong username or password.', 
true);
$this->Auth->authError = __('You have to log in to access this
page.', true);
$this->Auth->authorize = 'controller';
$this->Auth->deny('*');

if ($this->Auth->user())
{
$this->set('user', $this->Auth->user());
}
else
{
$this->set('user', null);
}
}

public function isAuthorized()
{
return true;
}
}
?>

Thanks in advance :)

- Dan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Strange error about config/core.php

2008-05-21 Thread Dan Soendergaard
Turned off safe mode and now it's working. :)

On 21 Maj, 16:56, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I changed a couple of methods in one of my controllers and suddenly
> receive the following error,
>
> Warning: Configure::include() [configure.include]: Unable to access /
> home/www/sporter.dk/config/core.php in /home/www/sporter.dk/cake/libs/
> configure.php on line 609
>
> Warning (2): Configure::include() [configure.include]: Unable to
> access /home/www/sporter.dk/config/bootstrap.php [CORE/cake/libs/
> configure.php, line 613]
>
> The odd thing is that it worked without any problems just hours ago.
>
> Here's the method I changed in my controller:
>
>         function matches()
>         {
>                 $this->layout = 'empty';
>                 Configure::load('notifications');
>
>                 $difference = time() - Configure::read('Notification.last');
>                 $diff = 85400;
>                 if ($difference > 86400)
>                 {
>                         $groups = $this->Activity->query(
>                                         'SELECT DISTINCT `User`.`zip`,
>                                         `Activity`.`id`,
>                                         `Activity`.`name`,
>                                         COUNT(`User`.`id`) AS user_count
>                                         FROM `users` User, `activities` 
> Activity
>                                         WHERE `User`.`activity_id` = 
> `Activity`.`id`
>                                         GROUP BY `User`.`zip`
>                                         HAVING `user_count` > 3'
>                                 );
>
>                         foreach ($groups as $group)
>                         {
>                                 $users = $this->User->find(
>                                         'all',
>                                         array(
>                                                 'conditions' => array(
>                                                         'User.activity_id' => 
> $group['Activity']['id'],
>                                                         'User.zip' => 
> $group['User']['zip']
>                                                 ),
>                                                 'fields' => 
> array('Activity.name', 'User.fullname',
> 'User.email'),
>                                                 'recursive' => 1
>                                         )
>                                 );
>
>                                 foreach ($users as $user)
>                                 {
>                                         $this->mailMatch($user);
>                                 }
>                         }
>
>                         Configure::write('Notification.last', time());
>                 }
>         }
>
>         private function mailMatch($data)
>         {
>                 $this->Email->to = $data['User']['email'];
>
>                 $this->Email->subject =
>                         __(sprintf('A group has been formed for %s in your 
> area!',
>                                 strtolower($data['Activity']['name'])), true
>                         );
>
>                 $this->Email->replyTo = '[EMAIL PROTECTED]';
>                 $this->Email->from = 'sporter <[EMAIL PROTECTED]>';
>                 $this->Email->template = 'match';
>
>                 $this->set('user', $data);
>
>                 $this->Email->send();
>         }
>
> What's even more strange is that, while CakePHP is looking for /home/
> www/sporter.dk/config/core.php the core.php file is really in /home/
> www/sporter.dk/app/config/core.php
>
> I've tried reuploading the complete site. All permissions are as they
> should be.
>
> I appreciate any help :)
> Thanks in advance!
>
> - Dan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Strange error about config/core.php

2008-05-21 Thread Dan Soendergaard

Hi,

I changed a couple of methods in one of my controllers and suddenly
receive the following error,

Warning: Configure::include() [configure.include]: Unable to access /
home/www/sporter.dk/config/core.php in /home/www/sporter.dk/cake/libs/
configure.php on line 609

Warning (2): Configure::include() [configure.include]: Unable to
access /home/www/sporter.dk/config/bootstrap.php [CORE/cake/libs/
configure.php, line 613]

The odd thing is that it worked without any problems just hours ago.

Here's the method I changed in my controller:

function matches()
{
$this->layout = 'empty';
Configure::load('notifications');

$difference = time() - Configure::read('Notification.last');
$diff = 85400;
if ($difference > 86400)
{
$groups = $this->Activity->query(
'SELECT DISTINCT `User`.`zip`,
`Activity`.`id`,
`Activity`.`name`,
COUNT(`User`.`id`) AS user_count
FROM `users` User, `activities` Activity
WHERE `User`.`activity_id` = 
`Activity`.`id`
GROUP BY `User`.`zip`
HAVING `user_count` > 3'
);

foreach ($groups as $group)
{
$users = $this->User->find(
'all',
array(
'conditions' => array(
'User.activity_id' => 
$group['Activity']['id'],
'User.zip' => 
$group['User']['zip']
),
'fields' => 
array('Activity.name', 'User.fullname',
'User.email'),
'recursive' => 1
)
);

foreach ($users as $user)
{
$this->mailMatch($user);
}
}

Configure::write('Notification.last', time());
}
}

private function mailMatch($data)
{
$this->Email->to = $data['User']['email'];

$this->Email->subject =
__(sprintf('A group has been formed for %s in your 
area!',
strtolower($data['Activity']['name'])), true
);

$this->Email->replyTo = '[EMAIL PROTECTED]';
$this->Email->from = 'sporter <[EMAIL PROTECTED]>';
$this->Email->template = 'match';

$this->set('user', $data);

$this->Email->send();
}

What's even more strange is that, while CakePHP is looking for /home/
www/sporter.dk/config/core.php the core.php file is really in /home/
www/sporter.dk/app/config/core.php

I've tried reuploading the complete site. All permissions are as they
should be.

I appreciate any help :)
Thanks in advance!

- Dan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Finding popular activities

2008-05-20 Thread Dan Soendergaard

Thank you so much! I'm still not entirely sure about how it works, but
I'll be reading up on bindModel :)
I've taken a look at counterCache and yes, it looks much easier. I'll
consider using it instead.

Again - thanks!

On 20 Maj, 15:41, grigri <[EMAIL PROTECTED]> wrote:
> $this->Activity->bindModel(array(
>   'hasOne' => array(
>     'TotalUsers' => array(
>       'className' => 'User',
>       'fields' => 'COUNT(TotalUsers.id) AS num_users'
>     )
>   )
> );
> $popularActivities = $this->Activity->find('all', array(
>   'conditions' => '1=1 GROUP BY Activity.id HAVING num_users > 0',
>   'order' => 'num_users DESC',
>   'limit' => 10,
>   'recursive' => 0
> ));
>
> Will find the 10 most popular activites, most popular first.
> Activities with no users are not returned.
>
> Also, look into counterCache - it will make this much easier for you.
>
> On May 20, 2:26 pm, Dan Soendergaard <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > My app contains a User model and an Activity model. A User belongsTo
> > an Activity. The foreign key is activity_id.
> > Now, I want to make a list of popular activities where popularity is
> > measured by how many users are signed up for it. I'm not sure how to
> > do this. Can I use $this->Activity->find()? If yes, how do I tell it
> > that I want the count of users for each activity?
>
> > Thanks in advance :)
>
> > Sincerely,
> > Dan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Finding popular activities

2008-05-20 Thread Dan Soendergaard

Hi,

My app contains a User model and an Activity model. A User belongsTo
an Activity. The foreign key is activity_id.
Now, I want to make a list of popular activities where popularity is
measured by how many users are signed up for it. I'm not sure how to
do this. Can I use $this->Activity->find()? If yes, how do I tell it
that I want the count of users for each activity?

Thanks in advance :)

Sincerely,
Dan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Class diagram (MVC)

2008-05-17 Thread Dan Soendergaard

Maybe this is what you're looking for? 
http://bakery.cakephp.org/articles/view/visualize-schema-task

On May 17, 5:16 pm, dandreta <[EMAIL PROTECTED]> wrote:
> Then, to seeing if I have understood it well. For my example, I have
> two classes:
> ---
> PersonsController
> {attributes}
> -model:Person
> {methods}
> +insertPerson(name,age,sex):void
> +obtListPersons():Person[]
> ---
> y
> 
> PersonModel
> {attributes}
> -id:int
> -name:String
> -age:int
> -sex:String
> {methods}
> +Person(id,name,age,sex):Person
> +obtListPersons():Person[]
> 
> Would it be like that?
> It is strange for me that in the class ModeloPersona, has the builder
> method of the class (+Person (id, name, age,sex):Person) and also the
> method that returns all of the persons (+obtListPersons ():Person [])
> because inside of a class only it must be its builder and the methods
> that obtain or modify its attributes (for example: +obtname():String
> and +setname (name:String):void). Or I am wrong?
>
> I hope that you can solve to me these doubts.
>
> On 16 mayo, 23:06, "Juan Miguel Paredes" <[EMAIL PROTECTED]>
> wrote:
>
> > On Sat, May 17, 2008 at 4:28 PM, Howard Glynn <[EMAIL PROTECTED]> wrote:
> > > Perhaps this is what you are looking for
>
> > >http://cakeexplorer.wordpress.com/2007/12/14/build-image-of-current-c...
> > >http://cakeexplorer.files.wordpress.com/2007/12/model_bakery.png
>
> > > Not tried it myself, filed on my list of things to do...
>
> > It will definitely be a good start, but the script would need to be
> > modified to draw the associations between controllers and models, as
> > well, if I understood the op's question correctly
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Publishing iCal calendars with Cake

2008-05-17 Thread Dan Soendergaard

Hi!

A school project of mine, written in Cake, contains a list of events.
So far the events are accessible as RSS feeds and on the web-site,
however, I thought that it would be cool to implement iCal output.

First, I tried to do it using RequestHandler (which I had just learned
to use yesterday), but it doesn't look like it supports iCal output.
So, I defined a layout,

--


BEGIN:VCALENDAR

VERSION:2.0

X-WR-CALNAME:HTXEvent

X-WR-TIMEZONE:Europe/Copenhagen

CALSCALE:GREGORIAN

METHOD:PUBLISH



END:VCALENDAR

--

I then made a calendar.ctp view,

--


BEGIN:VEVENT

DTSTART;VALUE=DATE:

DTEND;VALUE=DATE:

SUMMARY:



END:VEVENT



--

And defined the calendar function in my EventsController,

--
function calendar()
{
$this->layout = 'ical';

$events = $this->paginate();

if (isset($this->params['requested']))
{
return $events;
}

$this->set('events', $events);
}
--

The whole thing is very basic, reminds a lot of the old way of doing
RSS. However, would be cool if this could be implemented using
RequestAction, so do you guys have any suggestions to how that would
be done? Otherwise I'll let this act mail as a tutorial :)

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



Re: How do I link comments to a post?

2007-08-04 Thread Dan Soendergaard

Oops..! This: "I still can't find out if there's a official
way of naming tables and columns in the DB"

should have been

"I still can't find out if there's a official
way of naming columns in the DB".

I know models are dependant on the table names :)


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



Re: How do I link comments to a post?

2007-08-04 Thread Dan Soendergaard

> And yep it is that easy :)

While I waited for your answer to my second post, I figured it all out
and added basic user authentication to my blog. Could never have done
it that fast without cake!

> As for the error - when you turned debug on up to 2 do you get a Controller
> missing action or something like that?

No, it was a SQL error. I still can't find out if there's a official
way of naming tables and columns in the DB. I used 'post_id' but Cake
wanted 'id'. But now everything is okay :)

Again, thanks a lot!

Dan


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



Re: How do I link comments to a post?

2007-08-03 Thread Dan Soendergaard

> This usually indicates that either mod_rewrite is not working or you
> have fiddled with your paths in config/core.php

mod_rewrite is working as far as I can see. Also, since I can navigate
to /posts/ without any problem, there must be some other cause. Oh, I
sorted it out by turning on debugging. There was a couple of errors
with the database query which made it go wrong.

> Post hasMany Comments
> $data = $this->Post->read($postId);

The first line goes into the Post model and the second line goes into
the Post view, right?
If it really is that easy I'm never going to code plain PHP again!

Thanks a lot,

Dan


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



How do I link comments to a post?

2007-08-02 Thread Dan Soendergaard

Hi bakers!

I have just recently begun using CakePHP, and I'm already convinced
that's it's great! As my first project I followed the CakePHP Blog
tutorial in the Manual. It works just fine, but I'd like to also add
comments to my "blog". I've searched for a tutorial or tip on how to
do this, but have so far been unable to find anything useful.

As a start I added a 'comments' table to my database. Each comment has
an id, author, content and post-id. I also created views for index,
add and view (although I'd only need index and add, right?). I then
created comments_controller.php and my comment model.

It all looks all right but when I browse http://mydomain.com/cake/comments/
I get a:

Not found
The requested address was not found on this server.

So first question is, why?

When I can view comments, how do I link them to a post? Usually, I
would write a query like this:

SELECT author, content, date FROM comments WHERE post = $post_id

After reading some more documentation I found out that I could do this
in my comments_controller.php:

function index($id)
{
   $this->set('comments', $this->Comment->findAll('post = ' . $id));
}

But... because of my first problem I can't really check the result. Am
I in the right direction?

Thanks in advance!


Regards,

Dan


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