Re: ACL tutorial

2009-11-30 Thread Joseph Roberts
Try,

function beforeFilter() {
$this->Auth->logoutRedirect = array('controller' => 'xxx', 
'action'
=> 'xxx');
}

function logout() {
   $this->Auth->logout();
}

On Nov 30, 10:24 am, Lorenzo Bettini  wrote:
> Hi
>
> I've just started using cakephp, and in the second tutorial, the acl
> one, logout() in class userd_controller.php does not seem to work:
>
>         function logout() {
>                 $this->Session->setFlash('Good-Bye');
>                 $this->redirect($this->Auth->logout());
>         }
>
> infact I'm not logged out...
>
> any clue please?
>
> Moreover, are the implementations of these tutorials available for download?
>
> thanks in advance
>         Lorenzo
>
> --
> Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
> HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
> BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.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: Form Action URL from Router

2009-11-24 Thread Joseph Roberts
Solved it:

function checkPermissions(){
Configure::write('debug', 0);
$this->layout = 'ajax';

$user = $this->Auth->user('username');

// Sanitize URL for either development or production server
if(!strrpos($this->params['url']['url'], 'cake/missio'))
$url = str_replace('Users/checkPermissions//','',$this->params
['url']['url']);
else
$url = str_replace('Users/checkPermissions//cake/missio/','',
$this->params['url']['url']);

$pieces = explode('/', $url);
$controller = Inflector::camelize($pieces[0]);
$action = Inflector::variable($pieces[1]);

$aco = $controller.'/'.$action;

if($this->Acl->check($user, "$aco", '*'))
$perm = 'allowed';
else
$perm = 'denied';

$this->set('data', $perm);
}

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


Form Action URL from Router

2009-11-24 Thread Joseph Roberts
I have an application that uses Auth and ACL to check permissions in
the app_controller. I am also checking permissions on every AJAX call
by using jQuery's AjaxSetup to capture the XmlHttpRequest URL. This
process works perfectly for any manual AJAX call, but for Ajaxified
forms the action URL contains both the CAKE and APP_DIR which messes
up my ACL check because it doesn't recognize controller, CAKE or the
action, APP_DIR. On top of that, my ACL check needs a camelized
controller and a variablized action, and the URL sent by the form
helper has put underscores in the controller name.

Can anyone suggest a better way to check permissions on both static
page changes AND AJAX calls without leaving the GUI? When a ACL check
fails in my app_controller it redirects to a failed permissions error
page. That is fine for static page changes, but in the middle of an
AJAX GUI it is a nightmare. I need AJAX permission checks to respond
within the AJAX framework rather than taking the user out of it to a
message page.

Please help!

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


MySQL Report Queries

2009-10-26 Thread Joseph Roberts

I am having difficulty at work porting old PHP/MySQL reports into a
new CakePHP app. One old report consist of three loops in this format:

get all departments
 for each department
  get all jobs in department
  for each job
   sum hours and compute $ value (# hours * value per
hour)

I'm not a wizard with queries, and trying to put the old reports into
CakePHP is causing me headaches. I am trying to honor the fat model,
skinny controller design pattern as well as refrain from using $this-
>model->query() and make use of model associations. However, I cannot
get CakePHP to return the data I want in the manner I need to generate
the report I described above.

Can anyone suggest a way to retrieve this data without resorting to
query()? I'd really rather not burn cpu cycles looping through
departments and jobs.

Thanks,

Joe
--~--~-~--~~~---~--~~
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: One view to bind them all?

2009-04-14 Thread Joseph Roberts

Thanks, Brian. That is exactly what I needed.

