Tuesday, June 30, 2009

RE: return true or false

Sounds good thanks once again.

Basically a user has a profile and decides if they want it public or
private.

But running into to many if statements and is a complete mess.

Options for the profile owner public or private pretty simple

But if private I have to check friendships to see if the Auth.user and the
profile they are attempting to view has allowed them

So it looks like
Check public
if not public
Check friendsships
If there is a friendship
allow
If not no access
Else it public


-----Original Message-----
From: brian [mailto:bally.zijn@gmail.com]
Sent: June-30-09 6:56 AM
To: cake-php@googlegroups.com
Subject: Re: return true or false


like so?

if ($this->Profile->checkPublic ($profile_user_id)) {
// true
}
else
{
// false
}

On Mon, Jun 29, 2009 at 4:54 PM, Dave Maharaj ::
WidePixels.com<dave@widepixels.com> wrote:
> I have a function that checks if a users profile is public or private
>
> function checkPublicAccess ($profile_user_id)
>  {
>   // check if profile is public or private
>           //0 = private 1 = public
>           $params = array(
>      'conditions' => array('Profile.user_id' => $profile_user_id,
> 'Profile.public' => '1'),
>      'contain' => false,
>      'fields' => array('Profile.public'));
>
>           $q = $this->find('first', $params);
>
>           // profile is not public so you must be logged in
>           if (empty($q)) {
>               return false;
>     }
>  }
>
> My question is how do I in the controller use the 'false' return?
>
> if ($this->Profile->checkPublic ($profile_user_id) == false)?
>
>
> Thanks
>
> Dave
> >
>

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: