2001-09-04 03:17:40 +02:00
< ? php
/************************************************************************** \
2004-01-27 00:26:19 +01:00
* eGroupWare - Administration *
* http :// www . egroupware . org *
2001-09-04 03:17:40 +02:00
* -------------------------------------------- *
* This program 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 . *
\ **************************************************************************/
/* $Id$ */
class uiaclmanager
{
var $template ;
var $nextmatchs ;
var $public_functions = array (
'list_apps' => True ,
'access_form' => True ,
'account_list' => True
);
function uiaclmanager ()
{
2003-12-20 19:51:51 +01:00
$this -> account_id = ( int ) $_GET [ 'account_id' ];
2005-10-14 19:03:16 +02:00
if ( ! $this -> account_id || $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 64 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
2005-10-14 19:03:16 +02:00
$GLOBALS [ 'egw' ] -> redirect_link ( '/index.php' );
2003-08-28 16:16:30 +02:00
}
2005-10-14 19:03:16 +02:00
$this -> template =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2001-09-04 03:17:40 +02:00
}
function common_header ()
{
2005-10-14 19:03:16 +02:00
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ] = lang ( 'Admin' ) . ' - ' . lang ( 'ACL Manager' ) .
': ' . $GLOBALS [ 'egw' ] -> common -> grab_owner_name ( $this -> account_id );
$GLOBALS [ 'egw' ] -> common -> egw_header ();
2003-08-28 16:16:30 +02:00
echo parse_navbar ();
2001-09-04 03:17:40 +02:00
}
function list_apps ()
{
$this -> common_header ();
2005-10-14 19:03:16 +02:00
$GLOBALS [ 'egw' ] -> hooks -> process ( 'acl_manager' , array ( 'preferences' ));
2001-09-04 03:17:40 +02:00
$this -> template -> set_file ( array (
'app_list' => 'acl_applist.tpl'
));
$this -> template -> set_block ( 'app_list' , 'list' );
$this -> template -> set_block ( 'app_list' , 'app_row' );
$this -> template -> set_block ( 'app_list' , 'app_row_noicon' );
$this -> template -> set_block ( 'app_list' , 'link_row' );
$this -> template -> set_block ( 'app_list' , 'spacer_row' );
2004-08-25 13:21:23 +02:00
if ( is_array ( $GLOBALS [ 'acl_manager' ]))
2001-09-04 03:17:40 +02:00
{
2004-08-25 13:21:23 +02:00
foreach ( $GLOBALS [ 'acl_manager' ] as $app => $locations )
2001-09-04 03:17:40 +02:00
{
2005-10-14 19:03:16 +02:00
$icon = $GLOBALS [ 'egw' ] -> common -> image ( $app , array ( 'navbar.png' , $app . 'png' , 'navbar.gif' , $app . '.gif' ));
$this -> template -> set_var ( 'icon_backcolor' , $GLOBALS [ 'egw_info' ][ 'theme' ][ 'row_off' ]);
$this -> template -> set_var ( 'link_backcolor' , $GLOBALS [ 'egw_info' ][ 'theme' ][ 'row_off' ]);
$this -> template -> set_var ( 'app_name' , $GLOBALS [ 'egw_info' ][ 'apps' ][ $app ][ 'title' ]);
2004-08-25 13:21:23 +02:00
$this -> template -> set_var ( 'a_name' , $appname );
$this -> template -> set_var ( 'app_icon' , $icon );
if ( $icon )
{
$this -> template -> fp ( 'rows' , 'app_row' , True );
}
else
{
$this -> template -> fp ( 'rows' , 'app_row_noicon' , True );
}
if ( is_array ( $locations ))
{
foreach ( $locations as $loc => $value )
{
$link_values = array (
'menuaction' => 'admin.uiaclmanager.access_form' ,
'location' => $loc ,
'acl_app' => $app ,
'account_id' => $this -> account_id
);
2005-10-14 19:03:16 +02:00
$this -> template -> set_var ( 'link_location' , $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_values ));
2004-08-25 13:21:23 +02:00
$this -> template -> set_var ( 'lang_location' , lang ( $value [ 'name' ]));
$this -> template -> fp ( 'rows' , 'link_row' , True );
}
}
$this -> template -> parse ( 'rows' , 'spacer_row' , True );
2001-09-04 03:17:40 +02:00
}
}
2003-08-28 16:16:30 +02:00
$this -> template -> set_var ( array (
2005-10-14 19:03:16 +02:00
'cancel_action' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_users' ),
2003-08-28 16:16:30 +02:00
'lang_cancel' => lang ( 'Cancel' )
));
2001-09-04 03:17:40 +02:00
$this -> template -> pfp ( 'out' , 'list' );
}
function access_form ()
{
2003-08-28 16:16:30 +02:00
$location = $_GET [ 'location' ];
2001-09-04 03:17:40 +02:00
2003-08-28 16:16:30 +02:00
if ( $_POST [ 'submit' ] || $_POST [ 'cancel' ])
{
if ( $_POST [ 'submit' ])
{
$total_rights = 0 ;
2004-08-25 13:21:23 +02:00
if ( is_array ( $_POST [ 'acl_rights' ]))
2003-08-28 16:16:30 +02:00
{
2004-08-25 13:21:23 +02:00
foreach ( $_POST [ 'acl_rights' ] as $rights )
{
$total_rights += $rights ;
}
2003-08-28 16:16:30 +02:00
}
if ( $total_rights )
{
2005-10-14 19:03:16 +02:00
$GLOBALS [ 'egw' ] -> acl -> add_repository ( $_GET [ 'acl_app' ], $location , $this -> account_id , $total_rights );
2003-08-28 16:16:30 +02:00
}
else // we dont need to save 0 rights (= no restrictions)
{
2005-10-14 19:03:16 +02:00
$GLOBALS [ 'egw' ] -> acl -> delete_repository ( $_GET [ 'acl_app' ], $location , $this -> account_id );
2003-08-28 16:16:30 +02:00
}
}
$this -> list_apps ();
return ;
}
2005-10-14 19:03:16 +02:00
$GLOBALS [ 'egw' ] -> hooks -> single ( 'acl_manager' , $_GET [ 'acl_app' ]);
2003-08-28 16:16:30 +02:00
$acl_manager = $GLOBALS [ 'acl_manager' ][ $_GET [ 'acl_app' ]][ $location ];
2001-09-04 03:17:40 +02:00
$this -> common_header ();
$this -> template -> set_file ( 'form' , 'acl_manager_form.tpl' );
2005-10-14 19:03:16 +02:00
$acc =& CreateObject ( 'phpgwapi.accounts' , $this -> account_id );
2001-09-04 03:17:40 +02:00
$acc -> read_repository ();
2005-10-14 19:03:16 +02:00
$afn = $GLOBALS [ 'egw' ] -> common -> display_fullname ( $acc -> data [ 'account_lid' ], $acc -> data [ 'firstname' ], $acc -> data [ 'lastname' ]);
2001-09-04 03:17:40 +02:00
2005-10-14 19:03:16 +02:00
$this -> template -> set_var ( 'lang_message' , lang ( 'Check items to <b>%1</b> to %2 for %3' , lang ( $acl_manager [ 'name' ]), $GLOBALS [ 'egw_info' ][ 'apps' ][ $_GET [ 'acl_app' ]][ 'title' ], $afn ));
2001-09-04 03:17:40 +02:00
$link_values = array (
2003-08-28 16:16:30 +02:00
'menuaction' => 'admin.uiaclmanager.access_form' ,
'acl_app' => $_GET [ 'acl_app' ],
'location' => urlencode ( $_GET [ 'location' ]),
'account_id' => $this -> account_id
2001-09-04 03:17:40 +02:00
);
2005-10-14 19:03:16 +02:00
$acl =& CreateObject ( 'phpgwapi.acl' , $this -> account_id );
2001-09-04 06:26:51 +02:00
$acl -> read_repository ();
2003-08-28 16:16:30 +02:00
$grants = $acl -> get_rights ( $location , $_GET [ 'acl_app' ]);
2001-09-04 03:17:40 +02:00
2005-10-14 19:03:16 +02:00
$this -> template -> set_var ( 'form_action' , $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_values ));
2001-09-04 03:17:40 +02:00
2001-09-04 06:26:51 +02:00
$total = 0 ;
2004-08-25 13:21:23 +02:00
foreach ( $acl_manager [ 'rights' ] as $name => $value )
2001-09-04 03:17:40 +02:00
{
2003-08-28 16:16:30 +02:00
$cb .= '<input type="checkbox" name="acl_rights[]" value="' . $value . '"' . ( $grants & $value ? ' checked' : '' ) . '> ' . lang ( $name ) . " <br> \n " ;
2001-09-04 03:17:40 +02:00
}
2003-08-28 16:16:30 +02:00
$this -> template -> set_var ( 'select_values' , $cb );
$this -> template -> set_var ( 'lang_submit' , lang ( 'Save' ));
2001-09-04 03:17:40 +02:00
$this -> template -> set_var ( 'lang_cancel' , lang ( 'Cancel' ));
$this -> template -> pfp ( 'out' , 'form' );
}
}