On Apr 13, 1:40 pm, brian  wrote:
> On Mon, Apr 13, 2009 at 2:06 PM, Joseph Roberts
>
>
>
>  wrote:
>
> > Greetings fellow bakers,
>
> > I need help with a development project where I work at a rescue
> > mission. I am creating a volunteer management system that involves
> > many models such as: groups, jobs, volunteers, skeleton_jobs and
> > scheduled_jobs. Being new to CakePHP, this is my quandary: How do I
> > implement MVC in this case?
>
> > I would like to haveoneview, let's call it volunteer_manager.ctp,
> > that accesses information fromallthese aforementioned models and
> > displays the data in  tags in an iTunes-esque display so that
> > everything is ononescreen (i.e. mini calendar, scrollable divs for
> > lists of groups, volunteers and jobs). I have a prototype working with
> > drag and drop capability, but am running into issues with
> > requestAction. Some resources I've read have said requestAction is a
> > "bad practice."
>
> > That being said, how to I utilize data from a number of MVC
> > relationships in a singleviewwithout using requestAction? Should I
> > turn the groups, departments, volunteers, and jobs into elements that
> > are included within volunteer_manager.ctp? Each of these elements
> > requires the basic CRUD functions. Perhaps I'm not conceptualizing
> > elements properly, but from the Cookbook's description they seem to be
> > rather limited display aids rather than full blown MVC relationships.
> > I need help understanding elements or a viable alternative because the
> > relationships in this app are getting complicated and I don't want to
> > design myself into a corner.
>
> > For instance, when I click on a date in the mini calendar not only is
> > the calendar div updated, but the jobs div should be updated to
> > reflectallavailable jobs for that day AND the groups, volunteers,
> > and scheduled jobs should be updated as well. This requires a number
> > of requestAction calls as it now stands.
>
> > Perhaps I should get away from Ajax calls to update the individual
> >  tags in volunteer_manager.ctp, but I don't want to reload the
> > screen (and reload every bit of data in the divs) just becauseonediv
> > element needs to change.
>
> You can use a generalised manager ontroller to fetch the data from
> several models. Whether you include those other models in the
> controller's $uses array or use ClassRegistry::init() as needed is up
> to you (maybe you don't wantallof the models loaded for every
> action).
>
> You can still use ajax to make changes. Just point the requests to the
> appropriate controller. The link may be in aviewfor
> volunteer_manager but it can point to any other controller.

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



One view to bind them all?

2009-04-13 Thread Joseph Roberts

Greetings fellow bakers,

I need help with a development project where I work at a rescue
mission. I am creating a volunteer management system that involves
many models such as: groups, jobs, volunteers, skeleton_jobs and
scheduled_jobs. Being new to CakePHP, this is my quandary: How do I
implement MVC in this case?

I would like to have one view, let's call it volunteer_manager.ctp,
that accesses information from all these aforementioned models and
displays the data in  tags in an iTunes-esque display so that
everything is on one screen (i.e. mini calendar, scrollable divs for
lists of groups, volunteers and jobs). I have a prototype working with
drag and drop capability, but am running into issues with
requestAction. Some resources I've read have said requestAction is a
"bad practice."

That being said, how to I utilize data from a number of MVC
relationships in a single view without using requestAction? Should I
turn the groups, departments, volunteers, and jobs into elements that
are included within volunteer_manager.ctp? Each of these elements
requires the basic CRUD functions. Perhaps I'm not conceptualizing
elements properly, but from the Cookbook's description they seem to be
rather limited display aids rather than full blown MVC relationships.
I need help understanding elements or a viable alternative because the
relationships in this app are getting complicated and I don't want to
design myself into a corner.

For instance, when I click on a date in the mini calendar not only is
the calendar div updated, but the jobs div should be updated to
reflect all available jobs for that day AND the groups, volunteers,
and scheduled jobs should be updated as well. This requires a number
of requestAction calls as it now stands.

Perhaps I should get away from Ajax calls to update the individual
 tags in volunteer_manager.ctp, but I don't want to reload the
screen (and reload every bit of data in the divs) just because one div
element needs to change.

I hope this makes sense. If not, I'm sure y'all will let me know :)

Joe

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