fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [11091] controller: acl


From: Sigurd Nes
Subject: [Fmsystem-commits] [11091] controller: acl
Date: Mon, 06 May 2013 13:22:10 +0000

Revision: 11091
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11091
Author:   sigurdne
Date:     2013-05-06 13:22:07 +0000 (Mon, 06 May 2013)
Log Message:
-----------
controller: acl

Modified Paths:
--------------
    trunk/controller/inc/class.menu.inc.php
    trunk/controller/inc/class.uicase.inc.php
    trunk/controller/inc/class.uicheck_list.inc.php
    trunk/controller/inc/class.uicontrol.inc.php
    trunk/controller/inc/class.uicontrol_group.inc.php
    trunk/controller/inc/class.uicontrol_item.inc.php
    trunk/controller/inc/class.uidocument.inc.php
    trunk/controller/inc/class.uiprocedure.inc.php

Modified: trunk/controller/inc/class.menu.inc.php
===================================================================
--- trunk/controller/inc/class.menu.inc.php     2013-05-06 06:58:50 UTC (rev 
11090)
+++ trunk/controller/inc/class.menu.inc.php     2013-05-06 13:22:07 UTC (rev 
11091)
@@ -83,6 +83,7 @@
                                                'text'  => 
lang('Control_group'),
                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicontrol_group.index') ),
                                                'image' => array('property', 
'location_1'),
+                                               /*
                                                'children' => array(
                                                                                
        'component_for_control_group' => array
                                                                                
        (
@@ -91,6 +92,7 @@
                                                                                
                'image' => array('property', 'entity_1')
                                                                                
        )
                                                                                
)
+                                               */
                                        ),
                                        'procedure' => array
                                        (

Modified: trunk/controller/inc/class.uicase.inc.php
===================================================================
--- trunk/controller/inc/class.uicase.inc.php   2013-05-06 06:58:50 UTC (rev 
11090)
+++ trunk/controller/inc/class.uicase.inc.php   2013-05-06 13:22:07 UTC (rev 
11091)
@@ -61,7 +61,12 @@
         private $so_check_list;
 
         private $location_finder;
-    
+
+           private $read;
+           private $add;
+           private $edit;
+           private $delete;
+   
                var $public_functions = array(
             'add_case'                                 => true,
                        'save_case'                     => true,
@@ -92,7 +97,12 @@
             $this->so_check_list            = 
CreateObject('controller.socheck_list');
       
             $this->location_finder          = new location_finder();
-               }       
+
+                       $this->read    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1 
+                       $this->add     = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2 
+                       $this->edit    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4 
+                       $this->delete  = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8 
+               }       
                
         function add_case()
                {
@@ -178,7 +188,13 @@
                                       
'check_list/fragments/select_buildings_on_property'), $data);
                }
     
