phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] phpgwapi/inc class.accounts_shared.inc.php, 1.51, 1.


From: Bettina Gille <address@hidden>
Subject: [Phpgroupware-cvs] phpgwapi/inc class.accounts_shared.inc.php, 1.51, 1.52
Date: Thu, 06 Nov 2003 17:19:46 +0000

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv5002

Modified Files:
        class.accounts_shared.inc.php 
Log Message:
accounts_popup port to head

Index: class.accounts_shared.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.accounts_shared.inc.php,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** class.accounts_shared.inc.php       23 Aug 2003 00:44:53 -0000      1.51
--- class.accounts_shared.inc.php       6 Nov 2003 17:19:44 -0000       1.52
***************
*** 236,241 ****
--- 236,284 ----
                }
  
+               /*!
+               @function return_members
+               @abstract returns an array of users and groups seperated, 
including all members of groups, which i.e. have acl access for an application
+               @param $app_users (array, default to 0)
+               */
+               function return_members($app_users = 0)
+               {
+                       for ($i = 0;$i<count($app_users);$i++)
+                       {
+                               $type = 
$GLOBALS['phpgw']->accounts->get_type($app_users[$i]);
+                               if($type == 'g')
+                               {
+                                       $add_users['groups'][] = $app_users[$i];
+                                       $members[] = 
$GLOBALS['phpgw']->acl->get_ids_for_location($app_users[$i],1,'phpgw_group');
+                               }
+                               else
+                               {
+                                       $add_users['users'][] = $app_users[$i];
+                               }
+                       }
+ 
+                       $i = count($add_users['users']);
+ 
+                       while(is_array($members) && list(,$mem) = 
each($members))
+                       {
+                               for($j=0;$j<count($mem);$j++)
+                               {
+                                       $add_users['users'][$i] = $mem[$j];
+                                       $i++;
+                               }
+                       }
+                       return $add_users;
+               }
+ 
                function accounts_popup($app)
                {
+                       $GLOBALS['phpgw_info']['flags']['headonly'] = True;
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ 
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'accounts_popup',
+                                                                               
                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field',
+                                                                               
                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'nextmatchs'));
+ 
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('select accounts');
+ 
                        $group_id = get_var('group_id',array('GET','POST'));
  
***************
*** 279,345 ****
                        $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
  
