phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/class.boadmin.php, 1.1.1.3


From: nomail
Subject: [Phpgroupware-cvs] property/class.boadmin.php, 1.1.1.3
Date: Fri, 21 May 2004 16:05:34 -0000

Update of /property
Modified Files:
        Branch: 
          class.boadmin.php

date: 2004/04/23 21:26:33;  author: sigurdne;  state: Exp;  lines: +497 -497

Log Message:
no message
=====================================================================
Index: property/class.boadmin.php
diff -u property/class.boadmin.php:1.1.1.2 property/class.boadmin.php:1.1.1.3
--- property/class.boadmin.php:1.1.1.2  Fri Apr 23 20:25:06 2004
+++ property/class.boadmin.php  Fri Apr 23 21:26:33 2004
@@ -1,497 +1,497 @@
-<?php
-       
/**************************************************************************\
-       * phpGroupWare - property                                               
   *
-       * http://www.phpgroupware.org                                           
   *
-       *                                                                       
   *
-       * Facilities Management                                                 
   *
-       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
-       * 
------------------------------------------------------------------------ *
-       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
-       * This program is part of the GNU project, see http://www.gnu.org/      
   *
-       * 
------------------------------------------------------------------------ *
-       * 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.                                            
   *
-       
\**************************************************************************/
-
-       class property_boadmin
-       {
-               var $start;
-               var $query;
-               var $filter;
-               var $sort;
-               var $order;
-               var $cat_id;
-
-               function property_boadmin($session='')
-               {
-                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->so                       = 
CreateObject($this->currentapp.'_soadmin');
-                       $this->acl2             = 
CreateObject($this->currentapp.'_acl2','##DEFAULT##','##DEFAULT##');
-                       $this->right            = array(1,2,4,8,16,32,64,128);
-                       $this->app_id           
=$GLOBALS['phpgw']->applications->data[$GLOBALS['phpgw_info']['flags']['currentapp']]['id'];
-                       $this->fm_session       = 
CreateObject($this->currentapp.'_session');
-
-                       if ($session)
-                       {
-                               $this->read_sessiondata();
-                               $this->use_session = True;
-                       }
-
-
-                       $start  = get_var('start',array('POST','GET'));
-                       $query  = get_var('query',array('POST','GET'));
-                       $sort   = get_var('sort',array('POST','GET'));
-                       $order  = get_var('order',array('POST','GET'));
-                       $filter = get_var('filter',array('POST','GET'));
-                       $cat_id = get_var('cat_id',array('POST','GET'));
-                       $permission     = 
get_var('permission',array('POST','GET'));
-       //              $location       = 
get_var('location',array('POST','GET')); // don't work for some reason...
-                       $module = get_var('module',array('POST','GET'));
-                       $granting_group = 
get_var('granting_group',array('POST','GET'));
-
-                       if ($start)
-                       {
-                               $this->start=$start;
-                       }
-                       else
-                       {
-                               $this->start=0;
-                       }
-
-                       if(isset($query))
-                       {
-                               $this->query = $query;
-                       }
-                       if(isset($filter))
-                       {
-                               $this->filter = $filter;
-                       }
-                       if(isset($sort))
-                       {
-                               $this->sort = $sort;
-                       }
-                       if(isset($order))
-                       {
-                               $this->order = $order;
-                       }
-                       if(isset($cat_id))
-                       {
-                               $this->cat_id = $cat_id;
-                       }
-                       if(isset($module))
-                       {
-                               $this->location = $module;
-                       }
-                       if(isset($granting_group))
-                       {
-                               $this->granting_group = $granting_group;
-                       }
-
-               }
-
-
-               function read_sessiondata()
-               {
-                       $data = 
$this->fm_session->appsession('session_data','fm_admin');
-
-                       $this->start            = $data['start'];
-                       $this->query            = $data['query'];
-                       $this->filter           = $data['filter'];
-                       $this->sort                     = $data['sort'];
-                       $this->order            = $data['order'];
-                       $this->cat_id           = $data['cat_id'];
-                       $this->location         = $data['location'];
-                       $this->granting_group   = $data['granting_group'];
-               }
-
-               function save_sessiondata($data)
-               {
-                       if ($this->use_session)
-                       {
-                               
$this->fm_session->appsession('session_data','fm_admin',$data);
-                       }
-               }
-
-
-
-               function select_location($format='',$selected='',$grant='')
-               {
-
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$this->bocommon->xsl_add_file(array('select_location'));
-                                       break;
-                               case 'filter':
-                                       
$this->bocommon->xsl_add_file(array('filter_location'));
-                                       break;
-                       }
-
-                       $locations= $this->so->select_location($grant);
-
-                       while (is_array($locations) && list(,$loc) = 
each($locations))
-                       {
-                               $sel_loc = '';
-                               if ($loc['id']==$selected)
-                               {
-                                       $sel_loc = 'selected';
-                               }
-
-                               $location_list[] = array
-                               (
-                                       'id'            => $loc['id'],
-                                       'descr'         => $loc['id'] . ' [' . 
$loc['descr'] . ']',
-                                       'selected'      => $sel_loc
-                               );
-                       }
-
-                       for ($i=0;$i<count($location_list);$i++)
-                       {
-                               if ($location_list[$i]['selected'] != 
'selected')
-                               {
-                                       unset($location_list[$i]['selected']);
-                               }
-                       }
-
-                       return $location_list;
-               }
-
-               function select_category_list($format='',$selected='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$this->bocommon->xsl_add_file(array('cat_select'));
-                                       break;
-                               case 'filter':
-                                       
$this->bocommon->xsl_add_file(array('cat_filter'));
-                                       break;
-                       }
-
-
-                       $categories[0]['id']    = 'groups';
-                       $categories[0]['name']  = lang('Groups');
-                       $categories[1]['id']    = 'accounts';
-                       $categories[1]['name']  = lang('Users');
-
-                       while (is_array($categories) && list(,$category) = 
each($categories))
-                       {
-                               $sel_category = '';
-                               if ($category['id']==$selected)
-                               {
-                                       $sel_category = 'selected';
-                               }
-
-                               $category_list[] = array
-                               (
-                                       'cat_id'        => $category['id'],
-                                       'name'          => $category['name'],
-                                       'selected'      => $sel_category
-                               );
-                       }
-
-                       for ($i=0;$i<count($category_list);$i++)
-                       {
-                               if ($category_list[$i]['selected'] != 
'selected')
-                               {
-                                       unset($category_list[$i]['selected']);
-                               }
-                       }
-
-                       return $category_list;
-               }
-
-               function set_permission2($values,$r_processed,$type)
-               {
-                       @reset($values);
-                       $totalacl = array();
-                       while(list($rowinfo,$perm) = each($values))
-                       {
-                               list($user_id,$rights) = split('_',$rowinfo);
-                               $totalacl[$user_id] += $rights;
-                       }
-                       @reset($totalacl);
-                       while(list($user_id,$rights) = @each($totalacl))
-                       {
-                               $user_checked[]=$user_id;
-
-                               
$this->acl2->set($this->location,$rights,$user_id,$type);
-                       }
-
-                       if(is_array($r_processed) && is_array($user_checked))
-                       {
-                               $user_delete    = array_diff($r_processed, 
$user_checked);
-                       }
-                       else
-                       {
-                               $user_delete    = $r_processed;
-                       }
-                       if(is_array($user_delete) && count($user_delete)>0)
-                       {
-                               $user_delete= explode("_",implode("_", 
$user_delete));
-
-                               $this->remove_permission($user_delete,$type);
-                       }
-               }
-
-               function set_permission($values,$r_processed,$initials)
-               {
-                       if($initials)
-                       {
-                               $this->so->set_initials($initials);
-                       }
-
-                       $r_processed=explode("_",$r_processed);
-
-                       if(!$values['right'])
-                       {
-                               $values['right'] = array();
-                       }
-                       if(!$values['mask'])
-                       {
-                               $values['mask'] = array();
-                       }
-
-                       $this->set_permission2($values['right'],$r_processed,0);
-                       $this->set_permission2($values['mask'],$r_processed,1);
-
-//     $this->acl2->check('.invoice.test', $rights,$user_id);
-//     echo 'rights_cache:<pre>'; print_r($this->acl2->rights_cache); echo 
'</pre>';
-
-                       $receipt['message'][] = array('msg' => 
lang('permissions are updated!'));
-                       return $receipt;
-               }
-
-               function set_grant2($values,$r_processed,$type)
-               {
-                       @reset($values);
-                       $totalacl = array();
-                       while(list($rowinfo,$perm) = each($values))
-                       {
-                               list($user_id,$rights) = split('_',$rowinfo);
-                               $totalacl[$user_id] += $rights;
-                       }
-                       @reset($totalacl);
-                       while(list($user_id,$rights) = @each($totalacl))
-                       {
-                               $user_checked[]=$user_id;
-
-                               
$this->acl2->set_grant($this->location,$rights,$user_id,$type,$this->granting_group);
-                       }
-
-                       if(is_array($r_processed) && is_array($user_checked))
-                       {
-                               $user_delete    = array_diff($r_processed, 
$user_checked);
-                       }
-                       else
-                       {
-                               $user_delete    = $r_processed;
-                       }
-                       if(is_array($user_delete) && count($user_delete)>0)
-                       {
-                               $user_delete= explode("_",implode("_", 
$user_delete));
-
-                               $this->remove_grant($user_delete,$type);
-                       }
-
-               }
-
-               function set_grant($values,$r_processed)
-               {
-                       $r_processed=explode("_",$r_processed);
-
-                       if(!$values['right'])
-                       {
-                               $values['right'] = array();
-                       }
-                       if(!$values['mask'])
-                       {
-                               $values['mask'] = array();
-                       }
-
-                       $this->set_grant2($values['right'],$r_processed,0);
-                       $this->set_grant2($values['mask'],$r_processed,1);
-
-                       $receipt['message'][] = array('msg' => 
lang('permissions are updated!'));
-                       return $receipt;
-               }
-
-               function remove_permission($user_delete,$type)
-               {
-
-                       $right=$this->right;
-
-                       for ($i=0;$i<count($user_delete);$i++)
-                       {
-                               for ($j=0;$j<count($right);$j++)
-                               {
-                                       
$this->acl2->remove($this->location,$right[$j],$user_delete[$i],$type);
-                               }
-                       }
-               }
-
-               function remove_grant($user_delete,$type)
-               {
-
-                       $right=$this->right;
-
-                       for ($i=0;$i<count($user_delete);$i++)
-                       {
-                               for ($j=0;$j<count($right);$j++)
-                               {
-                                       
$this->acl2->remove_grant($this->location,$right[$j],$user_delete[$i],$type,$this->granting_group);
-                               }
-                       }
-               }
-
-               function get_user_list($type='',$app_id='')
-               {
-                       if($this->granting_group)
-                       {
-                               $owner = $this->granting_group;
-                       }
-                       else
-                       {
-                               $owner = $GLOBALS['phpgw_data']['user']['id'];
-                       }
-
-                       $right=$this->right;
-
-                       $GLOBALS['phpgw']->accounts->account_id = $owner;
-
-                       $allusers = 
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort, 
$this->order, $this->query);
-
-                       if (isSet($allusers) AND is_array($allusers))
-                       {
-                               $j=0;
-                               foreach($allusers as $account)
-                               {
-                                       
if($account['account_id']!=$GLOBALS['phpgw_data']['user']['id'] || 
$this->granting_group)
-                                       {
-                                               $user_list[$j]['account_id']    
        = $account['account_id'];
-                                               $user_list[$j]['account_lid']   
        = $account['account_lid'];
-                                               
$user_list[$j]['account_firstname'] = $account['account_firstname'];
-                                               
$user_list[$j]['account_lastname']      = $account['account_lastname'];
-                                               $user_list[$j]['initials']      
                = $this->so->get_initials($account['account_id']);
-
-                                               $count_right=count($right);
-                                               for ($i=0;$i<$count_right;$i++)
-                                               {
-                                                       
if($this->acl2->check_grant($owner,$this->location, 
$right[$i],$account['account_id'],$app_id,True,0,True))
-                                                       {
-                                                               
$user_list[$j]['right'][$right[$i]] = 'checked';
-                                                       }
-                                                       
if($this->acl2->check_grant($owner,$this->location, 
$right[$i],$account['account_id'],$this->app_id,True,1,True))
-                                                       {
-                                                               
$user_list[$j]['mask'][$right[$i]] = 'checked';
-                                                       }
-                                               }
-
-                                               if 
(isSet($user_list[$j]['mask']) AND is_array($user_list[$j]['mask']))
-                                               {
-                                                       $result_temp    = 
@array_diff(array_keys($user_list[$j]['right']), 
array_keys($user_list[$j]['mask']));
-                                                       if (isSet($result_temp) 
AND is_array($result_temp))
-                                                       {
-                                                               
foreach($result_temp as $temp)
-                                                               {
-                                                                       
$user_list[$j]['result'][$temp] = 'checked';
-                                                               }
-                                                       }
-                                               }
-                                               else
-                                               {
-                                                       
$user_list[$j]['result'] = $user_list[$j]['right'];
-                                               }
-
-                                               $user_list[$j]['right']['type'] 
= 'right';
-                                               $user_list[$j]['mask']['type'] 
= 'mask';
-                                               
$user_list[$j]['result']['type'] = 'result';
-
-                                               $j++;
-                                       }
-                               }
-                       }
-
-                       $this->total_records = $this->total_records + 
count($user_list);
-
-//html_print_r($user_list);
-
-                       return $user_list;
-               }
-
-
-               function get_user_list2($type='',$app_id='')
-               {
-                       $right=$this->right;
-
-                       $allusers = 
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort, 
$this->order, $this->query);
-
-                       if (isSet($allusers) AND is_array($allusers))
-                       {
-                               $j=0;
-                               foreach($allusers as $account)
-                               {
-                                       $user_list[$j]['account_id']            
= $account['account_id'];
-                                       $user_list[$j]['account_lid']           
= $account['account_lid'];
-                                       $user_list[$j]['account_firstname'] = 
$account['account_firstname'];
-                                       $user_list[$j]['account_lastname']      
= $account['account_lastname'];
-                                       $user_list[$j]['initials']              
        = $this->so->get_initials($account['account_id']);
-
-                                       $count_right=count($right);
-                                       for ($i=0;$i<$count_right;$i++)
-                                       {
-                                               
if($this->acl2->check($this->location, 
$right[$i],$account['account_id'],$this->app_id,True,0,True))
-                                               {
-                                                       
$user_list[$j]['right'][$right[$i]] = 'checked';
-                                               }
-                                               
if($this->acl2->check($this->location, 
$right[$i],$account['account_id'],$this->app_id,True,1,True))
-                                               {
-                                                       
$user_list[$j]['mask'][$right[$i]] = 'checked';
-                                               }
-                                       }
-
-                                       if (isSet($user_list[$j]['mask']) AND 
is_array($user_list[$j]['mask']))
-                                       {
-                                               $result_temp    = 
@array_diff(array_keys($user_list[$j]['right']), 
array_keys($user_list[$j]['mask']));
-                                               if (isSet($result_temp) AND 
is_array($result_temp))
-                                               {
-                                                       foreach($result_temp as 
$temp)
-                                                       {
-                                                               
$user_list[$j]['result'][$temp] = 'checked';
-                                                       }
-                                               }
-                                       }
-                                       else
-                                       {
-                                               $user_list[$j]['result'] = 
$user_list[$j]['right'];
-                                       }
-
-                                       $user_list[$j]['right']['type'] = 
'right';
-                                       $user_list[$j]['mask']['type'] = 'mask';
-                                       $user_list[$j]['result']['type'] = 
'result';
-
-                                       $j++;
-                               }
-                       }
-
-                       $this->total_records = $this->total_records + 
count($user_list);
-
-                       return $user_list;
-               }
-
-               function read_fm_id()
-               {
-
-                       $fm_ids = $this->so->read_fm_id();
-                       return $fm_ids;
-
-               }
-               function edit_id($values='')
-               {
-                       return $this->so->edit_id($values);
-
-               }
-       }
-?>
+<?php
+       
/**************************************************************************\
+       * phpGroupWare - property                                               
   *
+       * http://www.phpgroupware.org                                           
   *
+       *                                                                       
   *
+       * Facilities Management                                                 
   *
+       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
+       * 
------------------------------------------------------------------------ *
+       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
+       * This program is part of the GNU project, see http://www.gnu.org/      
   *
+       * 
------------------------------------------------------------------------ *
+       * 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.                                            
   *
+       
\**************************************************************************/
+
+       class property_boadmin
+       {
+               var $start;
+               var $query;
+               var $filter;
+               var $sort;
+               var $order;
+               var $cat_id;
+
+               function property_boadmin($session='')
+               {
+                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->so                       = 
CreateObject($this->currentapp.'_soadmin');
+                       $this->acl2             = 
CreateObject($this->currentapp.'_acl2','##DEFAULT##','##DEFAULT##');
+                       $this->right            = array(1,2,4,8,16,32,64,128);
+                       $this->app_id           
=$GLOBALS['phpgw']->applications->data[$GLOBALS['phpgw_info']['flags']['currentapp']]['id'];
+                       $this->fm_session       = 
CreateObject($this->currentapp.'_session');
+
+                       if ($session)
+                       {
+                               $this->read_sessiondata();
+                               $this->use_session = True;
+                       }
+
+
+                       $start  = get_var('start',array('POST','GET'));
+                       $query  = get_var('query',array('POST','GET'));
+                       $sort   = get_var('sort',array('POST','GET'));
+                       $order  = get_var('order',array('POST','GET'));
+                       $filter = get_var('filter',array('POST','GET'));
+                       $cat_id = get_var('cat_id',array('POST','GET'));
+                       $permission     = 
get_var('permission',array('POST','GET'));
+       //              $location       = 
get_var('location',array('POST','GET')); // don't work for some reason...
+                       $module = get_var('module',array('POST','GET'));
+                       $granting_group = 
get_var('granting_group',array('POST','GET'));
+
+                       if ($start)
+                       {
+                               $this->start=$start;
+                       }
+                       else
+                       {
+                               $this->start=0;
+                       }
+
+                       if(isset($query))
+                       {
+                               $this->query = $query;
+                       }
+                       if(isset($filter))
+                       {
+                               $this->filter = $filter;
+                       }
+                       if(isset($sort))
+                       {
+                               $this->sort = $sort;
+                       }
+                       if(isset($order))
+                       {
+                               $this->order = $order;
+                       }
+                       if(isset($cat_id))
+                       {
+                               $this->cat_id = $cat_id;
+                       }
+                       if(isset($module))
+                       {
+                               $this->location = $module;
+                       }
+                       if(isset($granting_group))
+                       {
+                               $this->granting_group = $granting_group;
+                       }
+
+               }
+
+
+               function read_sessiondata()
+               {
+                       $data = 
$this->fm_session->appsession('session_data','fm_admin');
+
+                       $this->start            = $data['start'];
+                       $this->query            = $data['query'];
+                       $this->filter           = $data['filter'];
+                       $this->sort                     = $data['sort'];
+                       $this->order            = $data['order'];
+                       $this->cat_id           = $data['cat_id'];
+                       $this->location         = $data['location'];
+                       $this->granting_group   = $data['granting_group'];
+               }
+
+               function save_sessiondata($data)
+               {
+                       if ($this->use_session)
+                       {
+                               
$this->fm_session->appsession('session_data','fm_admin',$data);
+                       }
+               }
+
+
+
+               function select_location($format='',$selected='',$grant='')
+               {
+
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$this->bocommon->xsl_add_file(array('select_location'));
+                                       break;
+                               case 'filter':
+                                       
$this->bocommon->xsl_add_file(array('filter_location'));
+                                       break;
+                       }
+
+                       $locations= $this->so->select_location($grant);
+
+                       while (is_array($locations) && list(,$loc) = 
each($locations))
+                       {
+                               $sel_loc = '';
+                               if ($loc['id']==$selected)
+                               {
+                                       $sel_loc = 'selected';
+                               }
+
+                               $location_list[] = array
+                               (
+                                       'id'            => $loc['id'],
+                                       'descr'         => $loc['id'] . ' [' . 
$loc['descr'] . ']',
+                                       'selected'      => $sel_loc
+                               );
+                       }
+
+                       for ($i=0;$i<count($location_list);$i++)
+                       {
+                               if ($location_list[$i]['selected'] != 
'selected')
+                               {
+                                       unset($location_list[$i]['selected']);
+                               }
+                       }
+
+                       return $location_list;
+               }
+
+               function select_category_list($format='',$selected='')
+               {
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$this->bocommon->xsl_add_file(array('cat_select'));
+                                       break;
+                               case 'filter':
+                                       
$this->bocommon->xsl_add_file(array('cat_filter'));
+                                       break;
+                       }
+
+
+                       $categories[0]['id']    = 'groups';
+                       $categories[0]['name']  = lang('Groups');
+                       $categories[1]['id']    = 'accounts';
+                       $categories[1]['name']  = lang('Users');
+
+                       while (is_array($categories) && list(,$category) = 
each($categories))
+                       {
+                               $sel_category = '';
+                               if ($category['id']==$selected)
+                               {
+                                       $sel_category = 'selected';
+                               }
+
+                               $category_list[] = array
+                               (
+                                       'cat_id'        => $category['id'],
+                                       'name'          => $category['name'],
+                                       'selected'      => $sel_category
+                               );
+                       }
+
+                       for ($i=0;$i<count($category_list);$i++)
+                       {
+                               if ($category_list[$i]['selected'] != 
'selected')
+                               {
+                                       unset($category_list[$i]['selected']);
+                               }
+                       }
+
+                       return $category_list;
+               }
+
+               function set_permission2($values,$r_processed,$type)
+               {
+                       @reset($values);
+                       $totalacl = array();
+                       while(list($rowinfo,$perm) = each($values))
+                       {
+                               list($user_id,$rights) = split('_',$rowinfo);
+                               $totalacl[$user_id] += $rights;
+                       }
+                       @reset($totalacl);
+                       while(list($user_id,$rights) = @each($totalacl))
+                       {
+                               $user_checked[]=$user_id;
+
+                               
$this->acl2->set($this->location,$rights,$user_id,$type);
+                       }
+
+                       if(is_array($r_processed) && is_array($user_checked))
+                       {
+                               $user_delete    = array_diff($r_processed, 
$user_checked);
+                       }
+                       else
+                       {
+                               $user_delete    = $r_processed;
+                       }
+                       if(is_array($user_delete) && count($user_delete)>0)
+                       {
+                               $user_delete= explode("_",implode("_", 
$user_delete));
+
+                               $this->remove_permission($user_delete,$type);
+                       }
+               }
+
+               function set_permission($values,$r_processed,$initials)
+               {
+                       if($initials)
+                       {
+                               $this->so->set_initials($initials);
+                       }
+
+                       $r_processed=explode("_",$r_processed);
+
+                       if(!$values['right'])
+                       {
+                               $values['right'] = array();
+                       }
+                       if(!$values['mask'])
+                       {
+                               $values['mask'] = array();
+                       }
+
+                       $this->set_permission2($values['right'],$r_processed,0);
+                       $this->set_permission2($values['mask'],$r_processed,1);
+
+//     $this->acl2->check('.invoice.test', $rights,$user_id);
+//     echo 'rights_cache:<pre>'; print_r($this->acl2->rights_cache); echo 
'</pre>';
+
+                       $receipt['message'][] = array('msg' => 
lang('permissions are updated!'));
+                       return $receipt;
+               }
+
+               function set_grant2($values,$r_processed,$type)
+               {
+                       @reset($values);
+                       $totalacl = array();
+                       while(list($rowinfo,$perm) = each($values))
+                       {
+                               list($user_id,$rights) = split('_',$rowinfo);
+                               $totalacl[$user_id] += $rights;
+                       }
+                       @reset($totalacl);
+                       while(list($user_id,$rights) = @each($totalacl))
+                       {
+                               $user_checked[]=$user_id;
+
+                               
$this->acl2->set_grant($this->location,$rights,$user_id,$type,$this->granting_group);
+                       }
+
+                       if(is_array($r_processed) && is_array($user_checked))
+                       {
+                               $user_delete    = array_diff($r_processed, 
$user_checked);
+                       }
+                       else
+                       {
+                               $user_delete    = $r_processed;
+                       }
+                       if(is_array($user_delete) && count($user_delete)>0)
+                       {
+                               $user_delete= explode("_",implode("_", 
$user_delete));
+
+                               $this->remove_grant($user_delete,$type);
+                       }
+
+               }
+
+               function set_grant($values,$r_processed)
+               {
+                       $r_processed=explode("_",$r_processed);
+
+                       if(!$values['right'])
+                       {
+                               $values['right'] = array();
+                       }
+                       if(!$values['mask'])
+                       {
+                               $values['mask'] = array();
+                       }
+
+                       $this->set_grant2($values['right'],$r_processed,0);
+                       $this->set_grant2($values['mask'],$r_processed,1);
+
+                       $receipt['message'][] = array('msg' => 
lang('permissions are updated!'));
+                       return $receipt;
+               }
+
+               function remove_permission($user_delete,$type)
+               {
+
+                       $right=$this->right;
+
+                       for ($i=0;$i<count($user_delete);$i++)
+                       {
+                               for ($j=0;$j<count($right);$j++)
+                               {
+                                       
$this->acl2->remove($this->location,$right[$j],$user_delete[$i],$type);
+                               }
+                       }
+               }
+
+               function remove_grant($user_delete,$type)
+               {
+
+                       $right=$this->right;
+
+                       for ($i=0;$i<count($user_delete);$i++)
+                       {
+                               for ($j=0;$j<count($right);$j++)
+                               {
+                                       
$this->acl2->remove_grant($this->location,$right[$j],$user_delete[$i],$type,$this->granting_group);
+                               }
+                       }
+               }
+
+               function get_user_list($type='',$app_id='')
+               {
+                       if($this->granting_group)
+                       {
+                               $owner = $this->granting_group;
+                       }
+                       else
+                       {
+                               $owner = $GLOBALS['phpgw_data']['user']['id'];
+                       }
+
+                       $right=$this->right;
+
+                       $GLOBALS['phpgw']->accounts->account_id = $owner;
+
+                       $allusers = 
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort, 
$this->order, $this->query);
+
+                       if (isSet($allusers) AND is_array($allusers))
+                       {
+                               $j=0;
+                               foreach($allusers as $account)
+                               {
+                                       
if($account['account_id']!=$GLOBALS['phpgw_data']['user']['id'] || 
$this->granting_group)
+                                       {
+                                               $user_list[$j]['account_id']    
        = $account['account_id'];
+                                               $user_list[$j]['account_lid']   
        = $account['account_lid'];
+                                               
$user_list[$j]['account_firstname'] = $account['account_firstname'];
+                                               
$user_list[$j]['account_lastname']      = $account['account_lastname'];
+                                               $user_list[$j]['initials']      
                = $this->so->get_initials($account['account_id']);
+
+                                               $count_right=count($right);
+                                               for ($i=0;$i<$count_right;$i++)
+                                               {
+                                                       
if($this->acl2->check_grant($owner,$this->location, 
$right[$i],$account['account_id'],$app_id,True,0,True))
+                                                       {
+                                                               
$user_list[$j]['right'][$right[$i]] = 'checked';
+                                                       }
+                                                       
if($this->acl2->check_grant($owner,$this->location, 
$right[$i],$account['account_id'],$this->app_id,True,1,True))
+                                                       {
+                                                               
$user_list[$j]['mask'][$right[$i]] = 'checked';
+                                                       }
+                                               }
+
+                                               if 
(isSet($user_list[$j]['mask']) AND is_array($user_list[$j]['mask']))
+                                               {
+                                                       $result_temp    = 
@array_diff(array_keys($user_list[$j]['right']), 
array_keys($user_list[$j]['mask']));
+                                                       if (isSet($result_temp) 
AND is_array($result_temp))
+                                                       {
+                                                               
foreach($result_temp as $temp)
+                                                               {
+                                                                       
$user_list[$j]['result'][$temp] = 'checked';
+                                                               }
+                                                       }
+                                               }
+                                               else
+                                               {
+                                                       
$user_list[$j]['result'] = $user_list[$j]['right'];
+                                               }
+
+                                               $user_list[$j]['right']['type'] 
= 'right';
+                                               $user_list[$j]['mask']['type'] 
= 'mask';
+                                               
$user_list[$j]['result']['type'] = 'result';
+
+                                               $j++;
+                                       }
+                               }
+                       }
+
+                       $this->total_records = $this->total_records + 
count($user_list);
+
+//html_print_r($user_list);
+
+                       return $user_list;
+               }
+
+
+               function get_user_list2($type='',$app_id='')
+               {
+                       $right=$this->right;
+
+                       $allusers = 
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort, 
$this->order, $this->query);
+
+                       if (isSet($allusers) AND is_array($allusers))
+                       {
+                               $j=0;
+                               foreach($allusers as $account)
+                               {
+                                       $user_list[$j]['account_id']            
= $account['account_id'];
+                                       $user_list[$j]['account_lid']           
= $account['account_lid'];
+                                       $user_list[$j]['account_firstname'] = 
$account['account_firstname'];
+                                       $user_list[$j]['account_lastname']      
= $account['account_lastname'];
+                                       $user_list[$j]['initials']              
        = $this->so->get_initials($account['account_id']);
+
+                                       $count_right=count($right);
+                                       for ($i=0;$i<$count_right;$i++)
+                                       {
+                                               
if($this->acl2->check($this->location, 
$right[$i],$account['account_id'],$this->app_id,True,0,True))
+                                               {
+                                                       
$user_list[$j]['right'][$right[$i]] = 'checked';
+                                               }
+                                               
if($this->acl2->check($this->location, 
$right[$i],$account['account_id'],$this->app_id,True,1,True))
+                                               {
+                                                       
$user_list[$j]['mask'][$right[$i]] = 'checked';
+                                               }
+                                       }
+
+                                       if (isSet($user_list[$j]['mask']) AND 
is_array($user_list[$j]['mask']))
+                                       {
+                                               $result_temp    = 
@array_diff(array_keys($user_list[$j]['right']), 
array_keys($user_list[$j]['mask']));
+                                               if (isSet($result_temp) AND 
is_array($result_temp))
+                                               {
+                                                       foreach($result_temp as 
$temp)
+                                                       {
+                                                               
$user_list[$j]['result'][$temp] = 'checked';
+                                                       }
+                                               }
+                                       }
+                                       else
+                                       {
+                                               $user_list[$j]['result'] = 
$user_list[$j]['right'];
+                                       }
+
+                                       $user_list[$j]['right']['type'] = 
'right';
+                                       $user_list[$j]['mask']['type'] = 'mask';
+                                       $user_list[$j]['result']['type'] = 
'result';
+
+                                       $j++;
+                               }
+                       }
+
+                       $this->total_records = $this->total_records + 
count($user_list);
+
+                       return $user_list;
+               }
+
+               function read_fm_id()
+               {
+
+                       $fm_ids = $this->so->read_fm_id();
+                       return $fm_ids;
+
+               }
+               function edit_id($values='')
+               {
+                       return $this->so->edit_id($values);
+
+               }
+       }
+?>




reply via email to

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