-               function save_case_ajax(){
+               function save_case_ajax()
+               {
+                       if(!$this->add && !$this->edit)
+                       {
+                               return json_encode( array( "status" => 
"not_saved" ) );
+                       }
+
                        $check_list_id = phpgw::get_var('check_list_id');
                        $control_item_id = phpgw::get_var('control_item_id');
                        $case_descr = phpgw::get_var('case_descr');
@@ -194,7 +210,8 @@
                        $check_item = 
$this->so_check_item->get_check_item_by_check_list_and_control_item($check_list_id,
 $control_item_id);
                                                        
                        // Makes a check item if there isn't already made one  
-                       if($check_item == null){
+                       if($check_item == null)
+                       {
                                $new_check_item = new controller_check_item();
                                $new_check_item->set_check_list_id( 
$check_list_id );
                                $new_check_item->set_control_item_id( 
$control_item_id );
@@ -219,31 +236,44 @@
             $case->set_location_code( $location_code );
 
                        // Saves selected value from  or measurement
-                       if($type == 'control_item_type_2'){
+                       if($type == 'control_item_type_2')
+                       {
                                $measurement = phpgw::get_var('measurement');
                                $case->set_measurement( $measurement );
-                       }else if($type == 'control_item_type_3'){
+                       }
+                       else if($type == 'control_item_type_3')
+                       {
                                $option_value = phpgw::get_var('option_value');
                                $case->set_measurement( $option_value );
-                       }else if($type == 'control_item_type_4'){
+                       }
+                       else if($type == 'control_item_type_4')
+                       {
                                $option_value = phpgw::get_var('option_value');
                                $case->set_measurement( $option_value );
                        }
                        
                        $case_id = $this->so->store($case);
                        
-                       if($case_id > 0){
+                       if($case_id > 0)
+                       {
                                $cl_status_updater = new 
check_list_status_updater();
                                $cl_status_updater->update_check_list_status( 
$check_list_id );
                                                
                                return json_encode( array( "status" => "saved" 
) );
                        }
-                       else{
+                       else
+                       {
                                return json_encode( array( "status" => 
"not_saved" ) );
                        }
                }
     
-               function save_case(){
+               function save_case()
+               {
+                       if(!$this->add && !$this->edit)
+                       {
+                               return json_encode( array( "status" => 
"not_saved" ) );
+                       }
+
                        $case_id = phpgw::get_var('case_id');
                        $case_descr = phpgw::get_var('case_descr');
                        $case_status = phpgw::get_var('case_status');
@@ -258,33 +288,36 @@
                        $case->set_measurement($measurement);
                        $case->set_status($case_status);
                        
-      if($case->validate())
-      {
-        $case_id = $this->so->store($case);
-        $case = $this->so->get_single($case_id);
+                       if($case->validate())
+                       {
+                               $case_id = $this->so->store($case);
+                               $case = $this->so->get_single($case_id);
 
-        if($case_id > 0){
-          $cl_status_updater = new check_list_status_updater();
-          $cl_status_updater->update_check_list_status( $check_list_id );
+                               if($case_id > 0)
+                               {
+                                       $cl_status_updater = new 
check_list_status_updater();
+                                       
$cl_status_updater->update_check_list_status( $check_list_id );
 
-          $check_item = 
$this->so_check_item->get_single($case->get_check_item_id());
-          $control_item = 
$this->so_control_item->get_single($check_item->get_control_item_id());
+                                       $check_item = 
$this->so_check_item->get_single($case->get_check_item_id());
+                                       $control_item = 
$this->so_control_item->get_single($check_item->get_control_item_id());
 
-          $type = $control_item->get_type();
+                                       $type = $control_item->get_type();
 
-          return json_encode( array( "status" => "saved", "type" => $type, 
"caseObj" => $case->toArray() ) );
-        }
-        else{
-          return json_encode( array( "status" => "not_saved" ) );
-        }
-      }
-      else
-      {
-        return json_encode( array( "status" => "error" ) );
-      }
+                                       return json_encode( array( "status" => 
"saved", "type" => $type, "caseObj" => $case->toArray() ) );
+                               }
+                               else
+                               {
+                                       return json_encode( array( "status" => 
"not_saved" ) );
+                               }
+                       }
+                       else
+                       {
+                               return json_encode( array( "status" => "error" 
) );
+                       }
                }
                
-               function create_case_message(){
+               function create_case_message()
+               {
                        $check_list_id = phpgw::get_var('check_list_id');
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
                                                
@@ -360,13 +393,20 @@
                        
self::render_template_xsl(array('check_list/fragments/check_list_menu', 
'case/create_case_message'), $data);
                }
                
-               function send_case_message(){
+               function send_case_message()
+               {
                        $check_list_id = phpgw::get_var('check_list_id');
                        $location_code = phpgw::get_var('location_code');
                        $message_title = phpgw::get_var('message_title');
                        $message_cat_id = phpgw::get_var('message_cat_id');
                        $case_ids = phpgw::get_var('case_ids');
                        
+                       if(!$this->add && !$this->edit)
+                       {
+                               phpgwapi_cache::message_set('No access', 
'error');
+                               $this->redirect(array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
+                       }
+
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
                                                
                        $control_id = $check_list->get_control_id();
@@ -388,7 +428,8 @@
                        
                        // Generates message details from comment field in 
check item 
                        $counter = 1;
-                       foreach($case_ids as $case_id){
+                       foreach($case_ids as $case_id)
+                       {
                                $case = $this->so->get_single($case_id);
                                $message_details .= "Gjøremål $counter: ";
                                $message_details .=  $case->get_descr() . 
"<br>";
@@ -443,7 +484,8 @@
                                                
                        // Registers message and updates check items with 
message ticket id
 
-                       foreach($case_ids as $case_id){
+                       foreach($case_ids as $case_id)
+                       {
                                $case = $this->so->get_single($case_id);
                                $case->set_location_id($location_id_ticket);
                                $case->set_location_item_id($message_ticket_id);
@@ -527,11 +569,17 @@
                        
self::render_template_xsl(array('check_list/fragments/check_list_menu', 
'case/view_case_message'), $data);
                }
                
-               public function updateStatusForCases($location_id, 
$location_item_id, $updateStatus = 0){
-                       
+               public function updateStatusForCases($location_id, 
$location_item_id, $updateStatus = 0)
+               {
+                       if(!$this->add && !$this->edit)
+                       {
+                               return;
+                       }
+
                        $cases_array = $this->so->get_cases_by_message( 
$location_id, $location_item_id );
 
-                       if(!empty ( $cases_array ) ){
+                       if(!empty ( $cases_array ) )
+                       {
                                // Updates status for cases related to message  
                                foreach($cases_array as $case){
                                        $case->set_status( $updateStatus );
@@ -556,24 +604,36 @@
                
                public function delete_case()
                {
+                       if(!$this->delete)
+                       {
+                               return json_encode( array( "status" => 
"not_deleted" ) );
+                       }
+
                        $case_id = phpgw::get_var('case_id');
                        $check_list_id = phpgw::get_var('check_list_id');
                                
                        $status = $this->so->delete($case_id);
                
-                       if($status){
+                       if($status)
+                       {
                                $cl_status_updater = new 
check_list_status_updater();
                                $cl_status_updater->update_check_list_status( 
$check_list_id );
                                                
                                return json_encode( array( "status" => 
"deleted" ) );
                        }
-                       else{
+                       else
+                       {
                                return json_encode( array( "status" => 
"not_deleted" ) );
                        }
                }
                
                public function close_case()
                {
+                       if(!$this->add && !$this->edit)
+                       {
+                               return json_encode( array( "status" => "false" 
) );
+                       }
+
                        $case_id = phpgw::get_var('case_id');
                        $check_list_id = phpgw::get_var('check_list_id');
                                
@@ -588,13 +648,19 @@
                                                
                                return json_encode( array( "status" => "true" ) 
);
                        }
-                       else{
+                       else
+                       {
                                return json_encode( array( "status" => "false" 
) );
                        }
                }
                
                public function open_case()
                {
+                       if(!$this->add && !$this->edit)
+                       {
+                               return json_encode( array( "status" => "false" 
) );
+                       }
+
                        $case_id = phpgw::get_var('case_id');
                        $check_list_id = phpgw::get_var('check_list_id');
                                
@@ -603,13 +669,15 @@
                        
                        $case_id = $this->so->store($case);
                                        
-                       if($case_id > 0){
+                       if($case_id > 0)
+                       {
                                $cl_status_updater = new 
check_list_status_updater();
                                $cl_status_updater->update_check_list_status( 
$check_list_id );
                                                
                                return json_encode( array( "status" => "true" ) 
);
                        }
-                       else{
+                       else
+                       {
                                return json_encode( array( "status" => "false" 
) );
                        }
                }

Modified: trunk/controller/inc/class.uicheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list.inc.php     2013-05-06 06:58:50 UTC 
(rev 11090)
+++ trunk/controller/inc/class.uicheck_list.inc.php     2013-05-06 13:22:07 UTC 
(rev 11091)
@@ -1,618 +1,650 @@
 <?php
 
-    /**
-     * phpGroupWare - controller: a part of a Facilities Management System.
-     *
-     * @author Erik Holm-Larsen <address@hidden>
-     * @author Torstein Vadla <address@hidden>
-     * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
-     * This file is part of phpGroupWare.
-     *
-     * phpGroupWare is free software; you can redistribute it and/or modify
-     * it under the terms of the GNU General Public License as published by
-     * the Free Software Foundation; either version 2 of the License, or
-     * (at your option) any later version.
-     *
-     * phpGroupWare is distributed in the hope that it will be useful,
-     * but WITHOUT ANY WARRANTY; without even the implied warranty of
-     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-     * GNU General Public License for more details.
-     *
-     * You should have received a copy of the GNU General Public License
-     * along with phpGroupWare; if not, write to the Free Software
-     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
USA
-     *
-     * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
-     * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
-     * @package property
-     * @subpackage controller
-     * @version $Id$
-     */
-    /**
-     * Import the jQuery class
-     */
-    phpgw::import_class('phpgwapi.jquery');
+       /**
+        * phpGroupWare - controller: a part of a Facilities Management System.
+        *
+        * @author Erik Holm-Larsen <address@hidden>
+        * @author Torstein Vadla <address@hidden>
+        * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
+        * @package property
+        * @subpackage controller
+        * @version $Id$
+        */
+       /**
+        * Import the jQuery class
+        */
+       phpgw::import_class('phpgwapi.jquery');
 
-    /**
-     * Import the yui class
-     */
-    phpgw::import_class('phpgwapi.yui');
-    phpgw::import_class('phpgwapi.uicommon');
-    phpgw::import_class('controller.socheck_list');
-    phpgw::import_class('phpgwapi.datetime');
+       /**
+        * Import the yui class
+        */
+       phpgw::import_class('phpgwapi.yui');
+       phpgw::import_class('phpgwapi.uicommon');
+       phpgw::import_class('controller.socheck_list');
+       phpgw::import_class('phpgwapi.datetime');
 
-    include_class('controller', 'check_list', 'inc/model/');
-    include_class('controller', 'check_item', 'inc/model/');
-    include_class('controller', 'date_generator', 'inc/component/');
-    include_class('controller', 'check_list_status_updater', 'inc/helper/');
-    include_class('controller', 'date_converter', 'inc/helper/');
-    include_class('controller', 'location_finder', 'inc/helper/');
+       include_class('controller', 'check_list', 'inc/model/');
+       include_class('controller', 'check_item', 'inc/model/');
+       include_class('controller', 'date_generator', 'inc/component/');
+       include_class('controller', 'check_list_status_updater', 'inc/helper/');
+       include_class('controller', 'date_converter', 'inc/helper/');
+       include_class('controller', 'location_finder', 'inc/helper/');
 
-    class controller_uicheck_list extends phpgwapi_uicommon
-    {
-        protected $so;
-        protected $so_control;
-        protected $so_control_item;
-        protected $so_check_item;
-        protected $so_procedure;
-        protected $so_control_group_list;
-        protected $so_control_group;
-        protected $so_control_item_list;
-        protected $location_finder;
-        var $public_functions = array(
-            'index' => true,
-            'add_check_list' => true,
-            'save_check_list' => true,
-            'edit_check_list' => true,
-            'print_check_list' => true,
-            'view_control_info' => true,
-            'view_control_details' => true,
-            'view_control_items' => true,
-            'get_check_list_info' => true,
-            'get_cases_for_check_list' => true,
-            'update_status' => true
-        );
+       class controller_uicheck_list extends phpgwapi_uicommon
+       {
+               protected $so;
+               protected $so_control;
+               protected $so_control_item;
+               protected $so_check_item;
+               protected $so_procedure;
+               protected $so_control_group_list;
+               protected $so_control_group;
+               protected $so_control_item_list;
+               protected $location_finder;
 
-        function __construct()
-        {
-            parent::__construct();
+               private $read;
+               private $add;
+               private $edit;
+               private $delete;
 
-            $this->so_control = CreateObject('controller.socontrol');
-            $this->so = CreateObject('controller.socheck_list');
-            $this->so_control_item = CreateObject('controller.socontrol_item');
-            $this->so_check_item = CreateObject('controller.socheck_item');
-            $this->so_procedure = CreateObject('controller.soprocedure');
-            $this->so_control_group_list = 
CreateObject('controller.socontrol_group_list');
-            $this->so_control_group = 
CreateObject('controller.socontrol_group');
-            $this->so_control_item_list = 
CreateObject('controller.socontrol_item_list');
+               var $public_functions = array(
+                       'index' => true,
+                       'add_check_list' => true,
+                       'save_check_list' => true,
+                       'edit_check_list' => true,
+                       'print_check_list' => true,
+                       'view_control_info' => true,
+                       'view_control_details' => true,
+                       'view_control_items' => true,
+                       'get_check_list_info' => true,
+                       'get_cases_for_check_list' => true,
+                       'update_status' => true
+               );
 
-            $this->location_finder = new location_finder();
+               function __construct()
+               {
+                       parent::__construct();
 
-            self::set_active_menu('controller::control::check_list');
-        }
+                       $this->so_control = 
CreateObject('controller.socontrol');
+                       $this->so = CreateObject('controller.socheck_list');
+                       $this->so_control_item = 
CreateObject('controller.socontrol_item');
+                       $this->so_check_item = 
CreateObject('controller.socheck_item');
+                       $this->so_procedure = 
CreateObject('controller.soprocedure');
+                       $this->so_control_group_list = 
CreateObject('controller.socontrol_group_list');
+                       $this->so_control_group = 
CreateObject('controller.socontrol_group');
+                       $this->so_control_item_list = 
CreateObject('controller.socontrol_item_list');
 
-        /**
-         * Public function for displaying checklists  
-         * 
-         * @param HTTP:: phpgw_return_as
-         * @return data array
-         */
-        public function index()
-        {
-            if(phpgw::get_var('phpgw_return_as') == 'json')
-            {
-                return $this->query();
-            }
-            self::add_javascript('phpgwapi', 'yahoo', 'datatable.js');
-            phpgwapi_yui::load_widget('datatable');
-            phpgwapi_yui::load_widget('paginator');
+                       $this->location_finder = new location_finder();
 
-            $data = array(
-                'datatable_name' => 'Sjekkliste (Ikke i bruk)',
-                'form' => array(
-                    'toolbar' => array(
-                        'item' => array(
-                            array('type' => 'filter',
-                                'name' => 'status',
-                                'text' => lang('Status'),
-                                'list' => array(
-                                    array(
-                                        'id' => 'none',
-                                        'name' => lang('Not selected')
-                                    ),
-                                    array(
-                                        'id' => 'NEW',
-                                        'name' => lang('NEW')
-                                    ),
-                                    array(
-                                        'id' => 'PENDING',
-                                        'name' => lang('PENDING')
-                                    ),
-                                    array(
-                                        'id' => 'REJECTED',
-                                        'name' => lang('REJECTED')
-                                    ),
-                                    array(
-                                        'id' => 'ACCEPTED',
-                                        'name' => lang('ACCEPTED')
-                                    )
-                                )
-                            ),
-                            array('type' => 'text',
-                                'text' => lang('searchfield'),
-                                'name' => 'query'
-                            ),
-                            array(
-                                'type' => 'submit',
-                                'name' => 'search',
-                                'value' => lang('Search')
-                            ),
-                        ),
-                    ),
-                ),
-                'datatable' => array(
-                    'source' => self::link(array('menuaction' => 
'controller.uicheck_list.index', 'phpgw_return_as' => 'json')),
-                    'field' => array(
-                        array(
-                            'key' => 'id',
-                            'label' => lang('ID'),
-                            'sortable' => true,
-                            'formatter' => 'YAHOO.portico.formatLink'
-                        ),
-                        array(
-                            'key' => 'title',
-                            'label' => lang('Control title'),
-                            'sortable' => false
-                        ),
-                        array(
-                            'key' => 'start_date',
-                            'label' => lang('start_date'),
-                            'sortable' => false
-                        ),
-                        array(
-                            'key' => 'planned_date',
-                            'label' => lang('planned_date'),
-                            'sortable' => false
-                        ),
-                        array(
-                            'key' => 'end_date',
-                            'label' => lang('end_date'),
-                            'sortable' => false
-                        ),
-                        array(
-                            'key' => 'link',
-                            'hidden' => true
-                        )
-                    )
-                ),
-            );
+                       $this->read     = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1 
+                       $this->add       = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2 
+                       $this->edit     = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4 
+                       $this->delete  = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8 
 
-            self::render_template_xsl('datatable_common', $data);
-        }
+                       
self::set_active_menu('controller::control::check_list');
+               }
 
-        /**
-         * Public function for displaying the add check list form
-         * 
-         * @param HTTP:: location code, control id, date
-         * @return data array
-         */
-        function add_check_list($check_list = null)
-        {
-            if($check_list == null)
-            {
-                $type = phpgw::get_var('type');
-                $control_id = phpgw::get_var('control_id');
-                $deadline_ts = phpgw::get_var('deadline_ts');
+               /**
+                * Public function for displaying checklists  
+                * 
+                * @param HTTP:: phpgw_return_as
+                * @return data array
+                */
+               public function index()
+               {
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               return $this->query();
+                       }
+                       self::add_javascript('phpgwapi', 'yahoo', 
'datatable.js');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('paginator');
 
-                $check_list = new controller_check_list();
-                $check_list->set_control_id($control_id);
-                $check_list->set_deadline($deadline_ts);
-            } else
-            {
-                if($check_list->get_component_id() > 0)
-                {
-                    $type = "component";
-                } else
-                {
-                    $type = "location";
-                }
-            }
+                       $data = array(
+                               'datatable_name' => 'Sjekkliste (Ikke i bruk)',
+                               'form' => array(
+                                       'toolbar' => array(
+                                               'item' => array(
+                                                       array('type' => 
'filter',
+                                                               'name' => 
'status',
+                                                               'text' => 
lang('Status'),
+                                                               'list' => array(
+                                                                       array(
+                                                                               
'id' => 'none',
+                                                                               
'name' => lang('Not selected')
+                                                                       ),
+                                                                       array(
+                                                                               
'id' => 'NEW',
+                                                                               
'name' => lang('NEW')
+                                                                       ),
+                                                                       array(
+                                                                               
'id' => 'PENDING',
+                                                                               
'name' => lang('PENDING')
+                                                                       ),
+                                                                       array(
+                                                                               
'id' => 'REJECTED',
+                                                                               
'name' => lang('REJECTED')
+                                                                       ),
+                                                                       array(
+                                                                               
'id' => 'ACCEPTED',
+                                                                               
'name' => lang('ACCEPTED')
+                                                                       )
+                                                               )
+                                                       ),
+                                                       array('type' => 'text',
+                                                               'text' => 
lang('searchfield'),
+                                                               'name' => 
'query'
+                                                       ),
+                                                       array(
+                                                               'type' => 
'submit',
+                                                               'name' => 
'search',
+                                                               'value' => 
lang('Search')
+                                                       ),
+                                               ),
+                                       ),
+                               ),
+                               'datatable' => array(
+                                       'source' => 
self::link(array('menuaction' => 'controller.uicheck_list.index', 
'phpgw_return_as' => 'json')),
+                                       'field' => array(
+                                               array(
+                                                       'key' => 'id',
+                                                       'label' => lang('ID'),
+                                                       'sortable' => true,
+                                                       'formatter' => 
'YAHOO.portico.formatLink'
+                                               ),
+                                               array(
+                                                       'key' => 'title',
+                                                       'label' => 
lang('Control title'),
+                                                       'sortable' => false
+                                               ),
+                                               array(
+                                                       'key' => 'start_date',
+                                                       'label' => 
lang('start_date'),
+                                                       'sortable' => false
+                                               ),
+                                               array(
+                                                       'key' => 'planned_date',
+                                                       'label' => 
lang('planned_date'),
+                                                       'sortable' => false
+                                               ),
+                                               array(
+                                                       'key' => 'end_date',
+                                                       'label' => 
lang('end_date'),
+                                                       'sortable' => false
+                                               ),
+                                               array(
+                                                       'key' => 'link',
+                                                       'hidden' => true
+                                               )
+                                       )
+                               ),
+                       );
 
-            if(!$location_code = $check_list->get_location_code())
-            {
-                $location_code = phpgw::get_var('location_code');
-                $check_list->set_location_code($location_code);
-                $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$check_list->get_location_code()));
-                $level = 
$this->location_finder->get_location_level($location_code);
-            }
+                       self::render_template_xsl('datatable_common', $data);
+               }
 
-            if($type == "component")
-            {
-                if($check_list != null)
-                {
-                    $location_id = phpgw::get_var('location_id');
-                    $check_list->set_location_id($location_id);
-                    $component_id = phpgw::get_var('component_id');
-                    $check_list->set_component_id($component_id);
-                }
+               /**
+                * Public function for displaying the add check list form
+                * 
+                * @param HTTP:: location code, control id, date
+                * @return data array
+                */
+               function add_check_list($check_list = null)
+               {
+                       if($check_list == null)
+                       {
+                               $type = phpgw::get_var('type');
+                               $control_id = phpgw::get_var('control_id');
+                               $deadline_ts = phpgw::get_var('deadline_ts');
 
-                $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id, 'id' => $component_id));
-                $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
+                               $check_list = new controller_check_list();
+                               $check_list->set_control_id($control_id);
+                               $check_list->set_deadline($deadline_ts);
+                       }
+                       else
+                       {
+                               if($check_list->get_component_id() > 0)
+                               {
+                                       $type = "component";
+                               }
+                               else
+                               {
+                                       $type = "location";
+                               }
+                       }
 
-                $component = new controller_component();
-                $component->set_location_code($component_arr['location_code']);
-                $component->set_xml_short_desc($short_desc);
+                       if(!$location_code = $check_list->get_location_code())
+                       {
+                               $location_code = 
phpgw::get_var('location_code');
+                               $check_list->set_location_code($location_code);
+                               $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$check_list->get_location_code()));
+                               $level = 
$this->location_finder->get_location_level($location_code);
+                       }
 
-                $component_array = $component->toArray();
-                $building_location_code = 
$this->location_finder->get_building_location_code($component_arr['location_code']);
-                $type = "component";
-            } else
-            {
-                $type = "location";
-            }
+                       if($type == "component")
+                       {
+                               if($check_list != null)
+                               {
+                                       $location_id = 
phpgw::get_var('location_id');
+                                       
$check_list->set_location_id($location_id);
+                                       $component_id = 
phpgw::get_var('component_id');
+                                       
$check_list->set_component_id($component_id);
+                               }
 
-            $control = 
$this->so_control->get_single($check_list->get_control_id());
+                               $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id, 'id' => $component_id));
+                               $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
 
-            $year = date("Y", $deadline_ts);
-            $month_nr = date("n", $deadline_ts);
+                               $component = new controller_component();
+                               
$component->set_location_code($component_arr['location_code']);
+                               $component->set_xml_short_desc($short_desc);
 
-            $level = 
$this->location_finder->get_location_level($location_code);
-            $user_role = true;
+                               $component_array = $component->toArray();
+                               $building_location_code = 
$this->location_finder->get_building_location_code($component_arr['location_code']);
+                               $type = "component";
+                       }
+                       else
+                       {
+                               $type = "location";
+                       }
 
-            // Fetches buildings on property
-            $buildings_on_property = 
$this->location_finder->get_buildings_on_property($user_role, $location_code, 
$level);
+                       $control = 
$this->so_control->get_single($check_list->get_control_id());
 
-            $data = array
-                (
-                'location_array' => $location_array,
-                'component_array' => $component_array,
-                'control' => $control,
-                'check_list' => $check_list,
-                'buildings_on_property' => $buildings_on_property,
-                'type' => $type,
-                'current_year' => $year,
-                'current_month_nr' => $month_nr,
-                'building_location_code' => $building_location_code,
-                'location_level' => $level,
-                'check_list_type' => 'add_check_list'
-            );
+                       $year = date("Y", $deadline_ts);
+                       $month_nr = date("n", $deadline_ts);
 
-            $GLOBALS['phpgw']->jqcal->add_listener('planned_date');
-            $GLOBALS['phpgw']->jqcal->add_listener('completed_date');
+                       $level = 
$this->location_finder->get_location_level($location_code);
+                       $user_role = true;
 
-            self::add_javascript('controller', 'controller', 'custom_ui.js');
-            self::add_javascript('controller', 'controller', 'ajax.js');
-            self::add_javascript('controller', 'controller', 'check_list.js');
+                       // Fetches buildings on property
+                       $buildings_on_property = 
$this->location_finder->get_buildings_on_property($user_role, $location_code, 
$level);
 
-            self::render_template_xsl(array('check_list/add_check_list', 
'check_list/fragments/nav_control_plan',
-                'check_list/fragments/check_list_top_section', 
'check_list/fragments/add_check_list_menu',
-                'check_list/fragments/select_buildings_on_property'), $data);
-        }
+                       $data = array
+                       (
+                               'location_array' => $location_array,
+                               'component_array' => $component_array,
+                               'control' => $control,
+                               'check_list' => $check_list,
+                               'buildings_on_property' => 
$buildings_on_property,
+                               'type' => $type,
+                               'current_year' => $year,
+                               'current_month_nr' => $month_nr,
+                               'building_location_code' => 
$building_location_code,
+                               'location_level' => $level,
+                               'check_list_type' => 'add_check_list'
+                       );
 
-        /**
-         * Public function for displaying the edit check list form  
-         * 
-         * @param HTTP:: check list id
-         * @return data array
-         */
-        function edit_check_list($check_list = null)
-        {
-            if($check_list == null)
-            {
-                $check_list_id = phpgw::get_var('check_list_id');
-                $check_list = $this->so->get_single($check_list_id);
-            }
+                       $GLOBALS['phpgw']->jqcal->add_listener('planned_date');
+                       
$GLOBALS['phpgw']->jqcal->add_listener('completed_date');
 
-            $control = 
$this->so_control->get_single($check_list->get_control_id());
+                       self::add_javascript('controller', 'controller', 
'custom_ui.js');
+                       self::add_javascript('controller', 'controller', 
'ajax.js');
+                       self::add_javascript('controller', 'controller', 
'check_list.js');
 
-            $component_id = $check_list->get_component_id();
+                       
self::render_template_xsl(array('check_list/add_check_list', 
'check_list/fragments/nav_control_plan',
+                               'check_list/fragments/check_list_top_section', 
'check_list/fragments/add_check_list_menu',
+                               
'check_list/fragments/select_buildings_on_property'), $data);
+               }
 
-            if($component_id > 0)
-            {
-                $location_id = $check_list->get_location_id();
-                $component_id = $check_list->get_component_id();
+               /**
+                * Public function for displaying the edit check list form  
+                * 
+                * @param HTTP:: check list id
+                * @return data array
+                */
+               function edit_check_list($check_list = null)
+               {
+                       if($check_list == null)
+                       {
+                               $check_list_id = 
phpgw::get_var('check_list_id');
+                               $check_list = 
$this->so->get_single($check_list_id);
+                       }
 
-                $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id, 'id' => $component_id));
-                $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
+                       $control = 
$this->so_control->get_single($check_list->get_control_id());
 
-                $component = new controller_component();
-                $component->set_location_code($component_arr['location_code']);
-                $component->set_xml_short_desc($short_desc);
-                $component_array = $component->toArray();
+                       $component_id = $check_list->get_component_id();
 
-                $type = 'component';
-                $building_location_code = 
$this->location_finder->get_building_location_code($component_arr['location_code']);
-            } else
-            {
-                $location_code = $check_list->get_location_code();
-                $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
-                $type = 'location';
-                $level = 
$this->location_finder->get_location_level($location_code);
-            }
+                       if($component_id > 0)
+                       {
+                               $location_id = $check_list->get_location_id();
+                               $component_id = $check_list->get_component_id();
 
-            $year = date("Y", $check_list->get_deadline());
-            $month = date("n", $check_list->get_deadline());
+                               $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id, 'id' => $component_id));
+                               $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
 
-            $level = 
$this->location_finder->get_location_level($location_code);
-            $user_role = true;
+                               $component = new controller_component();
+                               
$component->set_location_code($component_arr['location_code']);
+                               $component->set_xml_short_desc($short_desc);
+                               $component_array = $component->toArray();
 
-            // Fetches buildings on property
-            $buildings_on_property = 
$this->location_finder->get_buildings_on_property($user_role, $location_code, 
$level);
+                               $type = 'component';
+                               $building_location_code = 
$this->location_finder->get_building_location_code($component_arr['location_code']);
+                       }
+                       else
+                       {
+                               $location_code = 
$check_list->get_location_code();
+                               $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
+                               $type = 'location';
+                               $level = 
$this->location_finder->get_location_level($location_code);
+                       }
 
-            $data = array
-                (
-                'control' => $control,
-                'check_list' => $check_list,
-                '$buildings_on_property' => $buildings_on_property,
-                'location_array' => $location_array,
-                'component_array' => $component_array,
-                'type' => $type,
-                'current_year' => $year,
-                'current_month_nr' => $month,
-                'building_location_code' => $building_location_code,
-                'location_level' => $level
-            );
+                       $year = date("Y", $check_list->get_deadline());
+                       $month = date("n", $check_list->get_deadline());
 
-            $GLOBALS['phpgw']->jqcal->add_listener('planned_date');
-            $GLOBALS['phpgw']->jqcal->add_listener('completed_date');
-            $GLOBALS['phpgw']->jqcal->add_listener('deadline_date');
+                       $level = 
$this->location_finder->get_location_level($location_code);
+                       $user_role = true;
 
-            self::add_javascript('controller', 'controller', 'custom_ui.js');
-            self::add_javascript('controller', 'controller', 'ajax.js');
-            self::add_javascript('controller', 'controller', 'check_list.js');
+                       // Fetches buildings on property
+                       $buildings_on_property = 
$this->location_finder->get_buildings_on_property($user_role, $location_code, 
$level);
 
-            
self::render_template_xsl(array('check_list/fragments/check_list_menu', 
'check_list/fragments/nav_control_plan',
-                'check_list/fragments/check_list_top_section', 
'check_list/edit_check_list',
-                'check_list/fragments/select_buildings_on_property'), $data);
-        }
+                       $data = array
+                       (
+                               'control' => $control,
+                               'check_list' => $check_list,
+                               '$buildings_on_property' => 
$buildings_on_property,
+                               'location_array' => $location_array,
+                               'component_array' => $component_array,
+                               'type' => $type,
+                               'current_year' => $year,
+                               'current_month_nr' => $month,
+                               'building_location_code' => 
$building_location_code,
+                               'location_level' => $level
+                       );
 
-        /**
-         * Public function for saving a check list
-         * 
-         * @param HTTP:: location code, control id, status etc.. (check list 
details) 
-         * @return data array
-         */
-        function save_check_list()
-        {
-            $check_list_id = phpgw::get_var('check_list_id');
-            $control_id = phpgw::get_var('control_id');
-            $status = (int) phpgw::get_var('status');
-            $type = phpgw::get_var('type');
-            $deadline_date = phpgw::get_var('deadline_date', 'string');
-            $planned_date = phpgw::get_var('planned_date', 'string');
-            $completed_date = phpgw::get_var('completed_date', 'string');
-            $comment = phpgw::get_var('comment', 'string');
+                       $GLOBALS['phpgw']->jqcal->add_listener('planned_date');
+                       
$GLOBALS['phpgw']->jqcal->add_listener('completed_date');
+                       $GLOBALS['phpgw']->jqcal->add_listener('deadline_date');
 
-            $deadline_date_ts = 
date_converter::date_to_timestamp($deadline_date);
+                       self::add_javascript('controller', 'controller', 
'custom_ui.js');
+                       self::add_javascript('controller', 'controller', 
'ajax.js');
+                       self::add_javascript('controller', 'controller', 
'check_list.js');
 
-            if($planned_date != '')
-            {
-                $planned_date_ts = 
date_converter::date_to_timestamp($planned_date);
-            } else
-            {
-                $planned_date_ts = 0;
-            }
+                       
self::render_template_xsl(array('check_list/fragments/check_list_menu', 
'check_list/fragments/nav_control_plan',
+                               'check_list/fragments/check_list_top_section', 
'check_list/edit_check_list',
+                               
'check_list/fragments/select_buildings_on_property'), $data);
+               }
 
-            if($completed_date != '')
-            {
-                $completed_date_ts = 
phpgwapi_datetime::date_to_timestamp($completed_date);
-                $status = controller_check_list::STATUS_DONE;
-            } else
-            {
-                $completed_date_ts = 0;
-            }
+               /**
+                * Public function for saving a check list
+                * 
+                * @param HTTP:: location code, control id, status etc.. (check 
list details) 
+                * @return data array
+                */
+               function save_check_list()
+               {
+                       $check_list_id = phpgw::get_var('check_list_id');
+                       if(!$this->add && !$this->edit)
+                       {
+                               phpgwapi_cache::message_set('No access', 
'error');
+                               $this->redirect(array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
+                       }
 
-            if($check_list_id > 0)
-            {
-                $check_list = $this->so->get_single($check_list_id);
-            } else
-            {
-                $check_list = new controller_check_list();
-                $check_list->set_control_id($control_id);
-                $location_code = phpgw::get_var('location_code');
-                $check_list->set_location_code($location_code);
+                       $control_id = phpgw::get_var('control_id');
+                       $status = (int) phpgw::get_var('status');
+                       $type = phpgw::get_var('type');
+                       $deadline_date = phpgw::get_var('deadline_date', 
'string');
+                       $planned_date = phpgw::get_var('planned_date', 
'string');
+                       $completed_date = phpgw::get_var('completed_date', 
'string');
+                       $comment = phpgw::get_var('comment', 'string');
 
-                if($type == "component")
-                {
-                    $location_id = phpgw::get_var('location_id');
-                    $component_id = phpgw::get_var('component_id');
-                    $check_list->set_location_id($location_id);
-                    $check_list->set_component_id($component_id);
-                }
-            }
+                       $deadline_date_ts = 
date_converter::date_to_timestamp($deadline_date);
 
-            $check_list->set_status($status);
-            $check_list->set_comment($comment);
-            $check_list->set_deadline($deadline_date_ts);
-            $check_list->set_planned_date($planned_date_ts);
-            $check_list->set_completed_date($completed_date_ts);
+                       if($planned_date != '')
+                       {
+                               $planned_date_ts = 
date_converter::date_to_timestamp($planned_date);
+                       }
+                       else
+                       {
+                               $planned_date_ts = 0;
+                       }
 
-            if($check_list->validate())
-            {
-                $check_list_id = $this->so->store($check_list);
+                       if($completed_date != '')
+                       {
+                               $completed_date_ts = 
phpgwapi_datetime::date_to_timestamp($completed_date);
+                               $status = controller_check_list::STATUS_DONE;
+                       }
+                       else
+                       {
+                               $completed_date_ts = 0;
+                       }
 
-                $cl_status_updater = new check_list_status_updater();
-                $cl_status_updater->update_check_list_status($check_list_id);
+                       if($check_list_id > 0)
+                       {
+                               $check_list = 
$this->so->get_single($check_list_id);
+                       }
+                       else
+                       {
+                               $check_list = new controller_check_list();
+                               $check_list->set_control_id($control_id);
+                               $location_code = 
phpgw::get_var('location_code');
+                               $check_list->set_location_code($location_code);
 
-                if($check_list_id > 0)
-                {
-                    $this->redirect(array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
-                } else
-                {
-                    $this->edit_check_list($check_list);
-                }
-            } else
-            {
-                if($check_list->get_id() > 0)
-                {
-                    $this->edit_check_list($check_list);
-                } else
-                {
-                    $this->add_check_list($check_list);
-                }
-            }
-        }
+                               if($type == "component")
+                               {
+                                       $location_id = 
phpgw::get_var('location_id');
+                                       $component_id = 
phpgw::get_var('component_id');
+                                       
$check_list->set_location_id($location_id);
+                                       
$check_list->set_component_id($component_id);
+                               }
+                       }
 
-        function view_control_info()
-        {
-            $check_list_id = phpgw::get_var('check_list_id');
+                       $check_list->set_status($status);
+                       $check_list->set_comment($comment);
+                       $check_list->set_deadline($deadline_date_ts);
+                       $check_list->set_planned_date($planned_date_ts);
+                       $check_list->set_completed_date($completed_date_ts);
 
-            $check_list = $this->so->get_single($check_list_id);
-            $control = 
$this->so_control->get_single($check_list->get_control_id());
+                       if($check_list->validate())
+                       {
+                               $check_list_id = $this->so->store($check_list);
 
-            $component_id = $check_list->get_component_id();
+                               $cl_status_updater = new 
check_list_status_updater();
+                               
$cl_status_updater->update_check_list_status($check_list_id);
 
-            if($component_id > 0)
-            {
-                $location_id = $check_list->get_location_id();
-                $component_id = $check_list->get_component_id();
+                               if($check_list_id > 0)
+                               {
+                                       $this->redirect(array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
+                               }
+                               else
+                               {
+                                       $this->edit_check_list($check_list);
+                               }
+                       }
+                       else
+                       {
+                               if($check_list->get_id() > 0)
+                               {
+                                       $this->edit_check_list($check_list);
+                               } else
+                               {
+                                       $this->add_check_list($check_list);
+                               }
+                       }
+               }
 
-                $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id, 'id' => $component_id));
-                $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
+               function view_control_info()
+               {
+                       $check_list_id = phpgw::get_var('check_list_id');
 
-                $component = new controller_component();
-                $component->set_location_code($component_arr['location_code']);
-                $component->set_xml_short_desc($short_desc);
-                $component_array = $component->toArray();
+                       $check_list = $this->so->get_single($check_list_id);
+                       $control = 
$this->so_control->get_single($check_list->get_control_id());
 
-                $type = 'component';
-                $building_location_code = 
$this->location_finder->get_building_location_code($component_arr['location_code']);
-            } else
-            {
-                $location_code = $check_list->get_location_code();
-                $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
-                $type = 'location';
-                $level = 
$this->location_finder->get_location_level($location_code);
-            }
+                       $component_id = $check_list->get_component_id();
 
-            $year = date("Y", $check_list->get_deadline());
-            $month = date("n", $check_list->get_deadline());
+                       if($component_id > 0)
+                       {
+                               $location_id = $check_list->get_location_id();
+                               $component_id = $check_list->get_component_id();
 
-            $level = 
$this->location_finder->get_location_level($location_code);
-            $user_role = true;
+                               $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id, 'id' => $component_id));
+                               $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
 
-            // Fetches buildings on property
-            $buildings_on_property = 
$this->location_finder->get_buildings_on_property($user_role, $location_code, 
$level);
+                               $component = new controller_component();
+                               
$component->set_location_code($component_arr['location_code']);
+                               $component->set_xml_short_desc($short_desc);
+                               $component_array = $component->toArray();
 
-            $data = array
-                (
-                'control' => $control,
-                'check_list' => $check_list,
-                'buildings_on_property' => $buildings_on_property,
-                'location_array' => $location_array,
-                'component_array' => $component_array,
-                'type' => $type,
-                'current_year' => $year,
-                'current_month_nr' => $month,
-                'building_location_code' => $building_location_code,
-                'location_level' => $level
-            );
+                               $type = 'component';
+                               $building_location_code = 
$this->location_finder->get_building_location_code($component_arr['location_code']);
+                       }
+                       else
+                       {
+                               $location_code = 
$check_list->get_location_code();
+                               $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
+                               $type = 'location';
+                               $level = 
$this->location_finder->get_location_level($location_code);
+                       }
 
-            phpgwapi_jquery::load_widget('core');
+                       $year = date("Y", $check_list->get_deadline());
+                       $month = date("n", $check_list->get_deadline());
 
-            
self::render_template_xsl(array('check_list/fragments/check_list_menu', 
'check_list/fragments/check_list_top_section',
-                'check_list/fragments/nav_control_plan', 
'check_list/view_control_info',
-                'check_list/fragments/select_buildings_on_property'), $data);
-        }
+                       $level = 
$this->location_finder->get_location_level($location_code);
+                       $user_role = true;
 
-        function view_control_details()
-        {
-            $control_id = phpgw::get_var('control_id');
+                       // Fetches buildings on property
+                       $buildings_on_property = 
$this->location_finder->get_buildings_on_property($user_role, $location_code, 
$level);
 
-            $control = $this->so_control->get_single($control_id);
+                       $data = array
+                       (
+                               'control' => $control,
+                               'check_list' => $check_list,
+                               'buildings_on_property' => 
$buildings_on_property,
+                               'location_array' => $location_array,
+                               'component_array' => $component_array,
+                               'type' => $type,
+                               'current_year' => $year,
+                               'current_month_nr' => $month,
+                               'building_location_code' => 
$building_location_code,
+                               'location_level' => $level
+                       );
 
-            $data = array
-                (
-                'control' => $control,
-            );
+                       phpgwapi_jquery::load_widget('core');
 
-            self::render_template_xsl('check_list/view_control_details', 
$data);
-        }
+                       
self::render_template_xsl(array('check_list/fragments/check_list_menu', 
'check_list/fragments/check_list_top_section',
+                               'check_list/fragments/nav_control_plan', 
'check_list/view_control_info',
+                               
'check_list/fragments/select_buildings_on_property'), $data);
+               }
 
-        function view_control_items()
-        {
-            $check_list_id = phpgw::get_var('check_list_id');
-            $check_list = $this->so->get_single($check_list_id);
+               function view_control_details()
+               {
+                       $control_id = phpgw::get_var('control_id');
 
-            $control = 
$this->so_control->get_single($check_list->get_control_id());
-            $control_groups = 
$this->so_control_group_list->get_control_groups_by_control($control->get_id());
+                       $control = $this->so_control->get_single($control_id);
 
-            $saved_groups_with_items_array = array();
+                       $data = array
+                       (
+                               'control' => $control,
+                       );
 
-            //Populating array with saved control items for each group
-            foreach($control_groups as $control_group)
-            {
-                $saved_control_items = 
$this->so_control_item_list->get_control_items_by_control_and_group($control->get_id(),
 $control_group->get_id());
+                       
self::render_template_xsl('check_list/view_control_details', $data);
+               }
 
-                $control_item = 
$this->so_control_item->get_single($control_item_id);
+               function view_control_items()
+               {
+                       $check_list_id = phpgw::get_var('check_list_id');
+                       $check_list = $this->so->get_single($check_list_id);
 
-                $saved_groups_with_items_array[] = array("control_group" => 
$control_group->toArray(), "control_items" => $saved_control_items);
-            }
+                       $control = 
$this->so_control->get_single($check_list->get_control_id());
+                       $control_groups = 
$this->so_control_group_list->get_control_groups_by_control($control->get_id());
 
-            $data = array
-                (
-                'saved_groups_with_items_array' => 
$saved_groups_with_items_array,
-                'check_list' => $check_list
-            );
+                       $saved_groups_with_items_array = array();
 
-            self::render_template_xsl('check_list/view_control_items', $data);
-        }
+                       //Populating array with saved control items for each 
group
+                       foreach($control_groups as $control_group)
+                       {
+                               $saved_control_items = 
$this->so_control_item_list->get_control_items_by_control_and_group($control->get_id(),
 $control_group->get_id());
 
-        public function print_check_list()
-        {
-            $check_list_id = phpgw::get_var('check_list_id');
-            $check_list = $this->so->get_single($check_list_id);
+                               $control_item = 
$this->so_control_item->get_single($control_item_id);
 
-            $control = 
$this->so_control->get_single($check_list->get_control_id());
-            $control_groups = 
$this->so_control_group_list->get_control_groups_by_control($control->get_id());
+                               $saved_groups_with_items_array[] = 
array("control_group" => $control_group->toArray(), "control_items" => 
$saved_control_items);
+                       }
 
-            $saved_groups_with_items_array = array();
+                       $data = array
+                       (
+                               'saved_groups_with_items_array' => 
$saved_groups_with_items_array,
+                               'check_list' => $check_list
+                       );
 
-            //Populating array with saved control items for each group
-            foreach($control_groups as $control_group)
-            {
-                $saved_control_items = 
$this->so_control_item_list->get_control_items_by_control_and_group($control->get_id(),
 $control_group->get_id());
+                       
self::render_template_xsl('check_list/view_control_items', $data);
+               }
 
-                $control_item = 
$this->so_control_item->get_single($control_item_id);
+               public function print_check_list()
+               {
+                       $check_list_id = phpgw::get_var('check_list_id');
+                       $check_list = $this->so->get_single($check_list_id);
 
-                $saved_groups_with_items_array[] = array("control_group" => 
$control_group->toArray(), "control_items" => $saved_control_items);
-            }
+                       $control = 
$this->so_control->get_single($check_list->get_control_id());
+                       $control_groups = 
$this->so_control_group_list->get_control_groups_by_control($control->get_id());
 
-            $data = array
-                (
-                'saved_groups_with_items_array' => 
$saved_groups_with_items_array,
-                'check_list' => $check_list
-            );
+                       $saved_groups_with_items_array = array();
 
-            self::render_template_xsl('check_list/print_check_list', $data);
-        }
+                       //Populating array with saved control items for each 
group
+                       foreach($control_groups as $control_group)
+                       {
+                               $saved_control_items = 
$this->so_control_item_list->get_control_items_by_control_and_group($control->get_id(),
 $control_group->get_id());
 
-        // Returns check list info as JSON
-        public function get_check_list_info()
-        {
-            $check_list_id = phpgw::get_var('check_list_id');
-            $check_list = 
$this->so_check_list->get_single_with_check_items($check_list_id, "open");
+                               $control_item = 
$this->so_control_item->get_single($control_item_id);
 
-            return json_encode($check_list);
-        }
+                               $saved_groups_with_items_array[] = 
array("control_group" => $control_group->toArray(), "control_items" => 
$saved_control_items);
+                       }
 
-        // Returns open cases for a check list as JSON 
-        public function get_cases_for_check_list()
-        {
-            $check_list_id = phpgw::get_var('check_list_id');
+                       $data = array
+                       (
+                               'saved_groups_with_items_array' => 
$saved_groups_with_items_array,
+                               'check_list' => $check_list
+                       );
 
-            $check_items_with_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, null, "open", 
null);
+                       
self::render_template_xsl('check_list/print_check_list', $data);
+               }
 
-            return json_encode($check_items_with_cases);
-        }
+               // Returns check list info as JSON
+               public function get_check_list_info()
+               {
+                       $check_list_id = phpgw::get_var('check_list_id');
+                       $check_list = 
$this->so_check_list->get_single_with_check_items($check_list_id, "open");
 
-        /**
-         * Public function for updateing status for a check list
-         * 
-         * @return json encoded array with status saved or not saved
-         */
+                       return json_encode($check_list);
+               }
+
+               // Returns open cases for a check list as JSON 
+               public function get_cases_for_check_list()
+               {
+                       $check_list_id = phpgw::get_var('check_list_id');
+
+                       $check_items_with_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, null, "open", 
null);
+
+                       return json_encode($check_items_with_cases);
+               }
+
+               /**
+                * Public function for updateing status for a check list
+                * 
+                * @return json encoded array with status saved or not saved
+                */
                public function update_status()
                {
+                       if(!$this->add && !$this->edit)
+                       {
+                               return json_encode( array( "status" => 
'not_saved') );
+                       }
+
                        $check_list_id = phpgw::get_var('check_list_id');
                        $check_list_status = phpgw::get_var('status');
 
@@ -622,7 +654,7 @@
 
                        if($this->so->store($check_list))
                        {
-                               return json_encode( array( 'status' => 
$check_list_status) );
+                               return json_encode( array( 'status' => 
$check_list_status) );
                        }
                        else
                        {
@@ -630,9 +662,9 @@
                        }
                }
 
-        public function query()
-        {
-            
-        }
+               public function query()
+               {
+                       
+               }
 
-    }
+       }

Modified: trunk/controller/inc/class.uicontrol.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol.inc.php        2013-05-06 06:58:50 UTC 
(rev 11090)
+++ trunk/controller/inc/class.uicontrol.inc.php        2013-05-06 13:22:07 UTC 
(rev 11091)
@@ -60,6 +60,11 @@
     private $so_check_item;
     private $_category_acl;            
 
+    private $read;
+    private $add;
+    private $edit;
+    private $delete;
+
     public $public_functions = array
     (
                        'index'                                                 
                                                =>      true,
@@ -80,12 +85,12 @@
                {
                        parent::__construct('controller');
 
-                       $read    = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_READ, 'controller');//1 
-                       $add     = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_ADD, 'controller');//2 
-                       $edit    = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_EDIT, 'controller');//4 
-                       $delete  = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_DELETE, 'controller');//8 
+                       $this->read    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1 
+                       $this->add     = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2 
+                       $this->edit    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4 
+                       $this->delete  = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8 
                        
-                       $manage  = $GLOBALS['phpgw']->acl->check('.control', 
16, 'controller');//16
+                       $this->manage  = 
$GLOBALS['phpgw']->acl->check('.control', 16, 'controller');//16
 
                        //if(!$manage)
                        
@@ -323,7 +328,13 @@
                 * @param HTTP:: control id, control details fields
                 * @return redirect to function view_control_groups
                 */
-               public function save_control_details(){
+               public function save_control_details()
+               {
+                       if(!$this->add && !$this->edit)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'controller.uicontrol.index'));
+                       }
+
                        $control_id = phpgw::get_var('control_id');
                        
                        // Update existing control details
@@ -366,7 +377,8 @@
                                
                                $control_id = $this->so->store($control);
                                $this->redirect(array('menuaction' => 
'controller.uicontrol.view_control_groups', 'control_id' => $control_id));      
  
-                       }else
+                       }
+                       else
                        {
                                        $this->view_control_details($control);
                        }
@@ -439,6 +451,11 @@
                 */
                public function save_control_groups()
                {
+                       if(!$this->add && !$this->edit)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'controller.uicontrol.index'));
+                       }
+
                        $control_id = phpgw::get_var('control_id');
                        $control_group_ids = 
