mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Move resources to new API
This commit is contained in:
parent
ded2edee17
commit
cedab0ab00
@ -2,12 +2,15 @@
|
||||
/**
|
||||
* EGroupWare - resources
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
|
||||
* @license http://www.gnu.org/licenses/gpl.Api\Html GNU General Public License
|
||||
* @package resources
|
||||
* @link http://www.egroupware.org
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Acl;
|
||||
|
||||
/**
|
||||
* ACL business object for resources
|
||||
*
|
||||
@ -30,7 +33,7 @@ class bo_acl
|
||||
/**
|
||||
* Instance of categories class for resources
|
||||
*
|
||||
* @var categories
|
||||
* @var egw_cats
|
||||
*/
|
||||
var $egw_cats;
|
||||
|
||||
@ -46,7 +49,7 @@ class bo_acl
|
||||
define('EGW_ACL_DIRECT_BOOKING',128);
|
||||
define('EGW_ACL_CALREAD',256);
|
||||
|
||||
$this->egw_cats = new categories($user, 'resources');
|
||||
$this->egw_cats = new Api\Categories($user, 'resources');
|
||||
$this->debug = False;
|
||||
|
||||
//all this is only needed when called from uiacl.
|
||||
@ -86,7 +89,7 @@ class bo_acl
|
||||
* get list of cats where current user has given rights
|
||||
*
|
||||
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||
* @param int $perm_type one of EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING
|
||||
* @param int $perm_type one of Acl::READ, Acl::ADD, Acl::EDIT, Acl::DELETE, EGW_ACL_DIRECT_BOOKING
|
||||
* @param int $parent_id=0 cat_id of parent to return only children of that category
|
||||
* @return array cat_id => cat_name
|
||||
* TODO mark subcats and so on!
|
||||
@ -186,7 +189,7 @@ class bo_acl
|
||||
/**
|
||||
* checks one of the following rights for current user:
|
||||
*
|
||||
* EGW_ACL_READ, EGW_ACL_ADD, EGW_ACL_EDIT, EGW_ACL_DELETE, EGW_ACL_DIRECT_BOOKING
|
||||
* Acl::READ, Acl::ADD, Acl::EDIT, Acl::DELETE, EGW_ACL_DIRECT_BOOKING
|
||||
*
|
||||
* @param int $cat_id
|
||||
* @param int $right
|
||||
@ -226,12 +229,12 @@ class bo_acl
|
||||
'limit' => $this->limit,
|
||||
);
|
||||
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
|
||||
$GLOBALS['egw']->session->appsession('session_data','resources_acl',$data);
|
||||
Api\Cache::setSession('resources_acl', 'session_data', $data);
|
||||
}
|
||||
|
||||
function read_sessiondata()
|
||||
{
|
||||
$data = $GLOBALS['egw']->session->appsession('session_data','resources_acl');
|
||||
$data = Api\Cache::getSession('resources_acl', 'session_data');
|
||||
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
|
||||
|
||||
$this->start = $data['start'];
|
||||
@ -258,8 +261,8 @@ class bo_acl
|
||||
{
|
||||
$account_id = $account['account_id'];
|
||||
$rights = false;
|
||||
$rights = in_array($account_id,$readcat) ? ($rights | EGW_ACL_READ) : false;
|
||||
$rights = in_array($account_id,$writecat) ? ($rights | EGW_ACL_READ | EGW_ACL_ADD | EGW_ACL_EDIT | EGW_ACL_DELETE): $rights;
|
||||
$rights = in_array($account_id,$readcat) ? ($rights | Acl::READ) : false;
|
||||
$rights = in_array($account_id,$writecat) ? ($rights | Acl::READ | Acl::ADD | Acl::EDIT | Acl::DELETE): $rights;
|
||||
$rights = in_array($account_id,$calreadcat) ? ($rights | EGW_ACL_CALREAD) : $rights;
|
||||
$rights = in_array($account_id,$calbookcat) ? ($rights | EGW_ACL_DIRECT_BOOKING | EGW_ACL_CALREAD) : $rights;
|
||||
$rights = in_array($account_id,$admincat) ? ($rights = 511) : $rights;
|
||||
|
@ -10,6 +10,11 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Link;
|
||||
use EGroupware\Api\Egw;
|
||||
use EGroupware\Api\Acl;
|
||||
use EGroupware\Api\Vfs;
|
||||
|
||||
/**
|
||||
* General business object for resources
|
||||
@ -29,13 +34,13 @@ class resources_bo
|
||||
*/
|
||||
var $so;
|
||||
/**
|
||||
* Instance of resources acl class
|
||||
* Instance of resources Acl class
|
||||
*
|
||||
* @var bo_acl
|
||||
*/
|
||||
var $acl;
|
||||
/**
|
||||
* Instance of categories class for resources
|
||||
* Instance of Api\Categories class for resources
|
||||
*/
|
||||
var $cats;
|
||||
|
||||
@ -69,7 +74,7 @@ class resources_bo
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $user=null account_id of user to use for acl, default current user
|
||||
* @param int $user=null account_id of user to use for Acl, default current user
|
||||
*/
|
||||
function __construct($user=null)
|
||||
{
|
||||
@ -78,9 +83,9 @@ class resources_bo
|
||||
$this->cats = $this->acl->egw_cats;
|
||||
|
||||
$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,
|
||||
EGW_ACL_CALREAD => Acl::READ,
|
||||
EGW_ACL_DIRECT_BOOKING => Acl::READ | Acl::ADD | Acl::EDIT | Acl::DELETE,
|
||||
EGW_ACL_CAT_ADMIN => Acl::READ | Acl::ADD | Acl::EDIT | Acl::DELETE,
|
||||
);
|
||||
}
|
||||
|
||||
@ -93,11 +98,11 @@ class resources_bo
|
||||
{
|
||||
if(!$query['csv_export'])
|
||||
{
|
||||
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$query);
|
||||
Api\Cache::setSession('resources', 'index_nm', $query);
|
||||
}
|
||||
if ($query['store_state']) // request to store state in session and filter in prefs?
|
||||
{
|
||||
egw_cache::setSession('resources',$query['store_state'],$query);
|
||||
Api\Cache::setSession('resources',$query['store_state'],$query);
|
||||
//echo "<p>".__METHOD__."() query[filter]=$query[filter], prefs[resources][filter]={$GLOBALS['egw_info']['user']['preferences']['resources']['filter']}</p>\n";
|
||||
if ($query['filter'] != $GLOBALS['egw_info']['user']['preferences']['resources']['filter'])
|
||||
{
|
||||
@ -147,7 +152,7 @@ class resources_bo
|
||||
|
||||
if ($query['filter'])
|
||||
{
|
||||
if (($children = $this->acl->get_cats(EGW_ACL_READ,$query['filter'])))
|
||||
if (($children = $this->acl->get_cats(Acl::READ,$query['filter'])))
|
||||
{
|
||||
$filter['cat_id'] = array_keys($children);
|
||||
$filter['cat_id'][] = $query['filter'];
|
||||
@ -157,7 +162,7 @@ class resources_bo
|
||||
$filter['cat_id'] = $query['filter'];
|
||||
}
|
||||
}
|
||||
elseif (($readcats = $this->acl->get_cats(EGW_ACL_READ)))
|
||||
elseif (($readcats = $this->acl->get_cats(Acl::READ)))
|
||||
{
|
||||
$filter['cat_id'] = array_keys($readcats);
|
||||
}
|
||||
@ -189,10 +194,10 @@ class resources_bo
|
||||
return $nr;
|
||||
}
|
||||
|
||||
$config = config::read('resources');
|
||||
$config = Api\Config::read('resources');
|
||||
foreach($rows as $num => &$resource)
|
||||
{
|
||||
if (!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_EDIT))
|
||||
if (!$this->acl->is_permitted($resource['cat_id'],Acl::EDIT))
|
||||
{
|
||||
$readonlys["edit[$resource[res_id]]"] = true;
|
||||
}
|
||||
@ -200,14 +205,14 @@ class resources_bo
|
||||
{
|
||||
$resource['class'] .= 'deleted ';
|
||||
}
|
||||
if (!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_DELETE) ||
|
||||
if (!$this->acl->is_permitted($resource['cat_id'],Acl::DELETE) ||
|
||||
($resource['deleted'] && !$GLOBALS['egw_info']['user']['apps']['admin'] && $config['history'] == 'history')
|
||||
)
|
||||
{
|
||||
$readonlys["delete[$resource[res_id]]"] = true;
|
||||
$resource['class'] .= 'no_delete ';
|
||||
}
|
||||
if ((!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_ADD)) ||
|
||||
if ((!$this->acl->is_permitted($resource['cat_id'],Acl::ADD)) ||
|
||||
// Allow new accessory action when viewing accessories of a certain resource
|
||||
$query['filter2'] <= 0 && $resource['accessory_of'] != -1)
|
||||
{
|
||||
@ -266,7 +271,7 @@ class resources_bo
|
||||
$rows[$num]['admin'] = $this->acl->get_cat_admin($resource['cat_id']);
|
||||
}
|
||||
|
||||
if(!config::get_customfields('resources'))
|
||||
if(!Api\Storage\Customfields::get('resources'))
|
||||
{
|
||||
$rows['no_customfields'] = true;
|
||||
}
|
||||
@ -286,7 +291,7 @@ class resources_bo
|
||||
{
|
||||
return null; // not found
|
||||
}
|
||||
if (!$this->acl->is_permitted($data['cat_id'],EGW_ACL_READ))
|
||||
if (!$this->acl->is_permitted($data['cat_id'],Acl::READ))
|
||||
{
|
||||
return false; // permission denied
|
||||
}
|
||||
@ -302,7 +307,7 @@ class resources_bo
|
||||
*/
|
||||
function save($resource)
|
||||
{
|
||||
if(!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_EDIT))
|
||||
if(!$this->acl->is_permitted($resource['cat_id'],Acl::EDIT))
|
||||
{
|
||||
return lang('You are not permitted to edit this resource!');
|
||||
}
|
||||
@ -311,13 +316,13 @@ class resources_bo
|
||||
if(!$resource['res_id'])
|
||||
{
|
||||
$resource['res_owner'] = $GLOBALS['egw_info']['user']['account_id'];
|
||||
$resource['res_created'] = egw_time::server2user(time(),'ts');
|
||||
$resource['res_created'] = Api\DateTime::server2user(time(),'ts');
|
||||
$resource['res_id'] = $this->so->save($resource);
|
||||
}
|
||||
else
|
||||
{
|
||||
$resource['res_modifier'] = $GLOBALS['egw_info']['user']['account_id'];
|
||||
$resource['res_modified'] = egw_time::server2user(time(),'ts');
|
||||
$resource['res_modified'] = Api\DateTime::server2user(time(),'ts');
|
||||
$old = $this->read($resource['res_id']);
|
||||
}
|
||||
|
||||
@ -360,7 +365,7 @@ class resources_bo
|
||||
// Check for restore of deleted, restore held links
|
||||
if($old && $old['deleted'] && !$resource['deleted'])
|
||||
{
|
||||
egw_link::restore('resources', $resource['res_id']);
|
||||
Link::restore('resources', $resource['res_id']);
|
||||
}
|
||||
|
||||
// delete old pictures
|
||||
@ -370,22 +375,22 @@ class resources_bo
|
||||
}
|
||||
|
||||
// Update link title
|
||||
egw_link::notify_update('resources',$resource['res_id'], $resource);
|
||||
Link::notify_update('resources',$resource['res_id'], $resource);
|
||||
// save links
|
||||
if(is_array($resource['link_to']['to_id']))
|
||||
{
|
||||
egw_link::link('resources',$resource['res_id'],$resource['link_to']['to_id']);
|
||||
Link::link('resources',$resource['res_id'],$resource['link_to']['to_id']);
|
||||
}
|
||||
if($resource['accessory_of'] != $old['accessory_of'])
|
||||
{
|
||||
egw_link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']);
|
||||
Link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']);
|
||||
|
||||
// Check for resource changing to accessory - move its accessories to resource
|
||||
if($old['accessory_of'] == -1 && $accessories = $this->get_acc_list($resource['res_id']))
|
||||
{
|
||||
foreach($accessories as $accessory => $name)
|
||||
{
|
||||
egw_link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']);
|
||||
Link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']);
|
||||
$acc = $this->read($accessory);
|
||||
$acc['accessory_of'] = -1;
|
||||
$this->so->save($acc);
|
||||
@ -394,7 +399,7 @@ class resources_bo
|
||||
}
|
||||
if($resource['accessory_of'] != -1)
|
||||
{
|
||||
egw_link::link('resources',$resource['res_id'],'resources',$resource['accessory_of']);
|
||||
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)
|
||||
@ -432,19 +437,19 @@ class resources_bo
|
||||
*/
|
||||
function delete($res_id)
|
||||
{
|
||||
if(!$this->acl->is_permitted($this->so->get_value('cat_id',$res_id),EGW_ACL_DELETE))
|
||||
if(!$this->acl->is_permitted($this->so->get_value('cat_id',$res_id),Acl::DELETE))
|
||||
{
|
||||
return lang('You are not permitted to delete this resource!');
|
||||
}
|
||||
|
||||
// check if we only mark resources as deleted, or really delete them
|
||||
$old = $this->read($res_id);
|
||||
$config = config::read('resources');
|
||||
$config = Api\Config::read('resources');
|
||||
if ($config['history'] != '' && $old['deleted'] == null)
|
||||
{
|
||||
$old['deleted'] = time();
|
||||
$this->save($old);
|
||||
egw_link::unlink(0,'resources',$res_id,'','','',true);
|
||||
Link::unlink(0,'resources',$res_id,'','','',true);
|
||||
$accessories = $this->get_acc_list($res_id);
|
||||
foreach($accessories as $acc_id => $name)
|
||||
{
|
||||
@ -454,7 +459,7 @@ class resources_bo
|
||||
{
|
||||
$acc['deleted'] = time();
|
||||
$this->save($acc);
|
||||
egw_link::unlink(0,'resources',$acc_id,'','','',true);
|
||||
Link::unlink(0,'resources',$acc_id,'','','',true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -472,7 +477,7 @@ class resources_bo
|
||||
}
|
||||
};
|
||||
$this->remove_picture($res_id);
|
||||
egw_link::unlink(0,'resources',$res_id);
|
||||
Link::unlink(0,'resources',$res_id);
|
||||
// delete the resource from the calendar
|
||||
ExecMethod('calendar.calendar_so.deleteaccount','r'.$res_id);
|
||||
return false;
|
||||
@ -533,7 +538,7 @@ class resources_bo
|
||||
$resource['responsible'] = $this->acl->get_cat_admin($resource['cat_id']);
|
||||
|
||||
// preseed the cache
|
||||
egw_link::set_cache('resources',$resource['res_id'],$t=$this->link_title($resource));
|
||||
Link::set_cache('resources',$resource['res_id'],$t=$this->link_title($resource));
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@ -577,13 +582,13 @@ class resources_bo
|
||||
$only_keys = 'res_id,name,short_description,bookable,useable';
|
||||
|
||||
// If no read access to any category, just stop
|
||||
if(!$this->acl->get_cats(EGW_ACL_READ))
|
||||
if(!$this->acl->get_cats(Acl::READ))
|
||||
{
|
||||
$options['total'] = 0;
|
||||
return array();
|
||||
}
|
||||
$filter = array(
|
||||
'cat_id' => array_flip((array)$this->acl->get_cats(EGW_ACL_READ)),
|
||||
'cat_id' => array_flip((array)$this->acl->get_cats(Acl::READ)),
|
||||
//'accessory_of' => '-1'
|
||||
'deleted' => null
|
||||
);
|
||||
@ -610,11 +615,11 @@ class resources_bo
|
||||
{
|
||||
$this->bocal = new calendar_bo();
|
||||
}
|
||||
$start = new egw_time($cal_info['start']);
|
||||
$start = new Api\DateTime($cal_info['start']);
|
||||
$startarr= getdate($start->format('ts'));
|
||||
if (isset($cal_info['whole_day']) && $cal_info['whole_day']) {
|
||||
$startarr['hour'] = $startarr['minute'] = 0;
|
||||
$start = new egw_time($startarr);
|
||||
$start = new Api\DateTime($startarr);
|
||||
$end = $start->format('ts') + 86399;
|
||||
} else {
|
||||
$start = $start->format('ts');
|
||||
@ -717,7 +722,7 @@ class resources_bo
|
||||
{
|
||||
if (!($resource = $this->read(array('res_id' => $resource)))) return $resource;
|
||||
}
|
||||
elseif (!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_READ))
|
||||
elseif (!$this->acl->is_permitted($resource['cat_id'],Acl::READ))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -748,7 +753,7 @@ class resources_bo
|
||||
$titles[$resource['res_id']] = $this->link_title($resource);
|
||||
}
|
||||
}
|
||||
// we assume all not returned contacts are not readable for the user (as we report all deleted contacts to egw_link)
|
||||
// we assume all not returned contacts are not readable for the user (as we report all deleted contacts to Link)
|
||||
foreach($ids as $id)
|
||||
{
|
||||
if (!isset($titles[$id]))
|
||||
@ -790,7 +795,7 @@ class resources_bo
|
||||
imagejpeg($src_img,$tmp_name);
|
||||
imagedestroy($src_img);
|
||||
|
||||
egw_link::attach_file('resources',$resouce_id,array(
|
||||
Link::attach_file('resources',$resouce_id,array(
|
||||
'tmp_name' => $tmp_name,
|
||||
'name' => self::PICTURE_NAME,
|
||||
'type' => 'image/jpeg',
|
||||
@ -811,22 +816,21 @@ class resources_bo
|
||||
switch($resource['picture_src'])
|
||||
{
|
||||
case 'own_src':
|
||||
$picture = egw_link::vfs_path('resources',$resource['res_id'],self::PICTURE_NAME,true); // vfs path
|
||||
$picture = Link::vfs_path('resources',$resource['res_id'],self::PICTURE_NAME,true); // vfs path
|
||||
if ($fullsize)
|
||||
{
|
||||
$picture = egw::link(egw_vfs::download_url($picture));
|
||||
$picture = Egw::link(Vfs::download_url($picture));
|
||||
}
|
||||
else
|
||||
{
|
||||
$picture = egw::link('/etemplate/thumbnail.php', array(
|
||||
$picture = Egw::link('/api/thumbnail.php', array(
|
||||
'path' => $picture
|
||||
),false);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'cat_src':
|
||||
list($picture) = $this->cats->return_single($resource['cat_id']);
|
||||
$picture = unserialize($picture['data']);
|
||||
$picture = Api\Categories::id2name($resource['cat_id'], 'data');
|
||||
if($picture['icon'])
|
||||
{
|
||||
$picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$picture['icon']:'/phpgwapi/images/'.$picture['icon'];
|
||||
@ -851,7 +855,7 @@ class resources_bo
|
||||
*/
|
||||
function remove_picture($res_id)
|
||||
{
|
||||
if (($arr = egw_link::delete_attached('resources',$res_id,self::PICTURE_NAME)) && is_array($arr))
|
||||
if (($arr = Link::delete_attached('resources',$res_id,self::PICTURE_NAME)) && is_array($arr))
|
||||
{
|
||||
return array_shift($arr); // $arr = array($path => (bool)$ok);
|
||||
}
|
||||
|
@ -11,6 +11,9 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Acl;
|
||||
|
||||
/**
|
||||
* export resources to CSV
|
||||
*/
|
||||
@ -34,7 +37,7 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
$selection = array();
|
||||
if ($options['selection'] == 'search') {
|
||||
// ui selection with checkbox 'selected'
|
||||
$query = egw_cache::getSession('resources', 'get_rows');
|
||||
$query = Api\Cache::getSession('resources', 'get_rows');
|
||||
$query['num_rows'] = -1; // all
|
||||
unset($query['store_state']);
|
||||
$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
|
||||
@ -83,7 +86,7 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
|
||||
// Check if we need to load the custom fields
|
||||
$need_custom = false;
|
||||
foreach(config::get_customfields('resources') as $field => $settings) {
|
||||
foreach(Api\Storage\Customfields::get('resources') as $field => $settings) {
|
||||
if($options['mapping']['#'.$field]) {
|
||||
$need_custom = true;
|
||||
break;
|
||||
@ -179,7 +182,7 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
// In resources, not all categories are used
|
||||
$filters['cat_id']['type'] = 'select';
|
||||
$filters['cat_id']['name'] = 'filter';
|
||||
$filters['cat_id']['values']= (array)$this->bo->acl->get_cats(EGW_ACL_READ);
|
||||
$filters['cat_id']['values']= (array)$this->bo->acl->get_cats(Acl::READ);
|
||||
|
||||
// Add in resources / accessories
|
||||
$filters['filter2'] = array(
|
||||
|
@ -10,6 +10,11 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Egw;
|
||||
use EGroupware\Api\Acl;
|
||||
|
||||
/**
|
||||
* General hook object for resources
|
||||
* It encapsulats all the diffent hook methods
|
||||
@ -27,17 +32,17 @@ class resources_hooks
|
||||
if ($location == 'sidebox_menu')
|
||||
{
|
||||
// Magic etemplate2 favorites menu (from nextmatch widget)
|
||||
display_sidebox($appname, lang('Favorites'), egw_framework::favorite_list($appname, 'nextmatch-resources.show.rows-favorite'));
|
||||
display_sidebox($appname, lang('Favorites'), Framework\Favorites::list_favorites($appname, 'nextmatch-resources.show.rows-favorite'));
|
||||
|
||||
$title = $GLOBALS['egw_info']['apps']['resources']['title'].' '.lang('Menu');
|
||||
$file = array(
|
||||
'Resources list' => egw::link('/index.php',array(
|
||||
'Resources list' => Egw::link('/index.php',array(
|
||||
'menuaction' => 'resources.resources_ui.index',
|
||||
'ajax' => 'true')),
|
||||
);
|
||||
if($this->acl->get_cats(EGW_ACL_ADD))
|
||||
if($this->acl->get_cats(Acl::ADD))
|
||||
{
|
||||
$file['Add resource'] = "javascript:egw_openWindowCentered2('".egw::link('/index.php',array(
|
||||
$file['Add resource'] = "javascript:egw_openWindowCentered2('".Egw::link('/index.php',array(
|
||||
'menuaction' => 'resources.resources_ui.edit',
|
||||
'accessory_of' => -1
|
||||
),false)."','_blank',800,600,'yes')";
|
||||
@ -48,12 +53,12 @@ class resources_hooks
|
||||
if ($GLOBALS['egw_info']['user']['apps']['admin'])
|
||||
{
|
||||
$file = Array(
|
||||
'Site Configuration' => egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'),
|
||||
'Global Categories' => egw::link('/index.php',array(
|
||||
'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'),
|
||||
'Global Categories' => Egw::link('/index.php',array(
|
||||
'menuaction' => 'admin.admin_categories.index',
|
||||
'appname' => $appname,
|
||||
'global_cats'=> true)),
|
||||
'Configure Access Permissions' => egw::link('/index.php',
|
||||
'Configure Access Permissions' => Egw::link('/index.php',
|
||||
'menuaction=resources.ui_acl.acllist'),
|
||||
'Custom Fields'=>egw::link('/index.php',
|
||||
'menuaction=admin.customfields.index&appname=resources'),
|
||||
@ -112,14 +117,14 @@ class resources_hooks
|
||||
*/
|
||||
function delete_category($args)
|
||||
{
|
||||
$cat = categories::read($args['cat_id']);
|
||||
$cat = Api\Categories::read($args['cat_id']);
|
||||
|
||||
if(!$cat) return; // Can't find current cat?
|
||||
|
||||
if($cat['parent'] == 0)
|
||||
{
|
||||
// No parent, try the default cat from setup
|
||||
$categories = new categories('', 'resources');
|
||||
$categories = new Api\Categories('', 'resources');
|
||||
$default = $categories->name2id('General resources');
|
||||
if($default)
|
||||
{
|
||||
@ -214,7 +219,7 @@ class resources_hooks
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to tell framework we use only global categories (return link data in that case and false otherwise)
|
||||
* Hook to tell framework we use only global Api\Categories (return link data in that case and false otherwise)
|
||||
*
|
||||
* @param string|array $data hook-data or location
|
||||
* @return boolean|array
|
||||
|
@ -11,6 +11,7 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
/**
|
||||
* class to import resources from CSV
|
||||
@ -191,7 +192,7 @@ class resources_import_csv extends importexport_basic_import_csv {
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new egw_exception('Unsupported action');
|
||||
throw new Api\Exception('Unsupported action');
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,10 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Link;
|
||||
use EGroupware\Api\Framework;
|
||||
|
||||
class resources_reserve {
|
||||
|
||||
public function __construct() {
|
||||
@ -22,7 +26,7 @@ class resources_reserve {
|
||||
*/
|
||||
public function book($content = array(), $arguments = array())
|
||||
{
|
||||
egw_framework::validate_file('jscalendar','calendar');
|
||||
Framework::includeJS('jscalendar','calendar');
|
||||
$data = array();
|
||||
$readonlys = array();
|
||||
$display_days = $_GET['planner_days'] ? $_GET['planner_days'] : 3;
|
||||
@ -32,11 +36,11 @@ class resources_reserve {
|
||||
$register_code = ($_GET['confirm'] && preg_match('/^[0-9a-f]{32}$/',$_GET['confirm'])) ? $_GET['confirm'] : false;
|
||||
if($register_code && $registration = registration_bo::confirm($register_code)) {
|
||||
// Get calendar through link
|
||||
$links = egw_link::get_links('registration', $registration['reg_id'],'calendar');
|
||||
$links = Link::get_links('registration', $registration['reg_id'],'calendar');
|
||||
$bo = new calendar_boupdate();
|
||||
$data = $bo->read(current($links));
|
||||
|
||||
$addressbook = new addressbook_bo();
|
||||
$addressbook = new Api\Contacts();
|
||||
$data += $addressbook->read(key($data['participant_types']['c']));
|
||||
|
||||
// Show date of reservation, so they can see it blocked off
|
||||
@ -50,7 +54,7 @@ class resources_reserve {
|
||||
'quantity' => 0
|
||||
);
|
||||
calendar_so::split_status($data['participant_types']['r'][$content['resource']], $content['quantity'],$role);
|
||||
$data['msg']= '<div class="confirm">'.lang('Registration confirmed %1', egw_time::to($data['start'])) .'</div>';
|
||||
$data['msg']= '<div class="confirm">'.lang('Registration confirmed %1', Api\DateTime::to($data['start'])) .'</div>';
|
||||
} else {
|
||||
$data['msg']= '<div class="confirm">'.lang('Unable to process confirmation.').'</div>';
|
||||
}
|
||||
@ -83,7 +87,7 @@ class resources_reserve {
|
||||
// Use sitemgr's default appointment length
|
||||
if($GLOBALS['egw_info']['user']['account_lid'] != $GLOBALS['sitemgr_info']['anonymous_user'])
|
||||
{
|
||||
$preferences = new preferences($GLOBALS['egw']->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user']));
|
||||
$preferences = new Api\Preferences($GLOBALS['egw']->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user']));
|
||||
$preferences = $preferences->read_repository();
|
||||
$duration = $preferences['calendar']['defaultlength'] * 60;
|
||||
}
|
||||
@ -93,7 +97,7 @@ class resources_reserve {
|
||||
}
|
||||
$end_time = $start_time + $duration;
|
||||
|
||||
$config = config::read('registration');
|
||||
$config = Api\Config::read('registration');
|
||||
|
||||
// Not a user, need contact
|
||||
if($GLOBALS['egw_info']['user']['account_lid'] == $GLOBALS['sitemgr_info']['anonymous_user'] && !$content['contact_id'])
|
||||
@ -104,14 +108,14 @@ class resources_reserve {
|
||||
$content['private'] = 0; // in case default_private is set
|
||||
}
|
||||
|
||||
$addressbook = new addressbook_bo();
|
||||
$addressbook = new Api\Contacts();
|
||||
$contact_fields = $addressbook->contact_fields;
|
||||
unset($contact_fields['email']); // Always present
|
||||
unset($contact_fields['id']); // Address already there
|
||||
if(array_intersect_key($contact_fields,$content)) {
|
||||
$result = $addressbook->save($content);
|
||||
if(!$result) {
|
||||
throw new egw_exception_no_permission($addressbook->error);
|
||||
throw new Api\Exception\NoPermission($addressbook->error);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -129,7 +133,7 @@ class resources_reserve {
|
||||
if($contact) {
|
||||
// Make event
|
||||
$event = array(
|
||||
'title' => egw_link::title('addressbook', $contact_id),
|
||||
'title' => Link::title('addressbook', $contact_id),
|
||||
'start' => $start_time,
|
||||
'end' => $end_time,
|
||||
'participants' => array(
|
||||
@ -160,7 +164,7 @@ class resources_reserve {
|
||||
$data += $content;
|
||||
$data['msg'] = lang('Please choose a different time:')."\n";
|
||||
foreach($freetime as $slot) {
|
||||
$data['msg'] .= egw_time::to($slot['start']) . ' - ' . egw_time::to($slot['end'])."<br />\n";
|
||||
$data['msg'] .= Api\DateTime::to($slot['start']) . ' - ' . Api\DateTime::to($slot['end'])."<br />\n";
|
||||
}
|
||||
}
|
||||
elseif ($preserve['confirmation'] && $contact_id && $result)
|
||||
@ -175,21 +179,21 @@ class resources_reserve {
|
||||
if(is_numeric($reg_id))
|
||||
{
|
||||
// Link to event
|
||||
egw_link::link('registration', $reg_id, 'calendar', $result);
|
||||
Link::link('registration', $reg_id, 'calendar', $result);
|
||||
$reg = registration_bo::read($reg_id);
|
||||
|
||||
// Send email
|
||||
$email_info = $config + array(
|
||||
'title' => $data['name'],
|
||||
'subject' => $data['name'] . ' ' . egw_time::to($start_time),
|
||||
'subject' => $data['name'] . ' ' . Api\DateTime::to($start_time),
|
||||
'link' => $preserve['link'],
|
||||
);
|
||||
if($preserve['email_message'])
|
||||
{
|
||||
$email_info['message'] = lang($preserve['email_message'],
|
||||
egw_time::to($start_time),
|
||||
Api\DateTime::to($start_time),
|
||||
$preserve['link'].'&confirm='.$reg['register_code'],
|
||||
egw_time::to($reg['timestamp'])
|
||||
Api\DateTime::to($reg['timestamp'])
|
||||
);
|
||||
}
|
||||
$data['msg'] .= registration_bo::send_confirmation($email_info, $reg);
|
||||
@ -219,7 +223,7 @@ class resources_reserve {
|
||||
// Use sitemgr's default appointment length
|
||||
if($GLOBALS['egw_info']['user']['account_lid'] != $GLOBALS['sitemgr_info']['anonymous_user'])
|
||||
{
|
||||
$preferences = new preferences($GLOBALS['egw']->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user']));
|
||||
$preferences = new Api\Preferences($GLOBALS['egw']->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user']));
|
||||
$preferences = $preferences->read_repository();
|
||||
$data['duration'] = $preferences['calendar']['defaultlength'];
|
||||
}
|
||||
@ -263,7 +267,7 @@ class resources_reserve {
|
||||
}
|
||||
|
||||
public function ajax_update_planner($resource_id, $date) {
|
||||
$response = egw_json_response::get();
|
||||
$response = Api\Json\Response::get();
|
||||
$response->assign('exec[planner_div]','innerHTML',$this->get_planner(
|
||||
$resource_id,
|
||||
strtotime('yesterday',$date),
|
||||
@ -314,7 +318,7 @@ class resources_reserve {
|
||||
public function confirm($registration)
|
||||
{
|
||||
// Get calendar through link
|
||||
$links = egw_link::get_links('registration', $registration['reg_id'],'calendar');
|
||||
$links = Link::get_links('registration', $registration['reg_id'],'calendar');
|
||||
$bo = new calendar_boupdate();
|
||||
$event = $bo->read(current($links));
|
||||
if($registration['status'] == registration_bo::CONFIRMED)
|
||||
|
@ -1,106 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* eGroupWare - eTemplate Extension - Resource Select Widgets
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package resources
|
||||
* @link http://www.egroupware.org
|
||||
* @author RalfBecker-AT-outdoor-training.de
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* eTemplate Extension: select a resource
|
||||
*
|
||||
* @package resources
|
||||
*/
|
||||
class resources_select_widget
|
||||
{
|
||||
/**
|
||||
* exported methods of this class
|
||||
* @var array
|
||||
*/
|
||||
var $public_functions = array(
|
||||
'pre_process' => True,
|
||||
);
|
||||
/**
|
||||
* availible extensions and there names for the editor
|
||||
* @var array
|
||||
*/
|
||||
var $human_name = 'Select Resources';
|
||||
|
||||
/**
|
||||
* Constructor of the extension
|
||||
*
|
||||
* @param string $ui '' for html
|
||||
*/
|
||||
function resources_select_widget($ui)
|
||||
{
|
||||
$this->ui = $ui;
|
||||
}
|
||||
|
||||
/**
|
||||
* pre-processing of the extension
|
||||
*
|
||||
* This function is called before the extension gets rendered
|
||||
*
|
||||
* @param string $name form-name of the control
|
||||
* @param mixed &$value value / existing content, can be modified
|
||||
* @param array &$cell array with the widget, can be modified for ui-independent widgets
|
||||
* @param array &$readonlys names of widgets as key, to be made readonly
|
||||
* @param mixed &$extension_data data the extension can store persisten between pre- and post-process
|
||||
* @param object &$tmpl reference to the template we belong too
|
||||
* @return boolean true if extra label is allowed, false otherwise
|
||||
*/
|
||||
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
||||
{
|
||||
if ($cell['readonly'] && !is_array($value))
|
||||
{
|
||||
// no acl check here cause names are allways viewable
|
||||
list($res_id,$quantity) = explode(':',$value);
|
||||
$data = ExecMethod('resources.resources_bo.get_calendar_info',$res_id);
|
||||
$cell['type'] = 'label';
|
||||
$value = $data[0]['name']. ($data[0]['useable'] > 1 ? ' ['. ($quantity > 1 ? $quantity : 1). '/'. $data[0]['useable']. ']' : '');
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$GLOBALS['egw_info']['user']['apps']['resources'])
|
||||
{
|
||||
$cell = $tmpl->empty_cell();
|
||||
$cell['label'] = 'no resources';
|
||||
return false;
|
||||
}
|
||||
$tpl = new etemplate('resources.resource_selectbox');
|
||||
// keep the editor away from the generated tmpls
|
||||
$tpl->no_onclick = true;
|
||||
|
||||
if ($value)
|
||||
{
|
||||
$value = is_array($value) ? $value : explode(',',$value);
|
||||
foreach((array)$value as $id)
|
||||
{
|
||||
list($res_id,$quantity) = explode(':',$id);
|
||||
$data = ExecMethod('resources.resources_bo.get_calendar_info',$res_id);
|
||||
$sel_options[$data[0]['res_id'].($quantity > 1 ? (':'.$quantity) : '')] =
|
||||
$data[0]['name'].' ['.($quantity > 1 ? $quantity : 1).'/'.$data[0]['useable'].']';
|
||||
}
|
||||
$tpl->set_cell_attribute('resources','sel_options',$sel_options);
|
||||
}
|
||||
|
||||
$tpl->set_cell_attribute('resources','size',(int)$cell['size'].'+');
|
||||
$tpl->set_cell_attribute('resources','label',$cell['label']);
|
||||
$tpl->set_cell_attribute('resources','id','resources_selectbox');
|
||||
$tpl->set_cell_attribute('resources','name',$cell['name']);
|
||||
if ($cell['help'])
|
||||
{
|
||||
$tpl->set_cell_attribute('resources','help',$cell['help']);
|
||||
$tpl->set_cell_attribute('popup','label',$cell['help']);
|
||||
}
|
||||
$cell['type'] = 'template';
|
||||
$cell['size'] = $cell['label'] = '';
|
||||
$cell['name'] = 'resources.resource_selectbox';
|
||||
$cell['obj'] =& $tpl;
|
||||
|
||||
return True; // extra Label Ok
|
||||
}
|
||||
}
|
@ -10,13 +10,15 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
/**
|
||||
* General storage object for resources
|
||||
*
|
||||
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
|
||||
* @package resources
|
||||
*/
|
||||
class resources_so extends so_sql_cf
|
||||
class resources_so extends Api\Storage
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
@ -6,17 +6,18 @@
|
||||
* @copyright 2012 Nathan Gray
|
||||
* @package resources
|
||||
* @sub-package history
|
||||
* @see bo_tracking
|
||||
* @see Api\Storage\Tracking
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
/**
|
||||
* Resources - tracking object for history
|
||||
*/
|
||||
class resources_tracking extends bo_tracking
|
||||
class resources_tracking extends Api\Storage\Tracking
|
||||
{
|
||||
|
||||
|
||||
|
@ -10,6 +10,12 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Link;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Acl;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* General userinterface object for resources
|
||||
*
|
||||
@ -31,7 +37,7 @@ class resources_ui
|
||||
function __construct()
|
||||
{
|
||||
// print_r($GLOBALS['egw_info']); die();
|
||||
$this->tmpl = new etemplate_new('resources.show');
|
||||
$this->tmpl = new Etemplate('resources.show');
|
||||
$this->bo = new resources_bo();
|
||||
// $this->calui = CreateObject('resources.ui_calviews');
|
||||
}
|
||||
@ -49,7 +55,7 @@ class resources_ui
|
||||
{
|
||||
$sessiondata = $content['nm'];
|
||||
unset($sessiondata['rows']);
|
||||
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
|
||||
Api\Cache::setSession('resources', 'index_nm', $sessiondata);
|
||||
|
||||
if (isset($content['btn_delete_selected']))
|
||||
{
|
||||
@ -72,7 +78,7 @@ class resources_ui
|
||||
if(isset($row['view_acc']))
|
||||
{
|
||||
$sessiondata['filter2'] = array_search('pressed',$row['view_acc']);
|
||||
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
|
||||
Api\Cache::setSession('resources', 'index_nm', $sessiondata);
|
||||
return $this->index();
|
||||
}
|
||||
}
|
||||
@ -116,19 +122,19 @@ class resources_ui
|
||||
$content['nm']['row_id'] = 'res_id';
|
||||
$content['nm']['favorites'] = true;
|
||||
|
||||
$nm_session_data = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
|
||||
$nm_session_data = Api\Cache::getSession('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);
|
||||
$content['nm']['options-filter']= array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(Acl::READ);
|
||||
$content['nm']['options-filter2'] = resources_bo::$filter_options;
|
||||
if(!$content['nm']['filter2'])
|
||||
{
|
||||
$content['nm']['filter2'] = key(resources_bo::$filter_options);
|
||||
}
|
||||
|
||||
$config = config::read('resources');
|
||||
$config = Api\Config::read('resources');
|
||||
if($config['history'])
|
||||
{
|
||||
$content['nm']['options-filter2'][resources_bo::DELETED] = lang('Deleted');
|
||||
@ -146,14 +152,14 @@ class resources_ui
|
||||
|
||||
// check if user is permitted to add resources
|
||||
// If they can't read any categories, they won't be able to save it
|
||||
if(!$this->bo->acl->get_cats(EGW_ACL_ADD) || !$this->bo->acl->get_cats(EGW_ACL_READ))
|
||||
if(!$this->bo->acl->get_cats(Acl::ADD) || !$this->bo->acl->get_cats(Acl::READ))
|
||||
{
|
||||
$no_button['add'] = $no_button['nm']['add'] = true;
|
||||
}
|
||||
$no_button['back'] = true;
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('resources');
|
||||
|
||||
egw_framework::validate_file('.','resources','resources');
|
||||
Framework::includeJS('.','resources','resources');
|
||||
|
||||
if($content['nm']['filter2'] > 0)
|
||||
{
|
||||
@ -169,7 +175,7 @@ class resources_ui
|
||||
|
||||
$options = array();
|
||||
|
||||
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$content['nm']);
|
||||
Api\Cache::setSession('resources', 'index_nm', $content['nm']);
|
||||
$this->tmpl->read('resources.show');
|
||||
return $this->tmpl->exec('resources.resources_ui.index',$content,$sel_options,$no_button,$preserv);
|
||||
}
|
||||
@ -187,14 +193,14 @@ class resources_ui
|
||||
'caption' => 'open',
|
||||
'allowOnMultiple' => false,
|
||||
'url' => 'menuaction=resources.resources_ui.edit&res_id=$id',
|
||||
'popup' => egw_link::get_registry('resources', 'add_popup'),
|
||||
'popup' => Link::get_registry('resources', 'add_popup'),
|
||||
'group' => $group=1,
|
||||
'disableClass' => 'rowNoEdit',
|
||||
),
|
||||
'add' => array(
|
||||
'caption' => 'New resource',
|
||||
'url' => 'menuaction=resources.resources_ui.edit&accessory_of=-1',
|
||||
'popup' => egw_link::get_registry('resources', 'add_popup'),
|
||||
'popup' => Link::get_registry('resources', 'add_popup'),
|
||||
'group' => $group,
|
||||
'hideOnMobile' => true
|
||||
),
|
||||
@ -211,7 +217,7 @@ class resources_ui
|
||||
'icon' => 'new',
|
||||
'group' => $group,
|
||||
'url' => 'menuaction=resources.resources_ui.edit&res_id=0&accessory_of=$id',
|
||||
'popup' => egw_link::get_registry('resources', 'add_popup'),
|
||||
'popup' => Link::get_registry('resources', 'add_popup'),
|
||||
'disableClass' => 'no_new_accessory',
|
||||
'allowOnMultiple' => false
|
||||
),
|
||||
@ -458,16 +464,16 @@ class resources_ui
|
||||
break;
|
||||
}
|
||||
}
|
||||
egw_framework::refresh_opener($msg, 'resources',$content['res_id'],($button == 'delete'?'delete':'edit'));
|
||||
Framework::refresh_opener($msg, 'resources',$content['res_id'],($button == 'delete'?'delete':'edit'));
|
||||
|
||||
if($button != 'apply')
|
||||
{
|
||||
egw_framework::window_close();
|
||||
Framework::window_close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$nm_session_data = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
|
||||
$nm_session_data = Api\Cache::getSession('resources', 'index_nm');
|
||||
$res_id = is_numeric($content) ? (int)$content : $content['res_id'];
|
||||
if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
|
||||
if (isset($nm_session_data['filter2']) && $nm_session_data['filter2'] > 0) $accessory_of = $nm_session_data['filter2'];
|
||||
@ -520,7 +526,7 @@ class resources_ui
|
||||
$sel_options['status'] = resources_bo::$field2label;
|
||||
|
||||
//$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(Acl::ADD);
|
||||
$sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] :
|
||||
array('' => lang('select one')) + $sel_options['cat_id'];
|
||||
if($accessory_of > 0 || $content['accessory_of'] > 0)
|
||||
@ -545,12 +551,12 @@ class resources_ui
|
||||
|
||||
// Permissions
|
||||
$read_only = array();
|
||||
if($res_id && !$this->bo->acl->is_permitted($content['cat_id'],EGW_ACL_EDIT))
|
||||
if($res_id && !$this->bo->acl->is_permitted($content['cat_id'],Acl::EDIT))
|
||||
{
|
||||
$read_only['__ALL__'] = true;
|
||||
}
|
||||
$config = config::read('resources');
|
||||
if(!$this->bo->acl->is_permitted($content['cat_id'],EGW_ACL_DELETE) ||
|
||||
$config = Api\Config::read('resources');
|
||||
if(!$this->bo->acl->is_permitted($content['cat_id'],Acl::DELETE) ||
|
||||
($content['deleted'] && !$GLOBALS['egw_info']['user']['apps']['admin'] && $config['history'] == 'history'))
|
||||
{
|
||||
$read_only['delete'] = true;
|
||||
@ -564,7 +570,7 @@ class resources_ui
|
||||
}
|
||||
|
||||
// Disable custom tab if there are no custom fields defined
|
||||
$read_only['tabs']['custom'] = !(config::get_customfields('resources',true));
|
||||
$read_only['tabs']['custom'] = !(Api\Storage\Customfields::get('resources',true));
|
||||
$read_only['tabs']['history'] = ($content['history']['id'] != 0?false:true);
|
||||
|
||||
$preserv = $content;
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
class resources_wizard_export_csv extends importexport_wizard_basic_export_csv
|
||||
{
|
||||
public function __construct() {
|
||||
@ -23,7 +25,7 @@ class resources_wizard_export_csv extends importexport_wizard_basic_export_csv
|
||||
unset($this->export_fields['prize']);
|
||||
|
||||
// Custom fields
|
||||
$custom = config::get_customfields('resources', true);
|
||||
$custom = Api\Storage\Customfields::get('resources', true);
|
||||
foreach($custom as $name => $data) {
|
||||
$this->export_fields['#'.$name] = $data['label'];
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
class resources_wizard_import_csv extends importexport_wizard_basic_import_csv
|
||||
{
|
||||
|
||||
@ -44,7 +46,7 @@ class resources_wizard_import_csv extends importexport_wizard_basic_import_csv
|
||||
'accessory_of' => lang('Accessory of')
|
||||
);
|
||||
|
||||
$custom = config::get_customfields('resources', true);
|
||||
$custom = Api\Storage\Customfields::get('resources', true);
|
||||
foreach($custom as $name => $data) {
|
||||
$this->mapping_fields['#'.$name] = $data['label'];
|
||||
}
|
||||
|
@ -2,12 +2,16 @@
|
||||
/**
|
||||
* eGroupWare - resources
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
|
||||
* @license http://www.gnu.org/licenses/gpl.Api\Html GNU General Public License
|
||||
* @package resources
|
||||
* @link http://www.egroupware.org
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Egw;
|
||||
use EGroupware\Api\Acl;
|
||||
|
||||
/**
|
||||
* ACL userinterface object for resources
|
||||
*
|
||||
@ -46,10 +50,10 @@ class ui_acl
|
||||
|
||||
if ($_POST['btnDone'])
|
||||
{
|
||||
egw::redirect_link('/admin/index.php');
|
||||
Egw::redirect_link('/admin/index.php');
|
||||
}
|
||||
|
||||
common::egw_header();
|
||||
$GLOBALS['egw']->framework->header();
|
||||
echo parse_navbar();
|
||||
|
||||
if ($_POST['btnSave'])
|
||||
@ -59,7 +63,7 @@ class ui_acl
|
||||
$this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id],
|
||||
$_POST['inputcalread'][$cat_id],$_POST['inputcalbook'][$cat_id],$_POST['inputadmin'][$cat_id]);
|
||||
}
|
||||
config::save_value('location_cats', implode(',', $_POST['location_cats']), 'resources');
|
||||
Api\Config::save_value('location_cats', implode(',', $_POST['location_cats']), 'resources');
|
||||
}
|
||||
$template =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
|
||||
$template->set_file(array('acl' => 'acl.tpl'));
|
||||
@ -95,7 +99,7 @@ class ui_acl
|
||||
|
||||
if ($this->bo->cats)
|
||||
{
|
||||
$config = config::read('resources');
|
||||
$config = Api\Config::read('resources');
|
||||
$location_cats = $config['location_cats'] ? explode(',', $config['location_cats']) : array();
|
||||
foreach($this->bo->cats as $cat)
|
||||
{
|
||||
@ -106,11 +110,11 @@ class ui_acl
|
||||
'tr_color' => $tr_color,
|
||||
'catname' => $cat['name'],
|
||||
'catid' => $cat['id'],
|
||||
'read' => $this->selectlist(EGW_ACL_READ),
|
||||
'write' => $this->selectlist(EGW_ACL_ADD),
|
||||
'read' => $this->selectlist(Acl::READ),
|
||||
'write' => $this->selectlist(Acl::ADD),
|
||||
'calread' => $this->selectlist(EGW_ACL_CALREAD),
|
||||
'calbook' =>$this->selectlist(EGW_ACL_DIRECT_BOOKING),
|
||||
'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(EGW_ACL_CAT_ADMIN,true),
|
||||
'admin' => '<option value="" selected="1">'.lang('choose Api\Categories admin').'</option>'.$this->selectlist(EGW_ACL_CAT_ADMIN,true),
|
||||
'location_checked' => in_array($cat['id'], $location_cats) ? 'checked="1"' : '',
|
||||
));
|
||||
$template->parse('Cblock','cat_list',True);
|
||||
@ -167,7 +171,7 @@ class ui_acl
|
||||
{
|
||||
$selectlist .= ' selected="selected"';
|
||||
}
|
||||
$selectlist .= '>' . common::display_fullname($account['account_lid'],$account['account_firstname'],
|
||||
$selectlist .= '>' . Api\Accounts::format_username($account['account_lid'],$account['account_firstname'],
|
||||
$account['account_lastname'],$account['account_id']) . '</option>' . "\n";
|
||||
}
|
||||
return $selectlist;
|
||||
@ -200,6 +204,6 @@ class ui_acl
|
||||
function deny()
|
||||
{
|
||||
echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
|
||||
common::egw_exit(True);
|
||||
exit(True);
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,16 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
$resources_table_prefix = 'egw_resources';
|
||||
|
||||
// Add a general category for resources
|
||||
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'General resources','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__);
|
||||
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => Api\Categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'General resources','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__);
|
||||
$cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id');
|
||||
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'Locations','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__);
|
||||
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => Api\Categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'Locations','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__);
|
||||
$locations_cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id');
|
||||
config::save_value('location_cats', $locations_cat_id, 'resources');
|
||||
Api\Config::save_value('location_cats', $locations_cat_id, 'resources');
|
||||
|
||||
// Give default group all rights to this general cat
|
||||
$defaultgroup = $GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False);
|
||||
|
File diff suppressed because one or more lines are too long
@ -13,7 +13,7 @@
|
||||
|
||||
$setup_info['resources']['name'] = 'resources';
|
||||
$setup_info['resources']['title'] = 'Resources';
|
||||
$setup_info['resources']['version'] = '14.1';
|
||||
$setup_info['resources']['version'] = '16.1';
|
||||
$setup_info['resources']['app_order'] = 5;
|
||||
$setup_info['resources']['tables'] = array('egw_resources','egw_resources_extra');
|
||||
$setup_info['resources']['enable'] = 1;
|
||||
@ -37,12 +37,8 @@ $setup_info['resources']['hooks']['delete_category'] = 'resources.resources_hook
|
||||
$setup_info['resources']['hooks']['settings'] = 'resources_hooks::settings';
|
||||
|
||||
$setup_info['resources']['depends'][] = array(
|
||||
'appname' => 'phpgwapi',
|
||||
'versions' => Array('14.1')
|
||||
);
|
||||
$setup_info['resources']['depends'][] = array( // cause eTemplates is not in the api yet
|
||||
'appname' => 'etemplate',
|
||||
'versions' => Array('14.1')
|
||||
'appname' => 'api',
|
||||
'versions' => Array('16.1')
|
||||
);
|
||||
|
||||
|
||||
|
@ -11,6 +11,9 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Vfs;
|
||||
|
||||
function resources_upgrade0_0_1_008()
|
||||
{
|
||||
$GLOBALS['phpgw_setup']->oProc->AddColumn('egw_resources','picture_src',array(
|
||||
@ -291,24 +294,24 @@ function resources_upgrade1_2()
|
||||
*/
|
||||
function resources_upgrade1_4()
|
||||
{
|
||||
egw_vfs::$is_root = true;
|
||||
egw_vfs::load_wrapper('sqlfs');
|
||||
if (egw_vfs::is_dir('/resources/pictures'))
|
||||
Vfs::$is_root = true;
|
||||
Vfs::load_wrapper('sqlfs');
|
||||
if (Vfs::is_dir('/resources/pictures'))
|
||||
{
|
||||
egw_vfs::remove('/resources/pictures/thumbs'); // remove thumb dir incl. thumbnails
|
||||
foreach(egw_vfs::find('sqlfs://default/resources/pictures',array('url' => true)) as $url)
|
||||
Vfs::remove('/resources/pictures/thumbs'); // remove thumb dir incl. thumbnails
|
||||
foreach(Vfs::find('sqlfs://default/resources/pictures',array('url' => true)) as $url)
|
||||
{
|
||||
if (is_numeric($id = basename($url,'.jpg')))
|
||||
{
|
||||
if (!egw_vfs::is_dir($dir = "/apps/resources/$id"))
|
||||
if (!Vfs::is_dir($dir = "/apps/resources/$id"))
|
||||
{
|
||||
egw_vfs::mkdir($dir,0777,STREAM_MKDIR_RECURSIVE);
|
||||
Vfs::mkdir($dir,0777,STREAM_MKDIR_RECURSIVE);
|
||||
}
|
||||
rename($url,'sqlfs://default'.$dir.'/.picture.jpg'); // we need to rename on the same wrapper!
|
||||
}
|
||||
}
|
||||
egw_vfs::rmdir('/resources/pictures',0);
|
||||
egw_vfs::rmdir('/resources',0);
|
||||
Vfs::rmdir('/resources/pictures',0);
|
||||
Vfs::rmdir('/resources',0);
|
||||
}
|
||||
return $GLOBALS['setup_info']['resources']['currentver'] = '1.6';
|
||||
}
|
||||
@ -323,9 +326,9 @@ function resources_upgrade1_6()
|
||||
function resources_upgrade1_8()
|
||||
{
|
||||
// add location category required for CalDAV to distinguish between locations and resources
|
||||
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'Locations','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__);
|
||||
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => Api\Categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'Locations','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__);
|
||||
$locations_cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id');
|
||||
config::save_value('location_cats', $locations_cat_id, 'resources');
|
||||
Api\Config::save_value('location_cats', $locations_cat_id, 'resources');
|
||||
|
||||
// Give default group all rights to this general cat
|
||||
$defaultgroup = $GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False);
|
||||
@ -384,3 +387,7 @@ function resources_upgrade1_9_004()
|
||||
{
|
||||
return $GLOBALS['setup_info']['resources']['currentver'] = '14.1';
|
||||
}
|
||||
function resources_upgrade14_1()
|
||||
{
|
||||
return $GLOBALS['setup_info']['resources']['currentver'] = '16.1';
|
||||
}
|
@ -9,6 +9,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
/**
|
||||
* Needs permission to resources to read the resource, calendar app to properly push everything through
|
||||
*/
|
||||
@ -21,7 +23,7 @@ class module_resources_reservation extends sitemgr_module
|
||||
$this->description = lang('Simple reservation of a single item');
|
||||
$this->etemplate_method = 'resources.resources_reserve.book';
|
||||
|
||||
$categories = new categories('', 'resources');
|
||||
$categories = new Api\Categories('', 'resources');
|
||||
$cat_list = $categories->return_sorted_array();
|
||||
$cat_options = array();
|
||||
foreach($cat_list as $category)
|
||||
@ -101,12 +103,12 @@ class module_resources_reservation extends sitemgr_module
|
||||
*
|
||||
* @param array &$arguments $arguments['arg1']-$arguments['arg3'] will be passed for non-submitted forms (first call)
|
||||
* @param array $properties
|
||||
* @return string the html content
|
||||
* @return string the Api\Html content
|
||||
*/
|
||||
function get_content(&$arguments,$properties)
|
||||
{
|
||||
list($app) = explode('.',$this->etemplate_method);
|
||||
$GLOBALS['egw']->translation->add_app($app);
|
||||
Api\Translation::add_app($app);
|
||||
|
||||
$extra = "<style type=\"text/css\">\n<!--\n@import url(".$GLOBALS['egw_info']['server']['webserver_url'].
|
||||
"/etemplate/templates/default/app.css);\n";
|
||||
|
Loading…
Reference in New Issue
Block a user