CRUD behavior

2010-11-18 Thread Unite
Hi.

I have set up the cake ACL component (as per the book tutorial) and it
works 100% when individual permissions are not set.

Example:
ARO = User/username (User = ARO group, username = ARO user)
ACO = controllers/Users/index (controllers = ACO global controller,
Users = Users  controller, index = function or action)

Permission for above in aros_acos table 1,1,1,1 and -1,-1,-1,-1 works.
Allows or denys access to index via that user correctly.  (inheriting
from thier parents working properly aswell)

If I set the permissions for index for the user (or group) to 1,1,1,-1
(allow all accept delete or any other combination) the  ACL fails and
it works exactly the same as deny all (-1,-1,-1,-1).

my beforeFilter in apps controller looks like the following below

function beforeFilter() {
//Configure AuthComponent
$this->Auth->userModel = 'emailuser';
$this->Auth->authorize = 'actions';
$this->Auth->loginAction = array('controller' => 'emailusers',
'action' => 'login');
$this->Auth->logoutRedirect = array('controller' =>
'emailusers', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' =>
'emailusers', 'action' => 'index');
$this->Auth->allowedActions =
array('display','register','ajax_register', 'login', 'logout',
'group');
$this->Auth->actionPath = 'controllers/';
 }

Anyone got any suggestions?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


A help with HABTM relations

2010-11-18 Thread Synue Cunioci
Here is the thing. I have a table called tags, that has all the tags
that I'm going to associate with other tables in my database.

In the end I have the tables bellow for the HABTM relations:

activities_tags 112
cdocs_tags 11
clippings_tags 112
courses_tags 112
events_tags 112
informatives_tags 112
institutionals_tags 112
projects_tags 11
targets_tags 112

What I wish to have a function that recieves the id of a tag and query
the database for the first 2 results of all relations ordered by the
field created. Then I wish to group and ordered all results by field
created like if they were from the same table. So what I expect is to
have an array like bellow.

I don't know if i made myself clear but just note that the array is
ordered from 0 - 17 by the created field of each registry, and they
are not from the same table.

Thanks in advance. Hope someone can help me with this logical issue.

Array (
[0] => Array
(
[Activity] => Array
(
[id] => 4
[title] => atividade 03
[text] => atividade 03
[url_opening_photo_large] => atividades/
abertura03.jpg
[url_opening_photo_small] => eventos/
evento_lista03.png
[administrator_id] => 1
[url_content_photo] =>
[created] => 2010-11-18 15:00:21
[modified] => 2010-11-18 15:00:21
)
)
[1] => Array
(
[Cdoc] => Array
(
[id] => 7
[title] => atividade 07
[text] => atividade 07
[url_opening_photo_large] => atividades/
abertura07.jpg
[url_opening_photo_small] => eventos/
evento_lista07.png
[administrator_id] => 1
[url_content_photo] =>
[created] => 2010-11-18 14:10:21
[modified] => 2010-11-18 14:10:21
)
)
[2] => Array
(
[Informative] => Array
(
[id] => 4
[title] => atividade 03
[text] => atividade 03
[url_opening_photo_large] => atividades/
abertura03.jpg
[url_opening_photo_small] => eventos/
evento_lista03.png
[administrator_id] => 1
[url_content_photo] =>
[created] => 2010-11-17 15:00:21
[modified] => 2010-11-17 15:00:21
)
)
[3] => Array
(
[Project] => Array
(
[id] => 4
[title] => atividade 03
[text] => atividade 03
[url_opening_photo_large] => atividades/
abertura03.jpg
[url_opening_photo_small] => eventos/
evento_lista03.png
[administrator_id] => 1
[url_content_photo] =>
[created] => 2010-11-16 15:00:21
[modified] => 2010-11-16 15:00:21
)
)
[4] => Array
(
[Course] => Array
(
[id] => 4
[title] => atividade 03
[text] => atividade 03
[url_opening_photo_large] => atividades/
abertura03.jpg
[url_opening_photo_small] => eventos/
evento_lista03.png
[administrator_id] => 1
[url_content_photo] =>
[created] => 2010-11-15 15:00:21
[modified] => 2010-11-15 15:00:21
)
)
[5] => Array
(
[Target] => Array
(
[id] => 4
[title] => atividade 03
[text] => atividade 03
[url_opening_photo_large] => atividades/
abertura03.jpg
[url_opening_photo_small] => eventos/
evento_lista03.png
[administrator_id] => 1
[url_content_photo] =>
[created] => 2010-11-14 15:00:21
[modified] => 2010-11-14 15:00:21
)
)
[6] => Array
(
[Institutional] => Array
(
[id] => 4
[title] => atividade 03
[text] => atividade 03
[url_opening_photo_large] => atividades/
abertura03.jpg
[url_opening_photo_small] => eventos/
evento_lista03.png
[administrator_id] => 1
[url_content_photo] =>
[created] => 2010-11-13 15:00:21
[modified] => 2010-11-13 15:00:21
)
)
[7] => Array
(
[Clipping] => Array
(
[id] => 

Re: Baffling blank screen problem

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 5:09 PM, Jules  wrote:
> If I don't have debugging enabled, the site works, then fails after a
> few hours with a blank screen.
>
> If I have debugging enabled, the site works (and continues to work).
>
> On Nov 17, 9:27 pm, Toby G  wrote:
>> Can you clarify... Do you have debugging enabled?  Is it actually a
>> blank screen, or just falling over, but not displaying the error?

Do you have caching enabled? If so, what is the period?

Fatal errors when debug is disabled--but not when it's enabled--could
be caused by calls to the Debugger class in your code. Do you have
any?

In any case, have you looked at the server's log(s)?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Console bake - modify templates

2010-11-18 Thread euromark
answers and examples:
http://www.dereuromark.de/2010/06/22/cake-bake-custom-templates/

feel free to point out any missing pieces :)

for separating admin views from normal ones a ticket has been
submitted
as of now i don't know how to do that.

On 19 Nov., 01:04, Sarpidon  wrote:
> Hi! I am trying to modify the templates files to generate custom
> applications (with my css, actions etc)
> However I am not sure how to find specific data passed to the template
> files... for example take console/templates/default/views/index.ctp
>
> in there I want to be able to read the type of field (eg is it
> datetime? is it tinyint and so on). Where can I find this information?
> Where can I find what the $fields array holds or the $details array
> holds and so on... I hope I am making sense :)
>
> The same goes for other files like controller_actions (for example how
> do I separate admin views (admin_index) from normal ones...

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Router problem on android phone

2010-11-18 Thread twinkletoes
I'm seeing some very odd, Router-related behavior when accessing the
site I'm currently developing on my Android phone (Samsung Galaxy S GT-
I9000).

I'm on Cake version 1.3.4.

I've put this line in routes.php:

Router::connect('/', array('controller' => 'homepages', 'action' =>
'view'));

That's the only route I have in there, and in all desktop browsers
I've tested (Firefox, Opera, IE, Chrome, Safari), it works as
expected: the view action of the homepages controller is displayed
when accessing the plain domain root (www.domainname.com).

When I access it with the default web client on my Samsung Galaxy,
however, I get an error message:

"Error: Http:Controller could not be found

Error: Create the class Http:controller below in file app/controllers/
http:controller.php"

...and so on.

If I try to use Opera Mini to access the exact same URL from the exact
same phone, this error message doesn't appear. So I assume the
standard web client is somehow requesting the page differently, which
in turn gets misinterpreted by Cake's routing.

Also, if I access the controller and action by its full, unrouted URL,
everything pops up as it should.

Anyone heard of this problem before, or have any idea about what might
be the problem? Is it fixable?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Console bake - modify templates

2010-11-18 Thread Sarpidon
Hi! I am trying to modify the templates files to generate custom
applications (with my css, actions etc)
However I am not sure how to find specific data passed to the template
files... for example take console/templates/default/views/index.ctp

in there I want to be able to read the type of field (eg is it
datetime? is it tinyint and so on). Where can I find this information?
Where can I find what the $fields array holds or the $details array
holds and so on... I hope I am making sense :)