phpgw::get_var('control_group_ids');
 

Modified: trunk/controller/inc/class.uicontrol_group.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_group.inc.php  2013-05-06 06:58:50 UTC 
(rev 11090)
+++ trunk/controller/inc/class.uicontrol_group.inc.php  2013-05-06 13:22:07 UTC 
(rev 11091)
@@ -51,6 +51,11 @@
                private $so_control_item_list;
                private $so_control_group_list;
 
+           private $read;
+           private $add;
+           private $edit;
+           private $delete;
+
                public $public_functions = array
                (
                        'index'                                                 
                                                                        =>      
true,
@@ -71,11 +76,17 @@
                        $this->so_control_item_list = 
CreateObject('controller.socontrol_item_list');
                        $this->so_control_group_list = 
CreateObject('controller.socontrol_group_list');
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::control_group";
+
+                       $this->read    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1 
+                       $this->add     = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2 
+                       $this->edit    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4 
+                       $this->delete  = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8 
                }
 
                public function index()
                {
-                       if(phpgw::get_var('phpgw_return_as') == 'json') {
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
                                return $this->query();
                        }
 
@@ -204,6 +215,12 @@
 
                        if(isset($_POST['save_control_group'])) // The user has 
pressed the save button
                        {
+                               if(!$this->add && !$this->edit)
+                               {
+                                       phpgwapi_cache::message_set('No 
access', 'error');
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_group.index'));
+                               }
+
                                if(isset($control_group)) // Add new values to 
the control item
                                {
                                        
$control_group->set_group_name(phpgw::get_var('group_name'));
@@ -260,6 +277,12 @@
                        }
                        else if(isset($_POST['remove_control_group_items']))
                        {
+                               if(!$this->add && !$this->edit)
+                               {
+                                       phpgwapi_cache::message_set('No 
access', 'error');
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_group.index'));
+                               }
+
                                $control_item_ids = array();
                                // Fetching selected control items
                                $control_tag_ids = 
phpgw::get_var('item_remove_ids');
@@ -388,6 +411,12 @@
                        }
                        else if(isset($_POST['save_control_group_items']))
                        {
+                               if(!$this->add && !$this->edit)
+                               {
+                                       phpgwapi_cache::message_set('No 
access', 'error');
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_group.index'));
+                               }
+
                                $tab_to_display = 'control_group_items';
                                //update control items with control group id
                                //$control_group_id = 
phpgw::get_var('control_group_id');
@@ -534,6 +563,12 @@
 
                public function save_group_and_item_order()
                {
+                       if(!$this->add && !$this->edit)
+                       {
+                               phpgwapi_cache::message_set('No access', 
'error');
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'controller.uicontrol_group.index'));
+                       }
+
                        $control_id = phpgw::get_var('control_id');
                        $item_order_str = phpgw::get_var('item_order');
                        $group_order_str = phpgw::get_var('group_order');
@@ -644,7 +679,8 @@
                        {
                                $user_rows_per_page = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
                        }
-                       else {
+                       else
+                       {
                                $user_rows_per_page = 10;
                        }
 
@@ -767,12 +803,18 @@
                                $control_groups_array = 
$this->so->get_all_control_groups_array();
                        }
                        else
+                       {
                                $control_groups_array = 
$this->so->get_control_groups_by_control_area($control_area_id);
+                       }
 
                        if(count($control_groups_array)>0)
+                       {
                                return json_encode( $control_groups_array );
+                       }
                        else
+                       {
                                return null;
+                       }
                }
 
                public function get_control_area_by_control_group()
@@ -798,9 +840,13 @@
                        }
 
                        if(count($control_areas_array)>0)
+                       {
                                return json_encode( $control_areas_array );
+                       }
                        else
+                       {
                                return null;
+                       }
                }
 
        }

Modified: trunk/controller/inc/class.uicontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_item.inc.php   2013-05-06 06:58:50 UTC 
(rev 11090)
+++ trunk/controller/inc/class.uicontrol_item.inc.php   2013-05-06 13:22:07 UTC 
(rev 11091)
@@ -47,8 +47,12 @@
                private $so;
                private $so_control_group;
                private $so_control_item_option;
-               
 
+           private $read;
+           private $add;
+           private $edit;
+           private $delete;
+
                public $public_functions = array
                (
                        'index'                                                 
                =>      true,
@@ -68,8 +72,14 @@
                        $this->so_control_item_list = 
CreateObject('controller.socontrol_item_list');
                        $this->so_control_group = 
CreateObject('controller.socontrol_group');
                        $this->so_control_item_option = 
CreateObject('controller.socontrol_item_option');
-                       
+
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::control_item";
+
+                       $this->read    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1 
+                       $this->add     = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2 
+                       $this->edit    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4 
+                       $this->delete  = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8 
+
                }
 
                public function index()
@@ -99,7 +109,7 @@
                                (
                                        'id'    => $cat_list['cat_id'],
                                        'name'  => $cat_list['name'],
-                               );              
+                               );
                        }
                        // END categories
 
