mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-30 17:58:39 +01:00
started switching so-layer to so_sql(etemplate)
created first calender hooks
This commit is contained in:
parent
7679d73df0
commit
405cdee6d1
@ -43,24 +43,17 @@ class bo_resources
|
||||
|
||||
$criteria = array( 'name' => $query['search'],
|
||||
'short_description' => $query['search']
|
||||
);
|
||||
$cats = $query['filter'] ? array($query['filter'] => '') : $this->acl->get_cats(EGW_ACL_READ);
|
||||
); echo($query['filter']);
|
||||
$accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1;
|
||||
$filter = array('cat_id' => ($query['filter'] ? $query['filter'] : array_flip($this->acl->get_cats(EGW_ACL_READ))),'accessory_of' => $accessory_of);
|
||||
|
||||
$rows = array( 0 => array( 'id' => '',
|
||||
'name' => '',
|
||||
'short_description' => '',
|
||||
'quantity' => '',
|
||||
'useable' => '',
|
||||
'bookable' => '',
|
||||
'buyable' => '',
|
||||
'cat_id' => '',
|
||||
'location' => ''
|
||||
));
|
||||
$read_onlys = 'id,name,short_description,quantity,useable,bookable,buyable,cat_id,location';
|
||||
|
||||
$order_by = $query['order'] ? $query['order'].' '. $query['sort'] : '';
|
||||
$start = (int)$query['start'];
|
||||
|
||||
$nr = $this->so->search($criteria,$cats,$rows,$accessory_of,$order_by,$offset=$query['start'],$num_rows=0);
|
||||
$rows = $this->so->search($criteria,$read_onlys,$order_by,$extra_cols='',$wildcard='',$empty=False,$op='OR',$start,$filter,$join='',$need_full_no_count=false);
|
||||
$nr = $this->so->total;
|
||||
|
||||
foreach($rows as $num => $resource)
|
||||
{
|
||||
@ -222,16 +215,38 @@ class bo_resources
|
||||
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);
|
||||
$data = $this->so->search('','id,name','','','','','',$start,array('accessory_of' => $id),'',$need_full_no_count=true);
|
||||
foreach($data as $num => $resource)
|
||||
{
|
||||
$acc_list[$resource['id']] = $resource['name'];
|
||||
}
|
||||
return $acc_list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns info about resource for calender
|
||||
* @author Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
||||
* @param int/array $res_id single id or array $num => $res_id
|
||||
* @return array
|
||||
*/
|
||||
function get_calender_info($res_id)
|
||||
{
|
||||
if($id < 1) return;
|
||||
$data[0] = array('name' => '', 'useable' => '');
|
||||
foreach($res_id as $num => $id)
|
||||
{
|
||||
|
||||
}
|
||||
// $cats = array_flip($this->acl->get_cats(EGW_ACL_READ));
|
||||
$this->so->search(array('name' => '*'),false,$data,-1,$order_by='',$offset=false,$num_rows=-1);
|
||||
|
||||
if(is_array($res_id))
|
||||
{
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
||||
* query infolog for entries matching $pattern
|
||||
@ -239,11 +254,9 @@ class bo_resources
|
||||
*/
|
||||
function link_query( $pattern )
|
||||
{
|
||||
$criteria = array('name' => $pattern,'short_description' => $pattern);
|
||||
$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);
|
||||
|
||||
$criteria = array('name' => $pattern, 'short_description' => $pattern);
|
||||
$only_keys = 'id,name,short_description';
|
||||
$data = $this->so->search($criteria,$only_keys,$order_by='',$extra_cols='',$wildcard='%',$empty,$op='OR');
|
||||
foreach($data as $num => $resource)
|
||||
{
|
||||
if($num != 0)
|
||||
|
@ -3,7 +3,7 @@
|
||||
* eGroupWare - resources hooks *
|
||||
* http://www.eGroupWare.org *
|
||||
* Originally written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
||||
* Changes for resources by Cornelius Weiß <egw@von-und-zu-weiss.de> *
|
||||
* Changes for resources by Cornelius Wei<EFBFBD><egw@von-und-zu-weiss.de> *
|
||||
* *
|
||||
* ------------------------------------------------------- *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
@ -76,13 +76,19 @@ class resources_hooks
|
||||
}
|
||||
function search_link($args)
|
||||
{
|
||||
$appname = 'resources';
|
||||
return array( 'query' => 'resources.bo_resources.link_query',
|
||||
'title' => 'resources.bo_resources.link_title',
|
||||
'view' => array('menuaction' => 'resources.ui_resources.view'),
|
||||
'view_id' => 'id'
|
||||
);
|
||||
}
|
||||
|
||||
function calender_resources($args)
|
||||
{
|
||||
return $args['type'] =='r' ? array( 'select_template' => 'resources.resource_selectbox',
|
||||
'info' => 'resources.bo_resources.get_calender_info',
|
||||
) : false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -12,68 +12,18 @@
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id: */
|
||||
include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
|
||||
|
||||
class so_resources
|
||||
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';
|
||||
}
|
||||
|
||||
/**
|
||||
* searches db for rows matching searchcriteria and categories
|
||||
*
|
||||
* Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
||||
* '*' 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]));
|
||||
foreach($criteria as $col => $value)
|
||||
{
|
||||
$where .= ($where ? " OR " : " ( " ). $col . ((strstr($value,'*') || strstr($value,'*')) ?
|
||||
" LIKE '" . strtr(str_replace('_','\\_',addslashes($value)),'*?','%_') ."'":
|
||||
"='" .$value."'");
|
||||
}
|
||||
$where .= " ) ";
|
||||
foreach ((array)$cats as $cat_id => $cat_name)
|
||||
{
|
||||
$wherecats .= ($wherecats ? " OR " : " AND ( " ) .'cat_id' . "=".(int)$cat_id;
|
||||
}
|
||||
$wherecats .= $wherecats ? " ) " : "";
|
||||
$whereacc = " AND (accessory_of ='".$accessory_of."')";
|
||||
|
||||
$this->db->query( 'SELECT '.$select." FROM ".$this->rs_table." WHERE ".$where.$wherecats.$whereacc.
|
||||
($order_by != '' ? " ORDER BY $order_by" : ''),__LINE__,__FILE__);
|
||||
|
||||
$nr = $this->db->nf();
|
||||
if($offset > 0 && $nr > $offset)
|
||||
{
|
||||
$this->db->seek($offset-1);
|
||||
}
|
||||
if($num_rows==0)
|
||||
{
|
||||
$num_rows = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
|
||||
}
|
||||
for ($n = 1; $this->db->next_record() && $n!=$num_rows+1; ++$n)
|
||||
{
|
||||
$data[$n] = $this->db->row();
|
||||
}
|
||||
unset($data[0]);
|
||||
return $nr;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the value of $key from resource of $id
|
||||
*
|
||||
|
@ -33,6 +33,7 @@
|
||||
$setup_info['resources']['hooks']['admin'] = 'resources.resources_hooks.admin_prefs_sidebox';
|
||||
$setup_info['resources']['hooks']['sidebox_menu'] = 'resources.resources_hooks.admin_prefs_sidebox';
|
||||
$setup_info['resources']['hooks']['search_link'] = 'resources.resources_hooks.search_link';
|
||||
$setup_info['resources']['hooks']['calender_resources'] = 'resources.resources_hooks.calender_resources';
|
||||
// $setup_info['resources']['hooks'][] = 'home';
|
||||
// $setup_info['resources']['hooks'][] = 'settings';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user