Re: Global functions

2012-04-05 Thread luca capra
Sorry I've not understand what the problem is. The select doesn't 
prepopulate well?

Try checking what the value of

  debug( $this-request-data('Patient.bloodgroup') );

If it is a text value you need to give the right key to the select

$_bloodgroup = array_flip( $bloodgroup );
echo $this-Form-input('bloodgroup', array(
  'type' =  'select',
  'label' =  'blood group',
  'options' =  $bloodgroup,
  'default' =  '1',
  'value' =  $_bloodgroup[$this-request-data('Patient.bloodgroup')]
));


Il 05/04/2012 08:07, alexkd ha scritto:

As per your suggestion I added in afterFind(). Its working in
add,index and view.
But in edit, the select box is showing wrong because of the adjustment
in afterfind.
//
$bloodgroup = array(
 '0' =  'RH A+',
 '1' =  'RH A-',
 '2' =  'RH B+',
 '3' =  'RH B-',
 '4' =  'RH AB+',
 '5' =  'RH AB-'
 );
echo $this-Form-input('bloodgroup', array('type' =  'select',
'label' =  'blood group', 'options' =  $bloodgroup, 'default' =
'1'));
//
How can I add an empty field with the find query so I can duplicate
bloodgroup. and use it in edit.ctp



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.



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


How to stop redirecting to login page

2012-04-05 Thread Michael Gaiser
So, I have a login link in the corner of my homepage which I want people to
click on to login... pretty simple. Problem is that I cannot seem to view
my homepage as I am automatically redirected to the login page. This causes
issues when you login since the login returns you to the initial page (the
home page) which then transfers you back to the login etc. Inf loop time.
So I cannot seem to figure out why it is automatically redirecting my
homepage to the login page. Thanks.


app_controller:

function beforeFilter() {
$cookie = null;

//debug($this-Auth);

// Change the default field names for the username and password
$this-Auth-fields = array('username' = 'username', 'password' =
'passwd');

//Set application wide actions which do not require authentication
//$this-Auth-allow(array('*'));
$this-Auth-allow('/', 'login', 'logout', 'confirm');

//$this-Auth-allow(array('add'));

// this sets the Login Action
$this-Auth-loginAction = '/users/login';

// Where do we go after a successful login?
$this-Auth-loginRedirect = '/';

// Where do we go after a successful logout?
$this-Auth-logoutRedirect = '/';

// what type of authorization setup are we using
$this-Auth-authorize = 'controller';

//What is required to be a valid account?
$this-Auth-userScope = array('User.confirmed' = '1',
'User.active' = '1');

// What to say when the login was incorrect.
$this-Auth-loginError = 'Sorry, login failed.  Either your
username/password are incorrect or your account in not active.';
$this-Auth-authError = 'The page you tried to access is
restricted. You have been redirected to the page below.';

//Do we want to use our custom cookie login? If so this needs to be
false.
$this-Auth-autoRedirect = false;

//If we are not logged in yet, check if there is a cookie to log in
by
if( !$this-__setLoggedUserValues()  ($cookie =
$this-Cookie-read( $this-cookieName ) ) ){
 $this-Auth-login($cookie);
$this-__setLoggedUserValues();
}
else
{
//$this-redirect(array('controller' = 'users', 'action' =
'login'));;
}
}


function beforeRender() {
#This will build the menu bar
$this-__buildMenu();

#If we have an authorized user logged then pass over an array of
#controllers to which they have index action permission
if($this-Auth-user()) {
$controllerList = Configure::listObjects('controller');
$permittedControllers = array();
foreach($controllerList as $controllerItem) {
if($controllerItem  'App') {
if($this-__permitted($controllerItem, 'index')) {
$permittedControllers[] = $controllerItem;
}
}
}
}
$this-set(compact('permittedControllers'));

}



function isAuthorized() {
$result = $this-__permitted($this-name,$this-action);
return $result;
}