@@ -118,7 +128,7 @@
                                                                'text' => 
lang('Control_area'),
                                                                'list' => 
$control_areas_array2,
                                                        ),
-                                                       array('type' => 'text', 
+                                                       array('type' => 'text',
                                                                'text' => 
lang('searchfield'),
                                                                'name' => 
'query'
                                                        ),
@@ -172,11 +182,11 @@
                                        )
                                ),
                        );
-                       
+
                        phpgwapi_yui::load_widget('paginator');
                        phpgwapi_yui::load_widget('datatable');
                        self::add_javascript('phpgwapi', 'yahoo', 
'datatable.js');
-               
+
                        self::render_template_xsl( array( 'datatable_common' ), 
$data);
                }
 
@@ -203,35 +213,35 @@
                        if($control_item == null)
                        {
                                $control_item_id = phpgw::get_var('id');
-                       
+
                                // Edit control item
                                if($control_item_id > 0)
                                {
-                                       $control_item = 
$this->so->get_single_with_options($control_item_id); 
+                                       $control_item = 
$this->so->get_single_with_options($control_item_id);
                                }
                                // New control item
                                else
                                {
                                        $control_item = new 
controller_control_item();
-                               }       
+                               }
                        }
-                       
+
                        // Sigurd: START as categories
                        $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
                        $cats->supress_info     = true;
