[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] hrm/inc class.boadmin.inc.php, 1.3 class.uiadmin.inc.
From: |
sigurdne |
Subject: |
[Phpgroupware-cvs] hrm/inc class.boadmin.inc.php, 1.3 class.uiadmin.inc.php, 1.3 class.soadmin.inc.php, 1.3 class.bocommon.inc.php, 1.4 class.socommon.inc.php, 1.3 |
Date: |
Fri, 25 Nov 2005 12:58:00 +0100 |
Update of hrm/inc
Modified Files:
Branch: MAIN
class.boadmin.inc.php lines: +403 -503
class.uiadmin.inc.php lines: +594 -618
class.soadmin.inc.php lines: +32 -122
class.bocommon.inc.php lines: +658 -1379
class.socommon.inc.php lines: +92 -303
Log Message:
Improved acl
====================================================
Index: hrm/inc/class.boadmin.inc.php
diff -u hrm/inc/class.boadmin.inc.php:1.2 hrm/inc/class.boadmin.inc.php:1.3
--- hrm/inc/class.boadmin.inc.php:1.2 Mon Nov 21 20:25:33 2005
+++ hrm/inc/class.boadmin.inc.php Fri Nov 25 11:58:29 2005
@@ -1,504 +1,404 @@
-<?php
- /**
- * phpGroupWare - HRM: a human resource competence management system.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package hrm
- * @subpackage admin
- * @version $Id$
- */
-
- /**
- * Description
- * @package property
- */
-
- class boadmin
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- function boadmin($session='')
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soadmin');
- $this->catbo = createobject('phpgwapi.categories');
-
- $this->acl = $GLOBALS['phpgw']->acl;
- $this->right = array(1,2,4,8,16,32,64,128);
- $this->app_id
=$GLOBALS['phpgw']->applications->data[$GLOBALS['phpgw_info']['flags']['currentapp']]['id'];
-
- 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'));
- $allrows =
get_var('allrows',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;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
-
- }
-
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->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'];
- $this->allrows = $data['allrows'];
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin',$data);
- }
- }
-
- function select_location($format='',$selected='',$grant='')
- {
-
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('select_location'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_location'));
- break;
- }
-
-// $locations= $this->so->select_location($grant);
- $i=0;
- $locations[$i]['id'] = 'run';
- $locations[$i]['descr'] = 'Hrm-main';
- $i++;
- $locations[$i]['id'] = 'user';
- $locations[$i]['descr'] = 'Hrm-user';
- $i++;
- $locations[$i]['id'] = 'C-1';
- $locations[$i]['descr'] =
lang('contact_information');
- $i++;
- $locations[$i]['id'] = 'C-2';
- $locations[$i]['descr'] = lang('photo');
- $i++;
-
-
- $api_cats = $this->catbo->return_array('all', 0, True,
False, False, 'cat_name', True);
- if ( is_array($api_cats) )
- {
- foreach ($api_cats as $cat)
- {
- $locations[$i]['id'] = 'C' .
$cat['id'];
- $locations[$i]['descr'] = $cat['name'];
- $i++;
- }
- }
- unset($api_cats);
-
- 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':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->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)
- {
- @reset($values);
- while(list($rowinfo,$perm) = each($values))
- {
- list($user_id,$rights) = split('_',$rowinfo);
- $new_acl[$user_id][]=$rights;
- $user_checked[]=$user_id;
- }
-
- 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)
- {
- while(list(,$user_id) = each($user_delete))
- {
- $this->acl->account_id=$user_id;
- $this->acl->read_repository();
- $this->acl->delete($appname =
$this->currentapp, $this->location);
- $this->acl->save_repository();
- }
- }
-
- while(list($user_id,$new_rights) = @each($new_acl))
- {
- $this->acl->account_id=$user_id;
- $this->acl->read_repository();
- $this->acl->delete($appname =
$this->currentapp, $this->location);
-
- if(is_array($new_rights) &&
count($new_rights)>0)
- {
- foreach($new_rights as $right)
- {
- $this->acl->add($appname =
$this->currentapp, $this->location, $right);
- }
- }
-
- $this->acl->save_repository();
- }
- }
-
- function set_permission($values,$r_processed)
- {
-
- $r_processed=explode("_",$r_processed);
-
- if(!$values)
- {
- $values = array();
- }
-
-//_debug_array($values);
-//_debug_array($r_processed);
- $this->set_permission2($values,$r_processed);
-
-// echo 'rights_cache:<pre>'; print_r($this->acl->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->acl->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_grant($user_delete,$type)
- {
-
- $right=$this->right;
-
- for ($i=0;$i<count($user_delete);$i++)
- {
- for ($j=0;$j<count($right);$j++)
- {
-
$this->acl->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_info']['user']['account_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_info']['user']['account_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->acl->check_grant($owner,$this->location,
$right[$i],$account['account_id'],$app_id,True,0,True))
- {
-
$user_list[$j]['right'][$right[$i]] = 'checked';
- }
-
if($this->acl->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 =
$GLOBALS['phpgw']->accounts->total;
-
-//_debug_array($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']);
-
-
$this->acl->account_id=$account['account_id'];
-
- $this->acl->read_repository();
-
- $count_right=count($right);
- for ($i=0;$i<$count_right;$i++)
- {
-
if($this->acl->check($this->location, $right[$i],$this->currentapp))
- {
-
$user_list[$j]['right'][$right[$i]] = 'checked';
- }
-
if($this->acl->check($this->location,
$right[$i],$account['account_id'],$this->app_id,True,1,True))
- {
-
$user_list[$j]['mask'][$right[$i]] = 'checked';
- }
- }
-
- $j++;
- }
- }
-
- $this->total_records =
$GLOBALS['phpgw']->accounts->total;
-
- 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 - HRM: a human resource competence management system.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package hrm
+ * @subpackage admin
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boadmin
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ function boadmin($session='')
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soadmin');
+ $this->catbo = createobject('phpgwapi.categories');
+
+// $this->acl = $GLOBALS['phpgw']->acl;
+ $this->acl =
CreateObject($this->currentapp.'.acl2');
+ $this->right = array(1,2,4,8,16);
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $acl_app =
get_var('acl_app',array('POST','GET'));
+ $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'));
+ $module = get_var('module',array('POST','GET'));
+ $granting_group =
get_var('granting_group',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if($acl_app)
+ {
+ $this->acl_app = $acl_app;
+ }
+ else
+ {
+ $this->acl_app = $this->currentapp;
+ }
+ 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;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->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'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin',$data);
+ }
+ }
+
+ function select_location($format='',$selected='',$grant='')
+ {
+
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('select_location'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_location'));
+ break;
+ }
+
+// $locations= $this->so->select_location($grant);
+ $i=0;
+ $locations[$i]['id'] = 'run';
+ $locations[$i]['descr'] = 'Hrm-main';
+ $i++;
+ $locations[$i]['id'] = 'user';
+ $locations[$i]['descr'] = 'Hrm-user';
+ $i++;
+ $locations[$i]['id'] = 'C-1';
+ $locations[$i]['descr'] =
lang('contact_information');
+ $i++;
+ $locations[$i]['id'] = 'C-2';
+ $locations[$i]['descr'] = lang('photo');
+ $i++;
+
+
+ $api_cats = $this->catbo->return_array('all', 0, True,
False, False, 'cat_name', True);
+ if ( is_array($api_cats) )
+ {
+ foreach ($api_cats as $cat)
+ {
+ $locations[$i]['id'] = 'C' .
$cat['id'];
+ $locations[$i]['descr'] = $cat['name'];
+ $i++;
+ }
+ }
+ unset($api_cats);
+
+ 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':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->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, $grantor =
False, $type = False)
+ {
+ @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->acl->account_id=$user_id;
+ $this->acl->read_repository();
+ $this->acl->delete($appname = $this->acl_app,
$this->location,$grantor,$type);
+ $this->acl->add($appname = $this->acl_app,
$this->location, $rights,$grantor,$type);
+ $this->acl->save_repository();
+ }
+
+ 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)
+ {
+ while(list(,$user_id) = each($user_delete))
+ {
+ $this->acl->account_id=$user_id;
+ $this->acl->read_repository();
+ $this->acl->delete($appname =
$this->acl_app, $this->location,$grantor,$type);
+ $this->acl->save_repository();
+ }
+ }
+ }
+
+ function set_permission($values,$r_processed,$set_grant = '')
+ {
+
+ $r_processed=explode("_",$r_processed);
+
+ if(!$values['right'])
+ {
+ $values['right'] = array();
+ }
+ if(!$values['mask'])
+ {
+ $values['mask'] = array();
+ }
+
+ if($set_grant)
+ {
+ if($this->granting_group)
+ {
+ $grantor = $this->granting_group;
+ }
+ else
+ {
+ $grantor =
$GLOBALS['phpgw_info']['user']['account_id'];
+ }
+ }
+
+
$this->set_permission2($values['right'],$r_processed,$grantor,0);
+
$this->set_permission2($values['mask'],$r_processed,$grantor,1);
+
+ $receipt['message'][] = array('msg' =>
lang('permissions are updated!'));
+ return $receipt;
+ }
+
+
+ function get_user_list($type='',$get_grants='')
+ {
+ if($type == 'groups')
+ {
+ $check_account_type = array('accounts');
+ }
+ else
+ {
+ $check_account_type =
array('groups','accounts');
+ }
+
+ if($get_grants)
+ {
+ if($this->granting_group)
+ {
+ $grantor = $this->granting_group;
+ }
+ else
+ {
+ $grantor =
$GLOBALS['phpgw_info']['user']['account_id'];
+ }
+ }
+
+ $right=$this->right;
+
+ if ($this->allrows)
+ {
+ $this->start = -1;
+ $offset = -1;
+ }
+
+ $allusers =
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort,
$this->order, $this->query, $offset);
+
+ 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'];
+
+
$this->acl->account_id=$account['account_id'];
+
+ $this->acl->read_repository();
+
+ $count_right=count($right);
+ for ($i=0;$i<$count_right;$i++)
+ {
+
if($this->acl->check_brutto($this->location,
$right[$i],$this->acl_app,$grantor,0,$check_account_type))
+ {
+
if($this->acl->account_type == 'g')
+ {
+
$user_list[$j]['right'][$right[$i]] = 'from_group';
+ }
+ else
+ {
+
$user_list[$j]['right'][$right[$i]] = 'checked';
+ }
+
$user_list[$j]['result'][$right[$i]] = 'checked';
+ }
+
if($this->acl->check_brutto($this->location,
$right[$i],$this->acl_app,$grantor,1,$check_account_type))
+ {
+
if($this->acl->account_type == 'g')
+ {
+
$user_list[$j]['mask'][$right[$i]] = 'from_group';
+ }
+ else
+ {
+
$user_list[$j]['mask'][$right[$i]] = 'checked';
+ }
+
unset($user_list[$j]['result'][$right[$i]]);
+ }
+ }
+
+ $j++;
+ }
+ }
+
+ $this->total_records =
$GLOBALS['phpgw']->accounts->total;
+
+ return $user_list;
+ }
}
====================================================
Index: hrm/inc/class.uiadmin.inc.php
diff -u hrm/inc/class.uiadmin.inc.php:1.2 hrm/inc/class.uiadmin.inc.php:1.3
--- hrm/inc/class.uiadmin.inc.php:1.2 Mon Nov 21 20:25:33 2005
+++ hrm/inc/class.uiadmin.inc.php Fri Nov 25 11:58:29 2005
@@ -1,619 +1,595 @@
-<?php
- /**
- * phpGroupWare - HRM: a human resource competence management system.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package hrm
- * @subpackage admin
- * @version $Id$
- */
-
- /**
- * Description
- * @package hrm
- */
-
- class uiadmin
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $submodule_id;
- var $permission;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'list_acl' => True,
- 'aclprefs' => True,
- 'edit_id' => True,
- 'contact_info' => True
- );
-
- function uiadmin()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boadmin',true);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->filter =
$this->bo->filter;
- $this->cat_id =
$this->bo->cat_id;
- $this->location =
$this->bo->location;
- $this->granting_group =
$this->bo->granting_group;
- $this->allrows =
$this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'location' => $this->location,
- 'granting_group' =>
$this->granting_group,
- 'allrows' => $this->allrows
- );
-
- $this->bo->save_sessiondata($data);
- }
-
- function aclprefs()
- {
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
-
'search_field'));
-
- $values =
get_var('values',array('POST'));
- $r_processed = get_var('processed',array('POST'));
- $acl_app =
get_var('acl_app',array('GET'));
- $set_permission =
get_var('set_permission',array('POST'));
-
- $app_id =
$GLOBALS['phpgw']->applications->data[$acl_app]['id'];
-
- if($set_permission)
- {
- $receipt =
$this->bo->set_grant($values,$r_processed);
- }
-
- if ($this->location)
- {
- if(!$this->cat_id || $this->cat_id=='accounts')
- {
- $user_list =
$this->bo->get_user_list('accounts',$app_id);
- }
-
- while (is_array($user_list) && list(,$user) =
each($user_list))
- {
- $processed[] = $user['account_id'];
- $users[] = array
- (
- 'account_id'
=> $user['account_id'],
- 'lid'
=> $user['account_lid'],
- 'name'
=> $user['account_firstname'] . ' ' . $user['account_lastname'],
- 'read_right'
=> $user['right'][1],
- 'add_right'
=> $user['right'][2],
- 'edit_right'
=> $user['right'][4],
- 'delete_right'
=> $user['right'][8],
- 'lang_right'
=> lang('right'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete'
=> lang('Delete'), //8
- 'type'
=> 'users'
- );
- }
-
- if(!$this->cat_id || $this->cat_id=='groups')
- {
- $group_list =
$this->bo->get_user_list('groups',$app_id);
- }
-
-
- while (is_array($group_list) && list(,$group) =
each($group_list))
- {
- $processed[] = $group['account_id'];
- $groups[] = array
- (
- 'account_id'
=> $group['account_id'],
- 'lid'
=> $group['account_lid'],
- 'name'
=> $group['account_firstname'],
- 'read_right'
=> $group['right'][1],
- 'add_right'
=> $group['right'][2],
- 'edit_right'
=> $group['right'][4],
- 'delete_right'
=> $group['right'][8],
- 'lang_right'
=> lang('right'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete'
=> lang('Delete'), //8
- 'type'
=> 'groups'
- );
- }
-
- address@hidden("_", $processed);
- }
-
-
- $table_header[] = array
- (
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete' =>
lang('Delete'), //8
- 'lang_manager' =>
lang('Manager') //16
- );
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin.aclprefs',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'module'
=> $this->location,
- 'granting_group' =>
$this->granting_group
- );
-
- if(!$this->location)
- {
- $receipt['error'][] = array('msg' =>
lang('select a location!'));
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=> $GLOBALS['phpgw']->link('/preferences/index.php'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'processed'
=> $processed,
- 'location'
=> $this->location,
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($user_list)+count($group_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.aclprefs'),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-
- 'lang_groups'
=> lang('groups'),
- 'lang_users'
=> lang('users'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the permissions belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'cat_id'
=> $this->cat_id,
- 'permission'
=> False,
- 'grant'
=> 1,
-
- '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'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_permission' =>
$table_header,
- 'values_groups'
=> $groups,
- 'values_users'
=> $users,
- 'lang_no_location'
=> lang('No location'),
- 'lang_location_statustext' =>
lang('Select submodule'),
- 'select_name_location' =>
'module',
- 'location_list'
=> $this->bo->select_location('filter',$this->location,True),
-
- 'is_admin'
=> $GLOBALS['phpgw_info']['user']['apps']['admin'],
- 'lang_group_statustext' =>
lang('Select the granting group. To do not use a granting group select NO
GRANTING GROUP'),
- 'select_group_name'
=> 'granting_group',
- 'lang_no_group'
=> lang('No granting group'),
- 'group_list'
=>
$this->bocommon->get_group_list('filter',$this->granting_group,$start=-1,$sort='ASC',$order='account_firstname',$query='',$offset=-1),
- );
-
- $appname
= lang('preferences');
- $function_msg =
lang('set grants');
- $owner_name =
$GLOBALS['phpgw']->accounts->id2name($GLOBALS['phpgw']->accounts->account_id);
// get owner name for title
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg . ': ' .
$owner_name;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_permission' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
-
- }
-
- function list_acl()
- {
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
-
'search_field'));
-
- $values =
get_var('values',array('POST'));
- $r_processed = get_var('processed',array('POST'));
-
- $set_permission =
get_var('set_permission',array('POST'));
-
- if($set_permission)
- {
- $receipt =
$this->bo->set_permission($values['right'],$r_processed);
- }
-
- if ($this->location)
- {
- if($this->cat_id=='accounts')
- {
- $user_list =
$this->bo->get_user_list2('accounts',$app_id);
- }
-
- if (isSet($user_list) AND is_array($user_list))
- {
- foreach($user_list as $user)
- {
- $processed[] =
$user['account_id'];
- $users[] = array
- (
- 'account_id'
=> $user['account_id'],
- 'lid'
=> $user['account_lid'],
- 'name'
=> $user['account_firstname'] . ' ' .
$user['account_lastname'] . ' [' . $user['account_lid'] . ']',
- 'read_right'
=> $user['right'][1],
- 'add_right'
=> $user['right'][2],
- 'edit_right'
=> $user['right'][4],
- 'delete_right'
=> $user['right'][8],
- 'manage_right'
=> $user['right'][16],
- 'janitor_right'
=> $user['right'][32],
- 'supervisor_right'
=> $user['right'][64],
-
'budget_responsible_right' => $user['right'][128],
- 'lang_right'
=> lang('right'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete'
=> lang('Delete'), //8
- 'lang_manage'
=> lang('Manage'), //16
- 'type'
=> 'users'
- );
- }
- }
-
- if($this->cat_id=='groups')
- {
- $group_list =
$this->bo->get_user_list2('groups',$app_id);
- }
-
- if (isSet($group_list) AND
is_array($group_list))
- {
- foreach($group_list as $group)
- {
- $processed[] =
$group['account_id'];
- $groups[] = array
- (
- 'account_id'
=> $group['account_id'],
- 'lid'
=> $group['account_lid'],
- 'name'
=> $group['account_firstname'],
- 'read_right'
=> $group['right'][1],
- 'add_right'
=> $group['right'][2],
- 'edit_right'
=> $group['right'][4],
- 'delete_right'
=> $group['right'][8],
- 'manage_right'
=> $group['right'][16],
- 'lang_right'
=> lang('right'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete'
=> lang('Delete'), //8
- 'lang_manage'
=> lang('Manage'), //16
- 'type'
=> 'groups'
- );
- }
- }
-
-
- address@hidden("_", $processed);
- }
-
-
- $table_header[] = array
- (
- 'sort_lid' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'account_lid',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl',
-
'cat_id'
=>$this->cat_id,
-
'query'
=>$this->query,
-
'module'
=> $this->location,
-
'submodule_id'
=>$this->submodule_id)
-
)),
- 'sort_lastname' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'account_lastname',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl',
-
'cat_id'
=>$this->cat_id,
-
'query'
=>$this->query,
-
'module'
=> $this->location,
-
'submodule_id'
=>$this->submodule_id)
-
)),
- 'sort_firstname' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'account_firstname',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl',
-
'cat_id'
=>$this->cat_id,
-
'query'
=>$this->query,
-
'module'
=> $this->location,
-
'submodule_id'
=>$this->submodule_id)
-
)),
-
-
- 'lang_values' =>
lang('values'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete' =>
lang('Delete'), //8
- 'lang_manager' =>
lang('Manager'), //16
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin.list_acl',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'module' =>
$this->location
-
- );
-
- if(!$this->location)
- {
- $receipt['error'][] = array('msg' =>
lang('select a location!'));
- }
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=> $GLOBALS['phpgw']->link('/admin/index.php'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'processed'
=> $processed,
- 'location'
=> $this->location,
- 'links'
=> $links,
-
- 'num_records'
=> count($user_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the permissions belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'cat_id'
=> $this->cat_id,
- 'permission'
=> 1,
-
- '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'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_permission' =>
$table_header,
- 'values_groups'
=> $groups,
- 'values_users'
=> $users,
- 'lang_groups'
=> lang('groups'),
- 'lang_users'
=> lang('users'),
-
- 'lang_no_location'
=> lang('No location'),
- 'lang_location_statustext' =>
lang('Select submodule'),
- 'select_name_location' =>
'module',
- 'location_list'
=> $this->bo->select_location('filter',$this->location,False)
- );
-
- $appname
= lang('permission');
- $function_msg =
lang('set permission');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_permission' => $data));
- $this->save_sessiondata();
- }
-
- function edit_id()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('admin'));
-
- $values = get_var('values',array('POST'));
-
- if ($values['select'])
- {
- $receipt = $this->bo->edit_id($values);
- }
-
- $fm_ids = $this->bo->read_fm_id();
-
- for ($i=0;$i<count($fm_ids);$i++)
- {
-
- $content[] = array
- (
- 'descr' => $fm_ids[$i]['descr'],
- 'value' => $fm_ids[$i]['value'],
- 'remark' =>
$fm_ids[$i]['remark'],
- 'key_id' => $i
- );
- }
-
- $table_header[] = array
- (
- 'lang_select' => lang('Select'),
- 'lang_descr' => lang('Descr'),
- 'lang_value' => lang('Value'),
- 'lang_remark' => lang('Remark'),
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.edit_id'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
- 'lang_submit' =>
lang('submit'),
- 'lang_save' =>
lang('Edit'),
- 'lang_add_statustext' => lang('Edit ID'),
- 'lang_done' =>
lang('done'),
- 'lang_done_statustext' => lang('Back to
Admin'),
- 'lang_select' =>
lang('Select'),
- 'lang_descr' =>
lang('Descr'),
- 'lang_value' =>
lang('Value'),
- 'lang_remark' =>
lang('Remark'),
- 'id_table_header' =>
$table_header,
- 'id_values' =>
$content,
- );
-
- $appname
= lang('ID');
- $function_msg =
lang('edit ID');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_id' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function contact_info()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('admin'));
-
- $values = get_var('values',array('POST'));
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->preferences->account_id=$this->filter;
-
$GLOBALS['phpgw']->preferences->read_repository();
-
- if ($values['old_email'] != $values['email'])
- {
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"email",$values['email'],'user');
- $receipt['message'][] = array('msg' =>
lang('Users email is updated'));
- }
- if ($values['old_phone'] != $values['phone'])
- {
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"cellphone",$values['phone'],'user');
- $receipt['message'][] = array('msg' =>
lang('Users phone is updated'));
- }
- if ($values['old_approval_from'] !=
$values['approval_from'])
- {
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"approval_from",$values['approval_from'],'user');
- $receipt['message'][] = array('msg' =>
lang('Approval from is updated'));
- }
- if ($values['old_default_vendor_category'] !=
$values['default_vendor_category'])
- {
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"default_vendor_category",$values['default_vendor_category'],'user');
- $receipt['message'][] = array('msg' =>
lang('default vendor category is updated'));
- }
-
$GLOBALS['phpgw']->preferences->save_repository();
- }
-
- if($this->filter)
- {
- $prefs =
$this->bocommon->create_preferences($this->currentapp,$this->filter);
- }
-
- $cats = CreateObject('phpgwapi.categories');
- $cats->app_name = 'fm_vendor';
-
- $cat_data =
$cats->formatted_xslt_list(array('selected' =>
$prefs['default_vendor_category'],'globals' => True, 'link_data' =>array()));
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.contact_info'),
- 'done_action'
=> $GLOBALS['phpgw']->link('/admin/index.php'),
- 'lang_submit'
=> lang('submit'),
- 'lang_save'
=> lang('Edit'),
- 'lang_add_statustext' =>
lang('Edit ID'),
- 'lang_done'
=> lang('done'),
- 'lang_done_statustext' =>
lang('Back to Admin'),
-
- 'lang_email_statustext' =>
lang('Enter the email-address for this user'),
-
- 'lang_user'
=> lang('User'),
- 'lang_email'
=> lang('Email'),
- 'value_old_email'
=> $prefs['email'],
- 'value_email'
=> $prefs['email'],
-
- 'lang_phone'
=> lang('Phone'),
- 'value_old_phone'
=> $prefs['cellphone'],
- 'value_phone'
=> $prefs['cellphone'],
-
- 'lang_approval_from' =>
lang('Approval from'),
- 'value_old_approval_from' =>
$prefs['approval_from'],
- 'approval_from'
=>
$this->bocommon->get_user_list('select',$prefs['approval_from'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'select_user_name'
=> 'approval_from',
- 'lang_approval_from_statustext' => lang('Select
the users supervisor'),
-
- 'lang_default_vendor_category' =>
lang('default vendor category'),
- 'value_old_default_vendor_category' =>
$prefs['default_vendor_category'],
- 'vendor_category'
=> $cat_data['cat_list'],
- 'select_user_name'
=> 'approval_from',
- 'lang_default_vendor_category_statustext'
=> lang('Select default vendor category'),
- 'lang_no_cat'
=> lang('No category'),
-
-
- 'lang_user_statustext' =>
lang('Select the user to edit email'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'value_user_id'
=> $this->filter,
- 'user_list'
=>
$this->bocommon->get_user_list('filter',$this->filter,$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
- );
-
- $appname
= lang('User contact info');
- $function_msg
= lang('edit info');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('contact_info' => $data));
- $this->save_sessiondata();
- }
+<?php
+ /**
+ * phpGroupWare - HRM: a human resource competence management system.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package hrm
+ * @subpackage admin
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package hrm
+ */
+
+ class uiadmin
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $submodule_id;
+ var $permission;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'list_acl' => True,
+ 'aclprefs' => True,
+ 'edit_id' => True,
+ 'contact_info' => True
+ );
+
+ function uiadmin()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boadmin',true);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ $this->acl_app =
$this->bo->acl_app;
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->filter =
$this->bo->filter;
+ $this->cat_id =
$this->bo->cat_id;
+ $this->location =
$this->bo->location;
+ $this->granting_group =
$this->bo->granting_group;
+ $this->allrows =
$this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'location' => $this->location,
+ 'granting_group' =>
$this->granting_group,
+ 'allrows' => $this->allrows
+ );
+
+ $this->bo->save_sessiondata($data);
+ }
+
+ function aclprefs()
+ {
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
+
'search_field'));
+
+ $values = get_var('values',array('POST'));
+ $r_processed = get_var('processed',array('POST'));
+ $set_permission =
get_var('set_permission',array('POST'));
+
+ if($set_permission)
+ {
+ $receipt =
$this->bo->set_permission($values,$r_processed,true);
+ }
+
+ if ($this->location)
+ {
+ if($this->cat_id=='accounts')
+ {
+ $user_list =
$this->bo->get_user_list('accounts',true);
+ }
+
+ while (is_array($user_list) && list(,$user) =
each($user_list))
+ {
+ $processed[] = $user['account_id'];
+ $users[] = array
+ (
+ 'account_id'
=> $user['account_id'],
+ 'lid'
=> $user['account_lid'],
+ 'name'
=> $user['account_firstname'] . ' ' . $user['account_lastname'],
+ 'read_right'
=> $user['right'][1],
+ 'add_right'
=> $user['right'][2],
+ 'edit_right'
=> $user['right'][4],
+ 'delete_right'
=> $user['right'][8],
+ 'read_mask'
=> $user['mask'][1],
+ 'add_mask'
=> $user['mask'][2],
+ 'edit_mask'
=> $user['mask'][4],
+ 'delete_mask'
=> $user['mask'][8],
+ 'read_result'
=> $user['result'][1],
+ 'add_result'
=> $user['result'][2],
+ 'edit_result'
=> $user['result'][4],
+ 'delete_result'
=> $user['result'][8],
+ 'lang_right'
=> lang('right'),
+ 'lang_mask'
=> lang('mask'),
+ 'lang_result'
=> lang('result'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete'
=> lang('Delete'), //8
+ 'type'
=> 'users'
+ );
+ }
+
+ if($this->cat_id=='groups')
+ {
+ $group_list =
$this->bo->get_user_list('groups',true);
+ }
+
+
+ while (is_array($group_list) && list(,$group) =
each($group_list))
+ {
+ $processed[] = $group['account_id'];
+ $groups[] = array
+ (
+ 'account_id'
=> $group['account_id'],
+ 'lid'
=> $group['account_lid'],
+ 'name'
=> $group['account_firstname'],
+ 'read_right'
=> $group['right'][1],
+ 'add_right'
=> $group['right'][2],
+ 'edit_right'
=> $group['right'][4],
+ 'delete_right'
=> $group['right'][8],
+ 'read_mask'
=> $group['mask'][1],
+ 'add_mask'
=> $group['mask'][2],
+ 'edit_mask'
=> $group['mask'][4],
+ 'delete_mask'
=> $group['mask'][8],
+ 'read_result'
=> $group['result'][1],
+ 'add_result'
=> $group['result'][2],
+ 'edit_result'
=> $group['result'][4],
+ 'delete_result'
=> $group['result'][8],
+ 'lang_right'
=> lang('right'),
+ 'lang_mask'
=> lang('mask'),
+ 'lang_result'
=> lang('result'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete'
=> lang('Delete'), //8
+ 'type'
=> 'groups'
+ );
+ }
+//_debug_array($groups);
+
+ address@hidden("_", $processed);
+ }
+
+
+ $table_header[] = array
+ (
+ 'lang_read' =>
lang('Read'), //1
+ 'lang_add' =>
lang('Add'), //2
+ 'lang_edit' =>
lang('Edit'), //4
+ 'lang_delete' =>
lang('Delete'), //8
+ 'lang_manager' =>
lang('Manager') //16
+ );
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin.aclprefs',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'module'
=> $this->location,
+ 'granting_group' =>
$this->granting_group,
+ 'acl_app'
=> $this->acl_app
+ );
+
+ if(!$this->location)
+ {
+ $receipt['error'][] = array('msg' =>
lang('select a location!'));
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=> $GLOBALS['phpgw']->link('/preferences/index.php'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'processed'
=> $processed,
+ 'location'
=> $this->location,
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($user_list)+count($group_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.aclprefs'),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+
+ 'lang_groups'
=> lang('groups'),
+ 'lang_users'
=> lang('users'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the permissions belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'cat_id'
=> $this->cat_id,
+ 'permission'
=> False,
+ 'grant'
=> 1,
+
+ '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'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_permission' =>
$table_header,
+ 'values_groups'
=> $groups,
+ 'values_users'
=> $users,
+ 'lang_no_location'
=> lang('No location'),
+ 'lang_location_statustext' =>
lang('Select submodule'),
+ 'select_name_location' =>
'module',
+ 'location_list'
=> $this->bo->select_location('filter',$this->location,True),
+
+ 'is_admin'
=> $GLOBALS['phpgw_info']['user']['apps']['admin'],
+ 'lang_group_statustext' =>
lang('Select the granting group. To do not use a granting group select NO
GRANTING GROUP'),
+ 'select_group_name'
=> 'granting_group',
+ 'lang_no_group'
=> lang('No granting group'),
+ 'group_list'
=>
$this->bocommon->get_group_list('filter',$this->granting_group,$start=-1,$sort='ASC',$order='account_firstname',$query='',$offset=-1),
+ );
+
+ $appname
= lang('preferences');
+ $function_msg =
lang('set grants');
+ $owner_name =
$GLOBALS['phpgw']->accounts->id2name($GLOBALS['phpgw']->accounts->account_id);
// get owner name for title
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg . ': ' .
$owner_name;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_permission' => $data));
+ $this->save_sessiondata();
+ }
+
+ function list_acl()
+ {
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
+
'search_field'));
+
+ $values =
get_var('values',array('POST'));
+ $r_processed = get_var('processed',array('POST'));
+
+ $set_permission =
get_var('set_permission',array('POST'));
+
+ if($set_permission)
+ {
+ $receipt =
$this->bo->set_permission($values,$r_processed);
+ }
+
+ if ($this->location)
+ {
+ if($this->cat_id=='accounts')
+ {
+ $user_list =
$this->bo->get_user_list('accounts');
+ }
+
+ if (isSet($user_list) AND is_array($user_list))
+ {
+ foreach($user_list as $user)
+ {
+ $processed[] =
$user['account_id'];
+ $users[] = array
+ (
+ 'account_id'
=> $user['account_id'],
+ 'lid'
=> $user['account_lid'],
+ 'name'
=> $user['account_firstname'] . ' ' . $user['account_lastname']
. ' [' . $user['account_lid'] . ']',
+ 'read_right'
=> $user['right'][1],
+ 'add_right'
=> $user['right'][2],
+ 'edit_right'
=> $user['right'][4],
+ 'delete_right'
=> $user['right'][8],
+ 'manage_right'
=> $user['right'][16],
+ 'read_mask'
=> $user['mask'][1],
+ 'add_mask'
=> $user['mask'][2],
+ 'edit_mask'
=> $user['mask'][4],
+ 'delete_mask'
=> $user['mask'][8],
+ 'manage_mask'
=> $user['mask'][16],
+ 'read_result'
=> $user['result'][1],
+ 'add_result'
=> $user['result'][2],
+ 'edit_result'
=> $user['result'][4],
+ 'delete_result'
=> $user['result'][8],
+ 'manage_result'
=> $user['result'][16],
+ 'lang_right'
=> lang('right'),
+ 'lang_mask'
=> lang('mask'),
+ 'lang_result'
=> lang('result'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete'
=> lang('Delete'), //8
+ 'lang_manage'
=> lang('Manage'), //16
+ 'type'
=> 'users'
+ );
+ }
+ }
+
+ if($this->cat_id=='groups')
+ {
+ $group_list =
$this->bo->get_user_list('groups');
+ }
+
+ if (isSet($group_list) AND
is_array($group_list))
+ {
+ foreach($group_list as $group)
+ {
+ $processed[] =
$group['account_id'];
+ $groups[] = array
+ (
+ 'account_id'
=> $group['account_id'],
+ 'lid'
=> $group['account_lid'],
+ 'name'
=> $group['account_firstname'],
+ 'read_right'
=> $group['right'][1],
+ 'add_right'
=> $group['right'][2],
+ 'edit_right'
=> $group['right'][4],
+ 'delete_right'
=> $group['right'][8],
+ 'manage_right'
=> $group['right'][16],
+ 'read_mask'
=> $group['mask'][1],
+ 'add_mask'
=> $group['mask'][2],
+ 'edit_mask'
=> $group['mask'][4],
+ 'delete_mask'
=> $group['mask'][8],
+ 'manage_mask'
=> $group['mask'][16],
+ 'read_result'
=> $group['result'][1],
+ 'add_result'
=> $group['result'][2],
+ 'edit_result'
=> $group['result'][4],
+ 'delete_result'
=> $group['result'][8],
+ 'manage_result'
=> $group['result'][16],
+ 'lang_right'
=> lang('right'),
+ 'lang_mask'
=> lang('mask'),
+ 'lang_result'
=> lang('result'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete'
=> lang('Delete'), //8
+ 'lang_manage'
=> lang('Manage'), //16
+ 'type'
=> 'groups'
+ );
+ }
+ }
+
+
+ address@hidden("_", $processed);
+ }
+
+
+ $table_header[] = array
+ (
+ 'sort_lid' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'account_lid',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl',
+
'cat_id'
=>$this->cat_id,
+
'query'
=>$this->query,
+
'module'
=> $this->location,
+
'submodule_id'
=>$this->submodule_id)
+
)),
+ 'sort_lastname' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'account_lastname',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl',
+
'cat_id'
=>$this->cat_id,
+
'query'
=>$this->query,
+
'module'
=> $this->location,
+
'submodule_id'
=>$this->submodule_id)
+
)),
+ 'sort_firstname' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'account_firstname',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl',
+
'cat_id'
=>$this->cat_id,
+
'query'
=>$this->query,
+
'module'
=> $this->location,
+
'submodule_id'
=>$this->submodule_id)
+
)),
+
+
+ 'lang_values' =>
lang('values'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete' =>
lang('Delete'), //8
+ 'lang_manager' =>
lang('Manager'), //16
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin.list_acl',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'module' =>
$this->location
+
+ );
+
+ if(!$this->location)
+ {
+ $receipt['error'][] = array('msg' =>
lang('select a location!'));
+ }
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=> $GLOBALS['phpgw']->link('/admin/index.php'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'processed'
=> $processed,
+ 'location'
=> $this->location,
+ 'links'
=> $links,
+
+ 'num_records'
=> count($user_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the permissions belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'cat_id'
=> $this->cat_id,
+ 'permission'
=> 1,
+
+ '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'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_permission' =>
$table_header,
+ 'values_groups'
=> $groups,
+ 'values_users'
=> $users,
+ 'lang_groups'
=> lang('groups'),
+ 'lang_users'
=> lang('users'),
+
+ 'lang_no_location'
=> lang('No location'),
+ 'lang_location_statustext' =>
lang('Select submodule'),
+ 'select_name_location' =>
'module',
+ 'location_list'
=> $this->bo->select_location('filter',$this->location,False)
+ );
+
+ $appname
= lang('permission');
+ $function_msg =
lang('set permission');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_permission' => $data));
+ $this->save_sessiondata();
+ }
+
+ function contact_info()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('admin'));
+
+ $values = get_var('values',array('POST'));
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->preferences->account_id=$this->filter;
+
$GLOBALS['phpgw']->preferences->read_repository();
+
+ if ($values['old_email'] != $values['email'])
+ {
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"email",$values['email'],'user');
+ $receipt['message'][] = array('msg' =>
lang('Users email is updated'));
+ }
+ if ($values['old_phone'] != $values['phone'])
+ {
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"cellphone",$values['phone'],'user');
+ $receipt['message'][] = array('msg' =>
lang('Users phone is updated'));
+ }
+ if ($values['old_approval_from'] !=
$values['approval_from'])
+ {
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"approval_from",$values['approval_from'],'user');
+ $receipt['message'][] = array('msg' =>
lang('Approval from is updated'));
+ }
+ if ($values['old_default_vendor_category'] !=
$values['default_vendor_category'])
+ {
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"default_vendor_category",$values['default_vendor_category'],'user');
+ $receipt['message'][] = array('msg' =>
lang('default vendor category is updated'));
+ }
+
$GLOBALS['phpgw']->preferences->save_repository();
+ }
+
+ if($this->filter)
+ {
+ $prefs =
$this->bocommon->create_preferences($this->currentapp,$this->filter);
+ }
+
+ $cats = CreateObject('phpgwapi.categories');
+ $cats->app_name = 'fm_vendor';
+
+ $cat_data =
$cats->formatted_xslt_list(array('selected' =>
$prefs['default_vendor_category'],'globals' => True, 'link_data' =>array()));
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.contact_info'),
+ 'done_action'
=> $GLOBALS['phpgw']->link('/admin/index.php'),
+ 'lang_submit'
=> lang('submit'),
+ 'lang_save'
=> lang('Edit'),
+ 'lang_add_statustext' =>
lang('Edit ID'),
+ 'lang_done'
=> lang('done'),
+ 'lang_done_statustext' =>
lang('Back to Admin'),
+
+ 'lang_email_statustext' =>
lang('Enter the email-address for this user'),
+
+ 'lang_user'
=> lang('User'),
+ 'lang_email'
=> lang('Email'),
+ 'value_old_email'
=> $prefs['email'],
+ 'value_email'
=> $prefs['email'],
+
+ 'lang_phone'
=> lang('Phone'),
+ 'value_old_phone'
=> $prefs['cellphone'],
+ 'value_phone'
=> $prefs['cellphone'],
+
+ 'lang_approval_from' =>
lang('Approval from'),
+ 'value_old_approval_from' =>
$prefs['approval_from'],
+ 'approval_from'
=>
$this->bocommon->get_user_list('select',$prefs['approval_from'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'select_user_name'
=> 'approval_from',
+ 'lang_approval_from_statustext' => lang('Select
the users supervisor'),
+
+ 'lang_default_vendor_category' =>
lang('default vendor category'),
+ 'value_old_default_vendor_category' =>
$prefs['default_vendor_category'],
+ 'vendor_category'
=> $cat_data['cat_list'],
+ 'select_user_name'
=> 'approval_from',
+ 'lang_default_vendor_category_statustext'
=> lang('Select default vendor category'),
+ 'lang_no_cat'
=> lang('No category'),
+
+
+ 'lang_user_statustext' =>
lang('Select the user to edit email'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'value_user_id'
=> $this->filter,
+ 'user_list'
=>
$this->bocommon->get_user_list('filter',$this->filter,$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+ );
+
+ $appname
= lang('User contact info');
+ $function_msg
= lang('edit info');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('contact_info' => $data));
+ $this->save_sessiondata();
+ }
}
====================================================
Index: hrm/inc/class.soadmin.inc.php
diff -u hrm/inc/class.soadmin.inc.php:1.2 hrm/inc/class.soadmin.inc.php:1.3
--- hrm/inc/class.soadmin.inc.php:1.2 Mon Nov 21 20:25:33 2005
+++ hrm/inc/class.soadmin.inc.php Fri Nov 25 11:58:29 2005
@@ -1,123 +1,33 @@
-<?php
- /**
- * phpGroupWare - HRM: a human resource competence management system.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package hrm
- * @subpackage admin
- * @version $Id$
- */
-
- /**
- * Description
- * @package property
- */
-
- class soadmin
- {
-
- function soadmin()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
- }
-
-
- function get_initials($id)
- {
- $this->db->query("SELECT initials FROM fm_ecouser WHERE
id=$id ");
- $this->db->next_record();
- return $this->db->f('initials');
- }
-
- function set_initials($initials)
- {
- while (is_array($initials) && list($account_id,$value)
= each($initials))
- {
- $this->db->query("UPDATE fm_ecouser set
initials= '$value' WHERE id=$account_id ",__LINE__,__FILE__);
- if($value)
- {
- if(!$this->get_initials($account_id))
- {
- $account_lid =
strtoupper($GLOBALS['phpgw']->accounts->id2name($account_id));
- $this->db->query("INSERT INTO
fm_ecouser (id,lid,initials) VALUES ($account_id,'$account_lid','$value'
)",__LINE__,__FILE__);
- }
- }
- }
- }
-
- function select_location($grant='')
- {
- if($grant)
- {
- $filter = ' WHERE allow_grant=1';
- }
- $this->db->query("SELECT * FROM fm_acl_location $filter
ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $location[$i]['id']
= $this->db->f('id');
- $location[$i]['descr']
= stripslashes($this->db->f('descr'));
- $i++;
- }
-
- return $location;
- }
-
-
- function read_fm_id()
- {
- $sql = "select * from fm_idgenerator ";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $fm_ids[] = array(
- 'descr' =>
$this->db->f('name'),
- 'value' =>
$this->db->f('value'),
- 'remark' =>
$this->db->f('remark')
- );
-
- }
-
- return $fm_ids;
- }
-
- function edit_id($values='')
- {
- $field=$values['field'];
- $select=$values['select'];
-
- while($entry=each($select))
- {
- $n=$entry[0];
-
-
- $sql = "update fm_idgenerator set
value='$values[$n]' where name='$field[$n]'";
-
$this->db->query($sql,__LINE__,__FILE__);
-
- }
-
- $receipt['message'][] = array('msg' => lang('ID is
updated'));
- return $receipt;
- }
-
- function remove_permission($user_delete,$location)
- {
- foreach($user_delete as $account_id)
- {
- $sql = "DELETE FROM phpgw_acl where
acl_location = '$location' AND acl_account = ". intval($account_id);
- $this->db->query($sql,__LINE__,__FILE__);
- }
- }
+<?php
+ /**
+ * phpGroupWare - HRM: a human resource competence management system.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package hrm
+ * @subpackage admin
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package hrm
+ */
+
+ class soadmin
+ {
+
+ function soadmin()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->db = $GLOBALS['phpgw']->db;
+ $this->db2 = $this->db;
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ $this->join = $this->socommon->join;
+ $this->like = $this->socommon->like;
+ }
}
====================================================
Index: hrm/inc/class.bocommon.inc.php
diff -u hrm/inc/class.bocommon.inc.php:1.3 hrm/inc/class.bocommon.inc.php:1.4
--- hrm/inc/class.bocommon.inc.php:1.3 Tue Nov 22 13:26:35 2005
+++ hrm/inc/class.bocommon.inc.php Fri Nov 25 11:58:29 2005
@@ -1,1380 +1,659 @@
-<?php
- /**
- * phpGroupWare - HRM: a human resource competence management system.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package hrm
- * @subpackage core
- * @version $Id$
- */
-
- /**
- * Description
- * @package hrm
- */
-
- class bocommon
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
- var $district_id;
-
-
- var $public_functions = array
- (
- 'select_part_of_town' => True,
- 'menu' => True,
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bocommon()
- {
-// $GLOBALS['phpgw_info']['flags']['currentapp'] =
'hrm';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- if (!is_object($GLOBALS['phpgw']->asyncservice))
- {
- $GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
- }
- $this->async = &$GLOBALS['phpgw']->asyncservice;
-
- $this->join = $this->socommon->join;
- $this->left_join = $this->socommon->left_join;
- $this->like = $this->socommon->like;
-
- switch($GLOBALS['phpgw_info']['server']['db_type'])
- {
- case 'mssql':
- $this->dateformat = "M d
Y";
- $this->datetimeformat = "M d Y g:iA";
- break;
- case 'mysql':
- $this->dateformat =
"Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
- break;
- case 'pgsql':
- $this->dateformat =
"Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
-// $this->dateformat = "F j,
Y";
-// $this->datetimeformat = "F j, Y g:iA";
- break;
- }
-
- /* if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
- {
- $this->dateformat = "M d Y";
- $this->datetimeformat = "M d Y g:iA";
- }
- else
- {
- $this->dateformat = "Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
- }
-
-
- if(!$GLOBALS['phpgw_info']['flags']['css'])
- {
- $GLOBALS['phpgw_info']['flags']['css'] .=
"-->\n</style>\n"
- . '<link rel="stylesheet"
type="text/css" media="all" href="'
- .
$GLOBALS['phpgw_info']['server']['webserver_url'].'/' . $this->currentapp .
'/templates/'
- .
$GLOBALS['phpgw_info']['server']['template_set']
- .
'/css/'.$GLOBALS['phpgw_info']['server']['template_set'].'.css"
title="'.$GLOBALS['phpgw_info']['server']['template_set'].'" />'
- . "\n<style type=\"text/css\">\n<!--\n";
- }
-*/
- }
-
- function jscalendar()
- {
- $phpgw_js_url =
$GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js';
-// $img =
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default').'/cal.png';
- $img =
$GLOBALS['phpgw_info']['server']['webserver_url'] .
'/phpgwapi/templates/default/images/cal.png';
-
-// $img = $phpgw_js_url.'/jscalendar/img.gif';
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $jsDateFormat = str_replace(array('d', 'm', 'M', 'Y'),
array('%d', '%m', '%b', '%Y'), $dateformat);
-
- $GLOBALS['phpgw_info']['flags']['java_script']
.='</script>
- <link rel="stylesheet" type="text/css" media="all"
href="'.$phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css"
title="win2k-cold-1" >
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar.js"></script>
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar-setup.js"></script>
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js"></script>
- ';
-
-
-// <script type="text/javascript"
src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',$GLOBALS['phpgw']->link('/phpgwapi/js/jscalendar/jscalendar-setup.php')).'"></script>
-
- $cal_info=array(
-// 'stylesheet'
=> $phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css',
-// 'calendar_source'
=> $phpgw_js_url.'/jscalendar/calendar.js',
-// 'calendar_setup_source' =>
$phpgw_js_url.'/jscalendar/calendar-setup.js',
-// 'calendar_lang'
=>
$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js',
- 'jsDateFormat'
=> $jsDateFormat,
- 'img'
=> $img,
- );
- return $cal_info;
- }
-
- function check_perms($rights, $required)
- {
- // return (!!($rights & $required) == True);
- return ($rights & $required);
- }
-
- function create_preferences($app='',$user_id='')
- {
- return
$this->socommon->create_preferences($app,$user_id);
- }
-
- function get_lookup_entity($location='')
- {
- return $this->socommon->get_lookup_entity($location);
- }
-
- function get_start_entity($location='')
- {
- return $this->socommon->get_start_entity($location);
- }
-
- function msgbox_data($receipt)
- {
- $msgbox_data_error=array();
- if (isSet($receipt['error']) AND
is_array($receipt['error']))
- {
- foreach($receipt['error'] as $errors)
- {
- $msgbox_data_error +=
array($errors['msg']=> False);
- }
- }
-
- $msgbox_data_message=array();
-
- if (isSet($receipt['message']) AND
is_array($receipt['message']))
- {
- foreach($receipt['message'] as $messages)
- {
- $msgbox_data_message +=
array($messages['msg']=> True);
- }
- }
-
- $msgbox_data = $msgbox_data_error +
$msgbox_data_message;
-
- return $msgbox_data;
- }
-
- function moneyformat($amount)
- {
- if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
- {
- $moneyformat =
"CONVERT(MONEY,"."'$amount'".",0)";
- }
- else
- {
- $moneyformat = "'" . $amount . "'";
- }
-
- return $moneyformat;
- }
-
-
- function date_array($date)
- {
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $dateformat = str_replace(".","",$dateformat);
- $dateformat = str_replace("-","",$dateformat);
- $dateformat = str_replace("/","",$dateformat);
- $y=strpos($dateformat,'y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- $dateparts = explode('/', $date);
- $date_array['day'] = $dateparts[$d];
- $date_array['month'] = $dateparts[$m];
- $date_array['year'] = $dateparts[$y];
-
- return $date_array;
- }
-
- function date_to_timestamp($date)
- {
- if($date)
- {
- $date_array = $this->date_array($date);
- $date = mktime
(8,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
- }
- return $date;
- }
-
-
- function
column_list($selected='',$entity_type='',$cat_id,$allrows='')
- {
- $bostandard_entity =
CreateObject($this->currentapp.'.bostandard_entity',True);
-
- if(!$selected)
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$entity_type.'_columns_'.$cat_id];
- }
-
- $columns =
$bostandard_entity->read_attrib($entity_type,$cat_id,$allrows);
-//_debug_array($columns);
-
-
$column_list=$this->select_multi_list($selected,$columns);
-
- return $column_list;
-
- }
-
- function select_multi_list($selected='',$input_list)
- {
- $j=0;
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $output_list[$j]['id'] = $entry['id'];
- $output_list[$j]['name'] =
$entry['name'];
-
- for ($i=0;$i<count($selected);$i++)
- {
- if($selected[$i] ==
$entry['id'])
- {
-
$output_list[$j]['selected'] = 'selected';
- }
- }
- $j++;
- }
- }
-
- for ($i=0;$i<count($output_list);$i++)
- {
- if ($output_list[$i]['selected'] != 'selected')
- {
- unset($output_list[$i]['selected']);
- }
- }
-
- return $output_list;
- }
-
-
-
- function select_list($selected='',$input_list='')
- {
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $sel_entry = '';
- if ($entry['id']==$selected)
- {
- $sel_entry = 'selected';
- }
- $entry_list[] = array
- (
- 'id' => $entry['id'],
- 'name' =>
$entry['name'],
- 'selected' => $sel_entry
- );
- }
- for ($i=0;$i<count($entry_list);$i++)
- {
- if ($entry_list[$i]['selected'] !=
'selected')
- {
-
unset($entry_list[$i]['selected']);
- }
- }
- }
- return $entry_list;
- }
-
-
- function
get_user_list($format='',$selected='',$extra='',$default='',$start='',
$sort='', $order='', $query='',$offset='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
- break;
- }
-
- if(!$selected && $default)
- {
- $selected = $default;
- }
-
- if (is_array($extra))
- {
- foreach($extra as $extra_user)
- {
- $users_extra[]=array
- (
- 'account_id' => $extra_user,
- 'account_firstname' =>
lang($extra_user)
- );
- }
- }
-
- $accounts = CreateObject('phpgwapi.accounts');
- $users = $accounts->get_list('accounts', $start, $sort,
$order, $query,$offset);
- unset($accounts);
- if (is_array($users_extra) && is_array($users))
- {
- $users = $users_extra + $users;
- }
-
- if (isSet($users) AND is_array($users))
- {
- foreach($users as $user)
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'user_id' =>
$user['account_id'],
- 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
- }
-
- $user_count= count($user_list);
- for ($i=0;$i<$user_count;$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
-//_debug_array($user_list);
- return $user_list;
- }
-
- function get_group_list($format='',$selected='',$start='',
$sort='', $order='', $query='',$offset='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('group_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('group_filter'));
- break;
- }
-
- $accounts = CreateObject('phpgwapi.accounts');
- $users = $accounts->get_list('groups', $start, $sort,
$order, $query,$offset);
- unset($accounts);
- if (isSet($users) AND is_array($users))
- {
- foreach($users as $user)
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'id' => $user['account_id'],
- 'name' =>
$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
- }
-
- $user_count= count($user_list);
- for ($i=0;$i<$user_count;$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
-//_debug_array($user_list);
- return $user_list;
- }
-
-
- function
get_user_list_right($right='',$selected='',$acl_location='')
- {
-
$employees=$this->socommon->get_user_list_right($right,$acl_location);
- while (is_array($employees) && list(,$user) =
each($employees))
- {
- $sel_user = '';
- if ($user['account_lid']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'lid' =>
$user['account_lid'],
- 'firstname' =>
$user['account_firstname'],
- 'lastname' =>
$user['account_lastname'],
- 'selected' => $sel_user
- );
- }
-
- for ($i=0;$i<count($user_list);$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
- return $user_list;
- }
-
- function
get_user_list_right2($format='',$right='',$selected='',$acl_location='',$extra='',$default='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
- break;
- }
-
- if(!$selected && $default)
- {
- $selected = $default;
- }
-
- if (isset($extra) AND is_array($extra))
- {
- foreach($extra as $extra_user)
- {
- $users_extra[]=array
- (
- 'account_id' => $extra_user,
- 'account_firstname' =>
lang($extra_user)
- );
- }
- }
-
-
-
$users=$this->socommon->get_user_list_right($right,$acl_location);
-
- if (is_array($users_extra) && is_array($users))
- {
- foreach($users as $users_entry)
- {
- array_push($users_extra,$users_entry);
- }
- $users=$users_extra;
- }
-
- while (is_array($users) && list(,$user) = each($users))
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'user_id' =>
$user['account_id'],
- 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
-
- for ($i=0;$i<count($user_list);$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
- return $user_list;
- }
-
-
- function initiate_ui_vendorlookup($data)
- {
-//_debug_array($data);
-
- $contacts =
CreateObject($this->currentapp.'.soactor');
- $contacts->role='vendor';
-
- if($data['type']=='view')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('vendor_view'));
- }
- else
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('vendor_form'));
- }
-
- $vendor['value_vendor_id']
= $data['vendor_id'];
- $vendor['value_vendor_name'] =
$data['vendor_name'];
-
- if($data['vendor_id'] && !$data['vendor_name'])
- {
- $vendor_data
= $contacts->read_single(array('actor_id'=>$data['vendor_id']));
- if(is_array($vendor_data))
- {
- foreach($vendor_data['attributes'] as
$attribute)
- {
-
if($attribute['name']=='org_name')
- {
-
$vendor['value_vendor_name']=$attribute['value'];
- break;
- }
- }
- }
- }
-
- $vendor['vendor_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor');
- $vendor['lang_vendor']
= lang('Vendor');
- $vendor['lang_select_vendor_help'] =
lang('Klick this link to select vendor');
- $vendor['lang_vendor_name']
= lang('Vendor Name');
-
- unset($contacts);
-//_debug_array($vendor);
- return $vendor;
- }
-
-
- function initiate_ui_budget_account_lookup($data)
- {
- if($data['type']=='view')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account_view'));
- }
- else
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account_form'));
- }
-
- $b_account['value_b_account_id']
= $data['b_account_id'];
- $b_account['value_b_account_name']
= $data['b_account_name'];
- $b_account['b_account_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.b_account');
- $b_account['lang_b_account']
= lang('b_account');
- $b_account['lang_select_b_account_help'] =
lang('Klick this link to select budget account');
- $b_account['lang_b_account']
= lang('Budget account');
- if($data['b_account_id'] && !$data['b_account_name'])
- {
- $b_account_object =
CreateObject($this->currentapp.'.sob_account');
- $b_account_data =
$b_account_object->read_single($data['b_account_id']);
- $b_account['value_b_account_name'] =
$b_account_data['descr'];
- }
-
-//_debug_array($b_account);
- return $b_account;
- }
-
-
- function initiate_ui_alarm($data)
- {
- $boalarm =
CreateObject($this->currentapp.'.boalarm');
-
- if($data['type']=='view')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_view'));
- }
- else
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_form'));
- }
-
- $alarm['header'][] = array
- (
- 'lang_time' => lang('Time'),
- 'lang_text' => lang('Text'),
- 'lang_user' => lang('User'),
- 'lang_enabled' => lang('Enabled'),
- 'lang_select' => lang('Select')
- );
-
- $alarm['values'] =
$boalarm->read_alarms($data['alarm_type'],$data['id'],$data['text']);
- if(!count($alarm['values'])>0)
- {
- unset($alarm['values']);
- }
-
- if($data['type']=='form')
- {
- $alarm['alter_alarm'][] = array
- (
- 'lang_enable' =>
lang('Enable'),
- 'lang_disable' =>
lang('Disable'),
- 'lang_delete' =>
lang('Delete')
- );
-
- for ($i=1; $i<=31; $i++)
- {
-
$alarm['add_alarm']['day_list'][($i-1)][id] = $i;
- }
- $alarm['add_alarm']['lang_day']
= lang('Day');
- $alarm['add_alarm']['lang_day_statustext']
= lang('Day');
-
- for ($i=1; $i<=24; $i++)
- {
-
$alarm['add_alarm']['hour_list'][($i-1)][id] = $i;
- }
- $alarm['add_alarm']['lang_hour']
= lang('Hour');
- $alarm['add_alarm']['lang_hour_statustext']
= lang('Hour');
-
- for ($i=1; $i<=60; $i++)
- {
-
$alarm['add_alarm']['minute_list'][($i-1)][id] = $i;
- }
- $alarm['add_alarm']['lang_minute']
= lang('Minutes before the event');
- $alarm['add_alarm']['lang_minute_statustext']
= lang('Minutes before the event');
-
- $alarm['add_alarm']['user_list'] =
$this->get_user_list_right2('select',4,False,$data['acl_location'],False,$default=$this->account);
-
- $alarm['add_alarm']['lang_user']
= lang('User');
- $alarm['add_alarm']['lang_user_statustext']
= lang('Select the user the alarm belongs to.');
- $alarm['add_alarm']['lang_no_user']
= lang('No user');
- $alarm['add_alarm']['lang_add']
= lang('Add');
- $alarm['add_alarm']['lang_add_alarm']
= lang('Add alarm');
- $alarm['add_alarm']['lang_add_statustext']
= lang('Add alarm for selected user');
-
- }
-
-//_debug_array($alarm['values']);
- return $alarm;
- }
-
-
- function
select_multi_list_2($selected='',$input_list,$input_type='')
- {
- $j=0;
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $output_list[$j]['id'] = $entry['id'];
- $output_list[$j]['value'] =
$entry['value'];
- $output_list[$j]['input_type'] =
$input_type;
-
- for ($i=0;$i<count($selected);$i++)
- {
- if($selected[$i] ==
$entry['id'])
- {
-
$output_list[$j]['checked'] = 'checked';
- }
- }
- $j++;
- }
- }
-
- for ($i=0;$i<count($output_list);$i++)
- {
- if ($output_list[$i]['checked'] != 'checked')
- {
- unset($output_list[$i]['checked']);
- }
- }
-
- return $output_list;
- }
-
- function translate_datatype($datatype)
- {
- $datatype_text = array(
- 'V' => 'Varchar',
- 'I' => 'Integer',
- 'C' => 'char',
- 'N' => 'Float',
- 'D' => 'Date',
- 'T' => 'Memo',
- 'R' => 'Muliple radio',
- 'CH' => 'Muliple checkbox',
- 'LB' => 'Listbox',
- 'AB' => 'Contact',
- 'VENDOR' => 'Vendor',
- 'email' => 'Email'
- );
-
- $datatype = lang($datatype_text[$datatype]);
-
- return $datatype;
- }
-
- function translate_datatype_insert($datatype)
- {
- $datatype_text = array(
- 'V' => 'varchar',
- 'I' => 'int',
- 'C' => 'char',
- 'N' => 'decimal',
- 'D' => 'timestamp',
- 'T' => 'text',
- 'R' => 'int',
- 'CH' => 'text',
- 'LB' => 'int',
- 'AB' => 'int',
- 'VENDOR' => 'int',
- 'email' => 'varchar'
- );
-
- return $datatype_text[$datatype];
- }
-
- function translate_datatype_precision($datatype)
- {
- $datatype_precision = array(
- 'R' => 4,
- 'LB' => 4,
- 'AB' => 4,
- 'VENDOR' => 4,
- 'email' => 64
- );
-
- return $datatype_precision[$datatype];
- }
-
- function save_attributes($values_attribute,$type)
- {
-
- for ($i=0;$i<count($values_attribute);$i++)
- {
- if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
- }
- if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
- }
-
- if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
- }
-
- if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
- {
- $dateformat=
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $dateformat =
str_replace(".","",$dateformat);
- $dateformat =
str_replace("-","",$dateformat);
- $dateformat =
str_replace("/","",$dateformat);
- $y=strpos($dateformat,'Y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- $dateparts = explode('/',
$values_attribute[$i]['value']);
- $day = $dateparts[$d];
- $month = $dateparts[$m];
- $year = $dateparts[$y];
- $values_attribute[$i]['value'] =
date($this->dateformat,mktime(2,0,0,$month,$day,$year));
- }
- }
-
-
$this->socommon->save_attributes($values_attribute,$type);
- }
-
- function list_methods($_type='xmlrpc')
- {
- /*
- This handles introspection or discovery by the logged
in client,
- in which case the input might be an array. The
server always calls
- this function to fill the server dispatch map using a
string.
- */
- if (is_array($_type))
- {
- $_type = $_type['type'] ? $_type['type'] :
$_type[0];
- }
- switch($_type)
- {
- case 'xmlrpc':
- $xml_functions = array(
- 'read' => array(
- 'function' => 'read',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
- 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
- ),
- 'save' => array(
- 'function' => 'save',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Update a single entry by passing the fields.')
- ),
- 'delete' => array(
- 'function' => 'delete',
- 'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
- 'docstring' =>
lang('Delete a single entry by passing the id.')
- ),
- 'list' => array(
- 'function' => '_list',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Read a list of entries.')
- ),
- 'list_methods' => array(
- 'function' =>
'list_methods',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
- 'docstring' =>
lang('Read this list of methods.')
- )
- );
- return $xml_functions;
- break;
- case 'soap':
- return $this->soap_functions;
- break;
- default:
- return array();
- break;
- }
- }
-
- function add_leading_zero($num)
- {
-
- if ($id_type == "hex")
- {
- $num = hexdec($num);
- $num++;
- $num = dechex($num);
- }
- else
- {
- $num++;
- }
-
- if (strlen($num) == 4)
- $return = $num;
- if (strlen($num) == 3)
- $return = "0$num";
- if (strlen($num) == 2)
- $return = "00$num";
- if (strlen($num) == 1)
- $return = "000$num";
- if (strlen($num) == 0)
- $return = "0001";
-
- return strtoupper($return);
- }
-
-
- function read_location_data($location_code)
- {
- $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
-
- $location_types =
$soadmin_location->select_location_type();
- unset($soadmin_location);
-
- return
$this->socommon->read_location_data($location_code,$location_types);
- }
-
- function read_single_tenant($tenant_id)
- {
- return $this->socommon->read_single_tenant($tenant_id);
- }
-
- function check_location($location_code='',$type_id='')
- {
- return
$this->socommon->check_location($location_code,$type_id);
- }
-
- function generate_sql($data)
- {
-//_debug_array($data);
-
- $cols =
(isset($data['cols'])?$data['cols']:'');
- $entity_table =
(isset($data['entity_table'])?$data['entity_table']:'');
- $cols_return =
(isset($data['cols_return'])?$data['cols_return']:'');
- $uicols =
(isset($data['uicols'])?$data['uicols']:'');
- $joinmethod =
(isset($data['joinmethod'])?$data['joinmethod']:'');
- $paranthesis =
(isset($data['paranthesis'])?$data['paranthesis']:'');
- $lookup =
(isset($data['lookup'])?$data['lookup']:'');
- $location_level =
(isset($data['location_level'])?$data['location_level']:'');
- $no_address =
(isset($data['no_address'])?$data['no_address']:'');
-
- $this->join = $this->socommon->join;
-
- $joinmethod .= " $this->join fm_location1 ON
($entity_table.loc1 = fm_location1.loc1))";
- $paranthesis .='(';
- $joinmethod .= " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id))";
- $paranthesis .='(';
- $joinmethod .= " $this->join fm_owner ON
(fm_location1.owner_id = fm_owner.id))";
- $paranthesis .='(';
-
- $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
- $location_types =
$soadmin_location->select_location_type();
- $config = $soadmin_location->read_config('');
-
- if($location_level)
- {
- $type_id=$location_level;
- }
- else
- {
- $type_id = count($location_types);
- }
- $this->type_id = $type_id;
-
- for ($i=0; $i<$type_id; $i++)
- {
-
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
- $uicols['descr'][] =
$location_types[$i]['name'];
- $uicols['statustext'][] =
$location_types[$i]['descr'];
- }
-/*
- $fm_location_cols =
$soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
- $location_cols_count = count($fm_location_cols);
-
- for ($i=0;$i<$location_cols_count;$i++)
- {
- if($fm_location_cols[$i]['list']==1)
- {
- $cols_extra[]
= $fm_location_cols[$i]['column_name']; // only for lookup
- $cols_return[]
= $fm_location_cols[$i]['column_name'];
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
- $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
- $uicols['statustext'][] =
$fm_location_cols[$i]['statustext'];
- }
- }
-
-*/
- unset($soadmin_location);
-
- for ($i=0; $i< $this->type_id; $i++)
- {
- $cols_return[] = 'loc' .
$location_types[$i]['id'];
- }
-
- if($lookup)
- {
- $cols_return[] =
'loc1_name';
- $cols_extra[] =
'loc1_name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'loc1_name';
- $uicols['descr'][] =
lang('Property Name');
- $uicols['statustext'][] =
lang('Property Name');
-
- for ($i=2;$i<($type_id+1);$i++)
- {
- $cols_return_lookup[] = 'loc'
. $i . '_name';
- $uicols['input_type'][] =
'hidden';
- $uicols['name'][]
= 'loc' . $i . '_name';
- $uicols['descr'][]
= '';
- $uicols['statustext'][] = '';
- }
- }
-
- if(!$no_address)
- {
- $cols.= ",$entity_table.address";
- $cols_return[] =
'address';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'address';
- $uicols['descr'][] =
lang('address');
- $uicols['statustext'][] =
lang('address');
- }
-
-
- $config_count = count($config);
- for ($i=0;$i<$config_count;$i++)
- {
-
- if (($config[$i]['location_type'] <= $type_id)
&& ($config[$i]['query_value'] ==1))
- {
-
-
if($config[$i]['column_name']=='street_id')
- {
-
- $cols_return[]
= 'street_name';
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= 'street_name';
- $uicols['descr'][]
= lang('street name');
- $uicols['statustext'][]
= lang('street name');
-
- $cols_return[]
= 'street_number';
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= 'street_number';
- $uicols['descr'][]
= lang('street number');
- $uicols['statustext'][]
= lang('street number');
-
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= lang($config[$i]['input_text']);
- $uicols['statustext'][]
= lang($config[$i]['input_text']);
- if($lookup)
- {
- $cols_extra[]
= 'street_name';
- $cols_extra[]
= 'street_number';
- $cols_extra[]
= $config[$i]['column_name'];
- }
-
- }
- else
- {
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= $config[$i]['input_text'];
- $uicols['statustext'][]
= $config[$i]['input_text'];
-
- if($lookup)
- {
- $cols_extra[]
= $config[$i]['column_name'];
- }
- }
- }
- }
-
- $this->uicols = $uicols;
- $this->cols_return = $cols_return;
- $this->cols_extra = $cols_extra;
- $this->cols_return_lookup = $cols_return_lookup;
-
- $from .= " FROM $paranthesis $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- return $sql;
-
- }
-
- function select_part_of_town($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('select_part_of_town'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_part_of_town'));
- break;
- }
-
- $parts= $this->socommon->select_part_of_town();
-
- while (is_array($parts) && list(,$part) = each($parts))
- {
- $sel_part = '';
- if ($part['id']==$selected)
- {
- $sel_part = 'selected';
- }
-
- $part_of_town_list[] = array
- (
- 'id' => $part['id'],
- 'name' => $part['name'],
- 'selected' => $sel_part
- );
- }
-
- for ($i=0;$i<count($part_of_town_list);$i++)
- {
- if ($part_of_town_list[$i]['selected'] !=
'selected')
- {
-
unset($part_of_town_list[$i]['selected']);
- }
- }
-
- return $part_of_town_list;
- }
-
- function select_category_property_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories=
$this->socommon->select_category_property_list();
-
- 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 select_district_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('select_district'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_district'));
- break;
- }
-
- $districts= $this->socommon->select_district_list();
-
- while (is_array($districts) && list(,$district) =
each($districts))
- {
- $sel_district = '';
- if ($district['id']==$selected)
- {
- $sel_district = 'selected';
- }
-
- $district_list[] = array
- (
- 'id' => $district['id'],
- 'name' => $district['name'],
- 'selected' => $sel_district
- );
- }
-
- for ($i=0;$i<count($district_list);$i++)
- {
- if ($district_list[$i]['selected'] !=
'selected')
- {
- unset($district_list[$i]['selected']);
- }
- }
-
- return $district_list;
- }
-
-
- function validate_db_insert($values)
- {
- foreach($values as $value)
- {
- if($value || $value === 0)
- {
- $insert_value[] = "'".$value."'";
- }
- else
- {
- $insert_value[] = 'NULL';
- }
- }
-
- $values = implode(",", $insert_value);
- return $values;
- }
-
- function validate_db_update($value_set)
- {
- while (is_array($value_set) && list($field,$value) =
each($value_set))
- {
- if($value || $value === 0)
- {
- $value_entry[]= "$field='$value'";
- }
- else
- {
- $value_entry[]= "$field=NULL";
- }
- }
-
- $value_set = implode(",", $value_entry);
- return $value_set;
- }
-
- function fm_cache($name='',$value='')
- {
- return $this->socommon->fm_cache($name,$value);
- }
-
- function next_id($table,$key='')
- {
- return $this->socommon->next_id($table,$key);
- }
-
- function select_datatype($selected='')
- {
- $datatypes[0]['id']= 'V';
- $datatypes[0]['name']= lang('varchar');
- $datatypes[1]['id']= 'C';
- $datatypes[1]['name']= lang('Character');
- $datatypes[2]['id']= 'I';
- $datatypes[2]['name']= lang('Integer');
- $datatypes[3]['id']= 'N';
- $datatypes[3]['name']= lang('Decimal');
- $datatypes[4]['id']= 'D';
- $datatypes[4]['name']= lang('Date');
- $datatypes[5]['id']= 'T';
- $datatypes[5]['name']= lang('Memo');
- $datatypes[6]['id']= 'R';
- $datatypes[6]['name']= lang('Multiple radio');
- $datatypes[7]['id']= 'CH';
- $datatypes[7]['name']= lang('Multiple Checkbox');
- $datatypes[8]['id']= 'LB';
- $datatypes[8]['name']= lang('ListBox');
- $datatypes[9]['id']= 'AB';
- $datatypes[9]['name']= lang('Contact');
- $datatypes[10]['id']= 'VENDOR';
- $datatypes[10]['name']= lang('Vendor');
- $datatypes[11]['id']= 'email';
- $datatypes[11]['name']= lang('Email');
-
- return $this->select_list($selected,$datatypes);
-
- }
-
- function select_nullable($selected='')
- {
- $nullable[0]['id']= 'True';
- $nullable[0]['name']= lang('True');
- $nullable[1]['id']= 'False';
- $nullable[1]['name']= lang('False');
-
- return $this->select_list($selected,$nullable);
- }
-
-
- function excel($list,$name,$descr,$input_type='')
- {
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- $filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
-
- $workbook =
CreateObject($this->currentapp.'.excel',"-");
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header($filename,'application/vnd.ms-excel');
-
- $count_uicols_name=count($name);
-
- $worksheet1 =& $workbook->add_worksheet('First One');
-
- $j=0;
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- $m=0;
- for ($k=0;$k<$count_uicols_name;$k++)
- {
- if($input_type[$k]!='hidden')
- {
- $content[$j][$m]
= str_replace("\r\n"," ",$entry[$name[$k]]);
-
$worksheet1->write_string(0, $m, $descr[$k]);
- $m++;
- }
- }
- $j++;
- }
-
- foreach($content as $row)
- {
- $line++;
- for ($i=0; $i<count($row); $i++)
- {
-
$worksheet1->write($line,$i,$row[$i]);
- }
- }
- }
- $workbook->close();
-
- }
-
- function increment_id($name)
- {
- return $this->socommon->increment_id($name);
- }
-
- function get_origin_link($type)
- {
- if($type=='tts'):
- {
- $link = '.uitts.view';
- }
- elseif($type=='request'):
- {
- $link = '.uirequest.view';
- }
- elseif($type=='project'):
- {
- $link = '.uiproject.view';
- }
- elseif(substr($type,0,6)=='entity'):
- {
-
- $type = explode("_",$type);
- $entity_id = $type[1];
- $cat_id = $type[2];
- $link =
".uientity.view&entity_id=$entity_id&cat_id=$cat_id";
- }
- endif;
-
- return $link;
- }
-
- function select_wo_hours_category_list($selected='')
- {
- $category_list=
$this->socommon->select_wo_hours_category_list();
- if($selected)
- {
- $category_list =
$this->select_list($selected,$category_list);
- }
-
- return $category_list;
- }
-
-
+<?php
+ /**
+ * phpGroupWare - HRM: a human resource competence management system.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package hrm
+ * @subpackage core
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package hrm
+ */
+
+ class bocommon
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+ var $district_id;
+
+
+ var $public_functions = array
+ (
+ 'select_part_of_town' => True,
+ 'menu' => True,
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bocommon()
+ {
+// $GLOBALS['phpgw_info']['flags']['currentapp'] =
'hrm';
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ if (!is_object($GLOBALS['phpgw']->asyncservice))
+ {
+ $GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
+ }
+ $this->async = &$GLOBALS['phpgw']->asyncservice;
+
+ $this->join = $this->socommon->join;
+ $this->left_join = $this->socommon->left_join;
+ $this->like = $this->socommon->like;
+
+ switch($GLOBALS['phpgw_info']['server']['db_type'])
+ {
+ case 'mssql':
+ $this->dateformat = "M d
Y";
+ $this->datetimeformat = "M d Y g:iA";
+ break;
+ case 'mysql':
+ $this->dateformat =
"Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+ break;
+ case 'pgsql':
+ $this->dateformat =
"Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+// $this->dateformat = "F j,
Y";
+// $this->datetimeformat = "F j, Y g:iA";
+ break;
+ }
+
+ /* if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
+ {
+ $this->dateformat = "M d Y";
+ $this->datetimeformat = "M d Y g:iA";
+ }
+ else
+ {
+ $this->dateformat = "Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+ }
+
+
+ if(!$GLOBALS['phpgw_info']['flags']['css'])
+ {
+ $GLOBALS['phpgw_info']['flags']['css'] .=
"-->\n</style>\n"
+ . '<link rel="stylesheet"
type="text/css" media="all" href="'
+ .
$GLOBALS['phpgw_info']['server']['webserver_url'].'/' . $this->currentapp .
'/templates/'
+ .
$GLOBALS['phpgw_info']['server']['template_set']
+ .
'/css/'.$GLOBALS['phpgw_info']['server']['template_set'].'.css"
title="'.$GLOBALS['phpgw_info']['server']['template_set'].'" />'
+ . "\n<style type=\"text/css\">\n<!--\n";
+ }
+*/
+ }
+
+
+ function check_perms($rights, $required)
+ {
+ // return (!!($rights & $required) == True);
+ return ($rights & $required);
+ }
+
+ function create_preferences($app='',$user_id='')
+ {
+ return
$this->socommon->create_preferences($app,$user_id);
+ }
+
+ function msgbox_data($receipt)
+ {
+ $msgbox_data_error=array();
+ if (isSet($receipt['error']) AND
is_array($receipt['error']))
+ {
+ foreach($receipt['error'] as $errors)
+ {
+ $msgbox_data_error +=
array($errors['msg']=> False);
+ }
+ }
+
+ $msgbox_data_message=array();
+
+ if (isSet($receipt['message']) AND
is_array($receipt['message']))
+ {
+ foreach($receipt['message'] as $messages)
+ {
+ $msgbox_data_message +=
array($messages['msg']=> True);
+ }
+ }
+
+ $msgbox_data = $msgbox_data_error +
$msgbox_data_message;
+
+ return $msgbox_data;
+ }
+
+ function moneyformat($amount)
+ {
+ if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
+ {
+ $moneyformat =
"CONVERT(MONEY,"."'$amount'".",0)";
+ }
+ else
+ {
+ $moneyformat = "'" . $amount . "'";
+ }
+
+ return $moneyformat;
+ }
+
+
+ function date_array($date)
+ {
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $dateformat = str_replace(".","",$dateformat);
+ $dateformat = str_replace("-","",$dateformat);
+ $dateformat = str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ $dateparts = explode('/', $date);
+ $date_array['day'] = $dateparts[$d];
+ $date_array['month'] = $dateparts[$m];
+ $date_array['year'] = $dateparts[$y];
+
+ return $date_array;
+ }
+
+ function date_to_timestamp($date)
+ {
+ if($date)
+ {
+ $date_array = $this->date_array($date);
+ $date = mktime
(8,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+ }
+ return $date;
+ }
+
+
+ function select_multi_list($selected='',$input_list)
+ {
+ $j=0;
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $output_list[$j]['id'] = $entry['id'];
+ $output_list[$j]['name'] =
$entry['name'];
+
+ for ($i=0;$i<count($selected);$i++)
+ {
+ if($selected[$i] ==
$entry['id'])
+ {
+
$output_list[$j]['selected'] = 'selected';
+ }
+ }
+ $j++;
+ }
+ }
+
+ for ($i=0;$i<count($output_list);$i++)
+ {
+ if ($output_list[$i]['selected'] != 'selected')
+ {
+ unset($output_list[$i]['selected']);
+ }
+ }
+
+ return $output_list;
+ }
+
+
+ function select_list($selected='',$input_list='')
+ {
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $sel_entry = '';
+ if ($entry['id']==$selected)
+ {
+ $sel_entry = 'selected';
+ }
+ $entry_list[] = array
+ (
+ 'id' => $entry['id'],
+ 'name' =>
$entry['name'],
+ 'selected' => $sel_entry
+ );
+ }
+ for ($i=0;$i<count($entry_list);$i++)
+ {
+ if ($entry_list[$i]['selected'] !=
'selected')
+ {
+
unset($entry_list[$i]['selected']);
+ }
+ }
+ }
+ return $entry_list;
+ }
+
+
+ function
get_user_list($format='',$selected='',$extra='',$default='',$start='',
$sort='', $order='', $query='',$offset='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
+ break;
+ }
+
+ if(!$selected && $default)
+ {
+ $selected = $default;
+ }
+
+ if (is_array($extra))
+ {
+ foreach($extra as $extra_user)
+ {
+ $users_extra[]=array
+ (
+ 'account_id' => $extra_user,
+ 'account_firstname' =>
lang($extra_user)
+ );
+ }
+ }
+
+ $accounts = CreateObject('phpgwapi.accounts');
+ $users = $accounts->get_list('accounts', $start, $sort,
$order, $query,$offset);
+ unset($accounts);
+ if (is_array($users_extra) && is_array($users))
+ {
+ $users = $users_extra + $users;
+ }
+
+ if (isSet($users) AND is_array($users))
+ {
+ foreach($users as $user)
+ {
+ $sel_user = '';
+ if ($user['account_id']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'user_id' =>
$user['account_id'],
+ 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+ }
+
+ $user_count= count($user_list);
+ for ($i=0;$i<$user_count;$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+//_debug_array($user_list);
+ return $user_list;
+ }
+
+ function get_group_list($format='',$selected='',$start='',
$sort='', $order='', $query='',$offset='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('group_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('group_filter'));
+ break;
+ }
+
+ $accounts = CreateObject('phpgwapi.accounts');
+ $users = $accounts->get_list('groups', $start, $sort,
$order, $query,$offset);
+ unset($accounts);
+ if (isSet($users) AND is_array($users))
+ {
+ foreach($users as $user)
+ {
+ $sel_user = '';
+ if ($user['account_id']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'id' => $user['account_id'],
+ 'name' =>
$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+ }
+
+ $user_count= count($user_list);
+ for ($i=0;$i<$user_count;$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+//_debug_array($user_list);
+ return $user_list;
+ }
+
+
+ function initiate_ui_alarm($data)
+ {
+ $boalarm =
CreateObject($this->currentapp.'.boalarm');
+
+ if($data['type']=='view')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_view'));
+ }
+ else
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_form'));
+ }
+
+ $alarm['header'][] = array
+ (
+ 'lang_time' => lang('Time'),
+ 'lang_text' => lang('Text'),
+ 'lang_user' => lang('User'),
+ 'lang_enabled' => lang('Enabled'),
+ 'lang_select' => lang('Select')
+ );
+
+ $alarm['values'] =
$boalarm->read_alarms($data['alarm_type'],$data['id'],$data['text']);
+ if(!count($alarm['values'])>0)
+ {
+ unset($alarm['values']);
+ }
+
+ if($data['type']=='form')
+ {
+ $alarm['alter_alarm'][] = array
+ (
+ 'lang_enable' =>
lang('Enable'),
+ 'lang_disable' =>
lang('Disable'),
+ 'lang_delete' =>
lang('Delete')
+ );
+
+ for ($i=1; $i<=31; $i++)
+ {
+
$alarm['add_alarm']['day_list'][($i-1)][id] = $i;
+ }
+ $alarm['add_alarm']['lang_day']
= lang('Day');
+ $alarm['add_alarm']['lang_day_statustext']
= lang('Day');
+
+ for ($i=1; $i<=24; $i++)
+ {
+
$alarm['add_alarm']['hour_list'][($i-1)][id] = $i;
+ }
+ $alarm['add_alarm']['lang_hour']
= lang('Hour');
+ $alarm['add_alarm']['lang_hour_statustext']
= lang('Hour');
+
+ for ($i=1; $i<=60; $i++)
+ {
+
$alarm['add_alarm']['minute_list'][($i-1)][id] = $i;
+ }
+ $alarm['add_alarm']['lang_minute']
= lang('Minutes before the event');
+ $alarm['add_alarm']['lang_minute_statustext']
= lang('Minutes before the event');
+
+ $alarm['add_alarm']['user_list'] =
$this->get_user_list_right2('select',4,False,$data['acl_location'],False,$default=$this->account);
+
+ $alarm['add_alarm']['lang_user']
= lang('User');
+ $alarm['add_alarm']['lang_user_statustext']
= lang('Select the user the alarm belongs to.');
+ $alarm['add_alarm']['lang_no_user']
= lang('No user');
+ $alarm['add_alarm']['lang_add']
= lang('Add');
+ $alarm['add_alarm']['lang_add_alarm']
= lang('Add alarm');
+ $alarm['add_alarm']['lang_add_statustext']
= lang('Add alarm for selected user');
+
+ }
+
+//_debug_array($alarm['values']);
+ return $alarm;
+ }
+
+
+ function
select_multi_list_2($selected='',$input_list,$input_type='')
+ {
+ $j=0;
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $output_list[$j]['id'] = $entry['id'];
+ $output_list[$j]['value'] =
$entry['value'];
+ $output_list[$j]['input_type'] =
$input_type;
+
+ for ($i=0;$i<count($selected);$i++)
+ {
+ if($selected[$i] ==
$entry['id'])
+ {
+
$output_list[$j]['checked'] = 'checked';
+ }
+ }
+ $j++;
+ }
+ }
+
+ for ($i=0;$i<count($output_list);$i++)
+ {
+ if ($output_list[$i]['checked'] != 'checked')
+ {
+ unset($output_list[$i]['checked']);
+ }
+ }
+
+ return $output_list;
+ }
+
+
+ function list_methods($_type='xmlrpc')
+ {
+ /*
+ This handles introspection or discovery by the logged
in client,
+ in which case the input might be an array. The
server always calls
+ this function to fill the server dispatch map using a
string.
+ */
+ if (is_array($_type))
+ {
+ $_type = $_type['type'] ? $_type['type'] :
$_type[0];
+ }
+ switch($_type)
+ {
+ case 'xmlrpc':
+ $xml_functions = array(
+ 'read' => array(
+ 'function' => 'read',
+ 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
+ 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
+ ),
+ 'save' => array(
+ 'function' => 'save',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Update a single entry by passing the fields.')
+ ),
+ 'delete' => array(
+ 'function' => 'delete',
+ 'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
+ 'docstring' =>
lang('Delete a single entry by passing the id.')
+ ),
+ 'list' => array(
+ 'function' => '_list',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Read a list of entries.')
+ ),
+ 'list_methods' => array(
+ 'function' =>
'list_methods',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
+ 'docstring' =>
lang('Read this list of methods.')
+ )
+ );
+ return $xml_functions;
+ break;
+ case 'soap':
+ return $this->soap_functions;
+ break;
+ default:
+ return array();
+ break;
+ }
+ }
+
+ function add_leading_zero($num)
+ {
+
+ if ($id_type == "hex")
+ {
+ $num = hexdec($num);
+ $num++;
+ $num = dechex($num);
+ }
+ else
+ {
+ $num++;
+ }
+
+ if (strlen($num) == 4)
+ $return = $num;
+ if (strlen($num) == 3)
+ $return = "0$num";
+ if (strlen($num) == 2)
+ $return = "00$num";
+ if (strlen($num) == 1)
+ $return = "000$num";
+ if (strlen($num) == 0)
+ $return = "0001";
+
+ return strtoupper($return);
+ }
+
+
+ function validate_db_insert($values)
+ {
+ foreach($values as $value)
+ {
+ if($value || $value === 0)
+ {
+ $insert_value[] = "'".$value."'";
+ }
+ else
+ {
+ $insert_value[] = 'NULL';
+ }
+ }
+
+ $values = implode(",", $insert_value);
+ return $values;
+ }
+
+ function validate_db_update($value_set)
+ {
+ while (is_array($value_set) && list($field,$value) =
each($value_set))
+ {
+ if($value || $value === 0)
+ {
+ $value_entry[]= "$field='$value'";
+ }
+ else
+ {
+ $value_entry[]= "$field=NULL";
+ }
+ }
+
+ $value_set = implode(",", $value_entry);
+ return $value_set;
+ }
+
+ function fm_cache($name='',$value='')
+ {
+ return $this->socommon->fm_cache($name,$value);
+ }
+
+ function next_id($table,$key='')
+ {
+ return $this->socommon->next_id($table,$key);
+ }
+
+
+ function excel($list,$name,$descr,$input_type='')
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ $filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
+
+ $workbook =
CreateObject($this->currentapp.'.excel',"-");
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,'application/vnd.ms-excel');
+
+ $count_uicols_name=count($name);
+
+ $worksheet1 =& $workbook->add_worksheet('First One');
+
+ $j=0;
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ $m=0;
+ for ($k=0;$k<$count_uicols_name;$k++)
+ {
+ if($input_type[$k]!='hidden')
+ {
+ $content[$j][$m]
= str_replace("\r\n"," ",$entry[$name[$k]]);
+
$worksheet1->write_string(0, $m, $descr[$k]);
+ $m++;
+ }
+ }
+ $j++;
+ }
+
+ foreach($content as $row)
+ {
+ $line++;
+ for ($i=0; $i<count($row); $i++)
+ {
+
$worksheet1->write($line,$i,$row[$i]);
+ }
+ }
+ }
+ $workbook->close();
+
+ }
+
}
====================================================
Index: hrm/inc/class.socommon.inc.php
diff -u hrm/inc/class.socommon.inc.php:1.2 hrm/inc/class.socommon.inc.php:1.3
--- hrm/inc/class.socommon.inc.php:1.2 Mon Nov 21 20:25:33 2005
+++ hrm/inc/class.socommon.inc.php Fri Nov 25 11:58:29 2005
@@ -1,304 +1,93 @@
-<?php
- /**
- * phpGroupWare - HRM: a human resource competence management system.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package hrm
- * @subpackage core
- * @version $Id$
- */
-
- /**
- * Description
- * @package hrm
- */
-
- class socommon
- {
-
- function socommon()
- {
- //$GLOBALS['phpgw_info']['flags']['currentapp'] =
'hrm';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
- {
- $this->join = " JOIN ";
- $this->like = "ILIKE";
- }
- else
- {
- $this->join = " INNER JOIN ";
- $this->like = "LIKE";
- }
-
- $this->left_join = " LEFT JOIN ";
-
-
- }
-
- function fm_cache($name='',$value='')
- {
- if($value)
- {
- $value = serialize($value);
- $this->db->query("INSERT INTO fm_cache
(name,value)VALUES ('$name','$value')",__LINE__,__FILE__);
- }
- else
- {
- $this->db->query("SELECT value FROM fm_cache
where name='$name'");
- $this->db->next_record();
- $value= unserialize($this->db->f('value'));
- return $value;
-
- }
- }
-
- function create_preferences($app='',$user_id='')
- {
- $this->db->query("SELECT preference_value FROM
phpgw_preferences where preference_app = '$app' AND
preference_owner=".(int)$user_id );
- $this->db->next_record();
- $value=
unserialize($this->db->f('preference_value'));
- return $value;
- }
-
-
- function get_user_list_right($right='',$acl_location='')
- {
- $acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
- $myaccounts = CreateObject('phpgwapi.accounts');
-
- while($my_memberships && list($key,$group) =
each($my_memberships))
- {
- $security .= "," . $group['account_id'];
- }
-
- $sql = "SELECT * FROM phpgw_accounts $this->join
fm_acl2 on phpgw_accounts.account_id=fm_acl2.acl_account WHERE account_status =
'A' AND acl_location $this->like '%$acl_location%' order by account_lastname
ASC";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
-
if($acl2->check($acl_location,$right,$this->db->f('acl_account')))
- {
- if($this->db->f('account_type')=='g')
- {
- $members =
$myaccounts->member($this->db->f('account_id'));
- if (isset($members) AND
is_array($members))
- {
- foreach($members as
$user)
- {
-
$accounts[$user['account_id']] = array($user['account_id']);
- }
- unset($members);
- }
- }
- else
- {
-
$accounts[$this->db->f('acl_account')] = array($this->db->f('acl_account'));
- }
- }
- }
-
- unset($myaccounts);
-
- $sql = "SELECT account_id FROM phpgw_accounts WHERE
account_status = 'I'";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- unset($accounts[$this->db->f('account_id')]);
- }
-
- if (isset($accounts) AND is_array($accounts))
- {
- foreach($accounts as $account_id)
- {
- $i=0;
-
if(!$acl2->check($acl_location,$right,$account_id[0]))
- {
-
unset($accounts[$account_id[0]]);
- }
- $i++;
- }
- }
- address@hidden($accounts);
- $k=count($accounts);
- for ($i=0;$i<$k;$i++)
- {
- $in_list[] = $accounts[$i];
- }
-
- if($in_list)
- {
- $sql = 'SELECT * FROM phpgw_accounts where
account_id in ('. implode(',',$in_list) . ') order by account_lastname';
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $employees[] = Array(
- 'account_id' =>
$this->db->f('account_id'),
- 'account_lid' =>
$this->db->f('account_lid'),
- 'account_type' =>
$this->db->f('account_type'),
- 'account_firstname' =>
$this->db->f('account_firstname'),
- 'account_lastname' =>
$this->db->f('account_lastname'),
- 'account_status' =>
$this->db->f('account_status'),
- 'account_expires' =>
$this->db->f('account_expires')
- );
-
- }
- }
-/* for ($i=0;$i<$k;$i++)
- {
- $sql = 'SELECT * FROM phpgw_accounts where
account_id=' . (int)$accounts[$i];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $employees[] = Array(
- 'account_id' =>
$this->db->f('account_id'),
- 'account_lid' =>
$this->db->f('account_lid'),
- 'account_type' =>
$this->db->f('account_type'),
- 'account_firstname' =>
$this->db->f('account_firstname'),
- 'account_lastname' =>
$this->db->f('account_lastname'),
- 'account_status' =>
$this->db->f('account_status'),
- 'account_expires' =>
$this->db->f('account_expires')
- );
- }
-*/
- return $employees;
- }
-
- function read_single_tenant($id)
- {
-
- $this->db->query("SELECT * FROM fm_tenant WHERE id
=$id",__LINE__,__FILE__);
-
- $this->db->next_record();
- $tenant_data = array
- (
- 'first_name' =>
$this->db->f('first_name'),
- 'last_name' =>
$this->db->f('last_name'),
- 'contact_phone' =>
$this->db->f('contact_phone')
- );
-
-//_debug_array($tenant_data);
- return $tenant_data;
- }
-
- function check_location($location_code='',$type_id='')
- {
- $this->db->query("SELECT count(*) FROM
fm_location$type_id where location_code='$location_code'");
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- return True;
- }
- }
-
- function select_part_of_town()
- {
-
- $this->db->query("SELECT name, part_of_town_id FROM
fm_part_of_town ORDER BY name ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $part_of_town[$i]['id'] =
$this->db->f('part_of_town_id');
- $part_of_town[$i]['name'] =
stripslashes($this->db->f('name'));
- $i++;
- }
-
- return $part_of_town;
- }
-
- function select_district_list()
- {
-
- $this->db->query("SELECT id, descr FROM fm_district
where id >'0' ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $district[$i]['id']
= $this->db->f('id');
- $district[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $district;
- }
-
- function next_id($table='',$key='')
- {
- if(is_array($key))
- {
- while (is_array($key) && list($column,$value) =
each($key))
- {
- if($value)
- {
- $condition[] = $column . '=' .
$value;
- }
- }
-
- $where=' WHERE ' . implode(" AND ", $condition);
- }
-
- $this->db->query("SELECT max(id) as maximum FROM $table
$where",__LINE__,__FILE__);
- $this->db->next_record();
- $next_id = $this->db->f('maximum')+1;
- return "$next_id";
- }
-
- function get_lookup_entity($location)
- {
- $this->db->query("SELECT entity_id,name FROM
fm_entity_lookup $this->join fm_entity on
fm_entity_lookup.entity_id=fm_entity.id WHERE type='lookup' AND
location='$location' ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $entity[$i]['id']
= $this->db->f('entity_id');
- $entity[$i]['name']
= $this->db->f('name');
- $i++;
- }
- return $entity;
- }
-
- function get_start_entity($location)
- {
- $this->db->query("SELECT entity_id,name FROM
fm_entity_lookup $this->join fm_entity on
fm_entity_lookup.entity_id=fm_entity.id WHERE type='start' AND
location='$location' ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $entity[$i]['id']
= $this->db->f('entity_id');
- $entity[$i]['name']
= $this->db->f('name');
- $i++;
- }
- return $entity;
- }
-
- function increment_id($name)
- {
- $this->db->query("SELECT value FROM fm_idgenerator
WHERE name='$name'");
- $this->db->next_record();
- $next_id=$this->db->f('value') +1;
-
- $this->db->query("update fm_idgenerator set value =
$next_id WHERE name = 'workorder'");
- return $next_id;
- }
-
- function select_wo_hours_category_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_wo_hours_category ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $category_list[$i]['id'] = $this->db->f('id');
- $category_list[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
- return $category_list;
- }
+<?php
+ /**
+ * phpGroupWare - HRM: a human resource competence management system.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package hrm
+ * @subpackage core
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package hrm
+ */
+
+ class socommon
+ {
+
+ function socommon()
+ {
+ //$GLOBALS['phpgw_info']['flags']['currentapp'] =
'hrm';
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->db = $GLOBALS['phpgw']->db;
+ $this->db2 = $this->db;
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
+ {
+ $this->join = " JOIN ";
+ $this->like = "ILIKE";
+ }
+ else
+ {
+ $this->join = " INNER JOIN ";
+ $this->like = "LIKE";
+ }
+
+ $this->left_join = " LEFT JOIN ";
+
+
+ }
+
+ function fm_cache($name='',$value='')
+ {
+ if($value)
+ {
+ $value = serialize($value);
+ $this->db->query("INSERT INTO fm_cache
(name,value)VALUES ('$name','$value')",__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query("SELECT value FROM fm_cache
where name='$name'");
+ $this->db->next_record();
+ $value= unserialize($this->db->f('value'));
+ return $value;
+
+ }
+ }
+
+ function create_preferences($app='',$user_id='')
+ {
+ $this->db->query("SELECT preference_value FROM
phpgw_preferences where preference_app = '$app' AND
preference_owner=".(int)$user_id );
+ $this->db->next_record();
+ $value=
unserialize($this->db->f('preference_value'));
+ return $value;
+ }
+
+
+ function next_id($table='',$key='')
+ {
+ if(is_array($key))
+ {
+ while (is_array($key) && list($column,$value) =
each($key))
+ {
+ if($value)
+ {
+ $condition[] = $column . '=' .
$value;
+ }
+ }
+
+ $where=' WHERE ' . implode(" AND ", $condition);
+ }
+
+ $this->db->query("SELECT max(id) as maximum FROM $table
$where",__LINE__,__FILE__);
+ $this->db->next_record();
+ $next_id = $this->db->f('maximum')+1;
+ return "$next_id";
+ }
+
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] hrm/inc class.boadmin.inc.php, 1.3 class.uiadmin.inc.php, 1.3 class.soadmin.inc.php, 1.3 class.bocommon.inc.php, 1.4 class.socommon.inc.php, 1.3,
sigurdne <=