The same goes for other files like controller_actions (for example how
do I separate admin views (admin_index) from normal ones...

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Baffling blank screen problem

2010-11-18 Thread Jules
If I don't have debugging enabled, the site works, then fails after a
few hours with a blank screen.

If I have debugging enabled, the site works (and continues to work).

On Nov 17, 9:27 pm, Toby G  wrote:
> Can you clarify... Do you have debugging enabled?  Is it actually a
> blank screen, or just falling over, but not displaying the error?
>
> Toby
>
> On Nov 17, 1:00 am, Jules  wrote:
>
>
>
>
>
>
>
> > I have a new CakePHP installation I'm fiddling around with. I've built
> > a reasonably sophisticated CakePHP app before, so I like to think I
> > know my way around CakePHP, but am by no means an expert.
>
> > On my new installation, my test page (/pages/home) works fine. If I
> > come back after a few hours and refresh, I get a blank page. There is
> > no HTML being served at all. All other pages are the same. If I enable
> > debugging then refresh, the page loads. Then I disable debugging, and
> > the page *still* loads. But a couple of hours later, the whole thing
> > happens again.
>
> > This problem occurs in any web browser, so I'm fairly sure it's a
> > server-side problem.
>
> > I'm not sure how to debug this problem. Any suggestions?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: cakephp + jquery help

2010-11-18 Thread Dan
Simply include your *.js in the layout - $html->script('name_here') -
and you're done for the jQuery stuff.

The other thing would be to create an ajax layout and assign it to the
proper controller function:

function something(){
   var $layout = 'my_ajax_layout.ctp';
}

The layouts are in the apps/layouts/ folder. You can simply duplicate
default.ctp and name it ajax.ctp. My ajax layout file only has one
line: 

HTH!

On Nov 18, 3:12 pm, cricket  wrote:
> On Thu, Nov 18, 2010 at 6:42 AM, jd  wrote:
> > Hi All
>
> > Excuse the beginners question but...
>
> > I want to learn how to use jquery with cake. I presume that I should
> > use the JS helper. Apart from the docs at book.cakephp.org and
> > api.cakephp.org, are there any good sources of info for a beginner? I
> > have found lots of articles through Google, but they are a little over
> > my head. I have a good understanding of JavaScript and Ajax, but I am
> > relatively new to jquery.
>
> You don't have to use the helper. I never have.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: cakephp + jquery help

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 6:42 AM, jd  wrote:
> Hi All
>
> Excuse the beginners question but...
>
> I want to learn how to use jquery with cake. I presume that I should
> use the JS helper. Apart from the docs at book.cakephp.org and
> api.cakephp.org, are there any good sources of info for a beginner? I
> have found lots of articles through Google, but they are a little over
> my head. I have a good understanding of JavaScript and Ajax, but I am
> relatively new to jquery.

You don't have to use the helper. I never have.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Allowing edit/delete to writers.

2010-11-18 Thread cricket
2010/11/18 János Vasbányai :
> Hi!
> I'm building a blog app. This is my first CakeProject.
> I have 3 user groups:
> -users (only allowed to add comments to articles)
> -writers (allowed to write articles)
> -admins (everything)
>
> My question are:
> How to allow writers to edit/delete thier articles only?
> Is there a way to tell cake to match action names to groups? (i mean
> ADMIN_index allow to  ADMINs)
>
> I'm using $this->Auth->authorize = 'actions' as i have aros and acos.
> Thanx

I just mentioned something similar in another thread, actually. Have a
look at "Model data array: how to examine which model it comes from?".
It doesn't require ACL, though.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Controller not called

2010-11-18 Thread cricket
On Wed, Nov 17, 2010 at 3:16 PM, Xavier  wrote:
> Hi,
> I just started working with Cakephp. When I call http://localhost/Items
> I get the default page with an Error as page's title and no error or
> warning. Any Ideas or pointers?
>
>
> APP\controllers\items_controller.php
> 
> class ItemsController extends AppController {
>        var $name = 'Items';
>
>        function index() {
>
>               echo "we enter the controller";
>               $this->pageTitle = 'Novatem';
>               $this->layout = 'default';
>    }
>
> }

Do you have debug set to > 0?

Also, you shouldn't echo from inside a controller method unless that's
the only thing you're sending to the client (eg an AJAX response).

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Model data array: how to examine which model it comes from?

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 1:17 PM, Joshua Muheim  wrote:
> Thanks for your opinion, cricket.
>
> I just really like my approach because everything that has to do with
> permissions is handled at one single point. I'm only working on a
> small company-internal application, so I prefer handiness over
> performance stuff. I haven't too much experience with my solution yet,
> but I expect it to be very useful.

One other thing: Questions of passing a model to the view aside,
models should be agnostic with respect to access control and
authentication. The mechanism for this already exists and there's a
good reason why it's called the controller.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Saving & Loading Session Data

2010-11-18 Thread Stephen
Hi There

I need to give my customers the ability to save incomplete orders and
restore them at a later date.

The orders are quite intricate and can sometimes contain a lot of data (this
is another reason why I need save and load).

The data is contained within

$this->Session->read('Order');

Any hints on how I can achieve this?

I don't want to save other session data including auth session data.

-- 
Kind Regards
 Stephen  www.ninjacodermonkey.co.uk

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: How to determine whether there's an $id passed to an action? --psybear

2010-11-18 Thread Miles J
Personally, I would just set it on an action basis.

public function edit($id) {
$this->Model->id = $id;
}

Your getting into muddy territory going with that approach.

On Nov 18, 10:20 am, psybear83  wrote:
> Hi all
>
> I'd like to have a beforeFilter in my AppController which - whenever
> the view, edit or delete is accessed - automatically fills the
> AppController::model variable with the data of the passed $id.
>
> So I need to get the ID of the model from the URL in the beforeFilter.
> Sadly the $this->params variable doesn't have any 'id' named passed
> parameter:
>
> Array
> (
>     [pass] => Array
>         (
>             [0] => 1
>         )
> )
>
> Is it safe just to use the key 0 or is there a way to put up a default
> route or something which would name the key? So I wouldn't be
> dependent from the order in which the ID is passed?
>
> Thanks
> Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


How to determine whether there's an $id passed to an action? --psybear

2010-11-18 Thread psybear83
Hi all

I'd like to have a beforeFilter in my AppController which - whenever
the view, edit or delete is accessed - automatically fills the
AppController::model variable with the data of the passed $id.

So I need to get the ID of the model from the URL in the beforeFilter.
Sadly the $this->params variable doesn't have any 'id' named passed
parameter:

Array
(
[pass] => Array
(
[0] => 1
)
)

Is it safe just to use the key 0 or is there a way to put up a default
route or something which would name the key? So I wouldn't be
dependent from the order in which the ID is passed?

Thanks
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Model data array: how to examine which model it comes from?

2010-11-18 Thread Joshua Muheim
Thanks for your opinion, cricket.

I just really like my approach because everything that has to do with
permissions is handled at one single point. I'm only working on a
small company-internal application, so I prefer handiness over
performance stuff. I haven't too much experience with my solution yet,
but I expect it to be very useful.

On Thu, Nov 18, 2010 at 7:07 PM, cricket  wrote:
> On Thu, Nov 18, 2010 at 11:15 AM, Joshua Muheim  wrote:
>> Yes you're right, jeremy, I made this example up (my real User model
>> doesn't have an Address, I just added this to show that there are
>> cases where there's more than one key that isn't another array
>> itself).
>>
>> The reason why I'd like to know this is the following.
>>
>> I have implemented a simple ACL component that delivers an ActiveUser
>> object to the views which can be asked for permissions for certain
>> things:
>>
>> // In the view...
>> allowed('Users', 'edit')) echo
>> $this->Html->link(__('Edit User', true), array('action' => 'edit',
>> $post['User']['id'])); ?> 
>>
>> This works great so far, but it only works on the controller/action level.
>>
>> Every user is in a group which provides an ACL access string like
>> "!*:*,*:index,*:view" for guests or "!*:*,Users:*" for users editors
>> or "*:*" for administrators. So with the functionality above, only
>> administrators can edit users. But I'd also like my users to be able
>> to edit their own user data.
>>
>> So I thought of an extended $usr->allowed(...) version which also
>> accepts a model instance like the following:
>>
>> $usr->allowed('edit', $userInstance) // $userInstance is not the data
>> array, but a real "new User()" instance
>
> That looks like an awfully expensive way to do things. Why don't you
> just check with the session that this is the same User?
>
>
>> Then in the User::allowed(...) method I can ask the model instance
>> itself whether it wants to allow something or not:
>>
>> function allowed
>>  if(last param is model object)
>>    return modelObject->allows($action, $this->id)
>>  else
>>    do normal ACL string stuff...
>> }
>>
>> So I can implement an allows(...) method in every model I'd like to
>> have authorisation functionality on a model instance level:
>>
>> // In the model...
>> function allows($action, $userId)
>>  return $this->user_id == $userId // If the user is the same like the
>> one who owns the record, then let him edit it!
>
> view:
>
> if (if ($data['User']['id'] == $this->Session->read('Auth.User.id'))
> {
>        echo $this->Html->link(
>                'Profile',
>                array('admin' => 0, 'controller' => 'users', 'action' => 
> 'edit'), //
> no ID passed!
>                array('title' => 'Edit your profile')
>        );
> }
>
> controller (edit method not allowed by Auth):
>
> function edit()
> {
>        if (!empty($this->data))
>        {
>                // User.id isn't even in the edit form
>                $this->data['User']['id'] = $this->Auth->user('id');
>
>                // validate & save
>        }
>        else
>        {
>                $this->data = $this->User->read(null, $this->Auth->user('id'));
>        }
> }
>
> or:
>
> function edit()
> {
>        if (!empty($this->data))
>        {
>                if ($this->data['User']['id'] == $this->Auth->user('id'))
>                {
>                        // ...
>                }
>                else
>                {
>                        // Somebody's been fiddling with hidden form inputs. 
> Prepare a scolding.
>                }
>        }
>        else
>        {
>                $this->data = $this->User->read(null, $this->Auth->user('id'));
>        }
> }
>
> Done.
>
>> This works great so far, too. But because CakePHP doesn't deliver
>> views with real model instances but only data arrays, I'd like to be
>> able to pass them to the allowed(...) method, too. There I only have
>> to re-create the model instance, so I can ask it for allowance. And
>> here's the problem: it seems there can't be known what model a data
>> array originated from... Or can there? :-)
>
> Not that I want to encourage you to pursue this but, AFAIK, the first
> model in $data is the primary one.
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@