-                       
+
                        $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
                        $control_areas_array = $control_areas['cat_list'];
 
                        $control_groups_array = 
$this->so_control_group->get_control_group_array();
 
                        // Hack to fix display of &nbsp; char
-      $what_to_do_fixed = str_replace( "&nbsp;", " 
",$control_item->get_what_to_do() );
-      $control_item->set_what_to_do( $what_to_do_fixed );
-      
-      $how_to_do_fixed = str_replace( "&nbsp;", " 
",$control_item->get_how_to_do() );
-      $control_item->set_how_to_do( $how_to_do_fixed );
-                       
+                       $what_to_do_fixed = str_replace( "&nbsp;", " 
",$control_item->get_what_to_do() );
+                       $control_item->set_what_to_do( $what_to_do_fixed );
+
+               $how_to_do_fixed = str_replace( "&nbsp;", " 
",$control_item->get_how_to_do() );
+                       $control_item->set_how_to_do( $how_to_do_fixed );
+
                        $data = array
                        (
                                'editable'                              => true,
@@ -241,15 +251,20 @@
                        );
 
                        $this->use_yui_editor(array('what_to_do','how_to_do'));
-                       
+
                        phpgwapi_jquery::load_widget('core');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
 
                        self::render_template_xsl('control_item/control_item', 
$data);
                }
-               
+
                public function save()
                {
+                       if(!$this->add && !$this->edit)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'controller.uicontrol_item.index'));
+                       }
+
                        $control_item_id = phpgw::get_var('id');
                        $title = phpgw::get_var('title');
                        $required = phpgw::get_var('required') == 'on' ? true : 
false;
@@ -269,8 +284,8 @@
                        else
                        {
                                $control_item = new controller_control_item();
-                       } 
-                       
+                       }
+
                        $control_item->set_title($title);
                        $control_item->set_required($required);
                        $control_item->set_control_group_id($control_group_id);
