- phpgw --> egw

- some php5 stuff (clone of db object)
- partialy new db-functions
This commit is contained in:
Ralf Becker 2005-06-10 20:40:57 +00:00
parent ba42b6a9da
commit ec6a4600e8
8 changed files with 313 additions and 335 deletions

View File

@ -14,7 +14,9 @@
class bo_acl class bo_acl
{ {
/*! @var $permissions Holds alls permissions for resources of user */ /**
* @var $permissions Holds alls permissions for resources of user
*/
var $permissions; var $permissions;
var $acl; var $acl;
@ -30,14 +32,14 @@
function bo_acl($session=False) function bo_acl($session=False)
{ {
define('PHPGW_ACL_CAT_ADMIN',64); define('EGW_ACL_CAT_ADMIN',64);
define('PHPGW_ACL_DIRECT_BOOKING',128); define('EGW_ACL_DIRECT_BOOKING',128);
// define('PHPGW_ACL_CUSTOM_3',256); // define('EGW_ACL_CUSTOM_3',256);
$this->so = CreateObject('resources.so_acl'); $this->so =& CreateObject('resources.so_acl');
$this->permissions = $this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'],true); $this->permissions = $this->so->get_permissions($GLOBALS['egw_info']['user']['account_id'],true);
$this->egw_cats = createobject('phpgwapi.categories'); $this->egw_cats =& createobject('phpgwapi.categories');
$this->accounts = $GLOBALS['phpgw']->accounts->get_list(); $this->accounts = $GLOBALS['egw']->accounts->get_list();
$this->debug = False; $this->debug = False;
//all this is only needed when called from uiacl. //all this is only needed when called from uiacl.
@ -61,14 +63,14 @@
} }
} }
/*! /**
@function get_cats * get list of cats where current user has given rights
@abstract get list of cats where current user has given rights *
@author Cornelius Weiß <egw@von-und-zu-weiss.de> * @author Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param int $perm_type one of PHPGW_ACL_READ, PHPGW_ACL_ADD, PHPGW_ACL_EDIT, PHPGW_ACL_DELETE, PHPGW_ACL_DIRECT_BOOKING * @param int $perm_type one of EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING
@return array cat_id => cat_name * @return array cat_id => cat_name
TODO mark subcats and so on! * TODO mark subcats and so on!
*/ */
function get_cats($perm_type) function get_cats($perm_type)
{ {
$cats = $this->egw_cats->return_sorted_array(0,False,'','','',!$type); $cats = $this->egw_cats->return_sorted_array(0,False,'','','',!$type);
@ -80,7 +82,7 @@
{ {
$s .= '&nbsp;'; $s .= '&nbsp;';
} }
$s .= $GLOBALS['phpgw']->strip_html($cat['name']); $s .= $GLOBALS['egw']->strip_html($cat['name']);
if ($cat['app_name'] == 'phpgw') if ($cat['app_name'] == 'phpgw')
{ {
$s .= '&nbsp;&lt;' . lang('Global') . '&gt;'; $s .= '&nbsp;&lt;' . lang('Global') . '&gt;';
@ -96,32 +98,32 @@
} }
/*! /**
@function get_cat_name * gets name of category
@abstract gets name of category *
@author Lukas Weiß <wnz.gh05t@users.sourceforge.net> * @author Lukas Wei<EFBFBD> <wnz.gh05t@users.sourceforge.net>
@param int $cat_id * @param int $cat_id
@return mixed name of category * @return mixed name of category
*/ */
function get_cat_name($cat_id) function get_cat_name($cat_id)
{ {
$cat = $this->egw_cats->return_single($cat_id); $cat = $this->egw_cats->return_single($cat_id);
return $cat[0]['name']; return $cat[0]['name'];
} }
/*! /**
@function get_cat_admin * gets userid of admin for given category
@abstract gets userid of admin for given category *
@author Cornelius Weiß <egw@von-und-zu-weiss.de> * @author Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param int $cat_id * @param int $cat_id
@return int userid of cat admin * @return int userid of cat admin
*/ */
function get_cat_admin($cat_id) function get_cat_admin($cat_id)
{ {
$cat_rights = $this->get_rights($cat_id); $cat_rights = $this->get_rights($cat_id);
foreach ($cat_rights as $userid => $right) foreach ($cat_rights as $userid => $right)
{ {
if ($right & PHPGW_ACL_CAT_ADMIN) if ($right & EGW_ACL_CAT_ADMIN)
{ {
return $userid; return $userid;
} }
@ -129,25 +131,26 @@
return lang('none'); return lang('none');
} }
/*! /**
@function is_permitted * cheks one of the following rights for current user:
@abstract cheks one of the following rights for current user: *
@abstract PHPGW_ACL_READ, PHPGW_ACL_ADD, PHPGW_ACL_EDIT, PHPGW_ACL_DELETE, PHPGW_ACL_DIRECT_BOOKING * EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING
@param int $cat_id *
@param int $right * @param int $cat_id
@return bool user is permitted or not for right * @param int $right
*/ * @return bool user is permitted or not for right
*/
function is_permitted($cat_id,$right) function is_permitted($cat_id,$right)
{ {
return $this->permissions['L'.$cat_id] & $right; return $this->permissions['L'.$cat_id] & $right;
} }
/*! /**
@function get_rights * gets all rights from all user for given cat
@abstract gets all rights from all user for given cat *
@param int $cat_id * @param int $cat_id
@return array userid => right * @return array userid => right
*/ */
function get_rights($cat_id) function get_rights($cat_id)
{ {
return $this->so->get_rights('L'.$cat_id); return $this->so->get_rights('L'.$cat_id);
@ -165,12 +168,12 @@
'limit' => $this->limit, 'limit' => $this->limit,
); );
if($this->debug) { echo '<br>Read:'; _debug_array($data); } if($this->debug) { echo '<br>Read:'; _debug_array($data); }
$GLOBALS['phpgw']->session->appsession('session_data','resources_acl',$data); $GLOBALS['egw']->session->appsession('session_data','resources_acl',$data);
} }
function read_sessiondata() function read_sessiondata()
{ {
$data = $GLOBALS['phpgw']->session->appsession('session_data','resources_acl'); $data = $GLOBALS['egw']->session->appsession('session_data','resources_acl');
if($this->debug) { echo '<br>Read:'; _debug_array($data); } if($this->debug) { echo '<br>Read:'; _debug_array($data); }
$this->start = $data['start']; $this->start = $data['start'];
@ -194,13 +197,13 @@
$account_id = $account['account_id']; $account_id = $account['account_id'];
//write implies read //write implies read
$rights = in_array($account_id,$writecat) ? $rights = in_array($account_id,$writecat) ?
(PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT | PHPGW_ACL_DELETE) : (EGW_ACL_READ | EGW_ACL_ADD | EGW_ACL_EDIT | EGW_ACL_DELETE) :
(in_array($account_id,$readcat) ? PHPGW_ACL_READ : False); (in_array($account_id,$readcat) ? EGW_ACL_READ : False);
$rights = in_array($account_id,$bookcat) ? ($rights | PHPGW_ACL_DIRECT_BOOKING) : $rights; $rights = in_array($account_id,$bookcat) ? ($rights | EGW_ACL_DIRECT_BOOKING) : $rights;
$rights = in_array($account_id,$admincat) ? ($rights | PHPGW_ACL_CAT_ADMIN) : $rights; $rights = in_array($account_id,$admincat) ? ($rights | EGW_ACL_CAT_ADMIN) : $rights;
if ($rights) if ($rights)
{ {
$GLOBALS['phpgw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights); $GLOBALS['egw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights);
} }
} }
} }

