mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
use new vfs end egw_link class
This commit is contained in:
parent
a5b58e57e8
commit
b484528188
@ -1,4 +0,0 @@
|
||||
|
||||
pictures are stored in vfs.
|
||||
Thus eTemplate can't read pictures from vfs yet, u need to create a symlink into your resources directory!
|
||||
ln -s {outside-doc-root-path}/resources/pictures {egroupware-base-dir}/resources
|
@ -29,18 +29,14 @@ class bo_resources
|
||||
* @var so_resources
|
||||
*/
|
||||
var $so;
|
||||
|
||||
|
||||
function bo_resources()
|
||||
{
|
||||
$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('phpgwapi.bolink');
|
||||
$this->conf =& CreateObject('phpgwapi.config');
|
||||
$this->conf->read_repository();
|
||||
|
||||
$this->cal_right_transform = array(
|
||||
|
||||
$this->cal_right_transform = array(
|
||||
EGW_ACL_CALREAD => EGW_ACL_READ,
|
||||
EGW_ACL_DIRECT_BOOKING => EGW_ACL_READ | EGW_ACL_ADD | EGW_ACL_EDIT | EGW_ACL_DELETE,
|
||||
EGW_ACL_CAT_ADMIN => EGW_ACL_READ | EGW_ACL_ADD | EGW_ACL_EDIT | EGW_ACL_DELETE,
|
||||
@ -58,7 +54,7 @@ class bo_resources
|
||||
$query['search'] = $query['search'] ? $query['search'] : '*';
|
||||
$criteria = array('name' => $query['search'], 'short_description' => $query['search'], 'inventory_number' => $query['search']);
|
||||
$read_onlys = 'res_id,name,short_description,quantity,useable,bookable,buyable,cat_id,location,storage_info';
|
||||
|
||||
|
||||
$accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1;
|
||||
$filter = array('accessory_of' => $accessory_of);
|
||||
if ($query['filter'])
|
||||
@ -73,10 +69,10 @@ class bo_resources
|
||||
if($query['show_bookable']) $filter = $filter + array('bookable' => true);
|
||||
$order_by = $query['order'] ? $query['order'].' '. $query['sort'] : '';
|
||||
$start = (int)$query['start'];
|
||||
|
||||
|
||||
$rows = $this->so->search($criteria,$read_onlys,$order_by,'','%',$empty=False,$op='OR',$start,$filter,$join='',$need_full_no_count=false);
|
||||
$nr = $this->so->total;
|
||||
|
||||
|
||||
// we are called to serve bookable resources (e.g. calendar-dialog)
|
||||
if($query['show_bookable'])
|
||||
{
|
||||
@ -88,7 +84,7 @@ class bo_resources
|
||||
// we don't need all the following testing
|
||||
return $nr;
|
||||
}
|
||||
|
||||
|
||||
foreach((array)$rows as $num => $resource)
|
||||
{
|
||||
if (!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_EDIT))
|
||||
@ -117,7 +113,7 @@ class bo_resources
|
||||
$readonlys["buyable[$resource[res_id]]"] = true;
|
||||
}
|
||||
$readonlys["view_acc[$resource[res_id]]"] = true;
|
||||
$links = $this->link->get_links('resources',$resource['res_id']);
|
||||
$links = egw_link::get_links('resources',$resource['res_id']);
|
||||
if(count($links) != 0 && $accessory_of == -1)
|
||||
{
|
||||
foreach ($links as $link_num => $link)
|
||||
@ -154,7 +150,7 @@ class bo_resources
|
||||
}
|
||||
return $this->so->read(array('res_id' => $res_id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* saves a resource. pictures are saved in vfs
|
||||
*
|
||||
@ -168,7 +164,7 @@ class bo_resources
|
||||
{
|
||||
return lang('You are not permitted to edit this reource!');
|
||||
}
|
||||
|
||||
|
||||
// we need an id to save pictures and make links...
|
||||
if(!$resource['res_id'])
|
||||
{
|
||||
@ -178,13 +174,12 @@ class bo_resources
|
||||
switch ($resource['picture_src'])
|
||||
{
|
||||
case 'own_src':
|
||||
$vfs_data = array('string' => $this->pictures_dir.$resource['res_id'].'.jpg','relatives' => array(RELATIVE_ROOT));
|
||||
if($resource['own_file']['size'] > 0)
|
||||
{
|
||||
$msg = $this->save_picture($resource['own_file'],$resource['res_id']);
|
||||
break;
|
||||
}
|
||||
elseif($this->vfs->file_exists($vfs_data))
|
||||
elseif(@egw_vfs::stat($this->pictures_dir.$resource['res_id'].'.jpg'))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -210,7 +205,7 @@ class bo_resources
|
||||
{
|
||||
return $msg;
|
||||
}
|
||||
|
||||
|
||||
// delete old pictures
|
||||
if($resource['picture_src'] != 'own_src')
|
||||
{
|
||||
@ -220,13 +215,13 @@ class bo_resources
|
||||
// save links
|
||||
if(is_array($resource['link_to']['to_id']))
|
||||
{
|
||||
$this->link->link('resources',$resource['res_id'],$resource['link_to']['to_id']);
|
||||
egw_link::link('resources',$resource['res_id'],$resource['link_to']['to_id']);
|
||||
}
|
||||
if($resource['accessory_of'] != -1)
|
||||
{
|
||||
$this->link->link('resources',$resource['res_id'],'resources',$resource['accessory_of']);
|
||||
egw_link::link('resources',$resource['res_id'],'resources',$resource['accessory_of']);
|
||||
}
|
||||
|
||||
|
||||
if(!empty($resource['res_id']) && $this->so->get_value("cat_id",$resource['res_id']) != $resource['cat_id'] && $resource['accessory_of'] == -1)
|
||||
{
|
||||
$accessories = $this->get_acc_list($resource['res_id']);
|
||||
@ -238,7 +233,7 @@ class bo_resources
|
||||
$this->so->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->so->save($resource) ? false : lang('Something went wrong by saving resource');
|
||||
}
|
||||
|
||||
@ -254,18 +249,18 @@ class bo_resources
|
||||
{
|
||||
return lang('You are not permitted to delete this reource!');
|
||||
}
|
||||
|
||||
|
||||
if ($this->so->delete(array('res_id'=>$res_id)))
|
||||
{
|
||||
$this->remove_picture($res_id);
|
||||
$this->link->unlink(0,'resources',$res_id);
|
||||
egw_link::unlink(0,'resources',$res_id);
|
||||
// delete the resource from the calendar
|
||||
ExecMethod('calendar.socal.change_delete_user','r'.$res_id);
|
||||
return false;
|
||||
}
|
||||
return lang('Something went wrong by deleting resource');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gets list of accessories for resource
|
||||
*
|
||||
@ -283,12 +278,12 @@ class bo_resources
|
||||
}
|
||||
return $acc_list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns info about resource for calender
|
||||
* @author Cornelius Weiss<egw@von-und-zu-weiss.de>
|
||||
* @param int/array $res_id single id or array $num => $res_id
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
function get_calendar_info($res_id)
|
||||
{
|
||||
@ -296,7 +291,7 @@ class bo_resources
|
||||
if(!is_array($res_id) && $res_id < 1) return;
|
||||
|
||||
$data = $this->so->search(array('res_id' => $res_id),'res_id,cat_id,name,useable');
|
||||
|
||||
|
||||
foreach($data as $num => $resource)
|
||||
{
|
||||
$data[$num]['rights'] = false;
|
||||
@ -311,12 +306,12 @@ class bo_resources
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns status for a new calendar entry depending on resources ACL
|
||||
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||
* @param int $res_id single id
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
function get_calendar_new_status($res_id)
|
||||
{
|
||||
@ -324,7 +319,7 @@ class bo_resources
|
||||
if($data[0]['bookable'] == 0) return 'x';
|
||||
return $this->acl->is_permitted($data[0]['cat_id'],EGW_ACL_DIRECT_BOOKING) ? A : U;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||
* query infolog for entries matching $pattern
|
||||
@ -345,7 +340,7 @@ class bo_resources
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||
* get title for an infolog entry identified by $res_id
|
||||
@ -362,7 +357,7 @@ class bo_resources
|
||||
|
||||
return $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':'');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* resizes and saves an pictures in vfs
|
||||
*
|
||||
@ -371,22 +366,17 @@ class bo_resources
|
||||
* @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
|
||||
$vfs_data = array('string'=>$this->vfs_basedir,'relatives'=>array(RELATIVE_ROOT));
|
||||
if (!($this->vfs->file_exists($vfs_data)))
|
||||
if (!is_dir(egw_vfs::PREFIX.$this->vfs_basedir))
|
||||
{
|
||||
$this->vfs->override_acl = 1;
|
||||
$this->vfs->mkdir($vfs_data);
|
||||
$vfs_data['string'] = $this->pictures_dir;
|
||||
$this->vfs->mkdir($vfs_data);
|
||||
$vfs_data['string'] = $this->thumbs_dir;
|
||||
$this->vfs->mkdir($vfs_data);
|
||||
$this->vfs->override_acl = 0;
|
||||
egw_vfs::$is_root = true;
|
||||
egw_vfs::mkdir($this->pictures_dir,0777,STREAM_MKDIR_RECURSIVE);
|
||||
egw_vfs::mkdir($this->thumbs_dir,0777,STREAM_MKDIR_RECURSIVE);
|
||||
egw_vfs::$is_root = false;
|
||||
}
|
||||
|
||||
switch($file['type'])
|
||||
{
|
||||
case 'image/gif':
|
||||
@ -403,11 +393,11 @@ class bo_resources
|
||||
default:
|
||||
return lang('Picture type is not supported, sorry!');
|
||||
}
|
||||
|
||||
|
||||
$src_img_size = getimagesize($file['tmp_name']);
|
||||
$dst_img_size = array( 0 => 320, 1 => 240);
|
||||
$thumb_size = array( 0 => 64, 1 => 48);
|
||||
|
||||
|
||||
$tmp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/';
|
||||
if($src_img_size[0] > 64 || $src_img_size[1] > 48)
|
||||
{
|
||||
@ -436,38 +426,13 @@ class bo_resources
|
||||
imagejpeg($src_img,$tmp_dir.$resouce_id.'.thumb.jpg');
|
||||
}
|
||||
imagedestroy($src_img);
|
||||
|
||||
$this->vfs->override_acl = 1;
|
||||
$this->vfs->cp(array(
|
||||
'from' => $tmp_dir.$resouce_id.'.jpg',
|
||||
'to' => $this->pictures_dir.$resouce_id.'.jpg',
|
||||
'relatives' => array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT)
|
||||
));
|
||||
$this->vfs->set_attributes(array(
|
||||
'string' => $this->pictures_dir.$resouce_id.'.jpg',
|
||||
'relatives' => array (RELATIVE_ROOT),
|
||||
'attributes' => array (
|
||||
'mime_type' => 'image/jpeg',
|
||||
'comment' => 'picture of resource no.'.$resouce_id,
|
||||
'app' => $GLOBALS['egw_info']['flags']['currentapp']
|
||||
)));
|
||||
$this->vfs->cp(array(
|
||||
'from' => $tmp_dir.$resouce_id.'.thumb.jpg',
|
||||
'to' => $this->thumbs_dir.$resouce_id.'.jpg',
|
||||
'relatives' => array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT)
|
||||
));
|
||||
$this->vfs->set_attributes(array(
|
||||
'string' => $this->thumbs_dir.$resouce_id.'.jpg',
|
||||
'relatives' => array (RELATIVE_ROOT),
|
||||
'attributes' => array (
|
||||
'mime_type' => 'image/jpeg',
|
||||
'comment' => 'thumbnail of resource no.'.$resouce_id,
|
||||
'app' => $GLOBALS['egw_info']['flags']['currentapp']
|
||||
)));
|
||||
$this->vfs->override_acl = 0;
|
||||
return;
|
||||
|
||||
egw_vfs::$is_root = true;
|
||||
copy($tmp_dir.$resouce_id.'.jpg',egw_vfs::PREFIX.$this->pictures_dir.$resouce_id.'.jpg');
|
||||
copy($tmp_dir.$resouce_id.'.thumb.jpg',egw_vfs::PREFIX.$this->thumbs_dir.$resouce_id.'.jpg');
|
||||
egw_vfs::$is_root = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get resource picture either from vfs or from symlink
|
||||
* Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||
@ -484,8 +449,7 @@ class bo_resources
|
||||
switch($src)
|
||||
{
|
||||
case 'own_src':
|
||||
$picture = $this->conf->config_data['dont_use_vfs'] ? $GLOBALS['egw_info']['server']['webserver_url'] : 'vfs:';
|
||||
$picture .= $size ? $this->pictures_dir.$res_id.'.jpg' : $this->thumbs_dir.$res_id.'.jpg';
|
||||
$picture = egw::link(egw_vfs::download_url($size ? $this->pictures_dir.$res_id.'.jpg' : $this->thumbs_dir.$res_id.'.jpg'));
|
||||
break;
|
||||
case 'cat_src':
|
||||
list($picture) = $this->cats->return_single($this->so->get_value('cat_id',$res_id));
|
||||
@ -502,7 +466,7 @@ class bo_resources
|
||||
}
|
||||
return $picture;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove_picture
|
||||
* removes picture from vfs
|
||||
@ -513,15 +477,10 @@ class bo_resources
|
||||
*/
|
||||
function remove_picture($res_id)
|
||||
{
|
||||
$vfs_data = array('string' => $this->pictures_dir.$res_id.'.jpg','relatives' => array(RELATIVE_ROOT));
|
||||
$this->vfs->override_acl = 1;
|
||||
if($this->vfs->file_exists($vfs_data))
|
||||
{
|
||||
$this->vfs->rm($vfs_data);
|
||||
$vfs_data['string'] = $this->thumbs_dir.$res_id.'.jpg';
|
||||
$this->vfs->rm($vfs_data);
|
||||
}
|
||||
$this->vfs->override_acl = 0;
|
||||
egw_vfs::$is_root = true;
|
||||
egw_vfs::unlink($this->pictures_dir.$res_id.'.jpg');
|
||||
egw_vfs::unlink($this->thumbs_dir.$res_id.'.jpg');
|
||||
egw_vfs::$is_root = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,10 +20,10 @@ class resources_hooks
|
||||
function admin_prefs_sidebox($args)
|
||||
{
|
||||
$this->acl =& CreateObject('resources.bo_acl');
|
||||
|
||||
|
||||
$appname = 'resources';
|
||||
$location = is_array($args) ? $args['location'] : $args;
|
||||
|
||||
|
||||
if ($location == 'sidebox_menu')
|
||||
{
|
||||
$title = $GLOBALS['egw_info']['apps']['resources']['title'].' '.lang('Menu');
|
||||
@ -31,14 +31,14 @@ class resources_hooks
|
||||
'text' => lang('resources list'),
|
||||
'no_lang' => true,
|
||||
'link' => $GLOBALS['egw']->link('/index.php',array('menuaction' => 'resources.ui_resources.index' )),
|
||||
// 'icon' =>
|
||||
// 'icon' =>
|
||||
);
|
||||
|
||||
|
||||
if($this->acl->get_cats(EGW_ACL_ADD))
|
||||
{
|
||||
$file[] = array(
|
||||
'text' => '<a class="textSidebox" href="'.$GLOBALS['egw']->link('/index.php',array('menuaction' => 'resources.ui_resources.edit')).
|
||||
'" onclick="window.open(this.href,\'_blank\',\'dependent=yes,width=800,height=600,scrollbars=yes,status=yes\');
|
||||
'" onclick="window.open(this.href,\'_blank\',\'dependent=yes,width=800,height=600,scrollbars=yes,status=yes\');
|
||||
return false;">'.lang('add resource').'</a>',
|
||||
'no_lang' => true,
|
||||
'link' => false
|
||||
@ -48,7 +48,7 @@ class resources_hooks
|
||||
// 'text' => lang('planer'),
|
||||
// 'no_lang' => true,
|
||||
// 'link' => $GLOBALS['egw']->link('/index.php',array('menuaction' => 'resources.ui_calviews.planer' )),
|
||||
// 'icon' =>
|
||||
// 'icon' =>
|
||||
// );
|
||||
display_sidebox($appname,$title,$file);
|
||||
}
|
||||
@ -73,8 +73,6 @@ class resources_hooks
|
||||
if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences')
|
||||
{
|
||||
$file = Array(
|
||||
'Site configuration' => $GLOBALS['egw']->link('/index.php',array(
|
||||
'menuaction' => 'resources.ui_resources.admin' )),
|
||||
'Global Categories' => $GLOBALS['egw']->link('/index.php',array(
|
||||
'menuaction' => 'admin.uicategories.index',
|
||||
'appname' => $appname,
|
||||
@ -83,7 +81,6 @@ class resources_hooks
|
||||
'menuaction=resources.ui_acl.acllist'),
|
||||
'Custom Fields'=>$GLOBALS['egw']->link('/index.php',
|
||||
'menuaction=admin.customfields.edit&appname=resources'),
|
||||
// 'CSV-Import' => $GLOBALS['egw']->link('/infolog/csv_import.php')
|
||||
);
|
||||
if ($location == 'admin')
|
||||
{
|
||||
@ -95,7 +92,7 @@ class resources_hooks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function search_link($args)
|
||||
{
|
||||
return array(
|
||||
@ -110,20 +107,20 @@ class resources_hooks
|
||||
'menuaction' => 'resources.ui_resources.edit',
|
||||
),
|
||||
'add_app' => 'link_app',
|
||||
'add_id' => 'link_id',
|
||||
'add_id' => 'link_id',
|
||||
'add_popup' => '800x600',
|
||||
);
|
||||
}
|
||||
|
||||
function calendar_resources($args)
|
||||
{
|
||||
return array(
|
||||
return array(
|
||||
'widget' => 'resources_select',// widget to use for the selection of resources
|
||||
'info' => 'resources.bo_resources.get_calendar_info',// info method, returns array with id, type & name for a given id
|
||||
'max_quantity' => 'useable',// if set, key for max. quantity in array returned by info method
|
||||
'new_status' => 'resources.bo_resources.get_calendar_new_status',// method returning the status for new items, else 'U' is used
|
||||
'type' => 'r',// one char type-identifiy for this resources
|
||||
'icon' => 'calicon',//icon
|
||||
'icon' => 'calicon',//icon
|
||||
'participants_header' => lang('resources'), // header of participants from this type
|
||||
'cal_sidebox' => array(
|
||||
'menu_title' => lang('Select resources'),
|
||||
@ -132,5 +129,3 @@ class resources_hooks
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -22,7 +22,6 @@ class ui_resources
|
||||
'edit' => True,
|
||||
'show' => True,
|
||||
'select' => True,
|
||||
'admin' => True,
|
||||
'writeLangFile' => True
|
||||
);
|
||||
|
||||
@ -36,7 +35,7 @@ class ui_resources
|
||||
$this->tmpl = new etemplate('resources.show');
|
||||
$this->bo =& CreateObject('resources.bo_resources');
|
||||
// $this->calui = CreateObject('resources.ui_calviews');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +43,7 @@ class ui_resources
|
||||
*
|
||||
* Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||
* @param array $content content from eTemplate callback
|
||||
*
|
||||
*
|
||||
* FIXME don't translate cats in nextmach
|
||||
*/
|
||||
function index($content='')
|
||||
@ -54,7 +53,7 @@ class ui_resources
|
||||
$sessiondata = $content['nm'];
|
||||
unset($sessiondata['rows']);
|
||||
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
|
||||
|
||||
|
||||
if (isset($content['back']))
|
||||
{
|
||||
unset($sessiondata['view_accs_of']);
|
||||
@ -72,7 +71,7 @@ class ui_resources
|
||||
}
|
||||
return $this->index($msg);
|
||||
}
|
||||
|
||||
|
||||
foreach($content['nm']['rows'] as $row)
|
||||
{
|
||||
if(isset($row['delete']))
|
||||
@ -91,7 +90,7 @@ class ui_resources
|
||||
$msg = $content;
|
||||
$content = array();
|
||||
$content['msg'] = $msg;
|
||||
|
||||
|
||||
$content['nm']['header_left'] = 'resources.resource_select.header';
|
||||
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
||||
$content['nm']['no_filter'] = False;
|
||||
@ -103,14 +102,14 @@ class ui_resources
|
||||
$content['nm']['bottom_too'] = true;
|
||||
$content['nm']['order'] = 'name';
|
||||
$content['nm']['sort'] = 'ASC';
|
||||
|
||||
|
||||
$nm_session_data = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
|
||||
if($nm_session_data)
|
||||
{
|
||||
$content['nm'] = $nm_session_data;
|
||||
}
|
||||
$content['nm']['options-filter']= array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(EGW_ACL_READ);
|
||||
|
||||
|
||||
// check if user is permitted to add resources
|
||||
if(!$this->bo->acl->get_cats(EGW_ACL_ADD))
|
||||
{
|
||||
@ -119,12 +118,12 @@ class ui_resources
|
||||
$no_button['back'] = true;
|
||||
$no_button['add_sub'] = true;
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('resources');
|
||||
|
||||
|
||||
$GLOBALS['egw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
|
||||
function js_btn_book_selected(form)
|
||||
{
|
||||
resources = '';
|
||||
|
||||
|
||||
el = form.getElementsByTagName(\"input\");
|
||||
for (var i = 0; i < el.length; i++)
|
||||
{
|
||||
@ -172,7 +171,7 @@ class ui_resources
|
||||
* @param $content Content from the eTemplate Exec call or id on inital call
|
||||
*/
|
||||
function edit($content=0,$accessory_of = -1)
|
||||
{
|
||||
{
|
||||
if (is_array($content))
|
||||
{
|
||||
if(isset($content['save']) || isset($content['delete']))
|
||||
@ -192,7 +191,7 @@ class ui_resources
|
||||
unset($content['delete']);
|
||||
$content['msg'] = $this->bo->delete($content['res_id']);
|
||||
}
|
||||
|
||||
|
||||
if($content['msg'])
|
||||
{
|
||||
return $this->edit($content);
|
||||
@ -210,7 +209,7 @@ class ui_resources
|
||||
if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
|
||||
if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of'];
|
||||
$content = array('res_id' => $res_id);
|
||||
|
||||
|
||||
if ($res_id > 0)
|
||||
{
|
||||
$content = $this->bo->read($res_id);
|
||||
@ -221,17 +220,17 @@ class ui_resources
|
||||
'to_app' => 'resources'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// some presetes
|
||||
$content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true);
|
||||
$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
|
||||
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
|
||||
$content['accessory_of'] = $content['accessory_of'] ? $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);
|
||||
$sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] :
|
||||
$sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] :
|
||||
$content['cat_id'] ? $sel_options['cat_id'] : array('' => lang('select one')) + $sel_options['cat_id'];
|
||||
if($accessory_of > 0 || $content['accessory_of'] > 0)
|
||||
{
|
||||
@ -239,37 +238,13 @@ class ui_resources
|
||||
$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
|
||||
$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
|
||||
}
|
||||
|
||||
|
||||
// $content['general|page|pictures|links'] = 'resources.edit_tabs.page'; //debug
|
||||
$no_button = array(); // TODO: show delete button only if allowed to delete resource
|
||||
$preserv = $content;
|
||||
$this->tmpl->read('resources.edit');
|
||||
return $this->tmpl->exec('resources.ui_resources.edit',$content,$sel_options,$no_button,$preserv,2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* adminsection of resources
|
||||
*
|
||||
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||
*/
|
||||
function admin($content='')
|
||||
{
|
||||
if(is_array($content))
|
||||
{
|
||||
if(isset($content['save']))
|
||||
{
|
||||
$this->bo->conf->read_repository();
|
||||
$this->bo->conf->save_value('dont_use_vfs',$content['dont_use_vfs']);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $GLOBALS['egw']->redirect_link('/admin/index.php');
|
||||
}
|
||||
}
|
||||
$content = $this->bo->conf->read_repository();
|
||||
$this->tmpl->read('resources.admin');
|
||||
$this->tmpl->exec('resources.ui_resources.admin',$content,$sel_options,$no_button,$preserv);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -299,7 +274,7 @@ class ui_resources
|
||||
{
|
||||
return $this->edit($content['res_id']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
|
||||
|
||||
@ -311,23 +286,23 @@ class ui_resources
|
||||
'to_id' => $res_id,
|
||||
'to_app' => 'resources'
|
||||
);
|
||||
|
||||
|
||||
$content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true);
|
||||
$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
|
||||
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
|
||||
|
||||
|
||||
$content['quantity'] = ($content['useable'] == $content['quantity']) ? $content['quantity'] : $content['quantity'].' ('.lang('useable').' '.$content['useable'].')';
|
||||
|
||||
|
||||
//$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
|
||||
|
||||
|
||||
$content['cat_name'] = $this->bo->acl->get_cat_name($content['cat_id']);
|
||||
$content['cat_admin'] = $this->bo->acl->get_cat_admin($content['cat_id']);
|
||||
|
||||
|
||||
/* if($content['accessory_of'] > 0)
|
||||
{
|
||||
$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
|
||||
$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
$content['description'] = chop($content['long_description']) ? $content['long_description'] : (chop($content['short_description']) ? $content['short_description'] : lang("no description available"));
|
||||
$content['description'] = $content['description'] ? $content['description'] : lang('no description available');
|
||||
@ -346,9 +321,9 @@ class ui_resources
|
||||
$preserv = $content;
|
||||
$this->tmpl->read('resources.showdetails');
|
||||
return $this->tmpl->exec('resources.ui_resources.show',$content,$sel_options,$no_button,$preserv,2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* select resources
|
||||
*
|
||||
@ -361,13 +336,13 @@ class ui_resources
|
||||
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
|
||||
}
|
||||
$GLOBALS['phpgw']->js->set_onload("copyOptions('exec[resources][selectbox]');");
|
||||
|
||||
|
||||
$GLOBALS['egw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
|
||||
window.focus();
|
||||
|
||||
|
||||
openerid='resources_selectbox';
|
||||
id='exec[nm][rows][selectbox]';
|
||||
|
||||
|
||||
function addOption(label,value,button_id,useable)
|
||||
{
|
||||
quantity = document.getElementById(button_id+'[default_qty]').value;
|
||||
@ -396,8 +371,8 @@ class ui_resources
|
||||
for (i=0; i < selectBox.length; i++) {
|
||||
var selectvalue = selectBox.options[i].value.split(':');
|
||||
if (selectvalue[0] == resource_value[0]) {
|
||||
selectBox.options[i] = null;
|
||||
selectBox.options[selectBox.length] = new Option(label,value,false,true);
|
||||
selectBox.options[i] = null;
|
||||
selectBox.options[selectBox.length] = new Option(label,value,false,true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -406,7 +381,7 @@ class ui_resources
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function removeSelectedOptions()
|
||||
{
|
||||
openerSelectBox = opener.document.getElementById(openerid);
|
||||
@ -423,7 +398,7 @@ class ui_resources
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function copyOptions()
|
||||
{
|
||||
openerSelectBox = opener.document.getElementById(openerid);
|
||||
@ -436,12 +411,12 @@ class ui_resources
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function oneLineSubmit()
|
||||
{
|
||||
/*
|
||||
openerSelectBox = opener.document.getElementById(openerid);
|
||||
|
||||
|
||||
if (openerSelectBox) {
|
||||
if (openerSelectBox.selectedIndex >= 0) {
|
||||
selected = openerSelectBox.options[openerSelectBox.selectedIndex].value;
|
||||
@ -456,13 +431,13 @@ class ui_resources
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
window.close();
|
||||
}</script>";
|
||||
|
||||
|
||||
$content['nm']['header_left'] = 'resources.resource_select.header';
|
||||
$content['nm']['show_bookable'] = true;
|
||||
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
||||
@ -480,7 +455,7 @@ class ui_resources
|
||||
$this->tmpl->read('resources.resource_select');
|
||||
return $this->tmpl->exec('resources.ui_resources.select',$content,$sel_options,$no_button,$preserv,2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_calendar_sidebox
|
||||
* get data für calendar sidebox
|
||||
@ -493,14 +468,14 @@ class ui_resources
|
||||
{
|
||||
$cats = $this->bo->acl->get_cats(EGW_ACL_READ);
|
||||
if (!$cats) return array();
|
||||
|
||||
|
||||
$owners = explode(',',$param['owner']);
|
||||
unset($param['owner']);
|
||||
$res_cats = $selected = array();
|
||||
|
||||
// this gets the resource-ids of the cats and implodes them to the array-key of the selectbox,
|
||||
// so it is possible to select all resources of a category
|
||||
foreach($cats as $cat_id => $cat_name)
|
||||
foreach($cats as $cat_id => $cat_name)
|
||||
{
|
||||
if ($resources = $this->bo->so->search(array('cat_id' => $cat_id, 'bookable' => '1'),'res_id'))
|
||||
{
|
||||
@ -510,7 +485,7 @@ class ui_resources
|
||||
$keys[] = 'r'.$res['res_id'];
|
||||
}
|
||||
$res_cats[implode(',',$keys)] = $cat_name;
|
||||
|
||||
|
||||
if (count(array_intersect($keys,$owners)) == count($keys))
|
||||
{
|
||||
$selected[] = implode(',',$keys);
|
||||
@ -535,7 +510,7 @@ class ui_resources
|
||||
{
|
||||
$resources['r'.$data['res_id']] = $data['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$selectbox = html::select(
|
||||
'owner',
|
||||
$selected,
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* eGroupWare - resources
|
||||
* http://www.egroupware.org
|
||||
* http://www.egroupware.org
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package resources
|
||||
@ -10,7 +10,7 @@
|
||||
* @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
$setup_info['resources']['name'] = 'resources';
|
||||
$setup_info['resources']['title'] = 'Resources';
|
||||
$setup_info['resources']['version'] = '1.4';
|
||||
@ -18,15 +18,15 @@
|
||||
$setup_info['resources']['tables'] = array('egw_resources','egw_resources_extra');
|
||||
$setup_info['resources']['enable'] = 1;
|
||||
|
||||
$setup_info['resources']['author'] = 'Cornelius Weiss';
|
||||
$setup_info['resources']['license'] = 'GPL';
|
||||
$setup_info['resources']['author'] = 'Cornelius Weiss';
|
||||
$setup_info['resources']['license'] = 'GPL';
|
||||
$setup_info['resources']['description'] = 'A resource management and booking system, which integrates into eGroupWare\'s calendar.';
|
||||
$setup_info['resources']['note'] = '';
|
||||
$setup_info['resources']['maintainer'] = array(
|
||||
'name' => 'Cornelius Weiss',
|
||||
'email' => 'egw@von-und-zu-weiss.de'
|
||||
);
|
||||
|
||||
$setup_info['resources']['maintainer'] = array(
|
||||
'name' => 'Cornelius Weiss',
|
||||
'email' => 'egw@von-und-zu-weiss.de'
|
||||
);
|
||||
|
||||
$setup_info['resources']['hooks']['preferences'] = 'resources.resources_hooks.admin_prefs_sidebox';
|
||||
$setup_info['resources']['hooks']['admin'] = 'resources.resources_hooks.admin_prefs_sidebox';
|
||||
$setup_info['resources']['hooks']['sidebox_menu'] = 'resources.resources_hooks.admin_prefs_sidebox';
|
||||
@ -43,7 +43,3 @@
|
||||
'appname' => 'etemplate',
|
||||
'versions' => Array('1.3','1.4','1.5')
|
||||
);
|
||||
$setup_info['resources']['depends'][] = array( // cause of vfs psuedoprotocol is not fully in the api yet
|
||||
'appname' => 'filemanager',
|
||||
'versions' => Array('1.3','1.4','1.5')
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user