Re: Using same functions in several views

2010-07-20 Thread euromark
careful with foreach(Cache::read('userCapList') as $userCap)... !!! Cache::read() is not in all cases a array to iterate over sometimes its false etc so make sure to cast it to an array: foreach((array)Cache::read('userCapList') as $userCap)... or do it in 2 steps On 20 Jul., 16:48, "mattmoy..

Re: Using same functions in several views

2010-07-20 Thread mattmoy...@gmail.com
Your life would be soo much easier if you were using cake's ACL in your application. It handles all of the stuff you are trying to do automagically. It can be a little intimidating for new users but once you figure it out you will never use anything else again. Here is a great 2 part tutorial fr

Re: Using same functions in several views

2010-07-20 Thread Petter Andreas Strøm
Thanks people! Worked out great;) On Jul 20, 12:29 pm, "Mike Karthauser" wrote: > hi Petter; > > On Tue, July 20, 2010 9:12 am, Petter Andreas Str m wrote: > > Well, I have to explain the topic for the discussion too; > > > I'm looking for a solution where I can make a function to check if > > us

Re: Using same functions in several views

2010-07-20 Thread Petter Andreas Strøm
Thanks people! Worked out great;) On Jul 20, 12:29 pm, "Mike Karthauser" wrote: > hi Petter; > > On Tue, July 20, 2010 9:12 am, Petter Andreas Str m wrote: > > Well, I have to explain the topic for the discussion too; > > > I'm looking for a solution where I can make a function to check if > > us

Re: Using same functions in several views

2010-07-20 Thread Mike Karthauser
hi Petter; On Tue, July 20, 2010 9:12 am, Petter Andreas Strøm wrote: > Well, I have to explain the topic for the discussion too; > > I'm looking for a solution where I can make a function to check if > user have this capability like if(userHasCap('user_edit')). How can i > make a function like th

Re: Using same functions in several views

2010-07-20 Thread Zaky Katalan-Ezra
Inherit from Helper class and put it in /views/helpers. class LegendHelper extends Helper { var $helpers = Array("Html"); function legendColor($arg1, $arg2) { terun true;} } in view use it $legend-> legendColor(1, 5); Check out the new CakePHP Questions site http://cakeq

Re: Using same functions in several views

2010-07-20 Thread Petter Andreas Strøm
Well, I have to explain the topic for the discussion too; I'm looking for a solution where I can make a function to check if user have this capability like if(userHasCap('user_edit')). How can i make a function like this and include it into every view i need it? Component? Check out the new CakeP

Using same functions in several views

2010-07-20 Thread Petter Andreas Strøm
Hi, I'm trying to implement some functionality for hiding buttons(and info) from a page depending on parameters sat for the specific user (in the model). Off course to create some restrictions for the different users. But im kind of confused how to do this. The way i do it now is like: 1. Cache