Ideas on how to handle large logic classes w/ rights extension

Hi All…

Im kind of stuck on how the best way to reproduce current code in Yii. In my current application I have the following situation.

I have a security system that is basically a set of DB keys that allow an specific actions. These are checked when the corresponding actions requested simply by doing


if($userSettigns->KEYNAME == 1)

. I have a few classes that are large blocks of logic. The biggest handles requests via a FullCalendar installation i use on my page. Instead of having multiple calendars with different JS actions for the onClick event all click events are passed to the server for processing. The server looks at a combination of variables and passes back a appropriate dialog box to the user based on what was clicked and what their security access is.

The issues im running into are:

  1. where is the correct place to put these classes. They can be split into some sub pieces can be placed in Models and Controllers but a large piece of them need to remain intact. I was thinking of creating a controller that just handles these requests but is not called direct but from other controllers. Is this correct our should it be in an extension of some sort?

  2. How can I tie this in with the Rights plugin. The Rights plugin uses the Controller’s name and Action Names to assign its permissions. Since some of the permissions are not directly related to a action, ie ‘Admin Calendar’ (different view) how can I add these keys? I was originally thinking of creating a dumby controller with dumby actions that Rights can see and I can check for.

Am I completely off base?

thanks for the help.

Example of part of one of the classes I mentioned.


private function checkSecure(){

        $myDate = mktime(date('H'),date('i'),0,date('n'),date('j'),date('Y'));

        $str1 = explode('-', $this->cal->ShiftDate);

        $str2 = explode(':', $this->cal->StartTime);

        

        $myShiftDate = mktime($str2[0],$str2[1],0,$str1[1],$str1[2],$str1[0]);

        $myPostByDate = mktime(date('H'),date('i'),0,date('n'),(date('j') + $this->sysSettings->SubLimit),date('Y'));

        $act = explode('_', $_REQUEST['id']);

        

        if($this->usrSettings->CalAdmin == 1 && $_REQUEST['eventType'] != 'admin'){

            return TRUE;

        }elseif($_REQUEST['eventType'] == 'admin' && $act[2] != 'post' && $act[2] != 'fill' && $act[2] != 'email'){

            return TRUE;

        }else{      

            switch ($this->cal->ShiftStatusID) {

                case '1':

                case '5'://reg shift

                    if($myShiftDate < $myPostByDate){

                        if($this->usrSettings->CalByPassSubPostBy == 1){

                            if($myDate > $myShiftDate){

                                $this->menuTitle = "No Action Allowed";

                                $this->menuTxt = "<h3>This shift is past the point It can be posted.<br> Please contact a supervisor for assistance</h3>";

                                $this->menuBtn = "'Ok': function(){

                                                        \$('#calendar').fullCalendar('refetchEvents');

                                                        \$('#dialogBox').remove();

                                                    }";

                            }else{

                                return TRUE;

                            }

                        }else{

                            $this->menuTitle = "No Action Allowed";

                            $this->menuTxt = "<h3>This shift is past the point It can be posted.<br> Please contact a supervisor for assistance</h3>";

                            $this->menuBtn = "'Ok': function(){

                                                    \$('#calendar').fullCalendar('refetchEvents');

                                                    \$('#dialogBox').remove();

                                                }";

                        }

                    }else{

                        return TRUE;

                    }

                break;

                case '2': //open sub

                    if($myDate > $myShiftDate){

                            $this->menuTitle = "No Action Allowed";

                            $this->menuTxt = "<h3>This shift is past the point It can be taken.<br> Please contact a supervisor for assistance</h3>";

                            $this->menuBtn = "'Ok': function(){

                                                    \$('#calendar').fullCalendar('refetchEvents');

                                                    \$('#dialogBox').remove();

                                                }";

                    }else{

                        return TRUE;

                    }

                break;