Allowing edit/delete to writers.

2010-11-18 Thread János Vasbányai
Hi!
I'm building a blog app. This is my first CakeProject.
I have 3 user groups:
-users (only allowed to add comments to articles)
-writers (allowed to write articles)
-admins (everything)

My question are:
How to allow writers to edit/delete thier articles only?
Is there a way to tell cake to match action names to groups? (i mean
ADMIN_index allow to  ADMINs)

I'm using $this->Auth->authorize = 'actions' as i have aros and acos.
Thanx

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Redirect problem - blank page, Email component

2010-11-18 Thread Invi
Hi I have one big problem which drives me crazy. My application is
some kind of a database of graphics projects with data screens and
comments. In "Show Projects details" view there is an ability to
comment the graphic project. And after submitting the comment
application sends an email to the author of the project. After that it
should redirect to the "Show Projects details" view again but
unfortunately there is a problem. The page goes blank. And if I press
back on web browser and click refresh the comment shows up. I turn the
debug 2 on and there are no errors. Furthermore there is a table with
SQL data and above it a proper link where it should redirect. I have
Notification component which uses core Email component. In this
Notification component I have a method:

function send($subject = 'Message', $id, $template, $text = "", $mail
= WEBSTUDIO_EMAIL, $private = false) {

 $this->Email->reset()

$this->Email->delivery = 'smtp';
$this->Email->smtpOptions = array(
'port'=>'25',
'timeout'=>'30',
'host' => EMAIL_SMTP_HOST,
'username'=> EMAIL_SMTP_USER,
'password'=> EMAIL_SMTP_PASSWORD
);

$this->Email->to = $mail;
$this->Email->subject = '[Project '.$id.'] '.$subject;
$this->Email->from = EMAIL_NAME.' <'.EMAIL_FROM.'>';
$this->Email->sendAs = 'text';
$this->Email->replyTo = WEBSTUDIO_EMAIL;
$this->Email->template = $template;

$this->controller->set('id', $id);
$this->controller->set('text', $text);
$this->controller->set('email', $this->obAuth->user["User"]
['email']);
$this->controller->set('user', $this->obAuth->user["User"]
['username']);

App::import('Model', 'User');
$User = &new User();

if (!$private)
{

$emails = $User->findAll('`User`.`id` IN (SELECT user_id FROM
users_permissions WHERE user_id != '.$this->obAuth->user["User"]
['id'].' AND permission_id = '.$this->obAuth-
>id('COMMENTS_INFO').')',  array('DISTINCT `User`.`id`',
'`User`.`email`', '`User`.`name`'), null, null, null, 0);
foreach($emails as $email)
{
$this->Email->bcc[] = "{$email['User']['name']}
<{$email['User']['email']}>";
}

if ($mail != WEBSTUDIO_EMAIL)
{
$this->Email->bcc[] = WEBSTUDIO_EMAIL;
}
}

if ($this->Email->send())
{
$this->Session->setFlash('Wysłano wiadomość.');
$debug = $this->Session->read('Message.email');

$this->controller->log("\n\n*Wysłano wiadomość* \n
\n{$debug['message']}", 'email.' . date('Y-m-d'));
return true;
} else {
$this->Session->setFlash('Wystąpił błąd podczas 
wysyłania
wiadomości');

$debug = $this->Session->read('Message.email');
$this->controller->log("\n\n*Nie wysłano wiadomości 
".$this->Email-
>smtpError, "\n{$debug['message']}", 'email.' . date('Y-m-d'));
@mail(ADMIN_EMAIL, env('SERVER_NAME').' Error: email', 
"Temat: ".
$this->Email->subject."\n\nBłąd: ".$this->Email->smtpError);
}
return false;

Usage of this component in my Templates Controller is:

$this->Notification->send('Comment', $this->data['Comment']
['template_id'], 'comment', $orig_comment, $this->data['Comment']
['author_email']);

where as you can see 'comment' is a template of the mail. The content
of comment.ctp is:



==
:
http://th.netart.pl/templates/view/,
==
:


I narrowed the problem to this line in the Notification component:

$this->Email->template = $template;

When I commented it, the redirect method worked properly but the mail
was empty. I know that in this situation application has no email
template assigned. But even if went back to the previous state and try
to erase the content of the comment.ctp nothing has changed. There
were no Warning: Cannot modify header information - headers already
sent, just the blank page. I do not know why there is a problem with
this email template and I have just spent 10 hours to solve this and I
didn't find the solution to this. Please help me.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


cakephp + jquery help

2010-11-18 Thread jd
Hi All

Excuse the beginners question but...

I want to learn how to use jquery with cake. I presume that I should
use the JS helper. Apart from the docs at book.cakephp.org and
api.cakephp.org, are there any good sources of info for a beginner? I
have found lots of articles through Google, but they are a little over
my head. I have a good understanding of JavaScript and Ajax, but I am
relatively new to jquery.

Thanks in advance,

J

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Controller not called

2010-11-18 Thread Xavier
Hi,
I just started working with Cakephp. When I call http://localhost/Items
I get the default page with an Error as page's title and no error or
warning. Any Ideas or pointers?


APP\controllers\items_controller.php
pageTitle = 'Novatem';
   $this->layout = 'default';
}

}
?>

APP\models\item.php



Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


DB field i18n - where I wrong?

2010-11-18 Thread Mariano C.
I have a table called supports, with two fields: id and name.

1 single_s
2 double_s
...

Support model is:
 array('name'));

