forked from extern/egroupware
- rework storage layer to so_sql
- some bugfixes
This commit is contained in:
parent
9cc02bf68b
commit
8d96b0c05a
@ -19,6 +19,7 @@ class bo_resources
|
|||||||
var $pictures_dir = '/resources/pictures/';
|
var $pictures_dir = '/resources/pictures/';
|
||||||
var $thumbs_dir = '/resources/pictures/thumbs/';
|
var $thumbs_dir = '/resources/pictures/thumbs/';
|
||||||
var $resource_icons = '/resources/templates/default/images/resource_icons/';
|
var $resource_icons = '/resources/templates/default/images/resource_icons/';
|
||||||
|
var $debug = 0;
|
||||||
|
|
||||||
function bo_resources()
|
function bo_resources()
|
||||||
{
|
{
|
||||||
@ -43,14 +44,22 @@ class bo_resources
|
|||||||
*/
|
*/
|
||||||
function get_rows($query,&$rows,&$readonlys)
|
function get_rows($query,&$rows,&$readonlys)
|
||||||
{
|
{
|
||||||
|
if ($this->debug) _debug_array($query);
|
||||||
$query['search'] = $query['search'] ? $query['search'] : '*';
|
$query['search'] = $query['search'] ? $query['search'] : '*';
|
||||||
$criteria = array('name' => $query['search'], 'short_description' => $query['search']);
|
$criteria = array('name' => $query['search'], 'short_description' => $query['search']);
|
||||||
$read_onlys = 'id,name,short_description,quantity,useable,bookable,buyable,cat_id,location';
|
$read_onlys = 'id,name,short_description,quantity,useable,bookable,buyable,cat_id,location';
|
||||||
|
|
||||||
$accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1;
|
$accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1;
|
||||||
$filter = array('accessory_of' => $accessory_of);
|
$filter = array('accessory_of' => $accessory_of);
|
||||||
|
if ($query['filter'])
|
||||||
|
{
|
||||||
|
$filter = $filter + array('cat_id' => $query['filter']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$readcats = array_flip((array)$this->acl->get_cats(EGW_ACL_READ));
|
$readcats = array_flip((array)$this->acl->get_cats(EGW_ACL_READ));
|
||||||
if($readcats) $filter = $filter + array('cat_id' => $readcats);
|
if($readcats) $filter = $filter + array('cat_id' => $readcats);
|
||||||
|
}
|
||||||
if($query['show_bookable']) $filter = $filter + array('bookable' => true);
|
if($query['show_bookable']) $filter = $filter + array('bookable' => true);
|
||||||
$order_by = $query['order'] ? $query['order'].' '. $query['sort'] : '';
|
$order_by = $query['order'] ? $query['order'].' '. $query['sort'] : '';
|
||||||
$start = (int)$query['start'];
|
$start = (int)$query['start'];
|
||||||
@ -119,7 +128,7 @@ class bo_resources
|
|||||||
echo lang('Notify your administrator to correct this situation') . '<br>';
|
echo lang('Notify your administrator to correct this situation') . '<br>';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $this->so->read($id);
|
return $this->so->read(array('id' => $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -298,7 +307,7 @@ class bo_resources
|
|||||||
{
|
{
|
||||||
if (!is_array($resource) && $resource > 0)
|
if (!is_array($resource) && $resource > 0)
|
||||||
{
|
{
|
||||||
$resource = $this->so->read($resource);
|
$resource = $this->so->read(array('id' => $resource));
|
||||||
$title = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':'');
|
$title = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':'');
|
||||||
}
|
}
|
||||||
return $title ? $title : false;
|
return $title ? $title : false;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* option) any later version. *
|
* option) any later version. *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
/* $Id: */
|
/* $Id$ */
|
||||||
include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
|
include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
|
||||||
|
|
||||||
class so_resources extends so_sql
|
class so_resources extends so_sql
|
||||||
@ -19,22 +19,23 @@ class so_resources extends so_sql
|
|||||||
function so_resources()
|
function so_resources()
|
||||||
{
|
{
|
||||||
$this->so_sql('resources','egw_resources');
|
$this->so_sql('resources','egw_resources');
|
||||||
$this->db = clone($GLOBALS['egw']->db);
|
|
||||||
$this->db->set_app('resources');
|
// $this->db = clone($GLOBALS['egw']->db);
|
||||||
$this->rs_table = 'egw_resources';
|
// $this->db->set_app('resources');
|
||||||
|
// $this->rs_table = 'egw_resources';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the value of $key from resource of $id
|
* gets the value of $key from resource of $id
|
||||||
*
|
*
|
||||||
* Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
* Cornelius Weiss <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->select($this->rs_table,$key,array('id' => $id),__LINE__,__FILE__))
|
if($this->db->select($this->table_name,$key,array('id' => $id),__LINE__,__FILE__))
|
||||||
{
|
{
|
||||||
$value = $this->db->row(row);
|
$value = $this->db->row(row);
|
||||||
return $value[$key];
|
return $value[$key];
|
||||||
@ -42,38 +43,17 @@ class so_resources extends so_sql
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($id)
|
|
||||||
{
|
|
||||||
$this->db->delete($this->rs_table,$id,__LINE__,__FILE__);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* reads a resource exept binary datas
|
|
||||||
*
|
|
||||||
* Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
|
||||||
* @param int $id resource id
|
|
||||||
* @return array with key => value or false if not found
|
|
||||||
*/
|
|
||||||
function read($id)
|
|
||||||
{
|
|
||||||
if($this->db->select($this->rs_table,'*',array('id' => $id),__LINE__,__FILE__))
|
|
||||||
{
|
|
||||||
return $this->db->row(true);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* saves a resource including binary datas
|
* saves a resource including binary datas
|
||||||
*
|
*
|
||||||
* Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
* Cornelius Weiss <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)
|
||||||
{
|
{
|
||||||
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;
|
$this->data = $resource;
|
||||||
|
return parent::save() == 0 ? $this->data['id'] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -90,13 +90,9 @@ class ui_resources
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$msg = $content;
|
$msg = $content;
|
||||||
$content = array();
|
$content = array();
|
||||||
$content['msg'] = $msg;
|
$content['msg'] = $msg;
|
||||||
$content['nm'] = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
|
|
||||||
}
|
|
||||||
|
|
||||||
$content['nm']['header_left'] = 'resources.resource_select.header';
|
$content['nm']['header_left'] = 'resources.resource_select.header';
|
||||||
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
||||||
@ -107,6 +103,10 @@ class ui_resources
|
|||||||
$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;
|
||||||
|
$content['nm']['order'] = 'name';
|
||||||
|
$content['nm']['sort'] = 'ASC';
|
||||||
|
$content['nm'] = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
|
||||||
|
|
||||||
|
|
||||||
// check if user is permitted to add resources
|
// check if user is permitted to add resources
|
||||||
if(!$this->bo->acl->get_cats(EGW_ACL_ADD))
|
if(!$this->bo->acl->get_cats(EGW_ACL_ADD))
|
||||||
@ -119,7 +119,7 @@ class ui_resources
|
|||||||
|
|
||||||
if($content['nm']['view_accs_of'])
|
if($content['nm']['view_accs_of'])
|
||||||
{
|
{
|
||||||
$master = $this->bo->so->read($content['nm']['view_accs_of']);
|
$master = $this->bo->so->read(array('id' => $content['nm']['view_accs_of']));
|
||||||
$content['view_accs_of'] = $content['nm']['view_accs_of'];
|
$content['view_accs_of'] = $content['nm']['view_accs_of'];
|
||||||
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
||||||
$content['nm']['no_filter'] = true;
|
$content['nm']['no_filter'] = true;
|
||||||
@ -198,6 +198,7 @@ class ui_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;
|
||||||
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
|
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
|
||||||
|
$content['accessory_of'] = $accessory_of;
|
||||||
|
|
||||||
$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(EGW_ACL_ADD);
|
$sel_options['cat_id'] = $this->bo->acl->get_cats(EGW_ACL_ADD);
|
||||||
|
Loading…
Reference in New Issue
Block a user