diff --git a/resources/inc/class.bo_resources.inc.php b/resources/inc/class.bo_resources.inc.php
index 03fbe52c7e..80dc0fb67a 100755
--- a/resources/inc/class.bo_resources.inc.php
+++ b/resources/inc/class.bo_resources.inc.php
@@ -19,6 +19,7 @@ class bo_resources
var $pictures_dir = '/resources/pictures/';
var $thumbs_dir = '/resources/pictures/thumbs/';
var $resource_icons = '/resources/templates/default/images/resource_icons/';
+ var $debug = 0;
function bo_resources()
{
@@ -43,14 +44,22 @@ class bo_resources
*/
function get_rows($query,&$rows,&$readonlys)
{
+ if ($this->debug) _debug_array($query);
$query['search'] = $query['search'] ? $query['search'] : '*';
$criteria = array('name' => $query['search'], 'short_description' => $query['search']);
$read_onlys = 'id,name,short_description,quantity,useable,bookable,buyable,cat_id,location';
$accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1;
$filter = array('accessory_of' => $accessory_of);
- $readcats = array_flip((array)$this->acl->get_cats(EGW_ACL_READ));
- if($readcats) $filter = $filter + array('cat_id' => $readcats);
+ if ($query['filter'])
+ {
+ $filter = $filter + array('cat_id' => $query['filter']);
+ }
+ else
+ {
+ $readcats = array_flip((array)$this->acl->get_cats(EGW_ACL_READ));
+ if($readcats) $filter = $filter + array('cat_id' => $readcats);
+ }
if($query['show_bookable']) $filter = $filter + array('bookable' => true);
$order_by = $query['order'] ? $query['order'].' '. $query['sort'] : '';
$start = (int)$query['start'];
@@ -119,7 +128,7 @@ class bo_resources
echo lang('Notify your administrator to correct this situation') . '
';
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)
{
- $resource = $this->so->read($resource);
+ $resource = $this->so->read(array('id' => $resource));
$title = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':'');
}
return $title ? $title : false;
diff --git a/resources/inc/class.so_resources.inc.php b/resources/inc/class.so_resources.inc.php
index 02c527a310..c50e8364d8 100755
--- a/resources/inc/class.so_resources.inc.php
+++ b/resources/inc/class.so_resources.inc.php
@@ -11,7 +11,7 @@
* option) any later version. *
\**************************************************************************/
- /* $Id: */
+ /* $Id$ */
include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
class so_resources extends so_sql
@@ -19,22 +19,23 @@ class so_resources extends so_sql
function so_resources()
{
$this->so_sql('resources','egw_resources');
- $this->db = clone($GLOBALS['egw']->db);
- $this->db->set_app('resources');
- $this->rs_table = 'egw_resources';
+
+// $this->db = clone($GLOBALS['egw']->db);
+// $this->db->set_app('resources');
+// $this->rs_table = 'egw_resources';
}
/**
* gets the value of $key from resource of $id
*
- * Cornelius Wei�
+ * Cornelius Weiss
* @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->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);
return $value[$key];
@@ -42,38 +43,17 @@ class so_resources extends so_sql
return false;
}
- function delete($id)
- {
- $this->db->delete($this->rs_table,$id,__LINE__,__FILE__);
- return true;
- }
-
/**
- * 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)
- {
- 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
- *
- * 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 Weiss
+ * @param array $resource key => value
+ * @return mixed id of resource if all right, false if fale
*/
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;
}
}
diff --git a/resources/inc/class.ui_resources.inc.php b/resources/inc/class.ui_resources.inc.php
index 74fa3c1918..7b040ab95c 100755
--- a/resources/inc/class.ui_resources.inc.php
+++ b/resources/inc/class.ui_resources.inc.php
@@ -50,7 +50,7 @@ class ui_resources
*/
function index($content='')
{
-// _debug_array($content);
+// _debug_array($content);
if (is_array($content))
{
$sessiondata = $content['nm'];
@@ -90,13 +90,9 @@ class ui_resources
}
}
}
- else
- {
- $msg = $content;
- $content = array();
- $content['msg'] = $msg;
- $content['nm'] = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
- }
+ $msg = $content;
+ $content = array();
+ $content['msg'] = $msg;
$content['nm']['header_left'] = 'resources.resource_select.header';
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
@@ -107,6 +103,10 @@ class ui_resources
$content['nm']['no_filter2'] = true;
$content['nm']['filter_no_lang'] = 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
if(!$this->bo->acl->get_cats(EGW_ACL_ADD))
@@ -119,7 +119,7 @@ class ui_resources
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['nm']['get_rows'] = 'resources.bo_resources.get_rows';
$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['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
+ $content['accessory_of'] = $accessory_of;
$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
$sel_options['cat_id'] = $this->bo->acl->get_cats(EGW_ACL_ADD);