@@ -278,61 +293,64 @@
                        $control_item->set_type($type);
                        $control_item->set_what_to_do($what_to_do_txt);
                        $control_item->set_how_to_do($how_to_do_txt);
-      
+
                        if( $control_item->validate() )
                        {
-        $transaction_status = true;
-        
-        $db_control_item = $this->so->get_db();
-        $db_control_item->transaction_begin();
-                               
+                               $transaction_status = true;
+
+                               $db_control_item = $this->so->get_db();
+                               $db_control_item->transaction_begin();
+
                                $saved_control_item_id = 
$this->so->store($control_item);
-        
-        if($saved_control_item_id == 0)
-        {
-          $transaction_status = false;
-        }
-       
-        // Delete item option values
+
+                               if($saved_control_item_id == 0)
+                               {
+                               $transaction_status = false;
+                               }
+
+                               // Delete item option values
                                $delete_status = 
$this->so->delete_option_values( $saved_control_item_id );
-                               
-        if($delete_status == 0)
-        {
-          $transaction_status = false;
-        }
-        
-        if( $transaction_status == true)
-        {
-          $db_control_item->transaction_commit();
-        }
-        else
-        {
-          $db_control_item->transaction_abort();
-        }
-        
-        $option_values = array();
-        $option_values = phpgw::get_var('option_values');
-                       
-        $option_values_array = array();
-        foreach($option_values as $option_value){
-          $control_item_option = new 
controller_control_item_option($option_value, $saved_control_item_id);
-          $option_values_array[] = $control_item_option;
-        }
-      
-        $control_item->set_options_array($option_values_array);
-        
-        // Add new control item option values
+
+                               if($delete_status == 0)
+                               {
+                                       $transaction_status = false;
+                               }
+
+                               if( $transaction_status == true)
+                               {
+                                       $db_control_item->transaction_commit();
+                               }
+                               else
+                               {
+                                       $db_control_item->transaction_abort();
+                               }
+
+                               $option_values = array();
+                               $option_values = 
phpgw::get_var('option_values');
+
+                               $option_values_array = array();
+                               foreach($option_values as $option_value)
+                               {
+                                       $control_item_option = new 
controller_control_item_option($option_value, $saved_control_item_id);
+                                       $option_values_array[] = 
$control_item_option;
+                               }
+
+                               
$control_item->set_options_array($option_values_array);
+
+                               // Add new control item option values
                                if( ($transaction_status) & 
($saved_control_item_id > 0) & ($control_item->get_type() == 
'control_item_type_3' | $control_item->get_type() == 'control_item_type_4'))
                                {
                                        $control_item_options_array = 
$control_item->get_options_array();
-                                       
-                                       foreach($control_item_options_array as 
$control_item_option){
+
+                                       foreach($control_item_options_array as 
$control_item_option)
+                                       {
                                                $control_item_option_id = 
$this->so_control_item_option->store( $control_item_option );
                                        }
                                }
-                               
+
                                $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_item.view', 'id' => 
$saved_control_item_id));
-                       }else
+                       }
+                       else
                        {
                                $this->edit($control_item);
                        }