function getAll()
{
$this->unbindModel(array('hasMany' => array('BooksUser')));
$options = array
(
'fields' => array(
'Support.id',
'Support.name'
));

return $this->find('all', $options);
}
}
?>

I've created via shell the i18n table and filled with:
1   eng Support 1   nameSingle support
2   eng Support 2   nameDouble support
3   ita Support 1   nameSupporto singolo
4   ita Support 2   nameSupporto doppio

I use the Config.language session to change locale, matter of fact all
static string will be changed when session is switched to the new
value.
Db string never change and always eng locale is returned if I exec the
getAll(). Why?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: What are the links between relationships and containable?

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 1:02 PM, Jeremy Burns | Class Outfit
 wrote:
> And don't forget it's $actsAs, not $actAs (cricket has identified this in his 
> response).

I hadn't noticed. Been bit by that a couple of times (as with not
providing the keys in 'fields').

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Model data array: how to examine which model it comes from?

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 11:15 AM, Joshua Muheim  wrote:
> Yes you're right, jeremy, I made this example up (my real User model
> doesn't have an Address, I just added this to show that there are
> cases where there's more than one key that isn't another array
> itself).
>
> The reason why I'd like to know this is the following.
>
> I have implemented a simple ACL component that delivers an ActiveUser
> object to the views which can be asked for permissions for certain
> things:
>
> // In the view...
> allowed('Users', 'edit')) echo
> $this->Html->link(__('Edit User', true), array('action' => 'edit',
> $post['User']['id'])); ?> 
>
> This works great so far, but it only works on the controller/action level.
>
> Every user is in a group which provides an ACL access string like
> "!*:*,*:index,*:view" for guests or "!*:*,Users:*" for users editors
> or "*:*" for administrators. So with the functionality above, only
> administrators can edit users. But I'd also like my users to be able
> to edit their own user data.
>
> So I thought of an extended $usr->allowed(...) version which also
> accepts a model instance like the following:
>
> $usr->allowed('edit', $userInstance) // $userInstance is not the data
> array, but a real "new User()" instance

That looks like an awfully expensive way to do things. Why don't you
just check with the session that this is the same User?


> Then in the User::allowed(...) method I can ask the model instance
> itself whether it wants to allow something or not:
>
> function allowed
>  if(last param is model object)
>    return modelObject->allows($action, $this->id)
>  else
>    do normal ACL string stuff...
> }
>
> So I can implement an allows(...) method in every model I'd like to
> have authorisation functionality on a model instance level:
>
> // In the model...
> function allows($action, $userId)
>  return $this->user_id == $userId // If the user is the same like the
> one who owns the record, then let him edit it!

view:

if (if ($data['User']['id'] == $this->Session->read('Auth.User.id'))
{
echo $this->Html->link(
'Profile',
array('admin' => 0, 'controller' => 'users', 'action' => 
'edit'), //
no ID passed!
array('title' => 'Edit your profile')
);
}

controller (edit method not allowed by Auth):

function edit()
{
if (!empty($this->data))
{
// User.id isn't even in the edit form
$this->data['User']['id'] = $this->Auth->user('id');

// validate & save
}
else
{
$this->data = $this->User->read(null, $this->Auth->user('id'));
}
}

or:

function edit()
{
if (!empty($this->data))
{
if ($this->data['User']['id'] == $this->Auth->user('id'))
{
// ...
}
else
{
// Somebody's been fiddling with hidden form inputs. 
Prepare a scolding.
}
}
else
{
$this->data = $this->User->read(null, $this->Auth->user('id'));
}
}

Done.

> This works great so far, too. But because CakePHP doesn't deliver
> views with real model instances but only data arrays, I'd like to be
> able to pass them to the allowed(...) method, too. There I only have
> to re-create the model instance, so I can ask it for allowance. And
> here's the problem: it seems there can't be known what model a data
> array originated from... Or can there? :-)

Not that I want to encourage you to pursue this but, AFAIK, the first
model in $data is the primary one.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: CakePHP 1.3, JSHelper and Autocomplete, Missing method?

2010-11-18 Thread nurvzy
That cookbook link you reference is for the Ajax Helper, not the
JsHelper.  To my knowledge autocomplete is not supported out of the
box using the JsHelper.  But it's simple enough to do on your own.

http://docs.jquery.com/UI/Autocomplete

Nick