View File

@ -22,21 +22,21 @@ class bo_resources
function bo_resources() function bo_resources()
{ {
$this->so = CreateObject('resources.so_resources'); $this->so =& CreateObject('resources.so_resources');
$this->acl = CreateObject('resources.bo_acl'); $this->acl =& CreateObject('resources.bo_acl');
$this->cats = $this->acl->egw_cats; $this->cats = $this->acl->egw_cats;
$this->vfs = CreateObject('phpgwapi.vfs'); $this->vfs =& CreateObject('phpgwapi.vfs');
$this->link = CreateObject('infolog.bolink'); $this->link =& CreateObject('infolog.bolink');
$this->conf = CreateObject('phpgwapi.config'); $this->conf =& CreateObject('phpgwapi.config');
$this->conf->read_repository(); $this->conf->read_repository();
} }
/*! /**
@function get_rows * get rows for resources list
@abstract get rows for resources list *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
*/ */
function get_rows($query,&$rows,&$readonlys) function get_rows($query,&$rows,&$readonlys)
{ {
$query['search'] = $query['search'] ? $query['search'] : '*'; $query['search'] = $query['search'] ? $query['search'] : '*';
@ -44,7 +44,7 @@ class bo_resources
$criteria = array( 'name' => $query['search'], $criteria = array( 'name' => $query['search'],
'short_description' => $query['search'] 'short_description' => $query['search']
); );
$cats = $query['filter'] ? array($query['filter'] => '') : $this->acl->get_cats(PHPGW_ACL_READ); $cats = $query['filter'] ? array($query['filter'] => '') : $this->acl->get_cats(EGW_ACL_READ);
$accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1; $accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1;
$rows = array( 0 => array( 'id' => '', $rows = array( 0 => array( 'id' => '',
@ -60,19 +60,19 @@ class bo_resources
$order_by = $query['order'] ? $query['order'].' '. $query['sort'] : ''; $order_by = $query['order'] ? $query['order'].' '. $query['sort'] : '';
$nr = $this->so->search($criteria,$cats,&$rows,$accessory_of,$order_by,$offset=$query['start'],$num_rows=0); $nr = $this->so->search($criteria,$cats,$rows,$accessory_of,$order_by,$offset=$query['start'],$num_rows=0);
foreach($rows as $num => $resource) foreach($rows as $num => $resource)
{ {
if (!$this->acl->is_permitted($resource['cat_id'],PHPGW_ACL_EDIT)) if (!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_EDIT))
{ {
$readonlys["edit[$resource[id]]"] = true; $readonlys["edit[$resource[id]]"] = true;
} }
if (!$this->acl->is_permitted($resource['cat_id'],PHPGW_ACL_DELETE)) if (!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_DELETE))
{ {
$readonlys["delete[$resource[id]]"] = true; $readonlys["delete[$resource[id]]"] = true;
} }
if ((!$this->acl->is_permitted($resource['cat_id'],PHPGW_ACL_ADD)) || $accessory_of != -1) if ((!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_ADD)) || $accessory_of != -1)
{ {
$readonlys["new_acc[$resource[id]]"] = true; $readonlys["new_acc[$resource[id]]"] = true;
} }
@ -106,16 +106,16 @@ class bo_resources
return $nr; return $nr;
} }
/*! /**
@function read * reads a resource exept binary datas
@abstract reads a resource exept binary datas *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param int $id resource id * @param int $id resource id
@return array with key => value or false if not found or allowed * @return array with key => value or false if not found or allowed
*/ */
function read($id) function read($id)
{ {
if(!$this->acl->is_permitted($this->so->get_value('cat_id',$id),PHPGW_ACL_READ)) if(!$this->acl->is_permitted($this->so->get_value('cat_id',$id),EGW_ACL_READ))
{ {
echo lang('You are not permitted to get information about this resource!') . '<br>'; echo lang('You are not permitted to get information about this resource!') . '<br>';
echo lang('Notify your administrator to correct this situation') . '<br>'; echo lang('Notify your administrator to correct this situation') . '<br>';
@ -124,16 +124,16 @@ class bo_resources
return $this->so->read($id); return $this->so->read($id);
} }
/*! /**
@function save * saves a resource. pictures are saved in vfs
@abstract saves a resource. pictures are saved in vfs *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param array $resource array with key => value of all needed datas * @param array $resource array with key => value of all needed datas
@return string msg if somthing went wrong; nothing if all right * @return string msg if somthing went wrong; nothing if all right
*/ */
function save($resource) function save($resource)
{ {
if(!$this->acl->is_permitted($resource['cat_id'],PHPGW_ACL_EDIT)) if(!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_EDIT))
{ {
return lang('You are not permitted to edit this reource!'); return lang('You are not permitted to edit this reource!');
} }
@ -199,12 +199,12 @@ class bo_resources
return $this->so->save($resource) ? false : lang('Something went wrong by saving resource'); return $this->so->save($resource) ? false : lang('Something went wrong by saving resource');
} }
/*! /**
@function delete * deletes resource including pictures and links
@abstract deletes resource including pictures and links *
@autor Lukas Weiss <wnz_gh05t@users.sourceforge.net> * @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
@param int $id id of resource * @param int $id id of resource
*/ */
function delete($id) function delete($id)
{ {
$this->remove_picture($id); $this->remove_picture($id);
@ -212,19 +212,19 @@ class bo_resources
return $this->so->delete(array('id'=>$id)) ? false : lang('Something went wrong by deleting resource'); return $this->so->delete(array('id'=>$id)) ? false : lang('Something went wrong by deleting resource');
} }
/*! /**
@function get_acc_list * gets list of accessories for resource
@abstract gets list of accessories for resource *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param int $id id of resource * @param int $id id of resource
@return array * @return array
*/ */
function get_acc_list($id) function get_acc_list($id)
{ {
if($id < 1){return;} if($id < 1){return;}
$cat_id = $this->so->get_value('cat_id',$id); $cat_id = $this->so->get_value('cat_id',$id);
$data[0] = array('id' => '', 'name' => ''); $data[0] = array('id' => '', 'name' => '');
$this->so->search(array('name' => '*'),array($cat_id => ''),&$data,$accessory_of=$id,$order_by='',$offset=false,$num_rows=-1); $this->so->search(array('name' => '*'),array($cat_id => ''),$data,$accessory_of=$id,$order_by='',$offset=false,$num_rows=-1);
foreach($data as $num => $resource) foreach($data as $num => $resource)
{ {
$acc_list[$resource['id']] = $resource['name']; $acc_list[$resource['id']] = $resource['name'];
@ -232,18 +232,17 @@ class bo_resources
return $acc_list; return $acc_list;
} }
/*! /**
@function link_query * @author Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@syntax link_query( $pattern ) * query infolog for entries matching $pattern
@author Cornelius Weiß <egw@von-und-zu-weiss.de> *
@abstract query infolog for entries matching $pattern */
*/
function link_query( $pattern ) function link_query( $pattern )
{ {
$criteria = array('name' => $pattern,'short_description' => $pattern); $criteria = array('name' => $pattern,'short_description' => $pattern);
$cats = $this->acl->get_cats(PHPGW_ACL_READ); $cats = $this->acl->get_cats(EGW_ACL_READ);
$data[0] = array('id' => '','name' => '', 'short_description' => ''); $data[0] = array('id' => '','name' => '', 'short_description' => '');
$this->so->search($criteria,$cats,&$data,$accessory_of=-1,$order_by='',$offset=false,$num_rows=-1); $this->so->search($criteria,$cats,$data,$accessory_of=-1,$order_by='',$offset=false,$num_rows=-1);
foreach($data as $num => $resource) foreach($data as $num => $resource)
{ {
@ -255,12 +254,11 @@ class bo_resources
return $list; return $list;
} }
/*! /**
@function link_title * @author Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@syntax link_title( $id ) * get title for an infolog entry identified by $id
@author Cornelius Weiß <egw@von-und-zu-weiss.de> *
@abstract get title for an infolog entry identified by $id */
*/
function link_title( $resource ) function link_title( $resource )
{ {
if (!is_array($resource) && $resource > 0) if (!is_array($resource) && $resource > 0)
@ -271,15 +269,15 @@ class bo_resources
return $title ? $title : false; return $title ? $title : false;
} }
/*! /**
@function save_picture * resizes and saves an pictures in vfs
@abstract resizes and saves an pictures in vfs *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param array $file array with key => value * @param array $file array with key => value
@param int $resource_id * @param int $resource_id
@return mixed string with msg if somthing went wrong; nothing if all right * @return mixed string with msg if somthing went wrong; nothing if all right
TODO make thumb an picture sizes choosable by preferences * TODO make thumb an picture sizes choosable by preferences
*/ */
function save_picture($file,$resouce_id) function save_picture($file,$resouce_id)
{ {
// test upload dir // test upload dir
@ -316,7 +314,7 @@ class bo_resources
$dst_img_size = array( 0 => 320, 1 => 240); $dst_img_size = array( 0 => 320, 1 => 240);
$thumb_size = array( 0 => 64, 1 => 48); $thumb_size = array( 0 => 64, 1 => 48);
$tmp_dir = $GLOBALS['phpgw_info']['server']['temp_dir'].'/'; $tmp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/';
if($src_img_size[0] > 64 || $src_img_size[1] > 48) if($src_img_size[0] > 64 || $src_img_size[1] > 48)
{ {
$f = $thumb_size[0] / $src_img_size[0]; $f = $thumb_size[0] / $src_img_size[0];
@ -357,7 +355,7 @@ class bo_resources
'attributes' => array ( 'attributes' => array (
'mime_type' => 'image/jpeg', 'mime_type' => 'image/jpeg',
'comment' => 'picture of resource no.'.$resouce_id, 'comment' => 'picture of resource no.'.$resouce_id,
'app' => $GLOBALS['phpgw_info']['flags']['currentapp'] 'app' => $GLOBALS['egw_info']['flags']['currentapp']
))); )));
$this->vfs->mv(array( $this->vfs->mv(array(
'from' => $tmp_dir.$resouce_id.'.thumb.jpg', 'from' => $tmp_dir.$resouce_id.'.thumb.jpg',
@ -370,20 +368,19 @@ class bo_resources
'attributes' => array ( 'attributes' => array (
'mime_type' => 'image/jpeg', 'mime_type' => 'image/jpeg',
'comment' => 'thumbnail of resource no.'.$resouce_id, 'comment' => 'thumbnail of resource no.'.$resouce_id,
'app' => $GLOBALS['phpgw_info']['flags']['currentapp'] 'app' => $GLOBALS['egw_info']['flags']['currentapp']
))); )));
$this->vfs->override_acl = 0; $this->vfs->override_acl = 0;
return; return;
} }
/*! /**
@function get_picture * get resource picture either from vfs or from symlink
@abstact get resource picture either from vfs or from symlink * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * @param int $id id of resource
@param int $id id of resource * @param bool $size false = thumb, true = full pic
@param bool $size false = thumb, true = full pic * @return string url of picture
@return string url of picture */
*/
function get_picture($id=0,$size=false) function get_picture($id=0,$size=false)
{ {
if ($id > 0) if ($id > 0)
@ -394,7 +391,7 @@ class bo_resources
switch($src) switch($src)
{ {
case 'own_src': case 'own_src':
$picture = $this->conf->config_data['dont_use_vfs'] ? $GLOBALS['phpgw_info']['server']['webserver_url'] : 'vfs:'; $picture = $this->conf->config_data['dont_use_vfs'] ? $GLOBALS['egw_info']['server']['webserver_url'] : 'vfs:';
$picture .= $size ? $this->pictures_dir.$id.'.jpg' : $this->thumbs_dir.$id.'.jpg'; $picture .= $size ? $this->pictures_dir.$id.'.jpg' : $this->thumbs_dir.$id.'.jpg';
break; break;
case 'cat_src': case 'cat_src':
@ -402,24 +399,25 @@ class bo_resources
$picture = unserialize($picture['data']); $picture = unserialize($picture['data']);
if($picture['icon']) if($picture['icon'])
{ {
$picture = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/images/'.$picture['icon']; $picture = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$picture['icon'];
break; break;
} }
case 'gen_src': case 'gen_src':
default : default :
$picture = $GLOBALS['phpgw_info']['server']['webserver_url'].$this->resource_icons; $picture = $GLOBALS['egw_info']['server']['webserver_url'].$this->resource_icons;
$picture .= strstr($src,'.') ? $src : 'generic.png'; $picture .= strstr($src,'.') ? $src : 'generic.png';
} }
return $picture; return $picture;
} }
/*! /**
@fuction remove_picture * remove_picture
@abstract removes picture from vfs * removes picture from vfs
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> *
@param int $id id of resource * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@return bool succsess or not * @param int $id id of resource
*/ * @return bool succsess or not
*/
function remove_picture($id) function remove_picture($id)
{ {
$vfs_data = array('string' => $this->pictures_dir.$id.'.jpg','relatives' => array(RELATIVE_ROOT)); $vfs_data = array('string' => $this->pictures_dir.$id.'.jpg','relatives' => array(RELATIVE_ROOT));
@ -433,16 +431,17 @@ class bo_resources
$this->vfs->override_acl = 0; $this->vfs->override_acl = 0;
} }
/*! /**
@fuction get_genpicturelist * get_genpicturelist
@abstract gets all pictures from 'generic picutres dir' in selectbox style for eTemplate * gets all pictures from 'generic picutres dir' in selectbox style for eTemplate
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> *
@return array directory contens in eTemplates selectbox style * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
*/ * @return array directory contens in eTemplates selectbox style
*/
function get_genpicturelist() function get_genpicturelist()
{ {
$icons['generic.png'] = lang('gernal resource'); $icons['generic.png'] = lang('gernal resource');
$dir = dir(PHPGW_SERVER_ROOT.$this->resource_icons); $dir = dir(EGW_SERVER_ROOT.$this->resource_icons);
while($file = $dir->read()) while($file = $dir->read())
{ {
if (preg_match('/\\.(png|gif|jpe?g)$/i',$file) && $file != 'generic.png') if (preg_match('/\\.(png|gif|jpe?g)$/i',$file) && $file != 'generic.png')

View File

@ -24,20 +24,20 @@ class resources_hooks
if ($location == 'sidebox_menu') if ($location == 'sidebox_menu')
{ {
$file = array( $file = array(
'resources list' => $GLOBALS['phpgw']->link('/index.php',array( 'resources list' => $GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'resources.ui_resources.index' )), 'menuaction' => 'resources.ui_resources.index' )),
/*'add' => $GLOBALS['phpgw']->link('/index.php',array( /*'add' => $GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'resources.ui_resources.edit' ))*/ 'menuaction' => 'resources.ui_resources.edit' ))*/
); );
display_sidebox($appname,$GLOBALS['phpgw_info']['apps']['resources']['title'].' '.lang('Menu'),$file); display_sidebox($appname,$GLOBALS['egw_info']['apps']['resources']['title'].' '.lang('Menu'),$file);
} }
/* if ($GLOBALS['phpgw_info']['user']['apps']['preferences'] && $location != 'admin') /* if ($GLOBALS['egw_info']['user']['apps']['preferences'] && $location != 'admin')
{ {
$file = array( $file = array(
'Preferences' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname), 'Preferences' => $GLOBALS['egw']->link('/preferences/preferences.php','appname='.$appname),
'Grant Access' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname), 'Grant Access' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
'Edit Categories' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True') 'Edit Categories' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True')
); );
if ($location == 'preferences') if ($location == 'preferences')
{ {
@ -49,20 +49,20 @@ class resources_hooks
} }
} }
*/ */
if ($GLOBALS['phpgw_info']['user']['apps']['admin'] && $location != 'preferences') if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences')
{ {
$file = Array( $file = Array(
'Site configuration' => $GLOBALS['phpgw']->link('/index.php',array( 'Site configuration' => $GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'resources.ui_resources.admin' )), 'menuaction' => 'resources.ui_resources.admin' )),
'Global Categories' => $GLOBALS['phpgw']->link('/index.php',array( 'Global Categories' => $GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'admin.uicategories.index', 'menuaction' => 'admin.uicategories.index',
'appname' => $appname, 'appname' => $appname,
'global_cats'=> True)), 'global_cats'=> True)),
'Configure Access Permissions' => $GLOBALS['phpgw']->link('/index.php', 'Configure Access Permissions' => $GLOBALS['egw']->link('/index.php',
'menuaction=resources.ui_acl.acllist') 'menuaction=resources.ui_acl.acllist')
// 'Custom fields, typ and status' => $GLOBALS['phpgw']->link('/index.php',array( // 'Custom fields, typ and status' => $GLOBALS['egw']->link('/index.php',array(
// 'menuaction' => 'infolog.uicustomfields.edit')), // 'menuaction' => 'infolog.uicustomfields.edit')),
// 'CSV-Import' => $GLOBALS['phpgw']->link('/infolog/csv_import.php') // 'CSV-Import' => $GLOBALS['egw']->link('/infolog/csv_import.php')
); );
if ($location == 'admin') if ($location == 'admin')
{ {

View File

@ -18,7 +18,8 @@
function so_acl() function so_acl()
{ {
copyobj($GLOBALS['phpgw']->db,$this->db); $this->db = clone($GLOBALS['egw']->db);
$this->db->set_app('resources');
} }
function get_rights($location) function get_rights($location)
@ -39,20 +40,20 @@
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
} }
/*! /**
@function get_permission * gets permissions for resources of user
@abstract gets permissions for resources of user *
@discussion This function is needed, cause eGW api dosn't provide a usefull function for that topic! * This function is needed, cause eGW api dosn't provide a usefull function for that topic!
@discussion Using api-functions for that, would resault bad performace :-( * Using api-functions for that, would resault bad performace :-(
@autor autor of news_admin ? * autor of news_admin ?
*
@param int $user user_id we want to get perms for * @param int $user user_id we want to get perms for
@param bool $inc_groups get rights due to groupmembership of user * @param bool $inc_groups get rights due to groupmembership of user
*
*/ */
function get_permissions($user, $inc_groups) function get_permissions($user, $inc_groups)
{ {
$groups = $GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1, $user); $groups = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $user);
$result = array(); $result = array();
$sql = 'SELECT acl_location, acl_rights FROM phpgw_acl '; $sql = 'SELECT acl_location, acl_rights FROM phpgw_acl ';
$sql .= "WHERE acl_appname = 'resources' "; $sql .= "WHERE acl_appname = 'resources' ";

View File

@ -17,25 +17,26 @@ class so_resources
{ {
function so_resources() function so_resources()
{ {
$this->db = $GLOBALS['phpgw']->db; $this->db = clone($GLOBALS['egw']->db);
$this->db->set_app('resources');
$this->rs_table = 'egw_resources'; $this->rs_table = 'egw_resources';
} }
/*! /**
@function search * searches db for rows matching searchcriteria and categories
@abstract searches db for rows matching searchcriteria and categories *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@discussion '*' is replaced with sql-wildcard '%' * '*' is replaced with sql-wildcard '%'
@param array $criteria array of key => value for search. (or'ed together) * @param array $criteria array of key => value for search. (or'ed together)
@param array $cats array of cat_id => cat_name to be searched * @param array $cats array of cat_id => cat_name to be searched
@param &array $data reference of data array with cols to return in first row ( key => '') * @param &array $data reference of data array with cols to return in first row ( key => '')
@param int $accessory_of find accessories of id, default -1 = show all exept accessories * @param int $accessory_of find accessories of id, default -1 = show all exept accessories
@param string $order_by fieldnames + {ASC|DESC} separated by colons ',' * @param string $order_by fieldnames + {ASC|DESC} separated by colons ','
@param int $offset row to start from, default 0 * @param int $offset row to start from, default 0
@param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']
*
@return int number of matching rows * @return int number of matching rows
*/ */
function search($criteria,$cats,&$data,$accessory_of=-1,$order_by='',$offset=false,$num_rows=-1) function search($criteria,$cats,&$data,$accessory_of=-1,$order_by='',$offset=false,$num_rows=-1)
{ {
$select = implode(',',array_keys($data[0])); $select = implode(',',array_keys($data[0]));
@ -48,7 +49,7 @@ class so_resources
$where .= " ) "; $where .= " ) ";
foreach ((array)$cats as $cat_id => $cat_name) foreach ((array)$cats as $cat_id => $cat_name)
{ {
$wherecats .= ($wherecats ? " OR " : " AND ( " ) .'cat_id' . "='".$cat_id."'"; $wherecats .= ($wherecats ? " OR " : " AND ( " ) .'cat_id' . "=".(int)$cat_id;
} }
$wherecats .= $wherecats ? " ) " : ""; $wherecats .= $wherecats ? " ) " : "";
$whereacc = " AND (accessory_of ='".$accessory_of."')"; $whereacc = " AND (accessory_of ='".$accessory_of."')";
@ -63,7 +64,7 @@ class so_resources
} }
if($num_rows==0) if($num_rows==0)
{ {
$num_rows = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; $num_rows = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
} }
for ($n = 1; $this->db->next_record() && $n!=$num_rows+1; ++$n) for ($n = 1; $this->db->next_record() && $n!=$num_rows+1; ++$n)
{ {
@ -73,81 +74,56 @@ class so_resources
return $nr; return $nr;
} }
/*! /**
@function get_value * gets the value of $key from resource of $id
@abstract gets the value of $key from resource of $id *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param string $key key of value to get * @param string $key key of value to get
@param int $id resource id * @param int $id resource id
@return mixed value of key and resource, false if key or id not found. * @return mixed value of key and resource, false if key or id not found.
*/ */
function get_value($key,$id) function get_value($key,$id)
{ {
if($this->db->query( "SELECT ". $key . " FROM ".$this->rs_table." WHERE id = ".$id,__LINE__,__FILE__)) if($this->db->select($this->rs_table,$key,array('id' => $id),__LINE__,__FILE__))
{ {
$this->db->next_record(); $value = $this->db->row(row);
(array)$value = $this->db->row();
return $value[$key]; return $value[$key];
} }
return false; return false;
} }
function delete($id) function delete($id)
{ {
$this->db->delete($this->rs_table,$id,__LINE__,__FILE__); $this->db->delete($this->rs_table,$id,__LINE__,__FILE__);
return true; return true;
} }
/*! /**
@function read * reads a resource exept binary datas
@abstract reads a resource exept binary datas *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param int $id resource id * @param int $id resource id
@return array with key => value or false if not found * @return array with key => value or false if not found
*/ */
function read($id) function read($id)
{ {
$tabledef = $this->db->metadata($table=$this->rs_table,$full=false); if($this->db->select($this->rs_table,'*',array('id' => $id),__LINE__,__FILE__))
foreach($tabledef as $n => $fielddef)
{ {
if(!$fielddef['binary']) return $this->db->row(true);
{
$readfields[$n] = $fielddef['name'];
}
}
if($this->db->query( "SELECT ". implode(',',$readfields) . " FROM ".$this->rs_table." WHERE id = ".$id,__LINE__,__FILE__))
{
$this->db->next_record();
return $this->db->row();
} }
return false; return false;
} }
/*! /**
@function save * saves a resource including binary datas
@abstract saves a resource including binary datas *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param array $resource key => value * @param array $resource key => value
@return mixed id of resource if all right, false if fale * @return mixed id of resource if all right, false if fale
*/ */
function save($resource) function save($resource)
{ {
$where = array('id' => $resource['id']); return $this->db->insert($this->rs_table,$resource,array('id' => $resource['id']),__LINE__,__FILE__) ? $this->db->get_last_insert_id($this->rs_table, 'id') : false;
$tabledef = $this->db->metadata($table=$this->rs_table,$full=false);
foreach($tabledef as $n => $fielddef)
{
if(isset($resource[$fielddef['name']]))
{
$data[$fielddef['name']] = $resource[$fielddef['name']];
}
elseif($resource['id'] > 0) //we need to reload old data! bug in db::update?
{
$data[$fielddef['name']] = $this->get_value($fielddef['name'],$resource['id']);
}
}
return $this->db->insert($this->rs_table,$data,$where,__LINE__,__FILE__) ? $this->db->get_last_insert_id($this->rs_table, 'id') : false;
} }
} }

View File

@ -28,9 +28,9 @@
function ui_acl() function ui_acl()
{ {
$this->bo = createobject('resources.bo_acl',True); $this->bo =& createobject('resources.bo_acl',True);
$this->accounts = $GLOBALS['phpgw']->accounts->get_list(); $this->accounts = $GLOBALS['egw']->accounts->get_list();
$this->nextmatchs = createobject('phpgwapi.nextmatchs'); $this->nextmatchs =& createobject('phpgwapi.nextmatchs');
$this->start = $this->bo->start; $this->start = $this->bo->start;
$this->query = $this->bo->query; $this->query = $this->bo->query;
$this->order = $this->bo->order; $this->order = $this->bo->order;
@ -40,17 +40,17 @@
function acllist() function acllist()
{ {
if (!$GLOBALS['phpgw']->acl->check('run',1,'admin')) if (!$GLOBALS['egw']->acl->check('run',1,'admin'))
{ {
$this->deny(); $this->deny();
} }
if ($_POST['btnDone']) if ($_POST['btnDone'])
{ {
$GLOBALS['phpgw']->redirect_link('/admin/index.php'); $GLOBALS['egw']->redirect_link('/admin/index.php');
} }
$GLOBALS['phpgw']->common->phpgw_header(); $GLOBALS['egw']->common->egw_header();
echo parse_navbar(); echo parse_navbar();
if ($_POST['btnSave']) if ($_POST['btnSave'])
@ -61,10 +61,10 @@
} }
} }
$GLOBALS['phpgw']->template->set_file('acl', 'acl.tpl'); $GLOBALS['egw']->template->set_file('acl', 'acl.tpl');
$GLOBALS['phpgw']->template->set_block('acl','cat_list','Cblock'); $GLOBALS['egw']->template->set_block('acl','cat_list','Cblock');
$GLOBALS['phpgw']->template->set_var(array( $GLOBALS['egw']->template->set_var(array(
'title' => $GLOBALS['phpgw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'), 'title' => $GLOBALS['egw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'),
'lang_search' => lang('Search'), 'lang_search' => lang('Search'),
'lang_save' => lang('Save'), 'lang_save' => lang('Save'),
'lang_done' => lang('Done'), 'lang_done' => lang('Done'),
@ -78,11 +78,11 @@
$left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist'); $left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
$right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist'); $right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.uiacl.acllist');
$GLOBALS['phpgw']->template->set_var(array( $GLOBALS['egw']->template->set_var(array(
'left' => $left, 'left' => $left,
'right' => $right, 'right' => $right,
'lang_showing' => $this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start), 'lang_showing' => $this->nextmatchs->show_hits($this->bo->catbo->total_records,$this->start),
'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 'th_bg' => $GLOBALS['egw_info']['theme']['th_bg'],
'sort_cat' => $this->nextmatchs->show_sort_order( 'sort_cat' => $this->nextmatchs->show_sort_order(
$this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=resources.uiacl.acllist' $this->sort,'cat_name','cat_name','/index.php',lang('Category'),'&menuaction=resources.uiacl.acllist'
), ),
@ -95,18 +95,18 @@
$this->rights = $this->bo->get_rights($cat['id']); $this->rights = $this->bo->get_rights($cat['id']);
$tr_color = $this->nextmatchs->alternate_row_color($tr_color); $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
$GLOBALS['phpgw']->template->set_var(array( $GLOBALS['egw']->template->set_var(array(
'tr_color' => $tr_color, 'tr_color' => $tr_color,
'catname' => $cat['name'], 'catname' => $cat['name'],
'catid' => $cat['id'], 'catid' => $cat['id'],
'read' => $this->selectlist(PHPGW_ACL_READ), 'read' => $this->selectlist(EGW_ACL_READ),
'write' => $this->selectlist(PHPGW_ACL_ADD), 'write' => $this->selectlist(EGW_ACL_ADD),
'book' =>$this->selectlist(PHPGW_ACL_DIRECT_BOOKING), 'book' =>$this->selectlist(EGW_ACL_DIRECT_BOOKING),
'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(PHPGW_ACL_CAT_ADMIN,true) 'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(EGW_ACL_CAT_ADMIN,true)
)); ));
$GLOBALS['phpgw']->template->parse('Cblock','cat_list',True); $GLOBALS['egw']->template->parse('Cblock','cat_list',True);
} }
$GLOBALS['phpgw']->template->pfp('out','acl',True); $GLOBALS['egw']->template->pfp('out','acl',True);
} }
function selectlist($right,$users_only=false) function selectlist($right,$users_only=false)
@ -117,7 +117,7 @@
if(!($users_only && $account['account_lastname'] == 'Group')) if(!($users_only && $account['account_lastname'] == 'Group'))
{ {
$selectlist .= '<option value="' . $account['account_id'] . '"'; $selectlist .= '<option value="' . $account['account_id'] . '"';
if($this->rights[$account['account_id']] & $right) if($this->rights[$account['account_id']] & $right)
{ {
$selectlist .= ' selected="selected"'; $selectlist .= ' selected="selected"';
} }
@ -131,7 +131,7 @@
function deny() function deny()
{ {
echo '<p><center><b>'.lang('Access not permitted').'</b></center>'; echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
$GLOBALS['phpgw']->common->phpgw_exit(True); $GLOBALS['egw']->common->egw_exit(True);
} }
} }
?> ?>

View File

@ -23,30 +23,30 @@ class ui_resources
'writeLangFile' => True 'writeLangFile' => True
); );
/*! /**
@function ui_resources * constructor of class ui_resources
@abstract constructor of class ui_resources *
*/ */
function ui_resources() function ui_resources()
{ {
// print_r($GLOBALS['phpgw_info']); die(); // print_r($GLOBALS['egw_info']); die();
$this->tmpl = CreateObject('etemplate.etemplate','resources.show'); $this->tmpl =& CreateObject('etemplate.etemplate','resources.show');
$this->bo = CreateObject('resources.bo_resources'); $this->bo =& CreateObject('resources.bo_resources');
if(!@is_object($GLOBALS['phpgw']->js)) if(!@is_object($GLOBALS['egw']->js))
{ {
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
} }
} }
/*! /**
@function index * main resources list.
@abstract main resources list. *
@autor Cornelius Weiß <egw@von-und-zu-weiss.de> * Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@param array $content content from eTemplate callback * @param array $content content from eTemplate callback
*
FIXME don't translate cats in nextmach * FIXME don't translate cats in nextmach
*/ */
function index($content='') function index($content='')
{ {
if (is_array($content)) if (is_array($content))
@ -56,7 +56,7 @@ class ui_resources
if (isset($content['nm']['rows'])) if (isset($content['nm']['rows']))
{ {
unset($sessiondata['rows']); unset($sessiondata['rows']);
$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$sessiondata); $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
unset($content['nm']['rows']['checkbox']); unset($content['nm']['rows']['checkbox']);
switch (key($content['nm']['rows'])) switch (key($content['nm']['rows']))
@ -73,7 +73,7 @@ class ui_resources
case 'view_acc': case 'view_acc':
list($id) = each($content['nm']['rows']['view_acc']); list($id) = each($content['nm']['rows']['view_acc']);
$sessiondata['view_accs_of'] = $id; $sessiondata['view_accs_of'] = $id;
$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$sessiondata); $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
return $this->index(); return $this->index();
case 'view': case 'view':
list($id) = each($content['nm']['rows']['view']); list($id) = each($content['nm']['rows']['view']);
@ -84,39 +84,39 @@ class ui_resources
} }
if (isset($content['add'])) // note: this isn't used as add is a popup now! if (isset($content['add'])) // note: this isn't used as add is a popup now!
{ {
$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$sessiondata); $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
return $content['nm']['view_accs_of'] ? $this->edit(array('id' => 0, 'accessory_of' => $content['nm']['view_accs_of'])) : $this->edit(0); return $content['nm']['view_accs_of'] ? $this->edit(array('id' => 0, 'accessory_of' => $content['nm']['view_accs_of'])) : $this->edit(0);
} }
if (isset($content['back'])) if (isset($content['back']))
{ {
unset($sessiondata['view_accs_of']); unset($sessiondata['view_accs_of']);
$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$sessiondata); $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
return $this->index(); return $this->index();
} }
} }
else else
{ {
$content = array(); $content = array();
$content['nm'] = $GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm'); $content['nm'] = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
} }
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows'; $content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
$content['nm']['no_filter'] = False; $content['nm']['no_filter'] = False;
$content['nm']['filter_label'] = 'Category'; $content['nm']['filter_label'] = 'Category';
$content['nm']['filter_help'] = lang('Select a category'); // is this used??? $content['nm']['filter_help'] = lang('Select a category'); // is this used???
$content['nm']['options-filter']= array('0'=>lang('all categories'))+(array)$this->bo->acl->get_cats(PHPGW_ACL_READ); $content['nm']['options-filter']= array('0'=>lang('all categories'))+(array)$this->bo->acl->get_cats(EGW_ACL_READ);
$content['nm']['no_filter2'] = true; $content['nm']['no_filter2'] = true;
$content['nm']['filter_no_lang'] = true; $content['nm']['filter_no_lang'] = true;
$content['nm']['no_cat'] = true; $content['nm']['no_cat'] = true;
// check if user is permitted to add resources // check if user is permitted to add resources
if(!$this->bo->acl->get_cats(PHPGW_ACL_ADD)) if(!$this->bo->acl->get_cats(EGW_ACL_ADD))
{ {
$no_button['add'] = true; $no_button['add'] = true;
} }
$no_button['back'] = true; $no_button['back'] = true;
$no_button['add_sub'] = true; $no_button['add_sub'] = true;
$GLOBALS['phpgw_info']['flags']['app_header'] = lang('resources'); $GLOBALS['egw_info']['flags']['app_header'] = lang('resources');
if($content['nm']['view_accs_of']) if($content['nm']['view_accs_of'])
{ {
@ -128,22 +128,21 @@ class ui_resources
$no_button['back'] = false; $no_button['back'] = false;
$no_button['add'] = true; $no_button['add'] = true;
$no_button['add_sub'] = false; $no_button['add_sub'] = false;
$GLOBALS['phpgw_info']['flags']['app_header'] = lang('resources') . ' - ' . lang('accessories of ') . $master['name'] . $GLOBALS['egw_info']['flags']['app_header'] = lang('resources') . ' - ' . lang('accessories of ') . $master['name'] .
($master['short_description'] ? ' [' . $master['short_description'] . ']' : ''); ($master['short_description'] ? ' [' . $master['short_description'] . ']' : '');
} }
$preserv = $content; $preserv = $content;
$GLOBALS['phpgw']->session->appsession('session_data','resources_index_nm',$content['nm']); $GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$content['nm']);
$this->tmpl->read('resources.show'); $this->tmpl->read('resources.show');
$this->tmpl->exec('resources.ui_resources.index',$content,$sel_options,$no_button,$preserv); $this->tmpl->exec('resources.ui_resources.index',$content,$sel_options,$no_button,$preserv);
} }
/*! /**
@function edit * @author Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
@syntax edit($content=0) * invokes add or edit dialog for resources
@author Cornelius Weiß <egw@von-und-zu-weiss.de> *
@abstract invokes add or edit dialog for resources * @param $content Content from the eTemplate Exec call or id on inital call
@param $content Content from the eTemplate Exec call or id on inital call */
*/
function edit($content=0,$accessory_of = -1) function edit($content=0,$accessory_of = -1)
{ {
if (is_array($content)) if (is_array($content))
@ -170,17 +169,17 @@ class ui_resources
{ {
return $this->edit($content); return $this->edit($content);
} }
$js = "opener.location.href='".$GLOBALS['phpgw']->link('/index.php', $js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',
array('menuaction' => 'resources.ui_resources.index'))."';"; array('menuaction' => 'resources.ui_resources.index'))."';";
$js .= 'window.close();'; $js .= 'window.close();';
echo "<html><body><script>$js</script></body></html>\n"; echo "<html><body><script>$js</script></body></html>\n";
$GLOBALS['phpgw']->common->phpgw_exit(); $GLOBALS['egw']->common->egw_exit();
} }
elseif($content['cancel']) elseif($content['cancel'])
{ {
$js .= 'window.close();'; $js .= 'window.close();';
echo "<html><body><script>$js</script></body></html>\n"; echo "<html><body><script>$js</script></body></html>\n";
$GLOBALS['phpgw']->common->phpgw_exit(); $GLOBALS['egw']->common->egw_exit();
} }
} }
else else
@ -208,7 +207,7 @@ class ui_resources
$content['useable'] = $content['useable'] ? $content['useable'] : 1; $content['useable'] = $content['useable'] ? $content['useable'] : 1;
$sel_options['gen_src_list'] = $this->bo->get_genpicturelist(); $sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
$sel_options['cat_id'] = $this->bo->acl->get_cats(PHPGW_ACL_ADD); $sel_options['cat_id'] = $this->bo->acl->get_cats(EGW_ACL_ADD);
$sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] : array('' => lang('select one')) + $sel_options['cat_id']; $sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] : array('' => lang('select one')) + $sel_options['cat_id'];
if($accessory_of > 0 || $content['accessory_of'] > 0) if($accessory_of > 0 || $content['accessory_of'] > 0)
@ -226,11 +225,11 @@ class ui_resources
} }
/*! /**
@function admin * adminsection of resources
@abstract adminsection of resources *
@author Cornelius Weiß <egw@von-und-zu-weiss.de> * @author Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
*/ */
function admin($content='') function admin($content='')
{ {
if(is_array($content)) if(is_array($content))
@ -242,7 +241,7 @@ class ui_resources
} }
else else
{ {
return $GLOBALS['phpgw']->redirect_link('/admin/index.php'); return $GLOBALS['egw']->redirect_link('/admin/index.php');
} }
} }
$content = $this->bo->conf->read_repository(); $content = $this->bo->conf->read_repository();
@ -250,12 +249,12 @@ class ui_resources
$this->tmpl->exec('resources.ui_resources.admin',$content,$sel_options,$no_button,$preserv); $this->tmpl->exec('resources.ui_resources.admin',$content,$sel_options,$no_button,$preserv);
} }
/*! /**
@function show * showes a single resource
@abstract showes a single resource *
@param int $id resource id * @param int $id resource id
@author Lukas Weiss <wnz.gh05t@users.sourceforge.net> * @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
*/ */
function show($id=0) function show($id=0)
{ {
if (isset($_GET['id'])) $id = $_GET['id']; if (isset($_GET['id'])) $id = $_GET['id'];
@ -265,9 +264,9 @@ class ui_resources
$content['gen_src_list'] = strstr($content['picture_src'],'.') ? $content['picture_src'] : false; $content['gen_src_list'] = strstr($content['picture_src'],'.') ? $content['picture_src'] : false;
$content['picture_src'] = strstr($content['picture_src'],'.') ? 'gen_src' : $content['picture_src']; $content['picture_src'] = strstr($content['picture_src'],'.') ? 'gen_src' : $content['picture_src'];
$content['link_to'] = array( $content['link_to'] = array(
'to_id' => $id, 'to_id' => $id,
'to_app' => 'resources' 'to_app' => 'resources'
); );
$content['resource_picture'] = $this->bo->get_picture($content['id'],$content['picture_src'],$size=true); $content['resource_picture'] = $this->bo->get_picture($content['id'],$content['picture_src'],$size=true);
$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1; $content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
@ -275,8 +274,8 @@ class ui_resources
$content['quantity'] = ($content['useable'] == $content['quantity']) ? $content['quantity'] : $content['quantity'].' ('.lang('useable ').$content['useable'].')'; $content['quantity'] = ($content['useable'] == $content['quantity']) ? $content['quantity'] : $content['quantity'].' ('.lang('useable ').$content['useable'].')';
//$sel_options['gen_src_list'] = $this->bo->get_genpicturelist(); //$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
$content['cat_name'] = $this->bo->acl->get_cat_name($content['cat_id']); $content['cat_name'] = $this->bo->acl->get_cat_name($content['cat_id']);
$content['cat_admin'] = $this->bo->acl->get_cat_admin($content['cat_id']); $content['cat_admin'] = $this->bo->acl->get_cat_admin($content['cat_id']);
@ -297,12 +296,12 @@ class ui_resources
} }
/*! /**
@function delete * deletes a resource
@abstract deletes a resource *
@param int $id resource id * @param int $id resource id
@author Lukas Weiss <wnz.gh05t@users.sourceforge.net> * @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
*/ */
function delete($id) function delete($id)
{ {
$this->bo->delete($id); $this->bo->delete($id);

View File

@ -12,12 +12,12 @@
\**************************************************************************/ \**************************************************************************/
$GLOBALS['phpgw_info']['flags'] = array( $GLOBALS['egw_info']['flags'] = array(
'currentapp' => 'resources', 'currentapp' => 'resources',
'noheader' => True, 'noheader' => True,
'nonavbar' => True 'nonavbar' => True
); );
include('../header.inc.php'); include('../header.inc.php');
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=resources.ui_resources.index'); $GLOBALS['egw']->redirect_link('/index.php','menuaction=resources.ui_resources.index');