@@ -346,7 +364,7 @@
                {
                        //Retrieve the control_item object
                        $control_item_id = (int)phpgw::get_var('id');
-               
+
                        if(isset($control_item_id) && $control_item_id > 0)
                        {
                                $control_item = 
$this->so->get_single_with_options($control_item_id);
@@ -356,26 +374,26 @@
                                
$this->render('permission_denied.php',array('error' => 
lang('invalid_request')));
                                return;
                        }
-                       
+
                        $category = 
execMethod('phpgwapi.categories.return_single', 
$control_item->get_control_area_id());
                        $control_item->set_control_area_name( 
$category[0]['name'] );
-                       
-      // Hack to fix display of &nbsp; char
-      $what_to_do_fixed = str_replace( "&nbsp;", " 
",$control_item->get_what_to_do() );
-      $control_item->set_what_to_do( $what_to_do_fixed );
-      
-      $how_to_do_fixed = str_replace( "&nbsp;", " 
",$control_item->get_how_to_do() );
-      $control_item->set_how_to_do( $how_to_do_fixed );
-                       
+
+                       // Hack to fix display of &nbsp; char
+                       $what_to_do_fixed = str_replace( "&nbsp;", " 
",$control_item->get_what_to_do() );
+                       $control_item->set_what_to_do( $what_to_do_fixed );
+
+                       $how_to_do_fixed = str_replace( "&nbsp;", " 
",$control_item->get_how_to_do() );
+                       $control_item->set_how_to_do( $how_to_do_fixed );
+
                        $data = array
                        (
                                'control_item'  => $control_item,
-                               'view'                                  => true
+                               'view'                  => true
                        );
-                       
+
                        self::render_template_xsl('control_item/control_item', 
$data);
                }
-               
+
                public function query()
                {
                        $params = array(
@@ -385,7 +403,7 @@
                                'sort'  => phpgw::get_var('sort'),
                                'filters' => $filters
                        );
-                       
+
                        if(phpgw::get_var('sort_dir'))
                        {
                                $params['dir'] = phpgw::get_var('sort_dir');
@@ -398,13 +416,13 @@
                        $ctrl_area = phpgw::get_var('control_areas');
                        if(isset($ctrl_area) && $ctrl_area > 0)
                        {
-                               $filters['control_areas'] = $ctrl_area; 
+                               $filters['control_areas'] = $ctrl_area;
                        }
-                       
+
                        $ctrl_group = phpgw::get_var('control_groups');
                        if(isset($ctrl_group) && $ctrl_group > 0)
                        {
-                               $filters['control_groups'] = $ctrl_group; 
+                               $filters['control_groups'] = $ctrl_group;
                        }
 
 

Modified: trunk/controller/inc/class.uidocument.inc.php
===================================================================
--- trunk/controller/inc/class.uidocument.inc.php       2013-05-06 06:58:50 UTC 
(rev 11090)
+++ trunk/controller/inc/class.uidocument.inc.php       2013-05-06 13:22:07 UTC 
(rev 11091)
@@ -38,6 +38,12 @@
         private $so;
         private $so_procedure;
 
+           private $read;
+           private $add;
+           private $edit;
+           private $delete;
+
+
         public $public_functions = array
         (
                                'query'                                         
=> true,
@@ -53,6 +59,10 @@
             parent::__construct();
             $this->so = controller_sodocument::get_instance();
             $this->so_procedure = controller_soprocedure::get_instance();
+                       $this->read    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1 
+                       $this->add     = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2 
+                       $this->edit    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4 
+                       $this->delete  = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8 
         }
 
         public function query()
@@ -96,7 +106,8 @@
             
             //Serialize the documents found
             $rows = array();
-            foreach ($result_objects as $result) {
+            foreach ($result_objects as $result)
+            {
                 if(isset($result))
                 {
                     $rows[] = $result->serialize();
@@ -206,6 +217,14 @@
             
             if($_SERVER['REQUEST_METHOD'] == 'POST')
             {
+                               if(!$this->add && !$this->edit)
+                               {
+                                       phpgwapi_cache::message_set('No 
access', 'error');
+                            $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uidocument.show', 
+                                                                               
                                        'procedure_id' => $procedure->get_id(), 
+                                                                               
                                        'tab' => 'documents'));
+ 
+                               }
                 //Create a document object
                 $document = new controller_document();
                 $document->set_title(phpgw::get_var('document_title'));
@@ -291,6 +310,15 @@
             $document = $this->so->get_single($document_id);
             
             $procedure_id = intval(phpgw::get_var('procedure_id'));
+ 
+                       if(!$this->delete)
+                       {
+                               phpgwapi_cache::message_set('No access', 
'error');
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uidocument.show', 
+                                                                               
                                                        'procedure_id' => 
$procedure_id,
+                                                                               
                                                        'tab' => 'documents'));
+                       }
+ 
             $procedure = $this->so_procedure->get_single($procedure_id);
 
             $document_properties = $this->get_type_and_id($document);

Modified: trunk/controller/inc/class.uiprocedure.inc.php
===================================================================
--- trunk/controller/inc/class.uiprocedure.inc.php      2013-05-06 06:58:50 UTC 
(rev 11090)
+++ trunk/controller/inc/class.uiprocedure.inc.php      2013-05-06 13:22:07 UTC 
(rev 11091)
@@ -42,6 +42,11 @@
                private $so_control_group_list;
                private $so_control_group;
 
+           private $read;
+           private $add;
+           private $edit;
+           private $delete;
+
                public $public_functions = array
                (
                        'index'                                                 
=>      true,
@@ -65,6 +70,11 @@
 
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::procedure";
                        
+                       $this->read    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_READ, 'controller');//1 
+                       $this->add     = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_ADD, 'controller');//2 
+                       $this->edit    = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_EDIT, 'controller');//4 
+                       $this->delete  = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8 
+
                        $config = CreateObject('phpgwapi.config','controller');
                        $config->read();
                        $this->_category_acl = 
isset($config->config_data['acl_at_control_area']) && 
$config->config_data['acl_at_control_area'] == 1 ? true : false;
@@ -180,6 +190,12 @@
 
                        if(isset($_POST['save_procedure'])) // The user has 
pressed the save button
                        {
+                               if(!$this->add && !$this->edit)
+                               {
+                                       phpgwapi_cache::message_set('No 
access', 'error');
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uiprocedure.view', 'id' => $procedure_id));
+                               }
+
                                if(isset($procedure)) // Edit procedure
                                {
                                        $description_txt = 
phpgw::get_var('description','html');
@@ -238,6 +254,12 @@
                        }
                        else if(isset($_POST['revisit_procedure'])) // The user 
has pressed the revisit button
                        {
+                               if(!$this->add && !$this->edit)
+                               {
+                                       phpgwapi_cache::message_set('No 
access', 'error');
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uiprocedure.view', 'id' => $procedure_id));
+                               }
+
                                $old_procedure = 
$this->so->get_single($procedure_id);
                                if(isset($procedure)) // Edit procedure
                                {
@@ -533,7 +555,8 @@
                        }
                }
 
-               public function view_procedures_for_control(){
+               public function view_procedures_for_control()
+               {
                        $control_id = phpgw::get_var('control_id');
                        $location_code = phpgw::get_var('location_code');
                        
@@ -567,7 +590,8 @@
                        
self::render_template_xsl('procedure/view_procedures_for_control', $data);
                }
                
-               public function print_procedure(){
+               public function print_procedure()
+               {
                        $procedure_id = phpgw::get_var('procedure_id');
                        $location_code = phpgw::get_var('location_code');
                        $control_id = phpgw::get_var('control_id');
@@ -590,7 +614,8 @@
                                'dateformat'                    => 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']
                        );
                        
-                       if( !empty($control_group_id) ){
+                       if( !empty($control_group_id) )
+                       {
                                $control_group = 
$this->so_control_group->get_single($control_group_id);
                                $data['control_group'] = 
$control_group->toArray(); 
                        }
@@ -693,7 +718,7 @@
 
                }
 
-                       public function add_actions(&$value, $key, $params)
+               public function add_actions(&$value, $key, $params)
                {
                        //Defining new columns
                        $value['ajax'] = array();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]