On Nov 18, 1:09 am, Louie Miranda  wrote:
> I am trying to migrate my autocomplete to JSHelper using JQuery (As the
> default). And I think there are no documentation or examples yet that has
> been publicized as of this writing.
>
> Anyway, I did what the manual has told...
>
> *Controller:*
> var $helpers = array('Html', 'Form', 'Time', 'Js' => array('Jquery'));
>
> *Default.ctp*
> echo 
> $html->script('http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js');
> $this->Js->JqueryEngine->jQueryObject = '$j';
> print $this->Html->scriptBlock('var $j = jQuery.noConflict();',
>     array('inline' => false)); //Tell jQuery to go into noconflict mode
>
> *Now, from autocomplete (under view).*
>
> *The old code:*
> autoComplete('q', '/publications/autocompletetitle',
> array('minChars' => 4, 'class' => 'search')); ?>
>
> *Was switched to the following:*
> autoComplete('q', '/publications/autocompletetitle',
> array('minChars' => 4, 'class' => 'search')); ?>
>
> And the usual, it did not worked! :(. I turned-on debug and found this error
> message.
> *JsHelper:: Missing Method autoComplete is undefined
> [CORE/cake/libs/view/helpers/js.php, line 154]*
>
> So, I searched the API for 
> JSHelper.http://api13.cakephp.org/view_source/js-helper/
>
> And I did not find the code. The odd thing was actually following the
> example of the cakephp book for 1.3 for 
> autocomplete.http://book.cakephp.org/view/1370/autoComplete, and it turned 
> out wrong.
>
> Any ideas, how can I make autocomplete work on the new JSHelper? But, if the
> method does not exist, then it won't make any sense. I think I am missing
> something here? :(
>
> Please help.
> --
> Louie Miranda
>  - Email: lmira...@gmail.com
>  - Web:http://www.louiemiranda.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Trying to test a controller but autoRender=false doesn't seem to stop rendering!

2010-11-18 Thread Joshua Muheim
Thank you, Miles!

On Wed, Nov 17, 2010 at 8:04 PM, Miles J  wrote:
> I usually do:
>
> $this->autoLayout = $this->autoRender = false;
>
> On Nov 17, 1:57 am, psybear83  wrote:
>> Hi all
>>
>> That's my automatically generated controller test:
>>
>> > /* Comments Test cases generated on: 2010-11-17 10:11:59 :
>> 1289987639*/
>> App::import('Controller', 'Comments');
>>
>> class TestCommentsController extends CommentsController {
>>         var $autoRender = false;
>>
>>         function redirect($url, $status = null, $exit = true) {
>>                 $this->redirectUrl = $url;
>>         }
>>
>> }
>>
>> class CommentsControllerTestCase extends CakeTestCase {
>>         var $fixtures = array('app.comment', 'app.user', 'app.group',
>> 'app.active_user');
>>
>>         function startTest() {
>>                 $this->Comments =& new TestCommentsController();
>>                 $this->Comments->constructClasses();
>>         }
>>
>>         function endTest() {
>>                 unset($this->Comments);
>>                 ClassRegistry::flush();
>>         }
>>
>> }
>>
>> When running it, I'm getting errors from the default layout view:
>>
>> Notice (8): Undefined variable: users [APP/views/layouts/default.ctp,
>> line 41]
>>
>> etc.
>>
>> I tried to set
>>
>> var $layout = false;
>>
>> but this didn't work, too. What's wrong here?
>>
>> Thanks
>> Josh
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: What are the links between relationships and containable?

2010-11-18 Thread Jeremy Burns | Class Outfit
And don't forget it's $actsAs, not $actAs (cricket has identified this in his 
response).

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 18 Nov 2010, at 17:45, cricket wrote:

> On Thu, Nov 18, 2010 at 11:03 AM, Dan  wrote:
>> When using contain, I have to specify the $actAs = Containable for it
>> to work, correct?
> 
> Yes, of course. Just as with any other behavior. If you plan to use it
> a lot you can put it in AppModel's $actsAs array.
> 
>> And if you have a linking table (HABTM), would you have to specify
>> that model in the contain statement or can it be omitted (figured out
>> by Cake)?
> 
> You have to specify all models for which you want data, and there must
> be a chain of association running through them. If you have User <->
> Comment, and Comment <-> Tag, and you want a User's Tags, you must
> specify Comment in your contain array so that the behavior can work
> out how to get at Tag (and which ones to look for). Although it's not
> necessary to fetch the entire Comment, if you do provide a fields
> array for any of the contained models it should include the primary
> key and any relevant foreign keys.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: What are the links between relationships and containable?

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 11:03 AM, Dan  wrote:
> When using contain, I have to specify the $actAs = Containable for it
> to work, correct?

Yes, of course. Just as with any other behavior. If you plan to use it
a lot you can put it in AppModel's $actsAs array.

> And if you have a linking table (HABTM), would you have to specify
> that model in the contain statement or can it be omitted (figured out
> by Cake)?

You have to specify all models for which you want data, and there must
be a chain of association running through them. If you have User <->
Comment, and Comment <-> Tag, and you want a User's Tags, you must
specify Comment in your contain array so that the behavior can work
out how to get at Tag (and which ones to look for). Although it's not
necessary to fetch the entire Comment, if you do provide a fields
array for any of the contained models it should include the primary
key and any relevant foreign keys.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Search in associated tables (HABTM, Containable)

2010-11-18 Thread cricket
On Thu, Nov 18, 2010 at 6:12 AM, Matthias
 wrote:
> Thanks for the reply. Is this the best / usual way to do it? I thought
> that the models and database tables are "automagically" connected. And
> it works with the customers, as you can see above, but why doesnt it
> work for the items?

It's one way to do it. And it's probably the best way to get Cake to
use the closest thing to what one would normally do with straight SQL.
Cake's "automagic" querying of the DB comes at some cost, as joins
aren't necessarily used. Instead, it'll fetch the data using one or
more queries.

> And is the rest correct? Just asking because the same query with
> "WHERE `Customer`.`id` = 1" is done 2 times, and all the "SELECT
> `Item`.`name`" are done one by one, which looks incorrect to me.
> greetings

To be honest, I didn't wade through all of that.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Model data array: how to examine which model it comes from?

2010-11-18 Thread Joshua Muheim
Yes you're right, jeremy, I made this example up (my real User model
doesn't have an Address, I just added this to show that there are
cases where there's more than one key that isn't another array
itself).

The reason why I'd like to know this is the following.

I have implemented a simple ACL component that delivers an ActiveUser
object to the views which can be asked for permissions for certain
things:

// In the view...
allowed('Users', 'edit')) echo
$this->Html->link(__('Edit User', true), array('action' => 'edit',
$post['User']['id'])); ?> 

This works great so far, but it only works on the controller/action level.

Every user is in a group which provides an ACL access string like
"!*:*,*:index,*:view" for guests or "!*:*,Users:*" for users editors
or "*:*" for administrators. So with the functionality above, only
administrators can edit users. But I'd also like my users to be able
to edit their own user data.

So I thought of an extended $usr->allowed(...) version which also
accepts a model instance like the following:

$usr->allowed('edit', $userInstance) // $userInstance is not the data
array, but a real "new User()" instance

Then in the User::allowed(...) method I can ask the model instance
itself whether it wants to allow something or not:

function allowed
  if(last param is model object)
return modelObject->allows($action, $this->id)
  else
do normal ACL string stuff...
}

So I can implement an allows(...) method in every model I'd like to
have authorisation functionality on a model instance level:

// In the model...
function allows($action, $userId)
  return $this->user_id == $userId // If the user is the same like the
one who owns the record, then let him edit it!

This works great so far, too. But because CakePHP doesn't deliver
views with real model instances but only data arrays, I'd like to be
able to pass them to the allowed(...) method, too. There I only have
to re-create the model instance, so I can ask it for allowance. And
here's the problem: it seems there can't be known what model a data
array originated from... Or can there? :-)

Thanks for help... (and sorry for the long explanation...)

On Thu, Nov 18, 2010 at 4:53 PM, Jeremy Burns | Class Outfit
 wrote:
> Interesting question: why do you need to know? The User key contains user 
> data, the Address key contains address data, and the two are related...no? I 
> think your example array is missing some elements as there would normally be 
> a user_id key in the Address section...I think.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.com
> http://www.classoutfit.com
>
> On 18 Nov 2010, at 15:45, psybear83 wrote:
>
>> Hi everybody
>>
>> I have a User model which when loaded results in something like the
>> following array:
>>
>> Array
>> (
>>    [User] => Array
>>        (
>>            [id] => 3
>>            [name] => posts_editor
>>            [password] => 9fb00060ce49a5d5fab91b350b1529fda941a1de
>>            [superuser] => 0
>>        )
>>    [Post] => Array
>>        (
>>            [0] => Array
>>                (
>>                    [id] => 3
>>                    [user_id] => 3
>>                    [title] => Comment from comments editor
>>                    [body] => I like editing comments :-)
>>                )
>>        )
>>    [Group] => Array
>>        (
>>            [0] => Array
>>                (
>>                    [id] => 1
>>                    [name] => Posts Editors
>>                    [GroupsUser] => Array
>>                        (
>>                            [id] => 1
>>                            [group_id] => 1
>>                            [user_id] => 3
>>                        )
>>                )
>>        )
>> )
>>
>>
>> This is nice, but it seems that this array structure doesn't tell
>> itself where it came from, right? I could guess that it's from the
>> User model because there is only one key in the array that isn't
>> another array of data itself, but what if my model looked the
>> following (if my User model belonged to one Address):
>>
>> Array
>> (
>>    [User] => Array
>>        (
>>            [id] => 3
>>            [name] => posts_editor
>>            [password] => 9fb00060ce49a5d5fab91b350b1529fda941a1de
>>            [superuser] => 0
>>        )
>>    [Address] => Array
>>        (
>>            [street] => Some nice street 123
>>            [city] => Ducktown
>>        )
>> )
>>
>> Then it could be a User or an Address model, right? Or can we tell
>> from the order that it's a User and not an Address (i.e. maybe always
>> the first key ist the model, could that be?)? Or is there any other
>> way to determine the source of a model data array?
>>
>> Thanks for help, guys
>> Josh
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake-php

Re: What are the links between relationships and containable?

2010-11-18 Thread Dan
When using contain, I have to specify the $actAs = Containable for it
to work, correct?