function __permitted($controllerName,$actionName) {
//Ensure checks are all made lower case
$controllerName = low($controllerName);
$actionName = low($actionName);


//If permissions have not been cached to session...
if(!$this-Session-check('Permissions')){
//...then build permissions array and cache it
$permissions = array();

//everyone gets permission to logout
$permissions[]='users:logout';

//Import the User Model so we can build up the permission cache
App::import('Model', 'User');
$thisUser = new User;
$thisUser-Behaviors-attach('Containable');

//Now bring in the current users full record along with groups
$thisUser-contain('Group');
$thisGroups = $thisUser-find('first', array(
'conditions'=array('User.id'=$this-Auth-user('id'))
));

foreach($thisGroups['Group'] as $thisGroup) {
$thisUser-contain('Permission');
$thisPermissions = $thisUser-Group-find('first', array(
'conditions'=array('Group.id'=$thisGroup['id'])
));

foreach($thisPermissions['Permission'] as $thisPermission) {
$permissions[]=$thisPermission['name'];
}

}
//debug($permissions);
//write the permissions array to session
$permissions = array_unique($permissions);
$this-Session-write('Permissions',$permissions);

//}
}else{
//...they have been cached already, so retrieve them
$permissions = $this-Session-read('Permissions');
}

//Now iterate through permissions 

Re: How to stop redirecting to login page

2012-04-05 Thread Mike Griffin
On Thu, Apr 5, 2012 at 09:53, Michael Gaiser mjgai...@gmail.com wrote:
 So, I have a login link in the corner of my homepage which I want people to
 click on to login... pretty simple. Problem is that I cannot seem to view my
 homepage as I am automatically redirected to the login page. This causes
 issues when you login since the login returns you to the initial page (the
 home page) which then transfers you back to the login etc. Inf loop time. So
 I cannot seem to figure out why it is automatically redirecting my homepage
 to the login page. Thanks.


 app_controller:

     function beforeFilter() {
         $cookie = null;

         //debug($this-Auth);

         // Change the default field names for the username and password
         $this-Auth-fields = array('username' = 'username', 'password' =
 'passwd');

         //Set application wide actions which do not require authentication
         //$this-Auth-allow(array('*'));
         $this-Auth-allow('/', 'login', 'logout', 'confirm');


You should move $this-Auth-allow into the specific controller for
that action, I think.
For example, in the users controller for the login and logout actions.
So that means that wherever you have set your / route in routes.php
should have its own Auth-allow line to allow the action.

Does that make sense or have I confused it?

Don't forget to call parent::beforeFilter(); in the beforeFilter
function in your controller so that the appController one still gets
called.

Mike.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Default label options?

2012-04-05 Thread nabeel
Hi all,

Is there a way to set the default label options? I want every label to have 
a certain class.
Right now, on Form-create(), I call a helper function and pass it the 
options array, and it appends my default options from the helper, to the 
form specific ones.
It works rather well:


public function formOptions($params) {

  $params_default = array(
'url' = '', 'type' = 'post',
'class' = 'form-horizontal',
'inputDefaults' = array(
'label' = array('class' = 'control-label'),
'div' = 'control-group',
'between' = 'div class=controls', 'after' = '/div',
'error' = array('attributes' = array('wrap' = 'p', 'class' = 'controls 
help-block'))
)
  );

  return array_merge($params_default, $params);
}


If you're familiar with bootstrap, you can see that's what I'm using.
But that inputDefault of the label options doesn't stick - I don't think 
there's a way of doing this the way I want to, looking through the 
formOptions code, I don't see it there. Don't know if there's a way without 
touching every form.

Any ideas?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Default label options?

2012-04-05 Thread Nabeel S.
After looking through the formHelper, I don't see a way of doing this.
So I added the code and submit a pull-request on GitHub.

Hopefully that helps someone else!

Cheers

On Thu, Apr 5, 2012 at 10:12 AM, nabeel nshah...@gmail.com wrote:

 Hi all,

 Is there a way to set the default label options? I want every label to
 have a certain class.
 Right now, on Form-create(), I call a helper function and pass it the
 options array, and it appends my default options from the helper, to the
 form specific ones.
 It works rather well:


 public function formOptions($params) {

   $params_default = array(
  'url' = '', 'type' = 'post',
 'class' = 'form-horizontal',
  'inputDefaults' = array(
 'label' = array('class' = 'control-label'),
  'div' = 'control-group',
 'between' = 'div class=controls', 'after' = '/div',
  'error' = array('attributes' = array('wrap' = 'p', 'class' =
 'controls help-block'))
  )
   );

   return array_merge($params_default, $params);
 }


 If you're familiar with bootstrap, you can see that's what I'm using.
 But that inputDefault of the label options doesn't stick - I don't think
 there's a way of doing this the way I want to, looking through the
 formOptions code, I don't see it there. Don't know if there's a way without
 touching every form.

 Any ideas?

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 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


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Help with Finder

2012-04-05 Thread ingcara
Morning Bakers

I have the following case: In my application I have a search engine,
which you enter your email or name, it searches for registered users
to these criteria. The problem is that instead of a text input area, I
want to make a selection with SELECT, so the user does not have to
type anything, moreover wanted to have the same form a SELECT list of
options that will be added and show Users with these criteria.

I've tried everything, but unfortunately not able to make it work. Who
can help thanks.

The application works like this: The search criteria are in VIEW
Busca_a, and Pequisar pressing the button, this button calls the
function search () in controller and VIEW search.


The function in my CONTROLLER

function usuario_busca() {

$this-set('meuPerfil', 1);
if(!empty($this-data['tipo']) AND 
!empty($this-data['valor'])) {
switch($this-data['tipo']) {
case 'nome':

$dados = 
$this-Usuario-find('all',
array('conditions'=array('or'=array(

'sexualidade_usuario'=$this-data['valor'],
'nome_usuario 
LIKE'='%'.$this-data['valor'].'%',
'nascimento_usuario 
LIKE'='%'.$this-data['valor'],

'email_usuario'=$this-data['valor'] ,

'descricao_usuario'=$this-data['valor'],

'culinaria_usuario'=$this-data['valor'],

'altura_usuario'=$this-data['valor'],

'relacionamento_usuario'=$this-data['valor'],

'paixao_usuario'=$this-data['valor'])),

'order'=array('nome_usuario 
ASC'), 'limit'=200));

break;
default: break;
}

if(isset($dados) AND !empty($dados)) 
$this-set('dados', $dados);
$busca = array('valor'= $this-data['valor']);
$this-set('busca', $busca);
}
else $this-redirect($this-site['url']['site'] . 'usuario/rede/
perfil');
}





THE  VIEWs

VIEW BUSCA_A


form action=?php echo $site['url']['site'] ?usuario/rede/busca
method=post class=form busca


label for=nome_contatoQual é o numero de sua 
escolha:/label
input type=text id=nome_contato name=data[valor] 
/
input type=hidden name=data[tipo] value=nome /





button class=botao_1 botao_1_1 type=submit
title=PesquisarPesquisar/button

button class=botao_1 botao_1_1 type=reset
title=Limpar BuscaLimpar Busca/button




/form/ul/div






USUARIO BUSCA()

?php
$this-pageTitle = 'REDE: Resultado da busca para ' . $busca['valor'];
echo $this-element('barralateral');
?

div id=pag-rede-busca class=conteudo rede
?php $msgAlerta = $session-flash(); if(!empty($msgAlerta)) echo
'div class=alerta_1 alerta_1_1' . $msgAlerta . '/div'; ?

div class=box_e
?php
$img = (!empty($usuarioON['imagem_usuario'])) ? 
'upload/usuarios/
escala/' . $usuarioON['imagem_usuario'] : 'usuario.jpg';
echo 'img src=' . $site['url']['prefix'] . 'img/' . $img . '
alt=' . $usuarioON['nome_usuario'] . ' title=' .
$usuarioON['nome_usuario'] . ' width=175 /';
echo $this-element('lateralrede');
?
/div

div class=box_d
h2Resultados da busca para: span class=db?php echo
$busca['valor'] ?/span/h2

div class=conteudo
?php if(isset($dados) AND !empty($dados)): ?
ul class=produtos
?php
foreach($dados as $item):
$item = $item['Usuario'];

$nomePart = explode(' ', 
$item['nome_usuario']);
$nome = $nomePart[0];
if(isset($nomePart[1]) AND 
!empty($nomePart[1])) $nome .= ' ' .
$nomePart[1];
?
   

Undefined index error in controller

2012-04-05 Thread Daniel
I get the following error in my ImagesController:
Notice (8): Undefined index: Image [APP\Controller
\ImagesController.php, line 31]

The controller code is as follows (ending on line 31) :

public function img_upload($person_id = null) {
if ($this-request-is('post')) {
$fileinfo = $this-request-data['Image']['filename'];
...

The ctp file is as follows:

div class=images form
?php echo $this-Form-create('Image', array('enctype' = 'multipart/
form-data')); ?
fieldset
legend?php echo __('Upload Image'); ?/legend
?php echo $this-Form-input('filename', array('type' = 'file')); ?

/fieldset
?php echo $this-Form-end(__('Submit'));?
/div
div class=actions
h3?php echo __('Actions'); ?/h3
ul
li?php echo $this-Html-link(__('Home Page', true),
array('controller' = 'pages', 'action' = 'index')); ? /li
/ul
/div

What am I missing?

Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Undefined index error in controller

2012-04-05 Thread Jeremy Burns | Class Outfit
You are trying to access the 'Image' key of an array in line 31 of your 
images_controller, but the array key does not exist.

How do I know this? Because I read the error message.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 5 Apr 2012, at 16:48:15, Daniel wrote:

 I get the following error in my ImagesController:
 Notice (8): Undefined index: Image [APP\Controller
 \ImagesController.php, line 31]
 
 The controller code is as follows (ending on line 31) :
 
 public function img_upload($person_id = null) {
   if ($this-request-is('post')) {
   $fileinfo = $this-request-data['Image']['filename'];
 ...
 
 The ctp file is as follows:
 
 div class=images form
 ?php echo $this-Form-create('Image', array('enctype' = 'multipart/
 form-data')); ?
   fieldset
   legend?php echo __('Upload Image'); ?/legend
   ?php echo $this-Form-input('filename', array('type' = 'file')); ?
 
   /fieldset
 ?php echo $this-Form-end(__('Submit'));?
 /div
 div class=actions
   h3?php echo __('Actions'); ?/h3
   ul
   li?php echo $this-Html-link(__('Home Page', true),
 array('controller' = 'pages', 'action' = 'index')); ? /li
   /ul
 /div
 
 What am I missing?
 
 Thanks.
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
 
 
 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

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Undefined index error in controller

2012-04-05 Thread Tilen Majerle
ur cake version is ?

and instead of this  ?php echo $this-Form-create('Image',
array('enctype' = 'multipart/
form-data')); ?

use  ?php echo $this-Form-create('Image', array('type' = 'file')); ?

and in your controller simply debug $this-request-data to see what data
you have posted
--
Lep pozdrav, Tilen Majerle
http://majerle.eu



2012/4/5 Daniel danwgr...@gmail.com

 ?php echo $this-Form-create('Image', array('enctype' = 'multipart/
 form-data')); ?


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Message: No input file specified.

2012-04-05 Thread Sandeepa
Hello,

Please explain how you solved it!

I'm facing the same problem.

Thanks,
SN

On Monday, November 14, 2011 9:54:21 PM UTC+5:30, Mister Mistah wrote:

 lol i promise i tried that!! 

 It ended up being my .htaccess files.   they were wrong for some 
 reason, but good to go now 

 thanks! 

 On Nov 14, 9:54 am, phpMagpie p...@webbedit.co.uk wrote: 
  http://lmgtfy.com/?q=No+input+file+specified+cakephp

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Should I choose CakePHP over another framework for its MPTT / Nested Sets support?

2012-04-05 Thread Kevin Mitchell
Hello:

Thank you for letting me intrude on your time and presume on your 
expertise. I do appreciate your help in answering the following question.

Although I've done quite a bit of website development in the past with ASP 
and ColdFusion; recently with Drupal. I am new to PHP development and 
certainly to working with a PHP Framework -- yet, I am committed to 
learning, even at 60 years old! I'm trying to decide which direction to go 
re: a Framework; I obviously, at this age, am not heading into a career in 
PHP programming. I just want to build a tool to help myself and others 
manage my MySQL database.

I was investigating the Zend Framework. It seems a little intimidating, but 
I'm willing. What attracted me to CakePHP was what I read about it being 
relatively easy to learn and, especially, when I saw that that it's 
TreeBehavior was using a MPTT / Nested Sets database. I have been working 
on an extensive hierarchical database (a theological and biblical a 
curriculum, with the biblical data including Hebrew and Greek fields for 
individual sentences, clauses).

So, my question, do you think the fact that CakePHP supports / uses this 
MPTT logic is a fairly compelling reason for choosing the CakePHP framework 
-- along with my being relatively new to PHP programming? Is there another 
approach you might recommend?

I do appreciate your time in answering this: I have been spinning my wheels 
for weeks trying to decide what framework I should make a commitment to 
begin with.

Kevin
ncBc, Associate Pastor
BcResources.net

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


$this-Auth-user VERY slow

2012-04-05 Thread Dan Moseley
Hi,
I have been experiencing extremely long run times for some calls to $this-
Auth-user('id').

Most requests spend 0 time in this method, but seemingly random requests 
are taking upwards of 60 seconds..

Does anyone have any ideas or recommendations on this problem?

Thanks in advance,
Dan

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Should I choose CakePHP over another framework for its MPTT / Nested Sets support?

2012-04-05 Thread Jeremy Burns | Class Outfit
Hi Kevin

The 'what is the best framework' debate often surfaces here, and I am yet to 
see a compelling answer. It all comes down to what you feel comfortable with, 
making a choice and getting stuck in. Making any choice is preferable to 
pontificating. The Tree behaviour is certainly good; whether it's a deciding 
factor is hard to call. I would say that - as is probably the case with any 
framework or methodology - there is a pretty steep learning curve with Cake, 
but that 'ah-ha!' moment comes fairly soon.It might be tougher for you with no 
PHP knowledge, but then I had none when I picked it up. Both PHP and Cake are 
very straightforward once you get to grips with the basics, although of course 
it gets tougher once you decide to go off piste or stretch the boundaries. This 
forum is on the whole, a really friendly and useful resource and we are used to 
getting new folk such as yourself up and running. The Cake site also has a 
couple of very good tutorials; I would urge you to give them a go and follow 
them carefully. Many people jump bits and get lost, so come here for help. They 
are generally fairly robustly chastised and sent back to the classroom. RTFM, 
as they say. But so long as you are honest, try and help yourself and follow 
the good advice you are given, you won't regret choosing Cake.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 5 Apr 2012, at 15:54:47, Kevin Mitchell wrote:

 Hello:
 
 Thank you for letting me intrude on your time and presume on your expertise. 
 I do appreciate your help in answering the following question.
 
 Although I've done quite a bit of website development in the past with ASP 
 and ColdFusion; recently with Drupal. I am new to PHP development and 
 certainly to working with a PHP Framework -- yet, I am committed to learning, 
 even at 60 years old! I'm trying to decide which direction to go re: a 
 Framework; I obviously, at this age, am not heading into a career in PHP 
 programming. I just want to build a tool to help myself and others manage my 
 MySQL database.
 
 I was investigating the Zend Framework. It seems a little intimidating, but 
 I'm willing. What attracted me to CakePHP was what I read about it being 
 relatively easy to learn and, especially, when I saw that that it's 
 TreeBehavior was using a MPTT / Nested Sets database. I have been working on 
 an extensive hierarchical database (a theological and biblical a curriculum, 
 with the biblical data including Hebrew and Greek fields for individual 
 sentences, clauses).
 
 So, my question, do you think the fact that CakePHP supports / uses this MPTT 
 logic is a fairly compelling reason for choosing the CakePHP framework -- 
 along with my being relatively new to PHP programming? Is there another 
 approach you might recommend?
 
 I do appreciate your time in answering this: I have been spinning my wheels 
 for weeks trying to decide what framework I should make a commitment to begin 
 with.
 
 Kevin
 ncBc, Associate Pastor
 BcResources.net
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
  
  
 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

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Should I choose CakePHP over another framework for its MPTT / Nested Sets support?

2012-04-05 Thread Kevin Mitchell
Jeremy:

Thank you, so very much, for your answer; especially it's encouraging 
tone. I am working through trying to setup a development environment, so I 
can create that blog tutorial.

I guess the heart of my question is whether the TreeBehavior should be a 
deciding factor (given that I've already got a database designed in a way 
that it seems to support) -- i.e., is that kind of tree support, using 
Nested Sets, relatively unique to CakePHP. I don't know whether Zend comes 
with this kind of out-of-the-box support.

Again, Thank you!

Kevin 

On Thursday, April 5, 2012 9:22:50 AM UTC-7, Jeremy Burns wrote:

 Hi Kevin

 The 'what is the best framework' debate often surfaces here, and I am yet 
 to see a compelling answer. It all comes down to what you feel comfortable 
 with, making a choice and getting stuck in. Making any choice is preferable 
 to pontificating. The Tree behaviour is certainly good; whether it's a 
 deciding factor is hard to call. I would say that - as is probably the case 
 with any framework or methodology - there is a pretty steep learning curve 
 with Cake, but that 'ah-ha!' moment comes fairly soon.It might be tougher 
 for you with no PHP knowledge, but then I had none when I picked it up. 
 Both PHP and Cake are very straightforward once you get to grips with the 
 basics, although of course it gets tougher once you decide to go off piste 
 or stretch the boundaries. This forum is on the whole, a really friendly 
 and useful resource and we are used to getting new folk such as yourself up 
 and running. The Cake site also has a couple of very good tutorials; I 
 would urge you to give them a go and follow them carefully. Many people 
 jump bits and get lost, so come here for help. They are generally fairly 
 robustly chastised and sent back to the classroom. RTFM, as they say. But 
 so long as you are honest, try and help yourself and follow the good advice 
 you are given, you won't regret choosing Cake.

 Jeremy Burns
 Class Outfit

 http://www.classoutfit.com 

 On 5 Apr 2012, at 15:54:47, Kevin Mitchell wrote:

 Hello:

 Thank you for letting me intrude on your time and presume on your 
 expertise. I do appreciate your help in answering the following question.

 Although I've done quite a bit of website development in the past with ASP 
 and ColdFusion; recently with Drupal. I am new to PHP development and 
 certainly to working with a PHP Framework -- yet, I am committed to 
 learning, even at 60 years old! I'm trying to decide which direction to go 
 re: a Framework; I obviously, at this age, am not heading into a career in 
 PHP programming. I just want to build a tool to help myself and others 
 manage my MySQL database.

 I was investigating the Zend Framework. It seems a little intimidating, 
 but I'm willing. What attracted me to CakePHP was what I read about it 
 being relatively easy to learn and, especially, when I saw that that it's 
 TreeBehavior was using a MPTT / Nested Sets database. I have been working 
 on an extensive hierarchical database (a theological and biblical a 
 curriculum, with the biblical data including Hebrew and Greek fields for 
 individual sentences, clauses).

 So, my question, do you think the fact that CakePHP supports / uses this 
 MPTT logic is a fairly compelling reason for choosing the CakePHP framework 
 -- along with my being relatively new to PHP programming? Is there another 
 approach you might recommend?

 I do appreciate your time in answering this: I have been spinning my 
 wheels for weeks trying to decide what framework I should make a commitment 
 to begin with.

 Kevin
 ncBc, Associate Pastor
 BcResources.net



-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Auth error, even with allowed actions

2012-04-05 Thread Benjamin Allison
CakePHP: Auth error showing even on allowed actions

This one's making me scratch my head. I'm doing a basic authentication 
where I check a user's role, and allow or deny based on that role. I want 
to keep it simple and semantic (no ACL). But the Auth error message shows, 
even when the user attempts an allowed action... and remains visible after 
they've logged out.

Here's my app controller:

public $components = array(
'Session',
'Password',
'Auth' = array(
'loginRedirect' = array('controller' = 'users', 'action' = 
'index'),
'logoutRedirect' = array('controller' = 'pages', 'action' = 
'display', 'home'),
'authError' = Sorry, you're not allowed to do that.,
'authorize' = array('Controller')
),
'RequestHandler'
);

public function beforeFilter() {
$this-set('loggedIn', $this-Auth-loggedIn());
$this-set('current_user', $this-Auth-user());
$this-set('admin', $this-_isAdmin());
$this-set('coach', $this-_isCoach());
$this-Auth-allow('login', 'logout', 'display');
}

public function isAuthorized($user) {
if (isset($user['role'])  $user['role'] === 'admin') {
return true;
}
return false;
}

And here's the beforeFilter and isAuthorized from another controller:

public function beforeFilter() {
parent::beforeFilter();
}

public function isAuthorized($user) {
if ($user['role'] === 'coach') {
if ($this-action === 'index') {
return true;
}
if (in_array($this-action, array('view', 'edit', 'delete'))) {
$id = $this-request-params['pass'][0];
$this-User-id = $id;
if ($this-User-field('client_id') === $user['client_id'] ) 
return true;
} else {
return false;
}
}
return false;
}
return

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: How to stop redirecting to login page

2012-04-05 Thread Michael Gaiser
I forgot to post it, but there is a call to parent::beforeFilter() as well
as $this-Auth-allow('/', 'login', 'logout', 'confirm'); in the
beforeFilter within the User Controller.

I still cannot figure out why its automatically getting sent to the login
though.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Auth error, even with allowed actions

2012-04-05 Thread Benjamin Allison
I solved it by doing the following, though I'm not entirely sure why it's 
working!

public function isAuthorized($user = null) {
switch($this-action) {
case index:
case add:
if ($user['role'] == 'coach') {
return true;
}
break;

case view:
case edit:
case delete:
$id = $this-request-params['pass'][0];
$this-User-id = $id;
if ($user['role'] == 'coach'  $this-User-field('client_id') == 
$user['client_id']) {
return true;
}
break;
}
return parent::isAuthorized($user);
}

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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