-                       
$GLOBALS['phpgw']->template->set_root($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi'));
- 
-                       
$GLOBALS['phpgw']->template->set_file(array('accounts_list_t' => 
'accounts_popup.tpl'));
-                       
$GLOBALS['phpgw']->template->set_block('accounts_list_t','group_cal','cal');
-                       
$GLOBALS['phpgw']->template->set_block('accounts_list_t','group_other','other');
-                       
$GLOBALS['phpgw']->template->set_block('accounts_list_t','group_all','all');
- 
-                       
$GLOBALS['phpgw']->template->set_block('accounts_list_t','bla_intro','ibla');
-                       
$GLOBALS['phpgw']->template->set_block('accounts_list_t','other_intro','iother');
-                       
$GLOBALS['phpgw']->template->set_block('accounts_list_t','all_intro','iall');
- 
- 
-                       
$GLOBALS['phpgw']->template->set_block('accounts_list_t','accounts_list','list');
- 
- 
-                       
$GLOBALS['phpgw']->template->set_var('title',$GLOBALS['phpgw_info']['site_title']);
-                       
$GLOBALS['phpgw']->template->set_var('charset',$GLOBALS['phpgw']->translation->translate('charset'));
-                       
$GLOBALS['phpgw']->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']);
-                       
$GLOBALS['phpgw']->template->set_var('lang_search',lang('search'));
-                       
$GLOBALS['phpgw']->template->set_var('lang_groups',lang('user groups'));
-                       
$GLOBALS['phpgw']->template->set_var('lang_accounts',lang('user accounts'));
- 
-                       
$GLOBALS['phpgw']->template->set_var('img',$GLOBALS['phpgw']->common->image('phpgwapi','select'));
-                       
$GLOBALS['phpgw']->template->set_var('lang_select_user',lang('Select user'));
-                       
$GLOBALS['phpgw']->template->set_var('lang_select_group',lang('Select group'));
-                       
$GLOBALS['phpgw']->template->set_var('css_file',$GLOBALS['phpgw_info']['server']['webserver_url']
 . SEP . 'phpgwapi' . SEP . 'templates'
-                                                                               
                                        . SEP . 'idots' . SEP . 'css' . SEP . 
'idots.css');
- 
                        switch($app)
                        {
                                case 'calendar':
                                        $action = 
'calendar.uicalendar.accounts_popup';
!                                       
$GLOBALS['phpgw']->template->set_var('select_name',"participants[]'][0]");
!                                       
$GLOBALS['phpgw']->template->set_var('js_function','ExchangeAccountSelect');
!                                       
$GLOBALS['phpgw']->template->fp('ibla','bla_intro',True);
!                                       
$GLOBALS['phpgw']->template->fp('iall','all_intro',True);
                                        break;
                                case 'admin':
                                        $action = 
'admin.uiaccounts.accounts_popup';
!                                       
$GLOBALS['phpgw']->template->set_var('select_name',"account_user[]']");
!                                       
$GLOBALS['phpgw']->template->set_var('js_function','ExchangeAccountSelect');
!                                       
$GLOBALS['phpgw']->template->set_var('lang_perm',lang('group name'));
!                                       
$GLOBALS['phpgw']->template->fp('iother','other_intro',True);
                                        break;
                                case 'projects':
                                        $action = 
'projects.uiprojects.accounts_popup';
!                                       
$GLOBALS['phpgw']->template->set_var('select_name',"values[coordinator]']");
!                                       
$GLOBALS['phpgw']->template->set_var('js_function','ExchangeAccountText');
!                                       
$GLOBALS['phpgw']->template->fp('iother','other_intro',True);
!                                       
$GLOBALS['phpgw']->template->fp('iall','all_intro',True);
                                        break;
                                case 'e_projects':
                                        $action = 
'projects.uiprojects.e_accounts_popup';
                                        $app = 'projects';
!                                       
$GLOBALS['phpgw']->template->set_var('select_name',"employees[]']");
!                                       
$GLOBALS['phpgw']->template->set_var('js_function','ExchangeAccountSelect');
!                                       
$GLOBALS['phpgw']->template->fp('iother','other_intro',True);
!                                       
$GLOBALS['phpgw']->template->fp('iall','all_intro',True);
                                        break;
                        }
  
!                       
$GLOBALS['phpgw']->template->set_var('lang_perm',lang('Groups with permission 
for %1',lang($app)));
!                       
$GLOBALS['phpgw']->template->set_var('lang_nonperm',lang('Groups without 
permission for %1',lang($app)));
  
                        $link_data = array
--- 322,370 ----
                        $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
  
                        switch($app)
                        {
                                case 'calendar':
                                        $action = 
'calendar.uicalendar.accounts_popup';
!                                       $select_name = "participants[]'][0]";
!                                       $js_function = 'ExchangeAccountSelect';
                                        break;
                                case 'admin':
                                        $action = 
'admin.uiaccounts.accounts_popup';
!                                       $select_name = "account_user[]']";
!                                       $js_function = 'ExchangeAccountSelect';
!                                       break;
!                               case 'admin_acl':
!                                       $action = 
'admin.uiaclmanager.accounts_popup';
!                                       $app = 'addressbook';
!                                       $select_name = 
"account_addressmaster[]']";
!                                       $js_function = 'ExchangeAccountSelect';
                                        break;
                                case 'projects':
                                        $action = 
'projects.uiprojects.accounts_popup';
!                                       $select_name = "values[coordinator]']";
!                                       $js_function = 'ExchangeAccountText';
                                        break;
                                case 'e_projects':
                                        $action = 
'projects.uiprojects.e_accounts_popup';
                                        $app = 'projects';
!                                       $select_name = "employees[]']";
!                                       $js_function = 'ExchangeAccountSelect';
                                        break;
                        }
  
!                       $script = 'var userSelectBox = 
opener.document.forms["app_form"].elements[\'' . $select_name;
!                       $script .= 'function ExchangeAccountSelect(thisform)' . 
"\n";
!                       $script .= '{' . "\n";
!                       $script .= 'NewEntry = new 
Option(thisform.elements[1].value,thisform.elements[0].value,false,true);';
!                       $script .= 'userSelectBox.options[userSelectBox.length] 
= NewEntry;';
!                       $script .= '}';
!                       $script .= '</script>';
!                       $script .= '<script LANGUAGE="JavaScript">';
!                       $script .= 'function ExchangeAccountText(thisform)';
!                       $script .= '{';
!                       $script .= 'opener.document.app_form.accountid.value = 
thisform.elements[0].value;';
!                       $script .= 'opener.document.app_form.accountname.value 
= thisform.elements[1].value;';
!                       $script .= '}';
! 
  
                        $link_data = array
***************
*** 354,379 ****
                        {
                                $user_groups = 
$this->membership($this->account);
! 
!                               $app_user = 
$GLOBALS['phpgw']->acl->get_ids_for_location('run',1,$app);
!                               for ($i = 0;$i<count($app_user);$i++)
!                               {
!                                       $type = $this->get_type($app_user[$i]);
!                                       if($type == 'g')
!                                       {
!                                               $app_groups[] = $app_user[$i];
!                                               $members[] = 
$GLOBALS['phpgw']->acl->get_ids_for_location($app_user[$i],1,'phpgw_group');
!                                       }
!                               }
! 
!                               $i = count($app_user);
!                               while(is_array($members) && list(,$mem) = 
each($members))
!                               {
!                                       for($j=0;$j<count($mem);$j++)
!                                       {
!                                               $app_user[$i] = $mem[$j];
!                                               $i++;
!                                       }
!                               }
!                               //_debug_array($app_user);
                        }
                        else
--- 379,386 ----
                        {
                                $user_groups = 
$this->membership($this->account);
!                               $aclusers = 
$GLOBALS['phpgw']->acl->get_ids_for_location('run',1,$app);
!                               $acl_users = $this->return_members($aclusers);
!                               $app_user       = $acl_users['users'];
!                               $app_groups     = $acl_users['groups'];
                        }
                        else
***************
*** 408,421 ****
                                if (in_array($group['account_id'],$app_groups))
                                {
-                                       
$GLOBALS['phpgw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color($tr_color));
                                        //$link_data['group_id'] = 
$group['account_id'];
!                                       
$GLOBALS['phpgw']->template->set_var('link_user_group',$GLOBALS['phpgw']->link('/index.php','menuaction='
 . $action . '&group_id=' . $group['account_id']));
!                                       
$GLOBALS['phpgw']->template->set_var('name_user_group',$group['account_name']);
!                                       
$GLOBALS['phpgw']->template->set_var('account_display',$GLOBALS['phpgw']->common->grab_owner_name($group['account_id']));
!                                       
$GLOBALS['phpgw']->template->set_var('accountid',$group['account_id']);
                                        switch($app)
                                        {
!                                               case 'calendar':        
$GLOBALS['phpgw']->template->fp('cal','group_cal',True); break;
!                                               default:                        
$GLOBALS['phpgw']->template->fp('other','group_other',True); break;
                                        }
                                }
--- 415,435 ----
                                if (in_array($group['account_id'],$app_groups))
                                {
                                        //$link_data['group_id'] = 
$group['account_id'];
!                                       $user_groups[] = array
!                                       (
!                                               'link_user_group'       => 
$GLOBALS['phpgw']->link('/index.php','menuaction=' . $action . '&group_id=' . 
$group['account_id']),
!                                               'name_user_group'       => 
$group['account_name'],
!                                               'account_display'       => 
$GLOBALS['phpgw']->common->grab_owner_name($group['account_id']),
!                                               'accountid'                     
=> $group['account_id'],
!                               'img'                   => 
$GLOBALS['phpgw']->common->image('phpgwapi','select'),
!                               'js_function'           => $js_function,
!                               'lang_select_group'     => lang('Select group')
!                                       );
! 
                                        switch($app)
                                        {
!                                               case 'addressbook':
!                                               case 'calendar':        
$group_select = 'yes'; break;
!                                               default:                        
$group_other = 'yes'; break;
                                        }
                                }
***************
*** 424,431 ****
                                        if ($app != 'admin')
                                        {
!                                               
$GLOBALS['phpgw']->template->set_var('link_all_group',$GLOBALS['phpgw']->link('/index.php','menuaction='
 . $action . '&group_id=' . $group['account_id']));
!                                               
$GLOBALS['phpgw']->template->set_var('name_all_group',$group['account_name']);
!                                               
$GLOBALS['phpgw']->template->set_var('accountid',$group['account_id']);
!                                               
$GLOBALS['phpgw']->template->fp('all','group_all',True);
                                        }
                                }
--- 438,447 ----
                                        if ($app != 'admin')
                                        {
!                                               $all_groups[] = array
!                                               (
!                                                       'link_all_group'        
=> $GLOBALS['phpgw']->link('/index.php','menuaction=' . $action . '&group_id=' 
. $group['account_id']),
!                                                       'name_all_group'        
=> $group['account_name'],
!                                                       'accountid'             
        => $group['account_id']
!                                               );
                                        }
                                }
***************
*** 512,570 ****
                        }
  
- // --------------------------------- nextmatch ---------------------------
- 
-                       $left = 
$this->nextmatchs->left('/index.php',$start,$total,$link_data);
-                       $right = 
$this->nextmatchs->right('/index.php',$start,$total,$link_data);
-                       $GLOBALS['phpgw']->template->set_var('left',$left);
-                       $GLOBALS['phpgw']->template->set_var('right',$right);
- 
-                       
$GLOBALS['phpgw']->template->set_var('lang_showing',$this->nextmatchs->show_hits($total,$start));
- 
- // -------------------------- end nextmatch 
------------------------------------
- 
-                       
$GLOBALS['phpgw']->template->set_var('search_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
-                       
$GLOBALS['phpgw']->template->set_var('search_list',$this->nextmatchs->search(array('query'
 => $GLOBALS['query'], 'search_obj' => 1)));
- 
- // ---------------- list header variable template-declarations 
--------------------------
- 
- // -------------- list header variable template-declaration 
------------------------
-                       
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
-                       
$GLOBALS['phpgw']->template->set_var('sort_lid',$this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('LoginID'),$link_data));
-                       
$GLOBALS['phpgw']->template->set_var('sort_firstname',$this->nextmatchs->show_sort_order($sort,'account_firstname',$order,'/index.php',lang('Firstname'),$link_data));
-                       
$GLOBALS['phpgw']->template->set_var('sort_lastname',$this->nextmatchs->show_sort_order($sort,'account_lastname',$order,'/index.php',lang('Lastname'),$link_data));
- 
- // ------------------------- end header declaration 
--------------------------------
                        $stop = $start + $this->nextmatchs->maxmatches;
                        for ($i=$start;$i<count($val_users)&&$i<$stop;$i++)
                        {
!                               
$GLOBALS['phpgw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color($tr_color));
!                               $firstname = 
$val_users[$i]['account_firstname'];
!                               if (!$firstname) { $firstname = '&nbsp;'; }
!                               $lastname = $val_users[$i]['account_lastname'];
!                               if (!$lastname) { $lastname = '&nbsp;'; }
! 
! // ---------------- template declaration for list records 
-------------------------- 
! 
!                               $GLOBALS['phpgw']->template->set_var(array
                                (
!                                       'lid'                           => 
$val_users[$i]['account_lid'],
!                                       'firstname'                     => 
$firstname,
!                                       'lastname'                      => 
$lastname,
!                                       'accountid'                     => 
$val_users[$i]['account_id'],
!                                       'account_display'       => 
$GLOBALS['phpgw']->common->grab_owner_name($val_users[$i]['account_id'])
!                               ));
! 
!                               
$GLOBALS['phpgw']->template->fp('list','accounts_list',True);
                        }
  
!                       $GLOBALS['phpgw']->template->set_var('start',$start);
!                       $GLOBALS['phpgw']->template->set_var('sort',$sort);
!                       $GLOBALS['phpgw']->template->set_var('order',$order);
!                       
$GLOBALS['phpgw']->template->set_var('query',$GLOBALS['query']);
!                       
$GLOBALS['phpgw']->template->set_var('group_id',$group_id);
  
!                       
$GLOBALS['phpgw']->template->set_var('lang_done',lang('done'));
!                       
$GLOBALS['phpgw']->template->pfp('out','accounts_list_t',True);
!                       $GLOBALS['phpgw']->common->phpgw_exit();
                }
        }
--- 528,616 ----
                        }
  
                        $stop = $start + $this->nextmatchs->maxmatches;
                        for ($i=$start;$i<count($val_users)&&$i<$stop;$i++)
                        {
!                               $content[] = array
                                (
!                                       'lid'                                   
=> $val_users[$i]['account_lid'],
!                                       'firstname'                             
                => $val_users[$i]['account_firstname'],
!                                       'lastname'                              
                => $val_users[$i]['account_lastname'],
!                                       'accountid'                             
                => $val_users[$i]['account_id'],
!                                       'account_display'                       
                => 
$GLOBALS['phpgw']->common->grab_owner_name($val_users[$i]['account_id']),
!                               'img'                   => 
$GLOBALS['phpgw']->common->image('phpgwapi','select'),
!                               'lang_select_user'      => lang('Select user'),
!                               'js_function'           => $js_function
!                               );
                        }
  
!                       $table_close = array
!                       (
!                               'lang_close'                    => lang('close 
window'),
!                               'start' => $start,
!                               'sort'                  => $sort,
!                               'order'                 => $order,
!                               'query'                 => $GLOBALS['query'],
!                               'group_id'                      => $group_id,
!                       );
  
!                       $table_header = array
!                       (
!                               'sort_lid'      => 
$this->nextmatchs->show_sort_order(array
!                                                                               
(
!                                                                               
        'sort'  => $this->sort,
!                                                                               
        'var'   =>      'account_lid',
!                                                                               
        'order' =>      $this->order,
!                                                                               
        'extra'         => array('menuaction'   => $action,
!                                                                               
                                                'group_id'              => 
$group_id)
!                                                                               
)),
!                               'lang_lid'      => lang('lid'),
!                               'sort_lastname' => 
$this->nextmatchs->show_sort_order(array
!                                                                               
(
!                                                                               
        'sort'  => $this->sort,
!                                                                               
        'var'   =>      'account_lastname',
!                                                                               
        'order' =>      $this->order,
!                                                                               
        'extra'         => array('menuaction'   => $action,
!                                                                               
                                                'group_id'              => 
$group_id)
!                                                                               
)),
!                               'lang_lastname' => lang('lastname'),
!                               'sort_firstname'                => 
$this->nextmatchs->show_sort_order(array
!                                                                               
(
!                                                                               
        'sort'  => $this->sort,
!                                                                               
        'var'   => 'account_firstname',
!                                                                               
        'order' => $this->order,
!                                                                               
        'extra'         => array('menuaction'   => $action,
!                                                                               
                                                'group_id'              => 
$group_id)
!                                                                               
)),
!                               'lang_firstname'                => 
lang('firstname'),
!                               'lang_groups'   => lang('user groups'),
!                               'lang_accounts' => lang('user accounts'),
!                               'lang_perm'                     => 
($app=='admin'?lang('group name'):lang('Groups with permission for 
%1',lang($app))),
!                               'withoutperm'                   => 
($app=='admin'?'no':'yes'),
!                               'lang_nonperm'          => lang('Groups without 
permission for %1',lang($app)),
!                               'group_select'          => $group_select,
!                               'group_other'           => $group_other,
!                               'user_groups'           => $user_groups,
!                               'all_groups'            => $all_groups,
!                               'values'                        => $content,
!                               'table_close'                                   
=> $table_close
!                       );
! 
!                       $data = array
!                       (
!                               'app_java_script'       => $script,
!                               'start_record'                                  
=> $start,
!                               'record_limit'                                  
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
!                               'num_records'                                   
=> count($val_users),
!                               'all_records'                                   
=> $total,
!                               'nextmatchs_url'                                
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
!                               'nextmatchs_img_path'                   => 
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
!                               'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
!                               'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
!                               'query'                                         
        => $GLOBALS['query'],
!                               'lang_search'                                   
=> lang('search'),
!                               'table_header'                                  
=> $table_header
!                       );
! 
!                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
                }
        }





reply via email to

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