diff --git a/resources/inc/class.bo_acl.inc.php b/resources/inc/class.bo_acl.inc.php index 41d2d4a6b9..f306e7895e 100755 --- a/resources/inc/class.bo_acl.inc.php +++ b/resources/inc/class.bo_acl.inc.php @@ -14,7 +14,9 @@ class bo_acl { - /*! @var $permissions Holds alls permissions for resources of user */ + /** + * @var $permissions Holds alls permissions for resources of user + */ var $permissions; var $acl; @@ -30,14 +32,14 @@ function bo_acl($session=False) { - define('PHPGW_ACL_CAT_ADMIN',64); - define('PHPGW_ACL_DIRECT_BOOKING',128); -// define('PHPGW_ACL_CUSTOM_3',256); + define('EGW_ACL_CAT_ADMIN',64); + define('EGW_ACL_DIRECT_BOOKING',128); +// define('EGW_ACL_CUSTOM_3',256); - $this->so = CreateObject('resources.so_acl'); - $this->permissions = $this->so->get_permissions($GLOBALS['phpgw_info']['user']['account_id'],true); - $this->egw_cats = createobject('phpgwapi.categories'); - $this->accounts = $GLOBALS['phpgw']->accounts->get_list(); + $this->so =& CreateObject('resources.so_acl'); + $this->permissions = $this->so->get_permissions($GLOBALS['egw_info']['user']['account_id'],true); + $this->egw_cats =& createobject('phpgwapi.categories'); + $this->accounts = $GLOBALS['egw']->accounts->get_list(); $this->debug = False; //all this is only needed when called from uiacl. @@ -61,14 +63,14 @@ } } - /*! - @function get_cats - @abstract get list of cats where current user has given rights - @author Cornelius Weiß - @param int $perm_type one of PHPGW_ACL_READ, PHPGW_ACL_ADD, PHPGW_ACL_EDIT, PHPGW_ACL_DELETE, PHPGW_ACL_DIRECT_BOOKING - @return array cat_id => cat_name - TODO mark subcats and so on! - */ + /** + * get list of cats where current user has given rights + * + * @author Cornelius Wei� + * @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 + * TODO mark subcats and so on! + */ function get_cats($perm_type) { $cats = $this->egw_cats->return_sorted_array(0,False,'','','',!$type); @@ -80,7 +82,7 @@ { $s .= ' '; } - $s .= $GLOBALS['phpgw']->strip_html($cat['name']); + $s .= $GLOBALS['egw']->strip_html($cat['name']); if ($cat['app_name'] == 'phpgw') { $s .= ' <' . lang('Global') . '>'; @@ -96,32 +98,32 @@ } - /*! - @function get_cat_name - @abstract gets name of category - @author Lukas Weiß - @param int $cat_id - @return mixed name of category - */ + /** + * gets name of category + * + * @author Lukas Wei� + * @param int $cat_id + * @return mixed name of category + */ function get_cat_name($cat_id) { - $cat = $this->egw_cats->return_single($cat_id); - return $cat[0]['name']; + $cat = $this->egw_cats->return_single($cat_id); + return $cat[0]['name']; } - /*! - @function get_cat_admin - @abstract gets userid of admin for given category - @author Cornelius Weiß - @param int $cat_id - @return int userid of cat admin - */ + /** + * gets userid of admin for given category + * + * @author Cornelius Wei� + * @param int $cat_id + * @return int userid of cat admin + */ function get_cat_admin($cat_id) { $cat_rights = $this->get_rights($cat_id); foreach ($cat_rights as $userid => $right) { - if ($right & PHPGW_ACL_CAT_ADMIN) + if ($right & EGW_ACL_CAT_ADMIN) { return $userid; } @@ -129,25 +131,26 @@ return lang('none'); } - /*! - @function is_permitted - @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 - @param int $cat_id - @param int $right - @return bool user is permitted or not for right - */ + /** + * cheks one of the following rights for current user: + * + * EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING + * + * @param int $cat_id + * @param int $right + * @return bool user is permitted or not for right + */ function is_permitted($cat_id,$right) { return $this->permissions['L'.$cat_id] & $right; } - /*! - @function get_rights - @abstract gets all rights from all user for given cat - @param int $cat_id - @return array userid => right - */ + /** + * gets all rights from all user for given cat + * + * @param int $cat_id + * @return array userid => right + */ function get_rights($cat_id) { return $this->so->get_rights('L'.$cat_id); @@ -165,12 +168,12 @@ 'limit' => $this->limit, ); if($this->debug) { echo '
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() { - $data = $GLOBALS['phpgw']->session->appsession('session_data','resources_acl'); + $data = $GLOBALS['egw']->session->appsession('session_data','resources_acl'); if($this->debug) { echo '
Read:'; _debug_array($data); } $this->start = $data['start']; @@ -194,13 +197,13 @@ $account_id = $account['account_id']; //write implies read $rights = in_array($account_id,$writecat) ? - (PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT | PHPGW_ACL_DELETE) : - (in_array($account_id,$readcat) ? PHPGW_ACL_READ : False); - $rights = in_array($account_id,$bookcat) ? ($rights | PHPGW_ACL_DIRECT_BOOKING) : $rights; - $rights = in_array($account_id,$admincat) ? ($rights | PHPGW_ACL_CAT_ADMIN) : $rights; + (EGW_ACL_READ | EGW_ACL_ADD | EGW_ACL_EDIT | EGW_ACL_DELETE) : + (in_array($account_id,$readcat) ? EGW_ACL_READ : False); + $rights = in_array($account_id,$bookcat) ? ($rights | EGW_ACL_DIRECT_BOOKING) : $rights; + $rights = in_array($account_id,$admincat) ? ($rights | EGW_ACL_CAT_ADMIN) : $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); } } } diff --git a/resources/inc/class.bo_resources.inc.php b/resources/inc/class.bo_resources.inc.php index efac8e2dd2..761cad5bb1 100755 --- a/resources/inc/class.bo_resources.inc.php +++ b/resources/inc/class.bo_resources.inc.php @@ -22,21 +22,21 @@ class bo_resources function bo_resources() { - $this->so = CreateObject('resources.so_resources'); - $this->acl = CreateObject('resources.bo_acl'); + $this->so =& CreateObject('resources.so_resources'); + $this->acl =& CreateObject('resources.bo_acl'); $this->cats = $this->acl->egw_cats; - $this->vfs = CreateObject('phpgwapi.vfs'); - $this->link = CreateObject('infolog.bolink'); - $this->conf = CreateObject('phpgwapi.config'); + $this->vfs =& CreateObject('phpgwapi.vfs'); + $this->link =& CreateObject('infolog.bolink'); + $this->conf =& CreateObject('phpgwapi.config'); $this->conf->read_repository(); } - /*! - @function get_rows - @abstract get rows for resources list - @autor Cornelius Weiß - */ + /** + * get rows for resources list + * + * Cornelius Wei� + */ function get_rows($query,&$rows,&$readonlys) { $query['search'] = $query['search'] ? $query['search'] : '*'; @@ -44,7 +44,7 @@ class bo_resources $criteria = array( 'name' => $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; $rows = array( 0 => array( 'id' => '', @@ -60,19 +60,19 @@ class bo_resources $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) { - 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; } - 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; } - 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; } @@ -106,16 +106,16 @@ class bo_resources return $nr; } - /*! - @function read - @abstract reads a resource exept binary datas - @autor Cornelius Weiß - @param int $id resource id - @return array with key => value or false if not found or allowed - */ + /** + * reads a resource exept binary datas + * + * Cornelius Wei� + * @param int $id resource id + * @return array with key => value or false if not found or allowed + */ 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!') . '
'; echo lang('Notify your administrator to correct this situation') . '
'; @@ -124,16 +124,16 @@ class bo_resources return $this->so->read($id); } - /*! - @function save - @abstract saves a resource. pictures are saved in vfs - @autor Cornelius Weiß - @param array $resource array with key => value of all needed datas - @return string msg if somthing went wrong; nothing if all right - */ + /** + * saves a resource. pictures are saved in vfs + * + * Cornelius Wei� + * @param array $resource array with key => value of all needed datas + * @return string msg if somthing went wrong; nothing if all right + */ 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!'); } @@ -199,12 +199,12 @@ class bo_resources return $this->so->save($resource) ? false : lang('Something went wrong by saving resource'); } - /*! - @function delete - @abstract deletes resource including pictures and links - @autor Lukas Weiss - @param int $id id of resource - */ + /** + * deletes resource including pictures and links + * + * @author Lukas Weiss + * @param int $id id of resource + */ function delete($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'); } - /*! - @function get_acc_list - @abstract gets list of accessories for resource - @autor Cornelius Weiß - @param int $id id of resource - @return array - */ + /** + * gets list of accessories for resource + * + * Cornelius Wei� + * @param int $id id of resource + * @return array + */ function get_acc_list($id) { if($id < 1){return;} $cat_id = $this->so->get_value('cat_id',$id); $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) { $acc_list[$resource['id']] = $resource['name']; @@ -232,18 +232,17 @@ class bo_resources return $acc_list; } - /*! - @function link_query - @syntax link_query( $pattern ) - @author Cornelius Weiß - @abstract query infolog for entries matching $pattern - */ + /** + * @author Cornelius Wei� + * query infolog for entries matching $pattern + * + */ function link_query( $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' => ''); - $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) { @@ -255,12 +254,11 @@ class bo_resources return $list; } - /*! - @function link_title - @syntax link_title( $id ) - @author Cornelius Weiß - @abstract get title for an infolog entry identified by $id - */ + /** + * @author Cornelius Wei� + * get title for an infolog entry identified by $id + * + */ function link_title( $resource ) { if (!is_array($resource) && $resource > 0) @@ -271,15 +269,15 @@ class bo_resources return $title ? $title : false; } - /*! - @function save_picture - @abstract resizes and saves an pictures in vfs - @autor Cornelius Weiß - @param array $file array with key => value - @param int $resource_id - @return mixed string with msg if somthing went wrong; nothing if all right - TODO make thumb an picture sizes choosable by preferences - */ + /** + * resizes and saves an pictures in vfs + * + * Cornelius Wei� + * @param array $file array with key => value + * @param int $resource_id + * @return mixed string with msg if somthing went wrong; nothing if all right + * TODO make thumb an picture sizes choosable by preferences + */ function save_picture($file,$resouce_id) { // test upload dir @@ -316,7 +314,7 @@ class bo_resources $dst_img_size = array( 0 => 320, 1 => 240); $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) { $f = $thumb_size[0] / $src_img_size[0]; @@ -357,7 +355,7 @@ class bo_resources 'attributes' => array ( 'mime_type' => 'image/jpeg', 'comment' => 'picture of resource no.'.$resouce_id, - 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'] + 'app' => $GLOBALS['egw_info']['flags']['currentapp'] ))); $this->vfs->mv(array( 'from' => $tmp_dir.$resouce_id.'.thumb.jpg', @@ -370,20 +368,19 @@ class bo_resources 'attributes' => array ( 'mime_type' => 'image/jpeg', 'comment' => 'thumbnail of resource no.'.$resouce_id, - 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'] + 'app' => $GLOBALS['egw_info']['flags']['currentapp'] ))); $this->vfs->override_acl = 0; return; } - /*! - @function get_picture - @abstact get resource picture either from vfs or from symlink - @autor Cornelius Weiß - @param int $id id of resource - @param bool $size false = thumb, true = full pic - @return string url of picture - */ + /** + * get resource picture either from vfs or from symlink + * Cornelius Wei� + * @param int $id id of resource + * @param bool $size false = thumb, true = full pic + * @return string url of picture + */ function get_picture($id=0,$size=false) { if ($id > 0) @@ -394,7 +391,7 @@ class bo_resources switch($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'; break; case 'cat_src': @@ -402,24 +399,25 @@ class bo_resources $picture = unserialize($picture['data']); 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; } case 'gen_src': 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'; } return $picture; } - /*! - @fuction remove_picture - @abstract removes picture from vfs - @autor Cornelius Weiß - @param int $id id of resource - @return bool succsess or not - */ + /** + * remove_picture + * removes picture from vfs + * + * Cornelius Wei� + * @param int $id id of resource + * @return bool succsess or not + */ function remove_picture($id) { $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; } - /*! - @fuction get_genpicturelist - @abstract gets all pictures from 'generic picutres dir' in selectbox style for eTemplate - @autor Cornelius Weiß - @return array directory contens in eTemplates selectbox style - */ + /** + * get_genpicturelist + * gets all pictures from 'generic picutres dir' in selectbox style for eTemplate + * + * Cornelius Wei� + * @return array directory contens in eTemplates selectbox style + */ function get_genpicturelist() { $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()) { if (preg_match('/\\.(png|gif|jpe?g)$/i',$file) && $file != 'generic.png') diff --git a/resources/inc/class.resources_hooks.inc.php b/resources/inc/class.resources_hooks.inc.php index 87780280e8..fdd6fb282e 100644 --- a/resources/inc/class.resources_hooks.inc.php +++ b/resources/inc/class.resources_hooks.inc.php @@ -24,20 +24,20 @@ class resources_hooks if ($location == 'sidebox_menu') { $file = array( - 'resources list' => $GLOBALS['phpgw']->link('/index.php',array( + 'resources list' => $GLOBALS['egw']->link('/index.php',array( 'menuaction' => 'resources.ui_resources.index' )), - /*'add' => $GLOBALS['phpgw']->link('/index.php',array( + /*'add' => $GLOBALS['egw']->link('/index.php',array( '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( - 'Preferences' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname), - 'Grant Access' => $GLOBALS['phpgw']->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') + 'Preferences' => $GLOBALS['egw']->link('/preferences/preferences.php','appname='.$appname), + 'Grant Access' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname), + 'Edit Categories' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True') ); 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( - 'Site configuration' => $GLOBALS['phpgw']->link('/index.php',array( + 'Site configuration' => $GLOBALS['egw']->link('/index.php',array( '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', 'appname' => $appname, 'global_cats'=> True)), - 'Configure Access Permissions' => $GLOBALS['phpgw']->link('/index.php', + 'Configure Access Permissions' => $GLOBALS['egw']->link('/index.php', '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')), -// 'CSV-Import' => $GLOBALS['phpgw']->link('/infolog/csv_import.php') +// 'CSV-Import' => $GLOBALS['egw']->link('/infolog/csv_import.php') ); if ($location == 'admin') { diff --git a/resources/inc/class.so_acl.inc.php b/resources/inc/class.so_acl.inc.php index f8e7e2980f..c529be8b9c 100755 --- a/resources/inc/class.so_acl.inc.php +++ b/resources/inc/class.so_acl.inc.php @@ -18,7 +18,8 @@ function so_acl() { - copyobj($GLOBALS['phpgw']->db,$this->db); + $this->db = clone($GLOBALS['egw']->db); + $this->db->set_app('resources'); } function get_rights($location) @@ -39,20 +40,20 @@ $this->db->query($sql,__LINE__,__FILE__); } - /*! - @function get_permission - @abstract gets permissions for resources of user - @discussion 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 :-( - @autor autor of news_admin ? - - @param int $user user_id we want to get perms for - @param bool $inc_groups get rights due to groupmembership of user - - */ + /** + * gets permissions for resources of user + * + * This function is needed, cause eGW api dosn't provide a usefull function for that topic! + * Using api-functions for that, would resault bad performace :-( + * autor of news_admin ? + * + * @param int $user user_id we want to get perms for + * @param bool $inc_groups get rights due to groupmembership of user + * + */ 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(); $sql = 'SELECT acl_location, acl_rights FROM phpgw_acl '; $sql .= "WHERE acl_appname = 'resources' "; diff --git a/resources/inc/class.so_resources.inc.php b/resources/inc/class.so_resources.inc.php index 950cc642a9..33ee498e8f 100755 --- a/resources/inc/class.so_resources.inc.php +++ b/resources/inc/class.so_resources.inc.php @@ -17,25 +17,26 @@ class 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'; } - /*! - @function search - @abstract searches db for rows matching searchcriteria and categories - @autor Cornelius Weiß - @discussion '*' is replaced with sql-wildcard '%' - @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 $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 string $order_by fieldnames + {ASC|DESC} separated by colons ',' - @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'] - - @return int number of matching rows - */ + /** + * searches db for rows matching searchcriteria and categories + * + * Cornelius Wei� + * '*' is replaced with sql-wildcard '%' + * @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 $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 string $order_by fieldnames + {ASC|DESC} separated by colons ',' + * @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['egw_info']['user']['preferences']['common']['maxmatchs'] + * + * @return int number of matching rows + */ function search($criteria,$cats,&$data,$accessory_of=-1,$order_by='',$offset=false,$num_rows=-1) { $select = implode(',',array_keys($data[0])); @@ -48,7 +49,7 @@ class so_resources $where .= " ) "; 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 ? " ) " : ""; $whereacc = " AND (accessory_of ='".$accessory_of."')"; @@ -63,7 +64,7 @@ class so_resources } 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) { @@ -73,81 +74,56 @@ class so_resources return $nr; } - /*! - @function get_value - @abstract gets the value of $key from resource of $id - @autor Cornelius Weiß - @param string $key key of value to get - @param int $id resource id - @return mixed value of key and resource, false if key or id not found. - */ + /** + * gets the value of $key from resource of $id + * + * Cornelius Wei� + * @param string $key key of value to get + * @param int $id resource id + * @return mixed value of key and resource, false if key or id not found. + */ 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(); - (array)$value = $this->db->row(); + $value = $this->db->row(row); return $value[$key]; } return false; } function delete($id) - { - $this->db->delete($this->rs_table,$id,__LINE__,__FILE__); - return true; - } + { + $this->db->delete($this->rs_table,$id,__LINE__,__FILE__); + return true; + } - /*! - @function read - @abstract reads a resource exept binary datas - @autor Cornelius Weiß - @param int $id resource id - @return array with key => value or false if not found - */ + /** + * reads a resource exept binary datas + * + * Cornelius Wei� + * @param int $id resource id + * @return array with key => value or false if not found + */ function read($id) { - $tabledef = $this->db->metadata($table=$this->rs_table,$full=false); - foreach($tabledef as $n => $fielddef) + if($this->db->select($this->rs_table,'*',array('id' => $id),__LINE__,__FILE__)) { - if(!$fielddef['binary']) - { - $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 $this->db->row(true); } return false; } - /*! - @function save - @abstract saves a resource including binary datas - @autor Cornelius Weiß - @param array $resource key => value - @return mixed id of resource if all right, false if fale - */ + /** + * saves a resource including binary datas + * + * Cornelius Wei� + * @param array $resource key => value + * @return mixed id of resource if all right, false if fale + */ function save($resource) { - $where = array('id' => $resource['id']); - - $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; + 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; } } diff --git a/resources/inc/class.ui_acl.inc.php b/resources/inc/class.ui_acl.inc.php index bc309772cf..69067f966c 100755 --- a/resources/inc/class.ui_acl.inc.php +++ b/resources/inc/class.ui_acl.inc.php @@ -28,9 +28,9 @@ function ui_acl() { - $this->bo = createobject('resources.bo_acl',True); - $this->accounts = $GLOBALS['phpgw']->accounts->get_list(); - $this->nextmatchs = createobject('phpgwapi.nextmatchs'); + $this->bo =& createobject('resources.bo_acl',True); + $this->accounts = $GLOBALS['egw']->accounts->get_list(); + $this->nextmatchs =& createobject('phpgwapi.nextmatchs'); $this->start = $this->bo->start; $this->query = $this->bo->query; $this->order = $this->bo->order; @@ -40,17 +40,17 @@ function acllist() { - if (!$GLOBALS['phpgw']->acl->check('run',1,'admin')) + if (!$GLOBALS['egw']->acl->check('run',1,'admin')) { $this->deny(); } 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(); if ($_POST['btnSave']) @@ -61,10 +61,10 @@ } } - $GLOBALS['phpgw']->template->set_file('acl', 'acl.tpl'); - $GLOBALS['phpgw']->template->set_block('acl','cat_list','Cblock'); - $GLOBALS['phpgw']->template->set_var(array( - 'title' => $GLOBALS['phpgw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'), + $GLOBALS['egw']->template->set_file('acl', 'acl.tpl'); + $GLOBALS['egw']->template->set_block('acl','cat_list','Cblock'); + $GLOBALS['egw']->template->set_var(array( + 'title' => $GLOBALS['egw_info']['apps']['resources']['title'] . ' - ' . lang('Configure Access Permissions'), 'lang_search' => lang('Search'), 'lang_save' => lang('Save'), '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'); $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, 'right' => $right, '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( $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']); $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, 'catname' => $cat['name'], 'catid' => $cat['id'], - 'read' => $this->selectlist(PHPGW_ACL_READ), - 'write' => $this->selectlist(PHPGW_ACL_ADD), - 'book' =>$this->selectlist(PHPGW_ACL_DIRECT_BOOKING), - 'admin' => ''.$this->selectlist(PHPGW_ACL_CAT_ADMIN,true) + 'read' => $this->selectlist(EGW_ACL_READ), + 'write' => $this->selectlist(EGW_ACL_ADD), + 'book' =>$this->selectlist(EGW_ACL_DIRECT_BOOKING), + 'admin' => ''.$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) @@ -117,7 +117,7 @@ if(!($users_only && $account['account_lastname'] == 'Group')) { $selectlist .= '