And if you have a linking table (HABTM), would you have to specify
that model in the contain statement or can it be omitted (figured out
by Cake)?

On Nov 18, 10:03 am, euromark  wrote:
> @jeremy
> yes, redundant as long as you dont use find("list")
> in this case (i consider it a bug which i already reported) you will
> need containable
>
> On 18 Nov., 14:54, Jeremy Burns | Class Outfit
>
>  wrote:
> > Yes. If you try and contain a model that is not related (with $hasMany, 
> > $belongsTo etc) it will error. Don't forget that you can daisy chain them 
> > too by using nested arrays. So if you have:
>
> > User->Profile->ProfileData->ProfileDataType
>
> > ...you can do:
>
> > $result = $this->User->find(
> >         'all',
> >         array(
> >                 'contain' => array(
> >                         'Profile' => array(
> >                                 'ProfileData' => array(
> >                                         'ProfileDataType'
> >                                 )
> >                         )
> >                 )
> >         )
> > );
>
> > Happy to be corrected, but I think recursion is redundant when using 
> > contain, so no need to set it to -1 (although I suppose it doesn't hurt).
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> > On 18 Nov 2010, at 13:32, Dan wrote:
>
> > > I meant Model relationships. So, they would be required for the
> > > containable behavior to work then?
>
> > > On Nov 18, 8:38 am, Jeremy Burns | Class Outfit
> > >  wrote:
> > >> Do you mean relationships in the database or in the models? They are 
> > >> essential in the models (else Cake won't know how to relate models) and 
> > >> although not a Cake requirement I'd say it is paramount from a 
> > >> performance point of view in the database.
>
> > >> Jeremy Burns
> > >> Class Outfit
>
> > >> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> > >> On 18 Nov 2010, at 12:29, Dan wrote:
>
> > >>> Basically, can containable work without having relationships
> > >>> specified? Or does containable rely on those relationships?
>
> > >>> In some tutorials, they specify to use recursive = -1 and then
> > >>> containable to get more optimized SQL. I can't help but think, what's
> > >>> the point specifying the relationships??
>
> > >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > >>> with their CakePHP related questions.
>
> > >>> You received this message because you are subscribed to the Google 
> > >>> Groups "CakePHP" group.
> > >>> To post to this group, send email to cake-php@googlegroups.com
> > >>> To unsubscribe from this group, send email to
> > >>> cake-php+unsubscr...@googlegroups.com For more options, visit this 
> > >>> group athttp://groups.google.com/group/cake-php?hl=en
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > > with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups 
> > > "CakePHP" group.
> > > To post to this group, send email to cake-php@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php?hl=en
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Model data array: how to examine which model it comes from?

2010-11-18 Thread Jeremy Burns | Class Outfit
Interesting question: why do you need to know? The User key contains user data, 
the Address key contains address data, and the two are related...no? I think 
your example array is missing some elements as there would normally be a 
user_id key in the Address section...I think.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 18 Nov 2010, at 15:45, psybear83 wrote:

> Hi everybody
> 
> I have a User model which when loaded results in something like the
> following array:
> 
> Array
> (
>[User] => Array
>(
>[id] => 3
>[name] => posts_editor
>[password] => 9fb00060ce49a5d5fab91b350b1529fda941a1de
>[superuser] => 0
>)
>[Post] => Array
>(
>[0] => Array
>(
>[id] => 3
>[user_id] => 3
>[title] => Comment from comments editor
>[body] => I like editing comments :-)
>)
>)
>[Group] => Array
>(
>[0] => Array
>(
>[id] => 1
>[name] => Posts Editors
>[GroupsUser] => Array
>(
>[id] => 1
>[group_id] => 1
>[user_id] => 3
>)
>)
>)
> )
> 
> 
> This is nice, but it seems that this array structure doesn't tell
> itself where it came from, right? I could guess that it's from the
> User model because there is only one key in the array that isn't
> another array of data itself, but what if my model looked the
> following (if my User model belonged to one Address):
> 
> Array
> (
>[User] => Array
>(
>[id] => 3
>[name] => posts_editor
>[password] => 9fb00060ce49a5d5fab91b350b1529fda941a1de
>[superuser] => 0
>)
>[Address] => Array
>(
>[street] => Some nice street 123
>[city] => Ducktown
>)
> )
> 
> Then it could be a User or an Address model, right? Or can we tell
> from the order that it's a User and not an Address (i.e. maybe always
> the first key ist the model, could that be?)? Or is there any other
> way to determine the source of a model data array?
> 
> Thanks for help, guys
> Josh
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Model data array: how to examine which model it comes from?

2010-11-18 Thread psybear83
Hi everybody

I have a User model which when loaded results in something like the
following array:

Array
(
[User] => Array
(
[id] => 3
[name] => posts_editor
[password] => 9fb00060ce49a5d5fab91b350b1529fda941a1de
[superuser] => 0
)
[Post] => Array
(
[0] => Array
(
[id] => 3
[user_id] => 3
[title] => Comment from comments editor
[body] => I like editing comments :-)
)
)
[Group] => Array
(
[0] => Array
(
[id] => 1
[name] => Posts Editors
[GroupsUser] => Array
(
[id] => 1
[group_id] => 1
[user_id] => 3
)
)
)
)


This is nice, but it seems that this array structure doesn't tell
itself where it came from, right? I could guess that it's from the
User model because there is only one key in the array that isn't
another array of data itself, but what if my model looked the
following (if my User model belonged to one Address):

Array
(
[User] => Array
(
[id] => 3
[name] => posts_editor
[password] => 9fb00060ce49a5d5fab91b350b1529fda941a1de
[superuser] => 0
)
[Address] => Array
(
[street] => Some nice street 123
[city] => Ducktown
)
)

Then it could be a User or an Address model, right? Or can we tell
from the order that it's a User and not an Address (i.e. maybe always
the first key ist the model, could that be?)? Or is there any other
way to determine the source of a model data array?

Thanks for help, guys
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: What are the links between relationships and containable?

2010-11-18 Thread euromark
@jeremy
yes, redundant as long as you dont use find("list")
in this case (i consider it a bug which i already reported) you will
need containable


On 18 Nov., 14:54, Jeremy Burns | Class Outfit
 wrote:
> Yes. If you try and contain a model that is not related (with $hasMany, 
> $belongsTo etc) it will error. Don't forget that you can daisy chain them too 
> by using nested arrays. So if you have:
>
> User->Profile->ProfileData->ProfileDataType
>
> ...you can do:
>
> $result = $this->User->find(
>         'all',
>         array(
>                 'contain' => array(
>                         'Profile' => array(
>                                 'ProfileData' => array(
>                                         'ProfileDataType'
>                                 )
>                         )
>                 )
>         )
> );
>
> Happy to be corrected, but I think recursion is redundant when using contain, 
> so no need to set it to -1 (although I suppose it doesn't hurt).
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 18 Nov 2010, at 13:32, Dan wrote:
>
>
>
>
>
>
>
> > I meant Model relationships. So, they would be required for the
> > containable behavior to work then?
>
> > On Nov 18, 8:38 am, Jeremy Burns | Class Outfit
> >  wrote:
> >> Do you mean relationships in the database or in the models? They are 
> >> essential in the models (else Cake won't know how to relate models) and 
> >> although not a Cake requirement I'd say it is paramount from a performance 
> >> point of view in the database.
>
> >> Jeremy Burns
> >> Class Outfit
>
> >> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> >> On 18 Nov 2010, at 12:29, Dan wrote:
>
> >>> Basically, can containable work without having relationships
> >>> specified? Or does containable rely on those relationships?
>
> >>> In some tutorials, they specify to use recursive = -1 and then
> >>> containable to get more optimized SQL. I can't help but think, what's
> >>> the point specifying the relationships??
>
> >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> >>> with their CakePHP related questions.
>
> >>> You received this message because you are subscribed to the Google Groups 
> >>> "CakePHP" group.
> >>> To post to this group, send email to cake-php@googlegroups.com
> >>> To unsubscribe from this group, send email to
> >>> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> >>> athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 207 bytes

2010-11-18 Thread euromark
what exactly are you doing?
no way in hell that you need 290MB for user output (views)

On 18 Nov., 05:20, Sreenivas S Nair ♫  
wrote:
> Hi,
> Am hosting a web application which gets a very large amount of data every
> day.The mysql queries are  optimized to a maximum and also used containable
> feature through out the application.
> Still i am getting a memory error when the user visits some pages.
> Please tell me the fair amount of memory value range which i can given for a
> cakephp web application.* Now i gave memory_limit in my php.ini as 290MB*
>
> --
> Thanks '&' Regards
>  Sreenivas Soman

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: What are the links between relationships and containable?

2010-11-18 Thread Jeremy Burns | Class Outfit
Yes. If you try and contain a model that is not related (with $hasMany, 
$belongsTo etc) it will error. Don't forget that you can daisy chain them too 
by using nested arrays. So if you have:

User->Profile->ProfileData->ProfileDataType

...you can do:

$result = $this->User->find(
'all',
array(
'contain' => array(
'Profile' => array(
'ProfileData' => array(
'ProfileDataType'
)
)
)
)
);

Happy to be corrected, but I think recursion is redundant when using contain, 
so no need to set it to -1 (although I suppose it doesn't hurt).

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 18 Nov 2010, at 13:32, Dan wrote:

> I meant Model relationships. So, they would be required for the
> containable behavior to work then?
> 
> On Nov 18, 8:38 am, Jeremy Burns | Class Outfit
>  wrote:
>> Do you mean relationships in the database or in the models? They are 
>> essential in the models (else Cake won't know how to relate models) and 
>> although not a Cake requirement I'd say it is paramount from a performance 
>> point of view in the database.
>> 
>> Jeremy Burns
>> Class Outfit
>> 
>> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>> 
>> On 18 Nov 2010, at 12:29, Dan wrote:
>> 
>>> Basically, can containable work without having relationships
>>> specified? Or does containable rely on those relationships?
>> 
>>> In some tutorials, they specify to use recursive = -1 and then
>>> containable to get more optimized SQL. I can't help but think, what's
>>> the point specifying the relationships??
>> 
>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>>> with their CakePHP related questions.
>> 
>>> You received this message because you are subscribed to the Google Groups 
>>> "CakePHP" group.
>>> To post to this group, send email to cake-php@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
>>> athttp://groups.google.com/group/cake-php?hl=en
>> 
>> 
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Dynamic data in fixtures

2010-11-18 Thread Jacob
Hello all,

today I started with unit testing with SimpleTest and ran into a
problem. In some model i have a method 'findToday', which finds
records where 'day' is set to today's date. It's is a very simple
function which works but to become familiar with unit testing I wrote
a test en a fixture for it. While writing the fixture I realized that
the 'day' field had to be dynamic for the tests to succeed so i made a
variable $today which contains todays date date('Y/m/d'). This
variable I put in the fixed data.
I ran the test and it gave me an error:
  'Parse error: syntax error, unexpected '(', expecting ',' or ';'
in  on line 18'
I ran in to some information which said that fixture data is really
fixed, so there can't be any dynamic data in it.
How should I fix this problem? I don't want to update my fixtures
every time I want to test my function.

Greetz Jacob

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: What are the links between relationships and containable?

2010-11-18 Thread Dan
I meant Model relationships. So, they would be required for the
containable behavior to work then?

On Nov 18, 8:38 am, Jeremy Burns | Class Outfit
 wrote:
> Do you mean relationships in the database or in the models? They are 
> essential in the models (else Cake won't know how to relate models) and 
> although not a Cake requirement I'd say it is paramount from a performance 
> point of view in the database.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 18 Nov 2010, at 12:29, Dan wrote:
>
> > Basically, can containable work without having relationships
> > specified? Or does containable rely on those relationships?
>
> > In some tutorials, they specify to use recursive = -1 and then
> > containable to get more optimized SQL. I can't help but think, what's
> > the point specifying the relationships??
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: What are the links between relationships and containable?

2010-11-18 Thread Jeremy Burns | Class Outfit
Do you mean relationships in the database or in the models? They are essential 
in the models (else Cake won't know how to relate models) and although not a 
Cake requirement I'd say it is paramount from a performance point of view in 
the database.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 18 Nov 2010, at 12:29, Dan wrote:

> Basically, can containable work without having relationships
> specified? Or does containable rely on those relationships?
> 
> In some tutorials, they specify to use recursive = -1 and then
> containable to get more optimized SQL. I can't help but think, what's
> the point specifying the relationships??
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


What are the links between relationships and containable?

2010-11-18 Thread Dan
Basically, can containable work without having relationships
specified? Or does containable rely on those relationships?

In some tutorials, they specify to use recursive = -1 and then
containable to get more optimized SQL. I can't help but think, what's
the point specifying the relationships??

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Search in associated tables (HABTM, Containable)

2010-11-18 Thread Matthias
Thanks for the reply. Is this the best / usual way to do it? I thought
that the models and database tables are "automagically" connected. And
it works with the customers, as you can see above, but why doesnt it
work for the items?
And is the rest correct? Just asking because the same query with
"WHERE `Customer`.`id` = 1" is done 2 times, and all the "SELECT
`Item`.`name`" are done one by one, which looks incorrect to me.
greetings

On 17 Nov., 18:07, cricket  wrote:
> On Wed, Nov 17, 2010 at 10:22 AM, Matthias
>
>
>
>
>
>  wrote:
> > Hi all,
> > I'm trying to perform a search in some fields of associated tables. I
> > have an orders table for the order data, an items table for the items
> > the orders contain of, and a table connecting them (order parts).
>
> > So the models say:
> > Item: $hasMany = 'OrderPart'
> > Order: $hasMany = 'OrderPart'
> > OrderPart: $belongsTo = array('Order', 'Item');
> > Right?
>
> > To retrieve all orders i do:
> > $all_orders = $this->Order->find('all', array(
> >        'contain' => array(
> >                'Customer',
> >                'OrderPart' => 'Item.name'
> >        )
> > ));
>
> > The result is fine, although the SQL looks a bit dirty (the example
> > below is for only 2 entries):
> > SELECT `Order`.`id`, `Order`.`customer_id`, `Order`.`date_of_pickup`,
> > `Order`.`date_of_return`, `Order`.`total_lending_fee`,
> > `Order`.`currency`, `Order`.`status`, `Order`.`created`,
> > `Order`.`modified`, `Customer`.`id`, `Customer`.`name`,
> > `Customer`.`company`, `Customer`.`street_address`,
> > `Customer`.`postcode`, `Customer`.`city`, `Customer`.`country`,
> > `Customer`.`email`, `Customer`.`telephone`, `Customer`.`created`,
> > `Customer`.`modified` FROM `orders` AS `Order` LEFT JOIN `customers`
> > AS `Customer` ON (`Order`.`customer_id` = `Customer`.`id`) WHERE 1 = 1
> > ORDER BY `Order`.`id` ASC
>
> > SELECT `Customer`.`id`, `Customer`.`name`, `Customer`.`company`,
> > `Customer`.`street_address`, `Customer`.`postcode`, `Customer`.`city`,
> > `Customer`.`country`, `Customer`.`email`, `Customer`.`telephone`,
> > `Customer`.`created`, `Customer`.`modified` FROM `customers` AS
> > `Customer` WHERE `Customer`.`id` = 1
>
> > SELECT `Customer`.`id`, `Customer`.`name`, `Customer`.`company`,
> > `Customer`.`street_address`, `Customer`.`postcode`, `Customer`.`city`,
> > `Customer`.`country`, `Customer`.`email`, `Customer`.`telephone`,
> > `Customer`.`created`, `Customer`.`modified` FROM `customers` AS
> > `Customer` WHERE `Customer`.`id` = 1
>
> > SELECT `OrderPart`.`id`, `OrderPart`.`order_id`,
> > `OrderPart`.`item_id`, `OrderPart`.`quantity` FROM `order_parts` AS
> > `OrderPart` WHERE `OrderPart`.`order_id` IN (1, 2)
>
> > SELECT `Item`.`name` FROM `items` AS `Item` WHERE `Item`.`id` = 1
>
> > SELECT `Item`.`name` FROM `items` AS `Item` WHERE `Item`.`id` = 4
>
> > SELECT `Item`.`name` FROM `items` AS `Item` WHERE `Item`.`id` = 5
> > (...)
>
> > Now I want to search the following fields:
> > 'Customer.name',
> > 'Customer.company',
> > 'Item.name'
> > But I want to have all entries where the one search term matches ANY
> > of the 3 fields. So normally I'd write this:
>
> > $all_orders = $this->Order->find('all', array(
> >        'conditions' => array(
> >                'OR' => array(
> >                        'Customer.name LIKE' => $searchterm,
> >                        'Customer.company LIKE' => $searchterm,
> >                        'Item.name LIKE' => $searchterm
> >                )
> >        ),
> >        'contain' => array(
> >                'Customer',
> >                'OrderPart' => 'Item.name'
> >        )
> > ));
>
> > But then I get an error (normal, because the Item table is not
> > joined):
> > SQL Error: 1054: Unknown column 'Item.name' in 'where clause'
>
> > So how can I achive what I want to have?
>
> You could use a join. 
> See:http://book.cakephp.org/view/1047/Joining-tableshttp://nuts-and-bolts-of-cakephp.com/tag/cakephp-force-join/
>
> There should also be some other info online.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Auth / Acl redirect issue CakePHP 1.3.4

2010-11-18 Thread Tonu Tusk
Hi there, I had very similar problems to this...

If you split "visiting" urls into 6 separate cases.

1) not logged in visiting a url by clicking on a link
2) not logged in visiting a url by directly inputting it in browser
3) logged in visiting a url by clicking on a link - access allowed
4) logged in visiting a url by direclty inputting it in a browser -
access allowed
5) logged in visiting a url by clicking on a link - but insufficient
Acl permissions for page
6) logged in visiting a url by directly inputting it in a browser -
insufficient Acl permissions for page

You get varied behaviours.

This all arises due to the tightly interwoven dependency between
Auth / Acl, but not having sufficient distinct redirect variables
configured to deal with the
2 separate cases of insufficient privilages (excuse the spelling) vs
not authenticated.

I had a long (heated) chat in IRC with someone regarding this and have
also submitted this as a bug (i.e what happens in some of these cases
is not documented / inconsistent)
and in the end, even though it is (in my eyes) a VITAL part of the
framework to make sure it is addressed, I, and many others have been
brushed off (requests / queries of this nature do crop up
frequently)

I did figure out a solution, and in doing so decided to try and neaten
up my code / refactor it into a separate Acl component but in doing
more research, decided that the Acl mechanism
was just too cumbersome for what I need at the moment anyway. I
checked out authsome, and that works fine for me (although there was
some of the plugin code in that that needed to
be updated to make it work with Routes and plugins)

I might get round to digging out my fixes if you're interested, but
they were a bit unsitely and involved (if memory serves me) code
placed in beforeFilter, some more AppController variables being set
and
also an override of the referer and the acl check function to be
implemented, so it wasn't a nice fix.

I'd much rather it got recognised as a proper "core" issue to be coded
by a main dev team member.



On Nov 17, 5:02 am, Amit Badkas  wrote:
> Hi,
>
> Auth component uses 'loginRedirect' (by default, /users/login or
> /admin/users/login) class property for redirecting non-logged in users to
> login page if you are on restricted page.
>
> Amit Badkas
>
> PHP Applications for E-Biz:http://www.sanisoft.com
>
> On Wed, Nov 17, 2010 at 12:56 AM, danielnolan wrote:
>
> > I am not sure that is one hundred percent accurate, if I am logged in
> > as an admin and i type a restricted URL in the address bar of the
> > browser I get redirected to the main site home page. If i am not
> > logged in and I type the same restricted URL in the address bar of the
> > browser i get redirected to the admin/login page and I get a flash
> > message saying that I am not authorized to access that location.
>
> > So how does the app know to redirect me to the admin/login page when
> > not logged in, but when logged in I get redirected to the main site
> > home page?
>
> > On Nov 16, 12:08 am, Amit Badkas  wrote:
> > > Hi,
>
> > > The redirection after ACL fails depends on HTTP_REFERER environment
> > > variable. If you access the restricted URL directly then referrer doesn't
> > > get set, that's why '/' (by default, home page) is being used.
>
> > > Amit Badkas
>
> > > PHP Applications for E-Biz:http://www.sanisoft.com
>
> > > On Mon, Nov 15, 2010 at 10:06 PM, danielnolan  > >wrote:
>
> > > > I have an application setup with admin prefix route, Auth, and ACL.
> > > > everything seems to be working as expected, except when I am logged in
> > > > as an admin user and I try to access a ACL restriced action by typing
> > > > the url in the address bar of the browser. I get redirected to the
> > > > home page of the site (view/pages/home.ctp) instead of the admin
> > > > dashboard (users/admin_dashboard) i have created.
>
> > > > If I click on a link to the exact same action in the admin dashboard
> > > > that is restricted, I get redirected to the admin dashboard as
> > > > expected with an auth error message telling me I am not authorized to
> > > > access that location.
>
> > > > What am I missing?
>
> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > others
> > > > with their CakePHP related questions.
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "CakePHP" group.
> > > > To post to this group, send email to cake-php@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com
> > >For
> > more options, visit this group at
> > > >http://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from

CakePHP 1.3, JSHelper and Autocomplete, Missing method?

2010-11-18 Thread Louie Miranda
I am trying to migrate my autocomplete to JSHelper using JQuery (As the
default). And I think there are no documentation or examples yet that has
been publicized as of this writing.

Anyway, I did what the manual has told...

*Controller:*
var $helpers = array('Html', 'Form', 'Time', 'Js' => array('Jquery'));

*Default.ctp*
echo $html->script('
http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js');
$this->Js->JqueryEngine->jQueryObject = '$j';
print $this->Html->scriptBlock('var $j = jQuery.noConflict();',
array('inline' => false)); //Tell jQuery to go into noconflict mode

*Now, from autocomplete (under view).*

*The old code:*
autoComplete('q', '/publications/autocompletetitle',
array('minChars' => 4, 'class' => 'search')); ?>

*Was switched to the following:*
autoComplete('q', '/publications/autocompletetitle',
array('minChars' => 4, 'class' => 'search')); ?>

And the usual, it did not worked! :(. I turned-on debug and found this error
message.
*JsHelper:: Missing Method autoComplete is undefined
[CORE/cake/libs/view/helpers/js.php, line 154]*

So, I searched the API for JSHelper.
http://api13.cakephp.org/view_source/js-helper/

And I did not find the code. The odd thing was actually following the
example of the cakephp book for 1.3 for autocomplete.
http://book.cakephp.org/view/1370/autoComplete, and it turned out wrong.

Any ideas, how can I make autocomplete work on the new JSHelper? But, if the
method does not exist, then it won't make any sense. I think I am missing
something here? :(

Please help.
--
Louie Miranda
 - Email: lmira...@gmail.com
 - Web: http://www.louiemiranda.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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