Path

ez projects / ezapprove2 / forum / general / class include - exclude opt...


Class Include - Exclude Options

You need to be logged in to post messages in the forums. New users may register here.

Felipe Jaramillo

Member since:
09 January 2008

Posts: 2

Tuesday 03 March 2009 3:47:36 pm

Hi all,

I just add the class include - exclude functionality using a ini file, it was pretty easy but was not implemented...

In the evente type file (extension\ezapprove2\eventtypes\event\ezapprove2\ezapprove2type.php line 207)

Original



  switch( $eventData->attribute( 'approve_type' ) )


       {


           case eZApprove2Event::ApproveTypeUser:


           {


               $inExcludeGroups = false;


               $userIsEditor = false;


           } break;


 

           default:


           case eZApprove2Event::ApproveTypePredefined:


           {


               $inExcludeGroups = count( array_intersect( $userGroups, $workflowGroups ) ) != 0;


               $userIsEditor = ( in_array( $user->id(), $editors ) ||


                                 count( array_intersect( $userGroups, $approveGroups ) ) != 0 );


           } break;


       } 

 

/* HERE YOU MUST ADD THE EXTRA CODE*/


 

        if ( !$inExcludeGroups &&


            !$userIsEditor &&


            $correctSection && $class_include)


       {


                        


           switch( $eventData->attribute( 'approve_type' ) )


           {


               case eZApprove2Event::ApproveTypeUser:       

 



You must add the following lines:
(Don't forget to update the final if sentence)



                $ini_approve = eZINI::instance('ezapprove2.ini');


                $class_include_type = $ini_approve-> variable('ApproveClasses','IncludeType');


                $class_array = $ini_approve-> variable('ApproveClasses','ClassIdentifierList');


                $class_include=true;


                if (count($class_array) && is_array($class_array))


                {               


                        $object_class_identifier = $object-> contentClassIdentifier ();


                        if (count(array_intersect($class_array, array($object_class_identifier))))


                        {


                                if ($class_include_type == 'include')


                                {


                                        $class_include=true;            


                                }elseif ($class_include_type == 'exclude')


                                {


                                        $class_include=false;


                                }


                        }else


                        {


                                if ($class_include_type == 'include')


                                {


                                        $class_include=false;           


                                }elseif ($class_include_type == 'exclude')


                                {


                                        $class_include=true;


                                }


                        }


                }


                if ( !$inExcludeGroups &&


            !$userIsEditor &&


            $correctSection && $class_include)


       {  

 



And we need to add some line to the ezapprove2.ini file




#Include or exclude approve classes


[ApproveClasses]


IncludeType=include


ClassIdentifierList[]


ClassIdentifierList[]=   #Here the classes you want to include or exclude





I hope it is helpfull for everyone


Julian Mancera

Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia

Up

You need to be logged in to post messages in the forums. New users may register here.