make links working

This commit is contained in:
Cornelius Weiß 2005-02-24 18:24:26 +00:00
parent 15c225d84b
commit 088b6827a7
3 changed files with 61 additions and 52 deletions

View File

@ -26,6 +26,7 @@ class bo_resources
$this->acl = CreateObject('resources.bo_acl');
$this->cats = $this->acl->egw_cats;
$this->vfs = CreateObject('phpgwapi.vfs');
$this->link = CreateObject('infolog.bolink');
}
/*!
@ -112,7 +113,7 @@ class bo_resources
return lang('You are not permitted to edit this reource!');
}
// we need an id to save pictures
// we need an id to save pictures and make links...
if(!$resource['id'])
{
$resource['id'] = $this->so->save($resource);
@ -159,6 +160,12 @@ class bo_resources
{
$this->remove_picture($resource['id']);
}
// save links
if(is_array($resource['link_to']['to_id']))
{
$this->link->link('resources',$resource['id'],$resource['link_to']['to_id']);
}
return $this->so->save($resource) ? false : lang('Something went wrong by saving resource');
}

View File

@ -89,62 +89,64 @@ class ui_resources
/*!
@function edit
@syntax edit($content=0)
@author Cornelius Weiß <egw@von-und-zu-weiss.de>
@abstract invokes add or edit dialog for resources
@autor Cornelius Weiß <egw@von-und-zu-weiss.de>
@param mixed $content int for resource_id to edit ( 0 for new ). array if callback from dialog.
@param string $msg message to display on top of dialog
@param $content Content from the eTemplate Exec call or id on inital call
*/
function edit($content='',$msg='')
function edit($content=0)
{
if (is_array($content))
{
if(isset($content['save']) || isset($content['delete']))
{
if(isset($content['save']))
{
unset($content['save']);
if($content['id'] != 0)
{
// links are already saved by eTemplate
unset($resource['link_to']['to_id']);
}
$content['msg'] = $this->bo->save($content);
}
if(isset($content['delete']))
{
unset($content['delete']);
$content['msg'] = $this->delete($content['id']);
}
return $content['msg'] ? $this->edit($content) : $this->index();
}
elseif($content['cancel'])
{
return $this->index();
}
}
else
{
$resource_id = $content;
$content = array('resource_id' => $resource_id);
if ($resource_id > 0)
{
$content = $this->bo->read($resource_id);
$content['gen_src_list'] = strstr($content['picture_src'],'.') ? $content['picture_src'] : false;
$content['picture_src'] = strstr($content['picture_src'],'.') ? 'gen_src' : $content['picture_src'];
$content['link_to'] = array(
'to_id' => $resource_id,
'to_app' => 'resources'
);
// $sel_options += array('acc_list' => $this->bo->get_acc_list($resource_id));
}
$content['resource_picture'] = $this->bo->get_picture($resource_id,$content['picture_src'],$size=true);
}
$sel_options = array(
'cat_id' => $this->bo->acl->get_cats(PHPGW_ACL_ADD),
'gen_src_list' => $this->bo->get_genpicturelist()
);
$no_button = array();
if (is_array($content))
{
if(isset($content['delete']))
{
return $this->delete($content['id']);
}
if(isset($content['save']))
{
if(!$content['cat_id'] || !$content['name'])
{
$content['msg'] = lang('You need to choose at least a name and a category!');
$this->tmpl->read('resources.edit');
$this->tmpl->exec('resources.ui_resources.edit',$content,$sel_options,$no_button);
return;
}
$content['msg'] = $this->bo->save($content);
if($content['msg'])
{
$this->tmpl->read('resources.edit');
$this->tmpl->exec('resources.ui_resources.edit',$content,$sel_options,$no_button);
}
}
return $this->index();
}
if ($content > 0)
{
$preserv = array('id' => $content);
$content = $this->bo->read($content);
$content['gen_src_list'] = strstr($content['picture_src'],'.') ? $content['picture_src'] : false;
$content['picture_src'] = strstr($content['picture_src'],'.') ? 'gen_src' : $content['picture_src'];
$content['link_id'] = $content;
$sel_options += array('acc_list' => $this->bo->get_acc_list($content['id']));
}
else
{
$content = array();
}
$content['resource_picture'] = $this->bo->get_picture($content['id'],$content['picture_src'],$size=true);
$content['msg'] = $msg;
$preserv = (array)$preserv + $content; // debug for eTemplate tabs don't know if really needed atm.
$no_button = array(); // TODO: show delete button only if allowed to delete resource
$preserv = $content;
$this->tmpl->read('resources.edit');
$this->tmpl->exec('resources.ui_resources.edit',$content,$sel_options,$no_button,$preserv);

View File

@ -1,5 +1,5 @@
<?php
// eTemplates for Application 'resources', generated by soetemplate::dump4setup() 2005-02-24 14:08
// eTemplates for Application 'resources', generated by soetemplate::dump4setup() 2005-02-24 19:23
/* $Id$ */
@ -11,7 +11,7 @@ $templ_data[] = array('name' => 'resources.edit_buttons','template' => '','lang'
$templ_data[] = array('name' => 'resources.edit_pictures','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:3:{s:2:"c1";s:3:"nmr";s:2:"c2";s:3:"nmr";s:2:"c3";s:3:"nmr";}i:1;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:26:"Use general resources icon";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"gen_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:3:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"gen_src_list";}}i:2;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:23:"Use the category\'s icon";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"cat_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:3;a:3:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:15:"Use own picture";s:5:"align";s:5:"right";}s:1:"B";a:3:{s:4:"type";s:5:"radio";s:4:"size";s:7:"own_src";s:4:"name";s:11:"picture_src";}s:1:"C";a:2:{s:4:"type";s:4:"file";s:4:"name";s:8:"own_file";}}}s:4:"rows";i:3;s:4:"cols";i:3;}}','size' => '','style' => '','modified' => '1108638846',);
$templ_data[] = array('name' => 'resources.edit_tabs','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:3:{s:1:"A";s:3:"250";s:2:"c1";s:6:"row_on";s:2:"c2";s:7:"row_off";}i:1;a:2:{s:1:"A";a:4:{s:4:"type";s:4:"text";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";s:4:"help";s:16:"Name of resource";}s:1:"B";a:7:{s:4:"type";s:6:"select";s:4:"size";s:10:"select one";s:5:"label";s:8:"Category";s:7:"no_lang";s:1:"1";s:4:"name";s:6:"cat_id";s:6:"needed";s:1:"1";s:4:"help";s:44:"Which category does this resource belong to?";}}i:2;a:2:{s:1:"A";a:5:{s:4:"type";s:3:"tab";s:4:"span";s:3:"all";s:5:"label";s:54:"General|Description|Picture|Accessories|Links|Calendar";s:4:"name";s:48:"general|page|pictures|accessories|links|calendar";s:4:"help";s:194:"General informations about resource|Informations about the location of resource|Prizeing information for booking or buying|Web-Page of resource|Pictures or resource|The Calendar of this resource";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:3;s:4:"cols";i:2;}}','size' => '','style' => '','modified' => '1109155739',);
$templ_data[] = array('name' => 'resources.edit_tabs','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:3:{s:1:"A";s:3:"250";s:2:"c1";s:6:"row_on";s:2:"c2";s:7:"row_off";}i:1;a:2:{s:1:"A";a:5:{s:4:"type";s:4:"text";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";s:4:"help";s:16:"Name of resource";s:6:"needed";s:1:"1";}s:1:"B";a:7:{s:4:"type";s:6:"select";s:4:"size";s:10:"select one";s:5:"label";s:8:"Category";s:7:"no_lang";s:1:"1";s:4:"name";s:6:"cat_id";s:6:"needed";s:1:"1";s:4:"help";s:44:"Which category does this resource belong to?";}}i:2;a:2:{s:1:"A";a:5:{s:4:"type";s:3:"tab";s:4:"span";s:3:"all";s:5:"label";s:54:"General|Description|Picture|Accessories|Links|Calendar";s:4:"name";s:48:"general|page|pictures|accessories|links|calendar";s:4:"help";s:194:"General informations about resource|Informations about the location of resource|Prizeing information for booking or buying|Web-Page of resource|Pictures or resource|The Calendar of this resource";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:3;s:4:"cols";i:2;}}','size' => '','style' => '','modified' => '1109155739',);
$templ_data[] = array('name' => 'resources.edit_tabs.accessories','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:2:{i:0;a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:42:"Accessory only! Don\'t show in master list.";s:4:"name";s:14:"accessory_only";}i:1;a:3:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"1";i:1;a:4:{s:4:"type";s:8:"groupbox";s:5:"label";s:12:"Accessories:";s:4:"size";s:1:"1";i:1;a:4:{s:4:"type";s:6:"select";s:4:"size";s:2:"10";s:4:"name";s:8:"acc_list";s:7:"no_lang";s:1:"1";}}}}','size' => '','style' => '','modified' => '1109151621',);