phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] admin/inc/class.uiaclmanager.inc.php, 1.13


From: nomail
Subject: [Phpgroupware-cvs] admin/inc/class.uiaclmanager.inc.php, 1.13
Date: Thu, 30 Dec 2004 08:38:14 +0100

Update of /admin/inc
Modified Files:
        Branch: 
          class.uiaclmanager.inc.php

date: 2004/12/30 07:38:14;  author: skwashd;  state: Exp;  lines: +140 -156

Log Message:
new HEAD admin - sans GIFs
=====================================================================
Index: admin/inc/class.uiaclmanager.inc.php
diff -u admin/inc/class.uiaclmanager.inc.php:1.12 
admin/inc/class.uiaclmanager.inc.php:1.13
--- admin/inc/class.uiaclmanager.inc.php:1.12   Thu Nov 13 13:52:09 2003
+++ admin/inc/class.uiaclmanager.inc.php        Thu Dec 30 07:38:14 2004
@@ -17,14 +17,13 @@
        {
                var $template;
                var $nextmatchs;
-               var $public_functions = array(
+               var $public_functions = array
+               (
                        'list_apps'                             => True,
                        'access_form'                   => True,
-                       'account_list'                  => True,
                        'list_addressmasters'   => True,
                        'edit_addressmasters'   => True,
-                       'accounts_popup'                => True,
-                       'java_script'                   => True
+                       'accounts_popup'                => True
                );
 
                function uiaclmanager()
@@ -42,7 +41,10 @@
 
                function common_header()
                {
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Admin') . ' - ' . lang('ACL Manager') .
+                               ': ' . 
$GLOBALS['phpgw']->common->grab_owner_name($this->account_id);
                        $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
                }
 
                function list_apps()
@@ -60,14 +62,12 @@
                        $this->template->set_block('app_list','link_row');
                        $this->template->set_block('app_list','spacer_row');
 
-                       $this->template->set_var('lang_header',lang('ACL 
Manager'));
-
                        while (is_array($GLOBALS['acl_manager']) && 
list($app,$locations) = each($GLOBALS['acl_manager']))
                        {
                                $icon = 
$GLOBALS['phpgw']->common->image($app,array('navbar.gif',$app.'.gif'));
                                
$this->template->set_var('icon_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']);
                                
$this->template->set_var('link_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']);
-                               
$this->template->set_var('app_name',lang($GLOBALS['phpgw_info']['navbar'][$app]['title']));
+                               
$this->template->set_var('app_name',$GLOBALS['phpgw_info']['apps'][$app]['title']);
                                $this->template->set_var('a_name',$appname);
                                $this->template->set_var('app_icon',$icon);
 
@@ -82,83 +82,84 @@
 
                                while (is_array($locations) && 
list($loc,$value) = each($locations))
                                {
-                                       $total_rights = 0;
-                                       while (list($k,$v) = 
each($value['rights']))
-                                       {
-                                               $total_rights += $v;
-                                       }
-                                       reset($value['rights']);
+                                       $link_values = array(
+                                               'menuaction' => 
'admin.uiaclmanager.access_form',
+                                               'location'   => urlencode($loc),
+                                               'acl_app'    => $app,
+                                               'account_id' => 
$this->account_id
+                                       );
 
-                                       // If all of there rights are denied, 
then they shouldn't even see the option
-                                       if ($total_rights != 
$GLOBALS['phpgw']->acl->get_rights($loc,$app))
-                                       {
-                                               $link_values = array(
-                                                       'menuaction' => 
'admin.uiaclmanager.access_form',
-                                                       'location'   => 
urlencode(base64_encode($loc)),
-                                                       'acl_app'    => $app,
-                                                       'account_id' => 
$GLOBALS['account_id']
-                                               );
-
-                                               
$this->template->set_var('link_location',$GLOBALS['phpgw']->link('/index.php',$link_values));
-                                               
$this->template->set_var('lang_location',lang($value['name']));
-                                               
$this->template->fp('rows','link_row',True);
-                                       }
+                                       
$this->template->set_var('link_location',$GLOBALS['phpgw']->link('/index.php',$link_values));
+                                       
$this->template->set_var('lang_location',lang($value['name']));
+                                       
$this->template->fp('rows','link_row',True);
                                }
 
                                
$this->template->parse('rows','spacer_row',True);
                        }
+                       $this->template->set_var(array(
+                               'cancel_action' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_users'),
+                               'lang_cancel'   => lang('Cancel')
+                       ));
                        $this->template->pfp('out','list');
                }
 
                function access_form()
                {
-                       
$GLOBALS['phpgw']->hooks->single('acl_manager',$GLOBALS['acl_app']);
-                       $location = base64_decode($GLOBALS['location']);
+                       $location = $_GET['location'];
+
+                       if ($_POST['submit'] || $_POST['cancel'])
+                       {
+                               if ($_POST['submit'])
+                               {
+                                       $total_rights = 0;
+                                       while (is_array($_POST['acl_rights']) 
&& list(,$rights) = each($_POST['acl_rights']))
+                                       {
+                                               $total_rights += $rights;
+                                       }
 
-                       $acl_manager = 
$GLOBALS['acl_manager'][$GLOBALS['acl_app']][$location];
+                                       if ($total_rights)
+                                       {
+                                               
$GLOBALS['phpgw']->acl->add_repository($_GET['acl_app'], $location, 
$this->account_id, $total_rights);
+                                       }
+                                       else    // we dont need to save 0 
rights (= no restrictions)
+                                       {
+                                               
$GLOBALS['phpgw']->acl->delete_repository($_GET['acl_app'], $location, 
$this->account_id);
+                                       }
+                               }
+                               $this->list_apps();
+                               return;
+                       }
+                       
$GLOBALS['phpgw']->hooks->single('acl_manager',$_GET['acl_app']);
+                       $acl_manager = 
$GLOBALS['acl_manager'][$_GET['acl_app']][$location];
 
                        $this->common_header();
                        
$this->template->set_file('form','acl_manager_form.tpl');
 
-                       $acc = 
createobject('phpgwapi.accounts',$GLOBALS['account_id']);
+                       $acc = 
createobject('phpgwapi.accounts',$this->account_id);
                        $acc->read_repository();
                        $afn = 
$GLOBALS['phpgw']->common->display_fullname($acc->data['account_lid'],$acc->data['firstname'],$acc->data['lastname']);
 
-                       $this->template->set_var('lang_message',lang('Check 
items to <b>%1</b> to %2 for 
%3',$acl_manager['name'],$GLOBALS['acl_app'],$afn));
+                       $this->template->set_var('lang_message',lang('Check 
items to <b>%1</b> to %2 for 
%3',lang($acl_manager['name']),$GLOBALS['phpgw_info']['apps'][$_GET['acl_app']]['title'],$afn));
                        $link_values = array(
-                               'menuaction' => 'admin.boaclmanager.submit',
-                               'acl_app'    => $GLOBALS['acl_app'],
-                               'location'   => urlencode($GLOBALS['location']),
-                               'account_id' => $GLOBALS['account_id']
+                               'menuaction' => 
'admin.uiaclmanager.access_form',
+                               'acl_app'    => $_GET['acl_app'],
+                               'location'   => urlencode($_GET['location']),
+                               'account_id' => $this->account_id
                        );
 
-                       $acl    = 
createobject('phpgwapi.acl',$GLOBALS['account_id']);
+                       $acl    = 
createobject('phpgwapi.acl',$this->account_id);
                        $acl->read_repository();
+                       $grants = $acl->get_rights($location,$_GET['acl_app']);
 
                        
$this->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php',$link_values));
-                       $this->template->set_var('lang_title',lang('ACL 
Manager'));
 
                        $total = 0;
                        while (list($name,$value) = 
each($acl_manager['rights']))
                        {
-                               $grants = 
$acl->get_rights($location,$GLOBALS['acl_app']);
-
-                               if (! 
$GLOBALS['phpgw']->acl->check($location,$value,$GLOBALS['acl_app']))
-                               {
-                                       $s .= '<option value="' . $value . '"';
-                                       $s .= (($grants & $value)?' 
selected':'');
-                                       $s .= '>' . lang($name) . '</option>';
-                                       $total++;
-                               }
-                       }
-
-                       $size = 7;
-                       if ($total < 7)
-                       {
-                               $size = $total;
+                               $cb .= '<input type="checkbox" 
name="acl_rights[]" value="'.$value.'"'.($grants & $value ? ' checked' : 
'').'>&nbsp;'.lang($name)."<br>\n";
                        }
-                       $this->template->set_var('select_values','<select 
name="acl_rights[]" multiple size="' . $size . '">' . $s . '</select>');
-                       $this->template->set_var('lang_submit',lang('Submit'));
+                       $this->template->set_var('select_values',$cb);
+                       $this->template->set_var('lang_submit',lang('Save'));
                        $this->template->set_var('lang_cancel',lang('Cancel'));
 
                        $this->template->pfp('out','form');
@@ -166,8 +167,6 @@
 
                function list_addressmasters()
                {
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
-
                        $link_data = array
                        (
                                'menuaction'    => 
'admin.uiaclmanager.edit_addressmasters',
@@ -185,73 +184,69 @@
                        }
 
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('admin') . ': ' . lang('list addressmasters');
-                       $GLOBALS['phpgw']->xslttpl->add_file('addressmaster');
+                       $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
+
+                       
$GLOBALS['phpgw']->template->set_file(array('admin_list_t' => 
'list_accountmasters.tpl'));
+                       
$GLOBALS['phpgw']->template->set_block('admin_list_t','user_list','list');
+                       
$GLOBALS['phpgw']->template->set_block('admin_list_t','group_list','glist');
+
+                       
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
+
+                       
$GLOBALS['phpgw']->template->set_var('sort_lid',lang('loginid'));
+                       
$GLOBALS['phpgw']->template->set_var('sort_firstname',lang('firstname'));
+                       
$GLOBALS['phpgw']->template->set_var('sort_lastname',lang('lastname'));
+                       
$GLOBALS['phpgw']->template->set_var('sort_name',lang('name'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_edit',lang('edit'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_done',lang('done'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_users',lang('users'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_groups',lang('groups'));
 
                        $admins = $this->boacl->list_addressmasters();
                        
                        //_debug_array($admins);
-                       //exit;
+
                        if(is_array($admins))
                        {
                                foreach($admins as $admin)
                                {
                                        if ($admin['lastname'] != 'Group')
                                        {
-                                               $users[] = array
-                                               (
-                                                       'lid'           => 
$admin['lid'],
-                                                       'firstname'=> 
$admin['firstname'],
-                                                       'lastname'      => 
$admin['lastname']
-                                               );
+                                               
$this->nextmatchs->template_alternate_row_color(&$GLOBALS['phpgw']->template);
+                                       
+                                               
$GLOBALS['phpgw']->template->set_var(array
+                                                                               
     (
+                                                                               
             'lid'              => $admin['lid'],
+                                                                               
             'firstname'=> $admin['firstname'],
+                                                                               
             'lastname' => $admin['lastname'])
+                                                       );
+
+                                               
$GLOBALS['phpgw']->template->fp('list','user_list',True);
                                        }
                                        elseif ($admin['lastname'] == 'Group')
                                        {
-                                               $groups[] = array
-                                               (
-                                                       'lid'           => 
$admin['lid'],
-                                                       'firstname'=> 
$admin['firstname'],
-                                                       'lastname'      => 
$admin['lastname']
-                                               );
+                                               
$this->nextmatchs->template_alternate_row_color(&$GLOBALS['phpgw']->template);
+                                       
+                                               
$GLOBALS['phpgw']->template->set_var(array
+                                                                               
     (
+                                                                               
             'lid'              => $admin['lid'],
+                                                                               
             'firstname'=> $admin['firstname'],
+                                                                               
             'lastname' => $admin['lastname'])
+                                                       );
+                                               
$GLOBALS['phpgw']->template->fp('glist','group_list',True);
                                        }
                                }
                        }
-
-                       //_debug_array($users);
-                       //exit;
-
-                       $link_data['menuaction'] = 
'admin.uiaclmanager.list_addressmasters';
-
-                       $data = array
-                       (
-                               'sort_lid'                              => 
lang('loginid'),
-                               'sort_firstname'                => 
lang('firstname'),
-                               'sort_lastname'                 => 
lang('lastname'),
-                               'sort_name'                             => 
lang('name'),
-                               'lang_users'                    => 
lang('users'),
-                               'lang_groups'                   => 
lang('groups'),
-                               'addressmaster_user'    => $users,
-                               'addressmaster_group'   => $groups,
-                               'lang_edit'                             => 
lang('edit'),
-                               'lang_done'                             => 
lang('done'),
-                               'action_url'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data) 
-                       );
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('addressmaster_list' => 
$data));
+                       
$GLOBALS['phpgw']->template->pfp('out','admin_list_t',True);
                }
 
                function accounts_popup()
                {
-                       return 
$GLOBALS['phpgw']->accounts->accounts_popup('admin_acl');
-               }
-
-               function java_script()
-               {
-                       return 
$GLOBALS['phpgw']->accounts->java_script('admin_acl');
+                       
$GLOBALS['phpgw']->accounts->accounts_popup('admin_acl');
                }
 
                function edit_addressmasters()
                {
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
-
                        $link_data = array
                        (
                                'menuaction'    => 
'admin.uiaclmanager.list_addressmasters',
@@ -263,7 +258,7 @@
                                $error = 
$this->boacl->check_values($_POST['account_addressmaster'],$_POST['group_addressmaster']);
                                if(is_array($error))
                                {
-                                       $error_message = 
$GLOBALS['phpgw']->common->error_list($error);
+                                       
$GLOBALS['phpgw']->template->set_var('error_message',$GLOBALS['phpgw']->common->error_list($error));
                                }
                                else
                                {
@@ -278,34 +273,42 @@
                        }
 
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('admin') . ': ' . lang('edit addressmaster list');
-                       $GLOBALS['phpgw']->xslttpl->add_file('addressmaster');
+                       $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
+
+                       $GLOBALS['phpgw']->template->set_file(array('admin_add' 
=> 'form_accountmasters.tpl'));
+                       
$GLOBALS['phpgw']->template->set_block('admin_add','select');
+                       
$GLOBALS['phpgw']->template->set_block('admin_add','popwin');
+
+                       
$GLOBALS['phpgw']->template->set_var('lang_select_addressmasters',lang('Select 
addressmasters'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_save',lang('save'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('cancel'));
+
+                       $link_data['menuaction'] = 
'admin.uiaclmanager.edit_addressmasters';
+                       
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
 
                        if 
($GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection'] 
== 'popup')
                        {
                                $usel = $this->boacl->list_addressmasters();
+                               
$GLOBALS['phpgw']->template->set_var('accounts_link',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaclmanager.accounts_popup'));
+                               
$GLOBALS['phpgw']->template->set_var('lang_open_popup',lang('open popup 
window'));
+
                                while(is_array($usel) && list(,$acc) = 
each($usel))
                                {
-                                       $user_list[] = array
-                                       (
-                                               'account_id'    => 
$acc['account_id'],
-                                               'select_value'  => 'yes',
-                                               'fullname'              => 
$GLOBALS['phpgw']->common->display_fullname($acc['lid'],$acc['firstname'],$acc['lastname'])
-                                       );
+                                       $user_list .= '<option value="' . 
$acc['account_id'] . '" selected>'
+                                                               . 
$GLOBALS['phpgw']->common->display_fullname($acc['lid'],$acc['firstname'],$acc['lastname'])
+                                                               . 
'</option>'."\n";
                                }
                                $account_num = count($sel_accounts);
-
-                               $popwin_user = array
-                               (
-                                       'url'                           => "'" 
. 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaclmanager.accounts_popup')
 . "'",
-                                       'width'                         => 
'800',
-                                       'height'                        => 
'600',
-                                       'lang_open_popup'       => lang('open 
popup window'),
-                                       'select_size'           => 
($account_num < 7?$account_num:7),
-                                       'user_list'                     => 
$user_list
-                               );
+                               
$GLOBALS['phpgw']->template->set_var('select_size',($account_num < 
7?$account_num:7));
+                               
$GLOBALS['phpgw']->template->set_var('account_list',$user_list);
+                               
$GLOBALS['phpgw']->template->fp('accounts','popwin',True);
                        }
                        else
                        {
+                               
$GLOBALS['phpgw']->template->set_var('lang_select_users',lang('Select users'));
+                               
$GLOBALS['phpgw']->template->set_var('lang_select_groups',lang('Select 
groups'));
+
                                $app_user = 
$GLOBALS['phpgw']->acl->get_ids_for_location('run',1,'addressbook');
 
                                $add_users = 
$GLOBALS['phpgw']->accounts->return_members($app_user);
@@ -315,61 +318,42 @@
                                //_debug_array($usel);
                                for($i=0;$i<count($add_users['users']);$i++)
                                {
+                                       $user_list .= '<option value="' . 
$add_users['users'][$i] . '"';
                                        if (is_array($usel) && 
in_array($add_users['users'][$i],$usel))
                                        {
-                                               $select_value = 'yes';
+                                               $user_list .= ' SELECTED';
                                        }
-
-                                       $user_list[] = array
-                                       (
-                                               'account_id'    => 
$add_users['users'][$i],
-                                               'select_value'  => 
$select_value,
-                                               'fullname'              => 
$GLOBALS['phpgw']->common->grab_owner_name($add_users['users'][$i])
-                                       );
+                                       $user_list .= '>';
+                                       $user_list .= 
$GLOBALS['phpgw']->common->grab_owner_name($add_users['users'][$i])
+                                                       . '</option>' . "\n";
                                }
 
                                $add_user_num = count($add_users['users']);
+                               
$GLOBALS['phpgw']->template->set_var('u_select_size',($add_user_num < 
7?$add_user_num:7));
+                               
$GLOBALS['phpgw']->template->set_var('user_list',$user_list);
 
                                for($i=0;$i<count($add_users['groups']);$i++)
                                {
+                                       $group_list .= '<option value="' . 
$add_users['groups'][$i] . '"';
                                        if (is_array($usel) && 
in_array($add_users['groups'][$i],$usel))
                                        {
-                                               $select_value = 'yes';
+                                               $group_list .= ' selected';
                                        }
-
-                                       $group_list[] = array
-                                       (
-                                               'account_id'    => 
$add_users['groups'][$i],
-                                               'select_value'  => 
$select_value,
-                                               'fullname'              => 
$GLOBALS['phpgw']->common->grab_owner_name($add_users['groups'][$i])
-                                       );
+                                       $group_list .= '>';
+                                       $group_list .= 
$GLOBALS['phpgw']->common->grab_owner_name($add_users['groups'][$i])
+                                                       . '</option>' . "\n";
                                }
 
                                $add_group_num = count($add_users['groups']);
+                               
$GLOBALS['phpgw']->template->set_var('g_select_size',($add_group_num < 
7?$add_group_num:7));
+                               
$GLOBALS['phpgw']->template->set_var('group_list',$group_list);
 
-                               $select_user = array
-                               (
-                                       'lang_select_users'             => 
lang('Select users'),
-                                       'lang_select_groups'    => lang('Select 
groups'),
-                                       'u_select_size'                 => 
($add_user_num < 7?$add_user_num:7),
-                                       'g_select_size'                 => 
($add_group_num < 7?$add_group_num:7),
-                                       'group_list'                    => 
$group_list,
-                                       'user_list'                             
=> $user_list
-                               );
+                               
$GLOBALS['phpgw']->template->fp('accounts','select',True);
                        }
 
-                       $link_data['menuaction'] = 
'admin.uiaclmanager.edit_addressmasters';
-
-                       $data = array
-                       (
-                               'lang_select_addressmasters'    => lang('Select 
addressmasters'),
-                               'lang_save'                                     
        => lang('save'),
-                               'lang_cancel'                                   
=> lang('cancel'),
-                               'action_url'                                    
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'popwin_user'                                   
=> $popwin_user,
-                               'select_user'                                   
=> $select_user
-                       );
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('addressmaster_edit' => 
$data));
+                       $GLOBALS['phpgw']->template->set_var('select','');
+                       $GLOBALS['phpgw']->template->set_var('popwin','');
+                       $GLOBALS['phpgw']->template->pfp('out','admin_add');
                }
        }
 ?>




reply via email to

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